lower res, still slow
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 18 Oct 2022 15:00:25 +0000 (18:00 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 18 Oct 2022 15:00:25 +0000 (18:00 +0300)
Makefile
src/data.h
src/debug.c
src/gamescr.c
src/gba/main.c
src/voxscape.c

index b5de0c7..b7b0903 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,7 @@ install: $(bin)
 
 .PHONY: run
 run: $(bin)
-       mgba -3 $(bin)
+       mgba -3 --log-level=16 $(bin)
 
 .PHONY: debug
 debug: $(elf)
index 4cb08e2..e3f3290 100644 (file)
@@ -7,6 +7,8 @@
 #define CONV_RGB24_RGB15(r, g, b) \
        (((r) >> 3) | (((uint16_t)(g) & 0xf8) << 2) | (((uint16_t)(b) & 0xf8) << 7))
 
+#define VOX_SZ 256
+
 extern unsigned char color_pixels[];
 extern unsigned char color_cmap[];
 extern unsigned char height_pixels[];
index 2410574..42d1343 100644 (file)
@@ -10,9 +10,9 @@
 #include "util.h"
 
 uint16_t vblperf_color[] = {
-       /* grn  blue   cyan  yellow  orng    red     purple  d.green purple ... */
-       /* 60    30     20     15     12      10      8.5     7.5    ... */
-       0x3e0, 0xf863, 0xffc0, 0x3ff, 0x1ff, 0x001f, 0xf81f, 0x1e0, 0xf81f, 0xf81f, 0xf81f
+       /* white white  grn    blue   cyan    yellow   orng    red   purple  d.green white ... */
+       /* 60    30     20     15     12       10      8.5     7.5    6.6      6      5.4  ... */
+       0xffff, 0xffff, 0x3e0, 0xf863, 0xffc0, 0x3ff, 0x1ff, 0x001f, 0xf81f, 0x1e0, 0xffff, 0xffff, 0xffff
 };
 
 void vblperf_setcolor(int palidx)
index 0e5c6f8..e3ff340 100644 (file)
@@ -54,12 +54,12 @@ static int gamescr_start(void)
 
        vblperf_setcolor(0);
 
-       pos[0] = pos[1] = 256 << 16;
+       pos[0] = pos[1] = VOX_SZ << 15;
 
-       if(!(vox = vox_create(512, 512, height_pixels, color_pixels))) {
+       if(!(vox = vox_create(VOX_SZ, VOX_SZ, height_pixels, color_pixels))) {
                panic(get_pc(), "vox_create");
        }
-       vox_proj(vox, 45, 10, 100);
+       vox_proj(vox, 45, 2, VOX_SZ / 5);
 
        /* setup color image palette */
        for(i=0; i<192; i++) {
@@ -102,6 +102,10 @@ static void gamescr_frame(void)
        vblperf_end();
        wait_vblank();
        present(backbuf);
+
+       if(!(nframes & 15)) {
+               emuprint("vbl: %d", vblperf_count);
+       }
        vblperf_begin();
 }
 
@@ -151,9 +155,7 @@ static void draw(void)
        vox_sky_solid(vox, COLOR_ZENITH);
 }
 
-#ifdef BUILD_GBA
-__attribute__((noinline, target("arm"), section(".iwram")))
-#endif
+ARM_IWRAM
 static void gamescr_vblank(void)
 {
        num_vbl++;
index 8417df1..6e5dbc0 100644 (file)
@@ -32,8 +32,6 @@ int main(void)
        REG_DISPSTAT |= DISPSTAT_IEN_VBLANK;
        unmask(INTR_VBLANK);
 
-       intr_enable();
-
        if(init_screens() == -1) {
                panic(get_pc(), "failed to initialize screens");
        }
@@ -42,19 +40,22 @@ int main(void)
                panic(get_pc(), "failed to find game screen");
        }
 
+       intr_enable();
+
        for(;;) {
                curscr->frame();
        }
        return 0;
 }
 
+ARM_IWRAM
 static void vblank(void)
 {
+#ifdef VBLBAR
        vblperf_count++;
+#endif
 
-       if(curscr && curscr->vblank) {
-               curscr->vblank();
-       }
+       curscr->vblank();
 
 #ifndef NOSOUND
        mmVBlank();
index a9008ab..60c2781 100644 (file)
 #define FBWIDTH                240
 #define FBHEIGHT       160
 /* map size */
-#define XSZ                    512
-#define YSZ                    512
-#define XSHIFT         9
-#define XMASK          0x1ff
-#define YMASK          0x1ff
+#define XSZ                    256
+#define YSZ                    256
+#define XSHIFT         8
+#define XMASK          0xff
+#define YMASK          0xff
+#define HSCALE         20
 
 
 #define NO_LERP
@@ -61,6 +62,8 @@ struct voxscape *vox_create(int xsz, int ysz, uint8_t *himg, uint8_t *cimg)
 {
        struct voxscape *vox;
 
+       assert(xsz == XSZ && ysz == YSZ);
+
        if(!(vox = calloc(1, sizeof *vox))) {
                return 0;
        }
@@ -281,7 +284,7 @@ void vox_render_slice(struct voxscape *vox, int n)
                        color = last_col;
                } else {
                        hval = vox->height[offs] - vox->vheight;
-                       hval = hval * 40 / (vox->znear + n) + vox->horizon;
+                       hval = hval * HSCALE / (vox->znear + n) + vox->horizon;
                        if(hval > FBHEIGHT) hval = FBHEIGHT;
                        color = vox->color[offs];
                        last_offs = offs;
@@ -309,7 +312,7 @@ void vox_render_slice(struct voxscape *vox, int n)
                        color = last_col;
                } else {
                        hval = vox->height[offs] - vox->vheight;
-                       hval = hval * 40 / (vox->znear + n) + vox->horizon;
+                       hval = hval * HSCALE / (vox->znear + n) + vox->horizon;
                        if(hval > FBHEIGHT) hval = FBHEIGHT;
                        color = vox->color[offs];
                        last_offs = offs;