X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgamescr.c;fp=src%2Fgamescr.c;h=2744d5d5111fe47af88415005d1b8f50fd96b5c9;hb=e8d7821317677f1d0fd6ee9efa9b9ef0ef006d01;hp=9e9d6e1ec3f98925f205b20ce495ed972cfa5665;hpb=ff74cf463fa44906add9344891096cada0970205;p=gbajam21 diff --git a/src/gamescr.c b/src/gamescr.c index 9e9d6e1..2744d5d 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -93,66 +93,83 @@ void gamescr(void) __attribute__((noinline, target("arm"), section(".iwram"))) static void draw_tunnel(void) { - int i, j, tx, ty, angle, depth, zoffs, uoffs; - uint16_t pptop; - uint16_t *top; - uint16_t tun; - int32_t startx, starty; - uint16_t *tmap = (uint16_t*)tunmap; + int i, j, tx, ty, angle, depth, zoffs, uoffs, flip, tunturn; + static int tunsweep; + uint16_t pptop, ppbot; + uint16_t *top, *bot; + uint32_t tun, *tunptr; - zoffs = nframes; + //tunsweep = SIN(nframes) >> 4; + + if((bnstate & BN_RT) && tunsweep > -31) tunsweep--; + if((bnstate & BN_LT) && tunsweep < 31) tunsweep++; - /* - if(bnstate & KEY_LT) tunrot++; - if(bnstate & KEY_RT) tunrot--; - */ - tunrot = nframes; + flip = tunsweep < 0; + tunturn = abs(tunsweep) & 0x1f; - tunmat[0] = COS(tunrot); - tunmat[1] = -SIN(tunrot); - tunmat[2] = SIN(tunrot); - tunmat[3] = COS(tunrot); - tunx = (128 << 8) - tunmat[0] * 120 + tunmat[1] * -80; - tuny = (128 << 8) - tunmat[2] * 120 + tunmat[3] * -80; + zoffs = nframes; - uoffs = tunrot; + uoffs = flip ? -nframes : nframes; top = vram[backbuf]; - for(i=0; i<160; i++) { - startx = tunx; - starty = tuny; - for(j=0; j<240/2; j++) { - tx = (tunx >> 8) & 0xff; - ty = (tuny >> 8) & 0xff; - tun = tmap[(ty << 8) + tx]; - - tunx += tunmat[0]; - tuny += tunmat[2]; - - angle = tun & 0xff; - depth = (tun >> 8) & 0xff; - tx = ((angle >> 1) - uoffs) & 0x1f; - ty = ((depth >> 1) + zoffs) & 0x1f; - pptop = tex[(ty << 5) + tx]; - - tx = (tunx >> 8) & 0xff; - ty = (tuny >> 8) & 0xff; - tun = tmap[(ty << 8) + tx]; - - tunx += tunmat[0]; - tuny += tunmat[2]; - - angle = tun & 0xff; - depth = (tun >> 8) & 0xff; - tx = ((angle >> 1) - uoffs) & 0x1f; - ty = ((depth >> 1) + zoffs) & 0x1f; - pptop |= (uint16_t)tex[(ty << 5) + tx] << 8; - - *top++ = pptop; + bot = vram[backbuf] + 159 * 240 / 2; + tunptr = tunmap + tunturn * 9600; + + if(flip) { + tunptr += 240/2; + for(i=0; i<80; i++) { + for(j=0; j<240/2; j++) { + tun = *--tunptr; + tun = (tun >> 16) | (tun << 16); + + angle = tun & 0xff; + depth = (tun >> 8) & 0xff; + tx = ~((angle >> 1) - uoffs) & 0x1f; + ty = ((depth >> 1) + zoffs) & 0x1f; + pptop = tex[(ty << 5) + tx]; + tx = ((angle >> 1) + uoffs) & 0x1f; + ppbot = tex[(ty << 5) + tx]; + + angle = (tun >> 16) & 0xff; + depth = (tun >> 24) & 0xff; + tx = ~((angle >> 1) - uoffs) & 0x1f; + ty = ((depth >> 1) + zoffs) & 0x1f; + pptop |= (uint16_t)tex[(ty << 5) + tx] << 8; + tx = ((angle >> 1) + uoffs) & 0x1f; + ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8; + + *top++ = pptop; + *bot++ = ppbot; + } + bot -= 240; + tunptr += 240; + } + } else { + for(i=0; i<80; i++) { + for(j=0; j<240/2; j++) { + tun = *tunptr++; + + angle = tun & 0xff; + depth = (tun >> 8) & 0xff; + tx = ((angle >> 1) - uoffs) & 0x1f; + ty = ((depth >> 1) + zoffs) & 0x1f; + pptop = tex[(ty << 5) + tx]; + tx = ~((angle >> 1) + uoffs) & 0x1f; + ppbot = tex[(ty << 5) + tx]; + + angle = (tun >> 16) & 0xff; + depth = (tun >> 24) & 0xff; + tx = ((angle >> 1) - uoffs) & 0x1f; + ty = ((depth >> 1) + zoffs) & 0x1f; + pptop |= (uint16_t)tex[(ty << 5) + tx] << 8; + tx = ~((angle >> 1) + uoffs) & 0x1f; + ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8; + + *top++ = pptop; + *bot++ = ppbot; + } + bot -= 240; } - - tunx = startx + tunmat[1]; - tuny = starty + tunmat[3]; } }