Skip to content

Commit

Permalink
Remove (most) machine projectiles when any console is open
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Mar 10, 2024
1 parent 8e0a22b commit b1623db
Show file tree
Hide file tree
Showing 21 changed files with 187 additions and 77 deletions.
34 changes: 26 additions & 8 deletions src/actor.asm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
.IMPORT FuncA_Actor_TickSmokeExplosion
.IMPORT FuncA_Actor_TickSmokeFragment
.IMPORT FuncA_Actor_TickSmokeParticle
.IMPORT FuncA_Actor_TickSmokeSteamHorz
.IMPORT FuncA_Actor_TickSmokeSteamUp
.IMPORT FuncA_Objects_DrawActorBadBat
.IMPORT FuncA_Objects_DrawActorBadBeetleHorz
.IMPORT FuncA_Objects_DrawActorBadBeetleVert
Expand Down Expand Up @@ -116,6 +118,8 @@
.IMPORT FuncA_Objects_DrawActorSmokeExplosion
.IMPORT FuncA_Objects_DrawActorSmokeFragment
.IMPORT FuncA_Objects_DrawActorSmokeParticle
.IMPORT FuncA_Objects_DrawActorSmokeSteamHorz
.IMPORT FuncA_Objects_DrawActorSmokeSteamUp
.IMPORT FuncA_Room_InitActorBadBird
.IMPORT FuncA_Room_InitActorBadFirefly
.IMPORT FuncA_Room_InitActorBadFlydrop
Expand Down Expand Up @@ -147,6 +151,8 @@
.IMPORT Func_InitActorSmokeExplosion
.IMPORT Func_InitActorSmokeFragment
.IMPORT Func_InitActorSmokeParticle
.IMPORT Func_InitActorSmokeSteamHorz
.IMPORT Func_InitActorSmokeSteamUp
.IMPORT Func_Noop
.IMPORT Func_SetPointToAvatarCenter
.IMPORTZP Zp_PointX_i16
Expand All @@ -165,12 +171,12 @@ kProjGrenadeRadius = 2
kProjRocketRadius = 2
kProjSpikeRadius = 3
kProjSpineRadius = 1
kProjSteamMajorRadius = 8
kProjSteamMinorRadius = 3
kSmokeBloodRadius = 1
kSmokeExplosionRadius = 6
kSmokeFragmentRadius = 1
kSmokeParticleRadius = 1
kSteamMajorRadius = 8
kSteamMinorRadius = 3

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

Expand Down Expand Up @@ -499,12 +505,14 @@ _NoHit:
d_byte ProjRocket, kProjRocketRadius
d_byte ProjSpike, kProjSpikeRadius
d_byte ProjSpine, kProjSpineRadius
d_byte ProjSteamHorz, kProjSteamMinorRadius
d_byte ProjSteamUp, kProjSteamMajorRadius
d_byte ProjSteamHorz, kSteamMinorRadius
d_byte ProjSteamUp, kSteamMajorRadius
d_byte SmokeBlood, kSmokeBloodRadius
d_byte SmokeExplosion, kSmokeExplosionRadius
d_byte SmokeFragment, kSmokeFragmentRadius
d_byte SmokeParticle, kSmokeParticleRadius
d_byte SmokeSteamHorz, kSteamMinorRadius
d_byte SmokeSteamUp, kSteamMajorRadius
D_END
.ENDPROC
.PROC DataA_Actor_BoundingBoxDown_u8_arr
Expand Down Expand Up @@ -553,12 +561,14 @@ _NoHit:
d_byte ProjRocket, kProjRocketRadius
d_byte ProjSpike, kProjSpikeRadius
d_byte ProjSpine, kProjSpineRadius
d_byte ProjSteamHorz, kProjSteamMinorRadius
d_byte ProjSteamUp, kProjSteamMajorRadius
d_byte ProjSteamHorz, kSteamMinorRadius
d_byte ProjSteamUp, kSteamMajorRadius
d_byte SmokeBlood, kSmokeBloodRadius
d_byte SmokeExplosion, kSmokeExplosionRadius
d_byte SmokeFragment, kSmokeFragmentRadius
d_byte SmokeParticle, kSmokeParticleRadius
d_byte SmokeSteamHorz, kSteamMinorRadius
d_byte SmokeSteamUp, kSteamMajorRadius
D_END
.ENDPROC
.PROC DataA_Actor_BoundingBoxSide_u8_arr
Expand Down Expand Up @@ -607,12 +617,14 @@ _NoHit:
d_byte ProjRocket, kProjRocketRadius
d_byte ProjSpike, kProjSpikeRadius
d_byte ProjSpine, kProjSpineRadius
d_byte ProjSteamHorz, kProjSteamMajorRadius
d_byte ProjSteamUp, kProjSteamMinorRadius
d_byte ProjSteamHorz, kSteamMajorRadius
d_byte ProjSteamUp, kSteamMinorRadius
d_byte SmokeBlood, kSmokeBloodRadius
d_byte SmokeExplosion, kSmokeExplosionRadius
d_byte SmokeFragment, kSmokeFragmentRadius
d_byte SmokeParticle, kSmokeParticleRadius
d_byte SmokeSteamHorz, kSteamMajorRadius
d_byte SmokeSteamUp, kSteamMinorRadius
D_END
.ENDPROC

