shithub: pokecrystal

Download patch

ref: 789ebc73042e07b5e50b3cc3c17ebd1df141f000
parent: bfe2f6d52e035ea03a372cabb18ba5cf57823bf9
author: pikalaxalt <[email protected]>
date: Fri May 27 06:41:59 EDT 2016

Port homecall macro

--- a/home.asm
+++ b/home.asm
@@ -386,28 +386,12 @@
 ; 0x3198
 
 PrintNum:: ; 3198
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(_PrintNum)
-	rst Bankswitch
-
-	call _PrintNum
-
-	pop af
-	rst Bankswitch
+	homecall _PrintNum
 	ret
 ; 31a4
 
 MobilePrintNum:: ; 31a4
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(_MobilePrintNum)
-	rst Bankswitch
-
-	call _MobilePrintNum
-
-	pop af
-	rst Bankswitch
+	homecall _MobilePrintNum
 	ret
 ; 31b0
 
@@ -737,10 +721,10 @@
 
 	ld d, HP_GREEN
 	ld a, e
-	cp 24
+	cp (50 * 48 / 100)
 	ret nc
 	inc d ; yellow
-	cp 10
+	cp (21 * 48 / 100)
 	ret nc
 	inc d ; red
 	ret
--- a/home/copy.asm
+++ b/home/copy.asm
@@ -6,13 +6,7 @@
 	bit 7, a
 	jp z, Copy2bpp
 
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(_Get2bpp)
-	rst Bankswitch
-	call _Get2bpp
-	pop af
-	rst Bankswitch
+	homecall _Get2bpp
 
 	ret
 ; ddc
@@ -22,13 +16,7 @@
 	bit 7, a
 	jp z, Copy1bpp
 
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(_Get1bpp)
-	rst Bankswitch
-	call _Get1bpp
-	pop af
-	rst Bankswitch
+	homecall _Get1bpp
 
 	ret
 ; def
--- a/home/handshake.asm
+++ b/home/handshake.asm
@@ -1,12 +1,5 @@
 PrinterReceive:: ; 2057
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(_PrinterReceive)
-	rst Bankswitch
-
-	call _PrinterReceive
-	pop af
-	rst Bankswitch
+	homecall _PrinterReceive
 
 	ret
 ; 2063
--- a/home/math.asm
+++ b/home/math.asm
@@ -59,15 +59,7 @@
 	push hl
 	push de
 	push bc
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(_Divide)
-	rst Bankswitch
-
-	call _Divide
-
-	pop af
-	rst Bankswitch
+	homecall _Divide
 	pop bc
 	pop de
 	pop hl
--- a/home/palettes.asm
+++ b/home/palettes.asm
@@ -341,25 +341,11 @@
 
 
 FarCallSwapTextboxPalettes:: ; db1
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(SwapTextboxPalettes)
-	rst Bankswitch
-	call SwapTextboxPalettes
-	pop af
-	rst Bankswitch
+	homecall SwapTextboxPalettes
 	ret
 ; dbd
 
 FarCallScrollBGMapPalettes:: ; dbd
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(ScrollBGMapPalettes)
-	rst Bankswitch
-
-	call ScrollBGMapPalettes
-
-	pop af
-	rst Bankswitch
+	homecall ScrollBGMapPalettes
 	ret
 ; dc9
--- a/home/sine.asm
+++ b/home/sine.asm
@@ -8,14 +8,6 @@
 
 	ld e, a
 
-	ld a, [hROMBank]
-	push af
-	ld a, BANK(_Sine)
-	rst Bankswitch
-
-	call _Sine
-
-	pop af
-	rst Bankswitch
+	homecall _Sine
 	ret
 ; 1b1e
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -2929,7 +2929,7 @@
 	ret
 ; f789
 
-UseItemText ; f789
+UseItemText: ; f789
 	ld hl, UsedItemText
 	call PrintText
 	call Play_SFX_FULL_HEAL
--- a/macros.asm
+++ b/macros.asm
@@ -302,3 +302,15 @@
 endr
 endm
 
+homecall: MACRO
+	ld a, [hROMBank]
+	push af
+	ld a, BANK(\1)
+	rst Bankswitch
+
+	call \1
+
+	pop af
+	rst Bankswitch
+ENDM
+