summaryrefslogtreecommitdiff
path: root/home/farcall.asm
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-09-09 22:44:48 -0400
committeryenatch <yenatch@gmail.com>2013-09-09 22:44:48 -0400
commit84a9b3907b9db08ee38e873554d8a6b4ac1b72b4 (patch)
treee804b9ed15832481d632904f42355743d9232515 /home/farcall.asm
parent6439706943b53ad756d481dea683fa8ee97f4981 (diff)
rename common/ to home/
Diffstat (limited to 'home/farcall.asm')
-rw-r--r--home/farcall.asm55
1 files changed, 55 insertions, 0 deletions
diff --git a/home/farcall.asm b/home/farcall.asm
new file mode 100644
index 000000000..bdee3bf38
--- /dev/null
+++ b/home/farcall.asm
@@ -0,0 +1,55 @@
+FarCall_de: ; 2d54
+; Call a:de.
+; Preserves other registers.
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+ call .de
+ jr ReturnFarCall
+
+.de
+ push de
+ ret
+; 2d63
+
+
+FarCall_hl: ; 2d63
+; Call a:hl.
+; Preserves other registers.
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+ call Function2d82
+; 2d6e
+
+ReturnFarCall: ; 2d6e
+; 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
+; 2d82
+
+Function2d82: ; 2d82
+ jp [hl]
+; 2d83
+