Skip to content

Commit

Permalink
Implement last fake console in ShadowOffice room
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Oct 27, 2024
1 parent 6a5d410 commit 11fbef4
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/audio.asm
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ _ContinueNote:
beq _IncrementFramesAndReturn
_ContinueTone:
jsr Func_AudioCallInstrument ; preserves X, returns A
;; TODO: Apply master volume.
sta Hw_Channels_sChanRegs_arr5 + sChanRegs::Envelope_wo, x
_IncrementFramesAndReturn:
inc Ram_Music_sChanNote_arr + sChanNote::ElapsedFrames_u8, x
Expand Down
2 changes: 1 addition & 1 deletion src/breaker.asm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Zp_BreakerBeingActivated_eFlag: .res 1
;;; @prereq Explore mode is initialized.
.PROC Main_Breaker_TraceCircuit
jsr Func_FadeOutToBlack
;; TODO: implement this
;; TODO: implement circuit-tracing cutscene
fall Main_Breaker_LoadCoreRoom
.ENDPROC

Expand Down
2 changes: 2 additions & 0 deletions src/dialog.asm
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
.IMPORT DataA_Dialog_SewerPoolSign_sDialog
.IMPORT DataA_Dialog_ShadowDrillScreen_sDialog
.IMPORT DataA_Dialog_ShadowGateScreen_sDialog
.IMPORT DataA_Dialog_ShadowOfficeAcid_sDialog
.IMPORT DataA_Dialog_ShadowOfficeFireball_sDialog
.IMPORT DataA_Dialog_ShadowOfficeTeleport_sDialog
.IMPORT DataA_Dialog_ShadowTeleportScreen_sDialog
Expand Down Expand Up @@ -567,6 +568,7 @@ _Finish:
d_entry t, SewerPoolSign, DataA_Dialog_SewerPoolSign_sDialog
d_entry t, ShadowDrillScreen, DataA_Dialog_ShadowDrillScreen_sDialog
d_entry t, ShadowGateScreen, DataA_Dialog_ShadowGateScreen_sDialog
d_entry t, ShadowOfficeAcid, DataA_Dialog_ShadowOfficeAcid_sDialog
d_entry t, ShadowOfficeFireball, DataA_Dialog_ShadowOfficeFireball_sDialog
d_entry t, ShadowOfficeTeleport, DataA_Dialog_ShadowOfficeTeleport_sDialog
d_entry t, ShadowTeleportScreen, DataA_Dialog_ShadowTeleportScreen_sDialog
Expand Down
1 change: 1 addition & 0 deletions src/dialog.inc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ kDialogEntryCutscene = $ff ; ends the dialog and starts a new cutscene
SewerPoolSign
ShadowDrillScreen
ShadowGateScreen
ShadowOfficeAcid
ShadowOfficeFireball
ShadowOfficeTeleport
ShadowTeleportScreen
Expand Down
32 changes: 24 additions & 8 deletions src/fake.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
.INCLUDE "machine.inc"
.INCLUDE "machines/carriage.inc"
.INCLUDE "machines/emitter.inc"
.INCLUDE "machines/field.inc"
.INCLUDE "machines/lift.inc"
.INCLUDE "machines/multiplexer.inc"
.INCLUDE "machines/semaphore.inc"
.INCLUDE "machines/shared.inc"
.INCLUDE "macros.inc"
Expand All @@ -52,6 +54,8 @@
.IMPORT Func_Window_TransferBottomBorder
.IMPORT Func_Window_TransferClearRow
.IMPORT Main_Console_CloseWindow
.IMPORT Ppu_ChrObjAnnaNormal
.IMPORT Ppu_ChrObjBoss1
.IMPORT Ram_DeviceTarget_byte_arr
.IMPORT Ram_PpuTransfer_arr
.IMPORTZP Zp_ConsoleNeedsPower_u8
Expand All @@ -73,6 +77,18 @@ kFakeConsoleMessageRows = kMaxProgramLength / 2
;;; The width of the fake console message box, in tiles.
kFakeConsoleMessageCols = 19

;;; The eDiagram value to use for the "CoreDump" fake console. The only thing
;;; that matters is that it have a first tile ID of $f0, so that it will use
;;; the proper row of tiles from the second half of Ppu_ChrObjBoss1.
.ASSERT kTileIdBgDiagramCarriageFirst = $f0, error
kDiagramCoreDump = eDiagram::Carriage

;;; The eDiagram value to use for the "Corrupted" fake console. The only thing
;;; that matters is that it have a first tile ID of $f0, so that it will use
;;; the proper row of tiles from the first half of Ppu_ChrObjAnnaNormal.
.ASSERT kTileIdBgDiagramCarriageFirst = $f0, error
kDiagramCorrupted = eDiagram::Carriage

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

