Skip to content

Commit

Permalink
Add baddies to CityCenter, CityOutskirts, and CoreWest
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Mar 10, 2024
1 parent 9c3c75e commit 8e0a22b
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/actors/orc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
.IMPORT FuncA_Actor_HarmAvatarIfCollision
.IMPORT FuncA_Actor_IsAvatarWithinHorzDistance
.IMPORT FuncA_Actor_IsAvatarWithinVertDistances
.IMPORT FuncA_Actor_IsPointInRoomBounds
.IMPORT FuncA_Actor_MovePointTowardVelXDir
.IMPORT FuncA_Actor_NegateVelX
.IMPORT FuncA_Actor_SetPointInFrontOfActor
Expand Down Expand Up @@ -807,6 +808,8 @@ _MaybeJump:
;;; @param C Set if the orc cannot keep moving along its horizontal velocity.
;;; @preserve X
.PROC FuncA_Actor_IsOrcPointBlocked
jsr FuncA_Actor_IsPointInRoomBounds ; preserves X, returns C
bcc _IsBlocked
_CheckTerrain:
jsr Func_GetTerrainColumnPtrForPointX ; preserves X
jsr FuncA_Actor_GetRoomBlockRow ; preserves X, returns Y
Expand Down
26 changes: 18 additions & 8 deletions src/actors/shared.asm
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,22 @@ _Atan2:
rts
.ENDPROC

;;; Checks if the center of the actor is within the bounds of the room.
;;; Checks if the center of the actor is within the bounds of the current room.
;;; @param X The actor index.
;;; @return C Set if the actor is within the room bounds, cleared otherwise.
;;; @preserve X
.EXPORT FuncA_Actor_IsInRoomBounds
.PROC FuncA_Actor_IsInRoomBounds
jsr Func_SetPointToActorCenter ; preserves X
fall FuncA_Actor_IsPointInRoomBounds ; preserves X, returns C
.ENDPROC

;;; Checks if the point stored in Zp_PointX_i16 and Zp_PointY_i16 is within the
;;; bounds of the current room.
;;; @return C Set if the actor is within the room bounds, cleared otherwise.
;;; @preserve X
.EXPORT FuncA_Actor_IsPointInRoomBounds
.PROC FuncA_Actor_IsPointInRoomBounds
_CheckVert:
bit Zp_Current_sRoom + sRoom::Flags_bRoom
.assert bRoom::Tall = bProc::Overflow, error
Expand All @@ -187,26 +197,26 @@ _CheckVert:
ldya #kTallRoomHeightBlocks * kBlockHeightPx
@finishHeight:
stya T1T0 ; room height in pixels
lda Ram_ActorPosY_i16_0_arr, x
lda Zp_PointY_i16 + 0
cmp T0 ; room height in pixels (lo)
lda Ram_ActorPosY_i16_1_arr, x
bmi _NotInRoom ; actor is above the top of the room
lda Zp_PointY_i16 + 1
bmi _NotInRoom ; point is above the top of the room
sbc T1 ; room height in pixels (hi)
bge _NotInRoom ; actor is below the bottom of the room
bge _NotInRoom ; point is below the bottom of the room
_CheckHorz:
ldy Zp_Current_sRoom + sRoom::MaxScrollX_u16 + 1
.assert kScreenWidthPx = $100, error
iny
sty T0 ; room right side (hi)
lda Ram_ActorPosX_i16_0_arr, x
ldy Ram_ActorPosX_i16_1_arr, x
lda Zp_PointX_i16 + 0
ldy Zp_PointX_i16 + 1
bmi _NotInRoom
bne @checkRightSide
cmp Zp_Current_sRoom + sRoom::MinScrollX_u8
blt _NotInRoom
@checkRightSide:
cmp Zp_Current_sRoom + sRoom::MaxScrollX_u16 + 0 ; room right side (lo)
tya ; actor pos X (hi)
tya ; point pos X (hi)
sbc T0 ; room right side (hi)
bge _NotInRoom
_IsInRoom:
Expand Down
24 changes: 22 additions & 2 deletions src/rooms/city_center.asm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.INCLUDE "../machine.inc"
.INCLUDE "../machines/semaphore.inc"
.INCLUDE "../macros.inc"
.INCLUDE "../oam.inc"
.INCLUDE "../platform.inc"
.INCLUDE "../portrait.inc"
.INCLUDE "../ppu.inc"
Expand Down Expand Up @@ -254,8 +255,25 @@ _Platforms_sPlatform_arr:
.assert * - :- <= kMaxPlatforms * .sizeof(sPlatform), error
.byte ePlatform::None
_Actors_sActor_arr:
: ;; TODO: add some baddies
;; TODO: add Alex/Gronta NPCs for cutscene
: ;; TODO: add Alex/Gronta NPCs for cutscene
D_STRUCT sActor
d_byte Type_eActor, eActor::BadRhino
d_word PosX_i16, $00b0
d_word PosY_i16, $00e8
d_byte Param_byte, bObj::FlipH
D_END
D_STRUCT sActor
d_byte Type_eActor, eActor::BadOrc
d_word PosX_i16, $0170
d_word PosY_i16, $0158
d_byte Param_byte, 0
D_END
D_STRUCT sActor
d_byte Type_eActor, eActor::BadOrc
d_word PosX_i16, $0324
d_word PosY_i16, $0158
d_byte Param_byte, bObj::FlipH
D_END
.assert * - :- <= kMaxActors * .sizeof(sActor), error
.byte eActor::None
_Devices_sDevice_arr:
Expand Down Expand Up @@ -467,6 +485,8 @@ _WriteRegLock:
.SEGMENT "PRGA_Room"

