From 77ef8404a197d015398674482103afd9651a9f42 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 15 Dec 2015 18:59:49 -0500 Subject: [PATCH] Menu --- battle/core.asm | 52 +- battle/menu.asm | 4 +- engine/billspc.asm | 48 +- engine/decorations.asm | 6 +- engine/dummy_game.asm | 2 +- engine/init_gender.asm | 4 +- engine/intro_menu.asm | 8 +- engine/learn.asm | 8 +- engine/link.asm | 50 +- engine/mail.asm | 8 +- engine/main_menu.asm | 76 +-- engine/mart.asm | 8 +- engine/menu.asm | 755 ++++++++++++++++-------- engine/mon_icons.asm | 2 +- engine/mon_menu.asm | 12 +- engine/pack.asm | 30 +- engine/party_menu.asm | 10 +- engine/pokecenter_pc.asm | 6 +- engine/printer.asm | 116 ++-- engine/rtc.asm | 210 +++++++ engine/save.asm | 2 +- engine/scripting.asm | 14 +- engine/slot_machine.asm | 6 +- engine/sprite_anims.asm | 4 +- engine/startmenu.asm | 22 +- engine/stats_screen.asm | 4 +- engine/std_scripts.asm | 2 +- engine/tile_events.asm | 110 ++++ engine/tmhm2.asm | 12 +- event/buena.asm | 4 +- event/elevator.asm | 2 +- event/kurt.asm | 4 +- event/mom.asm | 4 +- event/move_deleter.asm | 2 +- home.asm | 2 +- home/handshake.asm | 13 + home/menu.asm | 93 ++- home/mobile.asm | 6 +- home/movement.asm | 22 +- home/serial.asm | 48 +- home/tilemap.asm | 15 +- hram.asm | 2 +- items/item_effects.asm | 16 +- lib/mobile/main.asm | 130 ++-- macros/event.asm | 12 +- main.asm | 658 ++------------------- maps/CeladonDeptStore6F.asm | 2 +- maps/CeladonGameCornerPrizeRoom.asm | 4 +- maps/DragonShrine.asm | 10 +- maps/EarlsPokemonAcademy.asm | 4 +- maps/GoldenrodCity.asm | 2 +- maps/GoldenrodDeptStore6F.asm | 2 +- maps/GoldenrodGameCorner.asm | 4 +- maps/GoldenrodPokeComCenter2FMobile.asm | 4 +- misc/fixed_words.asm | 8 +- misc/mobile_12.asm | 30 +- misc/mobile_12_2.asm | 50 +- misc/mobile_22.asm | 30 +- misc/mobile_22_2.asm | 6 +- misc/mobile_40.asm | 118 ++-- misc/mobile_41.asm | 2 +- misc/mobile_46.asm | 40 +- misc/mobile_5b.asm | 16 +- misc/mobile_5f.asm | 18 +- wram.asm | 47 +- 65 files changed, 1512 insertions(+), 1509 deletions(-) create mode 100755 engine/rtc.asm create mode 100755 engine/tile_events.asm diff --git a/battle/core.asm b/battle/core.asm index 926b7681c..aa656652e 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -2871,13 +2871,13 @@ AskUseNextPokemon: ; 3d1f8 .loop lb bc, 1, 7 call PlaceYesNoBox - ld a, [MenuSelection2] + ld a, [wMenuCursorY] jr c, .pressed_b and a ret .pressed_b - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 ; YES jr z, .loop ld hl, PartyMon1Speed @@ -3698,7 +3698,7 @@ OfferSwitch: ; 3d74b call StdBattleTextBox lb bc, 1, 7 call PlaceYesNoBox - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a jr nz, .said_no call Function3d2f7 @@ -5303,7 +5303,7 @@ BattleMenu_Pack: ; 3e1c7 .tutorial2 call GetMonFrontpic ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a call ExitMenu call UpdateBattleHUDs call WaitBGMap @@ -5343,7 +5343,7 @@ BattleMenuPKMN_Loop: call .GetMenu jr c, .PressedB call Function1bee - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 ; SWITCH jp z, TryPlayerSwitch cp $2 ; STATS @@ -5545,7 +5545,7 @@ BattleMonEntrance: ; 3e40b call SetPlayerTurn call SpikesDamage ld a, $2 - ld [MenuSelection2], a + ld [wMenuCursorY], a ret ; 3e459 @@ -5575,7 +5575,7 @@ PassedBattleMonEntrance: ; 3e459 BattleMenu_Run: ; 3e489 call Call_LoadTempTileMapToTileMap ld a, $3 - ld [MenuSelection2], a + ld [wMenuCursorY], a ld hl, BattleMonSpeed ld de, EnemyMonSpeed call TryToRunAwayFromBattle @@ -5671,9 +5671,9 @@ MoveSelectionScreen: ; 3e4bc inc a .skip_inc - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a ld a, [wNumMoves] inc a ld [wcfa3], a @@ -5726,7 +5726,7 @@ MoveSelectionScreen: ; 3e4bc .interpret_joypad ld a, $1 ld [hBGMapMode], a - call Function1bd3 + call ScrollingMenuJoypad bit D_UP_F, a jp nz, .pressed_up bit D_DOWN_F, a @@ -5738,9 +5738,9 @@ MoveSelectionScreen: ; 3e4bc xor a ld [wMoveSwapBuffer], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a - ld [MenuSelection2], a + ld [wMenuCursorY], a ld b, a ld a, [wMoveSelectionMenuType] dec a @@ -5763,7 +5763,7 @@ MoveSelectionScreen: ; 3e4bc ret nz ld hl, BattleMonPP - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld c, a ld b, 0 add hl, bc @@ -5779,7 +5779,7 @@ MoveSelectionScreen: ; 3e4bc ld a, [wc6e1] and a jr nz, .skip2 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld hl, BattleMonMoves ld c, a ld b, 0 @@ -5809,17 +5809,17 @@ MoveSelectionScreen: ; 3e4bc ; 3e61d .pressed_up - ld a, [MenuSelection2] + ld a, [wMenuCursorY] and a jp nz, .menu_loop ld a, [wNumMoves] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a jp .menu_loop ; 3e62e .pressed_down ; 3e62e - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [wNumMoves] rept 2 @@ -5828,7 +5828,7 @@ endr cp b jp nz, .menu_loop ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a jp .menu_loop ; 3e643 @@ -5845,7 +5845,7 @@ endr swap a and $f ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp b jr nz, .not_swapping_disabled_move ld a, [hl] @@ -5864,7 +5864,7 @@ endr ld a, [hl] and $f ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] swap a add b ld [hl], a @@ -5899,7 +5899,7 @@ endr ld d, h ld e, l pop hl - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, 0 @@ -5912,7 +5912,7 @@ endr ret .start_swap - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wMoveSwapBuffer], a jp MoveSelectionScreen ; 3e6c8 @@ -5934,7 +5934,7 @@ MoveInfoBox: ; 3e6c8 swap a and $f ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp b jr nz, .not_disabled @@ -5944,11 +5944,11 @@ MoveInfoBox: ; 3e6c8 jr .done .not_disabled - ld hl, MenuSelection2 + ld hl, wMenuCursorY dec [hl] call SetPlayerTurn ld hl, BattleMonMoves - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld c, a ld b, 0 add hl, bc @@ -5961,7 +5961,7 @@ MoveInfoBox: ; 3e6c8 ld [MonType], a callab GetMaxPPOfMove - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld c, [hl] inc [hl] ld b, 0 diff --git a/battle/menu.asm b/battle/menu.asm index 72b22841c..3efcc0079 100755 --- a/battle/menu.asm +++ b/battle/menu.asm @@ -3,7 +3,7 @@ LoadBattleMenu: ; 24ef2 call LoadMenuDataHeader ld a, [wd0d2] ld [wMenuCursorBuffer], a - call Function2039 + call InterpretBattleMenu ld a, [wMenuCursorBuffer] ld [wd0d2], a call ExitMenu @@ -25,7 +25,7 @@ ContestBattleMenu: ; 24f13 Function24f19: ; 24f19 ld a, [wd0d2] ld [wMenuCursorBuffer], a - call InterpretMenu + call _2DMenu ld a, [wMenuCursorBuffer] ld [wd0d2], a call ExitMenu diff --git a/engine/billspc.asm b/engine/billspc.asm index 33792477a..4346746f5 100755 --- a/engine/billspc.asm +++ b/engine/billspc.asm @@ -123,18 +123,18 @@ Functione245d: ; e245d (38:645d) ld de, PCString_WhatsUp call Functione2a6e ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a call Functione298d ret Functione247d: ; e247d (38:647d) ld hl, BillsPCDepositMenuDataHeader call CopyMenuDataHeader - ld a, [MenuSelection2] + ld a, [wMenuCursorY] call Function1d4b - call InterpretMenu2 + call VerticalMenu jp c, BillsPCDepositFuncCancel - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a and $3 ld e, a @@ -187,14 +187,14 @@ BillsPCDepositFuncRelease: ; e24e0 (38:64e0) jr c, BillsPCDepositFuncCancel call Functione2f5f jr c, BillsPCDepositFuncCancel - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af ld de, PCString_ReleasePKMN call Functione2a6e call LoadStandardMenuDataHeader lb bc, 14, 11 call PlaceYesNoBox - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call ExitMenu and a @@ -218,7 +218,7 @@ BillsPCDepositFuncRelease: ; e24e0 (38:64e0) ld de, PCString_WhatsUp call Functione2a6e pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ret BillsPCDepositFuncCancel: ; e2537 (38:6537) @@ -388,18 +388,18 @@ Functione2655: ; e2655 (38:6655) ld de, PCString_WhatsUp call Functione2a6e ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a call Functione298d ret BillsPC_Withdraw: ; e2675 (38:6675) ld hl, .MenuDataHeader call CopyMenuDataHeader - ld a, [MenuSelection2] + ld a, [wMenuCursorY] call Function1d4b - call InterpretMenu2 + call VerticalMenu jp c, .cancel - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a and 3 ld e, a @@ -448,7 +448,7 @@ endr ret .release: ; e26d8 (38:66d8) - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af call Functione2f5f jr c, .FailedRelease @@ -457,7 +457,7 @@ endr call LoadStandardMenuDataHeader lb bc, 14, 11 call PlaceYesNoBox - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call ExitMenu and a @@ -481,7 +481,7 @@ endr ld de, PCString_WhatsUp call Functione2a6e pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ret .cancel: ; e272b (38:672b) @@ -649,7 +649,7 @@ Functione283d: ; e283d ld de, PCString_WhatsUp call Functione2a6e ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a call Functione298d ret ; e285d @@ -657,11 +657,11 @@ Functione283d: ; e283d Functione285d: ; e285d ld hl, MenuDataHeader_0xe28c3 call CopyMenuDataHeader - ld a, [MenuSelection2] + ld a, [wMenuCursorY] call Function1d4b - call InterpretMenu2 + call VerticalMenu jp c, Functione28bd - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a and 3 ld e, a @@ -1764,11 +1764,11 @@ Functione2f95: ; e2f95 (38:6f95) ld hl, hJoyPressed ; $ffa7 ld a, [hl] and A_BUTTON | B_BUTTON | D_RIGHT | D_LEFT - ld [wcf73], a + ld [wMenuJoypad], a jr nz, .pressed_a_b_right_left ld a, [hl] and D_DOWN | D_UP - ld [wcf73], a + ld [wMenuJoypad], a jr nz, .pressed_down_up jr .pressed_a_b_right_left @@ -1791,7 +1791,7 @@ Functione2f95: ; e2f95 (38:6f95) .asm_e2fd1 xor a - ld [wcf73], a + ld [wMenuJoypad], a ret Functione2fd6: ; e2fd6 (38:6fd6) @@ -2367,7 +2367,7 @@ _ChangeBox: ; e35aa (38:75aa) lb bc, 8, 9 call TextBox call HandleScrollingMenu - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .done call Functione37af @@ -2549,10 +2549,10 @@ String_e36f1: ; e36f1 Functione36f9: ; e36f9 (38:76f9) ld hl, .MenuDataHeader call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu ret c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .Switch cp $2 diff --git a/engine/decorations.asm b/engine/decorations.asm index ef8ee76dd..794552a70 100755 --- a/engine/decorations.asm +++ b/engine/decorations.asm @@ -19,7 +19,7 @@ _KrisDecorationMenu: ; 0x2675c ld [wMenuCursorBuffer], a call .FindCategoriesWithOwnedDecos call DoNthMenu - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wd1ef], a jr c, .exit_menu ld a, [MenuSelection] @@ -401,7 +401,7 @@ PopulateDecoCategoryMenu: ; 2695b xor a ld [wMenuScrollPosition], a call HandleScrollingMenu - ld a, [wcf73] + ld a, [wMenuJoypad] cp 2 jr z, .no_action_2 call DoDecorationAction2 @@ -1009,7 +1009,7 @@ DecoAction_AskWhichSide: ; 26e70 call ExitMenu call CopyMenuData2 jr c, .nope - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp 3 jr z, .nope ld [Buffer2], a diff --git a/engine/dummy_game.asm b/engine/dummy_game.asm index cc188598f..e10633c88 100755 --- a/engine/dummy_game.asm +++ b/engine/dummy_game.asm @@ -416,7 +416,7 @@ Functione20e5: ; e20e5 ; e2101 Functione2101: ; e2101 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld l, a ld h, 0 diff --git a/engine/init_gender.asm b/engine/init_gender.asm index 9fda68a3c..9fc575520 100755 --- a/engine/init_gender.asm +++ b/engine/init_gender.asm @@ -33,9 +33,9 @@ InitGender: ; 48dcb (12:4dcb) ld hl, .MenuDataHeader call LoadMenuDataHeader call WaitBGMap2 - call InterpretMenu2 + call VerticalMenu call WriteBackup - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [PlayerGender], a ld c, 10 diff --git a/engine/intro_menu.asm b/engine/intro_menu.asm index 1ec4d86d5..7c80f1005 100755 --- a/engine/intro_menu.asm +++ b/engine/intro_menu.asm @@ -547,7 +547,7 @@ Continue_LoadMenuHeader: ; 5ebf .pokedex_header call Function1e35 call MenuBox - call Function1c89 + call PlaceVerticalMenuItems ret ; 5ed9 @@ -783,7 +783,7 @@ OakText7: ; 0x606f NamePlayer: ; 0x6074 callba MovePlayerPicRight callba ShowPlayerNamingChoices - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a jr z, .NewName call StorePlayerName @@ -828,8 +828,8 @@ NamePlayer: ; 0x6074 Function60e9: ; Unreferenced call LoadMenuDataHeader - call InterpretMenu2 - ld a, [MenuSelection2] + call VerticalMenu + ld a, [wMenuCursorY] dec a call CopyNameFromMenu call WriteBackup diff --git a/engine/learn.asm b/engine/learn.asm index f6df570e7..634c29512 100755 --- a/engine/learn.asm +++ b/engine/learn.asm @@ -155,8 +155,8 @@ ForgetMove: ; 65d3 ld [wcfa3], a ld a, $1 ld [wcfa4], a - ld [MenuSelection2], a - ld [wcfaa], a + ld [wMenuCursorY], a + ld [wMenuCursorX], a ld a, $3 ld [wcfa8], a ld a, $20 @@ -165,7 +165,7 @@ ForgetMove: ; 65d3 ld [wcfa6], a ld a, $20 ld [wcfa7], a - call Function1bc9 + call StaticMenuJoypad push af call Call_LoadTempTileMapToTileMap pop af @@ -173,7 +173,7 @@ ForgetMove: ; 65d3 bit 1, a jr nz, .cancel push hl - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, 0 diff --git a/engine/link.asm b/engine/link.asm index 2255133cb..677c503fa 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -1219,7 +1219,7 @@ rept 3 endr ld [hl], a ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a inc a ld [wPlayerLinkAction], a jp Function2888b @@ -1239,7 +1239,7 @@ Function28803: ; 28803 ld a, $6 ld [wcfa2], a ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a ld a, $10 ld [wcfa7], a ld a, $20 @@ -1264,7 +1264,7 @@ Function28835: ; 28835 .asm_2885b bit 6, a jr z, .asm_28883 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [OTPartyCount] cp b @@ -1280,7 +1280,7 @@ Function28835: ; 28835 pop bc pop hl ld a, [PartyCount] - ld [MenuSelection2], a + ld [wMenuCursorY], a jr Function2888b .asm_28883 @@ -1304,7 +1304,7 @@ Function2888b: ; 2888b ld a, $6 ld [wcfa2], a ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a ld a, $10 ld [wcfa7], a ld a, $20 @@ -1328,7 +1328,7 @@ Function288c5: ; 288c5 .asm_288d9 bit 7, a jr z, .asm_288fe - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a jp nz, Function2891c ld a, $1 @@ -1342,13 +1342,13 @@ Function288c5: ; 288c5 pop bc pop hl ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a jp Function28803 .asm_288fe bit 6, a jr z, Function2891c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [PartyCount] cp b @@ -1373,7 +1373,7 @@ Function2891c: ; 2891c Function28926: ; 28926 call LoadTileMapToTempTileMap - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af hlcoord 0, 15 ld b, $1 @@ -1398,21 +1398,21 @@ Function28926: ; 28926 ld a, $1 ld [wcfa2], a ld a, $1 - ld [MenuSelection2], a - ld [wcfaa], a + ld [wMenuCursorY], a + ld [wMenuCursorX], a ld a, $20 ld [wcfa7], a xor a ld [wcfa5], a ld [wcfa6], a - call Function1bd3 + call ScrollingMenuJoypad bit 4, a jr nz, .asm_2898d bit 1, a jr z, .asm_289cd .asm_28983 pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a call Call_LoadTempTileMapToTileMap jp Function2888b @@ -1430,14 +1430,14 @@ Function28926: ; 28926 ld a, $b ld [wcfa2], a ld a, $1 - ld [MenuSelection2], a - ld [wcfaa], a + ld [wMenuCursorY], a + ld [wMenuCursorX], a ld a, $20 ld [wcfa7], a xor a ld [wcfa5], a ld [wcfa6], a - call Function1bd3 + call ScrollingMenuJoypad bit 5, a jp nz, .asm_28946 bit 1, a @@ -1446,7 +1446,7 @@ Function28926: ; 28926 .asm_289cd pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $4 ld [wd263], a callab Function50db9 @@ -1465,7 +1465,7 @@ Function28926: ; 28926 .asm_289fe call Function1bee pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a dec a ld [wd002], a ld [wPlayerLinkAction], a @@ -1549,7 +1549,7 @@ UnknownText_0x28ac4: ; 0x28ac4 Function28ac9: ; 28ac9 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jp nz, Function2891c call Function1bf7 @@ -1579,12 +1579,12 @@ Function28ade: ; 28ade bit 6, a jr z, .asm_28b03 ld a, [OTPartyCount] - ld [MenuSelection2], a + ld [wMenuCursorY], a jp Function28803 .asm_28b03 ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a jp Function2888b .asm_28b0b @@ -1715,17 +1715,17 @@ Function28b87: ; 28b87 ld a, $3 ld [wcfa8], a ld a, $1 - ld [MenuSelection2], a - ld [wcfaa], a + ld [wMenuCursorY], a + ld [wMenuCursorX], a callba Function4d354 - call Function1bd3 + call ScrollingMenuJoypad push af call Call_ExitMenu call WaitBGMap2 pop af bit 1, a jr nz, .asm_28c33 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a jr z, .asm_28c54 diff --git a/engine/mail.asm b/engine/mail.asm index 6eef16a8c..f8619c9f6 100755 --- a/engine/mail.asm +++ b/engine/mail.asm @@ -402,10 +402,10 @@ MailboxPC: ; 0x44806 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [OBPals + 8 * 6], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wCurMessageIndex], a - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .exit call Function4484a @@ -419,10 +419,10 @@ MailboxPC: ; 0x44806 Function4484a: ; 0x4484a ld hl, MenuData44964 call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu jr c, .exit - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld hl, .JumpTable rst JumpTable diff --git a/engine/main_menu.asm b/engine/main_menu.asm index 01432dc04..9225945ef 100755 --- a/engine/main_menu.asm +++ b/engine/main_menu.asm @@ -202,7 +202,7 @@ Function49de4: ; 49de4 set 5, a ld [wcfa5], a call Function1f1a - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .asm_49e07 cp $1 @@ -390,15 +390,15 @@ Function49f16: ; 49f16 call PlaceString call WaitBGMap2 call SetPalettes - call Function1bc9 - ld hl, MenuSelection2 + call StaticMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc jr .asm_49f5d .asm_49f55 - call Function1bd3 - ld hl, MenuSelection2 + call ScrollingMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc @@ -410,7 +410,7 @@ Function49f16: ; 49f16 jr .asm_49f97 .asm_49f67 - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] cp $1 jp z, Function4a098 @@ -421,7 +421,7 @@ Function49f16: ; 49f16 cp $4 jp z, Function4a100 ld a, $1 - call Function1ff8 + call MenuClickSound .asm_49f84 pop bc @@ -434,7 +434,7 @@ Function49f16: ; 49f16 ret .asm_49f97 - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] dec a ld hl, MobileStrings2 @@ -452,7 +452,7 @@ Function49f16: ; 49f16 .asm_49fb7 call Function4a071 pop bc - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld [hl], b ld b, $a ld c, $1 @@ -529,7 +529,7 @@ endr Function4a098: ; 4a098 (12:6098) ld a, $2 - call Function1ff8 + call MenuClickSound call Function1bee call WaitBGMap call LoadStandardMenuDataHeader @@ -542,13 +542,13 @@ Function4a098: ; 4a098 (12:6098) Function4a0b9: ; 4a0b9 (12:60b9) ld a, $2 - call Function1ff8 + call MenuClickSound pop bc jp Function4a4c4 Function4a0c2: ; 4a0c2 (12:60c2) ld a, $2 - call Function1ff8 + call MenuClickSound ld a, BANK(sPlayerData) call GetSRAMBank ld hl, sPlayerData + PlayerName - wPlayerData @@ -574,7 +574,7 @@ Function4a0c2: ; 4a0c2 (12:60c2) Function4a100: ; 4a100 (12:6100) ld a, $2 - call Function1ff8 + call MenuClickSound call ClearBGPalettes call Function4a13b call ClearBGPalettes @@ -630,7 +630,7 @@ Function4a149: ; 4a149 (12:6149) ld b, $4 ld c, $12 call TextBox - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld hl, Strings_4a23d call GetNthString @@ -644,15 +644,15 @@ Function4a149: ; 4a149 (12:6149) call PlaceString callba Function104148 call SetPalettes - call Function1bc9 - ld hl, MenuSelection2 + call StaticMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc jr asm_4a19d Function4a195: ; 4a195 (12:6195) - call Function1bd3 - ld hl, MenuSelection2 + call ScrollingMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc @@ -663,19 +663,19 @@ asm_4a19d: ; 4a19d (12:619d) jr nz, .asm_4a1ba jr .asm_4a1bc .asm_4a1a7 - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] cp $1 jp z, Function4a20e cp $2 jp z, Function4a221 ld a, $1 - call Function1ff8 + call MenuClickSound .asm_4a1ba pop bc ret .asm_4a1bc - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] dec a ld hl, Strings_4a23d @@ -692,7 +692,7 @@ asm_4a19d: ; 4a19d (12:619d) .asm_4a1db call Function4a373 pop bc - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld [hl], b lb bc, 6, 1 hlcoord 2, 3 @@ -708,7 +708,7 @@ String_4a1ef: ; 4a1ef Function4a20e: ; 4a20e (12:620e) ld a, $1 - call Function1ff8 + call MenuClickSound callba Function1719c8 call ClearBGPalettes call DelayFrame @@ -716,12 +716,12 @@ Function4a20e: ; 4a20e (12:620e) Function4a221: ; 4a221 (12:6221) ld a, $1 - call Function1ff8 + call MenuClickSound call Function4a28a jr c, Function4a239 call Function4a373 ld a, $2 - ld [MenuSelection2], a + ld [wMenuCursorY], a jr .asm_4a235 .asm_4a235 pop bc @@ -767,13 +767,13 @@ Function4a28a: ; 4a28a (12:628a) call PlaceString callba Function104148 call Function4a118 - call Function1bd3 + call ScrollingMenuJoypad push af call PlayClickSFX pop af bit 1, a jr nz, .asm_4a33b - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $2 jr z, .asm_4a2f0 cp $3 @@ -796,10 +796,10 @@ Function4a28a: ; 4a28a (12:628a) callba Function104148 ld hl, MenuDataHeader_0x4a362 call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu bit 1, a jr nz, .asm_4a338 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $2 jr z, .asm_4a338 ld a, $5 @@ -1073,15 +1073,15 @@ Function4a4c4: ; 4a4c4 (12:64c4) call PlaceString call WaitBGMap2 call SetPalettes - call Function1bc9 - ld hl, MenuSelection2 + call StaticMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc jr asm_4a54d Function4a545: ; 4a545 (12:6545) - call Function1bd3 - ld hl, MenuSelection2 + call ScrollingMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc @@ -1092,7 +1092,7 @@ asm_4a54d: ; 4a54d (12:654d) jr nz, .asm_4a574 jr .asm_4a57e .asm_4a557 - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] cp $1 jp z, Function4a6ab @@ -1103,14 +1103,14 @@ asm_4a54d: ; 4a54d (12:654d) cp $4 jp z, Function4a6ab ld a, $1 - call Function1ff8 + call MenuClickSound .asm_4a574 pop bc call ClearBGPalettes call ClearTileMap jp Function49f0a .asm_4a57e - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] dec a add a @@ -1138,7 +1138,7 @@ asm_4a54d: ; 4a54d (12:654d) Function4a5b0: ; 4a5b0 (12:65b0) call Function4a680 pop bc - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld [hl], b ld b, $a ld c, $1 @@ -1206,7 +1206,7 @@ endr Function4a6ab: ; 4a6ab (12:66ab) ld a, $2 - call Function1ff8 + call MenuClickSound call ClearBGPalettes ld b, SCGB_08 call GetSGBLayout diff --git a/engine/mart.asm b/engine/mart.asm index 3437ef984..7d92e468b 100755 --- a/engine/mart.asm +++ b/engine/mart.asm @@ -185,9 +185,9 @@ StandardMart: ; 15b47 .TopMenu: ; 15b6e ld hl, MenuDataHeader_BuySell call CopyMenuDataHeader - call InterpretMenu2 + call VerticalMenu jr c, .quit - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .buy cp $2 @@ -481,10 +481,10 @@ BuyMenuLoop: ; 15cef call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wd045 + 1], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wd045], a call SpeechTextBox - ld a, [wcf73] + ld a, [wMenuJoypad] cp B_BUTTON jr z, .set_carry cp A_BUTTON diff --git a/engine/menu.asm b/engine/menu.asm index 22ca2b214..152be1992 100755 --- a/engine/menu.asm +++ b/engine/menu.asm @@ -1,54 +1,57 @@ -Function2400e:: ; 2400e +_2DMenu_:: ; 2400e ld hl, CopyMenuData2 - ld a, [wcf94] + ld a, [wMenuData2_2DMenuItemStringsBank] rst FarCall - call Function24085 + + call Draw2DMenu call UpdateSprites call ApplyTilemap - call Function2408f + call Get2DMenuSelection ret ; 24022 -Function24022:: ; 24022 +_InterpretBattleMenu:: ; 24022 ld hl, CopyMenuData2 - ld a, [wcf94] + ld a, [wMenuData2_2DMenuItemStringsBank] rst FarCall - call Function24085 + + call Draw2DMenu callba MobileTextBorder call UpdateSprites call ApplyTilemap - call Function2408f + call Get2DMenuSelection ret ; 2403c -Function2403c:: ; 2403c +_InterpretMobileMenu:: ; 2403c ld hl, CopyMenuData2 - ld a, [wcf94] + ld a, [wMenuData2_2DMenuItemStringsBank] rst FarCall - call Function24085 + + call Draw2DMenu callba MobileTextBorder call UpdateSprites call ApplyTilemap - call Function2411a - ld hl, wcfa5 + call Init2DMenuCursorPosition + ld hl, w2DMenuFlags1 set 7, [hl] -.asm_2405a +.loop call DelayFrame callba Function10032e ld a, [wcd2b] and a - jr nz, .asm_24076 - call Function241ba - ld a, [wcfa8] + jr nz, .quit + call MobileMenuJoypad + ld a, [w2DMenuFlags4] and c - jr z, .asm_2405a - call Function24098 + jr z, .loop + call Mobile_GetMenuSelection ret -.asm_24076 - ld a, [wcfa4] +.quit + ld a, [w2DMenuNumCols] ld c, a - ld a, [wcfa3] + ld a, [w2DMenuNumRows] call SimpleMultiply ld [wMenuCursorBuffer], a and a @@ -57,174 +60,173 @@ Function2403c:: ; 2403c -Function24085: ; 24085 +Draw2DMenu: ; 24085 xor a ld [hBGMapMode], a call MenuBox - call Function240db + call Place2DMenuItemStrings ret ; 2408f -Function2408f: ; 2408f - call Function2411a - call Function1bc9 - call Function1ff8 - -Function24098: ; 24098 +Get2DMenuSelection: ; 2408f + call Init2DMenuCursorPosition + call StaticMenuJoypad + call MenuClickSound +Mobile_GetMenuSelection: ; 24098 ld a, [wMenuData2Flags] bit 1, a - jr z, .asm_240a6 - call Function1bdd - bit 2, a - jr nz, .asm_240c9 + jr z, .skip + call GetMenuJoypad + bit SELECT_F, a + jr nz, .quit1 -.asm_240a6 +.skip ld a, [wMenuData2Flags] bit 0, a - jr nz, .asm_240b4 - call Function1bdd - bit 1, a - jr nz, .asm_240cb + jr nz, .skip2 + call GetMenuJoypad + bit B_BUTTON_F, a + jr nz, .quit2 -.asm_240b4 - ld a, [wcfa4] +.skip2 + ld a, [w2DMenuNumCols] ld c, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call SimpleMultiply ld c, a - ld a, [wcfaa] + ld a, [wMenuCursorX] add c ld [wMenuCursorBuffer], a and a ret -.asm_240c9 +.quit1 scf ret -.asm_240cb +.quit2 scf ret ; 240cd -Function240cd: ; 240cd +GetMenuNumberOfColumns: ; 240cd ld a, [wMenuData2Items] and $f ret ; 240d3 -Function240d3: ; 240d3 +GetMenuNumberOfRows: ; 240d3 ld a, [wMenuData2Items] swap a and $f ret ; 240db -Function240db: ; 240db - ld hl, wcf95 +Place2DMenuItemStrings: ; 240db + ld hl, wMenuData2_2DMenuItemStringsAddr ld e, [hl] inc hl ld d, [hl] call GetMenuTextStartCoord call Coord2Tile - call Function240d3 + call GetMenuNumberOfRows ld b, a -.asm_240eb +.row push bc push hl - call Function240cd + call GetMenuNumberOfColumns ld c, a -.asm_240f1 +.col push bc - ld a, [wcf94] - call Function201c + ld a, [wMenuData2_2DMenuItemStringsBank] + call Place2DMenuItemName inc de - ld a, [wcf93] + ld a, [wMenuData2Spacing] ld c, a - ld b, $0 + ld b, 0 add hl, bc pop bc dec c - jr nz, .asm_240f1 + jr nz, .col pop hl - ld bc, $28 + ld bc, 2 * SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, .asm_240eb - ld hl, wcf98 + jr nz, .row + ld hl, wMenuData2_2DMenuFunctionAddr ld a, [hli] ld h, [hl] ld l, a or h ret z - ld a, [wcf97] + ld a, [wMenuData2_2DMenuFunctionBank] rst FarCall ret ; 2411a -Function2411a: ; 2411a (9:411a) +Init2DMenuCursorPosition: ; 2411a (9:411a) call GetMenuTextStartCoord ld a, b - ld [wcfa1], a + ld [w2DMenuCursorInitY], a dec c ld a, c - ld [wcfa2], a - call Function240d3 - ld [wcfa3], a - call Function240cd - ld [wcfa4], a - call Function24179 - call Function2418a - call Function24193 - ld a, [wcfa4] + ld [w2DMenuCursorInitX], a + call GetMenuNumberOfRows + ld [w2DMenuNumRows], a + call GetMenuNumberOfColumns + ld [w2DMenuNumCols], a + call .InitFlags_a + call .InitFlags_b + call .InitFlags_c + ld a, [w2DMenuNumCols] ld e, a ld a, [wMenuCursorBuffer] ld b, a xor a - ld d, $0 -.asm_24146 + ld d, 0 +.loop inc d add e cp b - jr c, .asm_24146 + jr c, .loop sub e ld c, a ld a, b sub c and a - jr z, .asm_24157 + jr z, .reset1 cp e - jr z, .asm_24159 - jr c, .asm_24159 -.asm_24157 - ld a, $1 -.asm_24159 - ld [wcfaa], a - ld a, [wcfa3] + jr z, .okay1 + jr c, .okay1 +.reset1 + ld a, 1 +.okay1 + ld [wMenuCursorX], a + ld a, [w2DMenuNumRows] ld e, a ld a, d and a - jr z, .asm_24169 + jr z, .reset2 cp e - jr z, .asm_2416b - jr c, .asm_2416b -.asm_24169 - ld a, $1 -.asm_2416b - ld [MenuSelection2], a + jr z, .okay2 + jr c, .okay2 +.reset2 + ld a, 1 +.okay2 + ld [wMenuCursorY], a xor a - ld [wcfab], a - ld [wcfac], a - ld [wcfad], a + ld [wCursorOffCharacter], a + ld [wCursorCurrentTile], a + ld [wCursorCurrentTile + 1], a ret ; 24179 -Function24179: ; 24179 +.InitFlags_a: ; 24179 xor a - ld hl, wcfa5 + ld hl, w2DMenuFlags1 ld [hli], a ld [hld], a ld a, [wMenuData2Flags] @@ -235,89 +237,85 @@ Function24179: ; 24179 ret ; 2418a -Function2418a: ; 2418a - ld a, [wcf93] - or $20 - ld [wcfa7], a +.InitFlags_b: ; 2418a + ld a, [wMenuData2Spacing] + or %00100000 + ld [w2DMenuFlags3], a ret ; 24193 -Function24193: ; 24193 +.InitFlags_c: ; 24193 ld hl, wMenuData2Flags - ld a, $1 + ld a, %001 bit 0, [hl] - jr nz, .asm_2419e - or $2 - -.asm_2419e + jr nz, .skip + or %010 +.skip bit 1, [hl] - jr z, .asm_241a4 - or $4 - -.asm_241a4 - ld [wcfa8], a + jr z, .skip2 + or %100 +.skip2 + ld [w2DMenuFlags4], a ret ; 241a8 -Function241a8:: ; 241a8 - call Function24329 -Function241ab:: ; 241ab - ld hl, wcfa6 +_StaticMenuJoypad:: ; 241a8 + call Place2DMenuCursor +_ScrollingMenuJoypad:: ; 241ab + ld hl, w2DMenuFlags2 res 7, [hl] ld a, [hBGMapMode] push af - call Function24216 + call MenuJoypadLoop pop af ld [hBGMapMode], a ret ; 241ba -Function241ba: ; 241ba - ld hl, wcfa6 +MobileMenuJoypad: ; 241ba + ld hl, w2DMenuFlags2 res 7, [hl] ld a, [hBGMapMode] push af - call Function2431a - call Function24249 - jr nc, .asm_241cd - call Function24270 - -.asm_241cd + call Move2DMenuCursor + call Do2DMenuRTCJoypad + jr nc, .skip_joypad + call _2DMenuInterpretJoypad +.skip_joypad pop af ld [hBGMapMode], a - call Function1bdd + call GetMenuJoypad ld c, a ret ; 241d5 Function241d5: ; 241d5 - call Function24329 +; Unreferenced + call Place2DMenuCursor .loop - call Function2431a + call Move2DMenuCursor call Function10402d ; BUG: This function is in another bank. ; Pointer in current bank (9) is bogus. - call Function241fa + call .loop2 jr nc, .done - call Function24270 + call _2DMenuInterpretJoypad jr c, .done - ld a, [wcfa5] + ld a, [w2DMenuFlags1] bit 7, a jr nz, .done - call Function1bdd + call GetMenuJoypad ld c, a - ld a, [wcfa8] + ld a, [w2DMenuFlags4] and c jr z, .loop .done ret -; 241fa -Function241fa: ; 241fa -.loop - call Function24259 +.loop2 + call Menu_WasButtonPressed ret c ld c, 1 ld b, 3 @@ -326,36 +324,36 @@ Function241fa: ; 241fa ret c callba Function100337 ret c - ld a, [wcfa5] + ld a, [w2DMenuFlags1] bit 7, a - jr z, .loop + jr z, .loop2 and a ret ; 24216 -Function24216: ; 24216 -.asm_24216 - call Function2431a - call Function24238 - call Function24249 - jr nc, .asm_24237 - call Function24270 - jr c, .asm_24237 - ld a, [wcfa5] +MenuJoypadLoop: ; 24216 +.loop + call Move2DMenuCursor + call .BGMap_OAM + call Do2DMenuRTCJoypad + jr nc, .done + call _2DMenuInterpretJoypad + jr c, .done + ld a, [w2DMenuFlags1] bit 7, a - jr nz, .asm_24237 - call Function1bdd + jr nz, .done + call GetMenuJoypad ld b, a - ld a, [wcfa8] + ld a, [w2DMenuFlags4] and b - jr z, .asm_24216 + jr z, .loop -.asm_24237 +.done ret ; 24238 -Function24238: ; 24238 +.BGMap_OAM: ; 24238 ld a, [hOAMUpdate] push af ld a, $1 @@ -368,220 +366,479 @@ Function24238: ; 24238 ret ; 24249 -Function24249: ; 24249 -.asm_24249 +Do2DMenuRTCJoypad: ; 24249 +.loopRTC call RTC - call Function24259 + call Menu_WasButtonPressed ret c - ld a, [wcfa5] + ld a, [w2DMenuFlags1] bit 7, a - jr z, .asm_24249 + jr z, .loopRTC and a ret ; 24259 -Function24259: ; 24259 - ld a, [wcfa5] +Menu_WasButtonPressed: ; 24259 + ld a, [w2DMenuFlags1] bit 6, a - jr z, .asm_24266 + jr z, .skip_to_joypad callab PlaySpriteAnimationsAndDelayFrame -.asm_24266 +.skip_to_joypad call JoyTextDelay - call Function1bdd + call GetMenuJoypad and a ret z scf ret ; 24270 -Function24270: ; 24270 - call Function1bdd - bit 0, a - jp nz, Function24318 - bit 1, a - jp nz, Function24318 - bit 2, a - jp nz, Function24318 - bit 3, a - jp nz, Function24318 - bit 4, a - jr nz, .asm_242fa - bit 5, a - jr nz, .asm_242dc - bit 6, a - jr nz, .asm_242be - bit 7, a - jr nz, .asm_242a0 +_2DMenuInterpretJoypad: ; 24270 + call GetMenuJoypad + bit A_BUTTON_F, a + jp nz, .a_b_start_select + bit B_BUTTON_F, a + jp nz, .a_b_start_select + bit SELECT_F, a + jp nz, .a_b_start_select + bit START_F, a + jp nz, .a_b_start_select + bit D_RIGHT_F, a + jr nz, .d_right + bit D_LEFT_F, a + jr nz, .d_left + bit D_UP_F, a + jr nz, .d_up + bit D_DOWN_F, a + jr nz, .d_down and a ret -.asm_24299: ; 24299 - ld hl, wcfa6 +.set_bit_7: ; 24299 + ld hl, w2DMenuFlags2 set 7, [hl] scf ret -.asm_242a0 - ld hl, MenuSelection2 - ld a, [wcfa3] +.d_down + ld hl, wMenuCursorY + ld a, [w2DMenuNumRows] cp [hl] - jr z, .asm_242ac + jr z, .check_wrap_around_down inc [hl] xor a ret -.asm_242ac - ld a, [wcfa5] +.check_wrap_around_down + ld a, [w2DMenuFlags1] bit 5, a - jr nz, .asm_242ba + jr nz, .wrap_around_down bit 3, a - jp nz, .asm_24299 + jp nz, .set_bit_7 xor a ret -.asm_242ba +.wrap_around_down ld [hl], $1 xor a ret -.asm_242be - ld hl, MenuSelection2 +.d_up + ld hl, wMenuCursorY ld a, [hl] dec a - jr z, .asm_242c8 + jr z, .check_wrap_around_up ld [hl], a xor a ret -.asm_242c8 - ld a, [wcfa5] +.check_wrap_around_up + ld a, [w2DMenuFlags1] bit 5, a - jr nz, .asm_242d6 + jr nz, .wrap_around_up bit 2, a - jp nz, .asm_24299 + jp nz, .set_bit_7 xor a ret -.asm_242d6 - ld a, [wcfa3] +.wrap_around_up + ld a, [w2DMenuNumRows] ld [hl], a xor a ret -.asm_242dc - ld hl, wcfaa +.d_left + ld hl, wMenuCursorX ld a, [hl] dec a - jr z, .asm_242e6 + jr z, .check_wrap_around_left ld [hl], a xor a ret -.asm_242e6 - ld a, [wcfa5] +.check_wrap_around_left + ld a, [w2DMenuFlags1] bit 4, a - jr nz, .asm_242f4 + jr nz, .wrap_around_left bit 1, a - jp nz, .asm_24299 + jp nz, .set_bit_7 xor a ret -.asm_242f4 - ld a, [wcfa4] +.wrap_around_left + ld a, [w2DMenuNumCols] ld [hl], a xor a ret -.asm_242fa - ld hl, wcfaa - ld a, [wcfa4] +.d_right + ld hl, wMenuCursorX + ld a, [w2DMenuNumCols] cp [hl] - jr z, .asm_24306 + jr z, .check_wrap_around_right inc [hl] xor a ret -.asm_24306 - ld a, [wcfa5] +.check_wrap_around_right + ld a, [w2DMenuFlags1] bit 4, a - jr nz, .asm_24314 + jr nz, .wrap_around_right bit 0, a - jp nz, .asm_24299 + jp nz, .set_bit_7 xor a ret -.asm_24314 +.wrap_around_right ld [hl], $1 xor a ret ; 24318 -Function24318: ; 24318 +.a_b_start_select: ; 24318 xor a ret ; 2431a -Function2431a: ; 2431a - ld hl, wcfac +Move2DMenuCursor: ; 2431a + ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] ld l, a ld a, [hl] - cp $ed - jr nz, Function24329 - ld a, [wcfab] + cp "▶" + jr nz, Place2DMenuCursor + ld a, [wCursorOffCharacter] ld [hl], a - -Function24329: ; 24329 - ld a, [wcfa1] +Place2DMenuCursor: ; 24329 + ld a, [w2DMenuCursorInitY] ld b, a - ld a, [wcfa2] + ld a, [w2DMenuCursorInitX] ld c, a call Coord2Tile - ld a, [wcfa7] + ld a, [w2DMenuFlags3] swap a and $f ld c, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a xor a dec b - jr z, .asm_24348 -.asm_24344 + jr z, .got_row +.row_loop add c dec b - jr nz, .asm_24344 + jr nz, .row_loop -.asm_24348 - ld c, $14 +.got_row + ld c, SCREEN_WIDTH call AddNTimes - ld a, [wcfa7] + ld a, [w2DMenuFlags3] and $f ld c, a - ld a, [wcfaa] + ld a, [wMenuCursorX] ld b, a xor a dec b - jr z, .asm_2435f -.asm_2435b + jr z, .got_col +.col_loop add c dec b - jr nz, .asm_2435b + jr nz, .col_loop -.asm_2435f +.got_col ld c, a add hl, bc ld a, [hl] - cp $ed - jr z, .asm_2436b - ld [wcfab], a - ld [hl], $ed + cp "▶" + jr z, .cursor_on + ld [wCursorOffCharacter], a + ld [hl], "▶" -.asm_2436b +.cursor_on ld a, l - ld [wcfac], a + ld [wCursorCurrentTile], a ld a, h - ld [wcfad], a + ld [wCursorCurrentTile + 1], a ret ; 24374 + +_BackUpTiles:: ; 24374 +; Push the window + ld a, [rSVBK] + push af + ld a, $7 + ld [rSVBK], a + + ld hl, wWindowStackPointer + ld e, [hl] + inc hl + ld d, [hl] + push de + + ld b, $10 + ld hl, wMenuFlags +.loop + ld a, [hli] + ld [de], a + dec de + dec b + jr nz, .loop + +; If bit 6 or 7 of the menu flags is set, set bit 0 of the address +; at 7:[wWindowStackPointer], and draw the menu using the coordinates from the header. +; Otherwise, reset bit 0 of 7:[wWindowStackPointer]. + ld a, [wMenuFlags] + bit 6, a + jr nz, .bit_6 + bit 7, a + jr z, .not_bit_7 + +.bit_6 + ld hl, wWindowStackPointer + ld a, [hli] + ld h, [hl] + ld l, a + set 0, [hl] + call MenuBoxCoord2Tile + call .copy + call MenuBoxCoord2Attr + call .copy + jr .done + +.not_bit_7 + pop hl ; last-pushed register was de + push hl + ld a, [hld] + ld l, [hl] + ld h, a + res 0, [hl] + +.done + pop hl + call .ret ; empty function + ld a, h + ld [de], a + dec de + ld a, l + ld [de], a + dec de + ld hl, wWindowStackPointer + ld [hl], e + inc hl + ld [hl], d + + pop af + ld [rSVBK], a + ld hl, wWindowStackSize + inc [hl] + ret +; 243cd + +.copy: ; 243cd + call GetMenuBoxDims + inc b + inc c + call .ret ; empty function + +.row + push bc + push hl + +.col + ld a, [hli] + ld [de], a + dec de + dec c + jr nz, .col + + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + + ret +; 243e7 + +.ret: ; 243e7 + ret +; 243e8 + +_ExitMenu:: ; 243e8 + xor a + ld [hBGMapMode], a + + ld a, [rSVBK] + push af + ld a, $7 + ld [rSVBK], a + + call GetWindowStackTop + ld a, l + or h + jp z, Error_Cant_ExitMenu + ld a, l + ld [wWindowStackPointer], a + ld a, h + ld [wWindowStackPointer + 1], a + call PopWindow + ld a, [wMenuFlags] + bit 0, a + jr z, .next + ld d, h + ld e, l + call RestoreTileBackup + +.next + call GetWindowStackTop + ld a, h + or l + jr z, .done + call PopWindow + +.done + pop af + ld [rSVBK], a + ld hl, wWindowStackSize + dec [hl] + ret +; 24423 + +Function24423: ; 24423 + ld a, [VramState] + bit 0, a + ret z + xor a + call GetSRAMBank + hlcoord 0, 0 + ld de, sScratch + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyBytes + call CloseSRAM + call OverworldTextModeSwitch + xor a + call GetSRAMBank + ld hl, sScratch + decoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT +.asm_2444c + ld a, [hl] + cp $61 + jr c, .asm_24452 + ld [de], a + +.asm_24452 + inc hl + inc de + dec bc + ld a, c + or b + jr nz, .asm_2444c + call CloseSRAM + ret +; 2445d + +Error_Cant_ExitMenu: ; 2445d + ld hl, .Text_NoWindowsAvailableForPopping + call PrintText + call WaitBGMap +.InfiniteLoop + jr .InfiniteLoop +; 24468 + +.Text_NoWindowsAvailableForPopping: ; 24468 + text_jump UnknownText_0x1c46b7 + db "@" +; 2446d + +_InitVerticalMenuCursor:: ; 2446d + ld a, [wMenuData2Flags] + ld b, a + ld hl, w2DMenuCursorInitY + ld a, [wMenuBorderTopCoord] + inc a + bit 6, b + jr nz, .skip_offset + inc a +.skip_offset + ld [hli], a +; w2DMenuCursorInitX + ld a, [wMenuBorderLeftCoord] + inc a + ld [hli], a +; w2DMenuNumRows + ld a, [wMenuData2Items] + ld [hli], a +; w2DMenuNumCols + ld a, 1 + ld [hli], a +; w2DMenuFlags1 + ld [hl], $0 + bit 5, b + jr z, .skip_bit_5 + set 5, [hl] +.skip_bit_5 + ld a, [wMenuFlags] + bit 4, a + jr z, .skip_bit_6 + set 6, [hl] +.skip_bit_6 + inc hl +; w2DMenuFlags2 + xor a + ld [hli], a +; w2DMenuFlags3 + ld a, %00100000 + ld [hli], a +; w2DMenuFlags4 + ld a, %001 + bit 0, b + jr nz, .skip_bit_1 + add %010 +.skip_bit_1 + ld [hli], a +; wMenuCursorY + ld a, [wMenuCursorBuffer] + and a + jr z, .load_at_the_top + ld c, a + ld a, [wMenuData2Items] + cp c + jr nc, .load_position +.load_at_the_top + ld c, 1 +.load_position + ld [hl], c + inc hl +; wMenuCursorX + ld a, 1 + ld [hli], a +; wCursorOffCharacter, wCursorCurrentTile + xor a +rept 3 + ld [hli], a +endr + ret +; 244c3 diff --git a/engine/mon_icons.asm b/engine/mon_icons.asm index ebab47750..883dbdc96 100755 --- a/engine/mon_icons.asm +++ b/engine/mon_icons.asm @@ -363,7 +363,7 @@ GetGFXUnlessMobile: ; 8ea3f FreezeMonIcons: ; 8ea4a ld hl, wSpriteAnimationStructs ld e, PARTY_LENGTH - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld d, a .loop ld a, [hl] diff --git a/engine/mon_menu.asm b/engine/mon_menu.asm index 4c9fb2b89..b58b2e2bc 100755 --- a/engine/mon_menu.asm +++ b/engine/mon_menu.asm @@ -85,10 +85,10 @@ MonMenuLoop: ; 24d59 ld [wMenuData2Flags], a ld a, [Buffer1] ; items ld [wMenuData2Items], a - call Function1c10 + call InitVerticalMenuCursor ld hl, wcfa5 set 6, [hl] - call Function1bc9 + call StaticMenuJoypad ld de, SFX_READ_TEXT_2 call PlaySFX ld a, [hJoyPressed] @@ -103,7 +103,7 @@ MonMenuLoop: ; 24d59 ret .select - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, 0 @@ -301,16 +301,16 @@ BattleMonMenu: ; 24e99 ld [hBGMapMode], a call MenuBox call UpdateSprites - call Function1c89 + call PlaceVerticalMenuItems call WaitBGMap call CopyMenuData2 ld a, [wMenuData2Flags] bit 7, a jr z, .set_carry - call Function1c10 + call InitVerticalMenuCursor ld hl, wcfa5 set 6, [hl] - call Function1bc9 + call StaticMenuJoypad ld de, SFX_READ_TEXT_2 call PlaySFX ld a, [hJoyPressed] diff --git a/engine/pack.asm b/engine/pack.asm index efcead9de..33d44a745 100644 --- a/engine/pack.asm +++ b/engine/pack.asm @@ -72,7 +72,7 @@ Pack: ; 10000 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wItemsPocketCursor], a ld b, $7 ld c, $3 @@ -100,7 +100,7 @@ Pack: ; 10000 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a ld b, $3 ld c, $7 @@ -140,11 +140,11 @@ Pack: ; 10000 .load_jump push de call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu pop hl ret c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call Pack_GetJumptablePointer jp [hl] @@ -233,7 +233,7 @@ Pack: ; 10000 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wBallsPocketCursor], a ld b, $1 ld c, $5 @@ -302,11 +302,11 @@ Pack: ; 10000 .build_menu push de call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu pop hl ret c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call Pack_GetJumptablePointer jp [hl] @@ -737,7 +737,7 @@ BattlePack: ; 10493 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wItemsPocketCursor], a ld b, $7 ld c, $3 @@ -765,7 +765,7 @@ BattlePack: ; 10493 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a ld b, $3 ld c, $7 @@ -816,7 +816,7 @@ BattlePack: ; 10493 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wBallsPocketCursor], a ld b, $1 ld c, $5 @@ -841,11 +841,11 @@ TMHMSubmenu: ; 105dc (4:45dc) .proceed push de call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu pop hl ret c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call Pack_GetJumptablePointer jp [hl] @@ -1021,7 +1021,7 @@ DepositSellPack: ; 106be call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wItemsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wItemsPocketCursor], a ret @@ -1037,7 +1037,7 @@ DepositSellPack: ; 106be call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wKeyItemsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wKeyItemsPocketCursor], a ret @@ -1062,7 +1062,7 @@ DepositSellPack: ; 106be call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wBallsPocketScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wBallsPocketCursor], a ret diff --git a/engine/party_menu.asm b/engine/party_menu.asm index 5d28eb949..4aa71ecf7 100644 --- a/engine/party_menu.asm +++ b/engine/party_menu.asm @@ -696,7 +696,7 @@ InitPartyMenuWithCancel: ; 50405 ld a, $1 .done - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, A_BUTTON | B_BUTTON ld [wcfa8], a ret @@ -718,7 +718,7 @@ InitPartyMenuNoCancel: ; 0x5042d .skip ld a, $1 .done - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, A_BUTTON | B_BUTTON ld [wcfa8], a ret @@ -738,12 +738,12 @@ PartyMenuAttributes: ; 5044f PartyMenuSelect: ; 0x50457 ; sets carry if exitted menu. - call Function1bc9 + call StaticMenuJoypad call Function1bee ld a, [PartyCount] inc a ld b, a - ld a, [MenuSelection2] ; menu selection? + ld a, [wMenuCursorY] ; menu selection? cp b jr z, .exitmenu ; CANCEL ld [wPartyMenuCursor], a @@ -751,7 +751,7 @@ PartyMenuSelect: ; 0x50457 ld b, a bit 1, b jr nz, .exitmenu ; B button? - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [CurPartyMon], a ld c, a diff --git a/engine/pokecenter_pc.asm b/engine/pokecenter_pc.asm index 75f1daeec..8f18e8814 100755 --- a/engine/pokecenter_pc.asm +++ b/engine/pokecenter_pc.asm @@ -594,14 +594,14 @@ Function15985: ; 0x15985 call HandleScrollingMenu ld a, [wMenuScrollPosition] ld [wd0dd], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wd0d7], a pop af ld [wSpriteUpdatesEnabled], a ld a, [wd0e3] and a jr nz, .asm_159d8 - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .asm_15a06 cp $1 @@ -611,7 +611,7 @@ Function15985: ; 0x15985 jr .asm_159f8 .asm_159d8 - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .asm_159e9 cp $1 diff --git a/engine/printer.asm b/engine/printer.asm index 5db2f9ff2..53eefc1aa 100755 --- a/engine/printer.asm +++ b/engine/printer.asm @@ -20,7 +20,7 @@ Function84022: ; 84022 ld a, [wJumptableIndex] ld e, a ld d, 0 - ld hl, Jumptable_84031 + ld hl, .Jumptable rept 2 add hl, de endr @@ -31,27 +31,28 @@ endr ; 84031 -Jumptable_84031: ; 84031 (21:4031) - dw Function84077 - dw Function84143 - dw Function84120 - dw Function84099 - dw Function84180 - dw Function8412e - dw Function840c5 - dw Function84180 - dw Function84120 - dw Function840de - dw Function84180 - dw Function84120 - dw Function841a1 - dw Function84063 - dw Function8406d - dw Function84120 - dw Function84103 - dw Function84071 - dw Function841b0 - dw Function841b3 +.Jumptable: ; 84031 (21:4031) + jumptable_start + jumptable Function84077 + jumptable Function84143 + jumptable Function84120 + jumptable Function84099 + jumptable Function84180 + jumptable Function8412e + jumptable Function840c5 + jumptable Function84180 + jumptable Function84120 + jumptable Function840de + jumptable Function84180 + jumptable Function84120 + jumptable Function841a1 + jumptable Function84063 + jumptable Function8406d + jumptable Function84120 + jumptable Function84103 + jumptable Function84071 + jumptable Function841b0 + jumptable Function841b3 Function84059: ; 84059 (21:4059) @@ -427,12 +428,12 @@ Unknown_842d5: db 15, 0, $00, 0, 15, 0 ; unused ; 842db -Function842db:: ; 842db +_PrinterReceive:: ; 842db ld a, [wc2d5] add a ld e, a ld d, 0 - ld hl, Jumptable_842ea + ld hl, .Jumptable add hl, de ld a, [hli] ld h, [hl] @@ -441,39 +442,40 @@ Function842db:: ; 842db ; 842ea -Jumptable_842ea: ; 842ea (21:42ea) - dw Function8432f - dw Function84330 - dw Function84339 - dw Function84343 - dw Function8434d - dw Function84357 - dw Function84361 - dw Function8438b - dw Function84395 - dw Function8439f - dw Function843a8 - dw Function843b6 - dw Function84330 - dw Function843c0 - dw Function843c9 - dw Function843c9 - dw Function843c9 - dw Function843c0 - dw Function843c9 - dw Function8439f - dw Function843a8 - dw Function843e6 - dw Function84330 - dw Function843d2 - dw Function843c9 - dw Function843c9 - dw Function843c9 - dw Function843d2 - dw Function843c9 - dw Function8439f - dw Function843a8 - dw Function843b6 +.Jumptable: ; 842ea (21:42ea) + jumptable_start + jumptable Function8432f + jumptable Function84330 + jumptable Function84339 + jumptable Function84343 + jumptable Function8434d + jumptable Function84357 + jumptable Function84361 + jumptable Function8438b + jumptable Function84395 + jumptable Function8439f + jumptable Function843a8 + jumptable Function843b6 + jumptable Function84330 + jumptable Function843c0 + jumptable Function843c9 + jumptable Function843c9 + jumptable Function843c9 + jumptable Function843c0 + jumptable Function843c9 + jumptable Function8439f + jumptable Function843a8 + jumptable Function843e6 + jumptable Function84330 + jumptable Function843d2 + jumptable Function843c9 + jumptable Function843c9 + jumptable Function843c9 + jumptable Function843d2 + jumptable Function843c9 + jumptable Function8439f + jumptable Function843a8 + jumptable Function843b6 Function8432a: ; 8432a (21:432a) diff --git a/engine/rtc.asm b/engine/rtc.asm new file mode 100755 index 000000000..0007e8225 --- /dev/null +++ b/engine/rtc.asm @@ -0,0 +1,210 @@ +StopRTC: ; Unreferenced??? + ld a, SRAM_ENABLE + ld [MBC3SRamEnable], a + call LatchClock + ld a, RTC_DH + ld [MBC3SRamBank], a + ld a, [MBC3RTC] + set 6, a ; halt + ld [MBC3RTC], a + call CloseSRAM + ret +; 14019 + +StartRTC: ; 14019 + ld a, SRAM_ENABLE + ld [MBC3SRamEnable], a + call LatchClock + ld a, RTC_DH + ld [MBC3SRamBank], a + ld a, [MBC3RTC] + res 6, a ; halt + ld [MBC3RTC], a + call CloseSRAM + ret +; 14032 + +GetTimeOfDay:: ; 14032 +; get time of day based on the current hour + ld a, [hHours] ; hour + ld hl, TimesOfDay + +.check +; if we're within the given time period, +; get the corresponding time of day + cp [hl] + jr c, .match +; else, get the next entry +rept 2 + inc hl +endr +; try again + jr .check + +.match +; get time of day + inc hl + ld a, [hl] + ld [TimeOfDay], a + ret +; 14044 + +TimesOfDay: ; 14044 +; hours for the time of day +; 04-09 morn | 10-17 day | 18-03 nite + db 04, NITE + db 10, MORN + db 18, DAY + db 24, NITE + db -1, MORN +; 1404e + +Unknown_1404e: ; Unreferenced + db 20, 2 + db 40, 0 + db 60, 1 + db -1, 0 +; 14056 + +StageRTCTimeForSave: ; 14056 + call UpdateTime + ld hl, wRTC + ld a, [CurDay] + ld [hli], a + ld a, [hHours] + ld [hli], a + ld a, [hMinutes] + ld [hli], a + ld a, [hSeconds] + ld [hli], a + ret +; 1406a + +SaveRTC: ; 1406a + ld a, $a + ld [MBC3SRamEnable], a + call LatchClock + ld hl, MBC3RTC + ld a, $c + ld [MBC3SRamBank], a + res 7, [hl] + ld a, BANK(sRTCStatusFlags) + ld [MBC3SRamBank], a + xor a + ld [sRTCStatusFlags], a + call CloseSRAM + ret +; 14089 + +StartClock:: ; 14089 + call GetClock + call Function1409b + call FixDays + jr nc, .skip_set + ; bit 5: Day count exceeds 139 + ; bit 6: Day count exceeds 255 + call RecordRTCStatus ; set flag on sRTCStatusFlags + +.skip_set + call StartRTC + ret +; 1409b + +Function1409b: ; 1409b + ld hl, hRTCDayHi + bit 7, [hl] + jr nz, .set_bit_7 + bit 6, [hl] + jr nz, .set_bit_7 + xor a + ret + +.set_bit_7 + ; Day count exceeds 16383 + ld a, %10000000 + call RecordRTCStatus ; set bit 7 on sRTCStatusFlags + ret +; 140ae + +Function140ae: ; 140ae + call CheckRTCStatus + ld c, a + and %11000000 ; Day count exceeded 255 or 16383 + jr nz, .time_overflow + + ld a, c + and %00100000 ; Day count exceeded 139 + jr z, .dont_update + + call UpdateTime + ld a, [wRTC + 0] + ld b, a + ld a, [CurDay] + cp b + jr c, .dont_update + +.time_overflow + callba ClearDailyTimers + callba Function170923 +; mobile + ld a, $5 + call GetSRAMBank + ld a, [$aa8c] + inc a + ld [$aa8c], a + ld a, [$b2fa] + inc a + ld [$b2fa], a + call CloseSRAM + ret + +.dont_update + xor a + ret +; 140ed + +Function140ed:: ; 140ed + call GetClock + call FixDays + ld hl, hRTCSeconds + ld de, StartSecond + + ld a, [StringBuffer2 + 3] + sub [hl] + dec hl + jr nc, .okay_secs + add 60 +.okay_secs + ld [de], a + dec de + + ld a, [StringBuffer2 + 2] + sbc [hl] + dec hl + jr nc, .okay_mins + add 60 +.okay_mins + ld [de], a + dec de + + ld a, [StringBuffer2 + 1] + sbc [hl] + dec hl + jr nc, .okay_hrs + add 24 +.okay_hrs + ld [de], a + dec de + + ld a, [StringBuffer2] + sbc [hl] + dec hl + jr nc, .okay_days + add 140 + ld c, 7 + call SimpleDivide + +.okay_days + ld [de], a + ret +; 1412a diff --git a/engine/save.asm b/engine/save.asm index 9fcba708a..65faabb7a 100644 --- a/engine/save.asm +++ b/engine/save.asm @@ -213,7 +213,7 @@ SaveTheGame_yesorno: ; 14baf call LoadMenuTextBox lb bc, 0, 7 call PlaceYesNoBox - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call WriteBackup push af diff --git a/engine/scripting.asm b/engine/scripting.asm index d85cabe05..83d4e8a04 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -160,8 +160,8 @@ ENDC dw Script_buttonsound ; 55 dw Script_pokepic ; 56 dw Script_closepokepic ; 57 - dw Script_interpretmenu ; 58 - dw Script_interpretmenu2 ; 59 + dw Script__2dmenu ; 58 + dw Script_verticalmenu ; 59 dw Script_loadpikachudata ; 5a dw Script_randomwildmon ; 5b dw Script_loadmemtrainer ; 5c @@ -510,13 +510,13 @@ Script_closepokepic: ; 96f29 ret ; 96f30 -Script_interpretmenu2: ; 96f30 +Script_verticalmenu: ; 96f30 ; script command 0x59 ld a, [ScriptBank] - ld hl, InterpretMenu2 + ld hl, VerticalMenu rst FarCall - ld a, [MenuSelection2] + ld a, [wMenuCursorY] jr nc, .ok xor a .ok @@ -524,11 +524,11 @@ Script_interpretmenu2: ; 96f30 ret ; 96f41 -Script_interpretmenu: ; 96f41 +Script__2dmenu: ; 96f41 ; script command 0x58 ld a, [ScriptBank] - ld hl, InterpretMenu + ld hl, _2DMenu rst FarCall ld a, [wMenuCursorBuffer] jr nc, .ok diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index b5fceb0b6..91d8b3035 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -1714,10 +1714,10 @@ Slots_AskBet: ; 9307c (24:707c) call PrintText ld hl, .MenuDataHeader call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call WriteBackup ret c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, 4 sub b @@ -1803,7 +1803,7 @@ Slots_AskPlayAgain: ; 930e9 (24:70e9) call LoadMenuTextBox lb bc, 14, 12 call PlaceYesNoBox - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call WriteBackup and a diff --git a/engine/sprite_anims.asm b/engine/sprite_anims.asm index 54af5db37..79faa7606 100755 --- a/engine/sprite_anims.asm +++ b/engine/sprite_anims.asm @@ -57,7 +57,7 @@ endr ret .one: ; 8d2a2 (23:52a2) - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld hl, SPRITEANIMSTRUCT_INDEX add hl, bc @@ -116,7 +116,7 @@ endr ret .three: ; 8d2ea (23:52ea) - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld hl, SPRITEANIMSTRUCT_INDEX add hl, bc diff --git a/engine/startmenu.asm b/engine/startmenu.asm index b9f5462d7..546aff1d9 100755 --- a/engine/startmenu.asm +++ b/engine/startmenu.asm @@ -93,7 +93,7 @@ endr .loop call .PrintMenuAccount call Function1f1a - ld a, [wcf73] + ld a, [wMenuJoypad] cp B_BUTTON jr z, .b cp A_BUTTON @@ -799,7 +799,7 @@ GiveTakePartyMonItem: ; 12b60 ld hl, GiveTakeItemMenuData call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu jr c, .cancel @@ -808,7 +808,7 @@ GiveTakePartyMonItem: ; 12b60 ld de, wd050_MonNick ld bc, PKMN_NAME_LENGTH call CopyBytes - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp 1 jr nz, .take @@ -1109,12 +1109,12 @@ MonMailAction: ; 12d45 ; Show the READ/TAKE/QUIT menu. ld hl, .MenuDataHeader call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu ; Interpret the menu. jp c, .done - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .read cp $2 @@ -1483,7 +1483,7 @@ ChooseMoveToDelete: ; 12f5b jr .asm_12f93 .asm_12f86: ; 12f86 - call Function1bd3 + call ScrollingMenuJoypad bit 1, a jp nz, .asm_12f9f bit 0, a @@ -1551,7 +1551,7 @@ MoveScreenLoop: ; 12fd5 jr .skip_joy .joy_loop - call Function1bd3 + call ScrollingMenuJoypad bit 1, a jp nz, .b_button bit 0, a @@ -1589,7 +1589,7 @@ MoveScreenLoop: ; 12fd5 jp z, .exit ld a, [wMoveSwapBuffer] - ld [MenuSelection2], a + ld [wMenuCursorY], a xor a ld [wMoveSwapBuffer], a hlcoord 1, 2 @@ -1669,7 +1669,7 @@ MoveScreenLoop: ; 12fd5 ld a, [wMoveSwapBuffer] and a jr nz, .place_move - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wMoveSwapBuffer], a call Function1bee jp .moving_move @@ -1716,7 +1716,7 @@ MoveScreenLoop: ; 12fd5 .copy_move: ; 1313a push hl - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, $0 @@ -1834,7 +1834,7 @@ PrepareToPlaceMoveData: ; 13235 ld bc, PARTYMON_STRUCT_LENGTH ld a, [CurPartyMon] call AddNTimes - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, $0 diff --git a/engine/stats_screen.asm b/engine/stats_screen.asm index 84e1cf9ea..fe5b4664b 100755 --- a/engine/stats_screen.asm +++ b/engine/stats_screen.asm @@ -253,10 +253,10 @@ Function4de2c: ; 4de2c (13:5e2c) pop bc pop de pop hl - ld a, [wcf73] + ld a, [wMenuJoypad] and $c0 jr nz, .set_carry - ld a, [wcf73] + ld a, [wMenuJoypad] jr .clear_flags .notbreedmon diff --git a/engine/std_scripts.asm b/engine/std_scripts.asm index f0fae969b..c7e368c7c 100644 --- a/engine/std_scripts.asm +++ b/engine/std_scripts.asm @@ -1811,7 +1811,7 @@ CoinVendor_IntroScript: ; 0xbcde0 CoinVendor_SellCoinsMenuScript: ; 0xbcde4 special Special_DisplayMoneyAndCoinBalance loadmenudata CoinVendor_MenuDataHeader - interpretmenu2 + verticalmenu writebackup if_equal $1, CoinVendor_Buy50CoinsScript if_equal $2, CoinVendor_Buy500CoinsScript diff --git a/engine/tile_events.asm b/engine/tile_events.asm new file mode 100755 index 000000000..8a6f2bc66 --- /dev/null +++ b/engine/tile_events.asm @@ -0,0 +1,110 @@ +CheckWarpCollision:: ; 1499a +; Is this tile a warp? + ld a, [PlayerNextTile] + cp $60 + jr z, .warp + cp $68 + jr z, .warp + and $f0 + cp $70 + jr z, .warp + and a + ret + +.warp + scf + ret +; 149af + +CheckDirectionalWarp:: ; 149af +; If this is a directional warp, clear carry (press the designated button to warp). +; Else, set carry (immediate warp). + ld a, [PlayerNextTile] + cp $70 ; Warp on down + jr z, .not_warp + cp $76 ; Warp on left + jr z, .not_warp + cp $78 ; Warp on up + jr z, .not_warp + cp $7e ; Warp on right + jr z, .not_warp + scf + ret + +.not_warp + xor a + ret +; 149c6 + +CheckWarpFacingDown: ; 149c6 + ld de, 1 + ld hl, .blocks + ld a, [PlayerNextTile] + call IsInArray + ret +; 149d3 + +.blocks: ; 149d3 + db $71 ; door + db $79 + db $7a ; stairs + db $73 + db $7b ; cave entrance + db $74 + db $7c ; warp pad + db $75 + db $7d + db -1 +; 149dd + +CheckGrassCollision:: ; 149dd + ld a, [PlayerNextTile] + ld hl, .blocks + ld de, 1 + call IsInArray + ret +; 149ea + +.blocks: ; 149ea + db $08 + db $18 ; tall grass + db $14 ; tall grass + db $28 + db $29 + db $48 + db $49 + db $4a + db $4b + db $4c + db -1 +; 149f5 + +CheckCutCollision: ; 149f5 + ld a, c + ld hl, .blocks + ld de, 1 + call IsInArray + ret +; 14a00 + +.blocks: ; 14a00 + db $12 ; cut tree + db $1a ; cut tree + db $10 ; tall grass + db $18 ; tall grass + db $14 ; tall grass + db $1c ; tall grass + db -1 +; 14a07 + +Function14a07:: ; 14a07 + ld a, [PlayerNextTile] + ld de, $1f + cp $71 ; door + ret z + ld de, $13 + cp $7c ; warp pad + ret z + ld de, $23 + ret +; 14a1a diff --git a/engine/tmhm2.asm b/engine/tmhm2.asm index d9e05fb8c..9834fba7f 100755 --- a/engine/tmhm2.asm +++ b/engine/tmhm2.asm @@ -220,16 +220,16 @@ TMHM_PocketLoop: ; 2c8d3 (b:48d3) ld [wcfa8], a ld a, [wTMHMPocketCursor] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a jr TMHM_ShowTMMoveDescription TMHM_JoypadLoop: ; 2c915 (b:4915) call TMHM_DisplayPocketItems - call Function1bc9 + call StaticMenuJoypad ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [wTMHMPocketCursor], a xor a @@ -268,7 +268,7 @@ TMHM_ShowTMMoveDescription: ; 2c946 (b:4946) TMHM_ChooseTMorHM: ; 2c974 (b:4974) call TMHM_PlaySFX_ReadText2 call CountTMsHMs ; This stores the count to wd265. - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld b, a ld a, [wTMHMPocketScrollPosition] @@ -279,7 +279,7 @@ TMHM_ChooseTMorHM: ; 2c974 (b:4974) jr z, _TMHM_ExitPack ; our cursor was hovering over CANCEL TMHM_CheckHoveringOverCancel: ; 2c98a (b:498a) call TMHM_GetCurrentPocketPosition - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a .loop inc c diff --git a/event/buena.asm b/event/buena.asm index 76a378549..ddc78b016 100644 --- a/event/buena.asm +++ b/event/buena.asm @@ -255,9 +255,9 @@ Function8b0e2: ; 8b0e2 call HandleScrollingMenu ld a, [MenuSelection] ld c, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [MenuSelection], a - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .asm_8b111 ld a, c diff --git a/event/elevator.asm b/event/elevator.asm index 0aa5c1f05..68d8fbe5b 100755 --- a/event/elevator.asm +++ b/event/elevator.asm @@ -133,7 +133,7 @@ Function134dd: ; 134dd ld [wMenuScrollPosition], a call HandleScrollingMenu call WriteBackup - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .asm_1350b xor a diff --git a/event/kurt.asm b/event/kurt.asm index bb24f26ab..f7a3f3a55 100644 --- a/event/kurt.asm +++ b/event/kurt.asm @@ -40,7 +40,7 @@ Special_SelectApricornForKurt: ; 88018 and a jr z, .done ld [CurItem], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld c, a push bc call Kurt_PrintTextHowMany @@ -68,7 +68,7 @@ Kurt_SelectApricorn: ; 88055 call InitScrollingMenu call UpdateSprites call HandleScrollingMenu - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .nope ld a, [MenuSelection] diff --git a/event/mom.asm b/event/mom.asm index 61d374de9..8be55b6c6 100644 --- a/event/mom.asm +++ b/event/mom.asm @@ -106,10 +106,10 @@ endr call LoadStandardMenuDataHeader ld hl, MenuDataHeader_0x166b5 call CopyMenuDataHeader - call InterpretMenu2 + call VerticalMenu call WriteBackup jr c, .cancel - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .withdraw cp $2 diff --git a/event/move_deleter.asm b/event/move_deleter.asm index 44226cca8..8c4d954ab 100644 --- a/event/move_deleter.asm +++ b/event/move_deleter.asm @@ -25,7 +25,7 @@ MoveDeletion: call Function2b74 pop af jr c, .asm_2c5c3 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af ld a, [CurSpecies] ld [wd265], a diff --git a/home.asm b/home.asm index c1e944c39..e5b24fe6a 100644 --- a/home.asm +++ b/home.asm @@ -1161,7 +1161,7 @@ HandleScrollingMenu:: ; 350c pop af rst Bankswitch - ld a, [wcf73] + ld a, [wMenuJoypad] ret ; 3524 diff --git a/home/handshake.asm b/home/handshake.asm index 5c7664144..e53e78a5b 100644 --- a/home/handshake.asm +++ b/home/handshake.asm @@ -1,3 +1,16 @@ +PrinterReceive:: ; 2057 + ld a, [hROMBank] + push af + ld a, BANK(_PrinterReceive) + rst Bankswitch + + call _PrinterReceive + pop af + rst Bankswitch + + ret +; 2063 + AskSerial:: ; 2063 ; send out a handshake while serial int is off ld a, [wc2d4] diff --git a/home/menu.asm b/home/menu.asm index 26ac505e6..bfe0d1e62 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -72,25 +72,26 @@ Call_ExitMenu:: ; 1d7d ret ; 1d81 -InterpretMenu2:: +VerticalMenu:: xor a ld [hBGMapMode], a call MenuBox call UpdateSprites - call Function1c89 + call PlaceVerticalMenuItems call ApplyTilemap call CopyMenuData2 ld a, [wMenuData2Flags] bit 7, a jr z, .cancel - call Function1c10 - call Function1bc9 - call Function1ff8 + call InitVerticalMenuCursor + call StaticMenuJoypad + call MenuClickSound bit 1, a jr z, .okay .cancel scf ret + .okay and a ret @@ -98,9 +99,9 @@ InterpretMenu2:: GetMenu2:: ; 1dab call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call WriteBackup - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ret ; 1db8 @@ -162,14 +163,14 @@ _YesNoBox:: ; 1dd9 call BackUpTiles InterpretTwoOptionMenu:: ; 1dfe - call InterpretMenu2 + call VerticalMenu push af ld c, $f call DelayFrames call WriteBackup pop af jr c, .no - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp 2 ; no jr z, .no and a @@ -177,7 +178,7 @@ InterpretTwoOptionMenu:: ; 1dfe .no ld a, 2 - ld [MenuSelection2], a + ld [wMenuCursorY], a scf ret ; 1e1d @@ -233,8 +234,8 @@ DoNthMenu:: ; 1e5d call MenuWriteText call Function1eff call Function1f23 - call Function1bdd - call Function1ff8 + call GetMenuJoypad + call MenuClickSound ret ; 1e70 @@ -341,7 +342,7 @@ Function1efb:: ; 1efb ; 1eff Function1eff:: ; 1eff - call Function1c10 + call InitVerticalMenuCursor ld hl, wcfa8 ld a, [wMenuData2Flags] bit 3, a @@ -361,7 +362,7 @@ Function1eff:: ; 1eff Function1f1a:: ; 1f1a - call Function1bd3 + call ScrollingMenuJoypad ld hl, wcfa8 and [hl] jr Function1f2a @@ -369,8 +370,8 @@ Function1f1a:: ; 1f1a Function1f23:: ; 1f23 xor a - ld [wcf73], a - call Function1bc9 + ld [wMenuJoypad], a + call StaticMenuJoypad ; 1f2a Function1f2a:: ; 1f2a @@ -385,39 +386,39 @@ Function1f2a:: ; 1f2a bit 5, a jr nz, .asm_1f4b xor a - ld [wcf73], a + ld [wMenuJoypad], a jr .asm_1f57 .asm_1f44 ld a, $10 - ld [wcf73], a + ld [wMenuJoypad], a jr .asm_1f57 .asm_1f4b ld a, $20 - ld [wcf73], a + ld [wMenuJoypad], a jr .asm_1f57 .asm_1f52 ld a, $1 - ld [wcf73], a + ld [wMenuJoypad], a .asm_1f57 call Function1ebd - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld l, a ld h, $0 add hl, de ld a, [hl] ld [MenuSelection], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wMenuCursorBuffer], a and a ret .asm_1f6d ld a, $2 - ld [wcf73], a + ld [wMenuJoypad], a ld a, $ff ld [MenuSelection], a scf @@ -489,7 +490,7 @@ endr ; 1fbf ResetTextRelatedRAM:: ; 1fbf - ld hl, wcf71 + ld hl, wWindowStackPointer call .bytefill ld hl, wMenuDataHeader call .bytefill @@ -504,14 +505,14 @@ ResetTextRelatedRAM:: ; 1fbf ld [rSVBK], a xor a - ld hl, w7_dfff + ld hl, wWindowStackBottom rept 2 ld [hld], a endr ld a, l - ld [wcf71], a + ld [wWindowStackPointer], a ld a, h - ld [wcf72], a + ld [wWindowStackPointer + 1], a pop af ld [rSVBK], a @@ -525,15 +526,14 @@ endr ret ; 1ff8 -Function1ff8:: ; 1ff8 +MenuClickSound:: ; 1ff8 push af - and $3 + and A_BUTTON | B_BUTTON jr z, .nosound ld hl, wMenuFlags bit 3, [hl] jr nz, .nosound call PlayClickSFX - .nosound pop af ret @@ -555,7 +555,7 @@ MenuTextBoxWaitButton:: ; 2012 ret ; 201c -Function201c:: ; 201c +Place2DMenuItemName:: ; 201c ld [hBuffer], a ld a, [hROMBank] push af @@ -569,39 +569,26 @@ Function201c:: ; 201c ret ; 202a -InterpretMenu:: ; 202a +_2DMenu:: ; 202a ld a, [hROMBank] - ld [wcf94], a - callba Function2400e + ld [wMenuData2_2DMenuItemStringsBank], a + callba _2DMenu_ ld a, [wMenuCursorBuffer] ret ; 2039 -Function2039:: ; 2039 +InterpretBattleMenu:: ; 2039 ld a, [hROMBank] - ld [wcf94], a - callba Function24022 + ld [wMenuData2_2DMenuItemStringsBank], a + callba _InterpretBattleMenu ld a, [wMenuCursorBuffer] ret ; 2048 -Function2048:: ; 2048 +InterpretMobileMenu:: ; 2048 ld a, [hROMBank] - ld [wcf94], a - callba Function2403c + ld [wMenuData2_2DMenuItemStringsBank], a + callba _InterpretMobileMenu ld a, [wMenuCursorBuffer] ret ; 2057 - -Function2057:: ; 2057 - ld a, [hROMBank] - push af - ld a, BANK(Function842db) - rst Bankswitch - - call Function842db - pop af - rst Bankswitch - - ret -; 2063 diff --git a/home/mobile.asm b/home/mobile.asm index f8e45472e..de95cb2d7 100644 --- a/home/mobile.asm +++ b/home/mobile.asm @@ -51,14 +51,14 @@ Function3e60:: ; 3e60 ret ; 3e80 -Function3e80:: ; 3e80 +MobileReceive:: ; 3e80 ld a, [hROMBank] push af - ld a, BANK(Function1116c5) + ld a, BANK(_MobileReceive) ld [$c981], a rst Bankswitch - call Function1116c5 + call _MobileReceive pop bc ld a, b ld [$c981], a diff --git a/home/movement.asm b/home/movement.asm index 7de5e0432..427c42cd9 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -160,19 +160,19 @@ endr ret ; 1bc9 -Function1bc9:: ; 1bc9 - callab Function241a8 - call Function1bdd +StaticMenuJoypad:: ; 1bc9 + callab _StaticMenuJoypad + call GetMenuJoypad ret ; 1bd3 -Function1bd3:: ; 1bd3 - callab Function241ab - call Function1bdd +ScrollingMenuJoypad:: ; 1bd3 + callab _ScrollingMenuJoypad + call GetMenuJoypad ret ; 1bdd -Function1bdd:: ; 1bdd +GetMenuJoypad:: ; 1bdd push bc push af ld a, [hJoyLast] @@ -189,20 +189,20 @@ Function1bdd:: ; 1bdd ; 1bee Function1bee:: ; 1bee - ld hl, wcfac + ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] ld l, a - ld [hl], $ec + ld [hl], "▷" ret ; 1bf7 Function1bf7:: ; 1bf7 - ld hl, wcfac + ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] ld l, a - ld [hl], $7f + ld [hl], " " ret ; 1c00 diff --git a/home/serial.asm b/home/serial.asm index dceb3dcfc..b710a3204 100644 --- a/home/serial.asm +++ b/home/serial.asm @@ -6,17 +6,17 @@ Serial:: ; 6ef push de push hl - ld a, [hFFC9] + ld a, [hMobileReceive] and a - jr nz, .asm_71c + jr nz, .mobile ld a, [wc2d4] bit 0, a - jr nz, .asm_721 + jr nz, .printer ld a, [hLinkPlayerNumber] inc a ; is it equal to -1? - jr z, .asm_726 + jr z, .init_player_number ld a, [rSB] ld [hSerialReceive], a @@ -26,62 +26,62 @@ Serial:: ; 6ef ld a, [hLinkPlayerNumber] cp $2 - jr z, .asm_752 + jr z, .player2 ld a, 0 << rSC_ON ld [rSC], a ld a, 1 << rSC_ON ld [rSC], a - jr .asm_752 + jr .player2 -.asm_71c - call Function3e80 - jr .asm_75a +.mobile + call MobileReceive + jr .end -.asm_721 - call Function2057 - jr .asm_75a +.printer + call PrinterReceive + jr .end -.asm_726 +.init_player_number ld a, [rSB] cp $1 - jr z, .asm_730 + jr z, .player1 cp $2 - jr nz, .asm_752 + jr nz, .player2 -.asm_730 +.player1 ld [hSerialReceive], a ld [hLinkPlayerNumber], a cp $2 - jr z, .asm_74f + jr z, ._player2 xor a ld [rSB], a ld a, $3 ld [rDIV], a -.asm_73f +.wait_bit_7 ld a, [rDIV] bit 7, a - jr nz, .asm_73f + jr nz, .wait_bit_7 ld a, 0 << rSC_ON ld [rSC], a ld a, 1 << rSC_ON ld [rSC], a - jr .asm_752 + jr .player2 -.asm_74f +._player2 xor a ld [rSB], a -.asm_752 +.player2 ld a, $1 ld [hFFCA], a - ld a, $fe + ld a, -2 ld [hSerialSend], a -.asm_75a +.end pop hl pop de pop bc diff --git a/home/tilemap.asm b/home/tilemap.asm index 74ec17cee..a27c74cde 100644 --- a/home/tilemap.asm +++ b/home/tilemap.asm @@ -5,12 +5,12 @@ BackUpTiles:: ; 1c00 ExitMenu:: ; 0x1c07 push af - callab Function243e8 + callab _ExitMenu pop af ret -Function1c10:: ; 0x1c10 - callab Function2446d +InitVerticalMenuCursor:: ; 0x1c10 + callab _InitVerticalMenuCursor ret WriteBackup:: ; 0x1c17 @@ -54,7 +54,7 @@ RestoreTileBackup:: ; 0x1c23 ret -Function1c47:: ; 0x1c47 +PopWindow:: ; 0x1c47 ld b, $10 ld de, wMenuFlags .loop @@ -98,8 +98,8 @@ CopyMenuData2:: ; 1c66 ret ; 1c7e -Function1c7e:: ; 1c7e - ld hl, wcf71 +GetWindowStackTop:: ; 1c7e + ld hl, wWindowStackPointer ld a, [hli] ld h, [hl] ld l, a @@ -110,7 +110,7 @@ Function1c7e:: ; 1c7e ret ; 1c89 -Function1c89:: ; 1c89 +PlaceVerticalMenuItems:: ; 1c89 call CopyMenuData2 ld hl, wMenuData2Pointer ld e, [hl] @@ -131,6 +131,7 @@ Function1c89:: ; 1c89 pop bc dec b jr nz, .loop + ld a, [wMenuData2Flags] bit 4, a ret z diff --git a/hram.asm b/hram.asm index 63409acfb..772de0090 100644 --- a/hram.asm +++ b/hram.asm @@ -77,7 +77,7 @@ hMoneyTemp EQU $ffc3 hLCDStatCustom EQU $ffc6 -hFFC9 EQU $ffc9 +hMobileReceive EQU $ffc9 hFFCA EQU $ffca hLinkPlayerNumber EQU $ffcb hFFCC EQU $ffcc diff --git a/items/item_effects.asm b/items/item_effects.asm index bb4d7c1c6..bea79d359 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -2667,7 +2667,7 @@ Not_PP_Up: ; f6a7 Elixer_RestorePPofAllMoves: ; f6af xor a - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld [hli], a ld [hl], a ld b, NUM_MOVES @@ -2682,16 +2682,16 @@ Elixer_RestorePPofAllMoves: ; f6af call RestorePP jr z, .next - ld hl, wcfaa + ld hl, wMenuCursorX inc [hl] .next - ld hl, MenuSelection2 + ld hl, wMenuCursorY inc [hl] pop bc dec b jr nz, .moveLoop - ld a, [wcfaa] + ld a, [wMenuCursorX] and a jp nz, BattleRestorePP @@ -3120,7 +3120,7 @@ ApplyPPUp: ; f84c ld a, [wd265] dec a jr nz, .use - ld a, [MenuSelection2] + ld a, [wMenuCursorY] inc a cp b jr nz, .skip @@ -3197,7 +3197,7 @@ RestoreAllPP: ; f8b9 call GetPartyParamLocation pop de xor a ; PARTYMON - ld [MenuSelection2], a + ld [wMenuCursorY], a ld [MonType], a ld c, NUM_MOVES .loop @@ -3217,7 +3217,7 @@ RestoreAllPP: ; f8b9 add b ld [de], a inc de - ld hl, MenuSelection2 + ld hl, wMenuCursorY inc [hl] pop hl dec c @@ -3310,7 +3310,7 @@ GetMthMoveOfNthPartymon: ; f963 call AddNTimes GetMthMoveOfCurrentMon: ; f969 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld c, a ld b, 0 add hl, bc diff --git a/lib/mobile/main.asm b/lib/mobile/main.asm index 2fb46295d..753a858a4 100644 --- a/lib/mobile/main.asm +++ b/lib/mobile/main.asm @@ -1,5 +1,7 @@ ; A library included as part of the Mobile Adapter GB SDK. +charmap "", $d + INCLUDE "gbhw.asm" SECTION "Main", ROMX @@ -608,7 +610,7 @@ Function11032c: ; 11032c ; 110393 Function110393: ; 110393 - ld c, $ff + ld c, rIE % $100 ld a, [$ff00+c] or $c ld [$ff00+c], a @@ -1971,87 +1973,87 @@ endr Function110d37: ; 110d37 push bc push de - ld b, $0 -.asm_110d3b - ld a, $27 + ld b, 0 +.check_under_10k + ld a, 10000 / $100 cp h - jr c, .asm_110d49 - jr nz, .asm_110d52 - ld a, $10 + jr c, .subtract_10k + jr nz, .done_10k + ld a, 10000 % $100 cp l - jr z, .asm_110d49 - jr nc, .asm_110d52 + jr z, .subtract_10k + jr nc, .done_10k -.asm_110d49 +.subtract_10k inc b ld a, b - ld bc, $d8f0 + ld bc, -10000 add hl, bc ld b, a - jr .asm_110d3b + jr .check_under_10k -.asm_110d52 +.done_10k ld a, $30 or b ld [de], a inc de - ld b, $0 -.asm_110d59 - ld a, $3 + ld b, 0 +.check_under_1k + ld a, 1000 / $100 cp h - jr c, .asm_110d67 - jr nz, .asm_110d70 - ld a, $e8 + jr c, .subtract_1k + jr nz, .done_1k + ld a, 1000 % $100 cp l - jr z, .asm_110d67 - jr nc, .asm_110d70 + jr z, .subtract_1k + jr nc, .done_1k -.asm_110d67 +.subtract_1k inc b ld a, b - ld bc, $fc18 + ld bc, -1000 add hl, bc ld b, a - jr .asm_110d59 + jr .check_under_1k -.asm_110d70 +.done_1k ld a, $30 or b ld [de], a inc de - ld b, $0 -.asm_110d77 - ld a, $0 + ld b, 0 +.check_under_100 + ld a, 100 / $100 cp h - jr nz, .asm_110d83 - ld a, $64 + jr nz, .subtract_100 + ld a, 100 % $100 cp l - jr z, .asm_110d83 - jr nc, .asm_110d8c + jr z, .subtract_100 + jr nc, .check_under_10 -.asm_110d83 +.subtract_100 inc b ld a, b - ld bc, $ff9c + ld bc, -100 add hl, bc ld b, a - jr .asm_110d77 + jr .check_under_100 -.asm_110d8c +.check_under_10 ld a, $30 or b ld [de], a inc de ld b, $0 ld a, l -.asm_110d94 - cp $a - jr c, .asm_110d9d - sub $a +.subtract_10 + cp 10 + jr c, .done_10 + sub 10 inc b - jr .asm_110d94 + jr .subtract_10 -.asm_110d9d +.done_10 ld l, a ld a, $30 or b @@ -2064,19 +2066,19 @@ Function110d37: ; 110d37 ld l, e ld h, d ld b, $5 -.asm_110dac +.find_first_digit ld a, [hl] cp $30 - jr nz, .asm_110db7 + jr nz, .found_first_digit inc hl dec b - jr nz, .asm_110dac - jr .asm_110dd5 + jr nz, .find_first_digit + jr .done -.asm_110db7 +.found_first_digit ld a, $5 cp b - jr z, .asm_110dd5 + jr z, .done sub b ld c, a ld a, [$cb4c] @@ -2085,23 +2087,23 @@ Function110d37: ; 110d37 ld [$cb4c], a push hl ld b, $1 -.asm_110dc9 +.penultimate_loop inc b ld a, [hli] cp $d - jr nz, .asm_110dc9 + jr nz, .penultimate_loop pop hl call Function110000 pop hl ret -.asm_110dd5 +.done pop bc -.asm_110dd6 +.last_loop ld a, [de] inc de cp $a - jr nz, .asm_110dd6 + jr nz, .last_loop ret ; 110ddd @@ -3530,7 +3532,7 @@ Function1116a9: ; 1116a9 ret ; 1116c5 -Function1116c5:: ; 1116c5 (44:56c5) +_MobileReceive:: ; 1116c5 (44:56c5) ld a, [$c800] rrca jp nc, Function1118bc @@ -3636,7 +3638,6 @@ endr .asm_111778 xor a ld [$c800], a - Function11177c: ; 11177c (44:577c) ld hl, $c820 ld a, [hld] @@ -3835,7 +3836,6 @@ Function111892: ; 111892 (44:5892) xor a ld [hli], a inc [hl] - Function1118bc: ; 1118bc (44:58bc) ld hl, $c822 res 1, [hl] @@ -4974,31 +4974,31 @@ Unknown_1120a4: Unknown_1120b0: db "RCPT TO:<", 0 Unknown_1120ba: - db "DATA", $d, "\n", 0 + db "DATA\n", 0 Unknown_1120c1: - db "QUIT", $d, "\n", 0 + db "QUIT\n", 0 Unknown_1120c8: db "USER ", 0 Unknown_1120ce: db "PASS ", 0 Unknown_1120d4: - db "STAT", $d, "\n", 0 + db "STAT\n", 0 Unknown_1120db: - db "LIST 00000", $d, "\n", 0 + db "LIST 00000\n", 0 Unknown_1120e8: - db "RETR 00000", $d, "\n", 0 + db "RETR 00000\n", 0 Unknown_1120f5: - db "DELE 00000", $d, "\n", 0 + db "DELE 00000\n", 0 Unknown_112102: - db "TOP 00000 0", $d, "\n", 0 + db "TOP 00000 0\n", 0 Unknown_112110: db "GET ", 0 Unknown_112115: - db " HTTP/1.0", $d, "\n", 0 + db " HTTP/1.0\n", 0 Unknown_112121: db "User-Agent: CGB-", 0 Unknown_112132: - db $d, "\n", $d, "\n", 0 + db "\n\n", 0 Unknown_112137: db "POST ", 0 Unknown_11213d: diff --git a/macros/event.asm b/macros/event.asm index 8bb031e8c..2f4beadfc 100644 --- a/macros/event.asm +++ b/macros/event.asm @@ -574,14 +574,14 @@ closepokepic: macro db closepokepic_command endm - enum interpretmenu_command -interpretmenu: macro - db interpretmenu_command + enum _2dmenu_command +_2dmenu: macro + db _2dmenu_command endm - enum interpretmenu2_command -interpretmenu2: macro - db interpretmenu2_command + enum verticalmenu_command +verticalmenu: macro + db verticalmenu_command endm enum loadpikachudata_command diff --git a/main.asm b/main.asm index 5d5f4f3d9..e2dd7f213 100644 --- a/main.asm +++ b/main.asm @@ -5796,7 +5796,7 @@ Functiondcb6: ; dcb6 pop hl pop de - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af ld a, [MonType] push af @@ -5809,7 +5809,7 @@ Functiondcb6: ; dcb6 ld a, BOXMON ld [MonType], a ld a, b - ld [MenuSelection2], a + ld [wMenuCursorY], a push bc push hl push de @@ -5833,7 +5833,7 @@ Functiondcb6: ; dcb6 pop af ld [MonType], a pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ret ; dd21 @@ -7558,7 +7558,7 @@ BugCatchingContestBattleScript:: ; 0x135eb BugCatchingContestOverScript:: ; 0x135f8 playsound SFX_ELEVATOR_END opentext - writetext UnknownText_0x1360f + writetext BugCatchingContestText_BeeepTimesUp waitbutton jump BugCatchingContestReturnToGateScript ; 0x13603 @@ -7566,7 +7566,7 @@ BugCatchingContestOverScript:: ; 0x135f8 BugCatchingContestOutOfBallsScript: ; 0x13603 playsound SFX_ELEVATOR_END opentext - writetext UnknownText_0x13614 + writetext BugCatchingContestText_ContestIsOver waitbutton BugCatchingContestReturnToGateScript: ; 0x1360b @@ -7574,13 +7574,13 @@ BugCatchingContestReturnToGateScript: ; 0x1360b jumpstd bugcontestresultswarp ; 0x1360f -UnknownText_0x1360f: ; 0x1360f +BugCatchingContestText_BeeepTimesUp: ; 0x1360f ; ANNOUNCER: BEEEP! Time's up! text_jump UnknownText_0x1bd2ca db "@" ; 0x13614 -UnknownText_0x13614: ; 0x13614 +BugCatchingContestText_ContestIsOver: ; 0x13614 ; ANNOUNCER: The Contest is over! text_jump UnknownText_0x1bd2e7 db "@" @@ -7679,7 +7679,7 @@ CheckFacingTileForStd:: ; 1365b dbw $97, tv dbw $9d, window dbw $9f, incenseburner - db $ff ; end + db -1 ; end ; 1369a Script_JumpStdFromRAM: ; 0x1369a @@ -7756,350 +7756,19 @@ root set root+1 SECTION "bank5", ROMX, BANK[$5] -StopRTC: ; Unreferenced??? - ld a, SRAM_ENABLE - ld [MBC3SRamEnable], a - call LatchClock - ld a, RTC_DH - ld [MBC3SRamBank], a - ld a, [MBC3RTC] - set 6, a ; halt - ld [MBC3RTC], a - call CloseSRAM - ret -; 14019 - -StartRTC: ; 14019 - ld a, SRAM_ENABLE - ld [MBC3SRamEnable], a - call LatchClock - ld a, RTC_DH - ld [MBC3SRamBank], a - ld a, [MBC3RTC] - res 6, a ; halt - ld [MBC3RTC], a - call CloseSRAM - ret -; 14032 - -GetTimeOfDay:: ; 14032 -; get time of day based on the current hour - ld a, [hHours] ; hour - ld hl, TimesOfDay - -.check -; if we're within the given time period, -; get the corresponding time of day - cp [hl] - jr c, .match -; else, get the next entry -rept 2 - inc hl -endr -; try again - jr .check - -.match -; get time of day - inc hl - ld a, [hl] - ld [TimeOfDay], a - ret -; 14044 - -TimesOfDay: ; 14044 -; hours for the time of day -; 04-09 morn | 10-17 day | 18-03 nite - db 04, NITE - db 10, MORN - db 18, DAY - db 24, NITE - db -1, MORN -; 1404e - -Unknown_1404e: ; Unreferenced - db 20, 2 - db 40, 0 - db 60, 1 - db -1, 0 -; 14056 - -StageRTCTimeForSave: ; 14056 - call UpdateTime - ld hl, wRTC - ld a, [CurDay] - ld [hli], a - ld a, [hHours] - ld [hli], a - ld a, [hMinutes] - ld [hli], a - ld a, [hSeconds] - ld [hli], a - ret -; 1406a - -SaveRTC: ; 1406a - ld a, $a - ld [MBC3SRamEnable], a - call LatchClock - ld hl, MBC3RTC - ld a, $c - ld [MBC3SRamBank], a - res 7, [hl] - ld a, BANK(sRTCStatusFlags) - ld [MBC3SRamBank], a - xor a - ld [sRTCStatusFlags], a - call CloseSRAM - ret -; 14089 - -StartClock:: ; 14089 - call GetClock - call Function1409b - call FixDays - jr nc, .skip_set - ; bit 5: Day count exceeds 139 - ; bit 6: Day count exceeds 255 - call RecordRTCStatus ; set flag on sRTCStatusFlags - -.skip_set - call StartRTC - ret -; 1409b - -Function1409b: ; 1409b - ld hl, hRTCDayHi - bit 7, [hl] - jr nz, .set_bit_7 - bit 6, [hl] - jr nz, .set_bit_7 - xor a - ret - -.set_bit_7 - ; Day count exceeds 16383 - ld a, %10000000 - call RecordRTCStatus ; set bit 7 on sRTCStatusFlags - ret -; 140ae - -Function140ae: ; 140ae - call CheckRTCStatus - ld c, a - and %11000000 ; Day count exceeded 255 or 16383 - jr nz, .time_overflow - - ld a, c - and %00100000 ; Day count exceeded 139 - jr z, .dont_update - - call UpdateTime - ld a, [wRTC + 0] - ld b, a - ld a, [CurDay] - cp b - jr c, .dont_update - -.time_overflow - callba ClearDailyTimers - callba Function170923 -; mobile - ld a, $5 - call GetSRAMBank - ld a, [$aa8c] - inc a - ld [$aa8c], a - ld a, [$b2fa] - inc a - ld [$b2fa], a - call CloseSRAM - ret - -.dont_update - xor a - ret -; 140ed - -Function140ed:: ; 140ed - call GetClock - call FixDays - ld hl, hRTCSeconds - ld de, StartSecond - - ld a, [StringBuffer2 + 3] - sub [hl] - dec hl - jr nc, .okay_secs - add 60 -.okay_secs - ld [de], a - dec de - - ld a, [StringBuffer2 + 2] - sbc [hl] - dec hl - jr nc, .okay_mins - add 60 -.okay_mins - ld [de], a - dec de - - ld a, [StringBuffer2 + 1] - sbc [hl] - dec hl - jr nc, .okay_hrs - add 24 -.okay_hrs - ld [de], a - dec de - - ld a, [StringBuffer2] - sbc [hl] - dec hl - jr nc, .okay_days - add 140 - ld c, 7 - call SimpleDivide - -.okay_days - ld [de], a - ret -; 1412a - +INCLUDE "engine/rtc.asm" INCLUDE "engine/overworld.asm" - -CheckWarpCollision:: ; 1499a -; Is this tile a warp? - ld a, [PlayerNextTile] - cp $60 - jr z, .warp - cp $68 - jr z, .warp - and $f0 - cp $70 - jr z, .warp - and a - ret - -.warp - scf - ret -; 149af - -CheckDirectionalWarp:: ; 149af -; If this is a directional warp, clear carry (press the designated button to warp). -; Else, set carry (immediate warp). - ld a, [PlayerNextTile] - cp $70 ; Warp on down - jr z, .not_warp - cp $76 ; Warp on left - jr z, .not_warp - cp $78 ; Warp on up - jr z, .not_warp - cp $7e ; Warp on right - jr z, .not_warp - scf - ret - -.not_warp - xor a - ret -; 149c6 - -CheckWarpFacingDown: ; 149c6 - ld de, 1 - ld hl, .blocks - ld a, [PlayerNextTile] - call IsInArray - ret -; 149d3 - -.blocks: ; 149d3 - db $71 ; door - db $79 - db $7a ; stairs - db $73 - db $7b ; cave entrance - db $74 - db $7c ; warp pad - db $75 - db $7d - db -1 -; 149dd - -CheckGrassCollision:: ; 149dd - ld a, [PlayerNextTile] - ld hl, .blocks - ld de, 1 - call IsInArray - ret -; 149ea - -.blocks: ; 149ea - db $08 - db $18 ; tall grass - db $14 ; tall grass - db $28 - db $29 - db $48 - db $49 - db $4a - db $4b - db $4c - db -1 -; 149f5 - -CheckCutCollision: ; 149f5 - ld a, c - ld hl, .blocks - ld de, 1 - call IsInArray - ret -; 14a00 - -.blocks: ; 14a00 - db $12 ; cut tree - db $1a ; cut tree - db $10 ; tall grass - db $18 ; tall grass - db $14 ; tall grass - db $1c ; tall grass - db -1 -; 14a07 - -Function14a07:: ; 14a07 - ld a, [PlayerNextTile] - ld de, $1f - cp $71 ; door - ret z - ld de, $13 - cp $7c ; warp pad - ret z - ld de, $23 - ret -; 14a1a - +INCLUDE "engine/tile_events.asm" INCLUDE "engine/save.asm" - INCLUDE "engine/spawn_points.asm" - INCLUDE "engine/map_setup.asm" - INCLUDE "engine/pokecenter_pc.asm" - INCLUDE "engine/mart.asm" - INCLUDE "engine/money.asm" - INCLUDE "items/marts.asm" - INCLUDE "event/mom.asm" - INCLUDE "event/daycare.asm" - INCLUDE "event/photo.asm" - INCLUDE "engine/breeding/egg.asm" SECTION "Tileset Data 1", ROMX, BANK[TILESETS_1] @@ -8136,261 +7805,6 @@ StringBufferPointers:: ; 24000 INCLUDE "engine/menu.asm" -_BackUpTiles:: ; 24374 - ld a, [rSVBK] - push af - ld a, $7 - ld [rSVBK], a - - ld hl, wcf71 - ld e, [hl] - inc hl - ld d, [hl] - push de - - ld b, $10 - ld hl, wMenuFlags -.loop - ld a, [hli] - ld [de], a - dec de - dec b - jr nz, .loop - -; If bit 6 or 7 of the menu flags is set, set bit 0 of the address -; at 7:[wcf71], and draw the menu using the coordinates from the header. -; Otherwise, reset bit 0 of 7:[wcf71]. - ld a, [wMenuFlags] - bit 6, a - jr nz, .bit_6 - bit 7, a - jr z, .not_bit_7 - -.bit_6 - ld hl, wcf71 - ld a, [hli] - ld h, [hl] - ld l, a - set 0, [hl] - call MenuBoxCoord2Tile - call .copy - call MenuBoxCoord2Attr - call .copy - jr .done - -.not_bit_7 - pop hl ; last-pushed register was de - push hl - ld a, [hld] - ld l, [hl] - ld h, a - res 0, [hl] - -.done - pop hl - call .ret ; empty function - ld a, h - ld [de], a - dec de - ld a, l - ld [de], a - dec de - ld hl, wcf71 - ld [hl], e - inc hl - ld [hl], d - - pop af - ld [rSVBK], a - ld hl, wcf78 - inc [hl] - ret -; 243cd - -.copy: ; 243cd - call GetMenuBoxDims - inc b - inc c - call .ret ; empty function - -.row - push bc - push hl - -.col - ld a, [hli] - ld [de], a - dec de - dec c - jr nz, .col - - pop hl - ld bc, SCREEN_WIDTH - add hl, bc - pop bc - dec b - jr nz, .row - - ret -; 243e7 - -.ret: ; 243e7 - ret -; 243e8 - -Function243e8:: ; 243e8 - xor a - ld [hBGMapMode], a - - ld a, [rSVBK] - push af - ld a, $7 - ld [rSVBK], a - - call Function1c7e - ld a, l - or h - jp z, Function2445d - ld a, l - ld [wcf71], a - ld a, h - ld [wcf72], a - call Function1c47 - ld a, [wMenuFlags] - bit 0, a - jr z, .next - ld d, h - ld e, l - call RestoreTileBackup - -.next - call Function1c7e - ld a, h - or l - jr z, .done - call Function1c47 - -.done - pop af - ld [rSVBK], a - ld hl, wcf78 - dec [hl] - ret -; 24423 - -Function24423: ; 24423 - ld a, [VramState] - bit 0, a - ret z - xor a - call GetSRAMBank - hlcoord 0, 0 - ld de, sScratch - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyBytes - call CloseSRAM - call OverworldTextModeSwitch - xor a - call GetSRAMBank - ld hl, sScratch - decoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT -.asm_2444c - ld a, [hl] - cp $61 - jr c, .asm_24452 - ld [de], a - -.asm_24452 - inc hl - inc de - dec bc - ld a, c - or b - jr nz, .asm_2444c - call CloseSRAM - ret -; 2445d - -Function2445d: ; 2445d - ld hl, UnknownText_0x24468 - call PrintText - call WaitBGMap -.asm_24466 - jr .asm_24466 -; 24468 - -UnknownText_0x24468: ; 24468 - text_jump UnknownText_0x1c46b7 - db "@" -; 2446d - -Function2446d:: ; 2446d - ld a, [wMenuData2Flags] - ld b, a - ld hl, wcfa1 - ld a, [wMenuBorderTopCoord] - inc a - bit 6, b - jr nz, .asm_2447d - inc a - -.asm_2447d - ld [hli], a - ld a, [wMenuBorderLeftCoord] - inc a - ld [hli], a - ld a, [wMenuData2Items] - ld [hli], a - ld a, $1 - ld [hli], a - ld [hl], $0 - bit 5, b - jr z, .asm_24492 - set 5, [hl] - -.asm_24492 - ld a, [wMenuFlags] - bit 4, a - jr z, .asm_2449b - set 6, [hl] - -.asm_2449b - inc hl - xor a - ld [hli], a - ld a, $20 - ld [hli], a - ld a, $1 - bit 0, b - jr nz, .asm_244a9 - add $2 - -.asm_244a9 - ld [hli], a - ld a, [wMenuCursorBuffer] - and a - jr z, .asm_244b7 - ld c, a - ld a, [wMenuData2Items] - cp c - jr nc, .asm_244b9 - -.asm_244b7 - ld c, $1 - -.asm_244b9 - ld [hl], c - inc hl - ld a, $1 - ld [hli], a - xor a -rept 3 - ld [hli], a -endr - ret -; 244c3 - UpdateItemDescription: ; 0x244c3 ld a, [MenuSelection] ld [CurSpecies], a @@ -8532,7 +7946,7 @@ GetObjectTimeMask: ; 245a7 (9:45a7) Function245af:: ; 245af xor a - ld [wcf73], a + ld [wMenuJoypad], a ld [hBGMapMode], a inc a ld [hInMenu], a @@ -8555,8 +7969,8 @@ Function245cb:: ; 245cb ; 245d6 .exit: ; 245d6 - call Function1ff8 - ld [wcf73], a + call MenuClickSound + ld [wMenuJoypad], a ld a, 0 ld [hInMenu], a ret @@ -8590,7 +8004,7 @@ Function245f1: ; 245f1 MenuJoyAction: ; 24609 .loop - call Function1bd3 + call ScrollingMenuJoypad ld a, [hJoyLast] and D_PAD ld b, a @@ -8624,7 +8038,7 @@ MenuJoyAction: ; 24609 .a_button: ; 24644 call Function1bee - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call Function248d5 ld a, [MenuSelection] @@ -8653,7 +8067,7 @@ MenuJoyAction: ; 24609 ld a, [wMenuData2Flags] bit 7, a jp z, xor_a_dec_a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call Function248d5 ld a, [MenuSelection] @@ -8736,7 +8150,7 @@ MenuJoyAction: ; 24609 Function246fc: ; 246fc ld a, [wMenuScrollPosition] ld c, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] add c ld c, a ret @@ -8870,13 +8284,13 @@ Function24764: ; 24764 ld a, $1 .asm_247ca - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a xor a - ld [wcfac], a - ld [wcfad], a - ld [wcfab], a + ld [wCursorCurrentTile], a + ld [wCursorCurrentTile + 1], a + ld [wCursorOffCharacter], a ret ; 247dd @@ -9034,7 +8448,7 @@ Function248b8: ; 248b8 ret nz .asm_248c7 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call Function248d5 ld hl, wcf9e @@ -11582,14 +10996,14 @@ AskRememberPassword: ; 4ae12 add $4 ld [wMenuBorderBottomCoord], a call BackUpTiles - call InterpretMenu2 + call VerticalMenu push af ld c, 15 call DelayFrames call Buena_ExitMenu pop af jr c, .refused - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $2 jr z, .refused and a @@ -11597,7 +11011,7 @@ AskRememberPassword: ; 4ae12 .refused ld a, $2 - ld [MenuSelection2], a + ld [wMenuCursorY], a scf ret ; 4ae5e @@ -12009,14 +11423,14 @@ INCBIN "gfx/shrink2.2bpp.lz" ; 4d319 Function4d319: ; 4d319 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [CurPartyMon], a call LowVolume predef StatsScreenInit ld a, [CurPartyMon] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a call ClearScreen call ClearBGPalettes call MaxVolume @@ -12119,9 +11533,9 @@ _ResetClock: ; 4d3b1 call PrintText ld hl, .NoYes_MenuDataHeader call CopyMenuDataHeader - call InterpretMenu2 + call VerticalMenu ret c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 ret z call ClockResetPassword @@ -12395,9 +11809,9 @@ Function4d54c: ; 4d54c call PrintText ld hl, MenuDataHeader_0x4d585 call CopyMenuDataHeader - call InterpretMenu2 + call VerticalMenu ret c - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 ret z callba EmptyAllSRAMBanks @@ -14074,7 +13488,7 @@ endr push bc push hl push de - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] push af ld [hl], b @@ -14546,7 +13960,7 @@ _SwitchPartyMons: dec a ld [Buffer3], a ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [Buffer2], a ; wd1eb (aliases: MovementType) cp b @@ -16303,8 +15717,8 @@ ShowPlayerNamingChoices: ; 88297 ld hl, KrisNameMenuHeader .GotGender call LoadMenuDataHeader - call InterpretMenu2 - ld a, [MenuSelection2] + call VerticalMenu + ld a, [wMenuCursorY] dec a call CopyNameFromMenu call WriteBackup diff --git a/maps/CeladonDeptStore6F.asm b/maps/CeladonDeptStore6F.asm index 0753fb2dc..a65d63c34 100644 --- a/maps/CeladonDeptStore6F.asm +++ b/maps/CeladonDeptStore6F.asm @@ -29,7 +29,7 @@ CeladonVendingMachine: .Start special PlaceMoneyTopRightOW loadmenudata .MenuData - interpretmenu2 + verticalmenu writebackup if_equal $1, .FreshWater if_equal $2, .SodaPop diff --git a/maps/CeladonGameCornerPrizeRoom.asm b/maps/CeladonGameCornerPrizeRoom.asm index e800c007b..4b077896f 100644 --- a/maps/CeladonGameCornerPrizeRoom.asm +++ b/maps/CeladonGameCornerPrizeRoom.asm @@ -26,7 +26,7 @@ MapCeladonGameCornerPrizeRoomSignpost0Script: CeladonPrizeRoom_tmcounterloop: special Special_DisplayCoinCaseBalance loadmenudata MenuDataHeader_0x72790 - interpretmenu2 + verticalmenu writebackup if_equal $1, .doubleteam if_equal $2, .psychic @@ -130,7 +130,7 @@ MapCeladonGameCornerPrizeRoomSignpost1Script: writetext UnknownText_0x72974 special Special_DisplayCoinCaseBalance loadmenudata MenuDataHeader_0x72877 - interpretmenu2 + verticalmenu writebackup if_equal $1, .pikachu if_equal $2, .porygon diff --git a/maps/DragonShrine.asm b/maps/DragonShrine.asm index 8dadee3f7..347d77bfe 100644 --- a/maps/DragonShrine.asm +++ b/maps/DragonShrine.asm @@ -33,7 +33,7 @@ DragonShrineTestScript: writetext UnknownText_0x18d3bc buttonsound loadmenudata MenuDataHeader_0x18d215 - interpretmenu2 + verticalmenu writebackup if_equal $1, .RightAnswer if_equal $2, .WrongAnswer @@ -45,7 +45,7 @@ DragonShrineTestScript: writetext UnknownText_0x18d3d3 buttonsound loadmenudata MenuDataHeader_0x18d234 - interpretmenu2 + verticalmenu writebackup if_equal $1, .RightAnswer if_equal $2, .RightAnswer @@ -55,7 +55,7 @@ DragonShrineTestScript: writetext UnknownText_0x18d3f3 buttonsound loadmenudata MenuDataHeader_0x18d258 - interpretmenu2 + verticalmenu writebackup if_equal $1, .WrongAnswer if_equal $2, .RightAnswer @@ -65,7 +65,7 @@ DragonShrineTestScript: writetext UnknownText_0x18d420 buttonsound loadmenudata MenuDataHeader_0x18d283 - interpretmenu2 + verticalmenu writebackup if_equal $1, .RightAnswer if_equal $2, .WrongAnswer @@ -75,7 +75,7 @@ DragonShrineTestScript: writetext UnknownText_0x18d44a buttonsound loadmenudata MenuDataHeader_0x18d2a5 - interpretmenu2 + verticalmenu writebackup if_equal $1, .WrongAnswer if_equal $2, .RightAnswer diff --git a/maps/EarlsPokemonAcademy.asm b/maps/EarlsPokemonAcademy.asm index 5d92242a2..126db4efe 100644 --- a/maps/EarlsPokemonAcademy.asm +++ b/maps/EarlsPokemonAcademy.asm @@ -67,7 +67,7 @@ AcademyBlackboard: writetext AcademyBlackboardText .Loop loadmenudata .MenuHeader - interpretmenu + _2dmenu writebackup if_equal $1, .Poison if_equal $2, .Paralysis @@ -114,7 +114,7 @@ AcademyBlackboard: dn 3, 2 ; rows, columns db 5 ; spacing dba .Text - dbw $1a, 0 + dbw BANK(AcademyBlackboard), 0 .Text db "PSN@" diff --git a/maps/GoldenrodCity.asm b/maps/GoldenrodCity.asm index ef6321a2e..9e27ccf3b 100644 --- a/maps/GoldenrodCity.asm +++ b/maps/GoldenrodCity.asm @@ -68,7 +68,7 @@ MoveTutor: if_equal $2, .NotEnoughMoney writetext UnknownText_0x1990ce loadmenudata .MoveMenuDataHeader - interpretmenu2 + verticalmenu writebackup if_equal $1, .Flamethrower if_equal $2, .Thunderbolt diff --git a/maps/GoldenrodDeptStore6F.asm b/maps/GoldenrodDeptStore6F.asm index 47f5a9a08..c50eab46c 100644 --- a/maps/GoldenrodDeptStore6F.asm +++ b/maps/GoldenrodDeptStore6F.asm @@ -15,7 +15,7 @@ GoldenrodVendingMachine: .Start special PlaceMoneyTopRightOW loadmenudata .MenuData - interpretmenu2 + verticalmenu writebackup if_equal $1, .FreshWater if_equal $2, .SodaPop diff --git a/maps/GoldenrodGameCorner.asm b/maps/GoldenrodGameCorner.asm index a5c8e9100..18d24acdf 100644 --- a/maps/GoldenrodGameCorner.asm +++ b/maps/GoldenrodGameCorner.asm @@ -65,7 +65,7 @@ ReceptionistScript_0x56c28: UnknownScript_0x56c36: ; 056c36 special Special_DisplayCoinCaseBalance loadmenudata MenuDataHeader_0x56cc9 - interpretmenu2 + verticalmenu writebackup if_equal $1, UnknownScript_0x56c4d if_equal $2, UnknownScript_0x56c69 @@ -169,7 +169,7 @@ UnknownScript_0x56d0c: writetext UnknownText_0x56e8b special Special_DisplayCoinCaseBalance loadmenudata MenuDataHeader_0x56db0 - interpretmenu2 + verticalmenu writebackup if_equal $1, UnknownScript_0x56d26 if_equal $2, UnknownScript_0x56d54 diff --git a/maps/GoldenrodPokeComCenter2FMobile.asm b/maps/GoldenrodPokeComCenter2FMobile.asm index ae6f2da00..06d4aece6 100644 --- a/maps/GoldenrodPokeComCenter2FMobile.asm +++ b/maps/GoldenrodPokeComCenter2FMobile.asm @@ -26,7 +26,7 @@ MapGoldenrodPokeComCenter2FMobileSignpost0Script: UnknownScript_0x625df: reloadmappart loadmenudata MenuDataHeader_0x62602 - interpretmenu2 + verticalmenu writebackup if_equal $1, UnknownScript_0x625f0 if_equal $2, UnknownScript_0x625f8 @@ -71,7 +71,7 @@ MapGoldenrodPokeComCenter2FMobileSignpost1Script: UnknownScript_0x62629: reloadmappart loadmenudata MenuDataHeader_0x6264c - interpretmenu2 + verticalmenu writebackup if_equal $1, UnknownScript_0x6263a if_equal $2, UnknownScript_0x62642 diff --git a/misc/fixed_words.asm b/misc/fixed_words.asm index e1f1caa30..4f56936a8 100755 --- a/misc/fixed_words.asm +++ b/misc/fixed_words.asm @@ -288,7 +288,7 @@ Function11c1ca: ; 11c1ca ld [wcd2b], a ld a, $ff ld [wcd24], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a call Function11c254 call ClearBGPalettes @@ -1733,7 +1733,7 @@ String_11cb31: ; 11cb31 Function11cb52: ; 11cb52 (47:4b52) ld hl, Unknown_11cc01 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] .asm_11cb58 dec a jr z, .asm_11cb5f @@ -1771,7 +1771,7 @@ Function11cb66: ; 11cb66 (47:4b66) ld a, $4 call GetSRAMBank ld hl, $a007 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a sla a sla a @@ -1794,7 +1794,7 @@ Function11cb66: ; 11cb66 (47:4b66) ld de, Unknown_11cfc6 call Function11cfce ld hl, Unknown_11cc7e - ld a, [MenuSelection2] + ld a, [wMenuCursorY] .asm_11cbba dec a jr z, .asm_11cbc1 diff --git a/misc/mobile_12.asm b/misc/mobile_12.asm index e8af6c8ac..63fa6df4a 100755 --- a/misc/mobile_12.asm +++ b/misc/mobile_12.asm @@ -114,15 +114,15 @@ InitMobileProfile: ; 4802f (12:402f) call Function48187 call WaitBGMap2 call SetPalettes - call Function1bc9 - ld hl, MenuSelection2 + call StaticMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc jr asm_4815f Function48157: ; 48157 (12:4157) - call Function1bd3 - ld hl, MenuSelection2 + call ScrollingMenuJoypad + ld hl, wMenuCursorY ld b, [hl] push bc @@ -215,7 +215,7 @@ String_48202: ; 48202 Function4820d: ; 4820d (12:420d) call Function1bee - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] push af ld a, [wd002] @@ -235,7 +235,7 @@ Function4820d: ; 4820d (12:420d) cp $4 jp z, Function488d3 ld a, $2 - call Function1ff8 + call MenuClickSound ld a, [wd002] bit 6, a jr z, .asm_4825c @@ -301,12 +301,12 @@ asm_4828d: ; 4828d (12:428d) ld a, [PlayerGender] inc a ld [wMenuCursorBuffer], a - call Function1bc9 + call StaticMenuJoypad call PlayClickSFX call ExitMenu bit 0, a jp z, Function4840c - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] ld hl, Strings_484fb cp $1 @@ -415,7 +415,7 @@ Function48383: ; 48383 (12:4383) ld [wMenuScrollPosition], a jr .asm_483af .asm_483af - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld a, [hl] ld [wMenuCursorBuffer], a scf @@ -493,7 +493,7 @@ Function4840c: ; 4840c (12:440c) call PlaceString call Function486bf pop bc - ld hl, MenuSelection2 + ld hl, wMenuCursorY ld [hl], b ld a, [wd002] bit 6, a @@ -853,7 +853,7 @@ Function4876f: ; 4876f (12:476f) call Function4880e jr nc, .asm_487c6 ld a, $1 - call Function1ff8 + call MenuClickSound pop bc jr nz, .asm_487da ld a, b @@ -1154,7 +1154,7 @@ asm_48972: ; 48972 (12:4972) push de push hl ld a, $1 - call Function1ff8 + call MenuClickSound pop hl pop de pop bc @@ -1221,7 +1221,7 @@ Function48a3a: ; 48a3a (12:4a3a) ld a, $b ld [wcfa2], a ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a hlcoord 10, 8 ld b, $4 ld c, $8 @@ -1229,14 +1229,14 @@ Function48a3a: ; 48a3a (12:4a3a) hlcoord 12, 10 ld de, String_48aa1 call PlaceString - call Function1bc9 + call StaticMenuJoypad push af call PlayClickSFX call ExitMenu pop af bit 1, a jp nz, Function48a9a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .asm_48a98 ld a, [wd003] diff --git a/misc/mobile_12_2.asm b/misc/mobile_12_2.asm index 5b15f40d7..f8ebdbb00 100755 --- a/misc/mobile_12_2.asm +++ b/misc/mobile_12_2.asm @@ -494,7 +494,7 @@ Function4ab1a: ; 4ab1a ld a, $2 ld [wcfa4], a call Function4adf7 - call Function1bc9 + call StaticMenuJoypad call Function4abc3 jr c, .asm_4ab1a push af @@ -506,11 +506,11 @@ Function4ab1a: ; 4ab1a ld a, [PartyCount] inc a ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wd0d8], a cp b jr z, .asm_4ab7e - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [CurPartyMon], a ld c, a @@ -527,7 +527,7 @@ Function4ab1a: ; 4ab1a ret .asm_4ab6d - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wd0d8], a .asm_4ab73 ld de, SFX_READ_TEXT_2 @@ -539,7 +539,7 @@ Function4ab1a: ; 4ab1a .asm_4ab7e ld a, $1 ld [wd018], a - ld a, [wcfaa] + ld a, [wMenuCursorX] cp $2 jr z, .asm_4ab73 ld de, SFX_READ_TEXT_2 @@ -593,38 +593,38 @@ Function4abc3: ; 4abc3 jr z, .asm_4abd5 ld a, [PartyCount] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a jr .asm_4ac29 .asm_4abd5 bit 6, a jr z, .asm_4abeb - ld a, [MenuSelection2] - ld [MenuSelection2], a + ld a, [wMenuCursorY] + ld [wMenuCursorY], a and a jr nz, .asm_4ac29 ld a, [PartyCount] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a jr .asm_4ac29 .asm_4abeb bit 7, a jr z, .asm_4ac08 - ld a, [MenuSelection2] - ld [MenuSelection2], a + ld a, [wMenuCursorY] + ld [wMenuCursorY], a ld a, [PartyCount] rept 2 inc a endr ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp b jr nz, .asm_4ac29 ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a jr .asm_4ac29 .asm_4ac08 @@ -634,20 +634,20 @@ endr jr z, .asm_4ac56 .asm_4ac10 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [PartyCount] inc a cp b jr nz, .asm_4ac29 - ld a, [wcfaa] + ld a, [wMenuCursorX] cp $1 jr z, .asm_4ac26 ld a, $1 jr .asm_4ac29 .asm_4ac26 - ld [wcfaa], a + ld [wMenuCursorX], a .asm_4ac29 hlcoord 0, 1 @@ -662,14 +662,14 @@ endr dec a jr nz, .asm_4ac3b ld [hl], $7f - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [PartyCount] inc a cp b jr z, .asm_4ac54 ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a .asm_4ac54 scf @@ -747,10 +747,10 @@ Function4acaa: ; 4acaa ld [wMenuBorderLeftCoord], a ld a, $1 ld [wMenuCursorBuffer], a - call Function1c10 + call InitVerticalMenuCursor ld hl, wcfa5 set 6, [hl] - call Function1bc9 + call StaticMenuJoypad ld de, SFX_READ_TEXT_2 call PlaySFX ld a, [hJoyPressed] @@ -767,7 +767,7 @@ Function4acaa: ; 4acaa ld a, [wd019] bit 1, a jr nz, .asm_4ad0e - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, Function4ad17 cp $2 @@ -777,7 +777,7 @@ Function4acaa: ; 4acaa jr .asm_4acf3 .asm_4ad0e - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, Function4ad56 jr .asm_4acf3 @@ -927,9 +927,9 @@ Function4adf7: ; 4adf7 ret z ld a, [PartyCount] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1 - ld [wcfaa], a + ld [wMenuCursorX], a ld a, [wd019] res 0, a ld [wd019], a diff --git a/misc/mobile_22.asm b/misc/mobile_22.asm index cdc596e6f..3a65dd1bb 100644 --- a/misc/mobile_22.asm +++ b/misc/mobile_22.asm @@ -251,7 +251,7 @@ Function89261: ; 89261 call BackUpTiles call Function8923c call Function89209 - call InterpretMenu2 + call VerticalMenu push af ld c, $a call DelayFrames @@ -259,7 +259,7 @@ Function89261: ; 89261 call Function8920f pop af jr c, .done - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $2 jr z, .done and a @@ -2198,8 +2198,8 @@ Function89d5e: ; 89d5e (22:5d5e) pop af ld [wMenuCursorBuffer], a call Function8923c - call Function1c89 - call Function1c10 + call PlaceVerticalMenuItems + call InitVerticalMenuCursor ld hl, wcfa5 set 7, [hl] ret @@ -2224,7 +2224,7 @@ asm_89d90: ; 89d90 (22:5d90) push hl call _hl_ call Function89dab - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af call Function891ab pop af @@ -2239,7 +2239,7 @@ asm_89d90: ; 89d90 (22:5d90) Function89dab: ; 89dab (22:5dab) call Function8923c - callba Function241ba + callba MobileMenuJoypad call Function8923c ld a, c ld hl, wcfa8 @@ -2255,7 +2255,7 @@ Function89dab: ; 89dab (22:5dab) call PlayClickSFX ld a, [wcfa3] ld c, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp c jr z, .asm_89dd9 call Function1bee @@ -2275,7 +2275,7 @@ Function89de0: ; 89de0 (22:5de0) .asm_89dea call Function8a31c jr z, .asm_89dfd - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld c, a push bc ld hl, Jumptable_89e04 @@ -2784,7 +2784,7 @@ Function8a116: ; 8a116 (22:6116) call Function8923c call Function8a17b jr c, .asm_8a16b - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wd030], a dec d jr z, .asm_8a140 @@ -2867,7 +2867,7 @@ Function8a1b0: ; 8a1b0 ld c, $12 call TextBox hlcoord 1, 14 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld de, Strings_8a1cc dec a ld c, a @@ -3054,8 +3054,8 @@ Function8a31c: ; 8a31c (22:631c) ld a, c ld [wMenuCursorBuffer], a ld [MenuSelection], a - call Function1c89 - call Function1c10 + call PlaceVerticalMenuItems + call InitVerticalMenuCursor ld hl, wcfa5 set 7, [hl] .asm_8a34e @@ -3086,7 +3086,7 @@ Function8a31c: ; 8a31c (22:631c) ret Function8a383: ; 8a383 (22:6383) - callba Function241ba + callba MobileMenuJoypad ld a, c ld hl, wcfa8 and [hl] @@ -3106,7 +3106,7 @@ Function8a383: ; 8a383 (22:6383) ret Function8a3a2: ; 8a3a2 (22:63a2) - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld hl, wd002 ld e, a @@ -3834,7 +3834,7 @@ Function8a930: ; 8a930 (22:6930) ld [wd0e3], a .asm_8a943 call Function8b7bd - ld a, [wcf73] + ld a, [wMenuJoypad] and $1 jr nz, .asm_8a953 ld a, c diff --git a/misc/mobile_22_2.asm b/misc/mobile_22_2.asm index b794ba33a..e9e52bfeb 100644 --- a/misc/mobile_22_2.asm +++ b/misc/mobile_22_2.asm @@ -830,7 +830,7 @@ Function8b7bd: ; 8b7bd call Function89209 call HandleScrollingMenu call Function8920f - ld a, [wcf73] + ld a, [wMenuJoypad] cp $2 jr z, .asm_8b823 cp $20 @@ -854,7 +854,7 @@ Function8b7bd: ; 8b7bd .asm_8b824 ld c, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wd030], a ld a, [wMenuScrollPosition] ld [wd031], a @@ -880,7 +880,7 @@ Function8b83e: ; 8b83e Function8b84b: ; 8b84b ld [wMenuScrollPosition], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wMenuCursorBuffer], a ret ; 8b855 diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index f0ba0f957..a33f90952 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -89,7 +89,7 @@ Function100082: ; 100082 ld [hMapAnims], a ld [hLCDStatCustom], a ld a, $1 - ld [hFFC9], a + ld [hMobileReceive], a ld [hMobile], a ei ret @@ -98,7 +98,7 @@ Function100082: ; 100082 Function1000a4: ; 1000a4 di xor a - ld [hFFC9], a + ld [hMobileReceive], a ld [hMobile], a xor a ld [hVBlank], a @@ -173,7 +173,7 @@ Function1000fa: ; 1000fa and $13 ld [rIE], a xor a - ld [hFFC9], a + ld [hMobileReceive], a ld [hMobile], a ei @@ -818,8 +818,8 @@ Function100504: ; 100504 Function100513: ; 100513 call Function3f7c - call Function1c89 - call Function1c10 + call PlaceVerticalMenuItems + call InitVerticalMenuCursor ld hl, wcfa5 set 7, [hl] ret @@ -858,12 +858,12 @@ Function100545: ; 100545 ; 10054d Function10054d: ; 10054d - callba Function241ba + callba MobileMenuJoypad ld a, c ld hl, wcfa8 and [hl] ret z - call Function1ff8 + call MenuClickSound bit 0, a jr nz, .asm_100565 bit 1, a @@ -913,7 +913,7 @@ Function100597: ; 100597 ret z jr nc, .asm_1005a6 xor a - ld [MenuSelection2], a + ld [wMenuCursorY], a .asm_1005a6 call ExitMenu @@ -965,7 +965,7 @@ Function1005e1: ; 1005e1 ret z jr nc, .asm_1005f0 xor a - ld [MenuSelection2], a + ld [wMenuCursorY], a .asm_1005f0 call ExitMenu ld a, [wcd26] @@ -1823,7 +1823,7 @@ Function100b45: ; 100b45 call Function100b7a .asm_100b48 call Function100dd2 - callba Function241ba + callba MobileMenuJoypad push bc callba Function10402d call Function100e2d @@ -1832,7 +1832,7 @@ Function100b45: ; 100b45 ld a, [wcfa8] and c jr z, .asm_100b48 - callba Function24098 + callba Mobile_GetMenuSelection ret .asm_100b6b @@ -1849,11 +1849,11 @@ Function100b7a: ; 100b7a ld hl, CopyMenuData2 ld a, [wcf94] rst FarCall - callba Function24085 + callba Draw2DMenu callba MobileTextBorder call UpdateSprites call ApplyTilemap - callba Function2411a + callba Init2DMenuCursorPosition ld hl, wcfa5 set 7, [hl] ret @@ -1884,7 +1884,7 @@ Function100bc2: ; 100bc2 callba MoveInfoBox .asm_100bd1 call Function100dd2 - callba Function241ba + callba MobileMenuJoypad push bc callba Function10402d call Function100e2d @@ -1903,16 +1903,16 @@ Function100bc2: ; 100bc2 jr .asm_100bd1 .asm_100bff - ld a, [MenuSelection2] + ld a, [wMenuCursorY] and a jp nz, .asm_100bcb ld a, [wNumMoves] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a jp .asm_100bcb .asm_100c10 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [wNumMoves] rept 2 @@ -1921,11 +1921,11 @@ endr cp b jp nz, .asm_100bcb ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a jp .asm_100bcb .asm_100c25 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [CurMoveNum], a ld a, $1 @@ -1933,10 +1933,10 @@ endr ret .asm_100c30 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [CurMoveNum], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, 0 @@ -1951,7 +1951,7 @@ endr dec a cp c jr z, .asm_100c63 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, 0 @@ -1999,7 +1999,7 @@ Function100c98: ; 100c98 ld [wcfa3], a ld a, [CurMoveNum] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a ret ; 100cad @@ -2014,7 +2014,7 @@ Function100cb5: ; 100cb5 res 6, [hl] .asm_100cc0 call Function100dd2 - callba Function241ba + callba MobileMenuJoypad push bc callba PlaySpriteAnimations callba Function10402d @@ -2028,7 +2028,7 @@ Function100cb5: ; 100cb5 ld a, [PartyCount] inc a ld b, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp b jr z, .asm_100d17 ld [wd0d8], a @@ -2036,7 +2036,7 @@ Function100cb5: ; 100cb5 ld b, a bit 1, b jr nz, .asm_100d17 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [CurPartyMon], a ld c, a @@ -2068,7 +2068,7 @@ MobileBattleMonMenu: ; 100d22 res 6, [hl] .asm_100d30 call Function100dd2 - callba Function241ba + callba MobileMenuJoypad push bc callba PlaySpriteAnimations callba Function10402d @@ -2107,10 +2107,10 @@ Function100d67: ; 100d67 ld [hBGMapMode], a call MenuBox call UpdateSprites - call Function1c89 + call PlaceVerticalMenuItems call WaitBGMap call CopyMenuData2 - call Function1c10 + call InitVerticalMenuCursor ld hl, wcfa5 set 6, [hl] ret @@ -4186,7 +4186,7 @@ Function101b2b: ; 101b2b call Function1013dd ld a, 0 ld [wcd26], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .asm_101b51 ld a, $2 @@ -4239,7 +4239,7 @@ Function101b8f: ; 101b8f call Function1013dd ld a, 0 ld [wcd26], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .asm_101bbc ld a, $1 @@ -4283,7 +4283,7 @@ Function101be5: ; 101be5 call Function1013dd ld a, 0 ld [wcd26], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr nz, .asm_101c0b ld a, $2a @@ -5375,7 +5375,7 @@ Function102387: ; 102387 call Function102d9a call Function102dd3 ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a Function1023a1: ; 1023a1 call Function102283 @@ -5721,7 +5721,7 @@ Function1025ff: ; 1025ff set 2, [hl] callba Function1009f3 ret c - callba Function241ba + callba MobileMenuJoypad ld a, [wcfa8] and c ret z @@ -5741,20 +5741,20 @@ Function1025ff: ; 1025ff ret .asm_10262e - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [OTPartyCount] cp b ret nz call Function1bf7 ld a, [PartyCount] - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1d ld [wcd49], a ret .asm_102646 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 ret nz ld a, $23 @@ -5783,7 +5783,7 @@ Function10266b: ; 10266b set 2, [hl] callba Function1009f3 ret c - callba Function241ba + callba MobileMenuJoypad ld a, [wcfa8] and c ret z @@ -5803,7 +5803,7 @@ Function10266b: ; 10266b ret .asm_10269a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ret nz call Function1bf7 @@ -5812,7 +5812,7 @@ Function10266b: ; 10266b ret .asm_1026a8 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a ld a, [PartyCount] cp b @@ -5872,7 +5872,7 @@ Function1026f3: ; 1026f3 hlcoord 9, 17 ld [hl], $7f ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1d ld [wcd49], a ret @@ -5881,7 +5881,7 @@ Function1026f3: ; 1026f3 hlcoord 9, 17 ld [hl], $7f ld a, [OTPartyCount] - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, $1f ld [wcd49], a ret @@ -5992,7 +5992,7 @@ asm_1027c6: asm_1027d1: ld hl, wcd4b set 3, [hl] - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wcd4c], a ld a, $7 ld [wcd49], a @@ -6023,7 +6023,7 @@ String_102804: ; 102804 ; 102814 Function102814: ; 102814 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wcd52], a ld a, [wcd4c] dec a @@ -6075,7 +6075,7 @@ Function10286f: ; 10286f call Function1028fc ret nc ld a, [wcd52] - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, [wcd51] cp $8 jr nz, .asm_102886 @@ -6107,7 +6107,7 @@ Function1028a5: ; 1028a5 Function1028ab: ; 1028ab ld a, [wcd52] - ld [MenuSelection2], a + ld [wMenuCursorY], a call Function102f15 ld hl, wcd4b set 1, [hl] @@ -6325,7 +6325,7 @@ Function1029cf: ; 1029cf Function1029fe: ; 1029fe callba Function1009f3 ret c - callba Function241ba + callba MobileMenuJoypad ld a, c ld hl, wcfa8 and [hl] @@ -6333,7 +6333,7 @@ Function1029fe: ; 1029fe push af call ExitMenu pop af - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr nz, .asm_102a21 ld a, $1 @@ -6484,12 +6484,12 @@ Function102b32: ; 102b32 Function102b4e: ; 102b4e ld a, $1 ld [MonType], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af ld de, Unknown_102b73 call InitMenu3 pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, [OTPartyCount] ld [wcfa3], a ret @@ -6497,7 +6497,7 @@ Function102b4e: ; 102b4e Function102b68: ; 102b68 ; unreferenced xor a - ld hl, wcf71 + ld hl, wWindowStackPointer ld bc, $10 call ByteFill ret @@ -6509,12 +6509,12 @@ Unknown_102b73: Function102b7b: ; 102b7b xor a ld [MonType], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] push af ld de, Unknown_102b94 call InitMenu3 pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ld a, [PartyCount] ld [wcfa3], a ret @@ -6534,7 +6534,7 @@ Function102b9c: ; 102b9c ; 102bac Function102bac: ; 102bac - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld [CurPartyMon], a call LowVolume @@ -6542,7 +6542,7 @@ Function102bac: ; 102bac callba Function4dc8f ld a, [CurPartyMon] inc a - ld [MenuSelection2], a + ld [wMenuCursorY], a call Function102d9a call ClearPalettes call DelayFrame @@ -7737,10 +7737,10 @@ AskMobileOrCable: ; 103612 ld [wMenuCursorBuffer], a .skip_load - call InterpretMenu2 + call VerticalMenu call WriteBackup jr c, .pressed_b - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [ScriptVar], a ld c, a ld a, [wdc40] @@ -7825,10 +7825,10 @@ Mobile_SelectThreeMons: ; 10366e jr c, .asm_1036f4 ld hl, MenuDataHeader_103747 call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu call ExitMenu jr c, .asm_1036f4 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr z, .asm_1036d9 cp $2 diff --git a/misc/mobile_41.asm b/misc/mobile_41.asm index 90c775299..cc78c84e7 100755 --- a/misc/mobile_41.asm +++ b/misc/mobile_41.asm @@ -960,7 +960,7 @@ Function106442: ; 106442 call Function3e32 xor a ld [hMobile], a - ld [hFFC9], a + ld [hMobileReceive], a ld a, [wcd25] inc a ld [wcd25], a diff --git a/misc/mobile_46.asm b/misc/mobile_46.asm index 8a5a79b93..0689d4653 100755 --- a/misc/mobile_46.asm +++ b/misc/mobile_46.asm @@ -486,7 +486,7 @@ Function1183cb: ; 1183cb ld a, $f ld [rIE], a ld a, $1 - ld [hFFC9], a + ld [hMobileReceive], a ld [hMobile], a ei callba MobileFunc_106462 @@ -516,7 +516,7 @@ Function118440: ; 118440 Function118452: ; 118452 di xor a - ld [hFFC9], a + ld [hMobileReceive], a ld [hMobile], a ld [hVBlank], a call NormalSpeed @@ -5961,7 +5961,7 @@ Function11ad1b: ; 11ad1b call ClearSprites call ClearTileMap callba Function17c000 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld [wcd82], a dec a ld [hObjectStructIndexBuffer], a @@ -6035,7 +6035,7 @@ Function11ad95: ; 11ad95 callba ReloadMapPart call Function11ad8a ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a ld hl, Unknown_11afcc call Function11afb7 @@ -6062,13 +6062,13 @@ Function11adc4: jr .asm_11ae2e .asm_11ade6 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ret z jr .asm_11adf4 .asm_11aded - ld a, [MenuSelection2] + ld a, [wMenuCursorY] inc a cp $4 ret z @@ -6078,21 +6078,21 @@ Function11adc4: ld hl, Unknown_11afcc call Function11afbb pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ld hl, Unknown_11afcc call Function11afb7 ret .asm_11ae06 call PlayClickSFX - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld hl, wcd30 ld [hl], a and a jr z, .asm_11ae28 hlcoord 2, 14 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $2 jr z, .asm_11ae23 call Function11b272 @@ -6152,7 +6152,7 @@ Function11ae4e: ; 11ae4e callba ReloadMapPart call Function11ad8a ld a, $1 - ld [MenuSelection2], a + ld [wMenuCursorY], a ld hl, Unknown_11afd2 call Function11afb7 @@ -6183,13 +6183,13 @@ Function11ae98: jr .asm_11aef7 .asm_11aec1 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ret z jr .asm_11aecf .asm_11aec8 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] inc a cp $3 ret z @@ -6199,14 +6199,14 @@ Function11ae98: ld hl, Unknown_11afd2 call Function11afbb pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ld hl, Unknown_11afd2 call Function11afb7 ret .asm_11aee1 call PlayClickSFX - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $2 jr z, .asm_11aeb4 ld a, [wcd4b] @@ -6243,7 +6243,7 @@ Function11af04: ; 11af04 callba ReloadMapPart call Function11ad8a ld a, $2 - ld [MenuSelection2], a + ld [wMenuCursorY], a ld hl, Unknown_11afd2 call Function11afb7 @@ -6274,13 +6274,13 @@ Function11af4e: jr .asm_11afaa .asm_11af77 - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ret z jr .asm_11af85 .asm_11af7e - ld a, [MenuSelection2] + ld a, [wMenuCursorY] inc a cp $3 ret z @@ -6290,14 +6290,14 @@ Function11af4e: ld hl, Unknown_11afd2 call Function11afbb pop af - ld [MenuSelection2], a + ld [wMenuCursorY], a ld hl, Unknown_11afd2 call Function11afb7 ret .asm_11af97 call PlayClickSFX - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $2 jr z, .asm_11af6a ld a, $6 @@ -6320,7 +6320,7 @@ Function11afbb: ld e, $7f asm_11afbd: - ld a, [MenuSelection2] + ld a, [wMenuCursorY] dec a ld c, a ld b, 0 diff --git a/misc/mobile_5b.asm b/misc/mobile_5b.asm index 484a92ca0..fca94e3ba 100755 --- a/misc/mobile_5b.asm +++ b/misc/mobile_5b.asm @@ -1100,7 +1100,7 @@ Function16d734: ; 16d734 call Function16d759 call Function16d76a jr nc, .asm_16d758 - callba Function24270 + callba _2DMenuInterpretJoypad jr c, .asm_16d758 ld a, [wcfa5] bit 7, a @@ -1141,14 +1141,14 @@ Function16d76a: ; 16d76a ; 16d77a Function16d77a: ; 16d77a - ld hl, wcfac + ld hl, wCursorCurrentTile ld a, [hli] ld h, [hl] ld l, a ld a, [hl] cp $1f jr nz, .asm_16d792 - ld a, [wcfab] + ld a, [wCursorOffCharacter] ld [hl], a push hl push bc @@ -1168,7 +1168,7 @@ Function16d77a: ; 16d77a swap a and $f ld c, a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] ld b, a xor a dec b @@ -1184,7 +1184,7 @@ Function16d77a: ; 16d77a ld a, [wcfa7] and $f ld c, a - ld a, [wcfaa] + ld a, [wMenuCursorX] ld b, a xor a dec b @@ -1200,7 +1200,7 @@ Function16d77a: ; 16d77a ld a, [hl] cp $1f jr z, .asm_16d7de - ld [wcfab], a + ld [wCursorOffCharacter], a ld [hl], $1f push hl push bc @@ -1212,9 +1212,9 @@ Function16d77a: ; 16d77a .asm_16d7de ld a, l - ld [wcfac], a + ld [wCursorCurrentTile], a ld a, h - ld [wcfad], a + ld [wCursorCurrentTile + 1], a ret ; 16d7e7 diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm index 5a49698d9..928a59410 100644 --- a/misc/mobile_5f.asm +++ b/misc/mobile_5f.asm @@ -461,20 +461,20 @@ Special_Menu_ChallengeExplanationCancel: ; 17d224 ; 17d246 Function17d246: ; 17d246 - call InterpretMenu2 + call VerticalMenu jr c, .Exit ld a, [ScriptVar] cp $5 - jr nz, .UseMenuSelection2 - ld a, [MenuSelection2] + jr nz, .UsewMenuCursorY + ld a, [wMenuCursorY] cp $3 ret z - jr c, .UseMenuSelection2 + jr c, .UsewMenuCursorY dec a jr .LoadToScriptVar -.UseMenuSelection2 - ld a, [MenuSelection2] +.UsewMenuCursorY + ld a, [wMenuCursorY] .LoadToScriptVar ld [ScriptVar], a @@ -1933,16 +1933,16 @@ Function17dc1f: ; 17dc1f ld [wEnemyGoesFirst], a ld hl, wc708 call LoadMenuDataHeader - call InterpretMenu2 + call VerticalMenu jr nc, .asm_17dc6e ld a, $2 - ld [MenuSelection2], a + ld [wMenuCursorY], a .asm_17dc6e call WriteBackup pop af ld [rSVBK], a - ld a, [MenuSelection2] + ld a, [wMenuCursorY] cp $1 jr nz, .asm_17dc85 ld a, [$c68a] diff --git a/wram.asm b/wram.asm index 89d7a5b4a..d0de4866e 100644 --- a/wram.asm +++ b/wram.asm @@ -1484,19 +1484,15 @@ Requested1bppSource:: ; cf6d Requested1bppDest:: ; cf6f ds 2 -; something to do with menu -wcf71:: ds 1 -wcf72:: ds 1 -wMenuJoypad:: -wcf73:: ds 1 -MenuSelection:: ; cf74 - ds 1 +wWindowStackPointer:: dw ; cf71 +wMenuJoypad:: ds 1 ; cf73 +MenuSelection:: ds 1 ; cf74 wcf75:: ds 1 wcf76:: ds 1 wCurrPocketCursorPosition:: wcf77:: ds 1 -wcf78:: ds 9 +wWindowStackSize:: ds 9 ; menu data header wMenuDataHeader:: ; cf81 @@ -1520,39 +1516,52 @@ wMenuData2Flags:: ds 1 ; cf91 ; bit 4: ???? ; bit 3: ???? ; bit 2: ???? -; bit 1: ???? -; bit 0: ???? +; bit 1: Enable Select button +; bit 0: Disable B button wMenuData2Items:: ds 1 wMenuData2IndicesPointer:: +wMenuData2Spacing:: wcf93:: ds 1 +wMenuData2_2DMenuItemStringsBank:: wcf94:: ds 1 +wMenuData2_2DMenuItemStringsAddr:: wMenuData2DisplayFunctionPointer:: wMenuData2Bank:: wcf95:: ds 1 ; bank wMenuData2Addr:: wcf96:: ds 1 ; addr lo wMenuData2PointerTableAddr:: +wMenuData2_2DMenuFunctionBank:: wcf97:: ds 1 ; addr hi +wMenuData2_2DMenuFunctionAddr:: wcf98:: ds 3 wcf9b:: ds 3 wcf9e:: ds 3 wMenuData2End:: wMenuData3:: +w2DMenuCursorInitY:: wcfa1:: ds 1 +w2DMenuCursorInitX:: wcfa2:: ds 1 +w2DMenuNumRows:: wcfa3:: ds 1 +w2DMenuNumCols:: wcfa4:: ds 1 -wcfa5:: ds 1 ; dynamic menu flags? -wcfa6:: ds 1 ; dynamic menu flags? +w2DMenuFlags1:: +wcfa5:: ds 1 +w2DMenuFlags2:: +wcfa6:: ds 1 +w2DMenuFlags3:: wcfa7:: ds 1 +w2DMenuFlags4:: wcfa8:: ds 1 wMenuData3End:: -MenuSelection2:: ds 1 -wcfaa:: ds 1 -wcfab:: ds 1 -wcfac:: ds 1 -wcfad:: ds 4 +wMenuCursorY:: ds 1 +wMenuCursorX:: ds 1 +wCursorOffCharacter:: ds 1 +wCursorCurrentTile:: ds 2 + ds 3 OverworldDelay:: ; cfb1 ds 1 @@ -3257,5 +3266,5 @@ w6_d800:: INCLUDE "sram.asm" SECTION "WRAM 7", WRAMX, BANK [7] -w7_d000:: ds $1000 - 1 -w7_dfff:: ds 1 +wWindowStack:: ds $1000 - 1 +wWindowStackBottom:: ds 1