diff --git a/Menu/menu.asm b/Menu/menu.asm index 2779ea0..5937dee 100644 --- a/Menu/menu.asm +++ b/Menu/menu.asm @@ -95,6 +95,7 @@ Menu_InitGraphics: STZ.w $0300 ; ITEMSTEP STZ.w $037A ; USEY2 STZ.w $0301 ; USEY1 + STZ.w $020C ; Stats Screen Cursor Index INC $0200 } @@ -299,6 +300,7 @@ incsrc "menu_scroll.asm" Menu_StatsScreen: { JSR Menu_CheckHScroll + JSR Menu_StatsScreen_Input RTS } diff --git a/Menu/menu_journal.asm b/Menu/menu_journal.asm index efbbdd0..329e7e4 100644 --- a/Menu/menu_journal.asm +++ b/Menu/menu_journal.asm @@ -4,6 +4,10 @@ JOURNAL_STATE_FIRST_PAGE = $0000 JOURNAL_STATE_MIDDLE_PAGE = $0001 JOURNAL_STATE_LAST_PAGE = $0002 +; --------------------------------------------------------- +; Journal Handler +; --------------------------------------------------------- + Journal_Handler: { PHB : PHK : PLB @@ -28,6 +32,10 @@ Journal_Handler: RTL } +; --------------------------------------------------------- +; Page Navigation +; --------------------------------------------------------- + Journal_PrevPage: { LDA.l JournalState @@ -58,23 +66,85 @@ Journal_NextPage: RTS } +; --------------------------------------------------------- +; Entry Drawing +; --------------------------------------------------------- + Journal_DrawEntry: { REP #$30 - LDX.w #$0000 - LDY.w #$0000 + ; Calculate pointer to the text based on JournalState (Page #) + ; Entry = JournalEntries[JournalState] + LDA.l JournalState : AND.w #$00FF : ASL : TAX + LDA.w JournalEntries, X : STA.b $00 ; Store pointer in $00 (Direct Page) + + LDX.w #$0000 ; Text Offset + LDY.w #$0000 ; VRAM Offset + .loop - LDA.w BookEntries, X : STA.w $1292, Y - INY #2 : INX #2 - CPY.w #$001F : BCC .loop + ; Read from Indirect Address ($00) + Y (offset) + ; We need to be careful with addressing. + ; $00 is 16-bit pointer. We need to read from Bank 2D (current bank). + ; LDA ($00), Y works if Y is index. + ; But our X is the text offset index, Y is VRAM index. + ; Let's swap registers. + + PHY ; Save VRAM offset + TXY ; Y = Text Offset + LDA ($00), Y ; Read word from text table + PLY ; Restore VRAM offset + + STA.w $1292, Y ; Write to VRAM buffer + + INY #2 ; Next VRAM word + INX #2 ; Next Text word + + CPY.w #$0060 ; Copy 3 lines (32 bytes * 3 approx? No, original was $1F bytes -> 16 chars/1 line) + ; Original loop: CPY #$001F. That's 32 bytes (16 chars). + ; The BookEntries had 3 lines defined but the loop only did 1 line? + ; Original: + ; .loop + ; LDA.w BookEntries, X : STA.w $1292, Y + ; INY #2 : INX #2 + ; CPY.w #$001F : BCC .loop + ; Yes, it only copied the first line ($00 to $1E). + ; We should probably copy more lines. + ; Let's copy 6 lines ($60 bytes? No, $1F is 31. So 16 chars * 2 bytes = 32 bytes = $20) + ; Let's copy 3 lines = $60 bytes. + + CPY.w #$0060 : BCC .loop + SEP #$30 RTS } -BookEntries: - dw "THIS_IS_A_TEST__" - dw "______________ " - dw "______________ " +; --------------------------------------------------------- +; Data Tables +; --------------------------------------------------------- + +JournalEntries: + dw Entry_Page1 + dw Entry_Page2 + dw Entry_Page3 + +Entry_Page1: + dw "QUEST_LOG:_I____" + dw "Must_find_the___" + dw "missing_girl____" + +Entry_Page2: + dw "QUEST_LOG:_II___" + dw "The_Mushroom_is_" + dw "key_to_the_woods" + +Entry_Page3: + dw "QUEST_LOG:_III__" + dw "Zora_River_flows" + dw "from_the_north__" + +; --------------------------------------------------------- +; Background Drawing +; --------------------------------------------------------- Menu_DrawJournal: { @@ -182,5 +252,4 @@ Journal_DrawLastPage: .last_page_tilemap incbin "tilemaps/journal_end.bin" -} - +} \ No newline at end of file diff --git a/Menu/menu_select_item.asm b/Menu/menu_select_item.asm index 618795c..ae771dc 100644 --- a/Menu/menu_select_item.asm +++ b/Menu/menu_select_item.asm @@ -1,327 +1,459 @@ -; ========================================================= -; Item Selection Code - -; Decides which function to jump to. -Menu_ItemIndex: - db $00 - ; Bow, Boomerang, Hookshot, Bombs, Powder, Bottle 1 - db $03, $02, $0E, $01, $0A, $0B - ; Hammer, Lamp, Fire Rod, Ice Rod, Mirror, Bottle 2 - db $04, $09, $05, $06, $14, $0B - ; Ocarina, Book, Somaria, Byrna, Feather, Bottle3 - db $08, $0C, $12, $0D, $07, $0B - ; Deku, Zora, Wolf, Bunny Hood, Stone Mask, Bottle4 - db $11, $0F, $08, $10, $13, $0B - -; ========================================================= -; Decides which graphics is drawn -Menu_AddressIndex: - db $7EF340 ; Bow - db $7EF341 ; Boomerang - db $7EF342 ; Hookshot / Goldstar - db $7EF343 ; Bombs - db $7EF344 ; Powder - db $7EF35C ; Bottle 1 - - db $7EF34B ; Hammer - db $7EF34A ; Lamp - db $7EF345 ; Fire Rod - db $7EF346 ; Ice Rod - db $7EF353 ; Magic Mirror - db $7EF35D ; Bottle 2 - - db $7EF34C ; Ocarina ; shovel 7EF34F - db $7EF34E ; Book of Secrets - db $7EF350 ; Cane of Somaria / Cane of Byrna - db $7EF351 ; Fishing Rod / Portal Rod - db $7EF34D ; Roc's Feather - db $7EF35E ; Bottle 3 - - db $7EF349 ; Deku Mask - db $7EF347 ; Zora Mask - db $7EF358 ; Wolf Mask - db $7EF348 ; Bunny Hood - db $7EF352 ; Stone Mask - db $7EF35F ; Bottle #4 - -; ========================================================= - -Menu_ItemCursorPositions: - dw menu_offset(6,2) ; bow - dw menu_offset(6,5) ; boom - dw menu_offset(6,8) ; hookshot - dw menu_offset(6,12) ; bombs - dw menu_offset(6,15) ; deku mask - dw menu_offset(6,18) ; bottle1 - - dw menu_offset(9,2) ; hammer - dw menu_offset(9,5) ; lamp - dw menu_offset(9,8) ; firerod - dw menu_offset(9,12) ; icerod - dw menu_offset(9,15) ; goron - dw menu_offset(9,18) ; bottle2 - - dw menu_offset(12,2) ; shovel - dw menu_offset(12,5) ; feather - dw menu_offset(12,8) ; somaria - dw menu_offset(12,12) ; byrna / fishing rod - dw menu_offset(12,15) ; bunny hood - dw menu_offset(12,18) ; bottle3 - - dw menu_offset(15,2) ; powder - dw menu_offset(15,5) ; book - dw menu_offset(15,8) ; flute - dw menu_offset(15,12) ; mirror - dw menu_offset(15,15) ; stone mask - dw menu_offset(15,18) ; bottle4 - -; ========================================================= - -Menu_FindNextItem: -{ - LDY.w $0202 : INY - CPY.b #$19 : BCC .no_reset - LDY.b #$01 - .no_reset - STY.w $0202 - LDX.w Menu_AddressIndex-1, Y - LDA.l $7EF300, X - BEQ Menu_FindNextItem - RTS -} - -; ========================================================= - -Menu_FindPrevItem: -{ - LDY.w $0202 : DEY : BNE .no_reset - LDY.b #$18 - .no_reset - STY.w $0202 - LDX.w Menu_AddressIndex-1, Y - LDA.l $7EF300, X - BEQ Menu_FindPrevItem - RTS -} - -; ========================================================= - -Menu_FindNextDownItem: -{ - LDA.w $0202 : CLC : ADC.b #$06 - CMP.b #$19 : BCC .no_reset - SBC.b #$18 - .no_reset - TAY : STY.w $0202 - LDX.w Menu_AddressIndex-1, Y - LDA.l $7EF300, X - BEQ Menu_FindNextItem - RTS -} - -; ========================================================= - -Menu_FindNextUpItem: -{ - LDA.w $0202 : SEC : SBC.b #$06 - BPL .no_reset : BNE .no_reset - CLC : ADC.b #$18 - .no_reset - TAY : STY.w $0202 - CPY.b #$19 : BCS .reset_up - LDX.w Menu_AddressIndex-1, Y - LDA.l $7EF300, X - BEQ Menu_FindNextItem - RTS - .reset_up - LDY.b #$01 - STY.w $0202 - LDX.w Menu_AddressIndex-1, Y - LDA.l $7EF300, X - BEQ Menu_FindNextItem - RTS -} - - -; ========================================================= - -Menu_DeleteCursor: -{ - REP #$30 - LDX.w Menu_ItemCursorPositions-2, Y - -Menu_DeleteCursor_AltEntry: - LDA.w #$20F5 - STA.w $1108, X : STA.w $1148, X - STA.w $114E, X : STA.w $110E, X - STA.w $11C8, X : STA.w $1188, X - STA.w $118E, X : STA.w $11CE, X - SEP #$30 - STZ $0207 - RTS -} - -; ========================================================= - -Menu_InitItemScreen: -{ - SEP #$30 - LDY.w $0202 : BNE .all_good - ; Loop through the SRM of each item to see if we have - ; one of them so we can start with that one selected. - .lookForAlternateItem - LDY.b #$00 - - .loop - INY : CPY.b #$25 : BCS .bad - LDX.w Menu_AddressIndex-1, Y - LDA.l $7EF300, X - BEQ .loop - - STY.w $0202 - BRA .all_good - - .bad - ; If we made it here that means there are no items - ; available but one was still selected. This should - ; never happen under normal vanilla circumstances. - STZ.w $0202 - - STZ $0207 - LDA.b #$04 - STA.w $0200 - RTS - - .all_good - ; Double check we still have the item that was selected. - ; This is to prevent a bug where we can get stuck in an - ; infinite loop later on. - LDX.w Menu_AddressIndex-1, Y - LDA.l $7EF300, X - CMP.b #$01 : BCC .lookForAlternateItem - STZ $0207 - LDA.b #$04 - STA.w $0200 - RTS -} - -; ========================================================= - -Menu_AddressLong: - db $40 ; Bow - db $41 ; Boomerang - db $42 ; Hookshot - db $43 ; Bombs - db $44 ; Powder - db $5C ; Bottle 1 - - db $4B ; Hammer - db $4A ; Lamp - db $45 ; Fire Rod - db $46 ; Ice Rod - db $53 ; Magic Mirror - db $5D ; Bottle 2 - - db $4C ; Ocarina (formerly shovel 4F) - db $4E ; Book - db $50 ; Cane of Somaria / Cane of Byrna - db $51 ; Fishing Rod - db $4D ; Roc's Feather - db $5E ; Bottle 3 - - db $49 ; Deku Mask - db $47 ; Zora Mask - db $58 ; Wolf Mask - db $48 ; Bunny Hood - db $52 ; Stone Mask - db $5F ; Bottle 4 - -GotoNextItem_Local: -{ - ; Load our currently equipped item, and move to the next one - ; If we reach our limit (21), set it back to the bow and arrow slot. - LDA $0202 : INC A : CMP.b #$18 : BCC .dont_reset - LDA.b #$01 - .dont_reset - ; Otherwise try to equip the item in the next slot - STA $0202 - RTS -} - -DoWeHaveThisItem_Override: -{ - LDY.w $0202 : LDX.w Menu_AddressLong-1, Y - LDA.l $7EF300, X : CMP.b #$00 : BNE .have_this_item - CLC - RTL - .have_this_item - SEC - RTL -} - -TryEquipNextItem_Override: -{ - .keep_looking - JSR GotoNextItem_Local - JSL DoWeHaveThisItem_Override : BCC .keep_looking - RTS -} - -SearchForEquippedItem_Override: -{ - PHB : PHK : PLB - SEP #$30 - - LDY.b #$18 - .next_check - LDX.w Menu_AddressLong-1, Y - LDA.l $7EF300, X : CMP.b #$00 : BNE .item_available - DEY : BPL .next_check - - ; In this case we have no equippable items - STZ $0202 : STZ $0203 : STZ $0204 - - .we_have_that_item - REP #$30 - PLB - RTL - - .item_available - ; Is there an item currently equipped (in the HUD slot)? - LDA.w $0202 : BNE .alreadyEquipped - ; If not, set the equipped item to the Lamp - LDA.b #$08 : STA $0202 - - .alreadyEquipped - JMP .exit - .keep_looking - JSR GotoNextItem_Local - JSL DoWeHaveThisItem_Override : BCC .keep_looking - BCS .we_have_that_item - JSR TryEquipNextItem_Override - .exit - - REP #$30 - PLB - RTL -} - -pushpc - -org $0DDEB0 -ItemMenu_CheckForOwnership: -{ - JSL DoWeHaveThisItem_Override - RTS -} - -org $0DE399 -SearchForEquippedItem: -{ - JSL SearchForEquippedItem_Override - RTS -} -assert pc() <= $0DE3C7 - -pullpc - +; ========================================================= +; Item Selection Code + +; Decides which function to jump to. +Menu_ItemIndex: + db $00 + ; Bow, Boomerang, Hookshot, Bombs, Powder, Bottle 1 + db $03, $02, $0E, $01, $0A, $0B + ; Hammer, Lamp, Fire Rod, Ice Rod, Mirror, Bottle 2 + db $04, $09, $05, $06, $14, $0B + ; Ocarina, Book, Somaria, Byrna, Feather, Bottle3 + db $08, $0C, $12, $0D, $07, $0B + ; Deku, Zora, Wolf, Bunny Hood, Stone Mask, Bottle4 + db $11, $0F, $08, $10, $13, $0B + +; ========================================================= +; Decides which graphics is drawn +Menu_AddressIndex: + db $7EF340 ; Bow + db $7EF341 ; Boomerang + db $7EF342 ; Hookshot / Goldstar + db $7EF343 ; Bombs + db $7EF344 ; Powder + db $7EF35C ; Bottle 1 + + db $7EF34B ; Hammer + db $7EF34A ; Lamp + db $7EF345 ; Fire Rod + db $7EF346 ; Ice Rod + db $7EF353 ; Magic Mirror + db $7EF35D ; Bottle 2 + + db $7EF34C ; Ocarina ; shovel 7EF34F + db $7EF34E ; Book of Secrets + db $7EF350 ; Cane of Somaria / Cane of Byrna + db $7EF351 ; Fishing Rod / Portal Rod + db $7EF34D ; Roc's Feather + db $7EF35E ; Bottle 3 + + db $7EF349 ; Deku Mask + db $7EF347 ; Zora Mask + db $7EF358 ; Wolf Mask + db $7EF348 ; Bunny Hood + db $7EF352 ; Stone Mask + db $7EF35F ; Bottle #4 + +; ========================================================= + +Menu_ItemCursorPositions: + dw menu_offset(6,2) ; bow + dw menu_offset(6,5) ; boom + dw menu_offset(6,8) ; hookshot + dw menu_offset(6,12) ; bombs + dw menu_offset(6,15) ; deku mask + dw menu_offset(6,18) ; bottle1 + + dw menu_offset(9,2) ; hammer + dw menu_offset(9,5) ; lamp + dw menu_offset(9,8) ; firerod + dw menu_offset(9,12) ; icerod + dw menu_offset(9,15) ; goron + dw menu_offset(9,18) ; bottle2 + + dw menu_offset(12,2) ; shovel + dw menu_offset(12,5) ; feather + dw menu_offset(12,8) ; somaria + dw menu_offset(12,12) ; byrna / fishing rod + dw menu_offset(12,15) ; bunny hood + dw menu_offset(12,18) ; bottle3 + + dw menu_offset(15,2) ; powder + dw menu_offset(15,5) ; book + dw menu_offset(15,8) ; flute + dw menu_offset(15,12) ; mirror + dw menu_offset(15,15) ; stone mask + dw menu_offset(15,18) ; bottle4 + +; ========================================================= + +Menu_FindNextItem: +{ + LDY.w $0202 : INY + CPY.b #$19 : BCC .no_reset + LDY.b #$01 + .no_reset + STY.w $0202 + LDX.w Menu_AddressIndex-1, Y + LDA.l $7EF300, X + BEQ Menu_FindNextItem + RTS +} + +; ========================================================= + +Menu_FindPrevItem: +{ + LDY.w $0202 : DEY : BNE .no_reset + LDY.b #$18 + .no_reset + STY.w $0202 + LDX.w Menu_AddressIndex-1, Y + LDA.l $7EF300, X + BEQ Menu_FindPrevItem + RTS +} + +; ========================================================= + +Menu_FindNextDownItem: +{ + LDA.w $0202 : CLC : ADC.b #$06 + CMP.b #$19 : BCC .no_reset + SBC.b #$18 + .no_reset + TAY : STY.w $0202 + LDX.w Menu_AddressIndex-1, Y + LDA.l $7EF300, X + BEQ Menu_FindNextItem + RTS +} + +; ========================================================= + +Menu_FindNextUpItem: +{ + LDA.w $0202 : SEC : SBC.b #$06 + BPL .no_reset : BNE .no_reset + CLC : ADC.b #$18 + .no_reset + TAY : STY.w $0202 + CPY.b #$19 : BCS .reset_up + LDX.w Menu_AddressIndex-1, Y + LDA.l $7EF300, X + BEQ Menu_FindNextItem + RTS + .reset_up + LDY.b #$01 + STY.w $0202 + LDX.w Menu_AddressIndex-1, Y + LDA.l $7EF300, X + BEQ Menu_FindNextItem + RTS +} + + +; ========================================================= + +Menu_DeleteCursor: +{ + REP #$30 + LDX.w Menu_ItemCursorPositions-2, Y + +Menu_DeleteCursor_AltEntry: + LDA.w #$20F5 + STA.w $1108, X : STA.w $1148, X + STA.w $114E, X : STA.w $110E, X + STA.w $11C8, X : STA.w $1188, X + STA.w $118E, X : STA.w $11CE, X + SEP #$30 + STZ $0207 + RTS +} + +; ========================================================= + +Menu_InitItemScreen: +{ + SEP #$30 + LDY.w $0202 : BNE .all_good + ; Loop through the SRM of each item to see if we have + ; one of them so we can start with that one selected. + .lookForAlternateItem + LDY.b #$00 + + .loop + INY : CPY.b #$25 : BCS .bad + LDX.w Menu_AddressIndex-1, Y + LDA.l $7EF300, X + BEQ .loop + + STY.w $0202 + BRA .all_good + + .bad + ; If we made it here that means there are no items + ; available but one was still selected. This should + ; never happen under normal vanilla circumstances. + STZ.w $0202 + + STZ $0207 + LDA.b #$04 + STA.w $0200 + RTS + + .all_good + ; Double check we still have the item that was selected. + ; This is to prevent a bug where we can get stuck in an + ; infinite loop later on. + LDX.w Menu_AddressIndex-1, Y + LDA.l $7EF300, X + CMP.b #$01 : BCC .lookForAlternateItem + STZ $0207 + LDA.b #$04 + STA.w $0200 + RTS +} + +; ========================================================= + +Menu_AddressLong: + db $40 ; Bow + db $41 ; Boomerang + db $42 ; Hookshot + db $43 ; Bombs + db $44 ; Powder + db $5C ; Bottle 1 + + db $4B ; Hammer + db $4A ; Lamp + db $45 ; Fire Rod + db $46 ; Ice Rod + db $53 ; Magic Mirror + db $5D ; Bottle 2 + + db $4C ; Ocarina (formerly shovel 4F) + db $4E ; Book + db $50 ; Cane of Somaria / Cane of Byrna + db $51 ; Fishing Rod + db $4D ; Roc's Feather + db $5E ; Bottle 3 + + db $49 ; Deku Mask + db $47 ; Zora Mask + db $58 ; Wolf Mask + db $48 ; Bunny Hood + db $52 ; Stone Mask + db $5F ; Bottle 4 + +GotoNextItem_Local: +{ + ; Load our currently equipped item, and move to the next one + ; If we reach our limit (21), set it back to the bow and arrow slot. + LDA $0202 : INC A : CMP.b #$18 : BCC .dont_reset + LDA.b #$01 + .dont_reset + ; Otherwise try to equip the item in the next slot + STA $0202 + RTS +} + +DoWeHaveThisItem_Override: +{ + LDY.w $0202 : LDX.w Menu_AddressLong-1, Y + LDA.l $7EF300, X : CMP.b #$00 : BNE .have_this_item + CLC + RTL + .have_this_item + SEC + RTL +} + +TryEquipNextItem_Override: +{ + .keep_looking + JSR GotoNextItem_Local + JSL DoWeHaveThisItem_Override : BCC .keep_looking + RTS +} + +SearchForEquippedItem_Override: +{ + PHB : PHK : PLB + SEP #$30 + + LDY.b #$18 + .next_check + LDX.w Menu_AddressLong-1, Y + LDA.l $7EF300, X : CMP.b #$00 : BNE .item_available + DEY : BPL .next_check + + ; In this case we have no equippable items + STZ $0202 : STZ $0203 : STZ $0204 + + .we_have_that_item + REP #$30 + PLB + RTL + + .item_available + ; Is there an item currently equipped (in the HUD slot)? + LDA.w $0202 : BNE .alreadyEquipped + ; If not, set the equipped item to the Lamp + LDA.b #$08 : STA $0202 + + .alreadyEquipped + JMP .exit + .keep_looking + JSR GotoNextItem_Local + JSL DoWeHaveThisItem_Override : BCC .keep_looking + BCS .we_have_that_item + JSR TryEquipNextItem_Override + .exit + + REP #$30 + PLB + RTL +} + +pushpc + +org $0DDEB0 +ItemMenu_CheckForOwnership: +{ + JSL DoWeHaveThisItem_Override + RTS +} + +org $0DE399 +SearchForEquippedItem: +{ + JSL SearchForEquippedItem_Override + RTS +} +assert pc() <= $0DE3C7 + +pullpc + + +; ========================================================= +; Stats Screen Selector Logic +; ========================================================= + +Menu_StatsCursorPositions: + ; Row 14: Sword, Shield, Tunic + dw menu_offset(14,2) ; 0: Sword + dw menu_offset(14,5) ; 1: Shield + dw menu_offset(14,8) ; 2: Tunic + dw menu_offset(14,8) ; 3: Placeholder (maps to Tunic) + + ; Row 17: Glove, Flippers, Boots, Pearl + dw menu_offset(17,2) ; 4: Glove + dw menu_offset(17,5) ; 5: Flippers + dw menu_offset(17,8) ; 6: Boots + dw menu_offset(17,11) ; 7: Pearl + +Stats_Nav_Right: + db $01, $02, $00, $00, $05, $06, $07, $04 +Stats_Nav_Left: + db $02, $00, $01, $01, $07, $04, $05, $06 +Stats_Nav_Down: + db $04, $05, $06, $07, $00, $01, $02, $02 +Stats_Nav_Up: + db $04, $05, $06, $07, $00, $01, $02, $02 + +Menu_DrawStatsCursor: +{ + LDA.b #$20 : BIT.w $0207 + REP #$20 + BEQ .no_delete + ; Delete cursor + LDA.w #$20F5 + STA.w $1108, X : STA.w $1148, X + STA.w $114E, X : STA.w $110E, X + STA.w $11C8, X : STA.w $1188, X + STA.w $118E, X : STA.w $11CE, X + BRA .done + + .no_delete + ; We reuse the Item Menu cursor graphics + LDA.w #$3060 : STA.w $1108, X ; corner + LDA.w #$3070 : STA.w $1148, X + + LDA.w #$7060 : STA.w $110E, X ; corner + LDA.w #$7070 : STA.w $114E, X + + LDA.w #$3070 : STA.w $1188, X + LDA.w #$B060 : STA.w $11C8, X ; corner + + LDA.w #$7070 : STA.w $118E, X + LDA.w #$F060 : STA.w $11CE, X ; corner + + .done + SEP #$20 + RTS +} + +Menu_DeleteStatsCursor: +{ + REP #$30 + ; Use $020C for index + LDA.w $020C : AND.w #$00FF : ASL : TAY + LDX.w Menu_StatsCursorPositions, Y + + LDA.w #$20F5 + STA.w $1108, X : STA.w $1148, X + STA.w $114E, X : STA.w $110E, X + STA.w $11C8, X : STA.w $1188, X + STA.w $118E, X : STA.w $11CE, X + SEP #$30 + STZ $0207 + RTS +} + +Menu_StatsScreen_Input: +{ + INC $0207 + + ; Safety check for uninitialized index + LDA.w $020C : AND #$F8 : BEQ .safe_index + STZ.w $020C + .safe_index + + LDA.b $F4 ; Joypad + LSR : BCS .move_right + LSR : BCS .move_left + LSR : BCS .move_down + LSR : BCS .move_up + BRA .draw_cursor + + .move_right + JSR Menu_DeleteStatsCursor + LDY.w $020C + LDA.w Stats_Nav_Right, Y + STA.w $020C + BRA .play_sound + + .move_left + JSR Menu_DeleteStatsCursor + LDY.w $020C + LDA.w Stats_Nav_Left, Y + STA.w $020C + BRA .play_sound + + .move_down + JSR Menu_DeleteStatsCursor + LDY.w $020C + LDA.w Stats_Nav_Down, Y + STA.w $020C + BRA .play_sound + + .move_up + JSR Menu_DeleteStatsCursor + LDY.w $020C + LDA.w Stats_Nav_Up, Y + STA.w $020C + BRA .play_sound + + .play_sound + LDA.b #$20 : STA.w $012F + + .draw_cursor + SEP #$30 + LDA.w $020C : ASL : TAY + REP #$10 + LDX.w Menu_StatsCursorPositions, Y + JSR Menu_DrawStatsCursor + SEP #$20 + RTS +} \ No newline at end of file