gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/sm83/get_addr.s
1 .include "global.s"
2
3 .area _CODE
4
5 _get_win_xy_addr::
6 and #0x1f
7 ld d, a
8 ldh a, (.LCDC)
9 and #LCDCF_WIN9C00
10 jr z, .is98
11 jr .is9c
12
13 _get_bkg_xy_addr::
14 and #0x1f
15 ld d, a
16 ldh a, (.LCDC)
17 and #LCDCF_BG9C00
18 jr nz, .is9c
19 .is98:
20 ld b, #0x98 ; B = origin
21 jr .calculate_ofs
22 .is9c:
23 ld b, #0x9C ; B = origin
24
25 .calculate_ofs:
26 ld a, e
27 swap a
28 rlca
29 ld c, a
30 and #0x03
31 or b
32 ld b, a
33 ld a, #0xE0
34 and c
35 or d
36 ld c, a ; BC = (B << 8) + 0x20 * Y + X
37
38 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.