.PROC FuncA_Room_CityCenter_EnterRoom
;; TODO: If cutscene, halt machines and remove baddies.
;; TODO: If not cutscene, remove Alex/Gronta actors.
_UnlockDoor:
;; If the door has already been unlocked, unlock it.
flag_bit Sram_ProgressFlags_arr, eFlag::CityCenterDoorUnlocked
Expand Down
17 changes: 17 additions & 0 deletions src/rooms/city_outskirts.asm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ kAlexActorIndex = 0
kAlexDeviceIndexRight = 0
kAlexDeviceIndexLeft = 1

;;; The actor index for the rhino baddie in this room.
kRhinoActorIndex = 1

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

;;; The machine index for the CityOutskirtsLauncher machine.
Expand Down Expand Up @@ -173,6 +176,13 @@ _Actors_sActor_arr:
d_word PosY_i16, $0088
d_byte Param_byte, eNpcChild::AlexStanding
D_END
.assert * - :- = kRhinoActorIndex * .sizeof(sActor), error
D_STRUCT sActor
d_byte Type_eActor, eActor::BadRhino
d_word PosX_i16, $01b8
d_word PosY_i16, $00c8
d_byte Param_byte, 0
D_END
.assert * - :- <= kMaxActors * .sizeof(sActor), error
.byte eActor::None
_Devices_sDevice_arr:
Expand Down Expand Up @@ -266,6 +276,13 @@ _Alex:
sta Ram_DeviceType_eDevice_arr + kAlexDeviceIndexLeft
sta Ram_DeviceType_eDevice_arr + kAlexDeviceIndexRight
@keepAlex:
_Rhino:
;; The rhino baddie doesn't appear until after the lava breaker cutscene.
flag_bit Sram_ProgressFlags_arr, eFlag::BreakerLava
bne @keepRhino
lda #eActor::None
sta Ram_ActorType_eActor_arr + kRhinoActorIndex
@keepRhino:
_Rocks:
flag_bit Sram_ProgressFlags_arr, eFlag::CityOutskirtsBlastedRocks
bne @removeRocks
Expand Down
26 changes: 24 additions & 2 deletions src/rooms/core_west.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
;;;=========================================================================;;;

.INCLUDE "../actor.inc"
.INCLUDE "../flag.inc"
.INCLUDE "../macros.inc"
.INCLUDE "../oam.inc"
.INCLUDE "../platform.inc"
Expand All @@ -30,6 +31,8 @@
.IMPORT Data_Empty_sPlatform_arr
.IMPORT Func_Noop
.IMPORT Ppu_ChrObjCity
.IMPORT Ram_ActorType_eActor_arr
.IMPORT Sram_ProgressFlags_arr
.IMPORTZP Zp_AvatarPosX_i16
.IMPORTZP Zp_AvatarPosY_i16
.IMPORTZP Zp_Camera_bScroll
Expand All @@ -38,6 +41,9 @@

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

;;; The actor index for the orc baddie in this room.
kOrcActorIndex = 0

;;; The room pixel X- and Y-positions where the scroll lock axis changes.
kScrollCutoffPosX = $01a8
kScrollCutoffPosY = $00c0
Expand Down Expand Up @@ -67,7 +73,7 @@ _Ext_sRoomExt:
d_addr Actors_sActor_arr_ptr, _Actors_sActor_arr
d_addr Devices_sDevice_arr_ptr, Data_Empty_sDevice_arr
d_addr Passages_sPassage_arr_ptr, _Passages_sPassage_arr
d_addr Enter_func_ptr, FuncC_Core_West_UpdateScrollLock
d_addr Enter_func_ptr, FuncC_Core_West_EnterRoom
d_addr FadeIn_func_ptr, Func_Noop
d_addr Tick_func_ptr, FuncC_Core_West_UpdateScrollLock
d_addr Draw_func_ptr, Func_Noop
Expand All @@ -76,7 +82,14 @@ _TerrainData:
: .incbin "out/rooms/core_west.room"
.assert * - :- = 34 * 24, error
_Actors_sActor_arr:
: D_STRUCT sActor
: .assert * - :- = kOrcActorIndex * .sizeof(sActor), error
D_STRUCT sActor
d_byte Type_eActor, eActor::BadOrc
d_word PosX_i16, $006a
d_word PosY_i16, $00b8
d_byte Param_byte, 0
D_END
D_STRUCT sActor
d_byte Type_eActor, eActor::BadRhino
d_word PosX_i16, $018c
d_word PosY_i16, $00d8
Expand Down Expand Up @@ -112,6 +125,15 @@ _Passages_sPassage_arr:
.assert * - :- <= kMaxPassages * .sizeof(sPassage), error
.ENDPROC

.PROC FuncC_Core_West_EnterRoom
flag_bit Sram_ProgressFlags_arr, eFlag::PrisonUpperFreedKids
beq @keepOrc
lda #eActor::None
sta Ram_ActorType_eActor_arr + kOrcActorIndex
@keepOrc:
fall FuncC_Core_West_UpdateScrollLock
.ENDPROC

.PROC FuncC_Core_West_UpdateScrollLock
lda Zp_AvatarPosY_i16 + 0
cmp #<kScrollCutoffPosY
Expand Down

0 comments on commit 8e0a22b

Please sign in to comment.