2018-01-09 05:36:15 +00:00
|
|
|
INCLUDE "constants.asm"
|
|
|
|
|
2013-11-23 07:51:48 +00:00
|
|
|
|
2017-06-17 23:14:55 +00:00
|
|
|
SECTION "Events", ROMX
|
2013-11-23 07:51:48 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
OverworldLoop::
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMapStatus], a
|
2013-12-27 10:56:23 +00:00
|
|
|
.loop
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapStatus]
|
2013-12-27 10:56:23 +00:00
|
|
|
ld hl, .jumps
|
2013-11-22 10:04:32 +00:00
|
|
|
rst JumpTable
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapStatus]
|
2013-11-22 10:04:32 +00:00
|
|
|
cp 3 ; done
|
2013-12-27 10:56:23 +00:00
|
|
|
jr nz, .loop
|
2013-11-22 10:04:32 +00:00
|
|
|
.done
|
|
|
|
ret
|
|
|
|
|
2013-12-27 10:56:23 +00:00
|
|
|
.jumps
|
|
|
|
dw StartMap
|
|
|
|
dw EnterMap
|
|
|
|
dw HandleMap
|
2013-11-22 10:04:32 +00:00
|
|
|
dw .done
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DisableEvents:
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptFlags3], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
EnableEvents::
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, $ff
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptFlags3], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckBit5_ScriptFlags3:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
bit 5, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DisableWarpsConnxns:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
res 2, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DisableCoordEvents:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
res 1, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DisableStepCount:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
res 0, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DisableWildEncounters:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
res 4, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
EnableWarpsConnxns:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
set 2, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
EnableCoordEvents:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
set 1, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
EnableStepCount:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
set 0, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
EnableWildEncounters:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
set 4, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckWarpConnxnScriptFlag:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
bit 2, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckCoordEventScriptFlag:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
bit 1, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckStepCountScriptFlag:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
bit 0, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckWildEncountersScriptFlag:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
bit 4, [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
StartMap:
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptRunning], a
|
|
|
|
ld hl, wMapStatus
|
|
|
|
ld bc, wMapStatusEnd - wMapStatus
|
2013-11-22 10:04:32 +00:00
|
|
|
call ByteFill
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall InitCallReceiveDelay
|
2013-12-22 22:30:35 +00:00
|
|
|
call ClearJoypad
|
2018-06-24 14:09:41 +00:00
|
|
|
EnterMap:
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2016-01-12 17:46:18 +00:00
|
|
|
ld [wXYComparePointer], a
|
|
|
|
ld [wXYComparePointer + 1], a
|
2015-10-08 01:27:32 +00:00
|
|
|
call SetUpFiveStepWildEncounterCooldown
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall RunMapSetupScript
|
2015-11-13 23:59:49 +00:00
|
|
|
call DisableEvents
|
2013-12-27 10:56:23 +00:00
|
|
|
|
2015-10-07 17:19:41 +00:00
|
|
|
ld a, [hMapEntryMethod]
|
2015-11-12 04:38:57 +00:00
|
|
|
cp MAPSETUP_CONNECTION
|
2015-11-13 23:59:49 +00:00
|
|
|
jr nz, .dont_enable
|
|
|
|
call EnableEvents
|
|
|
|
.dont_enable
|
2013-12-27 10:56:23 +00:00
|
|
|
|
2015-10-07 17:19:41 +00:00
|
|
|
ld a, [hMapEntryMethod]
|
2015-10-24 23:49:19 +00:00
|
|
|
cp MAPSETUP_RELOADMAP
|
2015-07-15 19:48:44 +00:00
|
|
|
jr nz, .dontresetpoison
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wPoisonStepCount], a
|
2015-07-15 19:48:44 +00:00
|
|
|
.dontresetpoison
|
2013-12-27 10:56:23 +00:00
|
|
|
|
2015-10-24 23:49:19 +00:00
|
|
|
xor a ; end map entry
|
2015-10-07 17:19:41 +00:00
|
|
|
ld [hMapEntryMethod], a
|
2013-12-27 10:56:23 +00:00
|
|
|
ld a, 2 ; HandleMap
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMapStatus], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
UnusedWait30Frames:
|
2013-11-22 10:04:32 +00:00
|
|
|
ld c, 30
|
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
HandleMap:
|
2013-11-22 10:04:32 +00:00
|
|
|
call ResetOverworldDelay
|
2015-12-17 20:14:51 +00:00
|
|
|
call HandleMapTimeAndJoypad
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall HandleCmdQueue ; no need to farcall
|
2013-12-27 10:56:23 +00:00
|
|
|
call MapEvents
|
|
|
|
|
|
|
|
; Not immediately entering a connected map will cause problems.
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapStatus]
|
2013-12-27 10:56:23 +00:00
|
|
|
cp 2 ; HandleMap
|
2013-11-22 10:04:32 +00:00
|
|
|
ret nz
|
2013-12-27 10:56:23 +00:00
|
|
|
|
2016-05-17 12:40:42 +00:00
|
|
|
call HandleMapObjects
|
2013-11-22 10:04:32 +00:00
|
|
|
call NextOverworldFrame
|
2016-05-17 12:40:42 +00:00
|
|
|
call HandleMapBackground
|
|
|
|
call CheckPlayerState
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MapEvents:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapEventStatus]
|
2013-12-27 10:56:23 +00:00
|
|
|
ld hl, .jumps
|
2013-11-22 10:04:32 +00:00
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2013-12-27 10:56:23 +00:00
|
|
|
.jumps
|
|
|
|
dw .events
|
|
|
|
dw .no_events
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.events
|
2013-11-22 10:04:32 +00:00
|
|
|
call PlayerEvents
|
2015-11-13 23:59:49 +00:00
|
|
|
call DisableEvents
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall ScriptEvents
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.no_events
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MaxOverworldDelay:
|
2013-11-22 10:04:32 +00:00
|
|
|
db 2
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ResetOverworldDelay:
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [MaxOverworldDelay]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wOverworldDelay], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
NextOverworldFrame:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wOverworldDelay]
|
2013-11-22 10:04:32 +00:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
ld c, a
|
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
HandleMapTimeAndJoypad:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wMapEventStatus]
|
2013-12-27 10:56:23 +00:00
|
|
|
cp 1 ; no events
|
2013-11-22 10:04:32 +00:00
|
|
|
ret z
|
2013-12-27 10:56:23 +00:00
|
|
|
|
2013-11-22 10:04:32 +00:00
|
|
|
call UpdateTime
|
2013-12-22 22:30:35 +00:00
|
|
|
call GetJoypad
|
2013-11-22 10:04:32 +00:00
|
|
|
call TimeOfDayPals
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
HandleMapObjects:
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall HandleNPCStep ; engine/map_objects.asm
|
|
|
|
farcall _HandlePlayerStep
|
2015-12-25 03:58:42 +00:00
|
|
|
call _CheckObjectEnteringVisibleRange
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
HandleMapBackground:
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall _UpdateSprites
|
|
|
|
farcall ScrollScreen
|
|
|
|
farcall PlaceMapNameSign
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckPlayerState:
|
2015-11-15 04:02:38 +00:00
|
|
|
ld a, [wPlayerStepFlags]
|
2015-12-25 03:58:42 +00:00
|
|
|
bit 5, a ; in the middle of step
|
2015-07-15 19:48:44 +00:00
|
|
|
jr z, .events
|
2015-12-25 03:58:42 +00:00
|
|
|
bit 6, a ; stopping step
|
2015-07-15 19:48:44 +00:00
|
|
|
jr z, .noevents
|
2015-12-25 03:58:42 +00:00
|
|
|
bit 4, a ; in midair
|
2015-07-15 19:48:44 +00:00
|
|
|
jr nz, .noevents
|
2015-11-13 23:59:49 +00:00
|
|
|
call EnableEvents
|
2015-07-15 19:48:44 +00:00
|
|
|
.events
|
2013-12-27 10:56:23 +00:00
|
|
|
ld a, 0 ; events
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMapEventStatus], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.noevents
|
2013-12-27 10:56:23 +00:00
|
|
|
ld a, 1 ; no events
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wMapEventStatus], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
_CheckObjectEnteringVisibleRange:
|
2015-11-15 04:02:38 +00:00
|
|
|
ld hl, wPlayerStepFlags
|
2013-11-22 10:04:32 +00:00
|
|
|
bit 6, [hl]
|
|
|
|
ret z
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckObjectEnteringVisibleRange
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
PlayerEvents:
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2015-10-24 14:34:19 +00:00
|
|
|
; If there's already a player event, don't interrupt it.
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptRunning]
|
2013-11-22 10:04:32 +00:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
call Dummy_CheckScriptFlags3Bit5 ; This is a waste of time
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
call CheckTrainerBattle3
|
2015-07-15 19:48:44 +00:00
|
|
|
jr c, .ok
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
call CheckTileEvent
|
2015-07-15 19:48:44 +00:00
|
|
|
jr c, .ok
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
call RunMemScript
|
2015-07-15 19:48:44 +00:00
|
|
|
jr c, .ok
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2017-12-24 18:46:34 +00:00
|
|
|
call RunSceneScript
|
2015-07-15 19:48:44 +00:00
|
|
|
jr c, .ok
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
call CheckTimeEvents
|
2015-07-15 19:48:44 +00:00
|
|
|
jr c, .ok
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
call OWPlayerInput
|
2015-07-15 19:48:44 +00:00
|
|
|
jr c, .ok
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.ok
|
2013-11-22 10:04:32 +00:00
|
|
|
push af
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall EnableScriptMode
|
2013-11-22 10:04:32 +00:00
|
|
|
pop af
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptRunning], a
|
2015-10-24 23:49:19 +00:00
|
|
|
call DoPlayerEvent
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptRunning]
|
2015-11-12 04:38:57 +00:00
|
|
|
cp PLAYEREVENT_CONNECTION
|
2015-07-15 19:48:44 +00:00
|
|
|
jr z, .ok2
|
2015-11-12 04:38:57 +00:00
|
|
|
cp PLAYEREVENT_JOYCHANGEFACING
|
2015-07-15 19:48:44 +00:00
|
|
|
jr z, .ok2
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
xor a
|
2015-11-10 16:05:26 +00:00
|
|
|
ld [wLandmarkSignTimer], a
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.ok2
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckTrainerBattle3:
|
2013-11-22 10:04:32 +00:00
|
|
|
nop
|
|
|
|
nop
|
|
|
|
call CheckTrainerBattle2
|
2015-07-15 19:48:44 +00:00
|
|
|
jr nc, .nope
|
2013-12-27 10:56:23 +00:00
|
|
|
|
2015-11-12 16:10:19 +00:00
|
|
|
ld a, PLAYEREVENT_SEENBYTRAINER
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.nope
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckTileEvent:
|
2017-12-24 18:46:34 +00:00
|
|
|
; Check for warps, coord events, or wild battles.
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-11-13 23:59:49 +00:00
|
|
|
call CheckWarpConnxnScriptFlag
|
|
|
|
jr z, .connections_disabled
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckMovingOffEdgeOfMap
|
2015-11-12 16:10:19 +00:00
|
|
|
jr c, .map_connection
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 23:49:19 +00:00
|
|
|
call CheckWarpTile
|
2015-11-12 16:10:19 +00:00
|
|
|
jr c, .warp_tile
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-11-13 23:59:49 +00:00
|
|
|
.connections_disabled
|
|
|
|
call CheckCoordEventScriptFlag
|
|
|
|
jr z, .coord_events_disabled
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2017-12-24 18:46:34 +00:00
|
|
|
call CheckCurrentMapCoordEvents
|
2015-11-13 23:59:49 +00:00
|
|
|
jr c, .coord_event
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-11-13 23:59:49 +00:00
|
|
|
.coord_events_disabled
|
|
|
|
call CheckStepCountScriptFlag
|
|
|
|
jr z, .step_count_disabled
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
call CountStep
|
|
|
|
ret c
|
|
|
|
|
2015-11-13 23:59:49 +00:00
|
|
|
.step_count_disabled
|
|
|
|
call CheckWildEncountersScriptFlag
|
2015-07-15 19:48:44 +00:00
|
|
|
jr z, .ok
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-08 01:27:32 +00:00
|
|
|
call RandomEncounter
|
2013-11-22 10:04:32 +00:00
|
|
|
ret c
|
2015-10-08 01:27:32 +00:00
|
|
|
jr .ok ; pointless
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.ok
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-11-12 16:10:19 +00:00
|
|
|
.map_connection
|
|
|
|
ld a, PLAYEREVENT_CONNECTION
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-12 16:10:19 +00:00
|
|
|
.warp_tile
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPlayerStandingTile]
|
2013-11-22 10:04:32 +00:00
|
|
|
call CheckPitTile
|
2015-11-12 16:10:19 +00:00
|
|
|
jr nz, .not_pit
|
|
|
|
ld a, PLAYEREVENT_FALL
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-12 16:10:19 +00:00
|
|
|
.not_pit
|
|
|
|
ld a, PLAYEREVENT_WARP
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-13 23:59:49 +00:00
|
|
|
.coord_event
|
2016-01-06 12:44:50 +00:00
|
|
|
ld hl, wCurCoordEventScriptAddr
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckWildEncounterCooldown::
|
2015-10-08 01:27:32 +00:00
|
|
|
ld hl, wWildEncounterCooldown
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec [hl]
|
|
|
|
ret z
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
SetUpFiveStepWildEncounterCooldown:
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, 5
|
2015-10-08 01:27:32 +00:00
|
|
|
ld [wWildEncounterCooldown], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ret_968d7:
|
2015-10-24 23:49:19 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
SetMinTwoStepWildEncounterCooldown:
|
2015-10-08 01:27:32 +00:00
|
|
|
ld a, [wWildEncounterCooldown]
|
2013-11-22 10:04:32 +00:00
|
|
|
cp 2
|
|
|
|
ret nc
|
|
|
|
ld a, 2
|
2015-10-08 01:27:32 +00:00
|
|
|
ld [wWildEncounterCooldown], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Dummy_CheckScriptFlags3Bit5:
|
2015-07-15 19:48:44 +00:00
|
|
|
call CheckBit5_ScriptFlags3
|
2013-11-22 10:04:32 +00:00
|
|
|
ret z
|
2015-10-24 14:34:19 +00:00
|
|
|
call ret_2f3e
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
RunSceneScript:
|
2017-12-24 18:46:34 +00:00
|
|
|
ld a, [wCurrMapSceneScriptCount]
|
2013-11-22 10:04:32 +00:00
|
|
|
and a
|
2015-07-15 19:48:44 +00:00
|
|
|
jr z, .nope
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
ld c, a
|
2017-12-24 18:46:34 +00:00
|
|
|
call CheckScenes
|
2013-11-22 10:04:32 +00:00
|
|
|
cp c
|
2015-07-15 19:48:44 +00:00
|
|
|
jr nc, .nope
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2018-01-17 03:57:19 +00:00
|
|
|
ld hl, wCurrMapSceneScriptsPointer
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-07-20 15:28:05 +00:00
|
|
|
rept 4
|
2016-01-10 22:44:09 +00:00
|
|
|
add hl, de
|
2015-07-20 15:28:05 +00:00
|
|
|
endr
|
2016-04-10 18:42:14 +00:00
|
|
|
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call GetFarHalfword
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags
|
2013-11-22 10:04:32 +00:00
|
|
|
res 3, [hl]
|
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall EnableScriptMode
|
|
|
|
farcall ScriptEvents
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wScriptFlags
|
2013-11-22 10:04:32 +00:00
|
|
|
bit 3, [hl]
|
2015-07-15 19:48:44 +00:00
|
|
|
jr z, .nope
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-11-28 20:13:40 +00:00
|
|
|
ld hl, wPriorityScriptAddr
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-11-28 20:13:40 +00:00
|
|
|
ld a, [wPriorityScriptBank]
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.nope
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckTimeEvents:
|
2015-10-19 14:23:58 +00:00
|
|
|
ld a, [wLinkMode]
|
2013-11-22 10:04:32 +00:00
|
|
|
and a
|
2014-07-25 03:19:56 +00:00
|
|
|
jr nz, .nothing
|
|
|
|
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wStatusFlags2
|
2018-01-22 20:40:43 +00:00
|
|
|
bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
|
2015-10-24 14:34:19 +00:00
|
|
|
jr z, .do_daily
|
2014-07-25 03:19:56 +00:00
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckBugContestTimer
|
2015-10-24 14:34:19 +00:00
|
|
|
jr c, .end_bug_contest
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.do_daily
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckDailyResetTimer
|
|
|
|
farcall CheckPokerusTick
|
|
|
|
farcall CheckPhoneCall
|
2013-11-22 10:04:32 +00:00
|
|
|
ret c
|
|
|
|
|
2014-07-25 03:19:56 +00:00
|
|
|
.nothing
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.end_bug_contest
|
2015-07-16 22:10:10 +00:00
|
|
|
ld a, BANK(BugCatchingContestOverScript)
|
|
|
|
ld hl, BugCatchingContestOverScript
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.unused
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, 8
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
OWPlayerInput:
|
2013-11-22 10:04:32 +00:00
|
|
|
call PlayerMovement
|
|
|
|
ret c
|
|
|
|
and a
|
|
|
|
jr nz, .NoAction
|
|
|
|
|
|
|
|
; Can't perform button actions while sliding on ice.
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckStandingOnIce
|
2013-11-22 10:04:32 +00:00
|
|
|
jr c, .NoAction
|
|
|
|
|
|
|
|
call CheckAPressOW
|
|
|
|
jr c, .Action
|
|
|
|
|
|
|
|
call CheckMenuOW
|
|
|
|
jr c, .Action
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.NoAction:
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Action:
|
2013-11-22 10:04:32 +00:00
|
|
|
push af
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall StopPlayerForEvent
|
2013-11-22 10:04:32 +00:00
|
|
|
pop af
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckAPressOW:
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hJoyPressed]
|
|
|
|
and A_BUTTON
|
|
|
|
ret z
|
|
|
|
call TryObjectEvent
|
|
|
|
ret c
|
2017-12-24 18:46:34 +00:00
|
|
|
call TryBGEvent
|
2013-11-22 10:04:32 +00:00
|
|
|
ret c
|
2017-12-24 18:46:34 +00:00
|
|
|
call TryTileCollisionEvent
|
2013-11-22 10:04:32 +00:00
|
|
|
ret c
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
PlayTalkObject:
|
2013-11-22 10:04:32 +00:00
|
|
|
push de
|
|
|
|
ld de, SFX_READ_TEXT_2
|
|
|
|
call PlaySFX
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
TryObjectEvent:
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckFacingObject
|
2013-11-22 10:04:32 +00:00
|
|
|
jr c, .IsObject
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.IsObject:
|
2013-11-22 10:04:32 +00:00
|
|
|
call PlayTalkObject
|
2015-11-02 16:15:32 +00:00
|
|
|
ld a, [hObjectStructIndexBuffer]
|
2015-07-15 19:48:44 +00:00
|
|
|
call GetObjectStruct
|
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2013-11-22 10:04:32 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-22 06:49:18 +00:00
|
|
|
ld [hLastTalked], a
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-07-22 06:49:18 +00:00
|
|
|
ld a, [hLastTalked]
|
2013-11-22 10:04:32 +00:00
|
|
|
call GetMapObject
|
2015-07-15 19:48:44 +00:00
|
|
|
ld hl, MAPOBJECT_COLOR
|
2013-11-22 10:04:32 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 19:48:44 +00:00
|
|
|
and %00001111
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
; Bug: If IsInArray returns nc, data at bc will be executed as code.
|
|
|
|
push bc
|
|
|
|
ld de, 3
|
2015-07-15 19:48:44 +00:00
|
|
|
ld hl, .pointers
|
2013-11-22 10:04:32 +00:00
|
|
|
call IsInArray
|
2015-07-15 19:48:44 +00:00
|
|
|
jr nc, .nope_bugged
|
2013-11-22 10:04:32 +00:00
|
|
|
pop bc
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-17 23:14:55 +00:00
|
|
|
jp hl
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.nope_bugged
|
2015-11-15 19:59:38 +00:00
|
|
|
; pop bc
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.pointers
|
2017-12-24 18:46:34 +00:00
|
|
|
dbw OBJECTTYPE_SCRIPT, .script
|
|
|
|
dbw OBJECTTYPE_ITEMBALL, .itemball
|
|
|
|
dbw OBJECTTYPE_TRAINER, .trainer
|
2015-11-15 19:59:38 +00:00
|
|
|
; the remaining four are dummy events
|
2017-12-24 18:46:34 +00:00
|
|
|
dbw OBJECTTYPE_3, .three
|
|
|
|
dbw OBJECTTYPE_4, .four
|
|
|
|
dbw OBJECTTYPE_5, .five
|
|
|
|
dbw OBJECTTYPE_6, .six
|
2015-07-15 19:48:44 +00:00
|
|
|
db -1
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.script
|
2015-07-18 19:46:38 +00:00
|
|
|
ld hl, MAPOBJECT_SCRIPT_POINTER
|
2013-11-22 10:04:32 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.itemball
|
2015-07-18 19:46:38 +00:00
|
|
|
ld hl, MAPOBJECT_SCRIPT_POINTER
|
2013-11-22 10:04:32 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wEngineBuffer1
|
2013-11-22 10:04:32 +00:00
|
|
|
ld bc, 2
|
|
|
|
call FarCopyBytes
|
2015-11-15 19:59:38 +00:00
|
|
|
ld a, PLAYEREVENT_ITEMBALL
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.trainer
|
2015-11-15 19:59:38 +00:00
|
|
|
call TalkToTrainer
|
|
|
|
ld a, PLAYEREVENT_TALKTOTRAINER
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.three
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.four
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.five
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.six
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
TryBGEvent:
|
2017-12-24 18:46:34 +00:00
|
|
|
call CheckFacingBGEvent
|
|
|
|
jr c, .is_bg_event
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2017-12-24 18:46:34 +00:00
|
|
|
.is_bg_event:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wEngineBuffer3]
|
2017-12-24 18:46:34 +00:00
|
|
|
ld hl, .bg_events
|
2013-11-22 10:04:32 +00:00
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2017-12-24 18:46:34 +00:00
|
|
|
.bg_events
|
2013-11-22 10:04:32 +00:00
|
|
|
dw .read
|
|
|
|
dw .up
|
|
|
|
dw .down
|
|
|
|
dw .right
|
|
|
|
dw .left
|
|
|
|
dw .ifset
|
|
|
|
dw .ifnotset
|
|
|
|
dw .itemifset
|
2015-07-15 19:48:44 +00:00
|
|
|
dw .copy
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
.up
|
2015-11-15 19:59:38 +00:00
|
|
|
ld b, OW_UP
|
2013-11-22 10:04:32 +00:00
|
|
|
jr .checkdir
|
|
|
|
.down
|
2015-11-15 19:59:38 +00:00
|
|
|
ld b, OW_DOWN
|
2013-11-22 10:04:32 +00:00
|
|
|
jr .checkdir
|
|
|
|
.right
|
2015-11-15 19:59:38 +00:00
|
|
|
ld b, OW_RIGHT
|
2013-11-22 10:04:32 +00:00
|
|
|
jr .checkdir
|
|
|
|
.left
|
2015-11-15 19:59:38 +00:00
|
|
|
ld b, OW_LEFT
|
2013-11-22 10:04:32 +00:00
|
|
|
jr .checkdir
|
|
|
|
|
|
|
|
.checkdir
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPlayerDirection]
|
2013-11-22 10:04:32 +00:00
|
|
|
and %1100
|
|
|
|
cp b
|
|
|
|
jp nz, .dontread
|
|
|
|
|
|
|
|
.read
|
|
|
|
call PlayTalkObject
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wEngineBuffer4
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.itemifset
|
2017-12-24 18:46:34 +00:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 10:04:32 +00:00
|
|
|
jp nz, .dontread
|
|
|
|
call PlayTalkObject
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wEngineBuffer1
|
2013-11-22 10:04:32 +00:00
|
|
|
ld bc, 3
|
|
|
|
call FarCopyBytes
|
2015-12-15 16:21:58 +00:00
|
|
|
ld a, BANK(HiddenItemScript)
|
|
|
|
ld hl, HiddenItemScript
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.copy
|
2017-12-24 18:46:34 +00:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 10:04:32 +00:00
|
|
|
jr nz, .dontread
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2018-01-23 22:39:09 +00:00
|
|
|
ld de, wEngineBuffer1
|
2013-11-22 10:04:32 +00:00
|
|
|
ld bc, 3
|
|
|
|
call FarCopyBytes
|
|
|
|
jr .dontread
|
|
|
|
|
|
|
|
.ifset
|
2017-12-24 18:46:34 +00:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 10:04:32 +00:00
|
|
|
jr z, .dontread
|
2015-07-15 19:48:44 +00:00
|
|
|
jr .thenread
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
.ifnotset
|
2017-12-24 18:46:34 +00:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 10:04:32 +00:00
|
|
|
jr nz, .dontread
|
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.thenread
|
2013-11-22 10:04:32 +00:00
|
|
|
push hl
|
|
|
|
call PlayTalkObject
|
|
|
|
pop hl
|
|
|
|
inc hl
|
2015-12-27 02:59:03 +00:00
|
|
|
inc hl
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call GetFarHalfword
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.dontread
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckBGEventFlag:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wEngineBuffer4
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
push hl
|
2018-01-17 03:57:19 +00:00
|
|
|
call GetMapScriptsBank
|
2013-11-22 10:04:32 +00:00
|
|
|
call GetFarHalfword
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2015-11-12 16:10:19 +00:00
|
|
|
ld b, CHECK_FLAG
|
2013-11-22 10:04:32 +00:00
|
|
|
call EventFlagAction
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
PlayerMovement:
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall DoPlayerMovement
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, c
|
|
|
|
ld hl, .pointers
|
|
|
|
rst JumpTable
|
|
|
|
ld a, c
|
|
|
|
ret
|
|
|
|
|
|
|
|
.pointers
|
|
|
|
dw .zero
|
|
|
|
dw .one
|
|
|
|
dw .two
|
|
|
|
dw .three
|
|
|
|
dw .four
|
|
|
|
dw .five
|
|
|
|
dw .six
|
|
|
|
dw .seven
|
|
|
|
|
|
|
|
.zero
|
2018-06-24 14:09:41 +00:00
|
|
|
.four
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.seven
|
2015-10-24 23:49:19 +00:00
|
|
|
call ret_968d7 ; mobile
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.one
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, 5
|
|
|
|
ld c, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.two
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, 9
|
|
|
|
ld c, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.three
|
2013-11-22 10:04:32 +00:00
|
|
|
; force the player to move in some direction
|
2015-07-15 19:48:44 +00:00
|
|
|
ld a, BANK(Script_ForcedMovement)
|
|
|
|
ld hl, Script_ForcedMovement
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
; ld a, -1
|
|
|
|
ld c, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.five
|
2018-06-24 14:09:41 +00:00
|
|
|
.six
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, -1
|
|
|
|
ld c, a
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckMenuOW:
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
2015-10-24 14:34:19 +00:00
|
|
|
ld [hMenuReturn], a
|
2015-11-10 04:01:45 +00:00
|
|
|
ld [hMenuReturn + 1], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hJoyPressed]
|
|
|
|
|
2017-12-30 17:35:50 +00:00
|
|
|
bit SELECT_F, a
|
2013-11-22 10:04:32 +00:00
|
|
|
jr nz, .Select
|
|
|
|
|
2017-12-30 17:35:50 +00:00
|
|
|
bit START_F, a
|
2013-11-22 10:04:32 +00:00
|
|
|
jr z, .NoMenu
|
|
|
|
|
|
|
|
ld a, BANK(StartMenuScript)
|
|
|
|
ld hl, StartMenuScript
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.NoMenu:
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Select:
|
2013-11-22 10:04:32 +00:00
|
|
|
call PlayTalkObject
|
|
|
|
ld a, BANK(SelectMenuScript)
|
|
|
|
ld hl, SelectMenuScript
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
StartMenuScript:
|
2015-01-20 08:01:23 +00:00
|
|
|
callasm StartMenu
|
|
|
|
jump StartMenuCallback
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
SelectMenuScript:
|
2015-01-20 08:01:23 +00:00
|
|
|
callasm SelectMenu
|
|
|
|
jump SelectMenuCallback
|
2013-11-22 10:04:32 +00:00
|
|
|
|
|
|
|
StartMenuCallback:
|
2018-06-24 14:09:41 +00:00
|
|
|
SelectMenuCallback:
|
2015-10-24 14:34:19 +00:00
|
|
|
copybytetovar hMenuReturn
|
2018-02-03 02:09:17 +00:00
|
|
|
ifequal HMENURETURN_SCRIPT, .Script
|
|
|
|
ifequal HMENURETURN_ASM, .Asm
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Script:
|
2015-11-01 17:44:30 +00:00
|
|
|
ptjump wQueuedScriptBank
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Asm:
|
2015-11-01 17:44:30 +00:00
|
|
|
ptcallasm wQueuedScriptBank
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CountStep:
|
2015-10-24 14:34:19 +00:00
|
|
|
; Don't count steps in link communication rooms.
|
2015-10-19 14:23:58 +00:00
|
|
|
ld a, [wLinkMode]
|
2013-11-22 10:04:32 +00:00
|
|
|
and a
|
2015-07-15 19:48:44 +00:00
|
|
|
jr nz, .done
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
; If there is a special phone call, don't count the step.
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall CheckSpecialPhoneCall
|
2015-10-24 14:34:19 +00:00
|
|
|
jr c, .doscript
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
; If Repel wore off, don't count the step.
|
|
|
|
call DoRepelStep
|
|
|
|
jr c, .doscript
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
; Count the step for poison and total steps
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPoisonStepCount
|
2013-11-22 10:04:32 +00:00
|
|
|
inc [hl]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wStepCount
|
2013-11-22 10:04:32 +00:00
|
|
|
inc [hl]
|
2015-10-24 14:34:19 +00:00
|
|
|
; Every 256 steps, increase the happiness of all your Pokemon.
|
|
|
|
jr nz, .skip_happiness
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall StepHappiness
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.skip_happiness
|
|
|
|
; Every 256 steps, offset from the happiness incrementor by 128 steps,
|
|
|
|
; decrease the hatch counter of all your eggs until you reach the first
|
|
|
|
; one that is ready to hatch.
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wStepCount]
|
2013-11-22 10:04:32 +00:00
|
|
|
cp $80
|
2015-10-24 14:34:19 +00:00
|
|
|
jr nz, .skip_egg
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall DoEggStep
|
2015-10-24 14:34:19 +00:00
|
|
|
jr nz, .hatch
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.skip_egg
|
|
|
|
; Increase the EXP of (both) DayCare Pokemon by 1.
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall DayCareStep
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
; Every four steps, deal damage to all Poisoned Pokemon
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPoisonStepCount
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hl]
|
|
|
|
cp 4
|
2015-10-24 14:34:19 +00:00
|
|
|
jr c, .skip_poison
|
2013-11-22 10:04:32 +00:00
|
|
|
ld [hl], 0
|
|
|
|
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall DoPoisonStep
|
2015-10-24 14:34:19 +00:00
|
|
|
jr c, .doscript
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.skip_poison
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall DoBikeStep
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-07-15 19:48:44 +00:00
|
|
|
.done
|
2013-11-22 10:04:32 +00:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.doscript
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, -1
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-10-24 14:34:19 +00:00
|
|
|
.hatch
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, 8
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-01-02 18:38:56 +00:00
|
|
|
; unused
|
2018-06-24 14:09:41 +00:00
|
|
|
.unreferenced
|
2015-07-15 19:48:44 +00:00
|
|
|
ld a, 7
|
2013-11-22 10:04:32 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DoRepelStep:
|
2015-10-24 14:34:19 +00:00
|
|
|
ld a, [wRepelEffect]
|
2013-11-22 10:04:32 +00:00
|
|
|
and a
|
|
|
|
ret z
|
2015-09-09 23:27:07 +00:00
|
|
|
|
2013-11-22 10:04:32 +00:00
|
|
|
dec a
|
2015-10-24 14:34:19 +00:00
|
|
|
ld [wRepelEffect], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret nz
|
2015-09-09 23:27:07 +00:00
|
|
|
|
2015-07-16 22:10:10 +00:00
|
|
|
ld a, BANK(RepelWoreOffScript)
|
|
|
|
ld hl, RepelWoreOffScript
|
2013-11-22 10:04:32 +00:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
DoPlayerEvent:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptRunning]
|
2013-11-22 10:04:32 +00:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-12 04:38:57 +00:00
|
|
|
|
2015-11-05 20:08:00 +00:00
|
|
|
cp PLAYEREVENT_MAPSCRIPT ; run script
|
2013-11-22 10:04:32 +00:00
|
|
|
ret z
|
2015-11-12 04:38:57 +00:00
|
|
|
|
2015-11-05 20:08:00 +00:00
|
|
|
cp NUM_PLAYER_EVENTS
|
2013-11-22 10:04:32 +00:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2015-11-05 20:08:00 +00:00
|
|
|
ld hl, PlayerEventScriptPointers
|
2016-01-10 22:44:09 +00:00
|
|
|
add hl, bc
|
2016-05-10 16:31:49 +00:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hli]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptBank], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hli]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptPos], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ld a, [hl]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptPos + 1], a
|
2013-11-22 10:04:32 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
PlayerEventScriptPointers:
|
2015-11-12 04:38:57 +00:00
|
|
|
dba Invalid_0x96c2d ; 0
|
|
|
|
dba SeenByTrainerScript ; 1
|
|
|
|
dba TalkToTrainerScript ; 2
|
|
|
|
dba FindItemInBallScript ; 3
|
2015-11-13 23:59:49 +00:00
|
|
|
dba EdgeWarpScript ; 4
|
2015-11-12 04:38:57 +00:00
|
|
|
dba WarpToNewMapScript ; 5
|
|
|
|
dba FallIntoMapScript ; 6
|
|
|
|
dba Script_OverworldWhiteout ; 7
|
|
|
|
dba HatchEggScript ; 8
|
2015-11-13 23:59:49 +00:00
|
|
|
dba ChangeDirectionScript ; 9
|
2015-11-12 04:38:57 +00:00
|
|
|
dba Invalid_0x96c2d ; 10
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
Invalid_0x96c2d:
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-01-02 15:04:21 +00:00
|
|
|
; unused
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
HatchEggScript:
|
2015-07-15 19:48:44 +00:00
|
|
|
callasm OverworldHatchEgg
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
WarpToNewMapScript:
|
2013-11-22 10:04:32 +00:00
|
|
|
warpsound
|
2015-11-12 04:38:57 +00:00
|
|
|
newloadmap MAPSETUP_DOOR
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
FallIntoMapScript:
|
2015-11-12 04:38:57 +00:00
|
|
|
newloadmap MAPSETUP_FALL
|
2013-11-22 10:04:32 +00:00
|
|
|
playsound SFX_KINESIS
|
2015-07-22 06:49:18 +00:00
|
|
|
applymovement PLAYER, MovementData_0x96c48
|
2013-11-22 10:04:32 +00:00
|
|
|
playsound SFX_STRENGTH
|
2015-10-24 23:49:19 +00:00
|
|
|
scall LandAfterPitfallScript
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MovementData_0x96c48:
|
2013-11-22 10:04:32 +00:00
|
|
|
skyfall
|
|
|
|
step_end
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
LandAfterPitfallScript:
|
2013-11-22 10:04:32 +00:00
|
|
|
earthquake 16
|
|
|
|
end
|
|
|
|
|
2015-11-13 23:59:49 +00:00
|
|
|
EdgeWarpScript: ; 4
|
2015-11-12 04:38:57 +00:00
|
|
|
reloadandreturn MAPSETUP_CONNECTION
|
2013-11-22 10:04:32 +00:00
|
|
|
|
2015-11-13 23:59:49 +00:00
|
|
|
ChangeDirectionScript: ; 9
|
|
|
|
deactivatefacing 3
|
|
|
|
callasm EnableWildEncounters
|
2013-11-22 10:04:32 +00:00
|
|
|
end
|
|
|
|
|
2018-03-13 12:07:16 +00:00
|
|
|
INCLUDE "engine/overworld/scripting.asm"
|
2018-01-12 04:50:44 +00:00
|
|
|
|
2018-06-25 17:48:16 +00:00
|
|
|
WarpToSpawnPoint::
|
|
|
|
ld hl, wStatusFlags2
|
|
|
|
res STATUSFLAGS2_SAFARI_GAME_F, [hl]
|
|
|
|
res STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
RunMemScript::
|
|
|
|
; If there is no script here, we don't need to be here.
|
|
|
|
ld a, [wMapReentryScriptQueueFlag]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
; Execute the script at (wMapReentryScriptBank):(wMapReentryScriptAddress).
|
|
|
|
ld hl, wMapReentryScriptAddress
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, [wMapReentryScriptBank]
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
; Clear the buffer for the next script.
|
|
|
|
push af
|
|
|
|
xor a
|
|
|
|
ld hl, wMapReentryScriptQueueFlag
|
|
|
|
ld bc, 8
|
|
|
|
call ByteFill
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
|
|
|
LoadScriptBDE::
|
|
|
|
; If there's already a script here, don't overwrite.
|
|
|
|
ld hl, wMapReentryScriptQueueFlag
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
; Set the flag
|
|
|
|
ld [hl], 1
|
|
|
|
inc hl
|
|
|
|
; Load the script pointer b:de into (wMapReentryScriptBank):(wMapReentryScriptAddress)
|
|
|
|
ld [hl], b
|
|
|
|
inc hl
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
TryTileCollisionEvent::
|
|
|
|
call GetFacingTileCoord
|
|
|
|
ld [wEngineBuffer1], a
|
|
|
|
ld c, a
|
|
|
|
farcall CheckFacingTileForStdScript
|
|
|
|
jr c, .done
|
|
|
|
|
|
|
|
call CheckCutTreeTile
|
|
|
|
jr nz, .whirlpool
|
|
|
|
farcall TryCutOW
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.whirlpool
|
|
|
|
ld a, [wEngineBuffer1]
|
|
|
|
call CheckWhirlpoolTile
|
|
|
|
jr nz, .waterfall
|
|
|
|
farcall TryWhirlpoolOW
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.waterfall
|
|
|
|
ld a, [wEngineBuffer1]
|
|
|
|
call CheckWaterfallTile
|
|
|
|
jr nz, .headbutt
|
|
|
|
farcall TryWaterfallOW
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.headbutt
|
|
|
|
ld a, [wEngineBuffer1]
|
|
|
|
call CheckHeadbuttTreeTile
|
|
|
|
jr nz, .surf
|
|
|
|
farcall TryHeadbuttOW
|
|
|
|
jr c, .done
|
|
|
|
jr .noevent
|
|
|
|
|
|
|
|
.surf
|
|
|
|
farcall TrySurfOW
|
|
|
|
jr nc, .noevent
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.noevent
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.done
|
|
|
|
call PlayClickSFX
|
|
|
|
ld a, $ff
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
RandomEncounter::
|
|
|
|
; Random encounter
|
|
|
|
|
|
|
|
call CheckWildEncounterCooldown
|
|
|
|
jr c, .nope
|
|
|
|
call CanUseSweetScent
|
|
|
|
jr nc, .nope
|
|
|
|
ld hl, wStatusFlags2
|
|
|
|
bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
|
|
|
|
jr nz, .bug_contest
|
|
|
|
farcall TryWildEncounter
|
|
|
|
jr nz, .nope
|
|
|
|
jr .ok
|
|
|
|
|
|
|
|
.bug_contest
|
|
|
|
call _TryWildEncounter_BugContest
|
|
|
|
jr nc, .nope
|
|
|
|
jr .ok_bug_contest
|
|
|
|
|
|
|
|
.nope
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.ok
|
|
|
|
ld a, BANK(WildBattleScript)
|
|
|
|
ld hl, WildBattleScript
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.ok_bug_contest
|
|
|
|
ld a, BANK(BugCatchingContestBattleScript)
|
|
|
|
ld hl, BugCatchingContestBattleScript
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.done
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
WildBattleScript:
|
|
|
|
randomwildmon
|
|
|
|
startbattle
|
|
|
|
reloadmapafterbattle
|
|
|
|
end
|
|
|
|
|
|
|
|
CanUseSweetScent::
|
|
|
|
ld hl, wStatusFlags
|
|
|
|
bit STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl]
|
|
|
|
jr nz, .no
|
|
|
|
ld a, [wEnvironment]
|
|
|
|
cp CAVE
|
|
|
|
jr z, .ice_check
|
|
|
|
cp DUNGEON
|
|
|
|
jr z, .ice_check
|
|
|
|
farcall CheckGrassCollision
|
|
|
|
jr nc, .no
|
|
|
|
|
|
|
|
.ice_check
|
|
|
|
ld a, [wPlayerStandingTile]
|
|
|
|
call CheckIceTile
|
|
|
|
jr z, .no
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.no
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
_TryWildEncounter_BugContest:
|
|
|
|
call TryWildEncounter_BugContest
|
|
|
|
ret nc
|
|
|
|
call ChooseWildEncounter_BugContest
|
|
|
|
farcall CheckRepelEffect
|
|
|
|
ret
|
|
|
|
|
|
|
|
ChooseWildEncounter_BugContest::
|
|
|
|
; Pick a random mon out of ContestMons.
|
|
|
|
|
|
|
|
.loop
|
|
|
|
call Random
|
|
|
|
cp 100 << 1
|
|
|
|
jr nc, .loop
|
|
|
|
srl a
|
|
|
|
|
|
|
|
ld hl, ContestMons
|
|
|
|
ld de, 4
|
|
|
|
.CheckMon:
|
|
|
|
sub [hl]
|
|
|
|
jr c, .GotMon
|
|
|
|
add hl, de
|
|
|
|
jr .CheckMon
|
|
|
|
|
|
|
|
.GotMon:
|
|
|
|
inc hl
|
|
|
|
|
|
|
|
; Species
|
|
|
|
ld a, [hli]
|
|
|
|
ld [wTempWildMonSpecies], a
|
|
|
|
|
|
|
|
; 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
|
|
|
|
|
|
|
|
.RandomLevel:
|
|
|
|
; Get a random level between the min and max.
|
|
|
|
ld c, a
|
|
|
|
inc c
|
|
|
|
call Random
|
|
|
|
ld a, [hRandomAdd]
|
|
|
|
call SimpleDivide
|
|
|
|
add d
|
|
|
|
|
|
|
|
.GotLevel:
|
|
|
|
ld [wCurPartyLevel], a
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
TryWildEncounter_BugContest:
|
|
|
|
ld a, [wPlayerStandingTile]
|
|
|
|
call CheckSuperTallGrassTile
|
|
|
|
ld b, 40 percent
|
|
|
|
jr z, .ok
|
|
|
|
ld b, 20 percent
|
|
|
|
|
|
|
|
.ok
|
|
|
|
farcall ApplyMusicEffectOnEncounterRate
|
|
|
|
farcall ApplyCleanseTagEffectOnEncounterRate
|
|
|
|
call Random
|
|
|
|
ld a, [hRandomAdd]
|
|
|
|
cp b
|
|
|
|
ret c
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/wild/bug_contest_mons.asm"
|
|
|
|
|
|
|
|
DoBikeStep::
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
; 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.
|
|
|
|
ld hl, wStatusFlags2
|
|
|
|
bit STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl]
|
|
|
|
jr z, .NoCall
|
|
|
|
|
|
|
|
; If we're not on the bike, we don't have to be here.
|
|
|
|
ld a, [wPlayerState]
|
|
|
|
cp PLAYER_BIKE
|
|
|
|
jr nz, .NoCall
|
|
|
|
|
|
|
|
; If we're not in an area of phone service, we don't
|
|
|
|
; have to be here.
|
|
|
|
call GetMapPhoneService
|
|
|
|
and a
|
|
|
|
jr nz, .NoCall
|
|
|
|
|
|
|
|
; Check the bike step count and check whether we've
|
|
|
|
; taken 65536 of them yet.
|
|
|
|
ld hl, wBikeStep
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
ld e, [hl]
|
|
|
|
cp 255
|
|
|
|
jr nz, .increment
|
|
|
|
ld a, e
|
|
|
|
cp 255
|
|
|
|
jr z, .dont_increment
|
|
|
|
|
|
|
|
.increment
|
|
|
|
inc de
|
|
|
|
ld [hl], e
|
|
|
|
dec hl
|
|
|
|
ld [hl], d
|
|
|
|
|
|
|
|
.dont_increment
|
|
|
|
; If we've taken at least 1024 steps, have the bike
|
|
|
|
; shop owner try to call us.
|
|
|
|
ld a, d
|
|
|
|
cp HIGH(1024)
|
|
|
|
jr c, .NoCall
|
|
|
|
|
|
|
|
; If a call has already been queued, don't overwrite
|
|
|
|
; that call.
|
|
|
|
ld a, [wSpecialPhoneCallID]
|
|
|
|
and a
|
|
|
|
jr nz, .NoCall
|
|
|
|
|
|
|
|
; Queue the call.
|
|
|
|
ld a, SPECIALCALL_BIKESHOP
|
|
|
|
ld [wSpecialPhoneCallID], a
|
|
|
|
xor a
|
|
|
|
ld [wSpecialPhoneCallID + 1], a
|
|
|
|
ld hl, wStatusFlags2
|
|
|
|
res STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl]
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.NoCall:
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
ClearCmdQueue::
|
|
|
|
ld hl, wCmdQueue
|
2018-07-15 09:58:10 +00:00
|
|
|
ld de, CMDQUEUE_ENTRY_SIZE
|
|
|
|
ld c, CMDQUEUE_CAPACITY
|
2018-06-25 17:48:16 +00:00
|
|
|
xor a
|
|
|
|
.loop
|
|
|
|
ld [hl], a
|
|
|
|
add hl, de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
HandleCmdQueue::
|
|
|
|
ld hl, wCmdQueue
|
|
|
|
xor a
|
|
|
|
.loop
|
|
|
|
ld [hMapObjectIndexBuffer], a
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .skip
|
|
|
|
push hl
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
call HandleQueuedCommand
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
.skip
|
|
|
|
ld de, CMDQUEUE_ENTRY_SIZE
|
|
|
|
add hl, de
|
|
|
|
ld a, [hMapObjectIndexBuffer]
|
|
|
|
inc a
|
|
|
|
cp CMDQUEUE_CAPACITY
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
Unreferenced_GetNthCmdQueueEntry:
|
|
|
|
ld hl, wCmdQueue
|
|
|
|
ld bc, CMDQUEUE_ENTRY_SIZE
|
|
|
|
call AddNTimes
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
ret
|
|
|
|
|
|
|
|
WriteCmdQueue::
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
call .GetNextEmptyEntry
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
ret c
|
|
|
|
ld a, b
|
|
|
|
ld bc, CMDQUEUE_ENTRY_SIZE - 1
|
|
|
|
call FarCopyBytes
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.GetNextEmptyEntry:
|
|
|
|
ld hl, wCmdQueue
|
|
|
|
ld de, CMDQUEUE_ENTRY_SIZE
|
|
|
|
ld c, CMDQUEUE_CAPACITY
|
|
|
|
.loop
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
add hl, de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld a, CMDQUEUE_CAPACITY
|
|
|
|
sub c
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
DelCmdQueue::
|
|
|
|
ld hl, wCmdQueue
|
|
|
|
ld de, CMDQUEUE_ENTRY_SIZE
|
|
|
|
ld c, CMDQUEUE_CAPACITY
|
|
|
|
.loop
|
|
|
|
ld a, [hl]
|
|
|
|
cp b
|
|
|
|
jr z, .done
|
|
|
|
add hl, de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.done
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
_DelCmdQueue:
|
|
|
|
ld hl, CMDQUEUE_TYPE
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], 0
|
|
|
|
ret
|
|
|
|
|
|
|
|
HandleQueuedCommand:
|
|
|
|
ld hl, CMDQUEUE_TYPE
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-07-15 09:58:10 +00:00
|
|
|
cp NUM_CMDQUEUE_TYPES
|
2018-06-25 17:48:16 +00:00
|
|
|
jr c, .okay
|
|
|
|
xor a
|
|
|
|
|
|
|
|
.okay
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .Jumptable
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
pop af
|
|
|
|
rst FarCall
|
|
|
|
ret
|
|
|
|
|
|
|
|
.Jumptable:
|
|
|
|
dba CmdQueue_Null
|
|
|
|
dba CmdQueue_Null2
|
|
|
|
dba CmdQueue_StoneTable
|
|
|
|
dba CmdQueue_Type3
|
|
|
|
dba CmdQueue_Type4
|
|
|
|
|
|
|
|
CmdQueueAnonymousJumptable:
|
|
|
|
ld hl, CMDQUEUE_05
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
|
|
|
CmdQueueAnonJT_Increment:
|
|
|
|
ld hl, CMDQUEUE_05
|
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
CmdQueueAnonJT_Decrement:
|
|
|
|
ld hl, CMDQUEUE_05
|
|
|
|
add hl, bc
|
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
CmdQueue_Null:
|
|
|
|
ret
|
|
|
|
|
|
|
|
CmdQueue_Null2:
|
|
|
|
call ret_2f3e
|
|
|
|
ret
|
|
|
|
|
|
|
|
CmdQueue_Type4:
|
|
|
|
call CmdQueueAnonymousJumptable
|
|
|
|
; anonymous dw
|
|
|
|
dw .zero
|
|
|
|
dw .one
|
|
|
|
|
|
|
|
.zero
|
|
|
|
ld a, [hSCY]
|
|
|
|
ld hl, 4
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
call CmdQueueAnonJT_Increment
|
|
|
|
.one
|
|
|
|
ld hl, 1
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
dec a
|
|
|
|
ld [hl], a
|
|
|
|
jr z, .finish
|
|
|
|
and $1
|
|
|
|
jr z, .add
|
|
|
|
ld hl, 2
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hSCY]
|
|
|
|
sub [hl]
|
|
|
|
ld [hSCY], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.add
|
|
|
|
ld hl, 2
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hSCY]
|
|
|
|
add [hl]
|
|
|
|
ld [hSCY], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.finish
|
|
|
|
ld hl, 4
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [hSCY], a
|
|
|
|
call _DelCmdQueue
|
|
|
|
ret
|
|
|
|
|
|
|
|
CmdQueue_Type3:
|
|
|
|
call CmdQueueAnonymousJumptable
|
|
|
|
; anonymous dw
|
|
|
|
dw .zero
|
|
|
|
dw .one
|
|
|
|
dw .two
|
|
|
|
|
|
|
|
.zero
|
|
|
|
call .IsPlayerFacingDown
|
|
|
|
jr z, .PlayerNotFacingDown
|
|
|
|
call CmdQueueAnonJT_Increment
|
|
|
|
.one
|
|
|
|
call .IsPlayerFacingDown
|
|
|
|
jr z, .PlayerNotFacingDown
|
|
|
|
call CmdQueueAnonJT_Increment
|
|
|
|
|
|
|
|
ld hl, 2
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wd173], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.two
|
|
|
|
call .IsPlayerFacingDown
|
|
|
|
jr z, .PlayerNotFacingDown
|
|
|
|
call CmdQueueAnonJT_Decrement
|
|
|
|
|
|
|
|
ld hl, 3
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wd173], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.PlayerNotFacingDown:
|
|
|
|
ld a, $7f
|
|
|
|
ld [wd173], a
|
|
|
|
ld hl, 5
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], 0
|
|
|
|
ret
|
|
|
|
|
|
|
|
.IsPlayerFacingDown:
|
|
|
|
push bc
|
|
|
|
ld bc, wPlayerStruct
|
|
|
|
call GetSpriteDirection
|
|
|
|
and a
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
CmdQueue_StoneTable:
|
|
|
|
ld de, wPlayerStruct
|
|
|
|
ld a, NUM_OBJECT_STRUCTS
|
|
|
|
.loop
|
|
|
|
push af
|
|
|
|
|
|
|
|
ld hl, OBJECT_SPRITE
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .next
|
|
|
|
|
|
|
|
ld hl, OBJECT_MOVEMENTTYPE
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
cp SPRITEMOVEDATA_STRENGTH_BOULDER
|
|
|
|
jr nz, .next
|
|
|
|
|
|
|
|
ld hl, OBJECT_NEXT_TILE
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
call CheckPitTile
|
|
|
|
jr nz, .next
|
|
|
|
|
|
|
|
ld hl, OBJECT_DIRECTION_WALKING
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
cp STANDING
|
|
|
|
jr nz, .next
|
|
|
|
call HandleStoneQueue
|
|
|
|
jr c, .fall_down_hole
|
|
|
|
|
|
|
|
.next
|
|
|
|
ld hl, OBJECT_STRUCT_LENGTH
|
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
.fall_down_hole
|
|
|
|
pop af
|
|
|
|
ret
|