X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgamescr.c;h=e5dd8e4ba46c32042c66da12fdf297e84e26557d;hb=5295fa573612c0b9c8c47c3dc42464f75639845b;hp=330331eb63450429cd8965d2fffb6f3b8967f688;hpb=4f58871ec2e25fb8cd7dfc19d1e4999453cf9555;p=gbajam21 diff --git a/src/gamescr.c b/src/gamescr.c index 330331e..e5dd8e4 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -1,25 +1,26 @@ +#include #include #include "gbaregs.h" #include "dma.h" #include "data.h" +#include "util.h" +#include "intr.h" #include "debug.h" -#define present(x) \ - do { \ - REG_DISPCNT = DISPCNT_BG2 | 4 | ((x) << 4); \ - } while(0) - +static unsigned char tex[32 * 32] __attribute__((section(".iwram"))); 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; REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_FB1; + vblperf_start(0xff); + cdst = (uint16_t*)CRAM_BG_ADDR; csrc = tuncross_cmap; for(i=0; i<256; i++) { @@ -27,39 +28,51 @@ void gamescr(void) csrc += 3; } + fillblock_16byte(vram[0], 0xffffffff, 240 * 160 / 16); + fillblock_16byte(vram[1], 0xffffffff, 240 * 160 / 16); + + memcpy(tex, tuncross_pixels, 32 * 32); + nframes = 0; for(;;) { backbuf = ++nframes & 1; zoffs = nframes << 1; - cdst = vram[backbuf]; + top = vram[backbuf]; + bot = vram[backbuf] + 159 * 240 / 2; tunptr = tunmap; - for(i=0; i<160; i++) { + for(i=0; i<80; i++) { for(j=0; 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; } - //while(!(REG_DISPSTAT & DISPSTAT_VBLANK)); - while(REG_VCOUNT < 160); - //REG_DISPCNT ^= DISPCNT_FB1; + vblperf_end(); + wait_vblank(); present(backbuf); + vblperf_begin(); } }