pokecrystal-board/engine/overworld/map_setup.asm

248 lines
3.8 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
RunMapSetupScript::
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 18:59:03 -08:00
add hl, bc
2015-02-11 14:01:04 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
call ReadMapSetupScript
ret
INCLUDE "data/maps/setup_scripts.asm"
2015-02-11 14:01:04 -08:00
2018-06-24 07:09:41 -07:00
ReadMapSetupScript:
2015-02-11 14:01:04 -08:00
.loop
ld a, [hli]
cp map_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
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
2018-06-24 07:09:41 -07:00
MapSetupCommands:
; entries correspond to command indexes in constants/map_setup_constants.asm
2015-11-03 16:43:47 -08:00
dba EnableLCD ; 00
dba DisableLCD ; 01
dba InitSound ; 02
2015-11-03 16:43:47 -08:00
dba PlayMapMusic ; 03
dba RestartMapMusic ; 04
dba FadeToMapMusic ; 05
dba FadeMapMusicAndPalettes ; 06
dba PlayMapMusicBike ; 07
2015-11-03 16:43:47 -08:00
dba ForceMapMusic ; 08
dba FadeInToMusic ; 09
dba LoadBlockData ; 0a (callback 1)
dba LoadConnectionBlockData ; 0b
2015-11-03 16:43:47 -08:00
dba SaveScreen ; 0c
dba BufferScreen ; 0d
dba LoadMapGraphics ; 0e
dba LoadMapTileset ; 0f
2015-11-03 16:43:47 -08:00
dba LoadMapTimeOfDay ; 10
dba LoadMapPalettes ; 11
2015-11-03 16:43:47 -08:00
dba LoadWildMonData ; 12
dba RefreshMapSprites ; 13
dba HandleNewMap ; 14
dba HandleContinueMap ; 15
dba LoadMapObjects ; 16
dba EnterMapSpawnPoint ; 17
2015-11-03 16:43:47 -08:00
dba EnterMapConnection ; 18
dba EnterMapWarp ; 19
2015-11-03 16:43:47 -08:00
dba LoadMapAttributes ; 1a
dba LoadMapAttributes_SkipObjects ; 1b
2015-11-11 20:38:57 -08:00
dba ClearBGPalettes ; 1c
dba FadeOutPalettes ; 1d
dba FadeInPalettes ; 1e
dba GetMapScreenCoords ; 1f
dba GetWarpDestCoords ; 20
2015-11-03 16:43:47 -08:00
dba SpawnInFacingDown ; 21
2016-01-10 23:36:39 -08:00
dba SpawnPlayer ; 22
2015-11-03 16:43:47 -08:00
dba RefreshPlayerCoords ; 23
dba ResetPlayerObjectAction ; 24
dba SkipUpdateMapSprites ; 25
2015-11-03 16:43:47 -08:00
dba UpdateRoamMons ; 26
dba JumpRoamMons ; 27
dba FadeOutMapMusic ; 28
2015-11-03 16:43:47 -08:00
dba ActivateMapAnims ; 29
dba SuspendMapAnims ; 2a
dba ApplyMapPalettes ; 2b
dba EnableTextAcceleration ; 2c
dba InitMapNameSign ; 2d
2015-02-11 14:01:04 -08:00
EnableTextAcceleration:
2015-02-11 14:01:04 -08:00
xor a
2016-05-05 12:07:37 -07:00
ld [wDisableTextAcceleration], a
2015-02-11 14:01:04 -08:00
ret
2018-06-24 07:09:41 -07:00
ActivateMapAnims:
ld a, TRUE
ldh [hMapAnims], a
2015-02-11 14:01:04 -08:00
ret
2018-06-24 07:09:41 -07:00
SuspendMapAnims:
xor a ; FALSE
ldh [hMapAnims], a
2015-02-11 14:01:04 -08:00
ret
LoadMapObjects:
2016-01-06 04:44:50 -08:00
ld a, MAPCALLBACK_OBJECTS
call RunMapCallback
2017-12-24 09:47:30 -08:00
farcall LoadObjectMasks
farcall InitializeVisibleSprites
2015-02-11 14:01:04 -08:00
ret
2018-01-02 07:04:21 -08:00
; unused
2015-02-11 14:01:04 -08:00
ret
ResetPlayerObjectAction:
2015-10-24 07:34:19 -07:00
ld hl, wPlayerSpriteSetupFlags
2018-01-22 11:34:55 -08:00
set PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
2015-02-11 14:01:04 -08:00
ret
SkipUpdateMapSprites:
2015-10-24 07:34:19 -07:00
ld hl, wPlayerSpriteSetupFlags
2018-01-22 11:34:55 -08:00
set PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
2015-02-11 14:01:04 -08:00
ret
CheckUpdatePlayerSprite:
2015-02-11 14:01:04 -08:00
nop
2015-11-12 08:10:19 -08:00
call .CheckBiking
jr c, .ok
2015-11-12 08:10:19 -08:00
call .CheckSurfing
jr c, .ok
2015-11-12 08:10:19 -08:00
call .CheckSurfing2
jr c, .ok
2015-02-11 14:01:04 -08:00
ret
2015-11-12 08:10:19 -08:00
.ok
call UpdatePlayerSprite
2015-02-11 14:01:04 -08:00
ret
2018-06-24 07:09:41 -07:00
.CheckBiking:
2015-02-11 14:01:04 -08:00
and a
ld hl, wBikeFlags
2018-01-22 10:57:44 -08:00
bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
2015-02-11 14:01:04 -08:00
ret z
ld a, PLAYER_BIKE
2018-01-23 14:39:09 -08:00
ld [wPlayerState], a
2015-02-11 14:01:04 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
.CheckSurfing2:
2018-01-23 14:39:09 -08:00
ld a, [wPlayerState]
cp PLAYER_NORMAL
jr z, .nope
cp PLAYER_SKATE
jr z, .nope
cp PLAYER_SURF
jr z, .surfing
cp PLAYER_SURF_PIKA
jr z, .surfing
call GetMapEnvironment
2015-11-12 08:10:19 -08:00
cp INDOOR
2019-12-03 06:17:21 -08:00
jr z, .no_biking
cp ENVIRONMENT_5
2019-12-03 06:17:21 -08:00
jr z, .no_biking
2015-11-12 08:10:19 -08:00
cp DUNGEON
2019-12-03 06:17:21 -08:00
jr z, .no_biking
jr .nope
2019-12-03 06:17:21 -08:00
.no_biking
2018-01-23 14:39:09 -08:00
ld a, [wPlayerState]
cp PLAYER_BIKE
jr nz, .nope
.surfing
ld a, PLAYER_NORMAL
2018-01-23 14:39:09 -08:00
ld [wPlayerState], a
2015-02-11 14:01:04 -08:00
scf
ret
2015-11-12 08:10:19 -08:00
.nope
2015-02-11 14:01:04 -08:00
and a
ret
2018-06-24 07:09:41 -07:00
.CheckSurfing:
call CheckOnWater
2019-12-03 06:17:21 -08:00
jr nz, .nope2
2018-01-23 14:39:09 -08:00
ld a, [wPlayerState]
cp PLAYER_SURF
2019-12-03 06:17:21 -08:00
jr z, .is_surfing
cp PLAYER_SURF_PIKA
2019-12-03 06:17:21 -08:00
jr z, .is_surfing
ld a, PLAYER_SURF
2018-01-23 14:39:09 -08:00
ld [wPlayerState], a
2019-12-03 06:17:21 -08:00
.is_surfing
2015-02-11 14:01:04 -08:00
scf
ret
2019-12-03 06:17:21 -08:00
.nope2
2015-02-11 14:01:04 -08:00
and a
ret
FadeOutMapMusic:
2015-02-11 14:01:04 -08:00
ld a, 6
call SkipMusic
ret
ApplyMapPalettes:
2018-01-02 09:49:25 -08:00
farcall _UpdateTimePals
2015-02-11 14:01:04 -08:00
ret
FadeMapMusicAndPalettes:
2020-04-17 07:52:59 -07:00
ld e, LOW(MUSIC_NONE)
2018-01-23 14:39:09 -08:00
ld a, [wMusicFadeID]
2020-04-17 07:52:59 -07:00
ld d, HIGH(MUSIC_NONE)
2018-01-23 14:39:09 -08:00
ld a, [wMusicFadeID + 1]
2015-02-11 14:01:04 -08:00
ld a, $4
2018-01-23 14:39:09 -08:00
ld [wMusicFade], a
2015-11-20 08:47:52 -08:00
call RotateThreePalettesRight
2015-02-11 14:01:04 -08:00
ret
2018-06-24 07:09:41 -07:00
ForceMapMusic:
2018-01-23 14:39:09 -08:00
ld a, [wPlayerState]
cp PLAYER_BIKE
jr nz, .notbiking
call MinVolume
2015-02-11 14:01:04 -08:00
ld a, $88
2018-01-23 14:39:09 -08:00
ld [wMusicFade], a
.notbiking
2015-07-20 22:52:46 -07:00
call TryRestartMapMusic
2015-02-11 14:01:04 -08:00
ret