summaryrefslogtreecommitdiff
path: root/engine/menu
diff options
context:
space:
mode:
authorDaniel Harding <corrnondacqb@yahoo.com>2015-07-16 14:36:48 -0500
committerDaniel Harding <corrnondacqb@yahoo.com>2015-07-16 14:36:48 -0500
commit9e77982bc8658c09df187b4598f8cbabb427a271 (patch)
treed88ff7a45f7b8a80a02f099052da9b4eb2e14d21 /engine/menu
parentb1cb3788938fa981e65619f022a41f1c1d91ae3b (diff)
parentbd7d9815936decc5b636f4235c0ee745812dcb48 (diff)
Merge pull request #101 from YamaArashi/master
Misc changes
Diffstat (limited to 'engine/menu')
-rw-r--r--engine/menu/bills_pc.asm319
-rwxr-xr-xengine/menu/league_pc.asm44
-rwxr-xr-xengine/menu/main_menu.asm42
-rwxr-xr-xengine/menu/party_menu.asm2
-rwxr-xr-xengine/menu/pc.asm2
-rwxr-xr-xengine/menu/players_pc.asm152
-rwxr-xr-xengine/menu/start_menu.asm2
-rwxr-xr-xengine/menu/start_sub_menus.asm113
-rwxr-xr-xengine/menu/status_screen.asm30
9 files changed, 359 insertions, 347 deletions
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index fcc51af1..e0b405e8 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -1,44 +1,44 @@
-Func_213c8:: ; 213c8 (8:53c8)
+DisplayPCMainMenu:: ; 213c8 (8:53c8)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
call SaveScreenTilesToBuffer2
- ld a, [wd5a2]
+ ld a, [wNumHoFTeams]
and a
- jr nz, .asm_213f3
+ jr nz, .leaguePCAvailable
ld a, [wd74b]
- bit 5, a
- jr z, .asm_213ea
- ld a, [wd5a2]
+ bit 5, a ; received pokedex?
+ jr z, .noOaksPC
+ ld a, [wNumHoFTeams]
and a
- jr nz, .asm_213f3
+ jr nz, .leaguePCAvailable
hlCoord 0, 0
- ld b, $8
- ld c, $e
- jr .asm_213fa
-.asm_213ea
+ ld b, 8
+ ld c, 14
+ jr .next
+.noOaksPC
hlCoord 0, 0
- ld b, $6
- ld c, $e
- jr .asm_213fa
-.asm_213f3
+ ld b, 6
+ ld c, 14
+ jr .next
+.leaguePCAvailable
hlCoord 0, 0
- ld b, $a
- ld c, $e
-.asm_213fa
+ ld b, 10
+ ld c, 14
+.next
call TextBoxBorder
call UpdateSprites
- ld a, $3
+ ld a, 3
ld [wMaxMenuItem], a
ld a, [wd7f1]
bit 0, a
- jr nz, .asm_21414
+ jr nz, .metBill
hlCoord 2, 2
ld de, SomeonesPCText
- jr .asm_2141a
-.asm_21414
+ jr .next2
+.metBill
hlCoord 2, 2
ld de, BillsPCText
-.asm_2141a
+.next2
call PlaceString
hlCoord 2, 4
ld de, wPlayerName
@@ -48,43 +48,43 @@ Func_213c8:: ; 213c8 (8:53c8)
ld de, PlayersPCText
call PlaceString
ld a, [wd74b]
- bit 5, a
- jr z, .asm_21462
+ bit 5, a ; received pokedex?
+ jr z, .noOaksPC2
hlCoord 2, 6
ld de, OaksPCText
call PlaceString
- ld a, [wd5a2]
+ ld a, [wNumHoFTeams]
and a
- jr z, .asm_2145a
- ld a, $4
+ jr z, .noLeaguePC
+ ld a, 4
ld [wMaxMenuItem], a
hlCoord 2, 8
ld de, PKMNLeaguePCText
call PlaceString
hlCoord 2, 10
ld de, LogOffPCText
- jr .asm_2146d
-.asm_2145a
+ jr .next3
+.noLeaguePC
hlCoord 2, 8
ld de, LogOffPCText
- jr .asm_2146d
-.asm_21462
+ jr .next3
+.noOaksPC2
ld a, $2
ld [wMaxMenuItem], a
hlCoord 2, 6
ld de, LogOffPCText
-.asm_2146d
+.next3
call PlaceString
- ld a, $3
+ ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
- ld a, $2
+ ld a, 2
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
xor a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
ret
@@ -99,23 +99,23 @@ BillsPC_:: ; 0x214c2
ld hl, wd730
set 6, [hl]
xor a
- ld [wccd3], a
+ ld [wParentMenuItem], a
inc a ; MONSTER_NAME
ld [wNameListType], a
call LoadHpBarAndStatusTilePatterns
ld a, [wListScrollOffset]
push af
ld a, [wFlags_0xcd60]
- bit 3, a
+ bit 3, a ; accessing Bill's PC through another PC?
jr nz, BillsPCMenu
+; accessing it directly
ld a, $99
call PlaySound
ld hl, SwitchOnText
call PrintText
-Func_214e8: ; 214e8 (8:54e8)
-BillsPCMenu:
- ld a, [wccd3]
+BillsPCMenu: ; 214e8 (8:54e8)
+ ld a, [wParentMenuItem]
ld [wCurrentMenuItem], a
ld hl, vChars2 + $780
ld de, PokeballTileGraphics
@@ -123,79 +123,81 @@ BillsPCMenu:
call CopyVideoData
call LoadScreenTilesFromBuffer2DisableBGTransfer
hlCoord 0, 0
- ld b, $a
- ld c, $c
+ ld b, 10
+ ld c, 12
call TextBoxBorder
hlCoord 2, 2
ld de, BillsPCMenuText
call PlaceString
ld hl, wTopMenuItemY
- ld a, $2
- ld [hli], a
+ ld a, 2
+ ld [hli], a ; wTopMenuItemY
dec a
- ld [hli], a
+ ld [hli], a ; wTopMenuItemX
inc hl
inc hl
- ld a, $4
- ld [hli], a
- ld a, $3
- ld [hli], a
+ ld a, 4
+ ld [hli], a ; wMaxMenuItem
+ ld a, A_BUTTON | B_BUTTON
+ ld [hli], a ; wMenuWatchedKeys
xor a
- ld [hli], a
- ld [hli], a
+ ld [hli], a ; wLastMenuItem
+ ld [hli], a ; wPartyAndBillsPCSavedMenuItem
ld hl, wListScrollOffset
- ld [hli], a
- ld [hl], a
+ ld [hli], a ; wListScrollOffset
+ ld [hl], a ; wMenuWatchMovingOutOfBounds
ld [wPlayerMonNumber], a
ld hl, WhatText
call PrintText
hlCoord 9, 14
- ld b, $2
- ld c, $9
+ ld b, 2
+ ld c, 9
call TextBoxBorder
- ld a, [wd5a0]
+ ld a, [wCurrentBoxNum]
and $7f
cp 9
- jr c, .asm_2154f
+ jr c, .singleDigitBoxNum
+; two digit box num
sub 9
hlCoord 17, 16
ld [hl], "1"
add "0"
- jr .asm_21551
-.asm_2154f
+ jr .next
+.singleDigitBoxNum
add "1"
-.asm_21551
+.next
Coorda 18, 16
hlCoord 10, 16
ld de, BoxNoPCText
call PlaceString
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
call HandleMenuInput
bit 1, a
- jp nz, Func_21588 ; b button
+ jp nz, ExitBillsPC ; b button
call PlaceUnfilledArrowMenuCursor
ld a, [wCurrentMenuItem]
- ld [wccd3], a
+ ld [wParentMenuItem], a
and a
- jp z, Func_21618 ; withdraw
+ jp z, BillsPCWithdraw ; withdraw
cp $1
- jp z, Func_215ac ; deposit
+ jp z, BillsPCDeposit ; deposit
cp $2
- jp z, Func_21673 ; release
+ jp z, BillsPCRelease ; release
cp $3
- jp z, Func_216b3 ; change box
+ jp z, BillsPCChangeBox ; change box
-Func_21588: ; 21588 (8:5588)
+ExitBillsPC: ; 21588 (8:5588)
ld a, [wFlags_0xcd60]
- bit 3, a
- jr nz, .asm_2159a
+ bit 3, a ; accessing Bill's PC through another PC?
+ jr nz, .next
+; accessing it directly
call LoadTextBoxTilePatterns
ld a, $9a
call PlaySound
call WaitForSoundToFinish
-.asm_2159a
+.next
ld hl, wFlags_0xcd60
res 5, [hl]
call LoadScreenTilesFromBuffer2
@@ -205,26 +207,25 @@ Func_21588: ; 21588 (8:5588)
res 6, [hl]
ret
-Func_215ac: ; 215ac (8:55ac)
-BillsPCDeposit:
+BillsPCDeposit: ; 215ac (8:55ac)
ld a, [wPartyCount]
dec a
- jr nz, .asm_215bb
+ jr nz, .partyLargeEnough
ld hl, CantDepositLastMonText
call PrintText
jp BillsPCMenu
-.asm_215bb
+.partyLargeEnough
ld a, [W_NUMINBOX]
cp MONS_PER_BOX
- jr nz, .asm_215cb
+ jr nz, .boxNotFull
ld hl, BoxFullText
call PrintText
jp BillsPCMenu
-.asm_215cb
+.boxNotFull
ld hl, wPartyCount
- call Func_216be
+ call DisplayMonListMenu
jp c, BillsPCMenu
- call Func_2174b
+ call DisplayDepositWithdrawMenu
jp nc, BillsPCMenu
ld a, [wcf91]
call GetCryData
@@ -236,45 +237,45 @@ BillsPCDeposit:
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
- ld hl, wWhichTrade
- ld a, [wd5a0]
+ ld hl, wBoxNumString
+ ld a, [wCurrentBoxNum]
and $7f
cp 9
- jr c, .asm_2160a
+ jr c, .singleDigitBoxNum
sub 9
ld [hl], "1"
inc hl
add "0"
- jr .asm_2160c
-.asm_2160a
+ jr .next
+.singleDigitBoxNum
add "1"
-.asm_2160c
+.next
ld [hli], a
ld [hl], $50
ld hl, MonWasStoredText
call PrintText
jp BillsPCMenu
-Func_21618: ; 21618 (8:5618)
+BillsPCWithdraw: ; 21618 (8:5618)
ld a, [W_NUMINBOX]
and a
- jr nz, .asm_21627
+ jr nz, .boxNotEmpty
ld hl, NoMonText
call PrintText
- jp Func_214e8
-.asm_21627
+ jp BillsPCMenu
+.boxNotEmpty
ld a, [wPartyCount]
cp PARTY_LENGTH
- jr nz, .asm_21637
+ jr nz, .partyNotFull
ld hl, CantTakeMonText
call PrintText
- jp Func_214e8
-.asm_21637
+ jp BillsPCMenu
+.partyNotFull
ld hl, W_NUMINBOX
- call Func_216be
- jp c, Func_214e8
- call Func_2174b
- jp nc, Func_214e8
+ call DisplayMonListMenu
+ jp c, BillsPCMenu
+ call DisplayDepositWithdrawMenu
+ jp nc, BillsPCMenu
ld a, [wWhichPokemon]
ld hl, wBoxMonNicks
call GetPartyMonName
@@ -290,25 +291,25 @@ Func_21618: ; 21618 (8:5618)
call WaitForSoundToFinish
ld hl, MonIsTakenOutText
call PrintText
- jp Func_214e8
+ jp BillsPCMenu
-Func_21673: ; 21673 (8:5673)
+BillsPCRelease: ; 21673 (8:5673)
ld a, [W_NUMINBOX]
and a
- jr nz, .asm_21682
+ jr nz, .loop
ld hl, NoMonText
call PrintText
- jp Func_214e8
-.asm_21682
+ jp BillsPCMenu
+.loop
ld hl, W_NUMINBOX
- call Func_216be
- jp c, Func_214e8
+ call DisplayMonListMenu
+ jp c, BillsPCMenu
ld hl, OnceReleasedText
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_21682
+ jr nz, .loop
inc a
ld [wRemoveMonFromBox], a
call RemovePokemon
@@ -317,27 +318,27 @@ Func_21673: ; 21673 (8:5673)
call PlayCry
ld hl, MonWasReleasedText
call PrintText
- jp Func_214e8
+ jp BillsPCMenu
-Func_216b3: ; 216b3 (8:56b3)
+BillsPCChangeBox: ; 216b3 (8:56b3)
callba ChangeBox
- jp Func_214e8
+ jp BillsPCMenu
-Func_216be: ; 216be (8:56be)
+DisplayMonListMenu: ; 216be (8:56be)
ld a, l
- ld [wList], a
+ ld [wListPointer], a
ld a, h
- ld [wList + 1], a
+ ld [wListPointer + 1], a
xor a
ld [wPrintItemPrices], a
ld [wListMenuID], a
inc a ; MONSTER_NAME
ld [wNameListType], a
- ld a, [wcc2b]
+ ld a, [wPartyAndBillsPCSavedMenuItem]
ld [wCurrentMenuItem], a
call DisplayListMenuID
ld a, [wCurrentMenuItem]
- ld [wcc2b], a
+ ld [wPartyAndBillsPCSavedMenuItem], a
ret
BillsPCMenuText: ; 216e1 (8:56e1)
@@ -354,17 +355,19 @@ ENDC
BoxNoPCText: ; 21713 (8:5713)
db "BOX No.@"
-Func_2171b:: ; 2171b (8:571b)
+KnowsHMMove:: ; 2171b (8:571b)
+; returns whether mon with party index [wWhichPokemon] knows an HM move
ld hl, wPartyMon1Moves
ld bc, wPartyMon2 - wPartyMon1
- jr .asm_21729
+ jr .next
+; unreachable
ld hl, wBoxMon1Moves
ld bc, wBoxMon2 - wBoxMon1
-.asm_21729
+.next
ld a, [wWhichPokemon]
call AddNTimes
ld b, NUM_MOVES
-.asm_21731
+.loop
ld a, [hli]
push hl
push bc
@@ -375,7 +378,7 @@ Func_2171b:: ; 2171b (8:571b)
pop hl
ret c
dec b
- jr nz, .asm_21731
+ jr nz, .loop
and a
ret
@@ -387,72 +390,72 @@ HMMoveArray: ; 21745 (8:5745)
db FLASH
db -1
-Func_2174b: ; 2174b (8:574b)
+DisplayDepositWithdrawMenu: ; 2174b (8:574b)
hlCoord 9, 10
- ld b, $6
- ld c, $9
+ ld b, 6
+ ld c, 9
call TextBoxBorder
- ld a, [wccd3]
- and a
+ ld a, [wParentMenuItem]
+ and a ; was the Deposit or Withdraw item selected in the parent menu?
ld de, DepositPCText
- jr nz, .asm_21761
+ jr nz, .next
ld de, WithdrawPCText
-.asm_21761
+.next
hlCoord 11, 12
call PlaceString
hlCoord 11, 14
ld de, StatsCancelPCText
call PlaceString
ld hl, wTopMenuItemY
- ld a, $c
- ld [hli], a
- ld a, $a
- ld [hli], a
+ ld a, 12
+ ld [hli], a ; wTopMenuItemY
+ ld a, 10
+ ld [hli], a ; wTopMenuItemX
xor a
- ld [hli], a
+ ld [hli], a ; wCurrentMenuItem
inc hl
- ld a, $2
- ld [hli], a
- ld a, $3
- ld [hli], a
+ ld a, 2
+ ld [hli], a ; wMaxMenuItem
+ ld a, A_BUTTON | B_BUTTON
+ ld [hli], a ; wMenuWatchedKeys
xor a
- ld [hl], a
+ ld [hl], a ; wLastMenuItem
ld hl, wListScrollOffset
- ld [hli], a
- ld [hl], a
+ ld [hli], a ; wListScrollOffset
+ ld [hl], a ; wMenuWatchMovingOutOfBounds
ld [wPlayerMonNumber], a
- ld [wcc2b], a
-.asm_2178f
+ ld [wPartyAndBillsPCSavedMenuItem], a
+.loop
call HandleMenuInput
- bit 1, a
- jr nz, .asm_2179f
+ bit 1, a ; pressed B?
+ jr nz, .exit
ld a, [wCurrentMenuItem]
and a
- jr z, .asm_217a1
+ jr z, .choseDepositWithdraw
dec a
- jr z, .asm_217a3
-.asm_2179f
+ jr z, .viewStats
+.exit
and a
ret
-.asm_217a1
+.choseDepositWithdraw
scf
ret
-.asm_217a3
+.viewStats
call SaveScreenTilesToBuffer1
- ld a, [wccd3]
+ ld a, [wParentMenuItem]
and a
- ld a, $0
- jr nz, .asm_217b0
- ld a, $2
-.asm_217b0
- ld [wcc49], a
+ ld a, PLAYER_PARTY_DATA
+ jr nz, .next2
+ ld a, BOX_DATA
+.next2
+ ld [wMonDataLocation], a
predef StatusScreen
predef StatusScreen2
call LoadScreenTilesFromBuffer1
call ReloadTilesetTilePatterns
call GoPAL_SET_CF1C
call LoadGBPal
- jr .asm_2178f
+ jr .loop
DepositPCText: db "DEPOSIT@"
WithdrawPCText: db "WITHDRAW@"
@@ -518,9 +521,9 @@ CableClubLeftGameboy:: ; 5824 (8:5825)
ld a, [W_CURMAP]
cp BATTLE_CENTER
ld a, LINK_STATE_START_TRADE
- jr z, .asm_2183a
+ jr z, .next
inc a ; LINK_STATE_START_BATTLE
-.asm_2183a
+.next
ld [wLinkState], a
call EnableAutoTextBoxDrawing
tx_pre_jump JustAMomentText
@@ -535,9 +538,9 @@ CableClubRightGameboy:: ; 5845 (8:5845)
ld a, [W_CURMAP]
cp BATTLE_CENTER
ld a, LINK_STATE_START_TRADE
- jr z, .asm_2185a
+ jr z, .next
inc a ; LINK_STATE_START_BATTLE
-.asm_2185a
+.next
ld [wLinkState], a
call EnableAutoTextBoxDrawing
tx_pre_jump JustAMomentText
diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm
index a6dd7021..c38ab86b 100755
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -13,30 +13,32 @@ PKMNLeaguePC: ; 0x7657e
ld [W_SPRITEFLIPPED], a
ld [wUpdateSpritesEnabled], a
ld [wTrainerScreenX], a
- ld [wcd42], a
- ld a, [wd5a2]
+ ld [wHoFTeamNo], a
+ ld a, [wNumHoFTeams]
ld b, a
- cp NUM_HOF_TEAMS + 1
- jr c, .first
- ld b, NUM_HOF_TEAMS
+ cp HOF_TEAM_CAPACITY + 1
+ jr c, .loop
+; If the total number of hall of fame teams is greater than the storage
+; capacity, then calculate the number of the first team that is still recorded.
+ ld b, HOF_TEAM_CAPACITY
sub b
- ld [wcd42], a
-.first
- ld hl, wcd42
+ ld [wHoFTeamNo], a
+.loop
+ ld hl, wHoFTeamNo
inc [hl]
push bc
ld a, [wTrainerScreenX]
- ld [wWhichTrade], a
+ ld [wHoFMonSpecies], a
callba LoadHallOfFameTeams
- call Func_765e5
+ call LeaguePCShowTeam
pop bc
- jr c, .second
+ jr c, .doneShowingTeams
ld hl, wTrainerScreenX
inc [hl]
ld a, [hl]
cp b
- jr nz, .first
-.second
+ jr nz, .loop
+.doneShowingTeams
pop af
ld [hTilesetType], a
pop af
@@ -48,11 +50,11 @@ PKMNLeaguePC: ; 0x7657e
call GoPAL_SET_CF1C
jp GBPalNormal
-Func_765e5: ; 765e5 (1d:65e5)
+LeaguePCShowTeam: ; 765e5 (1d:65e5)
ld c, PARTY_LENGTH
.loop
push bc
- call Func_76610
+ call LeaguePCShowMon
call WaitForTextScrollButtonPress
ld a, [hJoyHeld]
bit 1, a
@@ -75,18 +77,18 @@ Func_765e5: ; 765e5 (1d:65e5)
scf
ret
-Func_76610: ; 76610 (1d:6610)
+LeaguePCShowMon: ; 76610 (1d:6610)
call GBPalWhiteOutWithDelay3
call ClearScreen
ld hl, wHallOfFame
ld a, [hli]
- ld [wWhichTrade], a
+ ld [wHoFMonSpecies], a
ld [wcf91], a
ld [wd0b5], a
ld [wBattleMonSpecies2], a
ld [wcf1d], a
ld a, [hli]
- ld [wTrainerFacingDirection], a
+ ld [wHoFMonLevel], a
ld de, wcd6d
ld bc, $000B
call CopyData
@@ -105,11 +107,11 @@ Func_76610: ; 76610 (1d:6610)
ld de, HallOfFameNoText
call PlaceString
hlCoord 16, 15
- ld de, wcd42
+ ld de, wHoFTeamNo
ld bc, $0103
call PrintNumber
- ld b, BANK(Func_702f0)
- ld hl, Func_702f0
+ ld b, BANK(HoFDisplayMonInfo)
+ ld hl, HoFDisplayMonInfo
jp Bankswitch
HallOfFameNoText: ; 76670 (1d:6670)
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index 0856352c..14480b0a 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -16,7 +16,7 @@ MainMenu: ; 5af2 (1:5af2)
call DelayFrames
xor a ; LINK_STATE_NONE
ld [wLinkState],a
- ld hl,wcc2b
+ ld hl,wPartyAndBillsPCSavedMenuItem
ld [hli],a
ld [hli],a
ld [hli],a
@@ -109,7 +109,7 @@ MainMenu: ; 5af2 (1:5af2)
ld [wd52a],a
ld c,10
call DelayFrames
- ld a,[wd5a2]
+ ld a,[wNumHoFTeams]
and a
jp z,SpecialEnterMap
ld a,[W_CURMAP] ; map ID
@@ -124,14 +124,14 @@ MainMenu: ; 5af2 (1:5af2)
Func_5bff: ; 5bff (1:5bff)
ld a,1
- ld [wd358],a
+ ld [wLetterPrintingDelayFlags],a
ld a,3
ld [W_OPTIONS],a
ret
LinkMenu: ; 5c0a (1:5c0a)
xor a
- ld [wd358], a
+ ld [wLetterPrintingDelayFlags], a
ld hl, wd72e
set 6, [hl]
ld hl, TextTerminator_6b20
@@ -452,12 +452,12 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
inc a
- ld [wd358],a
+ ld [wLetterPrintingDelayFlags],a
ld [wTrainerScreenY],a
ld a,3 ; text speed cursor Y coordinate
ld [wTopMenuItemY],a
call SetCursorPositionsFromOptions
- ld a,[wWhichTrade] ; text speed cursor X coordinate
+ ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
ld [wTopMenuItemX],a
ld a,$01
ld [H_AUTOBGTRANSFERENABLED],a ; enable auto background transfer
@@ -507,7 +507,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
.downPressed
cp a,16
ld b,-13
- ld hl,wWhichTrade
+ ld hl,wOptionsTextSpeedCursorX
jr z,.updateMenuVariables
ld b,5
cp a,3
@@ -522,7 +522,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
.upPressed
cp a,8
ld b,-5
- ld hl,wWhichTrade
+ ld hl,wOptionsTextSpeedCursorX
jr z,.updateMenuVariables
cp a,13
inc hl
@@ -541,17 +541,17 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
call PlaceUnfilledArrowMenuCursor
jp .loop
.cursorInBattleAnimation
- ld a,[wTrainerEngageDistance] ; battle animation cursor X coordinate
+ ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate
xor a,$0b ; toggle between 1 and 10
- ld [wTrainerEngageDistance],a
+ ld [wOptionsBattleAnimCursorX],a
jp .eraseOldMenuCursor
.cursorInBattleStyle
- ld a,[wTrainerFacingDirection] ; battle style cursor X coordinate
+ ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate
xor a,$0b ; toggle between 1 and 10
- ld [wTrainerFacingDirection],a
+ ld [wOptionsBattleStyleCursorX],a
jp .eraseOldMenuCursor
.pressedLeftInTextSpeed
- ld a,[wWhichTrade] ; text speed cursor X coordinate
+ ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
cp a,1
jr z,.updateTextSpeedXCoord
cp a,7
@@ -562,7 +562,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
sub a,7
jr .updateTextSpeedXCoord
.pressedRightInTextSpeed
- ld a,[wWhichTrade] ; text speed cursor X coordinate
+ ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
cp a,14
jr z,.updateTextSpeedXCoord
cp a,7
@@ -572,7 +572,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
.fromFastToMedium
add a,6
.updateTextSpeedXCoord
- ld [wWhichTrade],a ; text speed cursor X coordinate
+ ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate
jp .eraseOldMenuCursor
TextSpeedOptionText: ; 5fc0 (1:5fc0)
@@ -593,7 +593,7 @@ OptionMenuCancelText: ; 6018 (1:6018)
; sets the options variable according to the current placement of the menu cursors in the options menu
SetOptionsFromCursorPositions: ; 601f (1:601f)
ld hl,TextSpeedOptionData
- ld a,[wWhichTrade] ; text speed cursor X coordinate
+ ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
ld c,a
.loop
ld a,[hli]
@@ -604,7 +604,7 @@ SetOptionsFromCursorPositions: ; 601f (1:601f)
.textSpeedMatchFound
ld a,[hl]
ld d,a
- ld a,[wTrainerEngageDistance] ; battle animation cursor X coordinate
+ ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate
dec a
jr z,.battleAnimationOn
.battleAnimationOff
@@ -613,7 +613,7 @@ SetOptionsFromCursorPositions: ; 601f (1:601f)
.battleAnimationOn
res 7,d
.checkBattleStyle
- ld a,[wTrainerFacingDirection] ; battle style cursor X coordinate
+ ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate
dec a
jr z,.battleStyleShift
.battleStyleSet
@@ -638,7 +638,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c)
pop bc
dec hl
ld a,[hl]
- ld [wWhichTrade],a ; text speed cursor X coordinate
+ ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate
hlCoord 0, 3
call .placeUnfilledRightArrow
sla c
@@ -646,7 +646,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c)
jr nc,.storeBattleAnimationCursorX
ld a,10 ; Off
.storeBattleAnimationCursorX
- ld [wTrainerEngageDistance],a ; battle animation cursor X coordinate
+ ld [wOptionsBattleAnimCursorX],a ; battle animation cursor X coordinate
hlCoord 0, 8
call .placeUnfilledRightArrow
sla c
@@ -654,7 +654,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c)
jr nc,.storeBattleStyleCursorX
ld a,10
.storeBattleStyleCursorX
- ld [wTrainerFacingDirection],a ; battle style cursor X coordinate
+ ld [wOptionsBattleStyleCursorX],a ; battle style cursor X coordinate
hlCoord 0, 13
call .placeUnfilledRightArrow
; cursor in front of Cancel
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index edd65a81..fcdd5c50 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -227,7 +227,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld h,[hl]
ld l,a
push hl
- ld a,[wcf06]
+ ld a,[wUsedItemOnWhichPokemon]
ld hl,wPartyMonNicks
call GetPartyMonName
pop hl
diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm
index 2b8b9e92..8ee40c7c 100755
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -10,7 +10,7 @@ ActivatePC: ; 17e2c (5:7e2c)
call LoadScreenTilesFromBuffer2
call Delay3
PCMainMenu: ; 17e48 (5:7e48)
- callba Func_213c8
+ callba DisplayPCMainMenu
ld hl, wFlags_0xcd60
set 5, [hl]
call HandleMenuInput
diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm
index 8b433027..f436ae24 100755
--- a/engine/menu/players_pc.asm
+++ b/engine/menu/players_pc.asm
@@ -5,18 +5,19 @@ PlayerPC: ; 78e6 (1:78e6)
ld [wNameListType], a
call SaveScreenTilesToBuffer1
xor a
- ld [wcc2c], a
- ld [wccd3], a
+ ld [wBagSavedMenuItem], a
+ ld [wParentMenuItem], a
ld a, [wFlags_0xcd60]
- bit 3, a
- jr nz, Func_790c
+ bit 3, a ; accessing player's PC through another PC?
+ jr nz, PlayerPCMenu
+; accessing it directly
ld a, (SFX_02_45 - SFX_Headers_02) / 3
call PlaySound
ld hl, TurnedOnPC2Text
call PrintText
-Func_790c: ; 790c (1:790c)
- ld a, [wccd3]
+PlayerPCMenu: ; 790c (1:790c)
+ ld a, [wParentMenuItem]
ld [wCurrentMenuItem], a
ld hl, wFlags_0xcd60
set 5, [hl]
@@ -30,101 +31,102 @@ Func_790c: ; 790c (1:790c)
ld de, PlayersPCMenuEntries
call PlaceString
ld hl, wTopMenuItemY
- ld a, $2
- ld [hli], a
+ ld a, 2
+ ld [hli], a ; wTopMenuItemY
dec a
- ld [hli], a
+ ld [hli], a ; wTopMenuItemX
inc hl
inc hl
- ld a, $3
- ld [hli], a
- ld a, $3
- ld [hli], a
+ ld a, 3
+ ld [hli], a ; wMaxMenuItem
+ ld a, A_BUTTON | B_BUTTON
+ ld [hli], a ; wMenuWatchedKeys
xor a
ld [hl], a
ld hl, wListScrollOffset
- ld [hli], a
- ld [hl], a
+ ld [hli], a ; wListScrollOffset
+ ld [hl], a ; wMenuWatchMovingOutOfBounds
ld [wPlayerMonNumber], a
ld hl, WhatDoYouWantText
call PrintText
call HandleMenuInput
bit 1, a
- jp nz, Func_796d
+ jp nz, ExitPlayerPC
call PlaceUnfilledArrowMenuCursor
ld a, [wCurrentMenuItem]
- ld [wccd3], a
+ ld [wParentMenuItem], a
and a
- jp z, Func_7a12
+ jp z, PlayerPCWithdraw
dec a
- jp z, Func_7995
+ jp z, PlayerPCDeposit
dec a
- jp z, Func_7a8f
+ jp z, PlayerPCToss
-Func_796d: ; 796d (1:796d)
+ExitPlayerPC: ; 796d (1:796d)
ld a, [wFlags_0xcd60]
- bit 3, a
- jr nz, .asm_797c
+ bit 3, a ; accessing player's PC through another PC?
+ jr nz, .next
+; accessing it directly
ld a, (SFX_02_46 - SFX_Headers_02) / 3
call PlaySound
call WaitForSoundToFinish
-.asm_797c
+.next
ld hl, wFlags_0xcd60
res 5, [hl]
call LoadScreenTilesFromBuffer2
xor a
ld [wListScrollOffset], a
- ld [wcc2c], a
+ ld [wBagSavedMenuItem], a
ld hl, wd730
res 6, [hl]
xor a
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
-Func_7995: ; 7995 (1:7995)
+PlayerPCDeposit: ; 7995 (1:7995)
xor a
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld a, [wNumBagItems]
and a
- jr nz, Func_79ab
+ jr nz, .loop
ld hl, NothingToDepositText
call PrintText
- jp Func_790c
-
-Func_79ab: ; 79ab (1:79ab)
+ jp PlayerPCMenu
+.loop
ld hl, WhatToDepositText
call PrintText
ld hl, wNumBagItems
ld a, l
- ld [wList], a
+ ld [wListPointer], a
ld a, h
- ld [wList + 1], a
+ ld [wListPointer + 1], a
xor a
ld [wPrintItemPrices], a
- ld a, $3
+ ld a, ITEMLISTMENU
ld [wListMenuID], a
call DisplayListMenuID
- jp c, Func_790c
+ jp c, PlayerPCMenu
call IsKeyItem
- ld a, $1
+ ld a, 1
ld [wItemQuantity], a
ld a, [wIsKeyItem]
and a
- jr nz, .asm_79e7
+ jr nz, .next
+; if it's not a key item, there can be more than one of the item
ld hl, DepositHowManyText
call PrintText
call DisplayChooseQuantityMenu
cp $ff
- jp z, Func_79ab
-.asm_79e7
+ jp z, .loop
+.next
ld hl, wNumBoxItems
call AddItemToInventory
- jr c, .asm_79f8
+ jr c, .roomAvailable
ld hl, NoRoomToStoreText
call PrintText
- jp Func_79ab
-.asm_79f8
+ jp .loop
+.roomAvailable
ld hl, wNumBagItems
call RemoveItemFromInventory
call WaitForSoundToFinish
@@ -133,52 +135,52 @@ Func_79ab: ; 79ab (1:79ab)
call WaitForSoundToFinish
ld hl, ItemWasStoredText
call PrintText
- jp Func_79ab
+ jp .loop
-Func_7a12: ; 7a12 (1:7a12)
+PlayerPCWithdraw: ; 7a12 (1:7a12)
xor a
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld a, [wNumBoxItems]
and a
- jr nz, Func_7a28
+ jr nz, .loop
ld hl, NothingStoredText
call PrintText
- jp Func_790c
-
-Func_7a28: ; 7a28 (1:7a28)
+ jp PlayerPCMenu
+.loop
ld hl, WhatToWithdrawText
call PrintText
ld hl, wNumBoxItems
ld a, l
- ld [wList], a
+ ld [wListPointer], a
ld a, h
- ld [wList + 1], a
+ ld [wListPointer + 1], a
xor a
ld [wPrintItemPrices], a
- ld a, $3
+ ld a, ITEMLISTMENU
ld [wListMenuID], a
call DisplayListMenuID
- jp c, Func_790c
+ jp c, PlayerPCMenu
call IsKeyItem
- ld a, $1
+ ld a, 1
ld [wItemQuantity], a
ld a, [wIsKeyItem]
and a
- jr nz, .asm_7a64
+ jr nz, .next
+; if it's not a key item, there can be more than one of the item
ld hl, WithdrawHowManyText
call PrintText
call DisplayChooseQuantityMenu
cp $ff
- jp z, Func_7a28
-.asm_7a64
+ jp z, .loop
+.next
ld hl, wNumBagItems
call AddItemToInventory
- jr c, .asm_7a75
+ jr c, .roomAvailable
ld hl, CantCarryMoreText
call PrintText
- jp Func_7a28
-.asm_7a75
+ jp .loop
+.roomAvailable
ld hl, wNumBoxItems
call RemoveItemFromInventory
call WaitForSoundToFinish
@@ -187,56 +189,56 @@ Func_7a28: ; 7a28 (1:7a28)
call WaitForSoundToFinish
ld hl, WithdrewItemText
call PrintText
- jp Func_7a28
+ jp .loop
-Func_7a8f: ; 7a8f (1:7a8f)
+PlayerPCToss: ; 7a8f (1:7a8f)
xor a
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld a, [wNumBoxItems]
and a
- jr nz, Func_7aa5
+ jr nz, .loop
ld hl, NothingStoredText
call PrintText
- jp Func_790c
-
-Func_7aa5: ; 7aa5 (1:7aa5)
+ jp PlayerPCMenu
+.loop
ld hl, WhatToTossText
call PrintText
ld hl, wNumBoxItems
ld a, l
- ld [wList], a
+ ld [wListPointer], a
ld a, h
- ld [wList + 1], a
+ ld [wListPointer + 1], a
xor a
ld [wPrintItemPrices], a
- ld a, $3
+ ld a, ITEMLISTMENU
ld [wListMenuID], a
push hl
call DisplayListMenuID
pop hl
- jp c, Func_790c
+ jp c, PlayerPCMenu
push hl
call IsKeyItem
pop hl
- ld a, $1
+ ld a, 1
ld [wItemQuantity], a
ld a, [wIsKeyItem]
and a
- jr nz, .asm_7aef
+ jr nz, .next
ld a, [wcf91]
call IsItemHM
- jr c, .asm_7aef
+ jr c, .next
+; if it's not a key item, there can be more than one of the item
push hl
ld hl, TossHowManyText
call PrintText
call DisplayChooseQuantityMenu
pop hl
cp $ff
- jp z, Func_7aa5
-.asm_7aef
- call TossItem
- jp Func_7aa5
+ jp z, .loop
+.next
+ call TossItem ; disallows tossing key items
+ jp .loop
PlayersPCMenuEntries: ; 7af5 (1:7af5)
db "WITHDRAW ITEM"
diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm
index 0db0d052..7aa09df7 100755
--- a/engine/menu/start_menu.asm
+++ b/engine/menu/start_menu.asm
@@ -54,7 +54,7 @@ RedisplayStartMenu:: ; 2adf (0:2adf)
.buttonPressed ; A, B, or Start button pressed
call PlaceUnfilledArrowMenuCursor
ld a,[wCurrentMenuItem]
- ld [wcc2d],a ; save current menu item ID
+ ld [wBattleAndStartSavedMenuItem],a ; save current menu selection
ld a,b
and a,%00001010 ; was the Start button or B button pressed?
jp nz,CloseStartMenu
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index 825360a6..11b7fa90 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -33,14 +33,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld a,FIELD_MOVE_MON_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; display pokemon menu options
- ld hl,wWhichTrade
+ ld hl,wFieldMoves
ld bc,$020c ; max menu item ID, top menu item Y
ld e,5
.adjustMenuVariablesLoop
dec e
jr z,.storeMenuVariables
ld a,[hli]
- and a
+ and a ; end of field moves?
jr z,.storeMenuVariables
inc b
dec c
@@ -50,7 +50,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld hl,wTopMenuItemY
ld a,c
ld [hli],a ; top menu item Y
- ld a,[$fff7]
+ ld a,[hFieldMoveMonMenuTopMenuItemX]
ld [hli],a ; top menu item X
xor a
ld [hli],a ; current menu item ID
@@ -81,22 +81,22 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
jp z,.choseStats
ld c,a
ld b,0
- ld hl,wWhichTrade
+ ld hl,wFieldMoves
add hl,bc
jp .choseOutOfBattleMove
.choseSwitch
ld a,[wPartyCount]
cp a,2 ; is there more than one pokemon in the party?
jp c,StartMenu_Pokemon ; if not, no switching
- call SwitchPartyMon_Stats
+ call SwitchPartyMon_InitVarOrSwapData ; init [wMenuItemToSwap]
ld a,SWAP_MONS_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
call GoBackToPartyMenu
jp .checkIfPokemonChosen
.choseStats
call ClearSprites
- xor a
- ld [wcc49],a
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation],a
predef StatusScreen
predef StatusScreen2
call ReloadMapData
@@ -153,7 +153,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
bit 1,a ; does the player have the Cascade Badge?
jp z,.newBadgeRequired
predef UsedCut
- ld a,[wcd6a]
+ ld a,[wActionResultOrTookBattleTurn]
and a
jp z,.loop
jp CloseTextDisplay
@@ -169,7 +169,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld [wcf91],a
ld [wd152],a
call UseItem
- ld a,[wcd6a]
+ ld a,[wActionResultOrTookBattleTurn]
and a
jp z,.loop
call GBPalWhiteOutWithDelay3
@@ -197,7 +197,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld [wcf91],a
ld [wd152],a
call UseItem
- ld a,[wcd6a]
+ ld a,[wActionResultOrTookBattleTurn]
and a
jp z,.loop
call GBPalWhiteOutWithDelay3
@@ -256,14 +256,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld a,[H_QUOTIENT + 2]
sbc b
jp nc,.notHealthyEnough
- ld a,[wcc2b]
+ ld a,[wPartyAndBillsPCSavedMenuItem]
push af
ld a,POTION
ld [wcf91],a
ld [wd152],a
call UseItem
pop af
- ld [wcc2b],a
+ ld [wPartyAndBillsPCSavedMenuItem],a
jp .loop
.notHealthyEnough ; if current HP is less than 1/5 of max HP
ld hl,.notHealthyEnoughText
@@ -308,19 +308,19 @@ StartMenu_Item: ; 13302 (4:7302)
jr .exitMenu
.notInCableClubRoom
ld bc,wNumBagItems
- ld hl,wList
+ ld hl,wListPointer
ld a,c
ld [hli],a
- ld [hl],b ; store item bag pointer at wList (for DisplayListMenuID)
+ ld [hl],b ; store item bag pointer in wListPointer (for DisplayListMenuID)
xor a
ld [wPrintItemPrices],a
ld a,ITEMLISTMENU
ld [wListMenuID],a
- ld a,[wcc2c]
+ ld a,[wBagSavedMenuItem]
ld [wCurrentMenuItem],a
call DisplayListMenuID
ld a,[wCurrentMenuItem]
- ld [wcc2c],a
+ ld [wBagSavedMenuItem],a
jr nc,.choseItem
.exitMenu
call LoadScreenTilesFromBuffer2 ; restore saved screen
@@ -401,7 +401,7 @@ StartMenu_Item: ; 13302 (4:7302)
xor a
ld [wd152],a
call UseItem
- ld a,[wcd6a]
+ ld a,[wActionResultOrTookBattleTurn]
and a
jp z,ItemMenuLoop
jp CloseStartMenu
@@ -409,7 +409,7 @@ StartMenu_Item: ; 13302 (4:7302)
ld a,[wUpdateSpritesEnabled]
push af
call UseItem
- ld a,[wcd6a]
+ ld a,[wActionResultOrTookBattleTurn]
cp a,$02
jp z,.partyMenuNotDisplayed
call GBPalWhiteOutWithDelay3
@@ -566,7 +566,7 @@ DrawTrainerInfo: ; 1349a (4:749a)
ld de,vChars1 + $570
call TrainerInfo_FarCopyData
call EnableLCD
- ld hl,wWhichTrade
+ ld hl,wTrainerInfoTextBoxWidthPlus1
ld a,18 + 1
ld [hli],a
dec a
@@ -574,7 +574,7 @@ DrawTrainerInfo: ; 1349a (4:749a)
ld [hl],1
hlCoord 0, 0
call TrainerInfo_DrawTextBox
- ld hl,wWhichTrade
+ ld hl,wTrainerInfoTextBoxWidthPlus1
ld a,16 + 1
ld [hli],a
dec a
@@ -627,15 +627,15 @@ TrainerInfo_BadgesText: ; 13597 (4:7597)
; height is always 6
; INPUT:
; hl = destination address
-; [wWhichTrade] = width + 1
-; [wTrainerEngageDistance] = width
-; [wTrainerFacingDirection] = distance from the end of a text box row to the start of the next
+; [wTrainerInfoTextBoxWidthPlus1] = width
+; [wTrainerInfoTextBoxWidth] = width - 1
+; [wTrainerInfoTextBoxNextRowOffset] = distance from the end of a text box row to the start of the next
TrainerInfo_DrawTextBox: ; 135a0 (4:75a0)
ld a,$79 ; upper left corner tile ID
ld de,$7a7b ; top edge and upper right corner tile ID's
call TrainerInfo_DrawHorizontalEdge ; draw top edge
call TrainerInfo_NextTextBoxRow
- ld a,[wWhichTrade] ; width of the text box plus one
+ ld a,[wTrainerInfoTextBoxWidthPlus1]
ld e,a
ld d,0
ld c,6 ; height of the text box
@@ -651,7 +651,7 @@ TrainerInfo_DrawTextBox: ; 135a0 (4:75a0)
TrainerInfo_DrawHorizontalEdge: ; 135c3 (4:75c3)
ld [hli],a ; place left corner tile
- ld a,[wTrainerEngageDistance] ; width of the text box
+ ld a,[wTrainerInfoTextBoxWidth]
ld c,a
ld a,d
.loop
@@ -663,7 +663,7 @@ TrainerInfo_DrawHorizontalEdge: ; 135c3 (4:75c3)
ret
TrainerInfo_NextTextBoxRow: ; 135d0 (4:75d0)
- ld a,[wTrainerFacingDirection] ; distance to the start of the next row
+ ld a,[wTrainerInfoTextBoxNextRowOffset] ; distance to the start of the next row
.loop
inc hl
dec a
@@ -704,62 +704,65 @@ StartMenu_Option: ; 135f6 (4:75f6)
jp RedisplayStartMenu
SwitchPartyMon: ; 13613 (4:7613)
- call SwitchPartyMon_Stats
- ld a, [wWhichTrade]
- call SwitchPartyMon_OAM
+ call SwitchPartyMon_InitVarOrSwapData ; swap data
+ ld a, [wSwappedMenuItem]
+ call SwitchPartyMon_ClearGfx
ld a, [wCurrentMenuItem]
- call SwitchPartyMon_OAM
+ call SwitchPartyMon_ClearGfx
jp RedrawPartyMenu_
-SwitchPartyMon_OAM: ; 13625 (4:7625)
+SwitchPartyMon_ClearGfx: ; 13625 (4:7625)
push af
hlCoord 0, 0
ld bc, SCREEN_WIDTH * 2
call AddNTimes
ld c, SCREEN_WIDTH * 2
ld a, " "
-.asm_13633
+.clearMonBGLoop ; clear the mon's row in the party menu
ld [hli], a
dec c
- jr nz, .asm_13633
+ jr nz, .clearMonBGLoop
pop af
ld hl, wOAMBuffer
ld bc, $10
call AddNTimes
ld de, $4
ld c, e
-.asm_13645
+.clearMonOAMLoop
ld [hl], $a0
add hl, de
dec c
- jr nz, .asm_13645
+ jr nz, .clearMonOAMLoop
call WaitForSoundToFinish
ld a, (SFX_02_58 - SFX_Headers_02) / 3
jp PlaySound
-SwitchPartyMon_Stats: ; 13653 (4:7653)
+SwitchPartyMon_InitVarOrSwapData: ; 13653 (4:7653)
+; This is used to initialise [wMenuItemToSwap] and to actually swap the data.
ld a, [wMenuItemToSwap]
- and a
- jr nz, .asm_13661
+ and a ; has [wMenuItemToSwap] been initialised yet?
+ jr nz, .pickedMonsToSwap
+; If not, initialise [wMenuItemToSwap] so that it matches the current mon.
ld a, [wWhichPokemon]
- inc a
+ inc a ; [wMenuItemToSwap] counts from 1
ld [wMenuItemToSwap], a
ret
-.asm_13661
+.pickedMonsToSwap
xor a
ld [wPartyMenuTypeOrMessageID], a
ld a, [wMenuItemToSwap]
dec a
ld b, a
ld a, [wCurrentMenuItem]
- ld [wWhichTrade], a
- cp b
- jr nz, .asm_1367b
+ ld [wSwappedMenuItem], a
+ cp b ; swapping a mon with itself?
+ jr nz, .swappingDifferentMons
+; can't swap a mon with itself
xor a
ld [wMenuItemToSwap], a
ld [wPartyMenuTypeOrMessageID], a
ret
-.asm_1367b
+.swappingDifferentMons
ld a, b
ld [wMenuItemToSwap], a
push hl
@@ -770,20 +773,20 @@ SwitchPartyMon_Stats: ; 13653 (4:7653)
ld a, [wCurrentMenuItem]
add l
ld l, a
- jr nc, .asm_1368e
+ jr nc, .noCarry
inc h
-.asm_1368e
+.noCarry
ld a, [wMenuItemToSwap]
add e
ld e, a
- jr nc, .asm_13696
+ jr nc, .noCarry2
inc d
-.asm_13696
+.noCarry2
ld a, [hl]
- ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+ ld [hSwapTemp], a
ld a, [de]
ld [hl], a
- ld a, [H_DIVIDEND] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+ ld a, [hSwapTemp]
ld [de], a
ld hl, wPartyMons
ld bc, wPartyMon2 - wPartyMon1
@@ -791,19 +794,19 @@ SwitchPartyMon_Stats: ; 13653 (4:7653)
call AddNTimes
push hl
ld de, wSwitchPartyMonTempBuffer
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
call CopyData
ld hl, wPartyMons
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
ld a, [wMenuItemToSwap]
call AddNTimes
pop de
push hl
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
call CopyData
pop de
ld hl, wSwitchPartyMonTempBuffer
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
call CopyData
ld hl, wPartyMonOT
ld a, [wCurrentMenuItem]
@@ -842,7 +845,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653)
ld bc, $b
call CopyData
ld a, [wMenuItemToSwap]
- ld [wWhichTrade], a
+ ld [wSwappedMenuItem], a
xor a
ld [wMenuItemToSwap], a
ld [wPartyMenuTypeOrMessageID], a
diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm
index 7b3674e6..3f73a84f 100755
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -65,9 +65,10 @@ DrawHP_: ; 128fb (4:68fb)
; Predef 0x37
StatusScreen: ; 12953 (4:6953)
call LoadMonData
- ld a, [wcc49]
- cp $2 ; 2 means we're in a PC box
+ ld a, [wMonDataLocation]
+ cp BOX_DATA
jr c, .DontRecalculate
+; mon is in a box or daycare
ld a, [wLoadedMonBoxLevel]
ld [wLoadedMonLevel], a
ld [W_CURENEMYLVL], a
@@ -148,13 +149,13 @@ StatusScreen: ; 12953 (4:6953)
hlCoord 11, 10
predef PrintMonType
ld hl, NamePointers2
- call .asm_12a7e
+ call .GetStringPointer
ld d, h
ld e, l
hlCoord 9, 1
call PlaceString ; Pokémon name
ld hl, OTPointers
- call .asm_12a7e
+ call .GetStringPointer
ld d, h
ld e, l
hlCoord 12, 16
@@ -175,17 +176,18 @@ StatusScreen: ; 12953 (4:6953)
pop af
ld [hTilesetType], a
ret
-.asm_12a7e ; I don't know what this does, iterates over pointers?
- ld a, [wcc49]
+
+.GetStringPointer
+ ld a, [wMonDataLocation]
add a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wcc49]
- cp $3
+ ld a, [wMonDataLocation]
+ cp DAYCARE_DATA
ret z
ld a, [wWhichPokemon]
jp SkipFixedLengthTextEntries
@@ -316,7 +318,7 @@ StatusScreen2: ; 12b57 (4:6b57)
hlCoord 2, 9
ld de, wMovesString
call PlaceString ; Print moves
- ld a, [wcd6c]
+ ld a, [wNumMovesMinusOne]
inc a
ld c, a
ld a, $4
@@ -335,7 +337,7 @@ StatusScreen2: ; 12b57 (4:6b57)
.InitPP ; 12bbb
ld hl, wLoadedMonMoves
deCoord 14, 10
- ld b, $0
+ ld b, 0
.PrintPP ; 12bc3
ld a, [hli]
and a
@@ -356,15 +358,15 @@ StatusScreen2: ; 12b57 (4:6b57)
pop de
pop hl
push hl
- ld bc, $0014
+ ld bc, wPartyMon1PP - wPartyMon1Moves - 1
add hl, bc
ld a, [hl]
and $3f
- ld [wcd71], a
+ ld [wStatusScreenCurrentPP], a
ld h, d
ld l, e
push hl
- ld de, wcd71
+ ld de, wStatusScreenCurrentPP
ld bc, $0102
call PrintNumber
ld a, "/"