Skip to content

Commit

Permalink
Make mine boss spray dirt when emerging
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Mar 26, 2024
1 parent 381f61a commit f5c8bcb
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/actor.asm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
.IMPORT FuncA_Actor_TickProjSteamHorz
.IMPORT FuncA_Actor_TickProjSteamUp
.IMPORT FuncA_Actor_TickSmokeBlood
.IMPORT FuncA_Actor_TickSmokeDirt
.IMPORT FuncA_Actor_TickSmokeExplosion
.IMPORT FuncA_Actor_TickSmokeFragment
.IMPORT FuncA_Actor_TickSmokeParticle
Expand Down Expand Up @@ -116,6 +117,7 @@
.IMPORT FuncA_Objects_DrawActorProjSteamHorz
.IMPORT FuncA_Objects_DrawActorProjSteamUp
.IMPORT FuncA_Objects_DrawActorSmokeBlood
.IMPORT FuncA_Objects_DrawActorSmokeDirt
.IMPORT FuncA_Objects_DrawActorSmokeExplosion
.IMPORT FuncA_Objects_DrawActorSmokeFragment
.IMPORT FuncA_Objects_DrawActorSmokeParticle
Expand All @@ -134,6 +136,7 @@
.IMPORT FuncA_Room_InitActorProjFlamestrike
.IMPORT FuncA_Room_InitActorProjSpine
.IMPORT FuncA_Room_InitActorSmokeBlood
.IMPORT FuncA_Room_InitActorSmokeDirt
.IMPORT Func_InitActorBadGronta
.IMPORT Func_InitActorBadOrc
.IMPORT Func_InitActorNpcOrc
Expand Down Expand Up @@ -173,6 +176,7 @@ kProjRocketRadius = 2
kProjSpikeRadius = 3
kProjSpineRadius = 1
kSmokeBloodRadius = 1
kSmokeDirtRadius = 1
kSmokeExplosionRadius = 6
kSmokeFragmentRadius = 1
kSmokeParticleRadius = 1
Expand Down Expand Up @@ -509,6 +513,7 @@ _NoHit:
d_byte ProjSteamHorz, kSteamMinorRadius
d_byte ProjSteamUp, kSteamMajorRadius
d_byte SmokeBlood, kSmokeBloodRadius
d_byte SmokeDirt, kSmokeDirtRadius
d_byte SmokeExplosion, kSmokeExplosionRadius
d_byte SmokeFragment, kSmokeFragmentRadius
d_byte SmokeParticle, kSmokeParticleRadius
Expand Down Expand Up @@ -565,6 +570,7 @@ _NoHit:
d_byte ProjSteamHorz, kSteamMinorRadius
d_byte ProjSteamUp, kSteamMajorRadius
d_byte SmokeBlood, kSmokeBloodRadius
d_byte SmokeDirt, kSmokeDirtRadius
d_byte SmokeExplosion, kSmokeExplosionRadius
d_byte SmokeFragment, kSmokeFragmentRadius
d_byte SmokeParticle, kSmokeParticleRadius
Expand Down Expand Up @@ -621,6 +627,7 @@ _NoHit:
d_byte ProjSteamHorz, kSteamMajorRadius
d_byte ProjSteamUp, kSteamMinorRadius
d_byte SmokeBlood, kSmokeBloodRadius
d_byte SmokeDirt, kSmokeDirtRadius
d_byte SmokeExplosion, kSmokeExplosionRadius
d_byte SmokeFragment, kSmokeFragmentRadius
d_byte SmokeParticle, kSmokeParticleRadius
Expand Down Expand Up @@ -745,6 +752,7 @@ _TypeSpecificTick:
d_entry table, ProjSteamHorz, FuncA_Actor_TickProjSteamHorz
d_entry table, ProjSteamUp, FuncA_Actor_TickProjSteamUp
d_entry table, SmokeBlood, FuncA_Actor_TickSmokeBlood
d_entry table, SmokeDirt, FuncA_Actor_TickSmokeDirt
d_entry table, SmokeExplosion, FuncA_Actor_TickSmokeExplosion
d_entry table, SmokeFragment, FuncA_Actor_TickSmokeFragment
d_entry table, SmokeParticle, FuncA_Actor_TickSmokeParticle
Expand Down Expand Up @@ -854,6 +862,7 @@ _CheckVert:
d_entry table, ProjSteamHorz, Func_InitActorProjSteamHorz
d_entry table, ProjSteamUp, Func_InitActorProjSteamUp
d_entry table, SmokeBlood, FuncA_Room_InitActorSmokeBlood
d_entry table, SmokeDirt, FuncA_Room_InitActorSmokeDirt
d_entry table, SmokeExplosion, Func_InitActorSmokeExplosion
d_entry table, SmokeFragment, Func_InitActorSmokeFragment
d_entry table, SmokeParticle, Func_InitActorSmokeParticle
Expand Down Expand Up @@ -939,6 +948,7 @@ _CheckVert:
d_entry table, ProjSteamHorz, FuncA_Objects_DrawActorProjSteamHorz
d_entry table, ProjSteamUp, FuncA_Objects_DrawActorProjSteamUp
d_entry table, SmokeBlood, FuncA_Objects_DrawActorSmokeBlood
d_entry table, SmokeDirt, FuncA_Objects_DrawActorSmokeDirt
d_entry table, SmokeExplosion, FuncA_Objects_DrawActorSmokeExplosion
d_entry table, SmokeFragment, FuncA_Objects_DrawActorSmokeFragment
d_entry table, SmokeParticle, FuncA_Objects_DrawActorSmokeParticle
Expand Down
1 change: 1 addition & 0 deletions src/actor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ kMaxActors = 16
ProjSteamHorz ; emitted horizontally from boiler machine pipes
ProjSteamUp ; emitted vertically from boiler machine pipes
SmokeBlood ; a glob of blood from the temple boss
SmokeDirt ; a clump of dirt from the mine boss
SmokeExplosion ; a puff of smoke for when something explodes
SmokeFragment ; a fragment that falls under gravity
SmokeParticle ; a single particle of smoke
Expand Down
2 changes: 1 addition & 1 deletion src/actors/blood.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.INCLUDE "../actor.inc"
.INCLUDE "../macros.inc"
.INCLUDE "../oam.inc"
.INCLUDE "blood.inc"
.INCLUDE "dirt.inc"

