fractal effect is cooking
[dosdemo] / src / demo.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <math.h>
5 #include <errno.h>
6 #include "demo.h"
7 #include "screen.h"
8
9 int fb_width = 320;
10 int fb_height = 240;
11 int fb_bpp = 16;
12 void *fb_pixels;
13 unsigned long time_msec;
14 int mouse_x, mouse_y;
15 unsigned int mouse_bmask;
16
17 static unsigned long nframes;
18 static const char *start_scr_name = "tunnel";
19
20 int demo_init(int argc, char **argv)
21 {
22         if(argv[1]) {
23                 start_scr_name = argv[1];
24         }
25
26         if(scr_init() == -1) {
27                 return -1;
28         }
29         if(scr_change(scr_lookup(start_scr_name), 4000) == -1) {
30                 fprintf(stderr, "screen %s not found\n", start_scr_name);
31                 return -1;
32         }
33
34         return 0;
35 }
36
37 void demo_cleanup(void)
38 {
39         scr_shutdown();
40
41         if(time_msec) {
42                 float fps = (float)nframes / ((float)time_msec / 1000.0f);
43                 printf("average framerate: %.1f\n", fps);
44         }
45 }
46
47 void demo_draw(void)
48 {
49         scr_update();
50         scr_draw();
51
52         ++nframes;
53 }
54
55 void demo_keyboard(int key, int state)
56 {
57         if(state) {
58                 switch(key) {
59                 case 27:
60                         demo_quit();
61                         break;
62
63                 default:
64                         break;
65                 }
66         }
67 }