Skip to content

Commit

Permalink
Start implementing city breaker cutscene
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Feb 16, 2024
1 parent 5032e5c commit 6ecefea
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 37 deletions.
100 changes: 75 additions & 25 deletions src/breaker.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
;;;=========================================================================;;;

.INCLUDE "avatar.inc"
.INCLUDE "boss.inc"
.INCLUDE "cpu.inc"
.INCLUDE "cutscene.inc"
.INCLUDE "device.inc"
Expand All @@ -28,12 +29,14 @@
.INCLUDE "mmc3.inc"
.INCLUDE "music.inc"
.INCLUDE "oam.inc"
.INCLUDE "ppu.inc"
.INCLUDE "room.inc"
.INCLUDE "sample.inc"
.INCLUDE "scroll.inc"
.INCLUDE "spawn.inc"
.INCLUDE "tileset.inc"

.IMPORT FuncA_Avatar_SpawnAtDevice
.IMPORT FuncA_Cutscene_PlaySfxFlipBreaker
.IMPORT FuncM_SwitchPrgcAndLoadRoom
.IMPORT FuncM_SwitchPrgcAndLoadRoomWithMusic
Expand Down Expand Up @@ -135,13 +138,10 @@ Zp_BreakerBeingActivated_eFlag: .res 1
.EXPORT Main_Breaker_FadeBackToBreakerRoom
.PROC Main_Breaker_FadeBackToBreakerRoom
jsr Func_FadeOutToBlack
;; Un-hide the player avatar.
lda #eAvatar::Kneeling
sta Zp_AvatarPose_eAvatar
;; Reload the room that the breaker was in.
ldx Zp_Breaker_eRoom ; param: room to load
jsr FuncM_SwitchPrgcAndLoadRoom
jmp Main_Explore_EnterRoom
jmp_prga MainA_Avatar_EnterBossRoomAfterBreaker
.ENDPROC

;;;=========================================================================;;;
Expand Down Expand Up @@ -284,11 +284,6 @@ _BlinkCircuit:
rts
.ENDPROC

.EXPORT DataA_Cutscene_SharedFadeBackToBreakerRoom_sCutscene
.PROC DataA_Cutscene_SharedFadeBackToBreakerRoom_sCutscene
act_JumpToMain Main_Breaker_FadeBackToBreakerRoom
.ENDPROC

;;;=========================================================================;;;

.SEGMENT "PRGA_Breaker"
Expand Down Expand Up @@ -371,7 +366,7 @@ _Cutscene_eRoom_arr:
d_byte Crypt, eRoom::MermaidHut1
d_byte Lava, eRoom::TownHouse4
d_byte Mine, eRoom::GardenShrine
d_byte City, eRoom::MermaidHut1 ; TODO
d_byte City, eRoom::CityCenter
d_byte Shadow, eRoom::CoreLock
D_END
_Cutscene_eCutscene_arr:
Expand All @@ -381,14 +376,15 @@ _Cutscene_eCutscene_arr:
d_byte Crypt, eCutscene::MermaidHut1BreakerCrypt
d_byte Lava, eCutscene::TownHouse4BreakerLava
d_byte Mine, eCutscene::GardenShrineBreakerMine
d_byte City, eCutscene::SharedFadeBackToBreakerRoom ; TODO
d_byte City, eCutscene::CityCenterBreakerCity
d_byte Shadow, eCutscene::CoreLockBreakerShadow
D_END
.ENDPROC

