2013-11-23 07:33:53 +00:00
|
|
|
; More overworld event handling.
|
|
|
|
|
2013-11-23 07:51:48 +00:00
|
|
|
|
2015-07-19 03:45:39 +00:00
|
|
|
WarpToSpawnPoint:: ; 97c28
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wStatusFlags2
|
2015-12-26 16:31:56 +00:00
|
|
|
res 1, [hl] ; safari zone?
|
2015-11-13 05:49:27 +00:00
|
|
|
res 2, [hl] ; bug contest
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97c30
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
RunMemScript:: ; 97c30
|
|
|
|
; If there is no script here, we don't need to be here.
|
|
|
|
ld a, [wMapReentryScriptQueueFlag]
|
2013-11-23 07:33:53 +00:00
|
|
|
and a
|
|
|
|
ret z
|
2015-10-24 14:34:19 +00:00
|
|
|
; Execute the script at (wMapReentryScriptBank):(wMapReentryScriptAddress).
|
|
|
|
ld hl, wMapReentryScriptAddress
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-10-24 14:34:19 +00:00
|
|
|
ld a, [wMapReentryScriptBank]
|
2013-11-23 07:33:53 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
2015-10-24 14:34:19 +00:00
|
|
|
; Clear the buffer for the next script.
|
2013-11-23 07:33:53 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2015-10-24 14:34:19 +00:00
|
|
|
ld hl, wMapReentryScriptQueueFlag
|
2013-11-23 07:33:53 +00:00
|
|
|
ld bc, 8
|
|
|
|
call ByteFill
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
; 97c4f
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
LoadScriptBDE:: ; 97c4f
|
|
|
|
; If there's already a script here, don't overwrite.
|
|
|
|
ld hl, wMapReentryScriptQueueFlag
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret nz
|
2015-10-24 14:34:19 +00:00
|
|
|
; Set the flag
|
2013-11-23 07:33:53 +00:00
|
|
|
ld [hl], 1
|
|
|
|
inc hl
|
2015-10-24 14:34:19 +00:00
|
|
|
; Load the script pointer b:de into (wMapReentryScriptBank):(wMapReentryScriptAddress)
|
2013-11-23 07:33:53 +00:00
|
|
|
ld [hl], b
|
|
|
|
inc hl
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 97c5f
|
|
|
|
|
2017-12-24 18:46:34 +00:00
|
|
|
TryTileCollisionEvent:: ; 97c5f
|
2013-11-23 07:33:53 +00:00
|
|
|
call GetFacingTileCoord
|
|
|
|
ld [EngineBuffer1], a
|
|
|
|
ld c, a
|
2017-12-24 18:46:34 +00:00
|
|
|
farcall CheckFacingTileForStdScript
|
2015-07-16 22:10:10 +00:00
|
|
|
jr c, .done
|
2013-11-23 07:33:53 +00:00
|
|
|
|
|
|
|
call CheckCutTreeTile
|
|
|
|
jr nz, .whirlpool
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall TryCutOW
|
2015-07-16 22:10:10 +00:00
|
|
|
jr .done
|
2013-11-23 07:33:53 +00:00
|
|
|
|
|
|
|
.whirlpool
|
|
|
|
ld a, [EngineBuffer1]
|
|
|
|
call CheckWhirlpoolTile
|
|
|
|
jr nz, .waterfall
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall TryWhirlpoolOW
|
2015-07-16 22:10:10 +00:00
|
|
|
jr .done
|
2013-11-23 07:33:53 +00:00
|
|
|
|
|
|
|
.waterfall
|
|
|
|
ld a, [EngineBuffer1]
|
|
|
|
call CheckWaterfallTile
|
|
|
|
jr nz, .headbutt
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall TryWaterfallOW
|
2015-07-16 22:10:10 +00:00
|
|
|
jr .done
|
2013-11-23 07:33:53 +00:00
|
|
|
|
|
|
|
.headbutt
|
|
|
|
ld a, [EngineBuffer1]
|
|
|
|
call CheckHeadbuttTreeTile
|
|
|
|
jr nz, .surf
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall TryHeadbuttOW
|
2015-07-16 22:10:10 +00:00
|
|
|
jr c, .done
|
|
|
|
jr .noevent
|
2013-11-23 07:33:53 +00:00
|
|
|
|
|
|
|
.surf
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall TrySurfOW
|
2015-07-16 22:10:10 +00:00
|
|
|
jr nc, .noevent
|
|
|
|
jr .done
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-07-16 22:10:10 +00:00
|
|
|
.noevent
|
2013-11-23 07:33:53 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-16 22:10:10 +00:00
|
|
|
.done
|
2013-11-23 07:33:53 +00:00
|
|
|
call PlayClickSFX
|
|
|
|
ld a, $ff
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 97cc0
|
|
|
|
|
|
|
|
|
2015-10-08 01:27:32 +00:00
|
|
|
RandomEncounter:: ; 97cc0
|
|
|
|
; Random encounter
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-08 01:27:32 +00:00
|
|
|
call CheckWildEncounterCooldown
|
2015-10-01 20:55:24 +00:00
|
|
|
jr c, .nope
|
|
|
|
call CanUseSweetScent
|
|
|
|
jr nc, .nope
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wStatusFlags2
|
2015-11-01 14:38:48 +00:00
|
|
|
bit 2, [hl] ; bug contest
|
2015-10-01 20:55:24 +00:00
|
|
|
jr nz, .bug_contest
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall TryWildEncounter
|
2015-10-01 20:55:24 +00:00
|
|
|
jr nz, .nope
|
|
|
|
jr .ok
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.bug_contest
|
|
|
|
call _TryWildEncounter_BugContest
|
|
|
|
jr nc, .nope
|
|
|
|
jr .ok_bug_contest
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.nope
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.ok
|
2015-10-08 01:27:32 +00:00
|
|
|
ld a, BANK(WildBattleScript)
|
|
|
|
ld hl, WildBattleScript
|
2015-10-01 20:55:24 +00:00
|
|
|
jr .done
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.ok_bug_contest
|
2015-07-15 19:48:44 +00:00
|
|
|
ld a, BANK(BugCatchingContestBattleScript)
|
|
|
|
ld hl, BugCatchingContestBattleScript
|
2015-10-01 20:55:24 +00:00
|
|
|
jr .done
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.done
|
2013-11-23 07:33:53 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 97cf9
|
|
|
|
|
2015-10-08 01:27:32 +00:00
|
|
|
WildBattleScript: ; 97cf9
|
2015-12-02 02:54:11 +00:00
|
|
|
randomwildmon
|
2013-11-23 07:33:53 +00:00
|
|
|
startbattle
|
2015-12-26 23:11:55 +00:00
|
|
|
reloadmapafterbattle
|
2013-11-23 07:33:53 +00:00
|
|
|
end
|
|
|
|
; 97cfd
|
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
CanUseSweetScent:: ; 97cfd
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wStatusFlags
|
2013-11-23 07:33:53 +00:00
|
|
|
bit 5, [hl]
|
2015-10-01 20:55:24 +00:00
|
|
|
jr nz, .no
|
2017-12-24 18:08:38 +00:00
|
|
|
ld a, [wEnvironment]
|
2015-11-01 14:38:48 +00:00
|
|
|
cp CAVE
|
2015-10-01 20:55:24 +00:00
|
|
|
jr z, .ice_check
|
2015-11-01 14:38:48 +00:00
|
|
|
cp DUNGEON
|
2015-10-01 20:55:24 +00:00
|
|
|
jr z, .ice_check
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckGrassCollision
|
2015-10-01 20:55:24 +00:00
|
|
|
jr nc, .no
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.ice_check
|
2016-01-11 07:28:09 +00:00
|
|
|
ld a, [PlayerStandingTile]
|
2013-11-23 07:33:53 +00:00
|
|
|
call CheckIceTile
|
2015-10-01 20:55:24 +00:00
|
|
|
jr z, .no
|
2013-11-23 07:33:53 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.no
|
2013-11-23 07:33:53 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 97d23
|
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
_TryWildEncounter_BugContest: ; 97d23
|
2015-07-23 07:41:52 +00:00
|
|
|
call TryWildEncounter_BugContest
|
2013-11-23 07:33:53 +00:00
|
|
|
ret nc
|
2015-10-01 20:55:24 +00:00
|
|
|
call ChooseWildEncounter_BugContest
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckRepelEffect
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97d31
|
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
ChooseWildEncounter_BugContest:: ; 97d31
|
2013-11-23 07:33:53 +00:00
|
|
|
; Pick a random mon out of ContestMons.
|
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.loop
|
2013-11-23 07:33:53 +00:00
|
|
|
call Random
|
|
|
|
cp 100 << 1
|
2015-10-01 20:55:24 +00:00
|
|
|
jr nc, .loop
|
2013-11-23 07:33:53 +00:00
|
|
|
srl a
|
|
|
|
|
|
|
|
ld hl, ContestMons
|
|
|
|
ld de, 4
|
2016-04-10 18:42:14 +00:00
|
|
|
.CheckMon:
|
2013-11-23 07:33:53 +00:00
|
|
|
sub [hl]
|
|
|
|
jr c, .GotMon
|
|
|
|
add hl, de
|
|
|
|
jr .CheckMon
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.GotMon:
|
2013-11-23 07:33:53 +00:00
|
|
|
inc hl
|
|
|
|
|
|
|
|
; Species
|
|
|
|
ld a, [hli]
|
2015-07-23 07:41:52 +00:00
|
|
|
ld [TempWildMonSpecies], a
|
2013-11-23 07:33:53 +00:00
|
|
|
|
|
|
|
; Min level
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
|
|
|
|
; Max level
|
|
|
|
ld a, [hl]
|
|
|
|
|
|
|
|
sub d
|
|
|
|
jr nz, .RandomLevel
|
|
|
|
|
|
|
|
; If min and max are the same.
|
|
|
|
ld a, d
|
|
|
|
jr .GotLevel
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.RandomLevel:
|
2013-11-23 07:33:53 +00:00
|
|
|
; Get a random level between the min and max.
|
|
|
|
ld c, a
|
|
|
|
inc c
|
|
|
|
call Random
|
|
|
|
ld a, [hRandomAdd]
|
|
|
|
call SimpleDivide
|
|
|
|
add d
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.GotLevel:
|
2013-11-23 07:33:53 +00:00
|
|
|
ld [CurPartyLevel], a
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 97d64
|
|
|
|
|
2015-07-23 07:41:52 +00:00
|
|
|
TryWildEncounter_BugContest: ; 97d64
|
2016-01-11 07:28:09 +00:00
|
|
|
ld a, [PlayerStandingTile]
|
2015-07-23 07:41:52 +00:00
|
|
|
call CheckSuperTallGrassTile
|
2015-11-01 14:38:48 +00:00
|
|
|
ld b, 40 percent
|
2015-10-01 20:55:24 +00:00
|
|
|
jr z, .ok
|
2015-11-01 14:38:48 +00:00
|
|
|
ld b, 20 percent
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-01 20:55:24 +00:00
|
|
|
.ok
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall ApplyMusicEffectOnEncounterRate
|
|
|
|
farcall ApplyCleanseTagEffectOnEncounterRate
|
2013-11-23 07:33:53 +00:00
|
|
|
call Random
|
|
|
|
ld a, [hRandomAdd]
|
|
|
|
cp b
|
|
|
|
ret c
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 97d87
|
|
|
|
|
2017-12-12 03:59:30 +00:00
|
|
|
|
2017-12-11 18:47:58 +00:00
|
|
|
INCLUDE "data/wild/bug_contest_mons.asm"
|
2017-12-12 03:59:30 +00:00
|
|
|
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
DoBikeStep:: ; 97db3
|
2013-11-23 07:33:53 +00:00
|
|
|
nop
|
|
|
|
nop
|
2015-10-24 14:34:19 +00:00
|
|
|
; If the bike shop owner doesn't have our number, or
|
|
|
|
; if we've already gotten the call, we don't have to
|
|
|
|
; be here.
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wStatusFlags2
|
2015-11-22 17:01:58 +00:00
|
|
|
bit 4, [hl] ; bike shop call
|
2015-07-17 21:17:10 +00:00
|
|
|
jr z, .NoCall
|
2015-10-24 14:34:19 +00:00
|
|
|
|
|
|
|
; If we're not on the bike, we don't have to be here.
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [PlayerState]
|
2015-10-24 14:34:19 +00:00
|
|
|
cp PLAYER_BIKE
|
2015-07-17 21:17:10 +00:00
|
|
|
jr nz, .NoCall
|
2015-10-24 14:34:19 +00:00
|
|
|
|
|
|
|
; If we're not in an area of phone service, we don't
|
|
|
|
; have to be here.
|
2015-07-20 07:51:52 +00:00
|
|
|
call GetMapHeaderPhoneServiceNybble
|
2013-11-23 07:33:53 +00:00
|
|
|
and a
|
2015-07-17 21:17:10 +00:00
|
|
|
jr nz, .NoCall
|
2015-10-24 14:34:19 +00:00
|
|
|
|
|
|
|
; Check the bike step count and check whether we've
|
|
|
|
; taken 65536 of them yet.
|
|
|
|
ld hl, wBikeStep
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
ld e, [hl]
|
2015-10-24 14:34:19 +00:00
|
|
|
cp 255
|
|
|
|
jr nz, .increment
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, e
|
2015-10-24 14:34:19 +00:00
|
|
|
cp 255
|
|
|
|
jr z, .dont_increment
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.increment
|
2013-11-23 07:33:53 +00:00
|
|
|
inc de
|
|
|
|
ld [hl], e
|
|
|
|
dec hl
|
|
|
|
ld [hl], d
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.dont_increment
|
|
|
|
; If we've taken at least 1024 steps, have the bike
|
|
|
|
; shop owner try to call us.
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, d
|
2017-12-25 18:40:10 +00:00
|
|
|
cp HIGH(1024)
|
2015-07-17 21:17:10 +00:00
|
|
|
jr c, .NoCall
|
2015-10-24 14:34:19 +00:00
|
|
|
|
|
|
|
; If a call has already been queued, don't overwrite
|
|
|
|
; that call.
|
2015-07-17 21:17:10 +00:00
|
|
|
ld a, [wSpecialPhoneCallID]
|
2013-11-23 07:33:53 +00:00
|
|
|
and a
|
2015-07-17 21:17:10 +00:00
|
|
|
jr nz, .NoCall
|
2015-10-24 14:34:19 +00:00
|
|
|
|
|
|
|
; Queue the call.
|
|
|
|
ld a, SPECIALCALL_BIKESHOP
|
2015-07-17 21:17:10 +00:00
|
|
|
ld [wSpecialPhoneCallID], a
|
2013-11-23 07:33:53 +00:00
|
|
|
xor a
|
2015-07-17 21:17:10 +00:00
|
|
|
ld [wSpecialPhoneCallID + 1], a
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wStatusFlags2
|
2015-11-22 17:01:58 +00:00
|
|
|
res 4, [hl] ; bike shop call
|
2013-11-23 07:33:53 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.NoCall:
|
2013-11-23 07:33:53 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 97df9
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
ClearCmdQueue:: ; 97df9
|
|
|
|
ld hl, wCmdQueue
|
2015-07-17 21:17:10 +00:00
|
|
|
ld de, 6
|
|
|
|
ld c, 4
|
2013-11-23 07:33:53 +00:00
|
|
|
xor a
|
2015-07-17 21:17:10 +00:00
|
|
|
.loop
|
2013-11-23 07:33:53 +00:00
|
|
|
ld [hl], a
|
|
|
|
add hl, de
|
|
|
|
dec c
|
2015-07-17 21:17:10 +00:00
|
|
|
jr nz, .loop
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97e08
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
HandleCmdQueue:: ; 97e08
|
|
|
|
ld hl, wCmdQueue
|
2013-11-23 07:33:53 +00:00
|
|
|
xor a
|
2015-11-02 17:54:27 +00:00
|
|
|
.loop
|
2015-11-02 16:15:32 +00:00
|
|
|
ld [hMapObjectIndexBuffer], a
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-11-02 17:54:27 +00:00
|
|
|
jr z, .skip
|
2013-11-23 07:33:53 +00:00
|
|
|
push hl
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2015-11-19 04:16:25 +00:00
|
|
|
call HandleQueuedCommand
|
2013-11-23 07:33:53 +00:00
|
|
|
pop hl
|
|
|
|
|
2015-11-02 17:54:27 +00:00
|
|
|
.skip
|
2015-11-19 04:16:25 +00:00
|
|
|
ld de, CMDQUEUE_ENTRY_SIZE
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
2015-11-02 16:15:32 +00:00
|
|
|
ld a, [hMapObjectIndexBuffer]
|
2013-11-23 07:33:53 +00:00
|
|
|
inc a
|
2015-11-19 04:16:25 +00:00
|
|
|
cp CMDQUEUE_CAPACITY
|
2015-11-02 17:54:27 +00:00
|
|
|
jr nz, .loop
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97e25
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
GetNthCmdQueueEntry: ; 97e25 unreferenced
|
|
|
|
ld hl, wCmdQueue
|
|
|
|
ld bc, CMDQUEUE_ENTRY_SIZE
|
2013-11-23 07:33:53 +00:00
|
|
|
call AddNTimes
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
ret
|
|
|
|
; 97e31
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
WriteCmdQueue:: ; 97e31
|
2013-11-23 07:33:53 +00:00
|
|
|
push bc
|
|
|
|
push de
|
2015-11-19 04:16:25 +00:00
|
|
|
call .GetNextEmptyEntry
|
2013-11-23 07:33:53 +00:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
ret c
|
|
|
|
ld a, b
|
2015-11-19 04:16:25 +00:00
|
|
|
ld bc, CMDQUEUE_ENTRY_SIZE - 1
|
2013-11-23 07:33:53 +00:00
|
|
|
call FarCopyBytes
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 97e45
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.GetNextEmptyEntry: ; 97e45
|
|
|
|
ld hl, wCmdQueue
|
|
|
|
ld de, CMDQUEUE_ENTRY_SIZE
|
|
|
|
ld c, CMDQUEUE_CAPACITY
|
|
|
|
.loop
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-11-19 04:16:25 +00:00
|
|
|
jr z, .done
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
|
|
|
dec c
|
2015-11-19 04:16:25 +00:00
|
|
|
jr nz, .loop
|
2013-11-23 07:33:53 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.done
|
|
|
|
ld a, CMDQUEUE_CAPACITY
|
2013-11-23 07:33:53 +00:00
|
|
|
sub c
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 97e5c
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
DelCmdQueue:: ; 97e5c
|
|
|
|
ld hl, wCmdQueue
|
|
|
|
ld de, CMDQUEUE_ENTRY_SIZE
|
|
|
|
ld c, CMDQUEUE_CAPACITY
|
|
|
|
.loop
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hl]
|
|
|
|
cp b
|
2015-11-19 04:16:25 +00:00
|
|
|
jr z, .done
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
|
|
|
dec c
|
2015-11-19 04:16:25 +00:00
|
|
|
jr nz, .loop
|
2013-11-23 07:33:53 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.done
|
2013-11-23 07:33:53 +00:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 97e72
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
_DelCmdQueue: ; 97e72
|
|
|
|
ld hl, CMDQUEUE_TYPE
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], 0
|
|
|
|
ret
|
|
|
|
; 97e79
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
HandleQueuedCommand: ; 97e79
|
|
|
|
ld hl, CMDQUEUE_TYPE
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp 5
|
2015-11-19 04:16:25 +00:00
|
|
|
jr c, .okay
|
2013-11-23 07:33:53 +00:00
|
|
|
xor a
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.okay
|
2013-11-23 07:33:53 +00:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2016-05-17 12:40:42 +00:00
|
|
|
ld hl, .Jumptable
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
2016-05-10 16:31:49 +00:00
|
|
|
add hl, de
|
|
|
|
add hl, de
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hli]
|
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
pop af
|
|
|
|
rst FarCall
|
|
|
|
ret
|
|
|
|
; 97e94
|
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.Jumptable: ; 97e94
|
2015-11-19 04:16:25 +00:00
|
|
|
dba CmdQueue_Null
|
|
|
|
dba CmdQueue_Null2
|
|
|
|
dba CmdQueue_StoneTable
|
|
|
|
dba CmdQueue_Type3
|
|
|
|
dba CmdQueue_Type4
|
2013-11-23 07:33:53 +00:00
|
|
|
; 97ea3
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueueAnonymousJumptable: ; 97ea3
|
|
|
|
ld hl, CMDQUEUE_05
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
; 97eab
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueueAnonJT_Increment: ; 97eab
|
|
|
|
ld hl, CMDQUEUE_05
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 97eb1
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueueAnonJT_Decrement: ; 97eb1
|
|
|
|
ld hl, CMDQUEUE_05
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
; 97eb7
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueue_Null: ; 97eb7
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97eb8
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueue_Null2: ; 97eb8
|
2015-10-24 14:34:19 +00:00
|
|
|
call ret_2f3e
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97ebc
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueue_Type4: ; 97ebc
|
|
|
|
call CmdQueueAnonymousJumptable
|
2015-12-27 02:59:03 +00:00
|
|
|
; anonymous dw
|
2015-11-19 04:16:25 +00:00
|
|
|
dw .zero
|
|
|
|
dw .one
|
2013-11-23 07:33:53 +00:00
|
|
|
; 97ec3
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.zero ; 97ec3
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, [hSCY]
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 4
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-11-19 04:16:25 +00:00
|
|
|
call CmdQueueAnonJT_Increment
|
2016-04-10 19:01:49 +00:00
|
|
|
.one ; 97ecd
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 1
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
|
|
|
ld [hl], a
|
2016-05-17 12:40:42 +00:00
|
|
|
jr z, .finish
|
2013-11-23 07:33:53 +00:00
|
|
|
and $1
|
2016-05-17 12:40:42 +00:00
|
|
|
jr z, .add
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 2
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hSCY]
|
|
|
|
sub [hl]
|
|
|
|
ld [hSCY], a
|
|
|
|
ret
|
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.add
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 2
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hSCY]
|
|
|
|
add [hl]
|
|
|
|
ld [hSCY], a
|
|
|
|
ret
|
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
.finish
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 4
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [hSCY], a
|
2015-11-19 04:16:25 +00:00
|
|
|
call _DelCmdQueue
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97ef9
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueue_Type3: ; 97ef9
|
|
|
|
call CmdQueueAnonymousJumptable
|
2015-12-27 02:59:03 +00:00
|
|
|
; anonymous dw
|
2015-11-19 04:16:25 +00:00
|
|
|
dw .zero
|
|
|
|
dw .one
|
|
|
|
dw .two
|
2013-11-23 07:33:53 +00:00
|
|
|
; 97f02
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.zero ; 97f02
|
2015-11-19 04:16:25 +00:00
|
|
|
call .IsPlayerFacingDown
|
|
|
|
jr z, .PlayerNotFacingDown
|
|
|
|
call CmdQueueAnonJT_Increment
|
2016-04-10 19:01:49 +00:00
|
|
|
.one ; 97f0a
|
2015-11-19 04:16:25 +00:00
|
|
|
call .IsPlayerFacingDown
|
|
|
|
jr z, .PlayerNotFacingDown
|
|
|
|
call CmdQueueAnonJT_Increment
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 2
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-02-10 22:16:31 +00:00
|
|
|
ld [wd173], a
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97f1b
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.two ; 97f1b
|
2015-11-19 04:16:25 +00:00
|
|
|
call .IsPlayerFacingDown
|
|
|
|
jr z, .PlayerNotFacingDown
|
|
|
|
call CmdQueueAnonJT_Decrement
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 3
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-02-10 22:16:31 +00:00
|
|
|
ld [wd173], a
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
; 97f2c
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.PlayerNotFacingDown: ; 97f2c
|
2013-11-23 07:33:53 +00:00
|
|
|
ld a, $7f
|
2015-02-10 22:16:31 +00:00
|
|
|
ld [wd173], a
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, 5
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], 0
|
|
|
|
ret
|
|
|
|
; 97f38
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.IsPlayerFacingDown: ; 97f38
|
2013-11-23 07:33:53 +00:00
|
|
|
push bc
|
2015-02-10 22:16:31 +00:00
|
|
|
ld bc, PlayerStruct
|
2013-11-23 07:33:53 +00:00
|
|
|
call GetSpriteDirection
|
|
|
|
and a
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 97f42
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
CmdQueue_StoneTable: ; 97f42
|
2015-02-10 22:16:31 +00:00
|
|
|
ld de, PlayerStruct
|
2015-11-19 04:16:25 +00:00
|
|
|
ld a, NUM_OBJECT_STRUCTS
|
|
|
|
.loop
|
2013-11-23 07:33:53 +00:00
|
|
|
push af
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, OBJECT_SPRITE
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-11-19 04:16:25 +00:00
|
|
|
jr z, .next
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, OBJECT_MOVEMENTTYPE
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2017-12-09 17:24:50 +00:00
|
|
|
cp SPRITEMOVEDATA_STRENGTH_BOULDER
|
2015-11-19 04:16:25 +00:00
|
|
|
jr nz, .next
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, OBJECT_NEXT_TILE
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
call CheckPitTile
|
2015-11-19 04:16:25 +00:00
|
|
|
jr nz, .next
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
ld hl, OBJECT_DIRECTION_WALKING
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2015-11-19 04:16:25 +00:00
|
|
|
cp STANDING
|
|
|
|
jr nz, .next
|
|
|
|
call HandleStoneQueue
|
|
|
|
jr c, .fall_down_hole
|
2013-11-23 07:33:53 +00:00
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.next
|
|
|
|
ld hl, OBJECT_STRUCT_LENGTH
|
2013-11-23 07:33:53 +00:00
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
pop af
|
|
|
|
dec a
|
2015-11-19 04:16:25 +00:00
|
|
|
jr nz, .loop
|
2013-11-23 07:33:53 +00:00
|
|
|
ret
|
|
|
|
|
2015-11-19 04:16:25 +00:00
|
|
|
.fall_down_hole
|
2013-11-23 07:33:53 +00:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
; 97f7e
|