Skip to content

Commit

Permalink
Make FuncA_Room_InitActor only handle baddies and NPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Oct 18, 2024
1 parent c6f1118 commit 81cc23c
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 156 deletions.
129 changes: 37 additions & 92 deletions src/actor.asm
Original file line number Diff line number Diff line change
Expand Up @@ -156,37 +156,10 @@
.IMPORT FuncA_Room_InitActorBadWasp
.IMPORT FuncA_Room_InitActorNpcChild
.IMPORT FuncA_Room_InitActorNpcToddler
.IMPORT FuncA_Room_InitActorProjBreakball
.IMPORT FuncA_Room_InitActorProjBreakbomb
.IMPORT FuncA_Room_InitActorProjEgg
.IMPORT FuncA_Room_InitActorProjFlamestrike
.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
.IMPORT Func_InitActorBadSolifuge
.IMPORT Func_InitActorNpcOrc
.IMPORT Func_InitActorProjAcid
.IMPORT Func_InitActorProjAxe
.IMPORT Func_InitActorProjBreakfire
.IMPORT Func_InitActorProjBullet
.IMPORT Func_InitActorProjEmber
.IMPORT Func_InitActorProjFireball
.IMPORT Func_InitActorProjFireblast
.IMPORT Func_InitActorProjFood
.IMPORT Func_InitActorProjGrenade
.IMPORT Func_InitActorProjRocket
.IMPORT Func_InitActorProjSpike
.IMPORT Func_InitActorProjSteamHorz
.IMPORT Func_InitActorProjSteamUp
.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 Down Expand Up @@ -943,71 +916,43 @@ _Finish:
.REPEAT 2, table
D_TABLE_LO table, _JumpTable_ptr_0_arr
D_TABLE_HI table, _JumpTable_ptr_1_arr
D_TABLE .enum, eActor
d_entry table, None, Func_InitActorDefault
d_entry table, BadBat, Func_InitActorWithState1
d_entry table, BadBeetleHorz, Func_InitActorWithFlags
d_entry table, BadBeetleVert, Func_InitActorWithFlags
d_entry table, BadBird, FuncA_Room_InitActorBadBird
d_entry table, BadCrab, Func_InitActorDefault
d_entry table, BadFirefly, FuncA_Room_InitActorBadFirefly
d_entry table, BadFish, Func_InitActorWithFlags
d_entry table, BadFlydrop, FuncA_Room_InitActorBadFlydrop
d_entry table, BadGhostMermaid, Func_InitActorWithState1
d_entry table, BadGhostOrc, Func_InitActorWithState1
d_entry table, BadGooGreen, Func_InitActorWithFlags
d_entry table, BadGooRed, FuncA_Room_InitActorBadGooRed
d_entry table, BadGronta, Func_InitActorBadGronta
d_entry table, BadGrub, Func_InitActorWithFlags
d_entry table, BadGrubFire, Func_InitActorWithFlags
d_entry table, BadHotheadHorz, Func_InitActorWithFlags
d_entry table, BadHotheadVert, Func_InitActorWithFlags
d_entry table, BadJelly, Func_InitActorWithState1
d_entry table, BadLavaball, FuncA_Room_InitActorBadLavaball
d_entry table, BadOrc, Func_InitActorBadOrc
d_entry table, BadRhino, Func_InitActorWithFlags
d_entry table, BadRodent, Func_InitActorDefault
d_entry table, BadSlime, Func_InitActorWithFlags
d_entry table, BadSolifuge, Func_InitActorBadSolifuge
d_entry table, BadSpider, Func_InitActorDefault
d_entry table, BadToad, FuncA_Room_InitActorBadToad
d_entry table, BadVinebug, Func_InitActorDefault
d_entry table, BadWasp, FuncA_Room_InitActorBadWasp
d_entry table, NpcAdult, Func_InitActorWithState1
d_entry table, NpcChild, FuncA_Room_InitActorNpcChild
d_entry table, NpcDuck, Func_InitActorWithFlags
d_entry table, NpcOrc, Func_InitActorNpcOrc
d_entry table, NpcOrcSleeping, Func_InitActorDefault
d_entry table, NpcQueen, Func_InitActorDefault
d_entry table, NpcToddler, FuncA_Room_InitActorNpcToddler
d_entry table, ProjAcid, Func_InitActorProjAcid
d_entry table, ProjAxeBoomer, Func_InitActorProjAxe
d_entry table, ProjAxeSmash, Func_InitActorProjAxe
d_entry table, ProjBreakball, FuncA_Room_InitActorProjBreakball
d_entry table, ProjBreakbomb, FuncA_Room_InitActorProjBreakbomb
d_entry table, ProjBreakfire, Func_InitActorProjBreakfire
d_entry table, ProjBullet, Func_InitActorProjBullet
d_entry table, ProjEgg, FuncA_Room_InitActorProjEgg
d_entry table, ProjEmber, Func_InitActorProjEmber
d_entry table, ProjFireball, Func_InitActorProjFireball
d_entry table, ProjFireblast, Func_InitActorProjFireblast
d_entry table, ProjFlamestrike, FuncA_Room_InitActorProjFlamestrike
d_entry table, ProjFood, Func_InitActorProjFood
d_entry table, ProjGrenade, Func_InitActorProjGrenade
d_entry table, ProjRocket, Func_InitActorProjRocket
d_entry table, ProjSpike, Func_InitActorProjSpike
d_entry table, ProjSpine, FuncA_Room_InitActorProjSpine
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
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
D_TABLE kFirstNonStaticActorType
d_entry table, eActor::None, Func_InitActorDefault
d_entry table, eActor::BadBat, Func_InitActorWithState1
d_entry table, eActor::BadBeetleHorz, Func_InitActorWithFlags
d_entry table, eActor::BadBeetleVert, Func_InitActorWithFlags
d_entry table, eActor::BadBird, FuncA_Room_InitActorBadBird
d_entry table, eActor::BadCrab, Func_InitActorDefault
d_entry table, eActor::BadFirefly, FuncA_Room_InitActorBadFirefly
d_entry table, eActor::BadFish, Func_InitActorWithFlags
d_entry table, eActor::BadFlydrop, FuncA_Room_InitActorBadFlydrop
d_entry table, eActor::BadGhostMermaid, Func_InitActorWithState1
d_entry table, eActor::BadGhostOrc, Func_InitActorWithState1
d_entry table, eActor::BadGooGreen, Func_InitActorWithFlags
d_entry table, eActor::BadGooRed, FuncA_Room_InitActorBadGooRed
d_entry table, eActor::BadGronta, Func_InitActorBadGronta
d_entry table, eActor::BadGrub, Func_InitActorWithFlags
d_entry table, eActor::BadGrubFire, Func_InitActorWithFlags
d_entry table, eActor::BadHotheadHorz, Func_InitActorWithFlags
d_entry table, eActor::BadHotheadVert, Func_InitActorWithFlags
d_entry table, eActor::BadJelly, Func_InitActorWithState1
d_entry table, eActor::BadLavaball, FuncA_Room_InitActorBadLavaball
d_entry table, eActor::BadOrc, Func_InitActorBadOrc
d_entry table, eActor::BadRhino, Func_InitActorWithFlags
d_entry table, eActor::BadRodent, Func_InitActorDefault
d_entry table, eActor::BadSlime, Func_InitActorWithFlags
d_entry table, eActor::BadSolifuge, Func_InitActorBadSolifuge
d_entry table, eActor::BadSpider, Func_InitActorDefault
d_entry table, eActor::BadToad, FuncA_Room_InitActorBadToad
d_entry table, eActor::BadVinebug, Func_InitActorDefault
d_entry table, eActor::BadWasp, FuncA_Room_InitActorBadWasp
d_entry table, eActor::NpcAdult, Func_InitActorWithState1
d_entry table, eActor::NpcChild, FuncA_Room_InitActorNpcChild
d_entry table, eActor::NpcDuck, Func_InitActorWithFlags
d_entry table, eActor::NpcOrc, Func_InitActorNpcOrc
d_entry table, eActor::NpcOrcSleeping, Func_InitActorDefault
d_entry table, eActor::NpcQueen, Func_InitActorDefault
d_entry table, eActor::NpcToddler, FuncA_Room_InitActorNpcToddler
D_END
.ENDREPEAT
.ENDPROC
Expand Down
7 changes: 7 additions & 0 deletions src/actor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ kMaxActors = 16
NUM_VALUES
.ENDENUM
;;; eActor values less than this can be staticly initialized by a room's
;;; sRoomExt::Actors_sActor_arr_ptr array. eActor values greater than or equal
;;; to this can only be initialized dynamically, by calling some appropriate
;;; initialization function, which may well be in a different PRGA bank than
;;; PRGA_Room.
kFirstNonStaticActorType = eActor::ProjAcid

