11 static void draw_tunnel(void);
13 static int nframes, backbuf;
14 static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR };
15 static unsigned char *tex;
16 static uint16_t bnstate;
24 REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_FB1;
26 vblperf_setcolor(0xff);
28 cdst = (uint16_t*)CRAM_BG_ADDR;
30 for(i=0; i<256; i++) {
31 *cdst++ = CONV_RGB24_RGB15(csrc[0], csrc[1], csrc[2]);
35 fillblock_16byte(vram[0], 0xffffffff, 240 * 160 / 16);
36 fillblock_16byte(vram[1], 0xffffffff, 240 * 160 / 16);
38 tex = iwram_sbrk(32 * 32);
39 memcpy(tex, tuncross_pixels, 32 * 32);
41 select_input(BN_DPAD);
45 backbuf = ++nframes & 1;
47 bnstate = get_input();
58 __attribute__((noinline, target("arm"), section(".iwram")))
59 static void draw_tunnel(void)
62 int i, j, tx, ty, angle, depth, zoffs;
63 uint16_t pptop, ppbot;
65 uint32_t tun, *tunptr;
69 if(bnstate & BN_LEFT) uoffs++;
70 if(bnstate & BN_RIGHT) uoffs--;
73 bot = vram[backbuf] + 159 * 240 / 2;
81 for(j=1; j<240/2; j++) {
83 for(j=0; j<240/2; j++) {
88 depth = (tun >> 8) & 0xff;
89 tx = ((angle >> 1) + uoffs) & 0x1f;
90 ty = ((depth >> 1) + zoffs) & 0x1f;
91 pptop = tex[(ty << 5) + tx];
92 tx = ~((angle >> 1) - uoffs) & 0x1f;
93 ppbot = tex[(ty << 5) + tx];
95 angle = (tun >> 16) & 0xff;
96 depth = (tun >> 24) & 0xff;
97 tx = ((angle >> 1) + uoffs) & 0x1f;
98 ty = ((depth >> 1) + zoffs) & 0x1f;
99 pptop |= (uint16_t)tex[(ty << 5) + tx] << 8;
100 tx = ~((angle >> 1) - uoffs) & 0x1f;
101 ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8;