Update predef_pointers and wram, and correct typo's caused by search + replace

This commit is contained in:
libjet
2019-12-11 21:50:49 +00:00
parent 93872e920e
commit 7acf2ec917
31 changed files with 343 additions and 329 deletions

View File

@@ -1,5 +1,5 @@
INCLUDE "includes.asm"
INCLUDE "contents.asm"
INCLUDE "constants.asm"
SECTION "Egg Moves", ROMX, BANK[EGG_MOVES]

View File

@@ -1,12 +1,10 @@
INCLUDE "includes.asm"
INCLUDE "contents.asm"
INCLUDE "constants.asm"
SECTION "Evolutions and Attacks", ROMX, BANK[EVOS_ATTACKS]
INCLUDE "data/pokemon/evos_attacks_pointers.asm"
EvosAttacks::
BulbasaurEvosAttacks:

79
data/predef_pointers.asm Executable file
View File

@@ -0,0 +1,79 @@
; Predef routines can be used with the "predef" and "predef_jump" macros.
; This preserves registers bc, de, hl and f.
add_predef: MACRO
\1Predef::
dab \1
ENDM
PredefPointers::
add_predef LearnMove ; $0
add_predef DummyPredef1
add_predef HealParty ; this is both a special and a predef
add_predef SmallFarFlagAction
add_predef ComputeHPBarPixels
add_predef FillPP
add_predef TryAddMonToParty
add_predef AddTempmonToParty
add_predef SendGetMonIntoFromBox
add_predef SendMonIntoBox
add_predef GiveEgg
add_predef AnimateHPBar
add_predef CalcMonStats
add_predef CalcMonStatC
add_predef CanLearnTMHMMove
add_predef GetTMHMMove
add_predef LinkTextboxAtHL ; $ 10
add_predef PrintMoveDesc
add_predef UpdatePlayerHUD
add_predef PlaceGraphic
add_predef CheckPlayerPartyForFitMon
add_predef UpdateEnemyHUD
add_predef StartBattle
add_predef FillInExpBar
add_predef GetBattleMonBackpic ; $18
add_predef GetEnemyMonFrontpic
add_predef LearnLevelMoves
add_predef FillMoves
add_predef EvolveAfterBattle
add_predef TradeAnimationPlayer2
add_predef TradeAnimation
add_predef CopyMonToTempMon
add_predef ListMoves ; $20
add_predef PlaceNonFaintStatus
add_predef Unused_PlaceEnemyHPLevel
add_predef ListMovePP
add_predef GetGender
add_predef StatsScreenInit
add_predef DrawPlayerHP
add_predef DrawEnemyHP
add_predef PrintTempMonStats ; $28
add_predef GetTypeName
add_predef PrintMoveType
add_predef PrintType
add_predef PrintMonTypes
add_predef GetUnownLetter
add_predef LoadPoisonBGPals
add_predef DummyPredef2F
add_predef InitSGBBorder ; $30
add_predef LoadSGBLayout
add_predef Pokedex_GetArea
add_predef Unused_CheckShininess
add_predef DoBattleTransition
add_predef DummyPredef35
add_predef DummyPredef36
add_predef PlayBattleAnim
add_predef DummyPredef38 ; $38
add_predef DummyPredef39
add_predef DummyPredef3A
add_predef PartyMonItemName
add_predef GetMonFrontpic
add_predef GetMonBackpic
add_predef GetTrainerPic
add_predef DecompressGet2bpp
add_predef CheckTypeMatchup ; $40
add_predef ConvertMon_1to2
add_predef NewPokedexEntry
add_predef FrontpicPredef
add_predef UpdateTimePredef
dbw -1, InexplicablyEmptyFunction ; ???

View File

@@ -235,10 +235,10 @@ Functione566: ; e566 (3:6566)
call ByteFill
hlcoord 0, 0
lb bc, 10, 18
call TextBox
call Textbox
hlcoord 0, 12
ld bc, IncGradGBPalTable_13
call TextBox
call Textbox
call Function3456
call SetPalettes
ret

View File

@@ -31,7 +31,7 @@ CheckShininess:
and a
ret
CheckContestMon: ; 9072 (2:5072)
Unused_CheckShininess: ; 9072 (2:5072)
ld a, [hl]
cp $a0
jr c, .asm_908c

View File

@@ -522,7 +522,7 @@ DayCare_GiveEgg:
pop hl
push bc
ld b, FALSE
predef CalcPkmnStats
predef CalcMonStats
pop bc
ld hl, MON_HP
add hl, bc

View File

@@ -45,4 +45,4 @@ SetMemEvent:
ld e, a
ld b, SET_FLAG
call EventFlagAction
ret
ret

View File

@@ -121,7 +121,7 @@ LearnMove:
hlcoord 5, 2
ld b, $8
ld c, $d
call TextBox
call Textbox
hlcoord 7, 4
ld a, $28
ld [wBuffer1], a

View File

@@ -22,7 +22,7 @@ CanLearnTMHMMove: ; 11a25 (4:5a25)
ld b, CHECK_FLAG
push de
ld d, $0
predef FlagPredef
predef SmallFarFlagAction
pop de
ret

