Skip to content

Commit

Permalink
Add cutscene for Alex meeting you in FactoryElevator
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Mar 20, 2024
1 parent 637b95d commit 5574733
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/chr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,8 @@ _chr_begin:
chr_res $08
chr_inc "crane", kTileIdObjCraneFirst
chr_inc "bad_toad", kTileIdObjBadToadFirst
chr_res $40
chr_res $20
chr_inc "child_stand", kTileIdObjChildStandFirst
END_CHR_BANK
.ENDPROC

Expand Down
3 changes: 3 additions & 0 deletions src/cutscene.asm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
.IMPORT DataA_Cutscene_CoreLockBreakerShadow_sCutscene
.IMPORT DataA_Cutscene_CoreSouthCorraHelping_sCutscene
.IMPORT DataA_Cutscene_FactoryEastCorraHelping_sCutscene
.IMPORT DataA_Cutscene_FactoryElevatorWaitUp_sCutscene
.IMPORT DataA_Cutscene_GardenShrineBreakerMine_sCutscene
.IMPORT DataA_Cutscene_MermaidHut1AlexPetition_sCutscene
.IMPORT DataA_Cutscene_MermaidHut1BreakerCrypt_sCutscene
Expand Down Expand Up @@ -222,6 +223,8 @@ _Finish:
DataA_Cutscene_CoreSouthCorraHelping_sCutscene
d_entry table, FactoryEastCorraHelping, \
DataA_Cutscene_FactoryEastCorraHelping_sCutscene
d_entry table, FactoryElevatorWaitUp, \
DataA_Cutscene_FactoryElevatorWaitUp_sCutscene
d_entry table, GardenShrineBreakerMine, \
DataA_Cutscene_GardenShrineBreakerMine_sCutscene
d_entry table, MermaidHut1AlexPetition, \
Expand Down
1 change: 1 addition & 0 deletions src/cutscene.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ kMaxForks = 4
CoreLockBreakerShadow
CoreSouthCorraHelping
FactoryEastCorraHelping
FactoryElevatorWaitUp
GardenShrineBreakerMine
MermaidHut1AlexPetition
MermaidHut1BreakerCrypt
Expand Down
6 changes: 6 additions & 0 deletions src/dialog.asm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
.IMPORT DataA_Dialog_CoreSouthCorra_sDialog
.IMPORT DataA_Dialog_CryptTombPlaque_sDialog
.IMPORT DataA_Dialog_FactoryEastCorra_sDialog
.IMPORT DataA_Dialog_FactoryElevatorAlexHi_sDialog
.IMPORT DataA_Dialog_FactoryElevatorAlexWait_sDialog
.IMPORT DataA_Dialog_FactoryVaultAlex_sDialog
.IMPORT DataA_Dialog_FactoryVaultScreen_sDialog
.IMPORT DataA_Dialog_GardenEastCorra_sDialog
Expand Down Expand Up @@ -443,6 +445,10 @@ _Finish:
d_entry t, CoreSouthCorra, DataA_Dialog_CoreSouthCorra_sDialog
d_entry t, CryptTombPlaque, DataA_Dialog_CryptTombPlaque_sDialog
d_entry t, FactoryEastCorra, DataA_Dialog_FactoryEastCorra_sDialog
d_entry t, FactoryElevatorAlexHi, \
DataA_Dialog_FactoryElevatorAlexHi_sDialog
d_entry t, FactoryElevatorAlexWait, \
DataA_Dialog_FactoryElevatorAlexWait_sDialog
d_entry t, FactoryVaultAlex, DataA_Dialog_FactoryVaultAlex_sDialog
d_entry t, FactoryVaultScreen, DataA_Dialog_FactoryVaultScreen_sDialog
d_entry t, GardenEastCorra, DataA_Dialog_GardenEastCorra_sDialog
Expand Down
2 changes: 2 additions & 0 deletions src/dialog.inc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ kDialogEntryCutscene = $ff ; ends the dialog and starts a new cutscene
CoreSouthCorra
CryptTombPlaque
FactoryEastCorra
FactoryElevatorAlexHi
FactoryElevatorAlexWait
FactoryVaultAlex
FactoryVaultScreen
GardenEastCorra
Expand Down
1 change: 1 addition & 0 deletions src/flag.inc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ kSaveMagicNumber = $b2
TempleNaveTalkedToAlex
;; TODO: Sort the below within the above once it won't disrupt playtesting.
FactoryEastCorraHelped
FactoryElevatorTalkedToAlex
NUM_VALUES
.ENDENUM
.ASSERT eFlag::NUM_VALUES <= $100, error
Expand Down
150 changes: 148 additions & 2 deletions src/rooms/factory_elevator.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
;;;=========================================================================;;;

.INCLUDE "../actor.inc"
.INCLUDE "../actors/child.inc"
.INCLUDE "../avatar.inc"
.INCLUDE "../charmap.inc"
.INCLUDE "../cpu.inc"
.INCLUDE "../cutscene.inc"
.INCLUDE "../device.inc"
.INCLUDE "../dialog.inc"
.INCLUDE "../flag.inc"
.INCLUDE "../hud.inc"
.INCLUDE "../machine.inc"
Expand All @@ -33,18 +37,22 @@
.INCLUDE "elevator.inc"