;;; eActor values greater than or equal to this are "smoke" actors; that is,
;;; they are decorative animations that don't affect game physics.
kFirstSmokeActorType = eActor::SmokeBlood
Expand Down
10 changes: 3 additions & 7 deletions src/actors/acid.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,18 @@ kPaletteObjAcid = 2

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

.SEGMENT "PRG8"
.SEGMENT "PRGA_Actor"

;;; Initializes the specified actor as an acid projectile.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param X The actor index.
;;; @preserve X, T0+
.EXPORT Func_InitActorProjAcid
.PROC Func_InitActorProjAcid
.EXPORT FuncA_Actor_InitActorProjAcid
.PROC FuncA_Actor_InitActorProjAcid
ldy #eActor::ProjAcid ; param: actor type
jmp Func_InitActorDefault ; preserves X and T0+
.ENDPROC

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

.SEGMENT "PRGA_Actor"

;;; Performs per-frame updates for an acid projectile actor.
;;; @param X The actor index.
;;; @preserve X
Expand Down
10 changes: 3 additions & 7 deletions src/actors/axe.asm
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ kPaletteObjAxe = 0

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

.SEGMENT "PRG8"
.SEGMENT "PRGA_Actor"

;;; Initializes the specified actor as an axe projectile.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param A The angle to throw at, measured in increments of tau/256.
;;; @param X The actor index.
;;; @param Y The actor type to set (ProjAxeBoomer or ProjAxeSmash).
;;; @preserve X, T3+
.EXPORT Func_InitActorProjAxe
.PROC Func_InitActorProjAxe
.EXPORT FuncA_Actor_InitActorProjAxe
.PROC FuncA_Actor_InitActorProjAxe
pha ; angle
add #$40
and #$80
Expand All @@ -90,10 +90,6 @@ kPaletteObjAxe = 0
jmp Func_SetActorVelocityPolar ; preserves X and T3+
.ENDPROC

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

