gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit ad3742249666d6cbb87a94b2b9affcc53af799a8 parent 4e1d28757412dcf837ede001cfb25dd50aecffd3 Author: Toxa <untoxa@mail.ru> Date: Mon, 16 Mar 2026 16:18:31 +0300 SMS/GG/MSX: improve get_bkg_xy_addr() performance Diffstat:
| M | gbdk-lib/include/msx/msx.h | 2 | +- |
| M | gbdk-lib/include/sms/sms.h | 2 | +- |
| M | gbdk-lib/libc/targets/z80/coords_to_address.s | 17 | ++++++----------- |
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/gbdk-lib/include/msx/msx.h b/gbdk-lib/include/msx/msx.h @@ -834,7 +834,7 @@ uint8_t * set_tile_xy(uint8_t x, uint8_t y, uint8_t t) Z88DK_CALLEE PRESERVES_RE /** * Get address of X,Y tile of background map */ -uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl); +uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) PRESERVES_REGS(iyh, iyl); #define get_win_xy_addr get_bkg_xy_addr #endif /* _MSX_H */ diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -920,7 +920,7 @@ inline uint8_t * set_attribute_xy(uint8_t x, uint8_t y, uint8_t a) Z88DK_CALLEE /** * Get address of X,Y tile of background map */ -uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl); +uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) PRESERVES_REGS(iyh, iyl); #define get_win_xy_addr get_bkg_xy_addr #endif /* _SMS_H */ diff --git a/gbdk-lib/libc/targets/z80/coords_to_address.s b/gbdk-lib/libc/targets/z80/coords_to_address.s @@ -5,6 +5,12 @@ .area _HOME +; uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) __preserves_regs(iyh, iyl); + +_get_bkg_xy_addr:: + ld d, l + ld e, a + ; translate coords in DE into address in DE .coords_to_address:: ld a, (_shadow_VDP_R2) @@ -41,13 +47,3 @@ ld d, b ; dest DE = BC + ((0x20 * Y) * 2) + (X * 2) ret - -; uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) __z88dk_callee __preserves_regs(iyh, iyl); - -_get_bkg_xy_addr:: - pop hl - ex (sp), hl - ex de, hl - call .coords_to_address - ex de, hl - ret -
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.