16 static void update(void);
17 static void draw(void);
18 static void vblank(void);
20 static int nframes, num_vbl, backbuf;
21 static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR };
23 static const char *testlvl =
45 static struct xvertex tm_floor[] __attribute__((section(".rodata"))) = {
46 {0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
47 {-0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
48 {-0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210},
49 {0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210}
53 static struct level *lvl;
55 static struct player player;
64 REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1;
68 lvl = init_level(testlvl);
72 memset(&player, 0, sizeof player);
75 cmap = (uint16_t*)CRAM_BG_ADDR;
77 for(i=1; i<255; i++) {
83 select_input(BN_DPAD | BN_A | BN_B);
86 screen_vblank = vblank;
91 backbuf = ++nframes & 1;
92 fb = (unsigned char*)vram[backbuf];
94 polyfill_framebuffer(fb, 240, 160);
95 fillblock_16byte(fb, 0, 240 * 160 / 16);
107 static void update(void)
111 bnstate = get_input();
113 player_input(&player, bnstate);
115 upd_vis(lvl, &player);
118 static void draw(void)
124 /*xgl_translate(0, 0, 0x100000);*/
125 xgl_rotate_x(player.phi);
126 xgl_rotate_y(player.theta);
127 xgl_translate(player.x, 0, player.y);
129 for(i=0; i<lvl->numvis; i++) {
132 x = (int32_t)(cell->x - player.cx) << 17;
133 y = -(int32_t)(cell->y - player.cy) << 17;
136 xgl_translate(x, 0, y);
138 xgl_draw(XGL_QUADS, tm_floor, sizeof tm_floor / sizeof *tm_floor);
143 __attribute__((noinline, target("arm"), section(".iwram")))
144 static void vblank(void)