set_data.s (1159B)
1 .include "global.s" 2 3 .area _HOME 4 5_set_tile_data:: 6 ldhl sp, #6 7 ld d,(hl) 8 jr .copy_tiles 9_set_bkg_data:: 10_set_win_data:: 11 ld d, #0x90 12 ldh a, (.LCDC) 13 and #LCDCF_BG8000 14 jr z, .copy_tiles 15_set_sprite_data:: 16 ld d, #0x80 17.copy_tiles: 18 push bc 19 ldhl sp, #4 20 ld a, (hl+) ; ID of 1st tile 21 ld e, a 22 ld a, (hl+) ; Nb of tiles 23 ld c, a 24 ld a, (hl+) ; Src ptr 25 ld h, (hl) 26 ld l, a 27 28 ; Compute dest ptr 29 swap e ; *16 (size of a tile) 30 ld a, e 31 and #0x0F ; Get high bits 32 add d ; Add base offset of target tile "block" 33 ld d, a 34 ld a, e 35 and #0xF0 ; Get low bits only 36 ld e, a 372$: 38 ; Wrap from past $97FF to $8800 onwards 39 ; This can be reduced to "bit 4 must be clear if bit 3 is set" 40 bit 3, d 41 jr z, 1$ 42 res 4, d 431$: 44 ld b, #16 453$: 46 WAIT_STAT 47 ld a, (hl+) 48 ld (de), a 49 inc de 50 51 dec b 52 jr nz, 3$ 53 54 dec c 55 jr nz, 2$ 56 57 pop bc 58 ret