2018-06-24 16:09:41 +02:00
|
|
|
RunMapSetupScript::
|
2018-08-25 14:28:22 -04:00
|
|
|
ldh a, [hMapEntryMethod]
|
2015-02-11 14:01:04 -08:00
|
|
|
and $f
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, MapSetupScripts
|
|
|
|
add hl, bc
|
2015-12-26 21:59:03 -05:00
|
|
|
add hl, bc
|
2015-02-11 14:01:04 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call ReadMapSetupScript
|
|
|
|
ret
|
|
|
|
|
2017-12-27 01:29:15 -05:00
|
|
|
INCLUDE "data/maps/setup_scripts.asm"
|
2015-02-11 14:01:04 -08:00
|
|
|
|
2018-06-24 16:09:41 +02:00
|
|
|
ReadMapSetupScript:
|
2015-02-11 14:01:04 -08:00
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
2020-07-22 13:37:43 -04:00
|
|
|
cp -1 ; end?
|
2015-02-11 14:01:04 -08:00
|
|
|
ret z
|
|
|
|
|
|
|
|
push hl
|
|
|
|
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, MapSetupCommands
|
|
|
|
add hl, bc
|
2016-05-10 12:31:49 -04:00
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2015-02-11 14:01:04 -08:00
|
|
|
|
|
|
|
; bank
|
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
|
|
|
|
; address
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
|
|
|
|
; Bit 7 of the bank indicates a parameter.
|
|
|
|
; This is left unused.
|
|
|
|
bit 7, b
|
|
|
|
jr z, .go
|
|
|
|
|
|
|
|
pop de
|
|
|
|
ld a, [de]
|
|
|
|
ld c, a
|
|
|
|
inc de
|
|
|
|
push de
|
|
|
|
|
|
|
|
.go
|
|
|
|
ld a, b
|
|
|
|
and $7f
|
|
|
|
rst FarCall
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
jr .loop
|
|
|
|
|
2020-07-13 20:44:16 -04:00
|
|
|
INCLUDE "data/maps/setup_script_pointers.asm"
|
2015-02-11 14:01:04 -08:00
|
|
|
|
2019-11-18 18:16:50 +01:00
|
|
|
EnableTextAcceleration:
|
2015-02-11 14:01:04 -08:00
|
|
|
xor a
|
2016-05-05 15:07:37 -04:00
|
|
|
ld [wDisableTextAcceleration], a
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 16:09:41 +02:00
|
|
|
ActivateMapAnims:
|
2020-06-21 16:27:43 -04:00
|
|
|
ld a, TRUE
|
2018-08-25 14:28:22 -04:00
|
|
|
ldh [hMapAnims], a
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 16:09:41 +02:00
|
|
|
SuspendMapAnims:
|
2020-06-21 16:27:43 -04:00
|
|
|
xor a ; FALSE
|
2018-08-25 14:28:22 -04:00
|
|
|
ldh [hMapAnims], a
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2019-11-18 18:16:50 +01:00
|
|
|
LoadMapObjects:
|
2016-01-06 07:44:50 -05:00
|
|
|
ld a, MAPCALLBACK_OBJECTS
|
2015-07-20 03:51:52 -04:00
|
|
|
call RunMapCallback
|
2017-12-24 12:47:30 -05:00
|
|
|
farcall LoadObjectMasks
|
|
|
|
farcall InitializeVisibleSprites
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2019-11-18 18:16:50 +01:00
|
|
|
ResetPlayerObjectAction:
|
2015-10-24 10:34:19 -04:00
|
|
|
ld hl, wPlayerSpriteSetupFlags
|
2018-01-22 14:34:55 -05:00
|
|
|
set PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2019-11-18 18:16:50 +01:00
|
|
|
SkipUpdateMapSprites:
|
2015-10-24 10:34:19 -04:00
|
|
|
ld hl, wPlayerSpriteSetupFlags
|
2018-01-22 14:34:55 -05:00
|
|
|
set PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2020-06-16 19:38:00 -04:00
|
|
|
CheckUpdatePlayerSprite:
|
2024-01-04 22:30:40 +01:00
|
|
|
call .CheckForcedBiking
|
2015-07-20 03:51:52 -04:00
|
|
|
jr c, .ok
|
2015-11-12 11:10:19 -05:00
|
|
|
call .CheckSurfing
|
2015-07-20 03:51:52 -04:00
|
|
|
jr c, .ok
|
2024-01-04 22:30:40 +01:00
|
|
|
call .ResetSurfingOrBikingState
|
2015-07-20 03:51:52 -04:00
|
|
|
jr c, .ok
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
2015-11-12 11:10:19 -05:00
|
|
|
|
2015-07-20 03:51:52 -04:00
|
|
|
.ok
|
2020-06-16 19:38:00 -04:00
|
|
|
call UpdatePlayerSprite
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2024-01-04 22:30:40 +01:00
|
|
|
.CheckForcedBiking:
|
2015-02-11 14:01:04 -08:00
|
|
|
and a
|
2017-12-28 13:15:46 +01:00
|
|
|
ld hl, wBikeFlags
|
2018-01-22 13:57:44 -05:00
|
|
|
bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
|
2015-02-11 14:01:04 -08:00
|
|
|
ret z
|
2015-07-20 03:51:52 -04:00
|
|
|
ld a, PLAYER_BIKE
|
2018-01-23 17:39:09 -05:00
|
|
|
ld [wPlayerState], a
|
2015-02-11 14:01:04 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2024-01-04 22:30:40 +01:00
|
|
|
.ResetSurfingOrBikingState:
|
2018-01-23 17:39:09 -05:00
|
|
|
ld a, [wPlayerState]
|
2015-07-20 03:51:52 -04:00
|
|
|
cp PLAYER_NORMAL
|
|
|
|
jr z, .nope
|
2017-12-15 23:29:42 -05:00
|
|
|
cp PLAYER_SKATE
|
2015-07-20 03:51:52 -04:00
|
|
|
jr z, .nope
|
|
|
|
cp PLAYER_SURF
|
|
|
|
jr z, .surfing
|
|
|
|
cp PLAYER_SURF_PIKA
|
|
|
|
jr z, .surfing
|
2017-12-24 13:08:38 -05:00
|
|
|
call GetMapEnvironment
|
2023-08-04 18:45:50 +02:00
|
|
|
cp INDOOR_BUILDING
|
2019-12-03 09:17:21 -05:00
|
|
|
jr z, .no_biking
|
2015-07-20 03:51:52 -04:00
|
|
|
jr .nope
|
2019-12-03 09:17:21 -05:00
|
|
|
.no_biking
|
2018-01-23 17:39:09 -05:00
|
|
|
ld a, [wPlayerState]
|
2015-07-20 03:51:52 -04:00
|
|
|
cp PLAYER_BIKE
|
|
|
|
jr nz, .nope
|
|
|
|
.surfing
|
|
|
|
ld a, PLAYER_NORMAL
|
2018-01-23 17:39:09 -05:00
|
|
|
ld [wPlayerState], a
|
2015-02-11 14:01:04 -08:00
|
|
|
scf
|
|
|
|
ret
|
2015-11-12 11:10:19 -05:00
|
|
|
|
2015-07-20 03:51:52 -04:00
|
|
|
.nope
|
2015-02-11 14:01:04 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 16:09:41 +02:00
|
|
|
.CheckSurfing:
|
2015-07-23 03:41:52 -04:00
|
|
|
call CheckOnWater
|
2019-12-03 09:17:21 -05:00
|
|
|
jr nz, .nope2
|
2018-01-23 17:39:09 -05:00
|
|
|
ld a, [wPlayerState]
|
2015-07-20 03:51:52 -04:00
|
|
|
cp PLAYER_SURF
|
2019-12-03 09:17:21 -05:00
|
|
|
jr z, .is_surfing
|
2015-07-20 03:51:52 -04:00
|
|
|
cp PLAYER_SURF_PIKA
|
2019-12-03 09:17:21 -05:00
|
|
|
jr z, .is_surfing
|
2015-07-20 03:51:52 -04:00
|
|
|
ld a, PLAYER_SURF
|
2018-01-23 17:39:09 -05:00
|
|
|
ld [wPlayerState], a
|
2019-12-03 09:17:21 -05:00
|
|
|
.is_surfing
|
2015-02-11 14:01:04 -08:00
|
|
|
scf
|
|
|
|
ret
|
2019-12-03 09:17:21 -05:00
|
|
|
|
|
|
|
.nope2
|
2015-02-11 14:01:04 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2019-11-18 18:16:50 +01:00
|
|
|
FadeOutMapMusic:
|
2015-02-11 14:01:04 -08:00
|
|
|
ld a, 6
|
|
|
|
call SkipMusic
|
|
|
|
ret
|
|
|
|
|
2019-11-18 18:16:50 +01:00
|
|
|
ApplyMapPalettes:
|
2018-01-02 18:49:25 +01:00
|
|
|
farcall _UpdateTimePals
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2019-11-18 18:16:50 +01:00
|
|
|
FadeMapMusicAndPalettes:
|
2020-04-17 10:52:59 -04:00
|
|
|
ld e, LOW(MUSIC_NONE)
|
2018-01-23 17:39:09 -05:00
|
|
|
ld a, [wMusicFadeID]
|
2020-04-17 10:52:59 -04:00
|
|
|
ld d, HIGH(MUSIC_NONE)
|
2018-01-23 17:39:09 -05:00
|
|
|
ld a, [wMusicFadeID + 1]
|
2015-02-11 14:01:04 -08:00
|
|
|
ld a, $4
|
2018-01-23 17:39:09 -05:00
|
|
|
ld [wMusicFade], a
|
2015-11-20 11:47:52 -05:00
|
|
|
call RotateThreePalettesRight
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 16:09:41 +02:00
|
|
|
ForceMapMusic:
|
2018-01-23 17:39:09 -05:00
|
|
|
ld a, [wPlayerState]
|
2015-07-20 03:51:52 -04:00
|
|
|
cp PLAYER_BIKE
|
|
|
|
jr nz, .notbiking
|
2019-09-02 03:40:58 -05:00
|
|
|
call MinVolume
|
2015-02-11 14:01:04 -08:00
|
|
|
ld a, $88
|
2018-01-23 17:39:09 -05:00
|
|
|
ld [wMusicFade], a
|
2015-07-20 03:51:52 -04:00
|
|
|
.notbiking
|
2015-07-21 01:52:46 -04:00
|
|
|
call TryRestartMapMusic
|
2015-02-11 14:01:04 -08:00
|
|
|
ret
|
2023-11-28 09:44:10 +01:00
|
|
|
|
|
|
|
ResetLevelScopedEventFlags:
|
|
|
|
ld hl, wEventFlags + EVENT_LEVEL_SCOPED_FLAGS_START / 8
|
|
|
|
ld c, (EVENT_LEVEL_SCOPED_FLAGS_END / 8) - (EVENT_LEVEL_SCOPED_FLAGS_START / 8)
|
|
|
|
xor a
|
|
|
|
.loop
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
2023-12-31 15:05:07 +01:00
|
|
|
MapCallbackAtEndMapSetup:
|
|
|
|
ld a, MAPCALLBACK_ENDMAPSETUP
|
|
|
|
jp RunMapCallback
|