gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 728b58fcb0b148e64184c22aee4f5395d32429d1 parent 641d0e291d5b8ea7758cb33f12a74159509eafcb Author: Toxa <untoxa@mail.ru> Date: Sun, 22 Aug 2021 11:42:29 +0300 SMS/GG: fix vmemcpy() Diffstat:
| M | gbdk-lib/include/gb/gb.h | 10 | +++++++--- |
| M | gbdk-lib/include/sms/sms.h | 19 | ++++++++++++++----- |
| M | gbdk-lib/libc/targets/z80/putchar.s | 4 | ++-- |
| M | gbdk-lib/libc/targets/z80/scroll.s | 2 | +- |
| M | gbdk-lib/libc/targets/z80/vmemcpy.s | 16 | ++++++++-------- |
5 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -1225,16 +1225,20 @@ extern volatile struct OAM_item_t shadow_OAM[]; */ __REG _shadow_OAM_base; -/** Disable OAM DMA copy each VBlank -*/ #define DISABLE_OAM_DMA \ _shadow_OAM_base = 0 -/** Enable OAM DMA copy each VBlank and set it to transfer default shadow_OAM array +/** Disable OAM DMA copy each VBlank */ +#define DISABLE_VBL_TRANSFER DISABLE_OAM_DMA + #define ENABLE_OAM_DMA \ _shadow_OAM_base = (uint8_t)((uint16_t)&shadow_OAM >> 8) +/** Enable OAM DMA copy each VBlank and set it to transfer default shadow_OAM array +*/ +#define ENABLE_VBL_TRANSFER ENABLE_OAM_DMA + /** Enable OAM DMA copy each VBlank and set it to transfer any 256-byte aligned array */ inline void SET_SHADOW_OAM_ADDRESS(void * address) { diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -351,6 +351,15 @@ void set_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_cal #define set_sprite_2bpp_data(start,ntiles,src) set_tile_2bpp_data((uint8_t)(start)+0x100,(uint8_t)(ntiles),src) void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); +/** Copies arbitrary data to an address in VRAM + + @param dst destination VRAM Address + @param src Pointer to source buffer + @param size Number of bytes to copy + + Copies __size__ bytes from a buffer at _src__ to VRAM starting at __dst__. +*/ +void set_data(uint16_t dst, const void *src, uint16_t size) __z88dk_callee __preserves_regs(iyh, iyl); void vmemcpy(uint16_t dst, const void *src, uint16_t size) __z88dk_callee __preserves_regs(iyh, iyl); void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl); @@ -370,17 +379,17 @@ extern volatile uint8_t _shadow_OAM_base; */ extern volatile uint8_t _shadow_OAM_OFF; -/** Disable OAM copy each VBlank (note: there is no real DMA, this name is for compatibility with GB library) +/** Disable shadow OAM to VRAM copy on each VBlank */ -#define DISABLE_OAM_DMA \ +#define DISABLE_VBL_TRANSFER \ _shadow_OAM_OFF = 1 -/** Enable OAM DMA copy each VBlank and set it to transfer default shadow_OAM array +/** Enable shadow OAM to VRAM copy on each VBlank */ -#define ENABLE_OAM_DMA \ +#define ENABLE_VBL_TRANSFER \ _shadow_OAM_OFF = 0 -/** Enable OAM DMA copy each VBlank and set it to transfer any 256-byte aligned array +/** Sets address of 256-byte aligned array of shadow OAM to be transferred on each VBlank */ inline void SET_SHADOW_OAM_ADDRESS(void * address) { _shadow_OAM_base = (uint8_t)((uint16_t)address >> 8); diff --git a/gbdk-lib/libc/targets/z80/putchar.s b/gbdk-lib/libc/targets/z80/putchar.s @@ -4,7 +4,7 @@ .module putchar .globl font_current, font_set, font_load_ibm - .globl _scroll_viewport + .globl .scroll_viewport ; Structure offsets sfont_handle_sizeof = 3 @@ -118,7 +118,7 @@ _putchar:: ld a, #(.SCREEN_Y_OFS + .SCREEN_HEIGHT - 1) ld (.cury), a - call _scroll_viewport + call .scroll_viewport ret 3$: ld (.cury), a diff --git a/gbdk-lib/libc/targets/z80/scroll.s b/gbdk-lib/libc/targets/z80/scroll.s @@ -7,7 +7,7 @@ .area _HOME -_scroll_viewport:: +.scroll_viewport:: DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT ld hl, #(.VDP_TILEMAP + ((.SCREEN_Y_OFS + 1) * .VDP_MAP_WIDTH * 2)) diff --git a/gbdk-lib/libc/targets/z80/vmemcpy.s b/gbdk-lib/libc/targets/z80/vmemcpy.s @@ -5,6 +5,7 @@ .area _HOME ; void vmemcpy (unsigned int dst, const void *src, unsigned int size) __z88dk_callee __preserves_regs(iyh,iyl); +_set_data:: _vmemcpy:: pop de ; pop ret address pop hl ; dst @@ -14,27 +15,26 @@ _vmemcpy:: pop hl ; src pop bc ; size - dec bc - ld a, b ; HI(size) ld b, c ; LO(size) - inc a - ld c, #.VDP_DATA rlc b rrc b ; check b is zero jr z, 2$ - - inc b - 1$: outi jp nz, 1$ ; 10 = 26 (VRAM safe) 2$: + inc a + jp 4$ +3$: + outi + jp nz, 3$ ; 10 = 26 (VRAM safe) +4$: dec a - jp nz, 1$ + jp nz, 3$ ld h, d ld l, e
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.