ref: fe4ef4e5951e855174cbff3da308b342b0b5bd09
parent: 42dd25b3e50569d94ca78adf47c527a9859089b5
author: PikalaxALT <[email protected]>
date: Thu Dec 17 12:51:32 EST 2015
Elevator
--- 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 @@
ret z
ld a, 1
- ld [wd0ec], a
+ ld [wPlayerAction], a
call LoadStandardMenuDataHeader
ld hl, LinkBattleSendReceiveAction
@@ -9033,7 +9033,7 @@
call WriteBackup
xor a
- ld [wd0ec], a
+ ld [wPlayerAction], a
ret
; 37a82
--- a/engine/mart.asm
+++ b/engine/mart.asm
@@ -662,7 +662,7 @@
; 15e30
.PrintBCDPrices: ; 15e30
- ld a, [wcf77]
+ ld a, [wScrollingMenuCursorPosition]
ld c, a
ld b, 0
ld hl, wMartItem1BCD
--- a/engine/selectmenu.asm
+++ b/engine/selectmenu.asm
@@ -167,11 +167,11 @@
.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
--- a/engine/switch_items.asm
+++ b/engine/switch_items.asm
@@ -3,11 +3,11 @@
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 @@
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 @@
jr .asm_2494a
.init
- ld a, [wCurrPocketCursorPosition]
+ ld a, [wScrollingMenuCursorPosition]
inc a
ld [wSwitchItem], a
ret
@@ -38,7 +38,7 @@
.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 @@
pop hl
pop bc
call Function24aab
- ld a, [wCurrPocketCursorPosition]
+ ld a, [wScrollingMenuCursorPosition]
call Function24a4d
xor a
ld [wSwitchItem], a
@@ -64,7 +64,7 @@
.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 @@
add hl, bc
pop bc
call CopyBytes
- ld a, [wCurrPocketCursorPosition]
+ ld a, [wScrollingMenuCursorPosition]
call Function24a4d
xor a
ld [wSwitchItem], a
@@ -89,12 +89,12 @@
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 @@
call Function24a5c
inc hl
push hl
- ld a, [wCurrPocketCursorPosition]
+ ld a, [wScrollingMenuCursorPosition]
call Function24a5c
inc hl
ld a, [hl]
@@ -125,7 +125,7 @@
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 @@
.asm_24a01
push af
- ld a, [wCurrPocketCursorPosition]
+ ld a, [wScrollingMenuCursorPosition]
call Function24a5c
inc hl
pop af
--- a/event/basement_key.asm
+++ b/event/basement_key.asm
@@ -19,12 +19,12 @@
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
--- a/event/card_key.asm
+++ b/event/card_key.asm
@@ -24,12 +24,12 @@
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
--- 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 @@
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 @@
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 @@
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_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 @@
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 @@
GetElevatorFlorStrings: ; 13568
ld a, [MenuSelection]
-
GetFloorString: ; 1356b
push de
call FloorToString
--- a/event/itemfinder.asm
+++ b/event/itemfinder.asm
@@ -10,7 +10,7 @@
.resume
call QueueScript
ld a, $1
- ld [wd0ec], a
+ ld [wItemEffectSucceeded], a
ret
; 12599
--- a/event/sacred_ash.asm
+++ b/event/sacred_ash.asm
@@ -1,7 +1,7 @@
_SacredAsh: ; 507e6
ld a, $0
- ld [wd0ec], a
+ ld [wItemEffectSucceeded], a
call CheckAnyFaintedMon
ret nc
@@ -8,7 +8,7 @@
ld hl, SacredAshScript
call QueueScript
ld a, $1
- ld [wd0ec], a
+ ld [wItemEffectSucceeded], a
ret
; 507fb
--- a/event/squirtbottle.asm
+++ b/event/squirtbottle.asm
@@ -2,7 +2,7 @@
ld hl, UnknownScript_0x5073c
call QueueScript
ld a, $1
- ld [wd0ec], a
+ ld [wItemEffectSucceeded], a
ret
; 5073c
--- a/event/sweet_scent.asm
+++ b/event/sweet_scent.asm
@@ -2,7 +2,7 @@
ld hl, UnknownScript_0x506c8
call QueueScript
ld a, $1
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; 506c8
--- a/main.asm
+++ b/main.asm
@@ -351,7 +351,7 @@
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 @@
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; c796
@@ -2491,7 +2491,7 @@
OWFlash: ; c8ac
call .CheckUseFlash
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; c8b5
@@ -2558,7 +2558,7 @@
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; c91a
@@ -2778,16 +2778,16 @@
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 @@
Functioncade: ; cade
call AttemptToWaterfall
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cae7
@@ -3015,7 +3015,7 @@
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cbb2
@@ -3149,7 +3149,7 @@
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cc72
@@ -3240,7 +3240,7 @@
StrengthFunction: ; cce5
call .TryStrength
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; ccee
@@ -3397,7 +3397,7 @@
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cdae
@@ -3554,7 +3554,7 @@
HeadbuttFunction: ; ce7d
call TryHeadbuttFromMenu
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; ce86
@@ -3646,7 +3646,7 @@
RockSmashFunction: ; ceeb
call TryRockSmashFromMenu
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cef4
@@ -3775,7 +3775,7 @@
call FieldMoveJumptable
jr nc, .loop
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; cfa5
@@ -3988,7 +3988,7 @@
BikeFunction: ; d0b3
call .TryBike
and $7f
- ld [wd0ec], a
+ ld [wFieldMoveSucceeded], a
ret
; d0bc
@@ -4045,7 +4045,7 @@
; d119
.CheckIfRegistered: ; d119
- ld a, [wd0ef]
+ ld a, [wUsingItemWithSelect]
and a
ret z
ld h, d
@@ -8047,7 +8047,7 @@
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 @@
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 @@
.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 @@
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 @@
ld hl, hBGMapAddress
xor a
ld [hli], a
- ld [hl], $98
+ ld [hl], VBGMap0 / $100
ret
; 2ef6e
@@ -9735,11 +9735,11 @@
; 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 @@
jr nz, .x1
ret
-.left
+.right
; Right-aligned.
push bc
ld b, 0
--- a/maps/GoldenrodDeptStoreElevator.asm
+++ b/maps/GoldenrodDeptStoreElevator.asm
@@ -55,7 +55,7 @@
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:
--- a/misc/mobile_12.asm
+++ b/misc/mobile_12.asm
@@ -426,7 +426,7 @@
ret
Function483bb: ; 483bb (12:43bb)
- ld hl, wcf77
+ ld hl, wScrollingMenuCursorPosition
ld a, [hl]
inc a
ld [wd474], a
--- a/misc/mobile_22.asm
+++ b/misc/mobile_22.asm
@@ -3473,7 +3473,7 @@
jr z, .asm_8a66a
ld [MenuSelection], a
ld b, a
- ld a, [wcf77]
+ ld a, [wScrollingMenuCursorPosition]
inc a
ld [wd034], a
push bc
--- a/misc/mobile_22_2.asm
+++ b/misc/mobile_22_2.asm
@@ -818,7 +818,7 @@
and a
jr z, .asm_8b7ea
dec a
- ld [wcf77], a
+ ld [wScrollingMenuCursorPosition], a
.asm_8b7ea
hlcoord 0, 2
--- a/wram.asm
+++ b/wram.asm
@@ -1495,8 +1495,7 @@
wcf75:: ds 1
wcf76:: ds 1
-wCurrPocketCursorPosition::
-wcf77:: ds 1
+wScrollingMenuCursorPosition:: ds 1
wWindowStackSize:: ds 9
; menu data header
@@ -1792,6 +1791,7 @@
MenuItemsList::
CurFruitTree::
CurInput::
+wElevatorPointerBank::
EngineBuffer1:: ; d03e
ds 1
@@ -1799,15 +1799,18 @@
wJumpStdScriptBuffer::
CurFruit:: ; d03f
MartPointerBank::
+wElevatorPointerLo::
EngineBuffer2::
ds 1
wd040::
+wElevatorPointerHi::
MartPointer:: ; d040
EngineBuffer3::
ds 1
wd041::
+wElevatorOriginFloor::
EngineBuffer4::
wTempTrainerHeader::
wTempTrainerEventFlagLo::
@@ -1877,8 +1880,8 @@
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 @@
; 1 - use item
; 2 - switch
wSolvedUnownPuzzle::
-wd0ec:: ds 1
+ ds 1 ; d0ec
VramState:: ; d0ed
; bit 0: overworld sprite updating on/off
@@ -1914,11 +1917,13 @@
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
@@ -1925,7 +1930,6 @@
wMailboxItems:: ds MAILBOX_CAPACITY
wMailboxEnd:: ds 1 ; d1fe
ds 2
-CurMartEnd::
wd100:: ds 1
wd101:: ds 1