gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 0f5160316f8966d01030083b2ff5f95e69c0d73a parent ae027eea57e978cba1e36d76b1a4576e0069f748 Author: Toxa <untoxa@mail.ru> Date: Sun, 23 Nov 2025 02:11:19 +0300 GB: refactor get_bkg_xy_addr()/get_win_xy_addr() Diffstat:
| M | gbdk-lib/include/gb/gb.h | 4 | ++-- |
| M | gbdk-lib/libc/targets/sm83/get_addr.s | 27 | +++++++++++++-------------- |
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -995,7 +995,7 @@ uint8_t get_vram_byte(uint8_t * addr) PRESERVES_REGS(b, c, h, l); /** * Get address of X,Y tile of background map */ -uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b, c); +uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) PRESERVES_REGS(h, l); #define COMPAT_PALETTE(C0,C1,C2,C3) ((uint8_t)(((C3) << 6) | ((C2) << 4) | ((C1) << 2) | (C0))) @@ -1480,7 +1480,7 @@ inline void scroll_bkg(int8_t x, int8_t y) { /** * Get address of X,Y tile of window map */ -uint8_t * get_win_xy_addr(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b, c); +uint8_t * get_win_xy_addr(uint8_t x, uint8_t y) PRESERVES_REGS(h, l); /** Sets VRAM Tile Pattern data for the Window / Background diff --git a/gbdk-lib/libc/targets/sm83/get_addr.s b/gbdk-lib/libc/targets/sm83/get_addr.s @@ -3,37 +3,36 @@ .area _CODE _get_win_xy_addr:: + and #0x1f + ld d, a ldh a, (.LCDC) and #LCDCF_WIN9C00 jr z, .is98 jr .is9c _get_bkg_xy_addr:: + and #0x1f + ld d, a ldh a, (.LCDC) and #LCDCF_BG9C00 jr nz, .is9c .is98: - ld d, #0x98 ; DE = origin + ld b, #0x98 ; B = origin jr .calculate_ofs .is9c: - ld d, #0x9C ; DE = origin + ld b, #0x9C ; B = origin .calculate_ofs: - ldhl sp, #3 - - ld a, (hl-) - ld l, (hl) - - ld e, d + ld a, e swap a rlca - ld h, a + ld c, a and #0x03 - add e - ld d, a + or b + ld b, a ld a, #0xE0 - and h - add l - ld e, a ; dest DE = BASE + 0x20 * Y + X + and c + or d + ld c, a ; BC = (B << 8) + 0x20 * Y + X 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.