pokecrystal-board/engine/map_setup.asm
Rangi 32ed487a47 Merge branch 'master' of https://github.com/pret/pokecrystal
# Conflicts:
#	audio/engine.asm
#	constants/gfx_constants.asm
#	constants/map_data_constants.asm
#	constants/pokemon_data_constants.asm
#	constants/sprite_constants.asm
#	constants/wram_constants.asm
#	data/maps/data.asm
#	engine/battle/ai/scoring.asm
#	engine/battle/core.asm
#	engine/battle/effect_commands.asm
#	engine/battle/misc.asm
#	engine/battle_anims/getpokeballwobble.asm
#	engine/breeding.asm
#	engine/buy_sell_toss.asm
#	engine/decorations.asm
#	engine/events/battle_tower/battle_tower.asm
#	engine/events/battle_tower/rules.asm
#	engine/events/buena.asm
#	engine/events/bug_contest/contest_2.asm
#	engine/events/daycare.asm
#	engine/events/dratini.asm
#	engine/events/halloffame.asm
#	engine/events/happiness_egg.asm
#	engine/events/kurt.asm
#	engine/events/lucky_number.asm
#	engine/events/magnet_train.asm
#	engine/events/overworld.asm
#	engine/events/pokerus/pokerus.asm
#	engine/events/print_unown.asm
#	engine/events/print_unown_2.asm
#	engine/events/unown_walls.asm
#	engine/item_effects.asm
#	engine/link.asm
#	engine/mon_menu.asm
#	engine/player_object.asm
#	engine/routines/playslowcry.asm
#	engine/scripting.asm
#	engine/search.asm
#	engine/search2.asm
#	engine/specials.asm
#	engine/start_menu.asm
#	engine/timeset.asm
#	home/battle_vars.asm
#	home/map.asm
#	maps/GoldenrodUndergroundSwitchRoomEntrances.asm
#	maps/IlexForest.asm
#	maps/KrissHouse2F.asm
#	maps/Route39Barn.asm
#	mobile/mobile_12_2.asm
#	mobile/mobile_40.asm
#	mobile/mobile_5f.asm
#	wram.asm
2018-02-03 19:42:56 -05:00

261 lines
4.1 KiB
NASM

RunMapSetupScript:: ; 15363
ld a, [hMapEntryMethod]
and $f
dec a
ld c, a
ld b, 0
ld hl, MapSetupScripts
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
call ReadMapSetupScript
ret
; 15377
INCLUDE "data/maps/setup_scripts.asm"
ReadMapSetupScript: ; 1541d
.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
; 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
; 15440
MapSetupCommands: ; 15440
; entries correspond to command indexes in constants/map_setup_constants.asm
dba EnableLCD ; 00
dba DisableLCD ; 01
dba MapSetup_Sound_Off ; 02
dba PlayMapMusic ; 03
dba RestartMapMusic ; 04
dba FadeToMapMusic ; 05
dba RotatePalettesRightMapAndMusic ; 06
dba EnterMapMusic ; 07
dba ForceMapMusic ; 08
dba FadeInMusic ; 09
dba LoadBlockData ; 0a (callback 1)
dba LoadNeighboringBlockData ; 0b
dba SaveScreen ; 0c
dba BufferScreen ; 0d
dba LoadGraphics ; 0e
dba LoadTileset ; 0f
dba LoadMapTimeOfDay ; 10
dba LoadMapPalettes ; 11
dba LoadWildMonData ; 12
dba RefreshMapSprites ; 13
dba HandleNewMap ; 14
dba InitCommandQueue ; 15
dba LoadObjectsRunCallback_02 ; 16
dba LoadSpawnPoint ; 17
dba EnterMapConnection ; 18
dba LoadWarpData ; 19
dba LoadMapAttributes ; 1a
dba LoadMapAttributes_SkipPeople ; 1b
dba ClearBGPalettes ; 1c
dba FadeOutPalettes ; 1d
dba FadeInPalettes ; 1e
dba GetCoordOfUpperLeftCorner ; 1f
dba RestoreFacingAfterWarp ; 20
dba SpawnInFacingDown ; 21
dba SpawnPlayer ; 22
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
; 154ca
DontScrollText: ; 154ca
xor a
ld [wDisableTextAcceleration], a
ret
; 154cf
ActivateMapAnims: ; 154cf
ld a, $1
ld [hMapAnims], a
ret
; 154d3
SuspendMapAnims: ; 154d3
xor a
ld [hMapAnims], a
ret
; 154d7
LoadObjectsRunCallback_02: ; 154d7
ld a, MAPCALLBACK_OBJECTS
call RunMapCallback
farcall LoadObjectMasks
farcall InitializeVisibleSprites
ret
; 154ea (5:54ea)
; unused
ret
; 154eb
DelayClearingOldSprites: ; 154eb
ld hl, wPlayerSpriteSetupFlags
set PLAYERSPRITESETUP_RESET_ACTION_F, [hl]
ret
; 154f1
DelayLoadingNewSprites: ; 154f1
ld hl, wPlayerSpriteSetupFlags
set PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F, [hl]
ret
CheckReplaceKrisSprite: ; 154f7
nop
call .CheckBiking
jr c, .ok
call .CheckSurfing
jr c, .ok
call .CheckSurfing2
jr c, .ok
ret
.ok
call ReplaceKrisSprite
ret
.CheckBiking: ; 1550c (5:550c)
and a
ld hl, wBikeFlags
bit BIKEFLAGS_ALWAYS_ON_BIKE_F, [hl]
ret z
ld a, PLAYER_BIKE
ld [wPlayerState], a
scf
ret
.CheckSurfing2: ; 1551a (5:551a)
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
cp INDOOR
jr z, .checkbiking
cp ENVIRONMENT_5
jr z, .checkbiking
cp DUNGEON
jr z, .checkbiking
jr .nope
.checkbiking
ld a, [wPlayerState]
cp PLAYER_BIKE
jr nz, .nope
.surfing
ld a, PLAYER_NORMAL
ld [wPlayerState], a
scf
ret
.nope
and a
ret
.CheckSurfing: ; 1554e (5:554e)
call CheckOnWater
jr nz, .ret_nc
ld a, [wPlayerState]
cp PLAYER_SURF
jr z, ._surfing
cp PLAYER_SURF_PIKA
jr z, ._surfing
ld a, PLAYER_SURF
ld [wPlayerState], a
._surfing
scf
ret
.ret_nc
and a
ret
; 15567
FadeOldMapMusic: ; 15567
ld a, 6
call SkipMusic
ret
; 1556d
RetainOldPalettes: ; 1556d
farcall _UpdateTimePals
ret
RotatePalettesRightMapAndMusic: ; 15574
ld e, 0
ld a, [wMusicFadeID]
ld d, 0
ld a, [wMusicFadeID + 1]
ld a, $4
ld [wMusicFade], a
call RotateThreePalettesRight
ret
; 15587
ForceMapMusic: ; 15587
ld a, [wPlayerState]
cp PLAYER_BIKE
jr nz, .notbiking
call VolumeOff
ld a, $88
ld [wMusicFade], a
.notbiking
call TryRestartMapMusic
ret
; 1559a