SLICELEN = 1
};
-static unsigned char *vox_height;
+static unsigned char *vox_hmap;
static unsigned char *vox_color;
/* framebuffer */
static uint16_t *vox_fb;
{
assert(xsz == XSZ && ysz == YSZ);
- vox_height = himg;
+ vox_hmap = himg;
vox_color = cimg;
+ vox_fb = 0;
+ vox_coltop = 0;
+ vox_horizon = 0;
+ vox_x = vox_y = vox_angle = 0;
+ vox_fov = 0;
+ vox_znear = vox_zfar = 0;
+ vox_nslices = 0;
+ vox_slicelen = 0;
+ vox_valid = 0;
+ projlut = 0;
+
vox_vheight = 80;
return 0;
void vox_destroy(void)
{
- free(vox_color);
- free(vox_height);
- free(vox_coltop);
- free(vox_slicelen);
+ /* XXX we rely on the screen to clear up any allocated IWRAM */
}
#define H(x, y) \
- vox_height[((((y) >> 16) & YMASK) << XSHIFT) + (((x) >> 16) & XMASK)]
+ vox_hmap[((((y) >> 16) & YMASK) << XSHIFT) + (((x) >> 16) & XMASK)]
#define C(x, y) \
vox_color[((((y) >> 16) & YMASK) << XSHIFT) + (((x) >> 16) & XMASK)]
vox_horizon = horizon >= 0 ? horizon : (FBHEIGHT >> 1);
}
-void vox_view(int32_t x, int32_t y, int h, int32_t angle)
+int vox_view(int32_t x, int32_t y, int h, int32_t angle)
{
if(h < 0) {
h = H(x, y) - h;
vox_angle = angle;
vox_valid &= ~SLICELEN;
+
+ return h;
}
void vox_proj(int fov, int znear, int zfar)
hval = last_hval;
color = last_col;
} else {
- hval = vox_height[offs] - vox_vheight;
+ hval = vox_hmap[offs] - vox_vheight;
hval = ((hval * projlut[n]) >> 8) + vox_horizon;
if(hval > FBHEIGHT) hval = FBHEIGHT;
color = vox_color[offs];
obj = (struct vox_object*)((char*)obj + stride);
}
}
+
+int vox_height(int x, int y)
+{
+ return H(x, y);
+}
+
+int vox_check_vis(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
+{
+ /* TODO */
+ return 0;
+}