;;; Sets up the avatar and room scrolling for the current breaker's cutscene,
;;; then jumps to Main_Explore_EnterRoom.
;;; @prereq Rendering is disabled.
;;; @prereq Static room data is loaded.
.PROC MainA_Breaker_EnterCutsceneRoom
;; Hide the player avatar.
lda #eAvatar::Hidden
Expand All @@ -398,34 +394,88 @@ _Cutscene_eCutscene_arr:
.assert kFirstBreakerFlag > 0, error
sub #kFirstBreakerFlag
tay ; eBreaker value
;; Set room scroll and lock scrolling.
lda _ScrollX_u16_0_arr, y
sta Zp_RoomScrollX_u16 + 0
lda _ScrollX_u16_1_arr, y
sta Zp_RoomScrollX_u16 + 1
lda #bScroll::LockHorz
sta Zp_Camera_bScroll
;; Position the (hidden) player avatar so as to make the room scroll
;; position be what we want. (We don't want to do this by locking
;; scrolling, because we want e.g. the vertical scroll to be able to shift
;; while the dialog window is open.)
lda _AvatarPosX_i16_0_arr, y
sta Zp_AvatarPosX_i16 + 0
lda _AvatarPosX_i16_1_arr, y
sta Zp_AvatarPosX_i16 + 1
lda _AvatarPosY_i16_0_arr, y
sta Zp_AvatarPosY_i16 + 0
lda _AvatarPosY_i16_1_arr, y
sta Zp_AvatarPosY_i16 + 1
jmp Main_Explore_EnterRoom
_ScrollX_u16_0_arr:
_AvatarPosX_i16_0_arr:
D_ARRAY .enum, eBreaker
d_byte Garden, $a8
d_byte Temple, $50
d_byte Crypt, $a8
d_byte Lava, $80
d_byte Mine, $88
d_byte City, $f0
d_byte Shadow, $90
D_END
_AvatarPosX_i16_1_arr:
D_ARRAY .enum, eBreaker
d_byte Garden, $00
d_byte Temple, $d0
d_byte Temple, $01
d_byte Crypt, $00
d_byte Lava, $00
d_byte Mine, $08
d_byte City, $00 ; TODO
d_byte Shadow, $10
d_byte Mine, $00
d_byte City, $03
d_byte Shadow, $00
D_END
_ScrollX_u16_1_arr:
_AvatarPosY_i16_0_arr:
D_ARRAY .enum, eBreaker
d_byte Garden, $b8
d_byte Temple, $b8
d_byte Crypt, $b8
d_byte Lava, $c8
d_byte Mine, $88
d_byte City, $58
d_byte Shadow, $c8
D_END
_AvatarPosY_i16_1_arr:
D_ARRAY .enum, eBreaker
d_byte Garden, $00
d_byte Temple, $00
d_byte Crypt, $00
d_byte Lava, $00
d_byte Mine, $00
d_byte City, $00 ; TODO
d_byte City, $01
d_byte Shadow, $00
D_END
.ENDPROC

;;;=========================================================================;;;

.SEGMENT "PRGA_Avatar"

;;; Sets the avatar position and pose within the boss room for after a breaker
;;; cutscene, then jumps to Main_Explore_EnterRoom.
;;; @prereq Rendering is disabled.
;;; @prereq Static room data is loaded.
.PROC MainA_Avatar_EnterBossRoomAfterBreaker
;; Position the player avatar at the breaker device.
ldx #kBossBreakerDeviceIndex ; param: device index
jsr FuncA_Avatar_SpawnAtDevice
;; Since the room's Enter function hasn't been called yet, the breaker
;; device is actually still a Placeholder device, which has a different
;; spawn offset than a breaker. So correct the avatar's X-position within
;; the block.
lda Zp_AvatarPosX_i16 + 0
.assert kBlockWidthPx = $10, error
and #$f0
ora #kBreakerAvatarOffset
sta Zp_AvatarPosX_i16 + 0
;; Make the player avatar start out kneeling as the room fades in (since
;; that was the pose the avatar was last in when the boss room faded out
;; for the breaker cutscene).
lda #eAvatar::Kneeling
sta Zp_AvatarPose_eAvatar
jmp Main_Explore_EnterRoom
.ENDPROC

;;;=========================================================================;;;
1 change: 1 addition & 0 deletions src/charmap.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
;;;=========================================================================;;;

.CHARMAP $20, $00 ; ' '
.CHARMAP $60, $40 ; '`'
.CHARMAP $21, $41 ; '!'
.CHARMAP $3f, $42 ; '?'
.CHARMAP $2e, $43 ; '.'
Expand Down
6 changes: 3 additions & 3 deletions src/cutscene.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
.INCLUDE "mmc3.inc"
.INCLUDE "oam.inc"

