2013-11-22 23:51:48 -08:00
|
|
|
INCLUDE "includes.asm"
|
|
|
|
|
2017-06-17 16:14:55 -07:00
|
|
|
SECTION "Events", ROMX
|
2013-11-22 23:51:48 -08:00
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
OverworldLoop:: ; 966b0
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
2013-12-27 02:56:23 -08:00
|
|
|
ld [MapStatus], a
|
|
|
|
.loop
|
|
|
|
ld a, [MapStatus]
|
|
|
|
ld hl, .jumps
|
2013-11-22 02:04:32 -08:00
|
|
|
rst JumpTable
|
2013-12-27 02:56:23 -08:00
|
|
|
ld a, [MapStatus]
|
2013-11-22 02:04:32 -08:00
|
|
|
cp 3 ; done
|
2013-12-27 02:56:23 -08:00
|
|
|
jr nz, .loop
|
2013-11-22 02:04:32 -08:00
|
|
|
.done
|
|
|
|
ret
|
|
|
|
|
2013-12-27 02:56:23 -08:00
|
|
|
.jumps
|
|
|
|
dw StartMap
|
|
|
|
dw EnterMap
|
|
|
|
dw HandleMap
|
2013-11-22 02:04:32 -08:00
|
|
|
dw .done
|
|
|
|
; 966cb
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
DisableEvents: ; 966cb
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ld [ScriptFlags3], a
|
|
|
|
ret
|
|
|
|
; 966d0
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
EnableEvents:: ; 966d0
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, $ff
|
|
|
|
ld [ScriptFlags3], a
|
|
|
|
ret
|
|
|
|
; 966d6
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
CheckBit5_ScriptFlags3: ; 966d6
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
bit 5, [hl]
|
|
|
|
ret
|
|
|
|
; 966dc
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
DisableWarpsConnxns: ; 966dc
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
res 2, [hl]
|
|
|
|
ret
|
|
|
|
; 966e2
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
DisableCoordEvents: ; 966e2
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
res 1, [hl]
|
|
|
|
ret
|
|
|
|
; 966e8
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
DisableStepCount: ; 966e8
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
res 0, [hl]
|
|
|
|
ret
|
|
|
|
; 966ee
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
DisableWildEncounters: ; 966ee
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
res 4, [hl]
|
|
|
|
ret
|
|
|
|
; 966f4
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
EnableWarpsConnxns: ; 966f4
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
set 2, [hl]
|
|
|
|
ret
|
|
|
|
; 966fa
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
EnableCoordEvents: ; 966fa
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
set 1, [hl]
|
|
|
|
ret
|
|
|
|
; 96700
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
EnableStepCount: ; 96700
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
set 0, [hl]
|
|
|
|
ret
|
|
|
|
; 96706
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
EnableWildEncounters: ; 96706
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
set 4, [hl]
|
|
|
|
ret
|
|
|
|
; 9670c
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
CheckWarpConnxnScriptFlag: ; 9670c
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
bit 2, [hl]
|
|
|
|
ret
|
|
|
|
; 96712
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
CheckCoordEventScriptFlag: ; 96712
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
bit 1, [hl]
|
|
|
|
ret
|
|
|
|
; 96718
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
CheckStepCountScriptFlag: ; 96718
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
bit 0, [hl]
|
|
|
|
ret
|
|
|
|
; 9671e
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
CheckWildEncountersScriptFlag: ; 9671e
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, ScriptFlags3
|
|
|
|
bit 4, [hl]
|
|
|
|
ret
|
|
|
|
; 96724
|
|
|
|
|
2013-12-27 02:56:23 -08:00
|
|
|
StartMap: ; 96724
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
|
|
|
xor a
|
|
|
|
ld [ScriptRunning], a
|
2013-12-27 02:56:23 -08:00
|
|
|
ld hl, MapStatus
|
2015-12-17 12:14:51 -08:00
|
|
|
ld bc, wMapStatusEnd - MapStatus
|
2013-11-22 02:04:32 -08:00
|
|
|
call ByteFill
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall InitCallReceiveDelay
|
2013-12-22 14:30:35 -08:00
|
|
|
call ClearJoypad
|
2013-12-27 02:56:23 -08:00
|
|
|
EnterMap: ; 9673e
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
2016-01-12 09:46:18 -08:00
|
|
|
ld [wXYComparePointer], a
|
|
|
|
ld [wXYComparePointer + 1], a
|
2015-10-07 18:27:32 -07:00
|
|
|
call SetUpFiveStepWildEncounterCooldown
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall RunMapSetupScript
|
2015-11-13 15:59:49 -08:00
|
|
|
call DisableEvents
|
2013-12-27 02:56:23 -08:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
ld a, [hMapEntryMethod]
|
2015-11-11 20:38:57 -08:00
|
|
|
cp MAPSETUP_CONNECTION
|
2015-11-13 15:59:49 -08:00
|
|
|
jr nz, .dont_enable
|
|
|
|
call EnableEvents
|
|
|
|
.dont_enable
|
2013-12-27 02:56:23 -08:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
ld a, [hMapEntryMethod]
|
2015-10-24 16:49:19 -07:00
|
|
|
cp MAPSETUP_RELOADMAP
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .dontresetpoison
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ld [PoisonStepCount], a
|
2015-07-15 12:48:44 -07:00
|
|
|
.dontresetpoison
|
2013-12-27 02:56:23 -08:00
|
|
|
|
2015-10-24 16:49:19 -07:00
|
|
|
xor a ; end map entry
|
2015-10-07 10:19:41 -07:00
|
|
|
ld [hMapEntryMethod], a
|
2013-12-27 02:56:23 -08:00
|
|
|
ld a, 2 ; HandleMap
|
|
|
|
ld [MapStatus], a
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 9676d
|
|
|
|
|
2015-12-17 12:14:51 -08:00
|
|
|
UnusedWait30Frames: ; 9676d
|
2013-11-22 02:04:32 -08:00
|
|
|
ld c, 30
|
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
; 96773
|
|
|
|
|
2013-12-27 02:56:23 -08:00
|
|
|
HandleMap: ; 96773
|
2013-11-22 02:04:32 -08:00
|
|
|
call ResetOverworldDelay
|
2015-12-17 12:14:51 -08:00
|
|
|
call HandleMapTimeAndJoypad
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall HandleCmdQueue ; no need to farcall
|
2013-12-27 02:56:23 -08:00
|
|
|
call MapEvents
|
|
|
|
|
|
|
|
; Not immediately entering a connected map will cause problems.
|
|
|
|
ld a, [MapStatus]
|
|
|
|
cp 2 ; HandleMap
|
2013-11-22 02:04:32 -08:00
|
|
|
ret nz
|
2013-12-27 02:56:23 -08:00
|
|
|
|
2016-05-17 05:40:42 -07:00
|
|
|
call HandleMapObjects
|
2013-11-22 02:04:32 -08:00
|
|
|
call NextOverworldFrame
|
2016-05-17 05:40:42 -07:00
|
|
|
call HandleMapBackground
|
|
|
|
call CheckPlayerState
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 96795
|
|
|
|
|
2013-12-27 02:56:23 -08:00
|
|
|
MapEvents: ; 96795
|
|
|
|
ld a, [MapEventStatus]
|
|
|
|
ld hl, .jumps
|
2013-11-22 02:04:32 -08:00
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2013-12-27 02:56:23 -08:00
|
|
|
.jumps
|
|
|
|
dw .events
|
|
|
|
dw .no_events
|
2013-11-22 02:04:32 -08:00
|
|
|
; 967a1
|
|
|
|
|
2013-12-27 02:56:23 -08:00
|
|
|
.events ; 967a1
|
2013-11-22 02:04:32 -08:00
|
|
|
call PlayerEvents
|
2015-11-13 15:59:49 -08:00
|
|
|
call DisableEvents
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ScriptEvents
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 967ae
|
|
|
|
|
2013-12-27 02:56:23 -08:00
|
|
|
.no_events ; 967ae
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 967af
|
|
|
|
|
|
|
|
MaxOverworldDelay: ; 967af
|
|
|
|
db 2
|
|
|
|
; 967b0
|
|
|
|
|
|
|
|
ResetOverworldDelay: ; 967b0
|
|
|
|
ld a, [MaxOverworldDelay]
|
|
|
|
ld [OverworldDelay], a
|
|
|
|
ret
|
|
|
|
; 967b7
|
|
|
|
|
|
|
|
NextOverworldFrame: ; 967b7
|
|
|
|
ld a, [OverworldDelay]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
ld c, a
|
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
; 967c1
|
|
|
|
|
2015-12-17 12:14:51 -08:00
|
|
|
HandleMapTimeAndJoypad: ; 967c1
|
2013-12-27 02:56:23 -08:00
|
|
|
ld a, [MapEventStatus]
|
|
|
|
cp 1 ; no events
|
2013-11-22 02:04:32 -08:00
|
|
|
ret z
|
2013-12-27 02:56:23 -08:00
|
|
|
|
2013-11-22 02:04:32 -08:00
|
|
|
call UpdateTime
|
2013-12-22 14:30:35 -08:00
|
|
|
call GetJoypad
|
2013-11-22 02:04:32 -08:00
|
|
|
call TimeOfDayPals
|
|
|
|
ret
|
|
|
|
; 967d1
|
|
|
|
|
2016-05-17 05:40:42 -07:00
|
|
|
HandleMapObjects: ; 967d1
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall HandleNPCStep ; engine/map_objects.asm
|
|
|
|
farcall _HandlePlayerStep
|
2015-12-24 19:58:42 -08:00
|
|
|
call _CheckObjectEnteringVisibleRange
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 967e1
|
|
|
|
|
2016-05-17 05:40:42 -07:00
|
|
|
HandleMapBackground: ; 967e1
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _UpdateSprites
|
|
|
|
farcall ScrollScreen
|
|
|
|
farcall PlaceMapNameSign
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 967f4
|
|
|
|
|
2016-05-17 05:40:42 -07:00
|
|
|
CheckPlayerState: ; 967f4
|
2015-11-14 20:02:38 -08:00
|
|
|
ld a, [wPlayerStepFlags]
|
2015-12-24 19:58:42 -08:00
|
|
|
bit 5, a ; in the middle of step
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .events
|
2015-12-24 19:58:42 -08:00
|
|
|
bit 6, a ; stopping step
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .noevents
|
2015-12-24 19:58:42 -08:00
|
|
|
bit 4, a ; in midair
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .noevents
|
2015-11-13 15:59:49 -08:00
|
|
|
call EnableEvents
|
2015-07-15 12:48:44 -07:00
|
|
|
.events
|
2013-12-27 02:56:23 -08:00
|
|
|
ld a, 0 ; events
|
|
|
|
ld [MapEventStatus], a
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.noevents
|
2013-12-27 02:56:23 -08:00
|
|
|
ld a, 1 ; no events
|
|
|
|
ld [MapEventStatus], a
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 96812
|
|
|
|
|
2015-12-24 19:58:42 -08:00
|
|
|
_CheckObjectEnteringVisibleRange: ; 96812
|
2015-11-14 20:02:38 -08:00
|
|
|
ld hl, wPlayerStepFlags
|
2013-11-22 02:04:32 -08:00
|
|
|
bit 6, [hl]
|
|
|
|
ret z
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckObjectEnteringVisibleRange
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 9681f
|
|
|
|
|
|
|
|
PlayerEvents: ; 9681f
|
|
|
|
xor a
|
2015-10-24 07:34:19 -07:00
|
|
|
; If there's already a player event, don't interrupt it.
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [ScriptRunning]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
call Dummy_CheckScriptFlags3Bit5 ; This is a waste of time
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
call CheckTrainerBattle3
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
call CheckTileEvent
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
call RunMemScript
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
call RunSceneScript
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
call CheckTimeEvents
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
call OWPlayerInput
|
2015-07-15 12:48:44 -07:00
|
|
|
jr c, .ok
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2013-11-22 02:04:32 -08:00
|
|
|
push af
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall EnableScriptMode
|
2013-11-22 02:04:32 -08:00
|
|
|
pop af
|
|
|
|
|
|
|
|
ld [ScriptRunning], a
|
2015-10-24 16:49:19 -07:00
|
|
|
call DoPlayerEvent
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [ScriptRunning]
|
2015-11-11 20:38:57 -08:00
|
|
|
cp PLAYEREVENT_CONNECTION
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok2
|
2015-11-11 20:38:57 -08:00
|
|
|
cp PLAYEREVENT_JOYCHANGEFACING
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok2
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
xor a
|
2015-11-10 08:05:26 -08:00
|
|
|
ld [wLandmarkSignTimer], a
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok2
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96867
|
|
|
|
|
|
|
|
CheckTrainerBattle3: ; 96867
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
call CheckTrainerBattle2
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .nope
|
2013-12-27 02:56:23 -08:00
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
ld a, PLAYEREVENT_SEENBYTRAINER
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 96874
|
|
|
|
|
|
|
|
CheckTileEvent: ; 96874
|
2017-12-24 10:46:34 -08:00
|
|
|
; Check for warps, coord events, or wild battles.
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
call CheckWarpConnxnScriptFlag
|
|
|
|
jr z, .connections_disabled
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckMovingOffEdgeOfMap
|
2015-11-12 08:10:19 -08:00
|
|
|
jr c, .map_connection
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 16:49:19 -07:00
|
|
|
call CheckWarpTile
|
2015-11-12 08:10:19 -08:00
|
|
|
jr c, .warp_tile
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
.connections_disabled
|
|
|
|
call CheckCoordEventScriptFlag
|
|
|
|
jr z, .coord_events_disabled
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
call CheckCurrentMapCoordEvents
|
2015-11-13 15:59:49 -08:00
|
|
|
jr c, .coord_event
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
.coord_events_disabled
|
|
|
|
call CheckStepCountScriptFlag
|
|
|
|
jr z, .step_count_disabled
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
call CountStep
|
|
|
|
ret c
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
.step_count_disabled
|
|
|
|
call CheckWildEncountersScriptFlag
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .ok
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
call RandomEncounter
|
2013-11-22 02:04:32 -08:00
|
|
|
ret c
|
2015-10-07 18:27:32 -07:00
|
|
|
jr .ok ; pointless
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.ok
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.map_connection
|
|
|
|
ld a, PLAYEREVENT_CONNECTION
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.warp_tile
|
2016-01-10 23:28:09 -08:00
|
|
|
ld a, [PlayerStandingTile]
|
2013-11-22 02:04:32 -08:00
|
|
|
call CheckPitTile
|
2015-11-12 08:10:19 -08:00
|
|
|
jr nz, .not_pit
|
|
|
|
ld a, PLAYEREVENT_FALL
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-12 08:10:19 -08:00
|
|
|
.not_pit
|
|
|
|
ld a, PLAYEREVENT_WARP
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
.coord_event
|
2016-01-06 04:44:50 -08:00
|
|
|
ld hl, wCurCoordEventScriptAddr
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call CallScript
|
|
|
|
ret
|
|
|
|
; 968c7
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
CheckWildEncounterCooldown:: ; 968c7
|
|
|
|
ld hl, wWildEncounterCooldown
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec [hl]
|
|
|
|
ret z
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 968d1
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
SetUpFiveStepWildEncounterCooldown: ; 968d1
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, 5
|
2015-10-07 18:27:32 -07:00
|
|
|
ld [wWildEncounterCooldown], a
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 968d7
|
|
|
|
|
2015-10-24 16:49:19 -07:00
|
|
|
ret_968d7: ; 968d7
|
|
|
|
ret
|
|
|
|
;968d8
|
|
|
|
|
|
|
|
SetMinTwoStepWildEncounterCooldown: ; 968d8
|
2015-10-07 18:27:32 -07:00
|
|
|
ld a, [wWildEncounterCooldown]
|
2013-11-22 02:04:32 -08:00
|
|
|
cp 2
|
|
|
|
ret nc
|
|
|
|
ld a, 2
|
2015-10-07 18:27:32 -07:00
|
|
|
ld [wWildEncounterCooldown], a
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 968e4
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
Dummy_CheckScriptFlags3Bit5: ; 968e4
|
2015-07-15 12:48:44 -07:00
|
|
|
call CheckBit5_ScriptFlags3
|
2013-11-22 02:04:32 -08:00
|
|
|
ret z
|
2015-10-24 07:34:19 -07:00
|
|
|
call ret_2f3e
|
2013-11-22 02:04:32 -08:00
|
|
|
ret
|
|
|
|
; 968ec
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
RunSceneScript: ; 968ec
|
|
|
|
ld a, [wCurrMapSceneScriptCount]
|
2013-11-22 02:04:32 -08:00
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .nope
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
ld c, a
|
2017-12-24 10:46:34 -08:00
|
|
|
call CheckScenes
|
2013-11-22 02:04:32 -08:00
|
|
|
cp c
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .nope
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2017-12-24 10:46:34 -08:00
|
|
|
ld hl, wCurrMapSceneScriptHeaderPointer
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-07-20 08:28:05 -07:00
|
|
|
rept 4
|
2016-01-10 14:44:09 -08:00
|
|
|
add hl, de
|
2015-07-20 08:28:05 -07:00
|
|
|
endr
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-11-22 02:04:32 -08:00
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call GetFarHalfword
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call CallScript
|
|
|
|
|
|
|
|
ld hl, ScriptFlags
|
|
|
|
res 3, [hl]
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall EnableScriptMode
|
|
|
|
farcall ScriptEvents
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
ld hl, ScriptFlags
|
|
|
|
bit 3, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .nope
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
ld hl, wPriorityScriptAddr
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-11-28 12:13:40 -08:00
|
|
|
ld a, [wPriorityScriptBank]
|
2013-11-22 02:04:32 -08:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 9693a
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
CheckTimeEvents: ; 9693a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-11-22 02:04:32 -08:00
|
|
|
and a
|
2014-07-24 20:19:56 -07:00
|
|
|
jr nz, .nothing
|
|
|
|
|
2017-12-28 04:15:46 -08:00
|
|
|
ld hl, wStatusFlags2
|
2015-11-12 21:49:27 -08:00
|
|
|
bit 2, [hl] ; bug contest
|
2015-10-24 07:34:19 -07:00
|
|
|
jr z, .do_daily
|
2014-07-24 20:19:56 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckBugContestTimer
|
2015-10-24 07:34:19 -07:00
|
|
|
jr c, .end_bug_contest
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.do_daily
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckDailyResetTimer
|
|
|
|
farcall CheckPokerusTick
|
|
|
|
farcall CheckPhoneCall
|
2013-11-22 02:04:32 -08:00
|
|
|
ret c
|
|
|
|
|
2014-07-24 20:19:56 -07:00
|
|
|
.nothing
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.end_bug_contest
|
2015-07-16 15:10:10 -07:00
|
|
|
ld a, BANK(BugCatchingContestOverScript)
|
|
|
|
ld hl, BugCatchingContestOverScript
|
2013-11-22 02:04:32 -08:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96970
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.unused ; 96970
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, 8
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96974
|
|
|
|
|
|
|
|
OWPlayerInput: ; 96974
|
|
|
|
|
|
|
|
call PlayerMovement
|
|
|
|
ret c
|
|
|
|
and a
|
|
|
|
jr nz, .NoAction
|
|
|
|
|
|
|
|
; Can't perform button actions while sliding on ice.
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckStandingOnIce
|
2013-11-22 02:04:32 -08:00
|
|
|
jr c, .NoAction
|
|
|
|
|
|
|
|
call CheckAPressOW
|
|
|
|
jr c, .Action
|
|
|
|
|
|
|
|
call CheckMenuOW
|
|
|
|
jr c, .Action
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NoAction:
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Action:
|
2013-11-22 02:04:32 -08:00
|
|
|
push af
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall StopPlayerForEvent
|
2013-11-22 02:04:32 -08:00
|
|
|
pop af
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96999
|
|
|
|
|
|
|
|
CheckAPressOW: ; 96999
|
|
|
|
ld a, [hJoyPressed]
|
|
|
|
and A_BUTTON
|
|
|
|
ret z
|
|
|
|
call TryObjectEvent
|
|
|
|
ret c
|
2017-12-24 10:46:34 -08:00
|
|
|
call TryBGEvent
|
2013-11-22 02:04:32 -08:00
|
|
|
ret c
|
2017-12-24 10:46:34 -08:00
|
|
|
call TryTileCollisionEvent
|
2013-11-22 02:04:32 -08:00
|
|
|
ret c
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 969ac
|
|
|
|
|
|
|
|
PlayTalkObject: ; 969ac
|
|
|
|
push de
|
|
|
|
ld de, SFX_READ_TEXT_2
|
|
|
|
call PlaySFX
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 969b5
|
|
|
|
|
|
|
|
TryObjectEvent: ; 969b5
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckFacingObject
|
2013-11-22 02:04:32 -08:00
|
|
|
jr c, .IsObject
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.IsObject:
|
2013-11-22 02:04:32 -08:00
|
|
|
call PlayTalkObject
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [hObjectStructIndexBuffer]
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2013-11-22 02:04:32 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-21 23:49:18 -07:00
|
|
|
ld [hLastTalked], a
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-07-21 23:49:18 -07:00
|
|
|
ld a, [hLastTalked]
|
2013-11-22 02:04:32 -08:00
|
|
|
call GetMapObject
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, MAPOBJECT_COLOR
|
2013-11-22 02:04:32 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
and %00001111
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
; Bug: If IsInArray returns nc, data at bc will be executed as code.
|
|
|
|
push bc
|
|
|
|
ld de, 3
|
2015-07-15 12:48:44 -07:00
|
|
|
ld hl, .pointers
|
2013-11-22 02:04:32 -08:00
|
|
|
call IsInArray
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nc, .nope_bugged
|
2013-11-22 02:04:32 -08:00
|
|
|
pop bc
|
|
|
|
|
|
|
|
inc hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-17 16:14:55 -07:00
|
|
|
jp hl
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope_bugged
|
2015-11-15 11:59:38 -08:00
|
|
|
; pop bc
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.pointers
|
2017-12-24 10:46:34 -08:00
|
|
|
dbw OBJECTTYPE_SCRIPT, .script
|
|
|
|
dbw OBJECTTYPE_ITEMBALL, .itemball
|
|
|
|
dbw OBJECTTYPE_TRAINER, .trainer
|
2015-11-15 11:59:38 -08:00
|
|
|
; the remaining four are dummy events
|
2017-12-24 10:46:34 -08:00
|
|
|
dbw OBJECTTYPE_3, .three
|
|
|
|
dbw OBJECTTYPE_4, .four
|
|
|
|
dbw OBJECTTYPE_5, .five
|
|
|
|
dbw OBJECTTYPE_6, .six
|
2015-07-15 12:48:44 -07:00
|
|
|
db -1
|
2013-11-22 02:04:32 -08:00
|
|
|
; 96a04
|
|
|
|
|
2015-11-15 11:59:38 -08:00
|
|
|
.script ; 96a04
|
2015-07-18 12:46:38 -07:00
|
|
|
ld hl, MAPOBJECT_SCRIPT_POINTER
|
2013-11-22 02:04:32 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call CallScript
|
|
|
|
ret
|
|
|
|
; 96a12
|
|
|
|
|
2015-12-15 07:55:56 -08:00
|
|
|
.itemball ; 96a12
|
2015-07-18 12:46:38 -07:00
|
|
|
ld hl, MAPOBJECT_SCRIPT_POINTER
|
2013-11-22 02:04:32 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
ld de, EngineBuffer1
|
|
|
|
ld bc, 2
|
|
|
|
call FarCopyBytes
|
2015-11-15 11:59:38 -08:00
|
|
|
ld a, PLAYEREVENT_ITEMBALL
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96a29
|
|
|
|
|
2015-11-15 11:59:38 -08:00
|
|
|
.trainer ; 96a29
|
|
|
|
call TalkToTrainer
|
|
|
|
ld a, PLAYEREVENT_TALKTOTRAINER
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96a30
|
|
|
|
|
|
|
|
.three ; 96a30
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 96a32
|
|
|
|
|
|
|
|
.four ; 96a32
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 96a34
|
|
|
|
|
|
|
|
.five ; 96a34
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 96a36
|
|
|
|
|
|
|
|
.six ; 96a36
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 96a38
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
TryBGEvent: ; 96a38
|
|
|
|
call CheckFacingBGEvent
|
|
|
|
jr c, .is_bg_event
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
.is_bg_event:
|
2015-11-12 08:10:19 -08:00
|
|
|
ld a, [EngineBuffer3]
|
2017-12-24 10:46:34 -08:00
|
|
|
ld hl, .bg_events
|
2013-11-22 02:04:32 -08:00
|
|
|
rst JumpTable
|
|
|
|
ret
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
.bg_events
|
2013-11-22 02:04:32 -08:00
|
|
|
dw .read
|
|
|
|
dw .up
|
|
|
|
dw .down
|
|
|
|
dw .right
|
|
|
|
dw .left
|
|
|
|
dw .ifset
|
|
|
|
dw .ifnotset
|
|
|
|
dw .itemifset
|
2015-07-15 12:48:44 -07:00
|
|
|
dw .copy
|
2013-11-22 02:04:32 -08:00
|
|
|
; 96a59
|
|
|
|
|
|
|
|
.up
|
2015-11-15 11:59:38 -08:00
|
|
|
ld b, OW_UP
|
2013-11-22 02:04:32 -08:00
|
|
|
jr .checkdir
|
|
|
|
.down
|
2015-11-15 11:59:38 -08:00
|
|
|
ld b, OW_DOWN
|
2013-11-22 02:04:32 -08:00
|
|
|
jr .checkdir
|
|
|
|
.right
|
2015-11-15 11:59:38 -08:00
|
|
|
ld b, OW_RIGHT
|
2013-11-22 02:04:32 -08:00
|
|
|
jr .checkdir
|
|
|
|
.left
|
2015-11-15 11:59:38 -08:00
|
|
|
ld b, OW_LEFT
|
2013-11-22 02:04:32 -08:00
|
|
|
jr .checkdir
|
|
|
|
|
|
|
|
.checkdir
|
|
|
|
ld a, [PlayerDirection]
|
|
|
|
and %1100
|
|
|
|
cp b
|
|
|
|
jp nz, .dontread
|
|
|
|
|
|
|
|
.read
|
|
|
|
call PlayTalkObject
|
2015-11-12 08:10:19 -08:00
|
|
|
ld hl, EngineBuffer4
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.itemifset
|
2017-12-24 10:46:34 -08:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 02:04:32 -08:00
|
|
|
jp nz, .dontread
|
|
|
|
call PlayTalkObject
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
ld de, EngineBuffer1
|
|
|
|
ld bc, 3
|
|
|
|
call FarCopyBytes
|
2015-12-15 08:21:58 -08:00
|
|
|
ld a, BANK(HiddenItemScript)
|
|
|
|
ld hl, HiddenItemScript
|
2013-11-22 02:04:32 -08:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.copy
|
2017-12-24 10:46:34 -08:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 02:04:32 -08:00
|
|
|
jr nz, .dontread
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
ld de, EngineBuffer1
|
|
|
|
ld bc, 3
|
|
|
|
call FarCopyBytes
|
|
|
|
jr .dontread
|
|
|
|
|
|
|
|
.ifset
|
2017-12-24 10:46:34 -08:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 02:04:32 -08:00
|
|
|
jr z, .dontread
|
2015-07-15 12:48:44 -07:00
|
|
|
jr .thenread
|
2013-11-22 02:04:32 -08:00
|
|
|
|
|
|
|
.ifnotset
|
2017-12-24 10:46:34 -08:00
|
|
|
call CheckBGEventFlag
|
2013-11-22 02:04:32 -08:00
|
|
|
jr nz, .dontread
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.thenread
|
2013-11-22 02:04:32 -08:00
|
|
|
push hl
|
|
|
|
call PlayTalkObject
|
|
|
|
pop hl
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2013-11-22 02:04:32 -08:00
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call GetFarHalfword
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.dontread
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 96ad8
|
|
|
|
|
2017-12-24 10:46:34 -08:00
|
|
|
CheckBGEventFlag: ; 96ad8
|
2015-11-12 08:10:19 -08:00
|
|
|
ld hl, EngineBuffer4
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
push hl
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call GetFarHalfword
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2015-11-12 08:10:19 -08:00
|
|
|
ld b, CHECK_FLAG
|
2013-11-22 02:04:32 -08:00
|
|
|
call EventFlagAction
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 96af0
|
|
|
|
|
|
|
|
PlayerMovement: ; 96af0
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoPlayerMovement
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, c
|
|
|
|
ld hl, .pointers
|
|
|
|
rst JumpTable
|
|
|
|
ld a, c
|
|
|
|
ret
|
|
|
|
; 96afd
|
|
|
|
|
|
|
|
.pointers
|
|
|
|
dw .zero
|
|
|
|
dw .one
|
|
|
|
dw .two
|
|
|
|
dw .three
|
|
|
|
dw .four
|
|
|
|
dw .five
|
|
|
|
dw .six
|
|
|
|
dw .seven
|
|
|
|
|
|
|
|
.zero
|
|
|
|
.four ; 96b0d
|
|
|
|
xor a
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
; 96b10
|
|
|
|
|
|
|
|
.seven ; 96b10
|
2015-10-24 16:49:19 -07:00
|
|
|
call ret_968d7 ; mobile
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
; 96b16
|
|
|
|
|
|
|
|
.one ; 96b16
|
|
|
|
ld a, 5
|
|
|
|
ld c, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96b1b
|
|
|
|
|
|
|
|
.two ; 96b1b
|
|
|
|
ld a, 9
|
|
|
|
ld c, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96b20
|
|
|
|
|
|
|
|
.three ; 96b20
|
|
|
|
; force the player to move in some direction
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, BANK(Script_ForcedMovement)
|
|
|
|
ld hl, Script_ForcedMovement
|
2013-11-22 02:04:32 -08:00
|
|
|
call CallScript
|
|
|
|
; ld a, -1
|
|
|
|
ld c, a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96b2b
|
|
|
|
|
|
|
|
.five
|
|
|
|
.six ; 96b2b
|
|
|
|
ld a, -1
|
|
|
|
ld c, a
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 96b30
|
|
|
|
|
|
|
|
CheckMenuOW: ; 96b30
|
|
|
|
xor a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [hMenuReturn], a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hMenuReturn + 1], a
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hJoyPressed]
|
|
|
|
|
|
|
|
bit 2, a ; SELECT
|
|
|
|
jr nz, .Select
|
|
|
|
|
|
|
|
bit 3, a ; START
|
|
|
|
jr z, .NoMenu
|
|
|
|
|
|
|
|
ld a, BANK(StartMenuScript)
|
|
|
|
ld hl, StartMenuScript
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NoMenu:
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Select:
|
2013-11-22 02:04:32 -08:00
|
|
|
call PlayTalkObject
|
|
|
|
ld a, BANK(SelectMenuScript)
|
|
|
|
ld hl, SelectMenuScript
|
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96b58
|
|
|
|
|
|
|
|
StartMenuScript: ; 96b58
|
2015-01-20 00:01:23 -08:00
|
|
|
callasm StartMenu
|
|
|
|
jump StartMenuCallback
|
2013-11-22 02:04:32 -08:00
|
|
|
; 96b5f
|
|
|
|
|
|
|
|
SelectMenuScript: ; 96b5f
|
2015-01-20 00:01:23 -08:00
|
|
|
callasm SelectMenu
|
|
|
|
jump SelectMenuCallback
|
2013-11-22 02:04:32 -08:00
|
|
|
; 96b66
|
|
|
|
|
|
|
|
StartMenuCallback:
|
|
|
|
SelectMenuCallback: ; 96b66
|
2015-10-24 07:34:19 -07:00
|
|
|
copybytetovar hMenuReturn
|
|
|
|
if_equal HMENURETURN_SCRIPT, .Script
|
|
|
|
if_equal HMENURETURN_ASM, .Asm
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96b72
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Script: ; 96b72
|
2015-11-01 09:44:30 -08:00
|
|
|
ptjump wQueuedScriptBank
|
2013-11-22 02:04:32 -08:00
|
|
|
; 96b75
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Asm: ; 96b75
|
2015-11-01 09:44:30 -08:00
|
|
|
ptcallasm wQueuedScriptBank
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96b79
|
|
|
|
|
|
|
|
CountStep: ; 96b79
|
2015-10-24 07:34:19 -07:00
|
|
|
; Don't count steps in link communication rooms.
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-11-22 02:04:32 -08:00
|
|
|
and a
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .done
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
; If there is a special phone call, don't count the step.
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckSpecialPhoneCall
|
2015-10-24 07:34:19 -07:00
|
|
|
jr c, .doscript
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
; If Repel wore off, don't count the step.
|
|
|
|
call DoRepelStep
|
|
|
|
jr c, .doscript
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
; Count the step for poison and total steps
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, PoisonStepCount
|
|
|
|
inc [hl]
|
|
|
|
ld hl, StepCount
|
|
|
|
inc [hl]
|
2015-10-24 07:34:19 -07:00
|
|
|
; Every 256 steps, increase the happiness of all your Pokemon.
|
|
|
|
jr nz, .skip_happiness
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall StepHappiness
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07: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.
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [StepCount]
|
|
|
|
cp $80
|
2015-10-24 07:34:19 -07:00
|
|
|
jr nz, .skip_egg
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoEggStep
|
2015-10-24 07:34:19 -07:00
|
|
|
jr nz, .hatch
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.skip_egg
|
|
|
|
; Increase the EXP of (both) DayCare Pokemon by 1.
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DayCareStep
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
; Every four steps, deal damage to all Poisoned Pokemon
|
2013-11-22 02:04:32 -08:00
|
|
|
ld hl, PoisonStepCount
|
|
|
|
ld a, [hl]
|
|
|
|
cp 4
|
2015-10-24 07:34:19 -07:00
|
|
|
jr c, .skip_poison
|
2013-11-22 02:04:32 -08:00
|
|
|
ld [hl], 0
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoPoisonStep
|
2015-10-24 07:34:19 -07:00
|
|
|
jr c, .doscript
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.skip_poison
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoBikeStep
|
2013-11-22 02:04:32 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.done
|
2013-11-22 02:04:32 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.doscript
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, -1
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.hatch
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, 8
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96bd3
|
|
|
|
|
2016-04-10 12:01:49 -07:00
|
|
|
.unreferenced ; 96bd3
|
2015-07-15 12:48:44 -07:00
|
|
|
ld a, 7
|
2013-11-22 02:04:32 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96bd7
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
DoRepelStep: ; 96bd7
|
|
|
|
ld a, [wRepelEffect]
|
2013-11-22 02:04:32 -08:00
|
|
|
and a
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2013-11-22 02:04:32 -08:00
|
|
|
dec a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wRepelEffect], a
|
2013-11-22 02:04:32 -08:00
|
|
|
ret nz
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
ld a, BANK(RepelWoreOffScript)
|
|
|
|
ld hl, RepelWoreOffScript
|
2013-11-22 02:04:32 -08:00
|
|
|
call CallScript
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 96beb
|
|
|
|
|
2015-10-24 16:49:19 -07:00
|
|
|
DoPlayerEvent: ; 96beb
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [ScriptRunning]
|
|
|
|
and a
|
|
|
|
ret z
|
2015-11-11 20:38:57 -08:00
|
|
|
|
2015-11-05 12:08:00 -08:00
|
|
|
cp PLAYEREVENT_MAPSCRIPT ; run script
|
2013-11-22 02:04:32 -08:00
|
|
|
ret z
|
2015-11-11 20:38:57 -08:00
|
|
|
|
2015-11-05 12:08:00 -08:00
|
|
|
cp NUM_PLAYER_EVENTS
|
2013-11-22 02:04:32 -08:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2015-11-05 12:08:00 -08:00
|
|
|
ld hl, PlayerEventScriptPointers
|
2016-01-10 14:44:09 -08:00
|
|
|
add hl, bc
|
2016-05-10 09:31:49 -07:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2013-11-22 02:04:32 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [ScriptBank], a
|
|
|
|
ld a, [hli]
|
|
|
|
ld [ScriptPos], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [ScriptPos + 1], a
|
|
|
|
ret
|
|
|
|
; 96c0c
|
|
|
|
|
2015-11-05 12:08:00 -08:00
|
|
|
PlayerEventScriptPointers: ; 96c0c
|
2015-11-11 20:38:57 -08:00
|
|
|
dba Invalid_0x96c2d ; 0
|
|
|
|
dba SeenByTrainerScript ; 1
|
|
|
|
dba TalkToTrainerScript ; 2
|
|
|
|
dba FindItemInBallScript ; 3
|
2015-11-13 15:59:49 -08:00
|
|
|
dba EdgeWarpScript ; 4
|
2015-11-11 20:38:57 -08:00
|
|
|
dba WarpToNewMapScript ; 5
|
|
|
|
dba FallIntoMapScript ; 6
|
|
|
|
dba Script_OverworldWhiteout ; 7
|
|
|
|
dba HatchEggScript ; 8
|
2015-11-13 15:59:49 -08:00
|
|
|
dba ChangeDirectionScript ; 9
|
2015-11-11 20:38:57 -08:00
|
|
|
dba Invalid_0x96c2d ; 10
|
2013-11-22 02:04:32 -08:00
|
|
|
; 96c2d
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
Invalid_0x96c2d: ; 96c2d
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96c2e
|
|
|
|
|
2015-11-11 20:38:57 -08:00
|
|
|
; unreferenced
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96c2f
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
HatchEggScript: ; 96c2f
|
|
|
|
callasm OverworldHatchEgg
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96c34
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
WarpToNewMapScript: ; 96c34
|
2013-11-22 02:04:32 -08:00
|
|
|
warpsound
|
2015-11-11 20:38:57 -08:00
|
|
|
newloadmap MAPSETUP_DOOR
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96c38
|
|
|
|
|
|
|
|
FallIntoMapScript: ; 96c38
|
2015-11-11 20:38:57 -08:00
|
|
|
newloadmap MAPSETUP_FALL
|
2013-11-22 02:04:32 -08:00
|
|
|
playsound SFX_KINESIS
|
2015-07-21 23:49:18 -07:00
|
|
|
applymovement PLAYER, MovementData_0x96c48
|
2013-11-22 02:04:32 -08:00
|
|
|
playsound SFX_STRENGTH
|
2015-10-24 16:49:19 -07:00
|
|
|
scall LandAfterPitfallScript
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96c48
|
|
|
|
|
|
|
|
MovementData_0x96c48: ; 96c48
|
|
|
|
skyfall
|
|
|
|
step_end
|
|
|
|
; 96c4a
|
|
|
|
|
2015-10-24 16:49:19 -07:00
|
|
|
LandAfterPitfallScript: ; 96c4a
|
2013-11-22 02:04:32 -08:00
|
|
|
earthquake 16
|
|
|
|
end
|
|
|
|
; 96c4d
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
EdgeWarpScript: ; 4
|
2015-11-11 20:38:57 -08:00
|
|
|
reloadandreturn MAPSETUP_CONNECTION
|
2013-11-22 02:04:32 -08:00
|
|
|
; 96c4f
|
|
|
|
|
2015-11-13 15:59:49 -08:00
|
|
|
ChangeDirectionScript: ; 9
|
|
|
|
deactivatefacing 3
|
|
|
|
callasm EnableWildEncounters
|
2013-11-22 02:04:32 -08:00
|
|
|
end
|
|
|
|
; 96c56
|
|
|
|
|
2014-12-29 08:08:03 -08:00
|
|
|
INCLUDE "engine/scripting.asm"
|
|
|
|
INCLUDE "engine/events_2.asm"
|