Skip to content

Commit

Permalink
Add ConsoleCeiling device type for ShadowDrill room
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Jun 11, 2024
1 parent e777369 commit 152e48a
Show file tree
Hide file tree
Showing 74 changed files with 284 additions and 248 deletions.
5 changes: 4 additions & 1 deletion src/boss.asm
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,11 @@ _DisableConsoles:
ldx #kMaxDevices - 1
@loop:
lda Ram_DeviceType_eDevice_arr, x
cmp #eDevice::Console
cmp #eDevice::ConsoleFloor
beq @disable
cmp #eDevice::ConsoleCeiling
bne @continue
@disable:
lda #eDevice::Placeholder
sta Ram_DeviceType_eDevice_arr, x
@continue:
Expand Down
56 changes: 29 additions & 27 deletions src/device.asm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
.IMPORT FuncA_Objects_DrawDeviceBreakerDone
.IMPORT FuncA_Objects_DrawDeviceBreakerReady
.IMPORT FuncA_Objects_DrawDeviceBreakerRising
.IMPORT FuncA_Objects_DrawDeviceConsole
.IMPORT FuncA_Objects_DrawDeviceConsoleCeiling
.IMPORT FuncA_Objects_DrawDeviceConsoleFloor
.IMPORT FuncA_Objects_DrawDeviceFakeConsole
.IMPORT FuncA_Objects_DrawDeviceFlower
.IMPORT FuncA_Objects_DrawDeviceLeverCeiling
Expand Down Expand Up @@ -171,32 +172,33 @@ _Continue:
D_TABLE_LO table, _JumpTable_ptr_0_arr
D_TABLE_HI table, _JumpTable_ptr_1_arr
D_TABLE .enum, eDevice
d_entry table, None, Func_Noop
d_entry table, Boiler, Func_Noop
d_entry table, BreakerDone, FuncA_Objects_DrawDeviceBreakerDone
d_entry table, BreakerRising, FuncA_Objects_DrawDeviceBreakerRising
d_entry table, Door1Locked, FuncA_Objects_DrawDeviceLockedDoor
d_entry table, FlowerInert, FuncA_Objects_DrawDeviceFlower
d_entry table, Mousehole, Func_Noop
d_entry table, Placeholder, Func_Noop
d_entry table, Teleporter, FuncA_Objects_DrawDeviceTeleporter
d_entry table, BreakerReady, FuncA_Objects_DrawDeviceBreakerReady
d_entry table, Console, FuncA_Objects_DrawDeviceConsole
d_entry table, Door1Open, Func_Noop
d_entry table, Door1Unlocked, FuncA_Objects_DrawDeviceUnlockedDoor
d_entry table, Door2Open, Func_Noop
d_entry table, Door3Open, Func_Noop
d_entry table, FakeConsole, FuncA_Objects_DrawDeviceFakeConsole
d_entry table, Flower, FuncA_Objects_DrawDeviceFlower
d_entry table, LeverCeiling, FuncA_Objects_DrawDeviceLeverCeiling
d_entry table, LeverFloor, FuncA_Objects_DrawDeviceLeverFloor
d_entry table, Paper, FuncA_Objects_DrawDevicePaper
d_entry table, ScreenGreen, FuncA_Objects_DrawDeviceScreenGreen
d_entry table, ScreenRed, FuncA_Objects_DrawDeviceScreenRed
d_entry table, Sign, Func_Noop
d_entry table, TalkLeft, Func_Noop
d_entry table, TalkRight, Func_Noop
d_entry table, Upgrade, FuncA_Objects_DrawDeviceUpgrade
d_entry table, None, Func_Noop
d_entry table, Boiler, Func_Noop
d_entry table, BreakerDone, FuncA_Objects_DrawDeviceBreakerDone
d_entry table, BreakerRising, FuncA_Objects_DrawDeviceBreakerRising
d_entry table, Door1Locked, FuncA_Objects_DrawDeviceLockedDoor
d_entry table, FlowerInert, FuncA_Objects_DrawDeviceFlower
d_entry table, Mousehole, Func_Noop
d_entry table, Placeholder, Func_Noop
d_entry table, Teleporter, FuncA_Objects_DrawDeviceTeleporter
d_entry table, BreakerReady, FuncA_Objects_DrawDeviceBreakerReady
d_entry table, ConsoleCeiling, FuncA_Objects_DrawDeviceConsoleCeiling
d_entry table, ConsoleFloor, FuncA_Objects_DrawDeviceConsoleFloor
d_entry table, Door1Open, Func_Noop
d_entry table, Door1Unlocked, FuncA_Objects_DrawDeviceUnlockedDoor
d_entry table, Door2Open, Func_Noop
d_entry table, Door3Open, Func_Noop
d_entry table, FakeConsole, FuncA_Objects_DrawDeviceFakeConsole
d_entry table, Flower, FuncA_Objects_DrawDeviceFlower
d_entry table, LeverCeiling, FuncA_Objects_DrawDeviceLeverCeiling
d_entry table, LeverFloor, FuncA_Objects_DrawDeviceLeverFloor
d_entry table, Paper, FuncA_Objects_DrawDevicePaper
d_entry table, ScreenGreen, FuncA_Objects_DrawDeviceScreenGreen
d_entry table, ScreenRed, FuncA_Objects_DrawDeviceScreenRed
d_entry table, Sign, Func_Noop
d_entry table, TalkLeft, Func_Noop
d_entry table, TalkRight, Func_Noop
d_entry table, Upgrade, FuncA_Objects_DrawDeviceUpgrade
D_END
.ENDREPEAT
.ENDPROC
Expand Down
52 changes: 26 additions & 26 deletions src/device.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,35 @@ kMaxDevices = 16
.ENUM eDevice
;; Non-interactive device types; these generally act as temporary
;; placeholders for interactive devices.
None ; empty slot
Boiler ; boiler tank that can be hit by a fireblast
BreakerDone ; circuit breaker, after being activated
BreakerRising ; circuit breaker, rising out of the ground
Door1Locked ; leads to another Door1*; can't be entered until unlocked
FlowerInert ; a flower that can't be picked
Mousehole ; used by rodent baddies
Placeholder ; invisible and does nothing
Teleporter ; invisible spawn point for teleport field machines
None ; empty slot
Boiler ; boiler tank that can be hit by a fireblast
BreakerDone ; circuit breaker, after being activated
BreakerRising ; circuit breaker, rising out of the ground
Door1Locked ; leads to another Door1*; can't be entered until unlocked
FlowerInert ; a flower that can't be picked
Mousehole ; used by rodent baddies
Placeholder ; invisible and does nothing
Teleporter ; invisible spawn point for teleport field machines
;; Interactive device types. The player can interact with these by
;; pressing the B button while standing in front of them.
BreakerReady ; circuit breaker, ready to be activated
Console ; operates a machine
Door1Open ; leads to another Door1*; is never locked
Door1Unlocked ; leads to another Door1*; can be locked by room scripts
Door2Open ; leads to another Door2*; is never locked
Door3Open ; leads to another Door3*; is never locked
FakeConsole ; opens a console-looking window with an error message
BreakerReady ; circuit breaker, ready to be activated
ConsoleCeiling ; operates a machine
ConsoleFloor ; operates a machine
Door1Open ; leads to another Door1*; is never locked
Door1Unlocked ; leads to another Door1*; can be locked by room scripts
Door2Open ; leads to another Door2*; is never locked
Door3Open ; leads to another Door3*; is never locked
FakeConsole ; opens a console-looking window with an error message
Flower
LeverCeiling
LeverFloor
Paper ; collects the paper, and initiates dialogue for it
ScreenGreen ; initiates dialogue with the avatar's back to the camera
ScreenRed ; initiates dialogue with the avatar's back to the camera
Sign ; initiates dialogue with the avatar's back to the camera
TalkLeft ; initiates dialogue with the avatar facing to the left
TalkRight ; initiates dialogue with the avatar facing to the right
Upgrade
Paper ; collects the paper, and initiates dialogue for it
ScreenGreen ; initiates dialogue with the avatar's back to the camera
ScreenRed ; initiates dialogue with the avatar's back to the camera
Sign ; initiates dialogue with the avatar's back to the camera
TalkLeft ; initiates dialogue with the avatar facing to the left
TalkRight ; initiates dialogue with the avatar facing to the right
Upgrade ; collects the upgrade
NUM_VALUES
.ENDENUM

