Skip to content

Commit

Permalink
Refactor adult/mermaid NPCs, and implement human ghost NPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Jul 3, 2024
1 parent 1ff8b66 commit 2eb95bc
Show file tree
Hide file tree
Showing 29 changed files with 326 additions and 201 deletions.
21 changes: 7 additions & 14 deletions src/actor.asm
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@
.IMPORT FuncA_Objects_DrawActorBadWasp
.IMPORT FuncA_Objects_DrawActorNpcAdult
.IMPORT FuncA_Objects_DrawActorNpcChild
.IMPORT FuncA_Objects_DrawActorNpcMermaid
.IMPORT FuncA_Objects_DrawActorNpcMermaidQueen
.IMPORT FuncA_Objects_DrawActorNpcOrc
.IMPORT FuncA_Objects_DrawActorNpcQueen
.IMPORT FuncA_Objects_DrawActorNpcToddler
.IMPORT FuncA_Objects_DrawActorProjAcid
.IMPORT FuncA_Objects_DrawActorProjAxe
Expand Down Expand Up @@ -512,9 +511,8 @@ _NoHit:
d_byte BadWasp, 5
d_byte NpcAdult, 13
d_byte NpcChild, 7
d_byte NpcMermaid, 13
d_byte NpcMermaidQueen, 2
d_byte NpcOrc, kOrcBoundingBoxUp
d_byte NpcQueen, 2
d_byte NpcToddler, 4
d_byte ProjAcid, 1
d_byte ProjAxeBoomer, kProjAxeRadius
Expand Down Expand Up @@ -575,9 +573,8 @@ _NoHit:
d_byte BadWasp, 6
d_byte NpcAdult, 8
d_byte NpcChild, 8
d_byte NpcMermaid, 8
d_byte NpcMermaidQueen, 24
d_byte NpcOrc, kOrcBoundingBoxDown
d_byte NpcQueen, 24
d_byte NpcToddler, 8
d_byte ProjAcid, 3
d_byte ProjAxeBoomer, kProjAxeRadius
Expand Down Expand Up @@ -638,9 +635,8 @@ _NoHit:
d_byte BadWasp, 6
d_byte NpcAdult, 5
d_byte NpcChild, 5
d_byte NpcMermaid, 5
d_byte NpcMermaidQueen, 5
d_byte NpcOrc, kOrcBoundingBoxSide
d_byte NpcQueen, 5
d_byte NpcToddler, 3
d_byte ProjAcid, 2
d_byte ProjAxeBoomer, kProjAxeRadius
Expand Down Expand Up @@ -769,9 +765,8 @@ _TypeSpecificTick:
d_entry table, BadWasp, FuncA_Actor_TickBadWasp
d_entry table, NpcAdult, Func_Noop
d_entry table, NpcChild, Func_Noop
d_entry table, NpcMermaid, Func_Noop
d_entry table, NpcMermaidQueen, Func_Noop
d_entry table, NpcOrc, Func_Noop
d_entry table, NpcQueen, Func_Noop
d_entry table, NpcToddler, FuncA_Actor_TickNpcToddler
d_entry table, ProjAcid, FuncA_Actor_TickProjAcid
d_entry table, ProjAxeBoomer, FuncA_Actor_TickProjAxeBoomer
Expand Down Expand Up @@ -936,9 +931,8 @@ _Finish:
d_entry table, BadWasp, FuncA_Room_InitActorBadWasp
d_entry table, NpcAdult, Func_InitActorWithState1
d_entry table, NpcChild, FuncA_Room_InitActorNpcChild
d_entry table, NpcMermaid, Func_InitActorWithState1
d_entry table, NpcMermaidQueen, Func_InitActorDefault
d_entry table, NpcOrc, Func_InitActorNpcOrc
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
Expand Down Expand Up @@ -1028,9 +1022,8 @@ _Finish:
d_entry table, BadWasp, FuncA_Objects_DrawActorBadWasp
d_entry table, NpcAdult, FuncA_Objects_DrawActorNpcAdult
d_entry table, NpcChild, FuncA_Objects_DrawActorNpcChild
d_entry table, NpcMermaid, FuncA_Objects_DrawActorNpcMermaid
d_entry table, NpcMermaidQueen, FuncA_Objects_DrawActorNpcMermaidQueen
d_entry table, NpcOrc, FuncA_Objects_DrawActorNpcOrc
d_entry table, NpcQueen, FuncA_Objects_DrawActorNpcQueen
d_entry table, NpcToddler, FuncA_Objects_DrawActorNpcToddler
d_entry table, ProjAcid, FuncA_Objects_DrawActorProjAcid
d_entry table, ProjAxeBoomer, FuncA_Objects_DrawActorProjAxe
Expand Down
13 changes: 6 additions & 7 deletions src/actor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ kMaxActors = 16
BadToad ; jumps in place
BadVinebug ; moves vertically on a vine
BadWasp ; flies in a circle
NpcAdult
NpcChild
NpcMermaid
NpcMermaidQueen
NpcOrc
NpcToddler
NpcAdult ; used for human adults and for most mermaids
NpcChild ; used for human children
NpcOrc ; used for orcs, and Queen Eirene when she's standing
NpcQueen ; used for Queen Eirene when she's seated
NpcToddler ; used for baby Nina
ProjAcid ; acid dropped by a flydrop baddie
ProjAxeBoomer ; a boomerang axe thrown by Gronta
ProjAxeSmash ; a machine-smashing axe thrown by Gronta
Expand Down Expand Up @@ -106,7 +105,7 @@ kFirstSmokeActorType = eActor::SmokeBlood
;; * For BadBeetle*, this is the actor flip flags to set.
;; * For BadBird, this is a bBadBird value.
;; * For BadHothead*, this is the actor flip flags to set.
;; * For NpcAdult, this is the first tile ID (of six).
;; * For NpcAdult, this is an eNpcAdult value.
;; * For NpcChild, this is a bNpcChild value.
;; * For NpcMermaid, this is the first tile ID (of six).
;; * For NpcToddler, this is a bNpcToddler value.
Expand Down
85 changes: 40 additions & 45 deletions src/actors/townsfolk.asm → src/actors/adult.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.INCLUDE "../macros.inc"
.INCLUDE "../oam.inc"
.INCLUDE "../ppu.inc"
.INCLUDE "townsfolk.inc"
.INCLUDE "adult.inc"

