summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@gmail.com>2015-12-24 22:58:42 -0500
committerPikalaxALT <PikalaxALT@gmail.com>2015-12-24 22:58:42 -0500
commita5e928eb984d8995d17e42d415f687f5affb2935 (patch)
tree987ca936c71a712feabbf831f306b79d1feac7bf
parent1df28a6beb1f25bba384e446febe833c68b17056 (diff)
writebackup --> closewindow; game corner prize vendors; others
-rw-r--r--battle/core.asm8
-rw-r--r--battle/effect_commands.asm6
-rwxr-xr-xengine/billspc.asm2
-rwxr-xr-xengine/breeding/egg.asm2
-rw-r--r--engine/events.asm19
-rwxr-xr-xengine/init_gender.asm2
-rwxr-xr-xengine/intro_menu.asm8
-rwxr-xr-xengine/mail.asm2
-rwxr-xr-xengine/main_menu.asm2
-rw-r--r--engine/map_objects.asm16
-rwxr-xr-xengine/move_mon.asm1808
-rw-r--r--engine/pack.asm3
-rwxr-xr-xengine/player_step.asm271
-rwxr-xr-xengine/pokecenter_pc.asm2
-rw-r--r--engine/save.asm2
-rw-r--r--engine/scripting.asm8
-rwxr-xr-xengine/selectmenu.asm6
-rwxr-xr-xengine/slot_machine.asm4
-rwxr-xr-xengine/startmenu.asm4
-rw-r--r--engine/std_scripts.asm2
-rw-r--r--event/buena.asm4
-rwxr-xr-xevent/daycare.asm138
-rwxr-xr-xevent/elevator.asm2
-rw-r--r--event/kurt.asm2
-rw-r--r--event/mom.asm6
-rw-r--r--event/unown.asm2
-rw-r--r--home/menu.asm6
-rw-r--r--home/tilemap.asm2
-rw-r--r--home/window.asm2
-rw-r--r--macros/event.asm6
-rw-r--r--main.asm2360
-rw-r--r--maps/CeladonDeptStore6F.asm2
-rw-r--r--maps/CeladonGameCornerPrizeRoom.asm86
-rw-r--r--maps/DragonShrine.asm10
-rw-r--r--maps/EarlsPokemonAcademy.asm2
-rw-r--r--maps/GoldenrodCity.asm2
-rw-r--r--maps/GoldenrodDeptStore6F.asm2
-rw-r--r--maps/GoldenrodGameCorner.asm348
-rw-r--r--maps/GoldenrodPokeComCenter2FMobile.asm4
-rw-r--r--misc/mobile_22.asm8
-rw-r--r--misc/mobile_40.asm4
-rwxr-xr-xmisc/mobile_46.asm4
-rw-r--r--misc/mobile_5f.asm4
-rw-r--r--wram.asm23
44 files changed, 2605 insertions, 2601 deletions
diff --git a/battle/core.asm b/battle/core.asm
index 09ebefee9..dcc4fe31d 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -2932,7 +2932,7 @@ ForcePlayerMonChoice: ; 3d227
call ClearPalettes
call DelayFrame
call _LoadHPBar
- call WriteBackup
+ call CloseWindow
call GetMemSGBLayout
call SetPalettes
call SendOutPkmnText
@@ -5368,7 +5368,7 @@ BattleMenuPKMN_Loop:
call ClearPalettes
call DelayFrame
call _LoadHPBar
- call WriteBackup
+ call CloseWindow
call LoadTileMapToTempTileMap
call GetMemSGBLayout
call SetPalettes
@@ -5451,7 +5451,7 @@ TryPlayerSwitch: ; 3e358
call DelayFrame
call ClearSprites
call _LoadHPBar
- call WriteBackup
+ call CloseWindow
call GetMemSGBLayout
call SetPalettes
ld a, [CurPartyMon]
@@ -5464,7 +5464,7 @@ PlayerSwitch: ; 3e3ad
jr z, .not_linked
call LoadStandardMenuDataHeader
call LinkBattleSendReceiveAction
- call WriteBackup
+ call CloseWindow
.not_linked
call ParseEnemyAction
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index e7d4878bc..a52fb46db 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -8961,7 +8961,7 @@ BattleCommand_BatonPass: ; 379c9
; Return to battle scene
call ClearPalettes
callba _LoadBattleFontsHPBar
- call WriteBackup
+ call CloseWindow
call ClearSprites
hlcoord 1, 0
lb bc, 4, 10
@@ -9030,7 +9030,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67
call LoadStandardMenuDataHeader
ld hl, LinkBattleSendReceiveAction
call CallBattleCore
- call WriteBackup
+ call CloseWindow
xor a
ld [wPlayerAction], a
@@ -9061,7 +9061,7 @@ BatonPass_LinkEnemySwitch: ; 37a82
add BATTLEACTION_SWITCH1
ld [wBattleAction], a
.switch
- jp WriteBackup
+ jp CloseWindow
; 37aab
diff --git a/engine/billspc.asm b/engine/billspc.asm
index 14f0509b2..d77836061 100755
--- a/engine/billspc.asm
+++ b/engine/billspc.asm
@@ -2331,7 +2331,7 @@ _ChangeBox: ; e35aa (38:75aa)
call BillsPC_ChangeBoxSubmenu
jr .loop
.done
- call WriteBackup
+ call CloseWindow
ret
BillsPC_ClearTilemap: ; e35e2 (38:75e2)
diff --git a/engine/breeding/egg.asm b/engine/breeding/egg.asm
index d5ac77802..c9d401403 100755
--- a/engine/breeding/egg.asm
+++ b/engine/breeding/egg.asm
@@ -201,7 +201,7 @@ DoEggStep:: ; 16f3e
; 16f5e
OverworldHatchEgg:: ; 16f5e
- call ResetWindow
+ call RefreshScreen
call LoadStandardMenuDataHeader
call HatchEggs
call ExitAllMenus
diff --git a/engine/events.asm b/engine/events.asm
index 4dbe202cd..fcab94ef3 100644
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -228,28 +228,27 @@ HandleMapTimeAndJoypad: ; 967c1
Function967d1: ; 967d1
callba Function576a ; engine/map_objects.asm
- callba Functiond497
- call Function96812
+ callba _HandlePlayerStep
+ call _CheckObjectEnteringVisibleRange
ret
; 967e1
Function967e1: ; 967e1
callba _UpdateSprites
- callba Functiond4d2
+ callba ScrollScreen
callba PlaceMapNameSign
ret
; 967f4
Function967f4: ; 967f4
ld a, [wPlayerStepFlags]
- bit 5, a
+ bit 5, a ; in the middle of step
jr z, .events
- bit 6, a
+ bit 6, a ; stopping step
jr z, .noevents
- bit 4, a
+ bit 4, a ; in midair
jr nz, .noevents
call EnableEvents
-
.events
ld a, 0 ; events
ld [MapEventStatus], a
@@ -261,17 +260,15 @@ Function967f4: ; 967f4
ret
; 96812
-Function96812: ; 96812
+_CheckObjectEnteringVisibleRange: ; 96812
ld hl, wPlayerStepFlags
bit 6, [hl]
ret z
-
- callba Function81ca
+ callba CheckObjectEnteringVisibleRange
ret
; 9681f
PlayerEvents: ; 9681f
-
xor a
; If there's already a player event, don't interrupt it.
ld a, [ScriptRunning]
diff --git a/engine/init_gender.asm b/engine/init_gender.asm
index e4fbfd9e6..5de576c2a 100755
--- a/engine/init_gender.asm
+++ b/engine/init_gender.asm
@@ -34,7 +34,7 @@ InitGender: ; 48dcb (12:4dcb)
call LoadMenuDataHeader
call WaitBGMap2
call VerticalMenu
- call WriteBackup
+ call CloseWindow
ld a, [wMenuCursorY]
dec a
ld [PlayerGender], a
diff --git a/engine/intro_menu.asm b/engine/intro_menu.asm
index ddc728c4f..187dc0347 100755
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -362,13 +362,13 @@ Continue: ; 5d65
call DelayFrames
call ConfirmContinue
jr nc, .Check1Pass
- call WriteBackup
+ call CloseWindow
jr .FailToLoad
.Check1Pass
call Continue_CheckRTC_RestartClock
jr nc, .Check2Pass
- call WriteBackup
+ call CloseWindow
jr .FailToLoad
.Check2Pass
@@ -380,7 +380,7 @@ Continue: ; 5d65
ld [MusicFadeIDHi], a
call ClearBGPalettes
call Continue_MobileAdapterMenu
- call WriteBackup
+ call CloseWindow
call ClearTileMap
ld c, 20
call DelayFrames
@@ -832,7 +832,7 @@ Function60e9: ; Unreferenced
ld a, [wMenuCursorY]
dec a
call CopyNameFromMenu
- call WriteBackup
+ call CloseWindow
ret
; 60fa
diff --git a/engine/mail.asm b/engine/mail.asm
index 4c0af5f9b..0ca814c80 100755
--- a/engine/mail.asm
+++ b/engine/mail.asm
@@ -315,7 +315,7 @@ _KrisMailBoxMenu: ; 0x447a0
jr z, .nomail
call LoadStandardMenuDataHeader
call MailboxPC
- jp WriteBackup
+ jp CloseWindow
.nomail
ld hl, .EmptyMailboxText
diff --git a/engine/main_menu.asm b/engine/main_menu.asm
index 2012bf5ff..8d56d9fe0 100755
--- a/engine/main_menu.asm
+++ b/engine/main_menu.asm
@@ -17,7 +17,7 @@ MainMenu: ; 49cdc
ld hl, .MenuDataHeader
call LoadMenuDataHeader
call MainMenuJoypadLoop
- call WriteBackup
+ call CloseWindow
jr c, .quit
call ClearTileMap
ld a, [MenuSelection]
diff --git a/engine/map_objects.asm b/engine/map_objects.asm
index 3c509642c..21e601cdf 100644
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2875,7 +2875,7 @@ Function56a3: ; 56a3
; 56cd
Function56cd: ; 56cd
- ld a, [wd14c]
+ ld a, [wFollowNotExactPersonX]
ld d, a
ld hl, OBJECT_SPRITE_X_OFFSET
add hl, bc
@@ -2907,7 +2907,7 @@ Function56cd: ; 56cd
.ok3
ld [hUsedSpriteIndex], a
- ld a, [wd14d]
+ ld a, [wFollowNotExactPersonY]
ld e, a
ld hl, OBJECT_SPRITE_Y_OFFSET
add hl, bc
@@ -3357,9 +3357,9 @@ Function5958: ; 5958
push hl
push de
push bc
- ld a, [wd14c]
+ ld a, [wFollowNotExactPersonX]
ld d, a
- ld a, [wd14d]
+ ld a, [wFollowNotExactPersonY]
ld e, a
ld bc, ObjectStructs
ld a, NUM_OBJECT_STRUCTS
@@ -3391,8 +3391,8 @@ Function5958: ; 5958
jr nz, .loop
xor a
- ld [wd14c], a
- ld [wd14d], a
+ ld [wFollowNotExactPersonX], a
+ ld [wFollowNotExactPersonY], a
pop bc
pop de
pop hl
@@ -3544,7 +3544,7 @@ PRIORITY_HIGH EQU $30
add 8
ld e, a
- ld a, [wd14c]
+ ld a, [wFollowNotExactPersonX]
add e
ld [hFFBF], a
@@ -3559,7 +3559,7 @@ PRIORITY_HIGH EQU $30
add 12
ld e, a
- ld a, [wd14d]
+ ld a, [wFollowNotExactPersonY]
add e
ld [hFFC0], a
diff --git a/engine/move_mon.asm b/engine/move_mon.asm
new file mode 100755
index 000000000..de35f664e
--- /dev/null
+++ b/engine/move_mon.asm
@@ -0,0 +1,1808 @@
+TryAddMonToParty: ; d88c
+; Check if to copy wild Pkmn or generate new Pkmn
+ ; Whose is it?
+ ld de, PartyCount
+ ld a, [MonType]
+ and $f
+ jr z, .getpartylocation ; PARTYMON
+ ld de, OTPartyCount
+
+.getpartylocation
+ ; Do we have room for it?
+ ld a, [de]
+ inc a
+ cp PARTY_LENGTH + 1
+ ret nc
+ ; Increase the party count
+ ld [de], a
+ ld a, [de] ; Why are we doing this?
+ ld [$ffae], a ; HRAM backup
+ add e
+ ld e, a
+ jr nc, .loadspecies
+ inc d
+
+.loadspecies
+ ; Load the species of the Pokemon into the party list.
+ ; The terminator is usually here, but it'll be back.
+ ld a, [CurPartySpecies]
+ ld [de], a
+ ; Load the terminator into the next slot.
+ inc de
+ ld a, -1
+ ld [de], a
+ ; Now let's load the OT name.
+ ld hl, PartyMonOT
+ ld a, [MonType]
+ and $f
+ jr z, .loadOTname
+ ld hl, OTPartyMonOT
+
+.loadOTname
+ ld a, [$ffae] ; Restore index from backup
+ dec a
+ call SkipNames
+ ld d, h
+ ld e, l
+ ld hl, PlayerName
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ld a, [MonType]
+ and a
+ jr nz, .skipnickname
+ ld a, [CurPartySpecies]
+ ld [wd265], a
+ call GetPokemonName
+ ld hl, PartyMonNicknames
+ ld a, [$ffae]
+ dec a
+ call SkipNames
+ ld d, h
+ ld e, l
+ ld hl, StringBuffer1
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+
+.skipnickname
+ ld hl, PartyMon1Species
+ ld a, [MonType]
+ and $f
+ jr z, .initializeStats
+ ld hl, OTPartyMon1Species
+
+.initializeStats
+ ld a, [$ffae]
+ dec a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+GeneratePartyMonStats: ; d906
+ ld e, l
+ ld d, h
+ push hl
+ ld a, [CurPartySpecies]
+ ld [CurSpecies], a
+ call GetBaseData
+ ld a, [BaseDexNo]
+ ld [de], a
+ inc de
+ ld a, [wBattleMode]
+ and a
+ ld a, $0
+ jr z, .skipitem
+ ld a, [EnemyMonItem]
+
+.skipitem
+ ld [de], a
+ inc de
+ push de
+ ld h, d
+ ld l, e
+ ld a, [wBattleMode]
+ and a
+ jr z, .randomlygeneratemoves
+ ld a, [MonType]
+ and a
+ jr nz, .randomlygeneratemoves
+ ld de, EnemyMonMoves
+ rept NUM_MOVES + -1
+ ld a, [de]
+ inc de
+ ld [hli], a
+ endr
+ ld a, [de]
+ ld [hl], a
+ jr .next
+
+.randomlygeneratemoves
+ xor a
+ rept NUM_MOVES + -1
+ ld [hli], a
+ endr
+ ld [hl], a
+ ld [Buffer1], a
+ predef FillMoves
+
+.next
+ pop de
+rept 4
+ inc de
+endr
+ ld a, [PlayerID]
+ ld [de], a
+ inc de
+ ld a, [PlayerID + 1]
+ ld [de], a
+ inc de
+ push de
+ ld a, [CurPartyLevel]
+ ld d, a
+ callab CalcExpAtLevel
+ pop de
+ ld a, [hProduct + 1]
+ ld [de], a
+ inc de
+ ld a, [hProduct + 2]
+ ld [de], a
+ inc de
+ ld a, [hProduct + 3]
+ ld [de], a
+ inc de
+ xor a
+ ld b, $a
+.loop
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .loop
+ pop hl
+ push hl
+ ld a, [MonType]
+ and $f
+ jr z, .generateDVs
+ push hl
+ callba GetTrainerDVs
+ pop hl
+ jr .initializetrainermonstats
+
+.generateDVs
+ ld a, [CurPartySpecies]
+ ld [wd265], a
+ dec a
+ push de
+ call CheckCaughtMon
+ ld a, [wd265]
+ dec a
+ call SetSeenAndCaughtMon
+ pop de
+ pop hl
+ push hl
+ ld a, [wBattleMode]
+ and a
+ jr nz, .copywildmonstats
+ call Random
+ ld b, a
+ call Random
+ ld c, a
+
+.initializetrainermonstats
+ ld a, b
+ ld [de], a
+ inc de
+ ld a, c
+ ld [de], a
+ inc de
+ push hl
+ push de
+rept 2
+ inc hl
+endr
+ call FillPP
+ pop de
+ pop hl
+rept 4
+ inc de
+endr
+ ld a, 70
+ ld [de], a
+ inc de
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld a, [CurPartyLevel]
+ ld [de], a
+ inc de
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld bc, 10
+ add hl, bc
+ ld a, $1
+ ld c, a
+ ld b, FALSE
+ call CalcPkmnStatC
+ ld a, [hProduct + 2]
+ ld [de], a
+ inc de
+ ld a, [hProduct + 3]
+ ld [de], a
+ inc de
+ jr .next2
+
+.copywildmonstats
+ ld a, [EnemyMonDVs]
+ ld [de], a
+ inc de
+ ld a, [EnemyMonDVs + 1]
+ ld [de], a
+ inc de
+
+ push hl
+ ld hl, EnemyMonPP
+ ld b, NUM_MOVES
+.wildmonpploop
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .wildmonpploop
+ pop hl
+
+ ld a, BASE_HAPPINESS
+ ld [de], a
+ inc de
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld a, [CurPartyLevel]
+ ld [de], a
+ inc de
+ ld hl, EnemyMonStatus
+ ; Copy EnemyMonStatus
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ; Copy EnemyMonUnused
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ; Copy EnemyMonHP
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ inc de
+
+.next2
+ ld a, [wBattleMode]
+ dec a
+ jr nz, .generatestats
+ ld hl, EnemyMonMaxHP
+ ld bc, 2*6 ; MaxHP + 5 Stats
+ call CopyBytes
+ pop hl
+ jr .next3
+
+.generatestats
+ pop hl
+ ld bc, 2*5 ; 5 Stats
+ add hl, bc
+ ld b, $0 ; if b = 1, then the Stats of the Pkmn are calculated
+ ; only the current HP aren't set to MaxHP after this
+ call CalcPkmnStats
+
+.next3
+ ld a, [MonType]
+ and $f
+ jr nz, .done
+ ld a, [CurPartySpecies]
+ cp UNOWN
+ jr nz, .done
+ ld hl, PartyMon1DVs
+ ld a, [PartyCount]
+ dec a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ predef GetUnownLetter
+ callab UpdateUnownDex
+
+.done
+ scf ; When this function returns, the carry flag indicates success vs failure.
+ ret
+; da6d
+
+FillPP: ; da6d
+ push bc
+ ld b, NUM_MOVES
+.loop
+ ld a, [hli]
+ and a
+ jr z, .next
+ dec a
+ push hl
+ push de
+ push bc
+ ld hl, Moves
+ ld bc, MOVE_LENGTH
+ call AddNTimes
+ ld de, StringBuffer1
+ ld a, BANK(Moves)
+ call FarCopyBytes
+ pop bc
+ pop de
+ pop hl
+ ld a, [StringBuffer1 + MOVE_PP]
+
+.next
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .loop
+ pop bc
+ ret
+; da96
+
+AddTempmonToParty: ; da96
+ ld hl, PartyCount
+ ld a, [hl]
+ cp PARTY_LENGTH
+ scf
+ ret z
+
+ inc a
+ ld [hl], a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [CurPartySpecies]
+ ld [hli], a
+ ld [hl], $ff
+
+ ld hl, PartyMon1Species
+ ld a, [PartyCount]
+ dec a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld e, l
+ ld d, h
+ ld hl, TempMonSpecies
+ call CopyBytes
+
+ ld hl, PartyMonOT
+ ld a, [PartyCount]
+ dec a
+ call SkipNames
+ ld d, h
+ ld e, l
+ ld hl, OTPartyMonOT
+ ld a, [CurPartyMon]
+ call SkipNames
+ ld bc, NAME_LENGTH
+ call CopyBytes
+
+ ld hl, PartyMonNicknames
+ ld a, [PartyCount]
+ dec a
+ call SkipNames
+ ld d, h
+ ld e, l
+ ld hl, OTPartyMonNicknames
+ ld a, [CurPartyMon]
+ call SkipNames
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+
+ ld a, [CurPartySpecies]
+ ld [wNamedObjectIndexBuffer], a
+ cp EGG
+ jr z, .egg
+ dec a
+ call SetSeenAndCaughtMon
+ ld hl, PartyMon1Happiness
+ ld a, [PartyCount]
+ dec a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld [hl], BASE_HAPPINESS
+.egg
+
+ ld a, [CurPartySpecies]
+ cp UNOWN
+ jr nz, .done
+ ld hl, PartyMon1DVs
+ ld a, [PartyCount]
+ dec a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ predef GetUnownLetter
+ callab UpdateUnownDex
+ ld a, [wFirstUnownSeen]
+ and a
+ jr nz, .done
+ ld a, [UnownLetter]
+ ld [wFirstUnownSeen], a
+.done
+
+ and a
+ ret
+
+SentGetPkmnIntoFromBox: ; db3f
+; Sents/Gets Pkmn into/from Box depending on Parameter
+; wPokemonWithdrawDepositParameter == 0: get Pkmn into Party
+; wPokemonWithdrawDepositParameter == 1: sent Pkmn into Box
+; wPokemonWithdrawDepositParameter == 2: get Pkmn from DayCare
+; wPokemonWithdrawDepositParameter == 3: put Pkmn into DayCare
+
+ ld a, BANK(sBoxCount)
+ call GetSRAMBank
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .check_IfPartyIsFull
+ cp DAYCARE_WITHDRAW
+ jr z, .check_IfPartyIsFull
+ cp DAYCARE_DEPOSIT
+ ld hl, wBreedMon1Species
+ jr z, .breedmon
+
+ ; we want to sent a Pkmn into the Box
+ ; so check if there's enough space
+ ld hl, sBoxCount
+ ld a, [hl]
+ cp MONS_PER_BOX
+ jr nz, .there_is_room
+ jp CloseSRAM_And_SetCarryFlag
+
+.check_IfPartyIsFull
+ ld hl, PartyCount
+ ld a, [hl]
+ cp PARTY_LENGTH
+ jp z, CloseSRAM_And_SetCarryFlag
+
+.there_is_room
+ inc a
+ ld [hl], a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [wPokemonWithdrawDepositParameter]
+ cp DAYCARE_WITHDRAW
+ ld a, [wBreedMon1Species]
+ jr z, .okay1
+ ld a, [CurPartySpecies]
+
+.okay1
+ ld [hli], a
+ ld [hl], $ff
+ ld a, [wPokemonWithdrawDepositParameter]
+ dec a
+ ld hl, PartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld a, [PartyCount]
+ jr nz, .okay2
+ ld hl, sBoxMon1Species
+ ld bc, BOXMON_STRUCT_LENGTH
+ ld a, [sBoxCount]
+
+.okay2
+ dec a ; PartyCount - 1
+ call AddNTimes
+
+.breedmon
+ push hl
+ ld e, l
+ ld d, h
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ ld hl, sBoxMon1Species
+ ld bc, BOXMON_STRUCT_LENGTH
+ jr z, .okay3
+ cp DAYCARE_WITHDRAW
+ ld hl, wBreedMon1Species
+ jr z, .okay4
+ ld hl, PartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+
+.okay3
+ ld a, [CurPartyMon]
+ call AddNTimes
+
+.okay4
+ ld bc, BOXMON_STRUCT_LENGTH
+ call CopyBytes
+ ld a, [wPokemonWithdrawDepositParameter]
+ cp DAYCARE_DEPOSIT
+ ld de, wBreedMon1OT
+ jr z, .okay5
+ dec a
+ ld hl, PartyMonOT
+ ld a, [PartyCount]
+ jr nz, .okay6
+ ld hl, sBoxMonOT
+ ld a, [sBoxCount]
+
+.okay6
+ dec a
+ call SkipNames
+ ld d, h
+ ld e, l
+
+.okay5
+ ld hl, sBoxMonOT
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .okay7
+ ld hl, wBreedMon1OT
+ cp DAYCARE_WITHDRAW
+ jr z, .okay8
+ ld hl, PartyMonOT
+
+.okay7
+ ld a, [CurPartyMon]
+ call SkipNames
+
+.okay8
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ld a, [wPokemonWithdrawDepositParameter]
+ cp DAYCARE_DEPOSIT
+ ld de, wBreedMon1Nick
+ jr z, .okay9
+ dec a
+ ld hl, PartyMonNicknames
+ ld a, [PartyCount]
+ jr nz, .okay10
+ ld hl, sBoxMonNicknames
+ ld a, [sBoxCount]
+
+.okay10
+ dec a
+ call SkipNames
+ ld d, h
+ ld e, l
+
+.okay9
+ ld hl, sBoxMonNicknames
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .okay11
+ ld hl, wBreedMon1Nick
+ cp DAYCARE_WITHDRAW
+ jr z, .okay12
+ ld hl, PartyMonNicknames
+
+.okay11
+ ld a, [CurPartyMon]
+ call SkipNames
+
+.okay12
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+ pop hl
+
+ ld a, [wPokemonWithdrawDepositParameter]
+ cp PC_DEPOSIT
+ jr z, .took_out_of_box
+ cp DAYCARE_DEPOSIT
+ jp z, .CloseSRAM_And_ClearCarryFlag
+
+ push hl
+ srl a
+ add $2
+ ld [MonType], a
+ predef CopyPkmnToTempMon
+ callab CalcLevel
+ ld a, d
+ ld [CurPartyLevel], a
+ pop hl
+
+ ld b, h
+ ld c, l
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld [hl], a
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld hl, MON_STAT_EXP - 1
+ add hl, bc
+
+ push bc
+ ld b, $1
+ call CalcPkmnStats
+ pop bc
+
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr nz, .CloseSRAM_And_ClearCarryFlag
+ ld hl, MON_STATUS
+ add hl, bc
+ xor a
+ ld [hl], a
+ ld hl, MON_HP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld a, [CurPartySpecies]
+ cp EGG
+ jr z, .egg
+rept 2
+ inc hl
+endr
+ ld a, [hli]
+ ld [de], a
+ ld a, [hl]
+ inc de
+ ld [de], a
+ jr .CloseSRAM_And_ClearCarryFlag
+
+.egg
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ jr .CloseSRAM_And_ClearCarryFlag
+
+.took_out_of_box
+ ld a, [sBoxCount]
+ dec a
+ ld b, a
+ call Functiondcb6
+.CloseSRAM_And_ClearCarryFlag
+ call CloseSRAM
+ and a
+ ret
+; dcb1
+
+CloseSRAM_And_SetCarryFlag: ; dcb1
+ call CloseSRAM
+ scf
+ ret
+; dcb6
+
+Functiondcb6: ; dcb6
+ ld a, b
+ ld hl, sBoxMons
+ ld bc, BOXMON_STRUCT_LENGTH
+ call AddNTimes
+ ld b, h
+ ld c, l
+ ld hl, MON_PP
+ add hl, bc
+ push hl
+ push bc
+ ld de, TempMonPP
+ ld bc, NUM_MOVES
+ call CopyBytes
+ pop bc
+ ld hl, MON_MOVES
+ add hl, bc
+ push hl
+ ld de, TempMonMoves
+ ld bc, NUM_MOVES
+ call CopyBytes
+ pop hl
+ pop de
+
+ ld a, [wMenuCursorY]
+ push af
+ ld a, [MonType]
+ push af
+ ld b, 0
+.asm_dcec
+ ld a, [hli]
+ and a
+ jr z, .asm_dd18
+ ld [TempMonMoves], a
+ ld a, BOXMON
+ ld [MonType], a
+ ld a, b
+ ld [wMenuCursorY], a
+ push bc
+ push hl
+ push de
+ callba GetMaxPPOfMove
+ pop de
+ pop hl
+ ld a, [wd265]
+ ld b, a
+ ld a, [de]
+ and %11000000
+ add b
+ ld [de], a
+ pop bc
+ inc de
+ inc b
+ ld a, b
+ cp NUM_MOVES
+ jr c, .asm_dcec
+
+.asm_dd18
+ pop af
+ ld [MonType], a
+ pop af
+ ld [wMenuCursorY], a
+ ret
+; dd21
+
+RetrievePokemonFromDaycareMan: ; dd21
+ ld a, [wBreedMon1Species]
+ ld [CurPartySpecies], a
+ ld de, SFX_TRANSACTION
+ call PlaySFX
+ call WaitSFX
+ call GetBreedMon1LevelGrowth
+ ld a, b
+ ld [wd002], a
+ ld a, e
+ ld [CurPartyLevel], a
+ xor a
+ ld [wPokemonWithdrawDepositParameter], a
+ jp Functiondd64
+; dd42
+
+RetrievePokemonFromDaycareLady: ; dd42
+ ld a, [wBreedMon2Species]
+ ld [CurPartySpecies], a
+ ld de, SFX_TRANSACTION
+ call PlaySFX
+ call WaitSFX
+ call GetBreedMon2LevelGrowth
+ ld a, b
+ ld [wd002], a
+ ld a, e
+ ld [CurPartyLevel], a
+ ld a, PC_DEPOSIT
+ ld [wPokemonWithdrawDepositParameter], a
+ jp Functiondd64
+; dd64
+
+Functiondd64: ; dd64
+ ld hl, PartyCount
+ ld a, [hl]
+ cp PARTY_LENGTH
+ jr nz, .room_in_party
+ scf
+ ret
+
+.room_in_party
+ inc a
+ ld [hl], a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ ld a, [wBreedMon1Species]
+ ld de, wBreedMon1Nick
+ jr z, .okay
+ ld a, [wBreedMon2Species]
+ ld de, wBreedMon2Nick
+
+.okay
+ ld [hli], a
+ ld [CurSpecies], a
+ ld a, $ff
+ ld [hl], a
+ ld hl, PartyMonNicknames
+ ld a, [PartyCount]
+ dec a
+ call SkipNames
+ push hl
+ ld h, d
+ ld l, e
+ pop de
+ call CopyBytes
+ push hl
+ ld hl, PartyMonOT
+ ld a, [PartyCount]
+ dec a
+ call SkipNames
+ ld d, h
+ ld e, l
+ pop hl
+ call CopyBytes
+ push hl
+ call Functionde1a
+ pop hl
+ ld bc, BOXMON_STRUCT_LENGTH
+ call CopyBytes
+ call GetBaseData
+ call Functionde1a
+ ld b, d
+ ld c, e
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [CurPartyLevel]
+ ld [hl], a
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld hl, $a
+ add hl, bc
+ push bc
+ ld b, $1
+ call CalcPkmnStats
+ ld hl, PartyMon1Moves
+ ld a, [PartyCount]
+ dec a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld a, $1
+ ld [Buffer1], a
+ predef FillMoves
+ ld a, [PartyCount]
+ dec a
+ ld [CurPartyMon], a
+ callba HealPartyMon
+ ld a, [CurPartyLevel]
+ ld d, a
+ callab CalcExpAtLevel
+ pop bc
+ ld hl, $8
+ add hl, bc
+ ld a, [hMultiplicand]
+ ld [hli], a
+ ld a, [hMultiplicand + 1]
+ ld [hli], a
+ ld a, [hMultiplicand + 2]
+ ld [hl], a
+ and a
+ ret
+; de1a
+
+Functionde1a: ; de1a
+ ld a, [PartyCount]
+ dec a
+ ld hl, PartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ret
+; de2a
+
+DepositMonWithDaycareMan: ; de2a
+ ld de, wBreedMon1Nick
+ call DepositBreedmon
+ xor a
+ ld [wPokemonWithdrawDepositParameter], a
+ jp RemoveMonFromPartyOrBox
+; de37
+
+DepositMonWithDaycareLady: ; de37
+ ld de, wBreedMon2Nick
+ call DepositBreedmon
+ xor a
+ ld [wPokemonWithdrawDepositParameter], a
+ jp RemoveMonFromPartyOrBox
+; de44
+
+DepositBreedmon: ; de44
+ ld a, [CurPartyMon]
+ ld hl, PartyMonNicknames
+ call SkipNames
+ call CopyBytes
+ ld a, [CurPartyMon]
+ ld hl, PartyMonOT
+ call SkipNames
+ call CopyBytes
+ ld a, [CurPartyMon]
+ ld hl, PartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld bc, BOXMON_STRUCT_LENGTH
+ jp CopyBytes
+
+SentPkmnIntoBox: ; de6e
+; Sents the Pkmn into one of Bills Boxes
+; the data comes mainly from 'EnemyMon:'
+ ld a, BANK(sBoxCount)
+ call GetSRAMBank
+ ld de, sBoxCount
+ ld a, [de]
+ cp MONS_PER_BOX
+ jp nc, .full
+ inc a
+ ld [de], a
+
+ ld a, [CurPartySpecies]
+ ld [CurSpecies], a
+ ld c, a
+.loop
+ inc de
+ ld a, [de]
+ ld b, a
+ ld a, c
+ ld c, b
+ ld [de], a
+ inc a
+ jr nz, .loop
+
+ call GetBaseData
+ call ShiftBoxMon
+
+ ld hl, PlayerName
+ ld de, sBoxMonOT
+ ld bc, NAME_LENGTH
+ call CopyBytes
+
+ ld a, [CurPartySpecies]
+ ld [wd265], a
+ call GetPokemonName
+
+ ld de, sBoxMonNicknames
+ ld hl, StringBuffer1
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+
+ ld hl, EnemyMon
+ ld de, sBoxMon1
+ ld bc, 1 + 1 + NUM_MOVES ; species + item + moves
+ call CopyBytes
+
+ ld hl, PlayerID
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ inc de
+ push de
+ ld a, [CurPartyLevel]
+ ld d, a
+ callab CalcExpAtLevel
+ pop de
+ ld a, [hProduct + 1]
+ ld [de], a
+ inc de
+ ld a, [hProduct + 2]
+ ld [de], a
+ inc de
+ ld a, [hProduct + 3]
+ ld [de], a
+ inc de
+
+ ; Set all 5 Experience Values to 0
+ xor a
+ ld b, 2 * 5
+.loop2
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .loop2
+
+ ld hl, EnemyMonDVs
+ ld b, 2 + NUM_MOVES ; DVs and PP ; EnemyMonHappiness - EnemyMonDVs
+.loop3
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .loop3
+
+ ld a, BASE_HAPPINESS
+ ld [de], a
+ inc de
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld [de], a
+ inc de
+ ld a, [CurPartyLevel]
+ ld [de], a
+ ld a, [CurPartySpecies]
+ dec a
+ call SetSeenAndCaughtMon
+ ld a, [CurPartySpecies]
+ cp UNOWN
+ jr nz, .not_unown
+ ld hl, sBoxMon1DVs
+ predef GetUnownLetter
+ callab UpdateUnownDex
+
+.not_unown
+ ld hl, sBoxMon1Moves
+ ld de, TempMonMoves
+ ld bc, NUM_MOVES
+ call CopyBytes
+
+ ld hl, sBoxMon1PP
+ ld de, TempMonPP
+ ld bc, NUM_MOVES
+ call CopyBytes
+
+ ld b, 0
+ call Functiondcb6
+
+ call CloseSRAM
+ scf
+ ret
+; df42
+
+.full: ; df42
+ call CloseSRAM
+ and a
+ ret
+; df47
+
+ShiftBoxMon: ; df47
+ ld hl, sBoxMonOT
+ ld bc, NAME_LENGTH
+ call .shift
+
+ ld hl, sBoxMonNicknames
+ ld bc, PKMN_NAME_LENGTH
+ call .shift
+
+ ld hl, sBoxMons
+ ld bc, BOXMON_STRUCT_LENGTH
+
+.shift
+ ld a, [sBoxCount]
+ cp 2
+ ret c
+
+ push hl
+ call AddNTimes
+ dec hl
+ ld e, l
+ ld d, h
+ pop hl
+
+ ld a, [sBoxCount]
+ dec a
+ call AddNTimes
+ dec hl
+
+ push hl
+ ld a, [sBoxCount]
+ dec a
+ ld hl, 0
+ call AddNTimes
+ ld c, l
+ ld b, h
+ pop hl
+.loop
+ ld a, [hld]
+ ld [de], a
+ dec de
+ dec bc
+ ld a, c
+ or b
+ jr nz, .loop
+ ret
+; df8c
+
+GiveEgg:: ; df8c
+ ld a, [CurPartySpecies]
+ push af
+ callab GetPreEvolution
+ callab GetPreEvolution
+ ld a, [CurPartySpecies]
+ dec a
+
+; TryAddMonToParty sets Seen and Caught flags
+; when it is successful. This routine will make
+; sure that we aren't newly setting flags.
+ push af
+ call CheckCaughtMon
+ pop af
+ push bc
+ call CheckSeenMon
+ push bc
+
+ call TryAddMonToParty
+
+; If we haven't caught this Pokemon before receiving
+; the Egg, reset the flag that was just set by
+; TryAddMonToParty.
+ pop bc
+ ld a, c
+ and a
+ jr nz, .skip_caught_flag
+ ld a, [CurPartySpecies]
+ dec a
+ ld c, a
+ ld d, $0
+ ld hl, PokedexCaught
+ ld b, RESET_FLAG
+ predef FlagPredef
+
+.skip_caught_flag
+; If we haven't seen this Pokemon before receiving
+; the Egg, reset the flag that was just set by
+; TryAddMonToParty.
+ pop bc
+ ld a, c
+ and a
+ jr nz, .skip_seen_flag
+ ld a, [CurPartySpecies]
+ dec a
+ ld c, a
+ ld d, $0
+ ld hl, PokedexSeen
+ ld b, RESET_FLAG
+ predef FlagPredef
+
+.skip_seen_flag
+ pop af
+ ld [CurPartySpecies], a
+ ld a, [PartyCount]
+ dec a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld hl, PartyMon1Species
+ call AddNTimes
+ ld a, [CurPartySpecies]
+ ld [hl], a
+ ld hl, PartyCount
+ ld a, [hl]
+ ld b, 0
+ ld c, a
+ add hl, bc
+ ld a, EGG
+ ld [hl], a
+ ld a, [PartyCount]
+ dec a
+ ld hl, PartyMonNicknames
+ call SkipNames
+ ld de, String_Egg
+ call CopyName2
+ ld a, [PartyCount]
+ dec a
+ ld hl, PartyMon1Happiness
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld a, [wc2cc]
+ bit 1, a
+ ld a, 1
+ jr nz, .got_init_happiness
+ ld a, [BaseEggSteps]
+
+.got_init_happiness
+ ld [hl], a
+ ld a, [PartyCount]
+ dec a
+ ld hl, PartyMon1HP
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ xor a
+ ld [hli], a
+ ld [hl], a
+ and a
+ ret
+; e035
+
+String_Egg: ; e035
+ db "EGG@"
+; e039
+
+RemoveMonFromPartyOrBox: ; e039
+ ld hl, PartyCount
+
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .okay
+
+ ld a, BANK(sBoxCount)
+ call GetSRAMBank
+ ld hl, sBoxCount
+
+.okay
+ ld a, [hl]
+ dec a
+ ld [hli], a
+ ld a, [CurPartyMon]
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld e, l
+ ld d, h
+ inc de
+.loop
+ ld a, [de]
+ inc de
+ ld [hli], a
+ inc a
+ jr nz, .loop
+ ld hl, PartyMonOT
+ ld d, PARTY_LENGTH - 1
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .party
+ ld hl, sBoxMonOT
+ ld d, MONS_PER_BOX - 1
+
+.party
+ ; If this is the last mon in our party (box),
+ ; shift all the other mons up to close the gap.
+ ld a, [CurPartyMon]
+ call SkipNames
+ ld a, [CurPartyMon]
+ cp d
+ jr nz, .delete_inside
+ ld [hl], -1
+ jp .finish
+
+.delete_inside
+ ; Shift the OT names
+ ld d, h
+ ld e, l
+ ld bc, PKMN_NAME_LENGTH
+ add hl, bc
+ ld bc, PartyMonNicknames
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .party2
+ ld bc, sBoxMonNicknames
+.party2
+ call CopyDataUntil
+ ; Shift the struct
+ ld hl, PartyMons
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .party4
+ ld hl, sBoxMons
+ ld bc, BOXMON_STRUCT_LENGTH
+.party4
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .party5
+ ld bc, BOXMON_STRUCT_LENGTH
+ add hl, bc
+ ld bc, sBoxMonOT
+ jr .copy
+
+.party5
+ ld bc, PARTYMON_STRUCT_LENGTH
+ add hl, bc
+ ld bc, PartyMonOT
+.copy
+ call CopyDataUntil
+ ; Shift the nicknames
+ ld hl, PartyMonNicknames
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .party6
+ ld hl, sBoxMonNicknames
+.party6
+ ld bc, PKMN_NAME_LENGTH
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld bc, PKMN_NAME_LENGTH
+ add hl, bc
+ ld bc, PartyMonNicknamesEnd
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jr z, .party7
+ ld bc, sBoxMonNicknamesEnd
+.party7
+ call CopyDataUntil
+ ; Mail time!
+.finish
+ ld a, [wPokemonWithdrawDepositParameter]
+ and a
+ jp nz, CloseSRAM
+ ld a, [wLinkMode]
+ and a
+ ret nz
+ ; Shift mail
+ ld a, BANK(sPartyMail)
+ call GetSRAMBank
+ ; If this is the last mon in our party, no need to shift mail.
+ ld hl, PartyCount
+ ld a, [CurPartyMon]
+ cp [hl]
+ jr z, .close_sram
+ ; Shift our mail messages up.
+ ld hl, sPartyMail
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ push hl
+ add hl, bc
+ pop de
+ ld a, [CurPartyMon]
+ ld b, a
+.loop2
+ push bc
+ push hl
+ ld bc, MAIL_STRUCT_LENGTH
+ call CopyBytes
+ pop hl
+ push hl
+ ld bc, MAIL_STRUCT_LENGTH
+ add hl, bc
+ pop de
+ pop bc
+ inc b
+ ld a, [PartyCount]
+ cp b
+ jr nz, .loop2
+.close_sram
+ jp CloseSRAM
+; e134
+
+
+ComputeNPCTrademonStats: ; e134
+ ld a, MON_LEVEL
+ call GetPartyParamLocation
+ ld a, [hl]
+ ld [MON_LEVEL], a ; wow
+ ld a, MON_SPECIES
+ call GetPartyParamLocation
+ ld a, [hl]
+ ld [CurSpecies], a
+ call GetBaseData
+ ld a, MON_MAXHP
+ call GetPartyParamLocation
+ ld d, h
+ ld e, l
+ push de
+ ld a, MON_STAT_EXP - 1
+ call GetPartyParamLocation
+ ld b, $1
+ call CalcPkmnStats
+ pop de
+ ld a, MON_HP
+ call GetPartyParamLocation
+ ld a, [de]
+ inc de
+ ld [hli], a
+ ld a, [de]
+ ld [hl], a
+ ret
+; e167
+
+CalcPkmnStats: ; e167
+; 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
+; hl is the path to the Stat EXP
+; results in $ffb5 and $ffb6 are saved in [de]
+
+ ld c, $0
+.loop
+ inc c
+ call CalcPkmnStatC
+ ld a, [hMultiplicand + 1]
+ ld [de], a
+ inc de
+ ld a, [hMultiplicand + 2]
+ ld [de], a
+ inc de
+ ld a, c
+ cp STAT_SDEF
+ jr nz, .loop
+ ret
+; e17b
+
+CalcPkmnStatC: ; e17b
+; 'c' is 1-6 and points to the BaseStat
+; 1: HP
+; 2: Attack
+; 3: Defense
+; 4: Speed
+; 5: SpAtk
+; 6: SpDef
+ push hl
+ push de
+ push bc
+ ld a, b
+ ld d, a
+ push hl
+ ld hl, BaseStats
+ dec hl ; has to be decreased, because 'c' begins with 1
+ ld b, $0
+ add hl, bc
+ ld a, [hl]
+ ld e, a
+ pop hl
+ push hl
+ ld a, c
+ cp STAT_SDEF
+ jr nz, .not_spdef
+rept 2
+ dec hl
+endr
+
+.not_spdef
+ sla c
+ ld a, d
+ and a
+ jr z, .SkipSqrt
+ add hl, bc
+ push de
+ ld a, [hld]
+ ld e, a
+ ld d, [hl]
+ callba GetSquareRoot
+ pop de
+
+.SkipSqrt
+ srl c
+ pop hl
+ push bc
+ ld bc, MON_DVS - MON_HP_EXP + 1
+ add hl, bc
+ pop bc
+ ld a, c
+ cp STAT_ATK
+ jr z, .Attack
+ cp STAT_DEF
+ jr z, .Defense
+ cp STAT_SPD
+ jr z, .Speed
+ cp STAT_SATK
+ jr z, .Special
+ cp STAT_SDEF
+ jr z, .Special
+; DV_HP = (DV_ATK & 1) << 3 + (DV_DEF & 1) << 2 + (DV_SPD & 1) << 1 + (DV_SPC & 1)
+ push bc
+ ld a, [hl]
+ swap a
+ and $1
+rept 3
+ add a
+endr
+ ld b, a
+ ld a, [hli]
+ and $1
+rept 2
+ add a
+endr
+ add b
+ ld b, a
+ ld a, [hl]
+ swap a
+ and $1
+ add a
+ add b
+ ld b, a
+ ld a, [hl]
+ and $1
+ add b
+ pop bc
+ jr .GotDV
+
+.Attack
+ ld a, [hl]
+ swap a
+ and $f
+ jr .GotDV
+
+.Defense
+ ld a, [hl]
+ and $f
+ jr .GotDV
+
+.Speed
+ inc hl
+ ld a, [hl]
+ swap a
+ and $f
+ jr .GotDV
+
+.Special
+ inc hl
+ ld a, [hl]
+ and $f
+
+.GotDV
+ ld d, 0
+ add e
+ ld e, a
+ jr nc, .no_overflow_1
+ inc d
+
+.no_overflow_1
+ sla e
+ rl d
+ srl b
+ srl b
+ ld a, b
+ add e
+ jr nc, .no_overflow_2
+ inc d
+
+.no_overflow_2
+ ld [hMultiplicand + 2], a
+ ld a, d
+ ld [hMultiplicand + 1], a
+ xor a
+ ld [hMultiplicand + 0], a
+ ld a, [CurPartyLevel]
+ ld [hMultiplier], a
+ call Multiply
+ ld a, [hProduct + 1]
+ ld [hDividend + 0], a
+ ld a, [hProduct + 2]
+ ld [hDividend + 1], a
+ ld a, [hProduct + 3]
+ ld [hDividend + 2], a
+ ld a, 100
+ ld [hDivisor], a
+ ld a, 3
+ ld b, a
+ call Divide
+ ld a, c
+ cp STAT_HP
+ ld a, 5
+ jr nz, .not_hp
+ ld a, [CurPartyLevel]
+ ld b, a
+ ld a, [hQuotient + 2]
+ add b
+ ld [hMultiplicand + 2], a
+ jr nc, .no_overflow_3
+ ld a, [hQuotient + 1]
+ inc a
+ ld [hMultiplicand + 1], a
+
+.no_overflow_3
+ ld a, 10
+
+.not_hp
+ ld b, a
+ ld a, [hQuotient + 2]
+ add b
+ ld [hMultiplicand + 2], a
+ jr nc, .no_overflow_4
+ ld a, [hQuotient + 1]
+ inc a
+ ld [hMultiplicand + 1], a
+
+.no_overflow_4
+ ld a, [hQuotient + 1]
+ cp (1000 / $100) + 1
+ jr nc, .max_stat
+ cp 1000 / $100
+ jr c, .stat_value_okay
+ ld a, [hQuotient + 2]
+ cp 1000 % $100
+ jr c, .stat_value_okay
+
+.max_stat
+ ld a, 999 / $100
+ ld [hMultiplicand + 1], a
+ ld a, 999 % $100
+ ld [hMultiplicand + 2], a
+
+.stat_value_okay
+ pop bc
+ pop de
+ pop hl
+ ret
+; e277
+
+GivePoke:: ; e277
+ push de
+ push bc
+ xor a ; PARTYMON
+ ld [MonType], a
+ call TryAddMonToParty
+ jr nc, .failed
+ ld hl, PartyMonNicknames
+ ld a, [PartyCount]
+ dec a
+ ld [CurPartyMon], a
+ call SkipNames
+ ld d, h
+ ld e, l
+ pop bc
+ ld a, b
+ ld b, 0
+ push bc
+ push de
+ push af
+ ld a, [CurItem]
+ and a
+ jr z, .done
+ ld a, [CurPartyMon]
+ ld hl, PartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld a, [CurItem]
+ ld [hl], a
+ jr .done
+
+.failed
+ ld a, [CurPartySpecies]
+ ld [TempEnemyMonSpecies], a
+ callab LoadEnemyMon
+ call SentPkmnIntoBox
+ jp nc, .FailedToGiveMon
+ ld a, BOXMON
+ ld [MonType], a
+ xor a
+ ld [CurPartyMon], a
+ ld de, wMonOrItemNameBuffer
+ pop bc
+ ld a, b
+ ld b, 1
+ push bc
+ push de
+ push af
+ ld a, [CurItem]
+ and a
+ jr z, .done
+ ld a, [CurItem]
+ ld [sBoxMon1Item], a
+
+.done
+ ld a, [CurPartySpecies]
+ ld [wd265], a
+ ld [TempEnemyMonSpecies], a
+ call GetPokemonName
+ ld hl, StringBuffer1
+ ld de, wMonOrItemNameBuffer
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+ pop af
+ and a
+ jp z, .wildmon
+ pop de
+ pop bc
+ pop hl
+ push bc
+ push hl
+ ld a, [ScriptBank]
+ call GetFarHalfword
+ ld bc, PKMN_NAME_LENGTH
+ ld a, [ScriptBank]
+ call FarCopyBytes
+ pop hl
+rept 2
+ inc hl
+endr
+ ld a, [ScriptBank]
+ call GetFarHalfword
+ pop bc
+ ld a, b
+ and a
+ push de
+ push bc
+ jr nz, .send_to_box
+
+ push hl
+ ld a, [CurPartyMon]
+ ld hl, PartyMonOT
+ call SkipNames
+ ld d, h
+ ld e, l
+ pop hl
+.otnameloop
+ ld a, [ScriptBank]
+ call GetFarByte
+ ld [de], a
+ inc hl
+ inc de
+ cp "@"
+ jr nz, .otnameloop
+ ld a, [ScriptBank]
+ call GetFarByte
+ ld b, a
+ push bc
+ ld a, [CurPartyMon]
+ ld hl, PartyMon1ID
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld a, 01001 / $100
+ ld [hli], a
+ ld [hl], 01001 % $100
+ pop bc
+ callba SetGiftPartyMonCaughtData
+ jr .skip_nickname
+
+.send_to_box
+ ld a, BANK(sBoxMonOT)
+ call GetSRAMBank
+ ld de, sBoxMonOT
+.loop
+ ld a, [ScriptBank]
+ call GetFarByte
+ ld [de], a
+ inc hl
+ inc de
+ cp "@"
+ jr nz, .loop
+ ld a, [ScriptBank]
+ call GetFarByte
+ ld b, a
+ ld hl, sBoxMon1ID
+ call Random
+ ld [hli], a
+ call Random
+ ld [hl], a
+ call CloseSRAM
+ callba SetGiftBoxMonCaughtData
+ jr .skip_nickname
+
+.wildmon
+ pop de
+ pop bc
+ push bc
+ push de
+ ld a, b
+ and a
+ jr z, .party
+ callba SetBoxMonCaughtData
+ jr .set_caught_data
+
+.party
+ callba SetCaughtData
+.set_caught_data
+ callba GiveANickname_YesNo
+ pop de
+ jr c, .skip_nickname
+ call InitNickname
+
+.skip_nickname
+ pop bc
+ pop de
+ ld a, b
+ and a
+ ret z
+ ld hl, TextJump_WasSentToBillsPC
+ call PrintText
+ ld a, BANK(sBoxMonNicknames)
+ call GetSRAMBank
+ ld hl, wMonOrItemNameBuffer
+ ld de, sBoxMonNicknames
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+ call CloseSRAM
+ ld b, $1
+ ret
+; e3d4
+
+.FailedToGiveMon: ; e3d4
+ pop bc
+ pop de
+ ld b, $2
+ ret
+; e3d9
+
+TextJump_WasSentToBillsPC: ; 0xe3d9
+ ; was sent to BILL's PC.
+ text_jump Text_WasSentToBillsPC
+ db "@"
+; 0xe3de
+
+InitNickname: ; e3de
+ push de
+ call LoadStandardMenuDataHeader
+ call DisableSpriteUpdates
+ pop de
+ push de
+ ld b, $0
+ callba NamingScreen
+ pop hl
+ ld de, StringBuffer1
+ call InitName
+ ld a, $4 ; XXX could this be in bank 4 in pokered?
+ ld hl, ExitAllMenus
+ rst FarCall
+ ret
+; e3fd
diff --git a/engine/pack.asm b/engine/pack.asm
index dc29a6994..17ace5959 100644
--- a/engine/pack.asm
+++ b/engine/pack.asm
@@ -508,6 +508,7 @@ UseItem: ; 10311
ld [wJumptableIndex], a
ret
; 10364 (4:4364)
+
TossMenu: ; 10364
ld hl, Text_ThrowAwayHowMany
call Pack_PrintTextNoScroll
@@ -534,7 +535,7 @@ TossMenu: ; 10364
ret
; 1039d
-Function1039d: ; 1039d
+ResetPocketCursorPositions: ; 1039d
; unreferenced
ld a, [wCurrPocket]
and a
diff --git a/engine/player_step.asm b/engine/player_step.asm
new file mode 100755
index 000000000..2a789d1cb
--- /dev/null
+++ b/engine/player_step.asm
@@ -0,0 +1,271 @@
+_HandlePlayerStep:: ; d497 (3:5497)
+ ld a, [wPlayerStepFlags]
+ and a
+ ret z
+ bit 7, a ; starting step
+ jr nz, .update_overworld_map
+ bit 6, a ; finishing step
+ jr nz, .update_player_coords
+ bit 5, a ; ongoing step
+ jr nz, .finish
+ ret
+
+.update_overworld_map
+ ld a, 4
+ ld [wHandlePlayerStep], a
+ call UpdateOverworldMap
+ jr .finish
+
+.update_player_coords
+ call UpdatePlayerCoords
+ jr .finish
+
+.finish
+ call HandlePlayerStep
+ ld a, [wPlayerStepVectorX]
+ ld d, a
+ ld a, [wPlayerStepVectorY]
+ ld e, a
+ ld a, [wFollowNotExactPersonX]
+ sub d
+ ld [wFollowNotExactPersonX], a
+ ld a, [wFollowNotExactPersonY]
+ sub e
+ ld [wFollowNotExactPersonY], a
+ ret
+
+ScrollScreen:: ; d4d2 (3:54d2)
+ ld a, [wPlayerStepVectorX]
+ ld d, a
+ ld a, [wPlayerStepVectorY]
+ ld e, a
+ ld a, [hSCX]
+ add d
+ ld [hSCX], a
+ ld a, [hSCY]
+ add e
+ ld [hSCY], a
+ ret
+
+HandlePlayerStep: ; d4e5 (3:54e5)
+ ld hl, wHandlePlayerStep
+ ld a, [hl]
+ and a
+ ret z
+ dec [hl]
+ ld a, [hl]
+ ld hl, .Jumptable
+ rst JumpTable
+ ret
+
+.Jumptable: ; d4f2 (3:54f2)
+ jumptable_start
+ jumptable GetMovementPermissions
+ jumptable BufferScreen
+ jumptable .mobile
+ jumptable .fail2
+; The rest are never used. Ever.
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+ jumptable .fail1
+
+.fail1: ; d508 (3:5508)
+ ret
+
+.mobile: ; d509 (3:5509)
+ callba MobileFn_10602e
+ ret
+
+.fail2: ; d510 (3:5510)
+ ret
+
+UpdatePlayerCoords: ; d511 (3:5511)
+ ld a, [wPlayerStepDirection]
+ and a
+ jr nz, .check_step_down
+ ld hl, YCoord
+ inc [hl]
+ ret
+
+.check_step_down
+ cp UP
+ jr nz, .check_step_left
+ ld hl, YCoord
+ dec [hl]
+ ret
+
+.check_step_left
+ cp LEFT
+ jr nz, .check_step_right
+ ld hl, XCoord
+ dec [hl]
+ ret
+
+.check_step_right
+ cp RIGHT
+ ret nz
+ ld hl, XCoord
+ inc [hl]
+ ret
+
+UpdateOverworldMap: ; d536 (3:5536)
+ ld a, [wPlayerStepDirection]
+ and a
+ jr z, .step_down
+ cp UP
+ jr z, .step_up
+ cp LEFT
+ jr z, .step_left
+ cp RIGHT
+ jr z, .step_right
+ ret
+
+.step_down
+ call .ScrollOverworldMapDown
+ call LoadMapPart
+ call ScrollMapUp
+ ret
+
+.step_up
+ call .ScrollOverworldMapUp
+ call LoadMapPart
+ call ScrollMapDown
+ ret
+
+.step_left
+ call .ScrollOverworldMapLeft
+ call LoadMapPart
+ call ScrollMapRight
+ ret
+
+.step_right
+ call .ScrollOverworldMapRight
+ call LoadMapPart
+ call ScrollMapLeft
+ ret
+
+.ScrollOverworldMapDown: ; d571 (3:5571)
+ ld a, [wBGMapAnchor]
+ add 2 * BG_MAP_WIDTH
+ ld [wBGMapAnchor], a
+ jr nc, .not_overflowed
+ ld a, [wBGMapAnchor + 1]
+ inc a
+ and $3
+ or VBGMap0 / $100
+ ld [wBGMapAnchor + 1], a
+.not_overflowed
+ ld hl, wMetatileStandingY
+ inc [hl]
+ ld a, [hl]
+ cp 2 ; was 1
+ jr nz, .done_down
+ ld [hl], 0
+ call .Add6ToOverworldMapAnchor
+.done_down
+ ret
+
+.Add6ToOverworldMapAnchor: ; d595 (3:5595)
+ ld hl, wOverworldMapAnchor
+ ld a, [MapWidth]
+ add 6
+ add [hl]
+ ld [hli], a
+ ret nc
+ inc [hl]
+ ret
+
+.ScrollOverworldMapUp: ; d5a2 (3:55a2)
+ ld a, [wBGMapAnchor]
+ sub 2 * BG_MAP_WIDTH
+ ld [wBGMapAnchor], a
+ jr nc, .not_underflowed
+ ld a, [wBGMapAnchor + 1]
+ dec a
+ and $3
+ or VBGMap0 / $100
+ ld [wBGMapAnchor + 1], a
+.not_underflowed
+ ld hl, wMetatileStandingY
+ dec [hl]
+ ld a, [hl]
+ cp -1 ; was 0
+ jr nz, .done_up
+ ld [hl], $1
+ call .Sub6FromOverworldMapAnchor
+.done_up
+ ret
+
+.Sub6FromOverworldMapAnchor: ; d5c6 (3:55c6)
+ ld hl, wOverworldMapAnchor
+ ld a, [MapWidth]
+ add 6
+ ld b, a
+ ld a, [hl]
+ sub b
+ ld [hli], a
+ ret nc
+ dec [hl]
+ ret
+
+.ScrollOverworldMapLeft: ; d5d5 (3:55d5)
+ ld a, [wBGMapAnchor]
+ ld e, a
+ and $e0
+ ld d, a
+ ld a, e
+ sub $2
+ and $1f
+ or d
+ ld [wBGMapAnchor], a
+ ld hl, wMetatileStandingX
+ dec [hl]
+ ld a, [hl]
+ cp -1
+ jr nz, .done_left
+ ld [hl], 1
+ call .DecrementwOverworldMapAnchor
+.done_left
+ ret
+
+.DecrementwOverworldMapAnchor: ; d5f4 (3:55f4)
+ ld hl, wOverworldMapAnchor
+ ld a, [hl]
+ sub 1
+ ld [hli], a
+ ret nc
+ dec [hl]
+ ret
+
+.ScrollOverworldMapRight: ; d5fe (3:55fe)
+ ld a, [wBGMapAnchor]
+ ld e, a
+ and $e0
+ ld d, a
+ ld a, e
+ add $2
+ and $1f
+ or d
+ ld [wBGMapAnchor], a
+ ld hl, wMetatileStandingX
+ inc [hl]
+ ld a, [hl]
+ cp 2
+ jr nz, .done_right
+ ld [hl], 0
+ call .IncrementwOverworldMapAnchor
+.done_right
+ ret
+
+.IncrementwOverworldMapAnchor: ; d61d (3:561d)
+ ld hl, wOverworldMapAnchor
+ ld a, [hl]
+ add 1
+ ld [hli], a
+ ret nc
+ inc [hl]
+ ret
diff --git a/engine/pokecenter_pc.asm b/engine/pokecenter_pc.asm
index 1b6a1da2f..431ad8a43 100755
--- a/engine/pokecenter_pc.asm
+++ b/engine/pokecenter_pc.asm
@@ -23,7 +23,7 @@ PokemonCenterPC: ; 1559a
.shutdown
call PC_PlayShutdownSound
call ExitMenu
- call WriteBackup
+ call CloseWindow
ret
; 155d6
diff --git a/engine/save.asm b/engine/save.asm
index 65faabb7a..7750b0f41 100644
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -215,7 +215,7 @@ SaveTheGame_yesorno: ; 14baf
call PlaceYesNoBox
ld a, [wMenuCursorY]
dec a
- call WriteBackup
+ call CloseWindow
push af
call ret_d90
pop af
diff --git a/engine/scripting.asm b/engine/scripting.asm
index 44f53ceed..5de990006 100644
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -150,7 +150,7 @@ ScriptCommandTable: ; 96cb1
dw Script_repeattext ; 4d
dw Script_yesorno ; 4e
dw Script_loadmenudata ; 4f
- dw Script_writebackup ; 50
+ dw Script_closewindow ; 50
dw Script_jumptextfaceplayer ; 51
IF _CRYSTAL
dw Script_farjumptext ; 52
@@ -480,10 +480,10 @@ Script_loadmenudata: ; 96efa
ret
; 96f0f
-Script_writebackup: ; 96f0f
+Script_closewindow: ; 96f0f
; script command 0x50
- call WriteBackup
+ call CloseWindow
call UpdateSprites
ret
; 96f16
@@ -3038,7 +3038,7 @@ Script_refreshscreen: ; 97b20
; parameters:
; dummy (SingleByteParam)
- call ResetWindow
+ call RefreshScreen
call GetScriptByte
ret
; 97b27
diff --git a/engine/selectmenu.asm b/engine/selectmenu.asm
index 03210f43d..ce2ff8eb7 100755
--- a/engine/selectmenu.asm
+++ b/engine/selectmenu.asm
@@ -155,7 +155,7 @@ UseRegisteredItem: ; 133c3
; 133f5
.Party ; 133f5
- call ResetWindow
+ call RefreshScreen
call FadeToMenu
call DoItemEffect
call CloseSubmenu
@@ -165,7 +165,7 @@ UseRegisteredItem: ; 133c3
; 13406
.Overworld ; 13406
- call ResetWindow
+ call RefreshScreen
ld a, 1
ld [wUsingItemWithSelect], a
call DoItemEffect
@@ -181,7 +181,7 @@ UseRegisteredItem: ; 133c3
; 13422
.CantUse ; 13422
- call ResetWindow
+ call RefreshScreen
._cantuse
call CantUseItem
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index aad1e4def..0bb2cb53c 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -1712,7 +1712,7 @@ Slots_AskBet: ; 9307c (24:707c)
ld hl, .MenuDataHeader
call LoadMenuDataHeader
call VerticalMenu
- call WriteBackup
+ call CloseWindow
ret c
ld a, [wMenuCursorY]
ld b, a
@@ -1802,7 +1802,7 @@ Slots_AskPlayAgain: ; 930e9 (24:70e9)
call PlaceYesNoBox
ld a, [wMenuCursorY]
dec a
- call WriteBackup
+ call CloseWindow
and a
jr nz, .exit_slots
and a
diff --git a/engine/startmenu.asm b/engine/startmenu.asm
index 9127611ff..b5bd3140f 100755
--- a/engine/startmenu.asm
+++ b/engine/startmenu.asm
@@ -604,7 +604,7 @@ Function129f4: ; 129f4
call MenuTextBox
callba SelectQuantityToToss
push af
- call WriteBackup
+ call CloseWindow
call ExitMenu
pop af
jr c, .asm_12a42
@@ -1322,7 +1322,7 @@ MonMenu_Whirlpool: ; 12e7f
; 12e94
MonMenu_Waterfall: ; 12e94
- callba Functioncade
+ callba WaterfallFunction
ld a, [wFieldMoveSucceeded]
cp $1
jr nz, .Fail
diff --git a/engine/std_scripts.asm b/engine/std_scripts.asm
index b8762dfc0..7970b9c13 100644
--- a/engine/std_scripts.asm
+++ b/engine/std_scripts.asm
@@ -1811,7 +1811,7 @@ CoinVendor_SellCoinsMenuScript: ; 0xbcde4
special Special_DisplayMoneyAndCoinBalance
loadmenudata CoinVendor_MenuDataHeader
verticalmenu
- writebackup
+ closewindow
if_equal $1, CoinVendor_Buy50CoinsScript
if_equal $2, CoinVendor_Buy500CoinsScript
jump CoinVendor_CancelScript
diff --git a/event/buena.asm b/event/buena.asm
index 235f10686..97aab0c05 100644
--- a/event/buena.asm
+++ b/event/buena.asm
@@ -139,8 +139,8 @@ SpecialBuenaPrize: ; 8afd4
jr .loop
.done
- call WriteBackup
- call WriteBackup
+ call CloseWindow
+ call CloseWindow
ld hl, .Text_PleaseComeBackAgain
call PrintText
call JoyWaitAorB
diff --git a/event/daycare.asm b/event/daycare.asm
index 8125fb9d9..1be6c68a5 100755
--- a/event/daycare.asm
+++ b/event/daycare.asm
@@ -1,23 +1,23 @@
const_def
- const DAYCARETEXT_00
- const DAYCARETEXT_01
- const DAYCARETEXT_02
- const DAYCARETEXT_03
- const DAYCARETEXT_04
- const DAYCARETEXT_05
- const DAYCARETEXT_06
- const DAYCARETEXT_07
- const DAYCARETEXT_08
- const DAYCARETEXT_09
- const DAYCARETEXT_0A
- const DAYCARETEXT_0B
- const DAYCARETEXT_0C
- const DAYCARETEXT_0D
- const DAYCARETEXT_0E
- const DAYCARETEXT_0F
- const DAYCARETEXT_10
- const DAYCARETEXT_11
- const DAYCARETEXT_12
+ const DAYCARETEXT_MAN_INTRO
+ const DAYCARETEXT_MAN_EGG
+ const DAYCARETEXT_LADY_INTRO
+ const DAYCARETEXT_LADY_EGG
+ const DAYCARETEXT_WHICH_ONE
+ const DAYCARETEXT_DEPOSIT
+ const DAYCARETEXT_CANT_BREED_EGG
+ const DAYCARETEXT_LAST_MON
+ const DAYCARETEXT_LAST_ALIVE_MON
+ const DAYCARETEXT_COME_BACK_LATER
+ const DAYCARETEXT_REMOVE_MAIL
+ const DAYCARETEXT_GENIUSES
+ const DAYCARETEXT_ASK_WITHDRAW
+ const DAYCARETEXT_WITHDRAW
+ const DAYCARETEXT_TOO_SOON
+ const DAYCARETEXT_PARTY_FULL
+ const DAYCARETEXT_NOT_ENOUGH_MONEY
+ const DAYCARETEXT_OH_FINE
+ const DAYCARETEXT_COME_AGAIN
const DAYCARETEXT_13
Special_DayCareMan: ; 166d6
@@ -25,12 +25,12 @@ Special_DayCareMan: ; 166d6
bit 0, [hl]
jr nz, .AskWithdrawMon
ld hl, wDaycareMan
- ld a, DAYCARETEXT_00
+ ld a, DAYCARETEXT_MAN_INTRO
call DayCareManIntroText
jr c, .cancel
call DayCareAskDepositPokemon
jr c, .print_text
- callba Functionde2a
+ callba DepositMonWithDaycareMan
ld hl, wDaycareMan
set 0, [hl]
call DayCare_DepositPokemonText
@@ -38,13 +38,13 @@ Special_DayCareMan: ; 166d6
ret
.AskWithdrawMon
- callba Functione698
+ callba GetBreedMon1LevelGrowth
ld hl, wBreedMon1Nick
- call Function1686d
- call Function16807
+ call GetPriceToRetrieveBreedmon
+ call DayCare_AskWithdrawBreedMon
jr c, .print_text
- callba Functiondd21
- call Function16850
+ callba RetrievePokemonFromDaycareMan
+ call DayCare_TakeMoney_PlayCry
ld hl, wDaycareMan
res 0, [hl]
res 5, [hl]
@@ -64,12 +64,12 @@ Special_DayCareLady: ; 1672a
bit 0, [hl]
jr nz, .AskWithdrawMon
ld hl, wDaycareLady
- ld a, DAYCARETEXT_02
+ ld a, DAYCARETEXT_LADY_INTRO
call DayCareLadyIntroText
jr c, .cancel
call DayCareAskDepositPokemon
jr c, .print_text
- callba Functionde37
+ callba DepositMonWithDaycareLady
ld hl, wDaycareLady
set 0, [hl]
call DayCare_DepositPokemonText
@@ -77,13 +77,13 @@ Special_DayCareLady: ; 1672a
ret
.AskWithdrawMon
- callba Functione6b3
+ callba GetBreedMon2LevelGrowth
ld hl, wBreedMon2Nick
- call Function1686d
- call Function16807
+ call GetPriceToRetrieveBreedmon
+ call DayCare_AskWithdrawBreedMon
jr c, .print_text
- callba Functiondd42
- call Function16850
+ callba RetrievePokemonFromDaycareLady
+ call DayCare_TakeMoney_PlayCry
ld hl, wDaycareLady
res 0, [hl]
ld hl, wDaycareMan
@@ -121,7 +121,7 @@ DayCareAskDepositPokemon: ; 16798
ld a, [PartyCount]
cp 2
jr c, .OnlyOneMon
- ld a, DAYCARETEXT_04
+ ld a, DAYCARETEXT_WHICH_ONE
call PrintDayCareText
ld b, 6
callba SelectTradeOrDaycareMon
@@ -145,27 +145,27 @@ DayCareAskDepositPokemon: ; 16798
ret
.Declined
- ld a, DAYCARETEXT_12
+ ld a, DAYCARETEXT_COME_AGAIN
scf
ret
.Egg
- ld a, DAYCARETEXT_06
+ ld a, DAYCARETEXT_CANT_BREED_EGG
scf
ret
.OnlyOneMon
- ld a, DAYCARETEXT_07
+ ld a, DAYCARETEXT_LAST_MON
scf
ret
.OutOfUsableMons
- ld a, DAYCARETEXT_08
+ ld a, DAYCARETEXT_LAST_ALIVE_MON
scf
ret
.HoldingMail
- ld a, DAYCARETEXT_0A
+ ld a, DAYCARETEXT_REMOVE_MAIL
scf
ret
; 167f1
@@ -177,76 +177,76 @@ DayCareAskDepositPokemon: ; 16798
; 0x167f6
DayCare_DepositPokemonText: ; 167f6
- ld a, DAYCARETEXT_05
+ ld a, DAYCARETEXT_DEPOSIT
call PrintDayCareText
ld a, [CurPartySpecies]
call PlayCry
- ld a, DAYCARETEXT_09
+ ld a, DAYCARETEXT_COME_BACK_LATER
call PrintDayCareText
ret
; 16807
-Function16807: ; 16807
+DayCare_AskWithdrawBreedMon: ; 16807
ld a, [StringBuffer2 + 1]
and a
- jr nz, .asm_16819
- ld a, $f
+ jr nz, .grew_at_least_one_level
+ ld a, DAYCARETEXT_PARTY_FULL
call PrintDayCareText
call YesNoBox
- jr c, .asm_16844
- jr .asm_1682d
+ jr c, .refused
+ jr .check_money
-.asm_16819
- ld a, $b
+.grew_at_least_one_level
+ ld a, DAYCARETEXT_GENIUSES
call PrintDayCareText
call YesNoBox
- jr c, .asm_16844
- ld a, $c
+ jr c, .refused
+ ld a, DAYCARETEXT_ASK_WITHDRAW
call PrintDayCareText
call YesNoBox
- jr c, .asm_16844
+ jr c, .refused
-.asm_1682d
+.check_money
ld de, Money
ld bc, StringBuffer2 + 2
callba CompareMoney
- jr c, .asm_16848
+ jr c, .not_enough_money
ld a, [PartyCount]
- cp $6
- jr nc, .asm_1684c
+ cp PARTY_LENGTH
+ jr nc, .PartyFull
and a
ret
-.asm_16844
- ld a, $12
+.refused
+ ld a, DAYCARETEXT_COME_AGAIN
scf
ret
-.asm_16848
- ld a, $11
+.not_enough_money
+ ld a, DAYCARETEXT_OH_FINE
scf
ret
-.asm_1684c
- ld a, $10
+.PartyFull
+ ld a, DAYCARETEXT_NOT_ENOUGH_MONEY
scf
ret
; 16850
-Function16850: ; 16850
+DayCare_TakeMoney_PlayCry: ; 16850
ld bc, StringBuffer2 + 2
ld de, Money
callba TakeMoney
- ld a, $d
+ ld a, DAYCARETEXT_WITHDRAW
call PrintDayCareText
ld a, [CurPartySpecies]
call PlayCry
- ld a, $e
+ ld a, DAYCARETEXT_TOO_SOON
call PrintDayCareText
ret
; 1686d
-Function1686d: ; 1686d
+GetPriceToRetrieveBreedmon: ; 1686d
ld a, b
ld [StringBuffer2], a
ld a, d
@@ -255,10 +255,10 @@ Function1686d: ; 1686d
ld bc, NAME_LENGTH
call CopyBytes
ld hl, 0
- ld bc, $64
+ ld bc, 100
ld a, [StringBuffer2 + 1]
call AddNTimes
- ld de, $64
+ ld de, 100
add hl, de
xor a
ld [StringBuffer2 + 2], a
@@ -272,7 +272,7 @@ Function1686d: ; 1686d
PrintDayCareText: ; 1689b
ld e, a
ld d, 0
- ld hl, TextTable_168aa
+ ld hl, .TextTable
rept 2
add hl, de
endr
@@ -283,7 +283,7 @@ endr
ret
; 168aa
-TextTable_168aa: ; 168aa
+.TextTable: ; 168aa
dw .DayCareManIntro ; 00
dw .DayCareManOddEgg ; 01
dw .DayCareLadyIntro ; 02
diff --git a/event/elevator.asm b/event/elevator.asm
index 37b15a558..316bf382a 100755
--- a/event/elevator.asm
+++ b/event/elevator.asm
@@ -131,7 +131,7 @@ Elevator_AskWhichFloor: ; 134dd
xor a
ld [wMenuScrollPosition], a
call ScrollingMenu
- call WriteBackup
+ call CloseWindow
ld a, [wMenuJoypad]
cp B_BUTTON
jr z, .cancel
diff --git a/event/kurt.asm b/event/kurt.asm
index f1050fcdf..d9239b7fa 100644
--- a/event/kurt.asm
+++ b/event/kurt.asm
@@ -154,7 +154,7 @@ Kurt_SelectQuantity: ; 880c2
scf
.done
- call WriteBackup
+ call CloseWindow
ret
; 8810d
diff --git a/event/mom.asm b/event/mom.asm
index 737d92a36..4f57aec7f 100644
--- a/event/mom.asm
+++ b/event/mom.asm
@@ -108,7 +108,7 @@ endr
ld hl, MenuDataHeader_0x166b5
call CopyMenuDataHeader
call VerticalMenu
- call WriteBackup
+ call CloseWindow
jr c, .cancel
ld a, [wMenuCursorY]
cp $1
@@ -153,7 +153,7 @@ endr
call Function16517
call Function1656b
call Function16571
- call WriteBackup
+ call CloseWindow
jr c, .CancelDeposit
ld hl, StringBuffer2
ld a, [hli]
@@ -221,7 +221,7 @@ endr
call Function16512
call Function1656b
call Function16571
- call WriteBackup
+ call CloseWindow
jr c, .CancelWithdraw
ld hl, StringBuffer2
ld a, [hli]
diff --git a/event/unown.asm b/event/unown.asm
index 091d792e0..b37df3b3a 100644
--- a/event/unown.asm
+++ b/event/unown.asm
@@ -153,7 +153,7 @@ endr
call WaitBGMap2
call JoyWaitAorB
call PlayClickSFX
- call WriteBackup
+ call CloseWindow
ret
; 8aebc
diff --git a/home/menu.asm b/home/menu.asm
index 10878c282..6854d6c92 100644
--- a/home/menu.asm
+++ b/home/menu.asm
@@ -49,7 +49,7 @@ LoadMenuTextBox:: ; 1d58
MenuTextBoxBackup:: ; 1d67
call MenuTextBox
- call WriteBackup
+ call CloseWindow
ret
; 1d6e
@@ -100,7 +100,7 @@ VerticalMenu::
GetMenu2:: ; 1dab
call LoadMenuDataHeader
call VerticalMenu
- call WriteBackup
+ call CloseWindow
ld a, [wMenuCursorY]
ret
; 1db8
@@ -167,7 +167,7 @@ InterpretTwoOptionMenu:: ; 1dfe
push af
ld c, $f
call DelayFrames
- call WriteBackup
+ call CloseWindow
pop af
jr c, .no
ld a, [wMenuCursorY]
diff --git a/home/tilemap.asm b/home/tilemap.asm
index 60e16bc95..115efb3e5 100644
--- a/home/tilemap.asm
+++ b/home/tilemap.asm
@@ -13,7 +13,7 @@ InitVerticalMenuCursor:: ; 0x1c10
callab _InitVerticalMenuCursor
ret
-WriteBackup:: ; 0x1c17
+CloseWindow:: ; 0x1c17
push af
call ExitMenu
call ApplyTilemap
diff --git a/home/window.asm b/home/window.asm
index 44e984131..32494ee34 100644
--- a/home/window.asm
+++ b/home/window.asm
@@ -1,4 +1,4 @@
-ResetWindow:: ; 2dba
+RefreshScreen:: ; 2dba
call ClearWindowData
ld a, [hROMBank]
diff --git a/macros/event.asm b/macros/event.asm
index 2f4beadfc..8ef05b141 100644
--- a/macros/event.asm
+++ b/macros/event.asm
@@ -528,9 +528,9 @@ loadmenudata: macro
dw \1 ; data
endm
- enum writebackup_command
-writebackup: macro
- db writebackup_command
+ enum closewindow_command
+closewindow: macro
+ db closewindow_command
endm
enum jumptextfaceplayer_command
diff --git a/main.asm b/main.asm
index cbbfba98c..eb5d6bc94 100644
--- a/main.asm
+++ b/main.asm
@@ -68,7 +68,7 @@ Function6454:: ; 6454
push af
xor a
ld [hBGMapMode], a
- call Function6473
+ call .Function6473
pop af
ld [hBGMapMode], a
@@ -79,7 +79,7 @@ Function6454:: ; 6454
ret
; 6473
-Function6473: ; 6473
+.Function6473
xor a
ld [hLCDStatCustom], a
ld [hBGMapMode], a
@@ -87,7 +87,7 @@ Function6473: ; 6473
ld [hWY], a
call OverworldTextModeSwitch
ld a, VBGMap1 / $100
- call Function64b9
+ call .Function64b9
call Function2e20
callba LoadOW_BGPal7
callba ApplyPals
@@ -98,7 +98,7 @@ Function6473: ; 6473
ld [hWY], a
callba Function64db ; no need to farcall
ld a, VBGMap0 / $100
- call Function64b9
+ call .Function64b9
xor a
ld [wBGMapAnchor], a
ld a, VBGMap0 / $100
@@ -110,7 +110,7 @@ Function6473: ; 6473
ret
; 64b9
-Function64b9: ; 64b9
+.Function64b9: ; 64b9
ld [hBGMapAddress + 1], a
xor a
ld [hBGMapAddress], a
@@ -123,14 +123,13 @@ Function64bf:: ; 64bf
ld a, $1
ld [hOAMUpdate], a
- call Function64cd
+ call .Function64cd
pop af
ld [hOAMUpdate], a
ret
-; 64cd
-Function64cd: ; 64cd
+.Function64cd
call LoadFontsExtra
ld a, $90
ld [hWY], a
@@ -1041,10 +1040,10 @@ InitializeVisibleSprites: ; 8177
ret
; 81ca
-Function81ca:: ; 81ca
+CheckObjectEnteringVisibleRange:: ; 81ca
nop
ld a, [wPlayerStepDirection]
- cp $ff
+ cp STANDING
ret z
ld hl, .jumptable
rst JumpTable
@@ -1052,59 +1051,58 @@ Function81ca:: ; 81ca
; 81d6
.jumptable: ; 81d6
- dw Function81e5
- dw Function81de
- dw Function8232
- dw Function8239
+ dw .Down
+ dw .Up
+ dw .Left
+ dw .Right
; 81de
-Function81de: ; 81de
+.Up: ; 81de
ld a, [YCoord]
- sub $1
- jr Function81ea
+ sub 1
+ jr .Vertical
-Function81e5: ; 81e5
+.Down: ; 81e5
ld a, [YCoord]
- add $9
-
-Function81ea: ; 81ea
+ add 9
+.Vertical: ; 81ea
ld d, a
ld a, [XCoord]
ld e, a
ld bc, MapObjects + OBJECT_LENGTH
ld a, 1
-.loop
+.loop_v
ld [hMapObjectIndexBuffer], a
ld hl, MAPOBJECT_SPRITE
add hl, bc
ld a, [hl]
and a
- jr z, .next
+ jr z, .next_v
ld hl, MAPOBJECT_Y_COORD
add hl, bc
ld a, d
cp [hl]
- jr nz, .next
+ jr nz, .next_v
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
add hl, bc
ld a, [hl]
cp -1
- jr nz, .next
+ jr nz, .next_v
ld hl, MAPOBJECT_X_COORD
add hl, bc
ld a, [hl]
add 1
sub e
- jr c, .next
+ jr c, .next_v
cp MAPOBJECT_SCREEN_WIDTH
- jr nc, .next
+ jr nc, .next_v
push de
push bc
call CopyObjectStruct
pop bc
pop de
-.next
+.next_v
ld hl, OBJECT_LENGTH
add hl, bc
ld b, h
@@ -1112,57 +1110,56 @@ Function81ea: ; 81ea
ld a, [hMapObjectIndexBuffer]
inc a
cp NUM_OBJECTS
- jr nz, .loop
+ jr nz, .loop_v
ret
; 8232
-Function8232: ; 8232
+.Left: ; 8232
ld a, [XCoord]
sub 1
- jr Function823e
+ jr .Horizontal
-Function8239: ; 8239
+.Right: ; 8239
ld a, [XCoord]
- add $a
-
-Function823e: ; 823e
+ add 10
+.Horizontal: ; 823e
ld e, a
ld a, [YCoord]
ld d, a
ld bc, MapObjects + OBJECT_LENGTH
ld a, 1
-.loop
+.loop_h
ld [hMapObjectIndexBuffer], a
ld hl, MAPOBJECT_SPRITE
add hl, bc
ld a, [hl]
and a
- jr z, .next
+ jr z, .next_h
ld hl, MAPOBJECT_X_COORD
add hl, bc
ld a, e
cp [hl]
- jr nz, .next
+ jr nz, .next_h
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
add hl, bc
ld a, [hl]
cp -1
- jr nz, .next
+ jr nz, .next_h
ld hl, MAPOBJECT_Y_COORD
add hl, bc
ld a, [hl]
add 1
sub d
- jr c, .next
+ jr c, .next_h
cp MAPOBJECT_SCREEN_HEIGHT
- jr nc, .next
+ jr nc, .next_h
push de
push bc
call CopyObjectStruct
pop bc
pop de
-.next
+.next_h
ld hl, OBJECT_LENGTH
add hl, bc
ld b, h
@@ -1170,7 +1167,7 @@ Function823e: ; 823e
ld a, [hMapObjectIndexBuffer]
inc a
cp NUM_OBJECTS
- jr nz, .loop
+ jr nz, .loop_h
ret
; 8286
@@ -1238,7 +1235,7 @@ CopyTempObjectToObjectStruct: ; 8286
sub [hl]
and $f
swap a
- ld hl, wd14d
+ ld hl, wFollowNotExactPersonY
sub [hl]
ld hl, OBJECT_SPRITE_Y
add hl, de
@@ -1257,7 +1254,7 @@ CopyTempObjectToObjectStruct: ; 8286
sub [hl]
and $f
swap a
- ld hl, wd14c
+ ld hl, wFollowNotExactPersonX
sub [hl]
ld hl, OBJECT_SPRITE_X
add hl, de
@@ -1432,7 +1429,7 @@ FollowNotExact:: ; 839e
sub [hl]
and $f
swap a
- ld hl, wd14c
+ ld hl, wFollowNotExactPersonX
sub [hl]
ld hl, OBJECT_SPRITE_X
add hl, de
@@ -1445,7 +1442,7 @@ FollowNotExact:: ; 839e
sub [hl]
and $f
swap a
- ld hl, wd14d
+ ld hl, wFollowNotExactPersonY
sub [hl]
ld hl, OBJECT_SPRITE_Y
add hl, de
@@ -2812,11 +2809,11 @@ FlyFunction: ; ca3b
ld a, e
cp -1
jr z, .illegal
- cp $1c ; NUM_SPAWNS
+ cp NUM_SPAWNS
jr nc, .illegal
ld [wd001], a
- call WriteBackup
+ call CloseWindow
ld a, $1
ret
@@ -2829,7 +2826,7 @@ FlyFunction: ; ca3b
ret
.illegal
- call WriteBackup
+ call CloseWindow
call WaitBGMap
ld a, $80
ret
@@ -2872,14 +2869,14 @@ FlyFunction: ; ca3b
ret
; cade
-Functioncade: ; cade
- call AttemptToWaterfall
+WaterfallFunction: ; cade
+ call .TryWaterfall
and $7f
ld [wFieldMoveSucceeded], a
ret
; cae7
-AttemptToWaterfall: ; cae7
+.TryWaterfall: ; cae7
; Waterfall
ld de, ENGINE_RISINGBADGE
callba CheckBadge
@@ -2920,18 +2917,18 @@ Script_WaterfallFromMenu: ; 0xcb1c
Script_UsedWaterfall: ; 0xcb20
callasm GetPartyNick
- writetext UnknownText_0xcb51
+ writetext .Text_UsedWaterfall
waitbutton
closetext
playsound SFX_BUBBLEBEAM
.loop
- applymovement PLAYER, WaterfallStep
- callasm CheckContinueWaterfall
+ applymovement PLAYER, .WaterfallStep
+ callasm .CheckContinueWaterfall
iffalse .loop
end
; 0xcb38
-CheckContinueWaterfall: ; cb38
+.CheckContinueWaterfall: ; cb38
xor a
ld [ScriptVar], a
ld a, [PlayerNextTile]
@@ -2943,12 +2940,13 @@ CheckContinueWaterfall: ; cb38
ret
; cb4f
-WaterfallStep: ; cb4f
+.WaterfallStep: ; cb4f
turn_waterfall_up
step_end
; cb51
-UnknownText_0xcb51: ; 0xcb51
+.Text_UsedWaterfall: ; 0xcb51
+ ; used WATERFALL!
text_jump UnknownText_0x1c068e
db "@"
; 0xcb56
@@ -2977,24 +2975,26 @@ TryWaterfallOW:: ; cb56
; cb7e
Script_CantDoWaterfall: ; 0xcb7e
- jumptext UnknownText_0xcb81
+ jumptext .Text_CantDoWaterfall
; 0xcb81
-UnknownText_0xcb81: ; 0xcb81
+.Text_CantDoWaterfall: ; 0xcb81
+ ; Wow, it's a huge waterfall.
text_jump UnknownText_0x1c06a3
db "@"
; 0xcb86
Script_AskWaterfall: ; 0xcb86
opentext
- writetext UnknownText_0xcb90
+ writetext .AskUseWaterfall
yesorno
iftrue Script_UsedWaterfall
closetext
end
; 0xcb90
-UnknownText_0xcb90: ; 0xcb90
+.AskUseWaterfall: ; 0xcb90
+ ; Do you want to use WATERFALL?
text_jump UnknownText_0x1c06bf
db "@"
; 0xcb95
@@ -3059,14 +3059,14 @@ dig_incave
ld a, [Buffer2]
cp $2
jr nz, .escaperope
- ld hl, UsedDigScript
+ ld hl, .UsedDigScript
call QueueScript
ld a, $81
ret
.escaperope
callba SpecialKabutoChamber
- ld hl, UsedEscapeRopeScript
+ ld hl, .UsedEscapeRopeScript
call QueueScript
ld a, $81
ret
@@ -3076,47 +3076,47 @@ dig_incave
ld a, [Buffer2]
cp $2
jr nz, .failescaperope
- ld hl, UnknownText_0xcc26
+ ld hl, .Text_CantUseHere
call MenuTextBox
call WaitPressAorB_BlinkCursor
- call WriteBackup
+ call CloseWindow
.failescaperope
ld a, $80
ret
; cc1c
-UnknownText_0xcc1c: ; 0xcc1c
+.Text_UsedDig: ; 0xcc1c
; used DIG!
text_jump UnknownText_0x1c06de
db "@"
; 0xcc21
-UnknownText_0xcc21: ; 0xcc21
+.Text_UsedEscapeRope: ; 0xcc21
; used an ESCAPE ROPE.
text_jump UnknownText_0x1c06ed
db "@"
; 0xcc26
-UnknownText_0xcc26: ; 0xcc26
+.Text_CantUseHere: ; 0xcc26
; Can't use that here.
text_jump UnknownText_0x1c0705
db "@"
; 0xcc2b
-UsedEscapeRopeScript: ; 0xcc2b
+.UsedEscapeRopeScript: ; 0xcc2b
reloadmappart
special UpdateTimePals
- writetext UnknownText_0xcc21
- jump UsedDigOrEscapeRopeScript
+ writetext .Text_UsedEscapeRope
+ jump .UsedDigOrEscapeRopeScript
; 0xcc35
-UsedDigScript: ; 0xcc35
+.UsedDigScript: ; 0xcc35
reloadmappart
special UpdateTimePals
- writetext UnknownText_0xcc1c
+ writetext .Text_UsedDig
-UsedDigOrEscapeRopeScript: ; 0xcc3c
+.UsedDigOrEscapeRopeScript: ; 0xcc3c
waitbutton
closetext
playsound SFX_WARP_TO
@@ -3184,35 +3184,35 @@ TeleportFunction: ; cc61
.DoTeleport: ; cc9c
call GetPartyNick
- ld hl, Script_UsedTeleport
+ ld hl, .TeleportScript
call QueueScript
ld a, $81
ret
; cca8
.FailTeleport: ; cca8
- ld hl, UnknownText_0xccb6
+ ld hl, .Text_CantUseHere
call MenuTextBoxBackup
ld a, $80
ret
; ccb1
-UnknownText_0xccb1: ; 0xccb1
+.Text_ReturnToLastMonCenter: ; 0xccb1
; Return to the last #MON CENTER.
text_jump UnknownText_0x1c071a
db "@"
; 0xccb6
-UnknownText_0xccb6: ; 0xccb6
+.Text_CantUseHere: ; 0xccb6
; Can't use that here.
text_jump UnknownText_0x1c073b
db "@"
; 0xccbb
-Script_UsedTeleport: ; 0xccbb
+.TeleportScript: ; 0xccbb
reloadmappart
special UpdateTimePals
- writetext UnknownText_0xccb1
+ writetext .Text_ReturnToLastMonCenter
pause 60
reloadmappart
closetext
@@ -3248,44 +3248,40 @@ StrengthFunction: ; cce5
; Strength
ld de, ENGINE_PLAINBADGE
call CheckBadge
- jr c, FailedStrength
- jr StartToUseStrength
+ jr c, .Failed
+ jr .UseStrength
; ccf8
-AlreadyUsingStrength: ; unreferenced
- ld hl, UnknownText_0xcd01
+.AlreadyUsing: ; unreferenced
+ ld hl, .JumpText
call MenuTextBoxBackup
ld a, $80
ret
; cd01
-UnknownText_0xcd01: ; 0xcd01
+.JumpText: ; 0xcd01
text_jump UnknownText_0x1c0751
db "@"
; 0xcd06
-FailedStrength: ; cd06
+.Failed: ; cd06
ld a, $80
ret
; cd09
-StartToUseStrength: ; cd09
+.UseStrength: ; cd09
ld hl, Script_StrengthFromMenu
call QueueScript
ld a, $81
ret
; cd12
-Functioncd12: ; cd12
+SetStrengthFlag: ; cd12
ld hl, BikeFlags
set 0, [hl]
ld a, [CurPartyMon]
ld e, a
ld d, 0
- ; fallthrough
-; cd1d
-
-Functioncd1d: ; cd1d
ld hl, PartySpecies
add hl, de
ld a, [hl]
@@ -3299,22 +3295,22 @@ Script_StrengthFromMenu: ; 0xcd29
special UpdateTimePals
Script_UsedStrength: ; 0xcd2d
- callasm Functioncd12
- writetext UnknownText_0xcd41
+ callasm SetStrengthFlag
+ writetext .UsedStrength
copybytetovar Buffer6
cry 0
pause 3
- writetext UnknownText_0xcd46
+ writetext .StrengthAllowedItToMoveBoulders
closetext
end
; 0xcd41
-UnknownText_0xcd41: ; 0xcd41
+.UsedStrength: ; 0xcd41
text_jump UnknownText_0x1c0774
db "@"
; 0xcd46
-UnknownText_0xcd46: ; 0xcd46
+.StrengthAllowedItToMoveBoulders: ; 0xcd46
text_jump UnknownText_0x1c0788
db "@"
; 0xcd4b
@@ -3438,7 +3434,7 @@ Jumptable_cdae: ; cdae
ret
; cdd9
-UnknownText_0xcdd9: ; 0xcdd9
+Text_UsedWhirlpool: ; 0xcdd9
; used WHIRLPOOL!
text_jump UnknownText_0x1c0816
db "@"
@@ -3480,7 +3476,7 @@ Script_WhirlpoolFromMenu: ; 0xce0b
Script_UsedWhirlpool: ; 0xce0f
callasm GetPartyNick
- writetext UnknownText_0xcdd9
+ writetext Text_UsedWhirlpool
reloadmappart
callasm DisappearWhirlpool
closetext
@@ -3529,10 +3525,10 @@ TryWhirlpoolOW:: ; ce3e
; ce66
Script_MightyWhirlpool: ; 0xce66
- jumptext UnknownText_0xce69
+ jumptext .MightyWhirlpoolText
; 0xce69
-UnknownText_0xce69: ; 0xce69
+.MightyWhirlpoolText: ; 0xce69
text_jump UnknownText_0x1c082b
db "@"
; 0xce6e
@@ -4827,2086 +4823,9 @@ GetItemPrice: ; d486
ret
; d497
-Functiond497:: ; d497 (3:5497)
- ld a, [wPlayerStepFlags]
- and a
- ret z
- bit 7, a
- jr nz, .update_overworld_map
- bit 6, a
- jr nz, .update_player_coords
- bit 5, a
- jr nz, .finish
- ret
-
-.update_overworld_map
- ld a, $4
- ld [wd13f], a
- call UpdateOverworldMap
- jr .finish
-
-.update_player_coords
- call UpdatePlayerCoords
- jr .finish
-
-.finish
- call Functiond4e5
- ld a, [wPlayerStepVectorX]
- ld d, a
- ld a, [wPlayerStepVectorY]
- ld e, a
- ld a, [wd14c]
- sub d
- ld [wd14c], a
- ld a, [wd14d]
- sub e
- ld [wd14d], a
- ret
-
-Functiond4d2:: ; d4d2 (3:54d2)
- ld a, [wPlayerStepVectorX]
- ld d, a
- ld a, [wPlayerStepVectorY]
- ld e, a
- ld a, [hSCX]
- add d
- ld [hSCX], a
- ld a, [hSCY]
- add e
- ld [hSCY], a
- ret
-
-Functiond4e5: ; d4e5 (3:54e5)
- ld hl, wd13f
- ld a, [hl]
- and a
- ret z
- dec [hl]
- ld a, [hl]
- ld hl, .Jumptable
- rst JumpTable
- ret
-
-.Jumptable: ; d4f2 (3:54f2)
- jumptable_start
- jumptable GetMovementPermissions
- jumptable BufferScreen
- jumptable .mobile
- jumptable .fail2
- jumptable .fail1
- jumptable .fail1
- jumptable .fail1
- jumptable .fail1
- jumptable .fail1
- jumptable .fail1
- jumptable .fail1
-
-.fail1: ; d508 (3:5508)
- ret
-
-.mobile: ; d509 (3:5509)
- callba MobileFn_10602e
- ret
-
-.fail2: ; d510 (3:5510)
- ret
-
-UpdatePlayerCoords: ; d511 (3:5511)
- ld a, [wPlayerStepDirection]
- and a
- jr nz, .check_step_down
- ld hl, YCoord
- inc [hl]
- ret
-
-.check_step_down
- cp UP
- jr nz, .check_step_left
- ld hl, YCoord
- dec [hl]
- ret
-
-.check_step_left
- cp LEFT
- jr nz, .check_step_right
- ld hl, XCoord
- dec [hl]
- ret
-
-.check_step_right
- cp RIGHT
- ret nz
- ld hl, XCoord
- inc [hl]
- ret
-
-UpdateOverworldMap: ; d536 (3:5536)
- ld a, [wPlayerStepDirection]
- and a
- jr z, .step_down
- cp UP
- jr z, .step_up
- cp LEFT
- jr z, .step_left
- cp RIGHT
- jr z, .step_right
- ret
-
-.step_down
- call .ScrollOverworldMapDown
- call LoadMapPart
- call ScrollMapUp
- ret
-
-.step_up
- call .ScrollOverworldMapUp
- call LoadMapPart
- call ScrollMapDown
- ret
-
-.step_left
- call .ScrollOverworldMapLeft
- call LoadMapPart
- call ScrollMapRight
- ret
-
-.step_right
- call .ScrollOverworldMapRight
- call LoadMapPart
- call ScrollMapLeft
- ret
-
-.ScrollOverworldMapDown: ; d571 (3:5571)
- ld a, [wBGMapAnchor]
- add 2 * BG_MAP_WIDTH
- ld [wBGMapAnchor], a
- jr nc, .not_overflowed
- ld a, [wBGMapAnchor + 1]
- inc a
- and $3
- or VBGMap0 / $100
- ld [wBGMapAnchor + 1], a
-.not_overflowed
- ld hl, wMetatileStandingY
- inc [hl]
- ld a, [hl]
- cp 2 ; was 1
- jr nz, .done_down
- ld [hl], 0
- call .Add6ToOverworldMapAnchor
-.done_down
- ret
-
-.Add6ToOverworldMapAnchor: ; d595 (3:5595)
- ld hl, wOverworldMapAnchor
- ld a, [MapWidth]
- add 6
- add [hl]
- ld [hli], a
- ret nc
- inc [hl]
- ret
-
-.ScrollOverworldMapUp: ; d5a2 (3:55a2)
- ld a, [wBGMapAnchor]
- sub 2 * BG_MAP_WIDTH
- ld [wBGMapAnchor], a
- jr nc, .not_underflowed
- ld a, [wBGMapAnchor + 1]
- dec a
- and $3
- or VBGMap0 / $100
- ld [wBGMapAnchor + 1], a
-.not_underflowed
- ld hl, wMetatileStandingY
- dec [hl]
- ld a, [hl]
- cp -1 ; was 0
- jr nz, .done_up
- ld [hl], $1
- call .Sub6FromOverworldMapAnchor
-.done_up
- ret
-
-.Sub6FromOverworldMapAnchor: ; d5c6 (3:55c6)
- ld hl, wOverworldMapAnchor
- ld a, [MapWidth]
- add 6
- ld b, a
- ld a, [hl]
- sub b
- ld [hli], a
- ret nc
- dec [hl]
- ret
-
-.ScrollOverworldMapLeft: ; d5d5 (3:55d5)
- ld a, [wBGMapAnchor]
- ld e, a
- and $e0
- ld d, a
- ld a, e
- sub $2
- and $1f
- or d
- ld [wBGMapAnchor], a
- ld hl, wMetatileStandingX
- dec [hl]
- ld a, [hl]
- cp -1
- jr nz, .done_left
- ld [hl], 1
- call .DecrementwOverworldMapAnchor
-.done_left
- ret
-
-.DecrementwOverworldMapAnchor: ; d5f4 (3:55f4)
- ld hl, wOverworldMapAnchor
- ld a, [hl]
- sub 1
- ld [hli], a
- ret nc
- dec [hl]
- ret
-
-.ScrollOverworldMapRight: ; d5fe (3:55fe)
- ld a, [wBGMapAnchor]
- ld e, a
- and $e0
- ld d, a
- ld a, e
- add $2
- and $1f
- or d
- ld [wBGMapAnchor], a
- ld hl, wMetatileStandingX
- inc [hl]
- ld a, [hl]
- cp 2
- jr nz, .done_right
- ld [hl], 0
- call .IncrementwOverworldMapAnchor
-.done_right
- ret
-
-.IncrementwOverworldMapAnchor: ; d61d (3:561d)
- ld hl, wOverworldMapAnchor
- ld a, [hl]
- add 1
- ld [hli], a
- ret nc
- inc [hl]
- ret
-
+INCLUDE "engine/player_step.asm"
INCLUDE "engine/anim_hp_bar.asm"
-
-TryAddMonToParty: ; d88c
-; Check if to copy wild Pkmn or generate new Pkmn
- ; Whose is it?
- ld de, PartyCount
- ld a, [MonType]
- and $f
- jr z, .getpartylocation ; PARTYMON
- ld de, OTPartyCount
-
-.getpartylocation
- ; Do we have room for it?
- ld a, [de]
- inc a
- cp PARTY_LENGTH + 1
- ret nc
- ; Increase the party count
- ld [de], a
- ld a, [de] ; Why are we doing this?
- ld [$ffae], a ; HRAM backup
- add e
- ld e, a
- jr nc, .loadspecies
- inc d
-
-.loadspecies
- ; Load the species of the Pokemon into the party list.
- ; The terminator is usually here, but it'll be back.
- ld a, [CurPartySpecies]
- ld [de], a
- ; Load the terminator into the next slot.
- inc de
- ld a, -1
- ld [de], a
- ; Now let's load the OT name.
- ld hl, PartyMonOT
- ld a, [MonType]
- and $f
- jr z, .loadOTname
- ld hl, OTPartyMonOT
-
-.loadOTname
- ld a, [$ffae] ; Restore index from backup
- dec a
- call SkipNames
- ld d, h
- ld e, l
- ld hl, PlayerName
- ld bc, NAME_LENGTH
- call CopyBytes
- ld a, [MonType]
- and a
- jr nz, .skipnickname
- ld a, [CurPartySpecies]
- ld [wd265], a
- call GetPokemonName
- ld hl, PartyMonNicknames
- ld a, [$ffae]
- dec a
- call SkipNames
- ld d, h
- ld e, l
- ld hl, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
-
-.skipnickname
- ld hl, PartyMon1Species
- ld a, [MonType]
- and $f
- jr z, .initializeStats
- ld hl, OTPartyMon1Species
-
-.initializeStats
- ld a, [$ffae]
- dec a
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
-GeneratePartyMonStats: ; d906
- ld e, l
- ld d, h
- push hl
- ld a, [CurPartySpecies]
- ld [CurSpecies], a
- call GetBaseData
- ld a, [BaseDexNo]
- ld [de], a
- inc de
- ld a, [wBattleMode]
- and a
- ld a, $0
- jr z, .skipitem
- ld a, [EnemyMonItem]
-
-.skipitem
- ld [de], a
- inc de
- push de
- ld h, d
- ld l, e
- ld a, [wBattleMode]
- and a
- jr z, .randomlygeneratemoves
- ld a, [MonType]
- and a
- jr nz, .randomlygeneratemoves
- ld de, EnemyMonMoves
- rept NUM_MOVES + -1
- ld a, [de]
- inc de
- ld [hli], a
- endr
- ld a, [de]
- ld [hl], a
- jr .next
-
-.randomlygeneratemoves
- xor a
- rept NUM_MOVES + -1
- ld [hli], a
- endr
- ld [hl], a
- ld [Buffer1], a
- predef FillMoves
-
-.next
- pop de
-rept 4
- inc de
-endr
- ld a, [PlayerID]
- ld [de], a
- inc de
- ld a, [PlayerID + 1]
- ld [de], a
- inc de
- push de
- ld a, [CurPartyLevel]
- ld d, a
- callab CalcExpAtLevel
- pop de
- ld a, [hProduct + 1]
- ld [de], a
- inc de
- ld a, [hProduct + 2]
- ld [de], a
- inc de
- ld a, [hProduct + 3]
- ld [de], a
- inc de
- xor a
- ld b, $a
-.loop
- ld [de], a
- inc de
- dec b
- jr nz, .loop
- pop hl
- push hl
- ld a, [MonType]
- and $f
- jr z, .generateDVs
- push hl
- callba GetTrainerDVs
- pop hl
- jr .initializetrainermonstats
-
-.generateDVs
- ld a, [CurPartySpecies]
- ld [wd265], a
- dec a
- push de
- call CheckCaughtMon
- ld a, [wd265]
- dec a
- call SetSeenAndCaughtMon
- pop de
- pop hl
- push hl
- ld a, [wBattleMode]
- and a
- jr nz, .copywildmonstats
- call Random
- ld b, a
- call Random
- ld c, a
-
-.initializetrainermonstats
- ld a, b
- ld [de], a
- inc de
- ld a, c
- ld [de], a
- inc de
- push hl
- push de
-rept 2
- inc hl
-endr
- call FillPP
- pop de
- pop hl
-rept 4
- inc de
-endr
- ld a, 70
- ld [de], a
- inc de
- xor a
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld a, [CurPartyLevel]
- ld [de], a
- inc de
- xor a
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld bc, 10
- add hl, bc
- ld a, $1
- ld c, a
- ld b, FALSE
- call CalcPkmnStatC
- ld a, [hProduct + 2]
- ld [de], a
- inc de
- ld a, [hProduct + 3]
- ld [de], a
- inc de
- jr .next2
-
-.copywildmonstats
- ld a, [EnemyMonDVs]
- ld [de], a
- inc de
- ld a, [EnemyMonDVs + 1]
- ld [de], a
- inc de
-
- push hl
- ld hl, EnemyMonPP
- ld b, NUM_MOVES
-.wildmonpploop
- ld a, [hli]
- ld [de], a
- inc de
- dec b
- jr nz, .wildmonpploop
- pop hl
-
- ld a, BASE_HAPPINESS
- ld [de], a
- inc de
- xor a
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld a, [CurPartyLevel]
- ld [de], a
- inc de
- ld hl, EnemyMonStatus
- ; Copy EnemyMonStatus
- ld a, [hli]
- ld [de], a
- inc de
- ; Copy EnemyMonUnused
- ld a, [hli]
- ld [de], a
- inc de
- ; Copy EnemyMonHP
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- inc de
-
-.next2
- ld a, [wBattleMode]
- dec a
- jr nz, .generatestats
- ld hl, EnemyMonMaxHP
- ld bc, 2*6 ; MaxHP + 5 Stats
- call CopyBytes
- pop hl
- jr .next3
-
-.generatestats
- pop hl
- ld bc, 2*5 ; 5 Stats
- add hl, bc
- ld b, $0 ; if b = 1, then the Stats of the Pkmn are calculated
- ; only the current HP aren't set to MaxHP after this
- call CalcPkmnStats
-
-.next3
- ld a, [MonType]
- and $f
- jr nz, .done
- ld a, [CurPartySpecies]
- cp UNOWN
- jr nz, .done
- ld hl, PartyMon1DVs
- ld a, [PartyCount]
- dec a
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- predef GetUnownLetter
- callab UpdateUnownDex
-
-.done
- scf ; When this function returns, the carry flag indicates success vs failure.
- ret
-; da6d
-
-FillPP: ; da6d
- push bc
- ld b, NUM_MOVES
-.loop
- ld a, [hli]
- and a
- jr z, .next
- dec a
- push hl
- push de
- push bc
- ld hl, Moves
- ld bc, MOVE_LENGTH
- call AddNTimes
- ld de, StringBuffer1
- ld a, BANK(Moves)
- call FarCopyBytes
- pop bc
- pop de
- pop hl
- ld a, [StringBuffer1 + MOVE_PP]
-
-.next
- ld [de], a
- inc de
- dec b
- jr nz, .loop
- pop bc
- ret
-; da96
-
-AddTempmonToParty: ; da96
- ld hl, PartyCount
- ld a, [hl]
- cp PARTY_LENGTH
- scf
- ret z
-
- inc a
- ld [hl], a
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [CurPartySpecies]
- ld [hli], a
- ld [hl], $ff
-
- ld hl, PartyMon1Species
- ld a, [PartyCount]
- dec a
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld e, l
- ld d, h
- ld hl, TempMonSpecies
- call CopyBytes
-
- ld hl, PartyMonOT
- ld a, [PartyCount]
- dec a
- call SkipNames
- ld d, h
- ld e, l
- ld hl, OTPartyMonOT
- ld a, [CurPartyMon]
- call SkipNames
- ld bc, NAME_LENGTH
- call CopyBytes
-
- ld hl, PartyMonNicknames
- ld a, [PartyCount]
- dec a
- call SkipNames
- ld d, h
- ld e, l
- ld hl, OTPartyMonNicknames
- ld a, [CurPartyMon]
- call SkipNames
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
-
- ld a, [CurPartySpecies]
- ld [wNamedObjectIndexBuffer], a
- cp EGG
- jr z, .egg
- dec a
- call SetSeenAndCaughtMon
- ld hl, PartyMon1Happiness
- ld a, [PartyCount]
- dec a
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld [hl], BASE_HAPPINESS
-.egg
-
- ld a, [CurPartySpecies]
- cp UNOWN
- jr nz, .done
- ld hl, PartyMon1DVs
- ld a, [PartyCount]
- dec a
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- predef GetUnownLetter
- callab UpdateUnownDex
- ld a, [wFirstUnownSeen]
- and a
- jr nz, .done
- ld a, [UnownLetter]
- ld [wFirstUnownSeen], a
-.done
-
- and a
- ret
-
-SentGetPkmnIntoFromBox: ; db3f
-; Sents/Gets Pkmn into/from Box depending on Parameter
-; wPokemonWithdrawDepositParameter == 0: get Pkmn into Party
-; wPokemonWithdrawDepositParameter == 1: sent Pkmn into Box
-; wPokemonWithdrawDepositParameter == 2: get Pkmn from DayCare
-; wPokemonWithdrawDepositParameter == 3: put Pkmn into DayCare
-
- ld a, BANK(sBoxCount)
- call GetSRAMBank
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .check_IfPartyIsFull
- cp DAYCARE_WITHDRAW
- jr z, .check_IfPartyIsFull
- cp DAYCARE_DEPOSIT
- ld hl, wBreedMon1Species
- jr z, .breedmon
-
- ; we want to sent a Pkmn into the Box
- ; so check if there's enough space
- ld hl, sBoxCount
- ld a, [hl]
- cp MONS_PER_BOX
- jr nz, .there_is_room
- jp CloseSRAM_And_SetCarryFlag
-
-.check_IfPartyIsFull
- ld hl, PartyCount
- ld a, [hl]
- cp PARTY_LENGTH
- jp z, CloseSRAM_And_SetCarryFlag
-
-.there_is_room
- inc a
- ld [hl], a
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [wPokemonWithdrawDepositParameter]
- cp DAYCARE_WITHDRAW
- ld a, [wBreedMon1Species]
- jr z, .okay1
- ld a, [CurPartySpecies]
-
-.okay1
- ld [hli], a
- ld [hl], $ff
- ld a, [wPokemonWithdrawDepositParameter]
- dec a
- ld hl, PartyMon1Species
- ld bc, PARTYMON_STRUCT_LENGTH
- ld a, [PartyCount]
- jr nz, .okay2
- ld hl, sBoxMon1Species
- ld bc, BOXMON_STRUCT_LENGTH
- ld a, [sBoxCount]
-
-.okay2
- dec a ; PartyCount - 1
- call AddNTimes
-
-.breedmon
- push hl
- ld e, l
- ld d, h
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- ld hl, sBoxMon1Species
- ld bc, BOXMON_STRUCT_LENGTH
- jr z, .okay3
- cp DAYCARE_WITHDRAW
- ld hl, wBreedMon1Species
- jr z, .okay4
- ld hl, PartyMon1Species
- ld bc, PARTYMON_STRUCT_LENGTH
-
-.okay3
- ld a, [CurPartyMon]
- call AddNTimes
-
-.okay4
- ld bc, BOXMON_STRUCT_LENGTH
- call CopyBytes
- ld a, [wPokemonWithdrawDepositParameter]
- cp DAYCARE_DEPOSIT
- ld de, wBreedMon1OT
- jr z, .okay5
- dec a
- ld hl, PartyMonOT
- ld a, [PartyCount]
- jr nz, .okay6
- ld hl, sBoxMonOT
- ld a, [sBoxCount]
-
-.okay6
- dec a
- call SkipNames
- ld d, h
- ld e, l
-
-.okay5
- ld hl, sBoxMonOT
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .okay7
- ld hl, wBreedMon1OT
- cp DAYCARE_WITHDRAW
- jr z, .okay8
- ld hl, PartyMonOT
-
-.okay7
- ld a, [CurPartyMon]
- call SkipNames
-
-.okay8
- ld bc, NAME_LENGTH
- call CopyBytes
- ld a, [wPokemonWithdrawDepositParameter]
- cp DAYCARE_DEPOSIT
- ld de, wBreedMon1Nick
- jr z, .okay9
- dec a
- ld hl, PartyMonNicknames
- ld a, [PartyCount]
- jr nz, .okay10
- ld hl, sBoxMonNicknames
- ld a, [sBoxCount]
-
-.okay10
- dec a
- call SkipNames
- ld d, h
- ld e, l
-
-.okay9
- ld hl, sBoxMonNicknames
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .okay11
- ld hl, wBreedMon1Nick
- cp DAYCARE_WITHDRAW
- jr z, .okay12
- ld hl, PartyMonNicknames
-
-.okay11
- ld a, [CurPartyMon]
- call SkipNames
-
-.okay12
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
- pop hl
-
- ld a, [wPokemonWithdrawDepositParameter]
- cp PC_DEPOSIT
- jr z, .took_out_of_box
- cp DAYCARE_DEPOSIT
- jp z, .CloseSRAM_And_ClearCarryFlag
-
- push hl
- srl a
- add $2
- ld [MonType], a
- predef CopyPkmnToTempMon
- callab CalcLevel
- ld a, d
- ld [CurPartyLevel], a
- pop hl
-
- ld b, h
- ld c, l
- ld hl, MON_LEVEL
- add hl, bc
- ld [hl], a
- ld hl, MON_MAXHP
- add hl, bc
- ld d, h
- ld e, l
- ld hl, MON_STAT_EXP - 1
- add hl, bc
-
- push bc
- ld b, $1
- call CalcPkmnStats
- pop bc
-
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr nz, .CloseSRAM_And_ClearCarryFlag
- ld hl, MON_STATUS
- add hl, bc
- xor a
- ld [hl], a
- ld hl, MON_HP
- add hl, bc
- ld d, h
- ld e, l
- ld a, [CurPartySpecies]
- cp EGG
- jr z, .egg
-rept 2
- inc hl
-endr
- ld a, [hli]
- ld [de], a
- ld a, [hl]
- inc de
- ld [de], a
- jr .CloseSRAM_And_ClearCarryFlag
-
-.egg
- xor a
- ld [de], a
- inc de
- ld [de], a
- jr .CloseSRAM_And_ClearCarryFlag
-
-.took_out_of_box
- ld a, [sBoxCount]
- dec a
- ld b, a
- call Functiondcb6
-.CloseSRAM_And_ClearCarryFlag
- call CloseSRAM
- and a
- ret
-; dcb1
-
-CloseSRAM_And_SetCarryFlag: ; dcb1
- call CloseSRAM
- scf
- ret
-; dcb6
-
-Functiondcb6: ; dcb6
- ld a, b
- ld hl, sBoxMons
- ld bc, BOXMON_STRUCT_LENGTH
- call AddNTimes
- ld b, h
- ld c, l
- ld hl, MON_PP
- add hl, bc
- push hl
- push bc
- ld de, TempMonPP
- ld bc, NUM_MOVES
- call CopyBytes
- pop bc
- ld hl, MON_MOVES
- add hl, bc
- push hl
- ld de, TempMonMoves
- ld bc, NUM_MOVES
- call CopyBytes
- pop hl
- pop de
-
- ld a, [wMenuCursorY]
- push af
- ld a, [MonType]
- push af
- ld b, 0
-.asm_dcec
- ld a, [hli]
- and a
- jr z, .asm_dd18
- ld [TempMonMoves], a
- ld a, BOXMON
- ld [MonType], a
- ld a, b
- ld [wMenuCursorY], a
- push bc
- push hl
- push de
- callba GetMaxPPOfMove
- pop de
- pop hl
- ld a, [wd265]
- ld b, a
- ld a, [de]
- and %11000000
- add b
- ld [de], a
- pop bc
- inc de
- inc b
- ld a, b
- cp NUM_MOVES
- jr c, .asm_dcec
-
-.asm_dd18
- pop af
- ld [MonType], a
- pop af
- ld [wMenuCursorY], a
- ret
-; dd21
-
-Functiondd21: ; dd21
- ld a, [wBreedMon1Species]
- ld [CurPartySpecies], a
- ld de, SFX_TRANSACTION
- call PlaySFX
- call WaitSFX
- call Functione698
- ld a, b
- ld [wd002], a
- ld a, e
- ld [CurPartyLevel], a
- xor a
- ld [wPokemonWithdrawDepositParameter], a
- jp Functiondd64
-; dd42
-
-Functiondd42: ; dd42
- ld a, [wBreedMon2Species]
- ld [CurPartySpecies], a
- ld de, SFX_TRANSACTION
- call PlaySFX
- call WaitSFX
- call Functione6b3
- ld a, b
- ld [wd002], a
- ld a, e
- ld [CurPartyLevel], a
- ld a, PC_DEPOSIT
- ld [wPokemonWithdrawDepositParameter], a
- jp Functiondd64
-; dd64
-
-Functiondd64: ; dd64
- ld hl, PartyCount
- ld a, [hl]
- cp PARTY_LENGTH
- jr nz, .room_in_party
- scf
- ret
-
-.room_in_party
- inc a
- ld [hl], a
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- ld a, [wBreedMon1Species]
- ld de, wBreedMon1Nick
- jr z, .okay
- ld a, [wBreedMon2Species]
- ld de, wBreedMon2Nick
-
-.okay
- ld [hli], a
- ld [CurSpecies], a
- ld a, $ff
- ld [hl], a
- ld hl, PartyMonNicknames
- ld a, [PartyCount]
- dec a
- call SkipNames
- push hl
- ld h, d
- ld l, e
- pop de
- call CopyBytes
- push hl
- ld hl, PartyMonOT
- ld a, [PartyCount]
- dec a
- call SkipNames
- ld d, h
- ld e, l
- pop hl
- call CopyBytes
- push hl
- call Functionde1a
- pop hl
- ld bc, BOXMON_STRUCT_LENGTH
- call CopyBytes
- call GetBaseData
- call Functionde1a
- ld b, d
- ld c, e
- ld hl, MON_LEVEL
- add hl, bc
- ld a, [CurPartyLevel]
- ld [hl], a
- ld hl, MON_MAXHP
- add hl, bc
- ld d, h
- ld e, l
- ld hl, $a
- add hl, bc
- push bc
- ld b, $1
- call CalcPkmnStats
- ld hl, PartyMon1Moves
- ld a, [PartyCount]
- dec a
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- ld a, $1
- ld [Buffer1], a
- predef FillMoves
- ld a, [PartyCount]
- dec a
- ld [CurPartyMon], a
- callba HealPartyMon
- ld a, [CurPartyLevel]
- ld d, a
- callab CalcExpAtLevel
- pop bc
- ld hl, $8
- add hl, bc
- ld a, [hMultiplicand]
- ld [hli], a
- ld a, [hMultiplicand + 1]
- ld [hli], a
- ld a, [hMultiplicand + 2]
- ld [hl], a
- and a
- ret
-; de1a
-
-Functionde1a: ; de1a
- ld a, [PartyCount]
- dec a
- ld hl, PartyMon1Species
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld d, h
- ld e, l
- ret
-; de2a
-
-Functionde2a: ; de2a
- ld de, wBreedMon1Nick
- call Functionde44
- xor a
- ld [wPokemonWithdrawDepositParameter], a
- jp RemoveMonFromPartyOrBox
-; de37
-
-Functionde37: ; de37
- ld de, wBreedMon2Nick
- call Functionde44
- xor a
- ld [wPokemonWithdrawDepositParameter], a
- jp RemoveMonFromPartyOrBox
-; de44
-
-Functionde44: ; de44
- ld a, [CurPartyMon]
- ld hl, PartyMonNicknames
- call SkipNames
- call CopyBytes
- ld a, [CurPartyMon]
- ld hl, PartyMonOT
- call SkipNames
- call CopyBytes
- ld a, [CurPartyMon]
- ld hl, PartyMon1Species
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld bc, BOXMON_STRUCT_LENGTH
- jp CopyBytes
-
-SentPkmnIntoBox: ; de6e
-; Sents the Pkmn into one of Bills Boxes
-; the data comes mainly from 'EnemyMon:'
- ld a, BANK(sBoxCount)
- call GetSRAMBank
- ld de, sBoxCount
- ld a, [de]
- cp MONS_PER_BOX
- jp nc, .full
- inc a
- ld [de], a
-
- ld a, [CurPartySpecies]
- ld [CurSpecies], a
- ld c, a
-.loop
- inc de
- ld a, [de]
- ld b, a
- ld a, c
- ld c, b
- ld [de], a
- inc a
- jr nz, .loop
-
- call GetBaseData
- call ShiftBoxMon
-
- ld hl, PlayerName
- ld de, sBoxMonOT
- ld bc, NAME_LENGTH
- call CopyBytes
-
- ld a, [CurPartySpecies]
- ld [wd265], a
- call GetPokemonName
-
- ld de, sBoxMonNicknames
- ld hl, StringBuffer1
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
-
- ld hl, EnemyMon
- ld de, sBoxMon1
- ld bc, 1 + 1 + NUM_MOVES ; species + item + moves
- call CopyBytes
-
- ld hl, PlayerID
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- inc de
- push de
- ld a, [CurPartyLevel]
- ld d, a
- callab CalcExpAtLevel
- pop de
- ld a, [hProduct + 1]
- ld [de], a
- inc de
- ld a, [hProduct + 2]
- ld [de], a
- inc de
- ld a, [hProduct + 3]
- ld [de], a
- inc de
-
- ; Set all 5 Experience Values to 0
- xor a
- ld b, 2 * 5
-.loop2
- ld [de], a
- inc de
- dec b
- jr nz, .loop2
-
- ld hl, EnemyMonDVs
- ld b, 2 + NUM_MOVES ; DVs and PP ; EnemyMonHappiness - EnemyMonDVs
-.loop3
- ld a, [hli]
- ld [de], a
- inc de
- dec b
- jr nz, .loop3
-
- ld a, BASE_HAPPINESS
- ld [de], a
- inc de
- xor a
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld [de], a
- inc de
- ld a, [CurPartyLevel]
- ld [de], a
- ld a, [CurPartySpecies]
- dec a
- call SetSeenAndCaughtMon
- ld a, [CurPartySpecies]
- cp UNOWN
- jr nz, .not_unown
- ld hl, sBoxMon1DVs
- predef GetUnownLetter
- callab UpdateUnownDex
-
-.not_unown
- ld hl, sBoxMon1Moves
- ld de, TempMonMoves
- ld bc, NUM_MOVES
- call CopyBytes
-
- ld hl, sBoxMon1PP
- ld de, TempMonPP
- ld bc, NUM_MOVES
- call CopyBytes
-
- ld b, 0
- call Functiondcb6
-
- call CloseSRAM
- scf
- ret
-; df42
-
-.full: ; df42
- call CloseSRAM
- and a
- ret
-; df47
-
-ShiftBoxMon: ; df47
- ld hl, sBoxMonOT
- ld bc, NAME_LENGTH
- call .shift
-
- ld hl, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
- call .shift
-
- ld hl, sBoxMons
- ld bc, BOXMON_STRUCT_LENGTH
-
-.shift
- ld a, [sBoxCount]
- cp 2
- ret c
-
- push hl
- call AddNTimes
- dec hl
- ld e, l
- ld d, h
- pop hl
-
- ld a, [sBoxCount]
- dec a
- call AddNTimes
- dec hl
-
- push hl
- ld a, [sBoxCount]
- dec a
- ld hl, 0
- call AddNTimes
- ld c, l
- ld b, h
- pop hl
-.loop
- ld a, [hld]
- ld [de], a
- dec de
- dec bc
- ld a, c
- or b
- jr nz, .loop
- ret
-; df8c
-
-GiveEgg:: ; df8c
- ld a, [CurPartySpecies]
- push af
- callab GetPreEvolution
- callab GetPreEvolution
- ld a, [CurPartySpecies]
- dec a
-
-; TryAddMonToParty sets Seen and Caught flags
-; when it is successful. This routine will make
-; sure that we aren't newly setting flags.
- push af
- call CheckCaughtMon
- pop af
- push bc
- call CheckSeenMon
- push bc
-
- call TryAddMonToParty
-
-; If we haven't caught this Pokemon before receiving
-; the Egg, reset the flag that was just set by
-; TryAddMonToParty.
- pop bc
- ld a, c
- and a
- jr nz, .skip_caught_flag
- ld a, [CurPartySpecies]
- dec a
- ld c, a
- ld d, $0
- ld hl, PokedexCaught
- ld b, RESET_FLAG
- predef FlagPredef
-
-.skip_caught_flag
-; If we haven't seen this Pokemon before receiving
-; the Egg, reset the flag that was just set by
-; TryAddMonToParty.
- pop bc
- ld a, c
- and a
- jr nz, .skip_seen_flag
- ld a, [CurPartySpecies]
- dec a
- ld c, a
- ld d, $0
- ld hl, PokedexSeen
- ld b, RESET_FLAG
- predef FlagPredef
-
-.skip_seen_flag
- pop af
- ld [CurPartySpecies], a
- ld a, [PartyCount]
- dec a
- ld bc, PARTYMON_STRUCT_LENGTH
- ld hl, PartyMon1Species
- call AddNTimes
- ld a, [CurPartySpecies]
- ld [hl], a
- ld hl, PartyCount
- ld a, [hl]
- ld b, 0
- ld c, a
- add hl, bc
- ld a, EGG
- ld [hl], a
- ld a, [PartyCount]
- dec a
- ld hl, PartyMonNicknames
- call SkipNames
- ld de, String_Egg
- call CopyName2
- ld a, [PartyCount]
- dec a
- ld hl, PartyMon1Happiness
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld a, [wc2cc]
- bit 1, a
- ld a, 1
- jr nz, .got_init_happiness
- ld a, [BaseEggSteps]
-
-.got_init_happiness
- ld [hl], a
- ld a, [PartyCount]
- dec a
- ld hl, PartyMon1HP
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- xor a
- ld [hli], a
- ld [hl], a
- and a
- ret
-; e035
-
-String_Egg: ; e035
- db "EGG@"
-; e039
-
-RemoveMonFromPartyOrBox: ; e039
- ld hl, PartyCount
-
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .okay
-
- ld a, BANK(sBoxCount)
- call GetSRAMBank
- ld hl, sBoxCount
-
-.okay
- ld a, [hl]
- dec a
- ld [hli], a
- ld a, [CurPartyMon]
- ld c, a
- ld b, 0
- add hl, bc
- ld e, l
- ld d, h
- inc de
-.loop
- ld a, [de]
- inc de
- ld [hli], a
- inc a
- jr nz, .loop
- ld hl, PartyMonOT
- ld d, PARTY_LENGTH - 1
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .party
- ld hl, sBoxMonOT
- ld d, MONS_PER_BOX - 1
-
-.party
- ; If this is the last mon in our party (box),
- ; shift all the other mons up to close the gap.
- ld a, [CurPartyMon]
- call SkipNames
- ld a, [CurPartyMon]
- cp d
- jr nz, .delete_inside
- ld [hl], -1
- jp .finish
-
-.delete_inside
- ; Shift the OT names
- ld d, h
- ld e, l
- ld bc, PKMN_NAME_LENGTH
- add hl, bc
- ld bc, PartyMonNicknames
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .party2
- ld bc, sBoxMonNicknames
-.party2
- call CopyDataUntil
- ; Shift the struct
- ld hl, PartyMons
- ld bc, PARTYMON_STRUCT_LENGTH
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .party4
- ld hl, sBoxMons
- ld bc, BOXMON_STRUCT_LENGTH
-.party4
- ld a, [CurPartyMon]
- call AddNTimes
- ld d, h
- ld e, l
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .party5
- ld bc, BOXMON_STRUCT_LENGTH
- add hl, bc
- ld bc, sBoxMonOT
- jr .copy
-
-.party5
- ld bc, PARTYMON_STRUCT_LENGTH
- add hl, bc
- ld bc, PartyMonOT
-.copy
- call CopyDataUntil
- ; Shift the nicknames
- ld hl, PartyMonNicknames
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .party6
- ld hl, sBoxMonNicknames
-.party6
- ld bc, PKMN_NAME_LENGTH
- ld a, [CurPartyMon]
- call AddNTimes
- ld d, h
- ld e, l
- ld bc, PKMN_NAME_LENGTH
- add hl, bc
- ld bc, PartyMonNicknamesEnd
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jr z, .party7
- ld bc, sBoxMonNicknamesEnd
-.party7
- call CopyDataUntil
- ; Mail time!
-.finish
- ld a, [wPokemonWithdrawDepositParameter]
- and a
- jp nz, CloseSRAM
- ld a, [wLinkMode]
- and a
- ret nz
- ; Shift mail
- ld a, BANK(sPartyMail)
- call GetSRAMBank
- ; If this is the last mon in our party, no need to shift mail.
- ld hl, PartyCount
- ld a, [CurPartyMon]
- cp [hl]
- jr z, .close_sram
- ; Shift our mail messages up.
- ld hl, sPartyMail
- ld bc, MAIL_STRUCT_LENGTH
- call AddNTimes
- push hl
- add hl, bc
- pop de
- ld a, [CurPartyMon]
- ld b, a
-.loop2
- push bc
- push hl
- ld bc, MAIL_STRUCT_LENGTH
- call CopyBytes
- pop hl
- push hl
- ld bc, MAIL_STRUCT_LENGTH
- add hl, bc
- pop de
- pop bc
- inc b
- ld a, [PartyCount]
- cp b
- jr nz, .loop2
-.close_sram
- jp CloseSRAM
-; e134
-
-ComputeNPCTrademonStats: ; e134
- ld a, MON_LEVEL
- call GetPartyParamLocation
- ld a, [hl]
- ld [MON_LEVEL], a ; wow
- ld a, MON_SPECIES
- call GetPartyParamLocation
- ld a, [hl]
- ld [CurSpecies], a
- call GetBaseData
- ld a, MON_MAXHP
- call GetPartyParamLocation
- ld d, h
- ld e, l
- push de
- ld a, MON_STAT_EXP - 1
- call GetPartyParamLocation
- ld b, $1
- call CalcPkmnStats
- pop de
- ld a, MON_HP
- call GetPartyParamLocation
- ld a, [de]
- inc de
- ld [hli], a
- ld a, [de]
- ld [hl], a
- ret
-; e167
-
-CalcPkmnStats: ; e167
-; 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
-; hl is the path to the Stat EXP
-; results in $ffb5 and $ffb6 are saved in [de]
-
- ld c, $0
-.loop
- inc c
- call CalcPkmnStatC
- ld a, [hMultiplicand + 1]
- ld [de], a
- inc de
- ld a, [hMultiplicand + 2]
- ld [de], a
- inc de
- ld a, c
- cp STAT_SDEF
- jr nz, .loop
- ret
-; e17b
-
-CalcPkmnStatC: ; e17b
-; 'c' is 1-6 and points to the BaseStat
-; 1: HP
-; 2: Attack
-; 3: Defense
-; 4: Speed
-; 5: SpAtk
-; 6: SpDef
- push hl
- push de
- push bc
- ld a, b
- ld d, a
- push hl
- ld hl, BaseStats
- dec hl ; has to be decreased, because 'c' begins with 1
- ld b, $0
- add hl, bc
- ld a, [hl]
- ld e, a
- pop hl
- push hl
- ld a, c
- cp STAT_SDEF
- jr nz, .not_spdef
-rept 2
- dec hl
-endr
-
-.not_spdef
- sla c
- ld a, d
- and a
- jr z, .SkipSqrt
- add hl, bc
- push de
- ld a, [hld]
- ld e, a
- ld d, [hl]
- callba GetSquareRoot
- pop de
-
-.SkipSqrt
- srl c
- pop hl
- push bc
- ld bc, MON_DVS - MON_HP_EXP + 1
- add hl, bc
- pop bc
- ld a, c
- cp STAT_ATK
- jr z, .Attack
- cp STAT_DEF
- jr z, .Defense
- cp STAT_SPD
- jr z, .Speed
- cp STAT_SATK
- jr z, .Special
- cp STAT_SDEF
- jr z, .Special
-; DV_HP = (DV_ATK & 1) << 3 + (DV_DEF & 1) << 2 + (DV_SPD & 1) << 1 + (DV_SPC & 1)
- push bc
- ld a, [hl]
- swap a
- and $1
-rept 3
- add a
-endr
- ld b, a
- ld a, [hli]
- and $1
-rept 2
- add a
-endr
- add b
- ld b, a
- ld a, [hl]
- swap a
- and $1
- add a
- add b
- ld b, a
- ld a, [hl]
- and $1
- add b
- pop bc
- jr .GotDV
-
-.Attack
- ld a, [hl]
- swap a
- and $f
- jr .GotDV
-
-.Defense
- ld a, [hl]
- and $f
- jr .GotDV
-
-.Speed
- inc hl
- ld a, [hl]
- swap a
- and $f
- jr .GotDV
-
-.Special
- inc hl
- ld a, [hl]
- and $f
-
-.GotDV
- ld d, 0
- add e
- ld e, a
- jr nc, .no_overflow_1
- inc d
-
-.no_overflow_1
- sla e
- rl d
- srl b
- srl b
- ld a, b
- add e
- jr nc, .no_overflow_2
- inc d
-
-.no_overflow_2
- ld [hMultiplicand + 2], a
- ld a, d
- ld [hMultiplicand + 1], a
- xor a
- ld [hMultiplicand + 0], a
- ld a, [CurPartyLevel]
- ld [hMultiplier], a
- call Multiply
- ld a, [hProduct + 1]
- ld [hDividend + 0], a
- ld a, [hProduct + 2]
- ld [hDividend + 1], a
- ld a, [hProduct + 3]
- ld [hDividend + 2], a
- ld a, 100
- ld [hDivisor], a
- ld a, 3
- ld b, a
- call Divide
- ld a, c
- cp STAT_HP
- ld a, 5
- jr nz, .not_hp
- ld a, [CurPartyLevel]
- ld b, a
- ld a, [hQuotient + 2]
- add b
- ld [hMultiplicand + 2], a
- jr nc, .no_overflow_3
- ld a, [hQuotient + 1]
- inc a
- ld [hMultiplicand + 1], a
-
-.no_overflow_3
- ld a, 10
-
-.not_hp
- ld b, a
- ld a, [hQuotient + 2]
- add b
- ld [hMultiplicand + 2], a
- jr nc, .no_overflow_4
- ld a, [hQuotient + 1]
- inc a
- ld [hMultiplicand + 1], a
-
-.no_overflow_4
- ld a, [hQuotient + 1]
- cp (1000 / $100) + 1
- jr nc, .max_stat
- cp 1000 / $100
- jr c, .stat_value_okay
- ld a, [hQuotient + 2]
- cp 1000 % $100
- jr c, .stat_value_okay
-
-.max_stat
- ld a, 999 / $100
- ld [hMultiplicand + 1], a
- ld a, 999 % $100
- ld [hMultiplicand + 2], a
-
-.stat_value_okay
- pop bc
- pop de
- pop hl
- ret
-; e277
-
-GivePoke:: ; e277
- push de
- push bc
- xor a ; PARTYMON
- ld [MonType], a
- call TryAddMonToParty
- jr nc, .failed
- ld hl, PartyMonNicknames
- ld a, [PartyCount]
- dec a
- ld [CurPartyMon], a
- call SkipNames
- ld d, h
- ld e, l
- pop bc
- ld a, b
- ld b, 0
- push bc
- push de
- push af
- ld a, [CurItem]
- and a
- jr z, .done
- ld a, [CurPartyMon]
- ld hl, PartyMon1Item
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld a, [CurItem]
- ld [hl], a
- jr .done
-
-.failed
- ld a, [CurPartySpecies]
- ld [TempEnemyMonSpecies], a
- callab LoadEnemyMon
- call SentPkmnIntoBox
- jp nc, .FailedToGiveMon
- ld a, BOXMON
- ld [MonType], a
- xor a
- ld [CurPartyMon], a
- ld de, wMonOrItemNameBuffer
- pop bc
- ld a, b
- ld b, 1
- push bc
- push de
- push af
- ld a, [CurItem]
- and a
- jr z, .done
- ld a, [CurItem]
- ld [sBoxMon1Item], a
-
-.done
- ld a, [CurPartySpecies]
- ld [wd265], a
- ld [TempEnemyMonSpecies], a
- call GetPokemonName
- ld hl, StringBuffer1
- ld de, wMonOrItemNameBuffer
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
- pop af
- and a
- jp z, .wildmon
- pop de
- pop bc
- pop hl
- push bc
- push hl
- ld a, [ScriptBank]
- call GetFarHalfword
- ld bc, PKMN_NAME_LENGTH
- ld a, [ScriptBank]
- call FarCopyBytes
- pop hl
-rept 2
- inc hl
-endr
- ld a, [ScriptBank]
- call GetFarHalfword
- pop bc
- ld a, b
- and a
- push de
- push bc
- jr nz, .send_to_box
-
- push hl
- ld a, [CurPartyMon]
- ld hl, PartyMonOT
- call SkipNames
- ld d, h
- ld e, l
- pop hl
-.otnameloop
- ld a, [ScriptBank]
- call GetFarByte
- ld [de], a
- inc hl
- inc de
- cp "@"
- jr nz, .otnameloop
- ld a, [ScriptBank]
- call GetFarByte
- ld b, a
- push bc
- ld a, [CurPartyMon]
- ld hl, PartyMon1ID
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld a, 01001 / $100
- ld [hli], a
- ld [hl], 01001 % $100
- pop bc
- callba SetGiftPartyMonCaughtData
- jr .skip_nickname
-
-.send_to_box
- ld a, BANK(sBoxMonOT)
- call GetSRAMBank
- ld de, sBoxMonOT
-.loop
- ld a, [ScriptBank]
- call GetFarByte
- ld [de], a
- inc hl
- inc de
- cp "@"
- jr nz, .loop
- ld a, [ScriptBank]
- call GetFarByte
- ld b, a
- ld hl, sBoxMon1ID
- call Random
- ld [hli], a
- call Random
- ld [hl], a
- call CloseSRAM
- callba SetGiftBoxMonCaughtData
- jr .skip_nickname
-
-.wildmon
- pop de
- pop bc
- push bc
- push de
- ld a, b
- and a
- jr z, .party
- callba SetBoxMonCaughtData
- jr .set_caught_data
-
-.party
- callba SetCaughtData
-.set_caught_data
- callba GiveANickname_YesNo
- pop de
- jr c, .skip_nickname
- call InitNickname
-
-.skip_nickname
- pop bc
- pop de
- ld a, b
- and a
- ret z
- ld hl, TextJump_WasSentToBillsPC
- call PrintText
- ld a, BANK(sBoxMonNicknames)
- call GetSRAMBank
- ld hl, wMonOrItemNameBuffer
- ld de, sBoxMonNicknames
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
- call CloseSRAM
- ld b, $1
- ret
-; e3d4
-
-.FailedToGiveMon: ; e3d4
- pop bc
- pop de
- ld b, $2
- ret
-; e3d9
-
-TextJump_WasSentToBillsPC: ; 0xe3d9
- ; was sent to BILL's PC.
- text_jump Text_WasSentToBillsPC
- db "@"
-; 0xe3de
-
-InitNickname: ; e3de
- push de
- call LoadStandardMenuDataHeader
- call DisableSpriteUpdates
- pop de
- push de
- ld b, $0
- callba NamingScreen
- pop hl
- ld de, StringBuffer1
- call InitName
- ld a, $4 ; XXX could this be in bank 4 in pokered?
- ld hl, ExitAllMenus
- rst FarCall
- ret
-; e3fd
+INCLUDE "engine/move_mon.asm"
_BillsPC: ; e3fd
call .CheckCanUsePC
@@ -6979,7 +4898,7 @@ _BillsPC: ; e3fd
ld a, b
jr nc, .loop
.cancel
- call WriteBackup
+ call CloseWindow
ret
; e46f (3:646f)
@@ -7045,7 +4964,7 @@ BillsPC_MovePKMNMenu: ; e4cd
call ClearPCItemScreen
.quit
- call WriteBackup
+ call CloseWindow
and a
ret
; e4f9
@@ -7061,7 +4980,7 @@ BillsPC_DepositMenu: ; e4fe (3:64fe)
callba _DepositPKMN
call ReturnToMapFromSubmenu
call ClearPCItemScreen
- call WriteBackup
+ call CloseWindow
and a
ret
; e512 (3:6512)
@@ -7135,7 +5054,7 @@ BillsPC_WithdrawMenu: ; e559 (3:6559)
callba _WithdrawPKMN
call ReturnToMapFromSubmenu
call ClearPCItemScreen
- call WriteBackup
+ call CloseWindow
and a
ret
; e56d (3:656d)
@@ -7186,13 +5105,13 @@ ClearPCItemScreen: ; e58b
ret
; 0xe5bb
-Functione5bb: ; e5bb
+CopyBoxmonToTempMon: ; e5bb
ld a, [CurPartyMon]
ld hl, sBoxMon1Species
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld de, TempMonSpecies
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, BANK(sBoxMon1Species)
call GetSRAMBank
call CopyBytes
@@ -7203,9 +5122,9 @@ Functione5bb: ; e5bb
Functione5d9: ; unreferenced
ld a, [wCurBox]
cp b
- jr z, .asm_e5f1
+ jr z, .same_box
ld a, b
- ld hl, Unknown_e66e
+ ld hl, .BoxAddrs
ld bc, 3
call AddNTimes
ld a, [hli]
@@ -7214,30 +5133,30 @@ Functione5d9: ; unreferenced
ld h, [hl]
ld l, a
pop af
- jr .asm_e5f6
+ jr .okay
-.asm_e5f1
+.same_box
ld a, BANK(sBoxCount)
ld hl, sBoxCount
-.asm_e5f6
+.okay
call GetSRAMBank
ld a, [hl]
- ld bc, $16
+ ld bc, 1 + MONS_PER_BOX + 1
add hl, bc
ld b, a
ld c, $0
ld de, wc608
ld a, b
and a
- jr z, .asm_e66a
-.asm_e608
+ jr z, .empty_box
+.loop
push hl
push bc
ld a, c
ld bc, 0
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
ld [de], a
@@ -7246,33 +5165,36 @@ Functione5d9: ; unreferenced
call GetBaseData
pop bc
pop hl
+
push hl
push bc
ld a, c
- ld bc, $35c
+ ld bc, MONS_PER_BOX * (BOXMON_STRUCT_LENGTH + NAME_LENGTH)
add hl, bc
call SkipNames
call CopyBytes
pop bc
pop hl
+
push hl
push bc
ld a, c
- ld bc, $1f
+ ld bc, MON_LEVEL
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
ld [de], a
inc de
pop bc
pop hl
+
push hl
push bc
ld a, c
- ld bc, $15
+ ld bc, MON_DVS
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
and $f0
@@ -7285,24 +5207,23 @@ Functione5d9: ; unreferenced
ld a, [BaseGender]
cp b
ld a, $1
- jr c, .asm_e662
+ jr c, .okay2
xor a
-
-.asm_e662
+.okay2
ld [de], a
inc de
pop bc
pop hl
+
inc c
dec b
- jr nz, .asm_e608
-
-.asm_e66a
+ jr nz, .loop
+.empty_box
call CloseSRAM
ret
; e66e
-Unknown_e66e: ; e66e
+.BoxAddrs: ; e66e
dba sBox1
dba sBox2
dba sBox3
@@ -7319,10 +5240,10 @@ Unknown_e66e: ; e66e
dba sBox14
; e698
-Functione698: ; e698
+GetBreedMon1LevelGrowth: ; e698
ld hl, wBreedMon1Stats
ld de, TempMon
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
callab CalcLevel
ld a, [wBreedMon1Level]
@@ -7334,10 +5255,10 @@ Functione698: ; e698
ret
; e6b3
-Functione6b3: ; e6b3
+GetBreedMon2LevelGrowth: ; e6b3
ld hl, wBreedMon2Stats
ld de, TempMon
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
callab CalcLevel
ld a, [wBreedMon2Level]
@@ -7419,7 +5340,7 @@ GetPokeBallWobble: ; f971 (3:7971)
ld c, 0 ; next
jr nz, .done
- ld hl, WobbleChances
+ ld hl, .WobbleProbabilities
ld a, [Buffer1]
ld b, a
.loop
@@ -7455,8 +5376,9 @@ GetPokeBallWobble: ; f971 (3:7971)
ret
; f9ba (3:79ba)
-WobbleChances: ; f9ba
+.WobbleProbabilities: ; f9ba
; catch rate, chance of wobbling / 255
+; nLeft/255 = (nRight/255) ** 4
db 1, 63
db 2, 75
db 3, 84
@@ -8512,7 +6434,7 @@ _ReturnToBattle_UseBall: ; 2715c
callba GetMonFrontpic
callba _LoadBattleFontsHPBar
call GetMemSGBLayout
- call WriteBackup
+ call CloseWindow
call LoadStandardMenuDataHeader
call WaitBGMap
jp SetPalettes
@@ -11840,7 +9762,7 @@ CopyPkmnToTempMon: ; 5084a
cp OTPARTYMON
jr z, .copywholestruct
ld bc, BOXMON_STRUCT_LENGTH
- callab Functione5bb
+ callab CopyBoxmonToTempMon
jr .done
.copywholestruct
@@ -14559,7 +12481,7 @@ ShowPlayerNamingChoices: ; 88297
ld a, [wMenuCursorY]
dec a
call CopyNameFromMenu
- call WriteBackup
+ call CloseWindow
ret
; 882b5
diff --git a/maps/CeladonDeptStore6F.asm b/maps/CeladonDeptStore6F.asm
index d6c2fd97f..3abeda346 100644
--- a/maps/CeladonDeptStore6F.asm
+++ b/maps/CeladonDeptStore6F.asm
@@ -30,7 +30,7 @@ CeladonVendingMachine:
special PlaceMoneyTopRight
loadmenudata .MenuData
verticalmenu
- writebackup
+ closewindow
if_equal $1, .FreshWater
if_equal $2, .SodaPop
if_equal $3, .Lemonade
diff --git a/maps/CeladonGameCornerPrizeRoom.asm b/maps/CeladonGameCornerPrizeRoom.asm
index 4b077896f..1f2ca6ea3 100644
--- a/maps/CeladonGameCornerPrizeRoom.asm
+++ b/maps/CeladonGameCornerPrizeRoom.asm
@@ -9,25 +9,25 @@ CeladonGameCornerPrizeRoom_MapScriptHeader:
.MapCallbacks:
db 0
-GentlemanScript_0x726e9:
- jumptextfaceplayer UnknownText_0x728b8
+CeladonGameCornerPrizeRoomGentlemanScript:
+ jumptextfaceplayer CeladonGameCornerPrizeRoomGentlemanText
-PharmacistScript_0x726ec:
- jumptextfaceplayer UnknownText_0x728e9
+CeladonGameCornerPrizeRoomPharmacistScript:
+ jumptextfaceplayer CeladonGameCornerPrizeRoomPharmacistText
-MapCeladonGameCornerPrizeRoomSignpost0Script:
+GoldenrodGameCornerTMVendor:
faceplayer
opentext
- writetext UnknownText_0x7293e
+ writetext CeladonPrizeRoom_PrizeVendorIntroText
waitbutton
checkitem COIN_CASE
iffalse CeladonPrizeRoom_NoCoinCase
- writetext UnknownText_0x72974
+ writetext CeladonPrizeRoom_AskWhichPrizeText
CeladonPrizeRoom_tmcounterloop:
special Special_DisplayCoinCaseBalance
- loadmenudata MenuDataHeader_0x72790
+ loadmenudata CeladonPrizeRoom_TMMenuDataHeader
verticalmenu
- writebackup
+ closewindow
if_equal $1, .doubleteam
if_equal $2, .psychic
if_equal $3, .hyperbeam
@@ -67,50 +67,50 @@ CeladonPrizeRoom_tmcounterloop:
jump CeladonPrizeRoom_purchased
CeladonPrizeRoom_askbuy:
- writetext UnknownText_0x72991
+ writetext CeladonPrizeRoom_ConfirmPurchaseText
yesorno
end
CeladonPrizeRoom_purchased:
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x729ad
+ writetext CeladonPrizeRoom_HereYouGoText
waitbutton
jump CeladonPrizeRoom_tmcounterloop
CeladonPrizeRoom_notenoughcoins:
- writetext UnknownText_0x729bb
+ writetext CeladonPrizeRoom_NotEnoughCoinsText
waitbutton
closetext
end
CeladonPrizeRoom_notenoughroom:
- writetext UnknownText_0x729d8
+ writetext CeladonPrizeRoom_NotEnoughRoomText
waitbutton
closetext
end
CeladonPrizeRoom_cancel:
- writetext UnknownText_0x729f2
+ writetext CeladonPrizeRoom_ComeAgainText
waitbutton
closetext
end
CeladonPrizeRoom_NoCoinCase:
- writetext UnknownText_0x72a14
+ writetext CeladonPrizeRoom_NoCoinCaseText
waitbutton
closetext
end
-MenuDataHeader_0x72790:
+CeladonPrizeRoom_TMMenuDataHeader:
db $40 ; flags
db 02, 00 ; start coords
db 11, 15 ; end coords
- dw MenuData2_0x72798
+ dw .MenuData2
db 1 ; default option
-MenuData2_0x72798:
+.MenuData2:
db $80 ; flags
db 4 ; items
db "TM32 1500@"
@@ -119,19 +119,19 @@ MenuData2_0x72798:
db "CANCEL@"
-MapCeladonGameCornerPrizeRoomSignpost1Script:
+GoldenrodGameCornerPokemonVendor:
faceplayer
opentext
- writetext UnknownText_0x7293e
+ writetext CeladonPrizeRoom_PrizeVendorIntroText
waitbutton
checkitem COIN_CASE
iffalse CeladonPrizeRoom_NoCoinCase
.loop:
- writetext UnknownText_0x72974
+ writetext CeladonPrizeRoom_AskWhichPrizeText
special Special_DisplayCoinCaseBalance
- loadmenudata MenuDataHeader_0x72877
+ loadmenudata .MenuDataHeader
verticalmenu
- writebackup
+ closewindow
if_equal $1, .pikachu
if_equal $2, .porygon
if_equal $3, .larvitar
@@ -147,7 +147,7 @@ MapCeladonGameCornerPrizeRoomSignpost1Script:
iffalse CeladonPrizeRoom_cancel
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x729ad
+ writetext CeladonPrizeRoom_HereYouGoText
waitbutton
writebyte PIKACHU
special Special_GameCornerPrizeMonCheckDex
@@ -165,7 +165,7 @@ MapCeladonGameCornerPrizeRoomSignpost1Script:
iffalse CeladonPrizeRoom_cancel
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x729ad
+ writetext CeladonPrizeRoom_HereYouGoText
waitbutton
writebyte PORYGON
special Special_GameCornerPrizeMonCheckDex
@@ -183,7 +183,7 @@ MapCeladonGameCornerPrizeRoomSignpost1Script:
iffalse CeladonPrizeRoom_cancel
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x729ad
+ writetext CeladonPrizeRoom_HereYouGoText
waitbutton
writebyte LARVITAR
special Special_GameCornerPrizeMonCheckDex
@@ -192,14 +192,14 @@ MapCeladonGameCornerPrizeRoomSignpost1Script:
jump .loop
-MenuDataHeader_0x72877:
+.MenuDataHeader:
db $40 ; flags
db 02, 00 ; start coords
db 11, 17 ; end coords
- dw MenuData2_0x7287f
+ dw .MenuData2
db 1 ; default option
-MenuData2_0x7287f:
+.MenuData2:
db $80 ; flags
db 4 ; items
db "PIKACHU 2222@"
@@ -208,13 +208,13 @@ MenuData2_0x7287f:
db "CANCEL@"
-UnknownText_0x728b8:
+CeladonGameCornerPrizeRoomGentlemanText:
text "I wanted PORYGON,"
line "but I was short by"
cont "100 coins…"
done
-UnknownText_0x728e9:
+CeladonGameCornerPrizeRoomPharmacistText:
text "Whew…"
para "I've got to stay"
@@ -225,7 +225,7 @@ UnknownText_0x728e9:
cont "all my money…"
done
-UnknownText_0x7293e:
+CeladonPrizeRoom_PrizeVendorIntroText:
text "Welcome!"
para "We exchange your"
@@ -233,38 +233,38 @@ UnknownText_0x7293e:
cont "prizes!"
done
-UnknownText_0x72974:
+CeladonPrizeRoom_AskWhichPrizeText:
text "Which prize would"
line "you like?"
done
-UnknownText_0x72991:
+CeladonPrizeRoom_ConfirmPurchaseText:
text "OK, so you wanted"
line "a @"
text_from_ram StringBuffer3
text "?"
done
-UnknownText_0x729ad:
+CeladonPrizeRoom_HereYouGoText:
text "Here you go!"
done
-UnknownText_0x729bb:
+CeladonPrizeRoom_NotEnoughCoinsText:
text "You don't have"
line "enough coins."
done
-UnknownText_0x729d8:
+CeladonPrizeRoom_NotEnoughRoomText:
text "You have no room"
line "for it."
done
-UnknownText_0x729f2:
+CeladonPrizeRoom_ComeAgainText:
text "Oh. Please come"
line "back with coins!"
done
-UnknownText_0x72a14:
+CeladonPrizeRoom_NoCoinCaseText:
text "Oh? You don't have"
line "a COIN CASE."
done
@@ -283,10 +283,10 @@ CeladonGameCornerPrizeRoom_MapEventHeader:
.Signposts:
db 2
- signpost 1, 2, SIGNPOST_READ, MapCeladonGameCornerPrizeRoomSignpost0Script
- signpost 1, 4, SIGNPOST_READ, MapCeladonGameCornerPrizeRoomSignpost1Script
+ signpost 1, 2, SIGNPOST_READ, GoldenrodGameCornerTMVendor
+ signpost 1, 4, SIGNPOST_READ, GoldenrodGameCornerPokemonVendor
.PersonEvents:
db 2
- person_event SPRITE_GENTLEMAN, 2, 0, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, GentlemanScript_0x726e9, -1
- person_event SPRITE_PHARMACIST, 4, 4, SPRITEMOVEDATA_WALK_UP_DOWN, 1, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, PharmacistScript_0x726ec, -1
+ person_event SPRITE_GENTLEMAN, 2, 0, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, CeladonGameCornerPrizeRoomGentlemanScript, -1
+ person_event SPRITE_PHARMACIST, 4, 4, SPRITEMOVEDATA_WALK_UP_DOWN, 1, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, CeladonGameCornerPrizeRoomPharmacistScript, -1
diff --git a/maps/DragonShrine.asm b/maps/DragonShrine.asm
index 347d77bfe..942920874 100644
--- a/maps/DragonShrine.asm
+++ b/maps/DragonShrine.asm
@@ -34,7 +34,7 @@ DragonShrineTestScript:
buttonsound
loadmenudata MenuDataHeader_0x18d215
verticalmenu
- writebackup
+ closewindow
if_equal $1, .RightAnswer
if_equal $2, .WrongAnswer
if_equal $3, .RightAnswer
@@ -46,7 +46,7 @@ DragonShrineTestScript:
buttonsound
loadmenudata MenuDataHeader_0x18d234
verticalmenu
- writebackup
+ closewindow
if_equal $1, .RightAnswer
if_equal $2, .RightAnswer
if_equal $3, .WrongAnswer
@@ -56,7 +56,7 @@ DragonShrineTestScript:
buttonsound
loadmenudata MenuDataHeader_0x18d258
verticalmenu
- writebackup
+ closewindow
if_equal $1, .WrongAnswer
if_equal $2, .RightAnswer
if_equal $3, .RightAnswer
@@ -66,7 +66,7 @@ DragonShrineTestScript:
buttonsound
loadmenudata MenuDataHeader_0x18d283
verticalmenu
- writebackup
+ closewindow
if_equal $1, .RightAnswer
if_equal $2, .WrongAnswer
if_equal $3, .RightAnswer
@@ -76,7 +76,7 @@ DragonShrineTestScript:
buttonsound
loadmenudata MenuDataHeader_0x18d2a5
verticalmenu
- writebackup
+ closewindow
if_equal $1, .WrongAnswer
if_equal $2, .RightAnswer
if_equal $3, .WrongAnswer
diff --git a/maps/EarlsPokemonAcademy.asm b/maps/EarlsPokemonAcademy.asm
index 126db4efe..865e34c1c 100644
--- a/maps/EarlsPokemonAcademy.asm
+++ b/maps/EarlsPokemonAcademy.asm
@@ -68,7 +68,7 @@ AcademyBlackboard:
.Loop
loadmenudata .MenuHeader
_2dmenu
- writebackup
+ closewindow
if_equal $1, .Poison
if_equal $2, .Paralysis
if_equal $3, .Sleep
diff --git a/maps/GoldenrodCity.asm b/maps/GoldenrodCity.asm
index 9e27ccf3b..e50f6e223 100644
--- a/maps/GoldenrodCity.asm
+++ b/maps/GoldenrodCity.asm
@@ -69,7 +69,7 @@ MoveTutor:
writetext UnknownText_0x1990ce
loadmenudata .MoveMenuDataHeader
verticalmenu
- writebackup
+ closewindow
if_equal $1, .Flamethrower
if_equal $2, .Thunderbolt
if_equal $3, .IceBeam
diff --git a/maps/GoldenrodDeptStore6F.asm b/maps/GoldenrodDeptStore6F.asm
index 34f5ad350..3d54a45b0 100644
--- a/maps/GoldenrodDeptStore6F.asm
+++ b/maps/GoldenrodDeptStore6F.asm
@@ -16,7 +16,7 @@ GoldenrodVendingMachine:
special PlaceMoneyTopRight
loadmenudata .MenuData
verticalmenu
- writebackup
+ closewindow
if_equal $1, .FreshWater
if_equal $2, .SodaPop
if_equal $3, .Lemonade
diff --git a/maps/GoldenrodGameCorner.asm b/maps/GoldenrodGameCorner.asm
index 18d24acdf..d92233639 100644
--- a/maps/GoldenrodGameCorner.asm
+++ b/maps/GoldenrodGameCorner.asm
@@ -21,128 +21,128 @@ GoldenrodGameCorner_MapScriptHeader:
; callbacks
- dbw 2, UnknownScript_0x56bf9
+ dbw 2, .Callback
-UnknownScript_0x56bf9:
+.Callback
checkevent EVENT_BEAT_ELITE_FOUR
- iffalse UnknownScript_0x56c19
+ iffalse .finish
checkitem COIN_CASE
- iffalse UnknownScript_0x56c0e
+ iffalse .move_tutor_inside
checkcode VAR_WEEKDAY
- if_equal WEDNESDAY, UnknownScript_0x56c11
- if_equal SATURDAY, UnknownScript_0x56c11
-UnknownScript_0x56c0e:
+ if_equal WEDNESDAY, .move_tutor_outside
+ if_equal SATURDAY, .move_tutor_outside
+.move_tutor_inside
appear GOLDENRODGAMECORNER_POKEFAN_M3
return
-UnknownScript_0x56c11:
+.move_tutor_outside
checkflag ENGINE_DAILY_MOVE_TUTOR
- iftrue UnknownScript_0x56c19
+ iftrue .finish
disappear GOLDENRODGAMECORNER_POKEFAN_M3
-UnknownScript_0x56c19: ;0x56c19
+.finish
return
-PokefanMScript_0x56c1a:
+GoldenrodGameCornerPokefanM3Script:
faceplayer
opentext
- writetext UnknownText_0x5718a
+ writetext GoldenrodGameCornerPokefanM3Text
waitbutton
closetext
spriteface GOLDENRODGAMECORNER_POKEFAN_M3, RIGHT
end
-ClerkScript_0x56c25:
+GoldenrodGmeCornerCoinVendorScript:
jumpstd gamecornercoinvendor
-ReceptionistScript_0x56c28:
+GoldenrodGmeCornerTMVendorScript:
faceplayer
opentext
- writetext UnknownText_0x56e50
+ writetext GoldenrodGameCornerPrizeVendorIntroText
waitbutton
checkitem COIN_CASE
- iffalse UnknownScript_0x56cc3
- writetext UnknownText_0x56e8b
-UnknownScript_0x56c36: ; 056c36
+ iffalse GoldenrodGameCornerPrizeVendor_NoCoinCaseScript
+ writetext GoldenrodGameCornerPrizeVendorWhichPrizeText
+GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36
special Special_DisplayCoinCaseBalance
- loadmenudata MenuDataHeader_0x56cc9
+ loadmenudata GoldenrodGameCornerTMVendorMenuData
verticalmenu
- writebackup
- if_equal $1, UnknownScript_0x56c4d
- if_equal $2, UnknownScript_0x56c69
- if_equal $3, UnknownScript_0x56c85
- jump UnknownScript_0x56cbd
+ closewindow
+ if_equal $1, .Thunder
+ if_equal $2, .Blizzard
+ if_equal $3, .FireBlast
+ jump GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
-UnknownScript_0x56c4d:
+.Thunder:
checkcoins 5500
- if_equal $2, UnknownScript_0x56cb1
+ if_equal $2, GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript
itemtotext TM_THUNDER, $0
- scall UnknownScript_0x56ca1
- iffalse UnknownScript_0x56cbd
+ scall GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript
+ iffalse GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
giveitem TM_THUNDER
- iffalse UnknownScript_0x56cb7
+ iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
takecoins 5500
- jump UnknownScript_0x56ca6
+ jump GoldenrodGmeCornerTMVendor_FinishScript
-UnknownScript_0x56c69:
+.Blizzard:
checkcoins 5500
- if_equal $2, UnknownScript_0x56cb1
+ if_equal $2, GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript
itemtotext TM_BLIZZARD, $0
- scall UnknownScript_0x56ca1
- iffalse UnknownScript_0x56cbd
+ scall GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript
+ iffalse GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
giveitem TM_BLIZZARD
- iffalse UnknownScript_0x56cb7
+ iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
takecoins 5500
- jump UnknownScript_0x56ca6
+ jump GoldenrodGmeCornerTMVendor_FinishScript
-UnknownScript_0x56c85:
+.FireBlast:
checkcoins 5500
- if_equal $2, UnknownScript_0x56cb1
+ if_equal $2, GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript
itemtotext TM_FIRE_BLAST, $0
- scall UnknownScript_0x56ca1
- iffalse UnknownScript_0x56cbd
+ scall GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript
+ iffalse GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
giveitem TM_FIRE_BLAST
- iffalse UnknownScript_0x56cb7
+ iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
takecoins 5500
- jump UnknownScript_0x56ca6
+ jump GoldenrodGmeCornerTMVendor_FinishScript
-UnknownScript_0x56ca1:
- writetext UnknownText_0x56ea8
+GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript:
+ writetext GoldenrodGameCornerPrizeVendorConfirmPrizeText
yesorno
end
-UnknownScript_0x56ca6:
+GoldenrodGmeCornerTMVendor_FinishScript:
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x56ebd
+ writetext GoldenrodGameCornerPrizeVendorHereYouGoText
waitbutton
- jump UnknownScript_0x56c36
+ jump GoldenrodGmeCornerTMVendor_LoopScript
-UnknownScript_0x56cb1:
- writetext UnknownText_0x56ecb
+GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript:
+ writetext GoldenrodGameCornerPrizeVendorNeedMoreCoinsText
waitbutton
closetext
end
-UnknownScript_0x56cb7:
- writetext UnknownText_0x56ee8
+GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript:
+ writetext GoldenrodGameCornerPrizeVendorNoMoreRoomText
waitbutton
closetext
end
-UnknownScript_0x56cbd:
- writetext UnknownText_0x56f09
+GoldenrodGameCornerPrizeVendor_CancelPurchaseScript:
+ writetext GoldenrodGameCornerPrizeVendorQuitText
waitbutton
closetext
end
-UnknownScript_0x56cc3:
- writetext UnknownText_0x56f35
+GoldenrodGameCornerPrizeVendor_NoCoinCaseScript:
+ writetext GoldenrodGameCornerPrizeVendorNoCoinCaseText
waitbutton
closetext
end
-MenuDataHeader_0x56cc9:
+GoldenrodGameCornerTMVendorMenuData:
db $40 ; flags
db 02, 00 ; start coords
db 11, 15 ; end coords
@@ -158,87 +158,87 @@ MenuData2_0x56cd1:
db "CANCEL@"
-ReceptionistScript_0x56d01:
+GoldenrodGameCornerPrizeMonVendorScript:
faceplayer
opentext
- writetext UnknownText_0x56e50
+ writetext GoldenrodGameCornerPrizeVendorIntroText
waitbutton
checkitem COIN_CASE
- iffalse UnknownScript_0x56cc3
-UnknownScript_0x56d0c:
- writetext UnknownText_0x56e8b
+ iffalse GoldenrodGameCornerPrizeVendor_NoCoinCaseScript
+.loop
+ writetext GoldenrodGameCornerPrizeVendorWhichPrizeText
special Special_DisplayCoinCaseBalance
- loadmenudata MenuDataHeader_0x56db0
+ loadmenudata .MenuDataHeader
verticalmenu
- writebackup
- if_equal $1, UnknownScript_0x56d26
- if_equal $2, UnknownScript_0x56d54
- if_equal $3, UnknownScript_0x56d82
- jump UnknownScript_0x56cbd
+ closewindow
+ if_equal $1, .abra
+ if_equal $2, .cubone
+ if_equal $3, .wobbuffet
+ jump GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
-UnknownScript_0x56d26:
+.abra:
checkcoins 100
- if_equal $2, UnknownScript_0x56cb1
+ if_equal $2, GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript
checkcode VAR_PARTYCOUNT
- if_equal $6, UnknownScript_0x56cb7
+ if_equal $6, GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
pokenamemem ABRA, $0
- scall UnknownScript_0x56ca1
- iffalse UnknownScript_0x56cbd
+ scall GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript
+ iffalse GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x56ebd
+ writetext GoldenrodGameCornerPrizeVendorHereYouGoText
waitbutton
writebyte ABRA
special Special_GameCornerPrizeMonCheckDex
givepoke ABRA, 5
takecoins 100
- jump UnknownScript_0x56d0c
+ jump .loop
-UnknownScript_0x56d54:
+.cubone:
checkcoins 800
- if_equal $2, UnknownScript_0x56cb1
+ if_equal $2, GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript
checkcode VAR_PARTYCOUNT
- if_equal $6, UnknownScript_0x56cb7
+ if_equal $6, GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
pokenamemem CUBONE, $0
- scall UnknownScript_0x56ca1
- iffalse UnknownScript_0x56cbd
+ scall GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript
+ iffalse GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x56ebd
+ writetext GoldenrodGameCornerPrizeVendorHereYouGoText
waitbutton
writebyte CUBONE
special Special_GameCornerPrizeMonCheckDex
givepoke CUBONE, 15
takecoins 800
- jump UnknownScript_0x56d0c
+ jump .loop
-UnknownScript_0x56d82:
+.wobbuffet:
checkcoins 1500
- if_equal $2, UnknownScript_0x56cb1
+ if_equal $2, GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript
checkcode VAR_PARTYCOUNT
- if_equal $6, UnknownScript_0x56cb7
+ if_equal $6, GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
pokenamemem WOBBUFFET, $0
- scall UnknownScript_0x56ca1
- iffalse UnknownScript_0x56cbd
+ scall GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript
+ iffalse GoldenrodGameCornerPrizeVendor_CancelPurchaseScript
waitsfx
playsound SFX_TRANSACTION
- writetext UnknownText_0x56ebd
+ writetext GoldenrodGameCornerPrizeVendorHereYouGoText
waitbutton
writebyte WOBBUFFET
special Special_GameCornerPrizeMonCheckDex
givepoke WOBBUFFET, 15
takecoins 1500
- jump UnknownScript_0x56d0c
+ jump .loop
-MenuDataHeader_0x56db0:
+.MenuDataHeader:
db $40 ; flags
db 02, 00 ; start coords
db 11, 17 ; end coords
- dw MenuData2_0x56db8
+ dw .MenuData2
db 1 ; default option
-MenuData2_0x56db8:
+.MenuData2:
db $80 ; flags
db 4 ; items
db "ABRA 100@"
@@ -247,83 +247,83 @@ MenuData2_0x56db8:
db "CANCEL@"
-PharmacistScript_0x56df1:
+GoldenrodGameCornerPharmacistScript:
faceplayer
opentext
- writetext UnknownText_0x56f55
+ writetext GoldenrodGameCornerPharmacistText
waitbutton
closetext
spriteface LAST_TALKED, LEFT
end
-PokefanMScript_0x56dfc:
+GoldenrodGameCornerPokefanM1Script:
faceplayer
opentext
- writetext UnknownText_0x56f9e
+ writetext GoldenrodGameCornerPokefanM1Text
waitbutton
closetext
spriteface GOLDENRODGAMECORNER_POKEFAN_M1, RIGHT
end
-CooltrainerMScript_0x56e07:
+GoldenrodGameCornerCooltrainerMScript:
faceplayer
opentext
- writetext UnknownText_0x56ff4
+ writetext GoldenrodGameCornerCooltrainerMText
waitbutton
closetext
spriteface GOLDENRODGAMECORNER_COOLTRAINER_M, LEFT
end
-PokefanFScript_0x56e12:
+GoldenrodGameCornerPokefanFScript:
faceplayer
opentext
- writetext UnknownText_0x5702b
+ writetext GoldenrodGameCornerPokefanFText
waitbutton
closetext
spriteface GOLDENRODGAMECORNER_POKEFAN_F, RIGHT
end
-CooltrainerFScript_0x56e1d:
- jumptextfaceplayer UnknownText_0x57097
+GoldenrodGameCornerCooltrainerFScript:
+ jumptextfaceplayer GoldenrodGameCornerCooltrainerFText
-GentlemanScript_0x56e20:
+GoldenrodGameCornerGentlemanScript:
faceplayer
opentext
- writetext UnknownText_0x570b1
+ writetext GoldenrodGameCornerGentlemanText
waitbutton
closetext
spriteface GOLDENRODGAMECORNER_GENTLEMAN, RIGHT
end
-PokefanMScript_0x56e2b:
- jumptextfaceplayer UnknownText_0x5710d
+GoldenrodGameCornerPokefanM2Script:
+ jumptextfaceplayer GoldenrodGameCornerPokefanM2Text
-MapGoldenrodGameCornerSignpost30Script:
- jumptext UnknownText_0x571af
+GoldenrodGameCornerLeftTheirDrinkScript:
+ jumptext GoldenrodGameCornerLeftTheirDrinkText
-MapGoldenrodGameCornerSignpost17Script:
- random $6
- if_equal $0, MapGoldenrodGameCornerSignpost7Script
+GoldenrodGameCornerSlotsMachineScript:
+ random 6
+ if_equal 0, GoldenrodGameCornerLuckySlotsMachineScript
refreshscreen $0
- writebyte $0
+ writebyte FALSE
special Special_SlotMachine
closetext
end
-MapGoldenrodGameCornerSignpost7Script:
+GoldenrodGameCornerLuckySlotsMachineScript:
refreshscreen $0
- writebyte $1
+ writebyte TRUE
special Special_SlotMachine
closetext
end
-MapGoldenrodGameCornerSignpost29Script:
+GoldenrodGameCornerCardFlipMachineScript:
refreshscreen $0
special Special_CardFlip
closetext
end
-UnknownText_0x56e50:
+GoldenrodGameCornerPrizeVendorIntroText:
text "Welcome!"
para "We exchange your"
@@ -331,43 +331,43 @@ UnknownText_0x56e50:
cont "fabulous prizes!"
done
-UnknownText_0x56e8b:
+GoldenrodGameCornerPrizeVendorWhichPrizeText:
text "Which prize would"
line "you like?"
done
-UnknownText_0x56ea8:
+GoldenrodGameCornerPrizeVendorConfirmPrizeText:
text_from_ram StringBuffer3
text "."
line "Is that right?"
done
-UnknownText_0x56ebd:
+GoldenrodGameCornerPrizeVendorHereYouGoText:
text "Here you go!"
done
-UnknownText_0x56ecb:
+GoldenrodGameCornerPrizeVendorNeedMoreCoinsText:
text "Sorry! You need"
line "more coins."
done
-UnknownText_0x56ee8:
+GoldenrodGameCornerPrizeVendorNoMoreRoomText:
text "Sorry. You can't"
line "carry any more."
done
-UnknownText_0x56f09:
+GoldenrodGameCornerPrizeVendorQuitText:
text "OK. Please save"
line "your coins and"
cont "come again!"
done
-UnknownText_0x56f35:
+GoldenrodGameCornerPrizeVendorNoCoinCaseText:
text "Oh? You don't have"
line "a COIN CASE."
done
-UnknownText_0x56f55:
+GoldenrodGameCornerPharmacistText:
text "I always play this"
line "slot machine. It"
@@ -375,7 +375,7 @@ UnknownText_0x56f55:
line "others, I think."
done
-UnknownText_0x56f9e:
+GoldenrodGameCornerPokefanM1Text:
text "I just love this"
line "new slot machine."
@@ -384,13 +384,13 @@ UnknownText_0x56f9e:
cont "ones in CELADON."
done
-UnknownText_0x56ff4:
+GoldenrodGameCornerCooltrainerMText:
text "Life is a gamble."
line "I'm going to flip"
cont "cards till I drop!"
done
-UnknownText_0x5702b:
+GoldenrodGameCornerPokefanFText:
text "Card flip…"
para "I prefer it over"
@@ -403,12 +403,12 @@ UnknownText_0x5702b:
line "much lower."
done
-UnknownText_0x57097:
+GoldenrodGameCornerCooltrainerFText:
text "I won't quit until"
line "I win!"
done
-UnknownText_0x570b1:
+GoldenrodGameCornerGentlemanText:
text "I taught BLIZZARD"
line "to my #MON."
@@ -419,7 +419,7 @@ UnknownText_0x570b1:
line "worth it."
done
-UnknownText_0x5710d:
+GoldenrodGameCornerPokefanM2Text:
text "I couldn't win at"
line "the slots, and I"
@@ -433,12 +433,12 @@ UnknownText_0x5710d:
line "UNDERGROUND."
done
-UnknownText_0x5718a:
+GoldenrodGameCornerPokefanM3Text:
text "Wahahah! The coins"
line "keep rolling in!"
done
-UnknownText_0x571af:
+GoldenrodGameCornerLeftTheirDrinkText:
text "Someone left their"
line "drink."
@@ -459,49 +459,49 @@ GoldenrodGameCorner_MapEventHeader:
.Signposts:
db 31
- signpost 6, 6, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 7, 6, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 8, 6, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 9, 6, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 10, 6, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 11, 6, SIGNPOST_RIGHT, MapGoldenrodGameCornerSignpost17Script
- signpost 6, 7, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 7, 7, SIGNPOST_READ, MapGoldenrodGameCornerSignpost7Script
- signpost 8, 7, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 9, 7, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 10, 7, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 11, 7, SIGNPOST_LEFT, MapGoldenrodGameCornerSignpost17Script
- signpost 6, 12, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 7, 12, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 8, 12, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 9, 12, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 10, 12, SIGNPOST_READ, MapGoldenrodGameCornerSignpost17Script
- signpost 11, 12, SIGNPOST_RIGHT, MapGoldenrodGameCornerSignpost17Script
- signpost 6, 13, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 7, 13, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 8, 13, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 9, 13, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 10, 13, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 11, 13, SIGNPOST_LEFT, MapGoldenrodGameCornerSignpost29Script
- signpost 6, 18, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 7, 18, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 8, 18, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 9, 18, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 10, 18, SIGNPOST_READ, MapGoldenrodGameCornerSignpost29Script
- signpost 11, 18, SIGNPOST_RIGHT, MapGoldenrodGameCornerSignpost29Script
- signpost 1, 12, SIGNPOST_LEFT, MapGoldenrodGameCornerSignpost30Script
+ signpost 6, 6, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 7, 6, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 8, 6, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 9, 6, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 10, 6, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 11, 6, SIGNPOST_RIGHT, GoldenrodGameCornerSlotsMachineScript
+ signpost 6, 7, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 7, 7, SIGNPOST_READ, GoldenrodGameCornerLuckySlotsMachineScript
+ signpost 8, 7, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 9, 7, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 10, 7, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 11, 7, SIGNPOST_LEFT, GoldenrodGameCornerSlotsMachineScript
+ signpost 6, 12, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 7, 12, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 8, 12, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 9, 12, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 10, 12, SIGNPOST_READ, GoldenrodGameCornerSlotsMachineScript
+ signpost 11, 12, SIGNPOST_RIGHT, GoldenrodGameCornerSlotsMachineScript
+ signpost 6, 13, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 7, 13, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 8, 13, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 9, 13, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 10, 13, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 11, 13, SIGNPOST_LEFT, GoldenrodGameCornerCardFlipMachineScript
+ signpost 6, 18, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 7, 18, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 8, 18, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 9, 18, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 10, 18, SIGNPOST_READ, GoldenrodGameCornerCardFlipMachineScript
+ signpost 11, 18, SIGNPOST_RIGHT, GoldenrodGameCornerCardFlipMachineScript
+ signpost 1, 12, SIGNPOST_LEFT, GoldenrodGameCornerLeftTheirDrinkScript
.PersonEvents:
db 12
- person_event SPRITE_CLERK, 2, 3, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, ClerkScript_0x56c25, -1
- person_event SPRITE_RECEPTIONIST, 2, 16, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, ReceptionistScript_0x56c28, -1
- person_event SPRITE_RECEPTIONIST, 2, 18, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, ReceptionistScript_0x56d01, -1
- person_event SPRITE_PHARMACIST, 7, 8, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, 2, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, PharmacistScript_0x56df1, -1
- person_event SPRITE_PHARMACIST, 7, 8, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, 4, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, PharmacistScript_0x56df1, -1
- person_event SPRITE_POKEFAN_M, 10, 11, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_SCRIPT, 0, PokefanMScript_0x56dfc, -1
- person_event SPRITE_COOLTRAINER_M, 8, 14, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, CooltrainerMScript_0x56e07, -1
- person_event SPRITE_POKEFAN_F, 6, 17, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, PokefanFScript_0x56e12, -1
- person_event SPRITE_COOLTRAINER_F, 3, 10, SPRITEMOVEDATA_WANDER, 1, 2, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, CooltrainerFScript_0x56e1d, -1
- person_event SPRITE_GENTLEMAN, 10, 5, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, GentlemanScript_0x56e20, -1
- person_event SPRITE_POKEFAN_M, 9, 2, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_SCRIPT, 0, PokefanMScript_0x56e2b, -1
- person_event SPRITE_POKEFAN_M, 10, 17, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, PokefanMScript_0x56c1a, EVENT_GOLDENROD_GAME_CORNER_MOVE_TUTOR
+ person_event SPRITE_CLERK, 2, 3, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, GoldenrodGmeCornerCoinVendorScript, -1
+ person_event SPRITE_RECEPTIONIST, 2, 16, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, GoldenrodGmeCornerTMVendorScript, -1
+ person_event SPRITE_RECEPTIONIST, 2, 18, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerPrizeMonVendorScript, -1
+ person_event SPRITE_PHARMACIST, 7, 8, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, (1 << DAY), (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerPharmacistScript, -1
+ person_event SPRITE_PHARMACIST, 7, 8, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, (1 << NITE), (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerPharmacistScript, -1
+ person_event SPRITE_POKEFAN_M, 10, 11, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerPokefanM1Script, -1
+ person_event SPRITE_COOLTRAINER_M, 8, 14, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerCooltrainerMScript, -1
+ person_event SPRITE_POKEFAN_F, 6, 17, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerPokefanFScript, -1
+ person_event SPRITE_COOLTRAINER_F, 3, 10, SPRITEMOVEDATA_WANDER, 1, 2, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerCooltrainerFScript, -1
+ person_event SPRITE_GENTLEMAN, 10, 5, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerGentlemanScript, -1
+ person_event SPRITE_POKEFAN_M, 9, 2, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerPokefanM2Script, -1
+ person_event SPRITE_POKEFAN_M, 10, 17, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, GoldenrodGameCornerPokefanM3Script, EVENT_GOLDENROD_GAME_CORNER_MOVE_TUTOR
diff --git a/maps/GoldenrodPokeComCenter2FMobile.asm b/maps/GoldenrodPokeComCenter2FMobile.asm
index 06d4aece6..56ae85b30 100644
--- a/maps/GoldenrodPokeComCenter2FMobile.asm
+++ b/maps/GoldenrodPokeComCenter2FMobile.asm
@@ -27,7 +27,7 @@ UnknownScript_0x625df:
reloadmappart
loadmenudata MenuDataHeader_0x62602
verticalmenu
- writebackup
+ closewindow
if_equal $1, UnknownScript_0x625f0
if_equal $2, UnknownScript_0x625f8
jump UnknownScript_0x62600
@@ -72,7 +72,7 @@ UnknownScript_0x62629:
reloadmappart
loadmenudata MenuDataHeader_0x6264c
verticalmenu
- writebackup
+ closewindow
if_equal $1, UnknownScript_0x6263a
if_equal $2, UnknownScript_0x62642
jump UnknownScript_0x6264a
diff --git a/misc/mobile_22.asm b/misc/mobile_22.asm
index 70b4e04e4..64cb84dc3 100644
--- a/misc/mobile_22.asm
+++ b/misc/mobile_22.asm
@@ -255,7 +255,7 @@ Function89261: ; 89261
push af
ld c, $a
call DelayFrames
- call WriteBackup
+ call CloseWindow
call Function8920f
pop af
jr c, .done
@@ -2816,7 +2816,7 @@ Function8a116: ; 8a116 (22:6116)
ret
.asm_8a16b
call Function89209
- call WriteBackup
+ call CloseWindow
call Function8920f
scf
ret
@@ -2999,7 +2999,7 @@ Function8a2aa: ; 8a2aa (22:62aa)
and a
ret
.asm_8a2ea
- call WriteBackup
+ call CloseWindow
.asm_8a2ed
scf
ret
@@ -3901,7 +3901,7 @@ Function8a999: ; 8a999 (22:6999)
jr .asm_8a9a1
.asm_8a9bb
call Function89209
- call WriteBackup
+ call CloseWindow
call Function8920f
ret
diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm
index 9817f1afc..251876458 100644
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -2857,7 +2857,7 @@ Jumptable_101247: ; 101247
Function101251: ; 101251
call UpdateSprites
- call ResetWindow
+ call RefreshScreen
ld hl, UnknownText_0x1021f4
call Function1021e0
call Function1020ea
@@ -7752,7 +7752,7 @@ AskMobileOrCable: ; 103612
.skip_load
call VerticalMenu
- call WriteBackup
+ call CloseWindow
jr c, .pressed_b
ld a, [wMenuCursorY]
ld [ScriptVar], a
diff --git a/misc/mobile_46.asm b/misc/mobile_46.asm
index 43810dc89..c0e8634e1 100755
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -1416,7 +1416,7 @@ Function118982:
push af
ld a, $1
ld [rSVBK], a
- call WriteBackup
+ call CloseWindow
pop af
ld [rSVBK], a
ld a, [wcd38]
@@ -1440,7 +1440,7 @@ Function118982:
push af
ld a, $1
ld [rSVBK], a
- call WriteBackup
+ call CloseWindow
pop af
ld [rSVBK], a
ld a, $7
diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm
index 2c1972c1a..b16a75232 100644
--- a/misc/mobile_5f.asm
+++ b/misc/mobile_5f.asm
@@ -456,7 +456,7 @@ Special_Menu_ChallengeExplanationCancel: ; 17d224
.Load_Interpret
call LoadMenuDataHeader
call Function17d246
- call WriteBackup
+ call CloseWindow
ret
; 17d246
@@ -1939,7 +1939,7 @@ Function17dc1f: ; 17dc1f
ld [wMenuCursorY], a
.asm_17dc6e
- call WriteBackup
+ call CloseWindow
pop af
ld [rSVBK], a
ld a, [wMenuCursorY]
diff --git a/wram.asm b/wram.asm
index d4cdc71d7..1e563ece8 100644
--- a/wram.asm
+++ b/wram.asm
@@ -2050,7 +2050,7 @@ TempMon::
wSpriteFlags:: ds 1
-wd13f:: ds 2
+wHandlePlayerStep:: ds 2
PartyMenuActionText:: ; d141
ds 1
@@ -2073,16 +2073,21 @@ wPrevMapGroup:: ds 1
wPrevMapNumber:: ds 1
; d14c
-wd14c:: ds 1 ; used in FollowNotExact
-wd14d:: ds 1 ; used in FollowNotExact
+wFollowNotExactPersonX:: ds 1 ; used in FollowNotExact
+wFollowNotExactPersonY:: ds 1 ; used in FollowNotExact
; Player movement
-wPlayerStepVectorX:: ds 1
-wPlayerStepVectorY:: ds 1
-wPlayerStepFlags:: ds 1
-wPlayerStepDirection:: ds 1
-
-wBGMapAnchor:: ds 2
+wPlayerStepVectorX:: ds 1 ; d14e
+wPlayerStepVectorY:: ds 1 ; d14f
+wPlayerStepFlags:: ds 1 ; d150
+; bit 7: Start step
+; bit 6: Stop step
+; bit 5: Doing step
+; bit 4: In midair
+; bits 0-3: unused
+wPlayerStepDirection:: ds 1 ; d151
+
+wBGMapAnchor:: ds 2 ; d152
UsedSprites:: ds 64 ; d154
UsedSpritesEnd::