forked from gameboyadvancesp/understanding-pokemon-red
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpredefs.asm
164 lines (155 loc) · 4.44 KB
/
predefs.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
; wPredefIDで指定したPredef関数のバンクとポインタを取得する
; レジスタ(hl, de, bc)の中身をwPredefRegistersに退避
; 次に、バンクとpredef wPredefIDのアドレスを[wPredefBank]とhlに格納
;
; 返り値:
; - wPredefBank: Predef関数のバンク番号
; - hl: Predef関数のアドレス
GetPredefPointer:
; hlを退避
ld a, h
ld [wPredefRegisters], a
ld a, l
ld [wPredefRegisters + 1], a
; deを退避
ld hl, wPredefRegisters + 2
ld a, d
ld [hli], a
ld a, e
ld [hli], a
; bcを退避
ld a, b
ld [hli], a
ld [hl], c
; PredefPointers
ld hl, PredefPointers
; deがPredefPointersのwPredefIDのオフセットを指すようにする
ld de, 0
ld a, [wPredefID] ; a = wPredefID
ld e, a ; e = wPredefID
add a ; a *= 2
add e ; a *= 3 各エントリのサイズは3バイトなので
ld e, a
jr nc, .nocarry ; キャリーを処理
inc d
.nocarry
; deがPredefPointersのwPredefIDのエントリアドレスを指すようにする
add hl, de
ld d, h
ld e, l
; wPredefBankに対象のPredef関数のバンク番号を入れる
ld a, [de]
ld [wPredefBank], a
; get pointer
inc de ; エントリの1バイト目はバンク番号なのでいらない
; hl = Predef関数のアドレス
ld a, [de]
ld l, a
inc de
ld a, [de]
ld h, a
ret
; **PredefPointers**
; Predefされた関数のテーブル
; 各エントリはPredefされた関数のバンク番号とアドレスを持っている
; overworld mapスクリプト内で使用されている様子
PredefPointers::
add_predef DrawPlayerHUDAndHPBar
add_predef CopyUncompressedPicToTilemap
add_predef AnimateSendingOutMon
add_predef ScaleSpriteByTwo
add_predef LoadMonBackPic
add_predef CopyDownscaledMonTiles
dbw $03,JumpMoveEffect ; wrong bank
add_predef HealParty
add_predef MoveAnimation
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 ApplyOutOfBattlePoisonDamage
add_predef AnyPartyAlive
add_predef ShowObject
add_predef ShowObject2
add_predef ReplaceTileBlock
add_predef InitPlayerData2
add_predef LoadTilesetHeader
add_predef LearnMoveFromLevelUp
add_predef LearnMove
add_predef GetQuantityOfItemInBag
dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; home bank
dbw $03,GiveItem ; home bank
add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
add_predef PredefShakeScreenVertically
add_predef CalcPositionOfPlayerRelativeToNPC
add_predef ConvertNPCMovementDirectionsToJoypadMasks
add_predef PredefShakeScreenHorizontally
add_predef UpdateHPBar
add_predef HPBarLength
add_predef Diploma_TextBoxBorder
add_predef DoubleOrHalveSelectedStats
add_predef ShowPokedexMenu
add_predef EvolutionAfterBattle
add_predef SaveSAVtoSRAM0
add_predef InitOpponent
add_predef CableClub_Run
add_predef DrawBadges
add_predef ExternalClockTradeAnim
add_predef BattleTransition
add_predef CopyTileIDsFromList
add_predef PlayIntro
add_predef GetMoveSoundB
add_predef FlashScreen
add_predef GetTileAndCoordsInFrontOfPlayer
add_predef StatusScreen
add_predef StatusScreen2
add_predef InternalClockTradeAnim
add_predef TrainerEngage
add_predef IndexToPokedex
add_predef DisplayPicCenteredOrUpperRight
add_predef UsedCut
add_predef ShowPokedexData
add_predef WriteMonMoves
add_predef SaveSAV
add_predef LoadSGB
add_predef MarkTownVisitedAndLoadMissableObjects
add_predef SetPartyMonTypes
add_predef CanLearnTM
add_predef TMToMove
add_predef _RunPaletteCommand
add_predef StarterDex
add_predef _AddPartyMon
add_predef UpdateHPBar2
add_predef DrawEnemyHUDAndHPBar
add_predef LoadTownMap_Nest
add_predef PrintMonType
add_predef EmotionBubble
add_predef EmptyFunc3; return immediately
add_predef AskName
add_predef PewterGuys
add_predef SaveSAVtoSRAM2
add_predef LoadSAV2
add_predef LoadSAV
add_predef SaveSAVtoSRAM1
add_predef DoInGameTradeDialogue
add_predef HallOfFamePC
add_predef DisplayDexRating
dbw $1E, _LeaveMapAnim ; wrong bank
dbw $1E, EnterMapAnim ; wrong bank
add_predef GetTileTwoStepsInFrontOfPlayer
add_predef CheckForCollisionWhenPushingBoulder
add_predef PrintStrengthTxt
add_predef PickUpItem
add_predef PrintMoveType
add_predef LoadMovePPs
add_predef DrawHP
add_predef DrawHP2
add_predef DisplayElevatorFloorMenu
add_predef OaksAideScript