.IMPORT FuncA_Objects_Alloc2x1Shape
.IMPORT FuncA_Objects_Alloc2x2Shape
Expand All @@ -37,10 +37,8 @@
;;;=========================================================================;;;

;;; OBJ palette numbers to use for drawing various townsfolks NPC actors.
kPaletteObjAdult = 0
kPaletteObjMermaid = 0
kPaletteObjMermaidQueenBody = 0
kPaletteObjMermaidQueenHead = 1
kPaletteObjAdult = 0
kPaletteObjMermaid = 0

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

Expand All @@ -52,49 +50,46 @@ kPaletteObjMermaidQueenHead = 1
.EXPORT FuncA_Objects_DrawActorNpcAdult
.PROC FuncA_Objects_DrawActorNpcAdult
jsr FuncA_Objects_SetShapePosToActorCenter ; preserves X
;; Determine the object flags to use when drawing the NPC.
jsr FuncA_Objects_GetNpcActorFlags ; preserves X, returns A
.assert kPaletteObjAdult = 0, error
tay ; param: object flags
lda Ram_ActorState1_byte_arr, x ; param: first tile ID
jmp FuncA_Objects_Draw2x3TownsfolkShape ; preserves X
.ENDPROC

;;; Draws a mermaid NPC actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Objects_DrawActorNpcMermaid
.PROC FuncA_Objects_DrawActorNpcMermaid
jsr FuncA_Objects_SetShapePosToActorCenter ; preserves X
jsr FuncA_Objects_BobActorShapePosUpAndDown ; preserves X
;; Draw the actor.
jsr FuncA_Objects_GetNpcActorFlags ; preserves X, returns A
.assert kPaletteObjMermaid = 0, error
tay ; param: object flags
lda Ram_ActorState1_byte_arr, x ; param: first tile ID
cmp #kFirst2x4MermaidTileId
sta T1 ; object flags
;; If this NPC should float in the water/air, bob its position up and down.
ldy Ram_ActorState1_byte_arr, x ; eNpcAdult value
cpy #kFirstFloatingNpcAdult
blt @notFloating
jsr FuncA_Objects_BobActorShapePosUpAndDown ; preserves X and T1+
@notFloating:
;; Draw the NPC.
ldy Ram_ActorState1_byte_arr, x ; eNpcAdult value
lda _FirstTileId_u8_arr, y ; param: first tile ID
cpy #kFirst2x4NpcAdult
ldy T1 ; param: object flags
blt FuncA_Objects_Draw2x3TownsfolkShape ; preserves X
jmp FuncA_Objects_Draw2x4TownsfolkShape ; preserves X
.ENDPROC

