Skip to content

Commit

Permalink
Add Harm platform for jet machine flames
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Aug 28, 2024
1 parent 3d9d705 commit a52f0c9
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/machines/jet.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
.IMPORT FuncA_Objects_SetShapePosToMachineTopLeft
.IMPORT Func_DivMod
.IMPORT Func_MovePlatformTopTowardPointY
.IMPORT Func_MovePlatformVert
.IMPORT Ram_MachineGoalVert_u8_arr
.IMPORT Ram_MachineState1_byte_arr
.IMPORT Ram_Oam_sObj_arr64
Expand Down Expand Up @@ -140,9 +141,12 @@ kTileIdObjJetLowerMiddleFirst = kTileIdObjJetFirst + 1
jsr FuncA_Machine_DoubleIfResetting ; preserves T0+, returns A
;; Move the jet vertically, as necessary.
ldx T1 ; param: platform index
jsr Func_MovePlatformTopTowardPointY ; returns Z
jsr Func_MovePlatformTopTowardPointY ; preserves X, returns Z and A
beq _ReachedGoal
_Moved:
;; Move the jet's flame platform to match.
inx ; param: platform index
jsr Func_MovePlatformVert
ldx Zp_MachineIndex_u8
lda #kJetMaxFlamePower
sta Ram_MachineState1_byte_arr, x ; flame power
Expand Down
9 changes: 9 additions & 0 deletions src/machines/jet.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
kJetPlatformWidthPx = $20
kJetPlatformHeightPx = $0b

;;; The size of a jet machine's flame platform, in pixels.
kJetFlameWidthPx = $18
kJetFlameHeightPx = $05

;;; The offset for a jet machine's flame platform position, releative to its
;;; main platform position.
kJetFlameOffsetX = (kJetPlatformWidthPx - kJetFlameWidthPx) / 2
kJetFlameOffsetY = $08

;;; How many pixels a jet machine moves per tick of its Y register.
.DEFINE kJetMoveInterval $30

Expand Down
7 changes: 7 additions & 0 deletions src/rooms/core_elevator.asm
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ _Platforms_sPlatform_arr:
d_word Left_i16, $0080
d_word Top_i16, kJetInitPlatformTop
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Harm
d_word WidthPx_u16, kJetFlameWidthPx
d_byte HeightPx_u8, kJetFlameHeightPx
d_word Left_i16, $0080 + kJetFlameOffsetX
d_word Top_i16, kJetInitPlatformTop + kJetFlameOffsetY
D_END
.assert * - :- <= kMaxPlatforms * .sizeof(sPlatform), error
.byte ePlatform::None
_Devices_sDevice_arr:
Expand Down
32 changes: 30 additions & 2 deletions src/rooms/factory_elevator.asm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ kBrunoDeviceIndexLeft = 5
kBrunoDeviceIndexRight = 4

;;; The platform index for the zone where Bruno asks you to wait up.
kWaitUpZonePlatformIndex = 2
kWaitUpZonePlatformIndex = 4

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

Expand All @@ -109,7 +109,7 @@ kLowerJetMachineIndex = 1

;;; The platform indices for the jet machines in this room.
kUpperJetPlatformIndex = 0
kLowerJetPlatformIndex = 1
kLowerJetPlatformIndex = 2

;;; The initial and maximum permitted values for the jets' Y-goals.
kUpperJetInitGoalY = 9
Expand Down Expand Up @@ -213,6 +213,13 @@ _Platforms_sPlatform_arr:
d_word Left_i16, $0080
d_word Top_i16, $ffff & kUpperJetInitPlatformTop
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Harm
d_word WidthPx_u16, kJetFlameWidthPx
d_byte HeightPx_u8, kJetFlameHeightPx
d_word Left_i16, $0080 + kJetFlameOffsetX
d_word Top_i16, $ffff & (kUpperJetInitPlatformTop + kJetFlameOffsetY)
D_END
.assert * - :- = kLowerJetPlatformIndex * .sizeof(sPlatform), error
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Solid
Expand All @@ -221,6 +228,13 @@ _Platforms_sPlatform_arr:
d_word Left_i16, $0080
d_word Top_i16, kLowerJetInitPlatformTop
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Harm
d_word WidthPx_u16, kJetFlameWidthPx
d_byte HeightPx_u8, kJetFlameHeightPx
d_word Left_i16, $0080 + kJetFlameOffsetX
d_word Top_i16, kLowerJetInitPlatformTop + kJetFlameOffsetY
D_END
.assert * - :- = kWaitUpZonePlatformIndex * .sizeof(sPlatform), error
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Zone
Expand Down Expand Up @@ -512,6 +526,20 @@ _Hud:
lda Ram_PlatformTop_i16_1_arr, y
adc #0
sta Ram_PlatformBottom_i16_1_arr, y
;; Set flame platform top position relative to main platform.
lda Ram_PlatformTop_i16_0_arr, y
add #kJetFlameOffsetY
sta Ram_PlatformTop_i16_0_arr + 1, y
lda Ram_PlatformTop_i16_1_arr, y
adc #0
sta Ram_PlatformTop_i16_1_arr + 1, y
;; Set flame platform bottom position relative to top.
lda Ram_PlatformTop_i16_0_arr + 1, y
add #kJetFlameHeightPx
sta Ram_PlatformBottom_i16_0_arr + 1, y
lda Ram_PlatformTop_i16_1_arr, y
adc #0
sta Ram_PlatformBottom_i16_1_arr + 1, y
;; Init machine state from previous room.
lda Zp_RoomState + sElevatorState::PrevJetStatus_eMachine
sta Ram_MachineStatus_eMachine_arr, x
Expand Down
7 changes: 7 additions & 0 deletions src/rooms/mermaid_elevator.asm
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ _Platforms_sPlatform_arr:
d_word Left_i16, $0080
d_word Top_i16, kJetInitPlatformTop
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Harm
d_word WidthPx_u16, kJetFlameWidthPx
d_byte HeightPx_u8, kJetFlameHeightPx
d_word Left_i16, $0080 + kJetFlameOffsetX
d_word Top_i16, kJetInitPlatformTop + kJetFlameOffsetY
D_END
;; Water:
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Water
Expand Down

0 comments on commit a52f0c9

Please sign in to comment.