}
#define TUN_U(x) ((x) & 0x3f)
-#define TUN_V(x) (((x) >> 7) & 0x1ff)
+#define TUN_V(x) (((x) >> 6) & 0x3ff)
__attribute__((noinline, target("arm"), section(".iwram")))
static void draw_tunnel(void)
tunturn = abs(tunsweep) & 0x1f;
zoffs = num_vbl;
- uoffs = 0;//(flip ? -num_vbl : num_vbl) >> 2;
+ uoffs = (flip ? -num_vbl : num_vbl) >> 1;
top = vram[backbuf];
bot = vram[backbuf] + 159 * 240 / 2;
angle = TUN_U(tun >> 16);
depth = TUN_V(tun >> 16);
tx = ~(angle - uoffs) & 0x1f;
- ty = (depth + zoffs) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
pptop = tex[(ty << 5) + tx];
tx = (angle + uoffs) & 0x1f;
ppbot = tex[(ty << 5) + tx];
angle = TUN_U(tun);
depth = TUN_V(tun);
tx = ~(angle - uoffs) & 0x1f;
- ty = (depth + zoffs) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
pptop |= (uint16_t)tex[(ty << 5) + tx] << 8;
tx = (angle + uoffs) & 0x1f;
ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8;
angle = TUN_U(tun);
depth = TUN_V(tun);
tx = (angle - uoffs) & 0x1f;
- ty = (depth + zoffs) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
pptop = tex[(ty << 5) + tx];
tx = ~(angle + uoffs) & 0x1f;
ppbot = tex[(ty << 5) + tx];
angle = TUN_U(tun >> 16);
depth = TUN_V(tun >> 16);
tx = (angle - uoffs) & 0x1f;
- ty = (depth + zoffs) & 0x1f;
+ ty = ((depth >> 1) + zoffs) & 0x1f;
pptop |= (uint16_t)tex[(ty << 5) + tx] << 8;
tx = ~(angle + uoffs) & 0x1f;
ppbot |= (uint16_t)tex[(ty << 5) + tx] << 8;