Skip to content

Commit

Permalink
Animate the final terminal rising from the core
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Oct 28, 2024
1 parent 3ec2a5c commit a27251a
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/boss.asm
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ _FlipBreaker:
cmp #eDevice::BreakerRising
bne @finishedRising
lda Ram_DeviceAnim_u8_arr + kBossBreakerDeviceIndex
and #$03
mod #4
bne @done
lda #6 ; param: num frames
jmp Func_ShakeRoom
Expand Down
6 changes: 3 additions & 3 deletions src/chr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
.INCLUDE "platforms/gate.inc"
.INCLUDE "platforms/girder.inc"
.INCLUDE "platforms/glass.inc"
.INCLUDE "platforms/monitor.inc"
.INCLUDE "platforms/stepstone.inc"
.INCLUDE "platforms/terminal.inc"
.INCLUDE "platforms/water.inc"
.INCLUDE "portrait.inc"
.INCLUDE "rooms/boss_city.inc"
Expand Down Expand Up @@ -1216,7 +1216,7 @@ _chr_begin:
chr_inc "winch", kTileIdObjWinchFirst
chr_inc "proj_grenade", kTileIdObjProjGrenadeFirst
chr_inc "orc_gronta_crouch", kTileIdObjOrcGrontaCrouchFirst
chr_res $04
chr_inc "platform_terminal", kTileIdObjPlatformTerminalFirst
END_CHR_BANK
.ENDPROC

Expand Down Expand Up @@ -1422,7 +1422,7 @@ _chr_begin:
chr_inc "upgrade_opaddsub", kTileIdObjUpgradeOpAddSubFirst
chr_inc "machine_drums", kTileIdObjMachineDrumsFirst
chr_inc "npc_duck", kTileIdObjNpcDuckFirst
chr_inc "monitor", kTileIdObjMonitorFirst
chr_inc "platform_monitor", kTileIdObjPlatformMonitorFirst
chr_inc "platform_rocks", kTileIdObjPlatformRocksFirst
chr_res $02
chr_inc "bad_grub", kTileIdObjBadGrubFirst
Expand Down
16 changes: 13 additions & 3 deletions src/devices/console.asm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ kPaletteObjScreen = 1
;; If the device is animating, blink the console screen quickly.
lda Ram_DeviceAnim_u8_arr, x
and #$04
bne _Blank
bne FuncA_Objects_DrawDeviceScreenBlank ; preserves X
;; Check the machine's status.
ldy Ram_DeviceTarget_byte_arr, x ; machine index
lda Ram_MachineStatus_eMachine_arr, y
Expand All @@ -90,7 +90,7 @@ _Error:
;; Blink the console screen slowly.
lda Zp_FrameCounter_u8
and #$08
beq _Blank
beq FuncA_Objects_DrawDeviceScreenBlank ; preserves X
;; Draw the error screen.
ldy #kPaletteObjConsoleErr ; param: object flags
lda #kTileIdObjConsoleErr ; param: tile ID
Expand All @@ -101,7 +101,12 @@ _Ok:
lda #kTileIdObjConsoleOk ; param: tile ID
_Draw:
jmp FuncA_Objects_Draw1x1Shape ; preserves X
_Blank:
.ENDPROC

;;; Draws a console or screen device that's blank.
;;; @param X The device index.
;;; @preserve X
.PROC FuncA_Objects_DrawDeviceScreenBlank
rts
.ENDPROC

Expand Down Expand Up @@ -139,6 +144,11 @@ _Blank:
;;; @preserve X
.EXPORT FuncA_Objects_DrawDeviceScreenRed
.PROC FuncA_Objects_DrawDeviceScreenRed
;; If the device is animating, blink the screen quickly.
lda Ram_DeviceAnim_u8_arr, x
and #$04
bne FuncA_Objects_DrawDeviceScreenBlank ; preserves X
;; Draw the sceeen.
lda #kPaletteObjScreen ; param: object flags
fall FuncA_Objects_DrawDeviceScreenFloor
.ENDPROC
Expand Down
30 changes: 26 additions & 4 deletions src/platforms/monitor.asm → src/platforms/terminal.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
;;;=========================================================================;;;

