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 =
37 static struct xvertex tm_floor[] __attribute__((section(".rodata"))) = {
38 {0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
39 {-0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210},
40 {-0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210},
41 {0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210}
45 static struct level *lvl;
47 static struct player player;
56 REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1;
60 lvl = init_level(testlvl);
64 memset(&player, 0, sizeof player);
67 cmap = (uint16_t*)CRAM_BG_ADDR;
69 for(i=1; i<255; i++) {
75 select_input(BN_DPAD | BN_A | BN_B);
78 screen_vblank = vblank;
83 backbuf = ++nframes & 1;
84 fb = (unsigned char*)vram[backbuf];
86 polyfill_framebuffer(fb, 240, 160);
87 fillblock_16byte(fb, 0, 240 * 160 / 16);
99 static void update(void)
103 bnstate = get_input();
105 player_input(&player, bnstate);
107 upd_vis(lvl, &player);
110 static void draw(void)
116 xgl_translate(0, 0, 0x100000);
117 xgl_rotate_x(player.phi);
118 xgl_rotate_y(player.theta);
119 xgl_translate(player.x, 0, player.y);
121 for(i=0; i<lvl->numvis; i++) {
124 x = (int32_t)(cell->x - player.cx) << 17;
125 y = -(int32_t)(cell->y - player.cy) << 17;
128 xgl_translate(x, 0, y);
130 xgl_draw(XGL_QUADS, tm_floor, sizeof tm_floor / sizeof *tm_floor);
135 __attribute__((noinline, target("arm"), section(".iwram")))
136 static void vblank(void)