10 static void draw_tunnel(void);
12 static int nframes, backbuf;
13 static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR };
14 static unsigned char *tex;
22 REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_FB1;
24 vblperf_setcolor(0xff);
26 cdst = (uint16_t*)CRAM_BG_ADDR;
28 for(i=0; i<256; i++) {
29 *cdst++ = CONV_RGB24_RGB15(csrc[0], csrc[1], csrc[2]);
33 fillblock_16byte(vram[0], 0xffffffff, 240 * 160 / 16);
34 fillblock_16byte(vram[1], 0xffffffff, 240 * 160 / 16);
36 tex = iwram_sbrk(32 * 32);
37 memcpy(tex, tuncross_pixels, 32 * 32);
41 backbuf = ++nframes & 1;
52 __attribute__((noinline, target("arm"), section(".iwram")))
53 static void draw_tunnel(void)
55 int i, j, tx, ty, angle, depth, zoffs, uoffs;
56 uint16_t pptop, ppbot;
58 uint32_t tun, *tunptr;
64 bot = vram[backbuf] + 159 * 240 / 2;
70 for(j=1; j<240/2; j++) {
74 depth = (tun >> 8) & 0xff;
75 tx = ((angle >> 1) + uoffs) & 0x1f;
76 ty = ((depth >> 1) + zoffs) & 0x1f;
77 pptop = tex[(ty << 5) + tx];
78 tx = ((angle >> 1) - uoffs) & 0x1f;
79 ppbot = tex[(ty << 5) + tx];
81 angle = (tun >> 16) & 0xff;
82 depth = (tun >> 24) & 0xff;
83 tx = ((angle >> 1) + uoffs) & 0x1f;
84 ty = ((depth >> 1) + zoffs) & 0x1f;
85 pptop |= (uint16_t)tex[(ty << 5) + tx] << 8;
86 tx = ((angle >> 1) - uoffs) & 0x1f;
87 ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8;