Expand Down Expand Up @@ -735,6 +747,8 @@ _TypeSpecificTick:
d_entry table, SmokeExplosion, FuncA_Actor_TickSmokeExplosion
d_entry table, SmokeFragment, FuncA_Actor_TickSmokeFragment
d_entry table, SmokeParticle, FuncA_Actor_TickSmokeParticle
d_entry table, SmokeSteamHorz, FuncA_Actor_TickSmokeSteamHorz
d_entry table, SmokeSteamUp, FuncA_Actor_TickSmokeSteamUp
D_END
.ENDREPEAT
.ENDPROC
Expand Down Expand Up @@ -842,6 +856,8 @@ _CheckVert:
d_entry table, SmokeExplosion, Func_InitActorSmokeExplosion
d_entry table, SmokeFragment, Func_InitActorSmokeFragment
d_entry table, SmokeParticle, Func_InitActorSmokeParticle
d_entry table, SmokeSteamHorz, Func_InitActorSmokeSteamHorz
d_entry table, SmokeSteamUp, Func_InitActorSmokeSteamUp
D_END
.ENDREPEAT
.ENDPROC
Expand Down Expand Up @@ -925,6 +941,8 @@ _CheckVert:
d_entry table, SmokeExplosion, FuncA_Objects_DrawActorSmokeExplosion
d_entry table, SmokeFragment, FuncA_Objects_DrawActorSmokeFragment
d_entry table, SmokeParticle, FuncA_Objects_DrawActorSmokeParticle
d_entry table, SmokeSteamHorz, FuncA_Objects_DrawActorSmokeSteamHorz
d_entry table, SmokeSteamUp, FuncA_Objects_DrawActorSmokeSteamUp
D_END
.ENDREPEAT
.ENDPROC
Expand Down
2 changes: 2 additions & 0 deletions src/actor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ kMaxActors = 16
SmokeExplosion ; a puff of smoke for when something explodes
SmokeFragment ; a fragment that falls under gravity
SmokeParticle ; a single particle of smoke
SmokeSteamHorz ; like ProjSteamHorz, but without any physics interactions
SmokeSteamUp ; like ProjSteamUp, but without any physics interactions
NUM_VALUES
.ENDENUM

Expand Down
19 changes: 0 additions & 19 deletions src/actors/bullet.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
.IMPORT FuncA_Actor_HarmAvatarIfCollision
.IMPORT FuncA_Actor_IsInRoomBounds
.IMPORT FuncA_Objects_Draw1x1Actor
.IMPORT FuncA_Room_TurnProjectilesToSmoke
.IMPORT Func_InitActorDefault
.IMPORT Ram_ActorState1_byte_arr
.IMPORT Ram_ActorType_eActor_arr
.IMPORT Ram_ActorVelX_i16_1_arr
.IMPORT Ram_ActorVelY_i16_1_arr
.IMPORTZP Zp_ConsoleMachineIndex_u8

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

Expand Down Expand Up @@ -110,23 +108,6 @@ _Done:

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

.SEGMENT "PRGA_Room"

;;; If the console window is open, turns all bullet projectiles into smoke
;;; particles. If the console window is closed, does nothing. This should be
;;; called from room tick functions in rooms containing minigun machines.
.EXPORT FuncA_Room_RemoveAllBulletsIfConsoleOpen
.PROC FuncA_Room_RemoveAllBulletsIfConsoleOpen
lda Zp_ConsoleMachineIndex_u8
bmi @done
lda #eActor::ProjBullet ; param: projectile type
jmp FuncA_Room_TurnProjectilesToSmoke
@done:
rts
.ENDPROC

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

.SEGMENT "PRGA_Objects"

;;; Draws a bullet projectile actor.
Expand Down
75 changes: 74 additions & 1 deletion src/actors/steam.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
.IMPORTZP Zp_AvatarState_bAvatar
.IMPORTZP Zp_AvatarVelX_i16
.IMPORTZP Zp_AvatarVelY_i16
.IMPORTZP Zp_ConsoleMachineIndex_u8

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