Expand Down Expand Up @@ -87,13 +88,12 @@ kFirstInteractiveDeviceType = eDevice::BreakerReady
;; The "target" for this device, whose meaning depends on the device type:
;; * For boilers, this is the bBoiler value.
;; * For breakers, this is the eFlag::Breaker* value.
;; * For (real) consoles, this is the machine index (i.e. the index into
;; the current room's sRoom::Machines_sMachine_arr_ptr).
;; * For (real) consoles, this is the machine index.
;; * For doors, this is the eRoom value for the destination room.
;; * For fake consoles, this is the eFake value.
;; * For flowers, this is the eFlag::Flower* value.
;; * For levers, this is the byte offset into Zp_RoomState for the
;; lever's state value (0 or 1).
;; lever's state value.
;; * For mouseholes, this is the bMousehole value.
;; * For papers, this is the eFlag::Paper* value.
;; * For screen/sign/talk devices, this is the eDialog value.
Expand Down
93 changes: 61 additions & 32 deletions src/devices/console.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.INCLUDE "../oam.inc"

.IMPORT FuncA_Objects_Draw1x1Shape
.IMPORT FuncA_Objects_MoveShapeDownByA
.IMPORT FuncA_Objects_MoveShapeRightHalfTile
.IMPORT FuncA_Objects_SetShapePosToDeviceTopLeft
.IMPORT Ram_DeviceAnim_u8_arr
Expand All @@ -46,43 +47,55 @@ kPaletteObjScreen = 1

.SEGMENT "PRGA_Objects"

;;; Draws a ceiling console device.
;;; @param X The device index.
;;; @preserve X
.EXPORT FuncA_Objects_DrawDeviceConsoleCeiling
.PROC FuncA_Objects_DrawDeviceConsoleCeiling
ldy #5 ; param: vertical offset
bne FuncA_Objects_DrawDeviceConsole ; unconditional; preserves X
.ENDPROC

;;; Draws a floor console device.
;;; @param X The device index.
;;; @preserve X
.EXPORT FuncA_Objects_DrawDeviceConsoleFloor
.PROC FuncA_Objects_DrawDeviceConsoleFloor
ldy #0 ; param: vertical offset
fall FuncA_Objects_DrawDeviceConsole ; preserves X
.ENDPROC

;;; Draws a console device.
;;; @param X The device index.
;;; @param Y The vertical offset for the object to draw.
;;; @preserve X
.EXPORT FuncA_Objects_DrawDeviceConsole
.PROC FuncA_Objects_DrawDeviceConsole
;; The the device is animating, blink the console screen quickly.
jsr FuncA_Objects_SetShapePosForDeviceScreenWithOffset ; preserves X
;; If the device is animating, blink the console screen quickly.
lda Ram_DeviceAnim_u8_arr, x
and #$04
bne FuncA_Objects_DrawDeviceConsoleBlank ; preserves X
bne _Blank
;; Check the machine's status.
ldy Ram_DeviceTarget_byte_arr, x ; machine index
lda Ram_MachineStatus_eMachine_arr, y
cmp #eMachine::Error
bne FuncA_Objects_DrawDeviceConsoleOk ; preserves X
fall FuncA_Objects_DrawDeviceConsoleErr ; preserves X
.ENDPROC

;;; Draws a console device for a machine with an error.
;;; @param X The device index.
;;; @preserve X
.PROC FuncA_Objects_DrawDeviceConsoleErr
bne _Ok
_Error:
;; Blink the console screen slowly.
lda Zp_FrameCounter_u8
and #$08
beq FuncA_Objects_DrawDeviceConsoleBlank ; preserves X
beq _Blank
;; Draw the error screen.
jsr FuncA_Objects_SetShapePosToDeviceTopLeft ; preserves X
jsr FuncA_Objects_MoveShapeRightHalfTile ; preserves X
ldy #kPaletteObjConsoleErr ; param: object flags
lda #kTileIdObjConsoleErr ; param: tile ID
.assert kTileIdObjConsoleErr > 0, error
bne _Draw ; unconditional
_Ok:
ldy #kPaletteObjConsoleOk ; param: object flags
lda #kTileIdObjConsoleOk ; param: tile ID
_Draw:
jmp FuncA_Objects_Draw1x1Shape ; preserves X
.ENDPROC

;;; Draws a console device whose screen is currently blank.
;;; @param X The device index.
;;; @preserve X
.PROC FuncA_Objects_DrawDeviceConsoleBlank
_Blank:
rts
.ENDPROC

Expand All @@ -91,13 +104,6 @@ kPaletteObjScreen = 1
;;; @preserve X
.EXPORT FuncA_Objects_DrawDeviceFakeConsole
.PROC FuncA_Objects_DrawDeviceFakeConsole
fall FuncA_Objects_DrawDeviceConsoleOk ; preserves X
.ENDPROC

;;; Draws a console device for a machine that doesn't have an error.
;;; @param X The device index.
;;; @preserve X
.PROC FuncA_Objects_DrawDeviceConsoleOk
fall FuncA_Objects_DrawDeviceScreenGreen ; preserves X
.ENDPROC

Expand All @@ -106,7 +112,7 @@ kPaletteObjScreen = 1
;;; @preserve X
.EXPORT FuncA_Objects_DrawDeviceScreenGreen
.PROC FuncA_Objects_DrawDeviceScreenGreen
ldy #kPaletteObjConsoleOk ; param: object flags
lda #kPaletteObjConsoleOk ; param: object flags
.assert kPaletteObjConsoleOk <> 0, error
bne FuncA_Objects_DrawDeviceScreen ; unconditional, preserves X
.ENDPROC
Expand All @@ -116,19 +122,42 @@ kPaletteObjScreen = 1
;;; @preserve X
.EXPORT FuncA_Objects_DrawDeviceScreenRed
.PROC FuncA_Objects_DrawDeviceScreenRed
ldy #kPaletteObjScreen ; param: object flags
lda #kPaletteObjScreen ; param: object flags
fall FuncA_Objects_DrawDeviceScreen
.ENDPROC

;;; Draws a screen device.
;;; @param X The device index.
;;; @param Y The bObj value for the object flags.
;;; @param A The bObj value for the object flags.
;;; @preserve X
.PROC FuncA_Objects_DrawDeviceScreen
jsr FuncA_Objects_SetShapePosToDeviceTopLeft ; preserves X and Y
jsr FuncA_Objects_MoveShapeRightHalfTile ; preserves X and Y
pha ; object flags
jsr FuncA_Objects_SetShapePosForDeviceScreenNormal ; preserves X
pla ; object flags
tay ; param: object flags
lda #kTileIdObjScreen ; param: tile ID
jmp FuncA_Objects_Draw1x1Shape ; preserves X
.ENDPROC

;;; Sets the shape position for drawing a console or screen device with no
;;; vertical offset.
;;; @param X The device index.
;;; @preserve X
.PROC FuncA_Objects_SetShapePosForDeviceScreenNormal
ldy #0 ; param: vertical offset
fall FuncA_Objects_SetShapePosForDeviceScreenWithOffset
.ENDPROC

;;; Sets the shape position for drawing a console or screen device with the
;;; given vertical offset.
;;; @param X The device index.
;;; @param Y The vertical offset for the object to draw.
;;; @preserve X
.PROC FuncA_Objects_SetShapePosForDeviceScreenWithOffset
jsr FuncA_Objects_SetShapePosToDeviceTopLeft ; preserves X and Y
tya ; param: vertical offset
jsr FuncA_Objects_MoveShapeDownByA ; preserves X
jmp FuncA_Objects_MoveShapeRightHalfTile ; preserves X
.ENDPROC

;;;=========================================================================;;;
53 changes: 27 additions & 26 deletions src/explore.asm
Original file line number Diff line number Diff line change
Expand Up @@ -318,32 +318,33 @@ _CheckForActivateDevice:
D_TABLE_LO table, _JumpTable_ptr_0_arr
D_TABLE_HI table, _JumpTable_ptr_1_arr
D_TABLE .enum, eDevice
d_entry table, None, _ContinueExploring
d_entry table, Boiler, _ContinueExploring
d_entry table, BreakerDone, _ContinueExploring
d_entry table, BreakerRising, _ContinueExploring
d_entry table, Door1Locked, _ContinueExploring
d_entry table, FlowerInert, _ContinueExploring
d_entry table, Mousehole, _ContinueExploring
d_entry table, Placeholder, _ContinueExploring
d_entry table, Teleporter, _ContinueExploring
d_entry table, BreakerReady, _DeviceBreaker
d_entry table, Console, _DeviceConsole
d_entry table, Door1Open, _DeviceDoor
d_entry table, Door1Unlocked, _DeviceDoor
d_entry table, Door2Open, _DeviceDoor
d_entry table, Door3Open, _DeviceDoor
d_entry table, FakeConsole, _DeviceFakeConsole
d_entry table, Flower, _DeviceFlower
d_entry table, LeverCeiling, _DeviceLever
d_entry table, LeverFloor, _DeviceLever
d_entry table, Paper, _DevicePaper
d_entry table, ScreenGreen, _DeviceDialog
d_entry table, ScreenRed, _DeviceDialog
d_entry table, Sign, _DeviceDialog
d_entry table, TalkLeft, _DeviceDialog
d_entry table, TalkRight, _DeviceDialog
d_entry table, Upgrade, _DeviceUpgrade
d_entry table, None, _ContinueExploring
d_entry table, Boiler, _ContinueExploring
d_entry table, BreakerDone, _ContinueExploring
d_entry table, BreakerRising, _ContinueExploring
d_entry table, Door1Locked, _ContinueExploring
d_entry table, FlowerInert, _ContinueExploring
d_entry table, Mousehole, _ContinueExploring
d_entry table, Placeholder, _ContinueExploring
d_entry table, Teleporter, _ContinueExploring
d_entry table, BreakerReady, _DeviceBreaker
d_entry table, ConsoleCeiling, _DeviceConsole
d_entry table, ConsoleFloor, _DeviceConsole
d_entry table, Door1Open, _DeviceDoor
d_entry table, Door1Unlocked, _DeviceDoor
d_entry table, Door2Open, _DeviceDoor
d_entry table, Door3Open, _DeviceDoor
d_entry table, FakeConsole, _DeviceFakeConsole
d_entry table, Flower, _DeviceFlower
d_entry table, LeverCeiling, _DeviceLever
d_entry table, LeverFloor, _DeviceLever
d_entry table, Paper, _DevicePaper
d_entry table, ScreenGreen, _DeviceDialog
d_entry table, ScreenRed, _DeviceDialog
d_entry table, Sign, _DeviceDialog
d_entry table, TalkLeft, _DeviceDialog
d_entry table, TalkRight, _DeviceDialog
d_entry table, Upgrade, _DeviceUpgrade
D_END
.ENDREPEAT
_DeviceBreaker:
Expand Down
6 changes: 3 additions & 3 deletions src/rooms/boss_city.asm
Original file line number Diff line number Diff line change
Expand Up @@ -516,19 +516,19 @@ _Devices_sDevice_arr:
d_byte Target_byte, sState::LeverRight_u8
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::Console
d_byte Type_eDevice, eDevice::ConsoleFloor
d_byte BlockRow_u8, 12
d_byte BlockCol_u8, 1
d_byte Target_byte, kAmmoRackMachineIndex
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::Console
d_byte Type_eDevice, eDevice::ConsoleFloor
d_byte BlockRow_u8, 10
d_byte BlockCol_u8, 13
d_byte Target_byte, kReloaderMachineIndex
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::Console
d_byte Type_eDevice, eDevice::ConsoleFloor
d_byte BlockRow_u8, 12
d_byte BlockCol_u8, 13
d_byte Target_byte, kLauncherMachineIndex
Expand Down
Loading

0 comments on commit 152e48a

Please sign in to comment.