| ssjx.co.uk
Home of StormPlayer for Cybiko and other great programs |
| Home | Cybiko : Cybiko Guides : Cvc Videos | CyBorn | Amiga | Windows Games| Games| Links |
Simple image transition programThis program displays an image which is then slowly replaced using a cool transition effect. We do this by creating an array of 0-3999, randomising it and then use this random order to replace the screen bytes with the bytes from another image. You can download the source using the link below, the actual .app is not included as you will need to specify two image files for the program to use (lines 64 and 67). Once this is done, just run or double click on make.bat to create the pictran.app file. If you have any comments about this tutorial, please use the DevCybiko / PlanetCybiko forums or personal messaging and let me know! What you will need
The Cybiko SDK The programNote: Don't type in the line numbers!
1 //
2 // Simple picture transition by ssjx (4/8/6)
3 //
4
5 #include <cybiko.h>
6 struct module_t main_module;
7
8 struct FileInput file_input;
9
10 void loadpic(char *filename,char *dest)
11 {
12 FileInput_ctor(&file_input);
13
14 if(FileInput_open( &file_input,filename))
15 {
16 TRACE("Loading picture: %s",filename);
17 FileInput_seek( &file_input, 8, SEEK_SET );
18 Input_read( &file_input,dest,4000);
19 }
20 else
21 {
22 TRACE("Could not open file: %s.",filename);
23 }
24
25 FileInput_dtor( &file_input, LEAVE_MEMORY);
26 }
27
28 long main(int argc, char *argv[],bool start)
29 {
30 char *dis;
31 char *pic;
32 int *order;
33 int i;
34 int a,b,c;
35
36 init_module( &main_module );
37
38 dis=DisplayGraphics_get_page_ptr(main_module.m_gfx, 0);
39
40 pic=(char *)malloc(4000);
41 order=(int *)calloc(4000,sizeof(int));
42
43 if (pic!=0 && order!=0)
44 {
45 TRACE("Allocated required memory!");
46
47 for(i=0;i<4000;i++)
48 {
49 order[i]=i;
50 }
51
52 for(i=0;i<4000;i++)
53 {
54 a=random(4000);
55 b=random(4000);
56
57 c=order[a];
58 order[a]=order[b];
59 order[b]=c;
60 }
61
62 TRACE("Loading images!");
63
64 loadpic("pic1.pic",dis);
65 DisplayGraphics_show(main_module.m_gfx);
66
67 loadpic("pic2.pic",pic);
68
69 TRACE("Displaying!");
70 for(i=0;i<4000;i++)
71 {
72 dis[order[i]]=pic[order[i]];
73 DisplayGraphics_show(main_module.m_gfx);
74 }
75
76
77 }
78 else
79 {
80 TRACE("Could not allocate memory");
81 }
82
83 free(pic);
84 free(order);
85
86 return 0l;
87 }
How it works
|
| Links that help support site | |||
| RPoints | Buy from shops through RPoints and you can get money back. Includes Cdwow, Play.com, Dell and many other useful shops. | ||
| Top Cashback | Just like RPoints except they pay higher amounts on some shops. | ||
| Play-Asia | Very good online seller of games. They also stock a lot of retro games and consoles e.g. Saturn and Jaguar! | ||
| ©2008 ssjx |