gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 0985166ef3d59a7583cbfd02341d79cd467d2628 parent 1defcf000ba69492c3377af1f867b6e7cb77f0ba Author: Toxa <untoxa@mail.ru> Date: Tue, 16 Jan 2024 19:55:18 +0300 SMS/GG, MSX: allow nested locking of the shadow SAT copying on VBlank Diffstat:
24 files changed, 65 insertions(+), 50 deletions(-)
diff --git a/gbdk-lib/libc/targets/z80/gg/global.s b/gbdk-lib/libc/targets/z80/gg/global.s @@ -295,13 +295,13 @@ lbl: .endm .macro DISABLE_VBLANK_COPY - ld a, #1 - ld (__shadow_OAM_OFF), a + ld hl, #__shadow_OAM_OFF + inc (hl) .endm .macro ENABLE_VBLANK_COPY - xor a - ld (__shadow_OAM_OFF), a + ld hl, #__shadow_OAM_OFF + dec (hl) .endm .macro ADD_A_REG16 regH regL diff --git a/gbdk-lib/libc/targets/z80/gg/palette.s b/gbdk-lib/libc/targets/z80/gg/palette.s @@ -10,6 +10,7 @@ _set_palette_entry:: pop de pop bc + ld hl, #.VDP_CRAM bit 0, c jr z, 1$ @@ -36,6 +37,7 @@ _set_palette_entry:: jp po, 2$ ei 2$: + ld h, d ld l, e jp (hl) @@ -44,6 +46,9 @@ _set_palette_entry:: _set_palette:: pop de pop bc + + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + ld hl, #.VDP_CRAM bit 0, c ld a, b @@ -55,8 +60,6 @@ _set_palette:: ld c, a - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - ld a, i di ld a, l diff --git a/gbdk-lib/libc/targets/z80/msxdos/global.s b/gbdk-lib/libc/targets/z80/msxdos/global.s @@ -434,13 +434,13 @@ lbl: .endm .macro DISABLE_VBLANK_COPY - ld a, #1 - ld (__shadow_OAM_OFF), a + ld hl, #__shadow_OAM_OFF + inc (hl) .endm .macro ENABLE_VBLANK_COPY - xor a - ld (__shadow_OAM_OFF), a + ld hl, #__shadow_OAM_OFF + dec (hl) .endm .macro ADD_A_REG16 regH regL diff --git a/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect_xy.s b/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect_xy.s @@ -34,6 +34,9 @@ jr c, 5$ ld b, #>.VDP_TILEMAP 5$: + + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -42,8 +45,6 @@ ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA diff --git a/gbdk-lib/libc/targets/z80/msxdos/msx_refresh_oam.s b/gbdk-lib/libc/targets/z80/msxdos/msx_refresh_oam.s @@ -12,6 +12,7 @@ ; void refresh_OAM(); _refresh_OAM:: DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + ld de, #.VDP_SAT VDP_WRITE_CMD d, e diff --git a/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_data.s b/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_data.s @@ -9,6 +9,8 @@ ; void set_tile_1bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t colors) __z88dk_callee; _set_tile_1bpp_data:: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop af pop hl pop iy @@ -32,8 +34,6 @@ _set_tile_1bpp_data:: ld bc, #.VDP_TILEDATA0 add hl, bc - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - ld c, #.VDP_DATA inc iyh inc iyl diff --git a/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_sprite_data.s b/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_sprite_data.s @@ -9,6 +9,8 @@ ; void set_sprite_1bpp_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee; _set_sprite_1bpp_data:: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop af pop hl pop iy @@ -22,7 +24,6 @@ _set_sprite_1bpp_data:: ld bc, #.VDP_SPRDATA0 add hl, bc - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT VDP_WRITE_CMD h, l diff --git a/gbdk-lib/libc/targets/z80/msxdos/msx_set_native_data.s b/gbdk-lib/libc/targets/z80/msxdos/msx_set_native_data.s @@ -8,6 +8,8 @@ ; void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee _set_native_tile_data:: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop bc pop hl pop iy @@ -27,8 +29,6 @@ _set_native_tile_data:: ld bc, #.VDP_TILEDATA0 add hl, bc - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - ld c, #.VDP_DATA inc iyh inc iyl diff --git a/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map_xy.s b/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map_xy.s @@ -34,6 +34,8 @@ jr c, 5$ ld b, #>.VDP_TILEMAP 5$: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -42,8 +44,6 @@ ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA @@ -93,6 +93,7 @@ jp 1$ 6$: ENABLE_VBLANK_COPY ; switch ON copy shadow SAT + pop ix ; restore IX ret diff --git a/gbdk-lib/libc/targets/z80/putchar.s b/gbdk-lib/libc/targets/z80/putchar.s @@ -72,6 +72,8 @@ _putchar:: add a, e ld e, a + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + ld a, (.cury) ld l, a ld h, #0 @@ -97,7 +99,6 @@ _putchar:: ld c, #0 add hl, bc - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT WRITE_VDP_CMD_HL ld a, e diff --git a/gbdk-lib/libc/targets/z80/set_tile.s b/gbdk-lib/libc/targets/z80/set_tile.s @@ -9,20 +9,24 @@ ; void set_vram_byte(uint8_t * addr, uint8_t v) __z88dk_callee __preserves_regs(iyh, iyl); _set_vram_byte:: + DISABLE_VBLANK_COPY + pop de pop hl - DISABLE_VBLANK_COPY WRITE_VDP_CMD_HL ex de, hl dec sp ex (sp), hl ld a, h out (.VDP_DATA), a + ENABLE_VBLANK_COPY ret ; uint8_t * set_attributed_tile_xy(uint8_t x, uint8_t y, uint16_t t) __z88dk_callee __preserves_regs(iyh, iyl); _set_attributed_tile_xy:: + DISABLE_VBLANK_COPY + pop hl ; HL = ret pop de ; DE = YX ex (sp), hl ; HL = data @@ -30,7 +34,6 @@ _set_attributed_tile_xy:: call .coords_to_address ex de, hl - DISABLE_VBLANK_COPY WRITE_VDP_CMD_HL ld c, #.VDP_DATA @@ -43,6 +46,8 @@ _set_attributed_tile_xy:: ; uint8_t * set_tile_xy(uint8_t x, uint8_t y, uint8_t t) __z88dk_callee __preserves_regs(iyh, iyl); _set_tile_xy:: + DISABLE_VBLANK_COPY + pop hl ; HL = ret pop de ; DE = YX dec sp @@ -54,7 +59,6 @@ _set_tile_xy:: ld a, (.vdp_shift) ADD_A_REG16 h, l - DISABLE_VBLANK_COPY WRITE_VDP_CMD_HL ld a, d @@ -65,6 +69,8 @@ _set_tile_xy:: ; uint8_t * set_attribute_xy(uint8_t x, uint8_t y, uint8_t a) __z88dk_callee __preserves_regs(iyh, iyl); _set_attribute_xy:: + DISABLE_VBLANK_COPY + pop hl ; HL = ret pop de ; DE = YX dec sp @@ -76,7 +82,6 @@ _set_attribute_xy:: ld a, (.vdp_shift) ADD_A_REG16 h, l - DISABLE_VBLANK_COPY WRITE_VDP_CMD_HL in a, (.VDP_DATA) ; skip tile index diff --git a/gbdk-lib/libc/targets/z80/set_tile_map_xy.s b/gbdk-lib/libc/targets/z80/set_tile_map_xy.s @@ -41,6 +41,8 @@ or iyh ld b, a + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -50,8 +52,6 @@ ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA diff --git a/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s b/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s @@ -54,6 +54,8 @@ __map_tile_offset:: or iyh ld b, a + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -62,8 +64,6 @@ __map_tile_offset:: ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA diff --git a/gbdk-lib/libc/targets/z80/set_tile_submap.s b/gbdk-lib/libc/targets/z80/set_tile_submap.s @@ -93,6 +93,8 @@ _set_tile_submap:: or iyh ld b, a + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -102,8 +104,6 @@ _set_tile_submap:: ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA diff --git a/gbdk-lib/libc/targets/z80/set_tile_submap_compat.s b/gbdk-lib/libc/targets/z80/set_tile_submap_compat.s @@ -103,6 +103,8 @@ _set_tile_submap_compat:: or iyh ld b, a + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -112,8 +114,6 @@ _set_tile_submap_compat:: ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA diff --git a/gbdk-lib/libc/targets/z80/sms/global.s b/gbdk-lib/libc/targets/z80/sms/global.s @@ -259,13 +259,13 @@ lbl: .endm .macro DISABLE_VBLANK_COPY - ld a, #1 - ld (__shadow_OAM_OFF), a + ld hl, #__shadow_OAM_OFF + inc (hl) .endm .macro ENABLE_VBLANK_COPY - xor a - ld (__shadow_OAM_OFF), a + ld hl, #__shadow_OAM_OFF + dec (hl) .endm .macro ADD_A_REG16 regH regL diff --git a/gbdk-lib/libc/targets/z80/sms/palette.s b/gbdk-lib/libc/targets/z80/sms/palette.s @@ -40,6 +40,9 @@ _set_palette_entry:: _set_palette:: pop de pop bc + + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + ld hl, #.VDP_CRAM bit 0, c ld a, b @@ -51,8 +54,6 @@ _set_palette:: ld c, a - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - ld a, i di ld a, l diff --git a/gbdk-lib/libc/targets/z80/sms_fill_rect_xy.s b/gbdk-lib/libc/targets/z80/sms_fill_rect_xy.s @@ -41,6 +41,8 @@ or iyh ld b, a + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -50,8 +52,6 @@ ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA diff --git a/gbdk-lib/libc/targets/z80/sms_fill_rect_xy_compat.s b/gbdk-lib/libc/targets/z80/sms_fill_rect_xy_compat.s @@ -45,6 +45,8 @@ or iyh ld b, a + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop hl ; HL = source pop de ; DE = HW push ix ; save IX @@ -53,8 +55,6 @@ ld ixl, c push ix ; store dest - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - 1$: ; copy H rows VDP_WRITE_CMD ixh, ixl ld c, #.VDP_DATA diff --git a/gbdk-lib/libc/targets/z80/sms_refresh_oam.s b/gbdk-lib/libc/targets/z80/sms_refresh_oam.s @@ -12,6 +12,7 @@ ; void refresh_OAM(); _refresh_OAM:: DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + ld a, (_shadow_VDP_R5) srl a ld d, a diff --git a/gbdk-lib/libc/targets/z80/sms_set_1bpp_data.s b/gbdk-lib/libc/targets/z80/sms_set_1bpp_data.s @@ -9,6 +9,8 @@ ; void set_tile_1bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t colors) __z88dk_callee __preserves_regs(iyh,iyl); _set_tile_1bpp_data:: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop de ; pop ret address pop hl @@ -21,8 +23,6 @@ _set_tile_1bpp_data:: ld bc, #.VDP_VRAM add hl, bc - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - VDP_WRITE_CMD h, l ex de, hl ; hl = ret diff --git a/gbdk-lib/libc/targets/z80/sms_set_2bpp_data.s b/gbdk-lib/libc/targets/z80/sms_set_2bpp_data.s @@ -16,6 +16,8 @@ __current_2bpp_palette:: ; void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t palette) __z88dk_callee __preserves_regs(iyh,iyl); _set_tile_2bpp_data:: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop de ; pop ret address pop hl @@ -28,8 +30,6 @@ _set_tile_2bpp_data:: ld bc, #.VDP_VRAM add hl, bc - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - VDP_WRITE_CMD h, l ex de, hl ; hl = ret diff --git a/gbdk-lib/libc/targets/z80/sms_set_native_data.s b/gbdk-lib/libc/targets/z80/sms_set_native_data.s @@ -6,6 +6,8 @@ ; void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); _set_native_tile_data:: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + pop de ; pop ret address pop hl @@ -18,8 +20,6 @@ _set_native_tile_data:: ld bc, #.VDP_VRAM add hl, bc - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - VDP_WRITE_CMD h, l pop bc diff --git a/gbdk-lib/libc/targets/z80/vmemcpy.s b/gbdk-lib/libc/targets/z80/vmemcpy.s @@ -7,11 +7,11 @@ ; void vmemcpy (unsigned int dst, const void *src, unsigned int size) __z88dk_callee __preserves_regs(iyh,iyl); _set_data:: _vmemcpy:: + DISABLE_VBLANK_COPY + pop de ; pop ret address pop hl ; dst - DISABLE_VBLANK_COPY - VDP_WRITE_CMD h, l pop hl ; src
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.