screen system
[fbgfx] / src / tunnel.c
index c6504ce..4707d81 100644 (file)
@@ -4,7 +4,8 @@
 #include <assert.h>
 #include <imago2.h>
 #include "tpool.h"
-#include "tunnel.h"
+#include "demo.h"
+#include "screen.h"
 
 #define TEX_FNAME      "data/grid.png"
 #define TEX_USCALE     4
 #define USCALE 2
 #define VSCALE 1
 
-extern unsigned long time_msec;
+static int init(void);
+static void destroy(void);
+static void start(long trans_time);
+static void stop(long trans_time);
+static void draw(void);
 
 static void (*draw_tunnel_range)(void*, int, int);
 
@@ -22,6 +27,15 @@ static void draw_tunnel_range32(void *pixels, int starty, int num_lines);
 static int count_bits(unsigned int x);
 static int count_zeros(unsigned int x);
 
+static struct screen scr = {
+       "tunnel",
+       init,
+       destroy,
+       start,
+       stop,
+       draw
+};
+
 static int xsz, ysz, vxsz, vysz;
 static unsigned int *tunnel_map;
 static unsigned char *tunnel_fog;
@@ -34,14 +48,20 @@ static unsigned int tex_xmask, tex_ymask;
 static struct thread_pool *tpool;
 
 
-int init_tunnel(int x, int y, int bpp)
+struct screen *tunnel_screen(void)
+{
+       return &scr;
+}
+
+
+static int init(void)
 {
        int i, j, n;
        unsigned int *tmap;
        unsigned char *fog;
-       float aspect = (float)x / (float)y;
+       float aspect = (float)fb_width / (float)fb_height;
 
-       switch(bpp) {
+       switch(fb_depth) {
        case 16:
                draw_tunnel_range = draw_tunnel_range16;
                break;
@@ -49,12 +69,12 @@ int init_tunnel(int x, int y, int bpp)
                draw_tunnel_range = draw_tunnel_range32;
                break;
        default:
-               fprintf(stderr, "unsupported color depth: %d\n", bpp);
+               fprintf(stderr, "unsupported color depth: %d\n", fb_depth);
                return -1;
        }
 
-       xsz = x;
-       ysz = y;
+       xsz = fb_width;
+       ysz = fb_height;
        vxsz = xsz / USCALE;
        vysz = ysz / VSCALE;
 
@@ -117,13 +137,21 @@ int init_tunnel(int x, int y, int bpp)
        return 0;
 }
 
-void destroy_tunnel(void)
+static void destroy(void)
 {
        tpool_destroy(tpool);
        free(tunnel_map);
        free(tunnel_fog);
 }
 
+static void start(long trans_time)
+{
+}
+
+static void stop(long trans_time)
+{
+}
+
 #define NUM_WORK_ITEMS 32
 
 static struct work {
@@ -137,11 +165,11 @@ static void work_func(void *cls)
        draw_tunnel_range(w->pixels, w->starty, w->num_lines);
 }
 
-void draw_tunnel(void *pixels)
+static void draw(void)
 {
        int i, num_lines = vysz / NUM_WORK_ITEMS;
        for(i=0; i<NUM_WORK_ITEMS; i++) {
-               work[i].pixels = pixels;
+               work[i].pixels = fb_pixels;
                work[i].starty = i * num_lines;
                work[i].num_lines = num_lines;