pokecrystal/engine/overworld/map_setup.asm

247 lines
3.8 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
RunMapSetupScript::
ld a, [hMapEntryMethod]
2015-02-11 22:01:04 +00:00
and $f
dec a
ld c, a
ld b, 0
ld hl, MapSetupScripts
add hl, bc
2015-12-27 02:59:03 +00:00
add hl, bc
2015-02-11 22:01:04 +00:00
ld a, [hli]
ld h, [hl]
ld l, a
call ReadMapSetupScript
ret
INCLUDE "data/maps/setup_scripts.asm"
2015-02-11 22:01:04 +00:00
2018-06-24 14:09:41 +00:00
ReadMapSetupScript:
2015-02-11 22:01:04 +00:00
.loop
ld a, [hli]
cp -1
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 22:01:04 +00: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 14:09:41 +00:00
MapSetupCommands:
; entries correspond to command indexes in constants/map_setup_constants.asm
2015-11-04 00:43:47 +00:00
dba EnableLCD ; 00
dba DisableLCD ; 01
2015-11-12 04:38:57 +00:00
dba MapSetup_Sound_Off ; 02
2015-11-04 00:43:47 +00:00
dba PlayMapMusic ; 03
dba RestartMapMusic ; 04
dba FadeToMapMusic ; 05
2015-11-20 16:47:52 +00:00
dba RotatePalettesRightMapAndMusic ; 06
2015-11-04 00:43:47 +00:00
dba EnterMapMusic ; 07
dba ForceMapMusic ; 08
dba FadeInMusic ; 09
dba LoadBlockData ; 0a (callback 1)
2015-11-04 00:43:47 +00:00
dba LoadNeighboringBlockData ; 0b
dba SaveScreen ; 0c
dba BufferScreen ; 0d
dba LoadGraphics ; 0e
dba LoadTileset ; 0f
2015-11-04 00:43:47 +00:00
dba LoadMapTimeOfDay ; 10
dba LoadMapPalettes ; 11
2015-11-04 00:43:47 +00:00
dba LoadWildMonData ; 12
dba RefreshMapSprites ; 13
dba HandleNewMap ; 14
dba InitCommandQueue ; 15
2015-11-04 00:43:47 +00:00
dba LoadObjectsRunCallback_02 ; 16
dba LoadSpawnPoint ; 17
dba EnterMapConnection ; 18
dba LoadWarpData ; 19
dba LoadMapAttributes ; 1a
2015-11-12 16:10:19 +00:00
dba LoadMapAttributes_SkipPeople ; 1b
2015-11-12 04:38:57 +00:00
dba ClearBGPalettes ; 1c
dba FadeOutPalettes ; 1d
dba FadeInPalettes ; 1e
2015-11-04 00:43:47 +00:00
dba GetCoordOfUpperLeftCorner ; 1f
dba RestoreFacingAfterWarp ; 20
dba SpawnInFacingDown ; 21
2016-01-11 07:36:39 +00:00
dba SpawnPlayer ; 22
2015-11-04 00:43:47 +00:00
dba RefreshPlayerCoords ; 23
dba DelayClearingOldSprites ; 24
dba DelayLoadingNewSprites ; 25
dba UpdateRoamMons ; 26
dba JumpRoamMons ; 27
dba FadeOldMapMusic ; 28
dba ActivateMapAnims ; 29
dba SuspendMapAnims ; 2a
dba RetainOldPalettes ; 2b
dba DontScrollText ; 2c
dba ReturnFromMapSetupScript ; 2d
2015-02-11 22:01:04 +00:00
2018-06-24 14:09:41 +00:00
DontScrollText:
2015-02-11 22:01:04 +00:00
xor a
2016-05-05 19:07:37 +00:00
ld [wDisableTextAcceleration], a
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
ActivateMapAnims:
2015-02-11 22:01:04 +00:00
ld a, $1
2015-11-05 19:06:03 +00:00
ld [hMapAnims], a
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
SuspendMapAnims:
2015-02-11 22:01:04 +00:00
xor a
2015-11-05 19:06:03 +00:00
ld [hMapAnims], a
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
LoadObjectsRunCallback_02:
2016-01-06 12:44:50 +00:00
ld a, MAPCALLBACK_OBJECTS
call RunMapCallback
2017-12-24 17:47:30 +00:00
farcall LoadObjectMasks
farcall InitializeVisibleSprites
2015-02-11 22:01:04 +00:00
ret
2018-01-02 15:04:21 +00:00
; unused
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
DelayClearingOldSprites:
2015-10-24 14:34:19 +00:00
ld hl, wPlayerSpriteSetupFlags
2018-01-22 19:34:55 +00:00
set PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
DelayLoadingNewSprites:
2015-10-24 14:34:19 +00:00
ld hl, wPlayerSpriteSetupFlags
2018-01-22 19:34:55 +00:00
set PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
CheckReplaceKrisSprite:
2015-02-11 22:01:04 +00:00
nop
2015-11-12 16:10:19 +00:00
call .CheckBiking
jr c, .ok
2015-11-12 16:10:19 +00:00
call .CheckSurfing
jr c, .ok
2015-11-12 16:10:19 +00:00
call .CheckSurfing2
jr c, .ok
2015-02-11 22:01:04 +00:00
ret
2015-11-12 16:10:19 +00:00
.ok
2015-11-04 21:14:27 +00:00
call ReplaceKrisSprite
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
.CheckBiking:
2015-02-11 22:01:04 +00:00
and a
ld hl, wBikeFlags
2018-01-22 18:57:44 +00:00
bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
2015-02-11 22:01:04 +00:00
ret z
ld a, PLAYER_BIKE
2018-01-23 22:39:09 +00:00
ld [wPlayerState], a
2015-02-11 22:01:04 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
.CheckSurfing2:
2018-01-23 22:39:09 +00: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 16:10:19 +00:00
cp INDOOR
jr z, .checkbiking
cp ENVIRONMENT_5
jr z, .checkbiking
2015-11-12 16:10:19 +00:00
cp DUNGEON
jr z, .checkbiking
jr .nope
.checkbiking
2018-01-23 22:39:09 +00:00
ld a, [wPlayerState]
cp PLAYER_BIKE
jr nz, .nope
.surfing
ld a, PLAYER_NORMAL
2018-01-23 22:39:09 +00:00
ld [wPlayerState], a
2015-02-11 22:01:04 +00:00
scf
ret
2015-11-12 16:10:19 +00:00
.nope
2015-02-11 22:01:04 +00:00
and a
ret
2018-06-24 14:09:41 +00:00
.CheckSurfing:
call CheckOnWater
jr nz, .ret_nc
2018-01-23 22:39:09 +00:00
ld a, [wPlayerState]
cp PLAYER_SURF
2015-11-12 16:10:19 +00:00
jr z, ._surfing
cp PLAYER_SURF_PIKA
2015-11-12 16:10:19 +00:00
jr z, ._surfing
ld a, PLAYER_SURF
2018-01-23 22:39:09 +00:00
ld [wPlayerState], a
2015-11-12 16:10:19 +00:00
._surfing
2015-02-11 22:01:04 +00:00
scf
ret
.ret_nc
2015-02-11 22:01:04 +00:00
and a
ret
2018-06-24 14:09:41 +00:00
FadeOldMapMusic:
2015-02-11 22:01:04 +00:00
ld a, 6
call SkipMusic
ret
2018-06-24 14:09:41 +00:00
RetainOldPalettes:
2018-01-02 17:49:25 +00:00
farcall _UpdateTimePals
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
RotatePalettesRightMapAndMusic:
2015-02-11 22:01:04 +00:00
ld e, 0
2018-01-23 22:39:09 +00:00
ld a, [wMusicFadeID]
2015-02-11 22:01:04 +00:00
ld d, 0
2018-01-23 22:39:09 +00:00
ld a, [wMusicFadeID + 1]
2015-02-11 22:01:04 +00:00
ld a, $4
2018-01-23 22:39:09 +00:00
ld [wMusicFade], a
2015-11-20 16:47:52 +00:00
call RotateThreePalettesRight
2015-02-11 22:01:04 +00:00
ret
2018-06-24 14:09:41 +00:00
ForceMapMusic:
2018-01-23 22:39:09 +00:00
ld a, [wPlayerState]
cp PLAYER_BIKE
jr nz, .notbiking
2015-02-11 22:01:04 +00:00
call VolumeOff
ld a, $88
2018-01-23 22:39:09 +00:00
ld [wMusicFade], a
.notbiking
2015-07-21 05:52:46 +00:00
call TryRestartMapMusic
2015-02-11 22:01:04 +00:00
ret