diff --git a/battle/core.asm b/battle/core.asm index cf550a465..373a960bd 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -5342,7 +5342,7 @@ BattleMenuPKMN_Loop: callba FreezeMonIcons call .GetMenu jr c, .PressedB - call Function1bee + call PlaceHollowCursor ld a, [wMenuCursorY] cp $1 ; SWITCH jp z, TryPlayerSwitch diff --git a/data/odd_eggs.asm b/data/odd_eggs.asm index 1e4525d39..878126c64 100644 --- a/data/odd_eggs.asm +++ b/data/odd_eggs.asm @@ -52,7 +52,7 @@ GiveOddEgg: ; 1fb4b6 ld a, 1 ld [wItemQuantityChangeBuffer], a ld a, -1 - ld [ItemCountBuffer], a + ld [CurItemQuantity], a ld hl, NumItems call TossItem diff --git a/engine/billspc.asm b/engine/billspc.asm index 4363cce1d..14f0509b2 100755 --- a/engine/billspc.asm +++ b/engine/billspc.asm @@ -2323,7 +2323,7 @@ _ChangeBox: ; e35aa (38:75aa) hlcoord 0, 4 lb bc, 8, 9 call TextBox - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuJoypad] cp B_BUTTON jr z, .done diff --git a/engine/decorations.asm b/engine/decorations.asm index 794552a70..94c2a9413 100755 --- a/engine/decorations.asm +++ b/engine/decorations.asm @@ -11,16 +11,16 @@ _KrisDecorationMenu: ; 0x2675c ld hl, .MenuDataHeader call LoadMenuDataHeader xor a - ld [wd1ee], a + ld [Buffer5], a ld a, $1 - ld [wd1ef], a + ld [Buffer6], a .top_loop - ld a, [wd1ef] + ld a, [Buffer6] ld [wMenuCursorBuffer], a call .FindCategoriesWithOwnedDecos call DoNthMenu ld a, [wMenuCursorY] - ld [wd1ef], a + ld [Buffer6], a jr c, .exit_menu ld a, [MenuSelection] ld hl, .pointers @@ -31,7 +31,7 @@ _KrisDecorationMenu: ; 0x2675c call ExitMenu pop af ld [wcf76], a - ld a, [wd1ee] + ld a, [Buffer5] ld c, a ret ; 0x2679a @@ -400,7 +400,7 @@ PopulateDecoCategoryMenu: ; 2695b call InitScrollingMenu xor a ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuJoypad] cp 2 jr z, .no_action_2 @@ -803,7 +803,7 @@ DecoAction_TrySetItUp: ; 26d2d call DecoAction_SetItUp jr c, .failed ld a, 1 - ld [wd1ee], a + ld [Buffer5], a pop hl ld a, [MenuSelection] ld [hl], a @@ -865,7 +865,7 @@ DecoAction_TryPutItAway: ; 26d86 jr z, .nothingthere ; Put it away. ld a, $1 - ld [wd1ee], a + ld [Buffer5], a ld a, [Buffer1] ld [MenuSelection], a ld hl, StringBuffer3 @@ -889,7 +889,7 @@ DecoAction_setupornament: ; 26db3 call DecoAction_SetItUp_Ornament jr c, .cancel ld a, $1 - ld [wd1ee], a + ld [Buffer5], a jr DecoAction_FinishUp_Ornament .cancel @@ -981,7 +981,7 @@ DecoAction_PutItAway_Ornament: ; 26e46 ld hl, StringBuffer3 call GetDecorationName ld a, $1 - ld [wd1ee], a + ld [Buffer5], a xor a ld [wd1ec], a ld hl, DecoText_PutAwayTheDeco diff --git a/engine/intro_menu.asm b/engine/intro_menu.asm index ca80665b4..6c26f3a0c 100755 --- a/engine/intro_menu.asm +++ b/engine/intro_menu.asm @@ -545,7 +545,7 @@ Continue_LoadMenuHeader: ; 5ebf ld hl, .MenuDataHeader_NoDex .pokedex_header - call Function1e35 + call _OffsetMenuDataHeader call MenuBox call PlaceVerticalMenuItems ret diff --git a/engine/link.asm b/engine/link.asm index 2083c9fb6..69554611b 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -1271,7 +1271,7 @@ Function28835: ; 28835 jp nz, Function2891c xor a ld [MonType], a - call Function1bf7 + call HideCursor push hl push bc ld bc, NAME_LENGTH @@ -1333,7 +1333,7 @@ Function288c5: ; 288c5 jp nz, Function2891c ld a, $1 ld [MonType], a - call Function1bf7 + call HideCursor push hl push bc ld bc, NAME_LENGTH @@ -1353,7 +1353,7 @@ Function288c5: ; 288c5 ld a, [PartyCount] cp b jr nz, Function2891c - call Function1bf7 + call HideCursor push hl push bc ld bc, NAME_LENGTH @@ -1463,7 +1463,7 @@ Function28926: ; 28926 jp Function2888b .asm_289fe - call Function1bee + call PlaceHollowCursor pop af ld [wMenuCursorY], a dec a @@ -1552,7 +1552,7 @@ Function28ac9: ; 28ac9 ld a, [wMenuCursorY] cp $1 jp nz, Function2891c - call Function1bf7 + call HideCursor push hl push bc ld bc, NAME_LENGTH diff --git a/engine/mail.asm b/engine/mail.asm index f8619c9f6..4c0af5f9b 100755 --- a/engine/mail.asm +++ b/engine/mail.asm @@ -399,7 +399,7 @@ MailboxPC: ; 0x44806 ld [wMenuCursorBuffer], a ld a, [OBPals + 8 * 6] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [OBPals + 8 * 6], a ld a, [wMenuCursorY] diff --git a/engine/main_menu.asm b/engine/main_menu.asm index 888f5a9a5..306551a88 100755 --- a/engine/main_menu.asm +++ b/engine/main_menu.asm @@ -530,7 +530,7 @@ endr Function4a098: ; 4a098 (12:6098) ld a, $2 call MenuClickSound - call Function1bee + call PlaceHollowCursor call WaitBGMap call LoadStandardMenuDataHeader callba Function89de0 @@ -749,7 +749,7 @@ Function4a28a: ; 4a28a (12:628a) lb bc, 6, 1 ld a, " " call Function4a6d8 - call Function1bee + call PlaceHollowCursor call WaitBGMap call LoadStandardMenuDataHeader ld a, $5 @@ -786,7 +786,7 @@ Function4a28a: ; 4a28a (12:628a) scf ret .asm_4a2f0 - call Function1bee + call PlaceHollowCursor ld hl, UnknownText_0x4a358 call PrintText hlcoord 14, 7 diff --git a/engine/mart.asm b/engine/mart.asm index 7673df5af..8852e104b 100755 --- a/engine/mart.asm +++ b/engine/mart.asm @@ -470,7 +470,7 @@ endr BuyMenuLoop: ; 15cef - callba PlaceMoneyTopRightOW + callba PlaceMoneyTopRight call UpdateSprites ld hl, MenuDataHeader_Buy call CopyMenuDataHeader @@ -478,7 +478,7 @@ BuyMenuLoop: ; 15cef ld [wMenuCursorBuffer], a ld a, [wd045 + 1] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wd045 + 1], a ld a, [wMenuCursorY] @@ -875,7 +875,7 @@ Function15ee0: ; 15ee0 .okay_to_sell ld hl, Text_Mart_SellHowMany call PrintText - callba PlaceMoneyTopRightMenu + callba PlaceMoneyAtTopLeftOfTextbox callba SelectQuantityToSell call ExitMenu jr c, .declined @@ -899,7 +899,7 @@ Function15ee0: ; 15ee0 ld hl, Text_Mart_SoldForAmount call PrintTextBoxText call PlayTransactionSound - callba PlaceMoneyBottomLeftOW + callba PlaceMoneyBottomLeft call JoyWaitAorB .declined diff --git a/engine/pack.asm b/engine/pack.asm index 33d44a745..3168b817a 100644 --- a/engine/pack.asm +++ b/engine/pack.asm @@ -69,7 +69,7 @@ Pack: ; 10000 ld [wMenuCursorBuffer], a ld a, [wItemsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -97,7 +97,7 @@ Pack: ; 10000 ld [wMenuCursorBuffer], a ld a, [wKeyItemsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -230,7 +230,7 @@ Pack: ; 10000 ld [wMenuCursorBuffer], a ld a, [wBallsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -528,7 +528,7 @@ TossMenu: ; 10364 pop af jr c, .finish ld hl, NumItems - ld a, [ItemCountBuffer] + ld a, [CurItemQuantity] call TossItem call Pack_GetItemName ld hl, Text_ThrewAway @@ -577,7 +577,7 @@ RegisterItem: ; 103c2 rrca and $c0 ld b, a - ld a, [ItemCountBuffer] + ld a, [CurItemQuantity] inc a and $3f or b @@ -734,7 +734,7 @@ BattlePack: ; 10493 ld [wMenuCursorBuffer], a ld a, [wItemsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -762,7 +762,7 @@ BattlePack: ; 10493 ld [wMenuCursorBuffer], a ld a, [wKeyItemsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -813,7 +813,7 @@ BattlePack: ; 10493 ld [wMenuCursorBuffer], a ld a, [wBallsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -1018,7 +1018,7 @@ DepositSellPack: ; 106be ld [wMenuCursorBuffer], a ld a, [wItemsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -1034,7 +1034,7 @@ DepositSellPack: ; 106be ld [wMenuCursorBuffer], a ld a, [wKeyItemsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -1059,7 +1059,7 @@ DepositSellPack: ; 106be ld [wMenuCursorBuffer], a ld a, [wBallsPocketScrollPosition] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a ld a, [wMenuCursorY] @@ -1243,7 +1243,7 @@ TutorialPack: ; 107bb call InitPocket pop hl call CopyMenuDataHeader - call HandleScrollingMenu + call ScrollingMenu ret Pack_JumptableNext: ; 10866 (4:4866) diff --git a/engine/party_menu.asm b/engine/party_menu.asm index 4aa71ecf7..4df2c4251 100644 --- a/engine/party_menu.asm +++ b/engine/party_menu.asm @@ -739,7 +739,7 @@ PartyMenuAttributes: ; 5044f PartyMenuSelect: ; 0x50457 ; sets carry if exitted menu. call StaticMenuJoypad - call Function1bee + call PlaceHollowCursor ld a, [PartyCount] inc a ld b, a diff --git a/engine/pokecenter_pc.asm b/engine/pokecenter_pc.asm index 8f18e8814..acfd06783 100755 --- a/engine/pokecenter_pc.asm +++ b/engine/pokecenter_pc.asm @@ -591,7 +591,7 @@ Function15985: ; 0x15985 ld [wMenuCursorBuffer], a ld a, [wd0dd] ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuScrollPosition] ld [wd0dd], a ld a, [wMenuCursorY] @@ -636,7 +636,7 @@ Function15985: ; 0x15985 .asm_159fb callba Function24706 - call Function1bee + call PlaceHollowCursor and a ret diff --git a/engine/scripting.asm b/engine/scripting.asm index 83d4e8a04..a6499dcdb 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -2385,7 +2385,7 @@ Script_takeitem: ; 977f0 call GetScriptByte ld [wItemQuantityChangeBuffer], a ld a, -1 - ld [ItemCountBuffer], a + ld [CurItemQuantity], a ld hl, NumItems call TossItem ret nc diff --git a/engine/scrolling_menu.asm b/engine/scrolling_menu.asm new file mode 100755 index 000000000..c5a671ce6 --- /dev/null +++ b/engine/scrolling_menu.asm @@ -0,0 +1,544 @@ +_InitScrollingMenu:: ; 245af + xor a + ld [wMenuJoypad], a + ld [hBGMapMode], a + inc a + ld [hInMenu], a + call InitScrollingMenuCursor + call ScrollingMenu_InitFlags + call ScrollingMenu_ValidateSwitchItem + call ScrollingMenu_InitDisplay + call ApplyTilemap + xor a + ld [hBGMapMode], a + ret +; 245cb + +_ScrollingMenu:: ; 245cb +.loop + call ScrollingMenuJoyAction + jp c, .exit + call z, .zero + jr .loop +; 245d6 + +.exit: ; 245d6 + call MenuClickSound + ld [wMenuJoypad], a + ld a, 0 + ld [hInMenu], a + ret +; 245e1 + +.zero: ; 245e1 + call ScrollingMenu_InitDisplay + ld a, 1 + ld [hBGMapMode], a + ld c, 3 + call DelayFrames + xor a + ld [hBGMapMode], a + ret +; 245f1 + +ScrollingMenu_InitDisplay: ; 245f1 + xor a + ld [hBGMapMode], a + ld hl, Options + ld a, [hl] + push af + set NO_TEXT_SCROLL, [hl] + call ScrollingMenu_UpdateDisplay + call ScrollingMenu_PlaceCursor + call ScrollingMenu_CheckCallFunction3 + pop af + ld [Options], a + ret +; 24609 + +ScrollingMenuJoyAction: ; 24609 +.loop + call ScrollingMenuJoypad + ld a, [hJoyLast] + and D_PAD + ld b, a + ld a, [hJoyPressed] + and BUTTONS + or b + bit 0, a ; A + jp nz, .a_button + bit 1, a ; B + jp nz, .b_button + bit 2, a ; Select + jp nz, .select + bit 3, a ; Start + jp nz, .start + bit 4, a ; Right + jp nz, .d_right + bit 5, a ; Left + jp nz, .d_left + bit 6, a ; Up + jp nz, .d_up + bit 7, a ; Down + jp nz, .d_down + jr .loop +; 24640 + +.unreferenced: ; unreferenced + ld a, -1 + and a + ret +; 24644 + +.a_button: ; 24644 + call PlaceHollowCursor + ld a, [wMenuCursorY] + dec a + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld a, [MenuSelection] + ld [CurItem], a + ld a, [MenuSelectionQuantity] + ld [wItemQuantityBuffer], a + call ScrollingMenu_GetCursorPosition + dec a + ld [wScrollingMenuCursorPosition], a + ld [CurItemQuantity], a + ld a, [MenuSelection] + cp -1 + jr z, .b_button + ld a, A_BUTTON + scf + ret +; 2466f + +.b_button: ; 2466f + ld a, B_BUTTON + scf + ret +; 24673 + +.select: ; 24673 + ld a, [wMenuData2Flags] + bit 7, a + jp z, xor_a_dec_a + ld a, [wMenuCursorY] + dec a + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld a, [MenuSelection] + cp -1 + jp z, xor_a_dec_a + call ScrollingMenu_GetCursorPosition + dec a + ld [wScrollingMenuCursorPosition], a + ld a, SELECT + scf + ret +; 24695 + +.start: ; 24695 + ld a, [wMenuData2Flags] + bit 6, a + jp z, xor_a_dec_a + ld a, START + scf + ret +; 246a1 + +.d_left: ; 246a1 + ld hl, w2DMenuFlags2 + bit 7, [hl] + jp z, xor_a_dec_a + ld a, [wMenuData2Flags] + bit 3, a + jp z, xor_a_dec_a + ld a, D_LEFT + scf + ret +; 246b5 + +.d_right: ; 246b5 + ld hl, w2DMenuFlags2 + bit 7, [hl] + jp z, xor_a_dec_a + ld a, [wMenuData2Flags] + bit 2, a + jp z, xor_a_dec_a + ld a, D_RIGHT + scf + ret +; 246c9 + +.d_up: ; 246c9 + ld hl, w2DMenuFlags2 + bit 7, [hl] + jp z, xor_a + ld hl, wMenuScrollPosition + ld a, [hl] + and a + jr z, .xor_dec_up + dec [hl] + jp xor_a + +.xor_dec_up + jp xor_a_dec_a +; 246df + +.d_down: ; 246df + ld hl, w2DMenuFlags2 + bit 7, [hl] + jp z, xor_a + ld hl, wMenuScrollPosition + ld a, [wMenuData2_ScrollingMenuHeight] + add [hl] + ld b, a + ld a, [wScrollingMenuListSize] + cp b + jr c, .xor_dec_down + inc [hl] + jp xor_a + +.xor_dec_down + jp xor_a_dec_a +; 246fc + +ScrollingMenu_GetCursorPosition: ; 246fc + ld a, [wMenuScrollPosition] + ld c, a + ld a, [wMenuCursorY] + add c + ld c, a + ret +; 24706 + +Function24706: ; 24706 (9:4706) + call MenuBoxCoord2Tile + ld de, SCREEN_WIDTH + add hl, de + ld de, 2 * SCREEN_WIDTH + ld a, [wMenuData2_ScrollingMenuHeight] +.asm_24713 + ld [hl], " " + add hl, de + dec a + jr nz, .asm_24713 + ret + +InitScrollingMenuCursor: ; 2471a + ld hl, wMenuData2_ItemsPointerAddr + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wMenuData2_ItemsPointerBank] + call GetFarByte + ld [wScrollingMenuListSize], a + ld a, [wMenuData2_ScrollingMenuHeight] + ld c, a + ld a, [wMenuScrollPosition] + add c + ld c, a + ld a, [wScrollingMenuListSize] + inc a + cp c + jr nc, .skip + ld a, [wMenuData2_ScrollingMenuHeight] + ld c, a + ld a, [wScrollingMenuListSize] + inc a + sub c + jr nc, .store + xor a + +.store + ld [wMenuScrollPosition], a + +.skip + ld a, [wMenuScrollPosition] + ld c, a + ld a, [wMenuCursorBuffer] + add c + ld b, a + ld a, [wScrollingMenuListSize] + inc a + cp b + jr c, .asm_2475a + jr nc, .asm_24763 + +.asm_2475a + xor a + ld [wMenuScrollPosition], a + ld a, $1 + ld [wMenuCursorBuffer], a + +.asm_24763 + ret +; 24764 + +ScrollingMenu_InitFlags: ; 24764 + ld a, [wMenuData2Flags] + ld c, a + ld a, [wScrollingMenuListSize] + ld b, a + ld a, [wMenuBorderTopCoord] + add $1 + ld [w2DMenuCursorInitY], a + ld a, [wMenuBorderLeftCoord] + add $0 + ld [w2DMenuCursorInitX], a + ld a, [wMenuData2_ScrollingMenuHeight] + cp b + jr c, .asm_24786 + jr z, .asm_24786 + ld a, b + inc a + +.asm_24786 + ld [w2DMenuNumRows], a + ld a, $1 + ld [w2DMenuNumCols], a + ld a, $8c + bit 2, c + jr z, .asm_24796 + set 0, a + +.asm_24796 + bit 3, c + jr z, .asm_2479c + set 1, a + +.asm_2479c + ld [w2DMenuFlags1], a + xor a + ld [w2DMenuFlags2], a + ld a, $20 + ld [w2DMenuFlags3], a + ld a, $c3 + bit 7, c + jr z, .asm_247b0 + add $4 + +.asm_247b0 + bit 6, c + jr z, .asm_247b6 + add $8 + +.asm_247b6 + ld [w2DMenuFlags4], a + ld a, [w2DMenuNumRows] + ld b, a + ld a, [wMenuCursorBuffer] + and a + jr z, .asm_247c8 + cp b + jr z, .asm_247ca + jr c, .asm_247ca + +.asm_247c8 + ld a, $1 + +.asm_247ca + ld [wMenuCursorY], a + ld a, $1 + ld [wMenuCursorX], a + xor a + ld [wCursorCurrentTile], a + ld [wCursorCurrentTile + 1], a + ld [wCursorOffCharacter], a + ret +; 247dd + +ScrollingMenu_ValidateSwitchItem: ; 247dd + ld a, [wScrollingMenuListSize] + ld c, a + ld a, [wSwitchItem] + and a + jr z, .done + dec a + cp c + jr c, .done + xor a + ld [wSwitchItem], a + +.done + ret +; 247f0 + +ScrollingMenu_UpdateDisplay: ; 247f0 + call ClearWholeMenuBox + ld a, [wMenuData2Flags] + bit 4, a ; place arrows + jr z, .okay + ld a, [wMenuScrollPosition] + and a + jr z, .okay + ld a, [wMenuBorderTopCoord] + ld b, a + ld a, [wMenuBorderRightCoord] + ld c, a + call Coord2Tile + ld [hl], "▲" + +.okay + call MenuBoxCoord2Tile + ld bc, SCREEN_WIDTH + 1 + add hl, bc + ld a, [wMenuData2_ScrollingMenuHeight] + ld b, a + ld c, $0 +.loop + ld a, [wMenuScrollPosition] + add c + ld [wScrollingMenuCursorPosition], a + ld a, c + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld a, [MenuSelection] + cp -1 + jr z, .cancel + push bc + push hl + call ScrollingMenu_CallFunctions1and2 + pop hl + ld bc, 2 * SCREEN_WIDTH + add hl, bc + pop bc + inc c + ld a, c + cp b + jr nz, .loop + ld a, [wMenuData2Flags] + bit 4, a ; place arrows + jr z, .done + ld a, [wMenuBorderBottomCoord] + ld b, a + ld a, [wMenuBorderRightCoord] + ld c, a + call Coord2Tile + ld [hl], "▼" + +.done + ret + +.cancel + ld a, [wMenuData2Flags] + bit 0, a ; call function on cancel + jr nz, .call_function + ld de, .string_2485f + call PlaceString + ret + +.string_2485f + db "CANCEL@" + +.call_function + ld d, h + ld e, l + ld hl, wMenuData2_ScrollingMenuFunction1 + jp CallPointerAt +; 2486e + +ScrollingMenu_CallFunctions1and2: ; 2486e + push hl + ld d, h + ld e, l + ld hl, wMenuData2_ScrollingMenuFunction1 + call CallPointerAt + pop hl + ld a, [wMenuData2_ScrollingMenuWidth] + and a + jr z, .done + ld e, a + ld d, $0 + add hl, de + ld d, h + ld e, l + ld hl, wMenuData2_ScrollingMenuFunction2 + call CallPointerAt + +.done + ret +; 2488b + +ScrollingMenu_PlaceCursor: ; 2488b + ld a, [wSwitchItem] + and a + jr z, .done + ld b, a + ld a, [wMenuScrollPosition] + cp b + jr nc, .done + ld c, a + ld a, [wMenuData2_ScrollingMenuHeight] + add c + cp b + jr c, .done + ld a, b + sub c + dec a + add a + add $1 + ld c, a + ld a, [wMenuBorderTopCoord] + add c + ld b, a + ld a, [wMenuBorderLeftCoord] + add $0 + ld c, a + call Coord2Tile + ld [hl], "▷" + +.done + ret +; 248b8 + +ScrollingMenu_CheckCallFunction3: ; 248b8 + ld a, [wMenuData2Flags] + bit 5, a ; call function 3 + ret z + bit 1, a ; call function 3 if not switching items + jr z, .call + ld a, [wSwitchItem] + and a + ret nz + +.call + ld a, [wMenuCursorY] + dec a + call ScrollingMenu_GetListItemCoordAndFunctionArgs + ld hl, wMenuData2_ScrollingMenuFunction3 + call CallPointerAt + ret +; 248d5 + +ScrollingMenu_GetListItemCoordAndFunctionArgs: ; 248d5 + push de + push hl + ld e, a + ld a, [wMenuScrollPosition] + add e + ld e, a + ld d, $0 + ld hl, wMenuData2_ItemsPointerAddr + ld a, [hli] + ld h, [hl] + ld l, a + inc hl ; items + ld a, [wMenuData2_ScrollingMenuSpacing] + cp 1 + jr z, .got_spacing + cp 2 + jr z, .pointless_jump +.pointless_jump + add hl, de +.got_spacing + add hl, de + ld a, [wMenuData2_ItemsPointerBank] + call GetFarByte + ld [MenuSelection], a + ld [CurItem], a + inc hl + ld a, [wMenuData2_ItemsPointerBank] + call GetFarByte + ld [MenuSelectionQuantity], a + pop hl + pop de + ret +; 2490c diff --git a/engine/specials.asm b/engine/specials.asm index 08a5b6129..c79ebb7d2 100644 --- a/engine/specials.asm +++ b/engine/specials.asm @@ -101,7 +101,7 @@ SpecialsPointers:: ; c029 add_special SpecialCheckPokerus add_special Special_DisplayCoinCaseBalance add_special Special_DisplayMoneyAndCoinBalance - add_special PlaceMoneyTopRightOW + add_special PlaceMoneyTopRight add_special Special_CheckForLuckyNumberWinners add_special Special_CheckLuckyNumberShowFlag add_special Special_ResetLuckyNumberShowFlag diff --git a/engine/startmenu.asm b/engine/startmenu.asm index 546aff1d9..c744d185f 100755 --- a/engine/startmenu.asm +++ b/engine/startmenu.asm @@ -42,7 +42,7 @@ StartMenu:: ; 125cd ld a, [wMenuCursorBuffer] ld [wd0d2], a call PlayClickSFX - call Function1bee + call PlaceHollowCursor call .OpenMenu ; Menu items have different return functions. @@ -1671,7 +1671,7 @@ MoveScreenLoop: ; 12fd5 jr nz, .place_move ld a, [wMenuCursorY] ld [wMoveSwapBuffer], a - call Function1bee + call PlaceHollowCursor jp .moving_move .place_move diff --git a/engine/switch_items.asm b/engine/switch_items.asm index 7de3440fa..46e000fd1 100755 --- a/engine/switch_items.asm +++ b/engine/switch_items.asm @@ -145,7 +145,7 @@ Function249d1: ; 249d1 (9:49d1) inc hl pop af ld [hl], a - ld hl, wMenuData2Addr + ld hl, wMenuData2_ItemsPointerAddr ld a, [hli] ld h, [hl] ld l, a @@ -199,7 +199,7 @@ Function24a4d: ; 24a4d (9:4a4d) Function24a5c: ; 24a5c (9:4a5c) push af call Function24a80 - ld hl, wMenuData2Addr + ld hl, wMenuData2_ItemsPointerAddr ld a, [hli] ld h, [hl] ld l, a diff --git a/engine/tmhm2.asm b/engine/tmhm2.asm index 9834fba7f..5b034f9ec 100755 --- a/engine/tmhm2.asm +++ b/engine/tmhm2.asm @@ -5,11 +5,11 @@ TMHMPocket: ; 2c76f (b:476f) ld a, $0 ld [hInMenu], a ret nc - call Function1bee + call PlaceHollowCursor call WaitBGMap ld a, [CurItem] dec a - ld [ItemCountBuffer], a + ld [CurItemQuantity], a ld hl, TMsHMs ld c, a ld b, 0 diff --git a/event/basement_key.asm b/event/basement_key.asm index 6b32049a8..8fa47df5f 100755 --- a/event/basement_key.asm +++ b/event/basement_key.asm @@ -18,12 +18,12 @@ _BasementKey: ; 507b4 ; Let's use the Basement Key ld hl, .BasementKeyScript call QueueScript - ld a, 1 + ld a, TRUE ld [wItemEffectSucceeded], a ret .nope - ld a, $0 + ld a, FALSE ld [wItemEffectSucceeded], a ret ; 507e1 diff --git a/event/battle_tower.asm b/event/battle_tower.asm index 9c494b168..a938e34c7 100644 --- a/event/battle_tower.asm +++ b/event/battle_tower.asm @@ -1,29 +1,29 @@ -Function8b1e1: ; 8b1e1 - ld de, Unknown_8b1ed - call Function8b25b +CheckForMobileBattleRules: ; 8b1e1 + ld de, .PointerTables + call BattleTower_ExecuteJumptable ret z - call Function8b231 + call BattleTower_PleaseReturnWhenReady scf ret ; 8b1ed -Unknown_8b1ed: ; 8b1ed +.PointerTables: ; 8b1ed db 2 - dw Unknown_8b1f2 - dw Unknown_8b1f6 + dw .Functions + dw .TextPointers -Unknown_8b1f2: ; 8b1f2 - dw Function8b2bb - dw Function8b2c1 +.Functions: ; 8b1f2 + dw BattleTower_CheckPartyLengthIs3 + dw BattleTower_CheckPartyHasThreeMonsThatAreNotEggs ; 8b1f6 -Unknown_8b1f6: ; 8b1f6 - dw UnknownText_0x8b1fc - dw UnknownText_0x8b23d - dw UnknownText_0x8b242 +.TextPointers: ; 8b1f6 + dw .ExcuseMeText + dw JumpText_NeedAtLeastThreeMon + dw JumpText_EggDoesNotQualify ; 8b1fc -UnknownText_0x8b1fc: ; 0x8b1fc +.ExcuseMeText: ; 0x8b1fc ; Excuse me! text_jump UnknownText_0x1c5937 db "@" @@ -34,27 +34,27 @@ CheckForBattleTowerRules: ; 8b201 ld [hl], "3" inc hl ld [hl], "@" - ld de, CheckForBattleTowerRules_FunctionsText - call Function8b25b + ld de, .PointerTables + call BattleTower_ExecuteJumptable ret z - call Function8b231 + call BattleTower_PleaseReturnWhenReady scf ret ; 8b215 -CheckForBattleTowerRules_FunctionsText: ; 8b215 +.PointerTables: ; 8b215 db 4 - dw CheckForBattleTowerRules_Functions - dw CheckForBattleTowerRules_Text + dw .Functions + dw .TextPointers -CheckForBattleTowerRules_Functions: ; 8b21a +.Functions: ; 8b21a dw Function_PartyCountEq3 dw Function_PartySpeciesAreUnique dw Function_PartyItemsAreUnique dw Function_HasPartyAnEgg ; 8b222 -CheckForBattleTowerRules_Text: ; 8b222 +.TextPointers: ; 8b222 dw JumpText_ExcuseMeYoureNotReady dw JumpText_OnlyThreePkmnMayBeEntered dw JumpText_ThePkmnMustAllBeDifferentKinds @@ -68,25 +68,25 @@ JumpText_ExcuseMeYoureNotReady: ; 0x8b22c db "@" ; 0x8b231 -Function8b231: ; 8b231 - ld hl, UnknownText_0x8b238 +BattleTower_PleaseReturnWhenReady: ; 8b231 + ld hl, .PleaseReturnWhenReady call PrintText ret ; 8b238 -UnknownText_0x8b238: ; 0x8b238 +.PleaseReturnWhenReady: ; 0x8b238 ; Please return when you're ready. text_jump UnknownText_0x1c5962 db "@" ; 0x8b23d -UnknownText_0x8b23d: ; 0x8b23d +JumpText_NeedAtLeastThreeMon: ; 0x8b23d ; You need at least three #MON. text_jump UnknownText_0x1c5983 db "@" ; 0x8b242 -UnknownText_0x8b242: ; 0x8b242 +JumpText_EggDoesNotQualify: ; 0x8b242 ; Sorry, an EGG doesn't qualify. text_jump UnknownText_0x1c59a3 db "@" @@ -116,22 +116,22 @@ JumpText_YouCantTakeAnEgg: ; 0x8b256 db "@" ; 0x8b25b -Function8b25b: ; 8b25b +BattleTower_ExecuteJumptable: ; 8b25b ld bc, 0 -.asm_8b25e - call Function8b26c - call c, Function8b28e - call Function8b276 - jr nz, .asm_8b25e +.loop + call .DoJumptableFunction + call c, .PrintFailureText + call .Next_CheckReachedEnd + jr nz, .loop ld a, b and a ret ; 8b26c -Function8b26c: ; 8b26c +.DoJumptableFunction: ; 8b26c push de push bc - call Function8b27a + call .GetFunctionPointer ld a, c rst JumpTable pop bc @@ -139,14 +139,14 @@ Function8b26c: ; 8b26c ret ; 8b276 -Function8b276: ; 8b276 +.Next_CheckReachedEnd: ; 8b276 inc c ld a, [de] cp c ret ; 8b27a -Function8b27a: ; 8b27a +.GetFunctionPointer: ; 8b27a inc de ld a, [de] ld l, a @@ -156,7 +156,7 @@ Function8b27a: ; 8b27a ret ; 8b281 -Function8b281: ; 8b281 +.GetTextPointers: ; 8b281 rept 3 inc de endr @@ -168,38 +168,38 @@ endr ret ; 8b28a -Function8b28a: ; 8b28a +.LoadTextPointer: ; 8b28a ld a, [hli] ld h, [hl] ld l, a ret ; 8b28e -Function8b28e: ; 8b28e +.PrintFailureText: ; 8b28e push de push bc ld a, b and a - call z, Function8b29d + call z, .PrintFirstText pop bc - call Function8b2a9 + call .PrintNthText ld b, $1 pop de ret ; 8b29d -Function8b29d: ; 8b29d +.PrintFirstText: ; 8b29d push de - call Function8b281 - call Function8b28a + call .GetTextPointers + call .LoadTextPointer call PrintText pop de ret ; 8b2a9 -Function8b2a9: ; 8b2a9 +.PrintNthText: ; 8b2a9 push bc - call Function8b281 + call .GetTextPointers rept 2 inc hl endr @@ -207,32 +207,32 @@ endr rept 2 add hl, bc endr - call Function8b28a + call .LoadTextPointer call PrintText pop bc ret ; 8b2bb -Function8b2bb: ; 8b2bb +BattleTower_CheckPartyLengthIs3: ; 8b2bb ld a, [PartyCount] cp 3 ret ; 8b2c1 -Function8b2c1: ; 8b2c1 +BattleTower_CheckPartyHasThreeMonsThatAreNotEggs: ; 8b2c1 ld hl, PartyCount ld a, [hli] ld b, $0 ld c, a -.asm_8b2c8 +.loop ld a, [hli] cp EGG - jr z, .asm_8b2ce + jr z, .egg inc b -.asm_8b2ce +.egg dec c - jr nz, .asm_8b2c8 + jr nz, .loop ld a, [PartyCount] cp b ret z diff --git a/event/buena.asm b/event/buena.asm index ddc78b016..68df12dfa 100644 --- a/event/buena.asm +++ b/event/buena.asm @@ -82,10 +82,10 @@ SpecialBuenaPrize: ; 8afd4 .okay call DelayFrame call UpdateSprites - call Function8b097 + call PrintBlueCardBalance call Function8b0e2 jr z, .done - ld [wcf75], a + ld [MenuSelectionQuantity], a call Buena_getprize ld a, [hl] ld [wd265], a @@ -95,7 +95,7 @@ SpecialBuenaPrize: ; 8afd4 call YesNoBox jr c, .loop - ld a, [wcf75] + ld a, [MenuSelectionQuantity] call Buena_getprize inc hl ld a, [hld] @@ -118,7 +118,7 @@ SpecialBuenaPrize: ; 8afd4 ld a, [wBlueCardBalance] sub c ld [wBlueCardBalance], a - call Function8b097 + call PrintBlueCardBalance jr .Purchase .InsufficientBalance @@ -184,34 +184,34 @@ SpecialBuenaPrize: ; 8afd4 ; 0x8b090 Function8b090: ; 8b090 - ld hl, MenuDataHeader_0x8b0d1 + ld hl, BlueCardBalanceMenuDataHeader call LoadMenuDataHeader ret ; 8b097 -Function8b097: ; 8b097 +PrintBlueCardBalance: ; 8b097 ld de, wBlueCardBalance - call Function8b09e + call .DrawBox ret ; 8b09e -Function8b09e: ; 8b09e +.DrawBox: ; 8b09e push de xor a ld [hBGMapMode], a - ld hl, MenuDataHeader_0x8b0d1 + ld hl, BlueCardBalanceMenuDataHeader call CopyMenuDataHeader call MenuBox call UpdateSprites call MenuBoxCoord2Tile - ld bc, $0015 + ld bc, SCREEN_WIDTH + 1 add hl, bc ld de, .Points_string call PlaceString ld h, b ld l, c inc hl - ld a, $7f + ld a, " " ld [hli], a ld [hld], a pop de @@ -224,7 +224,7 @@ Function8b09e: ; 8b09e db "Points@" ; 8b0d1 -MenuDataHeader_0x8b0d1: ; 0x8b0d1 +BlueCardBalanceMenuDataHeader: ; 0x8b0d1 db $40 ; flags db 11, 00 ; start coords db 13, 11 ; end coords @@ -252,19 +252,19 @@ Function8b0e2: ; 8b0e2 ld [hBGMapMode], a call InitScrollingMenu call UpdateSprites - call HandleScrollingMenu + call ScrollingMenu ld a, [MenuSelection] ld c, a ld a, [wMenuCursorY] ld [MenuSelection], a ld a, [wMenuJoypad] cp $2 - jr z, .asm_8b111 + jr z, .cancel ld a, c and a ret nz -.asm_8b111 +.cancel xor a ret ; 8b113 @@ -281,8 +281,8 @@ Function8b0e2: ; 8b0e2 .MenuData2: ; 0x8b11c db $10 ; flags - db 4 ; items - db $d, $1 + db 4, 13 ; rows, columns + db 1 ; spacing dba .indices dba .prizeitem dba .prizepoints diff --git a/event/elevator.asm b/event/elevator.asm index 097293a56..37b15a558 100755 --- a/event/elevator.asm +++ b/event/elevator.asm @@ -130,7 +130,7 @@ Elevator_AskWhichFloor: ; 134dd call UpdateSprites xor a ld [wMenuScrollPosition], a - call HandleScrollingMenu + call ScrollingMenu call WriteBackup ld a, [wMenuJoypad] cp B_BUTTON diff --git a/event/kurt.asm b/event/kurt.asm index f7a3f3a55..54461aecb 100644 --- a/event/kurt.asm +++ b/event/kurt.asm @@ -67,7 +67,7 @@ Kurt_SelectApricorn: ; 88055 ld [hBGMapMode], a call InitScrollingMenu call UpdateSprites - call HandleScrollingMenu + call ScrollingMenu ld a, [wMenuJoypad] cp $2 jr z, .nope @@ -116,7 +116,7 @@ Kurt_SelectApricorn: ; 88055 call Kurt_GetQuantityOfApricorn ret z ld a, [wItemQuantityChangeBuffer] - ld [wcf75], a + ld [MenuSelectionQuantity], a callba PlaceMenuItemQuantity ret ; 880c2 @@ -231,16 +231,16 @@ Kurt_GiveUpSelectedQuantityOfSelectedApricorn: ; 88161 ld c, a ld e, $0 xor a - ld [ItemCountBuffer], a + ld [CurItemQuantity], a ld a, -1 ld [wd002], a ; Search for [CurItem] in the bag. .loop1 ; Increase the total count. - ld a, [ItemCountBuffer] + ld a, [CurItemQuantity] inc a - ld [ItemCountBuffer], a + ld [CurItemQuantity], a ; Get the index of the next item. inc hl ld a, [hli] @@ -256,7 +256,7 @@ Kurt_GiveUpSelectedQuantityOfSelectedApricorn: ; 88161 ld hl, wd002 add hl, de inc e - ld a, [ItemCountBuffer] + ld a, [CurItemQuantity] dec a ld [hli], a ld a, -1 @@ -322,7 +322,7 @@ Kurt_GiveUpSelectedQuantityOfSelectedApricorn: ; 88161 cp -1 jr z, .done push hl - ld [ItemCountBuffer], a + ld [CurItemQuantity], a call Kurt_GetRidOfItem pop hl ld a, [wItemQuantityChangeBuffer] @@ -375,7 +375,7 @@ endr Kurt_GetRidOfItem: ; 88211 push bc ld hl, NumItems - ld a, [ItemCountBuffer] + ld a, [CurItemQuantity] ld c, a ld b, $0 inc hl diff --git a/home.asm b/home.asm index e5b24fe6a..90f0988ce 100644 --- a/home.asm +++ b/home.asm @@ -1146,17 +1146,17 @@ GetMoveName:: ; 34f8 ; 350c -HandleScrollingMenu:: ; 350c +ScrollingMenu:: ; 350c call CopyMenuData2 ld a, [hROMBank] push af - ld a, BANK(Function245af) + ld a, BANK(_ScrollingMenu) rst Bankswitch - call Function245af - call Function3524 - call Function245cb + call _InitScrollingMenu + call .UpdatePalettes + call _ScrollingMenu pop af rst Bankswitch @@ -1165,7 +1165,7 @@ HandleScrollingMenu:: ; 350c ret ; 3524 -Function3524:: ; 3524 +.UpdatePalettes ; 3524 ld hl, VramState bit 0, [hl] jp nz, UpdateTimePals diff --git a/home/menu.asm b/home/menu.asm index b0d72c9f9..126dc53dc 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -34,12 +34,12 @@ ret_1d57:: ; 1d57 ; 1d58 LoadMenuTextBox:: ; 1d58 - ld hl, MenuDataHeader_0x1d5f + ld hl, .MenuDataHeader call LoadMenuDataHeader ret ; 1d5f -MenuDataHeader_0x1d5f:: ; 1d5f +.MenuDataHeader ; 1d5f db $40 ; tile backup db 12, 0 ; start coords db 17, 19 ; end coords @@ -54,12 +54,12 @@ MenuTextBoxBackup:: ; 1d67 ; 1d6e LoadStandardMenuDataHeader:: ; 1d6e - ld hl, MenuDataHeader_0x1d75 + ld hl, .MenuDataHeader call LoadMenuDataHeader ret ; 1d75 -MenuDataHeader_0x1d75:: ; 1d75 +.MenuDataHeader ; 1d75 db $40 ; tile backup db 0, 0 ; start coords db 17, 19 ; end coords @@ -187,24 +187,24 @@ YesNoMenuDataHeader:: ; 1e1d db $40 ; tile backup db 5, 10 ; start coords db 9, 15 ; end coords - dw YesNoMenuData2 + dw .MenuData2 db 1 ; default option ; 1e25 -YesNoMenuData2:: ; 1e25 +.MenuData2 ; 1e25 db $c0 ; flags db 2 db "YES@" db "NO@" ; 1e2e -Function1e2e:: ; 1e2e - call Function1e35 +OffsetMenuDataHeader:: ; 1e2e + call _OffsetMenuDataHeader call BackUpTiles ret ; 1e35 -Function1e35:: ; 1e35 +_OffsetMenuDataHeader:: ; 1e35 push de call CopyMenuDataHeader pop de @@ -243,7 +243,7 @@ SetUpMenu:: ; 1e70 call MenuFunc_1e7f ; ??? call MenuWriteText call Function1eff ; set up selection pointer - ld hl, wcfa5 + ld hl, w2DMenuFlags1 set 7, [hl] ret @@ -287,23 +287,23 @@ Function1ea6:: ; 1ea6 ; 1ebd Function1ebd:: ; 1ebd - ld hl, wcf93 + ld hl, wMenuData2IndicesPointer ld a, [hli] ld h, [hl] ld l, a ld a, [wcf76] and a - jr z, .asm_1ed3 + jr z, .skip ld b, a - ld c, $ff -.asm_1ecc + ld c, -1 +.loop ld a, [hli] cp c - jr nz, .asm_1ecc + jr nz, .loop dec b - jr nz, .asm_1ecc + jr nz, .loop -.asm_1ed3 +.skip ld d, h ld e, l ld a, [hl] @@ -313,28 +313,28 @@ Function1ebd:: ; 1ebd Function1eda:: ; 1eda call MenuBoxCoord2Tile - ld bc, $002a + ld bc, 2 * SCREEN_WIDTH + 2 add hl, bc -.asm_1ee1 +.loop inc de ld a, [de] - cp $ff + cp -1 ret z ld [MenuSelection], a push de push hl ld d, h ld e, l - ld hl, wcf95 - call Function1efb + ld hl, wMenuData2DisplayFunctionPointer + call .__wMenuData2DisplayFunction__ pop hl - ld de, $0028 + ld de, 2 * SCREEN_WIDTH add hl, de pop de - jr .asm_1ee1 + jr .loop ; 1efb -Function1efb:: ; 1efb +.__wMenuData2DisplayFunction__ ; 1efb ld a, [hli] ld h, [hl] ld l, a @@ -343,27 +343,27 @@ Function1efb:: ; 1efb Function1eff:: ; 1eff call InitVerticalMenuCursor - ld hl, wcfa8 + ld hl, w2DMenuFlags4 ld a, [wMenuData2Flags] bit 3, a - jr z, .asm_1f0e + jr z, .skip3 set 3, [hl] -.asm_1f0e +.skip3 ld a, [wMenuData2Flags] bit 2, a - jr z, .asm_1f19 + jr z, .skip4_5 set 5, [hl] set 4, [hl] -.asm_1f19 +.skip4_5 ret ; 1f1a Function1f1a:: ; 1f1a call ScrollingMenuJoypad - ld hl, wcfa8 + ld hl, w2DMenuFlags4 and [hl] jr Function1f2a ; 1f23 diff --git a/home/movement.asm b/home/movement.asm index cdb3507e0..2fba2bbba 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -188,7 +188,7 @@ GetMenuJoypad:: ; 1bdd ret ; 1bee -Function1bee:: ; 1bee +PlaceHollowCursor:: ; 1bee ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] @@ -197,7 +197,7 @@ Function1bee:: ; 1bee ret ; 1bf7 -Function1bf7:: ; 1bf7 +HideCursor:: ; 1bf7 ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] diff --git a/main.asm b/main.asm index 7560e8b99..6ed4dfef1 100644 --- a/main.asm +++ b/main.asm @@ -4456,7 +4456,7 @@ RemoveItemFromPocket: ; d2ff ld e, l ld a, [hli] ld c, a - ld a, [ItemCountBuffer] + ld a, [CurItemQuantity] cp c jr nc, .ok ; memory ld c, a @@ -7944,555 +7944,7 @@ GetObjectTimeMask: ; 245a7 (9:45a7) xor a ret -Function245af:: ; 245af - xor a - ld [wMenuJoypad], a - ld [hBGMapMode], a - inc a - ld [hInMenu], a - call ClearObjectStructsa - call Function24764 - call Function247dd - call Function245f1 - call ApplyTilemap - xor a - ld [hBGMapMode], a - ret -; 245cb - -Function245cb:: ; 245cb -.loop - call MenuJoyAction - jp c, .exit - call z, .zero - jr .loop -; 245d6 - -.exit: ; 245d6 - call MenuClickSound - ld [wMenuJoypad], a - ld a, 0 - ld [hInMenu], a - ret -; 245e1 - -.zero: ; 245e1 - call Function245f1 - ld a, 1 - ld [hBGMapMode], a - ld c, 3 - call DelayFrames - xor a - ld [hBGMapMode], a - ret -; 245f1 - -Function245f1: ; 245f1 - xor a - ld [hBGMapMode], a - ld hl, Options - ld a, [hl] - push af - set NO_TEXT_SCROLL, [hl] - call Function247f0 - call Function2488b - call Function248b8 - pop af - ld [Options], a - ret -; 24609 - -MenuJoyAction: ; 24609 -.loop - call ScrollingMenuJoypad - ld a, [hJoyLast] - and D_PAD - ld b, a - ld a, [hJoyPressed] - and BUTTONS - or b - bit 0, a ; A - jp nz, .a_button - bit 1, a ; B - jp nz, .b_button - bit 2, a ; Select - jp nz, .select - bit 3, a ; Start - jp nz, .start - bit 4, a ; Right - jp nz, .d_right - bit 5, a ; Left - jp nz, .d_left - bit 6, a ; Up - jp nz, .d_up - bit 7, a ; Down - jp nz, .d_down - jr .loop -; 24640 - -.unreferenced: ; unreferenced - ld a, -1 - and a - ret -; 24644 - -.a_button: ; 24644 - call Function1bee - ld a, [wMenuCursorY] - dec a - call Function248d5 - ld a, [MenuSelection] - ld [CurItem], a - ld a, [wcf75] - ld [wItemQuantityBuffer], a - call Function246fc - dec a - ld [wScrollingMenuCursorPosition], a - ld [wd107], a - ld a, [MenuSelection] - cp -1 - jr z, .b_button - ld a, A_BUTTON - scf - ret -; 2466f - -.b_button: ; 2466f - ld a, B_BUTTON - scf - ret -; 24673 - -.select: ; 24673 - ld a, [wMenuData2Flags] - bit 7, a - jp z, xor_a_dec_a - ld a, [wMenuCursorY] - dec a - call Function248d5 - ld a, [MenuSelection] - cp -1 - jp z, xor_a_dec_a - call Function246fc - dec a - ld [wScrollingMenuCursorPosition], a - ld a, SELECT - scf - ret -; 24695 - -.start: ; 24695 - ld a, [wMenuData2Flags] - bit 6, a - jp z, xor_a_dec_a - ld a, START - scf - ret -; 246a1 - -.d_left: ; 246a1 - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a_dec_a - ld a, [wMenuData2Flags] - bit 3, a - jp z, xor_a_dec_a - ld a, D_LEFT - scf - ret -; 246b5 - -.d_right: ; 246b5 - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a_dec_a - ld a, [wMenuData2Flags] - bit 2, a - jp z, xor_a_dec_a - ld a, D_RIGHT - scf - ret -; 246c9 - -.d_up: ; 246c9 - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a - ld hl, wMenuScrollPosition - ld a, [hl] - and a - jr z, .xor_dec_up - dec [hl] - jp xor_a - -.xor_dec_up - jp xor_a_dec_a -; 246df - -.d_down: ; 246df - ld hl, wcfa6 - bit 7, [hl] - jp z, xor_a - ld hl, wMenuScrollPosition - ld a, [wMenuData2Items] - add [hl] - ld b, a - ld a, [wd144] - cp b - jr c, .xor_dec_down - inc [hl] - jp xor_a - -.xor_dec_down - jp xor_a_dec_a -; 246fc - -Function246fc: ; 246fc - ld a, [wMenuScrollPosition] - ld c, a - ld a, [wMenuCursorY] - add c - ld c, a - ret -; 24706 - -Function24706: ; 24706 (9:4706) - call MenuBoxCoord2Tile - ld de, SCREEN_WIDTH - add hl, de - ld de, 2 * SCREEN_WIDTH - ld a, [wMenuData2Items] -.asm_24713 - ld [hl], " " - add hl, de - dec a - jr nz, .asm_24713 - ret - -ClearObjectStructsa: ; 2471a -; Get the value of (wMenuData2Bank):(wMenuData2Addr) and store it in wd144. - ld hl, wMenuData2Addr - ld a, [hli] - ld h, [hl] - ld l, a - ld a, [wMenuData2Bank] - call GetFarByte - ld [wd144], a -; if ([wd144] + 1) < [wMenuData2Items] + [wMenuScrollPosition]: [wMenuScrollPosition] = max(([wd144] + 1) - [wMenuData2Items], 0) - ld a, [wMenuData2Items] - ld c, a - ld a, [wMenuScrollPosition] - add c - ld c, a - ld a, [wd144] - inc a - cp c - jr nc, .skip - ld a, [wMenuData2Items] - ld c, a - ld a, [wd144] - inc a - sub c - jr nc, .store - xor a - -.store - ld [wMenuScrollPosition], a - -.skip - ld a, [wMenuScrollPosition] - ld c, a - ld a, [wMenuCursorBuffer] - add c - ld b, a - ld a, [wd144] - inc a - cp b - jr c, .asm_2475a - jr nc, .asm_24763 - -.asm_2475a - xor a - ld [wMenuScrollPosition], a - ld a, $1 - ld [wMenuCursorBuffer], a - -.asm_24763 - ret -; 24764 - -Function24764: ; 24764 - ld a, [wMenuData2Flags] - ld c, a - ld a, [wd144] - ld b, a - ld a, [wMenuBorderTopCoord] - add $1 - ld [wcfa1], a - ld a, [wMenuBorderLeftCoord] - add $0 - ld [wcfa2], a - ld a, [wMenuData2Items] - cp b - jr c, .asm_24786 - jr z, .asm_24786 - ld a, b - inc a - -.asm_24786 - ld [wcfa3], a - ld a, $1 - ld [wcfa4], a - ld a, $8c - bit 2, c - jr z, .asm_24796 - set 0, a - -.asm_24796 - bit 3, c - jr z, .asm_2479c - set 1, a - -.asm_2479c - ld [wcfa5], a - xor a - ld [wcfa6], a - ld a, $20 - ld [wcfa7], a - ld a, $c3 - bit 7, c - jr z, .asm_247b0 - add $4 - -.asm_247b0 - bit 6, c - jr z, .asm_247b6 - add $8 - -.asm_247b6 - ld [wcfa8], a - ld a, [wcfa3] - ld b, a - ld a, [wMenuCursorBuffer] - and a - jr z, .asm_247c8 - cp b - jr z, .asm_247ca - jr c, .asm_247ca - -.asm_247c8 - ld a, $1 - -.asm_247ca - ld [wMenuCursorY], a - ld a, $1 - ld [wMenuCursorX], a - xor a - ld [wCursorCurrentTile], a - ld [wCursorCurrentTile + 1], a - ld [wCursorOffCharacter], a - ret -; 247dd - -Function247dd: ; 247dd - ld a, [wd144] - ld c, a - ld a, [wd0e3] - and a - jr z, .asm_247ef - dec a - cp c - jr c, .asm_247ef - xor a - ld [wd0e3], a - -.asm_247ef - ret -; 247f0 - -Function247f0: ; 247f0 - call ClearWholeMenuBox - ld a, [wMenuData2Flags] - bit 4, a - jr z, .asm_2480d - ld a, [wMenuScrollPosition] - and a - jr z, .asm_2480d - ld a, [wMenuBorderTopCoord] - ld b, a - ld a, [wMenuBorderRightCoord] - ld c, a - call Coord2Tile - ld [hl], $61 - -.asm_2480d - call MenuBoxCoord2Tile - ld bc, $15 - add hl, bc - ld a, [wMenuData2Items] - ld b, a - ld c, $0 -.asm_2481a - ld a, [wMenuScrollPosition] - add c - ld [wScrollingMenuCursorPosition], a - ld a, c - call Function248d5 - ld a, [MenuSelection] - cp $ff - jr z, .asm_24851 - push bc - push hl - call Function2486e - pop hl - ld bc, $28 - add hl, bc - pop bc - inc c - ld a, c - cp b - jr nz, .asm_2481a - ld a, [wMenuData2Flags] - bit 4, a - jr z, .asm_24850 - ld a, [wMenuBorderBottomCoord] - ld b, a - ld a, [wMenuBorderRightCoord] - ld c, a - call Coord2Tile - ld [hl], $ee - -.asm_24850 - ret - -.asm_24851 - ld a, [wMenuData2Flags] - bit 0, a - jr nz, .asm_24866 - ld de, .string_2485f - call PlaceString - ret - -.string_2485f - db "CANCEL@" - -.asm_24866 - ld d, h - ld e, l - ld hl, wcf98 - jp CallPointerAt -; 2486e - -Function2486e: ; 2486e - push hl - ld d, h - ld e, l - ld hl, wcf98 - call CallPointerAt - pop hl - ld a, [wcf93] - and a - jr z, .asm_2488a - ld e, a - ld d, $0 - add hl, de - ld d, h - ld e, l - ld hl, wcf9b - call CallPointerAt - -.asm_2488a - ret -; 2488b - -Function2488b: ; 2488b - ld a, [wd0e3] - and a - jr z, .asm_248b7 - ld b, a - ld a, [wMenuScrollPosition] - cp b - jr nc, .asm_248b7 - ld c, a - ld a, [wMenuData2Items] - add c - cp b - jr c, .asm_248b7 - ld a, b - sub c - dec a - add a - add $1 - ld c, a - ld a, [wMenuBorderTopCoord] - add c - ld b, a - ld a, [wMenuBorderLeftCoord] - add $0 - ld c, a - call Coord2Tile - ld [hl], $ec - -.asm_248b7 - ret -; 248b8 - -Function248b8: ; 248b8 - ld a, [wMenuData2Flags] - bit 5, a - ret z - bit 1, a - jr z, .asm_248c7 - ld a, [wd0e3] - and a - ret nz - -.asm_248c7 - ld a, [wMenuCursorY] - dec a - call Function248d5 - ld hl, wcf9e - call CallPointerAt - ret -; 248d5 - -Function248d5: ; 248d5 - push de - push hl - ld e, a - ld a, [wMenuScrollPosition] - add e - ld e, a - ld d, $0 - ld hl, wMenuData2Addr - ld a, [hli] - ld h, [hl] - ld l, a - inc hl - ld a, [wcf94] - cp $1 - jr z, .asm_248f2 - cp $2 - jr z, .asm_248f1 - -.asm_248f1 - add hl, de - -.asm_248f2 - add hl, de - ld a, [wMenuData2Bank] - call GetFarByte - ld [MenuSelection], a - ld [CurItem], a - inc hl - ld a, [wMenuData2Bank] - call GetFarByte - ld [wcf75], a - pop hl - pop de - ret -; 2490c - +INCLUDE "engine/scrolling_menu.asm" INCLUDE "engine/switch_items.asm" PlaceMenuItemName: ; 0x24ab4 @@ -8518,7 +7970,7 @@ PlaceMenuItemQuantity: ; 0x24ac3 add hl, de ld [hl], "×" inc hl - ld de, wcf75 + ld de, MenuSelectionQuantity lb bc, 1, 2 call PrintNum @@ -8526,25 +7978,25 @@ PlaceMenuItemQuantity: ; 0x24ac3 ret ; 0x24ae8 -PlaceMoneyTopRightOW: ; 24ae8 +PlaceMoneyTopRight: ; 24ae8 ld hl, MenuDataHeader_0x24b15 call CopyMenuDataHeader - jr Function24b01 + jr PlaceMoneyDataHeader -PlaceMoneyBottomLeftOW: ; 24af0 +PlaceMoneyBottomLeft: ; 24af0 ld hl, MenuDataHeader_0x24b1d call CopyMenuDataHeader - jr Function24b01 + jr PlaceMoneyDataHeader -PlaceMoneyTopRightMenu: ; 24af8 +PlaceMoneyAtTopLeftOfTextbox: ; 24af8 ld hl, MenuDataHeader_0x24b15 - ld de, $b - call Function1e2e + lb de, 0, 11 + call OffsetMenuDataHeader -Function24b01: ; 24b01 +PlaceMoneyDataHeader: ; 24b01 call MenuBox call MenuBoxCoord2Tile - ld de, $15 + ld de, SCREEN_WIDTH + 1 add hl, de ld de, Money lb bc, PRINTNUM_MONEY | 3, 6 diff --git a/maps/CeladonDeptStore6F.asm b/maps/CeladonDeptStore6F.asm index a65d63c34..d6c2fd97f 100644 --- a/maps/CeladonDeptStore6F.asm +++ b/maps/CeladonDeptStore6F.asm @@ -27,7 +27,7 @@ CeladonVendingMachine: opentext writetext CeladonVendingText .Start - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight loadmenudata .MenuData verticalmenu writebackup diff --git a/maps/GoldenrodDeptStore6F.asm b/maps/GoldenrodDeptStore6F.asm index c50eab46c..34f5ad350 100644 --- a/maps/GoldenrodDeptStore6F.asm +++ b/maps/GoldenrodDeptStore6F.asm @@ -13,7 +13,7 @@ GoldenrodVendingMachine: opentext writetext GoldenrodVendingText .Start - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight loadmenudata .MenuData verticalmenu writebackup diff --git a/maps/MahoganyTown.asm b/maps/MahoganyTown.asm index 1e0a13fff..4eeafd92c 100644 --- a/maps/MahoganyTown.asm +++ b/maps/MahoganyTown.asm @@ -57,7 +57,7 @@ UnknownScript_0x190039: UnknownScript_0x190040: opentext writetext UnknownText_0x1900b0 - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight yesorno iffalse UnknownScript_0x190072 checkmoney $0, 300 @@ -67,7 +67,7 @@ UnknownScript_0x190040: waitsfx playsound SFX_TRANSACTION takemoney $0, 300 - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight writetext UnknownText_0x19014a waitbutton closetext diff --git a/maps/Route39Farmhouse.asm b/maps/Route39Farmhouse.asm index 07efecdf6..ca483c8cc 100644 --- a/maps/Route39Farmhouse.asm +++ b/maps/Route39Farmhouse.asm @@ -24,7 +24,7 @@ UnknownScript_0x9cec5: checkitem MOOMOO_MILK iftrue UnknownScript_0x9cf08 writetext UnknownText_0x9cfe1 - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight yesorno iffalse UnknownScript_0x9cf02 checkmoney $0, 500 @@ -32,7 +32,7 @@ UnknownScript_0x9cec5: giveitem MOOMOO_MILK iffalse UnknownScript_0x9cefc takemoney $0, 500 - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight waitsfx playsound SFX_TRANSACTION writetext UnknownText_0x9d05d diff --git a/maps/WarehouseEntrance.asm b/maps/WarehouseEntrance.asm index 0321c4bdf..78523ae8e 100644 --- a/maps/WarehouseEntrance.asm +++ b/maps/WarehouseEntrance.asm @@ -197,7 +197,7 @@ OlderHaircutBrotherScript: .DoHaircut: checkflag ENGINE_GOLDENROD_UNDERGROUND_GOT_HAIRCUT iftrue .AlreadyGotHaircut - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight writetext UnknownText_0x7c5f9 yesorno iffalse .Refused @@ -233,7 +233,7 @@ OlderHaircutBrotherScript: .then: takemoney $0, 500 - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight writetext UnknownText_0x7c6b8 waitbutton closetext @@ -280,7 +280,7 @@ YoungerHaircutBrotherScript: .DoHaircut: checkflag ENGINE_GOLDENROD_UNDERGROUND_GOT_HAIRCUT iftrue .AlreadyGotHaircut - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight writetext UnknownText_0x7c75c yesorno iffalse .Refused @@ -316,7 +316,7 @@ YoungerHaircutBrotherScript: .then: takemoney $0, 300 - special PlaceMoneyTopRightOW + special PlaceMoneyTopRight writetext UnknownText_0x7c80e waitbutton closetext diff --git a/misc/battle_tower_5c.asm b/misc/battle_tower_5c.asm index 0e3997ab1..b437cae83 100755 --- a/misc/battle_tower_5c.asm +++ b/misc/battle_tower_5c.asm @@ -1401,7 +1401,7 @@ endr ld a, 1 ld [wItemQuantityChangeBuffer], a ld a, -1 - ld [ItemCountBuffer], a + ld [CurItemQuantity], a ld hl, NumItems call TossItem ld a, $1 diff --git a/misc/mobile_12.asm b/misc/mobile_12.asm index bcf9ef18f..748b095de 100755 --- a/misc/mobile_12.asm +++ b/misc/mobile_12.asm @@ -214,7 +214,7 @@ String_48202: ; 48202 ; 4820d Function4820d: ; 4820d (12:420d) - call Function1bee + call PlaceHollowCursor ld hl, wMenuCursorY ld a, [hl] push af @@ -361,7 +361,7 @@ Function48304: ; 48304 (12:4304) ld [wMenuScrollPosition], a callba Function104148 .asm_48348 - call HandleScrollingMenu + call ScrollingMenu ld de, $629 call Function48383 jr c, .asm_48348 diff --git a/misc/mobile_12_2.asm b/misc/mobile_12_2.asm index f8ebdbb00..d7c987c36 100755 --- a/misc/mobile_12_2.asm +++ b/misc/mobile_12_2.asm @@ -499,7 +499,7 @@ Function4ab1a: ; 4ab1a jr c, .asm_4ab1a push af call Function4ab99 - call nc, Function1bee + call nc, PlaceHollowCursor pop af bit 1, a jr nz, .asm_4ab6d diff --git a/misc/mobile_22.asm b/misc/mobile_22.asm index a231e632d..8977c0fb0 100644 --- a/misc/mobile_22.asm +++ b/misc/mobile_22.asm @@ -2258,7 +2258,7 @@ Function89dab: ; 89dab (22:5dab) ld a, [wMenuCursorY] cp c jr z, .asm_89dd9 - call Function1bee + call PlaceHollowCursor scf ret .asm_89dd9 @@ -3076,7 +3076,7 @@ Function8a31c: ; 8a31c (22:631c) ret .asm_8a370 call Function89448 - call Function1bee + call PlaceHollowCursor call Function8a3a2 ld a, [MenuSelection] cp $ff diff --git a/misc/mobile_22_2.asm b/misc/mobile_22_2.asm index 451a6987d..080c21890 100644 --- a/misc/mobile_22_2.asm +++ b/misc/mobile_22_2.asm @@ -828,7 +828,7 @@ Function8b7bd: ; 8b7bd call Function8b75d call UpdateSprites call Function89209 - call HandleScrollingMenu + call ScrollingMenu call Function8920f ld a, [wMenuJoypad] cp $2 diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index 9daa37e06..bf1d10f9f 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -2024,7 +2024,7 @@ Function100cb5: ; 100cb5 ld a, [wcfa8] and c jr z, .asm_100cc0 - call Function1bee + call PlaceHollowCursor ld a, [PartyCount] inc a ld b, a @@ -5569,7 +5569,7 @@ Function1024de: ; 1024de ; 1024f6 Function1024f6: ; 1024f6 - call Function1bee + call PlaceHollowCursor ld hl, wcd4b set 1, [hl] ld a, [wcd4c] @@ -5746,7 +5746,7 @@ Function1025ff: ; 1025ff ld a, [OTPartyCount] cp b ret nz - call Function1bf7 + call HideCursor ld a, [PartyCount] ld [wMenuCursorY], a ld a, $1d @@ -5806,7 +5806,7 @@ Function10266b: ; 10266b ld a, [wMenuCursorY] dec a ret nz - call Function1bf7 + call HideCursor ld a, $1f ld [wcd49], a ret @@ -5847,7 +5847,7 @@ Jumptable_1026da: ; 1026da ; 1026de Function1026de: ; 1026de - call Function1bf7 + call HideCursor hlcoord 9, 17 ld [hl], $ed ld a, [wcd4a] @@ -5901,7 +5901,7 @@ Function1026f3: ; 1026f3 Function102738: ; 102738 ld hl, wcd4b set 6, [hl] - call Function1bee + call PlaceHollowCursor call Function1027eb ld hl, wcd4b set 1, [hl] @@ -7796,7 +7796,7 @@ Mobile_SelectThreeMons: ; 10366e call PrintText call YesNoBox jr c, .asm_103696 - callba Function8b1e1 + callba CheckForMobileBattleRules jr nc, .asm_103690 call JoyWaitAorB jr .asm_103696 @@ -7841,7 +7841,7 @@ Mobile_SelectThreeMons: ; 10366e jr .asm_1036b5 .asm_1036d9 - callba Function8b1e1 + callba CheckForMobileBattleRules jr nc, .asm_1036e6 call JoyWaitAorB jr .asm_1036f4 diff --git a/wram.asm b/wram.asm index 3cb2c9d88..bea0fd270 100644 --- a/wram.asm +++ b/wram.asm @@ -1492,8 +1492,7 @@ Requested1bppDest:: ; cf6f wWindowStackPointer:: dw ; cf71 wMenuJoypad:: ds 1 ; cf73 MenuSelection:: ds 1 ; cf74 - -wcf75:: ds 1 +MenuSelectionQuantity:: ds 1 ; cf75 wcf76:: ds 1 wScrollingMenuCursorPosition:: ds 1 wWindowStackSize:: ds 9 @@ -1523,24 +1522,30 @@ wMenuData2Flags:: ds 1 ; cf91 ; bit 1: Enable Select button ; bit 0: Disable B button +wMenuData2_ScrollingMenuHeight:: wMenuData2Items:: ds 1 wMenuData2IndicesPointer:: wMenuData2Spacing:: +wMenuData2_ScrollingMenuWidth:: wcf93:: ds 1 wMenuData2_2DMenuItemStringsBank:: +wMenuData2_ScrollingMenuSpacing:: wcf94:: ds 1 wMenuData2_2DMenuItemStringsAddr:: wMenuData2DisplayFunctionPointer:: -wMenuData2Bank:: +wMenuData2_ItemsPointerBank:: wcf95:: ds 1 ; bank -wMenuData2Addr:: +wMenuData2_ItemsPointerAddr:: wcf96:: ds 1 ; addr lo wMenuData2PointerTableAddr:: wMenuData2_2DMenuFunctionBank:: wcf97:: ds 1 ; addr hi wMenuData2_2DMenuFunctionAddr:: +wMenuData2_ScrollingMenuFunction1:: wcf98:: ds 3 +wMenuData2_ScrollingMenuFunction2:: wcf9b:: ds 3 +wMenuData2_ScrollingMenuFunction3:: wcf9e:: ds 3 wMenuData2End:: wMenuData3:: @@ -1941,7 +1946,7 @@ wd105:: ds 1 CurItem:: ; d106 ds 1 -ItemCountBuffer:: ; d107 +CurItemQuantity:: ; d107 wMartItemID:: wd107:: ds 1 @@ -1981,7 +1986,7 @@ wItemAttributeParamBuffer:: ; d142 CurPartyLevel:: ; d143 ds 1 -wd144:: ds 2 +wScrollingMenuListSize:: ds 2 ; used when following a map warp ; d146