From a54b2023cc634befc0771cd5104173d811668039 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 18 Oct 2022 18:00:25 +0300 Subject: [PATCH] lower res, still slow --- Makefile | 2 +- src/data.h | 2 ++ src/debug.c | 6 +++--- src/gamescr.c | 14 ++++++++------ src/gba/main.c | 11 ++++++----- src/voxscape.c | 17 ++++++++++------- 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index b5de0c7..b7b0903 100644 --- 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) diff --git a/src/data.h b/src/data.h index 4cb08e2..e3f3290 100644 --- a/src/data.h +++ b/src/data.h @@ -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[]; diff --git a/src/debug.c b/src/debug.c index 2410574..42d1343 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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) diff --git a/src/gamescr.c b/src/gamescr.c index 0e5c6f8..e3ff340 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -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++; diff --git a/src/gba/main.c b/src/gba/main.c index 8417df1..6e5dbc0 100644 --- a/src/gba/main.c +++ b/src/gba/main.c @@ -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(); diff --git a/src/voxscape.c b/src/voxscape.c index a9008ab..60c2781 100644 --- a/src/voxscape.c +++ b/src/voxscape.c @@ -11,11 +11,12 @@ #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; -- 1.7.10.4