From f5c8bcb9f9054447ad24ffed7603960e3aa6bd83 Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Tue, 26 Mar 2024 19:08:51 -0400 Subject: [PATCH] Make mine boss spray dirt when emerging --- src/actor.asm | 10 +++ src/actor.inc | 1 + src/actors/blood.asm | 2 +- src/actors/blood.inc | 3 - src/actors/dirt.asm | 111 ++++++++++++++++++++++++++++++ src/actors/dirt.inc | 31 +++++++++ src/chr.asm | 4 +- src/rooms/boss_lava.asm | 6 +- src/rooms/boss_mine.asm | 20 +++++- src/rooms/boss_temple.asm | 3 +- src/tiles/{blood.ahi => dirt.ahi} | 0 11 files changed, 180 insertions(+), 11 deletions(-) create mode 100644 src/actors/dirt.asm create mode 100644 src/actors/dirt.inc rename src/tiles/{blood.ahi => dirt.ahi} (100%) diff --git a/src/actor.asm b/src/actor.asm index b542f427..fc868796 100644 --- a/src/actor.asm +++ b/src/actor.asm @@ -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 @@ -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 @@ -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 @@ -173,6 +176,7 @@ kProjRocketRadius = 2 kProjSpikeRadius = 3 kProjSpineRadius = 1 kSmokeBloodRadius = 1 +kSmokeDirtRadius = 1 kSmokeExplosionRadius = 6 kSmokeFragmentRadius = 1 kSmokeParticleRadius = 1 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/actor.inc b/src/actor.inc index 4531844d..1e1776a1 100644 --- a/src/actor.inc +++ b/src/actor.inc @@ -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 diff --git a/src/actors/blood.asm b/src/actors/blood.asm index dfc2ddcd..c6b65225 100644 --- a/src/actors/blood.asm +++ b/src/actors/blood.asm @@ -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 diff --git a/src/actors/blood.inc b/src/actors/blood.inc index 2a3a5212..0928a0d9 100644 --- a/src/actors/blood.inc +++ b/src/actors/blood.inc @@ -26,7 +26,4 @@ ;;; * State3: Unused. ;;; * State4: Unused. -;;; Tile IDs for drawing blood smoke actors. -kTileIdObjBloodFirst = $a9 - ;;;=========================================================================;;; diff --git a/src/actors/dirt.asm b/src/actors/dirt.asm new file mode 100644 index 00000000..79f81951 --- /dev/null +++ b/src/actors/dirt.asm @@ -0,0 +1,111 @@ +;;;=========================================================================;;; +;;; Copyright 2022 Matthew D. Steele ;;; +;;; ;;; +;;; 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 . ;;; +;;;=========================================================================;;; + +.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 + +;;;=========================================================================;;; diff --git a/src/actors/dirt.inc b/src/actors/dirt.inc new file mode 100644 index 00000000..d1b5d8df --- /dev/null +++ b/src/actors/dirt.inc @@ -0,0 +1,31 @@ +;;;=========================================================================;;; +;;; Copyright 2022 Matthew D. Steele ;;; +;;; ;;; +;;; 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 . ;;; +;;;=========================================================================;;; + +;;; 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 + +;;;=========================================================================;;; diff --git a/src/chr.asm b/src/chr.asm index 233368f0..0748fd7e 100644 --- a/src/chr.asm +++ b/src/chr.asm @@ -21,7 +21,6 @@ .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" @@ -29,6 +28,7 @@ .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" @@ -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 diff --git a/src/rooms/boss_lava.asm b/src/rooms/boss_lava.asm index a1cd6230..53f75c75 100644 --- a/src/rooms/boss_lava.asm +++ b/src/rooms/boss_lava.asm @@ -18,7 +18,7 @@ ;;;=========================================================================;;; .INCLUDE "../actor.inc" -.INCLUDE "../actors/blood.inc" +.INCLUDE "../actors/dirt.inc" .INCLUDE "../boss.inc" .INCLUDE "../charmap.inc" .INCLUDE "../device.inc" @@ -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 diff --git a/src/rooms/boss_mine.asm b/src/rooms/boss_mine.asm index ed0f3fe3..f2da3435 100644 --- a/src/rooms/boss_mine.asm +++ b/src/rooms/boss_mine.asm @@ -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 @@ -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 @@ -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 diff --git a/src/rooms/boss_temple.asm b/src/rooms/boss_temple.asm index 48e7d303..fd298207 100644 --- a/src/rooms/boss_temple.asm +++ b/src/rooms/boss_temple.asm @@ -18,7 +18,7 @@ ;;;=========================================================================;;; .INCLUDE "../actor.inc" -.INCLUDE "../actors/blood.inc" +.INCLUDE "../actors/dirt.inc" .INCLUDE "../audio.inc" .INCLUDE "../boss.inc" .INCLUDE "../charmap.inc" @@ -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 diff --git a/src/tiles/blood.ahi b/src/tiles/dirt.ahi similarity index 100% rename from src/tiles/blood.ahi rename to src/tiles/dirt.ahi