.PHONY: run
run: $(bin)
- mgba -3 $(bin)
+ mgba -3 --log-level=16 $(bin)
.PHONY: debug
debug: $(elf)
#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[];
#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)
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++) {
vblperf_end();
wait_vblank();
present(backbuf);
+
+ if(!(nframes & 15)) {
+ emuprint("vbl: %d", vblperf_count);
+ }
vblperf_begin();
}
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++;
REG_DISPSTAT |= DISPSTAT_IEN_VBLANK;
unmask(INTR_VBLANK);
- intr_enable();
-
if(init_screens() == -1) {
panic(get_pc(), "failed to initialize screens");
}
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();
#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
{
struct voxscape *vox;
+ assert(xsz == XSZ && ysz == YSZ);
+
if(!(vox = calloc(1, sizeof *vox))) {
return 0;
}
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;
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;