2018-06-24 14:09:41 +00:00
|
|
|
Elevator::
|
2015-12-17 22:51:32 +00:00
|
|
|
call .LoadPointer
|
|
|
|
call .FindCurrentFloor
|
|
|
|
jr c, .quit
|
|
|
|
ld [wElevatorOriginFloor], a
|
|
|
|
call Elevator_AskWhichFloor
|
|
|
|
jr c, .quit
|
|
|
|
ld hl, wElevatorOriginFloor
|
2015-11-11 21:11:08 +00:00
|
|
|
cp [hl]
|
2015-12-17 22:51:32 +00:00
|
|
|
jr z, .quit
|
|
|
|
call Elevator_GoToFloor
|
2015-11-11 21:11:08 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-12-17 22:51:32 +00:00
|
|
|
.quit
|
2015-11-11 21:11:08 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.LoadPointer:
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, b
|
2015-12-17 22:51:32 +00:00
|
|
|
ld [wElevatorPointerBank], a
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, e
|
2017-12-10 03:24:43 +00:00
|
|
|
ld [wElevatorPointer], a
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, d
|
2017-12-10 03:24:43 +00:00
|
|
|
ld [wElevatorPointer + 1], a
|
2015-12-17 22:51:32 +00:00
|
|
|
call .LoadFloors
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.LoadFloors:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wCurElevator
|
2015-11-11 21:11:08 +00:00
|
|
|
ld bc, 4
|
2017-12-10 03:24:43 +00:00
|
|
|
ld hl, wElevatorPointer
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-12-17 22:51:32 +00:00
|
|
|
ld a, [wElevatorPointerBank]
|
2015-11-11 21:11:08 +00:00
|
|
|
call GetFarByte
|
|
|
|
inc hl
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2015-12-17 22:51:32 +00:00
|
|
|
.loop
|
|
|
|
ld a, [wElevatorPointerBank]
|
2015-11-11 21:11:08 +00:00
|
|
|
call GetFarByte
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
add hl, bc
|
2015-12-17 22:51:32 +00:00
|
|
|
cp -1
|
|
|
|
jr nz, .loop
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.FindCurrentFloor:
|
2017-12-10 03:24:43 +00:00
|
|
|
ld hl, wElevatorPointer
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-12-17 22:51:32 +00:00
|
|
|
ld a, [wElevatorPointerBank]
|
2015-11-11 21:11:08 +00:00
|
|
|
call GetFarByte
|
|
|
|
ld c, a
|
|
|
|
inc hl
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBackupMapGroup]
|
2015-11-11 21:11:08 +00:00
|
|
|
ld d, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBackupMapNumber]
|
2015-11-11 21:11:08 +00:00
|
|
|
ld e, a
|
2015-12-17 22:51:32 +00:00
|
|
|
ld b, 0
|
|
|
|
.loop2
|
|
|
|
ld a, [wElevatorPointerBank]
|
2015-11-11 21:11:08 +00:00
|
|
|
call GetFarByte
|
2015-12-17 22:51:32 +00:00
|
|
|
cp -1
|
|
|
|
jr z, .fail
|
2015-11-11 21:11:08 +00:00
|
|
|
inc hl
|
2016-05-04 15:46:23 +00:00
|
|
|
inc hl
|
2015-12-17 22:51:32 +00:00
|
|
|
ld a, [wElevatorPointerBank]
|
2015-11-11 21:11:08 +00:00
|
|
|
call GetFarByte
|
|
|
|
inc hl
|
|
|
|
cp d
|
2015-12-17 22:51:32 +00:00
|
|
|
jr nz, .next1
|
|
|
|
ld a, [wElevatorPointerBank]
|
2015-11-11 21:11:08 +00:00
|
|
|
call GetFarByte
|
|
|
|
inc hl
|
|
|
|
cp e
|
2015-12-17 22:51:32 +00:00
|
|
|
jr nz, .next2
|
|
|
|
jr .done
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2015-12-17 22:51:32 +00:00
|
|
|
.next1
|
2015-11-11 21:11:08 +00:00
|
|
|
inc hl
|
2015-12-17 22:51:32 +00:00
|
|
|
.next2
|
2015-11-11 21:11:08 +00:00
|
|
|
inc b
|
2015-12-17 22:51:32 +00:00
|
|
|
jr .loop2
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2015-12-17 22:51:32 +00:00
|
|
|
.done
|
2015-11-11 21:11:08 +00:00
|
|
|
xor a
|
|
|
|
ld a, b
|
|
|
|
ret
|
|
|
|
|
2015-12-17 22:51:32 +00:00
|
|
|
.fail
|
2015-11-11 21:11:08 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Elevator_GoToFloor:
|
2015-11-11 21:11:08 +00:00
|
|
|
push af
|
2017-12-10 03:24:43 +00:00
|
|
|
ld hl, wElevatorPointer
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
inc hl
|
|
|
|
pop af
|
|
|
|
ld bc, 4
|
|
|
|
call AddNTimes
|
|
|
|
inc hl
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wBackupWarpNumber
|
2015-12-17 22:51:32 +00:00
|
|
|
ld a, [wElevatorPointerBank]
|
2015-11-11 21:11:08 +00:00
|
|
|
ld bc, 3
|
|
|
|
call FarCopyBytes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Elevator_AskWhichFloor:
|
2018-01-23 21:08:43 +00:00
|
|
|
call LoadStandardMenuHeader
|
2015-11-11 21:11:08 +00:00
|
|
|
ld hl, Elevator_WhichFloorText
|
|
|
|
call PrintText
|
|
|
|
call Elevator_GetCurrentFloorText
|
2018-01-23 21:08:43 +00:00
|
|
|
ld hl, Elevator_MenuHeader
|
|
|
|
call CopyMenuHeader
|
2015-11-17 20:54:03 +00:00
|
|
|
call InitScrollingMenu
|
2015-11-11 21:11:08 +00:00
|
|
|
call UpdateSprites
|
|
|
|
xor a
|
2015-11-23 21:04:53 +00:00
|
|
|
ld [wMenuScrollPosition], a
|
2015-12-18 03:31:16 +00:00
|
|
|
call ScrollingMenu
|
2015-12-25 03:58:42 +00:00
|
|
|
call CloseWindow
|
2015-12-15 23:59:49 +00:00
|
|
|
ld a, [wMenuJoypad]
|
2015-12-17 22:51:32 +00:00
|
|
|
cp B_BUTTON
|
|
|
|
jr z, .cancel
|
2015-11-11 21:11:08 +00:00
|
|
|
xor a
|
2015-12-17 22:51:32 +00:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2015-12-17 22:51:32 +00:00
|
|
|
.cancel
|
2015-11-11 21:11:08 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
Elevator_WhichFloorText:
|
2015-11-11 21:11:08 +00:00
|
|
|
; Which floor?
|
|
|
|
text_jump UnknownText_0x1bd2bc
|
|
|
|
db "@"
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Elevator_GetCurrentFloorText:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wOptions
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
set NO_TEXT_SCROLL, [hl]
|
|
|
|
hlcoord 0, 0
|
|
|
|
ld b, 4
|
|
|
|
ld c, 8
|
|
|
|
call TextBox
|
|
|
|
hlcoord 1, 2
|
|
|
|
ld de, Elevator_CurrentFloorText
|
|
|
|
call PlaceString
|
|
|
|
hlcoord 4, 4
|
|
|
|
call Elevator_GetCurrentFloorString
|
|
|
|
pop af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wOptions], a
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Elevator_CurrentFloorText:
|
2015-11-11 21:11:08 +00:00
|
|
|
db "Now on:@"
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Elevator_GetCurrentFloorString:
|
2015-11-11 21:11:08 +00:00
|
|
|
push hl
|
2015-12-17 22:51:32 +00:00
|
|
|
ld a, [wElevatorOriginFloor]
|
2015-11-11 21:11:08 +00:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wCurElevatorFloors
|
2015-11-11 21:11:08 +00:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
pop de
|
|
|
|
call GetFloorString
|
|
|
|
ret
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
Elevator_MenuHeader:
|
2018-01-14 10:59:56 +00:00
|
|
|
db MENU_BACKUP_TILES ; flags
|
2018-01-13 21:38:14 +00:00
|
|
|
menu_coords 12, 1, 18, 9
|
2018-01-23 21:08:43 +00:00
|
|
|
dw Elevator_MenuData
|
2015-11-11 21:11:08 +00:00
|
|
|
db 1 ; default option
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
Elevator_MenuData:
|
2018-01-14 10:59:56 +00:00
|
|
|
db SCROLLINGMENU_DISPLAY_ARROWS ; flags
|
2015-11-11 21:11:08 +00:00
|
|
|
db 4, 0 ; rows, columns
|
|
|
|
db 1 ; horizontal spacing
|
2018-01-23 22:39:09 +00:00
|
|
|
dbw 0, wCurElevator
|
2018-01-11 06:45:27 +00:00
|
|
|
dba GetElevatorFloorStrings
|
2015-11-11 21:11:08 +00:00
|
|
|
dba NULL
|
|
|
|
dba NULL
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
GetElevatorFloorStrings:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMenuSelection]
|
2018-06-24 14:09:41 +00:00
|
|
|
GetFloorString:
|
2015-11-11 21:11:08 +00:00
|
|
|
push de
|
|
|
|
call FloorToString
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
jp PlaceString
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
FloorToString:
|
2015-11-11 21:11:08 +00:00
|
|
|
push de
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2018-01-11 06:45:27 +00:00
|
|
|
ld hl, ElevatorFloorNames
|
2015-11-11 21:11:08 +00:00
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-01-26 03:19:24 +00:00
|
|
|
INCLUDE "data/events/elevator_floors.asm"
|