View File

@@ -0,0 +1,24 @@
PlaceWaitingText::
hlcoord 3, 10
ld b, 1
ld c, 11
ld a, [wBattleMode]
and a
jr z, .notinbattle
call Textbox
jr .proceed
.notinbattle
predef LinkTextboxAtHL
.proceed
hlcoord 4, 11
ld de, .Waiting
call PlaceString
ld c, 50
jp DelayFrames
.Waiting:
db "Waiting...!@"

View File

@@ -152,11 +152,11 @@ Function5b45: ; 5b45 (1:5b45)
hlcoord 0, 12
ld b, $4
ld c, $d
call TextBox
call Textbox
ret
.asm_5b57
call SpeechTextBox
call SpeechTextbox
ret
Function5b5b: ; 5b5b (1:5b5b)
@@ -929,7 +929,7 @@ ShrinkPlayer: ; 6123 (1:6123)
ld a, e
ld [wMusicFadeID], a
ld a, d
ld [wMusicFadeIDHi], a
ld [wMusicFadeID + 1], a
ld de, SFX_ESCAPE_ROPE
call PlaySFX
@@ -1051,7 +1051,7 @@ Intro_PrepTrainerPic: ; 61df, 61e0 (1:61df, 1:61e0)
ShrinkFrame: ; 61f7 (1:61f7)
ld de, $9000
ld c, $31
predef DecompressPredef
predef DecompressGet2bpp
xor a
ld [hGraphicStartTile], a
hlcoord 6, 4

View File

@@ -214,7 +214,7 @@ GeneratePartyMonStats:
ld a, $1
ld c, a
ld b, $0
call CalcPkmnStatC
call CalcMonStatC
ld a, [hStringCmpString2]
ld [de], a
inc de
@@ -281,7 +281,7 @@ GeneratePartyMonStats:
ld bc, $a
add hl, bc
ld b, $0
call CalcPkmnStats
call CalcMonStats
.asm_da4b
ld a, [wMonType]
and $f
@@ -406,7 +406,7 @@ AddTempmonToParty: ; da9c (3:5a9c)
and a
ret
SentGetPkmnIntoFromBox: ; db45 (3:5b45)
SendGetMonIntoFromBox: ; db45 (3:5b45)
ld a, $1
call OpenSRAM
ld a, [wPokemonWithdrawDepositParameter]
@@ -544,7 +544,7 @@ SentGetPkmnIntoFromBox: ; db45 (3:5b45)
srl a
add $2
ld [wMonType], a
predef CopyPkmnToTempMon
predef CopyMonToTempMon
callfar CalcLevel
ld a, d
ld [wCurPartyLevel], a
@@ -562,7 +562,7 @@ SentGetPkmnIntoFromBox: ; db45 (3:5b45)
add hl, bc
push bc
ld b, $1
call CalcPkmnStats
call CalcMonStats
pop bc
ld a, [wPokemonWithdrawDepositParameter]
and a
@@ -766,7 +766,7 @@ Functiondd6a: ; dd6a (3:5d6a)
add hl, bc
push bc
ld b, $1
call CalcPkmnStats
call CalcMonStats
ld hl, wPartyMon1Moves
ld a, [wPokemonData]
dec a
@@ -836,7 +836,7 @@ Functionde4a: ; de4a (3:5e4a)
ld bc, BOXMON_STRUCT_LENGTH
jp CopyBytes
SentPkmnIntoBox: ; de74 (3:5e74)
SendMonIntoBox: ; de74 (3:5e74)
ld a, $1
call OpenSRAM
ld de, sBoxCount
@@ -1016,7 +1016,7 @@ GiveEgg: ; df92 (3:5f92)
ld d, $0
ld hl, wPokedexCaught
ld b, RESET_FLAG
predef FlagPredef
predef SmallFarFlagAction
.asm_dfc9
pop bc
ld a, c
@@ -1028,7 +1028,7 @@ GiveEgg: ; df92 (3:5f92)
ld d, $0
ld hl, wPokedexSeen
ld b, RESET_FLAG
predef FlagPredef
predef SmallFarFlagAction
.asm_dfdf
pop af
ld [wCurPartySpecies], a
@@ -1234,7 +1234,7 @@ ComputeNPCTrademonStats:
ld a, MON_STAT_EXP - 1
call GetPartyParamLocation
ld b, $1
call CalcPkmnStats
call CalcMonStats
pop de
ld a, MON_HP
call GetPartyParamLocation
@@ -1245,7 +1245,7 @@ ComputeNPCTrademonStats:
ld [hl], a
ret
CalcPkmnStats: ; e16d
CalcMonStats: ; e16d
; Calculates all 6 Stats of a Pkmn
; b: Take into account stat EXP if TRUE
; 'c' counts from 1-6 and points with 'BaseStats' to the base value
@@ -1255,7 +1255,7 @@ CalcPkmnStats: ; e16d
ld c, $0
.loop
inc c
call CalcPkmnStatC
call CalcMonStatC
ld a, [hMultiplicand + 1]
ld [de], a
inc de
@@ -1268,7 +1268,7 @@ CalcPkmnStats: ; e16d
ret
; e17b
CalcPkmnStatC: ; e181
CalcMonStatC: ; e181
; 'c' is 1-6 and points to the BaseStat
; 1: HP
; 2: Attack
@@ -1511,7 +1511,7 @@ GivePoke: ; Give a Pokemon from script
ld a, [wCurPartySpecies]
ld [wTempEnemyMonSpecies], a
callfar LoadEnemyMon
call SentPkmnIntoBox
call SendMonIntoBox
jp nc, Functione3af
ld a, BOXMON
ld [wMonType], a