.SEGMENT "PRGA_Actor"

;;; Performs per-frame updates for a boomerang axe projectile actor.
;;; @param X The actor index.
;;; @preserve X
Expand Down
6 changes: 3 additions & 3 deletions src/actors/breakball.asm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.INCLUDE "breakball.inc"

.IMPORT FuncA_Actor_HarmAvatarIfCollision
.IMPORT FuncA_Actor_InitActorProjBreakfire
.IMPORT FuncA_Actor_MovePointTowardVelXDir
.IMPORT FuncA_Actor_NegateVelX
.IMPORT FuncA_Actor_NegateVelY
Expand All @@ -34,7 +35,6 @@
.IMPORT FuncA_Objects_SetShapePosToActorCenter
.IMPORT Func_FindEmptyActorSlot
.IMPORT Func_InitActorDefault
.IMPORT Func_InitActorProjBreakfire
.IMPORT Func_InitActorSmokeExplosion
.IMPORT Func_IsPointInAnySolidPlatform
.IMPORT Func_MovePointDownByA
Expand Down Expand Up @@ -189,12 +189,12 @@ _Explode:
bcs @doneFirstBreakfire
jsr Func_SetActorCenterToPoint ; preserves X
lda #0 ; param: direction (0 = right)
jsr Func_InitActorProjBreakfire
jsr FuncA_Actor_InitActorProjBreakfire
@doneFirstBreakfire:
pla ; breakball actor index
tax ; param: actor index
lda #bObj::FlipH ; param: direction (FlipH = left)
jmp Func_InitActorProjBreakfire ; preserves X
jmp FuncA_Actor_InitActorProjBreakfire ; preserves X
.ENDPROC

;;;=========================================================================;;;
Expand Down
4 changes: 2 additions & 2 deletions src/actors/breakbomb.asm
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
.IMPORT FuncA_Actor_ApplyGravity
.IMPORT FuncA_Actor_CenterHitsTerrain
.IMPORT FuncA_Actor_HarmAvatarIfCollision
.IMPORT FuncA_Actor_InitActorProjBreakfire
.IMPORT FuncA_Objects_Draw1x1Actor
.IMPORT Func_GetRandomByte
.IMPORT Func_InitActorDefault
.IMPORT Func_InitActorProjBreakfire
.IMPORT Func_ShakeRoom
.IMPORT Ram_ActorPosY_i16_0_arr
.IMPORT Ram_ActorPosY_i16_1_arr
Expand Down Expand Up @@ -128,7 +128,7 @@ _ExplodeIfHitsTerrain:
;; TODO: play a sound
jsr Func_GetRandomByte ; preserves X, returns A
and #bObj::FlipH ; param: flags
jsr Func_InitActorProjBreakfire ; preserves X
jsr FuncA_Actor_InitActorProjBreakfire ; preserves X
@done:
rts
.ENDPROC
Expand Down
10 changes: 3 additions & 7 deletions src/actors/breakfire.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ kProjBreakfireMinLifetime = kBlockWidthPx * 12 * $100 / kProjBreakfireSpeed

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

.SEGMENT "PRG8"
.SEGMENT "PRGA_Actor"

