diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index d5d9a78b9..3e66c446a 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -1,7 +1,7 @@ DoPlayerTurn: ; 34000 call SetPlayerTurn - ld a, [wd0ec] + ld a, [wPlayerAction] and a ret nz @@ -9025,7 +9025,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67 ret z ld a, 1 - ld [wd0ec], a + ld [wPlayerAction], a call LoadStandardMenuDataHeader ld hl, LinkBattleSendReceiveAction @@ -9033,7 +9033,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67 call WriteBackup xor a - ld [wd0ec], a + ld [wPlayerAction], a ret ; 37a82 diff --git a/engine/mart.asm b/engine/mart.asm index d051d4632..7673df5af 100755 --- a/engine/mart.asm +++ b/engine/mart.asm @@ -662,7 +662,7 @@ MenuDataHeader_Buy: ; 0x15e18 ; 15e30 .PrintBCDPrices: ; 15e30 - ld a, [wcf77] + ld a, [wScrollingMenuCursorPosition] ld c, a ld b, 0 ld hl, wMartItem1BCD diff --git a/engine/selectmenu.asm b/engine/selectmenu.asm index 1298de0f9..03210f43d 100755 --- a/engine/selectmenu.asm +++ b/engine/selectmenu.asm @@ -167,11 +167,11 @@ UseRegisteredItem: ; 133c3 .Overworld ; 13406 call ResetWindow ld a, 1 - ld [wd0ef], a + ld [wUsingItemWithSelect], a call DoItemEffect xor a - ld [wd0ef], a - ld a, [wd0ec] + ld [wUsingItemWithSelect], a + ld a, [wItemEffectSucceeded] cp 1 jr nz, ._cantuse scf diff --git a/engine/switch_items.asm b/engine/switch_items.asm index 834648773..7de3440fa 100755 --- a/engine/switch_items.asm +++ b/engine/switch_items.asm @@ -3,11 +3,11 @@ SwitchItemsInBag: ; 2490c (9:490c) and a jr z, .init ld b, a - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] inc a cp b jr z, .trivial - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a5c ld a, [hl] cp $ff @@ -17,7 +17,7 @@ SwitchItemsInBag: ; 2490c (9:490c) ld [wSwitchItem], a call Function249a7 jp c, Function249d1 - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] ld c, a ld a, [wSwitchItem] cp c @@ -25,7 +25,7 @@ SwitchItemsInBag: ; 2490c (9:490c) jr .asm_2494a .init - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] inc a ld [wSwitchItem], a ret @@ -38,7 +38,7 @@ SwitchItemsInBag: ; 2490c (9:490c) .asm_2494a ld a, [wSwitchItem] call Function24a40 - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] ld d, a ld a, [wSwitchItem] ld e, a @@ -55,7 +55,7 @@ SwitchItemsInBag: ; 2490c (9:490c) pop hl pop bc call Function24aab - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a4d xor a ld [wSwitchItem], a @@ -64,7 +64,7 @@ SwitchItemsInBag: ; 2490c (9:490c) .asm_2497a ld a, [wSwitchItem] call Function24a40 - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] ld d, a ld a, [wSwitchItem] ld e, a @@ -78,7 +78,7 @@ SwitchItemsInBag: ; 2490c (9:490c) add hl, bc pop bc call CopyBytes - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a4d xor a ld [wSwitchItem], a @@ -89,12 +89,12 @@ Function249a7: ; 249a7 (9:49a7) call Function24a5c ld d, h ld e, l - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a5c ld a, [de] cp [hl] jr nz, .asm_249cd - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a97 cp 99 jr z, .asm_249cd @@ -115,7 +115,7 @@ Function249d1: ; 249d1 (9:49d1) call Function24a5c inc hl push hl - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a5c inc hl ld a, [hl] @@ -125,7 +125,7 @@ Function249d1: ; 249d1 (9:49d1) jr c, .asm_24a01 sub 99 push af - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a5c inc hl ld [hl], 99 @@ -140,7 +140,7 @@ Function249d1: ; 249d1 (9:49d1) .asm_24a01 push af - ld a, [wCurrPocketCursorPosition] + ld a, [wScrollingMenuCursorPosition] call Function24a5c inc hl pop af diff --git a/event/basement_key.asm b/event/basement_key.asm index 2800bac8d..6b32049a8 100755 --- a/event/basement_key.asm +++ b/event/basement_key.asm @@ -19,12 +19,12 @@ _BasementKey: ; 507b4 ld hl, .BasementKeyScript call QueueScript ld a, 1 - ld [wd0ec], a + ld [wItemEffectSucceeded], a ret .nope ld a, $0 - ld [wd0ec], a + ld [wItemEffectSucceeded], a ret ; 507e1 diff --git a/event/card_key.asm b/event/card_key.asm index dc7393911..711d97725 100755 --- a/event/card_key.asm +++ b/event/card_key.asm @@ -24,12 +24,12 @@ _CardKey: ; 50779 ld hl, .CardKeyScript call QueueScript ld a, $1 - ld [wd0ec], a + ld [wItemEffectSucceeded], a ret .nope ld a, $0 - ld [wd0ec], a + ld [wItemEffectSucceeded], a ret ; 507af diff --git a/event/elevator.asm b/event/elevator.asm index 68d8fbe5b..097293a56 100755 --- a/event/elevator.asm +++ b/event/elevator.asm @@ -1,62 +1,62 @@ Elevator:: ; 1342d - call Function1344a - call Function1347d - jr c, .asm_13448 - ld [wd041], a - call Function134dd - jr c, .asm_13448 - ld hl, wd041 + call .LoadPointer + call .FindCurrentFloor + jr c, .quit + ld [wElevatorOriginFloor], a + call Elevator_AskWhichFloor + jr c, .quit + ld hl, wElevatorOriginFloor cp [hl] - jr z, .asm_13448 - call Function134c0 + jr z, .quit + call Elevator_GoToFloor and a ret -.asm_13448 +.quit scf ret ; 1344a -Function1344a: ; 1344a +.LoadPointer: ; 1344a ld a, b - ld [EngineBuffer1], a + ld [wElevatorPointerBank], a ld a, e - ld [wd03f], a + ld [wElevatorPointerLo], a ld a, d - ld [wd040], a - call Function1345a + ld [wElevatorPointerHi], a + call .LoadFloors ret ; 1345a -Function1345a: ; 1345a - ld de, OBPals + 8 * 6 +.LoadFloors: ; 1345a + ld de, CurElevator ld bc, 4 - ld hl, wd03f + ld hl, wElevatorPointerLo ld a, [hli] ld h, [hl] ld l, a - ld a, [EngineBuffer1] + ld a, [wElevatorPointerBank] call GetFarByte inc hl ld [de], a inc de -.asm_1346f - ld a, [EngineBuffer1] +.loop + ld a, [wElevatorPointerBank] call GetFarByte ld [de], a inc de add hl, bc - cp $ff - jr nz, .asm_1346f + cp -1 + jr nz, .loop ret ; 1347d -Function1347d: ; 1347d - ld hl, wd03f +.FindCurrentFloor: ; 1347d + ld hl, wElevatorPointerLo ld a, [hli] ld h, [hl] ld l, a - ld a, [EngineBuffer1] + ld a, [wElevatorPointerBank] call GetFarByte ld c, a inc hl @@ -64,47 +64,46 @@ Function1347d: ; 1347d ld d, a ld a, [BackupMapNumber] ld e, a - ld b, $0 -.asm_13495 - ld a, [EngineBuffer1] + ld b, 0 +.loop2 + ld a, [wElevatorPointerBank] call GetFarByte - cp $ff - jr z, .asm_134be + cp -1 + jr z, .fail rept 2 inc hl endr - ld a, [EngineBuffer1] + ld a, [wElevatorPointerBank] call GetFarByte inc hl cp d - jr nz, .asm_134b7 - ld a, [EngineBuffer1] + jr nz, .next1 + ld a, [wElevatorPointerBank] call GetFarByte inc hl cp e - jr nz, .asm_134b8 - jr .asm_134bb + jr nz, .next2 + jr .done -.asm_134b7 +.next1 inc hl - -.asm_134b8 +.next2 inc b - jr .asm_13495 + jr .loop2 -.asm_134bb +.done xor a ld a, b ret -.asm_134be +.fail scf ret ; 134c0 -Function134c0: ; 134c0 +Elevator_GoToFloor: ; 134c0 push af - ld hl, wd03f + ld hl, wElevatorPointerLo ld a, [hli] ld h, [hl] ld l, a @@ -114,13 +113,13 @@ Function134c0: ; 134c0 call AddNTimes inc hl ld de, BackupWarpNumber - ld a, [EngineBuffer1] + ld a, [wElevatorPointerBank] ld bc, 3 call FarCopyBytes ret ; 134dd -Function134dd: ; 134dd +Elevator_AskWhichFloor: ; 134dd call LoadStandardMenuDataHeader ld hl, Elevator_WhichFloorText call PrintText @@ -134,13 +133,13 @@ Function134dd: ; 134dd call HandleScrollingMenu call WriteBackup ld a, [wMenuJoypad] - cp $2 - jr z, .asm_1350b + cp B_BUTTON + jr z, .cancel xor a - ld a, [wcf77] + ld a, [wScrollingMenuCursorPosition] ret -.asm_1350b +.cancel scf ret ; 1350d @@ -178,10 +177,10 @@ Elevator_CurrentFloorText: ; 13537 Elevator_GetCurrentFloorString: ; 1353f push hl - ld a, [wd041] + ld a, [wElevatorOriginFloor] ld e, a ld d, 0 - ld hl, wd0f1 + ld hl, CurElevatorFloors add hl, de ld a, [hl] pop de @@ -201,7 +200,7 @@ Elevator_MenuData2: ; 0x13558 db $10 ; flags db 4, 0 ; rows, columns db 1 ; horizontal spacing - dbw 0, OBPals + 8 * 6 + dbw 0, CurElevator dba GetElevatorFlorStrings dba NULL dba NULL @@ -209,7 +208,6 @@ Elevator_MenuData2: ; 0x13558 GetElevatorFlorStrings: ; 13568 ld a, [MenuSelection] - GetFloorString: ; 1356b push de call FloorToString diff --git a/event/itemfinder.asm b/event/itemfinder.asm index 8bef235d3..5e5e9c40b 100755 --- a/event/itemfinder.asm +++ b/event/itemfinder.asm @@ -10,7 +10,7 @@ ItemFinder: ; 12580 .resume call QueueScript ld a, $1 - ld [wd0ec], a + ld [wItemEffectSucceeded], a ret ; 12599 diff --git a/event/sacred_ash.asm b/event/sacred_ash.asm index 88d49b935..cc46eac9f 100755 --- a/event/sacred_ash.asm +++ b/event/sacred_ash.asm @@ -1,14 +1,14 @@ _SacredAsh: ; 507e6 ld a, $0 - ld [wd0ec], a + ld [wItemEffectSucceeded], a call CheckAnyFaintedMon ret nc ld hl, SacredAshScript call QueueScript ld a, $1 - ld [wd0ec], a + ld [wItemEffectSucceeded], a ret ; 507fb diff --git a/event/squirtbottle.asm b/event/squirtbottle.asm index b59cdc3f1..5f43e4029 100755 --- a/event/squirtbottle.asm +++ b/event/squirtbottle.asm @@ -2,7 +2,7 @@ _Squirtbottle: ; 50730 ld hl, UnknownScript_0x5073c call QueueScript ld a, $1 - ld [wd0ec], a + ld [wItemEffectSucceeded], a ret ; 5073c diff --git a/event/sweet_scent.asm b/event/sweet_scent.asm index 73dae7dc7..79a4b5819 100755 --- a/event/sweet_scent.asm +++ b/event/sweet_scent.asm @@ -2,7 +2,7 @@ SweetScentFromMenu: ; 506bc ld hl, UnknownScript_0x506c8 call QueueScript ld a, $1 - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; 506c8 diff --git a/main.asm b/main.asm index fada846ce..7560e8b99 100644 --- a/main.asm +++ b/main.asm @@ -351,7 +351,7 @@ endr ret z ld a, [CurPartyMon] ld b, a - ld a, [wd0d8] + ld a, [wPartyMenuCursor] cp b ret nz ld a, [de] @@ -2272,7 +2272,7 @@ CutFunction: ; c785 call FieldMoveJumptable jr nc, .loop and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; c796 @@ -2491,7 +2491,7 @@ WhirlpoolBlockPointers: ; c8a4 OWFlash: ; c8ac call .CheckUseFlash and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; c8b5 @@ -2558,7 +2558,7 @@ SurfFunction: ; c909 call FieldMoveJumptable jr nc, .loop and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; c91a @@ -2778,16 +2778,16 @@ AskSurfText: ; ca36 FlyFunction: ; ca3b call ClearBuffer1 -.asm_ca3e - ld hl, .data_ca4c +.loop + ld hl, .Jumptable call FieldMoveJumptable - jr nc, .asm_ca3e + jr nc, .loop and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; ca4c -.data_ca4c +.Jumptable dw .TryFly dw .DoFly dw .FailFly @@ -2875,7 +2875,7 @@ FlyFunction: ; ca3b Functioncade: ; cade call AttemptToWaterfall and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; cae7 @@ -3015,7 +3015,7 @@ dig_incave call FieldMoveJumptable jr nc, .loop and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; cbb2 @@ -3149,7 +3149,7 @@ TeleportFunction: ; cc61 call FieldMoveJumptable jr nc, .loop and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; cc72 @@ -3240,7 +3240,7 @@ Script_UsedTeleport: ; 0xccbb StrengthFunction: ; cce5 call .TryStrength and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; ccee @@ -3397,7 +3397,7 @@ WhirlpoolFunction: ; cd9d call FieldMoveJumptable jr nc, .loop and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; cdae @@ -3554,7 +3554,7 @@ UnknownText_0xce78: ; 0xce78 HeadbuttFunction: ; ce7d call TryHeadbuttFromMenu and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; ce86 @@ -3646,7 +3646,7 @@ UnknownText_0xcee6: ; 0xcee6 RockSmashFunction: ; ceeb call TryRockSmashFromMenu and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; cef4 @@ -3775,7 +3775,7 @@ FishFunction: ; cf8e call FieldMoveJumptable jr nc, .loop and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; cfa5 @@ -3988,7 +3988,7 @@ UnknownText_0xd0ae: ; unused BikeFunction: ; d0b3 call .TryBike and $7f - ld [wd0ec], a + ld [wFieldMoveSucceeded], a ret ; d0bc @@ -4045,7 +4045,7 @@ BikeFunction: ; d0b3 ; d119 .CheckIfRegistered: ; d119 - ld a, [wd0ef] + ld a, [wUsingItemWithSelect] and a ret z ld h, d @@ -8047,7 +8047,7 @@ MenuJoyAction: ; 24609 ld [wItemQuantityBuffer], a call Function246fc dec a - ld [wcf77], a + ld [wScrollingMenuCursorPosition], a ld [wd107], a ld a, [MenuSelection] cp -1 @@ -8075,7 +8075,7 @@ MenuJoyAction: ; 24609 jp z, xor_a_dec_a call Function246fc dec a - ld [wcf77], a + ld [wScrollingMenuCursorPosition], a ld a, SELECT scf ret @@ -8335,7 +8335,7 @@ Function247f0: ; 247f0 .asm_2481a ld a, [wMenuScrollPosition] add c - ld [wcf77], a + ld [wScrollingMenuCursorPosition], a ld a, c call Function248d5 ld a, [MenuSelection] @@ -9681,10 +9681,10 @@ PlayBattleMusic: ; 2ee6c ClearBattleRAM: ; 2ef18 xor a - ld [wd0ec], a + ld [wPlayerAction], a ld [wBattleResult], a - ld hl, wd0d8 + ld hl, wPartyMenuCursor rept 3 ld [hli], a endr @@ -9726,7 +9726,7 @@ endr ld hl, hBGMapAddress xor a ld [hli], a - ld [hl], $98 + ld [hl], VBGMap0 / $100 ret ; 2ef6e @@ -9735,11 +9735,11 @@ FillBox: ; 2ef6e ; with iterating tile starting from hFillBox at hl. ; Predef $13 - ld de, 20 + ld de, SCREEN_WIDTH ld a, [wc2c6] and a - jr nz, .left + jr nz, .right ld a, [hFillBox] .x1 @@ -9760,7 +9760,7 @@ FillBox: ; 2ef6e jr nz, .x1 ret -.left +.right ; Right-aligned. push bc ld b, 0 diff --git a/maps/GoldenrodDeptStoreElevator.asm b/maps/GoldenrodDeptStoreElevator.asm index 7326fd7b5..84db2f980 100644 --- a/maps/GoldenrodDeptStoreElevator.asm +++ b/maps/GoldenrodDeptStoreElevator.asm @@ -55,7 +55,7 @@ Elevator_0x566e0: elevfloor _4F, 3, GOLDENROD_DEPT_STORE_4F elevfloor _5F, 3, GOLDENROD_DEPT_STORE_5F elevfloor _6F, 2, GOLDENROD_DEPT_STORE_6F - db $ff ; end + db -1 ; end GoldenrodDeptStoreElevator_MapEventHeader: diff --git a/misc/mobile_12.asm b/misc/mobile_12.asm index e0a8a3173..bcf9ef18f 100755 --- a/misc/mobile_12.asm +++ b/misc/mobile_12.asm @@ -426,7 +426,7 @@ Function48383: ; 48383 (12:4383) ret Function483bb: ; 483bb (12:43bb) - ld hl, wcf77 + ld hl, wScrollingMenuCursorPosition ld a, [hl] inc a ld [wd474], a diff --git a/misc/mobile_22.asm b/misc/mobile_22.asm index ce7b9c7c9..a231e632d 100644 --- a/misc/mobile_22.asm +++ b/misc/mobile_22.asm @@ -3473,7 +3473,7 @@ Function8a62c: ; 8a62c (22:662c) jr z, .asm_8a66a ld [MenuSelection], a ld b, a - ld a, [wcf77] + ld a, [wScrollingMenuCursorPosition] inc a ld [wd034], a push bc diff --git a/misc/mobile_22_2.asm b/misc/mobile_22_2.asm index e9e52bfeb..451a6987d 100644 --- a/misc/mobile_22_2.asm +++ b/misc/mobile_22_2.asm @@ -818,7 +818,7 @@ Function8b7bd: ; 8b7bd and a jr z, .asm_8b7ea dec a - ld [wcf77], a + ld [wScrollingMenuCursorPosition], a .asm_8b7ea hlcoord 0, 2 diff --git a/wram.asm b/wram.asm index a05e606a9..3cb2c9d88 100644 --- a/wram.asm +++ b/wram.asm @@ -1495,8 +1495,7 @@ MenuSelection:: ds 1 ; cf74 wcf75:: ds 1 wcf76:: ds 1 -wCurrPocketCursorPosition:: -wcf77:: ds 1 +wScrollingMenuCursorPosition:: ds 1 wWindowStackSize:: ds 9 ; menu data header @@ -1792,6 +1791,7 @@ wd03b:: ds 3 MenuItemsList:: CurFruitTree:: CurInput:: +wElevatorPointerBank:: EngineBuffer1:: ; d03e ds 1 @@ -1799,15 +1799,18 @@ wd03f:: wJumpStdScriptBuffer:: CurFruit:: ; d03f MartPointerBank:: +wElevatorPointerLo:: EngineBuffer2:: ds 1 wd040:: +wElevatorPointerHi:: MartPointer:: ; d040 EngineBuffer3:: ds 1 wd041:: +wElevatorOriginFloor:: EngineBuffer4:: wTempTrainerHeader:: wTempTrainerEventFlagLo:: @@ -1877,8 +1880,8 @@ CurMoveNum:: ; d0d5 wLastPocket:: ds 1 wd0d7:: ds 1 -wPartyMenuCursor:: -wd0d8:: ds 1 +wd0d8:: +wPartyMenuCursor:: ds 1 wItemsPocketCursor:: ds 1 wKeyItemsPocketCursor:: ds 1 wBallsPocketCursor:: ds 1 @@ -1904,7 +1907,7 @@ wPlayerAction:: ; 1 - use item ; 2 - switch wSolvedUnownPuzzle:: -wd0ec:: ds 1 + ds 1 ; d0ec VramState:: ; d0ed ; bit 0: overworld sprite updating on/off @@ -1914,18 +1917,19 @@ VramState:: ; d0ed ds 1 wBattleResult:: ds 1 -wd0ef:: ds 1 +wUsingItemWithSelect:: ds 1 CurMart:: ds 16 +CurMartEnd:: ds CurMart - @ -wd0f0:: ds 1 +CurElevator:: ds 1 wd0f1:: +CurElevatorFloors:: wCurMessageIndex:: ds 1 wd0f2:: wMailboxCount:: ds 1 wMailboxItems:: ds MAILBOX_CAPACITY wMailboxEnd:: ds 1 ; d1fe ds 2 -CurMartEnd:: wd100:: ds 1 wd101:: ds 1