View File

@@ -1335,7 +1335,7 @@ Function10d70: ; 10d70 (4:4d70)
call Function10dc0
hlcoord 0, 12
ld bc, IncGradGBPalTable_13
call TextBox
call Textbox
call EnableLCD
call Function10ccd
ret

View File

@@ -1,102 +1,28 @@
GetPredefPointer:: ; 8b3b (2:4b3b)
GetPredefPointer::
; Return the bank and address of wPredefID in a and wPredefAddress.
; Save hl for later (back in Predef)
ld a, h
ld [wPredefHLBuffer], a
ld [wPredefTemp], a
ld a, l
ld [wPredefHLBuffer + 1], a
ld [wPredefTemp + 1], a
push de
ld a, [wPredefID]
ld e, a
ld d, $0
ld d, 0
ld hl, PredefPointers
add hl, de
add hl, de
add hl, de
pop de
ld a, [hli]
ld [wPredefPointerBuffer + 1], a
ld [wPredefAddress + 1], a
ld a, [hli]
ld [wPredefPointerBuffer], a
ld [wPredefAddress], a
ld a, [hl]
ret
PredefPointers::
; temp macro
predef_pointer: macro
IF DEF(GOLD)
dwb \1, \3
ENDC
IF DEF(SILVER)
dwb \2, \3
ENDC
endm
add_predef LearnMove ; $0
add_predef Predef1 ; $1
add_predef HealParty
add_predef FlagPredef
add_predef ComputeHPBarPixels
add_predef FillPP
add_predef TryAddMonToParty
add_predef AddTempmonToParty
add_predef SentGetPkmnIntoFromBox
add_predef SentPkmnIntoBox
add_predef GiveEgg
add_predef AnimateHPBar
add_predef CalcPkmnStats
add_predef CalcPkmnStatC
add_predef CanLearnTMHMMove
add_predef GetTMHMMove
add_predef Predef_LinkTextbox ; $ 10
add_predef PrintMoveDesc
add_predef UpdatePlayerHUD
add_predef PlaceGraphic
add_predef CheckPlayerPartyForFitPkmn
add_predef UpdateEnemyHUD
add_predef StartBattle
add_predef FillInExpBar
add_predef GetMonBackpic ; $18
add_predef GetMonFrontpic
add_predef LearnLevelMoves
add_predef FillMoves
add_predef EvolveAfterBattle
add_predef TradeAnimationPlayer2
add_predef TradeAnimation
add_predef CopyPkmnToTempMon
add_predef ListMoves ; $20
add_predef PlaceNonFaintStatus
add_predef Predef22
add_predef ListMovePP
add_predef GetGender
add_predef StatsScreenInit
add_predef DrawPlayerHP
add_predef DrawEnemyHP
add_predef PrintTempMonStats ; $28
add_predef GetTypeName
add_predef PrintMoveType
add_predef PrintType
add_predef PrintMonTypes
add_predef GetUnownLetter
add_predef LoadPoisonBGPals
add_predef Predef2F
add_predef InitSGBBorder ; $30
add_predef Predef_LoadSGBLayout
add_predef Area_
add_predef CheckContestMon
add_predef Predef_StartBattle
add_predef Predef35
add_predef Predef36
add_predef PlayBattleAnim
add_predef Predef38 ; $38
add_predef Predef39
add_predef Predef3A
add_predef PartyMonItemName
add_predef GetFrontpic
add_predef GetBackpic
add_predef GetTrainerPic
add_predef DecompressPredef
add_predef CheckTypeMatchup ; $40
add_predef ConvertMon_1to2
add_predef NewPokedexEntry
add_predef FrontpicPredef
add_predef UpdateTimePredef
dbw $ff, InexplicablyEmptyFunction
INCLUDE "data/predef_pointers.asm"

View File

@@ -547,7 +547,7 @@ FadeOutMusic: ; c628 (3:4628)
ld a, $0
ld [wMusicFadeID], a
ld a, $0
ld [wMusicFadeIDHi], a
ld [wMusicFadeID + 1], a
ld a, $2
ld [wMusicFade], a
ret

View File

@@ -341,8 +341,8 @@ Function6434:
ld hl, wce63
inc [hl]
xor a
ld [wMusicFadeIDLo], a
ld [wMusicFadeIDHi], a
ld [wMusicFadeID], a
ld [wMusicFadeID + 1], a
ld hl, wMusicFade
ld [hl], $8
ld hl, wce65

View File