.IMPORT FuncA_Actor_ApplyGravity
.IMPORT FuncA_Objects_Draw1x1Actor
Expand Down
3 changes: 0 additions & 3 deletions src/actors/blood.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@
;;; * State3: Unused.
;;; * State4: Unused.

;;; Tile IDs for drawing blood smoke actors.
kTileIdObjBloodFirst = $a9

;;;=========================================================================;;;
111 changes: 111 additions & 0 deletions src/actors/dirt.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
;;;=========================================================================;;;
;;; Copyright 2022 Matthew D. Steele <[email protected]> ;;;
;;; ;;;
;;; This file is part of Annalog. ;;;
;;; ;;;
;;; Annalog is free software: you can redistribute it and/or modify it ;;;
;;; under the terms of the GNU General Public License as published by the ;;;
;;; Free Software Foundation, either version 3 of the License, or (at your ;;;
;;; option) any later version. ;;;
;;; ;;;
;;; Annalog is distributed in the hope that it will be useful, but WITHOUT ;;;
;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ;;;
;;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ;;;
;;; for more details. ;;;
;;; ;;;
;;; You should have received a copy of the GNU General Public License along ;;;
;;; with Annalog. If not, see <http://www.gnu.org/licenses/>. ;;;
;;;=========================================================================;;;

.INCLUDE "../actor.inc"
.INCLUDE "../macros.inc"
.INCLUDE "../oam.inc"
.INCLUDE "dirt.inc"

.IMPORT FuncA_Actor_ApplyGravity
.IMPORT FuncA_Objects_Draw1x1Actor
.IMPORT Func_InitActorDefault
.IMPORT Func_SetActorVelocityPolar
.IMPORT Ram_ActorState1_byte_arr
.IMPORT Ram_ActorType_eActor_arr

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

;;; The speed of a dirt smoke, in half-pixels per frame.
kDirtSpeed = 6

;;; How many frames a dirt smoke lasts before being removed.
kDirtMaxAge = 36

;;; The OBJ palette number used for dirt smoke actors.
kPaletteObjDirt = 0

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

.SEGMENT "PRGA_Room"

;;; Initializes the specified actor as a dirt smoke.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param A The angle to move at, measured in increments of tau/256.
;;; @param X The actor index.
;;; @preserve X, T3+
.EXPORT FuncA_Room_InitActorSmokeDirt
.PROC FuncA_Room_InitActorSmokeDirt
pha ; angle
ldy #eActor::SmokeDirt ; param: actor type
jsr Func_InitActorDefault ; preserves X and T0+
ldy #kDirtSpeed ; param: speed
pla ; param: angle
jmp Func_SetActorVelocityPolar ; preserves X and T3+
.ENDPROC

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