.INCLUDE "../macros.inc"
.INCLUDE "monitor.inc"
.INCLUDE "../oam.inc"
.INCLUDE "terminal.inc"

.IMPORT FuncA_Objects_Draw2x2Shape
.IMPORT FuncA_Objects_MoveShapeDownAndRightOneTile
Expand All @@ -27,7 +28,7 @@
;;;=========================================================================;;;

;;; The OBJ palette number used for drawing monitor platforms.
kPaletteObjMonitor = 0
kPaletteObjTerminal = 0

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

Expand All @@ -38,10 +39,31 @@ kPaletteObjMonitor = 0
;;; @param X The platform index.
.EXPORT FuncA_Objects_DrawMonitorPlatform
.PROC FuncA_Objects_DrawMonitorPlatform
lda #kTileIdObjPlatformMonitorFirst ; param: first tile ID
.assert kTileIdObjPlatformMonitorFirst > 0, error
bne FuncA_Objects_DrawTerminalOrMonitorPlatform ; unconditional
.ENDPROC

;;; Draws a platform that is a console terminal. The platform width should be
;;; kBlockWidthPx and the platform height should be kBlockHeightPx.
;;; @param X The platform index.
.EXPORT FuncA_Objects_DrawTerminalPlatform
.PROC FuncA_Objects_DrawTerminalPlatform
lda #kTileIdObjPlatformTerminalFirst ; param: first tile ID
fall FuncA_Objects_DrawTerminalOrMonitorPlatform
.ENDPROC

;;; Draws a platform that is a console terminal or monitor. The platform width
;;; should be kBlockWidthPx and the platform height should be kBlockHeightPx.
;;; @param A The first tile ID.
;;; @param X The platform index.
;;; @preserve X
.PROC FuncA_Objects_DrawTerminalOrMonitorPlatform
pha ; first tile ID
jsr FuncA_Objects_SetShapePosToPlatformTopLeft ; preserves X
jsr FuncA_Objects_MoveShapeDownAndRightOneTile ; preserves X
lda #kTileIdObjMonitorFirst ; param: first tile ID
ldy #kPaletteObjMonitor ; param: flags
pla ; param: first tile ID
ldy #bObj::Pri | kPaletteObjTerminal ; param: flags
jmp FuncA_Objects_Draw2x2Shape ; preserves X and T2+
.ENDPROC

Expand Down
5 changes: 4 additions & 1 deletion src/platforms/monitor.inc → src/platforms/terminal.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
;;;=========================================================================;;;

;;; OBJ tile IDs for drawing monitor platforms.
kTileIdObjMonitorFirst = $94
kTileIdObjPlatformMonitorFirst = $94

;;; OBJ tile IDs for drawing terminal platforms.
kTileIdObjPlatformTerminalFirst = $fc