;;; Draws a mermaid queen NPC actor.
;;; @param X The actor index.
;;; @preserve X
.EXPORT FuncA_Objects_DrawActorNpcMermaidQueen
.PROC FuncA_Objects_DrawActorNpcMermaidQueen
jsr FuncA_Objects_SetShapePosToActorCenter ; preserves X
_TopHalf:
jsr FuncA_Objects_GetNpcActorFlags ; preserves X, returns A
.assert kPaletteObjMermaidQueenHead <> 0, error
ora #kPaletteObjMermaidQueenHead
tay ; param: object flags
lda #kTileIdMermaidQueenFirst ; param: first tile ID
jsr FuncA_Objects_Draw2x2Shape ; preserves X
_BottomHalf:
lda #kTileHeightPx * 2 ; param: offset
jsr FuncA_Objects_MoveShapeDownByA
ldy #kPaletteObjMermaidQueenBody ; param: object flags
lda #kTileIdMermaidQueenFirst + 4 ; param: first tile ID
jmp FuncA_Objects_Draw2x2Shape ; preserves X
bge FuncA_Objects_Draw2x4TownsfolkShape ; preserves X, unconditional
_FirstTileId_u8_arr:
D_ARRAY .enum, eNpcAdult
d_byte HumanElder1, kTileIdObjAdultElderFirst + 0
d_byte HumanElder2, kTileIdObjAdultElderFirst + 6
d_byte HumanMan, kTileIdObjAdultManFirst + 0
d_byte HumanSmith1, kTileIdObjAdultSmithFirst + 0
d_byte HumanSmith2, kTileIdObjAdultSmithFirst + 6
d_byte HumanWoman, kTileIdObjAdultWomanFirst + 0
d_byte MermaidFlorist, kTileIdObjMermaidFloristFirst + 0
d_byte GhostMan, kTileIdObjAdultGhostFirst + 6
d_byte GhostWoman, kTileIdObjAdultGhostFirst + 0
d_byte MermaidCorra, kTileIdObjMermaidCorraFirst + 0
d_byte MermaidDaphne, kTileIdObjMermaidDaphneFirst + 0
d_byte MermaidFarmer, kTileIdObjMermaidFarmerFirst + 0
d_byte MermaidGhost, kTileIdObjMermaidGhostFirst + 0
d_byte MermaidGuardF, kTileIdObjMermaidGuardFFirst + 0
d_byte MermaidGuardM, kTileIdObjMermaidGuardMFirst + 0
d_byte MermaidPhoebe, kTileIdObjMermaidPhoebeFirst + 0
d_byte CorraSwimmingDown1, kTileIdObjCorraSwimmingDownFirst + 0
d_byte CorraSwimmingDown2, kTileIdObjCorraSwimmingDownFirst + 6
d_byte CorraSwimmingUp1, kTileIdObjCorraSwimmingUpFirst + 0
d_byte CorraSwimmingUp2, kTileIdObjCorraSwimmingUpFirst + 8
D_END
.ENDPROC

;;; Draws a 2x3-tile shape, using the given first tile ID and the five
Expand Down
89 changes: 89 additions & 0 deletions src/actors/adult.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
;;;=========================================================================;;;
;;; 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 adult NPCs:
;;; * Param: The eNpcAdult value specifying the NPC's initial pose.
;;; * Flags: The FlipH bit is set if the NPC is facing left, or cleared if
;;; they are facing right. However, if State2 is false ($00), then this
;;; bit is ignored and instead the NPC automatically faces toward the
;;; player avatar.
;;; * State1: The current eNpcAdult value.
;;; * State2: Boolean; if true ($ff), the NPC uses Ram_ActorFlags_bObj_arr
;;; unchanged; if false ($00), the NPC is automatically drawn facing the
;;; player avatar.
;;; * State3: Unused.
;;; * State4: Unused.

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

