Skip to content

Commit

Permalink
Merge pull request #46 from andwhyisit/pausemenu-5
Browse files Browse the repository at this point in the history
Pause Menu Part 5
  • Loading branch information
andwhyisit authored Sep 7, 2024
2 parents 568735e + 2a9ce82 commit d4396df
Show file tree
Hide file tree
Showing 9 changed files with 607 additions and 2 deletions.
6 changes: 6 additions & 0 deletions game/src/core/state_indexes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ IncSubStateIndex::
inc a
ld [W_CoreSubStateIndex], a
ret

SECTION "Increment Item Action SubSubSubState Index", ROMX[$544F], BANK[$06]
IncItemActionSubSubSubStateIndex::
ld hl, W_ItemActionSubSubSubStateIndex
inc [hl]
ret
28 changes: 27 additions & 1 deletion game/src/gfx/tilemap.asm
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,33 @@ GetOverworldScrollTileOffset::
ld c, a
ret

SECTION "Clear Tilemaps and Attribmaps", ROMX[$408E], BANK[$15]
SECTION "Clear Tilemaps and Attribmaps 1", ROM0[$2936]
ClearMapRect::
ld a, b
ld [$C4EE], a

.rowLoop
push hl
ld a, [$C4EE]
ld b, a

.tileLoop
di
rst $20
xor a
ld [hli], a
ei
dec b
jr nz, .tileLoop

pop hl
ld de, $20
add hl, de
dec c
jr nz, .rowLoop
ret

SECTION "Clear Tilemaps and Attribmaps 2", ROMX[$408E], BANK[$15]
ClearMappings0::
ld hl, $9800
jr ClearMappings1.extEntry
Expand Down
158 changes: 158 additions & 0 deletions game/src/pausemenu/item_action_core.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
INCLUDE "game/src/common/macros.asm"
INCLUDE "game/src/common/constants.asm"

SECTION "Item Action State Machine 1", ROMX[$5318], BANK[$06]
ItemActionStateMachine::
ld a, [W_ItemActionSubSubStateIndex]
rst 0
dw ItemActionPlaceholderState ;00
dw ItemActionTownMapStateMachine ;01
dw $5454 ;02
dw $5454 ;03
dw $5454 ;04
dw $5454 ;05
dw ItemActionPlaceholderState ;06
dw ItemActionPlaceholderState ;07
dw ItemActionPlaceholderState ;08
dw $5454 ;09
dw $5454 ;0A
dw $5454 ;0B
dw ItemActionPlaceholderState ;0C
dw $559A ;0D
dw ItemActionPlaceholderState ;0E
dw ItemActionPlaceholderState ;0F
dw ItemActionPlaceholderState ;10
dw ItemActionPlaceholderState ;11
dw ItemActionPlaceholderState ;12
dw ItemActionPlaceholderState ;13
dw ItemActionPlaceholderState ;14
dw ItemActionPlaceholderState ;15
dw ItemActionPlaceholderState ;16
dw ItemActionPlaceholderState ;17
dw ItemActionPlaceholderState ;18
dw ItemActionPlaceholderState ;19
dw ItemActionPlaceholderState ;1A
dw ItemActionPlaceholderState ;1B
dw ItemActionPlaceholderState ;1C
dw ItemActionPlaceholderState ;1D
dw ItemActionPlaceholderState ;1E
dw ItemActionPlaceholderState ;1F
dw ItemActionPlaceholderState ;20
dw ItemActionPlaceholderState ;21
dw ItemActionPlaceholderState ;22
dw ItemActionPlaceholderState ;23
dw ItemActionPlaceholderState ;24
dw ItemActionPlaceholderState ;25
dw ItemActionPlaceholderState ;26
dw ItemActionPlaceholderState ;27
dw ItemActionPlaceholderState ;28
dw ItemActionPlaceholderState ;29
dw ItemActionPlaceholderState ;2A
dw ItemActionPlaceholderState ;2B
dw ItemActionPlaceholderState ;2C
dw ItemActionPlaceholderState ;2D
dw ItemActionPlaceholderState ;2E
dw ItemActionPlaceholderState ;2F
dw ItemActionPlaceholderState ;30
dw ItemActionPlaceholderState ;31
dw ItemActionPlaceholderState ;32
dw ItemActionPlaceholderState ;33
dw ItemActionPlaceholderState ;34
dw ItemActionPlaceholderState ;35
dw ItemActionPlaceholderState ;36
dw ItemActionPlaceholderState ;37
dw ItemActionPlaceholderState ;38
dw ItemActionPlaceholderState ;39
dw ItemActionPlaceholderState ;3A
dw ItemActionPlaceholderState ;3B
dw ItemActionPlaceholderState ;3C
dw ItemActionPlaceholderState ;3D
dw ItemActionPlaceholderState ;3E
dw ItemActionPlaceholderState ;3F
dw $577D ;40

