From: John Tsiombikas Date: Sat, 13 Jan 2024 22:58:55 +0000 (+0200) Subject: fixed nametab.B invalid address, and spr_submit with 0 sprites X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=9e5bd0a52f0428e1a11df30714357d0fc95b3975;p=mdlife fixed nametab.B invalid address, and spr_submit with 0 sprites --- diff --git a/Makefile b/Makefile index 6c173f8..d44e573 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ bin = $(name).bin warn = -pedantic -Wall dbg = -g -opt = -O3 +#opt = -O3 def = -D__NO_CTYPE inc = -I. -Isrc -Isrc/libc @@ -91,6 +91,10 @@ install: $(bin) [ -f /media/usbmass/MEGA/MEGA.RBF ] || cp $(bin) /media/usbmass/MEGA/MEGA.BIN umount /media/usbmass +.PHONY: debug +debug: $(bin) + $(TC)gdb $(elf) + # ---- tools ---- PNGDUMP = tools/pngdump/pngdump diff --git a/src/hwregs.h b/src/hwregs.h index 4455811..2ab7591 100644 --- a/src/hwregs.h +++ b/src/hwregs.h @@ -116,7 +116,7 @@ #define VDP_NA_ADDR(x) (((x) >> 10) & 0x38) #define VDP_NW_ADDR(x) (((x) >> 10) & 0x3e) -#define VDP_NB_ADDR(x) ((x) >> 13) +#define VDP_NB_ADDR(x) (((x) >> 13) & 7) #define VDP_SPRTAB_ADDR(x) ((x) >> 9) #define VDP_HSTAB_ADDR(x) ((x) >> 10) diff --git a/src/main.c b/src/main.c index 29fb6d5..9478ee8 100644 --- a/src/main.c +++ b/src/main.c @@ -30,7 +30,7 @@ int main(void) parts[0].update = dna_update; parts[1].start = simba_start; parts[1].update = simba_update; - part = parts + 1; + part = parts; part->start(); diff --git a/src/part_simba.c b/src/part_simba.c index 622bbbf..7c2611d 100644 --- a/src/part_simba.c +++ b/src/part_simba.c @@ -27,7 +27,7 @@ void simba_start(void) /* setup tilemaps */ src = simbabg_tmap; - vdp_setup_addr(VDP_VRAM, 0xd000); /* nametable B */ + vdp_setup_addr(VDP_VRAM, 0xe000); /* nametable B */ while(src < simbabg_tmap_end) { VDP_DATA = VDP_TILENAME(*src++, 2, 0); } diff --git a/src/sprite.S b/src/sprite.S index 158aaac..d258d62 100644 --- a/src/sprite.S +++ b/src/sprite.S @@ -8,11 +8,16 @@ .globl spr_submit spr_submit: - move.l spr_count, %d0 - lsl.l #2, %d0 | 4 words per sprite + move.w spr_count, %d0 + tst.w %d0 + bne.s 0f + | if spr_count is zero, upload a single null sprite + addq.w #1, %d0 +0: ext.l %d0 + lsl.w #2, %d0 | 4 words per sprite move.l %d0, -(%sp) pea spr_shadow - pea 0xe000.w | we placed the spirte table at e000 + pea 0xd000.w | we placed the spirte table at d000 jsr dma_systovram addq.l #8, %sp addq.l #4, %sp diff --git a/src/sprite.c b/src/sprite.c index 63305f3..9a6c6e7 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -3,7 +3,7 @@ #include "vdp.h" struct hwsprite spr_shadow[MAX_HWSPRITES]; -int spr_count; +short spr_count; void spr_begin(void) { @@ -13,7 +13,7 @@ void spr_begin(void) void spr_add(int x, int y, unsigned int tile, int sprsz) { - int id; + short id; struct hwsprite *spr; if(spr_count >= MAX_HWSPRITES) { diff --git a/src/sprite.h b/src/sprite.h index 17050e9..7b90506 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -15,7 +15,7 @@ struct hwsprite { #define MAX_HWSPRITES 64 extern struct hwsprite spr_shadow[MAX_HWSPRITES]; -extern int spr_count; +extern short spr_count; void spr_begin(void); void spr_add(int x, int y, unsigned int tile, int sprsz); diff --git a/src/vdp.S b/src/vdp.S index 990a3ef..c1cf6a2 100644 --- a/src/vdp.S +++ b/src/vdp.S @@ -70,8 +70,8 @@ def_reg_tab: .byte VDP_REG_MODE2, VDP_M2_INIT + VDP_M2_DISP | 1: mode 2 .byte VDP_REG_NAMEA, VDP_NA_ADDR(0xc000) | 2: scroll A nametable addr. .byte VDP_REG_NAMEW, 0 | 3: window nametable addr. - .byte VDP_REG_NAMEB, VDP_NB_ADDR(0xd000) | 4: scroll B nametable addr. - .byte VDP_REG_SPR, VDP_SPRTAB_ADDR(0xe000) | 5: sprite table addr. + .byte VDP_REG_NAMEB, VDP_NB_ADDR(0xe000) | 4: scroll B nametable addr. + .byte VDP_REG_SPR, VDP_SPRTAB_ADDR(0xd000) | 5: sprite table addr. .byte VDP_REG_BGCOL, 0 | 7: bg color .byte VDP_REG_HINTR, 0 | 10: horiz. interrupt interval .byte VDP_REG_MODE3, 0 | 11: mode 3