shithub: pokered

Download patch

ref: d10108a066c102bf2d167ac656d79308e41f304e
parent: 94dc6955431171d4dba5833e5784e102dd045b49
author: yenatch <yenatch@gmail.com>
date: Mon Jun 16 09:25:46 EDT 2014

Use macros to define predefs.

--- a/engine/battle/4.asm
+++ b/engine/battle/4.asm
@@ -15,7 +15,7 @@
 	inc b
 	ret
 
-Func_128ef: ; 128ef (4:68ef)
+DrawHP: ; 128ef (4:68ef)
 	call GetPredefRegisters
 	ld a, $1
 	jr asm_128fb
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6661,7 +6661,7 @@
 PlayMoveAnimation: ; 3ef07 (f:6f07)
 	ld [W_ANIMATIONID],a
 	call Delay3
-	PREDEF_JUMP MoveAnimationPredef ; predef 8
+	predef_jump MoveAnimation
 
 InitBattle: ; 3ef12 (f:6f12)
 	ld a, [W_CUROPPONENT] ; wd059
--- a/engine/hp_bar.asm
+++ b/engine/hp_bar.asm
@@ -46,6 +46,7 @@
 
 ; predef $48
 UpdateHPBar: ; fa1d (3:7a1d)
+UpdateHPBar2:
 	push hl
 	ld hl, wHPBarOldHP
 	ld a, [hli]
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -59,7 +59,7 @@
 	call PlaceString ; "TYPE1/"
 	FuncCoord 11,3
 	ld hl, Coord
-	PREDEF DrawHPBarPredef ; predef $5f
+	predef DrawHP ; predef $5f
 	ld hl, wcf25
 	call GetHealthBarColor
 	ld b, $3
--- a/engine/overworld/pokecenter.asm
+++ b/engine/overworld/pokecenter.asm
@@ -21,7 +21,7 @@
 	ld a, $18
 	ld [wSpriteStateData1 + $12], a ; make the nurse turn to face the machine
 	call Delay3
-	PREDEF HealPartyPredef
+	predef HealParty
 	callba AnimateHealingMachine ; do the healing machine animation
 	xor a
 	ld [wMusicHeaderPointer], a
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -52,105 +52,102 @@
 PredefPointers: ; 4fe79 (13:7e79)
 ; these are pointers to ASM routines.
 ; they appear to be used in overworld map scripts.
-	dbw BANK(Func_3cd60),Func_3cd60
-	dbw BANK(Func_3f0c6),Func_3f0c6
-	dbw BANK(Func_3f073),Func_3f073
-	dbw BANK(ScaleSpriteByTwo), ScaleSpriteByTwo
-	dbw BANK(LoadMonBackPic), LoadMonBackPic
-	dbw BANK(Func_79aba),Func_79aba
-	dbw BANK(Func_f132),Func_f132
-HealPartyPredef: ; 4fe8e (13:7e8e)
-	dbw BANK(HealParty),HealParty
-MoveAnimationPredef: ; 4fe91 (13:7e91)
-	dbw BANK(MoveAnimation),MoveAnimation; 08 play move animation
-	dbw BANK(DivideBCDPredef),DivideBCDPredef
-	dbw BANK(DivideBCDPredef),DivideBCDPredef
-	dbw BANK(AddBCDPredef), AddBCDPredef
-	dbw BANK(SubBCDPredef), SubBCDPredef
-	dbw BANK(DivideBCDPredef),DivideBCDPredef
-	dbw BANK(DivideBCDPredef),DivideBCDPredef
-	dbw BANK(InitPlayerData), InitPlayerData
-	dbw BANK(FlagActionPredef),FlagActionPredef
-	dbw BANK(HideObject), HideObject
-	dbw BANK(IsObjectHidden), IsObjectHidden
-	dbw BANK(Func_c69c),Func_c69c
-	dbw BANK(AnyPartyAlive), AnyPartyAlive
-	dbw BANK(ShowObject), ShowObject
-	dbw BANK(ShowObject), ShowObject
-	dbw BANK(Func_ee9e),Func_ee9e
-	dbw BANK(InitPlayerData), InitPlayerData
-	dbw BANK(Func_c754),Func_c754
-	dbw BANK(Func_3af5b),Func_3af5b
-	dbw BANK(LearnMove),LearnMove
-	dbw BANK(IsItemInBag_),IsItemInBag_ ; 1C, used in Pokémon Tower
+	add_predef Func_3cd60
+	add_predef Func_3f0c6
+	add_predef Func_3f073
+	add_predef ScaleSpriteByTwo
+	add_predef LoadMonBackPic
+	add_predef Func_79aba
+	add_predef Func_f132
+	add_predef HealParty
+	add_predef MoveAnimation; 08 play move animation
+	add_predef DivideBCDPredef
+	add_predef DivideBCDPredef2
+	add_predef AddBCDPredef
+	add_predef SubBCDPredef
+	add_predef DivideBCDPredef3
+	add_predef DivideBCDPredef4
+	add_predef InitPlayerData
+	add_predef FlagActionPredef
+	add_predef HideObject
+	add_predef IsObjectHidden
+	add_predef Func_c69c
+	add_predef AnyPartyAlive
+	add_predef ShowObject
+	add_predef ShowObject2
+	add_predef Func_ee9e
+	add_predef InitPlayerData2
+	add_predef Func_c754
+	add_predef Func_3af5b
+	add_predef LearnMove
+	add_predef IsItemInBag_ ; 1C, used in Pokémon Tower
 	dbw $03,Func_3eb5 ; for these two, the bank number is actually 0
 	dbw $03,GiveItem