@@ -1,4 +1,5 @@
INCLUDE "includes.asm"
INCLUDE "contents.asm"
INCLUDE "constants.asm"
; rst vectors
INCLUDE "home/rst.asm"
@@ -160,7 +161,7 @@ Function2ffe:: ; 2ffe (0:2ffe)
push de
push bc
ld d, $0
predef FlagPredef
predef SmallFarFlagAction
pop bc
pop de
.next
@@ -270,7 +271,7 @@ Function31e2:: ; 31e2 (0:31e2)
ld a, [wOptions]
bit 4, a
ret nz
ld a, [wTextBoxFlags]
ld a, [wTextboxFlags]
bit 1, a
ret z
push hl
@@ -280,7 +281,7 @@ Function31e2:: ; 31e2 (0:31e2)
ld a, [hl]
push af
ld [hl], a
ld a, [wTextBoxFlags]
ld a, [wTextboxFlags]
bit 0, a
jr z, .asm_3205
ld a, [wOptions]
@@ -873,7 +874,7 @@ GetSGBLayout:: ; 3583 (0:3583)
and a
ret z
.asm_358c
predef_jump Predef_LoadSGBLayout
predef_jump LoadSGBLayout
SetHPPal::
call GetHPPal
@@ -1184,7 +1185,7 @@ DrawScrollingMenu::
push de
call Coord2Tile
pop bc
jp TextBox
jp Textbox
ScrollingMenuJoyTextDelay::
call DelayFrame
@@ -1610,7 +1611,7 @@ PrepMonFrontpic_::
.egg
push hl
ld de, $9000
predef GetFrontpic
predef GetMonFrontpic
pop hl
xor a
ld [hGraphicStartTile], a

View File

@@ -47,7 +47,7 @@ Init:: ; 5d1 (0:05d1)
ld [rLCDC], a
; Clear WRAM
ld hl, wc000
ld hl, wMusicPlaying
ld bc, $2000
.ByteFill
ld [hl], $0

View File

@@ -199,10 +199,10 @@ Function2086::
call GetCurrentMapTrigger
call ResetBikeFlags
ld a, $5
call RunMapfarcallck
call RunMapCallback
farcall Function97c2a
ld a, $3
call RunMapfarcallck
call RunMapCallback
call GetMapHeaderTimeOfDayNybble
ld [wMapTimeOfDay], a
ret
@@ -742,7 +742,7 @@ ReadMapScripts:: ; 242e (0:242e)
ld h, [hl]
ld l, a
call ReadMapTriggers
call ReadMapfarcallcks
call ReadMapCallbacks
ret
CopySecondMapHeader:: ; 243b (0:243b)
@@ -811,7 +811,7 @@ ReadMapTriggers:: ; 248b (0:248b)
call AddNTimes
ret
ReadMapfarcallcks:: ; 24a2 (0:24a2)
ReadMapCallbacks:: ; 24a2 (0:24a2)
ld a, [hli]
ld c, a
ld [wd954], a
@@ -1035,7 +1035,7 @@ LoadBlockData::
call ChangeMap
call FillMapConnections
ld a, $1
call RunMapfarcallck
call RunMapCallback
ret
ChangeMap:: ; 260d (0:260d)
@@ -1256,24 +1256,24 @@ CallMapScript::
call GetMapScriptHeaderBank
jr CallScript
RunMapfarcallck:: ; 2764 (0:2764)
RunMapCallback:: ; 2764 (0:2764)
ld b, a
ld a, [hROMBank]
push af
call SwitchToMapScriptHeaderBank
call Findfarcallck
call FindCallback
jr nc, .asm_2779
call GetMapScriptHeaderBank
ld b, a
ld d, h
ld e, l
call ExecutefarcallckScript
call ExecuteCallbackScript
.asm_2779
pop af
rst Bankswitch
ret
Findfarcallck:: ; 277c (0:277c)
FindCallback:: ; 277c (0:277c)
ld a, [wd954]
ld c, a
and a
@@ -1303,8 +1303,8 @@ Findfarcallck:: ; 277c (0:277c)
scf
ret
ExecutefarcallckScript:: ; 279d (0:279d)
farcall Callfarcallck
ExecuteCallbackScript:: ; 279d (0:279d)
farcall CallCallback
ld a, [wd15e]
push af
ld hl, wd15b
@@ -1324,10 +1324,10 @@ MapTextbox::
push af
ld a, b
rst Bankswitch
call SetUpTextBox
call SetUpTextbox
ld a, $1
ld [hOAMUpdate], a
call PrintTextBoxText
call PrintTextboxText
xor a
ld [hOAMUpdate], a
pop af
@@ -2134,7 +2134,7 @@ ReturnToMapWithSpeechTextbox::
call ReloadTilesetAndPalettes
hlcoord 0, 12
lb bc, 4, 18
call TextBox
call Textbox
ld hl, wVramState
set 0, [hl]
call UpdateSprites

View File

@@ -23,7 +23,7 @@ CheckSeenMon::
ld b, CHECK_FLAG
PokedexFlagAction:: ; 35e4 (0:35e4)
ld d, 0
predef FlagPredef
predef SmallFarFlagAction
ld a, c
and a
ret

View File

