diff --git a/src/chr.asm b/src/chr.asm index 84481e77..71d3630f 100644 --- a/src/chr.asm +++ b/src/chr.asm @@ -1264,7 +1264,6 @@ _chr_begin: .EXPORT Ppu_ChrObjFactory .PROC Ppu_ChrObjFactory CHR2_BANK $80 - chr_res $02 chr_inc "jet", kTileIdObjJetFirst chr_inc "rotor", kTileIdObjRotorFirst chr_res $07 diff --git a/src/machines/jet.asm b/src/machines/jet.asm index aa1aa7d7..18f46184 100644 --- a/src/machines/jet.asm +++ b/src/machines/jet.asm @@ -34,6 +34,7 @@ .IMPORT Func_DivMod .IMPORT Func_MovePlatformTopTowardPointY .IMPORT Ram_MachineGoalVert_u8_arr +.IMPORT Ram_MachineState1_byte_arr .IMPORT Ram_Oam_sObj_arr64 .IMPORT Ram_PlatformTop_i16_0_arr .IMPORT Ram_PlatformTop_i16_1_arr @@ -140,8 +141,30 @@ kTileIdObjJetLowerMiddleFirst = kTileIdObjJetFirst + 1 ;; Move the jet vertically, as necessary. ldx T1 ; param: platform index jsr Func_MovePlatformTopTowardPointY ; returns Z - jeq FuncA_Machine_ReachedGoal + beq _ReachedGoal +_Moved: + ldx Zp_MachineIndex_u8 + lda #kJetMaxFlamePower + sta Ram_MachineState1_byte_arr, x ; flame power rts +_ReachedGoal: + ;; Determine minimum flame power (0 if at min/max height, or + ;; kJetMaxFlamePower/2 if hovering). + ldx Zp_MachineIndex_u8 + lda #0 + ldy Ram_MachineGoalVert_u8_arr, x + beq @setMin ; jet is at minimum height + cpy #9 + beq @setMin ; jet is at maximum height + @hovering: + lda #kJetMaxFlamePower / 2 + @setMin: + ;; Decrement flame power (down to minimum). + cmp Ram_MachineState1_byte_arr, x ; flame power + bge @done + dec Ram_MachineState1_byte_arr, x ; flame power + @done: + jmp FuncA_Machine_ReachedGoal .ENDPROC ;;;=========================================================================;;; @@ -155,39 +178,47 @@ kTileIdObjJetLowerMiddleFirst = kTileIdObjJetFirst + 1 jsr FuncA_Objects_SetShapePosToMachineTopLeft ;; Calculate the offset to use for the tile IDs for the bottom of the jet. ldx Zp_MachineIndex_u8 - lda Ram_MachineGoalVert_u8_arr, x - beq @done + ldy #0 ; flame level + lda Ram_MachineState1_byte_arr, x ; flame power + beq @doneFlameLevel + iny ; now Y is 1 + cmp #kJetMaxFlamePower / 2 + 1 + blt @checkFrameCounter + iny ; now Y is 2 + @checkFrameCounter: lda Zp_FrameCounter_u8 and #$04 - lsr a - adc #$02 - @done: - tax ; tile ID offset + beq @doneFlameLevel + iny + @doneFlameLevel: + tya ; flame level + mul #2 + sta T2 ; tile ID offset _LeftHalf: ;; Allocate objects. - jsr FuncA_Objects_MoveShapeDownAndRightOneTile ; preserves X + jsr FuncA_Objects_MoveShapeDownAndRightOneTile ; preserves T0+ lda #kPaletteObjMachineLight ; param: object flags - jsr FuncA_Objects_Alloc2x2Shape ; preserves X, returns C and Y + jsr FuncA_Objects_Alloc2x2Shape ; preserves T2+, returns C and Y bcs @done ;; Set tile IDs. - stx T0 ; tile ID offset jsr FuncA_Objects_GetMachineLightTileId ; preserves Y and T0+, returns A - ldx T0 ; param: tile ID offset - jsr FuncA_Objects_SetJetMachineTiles ; preserves X and Y + ldx T2 ; param: tile ID offset + jsr FuncA_Objects_SetJetMachineTiles ; preserves T1+ @done: _RightHalf: ;; Allocate objects. lda #kTileWidthPx * 2 ; param: offset - jsr FuncA_Objects_MoveShapeRightByA ; preserves X + jsr FuncA_Objects_MoveShapeRightByA lda #kPaletteObjMachineLight | bObj::FlipH ; param: object flags - jsr FuncA_Objects_Alloc2x2Shape ; preserves X; returns C and Y + jsr FuncA_Objects_Alloc2x2Shape ; preserves T2+, returns C and Y bcc @notDone rts @notDone: lda #kPaletteObjMachineLight | bObj::FlipV sta Ram_Oam_sObj_arr64 + .sizeof(sObj) * 0 + sObj::Flags_bObj, y - lda #kTileIdObjJetUpperCorner - .assert * = FuncA_Objects_SetJetMachineTiles, error, "fallthrough" + lda #kTileIdObjJetUpperCorner ; param: upper corner tile ID + ldx T2 ; param: tile ID offset + fall FuncA_Objects_SetJetMachineTiles .ENDPROC ;;; Helper function for FuncA_Objects_DrawJetMachine. Populates object tile @@ -195,7 +226,7 @@ _RightHalf: ;;; @param A The tile ID for the upper corner tile. ;;; @param X The tile ID offset for the bottom two tiles. ;;; @param Y The OAM byte offset for the first of the four tiles. -;;; @preserve X, Y +;;; @preserve X, Y, T1+ .PROC FuncA_Objects_SetJetMachineTiles sta Ram_Oam_sObj_arr64 + .sizeof(sObj) * 0 + sObj::Tile_u8, y stx T0 ; tile ID offset diff --git a/src/machines/jet.inc b/src/machines/jet.inc index 1ce368ae..1d830228 100644 --- a/src/machines/jet.inc +++ b/src/machines/jet.inc @@ -18,7 +18,10 @@ ;;;=========================================================================;;; ;;; State bytes for jet machines: -;;; * State1: Unused. +;;; * State1: The jet flame power, from 0 to kJetMaxFlamePower. This gets +;;; set to kJetMaxFlamePower when the jet is moving; decrements when the +;;; jet is not moving (down to kJetMaxFlamePower/2 if hovering, or down to +;;; zero if at min/max height). ;;; * State2: Unused. ;;; * State3: Unused. @@ -32,6 +35,9 @@ kJetPlatformHeightPx = $0b ;;; How many pixels a jet machine normally moves per frame. kJetMoveSpeed = 3 +;;; The maximum value for a jet machine's flame power stored in State1. +kJetMaxFlamePower = 24 + ;;; The CHR bank number containing the diagram for jet machines. kChrBankDiagramJet = $09 @@ -39,6 +45,6 @@ kChrBankDiagramJet = $09 kTileIdBgDiagramJetFirst = $f0 ;;; The start of OBJ tile IDs used for drawing jet machines. -kTileIdObjJetFirst = $82 +kTileIdObjJetFirst = $80 ;;;=========================================================================;;; diff --git a/src/tiles/jet.ahi b/src/tiles/jet.ahi index e56354f0..9650cbe6 100644 --- a/src/tiles/jet.ahi +++ b/src/tiles/jet.ahi @@ -1,4 +1,4 @@ -ahi1 f0 p1 i3 w16 h8 +ahi1 f0 p1 i4 w16 h8 ;0;982220;ECEEEC;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0 @@ -14,11 +14,20 @@ ahi1 f0 p1 i3 w16 h8 3111333331111111 0333111113333333 0003223223000000 -0000231320000000 +0000022200000000 +0000002000000000 +0000000000000000 +0000000000000000 +0000000000000000 + +3111333331111111 +0333111113333333 +0003223223000000 0000223220000000 0000022200000000 0000002000000000 0000000000000000 +0000000000000000 3111333331111111 0333111113333333