foo
authorJohn Tsiombikas <nuclear@member.fsf.org>
Wed, 19 Oct 2022 00:59:45 +0000 (03:59 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Wed, 19 Oct 2022 00:59:45 +0000 (03:59 +0300)
src/data.h
src/gamescr.c
src/voxscape.c

index ce9a2e7..06d7728 100644 (file)
@@ -7,7 +7,7 @@
 #define CONV_RGB24_RGB15(r, g, b) \
        (((r) >> 3) | (((uint16_t)(g) & 0xf8) << 2) | (((uint16_t)(b) & 0xf8) << 7))
 
-#define VOX_SZ 256
+#define VOX_SZ 512
 
 extern uint16_t color_pixels[];
 extern uint8_t height_pixels[];
index 9686456..6555328 100644 (file)
@@ -56,7 +56,7 @@ static int gamescr_start(void)
        if(!(vox = vox_create(VOX_SZ, VOX_SZ, height_pixels, color_pixels))) {
                panic(get_pc(), "vox_create");
        }
-       vox_proj(vox, 45, 2, VOX_SZ / 5);
+       vox_proj(vox, 30, 2, 80);
 
        nframes = 0;
        return 0;
index 3669ede..d57ad07 100644 (file)
 #define FBWIDTH                160
 #define FBHEIGHT       128
 /* map size */
-#define XSZ                    256
-#define YSZ                    256
-#define XSHIFT         8
-#define XMASK          0xff
-#define YMASK          0xff
-#define HSCALE         20
+#define XSZ                    512
+#define YSZ                    512
+#define XSHIFT         9
+#define XMASK          0x1ff
+#define YMASK          0x1ff
+#define HSCALE         40
 
 
 #define NO_LERP
@@ -24,7 +24,7 @@
 #define XLERP(a, b, t, fp) \
        ((((a) << (fp)) + ((b) - (a)) * (t)) >> fp)
 
-static uint16_t lerp_rgb(int r0, int g0, int b0, int r1, int g1, int b1, int32_t t);
+static inline uint16_t lerp_rgb(int r0, int g0, int b0, int r1, int g1, int b1, int32_t t);
 
 enum {
        SLICELEN        = 1
@@ -223,7 +223,6 @@ void vox_proj(struct voxscape *vox, int fov, int znear, int zfar)
        vox->zfar = zfar;
 
        vox->nslices = vox->zfar - vox->znear;
-       free(vox->slicelen);
        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);
                return;
@@ -245,6 +244,7 @@ void vox_render(struct voxscape *vox)
 
        vox_begin(vox);
        for(i=0; i<vox->nslices; i++) {
+               if(i >= 25 && (i & 1)) continue;
                vox_render_slice(vox, i);
        }
 }
@@ -289,7 +289,7 @@ void vox_render_slice(struct voxscape *vox, int n)
                        color = last_col;
                } else {
                        hval = vox->height[offs] - vox->vheight;
-                       hval = hval * HSCALE / (vox->znear + n) + vox->horizon;
+                       hval = hval * HSCALE / z + vox->horizon;
                        if(hval > FBHEIGHT) hval = FBHEIGHT;
                        color = vox->color[offs];
                        last_offs = offs;
@@ -362,7 +362,7 @@ void vox_sky_grad(struct voxscape *vox, uint16_t chor, uint16_t ctop)
        }
 }
 
-static uint16_t lerp_rgb(int r0, int g0, int b0, int r1, int g1, int b1, int32_t t)
+static inline uint16_t lerp_rgb(int r0, int g0, int b0, int r1, int g1, int b1, int32_t t)
 {
        int r = XLERP(r0, r1, t, 16);
        int g = XLERP(g0, g1, t, 16);