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 const char *testlvl =
58 static struct xvertex tm_floor[] __attribute__((section(".rodata"))) = {
59 {0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
60 {-0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
61 {-0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210},
62 {0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210}
66 static struct level *lvl;
68 static struct player player;
71 struct screen *init_game_screen(void)
76 static int gamescr_start(void)
81 gba_setmode(4, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1);
85 lvl = init_level(testlvl);
89 init_player(&player, lvl);
94 for(i=1; i<255; i++) {
100 select_input(BN_DPAD | BN_A | BN_B);
106 static void gamescr_stop(void)
110 static void gamescr_frame(void)
114 backbuf = ++nframes & 1;
115 fb = (unsigned char*)vram[backbuf];
117 polyfill_framebuffer(fb, 240, 160);
118 fillblock_16byte(fb, 0, 240 * 160 / 16);
129 static void update(void)
133 bnstate = get_input();
135 player_input(&player, bnstate);
137 upd_vis(lvl, &player);
140 static void draw(void)
147 xgl_translate(0, 0, view_zoom);
149 xgl_rotate_x(player.phi);
150 xgl_rotate_y(player.theta);
151 xgl_translate(player.x, 0, player.y);
153 for(i=0; i<lvl->numvis; i++) {
156 x = (int32_t)(cell->x - player.cx) << 17;
157 y = -(int32_t)(cell->y - player.cy) << 17;
160 xgl_translate(x, 0, y);
162 xgl_draw(XGL_QUADS, tm_floor, sizeof tm_floor / sizeof *tm_floor);
168 __attribute__((noinline, target("arm"), section(".iwram")))
170 static void gamescr_vblank(void)