Skip to content

Commit

Permalink
Add fake console EndThis to ShadowOffice room
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Sep 10, 2024
1 parent 4737949 commit ab67bf7
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 16 deletions.
35 changes: 22 additions & 13 deletions src/cursor.asm
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ _DrawCursors:
.EXPORT FuncA_Console_DrawFieldCursor
.PROC FuncA_Console_DrawFieldCursor
lda #$00 ; param: cursor diminished bool ($00 = undiminished)
.assert * = FuncA_Console_DrawFieldCursorFullOrDim, error, "fallthrough"
fall FuncA_Console_DrawFieldCursorFullOrDim
.ENDPROC

;;; Draws the console instruction field cursor, possibly diminished.
Expand Down Expand Up @@ -290,7 +290,7 @@ _DrawCursor:
sta T2 ; cursor width - 1
bit T3 ; cursor diminished bool
bpl FuncA_Console_DrawFullCursor
.assert * = FuncA_Console_DrawDiminishedCursor, error, "fallthrough"
fall FuncA_Console_DrawDiminishedCursor
.ENDPROC

;;; Draws a diminished window cursor at the specified position on the screen.
Expand Down Expand Up @@ -367,7 +367,7 @@ _ObjectLoop:
.ENDPROC

;;; Draws the console debug cursor.
;;; @prereq The machine console is open.
;;; @prereq The (real) machine console is open.
.EXPORT FuncA_Console_DrawDebugCursor
.PROC FuncA_Console_DrawDebugCursor
ldx Zp_ConsoleMachineIndex_u8
Expand Down Expand Up @@ -397,25 +397,35 @@ _Resetting:
rts
_DrawSolid:
lda #$00 ; param: diminished bool
beq FuncA_Console_DrawInstructionCursor ; unconditional
beq FuncA_Console_DrawPcCursor ; unconditional
_DrawDim:
lda #$ff ; param: diminished bool
.assert * = FuncA_Console_DrawInstructionCursor, error, "fallthrough"
fall FuncA_Console_DrawPcCursor
.ENDPROC

;;; Draws a console debug cursor that hilights the instruction number for the
;;; console machine's current PC.
;;; @prereq The machine console is open.
;;; @prereq The (real) machine console is open.
;;; @param A True ($ff) to draw the cursor diminished, false ($00) otherwise.
.PROC FuncA_Console_DrawPcCursor
ldy Zp_ConsoleMachineIndex_u8
ldx Ram_MachinePc_u8_arr, y ; param: instruction number
fall FuncA_Console_DrawInstructionCursor
.ENDPROC

;;; Draws a console debug cursor that hilights the specified instruction
;;; number.
;;; @prereq Zp_ConsoleNumInstRows_u8 is initialized.
;;; @param A True ($ff) to draw the cursor diminished, false ($00) otherwise.
;;; @param X The instruction number.
.EXPORT FuncA_Console_DrawInstructionCursor
.PROC FuncA_Console_DrawInstructionCursor
sta T1 ; cursor diminished bool
sta T0 ; cursor diminished bool
lda #2 ; param: num objects
jsr Func_AllocObjects ; preserves T0+, returns Y
jsr Func_AllocObjects ; preserves X and T0+, returns Y
_YPosition:
;; Calculate the window row that the cursor is in.
ldx Zp_ConsoleMachineIndex_u8
lda Ram_MachinePc_u8_arr, x
sta T0 ; instruction number
txa ; instruction number
cmp Zp_ConsoleNumInstRows_u8
blt @leftColumn
sub Zp_ConsoleNumInstRows_u8
Expand All @@ -429,7 +439,6 @@ _YPosition:
sta Ram_Oam_sObj_arr64 + .sizeof(sObj) * 1 + sObj::YPos_u8, y
_XPosition:
lda #kTileWidthPx * 2
ldx T0 ; instruction number
cpx Zp_ConsoleNumInstRows_u8
blt @leftColumn
lda #kTileWidthPx * 12
Expand All @@ -439,7 +448,7 @@ _XPosition:
sta Ram_Oam_sObj_arr64 + .sizeof(sObj) * 1 + sObj::XPos_u8, y
_TileAndFlags:
lda #kTileIdObjCursorSolidLeft
bit T1 ; cursor diminished bool
bit T0 ; cursor diminished bool
bpl @undiminished
lda #kTileIdObjCursorDimLeft
@undiminished:
Expand Down
62 changes: 62 additions & 0 deletions src/fake.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
.INCLUDE "cpu.inc"
.INCLUDE "fake.inc"
.INCLUDE "flag.inc"
.INCLUDE "hud.inc"
.INCLUDE "joypad.inc"
.INCLUDE "machine.inc"
.INCLUDE "machines/carriage.inc"
.INCLUDE "machines/emitter.inc"
.INCLUDE "machines/lift.inc"
.INCLUDE "machines/shared.inc"
Expand All @@ -34,6 +36,7 @@
.INCLUDE "window.inc"