-	dbw BANK(Func_480eb),Func_480eb
-	dbw BANK(Func_f8ba),Func_f8ba
-	dbw BANK(Func_480ff),Func_480ff
-	dbw BANK(Func_f929),Func_f929
-	dbw BANK(Func_f9a0),Func_f9a0
-	dbw BANK(Func_48125),Func_48125
-	dbw BANK(UpdateHPBar),UpdateHPBar
-	dbw BANK(HPBarLength), HPBarLength
-	dbw BANK(Func_5ab0),Func_5ab0
-	dbw BANK(Func_3ed02),Func_3ed02
-	dbw BANK(ShowPokedexMenu), ShowPokedexMenu
-	dbw BANK(Func_3ad1c),Func_3ad1c
-	dbw BANK(SaveSAVtoSRAM0),SaveSAVtoSRAM0
-	dbw BANK(InitOpponent),InitOpponent
-	dbw BANK(Func_5a5f),Func_5a5f
-	dbw BANK(DrawBadges), DrawBadges
-	dbw BANK(Func_410f3),Func_410f3
-	dbw BANK(BattleTransition),BattleTransition
-	dbw BANK(Func_79dda),Func_79dda
-	dbw BANK(PlayIntro),PlayIntro
-	dbw BANK(Func_79869),Func_79869
-	dbw BANK(FlashScreen), FlashScreen
-	dbw BANK(Func_c586),Func_c586
-	dbw BANK(StatusScreen),StatusScreen ; 37 0x12953
-	dbw BANK(StatusScreen2),StatusScreen2 ; 38
-	dbw BANK(Func_410e2),Func_410e2
-	dbw BANK(TrainerEngage), TrainerEngage
-	dbw BANK(IndexToPokedex),IndexToPokedex
-	dbw BANK(Predef3B),Predef3B; 3B display pic?
-	dbw BANK(UsedCut),UsedCut
-	dbw BANK(ShowPokedexData),ShowPokedexData
-	dbw BANK(WriteMonMoves),WriteMonMoves
-	dbw BANK(SaveSAV),SaveSAV
-	dbw BANK(LoadSGB), LoadSGB
-	dbw BANK(Func_f113),Func_f113
-	dbw BANK(SetPartyMonTypes),SetPartyMonTypes
-	dbw BANK(CanLearnTM), CanLearnTM
-	dbw BANK(TMToMove),TMToMove
-	dbw BANK(Func_71ddf),Func_71ddf
-	dbw BANK(StarterDex), StarterDex ; 46
-	dbw BANK(_AddPartyMon), _AddPartyMon
-	dbw BANK(UpdateHPBar),UpdateHPBar
-	dbw BANK(Func_3cdec),Func_3cdec
-	dbw BANK(LoadTownMap_Nest),LoadTownMap_Nest
-	dbw BANK(Func_27d6b),Func_27d6b
-	dbw BANK(EmotionBubble), EmotionBubble; 4C player exclamation
-	dbw BANK(Func_5aaf),Func_5aaf; return immediately
-	dbw BANK(AskName), AskName
-	dbw BANK(PewterGuys),PewterGuys
-	dbw BANK(SaveSAVtoSRAM2),SaveSAVtoSRAM2
-	dbw BANK(LoadSAVCheckSum2),LoadSAVCheckSum2
-	dbw BANK(LoadSAV),LoadSAV
-	dbw BANK(SaveSAVtoSRAM1),SaveSAVtoSRAM1
-	dbw BANK(Predef54),Predef54 ; 54 initiate trade
-	dbw BANK(HallOfFamePC), HallOfFamePC
-	dbw BANK(DisplayDexRating),DisplayDexRating
+	add_predef Func_480eb
+	add_predef Func_f8ba
+	add_predef Func_480ff
+	add_predef Func_f929
+	add_predef Func_f9a0
+	add_predef Func_48125
+	add_predef UpdateHPBar
+	add_predef HPBarLength
+	add_predef Func_5ab0
+	add_predef Func_3ed02
+	add_predef ShowPokedexMenu
+	add_predef Func_3ad1c
+	add_predef SaveSAVtoSRAM0
+	add_predef InitOpponent
+	add_predef Func_5a5f
+	add_predef DrawBadges
+	add_predef Func_410f3
+	add_predef BattleTransition
+	add_predef Func_79dda
+	add_predef PlayIntro
+	add_predef Func_79869
+	add_predef FlashScreen
+	add_predef Func_c586
+	add_predef StatusScreen
+	add_predef StatusScreen2
+	add_predef Func_410e2
+	add_predef TrainerEngage
+	add_predef IndexToPokedex
+	add_predef Predef3B; 3B display pic?
+	add_predef UsedCut
+	add_predef ShowPokedexData
+	add_predef WriteMonMoves
+	add_predef SaveSAV
+	add_predef LoadSGB
+	add_predef Func_f113
+	add_predef SetPartyMonTypes
+	add_predef CanLearnTM
+	add_predef TMToMove
+	add_predef Func_71ddf
+	add_predef StarterDex ; 46
+	add_predef _AddPartyMon
+	add_predef UpdateHPBar2
+	add_predef Func_3cdec
+	add_predef LoadTownMap_Nest
+	add_predef Func_27d6b
+	add_predef EmotionBubble; 4C player exclamation
+	add_predef Func_5aaf; return immediately
+	add_predef AskName
+	add_predef PewterGuys
+	add_predef SaveSAVtoSRAM2
+	add_predef LoadSAVCheckSum2
+	add_predef LoadSAV
+	add_predef SaveSAVtoSRAM1
+	add_predef Predef54 ; 54 initiate trade
+	add_predef HallOfFamePC
+	add_predef DisplayDexRating
 	dbw $1E, _LeaveMapAnim ; wrong bank
 	dbw $1E, Func_70510 ; wrong bank
