set_tile.s (1136B)
1.include "global.s" 2 3.area _CODE 4 5_set_vram_byte:: 6 ; de = addr, hl = &t 7 ldhl sp,#2 8 ld a,(hl+) 9 ld e, a 10 ld a,(hl+) 11 ld d, a 12 13 WAIT_STAT 14 15 ; Write tile 16 ld a,(hl) 17 ld (de),a 18 ret 19 20_set_win_tile_xy:: 21 ldh a,(.LCDC) 22 and #LCDCF_WIN9C00 23 jr z,.is98 24 jr .is9c 25_set_bkg_tile_xy:: 26 ldh a,(.LCDC) 27 and #LCDCF_BG9C00 28 jr nz,.is9c 29.is98: 30 ld d,#0x98 ; DE = origin 31 jr .set_tile_xy 32.is9c: 33 ld d,#0x9C ; DE = origin 34 35.set_tile_xy: 36 push bc 37 ldhl sp,#4 38 39 ld a, (hl+) 40 ld b, a 41 ld a, (hl+) 42 43 ld e, d 44 swap a 45 rlca 46 ld c, a 47 and #0x03 48 add e 49 ld d, a 50 ld a, #0xE0 51 and c 52 add b 53 ld e, a ; dest DE = BASE + 0x20 * Y + X 54 55 WAIT_STAT 56 ld a, (hl) 57 ld (de), a 58 59 pop bc 60 ret