summaryrefslogtreecommitdiff
path: root/engine/menu
diff options
context:
space:
mode:
Diffstat (limited to 'engine/menu')
-rw-r--r--engine/menu/bills_pc.asm121
-rwxr-xr-xengine/menu/diploma.asm113
-rw-r--r--engine/menu/diploma_1.asm17
-rwxr-xr-xengine/menu/league_pc.asm7
-rw-r--r--engine/menu/link_menu.asm910
-rwxr-xr-xengine/menu/main_menu.asm451
-rwxr-xr-xengine/menu/naming_screen.asm42
-rwxr-xr-xengine/menu/oaks_pc.asm4
-rw-r--r--engine/menu/options.asm443
-rwxr-xr-xengine/menu/party_menu.asm24
-rwxr-xr-xengine/menu/pc.asm12
-rwxr-xr-xengine/menu/players_pc.asm7
-rwxr-xr-xengine/menu/pokedex.asm787
-rwxr-xr-xengine/menu/prize_menu.asm197
-rwxr-xr-xengine/menu/start_menu.asm95
-rwxr-xr-xengine/menu/start_sub_menus.asm57
-rwxr-xr-xengine/menu/status_screen.asm38
-rw-r--r--engine/menu/swap_items.asm149
-rw-r--r--engine/menu/text_ids1.asm163
-rw-r--r--engine/menu/text_ids2.asm733
-rwxr-xr-xengine/menu/vending_machine.asm12
21 files changed, 3236 insertions, 1146 deletions
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index 384ab485..57699b8f 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -11,18 +11,15 @@ DisplayPCMainMenu::
and a
jr nz, .leaguePCAvailable
coord hl, 0, 0
- ld b, 8
- ld c, 14
+ lb bc, 8, 14
jr .next
.noOaksPC
coord hl, 0, 0
- ld b, 6
- ld c, 14
+ lb bc, 6, 14
jr .next
.leaguePCAvailable
coord hl, 0, 0
- ld b, 10
- ld c, 14
+ lb bc, 10, 14
.next
call TextBoxBorder
call UpdateSprites
@@ -92,7 +89,7 @@ OaksPCText: db "PROF.OAK's PC@"
PKMNLeaguePCText: db $4a, "LEAGUE@"
LogOffPCText: db "LOG OFF@"
-BillsPC_:: ; 0x214c2
+BillsPC_::
ld hl, wd730
set 6, [hl]
xor a
@@ -119,10 +116,13 @@ BillsPCMenu:
lb bc, BANK(PokeballTileGraphics), $01
call CopyVideoData
call LoadScreenTilesFromBuffer2DisableBGTransfer
+ coord hl, 0, 12
+ lb bc, 4, 18
+ call TextBoxBorder
coord hl, 0, 0
- ld b, 10
- ld c, 12
+ lb bc, 12, 12
call TextBoxBorder
+ call UpdateSprites
coord hl, 2, 2
ld de, BillsPCMenuText
call PlaceString
@@ -133,7 +133,7 @@ BillsPCMenu:
ld [hli], a ; wTopMenuItemX
inc hl
inc hl
- ld a, 4
+ ld a, 5
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
@@ -144,11 +144,8 @@ BillsPCMenu:
ld [hli], a ; wListScrollOffset
ld [hl], a ; wMenuWatchMovingOutOfBounds
ld [wPlayerMonNumber], a
- ld hl, WhatText
- call PrintText
coord hl, 9, 14
- ld b, 2
- ld c, 9
+ lb bc, 2, 9
call TextBoxBorder
ld a, [wCurrentBoxNum]
and $7f
@@ -184,6 +181,8 @@ BillsPCMenu:
jp z, BillsPCRelease ; release
cp $3
jp z, BillsPCChangeBox ; change box
+ cp $4
+ jp z, BillsPCPrintBox
ExitBillsPC:
ld a, [wFlags_0xcd60]
@@ -204,6 +203,10 @@ ExitBillsPC:
res 6, [hl]
ret
+BillsPCPrintBox:
+ callab PrintPCBox
+ jp BillsPCMenu
+
BillsPCDeposit:
ld a, [wPartyCount]
dec a
@@ -222,11 +225,26 @@ BillsPCDeposit:
ld hl, wPartyCount
call DisplayMonListMenu
jp c, BillsPCMenu
+ callab IsThisPartymonStarterPikachu_Party
+ jr nc, .asm_215ad
+ call CheckPikachuFollowingPlayer
+ jr z, .asm_215ad
+ ld hl, SleepingPikachuText2
+ call PrintText
+ jp BillsPCMenu
+.asm_215ad
call DisplayDepositWithdrawMenu
jp nc, BillsPCMenu
+ callab IsThisPartymonStarterPikachu_Party
+ jr nc, .asm_215c9
+ ld e, $1b
+ callab PlayPikachuSoundClip
+ jr .asm_215cf
+.asm_215c9
ld a, [wcf91]
- call GetCryData
- call PlaySoundWaitForCurrent
+ call PlayCry
+.asm_215cf
+ callabd_ModifyPikachuHappiness PIKAHAPPY_DEPOSITED
ld a, PARTY_TO_BOX
ld [wMoveMonType], a
call MoveMon
@@ -236,7 +254,7 @@ BillsPCDeposit:
call WaitForSoundToFinish
ld hl, wBoxNumString
ld a, [wCurrentBoxNum]
- and $7f
+ and " "
cp 9
jr c, .singleDigitBoxNum
sub 9
@@ -248,11 +266,15 @@ BillsPCDeposit:
add "1"
.next
ld [hli], a
- ld [hl], $50
+ ld [hl], "@"
ld hl, MonWasStoredText
call PrintText
jp BillsPCMenu
+SleepingPikachuText2:
+ TX_FAR _SleepingPikachuText2
+ db "@"
+
BillsPCWithdraw:
ld a, [wNumInBox]
and a
@@ -276,9 +298,15 @@ BillsPCWithdraw:
ld a, [wWhichPokemon]
ld hl, wBoxMonNicks
call GetPartyMonName
+ callab IsThisPartymonStarterPikachu_Box
+ jr nc, .asm_21660
+ ld e, $22
+ callab PlayPikachuSoundClip
+ jr .asm_21666
+.asm_21660
ld a, [wcf91]
- call GetCryData
- call PlaySoundWaitForCurrent
+ call PlayCry
+.asm_21666
xor a ; BOX_TO_PARTY
ld [wMoveMonType], a
call MoveMon
@@ -301,6 +329,8 @@ BillsPCRelease:
ld hl, wNumInBox
call DisplayMonListMenu
jp c, BillsPCMenu
+ callab IsThisPartymonStarterPikachu_Box
+ jr c, .asm_216cb
ld hl, OnceReleasedText
call PrintText
call YesNoChoice
@@ -317,6 +347,16 @@ BillsPCRelease:
call PrintText
jp BillsPCMenu
+.asm_216cb
+ ld a, [wWhichPokemon]
+ ld hl, wBoxMonNicks
+ call GetPartyMonName
+ ld e, $27
+ callab PlayPikachuSoundClip
+ ld hl, PikachuUnhappyText
+ call PrintText
+ jp BillsPCMenu
+
BillsPCChangeBox:
callba ChangeBox
jp BillsPCMenu
@@ -343,6 +383,7 @@ BillsPCMenuText:
next "DEPOSIT ", $4a
next "RELEASE ", $4a
next "CHANGE BOX"
+ next "PRINT BOX"
next "SEE YA!"
db "@"
@@ -382,12 +423,11 @@ HMMoveArray:
db SURF
db STRENGTH
db FLASH
- db -1
+ db $ff
DisplayDepositWithdrawMenu:
coord hl, 9, 10
- ld b, 6
- ld c, 9
+ lb bc, 6, 9
call TextBoxBorder
ld a, [wParentMenuItem]
and a ; was the Deposit or Withdraw item selected in the parent menu?
@@ -457,51 +497,55 @@ StatsCancelPCText:
db "STATS"
next "CANCEL@"
-SwitchOnText: ; 0x217e9
+SwitchOnText:
TX_FAR _SwitchOnText
db "@"
-WhatText: ; 0x217ee
+WhatText:
TX_FAR _WhatText
db "@"
-DepositWhichMonText: ; 0x217f3
+DepositWhichMonText:
TX_FAR _DepositWhichMonText
db "@"
-MonWasStoredText: ; 0x217f8
+MonWasStoredText:
TX_FAR _MonWasStoredText
db "@"
-CantDepositLastMonText: ; 0x217fd
+CantDepositLastMonText:
TX_FAR _CantDepositLastMonText
db "@"
-BoxFullText: ; 0x21802
+BoxFullText:
TX_FAR _BoxFullText
db "@"
-MonIsTakenOutText: ; 0x21807
+MonIsTakenOutText:
TX_FAR _MonIsTakenOutText
db "@"
-NoMonText: ; 0x2180c
+NoMonText:
TX_FAR _NoMonText
db "@"
-CantTakeMonText: ; 0x21811
+CantTakeMonText:
TX_FAR _CantTakeMonText
db "@"
-ReleaseWhichMonText: ; 0x21816
+PikachuUnhappyText:
+ TX_FAR _PikachuUnhappyText
+ db "@"
+
+ReleaseWhichMonText:
TX_FAR _ReleaseWhichMonText
db "@"
-OnceReleasedText: ; 0x2181b
+OnceReleasedText:
TX_FAR _OnceReleasedText
db "@"
-MonWasReleasedText: ; 0x21820
+MonWasReleasedText:
TX_FAR _MonWasReleasedText
db "@"
@@ -509,7 +553,7 @@ CableClubLeftGameboy::
ld a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
ret z
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_RIGHT
ret nz
ld a, [wCurMap]
@@ -526,7 +570,7 @@ CableClubRightGameboy::
ld a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
ret z
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_LEFT
ret nz
ld a, [wCurMap]
@@ -543,7 +587,7 @@ JustAMomentText::
TX_FAR _JustAMomentText
db "@"
- ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
@@ -551,4 +595,3 @@ JustAMomentText::
OpenBillsPCText::
db $FD ; FuncTX_BillsPC
-
diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm
deleted file mode 100755
index 09ba123e..00000000
--- a/engine/menu/diploma.asm
+++ /dev/null
@@ -1,113 +0,0 @@
-DisplayDiploma:
- call SaveScreenTilesToBuffer2
- call GBPalWhiteOutWithDelay3
- call ClearScreen
- xor a
- ld [wUpdateSpritesEnabled], a
- ld hl, wd730
- set 6, [hl]
- call DisableLCD
- ld hl, CircleTile
- ld de, vChars2 + $700
- ld bc, $0010
- ld a, BANK(CircleTile)
- call FarCopyData2
- coord hl, 0, 0
- lb bc, 16, 18
- predef Diploma_TextBoxBorder
- ld hl, DiplomaTextPointersAndCoords
- ld c, $5
-.asm_56715
- push bc
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
- push hl
- ld h, [hl]
- ld l, a
- call PlaceString
- pop hl
- inc hl
- pop bc
- dec c
- jr nz, .asm_56715
- coord hl, 10, 4
- ld de, wPlayerName
- call PlaceString
- callba DrawPlayerCharacter
-
-; Move the player 33 pixels right and set the priority bit so he appears
-; behind the background layer.
- ld hl, wOAMBuffer + $01
- lb bc, $80, $28
-.adjustPlayerGfxLoop
- ld a, [hl] ; X
- add 33
- ld [hli], a
- inc hl
- ld a, b
- ld [hli], a ; attributes
- inc hl
- dec c
- jr nz, .adjustPlayerGfxLoop
-
- call EnableLCD
- callba LoadTrainerInfoTextBoxTiles
- ld b, SET_PAL_GENERIC
- call RunPaletteCommand
- call Delay3
- call GBPalNormal
- ld a, $90
- ld [rOBP0], a
- call WaitForTextScrollButtonPress
- ld hl, wd730
- res 6, [hl]
- call GBPalWhiteOutWithDelay3
- call RestoreScreenTilesAndReloadTilePatterns
- call Delay3
- jp GBPalNormal
-
-UnusedPlayerNameLengthFunc:
-; Unused function that does a calculation involving the length of the player's
-; name.
- ld hl, wPlayerName
- ld bc, $ff00
-.loop
- ld a, [hli]
- cp "@"
- ret z
- dec c
- jr .loop
-
-DiplomaTextPointersAndCoords:
- dw DiplomaText
- dwCoord 5, 2
- dw DiplomaPlayer
- dwCoord 3, 4
- dw DiplomaEmptyText
- dwCoord 15, 4
- dw DiplomaCongrats
- dwCoord 2, 6
- dw DiplomaGameFreak
- dwCoord 9, 16
-
-DiplomaText:
- db $70,"Diploma",$70,"@"
-
-DiplomaPlayer:
- db "Player@"
-
-DiplomaEmptyText:
- db "@"
-
-DiplomaCongrats:
- db "Congrats! This"
- next "diploma certifies"
- next "that you have"
- next "completed your"
- next "#DEX.@"
-
-DiplomaGameFreak:
- db "GAME FREAK@"
diff --git a/engine/menu/diploma_1.asm b/engine/menu/diploma_1.asm
new file mode 100644
index 00000000..3f309bd2
--- /dev/null
+++ b/engine/menu/diploma_1.asm
@@ -0,0 +1,17 @@
+DisplayDiploma:
+ call SaveScreenTilesToBuffer2
+ call GBPalWhiteOutWithDelay3
+ call ClearScreen
+ xor a
+ ld [wUpdateSpritesEnabled], a
+ ld hl, wd730
+ set 6, [hl]
+ callab _DisplayDiploma
+ call WaitForTextScrollButtonPress
+ ld hl, wd730
+ res 6, [hl]
+ call GBPalWhiteOutWithDelay3
+ call ReloadTilesetTilePatterns
+ call RestoreScreenTilesAndReloadTilePatterns
+ call Delay3
+ jp GBPalNormal
diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm
index e1359063..9946b90d 100755
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -1,4 +1,4 @@
-PKMNLeaguePC: ; 0x7657e
+PKMNLeaguePC:
ld hl, AccessedHoFPCText
call PrintText
ld hl, wd730
@@ -100,8 +100,7 @@ LeaguePCShowMon:
call LoadFrontSpriteByMonIndex
call GBPalNormal
coord hl, 0, 13
- ld b, 2
- ld c, $12
+ lb bc, 2, 18
call TextBoxBorder
coord hl, 1, 15
ld de, HallOfFameNoText
@@ -110,7 +109,7 @@ LeaguePCShowMon:
ld de, wHoFTeamNo
lb bc, 1, 3
call PrintNumber
- jpba HoFDisplayMonInfo
+ jpba Func_7033f
HallOfFameNoText:
db "HALL OF FAME No @"
diff --git a/engine/menu/link_menu.asm b/engine/menu/link_menu.asm
new file mode 100644
index 00000000..458f653b
--- /dev/null
+++ b/engine/menu/link_menu.asm
@@ -0,0 +1,910 @@
+Func_f531b::
+ ld c,$14
+ call DelayFrames
+ ld a,$1
+ ld [wBuffer],a
+ xor a
+ ld [wUnknownSerialFlag_d499],a
+ coord hl, 0,0
+ lb bc, 4, 5
+ call TextBoxBorder
+ ld de,Text_f5791
+ coord hl, 1,2
+ call PlaceString
+ coord hl, 8,0
+ lb bc, 8, 10
+ call TextBoxBorder
+ coord hl, 10,2
+ ld de,Text_f579c
+ call PlaceString
+ coord hl, 0,10
+ lb bc, 6, 18
+ call TextBoxBorder
+ call UpdateSprites
+ xor a
+ ld [wUnusedCD37],a
+ ld [wd72d],a
+ ld [wd11e],a
+ ld hl,wTopMenuItemY
+ ld a,$2
+ ld [hli],a
+ ld a,$9
+ ld [hli],a
+ xor a
+ ld [hli],a
+ inc hl
+ ld a,$3
+ ld [hli],a
+ ld a,$3
+ ld [hli],a
+ xor a
+ ld [hl],a
+.asm_f5377
+ call Func_f56bd
+ call HandleMenuInput
+ and $3
+ add a
+ add a
+ ld b,a
+ ld a,[wCurrentMenuItem]
+ cp $3
+ jr nz,.asm_f5390
+ bit 2,b
+ jr z,.asm_f5390
+ dec a
+ ld b,$8
+.asm_f5390
+ add b
+ add $c0
+ ld [wLinkMenuSelectionSendBuffer],a
+ ld [wLinkMenuSelectionSendBuffer+1],a
+.asm_f5399
+ ld hl,wLinkMenuSelectionSendBuffer
+ ld a,[hl]
+ ld [hSerialSendData],a
+ call Serial_ExchangeByte
+ push af
+ ld hl,wLinkMenuSelectionSendBuffer
+ ld a,[hl]
+ ld [hSerialSendData],a
+ call Serial_ExchangeByte
+ pop bc
+ cp b
+ jr nz,.asm_f5399
+ and $f0
+ cp $c0
+ jr nz,.asm_f5399
+ ld a,b
+ and $c
+ jr nz,.asm_f53c4
+ ld a,[wLinkMenuSelectionSendBuffer]
+ and $c
+ jr z,.asm_f5377
+ jr .asm_f53df
+.asm_f53c4
+ ld a,[wLinkMenuSelectionSendBuffer]
+ and $c
+ jr z,.asm_f53d1
+ ld a,[hSerialConnectionStatus]
+ cp $2
+ jr z,.asm_f53df
+.asm_f53d1
+ ld a,$1
+ ld [wd11e],a
+ ld a,b
+ ld [wLinkMenuSelectionSendBuffer],a
+ and $3
+ ld [wCurrentMenuItem],a
+.asm_f53df
+ call DelayFrame
+ call DelayFrame
+ ld hl,wLinkMenuSelectionSendBuffer
+ ld a,[hl]
+ ld [hSerialSendData],a
+ call Serial_ExchangeByte
+ call Serial_ExchangeByte
+ ld b,$14
+.loop
+ call DelayFrame
+ call Serial_SendZeroByte
+ dec b
+ jr nz,.loop
+ ld b,$7f
+ ld c,$7f
+ ld d,$7f
+ ld e,$ec
+ ld a,[wLinkMenuSelectionSendBuffer]
+ bit 3,a
+ jr nz,.asm_f541a
+ ld b,e
+ ld e,c
+ ld a,[wCurrentMenuItem]
+ and a
+ jr z,.asm_f541a
+ ld c,b
+ ld b,d
+ dec a
+ jr z,.asm_f541a
+ ld d,c
+ ld c,b
+.asm_f541a
+ ld a,b
+ Coorda 9,2
+ ld a,c
+ Coorda 9,4
+ ld a,d
+ Coorda 9,6
+ ld a,e
+ Coorda 9,8
+ ld c,40
+ call DelayFrames
+ ld a,[wLinkMenuSelectionSendBuffer]
+ bit 3,a
+ jr nz,asm_f547f
+ ld a,[wCurrentMenuItem]
+ cp $3
+ jr z,asm_f547f
+ inc a
+ ld [wUnknownSerialFlag_d499],a
+ ld a,[wCurrentMenuItem]
+ ld hl,PointerTable_f5488
+ ld c,a
+ ld b,$0
+ add hl,bc
+ add hl,bc
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a
+ ld de,.returnaddress
+ push de
+ jp hl
+.returnaddress
+ ld [wLinkMenuSelectionSendBuffer],a
+ xor a
+ ld [wUnknownSerialCounter],a
+ ld [wUnknownSerialCounter+1],a
+ call Serial_SyncAndExchangeNybble
+ ld a,[wLinkMenuSelectionSendBuffer]
+ and a
+ jr nz,asm_f547c
+ ld a, [wLinkMenuSelectionReceiveBuffer]
+ and a
+ jr nz, Func_f5476
+ xor a
+ ld [wUnknownSerialCounter],a
+ ld [wUnknownSerialCounter+1],a
+ and a
+ ret
+
+Func_f5476::
+ ld hl,ColosseumIneligibleText
+ call PrintText
+asm_f547c::
+ jp Func_f531b
+
+asm_f547f::
+ xor a
+ ld [wUnknownSerialCounter],a
+ ld [wUnknownSerialCounter+1],a
+ scf
+ ret
+
+PointerTable_f5488::
+ dw PokeCup
+ dw PikaCup
+ dw PetitCup
+
+PokeCup::
+ ld hl,wPartyCount
+ ld a,[hli]
+ cp $3
+ jp nz,NotThreeMonsInParty
+ ld b,$3
+.loop
+ ld a,[hli]
+ cp MEW
+ jp z,MewInParty
+ dec b
+ jr nz,.loop
+ dec hl
+ dec hl
+ cp [hl] ; is third mon second mon?
+ jp z,DuplicateSpecies
+ dec hl ; wPartySpecies
+ cp [hl] ; is third mon first mon?
+ jp z,DuplicateSpecies
+ ld a,[hli]
+ cp [hl] ; is first mon second mon?
+ jp z,DuplicateSpecies
+ ld a,[wPartyMon1Level]
+ cp 56
+ jp nc,LevelAbove55
+ cp 50
+ jp c,LevelUnder50
+ ld b,a
+ ld a,[wPartyMon2Level]
+ cp 56
+ jp nc,LevelAbove55
+ cp 50
+ jp c,LevelUnder50
+ ld c,a
+ ld a,[wPartyMon3Level]
+ cp 56
+ jp nc,LevelAbove55
+ cp 50
+ jp c,LevelUnder50
+ add b
+ add c
+ cp 156
+ jp nc,CombinedLevelsGreaterThan155
+ xor a
+ ret
+
+PikaCup::
+ ld hl,wPartyCount
+ ld a,[hli]
+ cp $3
+ jp nz,NotThreeMonsInParty
+ ld b,$3
+.loop
+ ld a,[hli] ; wPartySpecies
+ cp MEW
+ jp z,MewInParty
+ dec b
+ jr nz,.loop
+ dec hl
+ dec hl
+ cp [hl] ; is third mon second mon?
+ jp z,DuplicateSpecies
+ dec hl ; wPartySpecies
+ cp [hl] ; is third mon first mon?
+ jp z,DuplicateSpecies
+ ld a,[hli]
+ cp [hl] ; is first mon second mon?
+ jp z,DuplicateSpecies
+ ld a,[wPartyMon1Level]
+ cp 21
+ jp nc,LevelAbove20
+ cp 15
+ jp c,LevelUnder15
+ ld b,a
+ ld a,[wPartyMon2Level]
+ cp 21
+ jp nc,LevelAbove20
+ cp 15
+ jp c,LevelUnder15
+ ld c,a
+ ld a,[wPartyMon3Level]
+ cp 21
+ jp nc,LevelAbove20
+ cp 15
+ jp c,LevelUnder15
+ add b
+ add c
+ cp 51
+ jp nc,CombinedLevelsAbove50
+ xor a
+ ret
+
+PetitCup::
+ ld hl,wPartyCount
+ ld a,[hli]
+ cp $3
+ jp nz,NotThreeMonsInParty
+ ld b,$3
+.loop
+ ld a,[hli]
+ cp MEW
+ jp z,MewInParty
+ dec b
+ jr nz,.loop
+ dec hl
+ dec hl
+ cp [hl] ; is third mon second mon?
+ jp z,DuplicateSpecies
+ dec hl ; wPartySpecies
+ cp [hl] ; is third mon first mon?
+ jp z,DuplicateSpecies
+ ld a,[hli]
+ cp [hl] ; is first mon second mon?
+ jp z,DuplicateSpecies
+ dec hl
+ ld a,[hl]
+ ld [wcf91],a
+ push hl
+ callab Func_3b10f
+ pop hl
+ jp c,asm_f56ad
+ inc hl
+ ld a,[hl]
+ ld [wcf91],a
+ push hl
+ callab Func_3b10f
+ pop hl
+ jp c,asm_f56ad
+ inc hl
+ ld a,[hl]
+ ld [wcf91],a
+ push hl
+ callab Func_3b10f
+ pop hl
+ jp c,asm_f56ad
+ dec hl
+ dec hl
+ ld b,$3
+.bigloop
+ ld a,[hli]
+ push hl
+ push bc
+ push af
+ dec a
+ ld c,a
+ ld b,$0
+ ld hl,PokedexEntryPointers
+ add hl,bc
+ add hl,bc
+ ld de,wcd6d
+ ld bc,$2
+ ld a,BANK(PokedexEntryPointers)
+ call FarCopyData
+ ld hl,wcd6d
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a
+ ld de,wcd6d
+ ld bc,$14
+ ld a,BANK(PokedexEntryPointers)
+ call FarCopyData
+ ld hl,wcd6d
+.loop2
+ ld a,[hli]
+ cp "@"
+ jr nz,.loop2
+ ld a,[hli]
+ cp $7
+ jp nc,asm_f5689
+ add a
+ add a
+ ld b,a
+ add a
+ add b
+ ld b,a
+ ld a,[hli]
+ add b
+ cp $51
+ jp nc,asm_f5689
+ ld a,[hli]
+ sub $b9
+ ld a,[hl]
+ sbc $1
+ jp nc,asm_f569b
+ pop af
+ pop bc
+ pop hl
+ dec b
+ jr nz,.bigloop
+ ld a,[wPartyMon1Level]
+ cp 31
+ jp nc,LevelAbove30
+ cp 25
+ jp c,LevelUnder25
+ ld b,a
+ ld a,[wPartyMon2Level]
+ cp 31
+ jp nc,LevelAbove30
+ cp 25
+ jp c,LevelUnder25
+ ld c,a
+ ld a,[wPartyMon3Level]
+ cp 31
+ jp nc,LevelAbove30
+ cp 25
+ jp c,LevelUnder25
+ add b
+ add c
+ cp 81
+ jp nc,CombinedLevelsAbove80
+ xor a
+ ret
+
+NotThreeMonsInParty::
+ ld hl,Colosseum3MonsText
+ call PrintText
+ ld a,$1
+ ret
+
+MewInParty::
+ ld hl,ColosseumMewText
+ call PrintText
+ ld a,$2
+ ret
+
+DuplicateSpecies::
+ ld hl,ColosseumDifferentMonsText
+ call PrintText
+ ld a,$3
+ ret
+
+LevelAbove55::
+ ld hl,ColosseumMaxL55Text
+ call PrintText
+ ld a,$4
+ ret
+
+LevelUnder50::
+ ld hl,ColosseumMinL50Text
+ call PrintText
+ ld a,$5
+ ret
+
+CombinedLevelsGreaterThan155::
+ ld hl,ColosseumTotalL155Text
+ call PrintText
+ ld a,$6
+ ret
+
+LevelAbove30::
+ ld hl,ColosseumMaxL30Text
+ call PrintText
+ ld a,$7
+ ret
+
+LevelUnder25::
+ ld hl,ColosseumMinL25Text
+ call PrintText
+ ld a,$8
+ ret
+
+CombinedLevelsAbove80::
+ ld hl,ColosseumTotalL80Text
+ call PrintText
+ ld a,$9
+ ret
+
+LevelAbove20::
+ ld hl,ColosseumMaxL20Text
+ call PrintText
+ ld a,$a
+ ret
+
+LevelUnder15::
+ ld hl,ColosseumMinL15Text
+ call PrintText
+ ld a,$b
+ ret
+
+CombinedLevelsAbove50::
+ ld hl,ColosseumTotalL50Text
+ call PrintText
+ ld a,$c
+ ret
+
+asm_f5689::
+ pop af
+ pop bc
+ pop hl
+ ld [wd11e],a
+ call GetMonName
+ ld hl,ColosseumHeightText
+ call PrintText
+ ld a,$d
+ ret
+
+asm_f569b::
+ pop af
+ pop bc
+ pop hl
+ ld [wd11e],a
+ call GetMonName
+ ld hl,ColosseumWeightText
+ call PrintText
+ ld a,$e
+ ret
+
+asm_f56ad::
+ ld a,[hl]
+ ld [wd11e],a
+ call GetMonName
+ ld hl,ColosseumEvolvedText
+ call PrintText
+ ld a,$f
+ ret
+
+Func_f56bd::
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED],a
+ coord hl, 1,11
+ lb bc, 6, 18
+ call ClearScreenArea
+ ld a,[wCurrentMenuItem]
+ cp $3
+ jr nc,.asm_f56e6
+ ld hl,PointerTable_f56ee
+ ld a,[wCurrentMenuItem]
+ ld c,a
+ ld b,$0
+ add hl,bc
+ add hl,bc
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a
+ ld d,h
+ ld e,l
+ coord hl, 1,12
+ call PlaceString
+.asm_f56e6
+ call Delay3
+ ld a,$1
+ ld [H_AUTOBGTRANSFERENABLED],a
+ ret
+
+PointerTable_f56ee::
+ dw Text_f56f4
+ dw Text_f5728
+ dw Text_f575b
+
+Text_f56f4::
+ db "LVs of 3<pkmn>:50-55"
+ next "Sum of LVs:155 MAX"
+ next "MEW can't attend.@"
+
+Text_f5728::
+ db "LVs of 3<pkmn>:15-20"
+ next "Sum of LVs:50 MAX"
+ next "MEW can't attend.@"
+
+Text_f575b::
+ db "3 Basic <pkmn>.LV25-30"
+ next "Sum of LVs:80 MAX"
+ next "6′8″ and 44lb MAX@"
+
+Text_f5791::
+ db "View"
+ next "Rules@"
+
+Text_f579c::
+ db "# Cup"
+ next "Pika Cup"
+ next "Petit Cup"
+ next "CANCEL@"
+
+Colosseum3MonsText::
+ TX_FAR _Colosseum3MonsText ; a0a2b
+ db "@"
+
+ColosseumMewText::
+ TX_FAR _ColosseumMewText ; a0a46
+ db "@"
+
+ColosseumDifferentMonsText::
+ TX_FAR _ColosseumDifferentMonsText ; a0a5f
+ db "@"
+
+ColosseumMaxL55Text::
+ TX_FAR _ColosseumMaxL55Text ; a0a81
+ db "@"
+
+ColosseumMinL50Text::
+ TX_FAR _ColosseumMinL50Text ; a0a9a
+ db "@"
+
+ColosseumTotalL155Text::
+ TX_FAR _ColosseumTotalL155Text ; a0aba
+ db "@"
+
+ColosseumMaxL30Text::
+ TX_FAR _ColosseumMaxL30Text ; a0ad9
+ db "@"
+
+ColosseumMinL25Text::
+ TX_FAR _ColosseumMinL25Text ; a0af2
+ db "@"
+
+ColosseumTotalL80Text::
+ TX_FAR _ColosseumTotalL80Text ; a0b12
+ db "@"
+
+ColosseumMaxL20Text::
+ TX_FAR _ColosseumMaxL20Text ; a0b30
+ db "@"
+
+ColosseumMinL15Text::
+ TX_FAR _ColosseumMinL15Text ; a0b49
+ db "@"
+
+ColosseumTotalL50Text::
+ TX_FAR _ColosseumTotalL50Text ; a0b69
+ db "@"
+
+ColosseumHeightText::
+ TX_FAR _ColosseumHeightText ; a0b87
+ db "@"
+
+ColosseumWeightText::
+ TX_FAR _ColosseumWeightText ; a0b9f
+ db "@"
+
+ColosseumEvolvedText::
+ TX_FAR _ColosseumEvolvedText ; a0bbb
+ db "@"
+
+ColosseumIneligibleText::
+ TX_FAR _ColosseumIneligibleText ; a0bd4
+ db "@"
+
+LinkMenu:
+ xor a
+ ld [wLetterPrintingDelayFlags], a
+ ld hl, wd72e
+ set 6, [hl]
+ ld hl, TextTerminator_f5a16
+ call PrintText
+ call SaveScreenTilesToBuffer1
+ ld hl, ColosseumWhereToText
+ call PrintText
+ coord hl, 5, 3
+ lb bc, 8, 13
+ call TextBoxBorder
+ call UpdateSprites
+ coord hl, 7, 5
+ ld de, TradeCenterText
+ call PlaceString
+ xor a
+ ld [wUnusedCD37], a
+ ld [wd72d], a
+ ld [wd11e], a
+ ld hl, wTopMenuItemY
+ ld a, $5
+ ld [hli], a
+ ld a, $6
+ ld [hli], a
+ xor a
+ ld [hli], a
+ inc hl
+ ld a, $3
+ ld [hli], a
+ ld [hli], a
+ xor a
+ ld [hl], a
+.waitForInputLoop
+ call HandleMenuInput
+ and A_BUTTON | B_BUTTON
+ add a
+ add a
+ ld b, a
+ ld a, [wCurrentMenuItem]
+ cp $3
+ jr nz,.asm_f586b
+ bit 2,b
+ jr z,.asm_f586b
+ dec a
+ ld b,$8
+.asm_f586b
+ add b
+ add $d0
+ ld [wLinkMenuSelectionSendBuffer], a
+ ld [wLinkMenuSelectionSendBuffer + 1], a
+.exchangeMenuSelectionLoop
+ call Serial_ExchangeLinkMenuSelection
+ ld a, [wLinkMenuSelectionReceiveBuffer]
+ ld b, a
+ and $f0
+ cp $d0
+ jr z, .asm_f5c7d
+ ld a, [wLinkMenuSelectionReceiveBuffer + 1]
+ ld b, a
+ and $f0
+ cp $d0
+ jr nz, .exchangeMenuSelectionLoop
+.asm_f5c7d
+ ld a, b
+ and $c ; did the enemy press A or B?
+ jr nz, .enemyPressedAOrB
+; the enemy didn't press A or B
+ ld a, [wLinkMenuSelectionSendBuffer]
+ and $c ; did the player press A or B?
+ jr z, .waitForInputLoop ; if neither the player nor the enemy pressed A or B, try again
+ jr .doneChoosingMenuSelection ; if the player pressed A or B but the enemy didn't, use the player's selection
+.enemyPressedAOrB
+ ld a, [wLinkMenuSelectionSendBuffer]
+ and $c ; did the player press A or B?
+ jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection
+; the enemy and the player both pressed A or B
+; The gameboy that is clocking the connection wins.
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
+ jr z, .doneChoosingMenuSelection
+.useEnemyMenuSelection
+ ld a, $1
+ ld [wd11e], a
+ ld a, b
+ ld [wLinkMenuSelectionSendBuffer], a
+ and $3
+ ld [wCurrentMenuItem], a ; wCurrentMenuItem
+.doneChoosingMenuSelection
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
+ jr nz, .skipStartingTransfer
+ call DelayFrame
+ call DelayFrame
+ ld a, START_TRANSFER_INTERNAL_CLOCK
+ ld [rSC], a
+.skipStartingTransfer
+ ld b, " "
+ ld c, " "
+ ld d, " "
+ ld e, "▷"
+ ld a, [wLinkMenuSelectionSendBuffer]
+ and (B_BUTTON << 2) ; was B button pressed?
+ jr nz, .updateCursorPosition
+; A button was pressed
+ ld a, [wCurrentMenuItem]
+ cp $2
+ jp z, .asm_f5963
+ ld b, e
+ ld e, c
+ ld a, [wCurrentMenuItem]
+ and a
+ jr z, .updateCursorPosition
+ ld c, b
+ ld b, d
+ dec a
+ jr z, .updateCursorPosition
+ ld d, c
+ ld c, b
+.updateCursorPosition
+ call Func_f59ec
+ call LoadScreenTilesFromBuffer1
+ ld a, [wLinkMenuSelectionSendBuffer]
+ and (B_BUTTON << 2) ; was B button pressed?
+ jr nz, .choseCancel ; cancel if B pressed
+ ld a, [wCurrentMenuItem]
+ cp $2
+ jr z, .choseCancel
+ xor a
+ ld [wWalkBikeSurfState], a ; start walking
+ ld a, [wCurrentMenuItem]
+ and a
+ ld a, COLOSSEUM
+ jr nz, .next
+ ld a, TRADE_CENTER
+.next
+ ld [wd72d], a
+ ld hl, ColosseumPleaseWaitText
+ call PrintText
+ ld c, 50
+ call DelayFrames
+ ld hl, wd732
+ res 1, [hl]
+ ld a, [wDefaultMap]
+ ld [wDestinationMap], a
+ callab SpecialWarpIn
+ ld c, 20
+ call DelayFrames
+ xor a
+ ld [wMenuJoypadPollCount], a
+ ld [wSerialExchangeNybbleSendData], a
+ inc a ; LINK_STATE_IN_CABLE_CLUB
+ ld [wLinkState], a
+ ld [wEnteringCableClub], a
+ jpab SpecialEnterMap
+.choseCancel
+ xor a
+ ld [wMenuJoypadPollCount], a
+ call Delay3
+ callab CloseLinkConnection
+ ld hl, ColosseumCanceledText
+ call PrintText
+ ld hl, wd72e
+ res 6, [hl]
+ ret
+
+.asm_f5963
+ ld a,[wd11e]
+ and a
+ jr nz,.asm_f5974
+ ld b," "
+ ld c," "
+ ld d,"▷"
+ ld e," "
+ call Func_f59ec
+.asm_f5974
+ xor a
+ ld [wBuffer], a
+ ld a,$ff
+ ld [wSerialExchangeNybbleReceiveData],a
+ ld a, $b
+ ld [wLinkMenuSelectionSendBuffer], a
+ ld b,$78
+.loop
+ ld a,[hSerialConnectionStatus]
+ cp $2
+ call z,DelayFrame
+ dec b
+ jr z,.asm_f59b2
+ call Serial_ExchangeNybble
+ call DelayFrame
+ ld a,[wSerialExchangeNybbleReceiveData]
+ inc a
+ jr z,.loop
+ ld b,$f
+.loop2
+ call DelayFrame
+ call Serial_ExchangeNybble
+ dec b
+ jr nz,.loop2
+ ld b,$f
+.loop3
+ call DelayFrame
+ call Serial_SendZeroByte
+ dec b
+ jr nz,.loop3
+ jr .asm_f59d6
+
+.asm_f59b2
+ xor a
+ ld [wUnknownSerialCounter],a
+ ld [wUnknownSerialCounter+1],a
+ ld a,[wd11e]
+ and a
+ jr z,.asm_f59cd
+ ld b," "
+ ld c," "
+ ld d," "
+ ld e,"▷"
+ call Func_f59ec
+ jp .choseCancel
+
+.asm_f59cd
+ ld hl,ColosseumVersionText
+ call PrintText
+ jp .choseCancel
+
+.asm_f59d6
+ ld b," "
+ ld c," "
+ ld d,"▷"
+ ld e," "
+ call Func_f59ec
+ call Func_f531b
+ jp c,.choseCancel
+ ld a,$f0
+ jp .next
+
+Func_f59ec::
+ ld a, b
+ Coorda 6, 5
+ ld a, c
+ Coorda 6, 7
+ ld a, d
+ Coorda 6, 9
+ ld a, e
+ Coorda 6, 11
+ ld c, 40
+ call DelayFrames
+ ret
+
+ColosseumWhereToText:
+ TX_FAR _ColosseumWhereToText
+ db "@"
+
+ColosseumPleaseWaitText:
+ TX_FAR _ColosseumPleaseWaitText
+ db "@"
+
+ColosseumCanceledText:
+ TX_FAR _ColosseumCanceledText
+ db "@"
+
+ColosseumVersionText:
+ TX_FAR _ColosseumVersionText ; 28:4c47
+ db "@"
+
+TextTerminator_f5a16:
+ db "@"
+
+TradeCenterText:
+ db "TRADE CENTER"
+ next "COLOSSEUM"
+ next "COLOSSEUM2"
+ next "CANCEL@"
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index d3152e4e..cf837a54 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -34,8 +34,7 @@ MainMenu:
jr z,.noSaveFile
; there's a save file
coord hl, 0, 0
- ld b,6
- ld c,13
+ lb bc, 6, 13
call TextBoxBorder
coord hl, 2, 2
ld de,ContinueText
@@ -43,8 +42,7 @@ MainMenu:
jr .next2
.noSaveFile
coord hl, 0, 0
- ld b,4
- ld c,13
+ lb bc, 4, 13
call TextBoxBorder
coord hl, 2, 2
ld de,NewGameText
@@ -129,185 +127,29 @@ InitOptions:
ld [wLetterPrintingDelayFlags],a
ld a,3 ; medium speed
ld [wOptions],a
+ ld a,64 ; audio?
+ ld [wPrinterSettings], a
ret
-LinkMenu:
- xor a
- ld [wLetterPrintingDelayFlags], a
- ld hl, wd72e
- set 6, [hl]
- ld hl, TextTerminator_6b20
- call PrintText
- call SaveScreenTilesToBuffer1
- ld hl, WhereWouldYouLikeText
- call PrintText
- coord hl, 5, 5
- ld b, $6
- ld c, $d
- call TextBoxBorder
- call UpdateSprites
- coord hl, 7, 7
- ld de, CableClubOptionsText
- call PlaceString
- xor a
- ld [wUnusedCD37], a
- ld [wd72d], a
- ld hl, wTopMenuItemY
- ld a, $7
- ld [hli], a
- ld a, $6
- ld [hli], a
- xor a
- ld [hli], a
- inc hl
- ld a, $2
- ld [hli], a
- inc a
- ; ld a, A_BUTTON | B_BUTTON
- ld [hli], a ; wMenuWatchedKeys
- xor a
- ld [hl], a
-.waitForInputLoop
- call HandleMenuInput
- and A_BUTTON | B_BUTTON
- add a
- add a
- ld b, a
- ld a, [wCurrentMenuItem]
- add b
- add $d0
- ld [wLinkMenuSelectionSendBuffer], a
- ld [wLinkMenuSelectionSendBuffer + 1], a
-.exchangeMenuSelectionLoop
- call Serial_ExchangeLinkMenuSelection
- ld a, [wLinkMenuSelectionReceiveBuffer]
- ld b, a
- and $f0
- cp $d0
- jr z, .asm_5c7d
- ld a, [wLinkMenuSelectionReceiveBuffer + 1]
- ld b, a
- and $f0
- cp $d0
- jr nz, .exchangeMenuSelectionLoop
-.asm_5c7d
- ld a, b
- and $c ; did the enemy press A or B?
- jr nz, .enemyPressedAOrB
-; the enemy didn't press A or B
- ld a, [wLinkMenuSelectionSendBuffer]
- and $c ; did the player press A or B?
- jr z, .waitForInputLoop ; if neither the player nor the enemy pressed A or B, try again
- jr .doneChoosingMenuSelection ; if the player pressed A or B but the enemy didn't, use the player's selection
-.enemyPressedAOrB
- ld a, [wLinkMenuSelectionSendBuffer]
- and $c ; did the player press A or B?
- jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection
-; the enemy and the player both pressed A or B
-; The gameboy that is clocking the connection wins.
- ld a, [hSerialConnectionStatus]
- cp USING_INTERNAL_CLOCK
- jr z, .doneChoosingMenuSelection
-.useEnemyMenuSelection
- ld a, b
- ld [wLinkMenuSelectionSendBuffer], a
- and $3
- ld [wCurrentMenuItem], a
-.doneChoosingMenuSelection
- ld a, [hSerialConnectionStatus]
- cp USING_INTERNAL_CLOCK
- jr nz, .skipStartingTransfer
- call DelayFrame
- call DelayFrame
- ld a, START_TRANSFER_INTERNAL_CLOCK
- ld [rSC], a
-.skipStartingTransfer
- ld b, $7f
- ld c, $7f
- ld d, $ec
- ld a, [wLinkMenuSelectionSendBuffer]
- and (B_BUTTON << 2) ; was B button pressed?
- jr nz, .updateCursorPosition
-; A button was pressed
- ld a, [wCurrentMenuItem]
- cp $2
- jr z, .updateCursorPosition
- ld c, d
- ld d, b
- dec a
- jr z, .updateCursorPosition
- ld b, c
- ld c, d
-.updateCursorPosition
- ld a, b
- Coorda 6, 7
- ld a, c
- Coorda 6, 9
- ld a, d
- Coorda 6, 11
- ld c, 40
- call DelayFrames
- call LoadScreenTilesFromBuffer1
- ld a, [wLinkMenuSelectionSendBuffer]
- and (B_BUTTON << 2) ; was B button pressed?
- jr nz, .choseCancel ; cancel if B pressed
- ld a, [wCurrentMenuItem]
- cp $2
- jr z, .choseCancel
- xor a
- ld [wWalkBikeSurfState], a ; start walking
- ld a, [wCurrentMenuItem]
- and a
- ld a, COLOSSEUM
- jr nz, .next
- ld a, TRADE_CENTER
-.next
- ld [wd72d], a
- ld hl, PleaseWaitText
- call PrintText
- ld c, 50
- call DelayFrames
- ld hl, wd732
- res 1, [hl]
- ld a, [wDefaultMap]
- ld [wDestinationMap], a
- call SpecialWarpIn
- ld c, 20
- call DelayFrames
- xor a
- ld [wMenuJoypadPollCount], a
- ld [wSerialExchangeNybbleSendData], a
- inc a ; LINK_STATE_IN_CABLE_CLUB
- ld [wLinkState], a
- ld [wEnteringCableClub], a
- jr SpecialEnterMap
-.choseCancel
- xor a
- ld [wMenuJoypadPollCount], a
- call Delay3
- call CloseLinkConnection
- ld hl, LinkCanceledText
+Func_5cc1:
+; unused?
+ ld a, $6d
+ cp $80
+ ret c ; will always be executed
+ ld hl, NotEnoughMemoryText
call PrintText
- ld hl, wd72e
- res 6, [hl]
ret
-WhereWouldYouLikeText:
- TX_FAR _WhereWouldYouLikeText
- db "@"
-
-PleaseWaitText:
- TX_FAR _PleaseWaitText
- db "@"
-
-LinkCanceledText:
- TX_FAR _LinkCanceledText
+NotEnoughMemoryText:
+ TX_FAR _NotEnoughMemoryText
db "@"
StartNewGame:
ld hl, wd732
res 1, [hl]
call OakSpeech
+ ld a, $8
+ ld [wPlayerMovingDirection], a
ld c, 20
call DelayFrames
@@ -323,6 +165,7 @@ SpecialEnterMap:
call ResetPlayerSpriteData
ld c, 20
call DelayFrames
+ call Func_5cc1
ld a, [wEnteringCableClub]
and a
ret nz
@@ -335,17 +178,11 @@ NewGameText:
db "NEW GAME", $4e
db "OPTION@"
-CableClubOptionsText:
- db "TRADE CENTER", $4e
- db "COLOSSEUM", $4e
- db "CANCEL@"
-
DisplayContinueGameInfo:
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 4, 7
- ld b, 8
- ld c, 14
+ lb bc, 8, 14
call TextBoxBorder
coord hl, 5, 9
ld de, SaveScreenInfoText
@@ -368,8 +205,7 @@ PrintSaveScreenText:
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 4, 0
- ld b, $8
- ld c, $e
+ lb bc, 8, 14
call TextBoxBorder
call LoadTextBoxTilePatterns
call UpdateSprites
@@ -427,260 +263,9 @@ SaveScreenInfoText:
next "TIME@"
DisplayOptionMenu:
- coord hl, 0, 0
- ld b,3
- ld c,18
- call TextBoxBorder
- coord hl, 0, 5
- ld b,3
- ld c,18
- call TextBoxBorder
- coord hl, 0, 10
- ld b,3
- ld c,18
- call TextBoxBorder
- coord hl, 1, 1
- ld de,TextSpeedOptionText
- call PlaceString
- coord hl, 1, 6
- ld de,BattleAnimationOptionText
- call PlaceString
- coord hl, 1, 11
- ld de,BattleStyleOptionText
- call PlaceString
- coord hl, 2, 16
- ld de,OptionMenuCancelText
- call PlaceString
- xor a
- ld [wCurrentMenuItem],a
- ld [wLastMenuItem],a
- inc a
- ld [wLetterPrintingDelayFlags],a
- ld [wUnusedCD40],a
- ld a,3 ; text speed cursor Y coordinate
- ld [wTopMenuItemY],a
- call SetCursorPositionsFromOptions
- ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
- ld [wTopMenuItemX],a
- ld a,$01
- ld [H_AUTOBGTRANSFERENABLED],a ; enable auto background transfer
- call Delay3
-.loop
- call PlaceMenuCursor
- call SetOptionsFromCursorPositions
-.getJoypadStateLoop
- call JoypadLowSensitivity
- ld a,[hJoy5]
- ld b,a
- 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
- bit 3,b ; Start button pressed?
- jr nz,.exitMenu
- bit 0,b ; A button pressed?
- jr z,.checkDirectionKeys
- ld a,[wTopMenuItemY]
- cp a,16 ; is the cursor on Cancel?
- jr nz,.loop
-.exitMenu
- ld a,SFX_PRESS_AB
- call PlaySound
- ret
-.eraseOldMenuCursor
- ld [wTopMenuItemX],a
- call EraseMenuCursor
- jp .loop
-.checkDirectionKeys
- ld a,[wTopMenuItemY]
- bit 7,b ; Down pressed?
- jr nz,.downPressed
- bit 6,b ; Up pressed?
- jr nz,.upPressed
- cp a,8 ; cursor in Battle Animation section?
- jr z,.cursorInBattleAnimation
- cp a,13 ; cursor in Battle Style section?
- jr z,.cursorInBattleStyle
- cp a,16 ; cursor on Cancel?
- jr z,.loop
-.cursorInTextSpeed
- bit 5,b ; Left pressed?
- jp nz,.pressedLeftInTextSpeed
- jp .pressedRightInTextSpeed
-.downPressed
- cp a,16
- ld b,-13
- ld hl,wOptionsTextSpeedCursorX
- jr z,.updateMenuVariables
- ld b,5
- cp a,3
- inc hl
- jr z,.updateMenuVariables
- cp a,8
- inc hl
- jr z,.updateMenuVariables
- ld b,3
- inc hl
- jr .updateMenuVariables
-.upPressed
- cp a,8
- ld b,-5
- ld hl,wOptionsTextSpeedCursorX
- jr z,.updateMenuVariables
- cp a,13
- inc hl
- jr z,.updateMenuVariables
- cp a,16
- ld b,-3
- inc hl
- jr z,.updateMenuVariables
- ld b,13
- inc hl
-.updateMenuVariables
- add b
- ld [wTopMenuItemY],a
- ld a,[hl]
- ld [wTopMenuItemX],a
- call PlaceUnfilledArrowMenuCursor
- jp .loop
-.cursorInBattleAnimation
- ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate
- xor a,$0b ; toggle between 1 and 10
- ld [wOptionsBattleAnimCursorX],a
- jp .eraseOldMenuCursor
-.cursorInBattleStyle
- ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate
- xor a,$0b ; toggle between 1 and 10
- ld [wOptionsBattleStyleCursorX],a
- jp .eraseOldMenuCursor
-.pressedLeftInTextSpeed
- ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
- cp a,1
- jr z,.updateTextSpeedXCoord
- cp a,7
- jr nz,.fromSlowToMedium
- sub a,6
- jr .updateTextSpeedXCoord
-.fromSlowToMedium
- sub a,7
- jr .updateTextSpeedXCoord
-.pressedRightInTextSpeed
- ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
- cp a,14
- jr z,.updateTextSpeedXCoord
- cp a,7
- jr nz,.fromFastToMedium
- add a,7
- jr .updateTextSpeedXCoord
-.fromFastToMedium
- add a,6
-.updateTextSpeedXCoord
- ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate
- jp .eraseOldMenuCursor
-
-TextSpeedOptionText:
- db "TEXT SPEED"
- next " FAST MEDIUM SLOW@"
-
-BattleAnimationOptionText:
- db "BATTLE ANIMATION"
- next " ON OFF@"
-
-BattleStyleOptionText:
- db "BATTLE STYLE"
- next " SHIFT SET@"
-
-OptionMenuCancelText:
- db "CANCEL@"
-
-; sets the options variable according to the current placement of the menu cursors in the options menu
-SetOptionsFromCursorPositions:
- ld hl,TextSpeedOptionData
- ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
- ld c,a
-.loop
- ld a,[hli]
- cp c
- jr z,.textSpeedMatchFound
- inc hl
- jr .loop
-.textSpeedMatchFound
- ld a,[hl]
- ld d,a
- ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate
- dec a
- jr z,.battleAnimationOn
-.battleAnimationOff
- set 7,d
- jr .checkBattleStyle
-.battleAnimationOn
- res 7,d
-.checkBattleStyle
- ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate
- dec a
- jr z,.battleStyleShift
-.battleStyleSet
- set 6,d
- jr .storeOptions
-.battleStyleShift
- res 6,d
-.storeOptions
- ld a,d
- ld [wOptions],a
+ callab DisplayOptionMenu_ ; 10:5c70
ret
-; reads the options variable and places menu cursors in the correct positions within the options menu
-SetCursorPositionsFromOptions:
- ld hl,TextSpeedOptionData + 1
- ld a,[wOptions]
- ld c,a
- and a,$3f
- push bc
- ld de,2
- call IsInArray
- pop bc
- dec hl
- ld a,[hl]
- 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 [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 [wOptionsBattleStyleCursorX],a ; battle style cursor X coordinate
- coord hl, 0, 13
- call .placeUnfilledRightArrow
-; cursor in front of Cancel
- coord hl, 0, 16
- ld a,1
-.placeUnfilledRightArrow
- ld e,a
- ld d,0
- add hl,de
- ld [hl],$ec ; unfilled right arrow menu cursor
- ret
-
-; table that indicates how the 3 text speed options affect frame delays
-; Format:
-; 00: X coordinate of menu cursor
-; 01: delay after printing a letter (in frames)
-TextSpeedOptionData:
- db 14,5 ; Slow
- db 7,3 ; Medium
- db 1,1 ; Fast
- db 7 ; default X coordinate (Medium)
- db $ff ; terminator
-
CheckForPlayerNameInSRAM:
; 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
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index 759be189..911c4e99 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -5,9 +5,8 @@ AskName:
ld a, [wIsInBattle]
dec a
coord hl, 0, 0
- ld b, 4
- ld c, 11
- call z, ClearScreenArea ; only if in wild batle
+ lb bc, 4, 11
+ call z, ClearScreenArea ; only if in wild battle
ld a, [wcf91]
ld [wd11e], a
call GetMonName
@@ -40,7 +39,7 @@ AskName:
pop af
ld [wUpdateSpritesEnabled], a
ld a, [wcf4b]
- cp $50
+ cp "@"
ret nz
.declinedNickname
ld d, h
@@ -49,7 +48,7 @@ AskName:
ld bc, NAME_LENGTH
jp CopyData
-DoYouWantToNicknameText: ; 0x6557
+DoYouWantToNicknameText:
TX_FAR _DoYouWantToNicknameText
db "@"
@@ -94,8 +93,7 @@ DisplayNamingScreen:
call LoadEDTile
callba LoadMonPartySpriteGfx
coord hl, 0, 4
- ld b, 9
- ld c, 18
+ lb bc, 9, 18
call TextBoxBorder
call PrintNamingText
ld a, 3
@@ -108,7 +106,7 @@ DisplayNamingScreen:
ld [wMenuWatchedKeys], a
ld a, 7
ld [wMaxMenuItem], a
- ld a, $50
+ ld a, "@"
ld [wcf4b], a
xor a
ld hl, wNamingScreenSubmitName
@@ -153,7 +151,7 @@ DisplayNamingScreen:
ld h, [hl]
ld l, a
push de
- jp [hl]
+ jp hl
.submitNickname
pop de
@@ -259,7 +257,7 @@ DisplayNamingScreen:
.addLetter
ld a, [wNamingScreenLetter]
ld [hli], a
- ld [hl], $50
+ ld [hl], "@"
ld a, SFX_PRESS_AB
call PlaySound
ret
@@ -324,12 +322,28 @@ DisplayNamingScreen:
jp EraseMenuCursor
LoadEDTile:
+; In Red/Blue, the bank for the ED_tile was defined incorrectly as bank0
+; Luckily, the MBC3 treats loading $0 into $2000-$2fff range as loading bank1 into $4000-$7fff range
+; Because Yellow uses the MBC5, loading $0 into $2000 - $2fff range will load bank0 instead of bank1 and thus incorrectly load the tile
+; Instead of defining the correct bank, GameFreak decided to simply copy the ED_Tile in the function during HBlank
ld de, ED_Tile
ld hl, vFont + $700
- 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
+ ld c, $4 ; number of copies needed
+.waitForHBlankLoop
+ ld a, [rSTAT]
+ and %10 ; in HBlank?
+ jr nz, .waitForHBlankLoop
+ ld a, [de]
+ ld [hli], a
+ ld [hli], a
+ inc de
+ ld a, [de]
+ ld [hli], a
+ ld [hli], a
+ inc de
+ dec c
+ jr nz, .waitForHBlankLoop
+ ret
ED_Tile:
INCBIN "gfx/ED_tile.1bpp"
diff --git a/engine/menu/oaks_pc.asm b/engine/menu/oaks_pc.asm
index 55852b63..e4172ec7 100755
--- a/engine/menu/oaks_pc.asm
+++ b/engine/menu/oaks_pc.asm
@@ -7,9 +7,9 @@ OpenOaksPC:
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_1e932
+ jr nz, .closePC
predef DisplayDexRating
-.asm_1e932
+.closePC
ld hl, ClosedOaksPCText
call PrintText
jp LoadScreenTilesFromBuffer2
diff --git a/engine/menu/options.asm b/engine/menu/options.asm
new file mode 100644
index 00000000..7bed30ae
--- /dev/null
+++ b/engine/menu/options.asm
@@ -0,0 +1,443 @@
+DisplayOptionMenu_:
+ call Func_41f06
+.optionMenuLoop
+ call JoypadLowSensitivity
+ ld a, [hJoy5]
+ and START | B_BUTTON
+ jr nz, .exitOptionMenu
+ call Func_41eb7
+ jr c, .asm_41c86
+ call Func_41c95
+ jr c, .exitOptionMenu
+.asm_41c86
+ call Func_41ee9
+ call DelayFrame
+ call DelayFrame
+ call DelayFrame
+ jr .optionMenuLoop
+.exitOptionMenu
+ ret
+
+Func_41c95:
+ ld a, [wOptionsCursorLocation]
+ ld e, a
+ ld d, $0
+ ld hl, OptionMenuJumpTable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+OptionMenuJumpTable:
+ dw OptionsMenu_TextSpeed
+ dw OptionsMenu_BattleAnimations
+ dw OptionsMenu_BattleStyle
+ dw OptionsMenu_SpeakerSettings
+ dw OptionsMenu_GBPrinterBrightness
+ dw OptionsMenu_Dummy
+ dw OptionsMenu_Dummy
+ dw OptionsMenu_Cancel
+
+OptionsMenu_TextSpeed:
+ call Func_41d07
+ ld a, [hJoy5]
+ bit 4, a ; right
+ jr nz, .pressedRight
+ bit 5, a
+ jr nz, .pressedLeft
+ jr .asm_41ce0
+.pressedRight
+ ld a, c
+ cp $2
+ jr c, .asm_41cca
+ ld c, $ff
+.asm_41cca
+ inc c
+ ld a, e
+ jr .asm_41cd6
+.pressedLeft
+ ld a, c
+ and a
+ jr nz, .asm_41cd4
+ ld c, $3
+.asm_41cd4
+ dec c
+ ld a, d
+.asm_41cd6
+ ld b, a
+ ld a, [wOptions]
+ and $f0
+ or b
+ ld [wOptions], a
+.asm_41ce0
+ ld b, $0
+ ld hl, TextSpeedStringsPointerTable
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ coord hl, 14, 2
+ call PlaceString
+ and a
+ ret
+
+TextSpeedStringsPointerTable:
+ dw FastText
+ dw MidText
+ dw SlowText
+
+FastText:
+ db "FAST@"
+MidText:
+ db "MID @"
+SlowText:
+ db "SLOW@"
+
+Func_41d07:
+ ld a, [wOptions]
+ and $f
+ cp $5
+ jr z, .slowTextOption
+ cp $1
+ jr z, .fastTextOption
+; mid text option
+ ld c, $1
+ lb de, 1, 5
+ ret
+.slowTextOption
+ ld c, $2
+ lb de, 3, 1
+ ret
+.fastTextOption
+ ld c, $0
+ lb de, 5, 3
+ ret
+
+OptionsMenu_BattleAnimations:
+ ld a, [hJoy5]
+ and D_RIGHT | D_LEFT
+ jr nz, .asm_41d33
+ ld a, [wOptions]
+ and $80 ; mask other bits
+ jr .asm_41d3b
+.asm_41d33
+ ld a, [wOptions]
+ xor $80
+ ld [wOptions], a
+.asm_41d3b
+ ld bc, $0
+ sla a
+ rl c
+ ld hl, AnimationOptionStringsPointerTable
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ coord hl, 14, 4
+ call PlaceString
+ and a
+ ret
+
+AnimationOptionStringsPointerTable:
+ dw AnimationOnText
+ dw AnimationOffText
+
+AnimationOnText:
+ db "ON @"
+AnimationOffText:
+ db "OFF@"
+
+OptionsMenu_BattleStyle:
+ ld a, [hJoy5]
+ and D_LEFT | D_RIGHT
+ jr nz, .asm_41d6b
+ ld a, [wOptions]
+ and $40 ; mask other bits
+ jr .asm_41d73
+.asm_41d6b
+ ld a, [wOptions]
+ xor $40
+ ld [wOptions], a
+.asm_41d73
+ ld bc, $0
+ sla a
+ sla a
+ rl c
+ ld hl, BattleStyleOptionStringsPointerTable
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ coord hl, 14, 6
+ call PlaceString
+ and a
+ ret
+
+BattleStyleOptionStringsPointerTable:
+ dw BattleStyleShiftText
+ dw BattleStyleSetText
+
+BattleStyleShiftText:
+ db "SHIFT@"
+BattleStyleSetText:
+ db "SET @"
+
+OptionsMenu_SpeakerSettings:
+ ld a, [wOptions]
+ and $30
+ swap a
+ ld c, a
+ ld a, [hJoy5]
+ bit 4, a
+ jr nz, .pressedRight
+ bit 5, a
+ jr nz, .pressedLeft
+ jr .asm_41dca
+.pressedRight
+ ld a, c
+ inc a
+ and $3
+ jr .asm_41dba
+.pressedLeft
+ ld a, c
+ dec a
+ and $3
+.asm_41dba
+ ld c, a
+ swap a
+ ld b, a
+ xor a
+ ld [rNR51], a
+ ld a, [wOptions]
+ and $cf
+ or b
+ ld [wOptions], a
+.asm_41dca
+ ld b, $0
+ ld hl, SpeakerOptionStringsPointerTable
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ coord hl, 8, 8
+ call PlaceString
+ and a
+ ret
+
+SpeakerOptionStringsPointerTable:
+ dw MonoSoundText
+ dw Earphone1SoundText
+ dw Earphone2SoundText
+ dw Earphone3SoundText
+
+MonoSoundText:
+ db "MONO @"
+Earphone1SoundText:
+ db "EARPHONE1@"
+Earphone2SoundText:
+ db "EARPHONE2@"
+Earphone3SoundText:
+ db "EARPHONE3@"
+
+OptionsMenu_GBPrinterBrightness:
+ call Func_41e7b
+ ld a, [hJoy5]
+ bit 4, a
+ jr nz, .pressedRight
+ bit 5, a
+ jr nz, .pressedLeft
+ jr .asm_41e32
+.pressedRight
+ ld a, c
+ cp $4
+ jr c, .asm_41e22
+ ld c, $ff
+.asm_41e22
+ inc c
+ ld a, e
+ jr .asm_41e2e
+.pressedLeft
+ ld a, c
+ and a
+ jr nz, .asm_41e2c
+ ld c, $5
+.asm_41e2c
+ dec c
+ ld a, d
+.asm_41e2e
+ ld b, a
+ ld [wPrinterSettings], a
+.asm_41e32
+ ld b, $0
+ ld hl, GBPrinterOptionStringsPointerTable
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ coord hl, 8, 10
+ call PlaceString
+ and a
+ ret
+
+GBPrinterOptionStringsPointerTable:
+ dw LightestPrintText
+ dw LighterPrintText
+ dw NormalPrintText
+ dw DarkerPrintText
+ dw DarkestPrintText
+
+LightestPrintText:
+ db "LIGHTEST@"
+LighterPrintText:
+ db "LIGHTER @"
+NormalPrintText:
+ db "NORMAL @"
+DarkerPrintText:
+ db "DARKER @"
+DarkestPrintText:
+ db "DARKEST @"
+
+Func_41e7b:
+ ld a, [wPrinterSettings]
+ and a
+ jr z, .asm_41e93
+ cp $20
+ jr z, .asm_41e99
+ cp $60
+ jr z, .asm_41e9f
+ cp $7f
+ jr z, .asm_41ea5
+ ld c, $2
+ lb de, $20, $60
+ ret
+.asm_41e93
+ ld c, $0
+ lb de, $7f, $20
+ ret
+.asm_41e99
+ ld c, $1
+ lb de, $0, $40
+ ret
+.asm_41e9f
+ ld c, $3
+ lb de, $40, $7f
+ ret
+.asm_41ea5
+ ld c, $4
+ lb de, $60, $0
+ ret
+
+OptionsMenu_Dummy:
+ and a
+ ret
+
+OptionsMenu_Cancel:
+ ld a, [hJoy5]
+ and A_BUTTON
+ jr nz, .pressedCancel
+ and a
+ ret
+.pressedCancel
+ scf
+ ret
+
+Func_41eb7:
+ ld hl, wOptionsCursorLocation
+ ld a, [hJoy5]
+ cp D_DOWN
+ jr z, .pressedDown
+ cp D_UP
+ jr z, .pressedUp
+ and a
+ ret
+.pressedDown
+ ld a, [hl]
+ cp $7
+ jr nz, .doNotWrapAround
+ ld [hl], $0
+ scf
+ ret
+.doNotWrapAround
+ cp $4
+ jr c, .regularIncrement
+ ld [hl], $6
+.regularIncrement
+ inc [hl]
+ scf
+ ret
+.pressedUp
+ ld a, [hl]
+ cp $7
+ jr nz, .doNotMoveCursorToPrintOption
+ ld [hl], $4
+ scf
+ ret
+.doNotMoveCursorToPrintOption
+ and a
+ jr nz, .regularDecrement
+ ld [hl], $8
+.regularDecrement
+ dec [hl]
+ scf
+ ret
+
+Func_41ee9:
+ coord hl, 1, 1
+ ld de, SCREEN_WIDTH
+ ld c, 16
+.loop
+ ld [hl], " "
+ add hl, de
+ dec c
+ jr nz, .loop
+ coord hl, 1, 2
+ ld bc, SCREEN_WIDTH * 2
+ ld a, [wOptionsCursorLocation]
+ call AddNTimes
+ ld [hl], "▶"
+ ret
+
+Func_41f06:
+ coord hl, 0, 0
+ lb bc, SCREEN_HEIGHT - 2, SCREEN_WIDTH - 2
+ call TextBoxBorder
+ coord hl, 2, 2
+ ld de, AllOptionsText
+ call PlaceString
+ coord hl, 2, 16
+ ld de, OptionMenuCancelText
+ call PlaceString
+ xor a
+ ld [wOptionsCursorLocation], a
+ ld c, 5
+.loop
+ push bc
+ call Func_41c95
+ pop bc
+ ld hl, wOptionsCursorLocation
+ inc [hl]
+ dec c
+ jr nz, .loop
+ xor a
+ ld [wOptionsCursorLocation], a
+ inc a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Delay3
+ ret
+
+AllOptionsText:
+ db "TEXT SPEED :"
+ next "ANIMATION :"
+ next "BATTLESTYLE:"
+ next "SOUND:"
+ next "PRINT:@"
+
+OptionMenuCancelText:
+ db "CANCEL@"
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index 7ef14232..669d49db 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -49,9 +49,17 @@ RedrawPartyMenu_:
call GetPartyMonName
pop hl
call PlaceString ; print the pokemon's name
- callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
ld a,[hPartyMonIndex]
ld [wWhichPokemon],a
+ callab IsThisPartymonStarterPikachu_Party
+ jr nc, .regularMon
+ call CheckPikachuFollowingPlayer
+ jr z, .regularMon
+ ld a, $ff
+ ld [hPartyMonIndex], a
+.regularMon
+ callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
+ ld a, [wWhichPokemon]
inc a
ld [hPartyMonIndex],a
call LoadMonData
@@ -88,14 +96,14 @@ RedrawPartyMenu_:
pop hl
push hl
ld bc,20 + 1 ; down 1 row and right 1 column
- ld a,[hFlags_0xFFF6]
+ ld a,[hFlags_0xFFFA]
set 0,a
- ld [hFlags_0xFFF6],a
+ ld [hFlags_0xFFFA],a
add hl,bc
predef DrawHP2 ; draw HP bar and prints current / max HP
- ld a,[hFlags_0xFFF6]
+ ld a,[hFlags_0xFFFA]
res 0,a
- ld [hFlags_0xFFF6],a
+ ld [hFlags_0xFFFA],a
call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl
jr .printLevel
@@ -109,8 +117,8 @@ RedrawPartyMenu_:
jr nz,.placeMoveLearnabilityString
ld de,.notAbleToLearnMoveText
.placeMoveLearnabilityString
- ld bc,20 + 9 ; down 1 row and right 9 columns
push hl
+ ld bc,20 + 9 ; down 1 row and right 9 columns
add hl,bc
call PlaceString
pop hl
@@ -150,7 +158,7 @@ RedrawPartyMenu_:
ld l,a
ld de,wcd6d
ld a,BANK(EvosMovesPointerTable)
- ld bc,Mon133_EvosEnd - Mon133_EvosMoves
+ ld bc, $0d ; Mon133_EvosEnd - Mon133_EvosMoves
call FarCopyData
ld hl,wcd6d
ld de,.notAbleToEvolveText
@@ -176,9 +184,9 @@ RedrawPartyMenu_:
; if it does match
ld de,.ableToEvolveText
.placeEvolutionStoneString
- ld bc,20 + 9 ; down 1 row and right 9 columns
pop hl
push hl
+ ld bc,20 + 9 ; down 1 row and right 9 columns
add hl,bc
call PlaceString
pop hl
diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm
index 8ec31226..b31970c8 100755
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -121,18 +121,18 @@ RemoveItemByID:
ld b, a
xor a
ld [hItemToRemoveIndex], a
-.asm_17f40
+.loop
ld a, [hli]
- cp $ff
+ cp $ff ; have we reached the cancel button (terminator)
ret z
- cp b
- jr z, .asm_17f4f
+ cp b ; is the current item the item we want?
+ jr z, .foundItem ; if so, remove it from the inventory
inc hl
ld a, [hItemToRemoveIndex]
inc a
ld [hItemToRemoveIndex], a
- jr .asm_17f40
-.asm_17f4f
+ jr .loop
+.foundItem
ld a, $1
ld [wItemQuantity], a
ld a, [hItemToRemoveIndex]
diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm
index bc2be4ef..1cc02cbf 100755
--- a/engine/menu/players_pc.asm
+++ b/engine/menu/players_pc.asm
@@ -1,6 +1,4 @@
PlayerPC:
- ld hl, wd730
- set 6, [hl]
ld a, ITEM_NAME
ld [wNameListType], a
call SaveScreenTilesToBuffer1
@@ -17,14 +15,15 @@ PlayerPC:
call PrintText
PlayerPCMenu:
+ ld hl, wd730
+ set 6, [hl]
ld a, [wParentMenuItem]
ld [wCurrentMenuItem], a
ld hl, wFlags_0xcd60
set 5, [hl]
call LoadScreenTilesFromBuffer2
coord hl, 0, 0
- ld b, $8
- ld c, $e
+ lb bc, 8, 14
call TextBoxBorder
call UpdateSprites
coord hl, 2, 2
diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm
index 3078f1a9..5bc8f119 100755
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -2,53 +2,57 @@ ShowPokedexMenu:
call GBPalWhiteOut
call ClearScreen
call UpdateSprites
- ld a,[wListScrollOffset]
+ ld a, [wListScrollOffset]
push af
xor a
- ld [wCurrentMenuItem],a
- ld [wListScrollOffset],a
- ld [wLastMenuItem],a
+ ld [wCurrentMenuItem], a
+ ld [wListScrollOffset], a
+ ld [wLastMenuItem], a
inc a
- ld [wd11e],a
- ld [hJoy7],a
+ ld [wd11e], a
+ ld [hJoy7], a
.setUpGraphics
+ callab LoadPokedexTilePatterns
+.loop
ld b, SET_PAL_GENERIC
call RunPaletteCommand
- callab LoadPokedexTilePatterns
.doPokemonListMenu
- ld hl,wTopMenuItemY
- ld a,3
- ld [hli],a ; top menu item Y
+ ld hl, wTopMenuItemY
+ ld a, 3
+ ld [hli], a ; top menu item Y
xor a
- ld [hli],a ; top menu item X
+ ld [hli], a ; top menu item X
inc a
- ld [wMenuWatchMovingOutOfBounds],a
+ ld [wMenuWatchMovingOutOfBounds], a
inc hl
inc hl
- ld a,6
- ld [hli],a ; max menu item ID
- ld [hl],D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
+ ld a, 6
+ ld [hli], a ; max menu item ID
+ ld [hl], D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
call HandlePokedexListMenu
- jr c,.goToSideMenu ; if the player chose a pokemon from the list
+ jr c, .goToSideMenu ; if the player chose a pokemon from the list
.exitPokedex
xor a
- ld [wMenuWatchMovingOutOfBounds],a
- ld [wCurrentMenuItem],a
- ld [wLastMenuItem],a
- ld [hJoy7],a
- ld [wWastedByteCD3A],a
- ld [wOverrideSimulatedJoypadStatesMask],a
+ ld [wMenuWatchMovingOutOfBounds], a
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ ld [hJoy7], a
+ ld [wWastedByteCD3A], a
+ ld [wOverrideSimulatedJoypadStatesMask], a
pop af
- ld [wListScrollOffset],a
+ ld [wListScrollOffset], a
call GBPalWhiteOutWithDelay3
call RunDefaultPaletteCommand
jp ReloadMapData
+
.goToSideMenu
call HandlePokedexSideMenu
dec b
- jr z,.exitPokedex ; if the player chose Quit
+ jr z, .exitPokedex ; if the player chose Quit
+ dec b
+ jr z, .doPokemonListMenu ; if pokemon not seen or player pressed B button
dec b
- jr z,.doPokemonListMenu ; if pokemon not seen or player pressed B button
+ jr z, .loop
jp .setUpGraphics ; if pokemon data or area was shown
; handles the menu on the lower right in the pokedex screen
@@ -59,204 +63,337 @@ ShowPokedexMenu:
; 02: the pokemon has not been seen yet or the player pressed the B button
HandlePokedexSideMenu:
call PlaceUnfilledArrowMenuCursor
- ld a,[wCurrentMenuItem]
+ ld a, [wCurrentMenuItem]
push af
- ld b,a
- ld a,[wLastMenuItem]
+ ld b, a
+ ld a, [wLastMenuItem]
push af
- ld a,[wListScrollOffset]
+ ld a, [wListScrollOffset]
push af
add b
inc a
- ld [wd11e],a
- ld a,[wd11e]
+ ld [wd11e], a
+ ld a, [wd11e]
push af
- ld a,[wDexMaxSeenMon]
+ ld a, [wDexMaxSeenMon]
push af ; this doesn't need to be preserved
- ld hl,wPokedexSeen
+ ld hl, wPokedexSeen
call IsPokemonBitSet
- ld b,2
- jr z,.exitSideMenu
+ ld b, 2
+ jr z, .exitSideMenu
call PokedexToIndex
- ld hl,wTopMenuItemY
- ld a,10
- ld [hli],a ; top menu item Y
- ld a,15
- ld [hli],a ; top menu item X
+ ld hl, wTopMenuItemY
+ ld a, 8
+ ld [hli], a ; top menu item Y
+ ld a, 15
+ ld [hli], a ; top menu item X
xor a
- ld [hli],a ; current menu item ID
+ ld [hli], a ; current menu item ID
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)
+ ld a, 4
+ 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 [wMenuWatchMovingOutOfBounds],a
+ ld [hli], a ; old menu item ID
+ ld [wMenuWatchMovingOutOfBounds], a
+ ld [hJoy7], a
.handleMenuInput
call HandleMenuInput
- bit 1,a ; was the B button pressed?
- ld b,2
- jr nz,.buttonBPressed
- ld a,[wCurrentMenuItem]
+ bit 1, a ; was the B button pressed?
+ ld b, 2
+ jr nz, .buttonBPressed
+ ld a, [wCurrentMenuItem]
and a
- jr z,.choseData
+ jr z, .choseData
+ dec a
+ jr z, .choseCry
dec a
- jr z,.choseCry
+ jr z, .choseArea
dec a
- jr z,.choseArea
+ jr z, .chosePrint
.choseQuit
- ld b,1
+ ld b, 1
.exitSideMenu
pop af
- ld [wDexMaxSeenMon],a
+ ld [wDexMaxSeenMon], a
pop af
- ld [wd11e],a
+ ld [wd11e], a
pop af
- ld [wListScrollOffset],a
+ ld [wListScrollOffset], a
pop af
- ld [wLastMenuItem],a
+ ld [wLastMenuItem], a
pop af
- ld [wCurrentMenuItem],a
+ ld [wCurrentMenuItem], a
+ ld a, $1
+ ld [hJoy7], a
push bc
coord hl, 0, 3
- ld de,20
+ ld de, 20
lb bc, " ", 13
call DrawTileLine ; cover up the menu cursor in the pokemon list
pop bc
ret
+
.buttonBPressed
push bc
- coord hl, 15, 10
- ld de,20
- lb bc, " ", 7
+ coord hl, 15, 8
+ ld de, 20
+ lb bc, " ", 9
call DrawTileLine ; cover up the menu cursor in the side menu
pop bc
jr .exitSideMenu
+
.choseData
call ShowPokedexDataInternal
- ld b,0
+ ld b, 0
jr .exitSideMenu
+
; play pokemon cry
.choseCry
- ld a,[wd11e]
+ ld a, [wd11e]
call GetCryData
call PlaySound
jr .handleMenuInput
+
.choseArea
predef LoadTownMap_Nest ; display pokemon areas
- ld b,0
+ ld b, 0
+ jr .exitSideMenu
+
+.chosePrint
+ ld a, [hTilesetType]
+ push af
+ xor a
+ ld [hTilesetType], a
+ ld a, [wd11e]
+ ld [wcf91], a
+ callab PrintPokedexEntry
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call ClearScreen
+ pop af
+ ld [hTilesetType], a
+ ld b, $3
jr .exitSideMenu
; handles the list of pokemon on the left of the pokedex screen
; sets carry flag if player presses A, unsets carry flag if player presses B
HandlePokedexListMenu:
+ call Pokedex_DrawInterface
+.loop
+ call Pokedex_PlacePokemonList
+ call GBPalNormal
+ call HandleMenuInput
+ bit BIT_B_BUTTON, a ; was the B button pressed?
+ jp nz, .buttonBPressed
+ bit BIT_A_BUTTON, a ; was the A button pressed?
+ jp nz, .buttonAPressed
+.checkIfUpPressed
+ bit BIT_D_UP, a ; was Up pressed?
+ jr z, .checkIfDownPressed
+.upPressed ; scroll up one row
+ ld a, [wListScrollOffset]
+ and a
+ jp z, .loop
+ dec a
+ ld [wListScrollOffset], a
+ jp .loop
+
+.checkIfDownPressed
+ bit BIT_D_DOWN, a ; was Down pressed?
+ jr z, .checkIfRightPressed
+.downPressed ; scroll down one row
+ ld a, [wDexMaxSeenMon]
+ cp a, 7
+ jp c, .loop ; can't if the list is shorter than 7
+ sub a, 7
+ ld b, a
+ ld a, [wListScrollOffset]
+ cp b
+ jp z, .loop
+ inc a
+ ld [wListScrollOffset], a
+ jp .loop
+
+.checkIfRightPressed
+ bit BIT_D_RIGHT, a ; was Right pressed?
+ jr z, .checkIfLeftPressed
+.rightPressed ; scroll down 7 rows
+ ld a, [wDexMaxSeenMon]
+ cp a, 7
+ jp c, .loop ; can't if the list is shorter than 7
+ sub a, 6
+ ld b, a
+ ld a, [wListScrollOffset]
+ add a, 7
+ ld [wListScrollOffset], a
+ cp b
+ jp c, .loop
+ dec b
+ ld a, b
+ ld [wListScrollOffset], a
+ jp .loop
+
+.checkIfLeftPressed ; scroll up 7 rows
+ bit BIT_D_LEFT, a ; was Left pressed?
+ jr z, .buttonAPressed
+.leftPressed
+ ld a, [wListScrollOffset]
+ sub a, 7
+ ld [wListScrollOffset], a
+ jp nc, .loop
+ xor a
+ ld [wListScrollOffset], a
+ jp .loop
+
+.buttonAPressed
+ scf
+ ret
+
+.buttonBPressed
+ and a
+ ret
+
+Pokedex_DrawInterface:
xor a
- ld [H_AUTOBGTRANSFERENABLED],a
+ ld [H_AUTOBGTRANSFERENABLED], a
; draw the horizontal line separating the seen and owned amounts from the menu
- 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
+ coord hl, 15, 6
+ ld a, $7a ; horizontal line tile
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
coord hl, 14, 0
- ld [hl],$71 ; vertical line tile
+ ld [hl], $71 ; vertical line tile
coord hl, 14, 1
call DrawPokedexVerticalLine
coord hl, 14, 9
call DrawPokedexVerticalLine
- ld hl,wPokedexSeen
- ld b,wPokedexSeenEnd - wPokedexSeen
+ ld hl, wPokedexSeen
+ ld b, wPokedexSeenEnd - wPokedexSeen
call CountSetBits
ld de, wNumSetBits
- coord hl, 16, 3
+ coord hl, 16, 2
lb bc, 1, 3
call PrintNumber ; print number of seen pokemon
- ld hl,wPokedexOwned
- ld b,wPokedexOwnedEnd - wPokedexOwned
+ ld hl, wPokedexOwned
+ ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
ld de, wNumSetBits
- coord hl, 16, 6
+ coord hl, 16, 5
lb bc, 1, 3
call PrintNumber ; print number of owned pokemon
- coord hl, 16, 2
- ld de,PokedexSeenText
+ coord hl, 16, 1
+ ld de, PokedexSeenText
call PlaceString
- coord hl, 16, 5
- ld de,PokedexOwnText
+ coord hl, 16, 4
+ ld de, PokedexOwnText
call PlaceString
coord hl, 1, 1
- ld de,PokedexContentsText
+ ld de, PokedexContentsText
call PlaceString
- coord hl, 16, 10
- ld de,PokedexMenuItemsText
+ coord hl, 16, 8
+ ld de, PokedexMenuItemsText
call PlaceString
; find the highest pokedex number among the pokemon the player has seen
- ld hl,wPokedexSeenEnd - 1
- ld b,(wPokedexSeenEnd - wPokedexSeen) * 8 + 1
+ ld hl, wPokedexSeenEnd - 1
+ ld b, (wPokedexSeenEnd - wPokedexSeen) * 8 + 1
.maxSeenPokemonLoop
- ld a,[hld]
- ld c,8
+ ld a, [hld]
+ ld c, 8
.maxSeenPokemonInnerLoop
dec b
sla a
- jr c,.storeMaxSeenPokemon
+ jr c, .storeMaxSeenPokemon
dec c
- jr nz,.maxSeenPokemonInnerLoop
+ jr nz, .maxSeenPokemonInnerLoop
jr .maxSeenPokemonLoop
+
.storeMaxSeenPokemon
- ld a,b
- ld [wDexMaxSeenMon],a
+ ld a, b
+ ld [wDexMaxSeenMon], a
+ ret
+
+DrawPokedexVerticalLine:
+ ld c, 9 ; height of line
+ ld de, SCREEN_WIDTH ; width of screen
+ ld a, $71 ; vertical line tile
.loop
+ ld [hl], a
+ add hl, de
+ xor a, 1 ; toggle between vertical line tile and box tile
+ dec c
+ jr nz, .loop
+ ret
+
+PokedexSeenText:
+ db "SEEN@"
+
+PokedexOwnText:
+ db "OWN@"
+
+PokedexContentsText:
+ db "CONTENTS@"
+
+PokedexMenuItemsText:
+ db "DATA"
+ next "CRY"
+ next "AREA"
+ next "PRNT"
+ next "QUIT@"
+
+Pokedex_PlacePokemonList:
xor a
- ld [H_AUTOBGTRANSFERENABLED],a
+ ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 4, 2
lb bc, 14, 10
call ClearScreenArea
coord hl, 1, 3
- ld a,[wListScrollOffset]
- ld [wd11e],a
- ld d,7
- ld a,[wDexMaxSeenMon]
- cp a,7
- jr nc,.printPokemonLoop
- ld d,a
+ ld a, [wListScrollOffset]
+ ld [wd11e], a
+ ld d, 7
+ ld a, [wDexMaxSeenMon]
+ cp a, 7
+ jr nc, .printPokemonLoop
+ ld d, a
dec a
- ld [wMaxMenuItem],a
+ ld [wMaxMenuItem], a
; loop to print pokemon pokedex numbers and names
; if the player has owned the pokemon, it puts a pokeball beside the name
.printPokemonLoop
- ld a,[wd11e]
+ ld a, [wd11e]
inc a
- ld [wd11e],a
+ ld [wd11e], a
push af
push de
push hl
- ld de,-SCREEN_WIDTH
- add hl,de
- ld de,wd11e
+ ld de, -SCREEN_WIDTH
+ add hl, de
+ ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print the pokedex number
- ld de,SCREEN_WIDTH
- add hl,de
+ ld de, SCREEN_WIDTH
+ add hl, de
dec hl
push hl
- ld hl,wPokedexOwned
+ ld hl, wPokedexOwned
call IsPokemonBitSet
pop hl
- ld a," "
- jr z,.writeTile
- ld a,$72 ; pokeball tile
+ ld a, " "
+ jr z, .writeTile
+ ld a, $72 ; pokeball tile
.writeTile
- ld [hl],a ; put a pokeball next to pokemon that the player has owned
+ ld [hl], a ; put a pokeball next to pokemon that the player has owned
push hl
- ld hl,wPokedexSeen
+ ld hl, wPokedexSeen
call IsPokemonBitSet
- jr nz,.getPokemonName ; if the player has seen the pokemon
- ld de,.dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon
+ jr nz, .getPokemonName ; if the player has seen the pokemon
+ ld de, .dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon
jr .skipGettingName
+
.dashedLine ; for unseen pokemon in the list
db "----------@"
.getPokemonName
@@ -267,119 +404,29 @@ HandlePokedexListMenu:
inc hl
call PlaceString
pop hl
- ld bc,2 * 20
- add hl,bc
+ ld bc, 2 * 20
+ add hl, bc
pop de
pop af
- ld [wd11e],a
+ ld [wd11e], a
dec d
- jr nz,.printPokemonLoop
- ld a,01
- ld [H_AUTOBGTRANSFERENABLED],a
+ jr nz, .printPokemonLoop
+ ld a, 01
+ ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
- call GBPalNormal
- call HandleMenuInput
- bit 1,a ; was the B button pressed?
- jp nz,.buttonBPressed
-.checkIfUpPressed
- bit 6,a ; was Up pressed?
- jr z,.checkIfDownPressed
-.upPressed ; scroll up one row
- ld a,[wListScrollOffset]
- and a
- jp z,.loop
- dec a
- ld [wListScrollOffset],a
- jp .loop
-.checkIfDownPressed
- bit 7,a ; was Down pressed?
- jr z,.checkIfRightPressed
-.downPressed ; scroll down one row
- ld a,[wDexMaxSeenMon]
- cp a,7
- jp c,.loop ; can't if the list is shorter than 7
- sub a,7
- ld b,a
- ld a,[wListScrollOffset]
- cp b
- jp z,.loop
- inc a
- ld [wListScrollOffset],a
- jp .loop
-.checkIfRightPressed
- bit 4,a ; was Right pressed?
- jr z,.checkIfLeftPressed
-.rightPressed ; scroll down 7 rows
- ld a,[wDexMaxSeenMon]
- cp a,7
- jp c,.loop ; can't if the list is shorter than 7
- sub a,6
- ld b,a
- ld a,[wListScrollOffset]
- add a,7
- ld [wListScrollOffset],a
- cp b
- jp c,.loop
- dec b
- ld a,b
- ld [wListScrollOffset],a
- jp .loop
-.checkIfLeftPressed ; scroll up 7 rows
- bit 5,a ; was Left pressed?
- jr z,.buttonAPressed
-.leftPressed
- ld a,[wListScrollOffset]
- sub a,7
- ld [wListScrollOffset],a
- jp nc,.loop
- xor a
- ld [wListScrollOffset],a
- jp .loop
-.buttonAPressed
- scf
- ret
-.buttonBPressed
- and a
- ret
-
-DrawPokedexVerticalLine:
- ld c,9 ; height of line
- ld de,20 ; width of screen
- ld a,$71 ; vertical line tile
-.loop
- ld [hl],a
- add hl,de
- xor a,1 ; toggle between vertical line tile and box tile
- dec c
- jr nz,.loop
ret
-PokedexSeenText:
- db "SEEN@"
-
-PokedexOwnText:
- db "OWN@"
-
-PokedexContentsText:
- db "CONTENTS@"
-
-PokedexMenuItemsText:
- db "DATA"
- next "CRY"
- next "AREA"
- next "QUIT@"
-
; tests if a pokemon's bit is set in the seen or owned pokemon bit fields
; INPUT:
; [wd11e] = pokedex number
; hl = address of bit field
IsPokemonBitSet:
- ld a,[wd11e]
+ ld a, [wd11e]
dec a
- ld c,a
- ld b,FLAG_TEST
+ ld c, a
+ ld b, FLAG_TEST
predef FlagActionPredef
- ld a,c
+ ld a, c
and a
ret
@@ -392,195 +439,255 @@ ShowPokedexData:
; function to display pokedex data from inside the pokedex
ShowPokedexDataInternal:
- ld hl,wd72c
- set 1,[hl]
- ld a,$33 ; 3/7 volume
- ld [rNR50],a
+ ld hl, wd72c
+ set 1, [hl]
+ ld a, $33 ; 3/7 volume
+ ld [rNR50], a
+ ld a, [hTilesetType]
+ push af
+ xor a
+ ld [hTilesetType], a
call GBPalWhiteOut ; zero all palettes
- call ClearScreen
- ld a,[wd11e] ; pokemon ID
- ld [wcf91],a
+ ld a, [wd11e] ; pokemon ID
+ ld [wcf91], a
push af
ld b, SET_PAL_POKEDEX
call RunPaletteCommand
pop af
- ld [wd11e],a
- ld a,[hTilesetType]
- push af
- xor a
- ld [hTilesetType],a
+ ld [wd11e], a
+ call DrawDexEntryOnScreen
+ call c, Pokedex_PrintFlavorTextAtRow11
+.waitForButtonPress
+ call JoypadLowSensitivity
+ ld a, [hJoy5]
+ and a, A_BUTTON | B_BUTTON
+ jr z, .waitForButtonPress
+ pop af
+ ld [hTilesetType], a
+ call GBPalWhiteOut
+ call ClearScreen
+ call RunDefaultPaletteCommand
+ call LoadTextBoxTilePatterns
+ call GBPalNormal
+ ld hl, wd72c
+ res 1, [hl]
+ ld a, $77 ; max volume
+ ld [rNR50], a
+ ret
+
+HeightWeightText:
+ db "HT ?", $60, "??", $61
+ next "WT ???lb@"
+
+; XXX does anything point to this?
+PokeText:
+ db "#@"
+
+; horizontal line that divides the pokedex text description from the rest of the data
+PokedexDataDividerLine:
+ db $68, $69, $6B, $69, $6B
+ db $69, $6B, $69, $6B, $6B
+ db $6B, $6B, $69, $6B, $69
+ db $6B, $69, $6B, $69, $6A
+ db "@"
+
+DrawDexEntryOnScreen:
+ call ClearScreen
+
coord hl, 0, 0
- ld de,1
+ ld de, 1
lb bc, $64, SCREEN_WIDTH
call DrawTileLine ; draw top border
+
coord hl, 0, 17
ld b, $6f
call DrawTileLine ; draw bottom border
+
coord hl, 0, 1
- ld de,20
+ ld de, 20
lb bc, $66, $10
call DrawTileLine ; draw left border
+
coord hl, 19, 1
- ld b,$67
+ ld b, $67
call DrawTileLine ; draw right border
- ld a,$63 ; upper left corner tile
+
+ ld a, $63 ; upper left corner tile
Coorda 0, 0
- ld a,$65 ; upper right corner tile
+ ld a, $65 ; upper right corner tile
Coorda 19, 0
- ld a,$6c ; lower left corner tile
+ ld a, $6c ; lower left corner tile
Coorda 0, 17
- ld a,$6e ; lower right corner tile
+ ld a, $6e ; lower right corner tile
+
Coorda 19, 17
coord hl, 0, 9
- ld de,PokedexDataDividerLine
+
+ ld de, PokedexDataDividerLine
call PlaceString ; draw horizontal divider line
+
coord hl, 9, 6
- ld de,HeightWeightText
+ ld de, HeightWeightText
call PlaceString
+
call GetMonName
coord hl, 9, 2
call PlaceString
- ld hl,PokedexEntryPointers
- ld a,[wd11e]
+
+ ld hl, PokedexEntryPointers
+ ld a, [wd11e]
dec a
- ld e,a
- ld d,0
- add hl,de
- add hl,de
- ld a,[hli]
- ld e,a
- ld d,[hl] ; de = address of pokedex entry
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl] ; de = address of pokedex entry
+
coord hl, 9, 4
call PlaceString ; print species name
- ld h,b
- ld l,c
+
+ ld h, b
+ ld l, c
push de
- ld a,[wd11e]
+ ld a, [wd11e]
push af
call IndexToPokedex
+
coord hl, 2, 8
ld a, "№"
- ld [hli],a
- ld a,$f2
- ld [hli],a
- ld de,wd11e
+ ld [hli], a
+ ld a, $f2
+ ld [hli], a
+ ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print pokedex number
- ld hl,wPokedexOwned
+
+ ld hl, wPokedexOwned
call IsPokemonBitSet
pop af
- ld [wd11e],a
- ld a,[wcf91]
- ld [wd0b5],a
+ ld [wd11e], a
+ ld a, [wcf91]
+ ld [wd0b5], a
pop de
+
push af
push bc
push de
push hl
+
call Delay3
call GBPalNormal
call GetMonHeader ; load pokemon picture location
coord hl, 1, 1
call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture
- ld a,[wcf91]
+ ld a, [wcf91]
call PlayCry ; play pokemon cry
+
pop hl
pop de
pop bc
pop af
- ld a,c
+
+ ld a, c
and a
- jp z,.waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description
+ ret z ; 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
+ ld a, [de] ; reads feet, but a is overwritten without being used
coord hl, 12, 6
lb bc, 1, 2
call PrintNumber ; print feet (height)
- ld a,$60 ; feet symbol tile (one tick)
- ld [hl],a
+ ld a, $60 ; feet symbol tile (one tick)
+ ld [hl], a
inc de
inc de ; de = address of inches (height)
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
+ ld a, $61 ; inches symbol tile (two ticks)
+ ld [hl], a
; now print the weight (note that weight is stored in tenths of pounds internally)
inc de
inc de
inc de ; de = address of upper byte of weight
push de
; put weight in big-endian order at hDexWeight
- ld hl,hDexWeight
- ld a,[hl] ; save existing value of [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 [hDexWeight]
- ld a,[hl] ; save existing value of [hDexWeight + 1]
+ ld a, [de] ; a = upper byte of weight
+ 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 [hDexWeight + 1]
- ld de,hDexWeight
+ ld a, [de] ; a = lower byte of weight
+ 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
coord hl, 14, 8
- ld a,[hDexWeight + 1]
- sub a,10
- 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
+ ld a, [hDexWeight + 1]
+ sub a, 10
+ 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
.next
inc hl
- ld a,[hli]
- ld [hld],a ; make space for the decimal point by moving the last digit forward one tile
- ld [hl],$f2 ; decimal point tile
+ ld a, [hli]
+ 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 [hDexWeight + 1],a ; restore original value of [hDexWeight + 1]
+ ld [hDexWeight + 1], a ; restore original value of [hDexWeight + 1]
pop af
- ld [hDexWeight],a ; restore original value of [hDexWeight]
+ ld [hDexWeight], a ; restore original value of [hDexWeight]
pop hl
inc hl ; hl = address of pokedex description text
+ scf
+ ret
+
+Pokedex_PrintFlavorTextAtRow11:
coord bc, 1, 11
- ld a,2
- ld [$fff4],a
+Pokedex_PrintFlavorTextAtBC:
+ ld a, 2
+ ld [$fff9], a
call TextCommandProcessor ; print pokedex description text
xor a
- ld [$fff4],a
-.waitForButtonPress
- call JoypadLowSensitivity
- ld a,[hJoy5]
- and a,A_BUTTON | B_BUTTON
- jr z,.waitForButtonPress
- pop af
- ld [hTilesetType],a
- call GBPalWhiteOut
- call ClearScreen
- call RunDefaultPaletteCommand
- call LoadTextBoxTilePatterns
- call GBPalNormal
- ld hl,wd72c
- res 1,[hl]
- ld a,$77 ; max volume
- ld [rNR50],a
+ ld [$fff9], a
ret
-HeightWeightText:
- db "HT ?",$60,"??",$61,$4E,"WT ???lb@"
-
-; XXX does anything point to this?
-PokeText:
- db "#@"
-
-; horizontal line that divides the pokedex text description from the rest of the data
-PokedexDataDividerLine:
- db $68,$69,$6B,$69,$6B
- db $69,$6B,$69,$6B,$6B
- db $6B,$6B,$69,$6B,$69
- db $6B,$69,$6B,$69,$6A
- db $50
+Pokedex_PrepareDexEntryForPrinting:
+ coord hl, 0, 0
+ ld de, SCREEN_WIDTH
+ lb bc, $66, $d
+ call DrawTileLine
+ coord hl, 19, 0
+ ld b, $67
+ call DrawTileLine
+ coord hl, 0, 13
+ ld de, $1
+ lb bc, $6f, SCREEN_WIDTH
+ call DrawTileLine
+ ld a, $6c
+ Coorda 0, 13
+ ld a, $6e
+ Coorda 19, 13
+ ld a, [wPrinterPokedexEntryTextPointer]
+ ld l, a
+ ld a, [wPrinterPokedexEntryTextPointer + 1]
+ ld h, a
+ coord bc, 1, 1
+ ld a, [hFlags_0xFFFA]
+ set 3, a
+ ld [hFlags_0xFFFA], a
+ call Pokedex_PrintFlavorTextAtBC
+ ld a, [hFlags_0xFFFA]
+ res 3, a
+ ld [hFlags_0xFFFA], a
+ ret
; draws a line of tiles
; INPUT:
@@ -592,10 +699,10 @@ DrawTileLine:
push bc
push de
.loop
- ld [hl],b
- add hl,de
+ ld [hl], b
+ add hl, de
dec c
- jr nz,.loop
+ jr nz, .loop
pop de
pop bc
ret
@@ -606,19 +713,19 @@ PokedexToIndex:
; converts the Pokédex number at wd11e to an index
push bc
push hl
- ld a,[wd11e]
- ld b,a
- ld c,0
- ld hl,PokedexOrder
+ ld a, [wd11e]
+ ld b, a
+ ld c, 0
+ ld hl, PokedexOrder
.loop ; go through the list until we find an entry with a matching dex number
inc c
- ld a,[hli]
+ ld a, [hli]
cp b
- jr nz,.loop
+ jr nz, .loop
- ld a,c
- ld [wd11e],a
+ ld a, c
+ ld [wd11e], a
pop hl
pop bc
ret
@@ -627,14 +734,14 @@ IndexToPokedex:
; converts the indexédex number at wd11e to a Pokédex number
push bc
push hl
- ld a,[wd11e]
+ ld a, [wd11e]
dec a
- ld hl,PokedexOrder
- ld b,0
- ld c,a
- add hl,bc
- ld a,[hl]
- ld [wd11e],a
+ ld hl, PokedexOrder
+ ld b, 0
+ ld c, a
+ add hl, bc
+ ld a, [hl]
+ ld [wd11e], a
pop hl
pop bc
ret
diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm
index b48fa99c..2a8dcb83 100755
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -23,8 +23,7 @@ CeladonPrizeMenu:
ld [wTopMenuItemX],a
call PrintPrizePrice
coord hl, 0, 2
- ld b,$08
- ld c,$10
+ lb bc, 8, 16
call TextBoxBorder
call GetPrizeMenuId
call UpdateSprites
@@ -32,14 +31,14 @@ CeladonPrizeMenu:
call PrintText
call HandleMenuInput ; menu choice handler
bit 1,a ; keypress = B (Cancel)
- jr nz,.NoChoice
+ jr nz, .noChoice
ld a,[wCurrentMenuItem]
- cp a,$03 ; "NO,THANKS" choice
- jr z,.NoChoice
+ cp $03 ; "NO,THANKS" choice
+ jr z, .noChoice
call HandlePrizeChoice
-.NoChoice
- ld hl,wd730
- res 6,[hl]
+.noChoice
+ ld hl, wd730
+ res 6, [hl]
ret
RequireCoinCaseTextPtr:
@@ -64,70 +63,70 @@ GetPrizeMenuId:
; display the three prizes' names
; (distinguishing between Pokemon names
; and Items (specifically TMs) names)
- 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)
+ ld a, [hSpriteIndexOrTextID]
+ sub 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,0
- ld e,a
- ld hl,PrizeDifferentMenuPtrs
- add hl,de
- ld a,[hli]
- ld d,[hl]
- ld e,a
+ ld d, $0
+ ld e, a
+ ld hl, PrizeDifferentMenuPtrs
+ add hl, de
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
inc hl
push hl
- ld hl,wPrize1
+ ld hl, wPrize1
call CopyString
pop hl
- ld a,[hli]
- ld h,[hl]
- ld l,a
- ld de,wPrize1Price
- ld bc,6
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wPrize1Price
+ ld bc, $6
call CopyData
- ld a,[wWhichPrizeWindow]
- cp a,$02 ;is TM_menu?
- jr nz,.putMonName
- ld a,[wPrize1]
- ld [wd11e],a
+ ld a, [wWhichPrizeWindow]
+ cp $02 ;is TM_menu?
+ jr nz, .putMonName
+ ld a, [wPrize1]
+ ld [wd11e], a
call GetItemName
coord hl, 2, 4
call PlaceString
- ld a,[wPrize2]
- ld [wd11e],a
+ ld a, [wPrize2]
+ ld [wd11e], a
call GetItemName
coord hl, 2, 6
call PlaceString
- ld a,[wPrize3]
- ld [wd11e],a
+ ld a, [wPrize3]
+ ld [wd11e], a
call GetItemName
coord hl, 2, 8
call PlaceString
jr .putNoThanksText
.putMonName
- ld a,[wPrize1]
- ld [wd11e],a
+ ld a, [wPrize1]
+ ld [wd11e], a
call GetMonName
coord hl, 2, 4
call PlaceString
- ld a,[wPrize2]
- ld [wd11e],a
+ ld a, [wPrize2]
+ ld [wd11e], a
call GetMonName
coord hl, 2, 6
call PlaceString
- ld a,[wPrize3]
- ld [wd11e],a
+ ld a, [wPrize3]
+ ld [wd11e], a
call GetMonName
coord hl, 2, 8
call PlaceString
.putNoThanksText
coord hl, 2, 10
- ld de,NoThanksText
+ ld de, NoThanksText
call PlaceString
; put prices on the right side of the textbox
- ld de,wPrize1Price
+ ld de, wPrize1Price
coord hl, 13, 5
; reg. c:
; [low nybble] number of bytes
@@ -138,91 +137,93 @@ GetPrizeMenuId:
call PrintBCDNumber
ld de,wPrize2Price
coord hl, 13, 7
- ld c,(%1 << 7 | 2)
+ ld c, (1 << 7 | 2)
call PrintBCDNumber
- ld de,wPrize3Price
+ ld de, wPrize3Price
coord hl, 13, 9
- ld c,(1 << 7 | 2)
+ ld c, (1 << 7 | 2)
jp PrintBCDNumber
+NoThanksText:
+ db "NO THANKS@"
+
INCLUDE "data/prizes.asm"
PrintPrizePrice:
coord hl, 11, 0
- ld b,$01
- ld c,$07
+ lb bc, 1, 7
call TextBoxBorder
call UpdateSprites
coord hl, 12, 0
- ld de,.CoinText
+ ld de, CoinString
call PlaceString
coord hl, 13, 1
- ld de,.SixSpacesText
+ ld de, SixSpacesString
call PlaceString
coord hl, 13, 1
ld de,wPlayerCoins
- ld c,%10000010
+ ld c, (1 << 7 | 2)
call PrintBCDNumber
ret
-.CoinText
+CoinString:
db "COIN@"
-.SixSpacesText
+SixSpacesString:
db " @"
LoadCoinsToSubtract:
ld a,[wWhichPrize]
add a
- ld d,0
- ld e,a
- ld hl,wPrize1Price
- add hl,de ; get selected prize's price
+ ld d, $0
+ ld e, a
+ ld hl, wPrize1Price
+ add hl, de ; get selected prize's price
xor a
- ld [hUnusedCoinsByte],a
- ld a,[hli]
- ld [hCoins],a
- ld a,[hl]
- ld [hCoins + 1],a
+ ld [hUnusedCoinsByte], a
+ ld a, [hli]
+ ld [hCoins], a
+ ld a, [hl]
+ ld [hCoins + 1], a
ret
HandlePrizeChoice:
- ld a,[wCurrentMenuItem]
- ld [wWhichPrize],a
- ld d,0
- ld e,a
- ld hl,wPrize1
- add hl,de
- ld a,[hl]
- ld [wd11e],a
- ld a,[wWhichPrizeWindow]
- cp a,$02 ; is prize a TM?
- jr nz,.GetMonName
+ ld a, [wCurrentMenuItem]
+ ld [wWhichPrize], a
+ ld d, $0
+ ld e, a
+ ld hl, wPrize1
+ add hl, de
+ ld a, [hl]
+ ld [wd11e], a
+ ld a, [wWhichPrizeWindow]
+ cp $02 ; is prize a TM?
+ jr nz, .getMonName
call GetItemName
- jr .GivePrize
-.GetMonName
+ jr .givePrize
+.getMonName
call GetMonName
-.GivePrize
+.givePrize
ld hl,SoYouWantPrizeTextPtr
call PrintText
call YesNoChoice
- ld a,[wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
+ ld a, [wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
and a
- jr nz,.PrintOhFineThen
+ jr nz, .printOhFineThen
call LoadCoinsToSubtract
call HasEnoughCoins
- jr c,.NotEnoughCoins
- ld a,[wWhichPrizeWindow]
- cp a,$02
- jr nz,.GiveMon
+ jr c, .notEnoughCoins
+ ld a, [wWhichPrizeWindow]
+ cp $02
+ jr nz, .giveMon
ld a,[wd11e]
- ld b,a
- ld a,1
- ld c,a
+ ld b, a
+ ld a, 1
+ ld c, a
call GiveItem
- jr nc,.BagFull
- jr .SubtractCoins
-.GiveMon
+ jr nc, .bagFull
+ jr .subtractCoins
+.giveMon
ld a,[wd11e]
ld [wcf91],a
push af
@@ -243,24 +244,24 @@ HandlePrizeChoice:
; were full), return without subtracting coins.
ret nc
-.SubtractCoins
+.subtractCoins
call LoadCoinsToSubtract
ld hl,hCoins + 1
ld de,wPlayerCoins + 1
ld c,$02 ; how many bytes
predef SubBCDPredef
jp PrintPrizePrice
-.BagFull
+.bagFull
ld hl,PrizeRoomBagIsFullTextPtr
jp PrintText
-.NotEnoughCoins
+.notEnoughCoins
ld hl,SorryNeedMoreCoinsText
jp PrintText
-.PrintOhFineThen
+.printOhFineThen
ld hl,OhFineThenTextPtr
jp PrintText
-UnknownData52951:
+UnknownData528b1:
; XXX what's this?
db $00,$01,$00,$01,$00,$01,$00,$00,$01
@@ -289,18 +290,18 @@ OhFineThenTextPtr:
db "@"
GetPrizeMonLevel:
- ld a,[wcf91]
- ld b,a
- ld hl,PrizeMonLevelDictionary
+ ld a, [wcf91]
+ ld b, a
+ ld hl, PrizeMonLevelDictionary
.loop
- ld a,[hli]
+ ld a, [hli]
cp b
- jr z,.matchFound
+ jr z, .matchFound
inc hl
jr .loop
.matchFound
- ld a,[hl]
- ld [wCurEnemyLVL],a
+ ld a, [hl]
+ ld [wCurEnemyLVL], a
ret
INCLUDE "data/prize_mon_levels.asm"
diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm
index 029d8c01..16a9973d 100755
--- a/engine/menu/start_menu.asm
+++ b/engine/menu/start_menu.asm
@@ -1,85 +1,84 @@
DisplayStartMenu::
- ld a,BANK(StartMenu_Pokedex)
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
- ld a,[wWalkBikeSurfState] ; walking/biking/surfing
- ld [wWalkBikeSurfStateCopy],a
- ld a, SFX_START_MENU
+ switchbank StartMenu_Pokedex ; also bank for other functions
+ ld a, [wWalkBikeSurfState] ; walking/biking/surfing
+ ld [wWalkBikeSurfStateCopy], a
+ ld a, $8f ; (SFX_02_3f - SFX_Headers_02) / 3 ; Start menu sound
call PlaySound
RedisplayStartMenu::
callba DrawStartMenu
+RedisplayStartMenu_DoNotDrawStartMenu:
callba PrintSafariZoneSteps ; print Safari Zone info, if in Safari Zone
call UpdateSprites
.loop
call HandleMenuInput
- ld b,a
+ ld b, a
.checkIfUpPressed
- bit 6,a ; was Up pressed?
- jr z,.checkIfDownPressed
- ld a,[wCurrentMenuItem] ; menu selection
+ bit 6, a ; was Up pressed?
+ jr z, .checkIfDownPressed
+ ld a, [wCurrentMenuItem] ; menu selection
and a
- jr nz,.loop
- ld a,[wLastMenuItem]
+ jr nz, .loop
+ ld a, [wLastMenuItem]
and a
- jr nz,.loop
+ jr nz, .loop
; if the player pressed tried to go past the top item, wrap around to the bottom
- CheckEvent EVENT_GOT_POKEDEX
- ld a,6 ; there are 7 menu items with the pokedex, so the max index is 6
- jr nz,.wrapMenuItemId
+ CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex?
+ ld a, 6 ; there are 7 menu items with the pokedex, so the max index is 6
+ jr nz, .wrapMenuItemId
dec a ; there are only 6 menu items without the pokedex
.wrapMenuItemId
- ld [wCurrentMenuItem],a
+ ld [wCurrentMenuItem], a
call EraseMenuCursor
jr .loop
.checkIfDownPressed
- bit 7,a
- jr z,.buttonPressed
+ bit 7, a
+ jr z, .buttonPressed
; if the player pressed tried to go past the bottom item, wrap around to the top
- CheckEvent EVENT_GOT_POKEDEX
- ld a,[wCurrentMenuItem]
- ld c,7 ; there are 7 menu items with the pokedex
- jr nz,.checkIfPastBottom
+ CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex?
+ ld a, [wCurrentMenuItem]
+ ld c, 7 ; there are 7 menu items with the pokedex
+ jr nz, .checkIfPastBottom
dec c ; there are only 6 menu items without the pokedex
.checkIfPastBottom
cp c
- jr nz,.loop
+ jr nz, .loop
; the player went past the bottom, so wrap to the top
xor a
- ld [wCurrentMenuItem],a
+ ld [wCurrentMenuItem], a
call EraseMenuCursor
jr .loop
.buttonPressed ; A, B, or Start button pressed
call PlaceUnfilledArrowMenuCursor
- ld a,[wCurrentMenuItem]
- ld [wBattleAndStartSavedMenuItem],a ; save current menu selection
- ld a,b
- and a,%00001010 ; was the Start button or B button pressed?
- jp nz,CloseStartMenu
+ ld a, [wCurrentMenuItem]
+ ld [wBattleAndStartSavedMenuItem], a ; save current menu selection
+ ld a, b
+ and a, %00001010 ; was the Start button or B button pressed?
+ jp nz, CloseStartMenu
call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2
- CheckEvent EVENT_GOT_POKEDEX
- ld a,[wCurrentMenuItem]
- jr nz,.displayMenuItem
+ CheckEvent EVENT_GOT_POKEDEX ; does the player have the pokedex?
+ ld a, [wCurrentMenuItem]
+ jr nz, .displayMenuItem
inc a ; adjust position to account for missing pokedex menu item
.displayMenuItem
- cp a,0
- jp z,StartMenu_Pokedex
- cp a,1
- jp z,StartMenu_Pokemon
- cp a,2
- jp z,StartMenu_Item
- cp a,3
- jp z,StartMenu_TrainerInfo
- cp a,4
- jp z,StartMenu_SaveReset
- cp a,5
- jp z,StartMenu_Option
+ cp a, 0
+ jp z, StartMenu_Pokedex
+ cp a, 1
+ jp z, StartMenu_Pokemon
+ cp a, 2
+ jp z, StartMenu_Item
+ cp a, 3
+ jp z, StartMenu_TrainerInfo
+ cp a, 4
+ jp z, StartMenu_SaveReset
+ cp a, 5
+ jp z, StartMenu_Option
; EXIT falls through to here
CloseStartMenu::
call Joypad
- ld a,[hJoyPressed]
- bit 0,a ; was A button newly pressed?
- jr nz,CloseStartMenu
+ ld a, [hJoyPressed]
+ bit 0, a ; was A button newly pressed?
+ jr nz, CloseStartMenu
call LoadTextBoxTilePatterns
jp CloseTextDisplay
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index 9ae6cbe5..fc553d93 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -34,7 +34,7 @@ StartMenu_Pokemon:
ld [wTextBoxID],a
call DisplayTextBoxID ; display pokemon menu options
ld hl,wFieldMoves
- lb bc, $02, $0c ; max menu item ID, top menu item Y
+ lb bc, 2, 12 ; max menu item ID, top menu item Y
ld e,5
.adjustMenuVariablesLoop
dec e
@@ -129,7 +129,7 @@ StartMenu_Pokemon:
dw .dig
dw .teleport
dw .softboiled
-.fly
+.fly ; 11d1b (4:5d1b)
bit 2,a ; does the player have the Thunder Badge?
jp z,.newBadgeRequired
call CheckIfInOutsideMap
@@ -144,12 +144,15 @@ StartMenu_Pokemon:
call ChooseFlyDestination
ld a,[wd732]
bit 3,a ; did the player decide to fly?
- jp nz,.goBackToMap
+ jr nz,.asm_5d4c
call LoadFontTilePatterns
ld hl,wd72e
set 1,[hl]
jp StartMenu_Pokemon
-.cut
+.asm_5d4c
+ call Func_1510
+ jp .goBackToMap
+.cut ; 11d52 (4:5d52)
bit 1,a ; does the player have the Cascade Badge?
jp z,.newBadgeRequired
predef UsedCut
@@ -157,7 +160,7 @@ StartMenu_Pokemon:
and a
jp z,.loop
jp CloseTextDisplay
-.surf
+.surf ; 11d66 (4:5d66)
bit 4,a ; does the player have the Soul Badge?
jp z,.newBadgeRequired
callba IsSurfingAllowed
@@ -165,22 +168,35 @@ StartMenu_Pokemon:
bit 1,[hl]
res 1,[hl]
jp z,.loop
+ ld a, [wcf91]
+ cp PIKACHU ; is this surfing pikachu?
+ jr z, .surfingPikachu
+ ld a, $1
+ jr .continue
+.surfingPikachu
+ ld a, $2
+.continue
+ ld [wd473], a
ld a,SURFBOARD
ld [wcf91],a
ld [wPseudoItemID],a
call UseItem
ld a,[wActionResultOrTookBattleTurn]
and a
- jp z,.loop
+ jr z,.reloadNormalSprite
call GBPalWhiteOutWithDelay3
jp .goBackToMap
-.strength
+.reloadNormalSprite
+ xor a
+ ld [wd473], a
+ jp .loop
+.strength ; 11dab (4:5dab)
bit 3,a ; does the player have the Rainbow Badge?
jp z,.newBadgeRequired
predef PrintStrengthTxt
call GBPalWhiteOutWithDelay3
jp .goBackToMap
-.flash
+.flash ; 11dbb (4:5dbb)
bit 0,a ; does the player have the Boulder Badge?
jp z,.newBadgeRequired
xor a
@@ -192,7 +208,7 @@ StartMenu_Pokemon:
.flashLightsAreaText
TX_FAR _FlashLightsAreaText
db "@"
-.dig
+.dig ; 11dd5 (4:5dd5)
ld a,ESCAPE_ROPE
ld [wcf91],a
ld [wPseudoItemID],a
@@ -202,7 +218,7 @@ StartMenu_Pokemon:
jp z,.loop
call GBPalWhiteOutWithDelay3
jp .goBackToMap
-.teleport
+.teleport ; 11ded (4:5ded)
call CheckIfInOutsideMap
jr z,.canTeleport
ld a,[wWhichPokemon]
@@ -217,12 +233,13 @@ StartMenu_Pokemon:
ld hl,wd732
set 3,[hl]
set 6,[hl]
+ call Func_1510
ld hl,wd72e
set 1,[hl]
res 4,[hl]
ld c,60
call DelayFrames
- call GBPalWhiteOutWithDelay3 ; zero all three palettes and wait 3 V-blanks
+ call GBPalWhiteOutWithDelay3 ; zero all three palettes and wait 3 frames
jp .goBackToMap
.warpToLastPokemonCenterText
TX_FAR _WarpToLastPokemonCenterText
@@ -233,7 +250,7 @@ StartMenu_Pokemon:
.cannotFlyHereText
TX_FAR _CannotFlyHereText
db "@"
-.softboiled
+.softboiled ; 11e35 (4:5e35)
ld hl,wPartyMon1MaxHP
ld a,[wWhichPokemon]
ld bc,wPartyMon2 - wPartyMon1
@@ -307,11 +324,10 @@ StartMenu_Item:
call PrintText
jr .exitMenu
.notInCableClubRoom
- ld bc,wNumBagItems
ld hl,wListPointer
- ld a,c
- ld [hli],a
- ld [hl],b ; store item bag pointer in wListPointer (for DisplayListMenuID)
+ ld [hl], wNumBagItems & $ff
+ inc hl
+ ld [hl], wNumBagItems / $100 ; store item bag pointer in wListPointer (for DisplayListMenuID)
xor a
ld [wPrintItemPrices],a
ld a,ITEMLISTMENU
@@ -515,10 +531,11 @@ StartMenu_TrainerInfo:
call LoadScreenTilesFromBuffer2 ; restore saved screen
call RunDefaultPaletteCommand
call ReloadMapData
+ callba DrawStartMenu ; XXX what difference does this make?
call LoadGBPal
pop af
ld [hTilesetType],a
- jp RedisplayStartMenu
+ jp RedisplayStartMenu_DoNotDrawStartMenu
; loads tile patterns and draws everything except for gym leader faces / badges
DrawTrainerInfo:
@@ -552,7 +569,7 @@ DrawTrainerInfo:
ld de,vChars2 + $200
ld bc,$0400
ld a,$03
- call FarCopyData2
+ call FarCopyData
ld hl,TextBoxGraphics
ld de,$00d0
add hl,de ; hl = colon tile pattern
@@ -560,7 +577,7 @@ DrawTrainerInfo:
ld bc,$0010
ld a,$04
push bc
- call FarCopyData2
+ call FarCopyData
pop bc
ld hl,TrainerInfoTextBoxTileGraphics + $80 ; background tile pattern
ld de,vChars1 + $570
@@ -612,7 +629,7 @@ DrawTrainerInfo:
TrainerInfo_FarCopyData:
ld a,BANK(TrainerInfoTextBoxTileGraphics)
- jp FarCopyData2
+ jp FarCopyData
TrainerInfo_NameMoneyTimeText:
db "NAME/"
diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm
index 4770483d..932d206a 100755
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -40,7 +40,7 @@ DrawHP_:
push hl
call DrawHPBar
pop hl
- ld a, [hFlags_0xFFF6]
+ ld a, [hFlags_0xFFFA]
bit 0, a
jr z, .printFractionBelowBar
ld bc, $9 ; right of bar
@@ -170,8 +170,25 @@ StatusScreen:
call GBPalNormal
coord hl, 1, 0
call LoadFlippedFrontSpriteByMonIndex ; draw Pokémon picture
+ ld a, [wMonDataLocation]
+ cp ENEMY_PARTY_DATA
+ jr z, .playRegularCry
+ cp BOX_DATA
+ jr z, .checkBoxData
+ callab IsThisPartymonStarterPikachu_Party
+ jr nc, .playRegularCry
+ jr .playPikachuSoundClip
+.checkBoxData
+ callab IsThisPartymonStarterPikachu_Box
+ jr nc, .playRegularCry
+.playPikachuSoundClip
+ ld e, 16
+ callab PlayPikachuSoundClip
+ jr .continue
+.playRegularCry
ld a, [wcf91]
call PlayCry ; play Pokémon cry
+.continue
call WaitForTextScrollButtonPress ; wait for button
pop af
ld [hTilesetType], a
@@ -223,7 +240,7 @@ OKText:
db "OK@"
; Draws a line starting from hl high b and wide c
-DrawLineBox: ; 0x12ac7
+DrawLineBox:
ld de, SCREEN_WIDTH ; New line
.PrintVerticalLine
ld [hl], $78 ; │
@@ -240,7 +257,7 @@ DrawLineBox: ; 0x12ac7
ld [hl], $6f ; ← (halfarrow ending)
ret
-PTile: ; 12adc (4:6adc) ; This is a single 1bpp "P" tile
+PTile: ; 11682 (4:5682) ; This is a single 1bpp "P" tile
INCBIN "gfx/p_tile.1bpp"
PTileEnd:
@@ -249,16 +266,14 @@ PrintStatsBox:
and a ; a is 0 from the status screen
jr nz, .DifferentBox
coord hl, 0, 8
- ld b, $8
- ld c, $8
+ lb bc, 8, 8
call TextBoxBorder ; Draws the box
coord hl, 1, 9 ; Start printing stats from here
ld bc, $0019 ; Number offset
jr .PrintStats
.DifferentBox
coord hl, 9, 2
- ld b, $8
- ld c, $9
+ lb bc, 8, 9
call TextBoxBorder
coord hl, 11, 3
ld bc, $0018
@@ -279,7 +294,7 @@ PrintStatsBox:
call PrintStat
ld de, wLoadedMonSpecial
jp PrintNumber
-PrintStat
+PrintStat:
push hl
call PrintNumber
pop hl
@@ -313,8 +328,7 @@ StatusScreen2:
coord hl, 19, 3
ld [hl], $78
coord hl, 0, 8
- ld b, 8
- ld c, 18
+ lb bc, 8, 18
call TextBoxBorder ; Draw move container
coord hl, 2, 9
ld de, wMovesString
@@ -335,11 +349,11 @@ StatusScreen2:
ld c, a
ld a, "-"
call StatusScreen_PrintPP ; Fill the rest with --
-.InitPP ; 12bbb
+.InitPP ; 1175e
ld hl, wLoadedMonMoves
coord de, 14, 10
ld b, 0
-.PrintPP ; 12bc3
+.PrintPP ; 11766
ld a, [hli]
and a
jr z, .PPDone
diff --git a/engine/menu/swap_items.asm b/engine/menu/swap_items.asm
new file mode 100644
index 00000000..b1fa78be
--- /dev/null
+++ b/engine/menu/swap_items.asm
@@ -0,0 +1,149 @@
+HandleItemListSwapping:
+ ld a,[wListMenuID]
+ cp a,ITEMLISTMENU
+ jp nz,DisplayListMenuIDLoop ; only rearrange item list menus
+ push hl
+ ld hl,wListPointer
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a
+ inc hl ; hl = beginning of list entries
+ ld a,[wCurrentMenuItem]
+ ld b,a
+ ld a,[wListScrollOffset]
+ add b
+ add a
+ ld c,a
+ ld b,0
+ add hl,bc ; hl = address of currently selected item entry
+ ld a,[hl]
+ pop hl
+ inc a
+ jp z,DisplayListMenuIDLoop ; ignore attempts to swap the Cancel menu item
+ ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
+ and a ; has the first item to swap already been chosen?
+ jr nz,.swapItems
+; if not, set the currently selected item as the first item
+ ld a,[wCurrentMenuItem]
+ inc a
+ ld b,a
+ ld a,[wListScrollOffset] ; index of top (visible) menu item within the list
+ add b
+ ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1)
+ ld c,20
+ call DelayFrames
+ jp DisplayListMenuIDLoop
+.swapItems
+ ld a,[wCurrentMenuItem]
+ inc a
+ ld b,a
+ ld a,[wListScrollOffset]
+ add b
+ ld b,a
+ ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
+ cp b ; is the currently selected item the same as the first item to swap?
+ jp z,DisplayListMenuIDLoop ; ignore attempts to swap an item with itself
+ dec a
+ ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1)
+ ld c,20
+ call DelayFrames
+ push hl
+ push de
+ ld hl,wListPointer
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a
+ inc hl ; hl = beginning of list entries
+ ld d,h
+ ld e,l ; de = beginning of list entries
+ ld a,[wCurrentMenuItem]
+ ld b,a
+ ld a,[wListScrollOffset]
+ add b
+ add a
+ ld c,a
+ ld b,0
+ add hl,bc ; hl = address of currently selected item entry
+ ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
+ add a
+ add e
+ ld e,a
+ jr nc,.noCarry
+ inc d
+.noCarry ; de = address of first item to swap
+ ld a,[de]
+ ld b,a
+ ld a,[hli]
+ cp b
+ jr z,.swapSameItemType
+.swapDifferentItems
+ ld [$ff95],a ; [$ff95] = second item ID
+ ld a,[hld]
+ ld [$ff96],a ; [$ff96] = second item quantity
+ ld a,[de]
+ ld [hli],a ; put first item ID in second item slot
+ inc de
+ ld a,[de]
+ ld [hl],a ; put first item quantity in second item slot
+ ld a,[$ff96]
+ ld [de],a ; put second item quantity in first item slot
+ dec de
+ ld a,[$ff95]
+ ld [de],a ; put second item ID in first item slot
+ xor a
+ ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped
+ pop de
+ pop hl
+ jp DisplayListMenuIDLoop
+.swapSameItemType
+ inc de
+ ld a,[hl]
+ ld b,a
+ ld a,[de]
+ add b ; a = sum of both item quantities
+ cp a,100 ; is the sum too big for one item slot?
+ jr c,.combineItemSlots
+; swap enough items from the first slot to max out the second slot if they can't be combined
+ sub a,99
+ ld [de],a
+ ld a,99
+ ld [hl],a
+ jr .done
+.combineItemSlots
+ ld [hl],a ; put the sum in the second item slot
+ ld hl,wListPointer
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a
+ dec [hl] ; decrease the number of items
+ ld a,[hl]
+ ld [wListCount],a ; update number of items variable
+ cp a,1
+ jr nz,.skipSettingMaxMenuItemID
+ ld [wMaxMenuItem],a ; if the number of items is only one now, update the max menu item ID
+.skipSettingMaxMenuItemID
+ dec de
+ ld h,d
+ ld l,e
+ inc hl
+ inc hl ; hl = address of item after first item to swap
+.moveItemsUpLoop ; erase the first item slot and move up all the following item slots to fill the gap
+ ld a,[hli]
+ ld [de],a
+ inc de
+ inc a ; reached the $ff terminator?
+ jr z,.afterMovingItemsUp
+ ld a,[hli]
+ ld [de],a
+ inc de
+ jr .moveItemsUpLoop
+.afterMovingItemsUp
+ xor a
+ ld [wListScrollOffset],a
+ ld [wCurrentMenuItem],a
+.done
+ xor a
+ ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped
+ pop de
+ pop hl
+ jp DisplayListMenuIDLoop
diff --git a/engine/menu/text_ids1.asm b/engine/menu/text_ids1.asm
new file mode 100644
index 00000000..e2fd76f4
--- /dev/null
+++ b/engine/menu/text_ids1.asm
@@ -0,0 +1,163 @@
+; function that performs initialization for DisplayTextID
+DisplayTextIDInit:
+ xor a
+ ld [wListMenuID],a
+ ld a,[wAutoTextBoxDrawingControl]
+ bit 0,a
+ jr nz,.skipDrawingTextBoxBorder
+ ld a,[hSpriteIndexOrTextID] ; text ID (or sprite ID)
+ and a
+ jr nz,.notStartMenu
+; if text ID is 0 (i.e. the start menu)
+; Note that the start menu text border is also drawn in the function directly
+; below this, so this seems unnecessary.
+ CheckEvent EVENT_GOT_POKEDEX
+; start menu with pokedex
+ coord hl, 10, 0
+ lb bc, 14, 8
+ jr nz,.drawTextBoxBorder
+; start menu without pokedex
+ coord hl, 10, 0
+ lb bc, 12, 8
+ jr .drawTextBoxBorder
+; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
+.notStartMenu
+ coord hl, 0, 12
+ lb bc, 4, 18
+.drawTextBoxBorder
+ call TextBoxBorder
+.skipDrawingTextBoxBorder
+ ld hl,wFontLoaded
+ set 0,[hl]
+ ld hl,wFlags_0xcd60
+ bit 4,[hl]
+ res 4,[hl]
+ jr nz,.skipMovingSprites
+ call UpdateSprites
+.skipMovingSprites
+; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite
+; this is done because when you talk to an NPC, they turn to look your way
+; the original direction they were facing must be restored after the dialogue is over
+ ld hl,wSpriteStateData1 + $19
+ ld c,$0f
+ ld de,$0010
+.spriteFacingDirectionCopyLoop
+ ld a,[hl]
+ inc h
+ ld [hl],a
+ dec h
+ add hl,de
+ dec c
+ jr nz,.spriteFacingDirectionCopyLoop
+; loop to force all the sprites in the middle of animation to stand still
+; (so that they don't like they're frozen mid-step during the dialogue)
+ ld hl,wSpriteStateData1 + 2
+ ld de,$0010
+ ld c,e
+.spriteStandStillLoop
+ ld a,[hl]
+ cp a,$ff ; is the sprite visible?
+ jr z,.nextSprite
+; if it is visible
+ and a,$fc
+ ld [hl],a
+.nextSprite
+ add hl,de
+ dec c
+ jr nz,.spriteStandStillLoop
+ ld b,vBGMap1 / $100 ; window background address
+ call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
+ xor a
+ ld [hWY],a ; put the window on the screen
+ call LoadFontTilePatterns
+ ld a,$01
+ ld [H_AUTOBGTRANSFERENABLED],a ; enable continuous WRAM to VRAM transfer each V-blank
+ ret
+
+; function that displays the start menu
+DrawStartMenu:
+ CheckEvent EVENT_GOT_POKEDEX
+; menu with pokedex
+ coord hl, 10, 0
+ lb bc, 14, 8
+ jr nz,.drawTextBoxBorder
+; shorter menu if the player doesn't have the pokedex
+ coord hl, 10, 0
+ lb bc, 12, 8
+.drawTextBoxBorder
+ call TextBoxBorder
+ ld a,D_DOWN | D_UP | START | B_BUTTON | A_BUTTON
+ ld [wMenuWatchedKeys],a
+ ld a,$02
+ ld [wTopMenuItemY],a ; Y position of first menu choice
+ ld a,$0b
+ ld [wTopMenuItemX],a ; X position of first menu choice
+ ld a,[wBattleAndStartSavedMenuItem] ; remembered menu selection from last time
+ ld [wCurrentMenuItem],a
+ ld [wLastMenuItem],a
+ xor a
+ ld [wMenuWatchMovingOutOfBounds],a
+ ld hl,wd730
+ set 6,[hl] ; no pauses between printing each letter
+ coord hl, 12, 2
+ CheckEvent EVENT_GOT_POKEDEX
+; case for not having pokdex
+ ld a,$06
+ jr z,.storeMenuItemCount
+; case for having pokedex
+ ld de,StartMenuPokedexText
+ call PrintStartMenuItem
+ ld a,$07
+.storeMenuItemCount
+ ld [wMaxMenuItem],a ; number of menu items
+ ld de,StartMenuPokemonText
+ call PrintStartMenuItem
+ ld de,StartMenuItemText
+ call PrintStartMenuItem
+ ld de,wPlayerName ; player's name
+ call PrintStartMenuItem
+ ld a,[wd72e]
+ bit 6,a ; is the player using the link feature?
+; case for not using link feature
+ ld de,StartMenuSaveText
+ jr z,.printSaveOrResetText
+; case for using link feature
+ ld de,StartMenuResetText
+.printSaveOrResetText
+ call PrintStartMenuItem
+ ld de,StartMenuOptionText
+ call PrintStartMenuItem
+ ld de,StartMenuExitText
+ call PlaceString
+ ld hl,wd730
+ res 6,[hl] ; turn pauses between printing letters back on
+ ret
+
+StartMenuPokedexText:
+ db "POKéDEX@"
+
+StartMenuPokemonText:
+ db "#MON@"
+
+StartMenuItemText:
+ db "ITEM@"
+
+StartMenuSaveText:
+ db "SAVE@"
+
+StartMenuResetText:
+ db "RESET@"
+
+StartMenuExitText:
+ db "EXIT@"
+
+StartMenuOptionText:
+ db "OPTION@"
+
+PrintStartMenuItem:
+ push hl
+ call PlaceString
+ pop hl
+ ld de,SCREEN_WIDTH * 2
+ add hl,de
+ ret
diff --git a/engine/menu/text_ids2.asm b/engine/menu/text_ids2.asm
new file mode 100644
index 00000000..fbac3986
--- /dev/null
+++ b/engine/menu/text_ids2.asm
@@ -0,0 +1,733 @@
+; function to draw various text boxes
+DisplayTextBoxID_:
+ ld a,[wTextBoxID]
+ cp a,TWO_OPTION_MENU
+ jp z,DisplayTwoOptionMenu
+ ld c,a
+ ld hl,TextBoxFunctionTable
+ ld de,3
+ call SearchTextBoxTable
+ jr c,.functionTableMatch
+ ld hl,TextBoxCoordTable
+ ld de,5
+ call SearchTextBoxTable
+ jr c,.coordTableMatch
+ ld hl,TextBoxTextAndCoordTable
+ ld de,9
+ call SearchTextBoxTable
+ jr c,.textAndCoordTableMatch
+.done
+ ret
+.functionTableMatch
+ ld a,[hli]
+ ld h,[hl]
+ ld l,a ; hl = address of function
+ ld de,.done
+ push de
+ jp [hl] ; jump to the function
+.coordTableMatch
+ call GetTextBoxIDCoords
+ call GetAddressOfScreenCoords
+ call TextBoxBorder
+ ret
+.textAndCoordTableMatch
+ call GetTextBoxIDCoords
+ push hl
+ call GetAddressOfScreenCoords
+ call TextBoxBorder
+ pop hl
+ call GetTextBoxIDText
+ ld a,[wd730]
+ push af
+ ld a,[wd730]
+ set 6,a ; no pauses between printing each letter
+ ld [wd730],a
+ call PlaceString
+ pop af
+ ld [wd730],a
+ call UpdateSprites
+ ret
+
+; function to search a table terminated with $ff for a byte matching c in increments of de
+; sets carry flag if a match is found and clears carry flag if not
+SearchTextBoxTable:
+ dec de
+.loop
+ ld a,[hli]
+ cp a,$ff
+ jr z,.notFound
+ cp c
+ jr z,.found
+ add hl,de
+ jr .loop
+.found
+ scf
+.notFound
+ ret
+
+; function to load coordinates from the TextBoxCoordTable or the TextBoxTextAndCoordTable
+; INPUT:
+; hl = address of coordinates
+; OUTPUT:
+; b = height
+; c = width
+; d = row of upper left corner
+; e = column of upper left corner
+GetTextBoxIDCoords:
+ ld a,[hli] ; column of upper left corner
+ ld e,a
+ ld a,[hli] ; row of upper left corner
+ ld d,a
+ ld a,[hli] ; column of lower right corner
+ sub e
+ dec a
+ ld c,a ; c = width
+ ld a,[hli] ; row of lower right corner
+ sub d
+ dec a
+ ld b,a ; b = height
+ ret
+
+; function to load a text address and text coordinates from the TextBoxTextAndCoordTable
+GetTextBoxIDText:
+ ld a,[hli]
+ ld e,a
+ ld a,[hli]
+ ld d,a ; de = address of text
+ push de ; save text address
+ ld a,[hli]
+ ld e,a ; column of upper left corner of text
+ ld a,[hl]
+ ld d,a ; row of upper left corner of text
+ call GetAddressOfScreenCoords
+ pop de ; restore text address
+ ret
+
+; function to point hl to the screen coordinates
+; INPUT:
+; d = row
+; e = column
+; OUTPUT:
+; hl = address of upper left corner of text box
+GetAddressOfScreenCoords:
+ push bc
+ coord hl, 0, 0
+ ld bc,20
+.loop ; loop to add d rows to the base address
+ ld a,d
+ and a
+ jr z,.addedRows
+ add hl,bc
+ dec d
+ jr .loop
+.addedRows
+ pop bc
+ add hl,de
+ ret
+
+; Format:
+; 00: text box ID
+; 01-02: function address
+TextBoxFunctionTable:
+ dbw MONEY_BOX, DisplayMoneyBox
+ dbw BUY_SELL_QUIT_MENU, DoBuySellQuitMenu
+ dbw FIELD_MOVE_MON_MENU, DisplayFieldMoveMonMenu
+ db $ff ; terminator
+
+; Format:
+; 00: text box ID
+; 01: column of upper left corner
+; 02: row of upper left corner
+; 03: column of lower right corner
+; 04: row of lower right corner
+TextBoxCoordTable:
+ db MESSAGE_BOX, 0, 12, 19, 17
+ db $03, 0, 0, 19, 14
+ db $07, 0, 0, 11, 6
+ db LIST_MENU_BOX, 4, 2, 19, 12
+ db $10, 7, 0, 19, 17
+ db MON_SPRITE_POPUP, 6, 4, 14, 13
+ db $ff ; terminator
+
+; Format:
+; 00: text box ID
+; 01: column of upper left corner
+; 02: row of upper left corner
+; 03: column of lower right corner
+; 04: row of lower right corner
+; 05-06: address of text
+; 07: column of beginning of text
+; 08: row of beginning of text
+; table of window positions and corresponding text [key, start column, start row, end column, end row, text pointer [2 bytes], text column, text row]
+TextBoxTextAndCoordTable:
+ db JP_MOCHIMONO_MENU_TEMPLATE
+ db 0,0,14,17 ; text box coordinates
+ dw JapaneseMochimonoText
+ db 3,0 ; text coordinates
+
+ db USE_TOSS_MENU_TEMPLATE
+ db 13,10,19,14 ; text box coordinates
+ dw UseTossText
+ db 15,11 ; text coordinates
+
+ db JP_SAVE_MESSAGE_MENU_TEMPLATE
+ db 0,0,7,5 ; text box coordinates
+ dw JapaneseSaveMessageText
+ db 2,2 ; text coordinates
+
+ db JP_SPEED_OPTIONS_MENU_TEMPLATE
+ db 0,6,5,10 ; text box coordinates
+ dw JapaneseSpeedOptionsText
+ db 2,7 ; text coordinates
+
+ db BATTLE_MENU_TEMPLATE
+ db 8,12,19,17 ; text box coordinates
+ dw BattleMenuText
+ db 10,14 ; text coordinates
+
+ db SAFARI_BATTLE_MENU_TEMPLATE
+ db 0,12,19,17 ; text box coordinates
+ dw SafariZoneBattleMenuText
+ db 2,14 ; text coordinates
+
+ db SWITCH_STATS_CANCEL_MENU_TEMPLATE
+ db 11,11,19,17 ; text box coordinates
+ dw SwitchStatsCancelText
+ db 13,12 ; text coordinates
+
+ db BUY_SELL_QUIT_MENU_TEMPLATE
+ db 0,0,10,6 ; text box coordinates
+ dw BuySellQuitText
+ db 2,1 ; text coordinates
+
+ db MONEY_BOX_TEMPLATE
+ db 11,0,19,2 ; text box coordinates
+ dw MoneyText
+ db 13,0 ; text coordinates
+
+ db JP_AH_MENU_TEMPLATE
+ db 7,6,11,10 ; text box coordinates
+ dw JapaneseAhText
+ db 8,8 ; text coordinates
+
+ db JP_POKEDEX_MENU_TEMPLATE
+ db 11,8,19,17 ; text box coordinates
+ dw JapanesePokedexMenu
+ db 12,10 ; text coordinates
+
+; note that there is no terminator
+
+BuySellQuitText:
+ db "BUY"
+ next "SELL"
+ next "QUIT@@"
+
+UseTossText:
+ db "USE"
+ next "TOSS@"
+
+JapaneseSaveMessageText:
+ db "きろく"
+ next "メッセージ@"
+
+JapaneseSpeedOptionsText:
+ db "はやい"
+ next "おそい@"
+
+MoneyText:
+ db "MONEY@"
+
+JapaneseMochimonoText:
+ db "もちもの@"
+
+JapaneseMainMenuText:
+ db "つづきから"
+ next "さいしょから@"
+
+BattleMenuText:
+ db "FIGHT ",$E1,$E2
+ next "ITEM RUN@"
+
+SafariZoneBattleMenuText:
+ db "BALL× BAIT"
+ next "THROW ROCK RUN@"
+
+SwitchStatsCancelText:
+ db "SWITCH"
+ next "STATS"
+ next "CANCEL@"
+
+JapaneseAhText:
+ db "アッ!@"
+
+JapanesePokedexMenu:
+ db "データをみる"
+ next "なきごえ"
+ next "ぶんぷをみる"
+ next "キャンセル@"
+
+DisplayMoneyBox:
+ ld hl, wd730
+ set 6, [hl]
+ ld a, MONEY_BOX_TEMPLATE
+ ld [wTextBoxID], a
+ call DisplayTextBoxID
+ coord hl, 13, 1
+ lb bc, 1, 6
+ call ClearScreenArea
+ coord hl, 12, 1
+ ld de, wPlayerMoney
+ ld c, $a3
+ call PrintBCDNumber
+ ld hl, wd730
+ res 6, [hl]
+ ret
+
+CurrencyString:
+ db " ¥@"
+
+DoBuySellQuitMenu:
+ ld a, [wd730]
+ set 6, a ; no printing delay
+ ld [wd730], a
+ xor a
+ ld [wChosenMenuItem], a
+ ld a, BUY_SELL_QUIT_MENU_TEMPLATE
+ ld [wTextBoxID], a
+ call DisplayTextBoxID
+ ld a, A_BUTTON | B_BUTTON
+ ld [wMenuWatchedKeys], a
+ ld a, $2
+ ld [wMaxMenuItem], a
+ ld a, $1
+ ld [wTopMenuItemY], a
+ ld a, $1
+ ld [wTopMenuItemX], a
+ xor a
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ ld [wMenuWatchMovingOutOfBounds], a
+ ld a, [wd730]
+ res 6, a ; turn on the printing delay
+ ld [wd730], a
+ call HandleMenuInput
+ call PlaceUnfilledArrowMenuCursor
+ bit 0, a ; was A pressed?
+ jr nz, .pressedA
+ bit 1, a ; was B pressed? (always true since only A/B are watched)
+ jr z, .pressedA
+ ld a, CANCELLED_MENU
+ ld [wMenuExitMethod], a
+ jr .quit
+.pressedA
+ ld a, CHOSE_MENU_ITEM
+ ld [wMenuExitMethod], a
+ ld a, [wCurrentMenuItem]
+ ld [wChosenMenuItem], a
+ ld b, a
+ ld a, [wMaxMenuItem]
+ cp b
+ jr z, .quit
+ ret
+.quit
+ ld a, CANCELLED_MENU
+ ld [wMenuExitMethod], a
+ ld a, [wCurrentMenuItem]
+ ld [wChosenMenuItem], a
+ scf
+ ret
+
+; displays a menu with two options to choose from
+; b = Y of upper left corner of text region
+; c = X of upper left corner of text region
+; hl = address where the text box border should be drawn
+DisplayTwoOptionMenu:
+ push hl
+ ld a, [wd730]
+ set 6, a ; no printing delay
+ ld [wd730], a
+
+; pointless because both values are overwritten before they are read
+ xor a
+ ld [wChosenMenuItem], a
+ ld [wMenuExitMethod], a
+
+ ld a, A_BUTTON | B_BUTTON
+ ld [wMenuWatchedKeys], a
+ ld a, $1
+ ld [wMaxMenuItem], a
+ ld a, b
+ ld [wTopMenuItemY], a
+ ld a, c
+ ld [wTopMenuItemX], a
+ xor a
+ ld [wLastMenuItem], a
+ ld [wMenuWatchMovingOutOfBounds], a
+ push hl
+ ld hl, wTwoOptionMenuID
+ bit 7, [hl] ; select second menu item by default?
+ res 7, [hl]
+ jr z, .storeCurrentMenuItem
+ inc a
+.storeCurrentMenuItem
+ ld [wCurrentMenuItem], a
+ pop hl
+ push hl
+ push hl
+ call TwoOptionMenu_SaveScreenTiles
+ ld a, [wTwoOptionMenuID]
+ ld hl, TwoOptionMenuStrings
+ ld e, a
+ ld d, $0
+ ld a, $5
+.menuStringLoop
+ add hl, de
+ dec a
+ jr nz, .menuStringLoop
+ ld a, [hli]
+ ld c, a
+ ld a, [hli]
+ ld b, a
+ ld e, l
+ ld d, h
+ pop hl
+ push de
+ ld a, [wTwoOptionMenuID]
+ cp TRADE_CANCEL_MENU
+ jr nz, .notTradeCancelMenu
+ call CableClub_TextBoxBorder
+ jr .afterTextBoxBorder
+.notTradeCancelMenu
+ call TextBoxBorder
+.afterTextBoxBorder
+ call UpdateSprites
+ pop hl
+ ld a, [hli]
+ and a ; put blank line before first menu item?
+ ld bc, 20 + 2
+ jr z, .noBlankLine
+ ld bc, 2 * 20 + 2
+.noBlankLine
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ pop hl
+ add hl, bc
+ call PlaceString
+ xor a
+ ld [wTwoOptionMenuID], a
+ ld hl, wd730
+ res 6, [hl]
+ call HandleMenuInput
+ pop hl
+ bit 1, a ; A button pressed?
+ jr nz, .choseSecondMenuItem ; automatically choose the second option if B is pressed
+.pressedAButton
+ ld a, [wCurrentMenuItem]
+ ld [wChosenMenuItem], a
+ and a
+ jr nz, .choseSecondMenuItem
+; chose first menu item
+ ld a, CHOSE_FIRST_ITEM
+ ld [wMenuExitMethod], a
+ ld c, 15
+ call DelayFrames
+ call TwoOptionMenu_RestoreScreenTiles
+ and a
+ ret
+.choseSecondMenuItem
+ ld a, 1
+ ld [wCurrentMenuItem], a
+ ld [wChosenMenuItem], a
+ ld a, CHOSE_SECOND_ITEM
+ ld [wMenuExitMethod], a
+ ld c, 15
+ call DelayFrames
+ call TwoOptionMenu_RestoreScreenTiles
+ scf
+ ret
+
+; Some of the wider/taller two option menus will not have the screen areas
+; they cover be fully saved/restored by the two functions below.
+; The bottom and right edges of the menu may remain after the function returns.
+
+TwoOptionMenu_SaveScreenTiles:
+ ld de, wBuffer
+ lb bc, 5, 6
+.loop
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .loop
+ push bc
+ ld bc, SCREEN_WIDTH - 6
+ add hl, bc
+ pop bc
+ ld c, $6
+ dec b
+ jr nz, .loop
+ ret
+
+TwoOptionMenu_RestoreScreenTiles:
+ ld de, wBuffer
+ lb bc, 5, 6
+.loop
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .loop
+ push bc
+ ld bc, SCREEN_WIDTH - 6
+ add hl, bc
+ pop bc
+ ld c, 6
+ dec b
+ jr nz, .loop
+ call UpdateSprites
+ ret
+
+; Format:
+; 00: byte width
+; 01: byte height
+; 02: byte put blank line before first menu item
+; 03: word text pointer
+TwoOptionMenuStrings:
+ db 4,3,0
+ dw .YesNoMenu
+ db 6,3,0
+ dw .NorthWestMenu
+ db 6,3,0
+ dw .SouthEastMenu
+ db 6,3,0
+ dw .YesNoMenu
+ db 6,3,0
+ dw .NorthEastMenu
+ db 7,3,0
+ dw .TradeCancelMenu
+ db 7,4,1
+ dw .HealCancelMenu
+ db 4,3,0
+ dw .NoYesMenu
+
+.NoYesMenu ; 7542 (1:7542)
+ db "NO",$4E,"YES@"
+.YesNoMenu ; 7549 (1:7549)
+ db "YES",$4E,"NO@"
+.NorthWestMenu ; 7550 (1:7550)
+ db "NORTH",$4E,"WEST@"
+.SouthEastMenu ; 755b (1:755b)
+ db "SOUTH",$4E,"EAST@"
+.NorthEastMenu ; 7566 (1:7566)
+ db "NORTH",$4E,"EAST@"
+.TradeCancelMenu ; 7571 (1:7571)
+ db "TRADE",$4E,"CANCEL@"
+.HealCancelMenu ; 757e (1:757e)
+ db "HEAL",$4E,"CANCEL@"
+
+DisplayFieldMoveMonMenu:
+ xor a
+ ld hl, wFieldMoves
+ ld [hli], a ; wFieldMoves
+ ld [hli], a ; wFieldMoves + 1
+ ld [hli], a ; wFieldMoves + 2
+ ld [hli], a ; wFieldMoves + 3
+ ld [hli], a ; wNumFieldMoves
+ ld [hl], 12 ; wFieldMovesLeftmostXCoord
+ call GetMonFieldMoves
+ ld a, [wNumFieldMoves]
+ and a
+ jr nz, .fieldMovesExist
+
+; no field moves
+ coord hl, 11, 11
+ lb bc, 5, 7
+ call TextBoxBorder
+ call UpdateSprites
+ ld a, 12
+ ld [hFieldMoveMonMenuTopMenuItemX], a ; fffb, not fff7
+ coord hl, 13, 12
+ ld de, PokemonMenuEntries
+ jp PlaceString
+
+.fieldMovesExist
+ push af
+
+; Calculate the text box position and dimensions based on the leftmost X coord
+; of the field move names before adjusting for the number of field moves.
+ coord hl, 0, 11
+ ld a, [wFieldMovesLeftmostXCoord]
+ dec a
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld b, 5
+ ld a, 18
+ sub e
+ ld c, a
+ pop af
+
+; For each field move, move the top of the text box up 2 rows while the leaving
+; the bottom of the text box at the bottom of the screen.
+ ld de, -SCREEN_WIDTH * 2
+.textBoxHeightLoop
+ add hl, de
+ inc b
+ inc b
+ dec a
+ jr nz, .textBoxHeightLoop
+
+; Make space for an extra blank row above the top field move.
+ ld de, -SCREEN_WIDTH
+ add hl, de
+ inc b
+
+ call TextBoxBorder
+ call UpdateSprites
+
+; Calculate the position of the first field move name to print.
+ coord hl, 0, 12
+ ld a, [wFieldMovesLeftmostXCoord]
+ inc a
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld de, -SCREEN_WIDTH * 2
+ ld a, [wNumFieldMoves]
+.calcFirstFieldMoveYLoop
+ add hl, de
+ dec a
+ jr nz, .calcFirstFieldMoveYLoop
+
+ xor a
+ ld [wNumFieldMoves], a
+ ld de, wFieldMoves
+.printNamesLoop
+ push hl
+ ld hl, FieldMoveNames
+ ld a, [de]
+ and a
+ jr z, .donePrintingNames
+ inc de
+ ld b, a ; index of name
+.skipNamesLoop ; skip past names before the name we want
+ dec b
+ jr z, .reachedName
+.skipNameLoop ; skip past current name
+ ld a, [hli]
+ cp "@"
+ jr nz, .skipNameLoop
+ jr .skipNamesLoop
+.reachedName
+ ld b, h
+ ld c, l
+ pop hl
+ push de
+ ld d, b
+ ld e, c
+ call PlaceString
+ ld bc, SCREEN_WIDTH * 2
+ add hl, bc
+ pop de
+ jr .printNamesLoop
+
+.donePrintingNames
+ pop hl
+ ld a, [wFieldMovesLeftmostXCoord]
+ ld [hFieldMoveMonMenuTopMenuItemX], a
+ coord hl, 0, 12
+ ld a, [wFieldMovesLeftmostXCoord]
+ inc a
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld de, PokemonMenuEntries
+ jp PlaceString
+
+FieldMoveNames:
+ db "CUT@"
+ db "FLY@"
+ db "@"
+ db "SURF@"
+ db "STRENGTH@"
+ db "FLASH@"
+ db "DIG@"
+ db "TELEPORT@"
+ db "SOFTBOILED@"
+
+PokemonMenuEntries:
+ db "STATS"
+ next "SWITCH"
+ next "CANCEL@"
+
+GetMonFieldMoves:
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMon1Moves
+ ld bc, wPartyMon2 - wPartyMon1
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld c, NUM_MOVES + 1
+ ld hl, wFieldMoves
+.loop
+ push hl
+.nextMove
+ dec c
+ jr z, .done
+ ld a, [de] ; move ID
+ and a
+ jr z, .done
+ ld b, a
+ inc de
+ ld hl, FieldMoveDisplayData
+.fieldMoveLoop
+ ld a, [hli]
+ cp $ff
+ jr z, .nextMove ; if the move is not a field move
+ cp b
+ jr z, .foundFieldMove
+ inc hl
+ inc hl
+ jr .fieldMoveLoop
+.foundFieldMove
+ ld a, b
+ ld [wLastFieldMoveID], a
+ ld a, [hli] ; field move name index
+ ld b, [hl] ; field move leftmost X coordinate
+ pop hl
+ ld [hli], a ; store name index in wFieldMoves
+ ld a, [wNumFieldMoves]
+ inc a
+ ld [wNumFieldMoves], a
+ ld a, [wFieldMovesLeftmostXCoord]
+ cp b
+ jr c, .skipUpdatingLeftmostXCoord
+ ld a, b
+ ld [wFieldMovesLeftmostXCoord], a
+.skipUpdatingLeftmostXCoord
+ ld a, [wLastFieldMoveID]
+ ld b, a
+ jr .loop
+.done
+ pop hl
+ ret
+
+; Format: [Move id], [name index], [leftmost tile]
+; Move id = id of move
+; Name index = index of name in FieldMoveNames
+; Leftmost tile = -1 + tile column in which the first letter of the move's name should be displayed
+; "SOFTBOILED" is $08 because it has 4 more letters than "SURF", for example, whose value is $0C
+FieldMoveDisplayData:
+ db CUT, $01, $0C
+ db FLY, $02, $0C
+ db $B4, $03, $0C ; unused field move
+ db SURF, $04, $0C
+ db STRENGTH, $05, $0A
+ db FLASH, $06, $0C
+ db DIG, $07, $0C
+ db TELEPORT, $08, $0A
+ db SOFTBOILED, $09, $08
+ db $ff ; list terminator
+
diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm
index b32568f9..d864141d 100755
--- a/engine/menu/vending_machine.asm
+++ b/engine/menu/vending_machine.asm
@@ -18,8 +18,7 @@ VendingMachineMenu:
ld hl, wd730
set 6, [hl]
coord hl, 0, 3
- ld b, 8
- ld c, 12
+ lb bc, 8, 12
call TextBoxBorder
call UpdateSprites
coord hl, 2, 5
@@ -130,6 +129,9 @@ LoadVendingMachineItem:
ret
VendingPrices:
- db FRESH_WATER,$00,$02,$00
- db SODA_POP, $00,$03,$00
- db LEMONADE, $00,$03,$50
+ db FRESH_WATER
+ money 200
+ db SODA_POP
+ money 300
+ db LEMONADE
+ money 350