visual studio project for the SDL backend
[dosdemo] / src / demo.c
index 32f764c..a9611f6 100644 (file)
@@ -3,23 +3,34 @@
 #include <string.h>
 #include <math.h>
 #include <errno.h>
+#include <limits.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;
 
 static unsigned long nframes;
 
 int demo_init(int argc, char **argv)
 {
+       if(scr_init() == -1) {
+               return -1;
+       }
+       scr_change(scr_lookup("tunnel"), 4000);
+
+       /* clear the framebuffer at least once */
+       memset(fb_pixels, 0, fb_width * fb_height * fb_bpp / CHAR_BIT);
        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 +39,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;
 }