;;;=========================================================================;;;
48 changes: 44 additions & 4 deletions src/rooms/core_boss.asm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
.INCLUDE "../cpu.inc"
.INCLUDE "../cutscene.inc"
.INCLUDE "../device.inc"
.INCLUDE "../devices/console.inc"
.INCLUDE "../dialog.inc"
.INCLUDE "../flag.inc"
.INCLUDE "../machine.inc"
Expand Down Expand Up @@ -55,6 +56,7 @@
.IMPORT DataA_Text1_CoreBossScreen_Intro_u8_arr
.IMPORT DataA_Text1_CoreBossScreen_Reactivate_u8_arr
.IMPORT DataA_Text1_CoreBossScreen_SelfDestruct_u8_arr
.IMPORT FuncA_Cutscene_PlaySfxBreakerRising
.IMPORT FuncA_Machine_BlasterTick
.IMPORT FuncA_Machine_BlasterTryAct
.IMPORT FuncA_Machine_BlasterWriteRegM
Expand All @@ -77,6 +79,7 @@
.IMPORT FuncA_Objects_DrawBlasterMirror
.IMPORT FuncA_Objects_DrawCannonMachine
.IMPORT FuncA_Objects_DrawLaserMachine
.IMPORT FuncA_Objects_DrawTerminalPlatform
.IMPORT FuncA_Objects_DrawWinchMachineWithSpikeball
.IMPORT FuncA_Objects_MoveShapeDownOneTile
.IMPORT FuncA_Objects_SetShapePosToPlatformTopLeft
Expand Down Expand Up @@ -110,6 +113,7 @@
.IMPORT Func_MovePlatformHorz
.IMPORT Func_MovePlatformLeftTowardPointX
.IMPORT Func_MovePlatformTopTowardPointY
.IMPORT Func_MovePlatformVert
.IMPORT Func_Noop
.IMPORT Func_PlaySfxExplodeSmall
.IMPORT Func_ResetWinchMachineState
Expand All @@ -119,6 +123,7 @@
.IMPORT Func_SetPointToAvatarCenter
.IMPORT Func_SetPointToPlatformCenter
.IMPORT Func_SetScrollGoalFromPoint
.IMPORT Func_ShakeRoom
.IMPORT Ppu_ChrObjBoss3
.IMPORT Ram_ActorFlags_bObj_arr
.IMPORT Ram_ActorPosX_i16_0_arr
Expand All @@ -131,6 +136,7 @@
.IMPORT Ram_ActorVelX_i16_1_arr
.IMPORT Ram_ActorVelY_i16_0_arr
.IMPORT Ram_ActorVelY_i16_1_arr
.IMPORT Ram_DeviceAnim_u8_arr
.IMPORT Ram_DeviceType_eDevice_arr
.IMPORT Ram_MachineGoalHorz_u8_arr
.IMPORT Ram_MachineGoalVert_u8_arr
Expand Down Expand Up @@ -186,6 +192,9 @@ kCutsceneZonePlatformIndex = 7
;;; The platform index for the wall that blocks the passage during the boss
;;; fight.
kPassageBarrierPlatformIndex = 8
;;; The platform index for drawing the final terminal that rises out of the
;;; core.
kFinalTerminalPlatformIndex = 9

;;; The initial value for the blaster's M (mirror) register.
kBlasterInitGoalM = 5
Expand Down Expand Up @@ -465,6 +474,14 @@ _Platforms_sPlatform_arr:
d_word Left_i16, $0018
d_word Top_i16, $0140
D_END
.assert * - :- = kFinalTerminalPlatformIndex * .sizeof(sPlatform), error
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Zone
d_word WidthPx_u16, $10
d_byte HeightPx_u8, $10
d_word Left_i16, $0110
d_word Top_i16, $0070
D_END
;; Top corners of reactor:
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Solid
Expand Down Expand Up @@ -1846,6 +1863,13 @@ _Col1:
.SEGMENT "PRGA_Objects"

