summaryrefslogtreecommitdiff
path: root/engine/menu
diff options
context:
space:
mode:
Diffstat (limited to 'engine/menu')
-rw-r--r--engine/menu/bills_pc.asm403
-rwxr-xr-xengine/menu/diploma.asm56
-rwxr-xr-xengine/menu/league_pc.asm70
-rwxr-xr-xengine/menu/main_menu.asm298
-rwxr-xr-xengine/menu/naming_screen.asm383
-rwxr-xr-xengine/menu/oaks_pc.asm2
-rwxr-xr-xengine/menu/party_menu.asm48
-rwxr-xr-xengine/menu/pc.asm67
-rwxr-xr-xengine/menu/players_pc.asm182
-rwxr-xr-xengine/menu/pokedex.asm171
-rwxr-xr-xengine/menu/prize_menu.asm130
-rwxr-xr-xengine/menu/start_menu.asm4
-rwxr-xr-xengine/menu/start_sub_menus.asm255
-rwxr-xr-xengine/menu/status_screen.asm247
-rwxr-xr-xengine/menu/vending_machine.asm63
15 files changed, 1206 insertions, 1173 deletions
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index 70b5bc33..87595a09 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -1,90 +1,87 @@
-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
- ld a, [wd74b]
- bit 5, a
- jr z, .asm_213ea
- ld a, [wd5a2]
+ jr nz, .leaguePCAvailable
+ CheckEvent EVENT_GOT_POKEDEX
+ jr z, .noOaksPC
+ ld a, [wNumHoFTeams]
and a
- jr nz, .asm_213f3
- ld hl, wTileMap
- ld b, $8
- ld c, $e
- jr .asm_213fa
-.asm_213ea
- ld hl, wTileMap
- ld b, $6
- ld c, $e
- jr .asm_213fa
-.asm_213f3
- ld hl, wTileMap
- ld b, $a
- ld c, $e
-.asm_213fa
+ jr nz, .leaguePCAvailable
+ coord hl, 0, 0
+ ld b, 8
+ ld c, 14
+ jr .next
+.noOaksPC
+ coord hl, 0, 0
+ ld b, 6
+ ld c, 14
+ jr .next
+.leaguePCAvailable
+ coord hl, 0, 0
+ 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
- hlCoord 2, 2
+ CheckEvent EVENT_MET_BILL
+ jr nz, .metBill
+ coord hl, 2, 2
ld de, SomeonesPCText
- jr .asm_2141a
-.asm_21414
- hlCoord 2, 2
+ jr .next2
+.metBill
+ coord hl, 2, 2
ld de, BillsPCText
-.asm_2141a
+.next2
call PlaceString
- hlCoord 2, 4
+ coord hl, 2, 4
ld de, wPlayerName
call PlaceString
ld l, c
ld h, b
ld de, PlayersPCText
call PlaceString
- ld a, [wd74b]
- bit 5, a
- jr z, .asm_21462
- hlCoord 2, 6
+ CheckEvent EVENT_GOT_POKEDEX
+ jr z, .noOaksPC2
+ coord hl, 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
+ coord hl, 2, 8
ld de, PKMNLeaguePCText
call PlaceString
- hlCoord 2, 10
+ coord hl, 2, 10
ld de, LogOffPCText
- jr .asm_2146d
-.asm_2145a
- hlCoord 2, 8
+ jr .next3
+.noLeaguePC
+ coord hl, 2, 8
ld de, LogOffPCText
- jr .asm_2146d
-.asm_21462
+ jr .next3
+.noOaksPC2
ld a, $2
ld [wMaxMenuItem], a
- hlCoord 2, 6
+ coord hl, 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,103 +96,105 @@ 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
- ld bc, (BANK(PokeballTileGraphics) << 8) + $01
+ lb bc, BANK(PokeballTileGraphics), $01
call CopyVideoData
call LoadScreenTilesFromBuffer2DisableBGTransfer
- ld hl, wTileMap
- ld b, $a
- ld c, $c
+ coord hl, 0, 0
+ ld b, 10
+ ld c, 12
call TextBoxBorder
- hlCoord 2, 2
+ coord hl, 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
+ coord hl, 9, 14
+ 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
+ coord hl, 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
+ coord hl, 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,139 +204,138 @@ 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
call PlaySoundWaitForCurrent
- ld a, $1
- ld [wcf95], a
- call Func_3a68
+ ld a, PARTY_TO_BOX
+ ld [wMoveMonType], a
+ call MoveMon
xor a
- ld [wcf95], a
+ 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
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
- xor a
- ld [wcf95], a
- call Func_3a68
- ld a, $1
- ld [wcf95], a
+ xor a ; BOX_TO_PARTY
+ ld [wMoveMonType], a
+ call MoveMon
+ ld a, 1
+ ld [wRemoveMonFromBox], a
call RemovePokemon
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 [wcf95], a
+ ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld a, [wcf91]
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 [wcf93], 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)
@@ -352,17 +350,19 @@ BillsPCMenuText: ; 216e1 (8:56e1)
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 ; 0x21721 $6
+ 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
@@ -373,7 +373,7 @@ Func_2171b:: ; 2171b (8:571b)
pop hl
ret c
dec b
- jr nz, .asm_21731 ; 0x21741 $ee
+ jr nz, .loop
and a
ret
@@ -385,72 +385,72 @@ HMMoveArray: ; 21745 (8:5745)
db FLASH
db -1
-Func_2174b: ; 2174b (8:574b)
- hlCoord 9, 10
- ld b, $6
- ld c, $9
+DisplayDepositWithdrawMenu: ; 2174b (8:574b)
+ coord hl, 9, 10
+ 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
- hlCoord 11, 12
+.next
+ coord hl, 11, 12
call PlaceString
- hlCoord 11, 14
+ coord hl, 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 RunDefaultPaletteCommand
call LoadGBPal
- jr .asm_2178f
+ jr .loop
DepositPCText: db "DEPOSIT@"
WithdrawPCText: db "WITHDRAW@"
@@ -514,15 +514,14 @@ CableClubLeftGameboy:: ; 5824 (8:5825)
cp SPRITE_FACING_RIGHT
ret nz
ld a, [W_CURMAP]
- cp BATTLE_CENTER
+ cp TRADE_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
- ld a, $22 ; JustAMomentText
- jp PrintPredefTextID
+ tx_pre_jump JustAMomentText
CableClubRightGameboy:: ; 5845 (8:5845)
ld a, [hSerialConnectionStatus]
@@ -532,15 +531,14 @@ CableClubRightGameboy:: ; 5845 (8:5845)
cp SPRITE_FACING_LEFT
ret nz
ld a, [W_CURMAP]
- cp BATTLE_CENTER
+ cp TRADE_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
- ld a, $22 ; JustAMomentText
- jp PrintPredefTextID
+ tx_pre_jump JustAMomentText
JustAMomentText:: ; 21865 (8:5865)
TX_FAR _JustAMomentText
@@ -550,9 +548,8 @@ JustAMomentText:: ; 21865 (8:5865)
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
- ld a, $23
- jp PrintPredefTextID
+ tx_pre_jump OpenBillsPCText
-PredefText23:: ; 21878 (8:5878)
+OpenBillsPCText:: ; 21878 (8:5878)
db $FD ; FuncTX_BillsPC
diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm
index 1624ed70..630c6c23 100755
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -7,15 +7,15 @@ DisplayDiploma: ; 566e2 (15:66e2)
ld hl, wd730
set 6, [hl]
call DisableLCD
- ld hl, CircleTile ; $7d88
+ ld hl, CircleTile
ld de, vChars2 + $700
ld bc, $0010
ld a, BANK(CircleTile)
call FarCopyData2
- ld hl, wTileMap
- ld bc, $1012
+ coord hl, 0, 0
+ lb bc, 16, 18
predef Diploma_TextBoxBorder
- ld hl, DiplomaTextPointersAndCoords ; $6784
+ ld hl, DiplomaTextPointersAndCoords
ld c, $5
.asm_56715
push bc
@@ -32,31 +32,35 @@ DisplayDiploma: ; 566e2 (15:66e2)
inc hl
pop bc
dec c
- jr nz, .asm_56715 ; 0x56725 $ee
- hlCoord 10, 4
+ jr nz, .asm_56715
+ coord hl, 10, 4
ld de, wPlayerName
call PlaceString
- callba Func_44dd
+ callba DrawPlayerCharacter
+
+; Move the player 33 pixels right and set the priority bit so he appears
+; behind the background layer.
ld hl, wOAMBuffer + $01
- ld bc, $8028
-.asm_5673e
- ld a, [hl]
- add $21
+ lb bc, $80, $28
+.adjustPlayerGfxLoop
+ ld a, [hl] ; X
+ add 33
ld [hli], a
inc hl
ld a, b
- ld [hli], a
+ ld [hli], a ; attributes
inc hl
dec c
- jr nz, .asm_5673e ; 0x56747 $f5
+ jr nz, .adjustPlayerGfxLoop
+
call EnableLCD
callba LoadTrainerInfoTextBoxTiles
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
call Delay3
call GBPalNormal
ld a, $90
- ld [$ff48], a
+ ld [rOBP0], a
call WaitForTextScrollButtonPress
ld hl, wd730
res 6, [hl]
@@ -65,27 +69,29 @@ DisplayDiploma: ; 566e2 (15:66e2)
call Delay3
jp GBPalNormal
-Func_56777: ; 56777 (15:6777)
+UnusedPlayerNameLengthFunc: ; 56777 (15:6777)
+; Unused function that does a calculation involving the length of the player's
+; name.
ld hl, wPlayerName
ld bc, $ff00
-.asm_5677d
+.loop
ld a, [hli]
- cp $50
+ cp "@"
ret z
dec c
- jr .asm_5677d ; 0x56782 $f9
+ jr .loop
DiplomaTextPointersAndCoords: ; 56784 (15:6784)
dw DiplomaText
- dw wTileMap + $2d
+ dwCoord 5, 2
dw DiplomaPlayer
- dw wTileMap + $53
+ dwCoord 3, 4
dw DiplomaEmptyText
- dw wTileMap + $5f
+ dwCoord 15, 4
dw DiplomaCongrats
- dw wTileMap + $7a
+ dwCoord 2, 6
dw DiplomaGameFreak
- dw wTileMap + $149
+ dwCoord 9, 16
DiplomaText:
db $70,"Diploma",$70,"@"
diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm
index a6dd7021..5b8ae7f0 100755
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -12,31 +12,33 @@ PKMNLeaguePC: ; 0x7657e
ld [hTilesetType], a
ld [W_SPRITEFLIPPED], a
ld [wUpdateSpritesEnabled], a
- ld [wTrainerScreenX], a
- ld [wcd42], a
- ld a, [wd5a2]
+ ld [wHoFTeamIndex2], a
+ 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 a, [wHoFTeamIndex2]
+ ld [wHoFTeamIndex], a
callba LoadHallOfFameTeams
- call Func_765e5
+ call LeaguePCShowTeam
pop bc
- jr c, .second
- ld hl, wTrainerScreenX
+ jr c, .doneShowingTeams
+ ld hl, wHoFTeamIndex2
inc [hl]
ld a, [hl]
cp b
- jr nz, .first
-.second
+ jr nz, .loop
+.doneShowingTeams
pop af
ld [hTilesetType], a
pop af
@@ -45,14 +47,14 @@ PKMNLeaguePC: ; 0x7657e
res 6, [hl]
call GBPalWhiteOutWithDelay3
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
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,42 +77,40 @@ 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 [wWholeScreenPaletteMonSpecies], a
ld a, [hli]
- ld [wTrainerFacingDirection], a
+ ld [wHoFMonLevel], a
ld de, wcd6d
- ld bc, $000B
+ ld bc, NAME_LENGTH
call CopyData
- ld b, $0B
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
ld c, 0
- call GoPAL_SET
- hlCoord 12, 5
+ call RunPaletteCommand
+ coord hl, 12, 5
call GetMonHeader
call LoadFrontSpriteByMonIndex
call GBPalNormal
- hlCoord 0, 13
+ coord hl, 0, 13
ld b, 2
ld c, $12
call TextBoxBorder
- hlCoord 1, 15
+ coord hl, 1, 15
ld de, HallOfFameNoText
call PlaceString
- hlCoord 16, 15
- ld de, wcd42
- ld bc, $0103
+ coord hl, 16, 15
+ ld de, wHoFTeamNo
+ lb bc, 1, 3
call PrintNumber
- ld b, BANK(Func_702f0)
- ld hl, Func_702f0
- jp Bankswitch
+ jpba HoFDisplayMonInfo
HallOfFameNoText: ; 76670 (1d:6670)
db "HALL OF FAME No @"
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index 756c7755..6c109cec 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -1,22 +1,21 @@
MainMenu: ; 5af2 (1:5af2)
; Check save file
- call Func_5bff
+ call InitOptions
xor a
- ld [wd08a],a
+ ld [wOptionsInitialized],a
inc a
- ld [wd088],a
- call Func_609e
- jr nc,.next0
+ ld [wSaveFileStatus],a
+ call CheckForPlayerNameInSRAM
+ jr nc,.mainMenuLoop
- ; Predef 52 loads the save from SRAM to RAM
predef LoadSAV
-.next0
+.mainMenuLoop
ld c,20
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
@@ -25,34 +24,35 @@ MainMenu: ; 5af2 (1:5af2)
ld hl,wd72e
res 6,[hl]
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns
call LoadFontTilePatterns
ld hl,wd730
set 6,[hl]
- ld a,[wd088]
+ ld a,[wSaveFileStatus]
cp a,1
- jr z,.next1
- hlCoord 0, 0
+ jr z,.noSaveFile
+; there's a save file
+ coord hl, 0, 0
ld b,6
ld c,13
call TextBoxBorder
- hlCoord 2, 2
+ coord hl, 2, 2
ld de,ContinueText
call PlaceString
jr .next2
-.next1
- hlCoord 0, 0
+.noSaveFile
+ coord hl, 0, 0
ld b,4
ld c,13
call TextBoxBorder
- hlCoord 2, 2
+ coord hl, 2, 2
ld de,NewGameText
call PlaceString
.next2
ld hl,wd730
res 6,[hl]
- call UpdateSprites ; OAM?
+ call UpdateSprites
xor a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
@@ -61,36 +61,38 @@ MainMenu: ; 5af2 (1:5af2)
ld [wTopMenuItemX],a
inc a
ld [wTopMenuItemY],a
- ld a,$B
+ ld a,A_BUTTON | B_BUTTON | START
ld [wMenuWatchedKeys],a
- ld a,[wd088]
+ ld a,[wSaveFileStatus]
ld [wMaxMenuItem],a
call HandleMenuInput
- bit 1,a
- jp nz,LoadTitlescreenGraphics ; load title screen (gfx and arrangement)
+ bit 1,a ; pressed B?
+ jp nz,DisplayTitleScreen ; if so, go back to the title screen
ld c,20
call DelayFrames
ld a,[wCurrentMenuItem]
ld b,a
- ld a,[wd088]
+ ld a,[wSaveFileStatus]
cp a,2
- jp z,.next3
- inc b ; adjust MenuArrow_Counter
-.next3
+ jp z,.skipInc
+; If there's no save file, increment the current menu item so that the numbers
+; are the same whether or not there's a save file.
+ inc b
+.skipInc
ld a,b
and a
- jr z,.next4 ; if press_A on Continue
+ jr z,.choseContinue
cp a,1
- jp z,Func_5d52 ; if press_A on NewGame
- call DisplayOptionMenu ; if press_a on Options
+ jp z,StartNewGame
+ call DisplayOptionMenu
ld a,1
- ld [wd08a],a
- jp .next0
-.next4
- call ContinueGame
+ ld [wOptionsInitialized],a
+ jp .mainMenuLoop
+.choseContinue
+ call DisplayContinueGameInfo
ld hl,wd126
set 5,[hl]
-.next6
+.inputLoop
xor a
ld [hJoyPressed],a
ld [hJoyReleased],a
@@ -98,18 +100,18 @@ MainMenu: ; 5af2 (1:5af2)
call Joypad
ld a,[hJoyHeld]
bit 0,a
- jr nz,.next5
+ jr nz,.pressedA
bit 1,a
- jp nz,.next0
- jr .next6
-.next5
+ jp nz,.mainMenuLoop ; pressed B
+ jr .inputLoop
+.pressedA
call GBPalWhiteOutWithDelay3
call ClearScreen
- ld a,4
- ld [wd52a],a
+ ld a,PLAYER_DIR_DOWN
+ ld [wPlayerDirection],a
ld c,10
call DelayFrames
- ld a,[wd5a2]
+ ld a,[wNumHoFTeams]
and a
jp z,SpecialEnterMap
ld a,[W_CURMAP] ; map ID
@@ -121,16 +123,17 @@ MainMenu: ; 5af2 (1:5af2)
set 2,[hl] ; fly warp or dungeon warp
call SpecialWarpIn
jp SpecialEnterMap
-Func_5bff: ; 5bff (1:5bff)
- ld a,1
- ld [wd358],a
- ld a,3
+
+InitOptions: ; 5bff (1:5bff)
+ ld a,1 ; no delay
+ ld [wLetterPrintingDelayFlags],a
+ ld a,3 ; medium speed
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
@@ -138,16 +141,16 @@ LinkMenu: ; 5c0a (1:5c0a)
call SaveScreenTilesToBuffer1
ld hl, WhereWouldYouLikeText
call PrintText
- hlCoord 5, 5
+ coord hl, 5, 5
ld b, $6
ld c, $d
call TextBoxBorder
call UpdateSprites
- hlCoord 7, 7
- ld de, TradeCenterText
+ coord hl, 7, 7
+ ld de, CableClubOptionsText
call PlaceString
xor a
- ld [wcd37], a
+ ld [wUnusedCD37], a
ld [wd72d], a
ld hl, wTopMenuItemY
ld a, $7
@@ -160,7 +163,8 @@ LinkMenu: ; 5c0a (1:5c0a)
ld a, $2
ld [hli], a
inc a
- ld [hli], a
+ ; ld a, A_BUTTON | B_BUTTON
+ ld [hli], a ; wMenuWatchedKeys
xor a
ld [hl], a
.waitForInputLoop
@@ -208,7 +212,7 @@ LinkMenu: ; 5c0a (1:5c0a)
ld a, b
ld [wLinkMenuSelectionSendBuffer], a
and $3
- ld [wCurrentMenuItem], a ; wCurrentMenuItem
+ ld [wCurrentMenuItem], a
.doneChoosingMenuSelection
ld a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
@@ -254,28 +258,28 @@ LinkMenu: ; 5c0a (1:5c0a)
ld [wWalkBikeSurfState], a ; start walking
ld a, [wCurrentMenuItem]
and a
- ld a, TRADE_CENTER
+ ld a, COLOSSEUM
jr nz, .next
- ld a, BATTLE_CENTER
+ ld a, TRADE_CENTER
.next
ld [wd72d], a
ld hl, PleaseWaitText
call PrintText
- ld c, $32
+ ld c, 50
call DelayFrames
ld hl, wd732
res 1, [hl]
ld a, [W_ANIMATIONID]
ld [wDestinationMap], a
call SpecialWarpIn
- ld c, $14
+ ld c, 20
call DelayFrames
xor a
ld [wMenuJoypadPollCount], a
ld [wSerialExchangeNybbleSendData], a
inc a ; LINK_STATE_IN_CABLE_CLUB
ld [wLinkState], a
- ld [wcc47], a
+ ld [wEnteringCableClub], a
jr SpecialEnterMap
.choseCancel
xor a
@@ -300,11 +304,11 @@ LinkCanceledText: ; 5d4d (1:5d4d)
TX_FAR _LinkCanceledText
db "@"
-Func_5d52: ; 5d52 (1:5d52)
+StartNewGame: ; 5d52 (1:5d52)
ld hl, wd732
res 1, [hl]
call OakSpeech
- ld c, $14
+ ld c, 20
call DelayFrames
; enter map after using a special warp or loading the game from the main menu
@@ -319,7 +323,7 @@ SpecialEnterMap: ; 5d5f (1:5d5f)
call ResetPlayerSpriteData
ld c, 20
call DelayFrames
- ld a, [wcc47]
+ ld a, [wEnteringCableClub]
and a
ret nz
jp EnterMap
@@ -331,89 +335,89 @@ NewGameText: ; 5d87 (1:5d87)
db "NEW GAME", $4e
db "OPTION@"
-TradeCenterText: ; 5d97 (1:5d97)
+CableClubOptionsText: ; 5d97 (1:5d97)
db "TRADE CENTER", $4e
db "COLOSSEUM", $4e
db "CANCEL@"
-ContinueGame: ; 5db5 (1:5db5)
+DisplayContinueGameInfo: ; 5db5 (1:5db5)
xor a
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- hlCoord 4, 7
- ld b, $8
- ld c, $e
+ ld [H_AUTOBGTRANSFERENABLED], a
+ coord hl, 4, 7
+ ld b, 8
+ ld c, 14
call TextBoxBorder
- hlCoord 5, 9
+ coord hl, 5, 9
ld de, SaveScreenInfoText
call PlaceString
- hlCoord 12, 9
- ld de, wPlayerName ; wd158
+ coord hl, 12, 9
+ ld de, wPlayerName
call PlaceString
- hlCoord 17, 11
- call Func_5e2f
- hlCoord 16, 13
- call Func_5e42
- hlCoord 13, 15
- call Func_5e55
- ld a, $1
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- ld c, $1e
+ coord hl, 17, 11
+ call PrintNumBadges
+ coord hl, 16, 13
+ call PrintNumOwnedMons
+ coord hl, 13, 15
+ call PrintPlayTime
+ ld a, 1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld c, 30
jp DelayFrames
PrintSaveScreenText: ; 5def (1:5def)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wTileMap + $4
+ coord hl, 4, 0
ld b, $8
ld c, $e
call TextBoxBorder
call LoadTextBoxTilePatterns
call UpdateSprites
- ld hl, wTileMap + $2d
+ coord hl, 5, 2
ld de, SaveScreenInfoText
call PlaceString
- ld hl, wTileMap + $34
+ coord hl, 12, 2
ld de, wPlayerName
call PlaceString
- ld hl, wTileMap + $61
- call Func_5e2f
- ld hl, wTileMap + $88
- call Func_5e42
- ld hl, wTileMap + $ad
- call Func_5e55
+ coord hl, 17, 4
+ call PrintNumBadges
+ coord hl, 16, 6
+ call PrintNumOwnedMons
+ coord hl, 13, 8
+ call PrintPlayTime
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
- ld c, $1e
+ ld c, 30
jp DelayFrames
-Func_5e2f: ; 5e2f (1:5e2f)
+PrintNumBadges: ; 5e2f (1:5e2f)
push hl
ld hl, W_OBTAINEDBADGES
ld b, $1
call CountSetBits
pop hl
- ld de, wd11e
- ld bc, $102
+ ld de, wNumSetBits
+ lb bc, 1, 2
jp PrintNumber
-Func_5e42: ; 5e42 (1:5e42)
+PrintNumOwnedMons: ; 5e42 (1:5e42)
push hl
- ld hl, wPokedexOwned ; wPokedexOwned
+ ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
pop hl
- ld de, wd11e
- ld bc, $103
+ ld de, wNumSetBits
+ lb bc, 1, 3
jp PrintNumber
-Func_5e55: ; 5e55 (1:5e55)
+PrintPlayTime: ; 5e55 (1:5e55)
ld de, W_PLAYTIMEHOURS + 1
- ld bc, $103
+ lb bc, 1, 3
call PrintNumber
ld [hl], $6d
inc hl
ld de, W_PLAYTIMEMINUTES + 1
- ld bc, $8102
+ lb bc, LEADING_ZEROES | 1, 2
jp PrintNumber
SaveScreenInfoText: ; 5e6a (1:5e6a)
@@ -423,40 +427,40 @@ SaveScreenInfoText: ; 5e6a (1:5e6a)
next "TIME@"
DisplayOptionMenu: ; 5e8a (1:5e8a)
- hlCoord 0, 0
+ coord hl, 0, 0
ld b,3
ld c,18
call TextBoxBorder
- hlCoord 0, 5
+ coord hl, 0, 5
ld b,3
ld c,18
call TextBoxBorder
- hlCoord 0, 10
+ coord hl, 0, 10
ld b,3
ld c,18
call TextBoxBorder
- hlCoord 1, 1
+ coord hl, 1, 1
ld de,TextSpeedOptionText
call PlaceString
- hlCoord 1, 6
+ coord hl, 1, 6
ld de,BattleAnimationOptionText
call PlaceString
- hlCoord 1, 11
+ coord hl, 1, 11
ld de,BattleStyleOptionText
call PlaceString
- hlCoord 2, 16
+ coord hl, 2, 16
ld de,OptionMenuCancelText
call PlaceString
xor a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
inc a
- ld [wd358],a
- ld [wTrainerScreenY],a
+ ld [wLetterPrintingDelayFlags],a
+ ld [wUnusedCD40],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
@@ -468,7 +472,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
call JoypadLowSensitivity
ld a,[hJoy5]
ld b,a
- and a,%11111011 ; any key besides select pressed?
+ and a,A_BUTTON | B_BUTTON | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ; any key besides select pressed?
jr z,.getJoypadStateLoop
bit 1,b ; B button pressed?
jr nz,.exitMenu
@@ -480,8 +484,8 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
cp a,16 ; is the cursor on Cancel?
jr nz,.loop
.exitMenu
- ld a,(SFX_02_40 - SFX_Headers_02) / 3
- call PlaySound ; play sound
+ ld a,SFX_PRESS_AB
+ call PlaySound
ret
.eraseOldMenuCursor
ld [wTopMenuItemX],a
@@ -506,7 +510,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
@@ -521,7 +525,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
@@ -540,17 +544,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
@@ -561,7 +565,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
@@ -571,7 +575,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)
@@ -592,7 +596,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]
@@ -603,7 +607,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
@@ -612,7 +616,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
@@ -637,27 +641,27 @@ SetCursorPositionsFromOptions: ; 604c (1:604c)
pop bc
dec hl
ld a,[hl]
- ld [wWhichTrade],a ; text speed cursor X coordinate
- hlCoord 0, 3
+ ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate
+ coord hl, 0, 3
call .placeUnfilledRightArrow
sla c
ld a,1 ; On
jr nc,.storeBattleAnimationCursorX
ld a,10 ; Off
.storeBattleAnimationCursorX
- ld [wTrainerEngageDistance],a ; battle animation cursor X coordinate
- hlCoord 0, 8
+ ld [wOptionsBattleAnimCursorX],a ; battle animation cursor X coordinate
+ coord hl, 0, 8
call .placeUnfilledRightArrow
sla c
ld a,1
jr nc,.storeBattleStyleCursorX
ld a,10
.storeBattleStyleCursorX
- ld [wTrainerFacingDirection],a ; battle style cursor X coordinate
- hlCoord 0, 13
+ ld [wOptionsBattleStyleCursorX],a ; battle style cursor X coordinate
+ coord hl, 0, 13
call .placeUnfilledRightArrow
; cursor in front of Cancel
- hlCoord 0, 16
+ coord hl, 0, 16
ld a,1
.placeUnfilledRightArrow
ld e,a
@@ -677,28 +681,32 @@ TextSpeedOptionData: ; 6096 (1:6096)
db 7 ; default X coordinate (Medium)
db $ff ; terminator
-Func_609e: ; 609e (1:609e)
- ld a, $a
- ld [$0], a
+CheckForPlayerNameInSRAM: ; 609e (1:609e)
+; Check if the player name data in SRAM has a string terminator character
+; (indicating that a name may have been saved there) and return whether it does
+; in carry.
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
- ld b, $b
- ld hl, $a598
-.asm_60b0
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
+ ld b, NAME_LENGTH
+ ld hl, sPlayerName
+.loop
ld a, [hli]
- cp $50
- jr z, .asm_60c1
+ cp "@"
+ jr z, .found
dec b
- jr nz, .asm_60b0
+ jr nz, .loop
+; not found
xor a
- ld [$0], a
- ld [$6000], a
+ ld [MBC1SRamEnable], a
+ ld [MBC1SRamBankingMode], a
and a
ret
-.asm_60c1
+.found
xor a
- ld [$0], a
- ld [$6000], a
+ ld [MBC1SRamEnable], a
+ ld [MBC1SRamBankingMode], a
scf
ret
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index df862d69..978216c8 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -4,37 +4,37 @@ AskName: ; 64eb (1:64eb)
push hl
ld a, [W_ISINBATTLE]
dec a
- ld hl, wTileMap
- ld b, $4
- ld c, $b
+ coord hl, 0, 0
+ ld b, 4
+ ld c, 11
call z, ClearScreenArea ; only if in wild batle
ld a, [wcf91]
ld [wd11e], a
call GetMonName
ld hl, DoYouWantToNicknameText
call PrintText
- hlCoord 14, 7
- ld bc, $80f
+ coord hl, 14, 7
+ lb bc, 8, 15
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID
pop hl
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_654c
+ jr nz, .declinedNickname
ld a, [wUpdateSpritesEnabled]
push af
xor a
ld [wUpdateSpritesEnabled], a
push hl
- ld a, $2
- ld [wd07d], a
+ ld a, NAME_MON_SCREEN
+ ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [W_ISINBATTLE]
and a
- jr nz, .asm_653e
+ jr nz, .inBattle
call ReloadMapSpriteTilePatterns
-.asm_653e
+.inBattle
call LoadScreenTilesFromBuffer1
pop hl
pop af
@@ -42,42 +42,42 @@ AskName: ; 64eb (1:64eb)
ld a, [wcf4b]
cp $50
ret nz
-.asm_654c
+.declinedNickname
ld d, h
ld e, l
ld hl, wcd6d
- ld bc, $000b
+ ld bc, NAME_LENGTH
jp CopyData
DoYouWantToNicknameText: ; 0x6557
TX_FAR _DoYouWantToNicknameText
db "@"
-Func_655c: ; 655c (1:655c)
- ld hl, wHPBarMaxHP
+DisplayNameRaterScreen: ; 655c (1:655c)
+ ld hl, wBuffer
xor a
ld [wUpdateSpritesEnabled], a
- ld a, $2
- ld [wd07d], a
+ ld a, NAME_MON_SCREEN
+ ld [wNamingScreenType], a
call DisplayNamingScreen
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
call LoadGBPal
ld a, [wcf4b]
- cp $50
- jr z, .asm_6594
+ cp "@"
+ jr z, .playerCancelled
ld hl, wPartyMonNicks
- ld bc, $b
+ ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld e, l
ld d, h
- ld hl, wHPBarMaxHP
- ld bc, $b
+ ld hl, wBuffer
+ ld bc, NAME_LENGTH
call CopyData
and a
ret
-.asm_6594
+.playerCancelled
scf
ret
@@ -88,44 +88,44 @@ DisplayNamingScreen: ; 6596 (1:6596)
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
call LoadHpBarAndStatusTilePatterns
call LoadEDTile
callba LoadMonPartySpriteGfx
- hlCoord 0, 4
- ld b, $9
- ld c, $12
+ coord hl, 0, 4
+ ld b, 9
+ ld c, 18
call TextBoxBorder
call PrintNamingText
- ld a, $3
+ ld a, 3
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
ld [wLastMenuItem], a
ld [wCurrentMenuItem], a
ld a, $ff
ld [wMenuWatchedKeys], a
- ld a, $7
+ ld a, 7
ld [wMaxMenuItem], a
ld a, $50
ld [wcf4b], a
xor a
- ld hl, wHPBarMaxHP + 1
+ ld hl, wNamingScreenSubmitName
ld [hli], a
ld [hli], a
- ld [wPartyMonAnimCounter], a
-.asm_65ed
+ ld [wAnimCounter], a
+.selectReturnPoint
call PrintAlphabet
call GBPalNormal
-.asm_65f3
- ld a, [wHPBarMaxHP + 1]
+.ABStartReturnPoint
+ ld a, [wNamingScreenSubmitName]
and a
- jr nz, .asm_662d
- call Func_680e
-.asm_65fc
+ jr nz, .submitNickname
+ call PrintNicknameAndUnderscores
+.dPadReturnPoint
call PlaceMenuCursor
-.asm_65ff
+.inputLoop
ld a, [wCurrentMenuItem]
push af
callba AnimatePartyMon_ForceSpeed1
@@ -134,17 +134,17 @@ DisplayNamingScreen: ; 6596 (1:6596)
call JoypadLowSensitivity
ld a, [hJoyPressed]
and a
- jr z, .asm_65ff
- ld hl, .unknownPointerTable_665e
-.asm_661a
+ jr z, .inputLoop
+ ld hl, .namingScreenButtonFunctions
+.checkForPressedButton
sla a
- jr c, .asm_6624
+ jr c, .foundPressedButton
inc hl
inc hl
inc hl
inc hl
- jr .asm_661a
-.asm_6624
+ jr .checkForPressedButton
+.foundPressedButton
ld a, [hli]
ld e, a
ld a, [hli]
@@ -154,15 +154,16 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld l, a
push de
jp [hl]
-.asm_662d
+
+.submitNickname
pop de
ld hl, wcf4b
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
call GBPalWhiteOutWithDelay3
call ClearScreen
call ClearSprites
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
xor a
ld [W_SUBANIMTRANSFORM], a
@@ -171,193 +172,197 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld a, [W_ISINBATTLE]
and a
jp z, LoadTextBoxTilePatterns
- ld hl, LoadHudTilePatterns
- ld b, BANK(LoadHudTilePatterns)
- jp Bankswitch
+ jpab LoadHudTilePatterns
-.unknownPointerTable_665e: ; 665e (1:665e)
- dw .asm_65fc
- dw .asm_673e
- dw .asm_65fc
- dw .asm_672c
- dw .asm_65fc
- dw .asm_6718
- dw .asm_65fc
- dw .asm_6702
- dw .asm_65f3
- dw .asm_668c
- dw .asm_65ed
- dw .asm_6683
- dw .asm_65f3
- dw .deleteLetter
- dw .asm_65f3
- dw .asm_6692
+.namingScreenButtonFunctions
+ dw .dPadReturnPoint
+ dw .pressedDown
+ dw .dPadReturnPoint
+ dw .pressedUp
+ dw .dPadReturnPoint
+ dw .pressedLeft
+ dw .dPadReturnPoint
+ dw .pressedRight
+ dw .ABStartReturnPoint
+ dw .pressedStart
+ dw .selectReturnPoint
+ dw .pressedSelect
+ dw .ABStartReturnPoint
+ dw .pressedB
+ dw .ABStartReturnPoint
+ dw .pressedA
-.asm_667e
+.pressedA_changedCase
pop de
- ld de, .asm_65ed ; $65ed
+ ld de, .selectReturnPoint
push de
-.asm_6683
- ld a, [wHPBarOldHP]
+.pressedSelect
+ ld a, [wAlphabetCase]
xor $1
- ld [wHPBarOldHP], a
+ ld [wAlphabetCase], a
ret
-.asm_668c
- ld a, $1
- ld [wHPBarMaxHP + 1], a
+
+.pressedStart
+ ld a, 1
+ ld [wNamingScreenSubmitName], a
ret
-.asm_6692
+
+.pressedA
ld a, [wCurrentMenuItem]
- cp $5
- jr nz, .asm_66a0
+ cp $5 ; "ED" row
+ jr nz, .didNotPressED
ld a, [wTopMenuItemX]
- cp $11
- jr z, .asm_668c
-.asm_66a0
+ cp $11 ; "ED" column
+ jr z, .pressedStart
+.didNotPressED
ld a, [wCurrentMenuItem]
- cp $6
- jr nz, .asm_66ae
+ cp $6 ; case switch row
+ jr nz, .didNotPressCaseSwtich
ld a, [wTopMenuItemX]
- cp $1
- jr z, .asm_667e
-.asm_66ae
+ cp $1 ; case switch column
+ jr z, .pressedA_changedCase
+.didNotPressCaseSwtich
ld hl, wMenuCursorLocation
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
ld a, [hl]
- ld [wHPBarNewHP], a
+ ld [wNamingScreenLetter], a
call CalcStringLength
- ld a, [wHPBarNewHP]
+ ld a, [wNamingScreenLetter]
cp $e5
- ld de, Dakutens ; $6885
- jr z, .asm_66e3
+ ld de, Dakutens
+ jr z, .dakutensAndHandakutens
cp $e4
- ld de, Handakutens ; $68d6
- jr z, .asm_66e3
- ld a, [wd07d]
- cp $2
+ ld de, Handakutens
+ jr z, .dakutensAndHandakutens
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
jr nc, .checkMonNameLength
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
cp $7 ; max length of player/rival names
jr .checkNameLength
.checkMonNameLength
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
cp $a ; max length of pokemon nicknames
.checkNameLength
jr c, .addLetter
ret
-.asm_66e3
+
+.dakutensAndHandakutens
push hl
- call Func_6871
+ call DakutensAndHandakutens
pop hl
ret nc
dec hl
.addLetter
- ld a, [wHPBarNewHP]
+ ld a, [wNamingScreenLetter]
ld [hli], a
ld [hl], $50
- ld a, (SFX_02_40 - SFX_Headers_02) / 3
+ ld a, SFX_PRESS_AB
call PlaySound
ret
-.deleteLetter
- ld a, [wHPBarMaxHP]
+.pressedB
+ ld a, [wNamingScreenNameLength]
and a
ret z
call CalcStringLength
dec hl
- ld [hl], $50
+ ld [hl], "@"
ret
-.asm_6702
+.pressedRight
ld a, [wCurrentMenuItem]
cp $6
- ret z
+ ret z ; can't scroll right on bottom row
ld a, [wTopMenuItemX]
- cp $11
- jp z, .asm_6714
+ cp $11 ; max
+ jp z, .wrapToFirstColumn
inc a
inc a
- jr .asm_6755
-.asm_6714
+ jr .done
+.wrapToFirstColumn
ld a, $1
- jr .asm_6755
-.asm_6718
+ jr .done
+.pressedLeft
ld a, [wCurrentMenuItem]
cp $6
- ret z
+ ret z ; can't scroll right on bottom row
ld a, [wTopMenuItemX]
dec a
- jp z, .asm_6728
+ jp z, .wrapToLastColumn
dec a
- jr .asm_6755
-.asm_6728
- ld a, $11
- jr .asm_6755
-.asm_672c
+ jr .done
+.wrapToLastColumn
+ ld a, $11 ; max
+ jr .done
+.pressedUp
ld a, [wCurrentMenuItem]
dec a
ld [wCurrentMenuItem], a
and a
ret nz
- ld a, $6
+ ld a, $6 ; wrap to bottom row
ld [wCurrentMenuItem], a
- ld a, $1
- jr .asm_6755
-.asm_673e
+ ld a, $1 ; force left column
+ jr .done
+.pressedDown
ld a, [wCurrentMenuItem]
inc a
ld [wCurrentMenuItem], a
cp $7
- jr nz, .asm_6750
+ jr nz, .wrapToTopRow
ld a, $1
ld [wCurrentMenuItem], a
- jr .asm_6755
-.asm_6750
+ jr .done
+.wrapToTopRow
cp $6
ret nz
ld a, $1
-.asm_6755
+.done
ld [wTopMenuItemX], a
jp EraseMenuCursor
LoadEDTile: ; 675b (1:675b)
ld de, ED_Tile
ld hl, vFont + $700
- ld bc, $1
+ ld bc, (ED_TileEnd - ED_Tile) / $8
+ ; to fix the graphical bug on poor emulators
+ ;lb bc, BANK(ED_Tile), (ED_TileEnd - ED_Tile) / $8
jp CopyVideoDataDouble
ED_Tile: ; 6767 (1:6767)
INCBIN "gfx/ED_tile.1bpp"
+ED_TileEnd:
PrintAlphabet: ; 676f (1:676f)
xor a
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- ld a, [wHPBarOldHP]
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld a, [wAlphabetCase]
and a
- ld de, LowerCaseAlphabet ; $679e
- jr nz, .asm_677e
- ld de, UpperCaseAlphabet ; $67d6
-.asm_677e
- hlCoord 2, 5
- ld bc, $509
-.asm_6784
+ ld de, LowerCaseAlphabet
+ jr nz, .lowercase
+ ld de, UpperCaseAlphabet
+.lowercase
+ coord hl, 2, 5
+ lb bc, 5, 9 ; 5 rows, 9 columns
+.outerLoop
push bc
-.asm_6785
+.innerLoop
ld a, [de]
ld [hli], a
inc hl
inc de
dec c
- jr nz, .asm_6785
- ld bc, $16
+ jr nz, .innerLoop
+ ld bc, SCREEN_WIDTH + 2
add hl, bc
pop bc
dec b
- jr nz, .asm_6784
+ jr nz, .outerLoop
call PlaceString
ld a, $1
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
+ ld [H_AUTOBGTRANSFERENABLED], a
jp Delay3
LowerCaseAlphabet: ; 679e (1:679e)
@@ -366,59 +371,61 @@ LowerCaseAlphabet: ; 679e (1:679e)
UpperCaseAlphabet: ; 67d6 (1:67d6)
db "ABCDEFGHIJKLMNOPQRSTUVWXYZ ×():;[]",$e1,$e2,"-?!♂♀/",$f2,",¥lower case@"
-Func_680e: ; 680e (1:680e)
+PrintNicknameAndUnderscores: ; 680e (1:680e)
call CalcStringLength
ld a, c
- ld [wHPBarMaxHP], a
- hlCoord 10, 2
- ld bc, $10a
+ ld [wNamingScreenNameLength], a
+ coord hl, 10, 2
+ lb bc, 1, 10
call ClearScreenArea
- hlCoord 10, 2
+ coord hl, 10, 2
ld de, wcf4b
call PlaceString
- hlCoord 10, 3
- ld a, [wd07d]
- cp $2
- jr nc, .asm_6835
- ld b, $7
- jr .asm_6837
-.asm_6835
- ld b, $a
-.asm_6837
- ld a, $76
-.asm_6839
+ coord hl, 10, 3
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
+ jr nc, .pokemon1
+ ld b, 7 ; player or rival max name length
+ jr .playerOrRival1
+.pokemon1
+ ld b, 10 ; pokemon max name length
+.playerOrRival1
+ ld a, $76 ; underscore tile id
+.placeUnderscoreLoop
ld [hli], a
dec b
- jr nz, .asm_6839
- ld a, [wd07d]
- cp $2
- ld a, [wHPBarMaxHP]
- jr nc, .asm_684b
- cp $7
- jr .asm_684d
-.asm_684b
- cp $a
-.asm_684d
- jr nz, .asm_6867
+ jr nz, .placeUnderscoreLoop
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
+ ld a, [wNamingScreenNameLength]
+ jr nc, .pokemon2
+ cp 7 ; player or rival max name length
+ jr .playerOrRival2
+.pokemon2
+ cp 10 ; pokemon max name length
+.playerOrRival2
+ jr nz, .emptySpacesRemaining
+ ; when all spaces are filled, force the cursor onto the ED tile
call EraseMenuCursor
- ld a, $11
+ ld a, $11 ; "ED" x coord
ld [wTopMenuItemX], a
- ld a, $5
+ ld a, $5 ; "ED" y corrd
ld [wCurrentMenuItem], a
- ld a, [wd07d]
- cp $2
- ld a, $9
- jr nc, .asm_6867
- ld a, $6
-.asm_6867
+ ld a, [wNamingScreenType]
+ cp NAME_MON_SCREEN
+ ld a, 9 ; keep the last underscore raised
+ jr nc, .pokemon3
+ ld a, 6 ; keep the last underscore raised
+.pokemon3
+.emptySpacesRemaining
ld c, a
ld b, $0
- hlCoord 10, 3
+ coord hl, 10, 3
add hl, bc
- ld [hl], $77
+ ld [hl], $77 ; raised underscore tile id
ret
-Func_6871: ; 6871 (1:6871)
+DakutensAndHandakutens: ; 6871 (1:6871)
push de
call CalcStringLength
dec hl
@@ -429,7 +436,7 @@ Func_6871: ; 6871 (1:6871)
ret nc
inc hl
ld a, [hl]
- ld [wHPBarNewHP], a
+ ld [wNamingScreenLetter], a
ret
Dakutens: ; 6885 (1:6885)
@@ -452,17 +459,17 @@ Handakutens: ; 68d6 (1:68d6)
CalcStringLength: ; 68eb (1:68eb)
ld hl, wcf4b
ld c, $0
-.asm_68f0
+.loop
ld a, [hl]
- cp $50
+ cp "@"
ret z
inc hl
inc c
- jr .asm_68f0
+ jr .loop
PrintNamingText: ; 68f8 (1:68f8)
- hlCoord 0, 1
- ld a, [wd07d]
+ coord hl, 0, 1
+ ld a, [wNamingScreenType]
ld de, YourTextString
and a
jr z, .notNickname
@@ -476,12 +483,12 @@ PrintNamingText: ; 68f8 (1:68f8)
pop af
ld [wd11e], a
call GetMonName
- hlCoord 4, 1
+ coord hl, 4, 1
call PlaceString
ld hl, $1
add hl, bc
ld [hl], $c9
- hlCoord 1, 3
+ coord hl, 1, 3
ld de, NicknameTextString
jr .placeString
.notNickname
diff --git a/engine/menu/oaks_pc.asm b/engine/menu/oaks_pc.asm
index 6e7edda2..7ff03c46 100755
--- a/engine/menu/oaks_pc.asm
+++ b/engine/menu/oaks_pc.asm
@@ -5,7 +5,7 @@ OpenOaksPC: ; 1e915 (7:6915)
ld hl, GetDexRatedText
call PrintText
call YesNoChoice
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld a, [wCurrentMenuItem]
and a
jr nz, .asm_1e932
predef DisplayDexRating
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index 242edd40..f3e1a138 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -1,4 +1,4 @@
-; [wd07d] = menu type / message ID
+; [wPartyMenuTypeOrMessageID] = menu type / message ID
; if less than $F0, it is a menu type
; menu types:
; 00: normal pokemon menu (e.g. Start menu)
@@ -21,21 +21,21 @@ DrawPartyMenu_: ; 12cd2 (4:6cd2)
xor a
ld [H_AUTOBGTRANSFERENABLED],a
call ClearScreen
- call UpdateSprites ; move sprites
+ call UpdateSprites
callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
RedrawPartyMenu_: ; 12ce3 (4:6ce3)
- ld a,[wd07d]
- cp a,$04
+ ld a,[wPartyMenuTypeOrMessageID]
+ cp a,SWAP_MONS_PARTY_MENU
jp z,.printMessage
call ErasePartyMenuCursors
- callba SendBlkPacket_PartyMenu ; loads some data to wcf2e
- hlCoord 3, 0
+ callba InitPartyMenuBlkPacket
+ coord hl, 3, 0
ld de,wPartySpecies
xor a
ld c,a
ld [hPartyMonIndex],a
- ld [wcf2d],a
+ ld [wWhichPartyMenuHPBar],a
.loop
ld a,[de]
cp a,$FF ; reached the terminator?
@@ -75,10 +75,10 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
inc hl
inc hl
.skipUnfilledRightArrow
- ld a,[wd07d] ; menu type
- cp a,$03
+ ld a,[wPartyMenuTypeOrMessageID] ; menu type
+ cp a,TMHM_PARTY_MENU
jr z,.teachMoveMenu
- cp a,$05
+ cp a,EVO_STONE_PARTY_MENU
jr z,.evolutionStoneMenu
push hl
ld bc,14 ; 14 columns to the right
@@ -96,7 +96,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
- call SetPartyMenuHealthBarColor ; color the HP bar (on SGB)
+ call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl
jr .printLevel
.teachMoveMenu
@@ -150,7 +150,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld l,a
ld de,wcd6d
ld a,BANK(EvosMovesPointerTable)
- ld bc,13
+ ld bc,Mon133_EvosEnd - Mon133_EvosMoves
call FarCopyData
ld hl,wcd6d
ld de,.notAbleToEvolveText
@@ -167,7 +167,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
dec hl
dec hl
ld b,[hl]
- ld a,[wd156] ; evolution stone item ID
+ ld a,[wEvoStoneItemID] ; the stone the player used
inc hl
inc hl
inc hl
@@ -188,15 +188,15 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
.notAbleToEvolveText
db "NOT ABLE@"
.afterDrawingMonEntries
- ld b,$0A
- call GoPAL_SET
+ ld b, SET_PAL_PARTY_MENU
+ call RunPaletteCommand
.printMessage
ld hl,wd730
ld a,[hl]
push af
push hl
set 6,[hl] ; turn off letter printing delay
- ld a,[wd07d] ; message ID
+ ld a,[wPartyMenuTypeOrMessageID] ; message ID
cp a,$F0
jr nc,.printItemUseMessage
add a
@@ -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
@@ -311,15 +311,15 @@ RareCandyText: ; 12ec0 (4:6ec0)
db $06
db "@"
-SetPartyMenuHealthBarColor: ; 12ec7 (4:6ec7)
- ld hl, wcf1f
- ld a, [wcf2d]
+SetPartyMenuHPBarColor: ; 12ec7 (4:6ec7)
+ ld hl, wPartyMenuHPBarColors
+ ld a, [wWhichPartyMenuHPBar]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
call GetHealthBarColor
- ld b, $fc
- call GoPAL_SET
- ld hl, wcf2d
+ ld b, UPDATE_PARTY_MENU_BLK_PACKET
+ call RunPaletteCommand
+ ld hl, wWhichPartyMenuHPBar
inc [hl]
ret
diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm
index 97895ca6..78b35b95 100755
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -1,16 +1,16 @@
ActivatePC: ; 17e2c (5:7e2c)
- call SaveScreenTilesToBuffer2 ;XXX: copy background from wTileMap to wTileMapBackup2
- ld a, (SFX_02_45 - SFX_Headers_02) / 3
- call PlaySound ;XXX: play sound or stop music
+ call SaveScreenTilesToBuffer2
+ ld a, SFX_TURN_ON_PC
+ call PlaySound
ld hl, TurnedOnPC1Text
call PrintText
- call WaitForSoundToFinish ;XXX: wait for sound to be done
+ call WaitForSoundToFinish
ld hl, wFlags_0xcd60
set 3, [hl]
- call LoadScreenTilesFromBuffer2 ;XXX: restore saved screen
+ call LoadScreenTilesFromBuffer2
call Delay3
PCMainMenu: ; 17e48 (5:7e48)
- callba Func_213c8
+ callba DisplayPCMainMenu
ld hl, wFlags_0xcd60
set 5, [hl]
call HandleMenuInput
@@ -51,31 +51,30 @@ PCMainMenu: ; 17e48 (5:7e48)
ld hl, wFlags_0xcd60
res 5, [hl]
set 3, [hl]
- ld a, (SFX_02_47 - SFX_Headers_02) / 3
- call PlaySound ;XXX: play sound or stop music
- call WaitForSoundToFinish ;XXX: wait for sound to be done
+ ld a, SFX_ENTER_PC
+ call PlaySound
+ call WaitForSoundToFinish
ld hl, AccessedMyPCText
call PrintText
callba PlayerPC
jr ReloadMainMenu
OaksPC: ; 17ec0 (5:7ec0)
- ld a, (SFX_02_47 - SFX_Headers_02) / 3
- call PlaySound ;XXX: play sound or stop music
- call WaitForSoundToFinish ;XXX: wait for sound to be done
+ ld a, SFX_ENTER_PC
+ call PlaySound
+ call WaitForSoundToFinish
callba OpenOaksPC
jr ReloadMainMenu
PKMNLeague: ; 17ed2 (5:7ed2)
- ld a, (SFX_02_47 - SFX_Headers_02) / 3
- call PlaySound ;XXX: play sound or stop music
- call WaitForSoundToFinish ;XXX: wait for sound to be done
+ ld a, SFX_ENTER_PC
+ call PlaySound
+ call WaitForSoundToFinish
callba PKMNLeaguePC
jr ReloadMainMenu
BillsPC: ; 17ee4 (5:7ee4)
- ld a, (SFX_02_47 - SFX_Headers_02) / 3
- call PlaySound ;XXX: play sound or stop music
- call WaitForSoundToFinish ;XXX: wait for sound to be done
- ld a, [wd7f1] ;has to do with having met Bill
- bit 0, a
+ ld a, SFX_ENTER_PC
+ call PlaySound
+ call WaitForSoundToFinish
+ CheckEvent EVENT_MET_BILL
jr nz, .billsPC ;if you've met bill, use that bill's instead of someone's
ld hl, AccessedSomeonesPCText
jr .printText
@@ -88,12 +87,12 @@ ReloadMainMenu: ; 17f06 (5:7f06)
xor a
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call ReloadMapData
- call UpdateSprites ;XXX: moves sprites
+ call UpdateSprites
jp PCMainMenu
LogOff: ; 17f13 (5:7f13)
- ld a, (SFX_02_46 - SFX_Headers_02) / 3
- call PlaySound ;XXX: play sound or stop music
- call WaitForSoundToFinish ;XXX: wait for sound to be done
+ ld a, SFX_TURN_OFF_PC
+ call PlaySound
+ call WaitForSoundToFinish
ld hl, wFlags_0xcd60
res 3, [hl]
res 5, [hl]
@@ -115,13 +114,13 @@ AccessedMyPCText: ; 17f32 (5:7f32)
TX_FAR _AccessedMyPCText
db "@"
-; removes one of the specified item ID [$FFdb] from bag (if existent)
+; removes one of the specified item ID [hItemToRemoveID] from bag (if existent)
RemoveItemByID: ; 17f37 (5:7f37)
- ld hl, wBagItems ; wd31e
- ld a, [$ffdb]
+ ld hl, wBagItems
+ ld a, [hItemToRemoveID]
ld b, a
xor a
- ld [$ffdc], a
+ ld [hItemToRemoveIndex], a
.asm_17f40
ld a, [hli]
cp $ff
@@ -129,14 +128,14 @@ RemoveItemByID: ; 17f37 (5:7f37)
cp b
jr z, .asm_17f4f
inc hl
- ld a, [$ffdc]
+ ld a, [hItemToRemoveIndex]
inc a
- ld [$ffdc], a
+ ld [hItemToRemoveIndex], a
jr .asm_17f40
.asm_17f4f
ld a, $1
- ld [wcf96], a
- ld a, [$ffdc]
- ld [wWhichPokemon], a ; wWhichPokemon
- ld hl, wNumBagItems ; wNumBagItems
+ ld [wItemQuantity], a
+ ld a, [hItemToRemoveIndex]
+ ld [wWhichPokemon], a
+ ld hl, wNumBagItems
jp RemoveItemFromInventory
diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm
index 147a27a4..00889e93 100755
--- a/engine/menu/players_pc.asm
+++ b/engine/menu/players_pc.asm
@@ -5,238 +5,240 @@ 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
- ld a, (SFX_02_45 - SFX_Headers_02) / 3
+ bit 3, a ; accessing player's PC through another PC?
+ jr nz, PlayerPCMenu
+; accessing it directly
+ ld a, SFX_TURN_ON_PC
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]
call LoadScreenTilesFromBuffer2
- ld hl, wTileMap
+ coord hl, 0, 0
ld b, $8
ld c, $e
call TextBoxBorder
call UpdateSprites
- hlCoord 2, 2
+ coord hl, 2, 2
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
- ld a, (SFX_02_46 - SFX_Headers_02) / 3
+ bit 3, a ; accessing player's PC through another PC?
+ jr nz, .next
+; accessing it directly
+ ld a, SFX_TURN_OFF_PC
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 [wcf93], a
- ld a, $3
+ ld [wPrintItemPrices], a
+ ld a, ITEMLISTMENU
ld [wListMenuID], a
call DisplayListMenuID
- jp c, Func_790c
+ jp c, PlayerPCMenu
call IsKeyItem
- ld a, $1
- ld [wcf96], a
- ld a, [wd124]
+ 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
- ld a, (SFX_02_55 - SFX_Headers_02) / 3
+ ld a, SFX_WITHDRAW_DEPOSIT
call PlaySound
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 [wcf93], a
- ld a, $3
+ ld [wPrintItemPrices], a
+ ld a, ITEMLISTMENU
ld [wListMenuID], a
call DisplayListMenuID
- jp c, Func_790c
+ jp c, PlayerPCMenu
call IsKeyItem
- ld a, $1
- ld [wcf96], a
- ld a, [wd124]
+ 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
- ld a, (SFX_02_55 - SFX_Headers_02) / 3
+ ld a, SFX_WITHDRAW_DEPOSIT
call PlaySound
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 [wcf93], a
- ld a, $3
+ ld [wPrintItemPrices], a
+ 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 [wcf96], a
- ld a, [wd124]
+ 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/pokedex.asm b/engine/menu/pokedex.asm
index bd4c40bd..7953b849 100755
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -1,7 +1,7 @@
ShowPokedexMenu: ; 40000 (10:4000)
call GBPalWhiteOut
call ClearScreen
- call UpdateSprites ; move sprites
+ call UpdateSprites
ld a,[wListScrollOffset]
push af
xor a
@@ -12,8 +12,8 @@ ShowPokedexMenu: ; 40000 (10:4000)
ld [wd11e],a
ld [hJoy7],a
.setUpGraphics
- ld b,$08
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
callab LoadPokedexTilePatterns
.doPokemonListMenu
ld hl,wTopMenuItemY
@@ -22,17 +22,17 @@ ShowPokedexMenu: ; 40000 (10:4000)
xor a
ld [hli],a ; top menu item X
inc a
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
inc hl
inc hl
ld a,6
ld [hli],a ; max menu item ID
- ld [hl],%00110011 ; menu watched keys (Left, Right, B button, A button)
+ ld [hl],D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
call HandlePokedexListMenu
jr c,.goToSideMenu ; if the player chose a pokemon from the list
.exitPokedex
xor a
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
ld [hJoy7],a
@@ -41,7 +41,7 @@ ShowPokedexMenu: ; 40000 (10:4000)
pop af
ld [wListScrollOffset],a
call GBPalWhiteOutWithDelay3
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp ReloadMapData
.goToSideMenu
call HandlePokedexSideMenu
@@ -71,8 +71,8 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
ld [wd11e],a
ld a,[wd11e]
push af
- ld a,[wWhichTrade]
- push af
+ ld a,[wDexMaxSeenMon]
+ push af ; this doesn't need to be preserved
ld hl,wPokedexSeen
call IsPokemonBitSet
ld b,2
@@ -88,10 +88,11 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
inc hl
ld a,3
ld [hli],a ; max menu item ID
+ ;ld a, A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys (A button and B button)
xor a
ld [hli],a ; old menu item ID
- ld [wcc37],a
+ ld [wMenuWatchMovingOutOfBounds],a
.handleMenuInput
call HandleMenuInput
bit 1,a ; was the B button pressed?
@@ -108,7 +109,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
ld b,1
.exitSideMenu
pop af
- ld [wWhichTrade],a
+ ld [wDexMaxSeenMon],a
pop af
ld [wd11e],a
pop af
@@ -118,17 +119,17 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
pop af
ld [wCurrentMenuItem],a
push bc
- hlCoord 0, 3
+ coord hl, 0, 3
ld de,20
- ld bc,$7f0d ; 13 blank tiles
+ lb bc, " ", 13
call DrawTileLine ; cover up the menu cursor in the pokemon list
pop bc
ret
.buttonBPressed
push bc
- hlCoord 15, 10
+ coord hl, 15, 10
ld de,20
- ld bc,$7f07 ; 7 blank tiles
+ lb bc, " ", 7
call DrawTileLine ; cover up the menu cursor in the side menu
pop bc
jr .exitSideMenu
@@ -139,8 +140,8 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
; play pokemon cry
.choseCry
ld a,[wd11e]
- call GetCryData ; get cry data
- call PlaySound ; play sound
+ call GetCryData
+ call PlaySound
jr .handleMenuInput
.choseArea
predef LoadTownMap_Nest ; display pokemon areas
@@ -153,43 +154,43 @@ HandlePokedexListMenu: ; 40111 (10:4111)
xor a
ld [H_AUTOBGTRANSFERENABLED],a
; draw the horizontal line separating the seen and owned amounts from the menu
- hlCoord 15, 8
+ coord hl, 15, 8
ld a,$7a ; horizontal line tile
ld [hli],a
ld [hli],a
ld [hli],a
ld [hli],a
ld [hli],a
- hlCoord 14, 0
+ coord hl, 14, 0
ld [hl],$71 ; vertical line tile
- hlCoord 14, 1
+ coord hl, 14, 1
call DrawPokedexVerticalLine
- hlCoord 14, 9
+ coord hl, 14, 9
call DrawPokedexVerticalLine
ld hl,wPokedexSeen
ld b,wPokedexSeenEnd - wPokedexSeen
call CountSetBits
- ld de,wd11e
- hlCoord 16, 3
- ld bc,$0103
+ ld de, wNumSetBits
+ coord hl, 16, 3
+ lb bc, 1, 3
call PrintNumber ; print number of seen pokemon
ld hl,wPokedexOwned
ld b,wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld de,wd11e
- hlCoord 16, 6
- ld bc,$0103
+ ld de, wNumSetBits
+ coord hl, 16, 6
+ lb bc, 1, 3
call PrintNumber ; print number of owned pokemon
- hlCoord 16, 2
+ coord hl, 16, 2
ld de,PokedexSeenText
call PlaceString
- hlCoord 16, 5
+ coord hl, 16, 5
ld de,PokedexOwnText
call PlaceString
- hlCoord 1, 1
+ coord hl, 1, 1
ld de,PokedexContentsText
call PlaceString
- hlCoord 16, 10
+ coord hl, 16, 10
ld de,PokedexMenuItemsText
call PlaceString
; find the highest pokedex number among the pokemon the player has seen
@@ -207,18 +208,18 @@ HandlePokedexListMenu: ; 40111 (10:4111)
jr .maxSeenPokemonLoop
.storeMaxSeenPokemon
ld a,b
- ld [wWhichTrade],a ; max seen pokemon
+ ld [wDexMaxSeenMon],a
.loop
xor a
ld [H_AUTOBGTRANSFERENABLED],a
- hlCoord 4, 2
- ld bc,$0e0a
+ coord hl, 4, 2
+ lb bc, 14, 10
call ClearScreenArea
- hlCoord 1, 3
+ coord hl, 1, 3
ld a,[wListScrollOffset]
ld [wd11e],a
ld d,7
- ld a,[wWhichTrade]
+ ld a,[wDexMaxSeenMon]
cp a,7
jr nc,.printPokemonLoop
ld d,a
@@ -233,12 +234,12 @@ HandlePokedexListMenu: ; 40111 (10:4111)
push af
push de
push hl
- ld de,-20
+ ld de,-SCREEN_WIDTH
add hl,de
ld de,wd11e
- ld bc,$8103
+ lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print the pokedex number
- ld de,20
+ ld de,SCREEN_WIDTH
add hl,de
dec hl
push hl
@@ -294,9 +295,9 @@ HandlePokedexListMenu: ; 40111 (10:4111)
bit 7,a ; was Down pressed?
jr z,.checkIfRightPressed
.downPressed ; scroll down one row
- ld a,[wWhichTrade]
+ ld a,[wDexMaxSeenMon]
cp a,7
- jp c,.loop
+ jp c,.loop ; can't if the list is shorter than 7
sub a,7
ld b,a
ld a,[wListScrollOffset]
@@ -309,9 +310,9 @@ HandlePokedexListMenu: ; 40111 (10:4111)
bit 4,a ; was Right pressed?
jr z,.checkIfLeftPressed
.rightPressed ; scroll down 7 rows
- ld a,[wWhichTrade]
+ ld a,[wDexMaxSeenMon]
cp a,7
- jp c,.loop
+ jp c,.loop ; can't if the list is shorter than 7
sub a,6
ld b,a
ld a,[wListScrollOffset]
@@ -377,7 +378,7 @@ IsPokemonBitSet: ; 402c2 (10:42c2)
ld a,[wd11e]
dec a
ld c,a
- ld b,2
+ ld b,FLAG_TEST
predef FlagActionPredef
ld a,c
and a
@@ -395,32 +396,32 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld hl,wd72c
set 1,[hl]
ld a,$33 ; 3/7 volume
- ld [$ff24],a
+ ld [rNR50],a
call GBPalWhiteOut ; zero all palettes
call ClearScreen
ld a,[wd11e] ; pokemon ID
ld [wcf91],a
push af
- ld b,04
- call GoPAL_SET
+ ld b, SET_PAL_POKEDEX
+ call RunPaletteCommand
pop af
ld [wd11e],a
ld a,[hTilesetType]
push af
xor a
ld [hTilesetType],a
- hlCoord 0, 0
+ coord hl, 0, 0
ld de,1
- ld bc,$6414
+ lb bc, $64, SCREEN_WIDTH
call DrawTileLine ; draw top border
- hlCoord 0, 17
- ld b,$6f
+ coord hl, 0, 17
+ ld b, $6f
call DrawTileLine ; draw bottom border
- hlCoord 0, 1
+ coord hl, 0, 1
ld de,20
- ld bc,$6610
+ lb bc, $66, $10
call DrawTileLine ; draw left border
- hlCoord 19, 1
+ coord hl, 19, 1
ld b,$67
call DrawTileLine ; draw right border
ld a,$63 ; upper left corner tile
@@ -431,14 +432,14 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
Coorda 0, 17
ld a,$6e ; lower right corner tile
Coorda 19, 17
- hlCoord 0, 9
+ coord hl, 0, 9
ld de,PokedexDataDividerLine
call PlaceString ; draw horizontal divider line
- hlCoord 9, 6
+ coord hl, 9, 6
ld de,HeightWeightText
call PlaceString
call GetMonName
- hlCoord 9, 2
+ coord hl, 9, 2
call PlaceString
ld hl,PokedexEntryPointers
ld a,[wd11e]
@@ -450,7 +451,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld a,[hli]
ld e,a
ld d,[hl] ; de = address of pokedex entry
- hlCoord 9, 4
+ coord hl, 9, 4
call PlaceString ; print species name
ld h,b
ld l,c
@@ -458,13 +459,13 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld a,[wd11e]
push af
call IndexToPokedex
- hlCoord 2, 8
+ coord hl, 2, 8
ld a, "№"
ld [hli],a
ld a,$f2
ld [hli],a
ld de,wd11e
- ld bc,$8103
+ lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print pokedex number
ld hl,wPokedexOwned
call IsPokemonBitSet
@@ -480,7 +481,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
call Delay3
call GBPalNormal
call GetMonHeader ; load pokemon picture location
- hlCoord 1, 1
+ coord hl, 1, 1
call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture
ld a,[wcf91]
call PlayCry ; play pokemon cry
@@ -493,15 +494,15 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
jp z,.waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description
inc de ; de = address of feet (height)
ld a,[de] ; reads feet, but a is overwritten without being used
- hlCoord 12, 6
- ld bc,$0102
+ coord hl, 12, 6
+ lb bc, 1, 2
call PrintNumber ; print feet (height)
ld a,$60 ; feet symbol tile (one tick)
ld [hl],a
inc de
inc de ; de = address of inches (height)
- hlCoord 15, 6
- ld bc,$8102
+ coord hl, 15, 6
+ lb bc, LEADING_ZEROES | 1, 2
call PrintNumber ; print inches (height)
ld a,$61 ; inches symbol tile (two ticks)
ld [hl],a
@@ -510,25 +511,25 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
inc de
inc de ; de = address of upper byte of weight
push de
-; put weight in big-endian order at $ff8b
- ld hl,$ff8b
- ld a,[hl] ; save existing value of [$ff8b]
+; put weight in big-endian order at hDexWeight
+ ld hl,hDexWeight
+ ld a,[hl] ; save existing value of [hDexWeight]
push af
ld a,[de] ; a = upper byte of weight
- ld [hli],a ; store upper byte of weight in [$ff8b]
- ld a,[hl] ; save existing value of [$ff8c]
+ ld [hli],a ; store upper byte of weight in [hDexWeight]
+ ld a,[hl] ; save existing value of [hDexWeight + 1]
push af
dec de
ld a,[de] ; a = lower byte of weight
- ld [hl],a ; store lower byte of weight in [$ff8c]
- ld de,$ff8b
- hlCoord 11, 8
- ld bc,$0205 ; no leading zeroes, right-aligned, 2 bytes, 5 digits
+ ld [hl],a ; store lower byte of weight in [hDexWeight + 1]
+ ld de,hDexWeight
+ coord hl, 11, 8
+ lb bc, 2, 5 ; 2 bytes, 5 digits
call PrintNumber ; print weight
- hlCoord 14, 8
- ld a,[$ff8c]
+ coord hl, 14, 8
+ ld a,[hDexWeight + 1]
sub a,10
- ld a,[$ff8b]
+ ld a,[hDexWeight]
sbc a,0
jr nc,.next
ld [hl],"0" ; if the weight is less than 10, put a 0 before the decimal point
@@ -538,12 +539,12 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld [hld],a ; make space for the decimal point by moving the last digit forward one tile
ld [hl],$f2 ; decimal point tile
pop af
- ld [$ff8c],a ; restore original value of [$ff8c]
+ ld [hDexWeight + 1],a ; restore original value of [hDexWeight + 1]
pop af
- ld [$ff8b],a ; restore original value of [$ff8b]
+ ld [hDexWeight],a ; restore original value of [hDexWeight]
pop hl
inc hl ; hl = address of pokedex description text
- bcCoord 1, 11
+ coord bc, 1, 11
ld a,2
ld [$fff4],a
call TextCommandProcessor ; print pokedex description text
@@ -552,27 +553,27 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
.waitForButtonPress
call JoypadLowSensitivity
ld a,[hJoy5]
- and a,%00000011 ; A button and B button
+ and a,A_BUTTON | B_BUTTON
jr z,.waitForButtonPress
pop af
ld [hTilesetType],a
call GBPalWhiteOut
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns
call GBPalNormal
ld hl,wd72c
res 1,[hl]
ld a,$77 ; max volume
- ld [$ff24],a
+ ld [rNR50],a
ret
HeightWeightText: ; 40448 (10:4448)
db "HT ?",$60,"??",$61,$4E,"WT ???lb@"
; XXX does anything point to this?
-Unknown_4045D: ; 4045d (10:445d)
- db $54,$50
+PokeText: ; 4045d (10:445d)
+ db "#@"
; horizontal line that divides the pokedex text description from the rest of the data
PokedexDataDividerLine: ; 4045f (10:445f)
diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm
index 0e904200..409f0bdb 100755
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -13,7 +13,7 @@ CeladonPrizeMenu: ; 5271b (14:671b)
xor a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
- ld a,$03
+ ld a,A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys],a
ld a,$03
ld [wMaxMenuItem],a
@@ -21,12 +21,12 @@ CeladonPrizeMenu: ; 5271b (14:671b)
ld [wTopMenuItemY],a
ld a,$01
ld [wTopMenuItemX],a
- call PrintPrizePrice ; 687A
- hlCoord 0, 2
+ call PrintPrizePrice
+ coord hl, 0, 2
ld b,$08
ld c,$10
call TextBoxBorder
- call GetPrizeMenuId ;678E
+ call GetPrizeMenuId
call UpdateSprites
ld hl,WhichPrizeTextPtr
call PrintText
@@ -36,7 +36,7 @@ CeladonPrizeMenu: ; 5271b (14:671b)
ld a,[wCurrentMenuItem]
cp a,$03 ; "NO,THANKS" choice
jr z,.NoChoice
- call HandlePrizeChoice ; 14:68C6
+ call HandlePrizeChoice
.NoChoice
ld hl,wd730
res 6,[hl]
@@ -58,18 +58,18 @@ WhichPrizeTextPtr: ; 52789 (14:6789)
GetPrizeMenuId: ; 5278e (14:678e)
; determine which one among the three
; prize-texts has been selected
-; using the text ID (stored in [$FF8C])
+; using the text ID (stored in [hSpriteIndexOrTextID])
; load the three prizes at wd13d-wd13f
; load the three prices at wd141-wd146
; display the three prizes' names
; (distinguishing between Pokemon names
; and Items (specifically TMs) names)
- ld a,[$FF8C]
- sub a,$03 ; prize-texts' id are 3, 4 and 5
- ld [wd12f],a ; prize-texts' id (relative, i.e. 0, 1 or 2)
+ ld a,[hSpriteIndexOrTextID]
+ sub a,3 ; prize-texts' id are 3, 4 and 5
+ ld [wWhichPrizeWindow],a ; prize-texts' id (relative, i.e. 0, 1 or 2)
add a
add a
- ld d,$00
+ ld d,0
ld e,a
ld hl,PrizeDifferentMenuPtrs
add hl,de
@@ -79,178 +79,184 @@ GetPrizeMenuId: ; 5278e (14:678e)
inc hl
push hl
ld hl,W_PRIZE1
- call CopyString ; XXX what does this do
+ call CopyString
pop hl
ld a,[hli]
ld h,[hl]
ld l,a
- ld de,wd141
- ld bc,$0006
+ ld de,wPrize1Price
+ ld bc,6
call CopyData
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02 ;is TM_menu?
jr nz,.putMonName
ld a,[W_PRIZE1]
ld [wd11e],a
call GetItemName
- hlCoord 2, 4
+ coord hl, 2, 4
call PlaceString
ld a,[W_PRIZE2]
ld [wd11e],a
call GetItemName
- hlCoord 2, 6
+ coord hl, 2, 6
call PlaceString
ld a,[W_PRIZE3]
ld [wd11e],a
call GetItemName
- hlCoord 2, 8
+ coord hl, 2, 8
call PlaceString
jr .putNoThanksText
-.putMonName ; 14:67EC
+.putMonName
ld a,[W_PRIZE1]
ld [wd11e],a
call GetMonName
- hlCoord 2, 4
+ coord hl, 2, 4
call PlaceString
ld a,[W_PRIZE2]
ld [wd11e],a
call GetMonName
- hlCoord 2, 6
+ coord hl, 2, 6
call PlaceString
ld a,[W_PRIZE3]
ld [wd11e],a
call GetMonName
- hlCoord 2, 8
+ coord hl, 2, 8
call PlaceString
-.putNoThanksText ; 14:6819
- hlCoord 2, 10
+.putNoThanksText
+ coord hl, 2, 10
ld de,NoThanksText
call PlaceString
; put prices on the right side of the textbox
- ld de,wd141
- hlCoord 13, 5
+ ld de,wPrize1Price
+ coord hl, 13, 5
; reg. c:
; [low nybble] number of bytes
; [bit 765 = %100] space-padding (not zero-padding)
ld c,(1 << 7 | 2)
; Function $15CD displays BCD value (same routine
; used by text-command $02)
- call PrintBCDNumber ; Print_BCD
- ld de,wd143
- hlCoord 13, 7
+ call PrintBCDNumber
+ ld de,wPrize2Price
+ coord hl, 13, 7
ld c,(%1 << 7 | 2)
call PrintBCDNumber
- ld de,wd145
- hlCoord 13, 9
+ ld de,wPrize3Price
+ coord hl, 13, 9
ld c,(1 << 7 | 2)
jp PrintBCDNumber
INCLUDE "data/prizes.asm"
PrintPrizePrice: ; 5287a (14:687a)
- hlCoord 11, 0
+ coord hl, 11, 0
ld b,$01
ld c,$07
call TextBoxBorder
- call UpdateSprites ; XXX save OAM?
- hlCoord 12, 0
+ call UpdateSprites
+ coord hl, 12, 0
ld de,.CoinText
call PlaceString
- hlCoord 13, 1
+ coord hl, 13, 1
ld de,.SixSpacesText
call PlaceString
- hlCoord 13, 1
+ coord hl, 13, 1
ld de,wPlayerCoins
ld c,%10000010
call PrintBCDNumber
ret
-.CoinText ; 14:68A5
+.CoinText
db "COIN@"
-.SixSpacesText ; 14:68AA
+.SixSpacesText
db " @"
LoadCoinsToSubtract: ; 528b1 (14:68b1)
- ld a,[wd139] ; backup of selected menu_entry
+ ld a,[wWhichPrize]
add a
- ld d,$00
+ ld d,0
ld e,a
- ld hl,wd141 ; first prize's price
+ ld hl,wPrize1Price
add hl,de ; get selected prize's price
xor a
- ld [$FF9F],a
+ ld [hUnusedCoinsByte],a
ld a,[hli]
- ld [$FFA0],a
+ ld [hCoins],a
ld a,[hl]
- ld [$FFA1],a
+ ld [hCoins + 1],a
ret
HandlePrizeChoice: ; 528c6 (14:68c6)
- ld a,[wCurrentMenuItem] ; selected menu_entry
- ld [wd139],a
- ld d,$00
+ ld a,[wCurrentMenuItem]
+ ld [wWhichPrize],a
+ ld d,0
ld e,a
ld hl,W_PRIZE1
add hl,de
ld a,[hl]
ld [wd11e],a
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02 ; is prize a TM?
jr nz,.GetMonName
call GetItemName
jr .GivePrize
-.GetMonName ; 14:68E3
+.GetMonName
call GetMonName
-.GivePrize ; 14:68E6
+.GivePrize
ld hl,SoYouWantPrizeTextPtr
call PrintText
- call YesNoChoice ; yes/no textbox
+ call YesNoChoice
ld a,[wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
and a
jr nz,.PrintOhFineThen
call LoadCoinsToSubtract
call HasEnoughCoins
jr c,.NotEnoughCoins
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02
jr nz,.GiveMon
ld a,[wd11e]
ld b,a
ld a,1
ld c,a
- call GiveItem ; GiveItem
+ call GiveItem
jr nc,.BagFull
jr .SubtractCoins
-.GiveMon ; 14:6912
+.GiveMon
ld a,[wd11e]
ld [wcf91],a
push af
- call GetPrizeMonLevel ; 14:6977
+ call GetPrizeMonLevel
ld c,a
pop af
ld b,a
call GivePokemon
+
+; If either the party or box was full, wait after displaying message.
push af
- ld a,[wccd3] ; XXX is there room?
+ ld a,[wAddedToParty]
and a
call z,WaitForTextScrollButtonPress
pop af
+
+; If the mon couldn't be given to the player (because both the party and box
+; were full), return without subtracting coins.
ret nc
-.SubtractCoins ; 14:692C
+
+.SubtractCoins
call LoadCoinsToSubtract
- ld hl,$FFA1
+ ld hl,hCoins + 1
ld de,wPlayerCoins + 1
ld c,$02 ; how many bytes
- predef SubBCDPredef ; subtract coins (BCD daa operations)
+ predef SubBCDPredef
jp PrintPrizePrice
.BagFull
ld hl,PrizeRoomBagIsFullTextPtr
jp PrintText
-.NotEnoughCoins ; 14:6945
+.NotEnoughCoins
ld hl,SorryNeedMoreCoinsText
jp PrintText
-.PrintOhFineThen ; 14:694B
+.PrintOhFineThen
ld hl,OhFineThenTextPtr
jp PrintText
@@ -286,13 +292,13 @@ GetPrizeMonLevel: ; 52977 (14:6977)
ld a,[wcf91]
ld b,a
ld hl,PrizeMonLevelDictionary
-.loop ; 14:697E
+.loop
ld a,[hli]
cp b
jr z,.matchFound
inc hl
jr .loop
-.matchFound ; 14:6985
+.matchFound
ld a,[hl]
ld [W_CURENEMYLVL],a
ret
diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm
index 3c3b837c..adedc263 100755
--- a/engine/menu/start_menu.asm
+++ b/engine/menu/start_menu.asm
@@ -8,7 +8,7 @@ DisplayStartMenu:: ; 29d1 (0:29d1)
RedisplayStartMenu:: ; 29e1 (0:29e1)
callba DrawStartMenu
callba PrintSafariZoneSteps ; print Safari Zone info, if in Safari Zone
- call UpdateSprites ; move sprites
+ call UpdateSprites
.loop
call HandleMenuInput
ld b,a
@@ -52,7 +52,7 @@ RedisplayStartMenu:: ; 29e1 (0:29e1)
.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 589224ab..ab8c8756 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -12,14 +12,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
jp z,RedisplayStartMenu
xor a
ld [wMenuItemToSwap],a
- ld [wd07d],a
+ ld [wPartyMenuTypeOrMessageID],a
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
jr .checkIfPokemonChosen
.loop
xor a
ld [wMenuItemToSwap],a
- ld [wd07d],a
+ ld [wPartyMenuTypeOrMessageID],a
call GoBackToPartyMenu
.checkIfPokemonChosen
jr nc,.chosePokemon
@@ -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 bc,$020c ; max menu item ID, top menu item Y
+ ld hl,wFieldMoves
+ lb bc, $02, $0c ; 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,14 +50,14 @@ 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
inc hl
ld a,b
ld [hli],a ; max menu item ID
- ld a,%00000011 ; A button, B button
+ ld a,A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys
xor a
ld [hl],a
@@ -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
- ld a,$04 ; swap pokemon positions menu
- ld [wd07d],a
+ 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
@@ -167,9 +167,9 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
jp z,.loop
ld a,SURFBOARD
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
- ld a,[wcd6a]
+ ld a,[wActionResultOrTookBattleTurn]
and a
jp z,.loop
call GBPalWhiteOutWithDelay3
@@ -195,9 +195,9 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
.dig
ld a,ESCAPE_ROPE
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],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
+ ld [wPseudoItemID],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
@@ -285,7 +285,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
; writes a blank tile to all possible menu cursor positions on the party menu
ErasePartyMenuCursors: ; 132ed (4:72ed)
- hlCoord 0, 1
+ coord hl, 0, 1
ld bc,2 * 20 ; menu cursor positions are 2 rows apart
ld a,6 ; 6 menu cursor positions
.loop
@@ -297,7 +297,7 @@ ErasePartyMenuCursors: ; 132ed (4:72ed)
ItemMenuLoop: ; 132fc (4:72fc)
call LoadScreenTilesFromBuffer2DisableBGTransfer ; restore saved screen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
StartMenu_Item: ; 13302 (4:7302)
ld a,[wLinkState]
@@ -308,24 +308,24 @@ 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 [wcf93],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
call LoadTextBoxTilePatterns
- call UpdateSprites ; move sprites
+ call UpdateSprites
jp RedisplayStartMenu
.choseItem
; erase menu cursor (blank each tile in front of an item name)
@@ -354,7 +354,7 @@ StartMenu_Item: ; 13302 (4:7302)
inc hl
inc a ; a = 1
ld [hli],a ; max menu item ID
- ld a,%00000011 ; A button, B button
+ ld a,A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys
xor a
ld [hl],a ; old menu item id
@@ -381,8 +381,8 @@ StartMenu_Item: ; 13302 (4:7302)
ld a,[wCurrentMenuItem]
and a
jr nz,.tossItem
-.useItem
- ld [wd152],a
+; use item
+ ld [wPseudoItemID],a ; a must be 0 due to above conditional jump
ld a,[wcf91]
cp a,HM_01
jr nc,.useItem_partyMenu
@@ -399,9 +399,9 @@ StartMenu_Item: ; 13302 (4:7302)
jp ItemMenuLoop
.useItem_closeMenu
xor a
- ld [wd152],a
+ ld [wPseudoItemID],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
@@ -423,7 +423,7 @@ StartMenu_Item: ; 13302 (4:7302)
jp ItemMenuLoop
.tossItem
call IsKeyItem
- ld a,[wd124]
+ ld a,[wIsKeyItem]
and a
jr nz,.skipAskingQuantity
ld a,[wcf91]
@@ -499,21 +499,21 @@ UsableItems_CloseMenu: ; 13459 (4:7459)
StartMenu_TrainerInfo: ; 13460 (4:7460)
call GBPalWhiteOut
call ClearScreen
- call UpdateSprites ; move sprites
+ call UpdateSprites
ld a,[hTilesetType]
push af
xor a
ld [hTilesetType],a
call DrawTrainerInfo
predef DrawBadges ; draw badges
- ld b,$0d
- call GoPAL_SET
+ ld b, SET_PAL_TRAINER_CARD
+ call RunPaletteCommand
call GBPalNormal
call WaitForTextScrollButtonPress ; wait for button press
call GBPalWhiteOut
call LoadFontTilePatterns
call LoadScreenTilesFromBuffer2 ; restore saved screen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call ReloadMapData
call LoadGBPal
pop af
@@ -523,37 +523,37 @@ StartMenu_TrainerInfo: ; 13460 (4:7460)
; loads tile patterns and draws everything except for gym leader faces / badges
DrawTrainerInfo: ; 1349a (4:749a)
ld de,RedPicFront
- ld bc,(BANK(RedPicFront) << 8) | $01
- predef Predef3B
+ lb bc, BANK(RedPicFront), $01
+ predef DisplayPicCenteredOrUpperRight
call DisableLCD
- hlCoord 0, 2
+ coord hl, 0, 2
ld a," "
call TrainerInfo_DrawVerticalLine
- hlCoord 1, 2
+ coord hl, 1, 2
call TrainerInfo_DrawVerticalLine
ld hl,vChars2 + $70
ld de,vChars2
ld bc,$70 * 4
call CopyData
- ld hl,TrainerInfoTextBoxTileGraphics ; $7b98 ; trainer info text box tile patterns
+ ld hl,TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns
ld de,vChars2 + $770
ld bc,$0080
push bc
call TrainerInfo_FarCopyData
- ld hl,BlankLeaderNames ; $7c28
+ ld hl,BlankLeaderNames
ld de,vChars2 + $600
ld bc,$0170
call TrainerInfo_FarCopyData
pop bc
- ld hl,BadgeNumbersTileGraphics ; $7d98 ; badge number tile patterns
+ ld hl,BadgeNumbersTileGraphics ; badge number tile patterns
ld de,vChars1 + $580
call TrainerInfo_FarCopyData
- ld hl,GymLeaderFaceAndBadgeTileGraphics ; $6a9e ; gym leader face and badge tile patterns
+ ld hl,GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns
ld de,vChars2 + $200
ld bc,$0400
ld a,$03
call FarCopyData2
- ld hl,TextBoxGraphics ; $6288
+ ld hl,TextBoxGraphics
ld de,$00d0
add hl,de ; hl = colon tile pattern
ld de,vChars1 + $560
@@ -562,56 +562,56 @@ DrawTrainerInfo: ; 1349a (4:749a)
push bc
call FarCopyData2
pop bc
- ld hl,TrainerInfoTextBoxTileGraphics + $80 ; $7c18 ; background tile pattern
+ ld hl,TrainerInfoTextBoxTileGraphics + $80 ; background tile pattern
ld de,vChars1 + $570
call TrainerInfo_FarCopyData
call EnableLCD
- ld hl,wWhichTrade
+ ld hl,wTrainerInfoTextBoxWidthPlus1
ld a,18 + 1
ld [hli],a
dec a
ld [hli],a
ld [hl],1
- hlCoord 0, 0
+ coord hl, 0, 0
call TrainerInfo_DrawTextBox
- ld hl,wWhichTrade
+ ld hl,wTrainerInfoTextBoxWidthPlus1
ld a,16 + 1
ld [hli],a
dec a
ld [hli],a
ld [hl],3
- hlCoord 1, 10
+ coord hl, 1, 10
call TrainerInfo_DrawTextBox
- hlCoord 0, 10
+ coord hl, 0, 10
ld a,$d7
call TrainerInfo_DrawVerticalLine
- hlCoord 19, 10
+ coord hl, 19, 10
call TrainerInfo_DrawVerticalLine
- hlCoord 6, 9
+ coord hl, 6, 9
ld de,TrainerInfo_BadgesText
call PlaceString
- hlCoord 2, 2
+ coord hl, 2, 2
ld de,TrainerInfo_NameMoneyTimeText
call PlaceString
- hlCoord 7, 2
+ coord hl, 7, 2
ld de,wPlayerName
call PlaceString
- hlCoord 8, 4
+ coord hl, 8, 4
ld de,wPlayerMoney
ld c,$e3
call PrintBCDNumber
- hlCoord 9, 6
+ coord hl, 9, 6
ld de,W_PLAYTIMEHOURS + 1 ; hours
- ld bc,$4103
+ lb bc, LEFT_ALIGN | 1, 3
call PrintNumber
ld [hl],$d6 ; colon tile ID
inc hl
ld de,W_PLAYTIMEMINUTES + 1 ; minutes
- ld bc,$8102
+ lb bc, LEADING_ZEROES | 1, 2
jp PrintNumber
TrainerInfo_FarCopyData: ; 1357f (4:757f)
- ld a,$0b
+ ld a,BANK(TrainerInfoTextBoxTileGraphics)
jp FarCopyData2
TrainerInfo_NameMoneyTimeText: ; 13584 (4:7584)
@@ -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
+ lb de, $7a, $7b ; 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
@@ -647,11 +647,11 @@ TrainerInfo_DrawTextBox: ; 135a0 (4:75a0)
dec c
jr nz,.loop
ld a,$7d ; lower left corner tile ID
- ld de,$777e ; bottom edge and lower right corner tile ID's
+ lb de,$77, $7e ; bottom edge and lower right corner tile ID's
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] ; wWhichTrade
- call SwitchPartyMon_OAM
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
- call SwitchPartyMon_OAM
+ call SwitchPartyMon_InitVarOrSwapData ; swap data
+ ld a, [wSwappedMenuItem]
+ call SwitchPartyMon_ClearGfx
+ ld a, [wCurrentMenuItem]
+ call SwitchPartyMon_ClearGfx
jp RedrawPartyMenu_
-SwitchPartyMon_OAM: ; 13625 (4:7625)
+SwitchPartyMon_ClearGfx: ; 13625 (4:7625)
push af
- ld hl, wTileMap
- ld bc, $28
+ coord hl, 0, 0
+ ld bc, SCREEN_WIDTH * 2
call AddNTimes
- ld c, $28
- ld a, $7f
-.asm_13633
+ ld c, SCREEN_WIDTH * 2
+ ld a, " "
+.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
+ ld a, SFX_SWAP
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
- ld a, [wWhichPokemon] ; wWhichPokemon
- inc a
+ 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 ; [wMenuItemToSwap] counts from 1
ld [wMenuItemToSwap], a
ret
-.asm_13661
+.pickedMonsToSwap
xor a
- ld [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
ld a, [wMenuItemToSwap]
dec a
ld b, a
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
- ld [wWhichTrade], a ; wWhichTrade
- cp b
- jr nz, .asm_1367b
+ ld a, [wCurrentMenuItem]
+ 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 [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
ret
-.asm_1367b
+.swappingDifferentMons
ld a, b
ld [wMenuItemToSwap], a
push hl
@@ -767,85 +770,85 @@ SwitchPartyMon_Stats: ; 13653 (4:7653)
ld hl, wPartySpecies
ld d, h
ld e, l
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ 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 ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+ ld [hSwapTemp], a
ld a, [de]
ld [hl], a
- ld a, [H_DIVIDEND] ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+ ld a, [hSwapTemp]
ld [de], a
ld hl, wPartyMons
ld bc, wPartyMon2 - wPartyMon1
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld a, [wCurrentMenuItem]
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 ; wd273
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld hl, wPartyMonOT
+ ld a, [wCurrentMenuItem]
call SkipFixedLengthTextEntries
push hl
ld de, wSwitchPartyMonTempBuffer
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
- ld hl, wPartyMonOT ; wd273
+ ld hl, wPartyMonOT
ld a, [wMenuItemToSwap]
call SkipFixedLengthTextEntries
pop de
push hl
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
pop de
ld hl, wSwitchPartyMonTempBuffer
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
- ld hl, wPartyMonNicks ; wPartyMonNicks
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld hl, wPartyMonNicks
+ ld a, [wCurrentMenuItem]
call SkipFixedLengthTextEntries
push hl
ld de, wSwitchPartyMonTempBuffer
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
- ld hl, wPartyMonNicks ; wPartyMonNicks
+ ld hl, wPartyMonNicks
ld a, [wMenuItemToSwap]
call SkipFixedLengthTextEntries
pop de
push hl
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
pop de
ld hl, wSwitchPartyMonTempBuffer
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wMenuItemToSwap]
- ld [wWhichTrade], a ; wWhichTrade
+ ld [wSwappedMenuItem], a
xor a
ld [wMenuItemToSwap], a
- ld [wd07d], a
+ ld [wPartyMenuTypeOrMessageID], a
pop de
pop hl
ret
diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm
index b5254694..c91d5eda 100755
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -50,12 +50,12 @@ DrawHP_: ; 128fb (4:68fb)
.printFraction
add hl, bc
ld de, wLoadedMonHP
- ld bc, $203
+ lb bc, 2, 3
call PrintNumber
ld a, "/"
ld [hli], a
ld de, wLoadedMonMaxHP
- ld bc, $203
+ lb bc, 2, 3
call PrintNumber
pop hl
pop de
@@ -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
- jr c, .DontRecalculate ; 0x1295b $14
+ 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
@@ -79,95 +80,95 @@ StatusScreen: ; 12953 (4:6953)
ld hl, wd72c
set 1, [hl]
ld a, $33
- ld [$ff24], a ; Reduce the volume
+ ld [rNR50], a ; Reduce the volume
call GBPalWhiteOutWithDelay3
call ClearScreen
- call UpdateSprites ; move sprites (?)
+ call UpdateSprites
call LoadHpBarAndStatusTilePatterns
- ld de, BattleHudTiles1 ; $6080 ; source
+ ld de, BattleHudTiles1 ; source
ld hl, vChars2 + $6d0 ; dest
- ld bc, (BANK(BattleHudTiles1) << 8) + $03 ; bank bytes/8
+ lb bc, BANK(BattleHudTiles1), $03
call CopyVideoDataDouble ; ·│ :L and halfarrow line end
- ld de, BattleHudTiles2 ; $6098
+ ld de, BattleHudTiles2
ld hl, vChars2 + $780
- ld bc, (BANK(BattleHudTiles2) << 8) + $01
+ lb bc, BANK(BattleHudTiles2), $01
call CopyVideoDataDouble ; │
- ld de, BattleHudTiles3 ; $60b0
+ ld de, BattleHudTiles3
ld hl, vChars2 + $760
- ld bc, (BANK(BattleHudTiles3) << 8) + $02
+ lb bc, BANK(BattleHudTiles3), $02
call CopyVideoDataDouble ; ─┘
ld de, PTile
ld hl, vChars2 + $720
- ld bc,(BANK(PTile) << 8 | $01)
+ lb bc, BANK(PTile), (PTileEnd - PTile) / $8
call CopyVideoDataDouble ; P (for PP), inline
ld a, [hTilesetType]
push af
xor a
ld [hTilesetType], a
- hlCoord 19, 1
- ld bc, $060a
+ coord hl, 19, 1
+ lb bc, 6, 10
call DrawLineBox ; Draws the box around name, HP and status
- ld de, $fffa
+ ld de, -6
add hl, de
ld [hl], $f2 ; . after No ("." is a different one)
dec hl
ld [hl], "№"
- hlCoord 19, 9
- ld bc, $0806
+ coord hl, 19, 9
+ lb bc, 8, 6
call DrawLineBox ; Draws the box around types, ID No. and OT
- hlCoord 10, 9
+ coord hl, 10, 9
ld de, Type1Text
call PlaceString ; "TYPE1/"
- hlCoord 11, 3
+ coord hl, 11, 3
predef DrawHP
- ld hl, wcf25
+ ld hl, wStatusScreenHPBarColor
call GetHealthBarColor
- ld b, $3
- call GoPAL_SET ; SGB palette
- hlCoord 16, 6
+ ld b, SET_PAL_STATUS_SCREEN
+ call RunPaletteCommand
+ coord hl, 16, 6
ld de, wLoadedMonStatus
call PrintStatusCondition
- jr nz, .StatusWritten ; 0x129fc $9
- hlCoord 16, 6
+ jr nz, .StatusWritten
+ coord hl, 16, 6
ld de, OKText
call PlaceString ; "OK"
.StatusWritten
- hlCoord 9, 6
+ coord hl, 9, 6
ld de, StatusText
call PlaceString ; "STATUS/"
- hlCoord 14, 2
+ coord hl, 14, 2
call PrintLevel ; Pokémon level
- ld a, [W_MONHDEXNUM]
+ ld a, [W_MONHINDEX]
ld [wd11e], a
ld [wd0b5], a
predef IndexToPokedex
- hlCoord 3, 7
+ coord hl, 3, 7
ld de, wd11e
- ld bc, $8103 ; Zero-padded, 3
+ lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; Pokémon no.
- hlCoord 11, 10
+ coord hl, 11, 10
predef PrintMonType
- ld hl, NamePointers2 ; $6a9d
- call .unk_12a7e
+ ld hl, NamePointers2
+ call .GetStringPointer
ld d, h
ld e, l
- hlCoord 9, 1
+ coord hl, 9, 1
call PlaceString ; Pokémon name
- ld hl, OTPointers ; $6a95
- call .unk_12a7e
+ ld hl, OTPointers
+ call .GetStringPointer
ld d, h
ld e, l
- hlCoord 12, 16
+ coord hl, 12, 16
call PlaceString ; OT
- hlCoord 12, 14
+ coord hl, 12, 14
ld de, wLoadedMonOTID
- ld bc, $8205 ; 5
+ lb bc, LEADING_ZEROES | 2, 5
call PrintNumber ; ID Number
ld d, $0
call PrintStatsBox
call Delay3
call GBPalNormal
- hlCoord 1, 0
+ coord hl, 1, 0
call LoadFlippedFrontSpriteByMonIndex ; draw Pokémon picture
ld a, [wcf91]
call PlayCry ; play Pokémon cry
@@ -175,17 +176,18 @@ StatusScreen: ; 12953 (4:6953)
pop af
ld [hTilesetType], a
ret
-.unk_12a7e ; 0x12a7e ; 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
@@ -221,43 +223,44 @@ OKText: ; 12ac4 (4:6ac4)
db "OK@"
; Draws a line starting from hl high b and wide c
-DrawLineBox ; 0x12ac7
- ld de, $0014 ; New line
+DrawLineBox: ; 0x12ac7
+ ld de, SCREEN_WIDTH ; New line
.PrintVerticalLine
ld [hl], $78 ; │
add hl, de
dec b
- jr nz, .PrintVerticalLine ; 0x12ace $fa
+ jr nz, .PrintVerticalLine
ld [hl], $77 ; ┘
dec hl
.PrintHorizLine
ld [hl], $76 ; ─
dec hl
dec c
- jr nz, .PrintHorizLine ; 0x12ad7 $fa
+ jr nz, .PrintHorizLine
ld [hl], $6f ; ← (halfarrow ending)
ret
PTile: ; 12adc (4:6adc) ; This is a single 1bpp "P" tile
INCBIN "gfx/p_tile.1bpp"
+PTileEnd:
PrintStatsBox: ; 12ae4 (4:6ae4)
ld a, d
and a ; a is 0 from the status screen
- jr nz, .DifferentBox ; 0x12ae6 $12
- hlCoord 0, 8
+ jr nz, .DifferentBox
+ coord hl, 0, 8
ld b, $8
ld c, $8
call TextBoxBorder ; Draws the box
- hlCoord 1, 9 ; Start printing stats from here
+ coord hl, 1, 9 ; Start printing stats from here
ld bc, $0019 ; Number offset
- jr .PrintStats ; 0x12af8 $10
+ jr .PrintStats
.DifferentBox
- hlCoord 9, 2
+ coord hl, 9, 2
ld b, $8
ld c, $9
call TextBoxBorder
- hlCoord 11, 3
+ coord hl, 11, 3
ld bc, $0018
.PrintStats
push bc
@@ -268,7 +271,7 @@ PrintStatsBox: ; 12ae4 (4:6ae4)
pop bc
add hl, bc
ld de, wLoadedMonAttack
- ld bc, $0203 ; three digits
+ lb bc, 2, 3
call PrintStat
ld de, wLoadedMonDefense
call PrintStat
@@ -280,7 +283,7 @@ PrintStat
push hl
call PrintNumber
pop hl
- ld de, $0028
+ ld de, SCREEN_WIDTH * 2
add hl, de
ret
@@ -295,8 +298,8 @@ StatusScreen2: ; 12b57 (4:6b57)
push af
xor a
ld [hTilesetType], a
- ld [$ffba], a
- ld bc, $0005
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld bc, NUM_MOVES + 1
ld hl, wMoves
call FillMemory
ld hl, wLoadedMonMoves
@@ -304,42 +307,42 @@ StatusScreen2: ; 12b57 (4:6b57)
ld bc, NUM_MOVES
call CopyData
callab FormatMovesString
- hlCoord 9, 2
- ld bc, $050a
+ coord hl, 9, 2
+ lb bc, 5, 10
call ClearScreenArea ; Clear under name
- hlCoord 19, 3
+ coord hl, 19, 3
ld [hl], $78
- hlCoord 0, 8
- ld b, $8
- ld c, $12
+ coord hl, 0, 8
+ ld b, 8
+ ld c, 18
call TextBoxBorder ; Draw move container
- hlCoord 2, 9
+ coord hl, 2, 9
ld de, wMovesString
call PlaceString ; Print moves
- ld a, [wcd6c]
+ ld a, [wNumMovesMinusOne]
inc a
ld c, a
ld a, $4
sub c
ld b, a ; Number of moves ?
- hlCoord 11, 10
- ld de, $0028
- ld a, $72
- call Func_12ccb ; Print "PP"
+ coord hl, 11, 10
+ ld de, SCREEN_WIDTH * 2
+ ld a, $72 ; special P tile id
+ call StatusScreen_PrintPP ; Print "PP"
ld a, b
and a
- jr z, .InitPP ; 0x12bb3 $6
+ jr z, .InitPP
ld c, a
ld a, "-"
- call Func_12ccb ; Fill the rest with --
+ call StatusScreen_PrintPP ; Fill the rest with --
.InitPP ; 12bbb
ld hl, wLoadedMonMoves
- deCoord 14, 10
- ld b, $0
+ coord de, 14, 10
+ ld b, 0
.PrintPP ; 12bc3
ld a, [hli]
and a
- jr z, .PPDone ; 0x12bc5 $4a
+ jr z, .PPDone
push bc
push hl
push de
@@ -356,24 +359,24 @@ 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 bc, $0102
+ ld de, wStatusScreenCurrentPP
+ lb bc, 1, 2
call PrintNumber
ld a, "/"
ld [hli], a
- ld de, wd11e
- ld bc, $0102
+ ld de, wMaxPP
+ lb bc, 1, 2
call PrintNumber
pop hl
- ld de, $0028
+ ld de, SCREEN_WIDTH * 2
add hl, de
ld d, h
ld e, l
@@ -382,19 +385,19 @@ StatusScreen2: ; 12b57 (4:6b57)
inc b
ld a, b
cp $4
- jr nz, .PrintPP ; 0x12c0f $b2
+ jr nz, .PrintPP
.PPDone
- hlCoord 9, 3
- ld de, EXPPointsText
+ coord hl, 9, 3
+ ld de, StatusScreenExpText
call PlaceString
- ld a, [wLoadedMonLevel] ; level
+ ld a, [wLoadedMonLevel]
push af
cp MAX_LEVEL
- jr z, .Level100 ; 0x12c20 $4
+ jr z, .Level100
inc a
ld [wLoadedMonLevel], a ; Increase temporarily if not 100
.Level100
- hlCoord 14, 6
+ coord hl, 14, 6
ld [hl], $70 ; 1-tile "to"
inc hl
inc hl
@@ -402,25 +405,25 @@ StatusScreen2: ; 12b57 (4:6b57)
pop af
ld [wLoadedMonLevel], a
ld de, wLoadedMonExp
- hlCoord 12, 4
- ld bc, $0307
+ coord hl, 12, 4
+ lb bc, 3, 7
call PrintNumber ; exp
- call .asm_12c86
+ call CalcExpToLevelUp
ld de, wLoadedMonExp
- hlCoord 7, 6
- ld bc, $0307
- call PrintNumber
- hlCoord 9, 0
- call Func_12cc3
- hlCoord 9, 1
- call Func_12cc3
- ld a, [W_MONHDEXNUM]
+ coord hl, 7, 6
+ lb bc, 3, 7
+ call PrintNumber ; exp needed to level up
+ coord hl, 9, 0
+ call StatusScreen_ClearName
+ coord hl, 9, 1
+ call StatusScreen_ClearName
+ ld a, [W_MONHINDEX]
ld [wd11e], a
call GetMonName
- hlCoord 9, 1
+ coord hl, 9, 1
call PlaceString
ld a, $1
- ld [$ffba], a
+ ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
@@ -428,28 +431,29 @@ StatusScreen2: ; 12b57 (4:6b57)
ld hl, wd72c
res 1, [hl]
ld a, $77
- ld [$ff24], a
+ ld [rNR50], a
call GBPalWhiteOut
jp ClearScreen
-.asm_12c86 ; This does some magic with lvl/exp?
- ld a, [wLoadedMonLevel] ; Load level
+
+CalcExpToLevelUp: ; 12c86 (4:6c86)
+ ld a, [wLoadedMonLevel]
cp MAX_LEVEL
- jr z, .asm_12ca7 ; 0x12c8b $1a ; If 100
+ jr z, .atMaxLevel
inc a
ld d, a
callab CalcExperience
ld hl, wLoadedMonExp + 2
- ld a, [$ff98]
+ ld a, [hExperience + 2]
sub [hl]
ld [hld], a
- ld a, [$ff97]
+ ld a, [hExperience + 1]
sbc [hl]
ld [hld], a
- ld a, [$ff96]
+ ld a, [hExperience]
sbc [hl]
ld [hld], a
ret
-.asm_12ca7
+.atMaxLevel
ld hl, wLoadedMonExp
xor a
ld [hli], a
@@ -457,21 +461,20 @@ StatusScreen2: ; 12b57 (4:6b57)
ld [hl], a
ret
-EXPPointsText: ; 12caf (4:6caf)
- db "EXP POINTS", $4e
-
-LevelUpText: ; 12cba (4:6cba)
- db "LEVEL UP@"
+StatusScreenExpText: ; 12caf (4:6caf)
+ db "EXP POINTS"
+ next "LEVEL UP@"
-Func_12cc3: ; 12cc3 (4:6cc3)
- ld bc, $a
- ld a, $7f
+StatusScreen_ClearName: ; 12cc3 (4:6cc3)
+ ld bc, 10
+ ld a, " "
jp FillMemory
-Func_12ccb: ; 12ccb (4:6ccb)
+StatusScreen_PrintPP: ; 12ccb (4:6ccb)
+; print PP or -- c times, going down two rows each time
ld [hli], a
ld [hld], a
add hl, de
dec c
- jr nz, Func_12ccb
+ jr nz, StatusScreen_PrintPP
ret
diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm
index 88cfcf65..8460889f 100755
--- a/engine/menu/vending_machine.asm
+++ b/engine/menu/vending_machine.asm
@@ -7,65 +7,66 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
xor a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
- ld a, $3
+ ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
- ld a, $3
+ ld a, 3
ld [wMaxMenuItem], a
- ld a, $5
+ ld a, 5
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
ld hl, wd730
set 6, [hl]
- hlCoord 0, 3
- ld b, $8
- ld c, $c
+ coord hl, 0, 3
+ ld b, 8
+ ld c, 12
call TextBoxBorder
call UpdateSprites
- hlCoord 2, 5
+ coord hl, 2, 5
ld de, DrinkText
call PlaceString
- hlCoord 9, 6
+ coord hl, 9, 6
ld de, DrinkPriceText
call PlaceString
ld hl, wd730
res 6, [hl]
call HandleMenuInput
- bit 1, a
- jr nz, .asm_74f93
+ bit 1, a ; pressed B?
+ jr nz, .notThirsty
ld a, [wCurrentMenuItem]
- cp $3
- jr z, .asm_74f93
+ cp 3 ; chose Cancel?
+ jr z, .notThirsty
xor a
- ld [$ff9f], a
- ld [$ffa1], a
+ ld [hMoney], a
+ ld [hMoney + 2], a
ld a, $2
- ld [$ffa0], a
+ ld [hMoney + 1], a
call HasEnoughMoney
jr nc, .enoughMoney
ld hl, VendingMachineText4
jp PrintText
.enoughMoney
- call Func_74fe7
- ld a, [$ffdb]
+ call LoadVendingMachineItem
+ ld a, [hVendingMachineItem]
ld b, a
ld c, 1
call GiveItem
jr nc, .BagFull
- ld b, $3c ; number of times to play the "brrrrr" sound
-.playDeliverySound ; 0x74f63
- ld c, $2
+
+ ld b, 60 ; number of times to play the "brrrrr" sound
+.playDeliverySound
+ ld c, 2
call DelayFrames
push bc
- ld a, (SFX_02_53 - SFX_Headers_02) / 3
+ ld a, SFX_PUSH_BOULDER
call PlaySound
pop bc
dec b
jr nz, .playDeliverySound
-.asm_74f72
+
ld hl, VendingMachineText5
call PrintText
- ld hl, $ffde
+ ld hl, hVendingMachinePrice + 2
ld de, wPlayerMoney + 2
ld c, $3
predef SubBCDPredef
@@ -75,7 +76,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
.BagFull
ld hl, VendingMachineText6
jp PrintText
-.asm_74f93
+.notThirsty
ld hl, VendingMachineText7
jp PrintText
@@ -110,22 +111,22 @@ VendingMachineText7: ; 74fe2 (1d:4fe2)
TX_FAR _VendingMachineText7
db "@"
-Func_74fe7: ; 74fe7 (1d:4fe7)
+LoadVendingMachineItem: ; 74fe7 (1d:4fe7)
ld hl, VendingPrices
ld a, [wCurrentMenuItem]
add a
add a
- ld d, $0
+ ld d, 0
ld e, a
add hl, de
ld a, [hli]
- ld [$ffdb], a
+ ld [hVendingMachineItem], a
ld a, [hli]
- ld [$ffdc], a
+ ld [hVendingMachinePrice], a
ld a, [hli]
- ld [$ffdd], a
+ ld [hVendingMachinePrice + 1], a
ld a, [hl]
- ld [$ffde], a
+ ld [hVendingMachinePrice + 2], a
ret
VendingPrices: ; 75000 (1d:5000)