diff options
author | Daniel Harding <33dannye@gmail.com> | 2021-09-19 00:21:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 00:21:14 -0500 |
commit | df67aac83b466dadf5f74c881bf84dd9ef19bdfc (patch) | |
tree | 47501aced2d256052b8f78bc97328d5af5703add /src/home/copy.asm | |
parent | e4bce9b7ee5e89f8edfd921de2379f0fa06af206 (diff) | |
parent | 8dee6b7a11e85d6d4b9f8ec9fb9d53a499fd37dc (diff) |
Merge pull request #110 from ElectroDeoxys/master
Split Home bank
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 |