.IMPORT FuncA_Console_AdjustAvatar
.IMPORT FuncA_Console_DrawInstructionCursor
.IMPORT FuncA_Console_WriteDiagramTransferDataForDiagram
.IMPORT FuncA_Objects_Draw1x1Shape
.IMPORT FuncA_Terrain_TransferTileColumn
Expand All @@ -51,6 +54,8 @@
.IMPORT Ram_PpuTransfer_arr
.IMPORTZP Zp_ConsoleNeedsPower_u8
.IMPORTZP Zp_ConsoleNumInstRows_u8
.IMPORTZP Zp_FloatingHud_bHud
.IMPORTZP Zp_FrameCounter_u8
.IMPORTZP Zp_P1ButtonsPressed_bJoypad
.IMPORTZP Zp_ShapePosX_i16
.IMPORTZP Zp_ShapePosY_i16
Expand Down Expand Up @@ -98,7 +103,10 @@ _GameLoop:
;;; @prereq Zp_Current_eFake is initialized.
;;; @prereq The console window is fully visible.
.PROC Main_FakeConsole_Message
lda #bHud::NoMachine | bHud::Hidden
sta Zp_FloatingHud_bHud
_GameLoop:
jsr_prga FuncA_Console_DrawFakeConsoleCursor
jsr FuncM_DrawFakeConsoleObjectsAndProcessFrame
jsr_prga FuncA_Terrain_OnFakeConsoleOpen
lda Zp_P1ButtonsPressed_bJoypad
Expand Down Expand Up @@ -149,6 +157,7 @@ _InitWindow:
_Chr0cBank_u8_arr:
D_ARRAY .enum, eFake
d_byte CoreDump, $61 ; TODO
d_byte EndThis, kChrBankDiagramCarriage
d_byte Ethical, $60 ; TODO
d_byte InsufficientData, $50 ; TODO
d_byte NoPower, kChrBankDiagramLift
Expand Down Expand Up @@ -211,6 +220,7 @@ _DrawStatus:
_Fake_eDiagram:
D_ARRAY .enum, eFake
d_byte CoreDump, eDiagram::MinigunDown ; TODO
d_byte EndThis, eDiagram::Carriage
d_byte Ethical, eDiagram::MinigunDown ; TODO
d_byte InsufficientData, eDiagram::MinigunDown ; TODO
d_byte NoPower, eDiagram::Lift
Expand Down Expand Up @@ -267,6 +277,15 @@ _Fake_eDiagram:
.addr _CoreDump5_u8_arr19
.addr _CoreDump6_u8_arr19
.addr _CoreDump7_u8_arr19
d_byte EndThis
.addr _EndThis0_u8_arr19
.addr _EndThis1_u8_arr19
.addr _EndThis2_u8_arr19
.addr _EndThis3_u8_arr19
.addr _EndThis4_u8_arr19
.addr _EndThis5_u8_arr19
.addr _EndThis6_u8_arr19
.addr _EndThis7_u8_arr19
d_byte Ethical
.addr _Blank_u8_arr19
.addr _Blank_u8_arr19
Expand Down Expand Up @@ -322,6 +341,30 @@ _CoreDump6_u8_arr19:
_CoreDump7_u8_arr19:
: .byte "7: ", kTileIdBgWindowVert, '0' + 15, ": "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis0_u8_arr19:
: .byte "0:END ", kTileIdBgWindowVert, "8:END "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis1_u8_arr19:
: .byte "1:END ", kTileIdBgWindowVert, "9:END "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis2_u8_arr19:
: .byte "2:END ", kTileIdBgWindowVert, '0' + 10, ":END "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis3_u8_arr19:
: .byte "3:END ", kTileIdBgWindowVert, '0' + 11, ":END "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis4_u8_arr19:
: .byte "4:END ", kTileIdBgWindowVert, '0' + 12, ":END "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis5_u8_arr19:
: .byte "5:END ", kTileIdBgWindowVert, '0' + 13, ":END "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis6_u8_arr19:
: .byte "6:END ", kTileIdBgWindowVert, '0' + 14, ":THIS, "
.assert * - :- = kFakeConsoleMessageCols, error
_EndThis7_u8_arr19:
: .byte "7:END ", kTileIdBgWindowVert, '0' + 15, ":PLEASE "
.assert * - :- = kFakeConsoleMessageCols, error
_Ethical2_u8_arr19:
: .byte "SYNTAX ERROR: "
.assert * - :- = kFakeConsoleMessageCols, error
Expand Down Expand Up @@ -354,6 +397,23 @@ _NoPower5_u8_arr19:
.assert * - :- = kFakeConsoleMessageCols, error
.ENDPROC

