gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/sm83/set_tile.s
1 .include "global.s"
2
3 .area _CODE
4
5 _set_vram_byte::
6 WAIT_STAT_HL
7
8 ; Write tile
9 ld (de),a
10 ret
11
12 _set_win_tile_xy::
13 ld d, a
14 ldh a, (.LCDC)
15 and #LCDCF_WIN9C00
16 jr z, .is98
17 jr .is9c
18
19 _set_bkg_tile_xy::
20 ld d, a
21 ldh a, (.LCDC)
22 and #LCDCF_BG9C00
23 jr nz, .is9c
24 .is98:
25 ld b, #0x98
26 jr .set_tile_xy
27 .is9c:
28 ld b,#0x9C
29
30 .set_tile_xy: ; DE = XY; B = origin
31 ld l, #0x1f
32 ld a, d
33 and l
34 ld d, a
35 ld a, e
36 and l
37
38 ld c, b
39 swap a
40 rlca
41 ld e, a
42 and #0x03
43 add c
44 ld b, a
45 ld a, #0xE0
46 and e
47 add d
48 ld c, a ; dest BC = (BASE << 8) + 0x20 * Y + X
49
50 ldhl sp, #2
51 WAIT_STAT
52 ld a, (hl)
53 ld (bc), a ; return BC as result
54
55 pop hl
56 inc sp
57 jp (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.