17 static int gamescr_start(void);
18 static void gamescr_stop(void);
19 static void gamescr_frame(void);
20 static void gamescr_vblank(void);
22 static void update(void);
23 static void draw(void);
25 static struct screen gamescr = {
33 static int nframes, num_vbl, backbuf;
34 static uint16_t *vram[] = { gba_vram_lfb0, gba_vram_lfb1 };
36 static int32_t pos[2], angle;
37 static struct voxscape *vox;
39 #define COLOR_HORIZON 192
40 #define COLOR_ZENITH 255
44 struct screen *init_game_screen(void)
49 static int gamescr_start(void)
53 gba_setmode(5, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1);
57 pos[0] = pos[1] = VOX_SZ << 15;
59 if(!(vox = vox_create(VOX_SZ, VOX_SZ, height_pixels, color_pixels))) {
60 panic(get_pc(), "vox_create");
62 vox_proj(vox, 45, 2, VOX_SZ / 5);
68 static void gamescr_stop(void)
72 static void gamescr_frame(void)
76 backbuf = ++nframes & 1;
77 fb = (unsigned char*)vram[backbuf];
79 vox_framebuf(vox, 160, 128, fb, -1);
89 emuprint("vbl: %d", vblperf_count);
94 #define WALK_SPEED 0x40000
95 #define TURN_SPEED 0x100
97 static void update(void)
99 int32_t fwd[2], right[2];
102 if((input = read_input())) {
104 if(input & BN_LT) angle += TURN_SPEED;
105 if(input & BN_RT) angle -= TURN_SPEED;
107 fwd[0] = -SIN(angle);
116 if(input & BN_DOWN) {
120 if(input & BN_RIGHT) {
124 if(input & BN_LEFT) {
129 vox_view(vox, pos[0], pos[1], -30, angle);
133 static void draw(void)
136 //vox_sky_grad(vox, COLOR_HORIZON, COLOR_ZENITH);
137 vox_sky_solid(vox, COLOR_ZENITH);
141 static void gamescr_vblank(void)