;;; Possible values for an adult NPC actor's State1 byte.
.ENUM eNpcAdult
;; NPCs that sit/stand on dry land:
HumanElder1
HumanElder2
HumanMan
HumanSmith1
HumanSmith2
HumanWoman
MermaidFlorist
;; NPCs that float, bobbing up and down in the water/air:
GhostMan
GhostWoman
MermaidCorra
MermaidDaphne
MermaidFarmer
MermaidGhost
MermaidGuardF
MermaidGuardM
MermaidPhoebe
CorraSwimmingDown1
CorraSwimmingDown2
;; NPCs that float AND are drawn with 2x4 tiles instead of 2x3:
CorraSwimmingUp1
CorraSwimmingUp2
NUM_VALUES
.ENDENUM

;;; eNpcAdult values greater than or equal to this are for NPCs that float.
kFirstFloatingNpcAdult = eNpcAdult::GhostMan

;;; eNpcAdult values greater than or equal to this are drawn with 2x4 tiles,
;;; instead of 2x3.
kFirst2x4NpcAdult = eNpcAdult::CorraSwimmingUp1

;;; The first tile IDs for various human adults.
kTileIdObjAdultElderFirst = $c4
kTileIdObjAdultGhostFirst = $e4
kTileIdObjAdultManFirst = $d6
kTileIdObjAdultSmithFirst = $b8
kTileIdObjAdultWomanFirst = $d0

;;; The first tile IDs for various mermaids.
kTileIdObjCorraSwimmingDownFirst = $e0
kTileIdObjCorraSwimmingUpFirst = $f0
kTileIdObjMermaidCorraFirst = $aa
kTileIdObjMermaidFloristFirst = $92
kTileIdObjMermaidDaphneFirst = $98
kTileIdObjMermaidGhostFirst = $c4
kTileIdObjMermaidGuardFFirst = $9e
kTileIdObjMermaidGuardMFirst = $80
kTileIdObjMermaidPhoebeFirst = $86
kTileIdObjMermaidFarmerFirst = $8c

;;;=========================================================================;;;
10 changes: 5 additions & 5 deletions src/actors/ghost.asm
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

.INCLUDE "../macros.inc"
.INCLUDE "../ppu.inc"
.INCLUDE "adult.inc"
.INCLUDE "ghost.inc"
.INCLUDE "orc.inc"
.INCLUDE "townsfolk.inc"

.IMPORT Data_PowersOfTwo_u8_arr8
.IMPORT FuncA_Objects_BobActorShapePosUpAndDown
Expand Down Expand Up @@ -158,10 +158,10 @@
jmp FuncA_Objects_Draw2x3TownsfolkShape ; preserves X
_FirstTileId_u8_arr:
D_ARRAY .enum, eBadGhost
d_byte Absent, kTileIdMermaidGhostFirst + 0
d_byte Idle, kTileIdMermaidGhostFirst + 0
d_byte Disappearing, kTileIdMermaidGhostFirst + 0
d_byte Reappearing, kTileIdMermaidGhostFirst + 0
d_byte Absent, kTileIdObjMermaidGhostFirst + 0
d_byte Idle, kTileIdObjMermaidGhostFirst + 0
d_byte Disappearing, kTileIdObjMermaidGhostFirst + 0
d_byte Reappearing, kTileIdObjMermaidGhostFirst + 0
D_END
.ENDPROC

Expand Down
6 changes: 3 additions & 3 deletions src/actors/orc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ kBadGrontaMaxJumpUpBlocks = 2
GruntThrowing2
GruntStanding
GhostStanding
;; Gronta (red palette for head):
;; Gronta (or Eirene) (red palette for head):
GrontaRunning1
GrontaRunning2
GrontaRunning3
Expand All @@ -120,11 +120,11 @@ kBadGrontaMaxJumpUpBlocks = 2
GrontaParley
GrontaStanding
GrontaThrowing
EireneParley
EireneParley ; not really an orc, but drawn like Gronta
NUM_VALUES
.ENDENUM

;;; eNpcOrc values greater than or equal to this are Gronta.
;;; eNpcOrc values greater than or equal to this are Gronta (or Queen Eirene).
kNpcOrcFirstGronta = eNpcOrc::GrontaRunning1

;;; How far an orc actor's bounding box extends in each direction from the
Expand Down
Loading

0 comments on commit 2eb95bc

Please sign in to comment.