.IMPORT DataA_Cutscene_CityCenterBreakerCity_sCutscene
.IMPORT DataA_Cutscene_CityFlowerOrcAttack_sCutscene
.IMPORT DataA_Cutscene_CityOutskirtsLook_sCutscene
.IMPORT DataA_Cutscene_CoreBossFinaleReactivate_sCutscene
Expand All @@ -46,7 +47,6 @@
.IMPORT DataA_Cutscene_PrisonUpperBreakerTemple_sCutscene
.IMPORT DataA_Cutscene_PrisonUpperFreeAlex_sCutscene
.IMPORT DataA_Cutscene_PrisonUpperFreeKids_sCutscene
.IMPORT DataA_Cutscene_SharedFadeBackToBreakerRoom_sCutscene
.IMPORT DataA_Cutscene_SharedFlipBreaker_sCutscene
.IMPORT DataA_Cutscene_SharedTeleportIn_sCutscene
.IMPORT DataA_Cutscene_SharedTeleportOut_sCutscene
Expand Down Expand Up @@ -197,6 +197,8 @@ _Finish:
D_TABLE_HI table, DataA_Cutscene_Table_sCutscene_ptr_1_arr
D_TABLE .enum, eCutscene
d_entry table, None, DataA_Cutscene_Null_sCutscene
d_entry table, CityCenterBreakerCity, \
DataA_Cutscene_CityCenterBreakerCity_sCutscene
d_entry table, CityFlowerOrcAttack, \
DataA_Cutscene_CityFlowerOrcAttack_sCutscene
d_entry table, CityOutskirtsLook, \
Expand Down Expand Up @@ -235,8 +237,6 @@ _Finish:
DataA_Cutscene_PrisonUpperFreeAlex_sCutscene
d_entry table, PrisonUpperFreeKids, \
DataA_Cutscene_PrisonUpperFreeKids_sCutscene
d_entry table, SharedFadeBackToBreakerRoom, \
DataA_Cutscene_SharedFadeBackToBreakerRoom_sCutscene
d_entry table, SharedFlipBreaker, \
DataA_Cutscene_SharedFlipBreaker_sCutscene
d_entry table, SharedTeleportIn, \
Expand Down
2 changes: 1 addition & 1 deletion src/cutscene.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ kMaxForks = 4
;;; The list of cutscenes in the game.
.ENUM eCutscene
None
CityCenterBreakerCity
CityFlowerOrcAttack
CityOutskirtsLook
CoreBossFinaleReactivate
Expand All @@ -57,7 +58,6 @@ kMaxForks = 4
PrisonUpperBreakerTemple
PrisonUpperFreeAlex
PrisonUpperFreeKids
SharedFadeBackToBreakerRoom ; TODO: get rid of this
SharedFlipBreaker
SharedTeleportIn
SharedTeleportOut
Expand Down
3 changes: 3 additions & 0 deletions src/dialog.asm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

.IMPORT DataA_Dialog_CityBuilding2Screen_sDialog
.IMPORT DataA_Dialog_CityBuilding6Screen_sDialog
.IMPORT DataA_Dialog_CityCenterBreakerCity1_sDialog
.IMPORT DataA_Dialog_CityFlowerOrcAngry_sDialog
.IMPORT DataA_Dialog_CityFlowerOrcCalm_sDialog
.IMPORT DataA_Dialog_CityOutskirtsAlex1_sDialog
Expand Down Expand Up @@ -425,6 +426,8 @@ _Finish:
D_TABLE .enum, eDialog
d_entry t, CityBuilding2Screen, DataA_Dialog_CityBuilding2Screen_sDialog
d_entry t, CityBuilding6Screen, DataA_Dialog_CityBuilding6Screen_sDialog
d_entry t, CityCenterBreakerCity1, \
DataA_Dialog_CityCenterBreakerCity1_sDialog
d_entry t, CityFlowerOrcAngry, DataA_Dialog_CityFlowerOrcAngry_sDialog
d_entry t, CityFlowerOrcCalm, DataA_Dialog_CityFlowerOrcCalm_sDialog
d_entry t, CityOutskirtsAlex1, DataA_Dialog_CityOutskirtsAlex1_sDialog
Expand Down
1 change: 1 addition & 0 deletions src/dialog.inc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ kDialogEntryCutscene = $ff ; ends the dialog and starts a new cutscene
.ENUM eDialog
CityBuilding2Screen
CityBuilding6Screen
CityCenterBreakerCity1
CityFlowerOrcAngry
CityFlowerOrcCalm
CityOutskirtsAlex1
Expand Down
5 changes: 5 additions & 0 deletions src/explore.asm
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Zp_Next_eCutscene: .res 1
;;; been loaded and the player avatar positioned within the room, but the
;;; room's Enter_func_ptr has not yet been called.
;;; @prereq Rendering is disabled.
;;; @prereq Static room data is loaded and avatar is positioned.
.EXPORT Main_Explore_EnterRoom
.PROC Main_Explore_EnterRoom
jsr_prga FuncA_Room_InitAllMachinesAndCallRoomEnter
Expand Down Expand Up @@ -418,6 +419,10 @@ _UpDownPassage:
;;; player avatar is near (if any), or sets bDevice::NoneNearby if the avatar
;;; is not near an interactive device.
.PROC FuncA_Avatar_FindNearbyDevice
;; If the player avatar is hidden, treat them as not near any device.
lda Zp_AvatarPose_eAvatar
.assert eAvatar::Hidden = 0, error
beq @noneNearby
;; If the player avatar is airborne, treat them as not near any device.
bit Zp_AvatarState_bAvatar
.assert bAvatar::Airborne = bProc::Negative, error
Expand Down
Loading

0 comments on commit 6ecefea

Please sign in to comment.