.IMPORT DataA_Room_Factory_sTileset
.IMPORT Data_Empty_sActor_arr
.IMPORT FuncA_Machine_Error
.IMPORT FuncA_Machine_GenericTryMoveY
.IMPORT FuncA_Machine_JetTick
.IMPORT FuncA_Machine_WriteToLever
.IMPORT FuncA_Machine_WriteToPhantomLever
.IMPORT FuncA_Objects_DrawJetMachine
.IMPORT FuncA_Room_ResetLever
.IMPORT Func_IsPointInPlatform
.IMPORT Func_MachineJetReadRegY
.IMPORT Func_Noop
.IMPORT Func_SetFlag
.IMPORT Func_SetMachineIndex
.IMPORT Func_SetPointToAvatarCenter
.IMPORT Ppu_ChrObjFactory
.IMPORT Ram_ActorType_eActor_arr
.IMPORT Ram_DeviceType_eDevice_arr
.IMPORT Ram_MachineGoalVert_u8_arr
.IMPORT Ram_MachinePc_u8_arr
.IMPORT Ram_MachineRegA_u8_arr
Expand All @@ -54,14 +62,28 @@
.IMPORT Ram_PlatformBottom_i16_1_arr
.IMPORT Ram_PlatformTop_i16_0_arr
.IMPORT Ram_PlatformTop_i16_1_arr
.IMPORT Sram_ProgressFlags_arr
.IMPORTZP Zp_AvatarPosY_i16
.IMPORTZP Zp_AvatarState_bAvatar
.IMPORTZP Zp_Current_sMachine_ptr
.IMPORTZP Zp_FloatingHud_bHud
.IMPORTZP Zp_Next_eCutscene
.IMPORTZP Zp_Previous_eRoom
.IMPORTZP Zp_RoomState

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

;;; The actor index for Alex in this room.
kAlexActorIndex = 0
;;; The talk devices indices for Alex in this room.
kAlexDeviceIndexLeft = 5
kAlexDeviceIndexRight = 4

;;; The platform index for the zone where Alex asks you to wait up.
kWaitUpZonePlatformIndex = 2

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

;;; The indices of the vertical passages at the top and bottom of the room.
kUpperShaftPassageIndex = 4
kLowerShaftPassageIndex = 5
Expand Down Expand Up @@ -120,7 +142,7 @@ _Ext_sRoomExt:
D_STRUCT sRoomExt
d_addr Terrain_sTileset_ptr, DataA_Room_Factory_sTileset
d_addr Platforms_sPlatform_arr_ptr, _Platforms_sPlatform_arr
d_addr Actors_sActor_arr_ptr, Data_Empty_sActor_arr
d_addr Actors_sActor_arr_ptr, _Actors_sActor_arr
d_addr Devices_sDevice_arr_ptr, _Devices_sDevice_arr
d_addr Passages_sPassage_arr_ptr, _Passages_sPassage_arr
d_addr Enter_func_ptr, FuncA_Room_FactoryElevator_EnterRoom
Expand Down Expand Up @@ -188,8 +210,26 @@ _Platforms_sPlatform_arr:
d_word Left_i16, $0080
d_word Top_i16, kLowerJetInitPlatformTop
D_END
.assert * - :- = kWaitUpZonePlatformIndex * .sizeof(sPlatform), error
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Zone
d_word WidthPx_u16, $20
d_byte HeightPx_u8, $10
d_word Left_i16, $00a0
d_word Top_i16, $0100
D_END
.assert * - :- <= kMaxPlatforms * .sizeof(sPlatform), error
.byte ePlatform::None
_Actors_sActor_arr:
: .assert * - :- = kAlexActorIndex * .sizeof(sActor), error
D_STRUCT sActor
d_byte Type_eActor, eActor::NpcChild
d_word PosX_i16, $00d0
d_word PosY_i16, $0128
d_byte Param_byte, eNpcChild::AlexStanding
D_END
.assert * - :- <= kMaxActors * .sizeof(sActor), error
.byte eActor::None
_Devices_sDevice_arr:
: D_STRUCT sDevice
d_byte Type_eDevice, eDevice::Console
Expand Down Expand Up @@ -217,6 +257,20 @@ _Devices_sDevice_arr:
d_byte BlockCol_u8, 7
d_byte Target_byte, sElevatorState::LowerJetUpperLever_u8
D_END
.assert * - :- = kAlexDeviceIndexRight * .sizeof(sDevice), error
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::TalkRight
d_byte BlockRow_u8, 18
d_byte BlockCol_u8, 12
d_byte Target_byte, eDialog::FactoryElevatorAlexHi
D_END
.assert * - :- = kAlexDeviceIndexLeft * .sizeof(sDevice), error
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::TalkLeft
d_byte BlockRow_u8, 18
d_byte BlockCol_u8, 13
d_byte Target_byte, eDialog::FactoryElevatorAlexHi
D_END
.assert * - :- <= kMaxDevices * .sizeof(sDevice), error
.byte eDevice::None
_Passages_sPassage_arr:
Expand Down Expand Up @@ -297,7 +351,24 @@ _Passages_sPassage_arr:

.SEGMENT "PRGA_Room"

;;; @param A The bSpawn value for where the avatar is entering the room.
.PROC FuncA_Room_FactoryElevator_EnterRoom
_MaybeRemoveAlex:
pha ; bSpawn value
flag_bit Sram_ProgressFlags_arr, eFlag::FactoryPassLoweredRocks
beq @removeAlex ; Alex isn't here yet
flag_bit Sram_ProgressFlags_arr, eFlag::FactoryVaultTalkedToAlex
beq @keepAlex ; Alex is still here
@removeAlex:
lda #0
.assert eActor::None = 0, error
sta Ram_ActorType_eActor_arr + kAlexActorIndex
.assert eDevice::None = 0, error
sta Ram_DeviceType_eDevice_arr + kAlexDeviceIndexLeft
sta Ram_DeviceType_eDevice_arr + kAlexDeviceIndexRight
@keepAlex:
pla ; bSpawn value
_CheckPassage:
;; Check which vertical shaft the player avatar entered from, if either.
cmp #bSpawn::Passage | kUpperShaftPassageIndex
beq _UpperShaft
Expand Down Expand Up @@ -328,6 +399,29 @@ _LowerShaft:
.ENDPROC

.PROC FuncA_Room_FactoryElevator_TickRoom
_StartCutscene:
;; If Alex isn't here, or if Anna has already talked to Alex, don't start
;; the cutscene.
flag_bit Sram_ProgressFlags_arr, eFlag::FactoryPassLoweredRocks
beq @done ; Alex isn't here yet
flag_bit Sram_ProgressFlags_arr, eFlag::FactoryVaultTalkedToAlex
bne @done ; Alex is no longer here
flag_bit Sram_ProgressFlags_arr, eFlag::FactoryElevatorTalkedToAlex
bne @done
;; If the player avatar isn't standing in the cutscene-starting zone, don't
;; start it yet.
bit Zp_AvatarState_bAvatar
.assert bAvatar::Airborne = bProc::Negative, error
bmi @done
jsr Func_SetPointToAvatarCenter
ldy #kWaitUpZonePlatformIndex ; param: platform index
jsr Func_IsPointInPlatform ; returns C
bcc @done
;; Start the cutscene.
lda #eCutscene::FactoryElevatorWaitUp
sta Zp_Next_eCutscene
@done:
_StoreElevatorState:
ldx #kUpperJetMachineIndex ; param: machine index
lda Zp_AvatarPosY_i16 + 1
beq FuncA_Room_StoreElevatorJetState
Expand Down Expand Up @@ -496,3 +590,55 @@ _WriteL:
.ENDPROC

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

.SEGMENT "PRGA_Cutscene"

.EXPORT DataA_Cutscene_FactoryElevatorWaitUp_sCutscene
.PROC DataA_Cutscene_FactoryElevatorWaitUp_sCutscene
act_SetAvatarState 0
act_SetAvatarVelX 0
act_SetAvatarPose eAvatar::Standing
act_SetActorState1 kAlexActorIndex, eNpcChild::AlexLooking
act_RunDialog eDialog::FactoryElevatorAlexWait
act_WalkAvatar $00ba
act_SetAvatarFlags kPaletteObjAvatarNormal | 0
act_SetAvatarPose eAvatar::Standing
act_WaitFrames 30
act_RunDialog eDialog::FactoryElevatorAlexHi
act_SetActorState1 kAlexActorIndex, eNpcChild::AlexStanding
act_ContinueExploring
.ENDPROC

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

.SEGMENT "PRGA_Dialog"

.EXPORT DataA_Dialog_FactoryElevatorAlexWait_sDialog
.PROC DataA_Dialog_FactoryElevatorAlexWait_sDialog
dlg_Text ChildAlex, DataA_Text2_FactoryElevatorAlex_Wait_u8_arr
dlg_Done
.ENDPROC

.EXPORT DataA_Dialog_FactoryElevatorAlexHi_sDialog
.PROC DataA_Dialog_FactoryElevatorAlexHi_sDialog
dlg_Text ChildAlex, DataA_Text2_FactoryElevatorAlex_Hi_u8_arr
dlg_Call _SetFlag
dlg_Done
_SetFlag:
ldx #eFlag::FactoryElevatorTalkedToAlex ; param: flag
jmp Func_SetFlag
.ENDPROC

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

.SEGMENT "PRGA_Text2"

.PROC DataA_Text2_FactoryElevatorAlex_Wait_u8_arr
.byte "Hey Anna, wait up!#"
.ENDPROC

.PROC DataA_Text2_FactoryElevatorAlex_Hi_u8_arr
.byte "TODO: Hi!#"
.ENDPROC

;;;=========================================================================;;;
1 change: 1 addition & 0 deletions src/rooms/temple_entry.asm
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ _MoveColumn:
@done:
rts
.ENDPROC

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

.SEGMENT "PRGA_Cutscene"
Expand Down

0 comments on commit 5574733

Please sign in to comment.