.PROC FuncA_Objects_CoreBoss_DrawRoom
_FinalTerminal:
lda Zp_RoomState + sState::Current_eGrontaPhase
cmp #eGrontaPhase::Defeated
bne @done
ldx #kFinalTerminalPlatformIndex ; param: platform index
jsr FuncA_Objects_DrawTerminalPlatform
@done:
_PassageBarrier:
lda Ram_PlatformType_ePlatform_arr + kPassageBarrierPlatformIndex
cmp #kFirstSolidPlatformType
Expand Down Expand Up @@ -2021,8 +2045,11 @@ _ChangeGrontaFromNpcToBad:
act_SetScrollFlags 0
act_CallFunc _LookAtTopOfCore
act_WaitFrames 60
act_CallFunc _MakeFinalTerminalAppear
act_WaitFrames 60
act_CallFunc FuncA_Cutscene_PlaySfxBreakerRising
act_RepeatFunc 64, _RaiseFinalTerminal
act_WaitFrames 30
act_CallFunc _TurnOnFinalTerminal
act_WaitFrames 90
act_ContinueExploring
_MakeGrontaDefeated:
lda #eGrontaPhase::Defeated
Expand Down Expand Up @@ -2052,10 +2079,23 @@ _LookAtTopOfCore:
stax Zp_ScrollGoalX_u16
sta Zp_ScrollGoalY_u8
rts
_MakeFinalTerminalAppear:
;; TODO: animate the terminal rising from the core
_RaiseFinalTerminal:
txa ; repeat counter
mod #4
bne @done
ldx #kFinalTerminalPlatformIndex ; param: platform index
lda #<-1 ; param: move by
jsr Func_MovePlatformVert
lda #6 ; param: num frames
jmp Func_ShakeRoom
@done:
rts
_TurnOnFinalTerminal:
lda #eDevice::ScreenRed
sta Ram_DeviceType_eDevice_arr + kFinalTerminalDeviceIndex
lda #kConsoleAnimCountdown
sta Ram_DeviceAnim_u8_arr + kFinalTerminalDeviceIndex
;; TODO: play a sound for the terminal turning on
rts
.ENDPROC

Expand Down
8 changes: 8 additions & 0 deletions src/sounds/breaker.asm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
jmp Func_PlaySfxSequenceNoise ; preserves T0+
.ENDPROC

;;; Starts playing the sound for when a breaker device rises from the floor.
;;; @preserve T0+
.EXPORT FuncA_Cutscene_PlaySfxBreakerRising
.PROC FuncA_Cutscene_PlaySfxBreakerRising
ldya #Data_BreakerRising_sSfxSeq_arr
jmp Func_PlaySfxSequenceNoise ; preserves T0+
.ENDPROC

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

.SEGMENT "PRGA_Room"
Expand Down
16 changes: 8 additions & 8 deletions src/tiles/core_pipes2.ahi
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ ahi1 f0 p1 i12 w8 h8
31111113
33333333

00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111

03000003
33300333
Expand Down
39 changes: 0 additions & 39 deletions src/tiles/monitor.ahi

This file was deleted.

20 changes: 20 additions & 0 deletions src/tiles/platform_monitor.ahi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ahi1 f0 p1 i1 w16 h16

0;FF0;54;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0

0000000000000000
0000222222220000
0002000000002000
0002000000002200
0002000000002200
0002000000002200
0002000000002200
0002000000002200
0002000000002200
0002222222222000
0000002222000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
20 changes: 20 additions & 0 deletions src/tiles/platform_terminal.ahi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ahi1 f0 p1 i1 w16 h16

00080;0;54;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0

0000000000000000
0000222222220000
0002000000002000
0002000000002200
0002000000002200
0002000000002200
0002000000002200
0002000000002200
0002000000002200
0002222222222000
0000002222000000
0002222222222000
0002111221212000
0002222222222000
0002222222222000
0002222222222000
2 changes: 1 addition & 1 deletion src/tilesets/core.bg
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ BABABBBBBBBCBDBBBEBABABFBDBCBABABBBCBDBB DG BABABBBBBDCABOBP
GAGBGAGBGA GBGA GB DEEE BBBBCABDBCBABACABCBDGAGB
GB GAGB GAGBGAGBGA DIDM BEBFBBBBCABABABFBEBFGBGA
EADEDEEBDG DHDG DHDG DFEGEADEDEEBDEDE DFDFEEDEDFDFDFDF
DG DHDG DHDEDEDEDEDEEEDG DKDODPDL DEDE DKDODG DH
DG DHDG DHDEDEDEDEDEEEDG DKDODPDLCBCBDEDE DKDODG DH

0 comments on commit a27251a

Please sign in to comment.