.ZEROPAGE
Expand Down Expand Up @@ -158,11 +174,11 @@ _InitWindow:
jmp Func_PlaySfxWindowOpen
_Chr0cBank_u8_arr:
D_ARRAY .enum, eFake
d_byte CoreDump, $61 ; TODO
d_byte Corrupted, $61 ; TODO
d_byte CoreDump, <.bank(Ppu_ChrObjBoss1) + 1 ; second half
d_byte Corrupted, <.bank(Ppu_ChrObjAnnaNormal) + 0 ; first half
d_byte EndThis, kChrBankDiagramCarriage
d_byte InsufficientData, $50 ; TODO
d_byte IsThisEthical, $60 ; TODO
d_byte InsufficientData, kChrBankDiagramMultiplexer
d_byte IsThisEthical, kChrBankDiagramField
d_byte NoPower, kChrBankDiagramLift
d_byte NoResponse, kChrBankDiagramSemaphoreComm
D_END
Expand Down Expand Up @@ -223,11 +239,11 @@ _DrawStatus:
jmp FuncA_Console_WriteDiagramTransferDataForDiagram
_Fake_eDiagram:
D_ARRAY .enum, eFake
d_byte CoreDump, eDiagram::MinigunDown ; TODO
d_byte Corrupted, eDiagram::MinigunDown ; TODO
d_byte CoreDump, kDiagramCoreDump
d_byte Corrupted, kDiagramCorrupted
d_byte EndThis, eDiagram::Carriage
d_byte InsufficientData, eDiagram::MinigunDown ; TODO
d_byte IsThisEthical, eDiagram::MinigunDown ; TODO
d_byte InsufficientData, eDiagram::Multiplexer
d_byte IsThisEthical, eDiagram::Field
d_byte NoPower, eDiagram::Lift
d_byte NoResponse, eDiagram::SemaphoreComm
D_END
Expand Down
2 changes: 1 addition & 1 deletion src/rooms/shadow_flower.asm
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ _MaybeKillFlowerBaddie:
ldy #0 ; param: laser bottom (hi)
jmp FuncA_Machine_LaserTryAct
_LaserBottom_i16_0_arr:
: .byte $50, $c0, $90, $70, $c5, $70, $c5, $80, $c0, $30
: .byte $50, $c0, $90, $70, $c0, $70, $80, $80, $c0, $30
.assert * - :- = kLaserMaxGoalX + 1, error
.ENDPROC

Expand Down
57 changes: 55 additions & 2 deletions src/rooms/shadow_office.asm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
.IMPORT FuncA_Terrain_FadeInShortRoomWithLava
.IMPORT Func_BufferPpuTransfer
.IMPORT Func_FindEmptyActorSlot
.IMPORT Func_InitActorDefault
.IMPORT Func_InitActorProjFireball
.IMPORT Func_InitActorSmokeExplosion
.IMPORT Func_IsPointInPlatform
Expand All @@ -62,10 +63,19 @@
.IMPORTZP Zp_AvatarPosX_i16
.IMPORTZP Zp_AvatarPosY_i16
.IMPORTZP Zp_PointX_i16
.IMPORTZP Zp_PointY_i16
.IMPORTZP Zp_RoomState

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

;;; How long between drips of acid, in frames.
.DEFINE kAcidDripSlowdown 8

;;; The total time for a full acid dripping sequence, in frames.
kAcidDripFrames = kAcidDripSlowdown * 4

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

;;; The actor index for the ghost in this room.
kGhostActorIndex = 0

Expand Down Expand Up @@ -119,6 +129,8 @@ kLiftInitPlatformTop = kLiftMaxPlatformTop - kLiftInitGoalY * kBlockHeightPx

;;; Defines room-specific state data for this particular room.
.STRUCT sState
;; How many more frames until the acid console can be activated again.
AcidCooldown_u8 .byte
;; How many more frames until the fireball console can be activated again.
FireballCooldown_u8 .byte
;; How many more frames until the teleport count resets.
Expand Down Expand Up @@ -235,10 +247,10 @@ _Devices_sDevice_arr:
d_byte Target_byte, eFake::CoreDump
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::FakeConsole
d_byte Type_eDevice, eDevice::ScreenGreen
d_byte BlockRow_u8, 2
d_byte BlockCol_u8, 6
d_byte Target_byte, eFake::InsufficientData ; TODO shock vert
d_byte Target_byte, eDialog::ShadowOfficeAcid
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::FakeConsole
Expand Down Expand Up @@ -330,6 +342,34 @@ _Passages_sPassage_arr:
.SEGMENT "PRGA_Room"

.PROC FuncA_Room_ShadowOffice_TickRoom
_Acid:
;; Check if acid is currently dripping from the ceiling.
lda Zp_RoomState + sState::AcidCooldown_u8
beq @done ; acid drip sequence is not active
;; Drip one drop of acid every kAcidDripSlowdown frames.
dec Zp_RoomState + sState::AcidCooldown_u8
mod #kAcidDripSlowdown
bne @done ; don't drip acid this frame
;; Calculate the starting point for this drop of acid.
lda Zp_RoomState + sState::AcidCooldown_u8
.assert $10 .mod kAcidDripSlowdown = 0, error
mul #$10 / kAcidDripSlowdown
and #$f0
rsub #$78
sta Zp_PointX_i16 + 0
lda #$13
sta Zp_PointY_i16 + 0
lda #0
sta Zp_PointX_i16 + 1
sta Zp_PointY_i16 + 1
;; Spawn an acid projectile at the starting point.
jsr Func_FindEmptyActorSlot ; sets C on failure, returns X
bcs @done
jsr Func_SetActorCenterToPoint ; preserves X
ldy #eActor::ProjAcid ; param: actor type
jsr Func_InitActorDefault
;; TODO: play a sound for dripping acid
@done:
_CoolDownFireball:
lda Zp_RoomState + sState::FireballCooldown_u8
beq @done
Expand Down Expand Up @@ -445,6 +485,19 @@ _Return:

.SEGMENT "PRGA_Dialog"

.EXPORT DataA_Dialog_ShadowOfficeAcid_sDialog
.PROC DataA_Dialog_ShadowOfficeAcid_sDialog
dlg_Call _DripAcid
dlg_Done
_DripAcid:
lda Zp_RoomState + sState::AcidCooldown_u8
bne @done
lda #kAcidDripFrames
sta Zp_RoomState + sState::AcidCooldown_u8
@done:
rts
.ENDPROC

.EXPORT DataA_Dialog_ShadowOfficeFireball_sDialog
.PROC DataA_Dialog_ShadowOfficeFireball_sDialog
dlg_Call _ShootFireball
Expand Down

0 comments on commit 11fbef4

Please sign in to comment.