ItemActionPlaceholderState::
ret

ItemActionTownMapStateMachine::
ld a, [W_ItemActionSubSubSubStateIndex]
rst 0

dw ItemActionTownMapUsabilityCheckState
dw ItemActionPrepareScriptEngineState
dw ItemActionPrintErrorMessageState
dw ItemActionTownMapPlaceholderState
dw ItemActionPrepareFadeOutState
dw ItemActionFadeState
dw ItemActionOpenTownMapState

ItemActionTownMapPlaceholderState::
ret

ItemActionTownMapUsabilityCheckState::
ld a, [$C65F]
and $20
jr z, .itemCanBeUsedHere
ld bc, $22
call ItemActionStoreMessageIndex
jp IncItemActionSubSubSubStateIndex

.itemCanBeUsedHere
ld a, 4
ld [W_ItemActionSubSubSubStateIndex], a
ret

ItemActionOpenTownMapState::
ld a, 0
ld [$C4EE], a
ld a, $14
ld [$C4EF], a
ld a, 0
ld [$C4F0], a
ld a, $12
ld [$C4F1], a
ld a, 3
cbcallindex $B2
xor a
ld [$C4E0], a
ld a, $4E
ld [W_CoreStateIndex], a
xor a
ld [W_CoreSubStateIndex], a
ret

SECTION "Item Action State Machine 2", ROMX[$53FD], BANK[$06]
ItemActionPrepareScriptEngineState::
cbcall InitiateMainScript
jp IncItemActionSubSubSubStateIndex

ItemActionPrintErrorMessageState::
ld a, [W_ItemActionMessageIndex]
ld b, a
ld a, [W_ItemActionMessageIndex + 1]
ld c, a
ld a, 1
cbcall MainScriptLoopHelper
ld a, [W_MainScriptExitMode]
or a
ret z
call LoadSelectedItemDescription
ld a, 4
ld [W_CoreSubStateIndex], a
ret

ItemActionPrepareFadeOutState::
ld hl, 1
ld bc, 1
ld d, $FF
ld e, $FF
ld a, 8
cbcall SetupPalswapAnimation
jp IncItemActionSubSubSubStateIndex

ItemActionFadeState::
cbcallindex $35
ld a, [W_PaletteAnimRunning]
or a
ret nz
jp IncItemActionSubSubSubStateIndex
2 changes: 1 addition & 1 deletion game/src/pausemenu/item_core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ ItemMenuMustBeInVehicleMessageState::
ret

ItemMenuTriggerSpecialItemActionState::
jp $5318
jp ItemActionStateMachine

ItemMenuReturnState::
ld a, 6
Expand Down
11 changes: 11 additions & 0 deletions game/src/pausemenu/items.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
INCLUDE "game/src/common/macros.asm"
INCLUDE "game/src/common/constants.asm"

SECTION "Item Action Message Index Variable", WRAM0[$C495]
W_ItemActionMessageIndex:: ds 2

SECTION "Item Page Row Index", WRAM0[$C4FC]
W_ItemPageRowIndex:: ds 1

Expand Down Expand Up @@ -240,6 +243,14 @@ ItemMenuShowPageArrows::
ld [$C104], a
ret

SECTION "Item Action Helper Functions", ROMX[$53F4], BANK[$06]
ItemActionStoreMessageIndex::
ld a, b
ld [W_ItemActionMessageIndex], a
ld a, c
ld [W_ItemActionMessageIndex + 1], a
ret

SECTION "Item Helper Functions", ROMX[$5834], BANK[$15]
IsItemInInventory::
ld [$C4EE], a
Expand Down
Loading

0 comments on commit d4396df

Please sign in to comment.