summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-02-23 20:20:04 -0500
committeryenatch <yenatch@gmail.com>2013-02-24 04:17:58 -0500
commit78e0e17e53635f35a0ce1416b700696077287269 (patch)
tree554629e4446ae799cdc541a2f7b5c98e4861c7a2
parent8bbfa54059a3d4a242ff530e87c034ec48f5f4eb (diff)
finally disassemble FarCall (rst $8)
-rw-r--r--main.asm40
1 files changed, 38 insertions, 2 deletions
diff --git a/main.asm b/main.asm
index 75a280eeb..e54bd8bee 100644
--- a/main.asm
+++ b/main.asm
@@ -4,7 +4,7 @@ SECTION "rst0",HOME[$0]
jp Start
SECTION "rst8",HOME[$8] ; FarCall
- jp $2d63
+ jp FarJpHl
SECTION "rst10",HOME[$10] ; Bankswitch
ld [$ff9d], a
@@ -2355,7 +2355,43 @@ GetWorldMapLocation: ; 0x2caf
ret
; 0x2cbd
-INCBIN "baserom.gbc",$2cbd,$2d83-$2cbd
+INCBIN "baserom.gbc",$2cbd,$2d63-$2cbd
+
+FarJpHl: ; 2d63
+; Jump to a:hl.
+; Preserves all registers besides a.
+
+; Switch to the new bank.
+ ld [$ff8b], a
+ ld a, [$ff9d]
+ push af
+ ld a, [$ff8b]
+ rst Bankswitch
+
+ call .hl
+
+; We want to retain the contents of f.
+; To do this, we can pop to bc instead of af.
+
+ ld a, b
+ ld [$cfb9], a
+ ld a, c
+ ld [$cfba], a
+
+; Restore the working bank.
+ pop bc
+ ld a, b
+ rst Bankswitch
+
+ ld a, [$cfb9]
+ ld b, a
+ ld a, [$cfba]
+ ld c, a
+ ret
+.hl
+ jp [hl]
+; 2d83
+
Predef: ; 2d83
; call a function from given id a