gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit f27a0d76062463bbf86e812d06618bf207a3dd0c parent 1b5f9f1255849e36b52b3d60787b171507d77f39 Author: Toxa <untoxa@mail.ru> Date: Thu, 26 Aug 2021 14:39:41 +0300 SMS/GG: optimize set_tile_2bpp_data(); set_*_2bpp_data takes into account corner case for 256 tiles Diffstat:
| M | gbdk-lib/include/sms/sms.h | 4 | ++-- |
| M | gbdk-lib/libc/targets/z80/set_2bpp_data.s | 40 | +++++++++++++++++++++++++--------------- |
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -356,10 +356,10 @@ inline void set_2bpp_palette(uint16_t palette) { } void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t palette) __z88dk_callee __preserves_regs(iyh,iyl); inline void set_bkg_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) { - set_tile_2bpp_data(start, ntiles, src, _current_2bpp_palette); + set_tile_2bpp_data(start, (ntiles)?ntiles:256, src, _current_2bpp_palette); } inline void set_sprite_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) { - set_tile_2bpp_data((uint8_t)(start) + 0x100u, ntiles, src, _current_2bpp_palette); + set_tile_2bpp_data((uint8_t)(start) + 0x100u, (ntiles)?ntiles:256, src, _current_2bpp_palette); } /** Copies arbitrary data to an address in VRAM diff --git a/gbdk-lib/libc/targets/z80/set_2bpp_data.s b/gbdk-lib/libc/targets/z80/set_2bpp_data.s @@ -70,22 +70,33 @@ _set_tile_2bpp_data:: push de ; save palette - or a - jr z, 4$ - -3$: - srl d - rr e - srl d - rr e - srl d - rr e - srl d - rr e + inc a dec a - jr nz, 3$ -4$: + jr nz, 10$ + ; zero ld a, e + jr 13$ +10$: + dec a + jr nz, 11$ + ; one + ld a, e + jr 14$ +11$: + dec a + jr nz, 12$ + ; two + ld a, d + jr 13$ +12$: + ;three + ld a, d +14$: + rra + rra + rra + rra +13$: and #0x0F rra @@ -116,7 +127,6 @@ _set_tile_2bpp_data:: dec ixh jr nz, 6$ - 2$: ex (sp), hl
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.