Skip to content

Commit

Permalink
Merge pull request #44 from andwhyisit/pausemenu-4
Browse files Browse the repository at this point in the history
Pause Menu Part 4
  • Loading branch information
andwhyisit authored Aug 14, 2024
2 parents 0c99cd0 + dc90b35 commit 8839390
Show file tree
Hide file tree
Showing 3 changed files with 373 additions and 20 deletions.
4 changes: 4 additions & 0 deletions game/src/core/state_indexes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ W_CoreSubStateIndex:: ds 1
SECTION "Transport Option State Indexes", WRAM0[$C57A]
W_TransportOptionSubSubSubStateIndex:: ds 1

SECTION "Item Action State Indexes", WRAM0[$C57C]
W_ItemActionSubSubStateIndex:: ds 1
W_ItemActionSubSubSubStateIndex:: ds 1

SECTION "Naming Screen State Indexes", WRAM0[$C580]
W_NamingScreenSubSubStateIndex:: ds 1

Expand Down
157 changes: 137 additions & 20 deletions game/src/pausemenu/item_core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ ItemMenuStateMachine::
dw ItemMenuMappingState ; 01
dw ItemMenuPrepareFadeInState ; 02
dw ItemMenuFadeInState ; 03
dw $4DC2 ; 04
dw $4DFD ; 05
dw $4E17 ; 06
dw ItemMenuItemSelectionInputHandlerState ; 04
dw ItemMenuUseItemConfirmationState ; 05
dw ItemMenuAttemptToUseItemState ; 06
dw ItemMenuPrepareScriptEngineState ; 07
dw $4E4E ; 08
dw $4EAD ; 09
dw ItemMenuCantUseMessageState ; 08
dw ItemMenuPlaceholderState ; 09
dw ItemMenuPrepareScriptEngineState ; 0A
dw $4E69 ; 0B
dw $4EAD ; 0C
dw ItemMenuCantUseHereMessageState ; 0B
dw ItemMenuPlaceholderState ; 0C
dw ItemMenuPrepareScriptEngineState ; 0D
dw $4E84 ; 0E
dw $4EAD ; 0F
dw $4E9F ; 10
dw $4EA2 ; 11
dw $4EAD ; 12
dw ItemMenuMustBeInVehicleMessageState ; 0E
dw ItemMenuPlaceholderState ; 0F
dw ItemMenuTriggerSpecialItemActionState ; 10
dw ItemMenuReturnState ; 11
dw ItemMenuPlaceholderState ; 12
; This next part may be junk code+data.
ld a, 6
call ScheduleMusic
dw $4EAD
dw ItemMenuPlaceholderState

ItemMenuPrepareScriptEngineState::
cbcall InitiateMainScript
Expand Down Expand Up @@ -62,13 +62,13 @@ ItemMenuMappingState::
ld e, $4F
ld a, 0
cbcall DecompressAttribmap0
call $4EAE ; ItemMenuCountPages?
call $4ED5 ; ItemMenuMapPageIndicator?
call $4EF5 ; ItemMenuPrintPageItemNames?
call $4F84 ; ItemMenuDetermineSelectedItemInventorySlot?
call $4F95 ; ItemMenuPrintSelectedItemQuantity?
call $4FD5 ; LoadSelectedItemDescription?
call $5006 ; ItemMenuShowPageArrows?
call ItemMenuCountPages
call ItemMenuMapPageIndicator
call ItemMenuPrintPageItemNames
call ItemMenuDetermineSelectedItemInventorySlot
call ItemMenuPrintSelectedItemQuantity
call LoadSelectedItemDescription
call ItemMenuShowPageArrows
call $503F
ld a, 1
ld [W_OAM_SpritesReady], a
Expand All @@ -83,4 +83,121 @@ ItemMenuPrepareFadeInState::
cbcall SetupPalswapAnimation
jp IncSubStateIndex

ItemMenuItemSelectionInputHandlerState::
; Redundant fade-related call was removed from this spot in the transition from M3 to M4.
ld de, $C0C0
cbcallindex 9
call ItemMenuAnimatePageArrows
call $5051
call $513C
call $507B
call $51E0
call $5224
call $529F
ld a, [$C4EE]
or a
jp nz, IncSubStateIndex
call $527B
ld a, [$C4EE]
cp 1
ret nz

.doExit
ld a, $A
ld [W_CoreStateIndex], a
ld a, 7
ld [W_CoreSubStateIndex], a
ret

ItemMenuUseItemConfirmationState::
; Redundant fade-related call was removed from this spot in the transition from M3 to M4.
ld a, 2
cbcallindex $52
ld a, [$C771]
or a
ret z
cp 1
jp z, IncSubStateIndex
ld a, 4
ld [W_CoreSubStateIndex], a
ret

ItemMenuAttemptToUseItemState::
call ItemMenuDetermineSelectedItemInventorySlot
call $52E3 ; ItemMenuCheckVehicleRequirement
or a
jp nz, .mustBeInVehicle
call ItemMenuDetermineSelectedItemInventorySlot
call $52C5
or a
jp z, IncSubStateIndex
ld [W_ItemActionSubSubStateIndex], a
cp $40
jr z, .canBeUsedFromItemMenu
call $52FA
or a
jr z, .canBeUsedFromItemMenu
ld a, $A
ld [W_CoreSubStateIndex], a
ret

.canBeUsedFromItemMenu
xor a
ld [W_ItemActionSubSubSubStateIndex], a
ld a, $10
ld [W_CoreSubStateIndex], a
ret

.mustBeInVehicle
ld a, $D
ld [W_CoreSubStateIndex], a
ret

ItemMenuCantUseMessageState::
ld bc, $20
ld a, 1
cbcall MainScriptLoopHelper
ld a, [W_MainScriptExitMode]
or a
ret z
call LoadSelectedItemDescription
ld a, 4
ld [W_CoreSubStateIndex], a
ret

ItemMenuCantUseHereMessageState::
ld bc, $21
ld a, 1
cbcall MainScriptLoopHelper
ld a, [W_MainScriptExitMode]
or a
ret z
call LoadSelectedItemDescription
ld a, 4
ld [W_CoreSubStateIndex], a
ret

ItemMenuMustBeInVehicleMessageState::
ld bc, $2B
ld a, 1
cbcall MainScriptLoopHelper
ld a, [W_MainScriptExitMode]
or a
ret z
call LoadSelectedItemDescription
ld a, 4
ld [W_CoreSubStateIndex], a
ret

ItemMenuTriggerSpecialItemActionState::
jp $5318

ItemMenuReturnState::
ld a, 6
call ScheduleMusic
ld a, 1
ld [W_CoreSubStateIndex], a
ret

ItemMenuPlaceholderState::
ret
Loading

0 comments on commit 8839390

Please sign in to comment.