.SEGMENT "PRGA_Actor"

;;; Performs per-frame updates for a dirt smoke actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Actor_TickSmokeDirt
.PROC FuncA_Actor_TickSmokeDirt
inc Ram_ActorState1_byte_arr, x ; expiration timer
lda Ram_ActorState1_byte_arr, x ; expiration timer
cmp #kDirtMaxAge
bge _Expire
jmp FuncA_Actor_ApplyGravity ; preserves X
_Expire:
lda #eActor::None
sta Ram_ActorType_eActor_arr, x
rts
.ENDPROC

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

.SEGMENT "PRGA_Objects"

;;; Draws a dirt smoke actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Objects_DrawActorSmokeDirt
.PROC FuncA_Objects_DrawActorSmokeDirt
lda Ram_ActorState1_byte_arr, x ; expiration timer
pha ; expiration timer
and #$18
.assert bObj::FlipV = $80, error
.assert bObj::FlipH = $40, error
mul #8
ora #kPaletteObjDirt
tay ; param: object flags
pla ; expiration timer
cmp #kDirtMaxAge * 2 / 3
blt @big
@small:
lda #kTileIdObjDirtFirst + 1 ; param: tile ID
bne @draw ; unconditional
@big:
lda #kTileIdObjDirtFirst + 0 ; param: tile ID
@draw:
jmp FuncA_Objects_Draw1x1Actor ; preserves X
.ENDPROC

;;;=========================================================================;;;
31 changes: 31 additions & 0 deletions src/actors/dirt.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;;;=========================================================================;;;
;;; Copyright 2022 Matthew D. Steele <[email protected]> ;;;
;;; ;;;
;;; This file is part of Annalog. ;;;
;;; ;;;
;;; Annalog is free software: you can redistribute it and/or modify it ;;;
;;; under the terms of the GNU General Public License as published by the ;;;
;;; Free Software Foundation, either version 3 of the License, or (at your ;;;
;;; option) any later version. ;;;
;;; ;;;
;;; Annalog is distributed in the hope that it will be useful, but WITHOUT ;;;
;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ;;;
;;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ;;;
;;; for more details. ;;;
;;; ;;;
;;; You should have received a copy of the GNU General Public License along ;;;
;;; with Annalog. If not, see <http://www.gnu.org/licenses/>. ;;;
;;;=========================================================================;;;

;;; State bytes for dirt smoke:
;;; * Flags: Unused.
;;; * State1: Counter that starts at zero and increments every frame; once it
;;; ticks high enough, the dirt is removed.
;;; * State2: Unused.
;;; * State3: Unused.
;;; * State4: Unused.

;;; Tile IDs for drawing dirt smoke actors.
kTileIdObjDirtFirst = $a9

;;;=========================================================================;;;
4 changes: 2 additions & 2 deletions src/chr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
.INCLUDE "actors/axe.inc"
.INCLUDE "actors/bat.inc"
.INCLUDE "actors/bird.inc"
.INCLUDE "actors/blood.inc"
.INCLUDE "actors/breakball.inc"
.INCLUDE "actors/breakbomb.inc"
.INCLUDE "actors/breakfire.inc"
.INCLUDE "actors/bullet.inc"
.INCLUDE "actors/child.inc"
.INCLUDE "actors/crab.inc"
.INCLUDE "actors/crawler.inc"
.INCLUDE "actors/dirt.inc"
.INCLUDE "actors/ember.inc"
.INCLUDE "actors/fireball.inc"
.INCLUDE "actors/firefly.inc"
Expand Down Expand Up @@ -1113,7 +1113,7 @@ _chr_begin:
chr_inc "fireblast", kTileIdObjFireblastFirst
chr_inc "platform_city_walls", kTileIdObjPlatformCityWalls
chr_inc "outbreak_obj", kTileIdObjOutbreakFirst
chr_inc "blood", kTileIdObjBloodFirst
chr_inc "dirt", kTileIdObjDirtFirst
chr_inc "breakfire", kTileIdObjBreakfireFirst
chr_inc "crane", kTileIdObjCraneFirst
chr_inc "proj_spine", kTileIdObjProjSpineFirst
Expand Down
6 changes: 3 additions & 3 deletions src/rooms/boss_lava.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;;;=========================================================================;;;