Expand Down Expand Up @@ -78,6 +79,52 @@ kPaletteObjSteam = 0
jmp Func_InitActorDefault ; preserves X and T0+
.ENDPROC

;;; Initializes the specified actor as a horizontal steam smoke.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param A The facing direction (either 0 or bObj::FlipH).
;;; @param X The actor index.
;;; @preserve X, T0+
.EXPORT Func_InitActorSmokeSteamHorz := Func_InitActorProjSteamHorz

;;; Initializes the specified actor as an upward steam smoke.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param X The actor index.
;;; @preserve X, T0+
.EXPORT Func_InitActorSmokeSteamUp := Func_InitActorProjSteamUp

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

.SEGMENT "PRGA_Room"

;;; If the console window is open, turns all steam projectiles into steam
;;; smoke. If the console window is closed, does nothing. This should be
;;; called from room tick functions in rooms containing boiler machines.
.EXPORT FuncA_Room_TurnSteamToSmokeIfConsoleOpen
.PROC FuncA_Room_TurnSteamToSmokeIfConsoleOpen
lda Zp_ConsoleMachineIndex_u8
bmi @done
ldx #kMaxActors - 1
@loop:
lda Ram_ActorType_eActor_arr, x
cmp #eActor::ProjSteamHorz
beq @change
cmp #eActor::ProjSteamUp
bne @continue
@change:
.linecont +
.assert eActor::SmokeSteamHorz - eActor::ProjSteamHorz = \
eActor::SmokeSteamUp - eActor::ProjSteamUp, error
.linecont -
add #eActor::SmokeSteamHorz - eActor::ProjSteamHorz
sta Ram_ActorType_eActor_arr, x
@continue:
dex
.assert kMaxActors <= $80, error
bpl @loop
@done:
rts
.ENDPROC

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

.SEGMENT "PRGA_Actor"
Expand Down Expand Up @@ -141,7 +188,7 @@ kPaletteObjSteam = 0
@noClamp:
sta Zp_AvatarVelY_i16 + 1
@noPush:
.assert * = FuncA_Actor_IncrementSteamAge, error, "fallthrough"
fall FuncA_Actor_IncrementSteamAge ; preserves X
.ENDPROC

;;; Increments the state byte for the specified steam actor, and removes the
Expand Down Expand Up @@ -181,6 +228,16 @@ kPaletteObjSteam = 0
rts
.ENDPROC

;;; Performs per-frame updates for a horizontal steam smoke actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Actor_TickSmokeSteamHorz := FuncA_Actor_IncrementSteamAge

;;; Performs per-frame updates for an upward steam smoke actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Actor_TickSmokeSteamUp := FuncA_Actor_IncrementSteamAge

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

.SEGMENT "PRGA_Objects"
Expand Down Expand Up @@ -211,4 +268,20 @@ kPaletteObjSteam = 0
jmp FuncA_Objects_Draw1x2Actor ; preserves X
.ENDPROC

;;; Draws a horizontal steam smoke actor.
;;; @param X The actor index.
;;; @preserve X
.LINECONT +
.EXPORT FuncA_Objects_DrawActorSmokeSteamHorz := \
FuncA_Objects_DrawActorProjSteamHorz
.LINECONT -

;;; Draws an upward steam smoke actor.
;;; @param X The actor index.
;;; @preserve X
.LINECONT +
.EXPORT FuncA_Objects_DrawActorSmokeSteamUp := \
FuncA_Objects_DrawActorProjSteamUp
.LINECONT -

;;;=========================================================================;;;
3 changes: 2 additions & 1 deletion src/actors/steam.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
;;; with Annalog. If not, see <http://www.gnu.org/licenses/>. ;;;
;;;=========================================================================;;;

;;; State bytes for steam projectiles:
;;; State bytes for steam projectiles/smoke:
;;; * Flags: For horizontal steam, the bObj::FlipH bit is set if the steam is
;;; aimed leftward, or cleared if it is aimed rightward. Unused for upward
;;; steam.
;;; * State1: Counter that starts at zero and increments every frame; when it
;;; reaches kSteamNumFrames, then the steam is removed.
;;; * State2: Unused.
;;; * State3: Unused.
;;; * State4: Unused.

;;; How long a steam actor animates before disappearing, in frames.
kSteamNumFrames = 32
Expand Down
9 changes: 0 additions & 9 deletions src/machines/blaster.asm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
.IMPORT FuncA_Objects_Draw1x1Shape
.IMPORT FuncA_Objects_GetMachineLightTileId
.IMPORT FuncA_Objects_SetShapePosToPlatformTopLeft
.IMPORT FuncA_Room_TurnProjectilesToSmoke
.IMPORT Func_FindEmptyActorSlot
.IMPORT Func_InitActorProjFireblast
.IMPORT Func_IsPointInPlatform
Expand Down Expand Up @@ -229,14 +228,6 @@ _Finish:

