summaryrefslogtreecommitdiff
path: root/engine/menu
diff options
context:
space:
mode:
Diffstat (limited to 'engine/menu')
-rw-r--r--engine/menu/bills_pc.asm40
-rwxr-xr-xengine/menu/diploma.asm2
-rwxr-xr-xengine/menu/main_menu.asm126
-rwxr-xr-xengine/menu/naming_screen.asm2
-rwxr-xr-xengine/menu/start_sub_menus.asm12
-rwxr-xr-xengine/menu/vending_machine.asm4
6 files changed, 95 insertions, 91 deletions
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index 891ef6e8..a26c5aed 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -508,48 +508,48 @@ MonWasReleasedText: ; 0x21820
TX_FAR _MonWasReleasedText
db "@"
-PrintJustAMomentText1:: ; 5824 (8:5825)
- ld a, [$ffaa]
- cp $1
+CableClubLeftGameboy:: ; 5824 (8:5825)
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
ret z
- ld a, [wSpriteStateData1 + 9]
- cp $c
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ cp SPRITE_FACING_RIGHT
ret nz
ld a, [W_CURMAP]
cp BATTLE_CENTER
- ld a, $2
+ ld a, LINK_STATE_START_TRADE
jr z, .asm_2183a
- inc a
+ inc a ; LINK_STATE_START_BATTLE
.asm_2183a
- ld [W_ISLINKBATTLE], a
+ ld [wLinkState], a
call EnableAutoTextBoxDrawing
- ld a, $22
+ ld a, $22 ; JustAMomentText
jp PrintPredefTextID
-PrintJustAMomentText2:: ; 5845 (8:5845)
- ld a, [$ffaa]
- cp $2
+CableClubRightGameboy:: ; 5845 (8:5845)
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
ret z
- ld a, [wSpriteStateData1 + 9]
- cp $8
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ cp SPRITE_FACING_LEFT
ret nz
ld a, [W_CURMAP]
cp BATTLE_CENTER
- ld a, $2
+ ld a, LINK_STATE_START_TRADE
jr z, .asm_2185a
- inc a
+ inc a ; LINK_STATE_START_BATTLE
.asm_2185a
- ld [W_ISLINKBATTLE], a
+ ld [wLinkState], a
call EnableAutoTextBoxDrawing
- ld a, $22
+ ld a, $22 ; JustAMomentText
jp PrintPredefTextID
JustAMomentText:: ; 21865 (8:5865)
TX_FAR _JustAMomentText
db "@"
- ld a, [wSpriteStateData1 + 9]
- cp $4
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
ld a, $23
diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm
index 95b2a87d..1624ed70 100755
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -14,7 +14,7 @@ DisplayDiploma: ; 566e2 (15:66e2)
call FarCopyData2
ld hl, wTileMap
ld bc, $1012
- predef Func_5ab0
+ predef Diploma_TextBoxBorder
ld hl, DiplomaTextPointersAndCoords ; $6784
ld c, $5
.asm_56715
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index c6052f03..756c7755 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -14,8 +14,8 @@ MainMenu: ; 5af2 (1:5af2)
.next0
ld c,20
call DelayFrames
- xor a
- ld [W_ISLINKBATTLE],a
+ xor a ; LINK_STATE_NONE
+ ld [wLinkState],a
ld hl,wcc2b
ld [hli],a
ld [hli],a
@@ -133,7 +133,7 @@ LinkMenu: ; 5c0a (1:5c0a)
ld [wd358], a
ld hl, wd72e
set 6, [hl]
- ld hl, TextTerminator_6b20 ; $6b20
+ ld hl, TextTerminator_6b20
call PrintText
call SaveScreenTilesToBuffer1
ld hl, WhereWouldYouLikeText
@@ -149,7 +149,7 @@ LinkMenu: ; 5c0a (1:5c0a)
xor a
ld [wcd37], a
ld [wd72d], a
- ld hl, wTopMenuItemY ; wTopMenuItemY
+ ld hl, wTopMenuItemY
ld a, $7
ld [hli], a
ld a, $6
@@ -163,97 +163,101 @@ LinkMenu: ; 5c0a (1:5c0a)
ld [hli], a
xor a
ld [hl], a
-.asm_5c52
+.waitForInputLoop
call HandleMenuInput
- and $3
+ and A_BUTTON | B_BUTTON
add a
add a
ld b, a
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld a, [wCurrentMenuItem]
add b
add $d0
- ld [wcc42], a
- ld [wcc43], a
-.asm_5c66
- call Func_2247
- ld a, [wcc3d]
+ 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, [wcc3e]
+ ld a, [wLinkMenuSelectionReceiveBuffer + 1]
ld b, a
and $f0
cp $d0
- jr nz, .asm_5c66
+ jr nz, .exchangeMenuSelectionLoop
.asm_5c7d
ld a, b
- and $c
- jr nz, .asm_5c8b
- ld a, [wcc42]
- and $c
- jr z, .asm_5c52
- jr .asm_5ca1
-.asm_5c8b
- ld a, [wcc42]
- and $c
- jr z, .asm_5c98
- ld a, [$ffaa]
- cp $2
- jr z, .asm_5ca1
-.asm_5c98
+ 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 [wcc42], a
+ ld [wLinkMenuSelectionSendBuffer], a
and $3
ld [wCurrentMenuItem], a ; wCurrentMenuItem
-.asm_5ca1
- ld a, [$ffaa]
- cp $2
- jr nz, .asm_5cb1
+.doneChoosingMenuSelection
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
+ jr nz, .skipStartingTransfer
call DelayFrame
call DelayFrame
- ld a, $81
- ld [$ff02], a
-.asm_5cb1
+ ld a, START_TRANSFER_INTERNAL_CLOCK
+ ld [rSC], a
+.skipStartingTransfer
ld b, $7f
ld c, $7f
ld d, $ec
- ld a, [wcc42]
- and $8
- jr nz, .asm_5ccc
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ 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, .asm_5ccc
+ jr z, .updateCursorPosition
ld c, d
ld d, b
dec a
- jr z, .asm_5ccc
+ jr z, .updateCursorPosition
ld b, c
ld c, d
-.asm_5ccc
+.updateCursorPosition
ld a, b
Coorda 6, 7
ld a, c
Coorda 6, 9
ld a, d
Coorda 6, 11
- ld c, $28
+ ld c, 40
call DelayFrames
call LoadScreenTilesFromBuffer1
- ld a, [wcc42]
- and $8
- jr nz, .asm_5d2d
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ 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, .asm_5d2d
+ jr z, .choseCancel
xor a
- ld [wWalkBikeSurfState], a
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld [wWalkBikeSurfState], a ; start walking
+ ld a, [wCurrentMenuItem]
and a
ld a, TRADE_CENTER
- jr nz, .asm_5cfc
+ jr nz, .next
ld a, BATTLE_CENTER
-.asm_5cfc
+.next
ld [wd72d], a
ld hl, PleaseWaitText
call PrintText
@@ -261,23 +265,23 @@ LinkMenu: ; 5c0a (1:5c0a)
call DelayFrames
ld hl, wd732
res 1, [hl]
- ld a, [W_ANIMATIONID] ; W_ANIMATIONID
+ ld a, [W_ANIMATIONID]
ld [wDestinationMap], a
call SpecialWarpIn
ld c, $14
call DelayFrames
xor a
- ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount
- ld [wcc42], a
- inc a
- ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE
+ ld [wMenuJoypadPollCount], a
+ ld [wSerialExchangeNybbleSendData], a
+ inc a ; LINK_STATE_IN_CABLE_CLUB
+ ld [wLinkState], a
ld [wcc47], a
jr SpecialEnterMap
-.asm_5d2d
+.choseCancel
xor a
- ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount
+ ld [wMenuJoypadPollCount], a
call Delay3
- call Func_72d7
+ call CloseLinkConnection
ld hl, LinkCanceledText
call PrintText
ld hl, wd72e
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index b7db452a..5d338628 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -16,7 +16,7 @@ AskName: ; 64eb (1:64eb)
hlCoord 14, 7
ld bc, $80f
ld a, $14
- ld [wd125], a
+ ld [wTextBoxID], a
call DisplayTextBoxID
pop hl
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index c6373e76..cdd93875 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -31,7 +31,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
.chosePokemon
call SaveScreenTilesToBuffer1 ; save screen
ld a,$04
- ld [wd125],a
+ ld [wTextBoxID],a
call DisplayTextBoxID ; display pokemon menu options
ld hl,wWhichTrade
ld bc,$020c ; max menu item ID, top menu item Y
@@ -300,13 +300,13 @@ ItemMenuLoop: ; 132fc (4:72fc)
call GoPAL_SET_CF1C
StartMenu_Item: ; 13302 (4:7302)
- ld a,[W_ISLINKBATTLE]
- dec a
- jr nz,.notInLinkBattle
+ ld a,[wLinkState]
+ dec a ; is the player in the Colosseum or Trade Centre?
+ jr nz,.notInCableClubRoom
ld hl,CannotUseItemsHereText
call PrintText
jr .exitMenu
-.notInLinkBattle
+.notInCableClubRoom
ld bc,wNumBagItems
ld hl,wcf8b
ld a,c
@@ -342,7 +342,7 @@ StartMenu_Item: ; 13302 (4:7302)
jp z,.useOrTossItem
.notBicycle1
ld a,$06 ; use/toss menu
- ld [wd125],a
+ ld [wTextBoxID],a
call DisplayTextBoxID
ld hl,wTopMenuItemY
ld a,11
diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm
index c2968e2f..1eba782b 100755
--- a/engine/menu/vending_machine.asm
+++ b/engine/menu/vending_machine.asm
@@ -2,7 +2,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
ld hl, VendingMachineText1
call PrintText
ld a, $13
- ld [wd125], a
+ ld [wTextBoxID], a
call DisplayTextBoxID
xor a
ld [wCurrentMenuItem], a ; wCurrentMenuItem
@@ -70,7 +70,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
ld c, $3
predef SubBCDPredef
ld a, $13
- ld [wd125], a
+ ld [wTextBoxID], a
jp DisplayTextBoxID
.BagFull
ld hl, VendingMachineText6