@@ -1,34 +1,52 @@
Predef:: ; 2e49 (0:2e49)
Predef::
; Call predefined function a.
; Preserves bc, de, hl and f.
ld [wPredefID], a
ld a, [hROMBank]
ldh a, [hROMBank]
push af
ld a, BANK(GetPredefPointer)
rst Bankswitch
call GetPredefPointer
call GetPredefPointer ; stores hl in wPredefTemp
; Switch to the new function's bank
rst Bankswitch
ld hl, .return
; Instead of directly calling stuff,
; push it to the stack in reverse.
ld hl, .Return
push hl
ld a, [wPredefPointerBuffer]
; Call the Predef function
ld a, [wPredefAddress]
ld h, a
ld a, [wPredefPointerBuffer + 1]
ld a, [wPredefAddress + 1]
ld l, a
push hl
ld a, [wPredefHLBuffer]
; Get hl back
ld a, [wPredefTemp]
ld h, a
ld a, [wPredefHLBuffer + 1]
ld a, [wPredefTemp + 1]
ld l, a
ret
.return
.Return:
; Clean up after the Predef call
ld a, h
ld [wPredefHLBuffer], a
ld [wPredefTemp], a
ld a, l
ld [wPredefHLBuffer + 1], a
ld [wPredefTemp + 1], a
pop hl
ld a, h
rst Bankswitch
ld a, [wPredefHLBuffer]
ld a, [wPredefTemp]
ld h, a
ld a, [wPredefHLBuffer + 1]
ld a, [wPredefTemp + 1]
ld l, a
ret
ret

View File

@@ -19,10 +19,10 @@ BattleRandom::
ld a, BANK(BattleRandom_)
rst Bankswitch
call BattleRandom_
ld [wPredefHLBuffer + 1], a
ld [wPredefTemp + 1], a
pop af
rst Bankswitch
ld a, [wPredefHLBuffer + 1]
ld a, [wPredefTemp + 1]
ret
RandomRange::

View File

@@ -35,20 +35,20 @@ FillScreenWithTextboxPal::
call ByteFill
jr ClearTileMap
TextBox:: ; eef (0:0eef)
Textbox:: ; eef (0:0eef)
push bc
push hl
call TextBoxBorder
call TextboxBorder
pop hl
pop bc
jr TextBoxPalette
jr TextboxPalette
TextBoxBorder:: ; ef8 (0:0ef8)
TextboxBorder:: ; ef8 (0:0ef8)
push hl
ld a, "┌"
ld [hli], a
inc a
call TextBoxBorder_PlaceTiles
call TextboxBorder_PlaceTiles
inc a
ld [hl], a
pop hl
@@ -61,7 +61,7 @@ TextBoxBorder:: ; ef8 (0:0ef8)
ld a, "│"
ld [hli], a
ld a, " "
call TextBoxBorder_PlaceTiles
call TextboxBorder_PlaceTiles
ld [hl], "│"
pop hl
@@ -74,11 +74,11 @@ TextBoxBorder:: ; ef8 (0:0ef8)
ld a, "└"
ld [hli], a
ld a, "─"
call TextBoxBorder_PlaceTiles
call TextboxBorder_PlaceTiles
ld [hl], "┘"
ret
TextBoxBorder_PlaceTiles:: ; f25 (0:0f25)
TextboxBorder_PlaceTiles:: ; f25 (0:0f25)
ld d, c
.loop
ld [hli], a
@@ -86,7 +86,7 @@ TextBoxBorder_PlaceTiles:: ; f25 (0:0f25)
jr nz, .loop
ret
TextBoxPalette
TextboxPalette
ld de, wAttrMap - wTileMap
add hl, de
inc b
@@ -109,11 +109,11 @@ TextBoxPalette
jr nz, .col
ret
SpeechTextBox:: ; f45 (0:0f45)
SpeechTextbox:: ; f45 (0:0f45)
hlcoord TEXTBOX_X, TEXTBOX_Y
ld b, TEXTBOX_INNERH
ld c, TEXTBOX_INNERW
jp TextBox
jp Textbox
TestText::
text "ゲームフりーク!"
@@ -126,15 +126,15 @@ RadioTerminator:: ; 1052
.stop db "@"
PrintText::
call SetUpTextBox
PrintTextBoxText::
call SetUpTextbox
PrintTextboxText::
bccoord TEXTBOX_INNERX, TEXTBOX_INNERY
call PlaceHLTextAtBC
ret
SetUpTextBox:: ; f68 (0:0f68)
SetUpTextbox:: ; f68 (0:0f68)
push hl
call SpeechTextBox
call SpeechTextbox
call UpdateSprites
call ApplyTilemap
pop hl
@@ -551,15 +551,15 @@ PokeFluteTerminatorCharacter::
.stop db "@"
PlaceHLTextAtBC:: ; 1272 (0:1272)
ld a, [wTextBoxFlags]
ld a, [wTextboxFlags]
push af
set 1, a
ld [wTextBoxFlags], a
ld [wTextboxFlags], a
call DoTextUntilTerminator
pop af
ld [wTextBoxFlags], a
ld [wTextboxFlags], a
ret
DoTextUntilTerminator:: ; 1283 (0:1283)
@@ -690,7 +690,7 @@ Text_TX_BOX:: ; 1318 (0:1318)
push hl
ld h, d
ld l, e
call TextBox
call Textbox
pop hl
ret

