15 static void update(void);
16 static void draw(void);
17 static void vblank(void);
19 static int nframes, num_vbl, backbuf;
20 static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR };
22 static const char *testlvl =
36 static struct xvertex cube[] __attribute__((section(".rodata"))) = {
38 {-0x10000, -0x10000, -0x10000, 0, 0, -0x10000, 255},
39 {0x10000, -0x10000, -0x10000, 0, 0, -0x10000, 255},
40 {0x10000, 0x10000, -0x10000, 0, 0, -0x10000, 255},
41 {-0x10000, 0x10000, -0x10000, 0, 0, -0x10000, 255},
43 {0x10000, -0x10000, -0x10000, 0x10000, 0, 0, 128},
44 {0x10000, -0x10000, 0x10000, 0x10000, 0, 0, 128},
45 {0x10000, 0x10000, 0x10000, 0x10000, 0, 0, 128},
46 {0x10000, 0x10000, -0x10000, 0x10000, 0, 0, 128},
48 {0x10000, -0x10000, 0x10000, 0, 0, 0x10000, 200},
49 {-0x10000, -0x10000, 0x10000, 0, 0, 0x10000, 200},
50 {-0x10000, 0x10000, 0x10000, 0, 0, 0x10000, 200},
51 {0x10000, 0x10000, 0x10000, 0, 0, 0x10000, 200},
53 {-0x10000, -0x10000, 0x10000, -0x10000, 0, 0, 192},
54 {-0x10000, -0x10000, -0x10000, -0x10000, 0, 0, 192},
55 {-0x10000, 0x10000, -0x10000, -0x10000, 0, 0, 192},
56 {-0x10000, 0x10000, 0x10000, -0x10000, 0, 0, 192},
58 {-0x10000, 0x10000, -0x10000, 0, 0x10000, 0, 150},
59 {0x10000, 0x10000, -0x10000, 0, 0x10000, 0, 150},
60 {0x10000, 0x10000, 0x10000, 0, 0x10000, 0, 150},
61 {-0x10000, 0x10000, 0x10000, 0, 0x10000, 0, 150},
63 {0x10000, -0x10000, -0x10000, 0, -0x10000, 0, 210},
64 {-0x10000, -0x10000, -0x10000, 0, -0x10000, 0, 210},
65 {-0x10000, -0x10000, 0x10000, 0, -0x10000, 0, 210},
66 {0x10000, -0x10000, 0x10000, 0, -0x10000, 0, 210}
70 static struct level *lvl;
72 static int32_t cam_theta, cam_phi;
78 REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1;
80 vblperf_setcolor(0xff);
82 lvl = init_level(testlvl);
86 select_input(BN_DPAD);
89 screen_vblank = vblank;
94 backbuf = ++nframes & 1;
95 fb = (unsigned char*)vram[backbuf];
97 polyfill_framebuffer(fb, 240, 160);
98 fillblock_16byte(fb, 0, 240 * 160 / 16);
110 static void update(void)
114 bnstate = get_input();
116 if(bnstate & KEY_UP) {
118 if(cam_phi > X_HPI) cam_phi = X_HPI;
120 if(bnstate & KEY_DOWN) {
122 if(cam_phi < -X_HPI) cam_phi = -X_HPI;
124 if(bnstate & KEY_LEFT) {
126 if(cam_theta > X_2PI) cam_theta -= X_2PI;
128 if(bnstate & KEY_RIGHT) {
130 if(cam_theta < X_2PI) cam_theta += X_2PI;
134 static void draw(void)
137 //xgl_translate(0, -0x50000, 0);
138 xgl_translate(0, 0, 0x80000);
139 xgl_rotate_x(cam_phi);
140 xgl_rotate_y(cam_theta);
142 xgl_draw(XGL_QUADS, cube, sizeof cube / sizeof *cube);
145 __attribute__((noinline, target("arm"), section(".iwram")))
146 static void vblank(void)