X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgamescr.c;h=1b11c25796d657fbf863aedf20d4273313cfe007;hb=622fc6ef720a41a066e1bfcbdc6e003609da2da7;hp=4c7d6bae8745a7e94851a6b89c49f65801f17cdc;hpb=e2ed633cc1ea03fcc73d862adfc154cbfb3a537c;p=gbajam21 diff --git a/src/gamescr.c b/src/gamescr.c index 4c7d6ba..1b11c25 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -1,3 +1,4 @@ +#include #include #include "gbaregs.h" #include "dma.h" @@ -10,13 +11,14 @@ void gamescr(void) { int i, j, tx, ty, angle, depth, nframes, backbuf, zoffs; static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR }; - uint16_t *cdst; + uint16_t *cdst, *top, *bot; unsigned char *csrc; uint32_t tun, *tunptr; + unsigned char *tex; REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_FB1; - vblperf_start(0xff); + vblperf_setcolor(0xff); cdst = (uint16_t*)CRAM_BG_ADDR; csrc = tuncross_cmap; @@ -25,8 +27,11 @@ void gamescr(void) csrc += 3; } - dma_fill16(3, vram[0], 0xffff, 240 * 160 / 2); - dma_fill16(3, vram[1], 0xffff, 240 * 160 / 2); + fillblock_16byte(vram[0], 0xffffffff, 240 * 160 / 16); + fillblock_16byte(vram[1], 0xffffffff, 240 * 160 / 16); + + tex = iwram_sbrk(32 * 32); + memcpy(tex, tuncross_pixels, 32 * 32); nframes = 0; for(;;) { @@ -34,35 +39,43 @@ void gamescr(void) zoffs = nframes << 1; - cdst = vram[backbuf]; + top = vram[backbuf]; + bot = vram[backbuf] + 159 * 240 / 2; tunptr = tunmap; - for(i=0; i<160; i++) { - cdst++; - tunptr += 2; + for(i=0; i<80; i++) { + top++; + bot++; + tunptr++; for(j=1; j<240/2; j++) { - uint16_t pp; + uint16_t pptop, ppbot; tun = *tunptr++; - angle = tun & 0xffff; - depth = tun >> 16; - tx = (angle >> 6) & 0x7f; - ty = ((depth >> 7) - zoffs) & 0x7f; - pp = tuncross_pixels[(ty << 7) + tx]; - tun = *tunptr++; - angle = tun & 0xffff; - depth = tun >> 16; - tx = (angle >> 6) & 0x7f; - ty = ((depth >> 7) - zoffs) & 0x7f; - pp |= (uint16_t)tuncross_pixels[(ty << 7) + tx] << 8; + angle = tun & 0xff; + depth = (tun >> 8) & 0xff; + tx = ((angle >> 1) + zoffs) & 0x1f; + ty = ((depth >> 1) + zoffs) & 0x1f; + pptop = tex[(ty << 5) + tx]; + tx = ((angle >> 1) - zoffs) & 0x1f; + ppbot = tex[(ty << 5) + tx]; + + angle = (tun >> 16) & 0xff; + depth = (tun >> 24) & 0xff; + tx = ((angle >> 1) + zoffs) & 0x1f; + ty = ((depth >> 1) + zoffs) & 0x1f; + pptop |= (uint16_t)tex[(ty << 5) + tx] << 8; + tx = ((angle >> 1) - zoffs) & 0x1f; + ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8; - *cdst++ = pp; + *top++ = pptop; + *bot++ = ppbot; } + bot -= 240; } vblperf_end(); wait_vblank(); present(backbuf); - vblperf_start(); + vblperf_begin(); } }