diff --git a/src/actor.asm b/src/actor.asm index b448c343..b774f2d3 100644 --- a/src/actor.asm +++ b/src/actor.asm @@ -78,6 +78,7 @@ .IMPORT FuncA_Actor_TickSmokeExplosion .IMPORT FuncA_Actor_TickSmokeFragment .IMPORT FuncA_Actor_TickSmokeParticle +.IMPORT FuncA_Actor_TickSmokeRaindrop .IMPORT FuncA_Actor_TickSmokeSteamHorz .IMPORT FuncA_Actor_TickSmokeSteamUp .IMPORT FuncA_Actor_TickSmokeWaterfall @@ -138,6 +139,7 @@ .IMPORT FuncA_Objects_DrawActorSmokeExplosion .IMPORT FuncA_Objects_DrawActorSmokeFragment .IMPORT FuncA_Objects_DrawActorSmokeParticle +.IMPORT FuncA_Objects_DrawActorSmokeRaindrop .IMPORT FuncA_Objects_DrawActorSmokeSteamHorz .IMPORT FuncA_Objects_DrawActorSmokeSteamUp .IMPORT FuncA_Objects_DrawActorSmokeWaterfall @@ -157,6 +159,7 @@ .IMPORT FuncA_Room_InitActorProjSpine .IMPORT FuncA_Room_InitActorSmokeBlood .IMPORT FuncA_Room_InitActorSmokeDirt +.IMPORT FuncA_Room_InitActorSmokeRaindrop .IMPORT FuncA_Room_InitActorSmokeWaterfall .IMPORT Func_InitActorBadGronta .IMPORT Func_InitActorBadOrc @@ -549,6 +552,7 @@ _NoHit: d_byte SmokeExplosion, kSmokeExplosionRadius d_byte SmokeFragment, kSmokeFragmentRadius d_byte SmokeParticle, kSmokeParticleRadius + d_byte SmokeRaindrop, 2 d_byte SmokeSteamHorz, kSteamMinorRadius d_byte SmokeSteamUp, kSteamMajorRadius d_byte SmokeWaterfall, 0 @@ -615,6 +619,7 @@ _NoHit: d_byte SmokeExplosion, kSmokeExplosionRadius d_byte SmokeFragment, kSmokeFragmentRadius d_byte SmokeParticle, kSmokeParticleRadius + d_byte SmokeRaindrop, 2 d_byte SmokeSteamHorz, kSteamMinorRadius d_byte SmokeSteamUp, kSteamMajorRadius d_byte SmokeWaterfall, 8 @@ -681,6 +686,7 @@ _NoHit: d_byte SmokeExplosion, kSmokeExplosionRadius d_byte SmokeFragment, kSmokeFragmentRadius d_byte SmokeParticle, kSmokeParticleRadius + d_byte SmokeRaindrop, 1 d_byte SmokeSteamHorz, kSteamMajorRadius d_byte SmokeSteamUp, kSteamMinorRadius d_byte SmokeWaterfall, 4 @@ -815,6 +821,7 @@ _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, SmokeRaindrop, FuncA_Actor_TickSmokeRaindrop d_entry table, SmokeSteamHorz, FuncA_Actor_TickSmokeSteamHorz d_entry table, SmokeSteamUp, FuncA_Actor_TickSmokeSteamUp d_entry table, SmokeWaterfall, FuncA_Actor_TickSmokeWaterfall @@ -986,6 +993,7 @@ _Finish: d_entry table, SmokeExplosion, Func_InitActorSmokeExplosion d_entry table, SmokeFragment, Func_InitActorSmokeFragment d_entry table, SmokeParticle, Func_InitActorSmokeParticle + d_entry table, SmokeRaindrop, FuncA_Room_InitActorSmokeRaindrop d_entry table, SmokeSteamHorz, Func_InitActorSmokeSteamHorz d_entry table, SmokeSteamUp, Func_InitActorSmokeSteamUp d_entry table, SmokeWaterfall, FuncA_Room_InitActorSmokeWaterfall @@ -1081,6 +1089,7 @@ _Finish: d_entry table, SmokeExplosion, FuncA_Objects_DrawActorSmokeExplosion d_entry table, SmokeFragment, FuncA_Objects_DrawActorSmokeFragment d_entry table, SmokeParticle, FuncA_Objects_DrawActorSmokeParticle + d_entry table, SmokeRaindrop, FuncA_Objects_DrawActorSmokeRaindrop d_entry table, SmokeSteamHorz, FuncA_Objects_DrawActorSmokeSteamHorz d_entry table, SmokeSteamUp, FuncA_Objects_DrawActorSmokeSteamUp d_entry table, SmokeWaterfall, FuncA_Objects_DrawActorSmokeWaterfall diff --git a/src/actor.inc b/src/actor.inc index 4eedd6a6..b6c0a624 100644 --- a/src/actor.inc +++ b/src/actor.inc @@ -83,6 +83,7 @@ kMaxActors = 16 SmokeExplosion ; a puff of smoke for when something explodes SmokeFragment ; a fragment that falls under gravity SmokeParticle ; a single particle of smoke + SmokeRaindrop ; a falling drop of water SmokeSteamHorz ; like ProjSteamHorz, but without any physics interactions SmokeSteamUp ; like ProjSteamUp, but without any physics interactions SmokeWaterfall ; pours out of a water pipe diff --git a/src/actors/lavaball.inc b/src/actors/lavaball.inc index e65ebf60..9617bde1 100644 --- a/src/actors/lavaball.inc +++ b/src/actors/lavaball.inc @@ -31,6 +31,6 @@ kLavaballStartYShort = $d4 kLavaballStartYTall = $164 ;;; Tile IDs for drawing lavaball baddie actors. -kTileIdObjBadLavaballFirst = $b0 +kTileIdObjBadLavaballFirst = $90 ;;;=========================================================================;;; diff --git a/src/actors/raindrop.asm b/src/actors/raindrop.asm new file mode 100644 index 00000000..56fe5a84 --- /dev/null +++ b/src/actors/raindrop.asm @@ -0,0 +1,97 @@ +;;;=========================================================================;;; +;;; 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 "raindrop.inc" + +.IMPORT FuncA_Actor_ApplyGravityWithTerminalVelocity +.IMPORT FuncA_Actor_CenterHitsTerrain +.IMPORT FuncA_Actor_IsInRoomBounds +.IMPORT FuncA_Objects_Draw1x1Actor +.IMPORT Func_InitActorDefault +.IMPORT Func_InitActorSmokeParticle +.IMPORT Ram_ActorState1_byte_arr +.IMPORT Ram_ActorType_eActor_arr + +;;;=========================================================================;;; + +;;; The maximum downward speed of a falling raindrop smoke, in pixels per +;;; frame. +kRaindropTerminalVelocity = 4 + +;;; The OBJ palette number used for raindrop smoke actors. +kPaletteObjRaindrop = 0 + +;;;=========================================================================;;; + +.SEGMENT "PRGA_Room" + +;;; Initializes the specified actor as a raindrop smoke. +;;; @prereq The actor's pixel position has already been initialized. +;;; @param X The actor index. +;;; @preserve X, T0+ +.EXPORT FuncA_Room_InitActorSmokeRaindrop +.PROC FuncA_Room_InitActorSmokeRaindrop + ldy #eActor::SmokeRaindrop ; param: actor type + jmp Func_InitActorDefault ; preserves X and T0+ +.ENDPROC + +;;;=========================================================================;;; + +.SEGMENT "PRGA_Actor" + +;;; Performs per-frame updates for a raindrop smoke actor. +;;; @param X The actor index. +;;; @preserve X +.EXPORT FuncA_Actor_TickSmokeRaindrop +.PROC FuncA_Actor_TickSmokeRaindrop + inc Ram_ActorState1_byte_arr, x ; expiration timer + beq _Expire + jsr FuncA_Actor_IsInRoomBounds ; preserves X, returns C + bcc _Expire + jsr FuncA_Actor_CenterHitsTerrain ; preserves X, returns C + bcs _Evaporate + lda #kRaindropTerminalVelocity ; param: terminal velocity + jmp FuncA_Actor_ApplyGravityWithTerminalVelocity ; preserves X +_Expire: + lda #eActor::None + sta Ram_ActorType_eActor_arr, x + rts +_Evaporate: + lda #$c0 ; param: angle ($c0 = up) + jmp Func_InitActorSmokeParticle +.ENDPROC + +;;;=========================================================================;;; + +.SEGMENT "PRGA_Objects" + +;;; Draws a raindrop smoke actor. +;;; @param X The actor index. +;;; @preserve X +.EXPORT FuncA_Objects_DrawActorSmokeRaindrop +.PROC FuncA_Objects_DrawActorSmokeRaindrop + ldy #kPaletteObjRaindrop ; param: object flags + lda #kTileIdObjRaindrop ; param: tile ID + jmp FuncA_Objects_Draw1x1Actor ; preserves X +.ENDPROC + +;;;=========================================================================;;; diff --git a/src/actors/raindrop.inc b/src/actors/raindrop.inc new file mode 100644 index 00000000..ed3ecede --- /dev/null +++ b/src/actors/raindrop.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 raindrop smoke: +;;; * Flags: Unused. +;;; * State1: Counter that starts at zero and increments every frame; if it +;;; wraps back around to zero before the raindrop hits the floor, then the +;;; raindrop is removed. +;;; * State2: Unused. +;;; * State3: Unused. +;;; * State4: Unused. + +kTileIdObjRaindrop = $b7 + +;;;=========================================================================;;; diff --git a/src/chr.asm b/src/chr.asm index f5ec9d73..e0b8d842 100644 --- a/src/chr.asm +++ b/src/chr.asm @@ -44,6 +44,7 @@ .INCLUDE "actors/lavaball.inc" .INCLUDE "actors/orc.inc" .INCLUDE "actors/queen.inc" +.INCLUDE "actors/raindrop.inc" .INCLUDE "actors/rhino.inc" .INCLUDE "actors/rodent.inc" .INCLUDE "actors/slime.inc" @@ -1322,13 +1323,15 @@ _chr_begin: chr_res $03 chr_inc "upgrade_opcopy", kTileIdObjUpgradeOpCopyFirst chr_inc "boiler_flame", kTileIdObjBoilerFlameFirst - chr_res $0a + chr_res $02 + chr_inc "bad_lavaball", kTileIdObjBadLavaballFirst chr_inc "blaster", kTileIdObjBlasterFirst chr_res $01 chr_inc "fireblast", kTileIdObjFireblastFirst chr_res $04 chr_inc "bad_hothead", kTileIdObjBadHotheadFirst - chr_inc "bad_lavaball", kTileIdObjBadLavaballFirst + chr_res $07 + chr_inc "raindrop", kTileIdObjRaindrop chr_inc "anchor", kTileIdObjAnchorFirst chr_inc "valve", kTileIdObjValveFirst chr_res $08 @@ -1418,7 +1421,8 @@ _chr_begin: chr_res $02 chr_inc "bad_grub", kTileIdObjBadGrubFirst chr_inc "bad_slime", kTileIdObjBadSlimeFirst - chr_res $0a + chr_res $09 + chr_inc "raindrop", kTileIdObjRaindrop chr_inc "bad_toad", kTileIdObjBadToadFirst chr_inc "bad_bird", kTileIdObjBadBirdFirst chr_inc "bad_crab", kTileIdObjBadCrabFirst diff --git a/src/flag.inc b/src/flag.inc index 37640f51..a14339dc 100644 --- a/src/flag.inc +++ b/src/flag.inc @@ -164,6 +164,7 @@ kSaveMagicNumber = $b2 LavaCenterChain1Broken LavaCenterChain2Broken LavaCenterChain3Broken + LavaWestDroppedIn MermaidHut1AlexPetition MermaidHut1MetQueen MermaidHut4MetFlorist diff --git a/src/newgame.asm b/src/newgame.asm index 7d04a530..17d1f360 100644 --- a/src/newgame.asm +++ b/src/newgame.asm @@ -297,6 +297,7 @@ _SetFlags: .byte eFlag::FlowerGarden .byte eFlag::MermaidSpringConsoleFixed .byte eFlag::MermaidSpringUnplugged + .byte eFlag::LavaWestDroppedIn .byte eFlag::UpgradeOpCopy .byte eFlag::PaperManual3 .byte eFlag::PaperJerome10 diff --git a/src/rooms/lava_west.asm b/src/rooms/lava_west.asm index de7b16c0..ddef2f91 100644 --- a/src/rooms/lava_west.asm +++ b/src/rooms/lava_west.asm @@ -42,18 +42,25 @@ .IMPORT FuncA_Objects_AnimateLavaTerrain .IMPORT FuncA_Objects_DrawBoilerMachine .IMPORT FuncA_Objects_DrawBoilerValve +.IMPORT FuncA_Room_InitActorSmokeRaindrop .IMPORT FuncA_Room_MachineBoilerReset .IMPORT FuncA_Room_ResetLever .IMPORT FuncA_Room_TurnSteamToSmokeIfConsoleOpen .IMPORT FuncA_Terrain_FadeInTallRoomWithLava .IMPORT Func_DistanceSensorRightDetectPoint .IMPORT Func_EmitSteamUpFromPipe +.IMPORT Func_FindEmptyActorSlot .IMPORT Func_MachineBoilerReadReg .IMPORT Func_MarkMinimap .IMPORT Func_Noop +.IMPORT Func_SetActorCenterToPoint +.IMPORT Func_SetFlag .IMPORT Func_SetPointToAvatarCenter .IMPORT Ppu_ChrObjLava +.IMPORT Ram_ActorVelY_i16_1_arr .IMPORT Ram_MachineGoalHorz_u8_arr +.IMPORTZP Zp_PointX_i16 +.IMPORTZP Zp_PointY_i16 .IMPORTZP Zp_RoomState ;;;=========================================================================;;; @@ -346,12 +353,42 @@ _ReadD: ;; If the player avatar didn't enter from the shaft, do nothing. cmp #bSpawn::Passage | kShaftPassageIndex bne @done + ;; Set the flag indicating that the player entered the lava pits. + ldx #eFlag::LavaWestDroppedIn ; param: flag + jsr Func_SetFlag ; sets C if flag was already set + bcs @doneRaindrops + ;; The first time the player avatar drops in from the shaft, have some + ;; water droplets fall in too. + lda #0 + sta Zp_PointX_i16 + 1 + sta Zp_PointY_i16 + 1 + ldy #3 + @loop: + lda _RaindropPosX_u8_arr, y + sta Zp_PointX_i16 + 0 + lda _RaindropPosY_u8_arr, y + sta Zp_PointY_i16 + 0 + jsr Func_FindEmptyActorSlot ; preserves Y, returns C and X + bcs @doneRaindrops ; no more actor slots available + jsr Func_SetActorCenterToPoint ; preserves X and Y + sty T0 ; loop index + jsr FuncA_Room_InitActorSmokeRaindrop ; preserves X and T0+ + ldy T0 ; loop index + lda #2 + sta Ram_ActorVelY_i16_1_arr, x + dey + bpl @loop + @doneRaindrops: ;; Mark the bottom minimap cell of the shaft as explored. lda #kShaftMinimapCol ; param: minimap col ldy #kShaftMinimapBottomRow ; param: minimap row jmp Func_MarkMinimap @done: rts +_RaindropPosX_u8_arr: + .byte $73, $85, $8d, $7c +_RaindropPosY_u8_arr: + .byte $08, $01, $0f, $1c .ENDPROC .PROC FuncA_Room_LavaWestBoiler_Reset diff --git a/src/rooms/mermaid_spring.asm b/src/rooms/mermaid_spring.asm index 96496e32..b1e68c79 100644 --- a/src/rooms/mermaid_spring.asm +++ b/src/rooms/mermaid_spring.asm @@ -57,6 +57,7 @@ .IMPORT FuncA_Objects_MoveShapeRightByA .IMPORT FuncA_Objects_MoveShapeRightOneTile .IMPORT FuncA_Objects_SetShapePosToPlatformTopLeft +.IMPORT FuncA_Room_InitActorSmokeRaindrop .IMPORT Func_FindEmptyActorSlot .IMPORT Func_InitActorSmokeExplosion .IMPORT Func_MovePlatformLeftTowardPointX @@ -70,6 +71,7 @@ .IMPORT Func_ShakeRoom .IMPORT Ppu_ChrObjSewer .IMPORT Ram_ActorType_eActor_arr +.IMPORT Ram_ActorVelY_i16_0_arr .IMPORT Ram_DeviceType_eDevice_arr .IMPORT Ram_MachineGoalVert_u8_arr .IMPORT Ram_MachineStatus_eMachine_arr @@ -436,7 +438,26 @@ _RemoveRocksAndWater: lda #30 ; param: num frames jsr Func_ShakeRoom _AnimateFallingWater: - ;; TODO: start animating falling water + lda #0 + sta Zp_PointX_i16 + 1 + sta Zp_PointY_i16 + 1 + lda #$f6 + sta Zp_PointY_i16 + 0 + ldy #3 + @loop: + lda _RaindropPosX_u8_arr, y + sta Zp_PointX_i16 + 0 + jsr Func_FindEmptyActorSlot ; preserves Y, returns C and X + bcs @done ; no more actor slots available + jsr Func_SetActorCenterToPoint ; preserves X and Y + sty T0 ; loop index + jsr FuncA_Room_InitActorSmokeRaindrop ; preserves X and T0+ + ldy T0 ; loop index + lda _RaindropVelY_u8_arr, y + sta Ram_ActorVelY_i16_0_arr, x + dey + bpl @loop + @done: _AnimateExplodingRocks: ldy #kRocksPlatformIndex ; param: platform index jsr Func_SetPointToPlatformCenter @@ -452,6 +473,10 @@ _SpawnExplosionAtPoint: jmp Func_InitActorSmokeExplosion @done: rts +_RaindropPosX_u8_arr: + .byte $74, $84, $8c, $7c +_RaindropVelY_u8_arr: + .byte $20, $00, $40, $80 .ENDPROC ;;;=========================================================================;;; diff --git a/src/tiles/raindrop.ahi b/src/tiles/raindrop.ahi new file mode 100644 index 00000000..99bb0cc5 --- /dev/null +++ b/src/tiles/raindrop.ahi @@ -0,0 +1,12 @@ +ahi1 f0 p1 i1 w8 h8 + +0008;0;54;ECEEEC;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0 + +00020000 +00020000 +02030000 +02030020 +03000020 +03000030 +00000030 +00000000