Use LOAD/ENDL for OAM DMA code in HRAM (requires rgbds 0.4.1)

This commit is contained in:
Rangi
2020-07-21 19:43:56 -04:00
parent d96f914315
commit bb25c1074c
7 changed files with 26 additions and 20 deletions

View File

@@ -1,21 +1,28 @@
WriteOAMDMACodeToHRAM::
ld c, LOW(hTransferVirtualOAM)
ld b, .PushOAMEnd - .PushOAM
ld hl, .PushOAM
.loop
ld b, OAMDMACodeEnd - OAMDMACode
ld hl, OAMDMACode
.copy
ld a, [hli]
ldh [c], a
inc c
dec b
jr nz, .loop
jr nz, .copy
ret
.PushOAM:
OAMDMACode:
; This code is defined in ROM, but
; copied to and called from HRAM.
LOAD "OAM DMA", HRAM
hTransferVirtualOAM::
; initiate DMA
ld a, HIGH(wVirtualOAM)
ldh [rDMA], a
; wait for DMA to finish
ld a, NUM_SPRITE_OAM_STRUCTS
.pushoam_loop
.wait
dec a
jr nz, .pushoam_loop
jr nz, .wait
ret
.PushOAMEnd
ENDL
OAMDMACodeEnd: