aboutsummaryrefslogtreecommitdiffstats
path: root/engine/gfx/oam_dma.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
committerdannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
commit5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch)
treedde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /engine/gfx/oam_dma.asm
parentMerge pull request #55 from Deokishisu/patch-1 (diff)
downloadpokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.gz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.xz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.zip
Sync with pokered
Diffstat (limited to 'engine/gfx/oam_dma.asm')
-rw-r--r--engine/gfx/oam_dma.asm28
1 files changed, 28 insertions, 0 deletions
diff --git a/engine/gfx/oam_dma.asm b/engine/gfx/oam_dma.asm
new file mode 100644
index 00000000..fe93e90d
--- /dev/null
+++ b/engine/gfx/oam_dma.asm
@@ -0,0 +1,28 @@
+WriteDMACodeToHRAM::
+; Since no other memory is available during OAM DMA,
+; DMARoutine is copied to HRAM and executed there.
+ ld c, LOW(hDMARoutine)
+ ld b, DMARoutineEnd - DMARoutine
+ ld hl, DMARoutine
+.copy
+ ld a, [hli]
+ ldh [c], a
+ inc c
+ dec b
+ jr nz, .copy
+ ret
+
+DMARoutine:
+LOAD "OAM DMA", HRAM
+hDMARoutine::
+ ; initiate DMA
+ ld a, HIGH(wOAMBuffer)
+ ldh [rDMA], a
+ ; wait for DMA to finish
+ ld a, $28
+.wait
+ dec a
+ jr nz, .wait
+ ret
+ENDL
+DMARoutineEnd: