fractal effect is cooking
[dosdemo] / src / demo.c
index 32f764c..98f8001 100644 (file)
@@ -4,22 +4,40 @@
 #include <math.h>
 #include <errno.h>
 #include "demo.h"
+#include "screen.h"
 
-int fbwidth = 320;
-int fbheight = 240;
-int fbbpp = 8;
-unsigned char *fbpixels;
+int fb_width = 320;
+int fb_height = 240;
+int fb_bpp = 16;
+void *fb_pixels;
 unsigned long time_msec;
+int mouse_x, mouse_y;
+unsigned int mouse_bmask;
 
 static unsigned long nframes;
+static const char *start_scr_name = "tunnel";
 
 int demo_init(int argc, char **argv)
 {
+       if(argv[1]) {
+               start_scr_name = argv[1];
+       }
+
+       if(scr_init() == -1) {
+               return -1;
+       }
+       if(scr_change(scr_lookup(start_scr_name), 4000) == -1) {
+               fprintf(stderr, "screen %s not found\n", start_scr_name);
+               return -1;
+       }
+
        return 0;
 }
 
 void demo_cleanup(void)
 {
+       scr_shutdown();
+
        if(time_msec) {
                float fps = (float)nframes / ((float)time_msec / 1000.0f);
                printf("average framerate: %.1f\n", fps);
@@ -28,16 +46,8 @@ void demo_cleanup(void)
 
 void demo_draw(void)
 {
-       int i, j;
-       unsigned char *fbptr = fbpixels;
-
-       for(i=0; i<fbheight; i++) {
-               for(j=0; j<fbwidth; j++) {
-                       int val = i^j;
-
-                       *fbptr++ = val;
-               }
-       }
+       scr_update();
+       scr_draw();
 
        ++nframes;
 }