.INCLUDE "../actor.inc"
.INCLUDE "../actors/blood.inc"
.INCLUDE "../actors/dirt.inc"
.INCLUDE "../boss.inc"
.INCLUDE "../charmap.inc"
.INCLUDE "../device.inc"
Expand Down Expand Up @@ -806,14 +806,14 @@ _DrawBgRocks:
jsr FuncA_Objects_MoveShapeRightByA
lda #$10 ; param: offset
jsr FuncA_Objects_MoveShapeDownByA
lda #kTileIdObjBloodFirst + 0
lda #kTileIdObjDirtFirst + 0
ldy #bObj::Pri ; param: object flags
jsr FuncA_Objects_Draw1x1Shape
lda #$48 ; param: offset
jsr FuncA_Objects_MoveShapeRightByA
lda #$20 ; param: offset
jsr FuncA_Objects_MoveShapeDownByA
lda #kTileIdObjBloodFirst + 1
lda #kTileIdObjDirtFirst + 1
ldy #bObj::Pri ; param: object flags
jmp FuncA_Objects_Draw1x1Shape
.ENDPROC
Expand Down
20 changes: 19 additions & 1 deletion src/rooms/boss_mine.asm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
.IMPORT FuncA_Objects_MoveShapeDownByA
.IMPORT FuncA_Objects_MoveShapeRightByA
.IMPORT FuncA_Objects_SetShapePosToPlatformTopLeft
.IMPORT FuncA_Room_InitActorSmokeDirt
.IMPORT FuncA_Room_InitBoss
.IMPORT FuncA_Room_MachineResetRun
.IMPORT FuncA_Room_TickBoss
Expand Down Expand Up @@ -527,12 +528,29 @@ _BossBurrowing:
inx ; param: eBossLoc::Exit* value
stx Zp_RoomState + sState::Current_eBossLoc
jsr FuncC_Boss_MineTransferExitEmerge
;; Spray dirt from the exit.
ldy #kBossBodyPlatformIndex ; param: platform index
jsr Func_SetPointToPlatformCenter
lda #2
sta T3 ; loop index
@dirtLoop:
jsr Func_FindEmptyActorSlot ; preserves T0+, returns C and X
bcs @dirtDone
jsr Func_SetActorCenterToPoint ; preserves X and T0+
ldy T3 ; loop index
lda _DirtAngle_u8_arr3, y ; param: angle
jsr FuncA_Room_InitActorSmokeDirt ; preserves T3+
dec T3 ; loop index
bpl @dirtLoop
@dirtDone:
;; Start emering from that exit.
;; TODO: play a sound
lda #eBossMode::Emerging
sta Zp_RoomState + sState::Current_eBossMode
lda #kBossEmergeFrames ; param: num frames
jmp Func_ShakeRoom
_DirtAngle_u8_arr3:
.byte $a8, $c4, $d0
_BossEmerging:
lda Zp_RoomState + sState::BossEmerge_u8
cmp #kBossEmergeFrames
Expand Down Expand Up @@ -612,7 +630,7 @@ _ExitTop_u8_arr:
sta T0 ; angle to fire at
jsr Func_FindEmptyActorSlot ; preserves T0+, returns C and X
bcs @done
jsr Func_SetActorCenterToPoint ; preserves T0+
jsr Func_SetActorCenterToPoint ; preserves X and T0+
lda T0 ; param: angle to fire at
jsr Func_InitActorProjFireball
;; TODO: play a sound
Expand Down
3 changes: 2 additions & 1 deletion src/rooms/boss_temple.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
;;;=========================================================================;;;

.INCLUDE "../actor.inc"
.INCLUDE "../actors/blood.inc"
.INCLUDE "../actors/dirt.inc"
.INCLUDE "../audio.inc"
.INCLUDE "../boss.inc"
.INCLUDE "../charmap.inc"
Expand Down Expand Up @@ -211,6 +211,7 @@ kBossStunAnimFrames = 24
kTileIdObjOutbreakBrainFirst = kTileIdObjOutbreakFirst + 0
kTileIdObjOutbreakEyeFirst = kTileIdObjOutbreakFirst + 4
kTileIdObjOutbreakClaw = kTileIdObjOutbreakFirst + 8
kTileIdObjBloodFirst = kTileIdObjDirtFirst

;;; OBJ palette numbers used for drawing the boss.
kPaletteObjOutbreakBrain = 1
Expand Down
File renamed without changes.

0 comments on commit f5c8bcb

Please sign in to comment.