pokecrystal/engine/events/elevator.asm

233 lines
3.3 KiB
NASM
Raw Normal View History

2015-11-11 21:11:08 +00:00
Elevator:: ; 1342d
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
; 1344a
2015-12-17 22:51:32 +00:00
.LoadPointer: ; 1344a
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
; 1345a
2015-12-17 22:51:32 +00:00
.LoadFloors: ; 1345a
ld de, CurElevator
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
; 1347d
2015-12-17 22:51:32 +00:00
.FindCurrentFloor: ; 1347d
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
ld a, [BackupMapGroup]
ld d, a
ld a, [BackupMapNumber]
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
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
; 134c0
2015-12-17 22:51:32 +00:00
Elevator_GoToFloor: ; 134c0
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
2015-11-12 16:10:19 +00:00
ld de, BackupWarpNumber
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
; 134dd
2015-12-17 22:51:32 +00:00
Elevator_AskWhichFloor: ; 134dd
call LoadStandardMenuHeader
2015-11-11 21:11:08 +00:00
ld hl, Elevator_WhichFloorText
call PrintText
call Elevator_GetCurrentFloorText
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
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
; 1350d
Elevator_WhichFloorText: ; 0x1350d
; Which floor?
text_jump UnknownText_0x1bd2bc
db "@"
; 0x13512
Elevator_GetCurrentFloorText: ; 13512
ld hl, Options
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
ld [Options], a
ret
; 13537
Elevator_CurrentFloorText: ; 13537
db "Now on:@"
; 1353f
Elevator_GetCurrentFloorString: ; 1353f
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
2015-12-17 22:51:32 +00:00
ld hl, CurElevatorFloors
2015-11-11 21:11:08 +00:00
add hl, de
ld a, [hl]
pop de
call GetFloorString
ret
; 13550
Elevator_MenuHeader: ; 0x13550
db MENU_BACKUP_TILES ; flags
menu_coords 12, 1, 18, 9
dw Elevator_MenuData
2015-11-11 21:11:08 +00:00
db 1 ; default option
; 0x13558
Elevator_MenuData: ; 0x13558
db SCROLLINGMENU_DISPLAY_ARROWS ; flags
2015-11-11 21:11:08 +00:00
db 4, 0 ; rows, columns
db 1 ; horizontal spacing
2015-12-17 22:51:32 +00:00
dbw 0, CurElevator
2018-01-11 06:45:27 +00:00
dba GetElevatorFloorStrings
2015-11-11 21:11:08 +00:00
dba NULL
dba NULL
; 13568
2018-01-11 06:45:27 +00:00
GetElevatorFloorStrings: ; 13568
2015-11-11 21:11:08 +00:00
ld a, [MenuSelection]
GetFloorString: ; 1356b
push de
call FloorToString
ld d, h
ld e, l
pop hl
jp PlaceString
; 13575
FloorToString: ; 13575
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
add hl, de
2015-11-11 21:11:08 +00:00
ld a, [hli]
ld h, [hl]
ld l, a
pop de
ret
; 13583
2018-01-11 06:45:27 +00:00
INCLUDE "data/elevator_floors.asm"