pokered/scripts/VermilionDock.asm

218 lines
4.4 KiB
NASM
Raw Normal View History

VermilionDock_Script:
2014-05-18 18:19:10 +00:00
call EnableAutoTextBoxDrawing
2015-07-21 17:36:03 +00:00
CheckEventHL EVENT_STARTED_WALKING_OUT_OF_DOCK
jr nz, .walking_out_of_dock
2015-07-21 17:36:03 +00:00
CheckEventReuseHL EVENT_GOT_HM01
2014-05-18 18:19:10 +00:00
ret z
2014-09-13 07:50:56 +00:00
ld a, [wDestinationWarpID]
2014-05-18 18:19:10 +00:00
cp $1
ret nz
2015-07-21 01:32:02 +00:00
CheckEventReuseHL EVENT_SS_ANNE_LEFT
jp z, VermilionDockSSAnneLeavesScript
2015-07-21 17:36:03 +00:00
SetEventReuseHL EVENT_STARTED_WALKING_OUT_OF_DOCK
2014-05-18 18:19:10 +00:00
call Delay3
ld hl, wStatusFlags5
set BIT_SCRIPTED_MOVEMENT_STATE, [hl]
ld hl, wSimulatedJoypadStatesEnd
2015-07-21 17:36:03 +00:00
ld a, D_UP
2014-05-18 18:19:10 +00:00
ld [hli], a
ld [hli], a
ld [hl], a
ld a, $3
ld [wSimulatedJoypadStatesIndex], a
2014-05-18 18:19:10 +00:00
xor a
ld [wSpritePlayerStateData2MovementByte1], a
ld [wOverrideSimulatedJoypadStatesMask], a
2014-05-18 18:19:10 +00:00
dec a
2014-05-25 17:51:53 +00:00
ld [wJoyIgnore], a
2014-05-18 18:19:10 +00:00
ret
.walking_out_of_dock
2015-07-21 17:36:03 +00:00
CheckEventAfterBranchReuseHL EVENT_WALKED_OUT_OF_DOCK, EVENT_STARTED_WALKING_OUT_OF_DOCK
2014-05-18 18:19:10 +00:00
ret nz
ld a, [wSimulatedJoypadStatesIndex]
2014-05-18 18:19:10 +00:00
and a
ret nz
2014-05-25 17:51:53 +00:00
ld [wJoyIgnore], a
2015-07-21 17:36:03 +00:00
SetEventReuseHL EVENT_WALKED_OUT_OF_DOCK
2014-05-18 18:19:10 +00:00
ret
VermilionDockSSAnneLeavesScript:
2015-07-21 01:32:02 +00:00
SetEventForceReuseHL EVENT_SS_ANNE_LEFT
ld a, SFX_STOP_ALL_MUSIC
2014-05-25 17:51:53 +00:00
ld [wJoyIgnore], a
2015-08-09 05:32:44 +00:00
ld [wNewSoundID], a
2014-05-18 18:19:10 +00:00
call PlaySound
ld c, BANK(Music_Surfing)
ld a, MUSIC_SURFING
call PlayMusic
farcall LoadSmokeTileFourTimes
2014-05-18 18:19:10 +00:00
xor a
ld [wSpritePlayerStateData1ImageIndex], a
ld c, 120
2014-05-18 18:19:10 +00:00
call DelayFrames
ld b, $9c
call CopyScreenTileBufferToVRAM
hlcoord 0, 10
2015-08-10 04:56:20 +00:00
ld bc, SCREEN_WIDTH * 6
ld a, $14 ; water tile
2014-05-18 18:19:10 +00:00
call FillMemory
2015-07-19 03:49:52 +00:00
ld a, 1
ldh [hAutoBGTransferEnabled], a
2014-05-18 18:19:10 +00:00
call Delay3
xor a
ldh [hAutoBGTransferEnabled], a
2015-07-19 03:49:52 +00:00
ld [wSSAnneSmokeDriftAmount], a
ldh [rOBP1], a
2015-07-19 03:49:52 +00:00
ld a, 88
ld [wSSAnneSmokeX], a
2014-09-14 18:29:18 +00:00
ld hl, wMapViewVRAMPointer
2014-05-18 18:19:10 +00:00
ld c, [hl]
inc hl
ld b, [hl]
push bc
push hl
2015-07-19 08:46:12 +00:00
ld a, SFX_SS_ANNE_HORN
2014-05-18 18:19:10 +00:00
call PlaySoundWaitForCurrent
ld a, $ff
2014-09-13 07:50:56 +00:00
ld [wUpdateSpritesEnabled], a
2014-05-18 18:19:10 +00:00
ld d, $0
ld e, $8
.shift_columns_up
ld hl, $2
2014-05-18 18:19:10 +00:00
add hl, bc
ld a, l
2014-09-14 18:29:18 +00:00
ld [wMapViewVRAMPointer], a
2014-05-18 18:19:10 +00:00
ld a, h
2014-09-14 18:29:18 +00:00
ld [wMapViewVRAMPointer + 1], a
2014-05-18 18:19:10 +00:00
push hl
push de
call ScheduleEastColumnRedraw
2015-07-19 03:49:52 +00:00
call VermilionDock_EmitSmokePuff
2014-05-18 18:19:10 +00:00
pop de
ld b, $10
.smoke_puff_drift_loop
2015-07-19 03:49:52 +00:00
call VermilionDock_AnimSmokePuffDriftRight
2014-05-18 18:19:10 +00:00
ld c, $8
.delay_between_drifts
call VermilionDock_SyncScrollWithLY
2014-05-18 18:19:10 +00:00
dec c
jr nz, .delay_between_drifts
2014-05-18 18:19:10 +00:00
inc d
dec b
jr nz, .smoke_puff_drift_loop
2014-05-18 18:19:10 +00:00
pop bc
dec e
jr nz, .shift_columns_up
2014-05-18 18:19:10 +00:00
xor a
ldh [rWY], a
ldh [hWY], a
2015-08-13 05:14:31 +00:00
call VermilionDock_EraseSSAnne
2014-05-18 18:19:10 +00:00
ld a, $90
ldh [hWY], a
2014-05-18 18:19:10 +00:00
ld a, $1
2014-09-13 07:50:56 +00:00
ld [wUpdateSpritesEnabled], a
2014-05-18 18:19:10 +00:00
pop hl
pop bc
ld [hl], b
dec hl
ld [hl], c
call LoadPlayerSpriteGraphics
2014-09-13 07:50:56 +00:00
ld hl, wNumberOfWarps
2014-05-18 18:19:10 +00:00
dec [hl]
ret
2016-06-12 00:24:04 +00:00
VermilionDock_AnimSmokePuffDriftRight:
2014-05-18 18:19:10 +00:00
push bc
push de
2022-07-09 21:18:18 +00:00
ld hl, wShadowOAMSprite04XCoord
2015-07-19 03:49:52 +00:00
ld a, [wSSAnneSmokeDriftAmount]
2014-05-18 18:19:10 +00:00
swap a
ld c, a
2015-07-19 03:49:52 +00:00
ld de, 4
.drift_loop
2014-05-18 18:19:10 +00:00
inc [hl]
inc [hl]
add hl, de
dec c
jr nz, .drift_loop
2014-05-18 18:19:10 +00:00
pop de
pop bc
ret
2016-06-12 00:24:04 +00:00
VermilionDock_EmitSmokePuff:
2015-07-19 03:49:52 +00:00
; new smoke puff above the S.S. Anne's front smokestack
ld a, [wSSAnneSmokeX]
sub 16
ld [wSSAnneSmokeX], a
2014-05-18 18:19:10 +00:00
ld c, a
2015-07-19 03:49:52 +00:00
ld b, 100 ; Y
ld a, [wSSAnneSmokeDriftAmount]
2014-05-18 18:19:10 +00:00
inc a
2015-07-19 03:49:52 +00:00
ld [wSSAnneSmokeDriftAmount], a
2014-05-18 18:19:10 +00:00
ld a, $1
ld de, VermilionDockOAMBlock
call WriteOAMBlock
ret
2016-06-12 00:24:04 +00:00
VermilionDockOAMBlock:
; tile ID, attributes
2014-05-18 18:19:10 +00:00
db $fc, $10
db $fd, $10
db $fe, $10
db $ff, $10
VermilionDock_SyncScrollWithLY:
2014-05-18 18:19:10 +00:00
ld h, d
ld l, $50
call .sync_scroll_ly
2014-05-18 18:19:10 +00:00
ld h, $0
ld l, $80
.sync_scroll_ly
ldh a, [rLY]
2014-05-18 18:19:10 +00:00
cp l
jr nz, .sync_scroll_ly
2014-05-18 18:19:10 +00:00
ld a, h
ldh [rSCX], a
.wait_for_ly_match
ldh a, [rLY]
2014-05-18 18:19:10 +00:00
cp h
jr z, .wait_for_ly_match
2014-05-18 18:19:10 +00:00
ret
2016-06-12 00:24:04 +00:00
VermilionDock_EraseSSAnne:
2015-08-13 05:14:31 +00:00
; Fill the area the S.S. Anne occupies in BG map 0 with water tiles.
ld hl, wVermilionDockTileMapBuffer
ld bc, wVermilionDockTileMapBufferEnd - wVermilionDockTileMapBuffer
2015-08-13 05:14:31 +00:00
ld a, $14 ; water tile
2014-05-18 18:19:10 +00:00
call FillMemory
hlbgcoord 0, 10
2015-08-13 05:14:31 +00:00
ld de, wVermilionDockTileMapBuffer
lb bc, BANK(wVermilionDockTileMapBuffer), 12
2014-05-18 18:19:10 +00:00
call CopyVideoData
2015-08-13 05:14:31 +00:00
; Replace the blocks of the lower half of the ship with water blocks. This
; leaves the upper half alone, but that doesn't matter because replacing any of
; the blocks is unnecessary because the blocks the ship occupies are south of
; the player and won't be redrawn when the player automatically walks north and
; exits the map. This code could be removed without affecting anything.
hlowcoord 5, 2, VERMILION_DOCK_WIDTH
2015-08-13 05:14:31 +00:00
ld a, $d ; water block
2014-05-18 18:19:10 +00:00
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
2015-08-13 05:14:31 +00:00
2015-07-19 08:46:12 +00:00
ld a, SFX_SS_ANNE_HORN
2014-05-18 18:19:10 +00:00
call PlaySound
ld c, 120
2014-05-18 18:19:10 +00:00
call DelayFrames
ret
VermilionDock_TextPointers:
def_text_pointers
dw_const VermilionDockUnusedText, TEXT_VERMILIONDOCK_UNUSED
2014-05-18 18:19:10 +00:00
VermilionDockUnusedText:
text_far _VermilionDockUnusedText
text_end