Skip to content

Commit

Permalink
Populate SewerNorth room
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Aug 1, 2024
1 parent 2ab1501 commit 394ce65
Show file tree
Hide file tree
Showing 21 changed files with 823 additions and 70 deletions.
4 changes: 2 additions & 2 deletions build/bg2tset.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ static const struct {
{0xb4, "ropediag"},
{0xa0, "scaffhold"},
{0x60, "sewage_anim0"},
{0x80, "sewer1"},
{0x90, "sewer2"},
{0x90, "sewer1"},
{0xa0, "sewer2"},
{0x80, "steam_pipes"},
{0xb0, "tank"},
{0x80, "temple1"},
Expand Down
9 changes: 9 additions & 0 deletions src/actor.asm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
.IMPORT FuncA_Actor_TickSmokeParticle
.IMPORT FuncA_Actor_TickSmokeSteamHorz
.IMPORT FuncA_Actor_TickSmokeSteamUp
.IMPORT FuncA_Actor_TickSmokeWaterfall
.IMPORT FuncA_Objects_DrawActorBadBat
.IMPORT FuncA_Objects_DrawActorBadBeetleHorz
.IMPORT FuncA_Objects_DrawActorBadBeetleVert
Expand Down Expand Up @@ -139,6 +140,7 @@
.IMPORT FuncA_Objects_DrawActorSmokeParticle
.IMPORT FuncA_Objects_DrawActorSmokeSteamHorz
.IMPORT FuncA_Objects_DrawActorSmokeSteamUp
.IMPORT FuncA_Objects_DrawActorSmokeWaterfall
.IMPORT FuncA_Room_InitActorBadBird
.IMPORT FuncA_Room_InitActorBadFirefly
.IMPORT FuncA_Room_InitActorBadFlydrop
Expand All @@ -155,6 +157,7 @@
.IMPORT FuncA_Room_InitActorProjSpine
.IMPORT FuncA_Room_InitActorSmokeBlood
.IMPORT FuncA_Room_InitActorSmokeDirt
.IMPORT FuncA_Room_InitActorSmokeWaterfall
.IMPORT Func_InitActorBadGronta
.IMPORT Func_InitActorBadOrc
.IMPORT Func_InitActorNpcOrc
Expand Down Expand Up @@ -548,6 +551,7 @@ _NoHit:
d_byte SmokeParticle, kSmokeParticleRadius
d_byte SmokeSteamHorz, kSteamMinorRadius
d_byte SmokeSteamUp, kSteamMajorRadius
d_byte SmokeWaterfall, 0
D_END
.ENDPROC
.PROC DataA_Actor_BoundingBoxDown_u8_arr
Expand Down Expand Up @@ -613,6 +617,7 @@ _NoHit:
d_byte SmokeParticle, kSmokeParticleRadius
d_byte SmokeSteamHorz, kSteamMinorRadius
d_byte SmokeSteamUp, kSteamMajorRadius
d_byte SmokeWaterfall, 8
D_END
.ENDPROC
.PROC DataA_Actor_BoundingBoxSide_u8_arr
Expand Down Expand Up @@ -678,6 +683,7 @@ _NoHit:
d_byte SmokeParticle, kSmokeParticleRadius
d_byte SmokeSteamHorz, kSteamMajorRadius
d_byte SmokeSteamUp, kSteamMinorRadius
d_byte SmokeWaterfall, 4
D_END
.ENDPROC

Expand Down Expand Up @@ -811,6 +817,7 @@ _TypeSpecificTick:
d_entry table, SmokeParticle, FuncA_Actor_TickSmokeParticle
d_entry table, SmokeSteamHorz, FuncA_Actor_TickSmokeSteamHorz
d_entry table, SmokeSteamUp, FuncA_Actor_TickSmokeSteamUp
d_entry table, SmokeWaterfall, FuncA_Actor_TickSmokeWaterfall
D_END
.ENDREPEAT
.ENDPROC
Expand Down Expand Up @@ -981,6 +988,7 @@ _Finish:
d_entry table, SmokeParticle, Func_InitActorSmokeParticle
d_entry table, SmokeSteamHorz, Func_InitActorSmokeSteamHorz
d_entry table, SmokeSteamUp, Func_InitActorSmokeSteamUp
d_entry table, SmokeWaterfall, FuncA_Room_InitActorSmokeWaterfall
D_END
.ENDREPEAT
.ENDPROC
Expand Down Expand Up @@ -1075,6 +1083,7 @@ _Finish:
d_entry table, SmokeParticle, FuncA_Objects_DrawActorSmokeParticle
d_entry table, SmokeSteamHorz, FuncA_Objects_DrawActorSmokeSteamHorz
d_entry table, SmokeSteamUp, FuncA_Objects_DrawActorSmokeSteamUp
d_entry table, SmokeWaterfall, FuncA_Objects_DrawActorSmokeWaterfall
D_END
.ENDREPEAT
.ENDPROC
Expand Down
1 change: 1 addition & 0 deletions src/actor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ kMaxActors = 16
SmokeParticle ; a single particle of smoke
SmokeSteamHorz ; like ProjSteamHorz, but without any physics interactions
SmokeSteamUp ; like ProjSteamUp, but without any physics interactions
SmokeWaterfall ; pours out of a water pipe
NUM_VALUES
.ENDENUM
Expand Down
176 changes: 176 additions & 0 deletions src/actors/waterfall.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
;;;=========================================================================;;;
;;; 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 "../platforms/water.inc"
.INCLUDE "../ppu.inc"

.IMPORT FuncA_Objects_Draw1x1Shape
.IMPORT FuncA_Objects_MoveShapeDownByA
.IMPORT FuncA_Objects_MoveShapeDownOneTile
.IMPORT FuncA_Objects_MoveShapeLeftHalfTile
.IMPORT FuncA_Objects_MoveShapeUpByA
.IMPORT FuncA_Objects_MoveShapeUpHalfTile
.IMPORT FuncA_Objects_SetShapePosToActorCenter
.IMPORT Func_InitActorWithState1
.IMPORT Ram_ActorPosY_i16_0_arr
.IMPORT Ram_ActorPosY_i16_1_arr
.IMPORT Ram_ActorState1_byte_arr
.IMPORT Ram_ActorState2_byte_arr
.IMPORT Ram_ActorState3_byte_arr
.IMPORT Ram_ActorState4_byte_arr
.IMPORT Ram_ActorType_eActor_arr
.IMPORT Ram_PlatformTop_i16_0_arr
.IMPORT Ram_PlatformTop_i16_1_arr
.IMPORTZP Zp_FrameCounter_u8

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

;;; How fast a waterfall falls, in pixels per frame.
kWaterfallSpeed = 3

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

.SEGMENT "PRGA_Room"

;;; Initializes the specified actor as a waterfall smoke.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param A The platform index for the water below.
;;; @param X The actor index.
;;; @preserve X, T0+
.EXPORT FuncA_Room_InitActorSmokeWaterfall
.PROC FuncA_Room_InitActorSmokeWaterfall
ldy #eActor::SmokeWaterfall ; param: actor type
jmp Func_InitActorWithState1 ; preserves X and T0+
.ENDPROC

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

.SEGMENT "PRGA_Actor"

;;; Performs per-frame updates for a waterfall smoke actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Actor_TickSmokeWaterfall
.PROC FuncA_Actor_TickSmokeWaterfall
_ApplyGravity:
lda Ram_ActorState3_byte_arr, x ; is shut off (boolean)
bmi @isShutOff
@isStillPouring:
lda Ram_ActorState2_byte_arr, x ; waterfall height in pixels
add #kWaterfallSpeed
sta Ram_ActorState2_byte_arr, x ; waterfall height in pixels
bne @done ; unconditional
@isShutOff:
lda Ram_ActorPosY_i16_0_arr, x
add #kWaterfallSpeed
sta Ram_ActorPosY_i16_0_arr, x
lda Ram_ActorPosY_i16_1_arr, x
adc #0
sta Ram_ActorPosY_i16_1_arr, x
@done:
_RemoveIfBelowWater:
ldy Ram_ActorState1_byte_arr, x ; water platform index
lda Ram_PlatformTop_i16_0_arr, y
sub Ram_ActorPosY_i16_0_arr, x
sta T0 ; distance to water
lda Ram_PlatformTop_i16_1_arr, y
sbc Ram_ActorPosY_i16_1_arr, x
beq @done
lda #eActor::None
sta Ram_ActorType_eActor_arr, x
rts
@done:
_ClampHeight:
lda T0 ; distance to water
cmp Ram_ActorState2_byte_arr, x ; waterfall height in pixels
beq @hasHitWater
bge @done
@clamp:
sta Ram_ActorState2_byte_arr, x ; waterfall height in pixels
@hasHitWater:
lda #$ff
sta Ram_ActorState4_byte_arr, x ; has hit water (boolean)
@done:
rts
.ENDPROC

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

.SEGMENT "PRGA_Objects"

;;; Draws a waterfall smoke actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Objects_DrawActorSmokeWaterfall
.PROC FuncA_Objects_DrawActorSmokeWaterfall
jsr FuncA_Objects_SetShapePosToActorCenter ; preserves X
jsr FuncA_Objects_MoveShapeLeftHalfTile ; preserves X
jsr FuncA_Objects_MoveShapeUpHalfTile ; preserves X
lda Zp_FrameCounter_u8
sub Ram_ActorState2_byte_arr, x ; waterfall height in pixels
div #2
mod #4
sta T3 ; waterfall animation (0-3)
_DrawSplash:
ldy Ram_ActorState1_byte_arr, x ; water platform index
lda Ram_PlatformTop_i16_0_arr, y
sub Ram_ActorPosY_i16_0_arr, x
sta T2 ; distance to water
cmp Ram_ActorState2_byte_arr, x ; waterfall height in pixels
bne @done
jsr FuncA_Objects_MoveShapeDownByA ; preserves X and T0+
lda T3 ; waterfall animation (0-3)
.assert kTileIdObjPlatformWaterfallFirst .mod 4 = 0, error
ora #kTileIdObjPlatformWaterfallFirst ; param: tile ID
ldy #kPaletteObjWater ; param: object flags
jsr FuncA_Objects_Draw1x1Shape ; preserves X and T2+
lda T2 ; distance to water
jsr FuncA_Objects_MoveShapeUpByA ; preserves X and T0+
@done:
_DrawWaterfall:
lda Ram_ActorState2_byte_arr, x ; waterfall height in pixels
beq @done
div #kTileHeightPx
sta T2 ; num tiles left to draw
lda Ram_ActorState2_byte_arr, x ; waterfall height in pixels
mod #kTileHeightPx ; param: offset
beq @skipFirstTile
inc T2 ; num tiles left to draw
bne @offset ; unconditional
@skipFirstTile:
lda #kTileHeightPx
@offset:
jsr FuncA_Objects_MoveShapeDownByA ; preserves X and T0+
@loop:
lda T3 ; waterfall animation (0-3)
.assert kTileIdObjPlatformSewageFirst .mod 4 = 0, error
ora #kTileIdObjPlatformSewageFirst ; param: tile ID
ldy #bObj::Pri | kPaletteObjWater ; param: object flags
jsr FuncA_Objects_Draw1x1Shape ; preserves X and T2+
jsr FuncA_Objects_MoveShapeDownOneTile ; preserves X and T0+
dec T2 ; num tiles left to draw
bne @loop
@done:
rts
.ENDPROC

;;;=========================================================================;;;
31 changes: 31 additions & 0 deletions src/actors/waterfall.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 waterfall smoke:
;;; * Flags: Unused.
;;; * Param: The platform index for the water below.
;;; * State1: The platform index for the water below.
;;; * State2: The current height of the waterfall, in pixels.
;;; * State3: Boolean; true ($ff) if this waterfall has been shut off and the
;;; top end is now falling, false ($00) if the water is still pouring from
;;; the pipe.
;;; * State4: Boolean; true ($ff) if the bottom end of this waterfall has
;;; reached the water below yet, false ($00) if not.

;;;=========================================================================;;;
4 changes: 2 additions & 2 deletions src/chr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,9 @@ _chr_begin:
.EXPORT Ppu_ChrBgSewer
.PROC Ppu_ChrBgSewer
CHR1_BANK $80
chr_inc "steam_pipes"
chr_inc "sewer1"
chr_inc "sewer2"
chr_res $10
chr_res $0c
chr_inc "pump"
END_CHR_BANK
Expand Down Expand Up @@ -1298,7 +1298,7 @@ _chr_begin:
chr_inc "mermaid_corra", kTileIdObjMermaidCorraFirst
chr_inc "bad_vinebug", kTileIdObjBadVinebugFirst
chr_inc "anchor", kTileIdObjAnchorFirst
chr_res $05
chr_inc "valve", kTileIdObjValveFirst
chr_inc "bad_beetle", kTileIdObjBadBeetleFirst
chr_res $04
chr_inc "bad_fish", kTileIdObjBadFishFirst
Expand Down
37 changes: 25 additions & 12 deletions src/machines/boiler.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ kPaletteObjValve = 0
.EXPORT Func_MachineBoilerReadReg
.PROC Func_MachineBoilerReadReg
ldx Zp_MachineIndex_u8
lda Ram_MachineGoalHorz_u8_arr, x ; valve goal
lda Ram_MachineState1_byte_arr, x ; valve angle
add #kBoilerValveAnimSlowdown / 2
div #kBoilerValveAnimSlowdown
rts
.ENDPROC

Expand Down Expand Up @@ -157,7 +159,7 @@ _Valve:
jsr FuncA_Objects_MoveShapeDownByA ; preserves Y
tya ; ignition cooldown
div #2
and #$01
mod #2
.assert kTileIdObjBoilerFlameFirst .mod 2 = 0, error
ora #kTileIdObjBoilerFlameFirst ; param: tile ID
ldy #kPaletteObjBoilerFlame ; param: object flags
Expand All @@ -168,23 +170,34 @@ _Valve:

;;; Draws the valve for a boiler machine. The valve platform should be 8x8
;;; pixels and centered on the center of the valve.
;;; @prereq Zp_MachineIndex_u8 and Zp_Current_sMachine_ptr are initialized.
;;; @param X The platform index for the valve.
.EXPORT FuncA_Objects_DrawBoilerValve
.PROC FuncA_Objects_DrawBoilerValve
jsr FuncA_Objects_SetShapePosToPlatformTopLeft
ldy Zp_MachineIndex_u8
lda Ram_MachineState1_byte_arr, y ; valve angle (in tau/32 units)
fall FuncA_Objects_DrawValveShape
.ENDPROC

;;; Draws a valve for a boiler or multiplexer machine at the current shape
;;; position.
;;; @param A The angle of the valve (in tau/32 units)
;;; @preserve X
.EXPORT FuncA_Objects_DrawValveShape
.PROC FuncA_Objects_DrawValveShape
div #2
tay ; valve angle (in tau/16 units)
jsr FuncA_Objects_SetShapePosToPlatformTopLeft ; preserves Y
tya ; valve angle (in tau/16 units)
pha ; valve angle (in tau/16 units)
div #4
and #$03
tax
tya ; valve angle (in tau/16 units)
ldy _Flags_bObj_arr4, x ; param: object flags
and #$07
tax ; valve angle (in tau/16 units, mod 8)
lda _TileId_u8_arr8, x ; param: tile ID
mod #4
tay ; valve angle (in tau/4 units, mod 4)
lda _Flags_bObj_arr4, y
sta T0 ; object flags
pla ; valve angle (in tau/16 units)
mod #8
tay ; valve angle (in tau/16 units, mod 8)
lda _TileId_u8_arr8, y ; param: tile ID
ldy T0 ; param: object flags
jmp FuncA_Objects_Draw1x1Shape
_TileId_u8_arr8:
.byte kTileIdObjValveFirst + 0
Expand Down
Loading

0 comments on commit 394ce65

Please sign in to comment.