get_addr.s (761B)
1.include "global.s" 2 3.area _CODE 4 5_get_win_xy_addr:: 6 ldh a, (.LCDC) 7 and #LCDCF_WIN9C00 8 jr z, .is98 9 jr .is9c 10 11_get_bkg_xy_addr:: 12 ldh a, (.LCDC) 13 and #LCDCF_BG9C00 14 jr nz, .is9c 15.is98: 16 ld d, #0x98 ; DE = origin 17 jr .calculate_ofs 18.is9c: 19 ld d, #0x9C ; DE = origin 20 21.calculate_ofs: 22 ldhl sp, #3 23 24 ld a, (hl-) 25 ld l, (hl) 26 27 ld e, d 28 swap a 29 rlca 30 ld h, a 31 and #0x03 32 add e 33 ld d, a 34 ld a, #0xE0 35 and h 36 add l 37 ld e, a ; dest DE = BASE + 0x20 * Y + X 38 39 ret