ARM_IWRAM
static void gamescr_vblank(void)
{
- static int bank, bankdir, theta, scale;
+ static int bank, bankdir, theta, s;
int32_t sa, ca;
theta = -(bank << 3);
- scale = MAXBANK + (abs(bank) >> 3);
- sa = SIN(theta) / scale;
- ca = COS(theta) / scale;
+#if 0
+ s = 0x100000 / (MAXBANK + (abs(bank) >> 3));
+ sa = ((SIN(theta) >> 8) * s) >> 12;
+ ca = ((COS(theta) >> 8) * s) >> 12;
+#else
+ s = (MAXBANK + (abs(bank) >> 3));
+ sa = SIN(theta) / s;
+ ca = COS(theta) / s;
+#endif
REG_BG2X = -ca * 120 - sa * 80 + (120 << 8);
REG_BG2Y = sa * 120 - ca * 80 + (80 << 8);
unsigned int valid;
};
-static int *projtab;
-
int vox_quality = 1;
+int *projlut;
struct voxscape *vox_create(int xsz, int ysz, uint8_t *himg, uint8_t *cimg)
{
if(xres != vox->fbwidth) {
if(!(vox->coltop = iwram_sbrk(xres * sizeof *vox->coltop))) {
panic(get_pc(), "vox_framebuf: failed to allocate column table (%d)\n", xres);
- return;
}
}
vox->fb = fb;
if(!(vox->slicelen = iwram_sbrk(vox->nslices * sizeof *vox->slicelen))) {
panic(get_pc(), "vox_proj: failed to allocate slice length table (%d)\n", vox->nslices);
}
- if(!(projtab = iwram_sbrk(vox->nslices * sizeof *projtab))) {
- panic(get_pc(), "vox_proj: failed to allocate projection table (%d)\n", vox->nslices);
+ if(!(projlut = iwram_sbrk(vox->nslices * sizeof *projlut))) {
+ panic(get_pc(), "vox_framebuf: failed to allocate projection table (%d)\n", vox->nslices);
}
}
float theta = (float)vox->fov * M_PI / 360.0f; /* half angle */
for(i=0; i<vox->nslices; i++) {
vox->slicelen[i] = (int32_t)((vox->znear + i) * tan(theta) * 4.0f * 65536.0f);
- projtab[i] = (HSCALE << 8) / (vox->znear + i);
+ projlut[i] = (HSCALE << 8) / (vox->znear + i);
}
vox->valid |= SLICELEN;
}
int32_t x, y, len, xstep, ystep;
uint8_t color, last_col;
uint16_t *fbptr;
+ int proj;
z = vox->znear + n;
x = vox->x - SIN(vox->angle) * z - xstep * (FBWIDTH / 4);
y = vox->y + COS(vox->angle) * z - ystep * (FBWIDTH / 4);
+ /*proj = (HSCALE << 8) / (vox->znear + n);*/
+
for(i=0; i<FBWIDTH/2; i++) {
col = i << 1;
offs = (((y >> 16) & YMASK) << XSHIFT) + ((x >> 16) & XMASK);
color = last_col;
} else {
hval = vox->height[offs] - vox->vheight;
- /*hval = hval * HSCALE / (vox->znear + n) + vox->horizon;*/
- hval = ((hval * projtab[n]) >> 8) + vox->horizon;
+ hval = ((hval * projlut[n]) >> 8) + vox->horizon;
if(hval > FBHEIGHT) hval = FBHEIGHT;
color = vox->color[offs];
last_offs = offs;