Created
April 10, 2020 08:00
-
-
Save ISSOtm/794d28f3f59645e7966b7dc8bc2afc14 to your computer and use it in GitHub Desktop.
Sample from a VBlank handler to transfer tiles using "popslide"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
push de | |
ld [wSP], sp | |
ldh a, [hVRAMCopySrc] | |
ld l, a | |
ldh a, [hVRAMCopySrc+1] | |
ld h, a | |
ld sp, hl | |
ldh a, [hVRAMCopyDest] | |
ld l, a | |
ldh a, [hVRAMCopyDest+1] | |
ld h, a | |
ld a, c | |
cp 14 | |
jr c, .copyTile | |
ld c, 14 | |
.copyTile | |
REPT 16 / 2 ; Copy 1 tile (16 bytes), 2 bytes per "block" | |
pop de | |
ld a, e | |
ld [hli], a | |
ld a, d | |
ld [hli], a | |
ENDR | |
dec c | |
jr nz, .copyTile | |
ld sp, wSP | |
pop hl | |
ld sp, hl | |
pop de | |
jr c, .finishedVRAMTransfer | |
ld hl, hVRAMCopyNbTiles | |
ld a, [hl] | |
sub 14 | |
ld [hli], a | |
assert hVRAMCopyNbTiles + 1 == hVRAMCopyDest | |
ld a, [hl] | |
add a, 14 * 16 | |
ld [hli], a | |
jr nc, .noCarry | |
inc [hl] | |
.noCarry | |
inc hl | |
assert hVRAMCopyDest + 2 == hVRAMCopySrc | |
ld a, [hl] | |
add a, 14 * 16 | |
ld [hli], a | |
jr nc, .doneVRAMTransfer | |
inc [hl] | |
.doneVRAMTransfer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment