summaryrefslogtreecommitdiff
path: root/home/predef.asm
diff options
context:
space:
mode:
authorU-Fish-PC\Daniel <corrnondacqb@yahoo.com>2014-06-09 15:10:49 -0400
committerU-Fish-PC\Daniel <corrnondacqb@yahoo.com>2014-06-09 15:10:49 -0400
commitd266f788b4ba251c5a41f47745c941d81e5d7d88 (patch)
tree004892d1cc02111732dcb81ef9734ab13ab49ef5 /home/predef.asm
parent683a62cc1cb7d07b4c88eeec9333c415da8f0bdc (diff)
parentfc123e360b147221b5b44d265cdf38feabe99bbe (diff)
Merge branch 'master' of https://github.com/yenatch/pokered
Diffstat (limited to 'home/predef.asm')
-rw-r--r--home/predef.asm50
1 files changed, 50 insertions, 0 deletions
diff --git a/home/predef.asm b/home/predef.asm
new file mode 100644
index 00000000..1777d09f
--- /dev/null
+++ b/home/predef.asm
@@ -0,0 +1,50 @@
+Predef::
+; Call predefined function a.
+; To preserve other registers, have the
+; destination call GetPredefRegisters.
+
+ ; Save the predef id for GetPredefPointer.
+ ld [wPredefID], a
+
+ ; A hack for LoadDestinationWarpPosition.
+ ; See Func_c754 (predef $19).
+ ld a, [H_LOADEDROMBANK]
+ ld [wPredefParentBank], a
+
+ push af
+ ld a, BANK(GetPredefPointer)
+ ld [H_LOADEDROMBANK], a
+ ld [$2000], a
+
+ call GetPredefPointer
+
+ ld a, [wPredefBank]
+ ld [H_LOADEDROMBANK], a
+ ld [$2000], a
+
+ ld de, .done
+ push de
+ jp [hl]
+.done
+
+ pop af
+ ld [H_LOADEDROMBANK], a
+ ld [$2000], a
+ ret
+
+GetPredefRegisters::
+; Restore the contents of register pairs
+; when GetPredefPointer was called.
+ ld a, [wPredefRegisters + 0]
+ ld h, a
+ ld a, [wPredefRegisters + 1]
+ ld l, a
+ ld a, [wPredefRegisters + 2]
+ ld d, a
+ ld a, [wPredefRegisters + 3]
+ ld e, a
+ ld a, [wPredefRegisters + 4]
+ ld b, a
+ ld a, [wPredefRegisters + 5]
+ ld c, a
+ ret