#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);
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;
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;
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;
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 {
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;