;;; Draws the cursor (if any) for the current fake console window.
;;; @prereq Zp_Current_eFake is initialized.
;;; @prereq Zp_ConsoleNumInstRows_u8 is initialized.
.PROC FuncA_Console_DrawFakeConsoleCursor
lda Zp_Current_eFake
cmp #eFake::EndThis
bne @done
lda Zp_FrameCounter_u8
and #$04
bne @done
lda #0 ; param: diminished bool
tax ; param: instruction number
jmp FuncA_Console_DrawInstructionCursor
@done:
rts
.ENDPROC

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

.SEGMENT "PRGA_Terrain"
Expand Down Expand Up @@ -409,13 +469,15 @@ _NoPower5_u8_arr19:
_ShapeX_u8_arr:
D_ARRAY .enum, eFake
d_byte CoreDump, $60
d_byte EndThis, $47
d_byte Ethical, $47
d_byte InsufficientData, $a0
d_byte NoPower, $77
D_END
_ShapeY_u8_arr:
D_ARRAY .enum, eFake
d_byte CoreDump, $80
d_byte EndThis, $37
d_byte Ethical, $a0
d_byte InsufficientData, $c0
d_byte NoPower, $67
Expand Down
1 change: 1 addition & 0 deletions src/fake.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
;;; room, as it happens).
.ENUM eFake
CoreDump
EndThis
Ethical
InsufficientData
NoPower
Expand Down
6 changes: 3 additions & 3 deletions src/rooms/shadow_office.asm
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ _Devices_sDevice_arr:
d_byte Type_eDevice, eDevice::FakeConsole
d_byte BlockRow_u8, 2
d_byte BlockCol_u8, 6
d_byte Target_byte, eFake::InsufficientData ; TODO
d_byte Target_byte, eFake::InsufficientData ; TODO shock vert
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::FakeConsole
d_byte BlockRow_u8, 2
d_byte BlockCol_u8, 10
d_byte Target_byte, eFake::InsufficientData ; TODO
d_byte Target_byte, eFake::EndThis
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::ConsoleFloor
Expand All @@ -238,7 +238,7 @@ _Devices_sDevice_arr:
d_byte Type_eDevice, eDevice::FakeConsole
d_byte BlockRow_u8, 5
d_byte BlockCol_u8, 2
d_byte Target_byte, eFake::InsufficientData ; TODO
d_byte Target_byte, eFake::InsufficientData ; TODO shock horz
D_END
D_STRUCT sDevice
d_byte Type_eDevice, eDevice::FakeConsole
Expand Down

0 comments on commit ab67bf7

Please sign in to comment.