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(4, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1);
57 pos[0] = pos[1] = 256 << 16;
59 if(!(vox = vox_create(512, 512, height_pixels, color_pixels))) {
60 panic(get_pc(), "vox_create");
62 vox_proj(vox, 45, 1, 250);
64 /* setup color image palette */
65 for(i=0; i<192; i++) {
66 int r = color_cmap[i * 3];
67 int g = color_cmap[i * 3 + 1];
68 int b = color_cmap[i * 3 + 2];
69 gba_bgpal[i] = ((r << 8) & 0x7c00) | ((g << 2) & 0x3e0) | (b >> 3);
72 /* setup sky gradient palette */
75 int r = (0xcc00 + (0x55 - 0xcc) * t) >> 8;
76 int g = (0x7700 + (0x88 - 0x77) * t) >> 8;
77 int b = (0xff00 + (0xcc - 0xff) * t) >> 8;
78 int cidx = COLOR_HORIZON + i;
79 gba_bgpal[cidx] = ((r << 8) & 0x7c00) | ((g << 2) & 0x3e0) | (b >> 3);
82 /*select_input(BN_DPAD | BN_LT | BN_RT);*/
88 static void gamescr_stop(void)
92 static void gamescr_frame(void)
96 backbuf = ++nframes & 1;
97 fb = (unsigned char*)vram[backbuf];
99 vox_framebuf(vox, 240, 160, fb, -1);
110 #define WALK_SPEED 0x40000
111 #define TURN_SPEED 0x100
113 static void update(void)
115 int32_t fwd[2], right[2];
118 input = read_input();
120 if(input & BN_LT) angle += TURN_SPEED;
121 if(input & BN_RT) angle -= TURN_SPEED;
123 fwd[0] = -SIN(angle);
132 if(input & BN_DOWN) {
136 if(input & BN_RIGHT) {
140 if(input & BN_LEFT) {
145 vox_view(vox, pos[0], pos[1], -30, angle);
148 static void draw(void)
152 vox_sky_grad(vox, COLOR_HORIZON, COLOR_ZENITH);
153 //vox_sky_solid(vox, COLOR_ZENITH);
157 __attribute__((noinline, target("arm"), section(".iwram")))
159 static void gamescr_vblank(void)