.SEGMENT "PRGA_Room"

;;; Reset implemention for blaster machines.
;;; @prereq Zp_MachineIndex_u8 and Zp_Current_sMachine_ptr are initialized.
.EXPORT FuncA_Room_MachineBlasterReset
.PROC FuncA_Room_MachineBlasterReset
lda #eActor::ProjFireblast ; param: projectile type
jmp FuncA_Room_TurnProjectilesToSmoke
.ENDPROC

;;; Checks if any fireblasts are hitting the specified mirror, and if so,
;;; reflects them off of the mirror.
;;; @param A The absolute mirror angle, in increments of tau/16.
Expand Down
4 changes: 1 addition & 3 deletions src/machines/cannon.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
.IMPORT FuncA_Machine_StartWaiting
.IMPORT FuncA_Objects_Alloc2x2MachineShape
.IMPORT FuncA_Objects_GetMachineLightTileId
.IMPORT FuncA_Room_TurnProjectilesToSmoke
.IMPORT Func_FindEmptyActorSlot
.IMPORT Func_InitActorProjGrenade
.IMPORT Ram_ActorPosX_i16_0_arr
Expand Down Expand Up @@ -94,8 +93,7 @@ kTileIdObjCannonBarrelLow = kTileIdObjCannonFirst + $04
ldx Zp_MachineIndex_u8
lda #0
sta Ram_MachineGoalVert_u8_arr, x
lda #eActor::ProjGrenade ; param: projectile type
jmp FuncA_Room_TurnProjectilesToSmoke
rts
.ENDPROC

;;;=========================================================================;;;
Expand Down
14 changes: 12 additions & 2 deletions src/machines/shared.asm
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,19 @@

.SEGMENT "PRGA_Room"

;;; If a machine console window is open, turns all projectile actors of the
;;; specified type into smoke particles. This should generally be called from
;;; a room's Tick function.
;;; @param A The eActor::Proj* value.
;;; @preserve X
.EXPORT FuncA_Room_TurnProjectilesToSmokeIfConsoleOpen
.PROC FuncA_Room_TurnProjectilesToSmokeIfConsoleOpen
ldy Zp_ConsoleMachineIndex_u8
bpl FuncA_Room_TurnProjectilesToSmoke ; preserves X
rts
.ENDPROC

;;; Turns all projectile actors of the specified type into smoke particles.
;;; This should be called from the Reset function of machines that shoot
;;; projectiles.
;;; @param A The eActor::Proj* value.
;;; @preserve X
.EXPORT FuncA_Room_TurnProjectilesToSmoke
Expand Down
9 changes: 7 additions & 2 deletions src/rooms/boss_garden.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
.IMPORT FuncA_Room_ResetLever
.IMPORT FuncA_Room_TickBoss
.IMPORT FuncA_Room_TurnProjectilesToSmoke
.IMPORT FuncA_Room_TurnProjectilesToSmokeIfConsoleOpen
.IMPORT Func_AckIrqAndLatchWindowFromParam4
.IMPORT Func_AckIrqAndSetLatch
.IMPORT Func_DivMod
Expand Down Expand Up @@ -400,6 +401,10 @@ _BossIsAlive:
;;; Room tick function for the BossGarden room.
;;; @prereq PRGA_Room is loaded.
.PROC FuncC_Boss_Garden_TickRoom
_MachineProjectiles:
lda #eActor::ProjGrenade ; param: projectile type
jsr FuncA_Room_TurnProjectilesToSmokeIfConsoleOpen ; preserves X
_Boss:
.assert eBossMode::Dead = 0, error
lda Zp_RoomState + sState::Current_eBossMode ; param: zero if boss is dead
jmp FuncA_Room_TickBoss
Expand Down Expand Up @@ -748,9 +753,9 @@ _HitOpenEye:
lda Zp_RoomState + sState::BossEyeHealth_u8_arr2 + 0
ora Zp_RoomState + sState::BossEyeHealth_u8_arr2 + 1
bne @bossIsStillAlive
lda #eActor::ProjFireball
lda #eActor::ProjFireball ; param: projectile type
jsr FuncA_Room_TurnProjectilesToSmoke ; preserves X
lda #eActor::ProjSpike
lda #eActor::ProjSpike ; param: projectile type
jsr FuncA_Room_TurnProjectilesToSmoke ; preserves X
lda #ePlatform::Zone
sta Ram_PlatformType_ePlatform_arr + kThornsPlatformIndex
Expand Down
Loading

0 comments on commit b1623db

Please sign in to comment.