2018-06-24 07:09:41 -07:00
|
|
|
HandleStoneQueue::
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2018-04-04 21:35:14 -07:00
|
|
|
push af
|
|
|
|
|
|
|
|
call SwitchToMapScriptsBank
|
|
|
|
call .WarpAction
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.WarpAction:
|
2018-04-04 21:35:14 -07:00
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
cp $ff
|
|
|
|
jr z, .nope
|
|
|
|
|
|
|
|
ld l, a
|
|
|
|
push hl
|
|
|
|
call .IsObjectOnWarp
|
|
|
|
pop hl
|
|
|
|
jr nc, .nope
|
|
|
|
ld d, a
|
|
|
|
ld e, l
|
|
|
|
call .IsObjectInStoneTable
|
|
|
|
jr nc, .nope
|
|
|
|
call CallMapScript
|
|
|
|
farcall EnableScriptMode
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.nope
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.IsObjectOnWarp:
|
2018-04-04 21:35:14 -07:00
|
|
|
push de
|
|
|
|
|
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld hl, OBJECT_NEXT_MAP_Y
|
|
|
|
add hl, de
|
|
|
|
ld e, [hl]
|
|
|
|
|
|
|
|
sub 4
|
|
|
|
ld d, a
|
|
|
|
ld a, e
|
|
|
|
sub 4
|
|
|
|
ld e, a
|
|
|
|
call .check_on_warp
|
|
|
|
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.check_on_warp
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapWarpsPointer
|
2018-04-04 21:35:14 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapWarpCount]
|
2018-04-04 21:35:14 -07:00
|
|
|
and a
|
|
|
|
jr z, .nope2
|
|
|
|
|
|
|
|
.loop
|
|
|
|
push af
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
|
|
|
jr nz, .not_on_warp
|
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
cp d
|
|
|
|
jr nz, .not_on_warp
|
|
|
|
jr .found_warp
|
|
|
|
|
|
|
|
.not_on_warp
|
|
|
|
ld a, 5
|
|
|
|
add l
|
|
|
|
ld l, a
|
|
|
|
jr nc, .no_carry
|
|
|
|
inc h
|
|
|
|
.no_carry
|
|
|
|
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
.nope2
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.found_warp
|
|
|
|
pop af
|
|
|
|
ld d, a
|
2018-09-09 12:09:51 -07:00
|
|
|
ld a, [wCurMapWarpCount]
|
2018-04-04 21:35:14 -07:00
|
|
|
sub d
|
|
|
|
inc a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.IsObjectInStoneTable:
|
2018-04-04 21:35:14 -07:00
|
|
|
inc e
|
|
|
|
ld hl, CMDQUEUE_ADDR
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
.loop2
|
|
|
|
ld a, [hli]
|
|
|
|
cp $ff
|
|
|
|
jr z, .nope3
|
|
|
|
cp d
|
|
|
|
jr nz, .next_inc3
|
|
|
|
ld a, [hli]
|
|
|
|
cp e
|
|
|
|
jr nz, .next_inc2
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
jr .yes
|
|
|
|
|
|
|
|
.next_inc3
|
|
|
|
inc hl
|
|
|
|
|
|
|
|
.next_inc2
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
jr .loop2
|
|
|
|
|
|
|
|
.nope3
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.yes
|
|
|
|
scf
|
|
|
|
ret
|