-	dbw BANK(Func_c5be),Func_c5be
-	dbw BANK(Func_c60b),Func_c60b
-	dbw BANK(PrintStrengthTxt), PrintStrengthTxt
-	dbw BANK(PickupItem),PickupItem
-	dbw BANK(Func_27d98),Func_27d98
-	dbw BANK(LoadMovePPs),LoadMovePPs
-DrawHPBarPredef: ; 4ff96 (13:7f96)
-	dbw BANK(Func_128ef),Func_128ef ; 5F draw HP bar
-	dbw BANK(Func_128f6),Func_128f6
-	dbw BANK(Func_1c9c6),Func_1c9c6
-	dbw BANK(OaksAideScript),OaksAideScript
+	add_predef Func_c5be
+	add_predef Func_c60b
+	add_predef PrintStrengthTxt
+	add_predef PickupItem
+	add_predef Func_27d98
+	add_predef LoadMovePPs
+	add_predef DrawHP ; 5F
+	add_predef Func_128f6
+	add_predef Func_1c9c6
+	add_predef OaksAideScript
--- a/home/init.asm
+++ b/home/init.asm
@@ -95,8 +95,7 @@
 
 	ei
 
-	ld a, $40 ; PREDEF_SGB_BORDER
-	call Predef
+	predef LoadSGB
 
 	ld a, BANK(SFX_1f_67)
 	ld [wc0ef], a
@@ -108,8 +107,7 @@
 	dec a
 	ld [wcfcb], a
 
-	ld a, $32 ; PREDEF_INTRO
-	call Predef
+	predef PlayIntro
 
 	call DisableLCD
 	call ClearVram
--- a/macros.asm
+++ b/macros.asm
@@ -138,13 +138,23 @@
 	ENDM
 
 ; Predef macro.
-PREDEF: MACRO
-	ld a, (\1 - PredefPointers) / 3
+add_predef: MACRO
+\1Predef::
+	db BANK(\1)
+	dw \1
+	ENDM
+
+predef_id: MACRO
+	ld a, (\1Predef - PredefPointers) / 3
+	ENDM
+
+predef: MACRO
+	predef_id \1
 	call Predef
 	ENDM
 
-PREDEF_JUMP: MACRO
-	ld a, (\1 - PredefPointers) / 3
+predef_jump: MACRO
+	predef_id \1
 	jp Predef
 	ENDM
 
--- a/main.asm
+++ b/main.asm
@@ -494,8 +494,7 @@
 	ld a, RHYDON
 	ld [W_CUROPPONENT], a
 
-	ld a, $2c ; PREDEF_BATTLE
-	call Predef
+	predef InitOpponent
 
 	; When the battle ends,
 	; do it all again.
@@ -3259,6 +3258,7 @@
 ; adds missable object (items, leg. pokemon, etc.) to the map
 ; [wcc4d]: index of the missable object to be added (global index)
 ShowObject: ; f1c8 (3:71c8)
+ShowObject2:
 	ld hl, W_MISSABLEOBJECTFLAGS
 	ld a, [wcc4d]
 	ld c, a
@@ -4136,6 +4136,9 @@
 
 
 DivideBCDPredef::
+DivideBCDPredef2::
+DivideBCDPredef3::
+DivideBCDPredef4::
 	call GetPredefRegisters
 
 DivideBCD::
@@ -4347,6 +4350,7 @@
 
 
 InitPlayerData:
+InitPlayerData2:
 
 	call Random
 	ld a, [hRandomSub]
--- a/scripts/redshouse1f.asm
+++ b/scripts/redshouse1f.asm
@@ -27,7 +27,7 @@
 	call PrintText
 	call GBFadeOut2
 	call ReloadMapData
-	PREDEF HealPartyPredef
+	predef HealParty
 	ld a, MUSIC_PKMN_HEALED
 	ld [wc0ee], a
 	call PlaySound ; play sound?