diff options
Diffstat (limited to 'src/home/copy.asm')
-rw-r--r-- | src/home/copy.asm | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/home/copy.asm b/src/home/copy.asm new file mode 100644 index 0000000..8b21f90 --- /dev/null +++ b/src/home/copy.asm @@ -0,0 +1,57 @@ +; copy c bytes of data from hl to de, b times. +; used to copy gfx data with c = TILE_SIZE +CopyGfxData: + ld a, [wLCDC] + rla + jr nc, .next_tile +.hblank_copy + push bc + push hl + push de + ld b, c + call JPHblankCopyDataHLtoDE + ld b, $0 + pop hl + add hl, bc + ld e, l + ld d, h + pop hl + add hl, bc + pop bc + dec b + jr nz, .hblank_copy + ret +.next_tile + push bc +.copy_tile + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .copy_tile + pop bc + dec b + jr nz, .next_tile + ret + +; copy bc bytes from hl to de. preserves all registers except af +CopyDataHLtoDE_SaveRegisters: + push hl + push de + push bc + call CopyDataHLtoDE + pop bc + pop de + pop hl + ret + +; copy bc bytes from hl to de +CopyDataHLtoDE: + ld a, [hli] + ld [de], a + inc de + dec bc + ld a, c + or b + jr nz, CopyDataHLtoDE + ret |