View File

@@ -195,7 +195,7 @@ MenuBox:: ; 1b4e (0:1b4e)
call GetMenuBoxDims
dec b
dec c
jp TextBox
jp Textbox
GetMenuTextStartCoord:: ; 1b59 (0:1b59)
ld a, [wMenuBorderTopCoord]

View File

@@ -46,7 +46,7 @@ OpenText::
ld a, BANK(ReanchorBGMap_NoOAMUpdate) ; and BANK(LoadFonts_NoOAMUpdate)
rst Bankswitch
call ReanchorBGMap_NoOAMUpdate
call SpeechTextBox
call SpeechTextbox
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
call LoadFonts_NoOAMUpdate
pop af

View File

@@ -1,2 +0,0 @@
INCLUDE "contents.asm"
INCLUDE "constants.asm"

View File

@@ -556,7 +556,7 @@ UltraBall: ; e926
.send_mon_to_pc
call ClearSprites
predef SentPkmnIntoBox
predef SendMonIntoBox
ld a, BANK(sBoxCount)
call OpenSRAM
ld a, [sBoxCount]
@@ -1083,7 +1083,7 @@ Functioneee0: ; eee0 (3:6ee0)
ld a, MON_STAT_EXP - 1
call GetPartyParamLocation
ld b, $1
predef_jump CalcPkmnStats
predef_jump CalcMonStats
Functioneef3: ; eef3 (3:6ef3)
xor a
@@ -1198,11 +1198,11 @@ RareCandy: ; ef68 (3:6f68)
call Functionf2a0
xor a
ld [wMonType], a
predef CopyPkmnToTempMon
predef CopyMonToTempMon
hlcoord 9, 0
ld b, 10
ld c, 9
call TextBox
call Textbox
hlcoord 11, 1
ld bc, $4
predef PrintTempMonStats
@@ -1406,7 +1406,7 @@ Functionf12c: ; f12c (3:712c)
ld d, $0
ld hl, wcbda
ld b, CHECK_FLAG
predef FlagPredef
predef SmallFarFlagAction
ld a, c
and a
jr z, .asm_f15a
@@ -1414,7 +1414,7 @@ Functionf12c: ; f12c (3:712c)
ld c, a
ld hl, wcb42
ld b, SET_FLAG
predef FlagPredef
predef SmallFarFlagAction
.asm_f15a
xor a
ld [wLowHealthAlarm], a

8
macros/predef.asm Normal file → Executable file
View File

@@ -1,11 +1,3 @@
predef_const: MACRO
enum \1Predef
ENDM
add_predef: MACRO
\1Predef:: dab \1
ENDM
predef_id: MACRO
; Some functions load the predef id
; without immediately calling Predef.

View File

@@ -1,29 +1,12 @@
INCLUDE "includes.asm"
INCLUDE "contents.asm"
INCLUDE "constants.asm"
SECTION "bank1", ROMX, BANK[$1]
PlaceWaitingText:: ; 4000 (1:4000)
hlcoord 3, 10
ld b, $1
ld c, $b
ld a, [wBattleMode]
and a
jr z, .asm_4012
call TextBox
jr .asm_4017
.asm_4012
predef Predef_LinkTextbox
.asm_4017
hlcoord 4, 11
ld de, .Waiting
call PlaceString
ld c, 50
jp DelayFrames
SECTION "bank1", ROMX
.Waiting:
db "Waiting...!@"
INCLUDE "engine/link/place_waiting_text.asm"
Predef1:
DummyPredef1:
ret
LoadPushOAM:: ; 4032 (1:4032)
@@ -353,7 +336,7 @@ INCLUDE "engine/specials.asm"
Functionc660:
nop
FlagPredef:
SmallFarFlagAction:
push hl
push bc
push bc
@@ -798,7 +781,7 @@ ReturnToBattle_UseBall_:
SECTION "banka", ROMX, BANK[$a]
dr $28000, $28d88
Predef_LinkTextbox::
LinkTextboxAtHL::
dr $28d88, $28dea
TradeAnimation::
@@ -915,7 +898,7 @@ SECTION "bankf", ROMX, BANK[$f]
FleeMons::
dr $3c551, $3d70a
CheckPlayerPartyForFitPkmn::
CheckPlayerPartyForFitMon::
dr $3d70a, $3d8f5
Function3d8f5:
@@ -938,10 +921,10 @@ BattleRandom_:: ; 3ec11
FillInExpBar::
dr $3f196, $3f243
GetMonBackpic::
GetBattleMonBackpic::
dr $3f243, $3f282
GetMonFrontpic::
GetEnemyMonFrontpic::
dr $3f282, $3f2c7
StartBattle::
@@ -1035,7 +1018,7 @@ BasementKeyFunction:
SacredAshFunction:
dr $50819, $5087d
CopyPkmnToTempMon::
CopyMonToTempMon::
dr $5087d, $50940
PrintMonTypes::
@@ -1068,7 +1051,7 @@ GetGender::
ListMovePP::
dr $51364, $513e4
Predef22::
Unused_PlaceEnemyHPLevel::
dr $513e4, $51437
PlaceNonFaintStatus::
@@ -1086,19 +1069,19 @@ CalcExpAtLevel:
GetUnownLetter::
dr $51749, $51780
GetFrontpic::
GetMonFrontpic::
dr $51780, $51786
FrontpicPredef::
dr $51786, $51803
GetBackpic::
GetMonBackpic::
dr $51803, $518a0
GetTrainerPic::
dr $518a0, $518fa
DecompressPredef::
DecompressGet2bpp::
dr $518fa, $51b0b
INCLUDE "data/pokemon/base_stats.asm"
@@ -1166,8 +1149,8 @@ ResetClock_:
DeleteSaveData_:
dr $8c310, $8c355
Predef35::
Predef36::
DummyPredef35::
DummyPredef36::
ret
UpdateTimeOfDayPal:: ; 8c356
@@ -1194,7 +1177,7 @@ FadeBlackQuickly:
Function8c3e9:: ; 8c3e9
dr $8c3e9, $8c513
Predef_StartBattle::
DoBattleTransition::
dr $8c513, $8ca5e
PlayWhirlpoolSound:
@@ -1267,7 +1250,7 @@ Function919c1:
TownMap_:
dr $91a4f, $91c7f
Area_::
Pokedex_GetArea::
dr $91c7f, $92c36
Function92c36:
dr $92c36, $94000
@@ -1371,7 +1354,7 @@ Functionc7cd0:
SECTION "bank32", ROMX, BANK[$32]
dr $c8000, $c80d6
Predef2F::
DummyPredef2F::
dr $c80d6, $c900a
INCLUDE "data/moves/animations.asm"
@@ -1386,8 +1369,8 @@ DisplayCaughtContestMonStats:
DisplayAlreadyCaughtText:
dr $cc0c8, $cc0d6
Predef38::
Predef39::
DummyPredef38::
DummyPredef39::
ret
PlayBattleAnim::
@@ -1495,7 +1478,7 @@ MagikarpHouseSign:
SECTION "bank3f", ROMX, BANK[$3f]
nop
Predef3A::
DummyPredef3A::
ret
dr $fc002, $100000