;;; Initializes the specified actor as a breakfire projectile.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param A Zero if the breakfire should move right, or bObj::FlipH for left.
;;; @param X The actor index.
;;; @preserve X
.EXPORT Func_InitActorProjBreakfire
.PROC Func_InitActorProjBreakfire
.EXPORT FuncA_Actor_InitActorProjBreakfire
.PROC FuncA_Actor_InitActorProjBreakfire
sta T0 ; horz flag
ldy #eActor::ProjBreakfire ; param: actor type
lda #kProjBreakfireMinLifetime ; param: min time remaining
Expand All @@ -87,10 +87,6 @@ _InitVelX:
rts
.ENDPROC

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

.SEGMENT "PRGA_Actor"

;;; Performs per-frame updates for a breakfire projectile actor.
;;; @param X The actor index.
;;; @preserve X
Expand Down
6 changes: 3 additions & 3 deletions src/actors/bullet.asm
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ kPaletteObjBullet = 1

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

.SEGMENT "PRG8"
.SEGMENT "PRGA_Machine"

;;; Initializes the specified actor as a bullet projectile.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param A The eDir value for the bullet direction.
;;; @param X The actor index.
;;; @preserve X
.EXPORT Func_InitActorProjBullet
.PROC Func_InitActorProjBullet
.EXPORT FuncA_Machine_InitActorProjBullet
.PROC FuncA_Machine_InitActorProjBullet
pha ; eDir value
ldy #eActor::ProjBullet ; param: actor type
jsr Func_InitActorDefault
Expand Down
4 changes: 2 additions & 2 deletions src/actors/flydrop.asm
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
.IMPORT FuncA_Actor_FaceOppositeDir
.IMPORT FuncA_Actor_FaceTowardsAvatar
.IMPORT FuncA_Actor_HarmAvatarIfCollision
.IMPORT FuncA_Actor_InitActorProjAcid
.IMPORT FuncA_Actor_IsAvatarAboveOrBelow
.IMPORT FuncA_Actor_IsAvatarWithinHorzDistance
.IMPORT FuncA_Actor_SetPointInFrontOfActor
.IMPORT FuncA_Actor_SetVelXForward
.IMPORT FuncA_Objects_Draw2x2Actor
.IMPORT Func_FindEmptyActorSlot
.IMPORT Func_GetRandomByte
.IMPORT Func_InitActorProjAcid
.IMPORT Func_InitActorWithFlags
.IMPORT Func_MovePointDownByA
.IMPORT Func_PointHitsTerrain
Expand Down Expand Up @@ -117,7 +117,7 @@ _DropAcid:
jsr Func_FindEmptyActorSlot ; preserves T0+, returns C and X
bcs @noAcid
jsr Func_SetActorCenterToPoint ; preserves X and T0+
jsr Func_InitActorProjAcid ; preserves X and T0+
jsr FuncA_Actor_InitActorProjAcid ; preserves X and T0+
;; Give the acid projectile a random X-velocity from -0.5 to +0.5 pixels
;; per frame.
ldy #0
Expand Down
6 changes: 3 additions & 3 deletions src/actors/food.asm
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ kWaterLine = $00b5

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

.SEGMENT "PRG8"
.SEGMENT "PRGA_Cutscene"

;;; Initializes the specified actor as a food projectile.
;;; @prereq The actor's pixel position has already been initialized.
;;; @param A The number of frames before the food should expire.
;;; @param X The actor index.
;;; @preserve X
.EXPORT Func_InitActorProjFood
.PROC Func_InitActorProjFood
.EXPORT FuncA_Cutscene_InitActorProjFood
.PROC FuncA_Cutscene_InitActorProjFood
ldy #eActor::ProjFood ; param: actor type
jmp Func_InitActorWithState1 ; preserves X
.ENDPROC
Expand Down
6 changes: 3 additions & 3 deletions src/actors/grenade.asm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ kPaletteObjGrenade = 0

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

.SEGMENT "PRG8"
.SEGMENT "PRGA_Machine"

;;; Initializes the specified actor as a grenade projectile. The grenade can
;;; be aimed in one of four initial angles:
Expand All @@ -60,8 +60,8 @@ kPaletteObjGrenade = 0
;;; @param A The aim angle (0-3).
;;; @param X The actor index.
;;; @preserve X
.EXPORT Func_InitActorProjGrenade
.PROC Func_InitActorProjGrenade
.EXPORT FuncA_Machine_InitActorProjGrenade
.PROC FuncA_Machine_InitActorProjGrenade
pha ; aim angle index
ldy #eActor::ProjGrenade ; param: actor type
jsr Func_InitActorDefault ; preserves X
Expand Down
Loading

0 comments on commit 81cc23c

Please sign in to comment.