shithub: pokecrystal

Download patch

ref: 78e0e17e53635f35a0ce1416b700696077287269
parent: 8bbfa54059a3d4a242ff530e87c034ec48f5f4eb
author: yenatch <[email protected]>
date: Sat Feb 23 15:20:04 EST 2013

finally disassemble FarCall (rst $8)

--- a/main.asm
+++ b/main.asm
@@ -4,7 +4,7 @@
 	jp Start
 
 SECTION "rst8",HOME[$8] ; FarCall
-	jp $2d63
+	jp FarJpHl
 
 SECTION "rst10",HOME[$10] ; Bankswitch
 	ld [$ff9d], a
@@ -2355,7 +2355,43 @@
 	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