View File

@@ -1,4 +1,4 @@
Predef_LoadSGBLayout: ; 8c2d (2:4c2d)
LoadSGBLayout: ; 8c2d (2:4c2d)
call CheckCGB
jp nz, Predef_LoadSGBLayoutCGB
ld a, b

175
wram.asm
View File

@@ -1,13 +1,16 @@
INCLUDE "includes.asm"
INCLUDE "contents.asm"
INCLUDE "constants.asm"
INCLUDE "macros/wram.asm"
INCLUDE "vram.asm"
SECTION "Audio RAM", WRAM0
wc000::
wMusic::
wMusicPlaying:: ; c000
; nonzero if playing
ds 1
wMusicPlaying:: db ; c100
wChannels::
wChannel1:: channel_struct wChannel1 ; c101
@@ -18,121 +21,113 @@ wChannel4:: channel_struct wChannel4 ; c197
wSFXChannels::
wChannel5:: channel_struct wChannel5 ; c1c9
wChannel6:: channel_struct wChannel6 ; c1fb
wChannel7:: channel_struct wChannel7 ; c12d
wChannel8:: channel_struct wChannel8 ; c15f
wChannel7:: channel_struct wChannel7 ; c22d
wChannel8:: channel_struct wChannel8 ; c25f
ds 1 ; c191
wCurTrackDuty:: ds 1
wCurTrackIntensity:: ds 1
ds 1 ; c291
wCurTrackDuty:: db
wCurTrackIntensity:: db
wCurTrackFrequency:: dw
wUnusedBCDNumber:: db ; BCD value, dummied out
wCurNoteDuration:: ds 1 ; used in MusicE0 and LoadNote
wCurNoteDuration:: db ; used in MusicE0 and LoadNote
wCurMusicByte:: ; c198
ds 1
wCurChannel:: ; c199
ds 1
wVolume:: ; c19a
; corresponds to $ff24
wCurMusicByte:: db ; c298
wCurChannel:: db ; c299
wVolume:: ; c29a
; corresponds to rNR50
; Channel control / ON-OFF / Volume (R/W)
; bit 7 - Vin->SO2 ON/OFF
; bit 6-4 - SO2 output level (volume) (# 0-7)
; bit 3 - Vin->SO1 ON/OFF
; bit 2-0 - SO1 output level (volume) (# 0-7)
ds 1
wSoundOutput:: ; c19b
; corresponds to $ff25
db
wSoundOutput:: ; c29b
; corresponds to rNR51
; bit 4-7: ch1-4 so2 on/off
; bit 0-3: ch1-4 so1 on/off
ds 1
wSoundInput:: ; c19c
; corresponds to $ff26
db
wSoundInput:: ; c29c
; corresponds to rNR52
; bit 7: global on/off
; bit 0: ch1 on/off
; bit 1: ch2 on/off
; bit 2: ch3 on/off
; bit 3: ch4 on/off
ds 1
db
wMusicID::
wMusicIDLo:: ; c19d
ds 1
wMusicIDHi:: ; c19e
ds 1
wMusicBank:: ; c19f
ds 1
wNoiseSampleAddress::
wNoiseSampleAddressLo:: ; c1a0
ds 1
wNoiseSampleAddressHi:: ; c1a1
ds 1
wNoiseSampleDelay:: ; noise delay? ; c1a2
ds 1
; c1a3
ds 1
wMusicNoiseSampleSet:: ; c1a4
ds 1
wSFXNoiseSampleSet:: ; c1a5
ds 1
wLowHealthAlarm:: ; c1a6
wMusicID:: dw ; c29d
wMusicBank:: db ; c29f
wNoiseSampleAddress:: dw ; c2a0
wNoiseSampleDelay:: db ; c2a2
ds 1 ; c2a3
wMusicNoiseSampleSet:: db ; c2a4
wSFXNoiseSampleSet:: db ; c2a5
wLowHealthAlarm:: ; c2a6
; bit 7: on/off
; bit 4: pitch
; bit 0-3: counter
ds 1
wMusicFade:: ; c1a7
db
wMusicFade:: ; c2a7
; fades volume over x frames
; bit 7: fade in/out
; bit 0-5: number of frames for each volume level
; $00 = none (default)
ds 1
wMusicFadeCount:: ; c1a8
ds 1
wMusicFadeID::
wMusicFadeIDLo:: ; c1a9
ds 1
wMusicFadeIDHi:: ; c1aa
ds 1
db
wMusicFadeCount:: db ; c2a8
wMusicFadeID:: dw ; c2a9
ds 5
wCryPitch:: ; c1b0
ds 2
wCryLength:: ; c1b2
ds 2
wLastVolume:: ; c1b4
ds 1
wUnusedMusicF9Flag:: ds 1 ; c1b5
wSFXPriority:: ; c1b6
wCryPitch:: dw ; c2b0
wCryLength:: dw ; c2b2
wLastVolume:: db ; c2b4
wUnusedMusicF9Flag:: db ; c2b5
wSFXPriority:: ; c2b6
; if nonzero, turn off music when playing sfx
db
ds 1
ds 1
wChannel1JumpCondition:: ds 1
wChannel2JumpCondition:: ds 1
wChannel3JumpCondition:: ds 1
wChannel4JumpCondition:: ds 1
wStereoPanningMask:: ds 1 ; c1bc
wCryTracks:: ; c1bd
wChannel1JumpCondition:: db
wChannel2JumpCondition:: db
wChannel3JumpCondition:: db
wChannel4JumpCondition:: db
wStereoPanningMask:: db ; c2bc
wCryTracks:: ; c2bd
; plays only in left or right track depending on what side the monster is on
; both tracks active outside of battle
ds 1
wSFXDuration:: ds 1
wCurSFX:: ; c1bf
; id of sfx currently playing
ds 1
wChannelsEnd::
wMapMusic:: ; c1c0
ds 1
db
wDontPlayMapMusicOnReload:: ds 1
wSFXDuration:: db
wCurSFX:: ; c2bf
; id of sfx currently playing
db
wChannelsEnd::
wMapMusic:: db ; c2c0
wDontPlayMapMusicOnReload:: db
wMusicEnd::
SECTION "WRAM", WRAM0
wLZAddress:: dw ; c1c2
wLZBank:: ds 1 ; c1c4
wc1c5:: ds 1 ; c1c5
wInputType:: ds 1 ; c1c6
wAutoInputAddress:: dw ; c1c7
wAutoInputBank:: ds 1 ; c1c9
wAutoInputLength:: ds 1 ; c1ca
SECTION "WRAM", WRAM0
wLZAddress:: dw ; c2c2
wLZBank:: db ; c2c4
wBoxAlignment:: db
wInputType:: db ; c2c6
wAutoInputAddress:: dw ; c2c7
wAutoInputBank:: db ; c2c9
wAutoInputLength:: db ; c2ca
wMonStatusFlags:: ds 1 ; c1cb
wGameLogicPaused:: ds 1 ; c1cc
@@ -2433,8 +2428,8 @@ wcfd8:: ds 1 ; cfd8
wcfd9:: ds 1 ; cfd9
wcfda:: ds 1 ; cfda
wPredefID:: ds 1 ; cfdb
wPredefHLBuffer:: dw ; cfdc
wPredefPointerBuffer:: dw ; cfde
wPredefTemp:: dw ; cfdc
wPredefAddress:: dw ; cfde
wFarCallBCBuffer:: dw ; cfe0
wcfe2:: ds 1 ; cfe2
wcfe3:: ds 1 ; cfe3
@@ -2841,11 +2836,11 @@ wOptions:: ; d199
ds 1
wSaveFileExists:: ds 1 ; d19a
wTextBoxFrame:: ; d19b
wTextboxFrame:: ; d19b
; bits 0-2: textbox frame 0-7
ds 1
wTextBoxFlags:: ; d19c
wTextboxFlags:: ; d19c
; bit 0: 1-frame text delay
; bit 1: when unset, no text delay
ds 1