Skip to content

Commit

Permalink
Make CoreDump fake console reveal orc tank in ShadowOffice
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Aug 3, 2024
1 parent 4ffc985 commit 88c2f79
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 39 deletions.
39 changes: 39 additions & 0 deletions src/fake.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
.INCLUDE "console.inc"
.INCLUDE "cpu.inc"
.INCLUDE "fake.inc"
.INCLUDE "flag.inc"
.INCLUDE "joypad.inc"
.INCLUDE "machine.inc"
.INCLUDE "machines/emitter.inc"
Expand All @@ -35,9 +36,12 @@
.IMPORT FuncA_Console_AdjustAvatar
.IMPORT FuncA_Console_WriteDiagramTransferDataForDiagram
.IMPORT FuncA_Objects_Draw1x1Shape
.IMPORT FuncA_Terrain_TransferTileColumn
.IMPORT FuncM_ConsoleScrollTowardsGoalAndTick
.IMPORT FuncM_DrawObjectsForRoom
.IMPORT Func_ClearRestOfOamAndProcessFrame
.IMPORT Func_ProcessFrame
.IMPORT Func_SetFlag
.IMPORT Func_Window_PrepareRowTransfer
.IMPORT Func_Window_ScrollUp
.IMPORT Func_Window_TransferBottomBorder
Expand Down Expand Up @@ -96,6 +100,7 @@ _GameLoop:
.PROC Main_FakeConsole_Message
_GameLoop:
jsr FuncM_DrawFakeConsoleObjectsAndProcessFrame
jsr_prga FuncA_Terrain_OnFakeConsoleOpen
lda Zp_P1ButtonsPressed_bJoypad
and #bJoypad::AButton | bJoypad::BButton
beq _GameLoop
Expand Down Expand Up @@ -351,6 +356,40 @@ _NoPower5_u8_arr19:

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

.SEGMENT "PRGA_Terrain"

;;; Called when a fake console window is fully open. Makes the orc tank in the
;;; ShadowOffice room appear the first time the CoreDump fake console is
;;; used.
;;; @prereq Zp_Current_eFake is initialized.
.PROC FuncA_Terrain_OnFakeConsoleOpen
;; Do nothing unless this is the CoreDump fake console.
lda Zp_Current_eFake
.assert eFake::CoreDump = 0, error
bne @done
;; Set the ShadowOfficeRemovedWall flag; do nothing else if it was already
;; set.
ldx #eFlag::ShadowOfficeRemovedWall ; param: flag
jsr Func_SetFlag ; sets C if flag was already set
bcs @done
;; Restore the original terrain tiles for the six room tile columns from 12
;; through 17. To avoid overflowing the PPU buffer, just do one tile
;; column per frame.
lda #12 ; param: room tile col
sta T2 ; next room tile col
@loop:
jsr FuncA_Terrain_TransferTileColumn ; preserves T2+
jsr Func_ProcessFrame ; preserves T0+
inc T2 ; next room tile col
lda T2 ; param: next room tile col
cmp #18
blt @loop
@done:
rts
.ENDPROC

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

.SEGMENT "PRGA_Objects"

;;; Draws the fake machine light for when a fake console window is open.
Expand Down
13 changes: 9 additions & 4 deletions src/ppu.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@
.DEFINE kTileHeightPx 8
.DEFINE kBlockWidthPx 16
.DEFINE kBlockHeightPx 16
kScreenWidthBlocks = 16
kScreenHeightBlocks = 15
kScreenWidthTiles = kScreenWidthBlocks * 2
kScreenHeightTiles = kScreenHeightBlocks * 2
.DEFINE kScreenWidthBlocks 16
.DEFINE kScreenHeightBlocks 15
.DEFINE kScreenWidthTiles 32
.DEFINE kScreenHeightTiles 30
kScreenWidthPx = kScreenWidthTiles * kTileWidthPx
kScreenHeightPx = kScreenHeightTiles * kTileHeightPx

.ASSERT kBlockWidthPx = kTileWidthPx * 2, error
.ASSERT kBlockHeightPx = kTileHeightPx * 2, error
.ASSERT kScreenWidthTiles = kScreenWidthBlocks * 2, error
.ASSERT kScreenHeightTiles = kScreenHeightBlocks * 2, error

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

;;; PPU control register.
Expand Down
35 changes: 35 additions & 0 deletions src/rooms/shadow_descent.asm
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,41 @@ _Platforms_sPlatform_arr:
d_word Left_i16, $00e8
d_word Top_i16, kBarrierShutTop
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Solid
d_word WidthPx_u16, $10
d_byte HeightPx_u8, $08
d_word Left_i16, $0060
d_word Top_i16, $0078
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Solid
d_word WidthPx_u16, $10
d_byte HeightPx_u8, $08
d_word Left_i16, $00b0
d_word Top_i16, $0078
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Solid
d_word WidthPx_u16, $10
d_byte HeightPx_u8, $08
d_word Left_i16, $0070
d_word Top_i16, $0090
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Solid
d_word WidthPx_u16, $10
d_byte HeightPx_u8, $08
d_word Left_i16, $00a0
d_word Top_i16, $0090
D_END
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Solid
d_word WidthPx_u16, $20
d_byte HeightPx_u8, $08
d_word Left_i16, $0080
d_word Top_i16, $0110
D_END
;; Lava:
D_STRUCT sPlatform
d_byte Type_ePlatform, ePlatform::Kill
Expand Down
10 changes: 5 additions & 5 deletions src/rooms/shadow_descent.bg
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ ENEBED BDBC EGEBEG
BDBC
BDBC
EEENEB BDBC DABBEAENEN
EMECBACN BDBC DBBACBEAEN
EMED BKBIEOEOEOEOEOEOEOEOEAEFEEENEN
EGEB BC BDBC EMEDEAEF
EMECBACN DL BDBC DL DBBACBEAEN
EMED BKBIEOEDECEOEOECEDEOEAEFEEENEN
EGEB BC DKBDBCDK EMEDEAEF
ENENEFCCDA BDBC CMBAEGENEBEM
EAEBEMBADB BDBC BD EEEH
ENENEHEEENEBEOEOEOEOEOEOBL DA EDEE
ENEBEAEJ BDBC CGBADBBAECEM
EEENEBEDBACN BDBC ECEAEHEG
EMEC BC BDBC CMBAEGENENEN
EMED DA BKBIEOEOEOEOBIBL EEENENEN
EGEFBADBBACH BDBC BD EMECEAEN
EMED DA BKBIEOECECEOBIBL EEENENEN
EGEFBADBBACH BOBP BD EMECEAEN
ENELENEB BDBC CGBAEDEGENEN
BDBC
ECEC
Expand Down
105 changes: 84 additions & 21 deletions src/rooms/shadow_office.asm
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
.INCLUDE "../macros.inc"
.INCLUDE "../platform.inc"
.INCLUDE "../platforms/lava.inc"
.INCLUDE "../ppu.inc"
.INCLUDE "../room.inc"

.IMPORT DataA_Room_Shadow_sTileset
.IMPORT FuncA_Objects_AnimateLavaTerrain
.IMPORT FuncA_Room_MakeNpcGhostDisappear
.IMPORT FuncA_Terrain_FadeInShortRoomWithLava
.IMPORT Func_BufferPpuTransfer
.IMPORT Func_FindEmptyActorSlot
.IMPORT Func_InitActorSmokeExplosion
.IMPORT Func_IsPointInPlatform
Expand All @@ -42,7 +44,6 @@
.IMPORT Func_SetPointToAvatarCenter
.IMPORT Ppu_ChrObjShadow
.IMPORT Ram_ActorPosY_i16_1_arr
.IMPORT Ram_ActorType_eActor_arr
.IMPORT Ram_PlatformType_ePlatform_arr
.IMPORT Sram_ProgressFlags_arr
.IMPORTZP Zp_AvatarPosX_i16
Expand All @@ -62,6 +63,28 @@ kGhostWallPlatformIndex = 1

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

;;; The tile row/col in the upper nametable for the top-left corner of the
;;; ghost wall's BG tiles.
kWallStartRow = 19
kWallStartCol = 12

;;; The PPU addresses for the start (left) of each row of the ghost wall's BG
;;; tiles.
.LINECONT +
Ppu_WallRow0Start = Ppu_Nametable0_sName + sName::Tiles_u8_arr + \
kScreenWidthTiles * (kWallStartRow + 0) + kWallStartCol
Ppu_WallRow1Start = Ppu_Nametable0_sName + sName::Tiles_u8_arr + \
kScreenWidthTiles * (kWallStartRow + 1) + kWallStartCol
Ppu_WallRow2Start = Ppu_Nametable0_sName + sName::Tiles_u8_arr + \
kScreenWidthTiles * (kWallStartRow + 2) + kWallStartCol
Ppu_WallRow3Start = Ppu_Nametable0_sName + sName::Tiles_u8_arr + \
kScreenWidthTiles * (kWallStartRow + 3) + kWallStartCol
Ppu_WallRow4Start = Ppu_Nametable0_sName + sName::Tiles_u8_arr + \
kScreenWidthTiles * (kWallStartRow + 4) + kWallStartCol
.LINECONT -

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

.SEGMENT "PRGC_Shadow"

.EXPORT DataC_Shadow_Office_sRoom
Expand All @@ -86,7 +109,7 @@ _Ext_sRoomExt:
d_addr Devices_sDevice_arr_ptr, _Devices_sDevice_arr
d_addr Passages_sPassage_arr_ptr, _Passages_sPassage_arr
d_addr Enter_func_ptr, FuncA_Room_ShadowOffice_EnterRoom
d_addr FadeIn_func_ptr, FuncA_Terrain_FadeInShortRoomWithLava
d_addr FadeIn_func_ptr, FuncA_Terrain_ShadowOffice_FadeInRoom
d_addr Tick_func_ptr, FuncA_Room_ShadowOffice_TickRoom
d_addr Draw_func_ptr, FuncA_Objects_AnimateLavaTerrain
D_END
Expand Down Expand Up @@ -219,25 +242,6 @@ _Passages_sPassage_arr:

.SEGMENT "PRGA_Room"

.PROC FuncA_Room_ShadowOffice_EnterRoom
_MaybeRemoveWall:
flag_bit Sram_ProgressFlags_arr, eFlag::ShadowOfficeRemovedWall
beq _Return
lda #ePlatform::Zone
sta Ram_PlatformType_ePlatform_arr + kGhostWallPlatformIndex
_MaybeRevealGhost:
flag_bit Sram_ProgressFlags_arr, eFlag::ShadowOfficeTaggedGhost
bne _RemoveGhost
lda #0
sta Ram_ActorPosY_i16_1_arr + kGhostActorIndex
rts
_RemoveGhost:
lda #eActor::None
sta Ram_ActorType_eActor_arr + kGhostActorIndex
_Return:
rts
.ENDPROC

.PROC FuncA_Room_ShadowOffice_TickRoom
_MaybeTagGhost:
;; If the avatar isn't in the tag zone, don't tag the ghost.
Expand All @@ -254,7 +258,66 @@ _MaybeTagGhost:
ldy #eActor::BadGhostOrc ; param: new actor type
jmp FuncA_Room_MakeNpcGhostDisappear
@done:
_MaybeRemoveWallAndRevealGhost:
fall FuncA_Room_ShadowOffice_EnterRoom
.ENDPROC

.PROC FuncA_Room_ShadowOffice_EnterRoom
_MaybeRemoveWall:
flag_bit Sram_ProgressFlags_arr, eFlag::ShadowOfficeRemovedWall
beq _Return
lda #ePlatform::Zone
sta Ram_PlatformType_ePlatform_arr + kGhostWallPlatformIndex
_MaybeRevealGhost:
flag_bit Sram_ProgressFlags_arr, eFlag::ShadowOfficeTaggedGhost
bne _Return
lda #0
sta Ram_ActorPosY_i16_1_arr + kGhostActorIndex
rts
_Return:
rts
.ENDPROC

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

.SEGMENT "PRGA_Terrain"

.PROC DataA_Terrain_ShadowOfficeTransfer_arr
;; Row 0:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_WallRow0Start ; transfer destination
.byte 6
.byte $14, $8a, $8a, $8a, $8a, $15
;; Row 1:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_WallRow1Start ; transfer destination
.byte 6
.byte $88, $87, $8b, $8b, $86, $89
;; Row 2:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_WallRow2Start ; transfer destination
.byte 6
.byte $16, $17, $14, $15, $88, $89
;; Row 3:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_WallRow3Start ; transfer destination
.byte 6
.byte $14, $8a, $84, $89, $88, $89
;; Row 4:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_WallRow4Start ; transfer destination
.byte 6
.byte $16, $8b, $8b, $17, $16, $17
.ENDPROC

.PROC FuncA_Terrain_ShadowOffice_FadeInRoom
flag_bit Sram_ProgressFlags_arr, eFlag::ShadowOfficeRemovedWall
bne @noGhostWall
ldax #DataA_Terrain_ShadowOfficeTransfer_arr ; param: data pointer
ldy #.sizeof(DataA_Terrain_ShadowOfficeTransfer_arr) ; param: data length
jsr Func_BufferPpuTransfer
@noGhostWall:
jmp FuncA_Terrain_FadeInShortRoomWithLava
.ENDPROC

;;;=========================================================================;;;
Expand Down
2 changes: 1 addition & 1 deletion src/rooms/shadow_office.bg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FF AIAIAIAI BD EDEGEN
EMAB AB ABBD FMEFEA
EIEBBIEAFNBIEOCEBBBBEOCD ABECEGEN
ED BD FMEPENEN
FOAJAB EC AB AB ECEDECEE
FOAJAB EC AB AB ECBOECEE
EMBIEC AB FPBIEOBIEOBIEGEFEMEM
EHAJEMBIEO BC EMEDEM
EF EM FMENEB AB EGEBEG
Expand Down
8 changes: 4 additions & 4 deletions src/terrain.asm
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,14 @@ _Done:

;;; Buffers a PPU transfer to update one tile column from the current room.
;;; @param A The index of the room tile column to transfer.
;;; @preserve T2+
.EXPORT FuncA_Terrain_TransferTileColumn
.PROC FuncA_Terrain_TransferTileColumn
tax
.assert kScreenWidthTiles = $20, error
and #$1f
tax ; room tile column index
mod #kScreenWidthTiles
sta T1 ; nametable column index
txa ; param: room tile column index
jsr FuncA_Terrain_GetColumnPtrForTileIndex
jsr FuncA_Terrain_GetColumnPtrForTileIndex ; preserves T0+
;; Buffer a PPU transfer for the upper nametable.
_UpperTransfer:
ldx Zp_PpuTransferLen_u8
Expand Down
8 changes: 4 additions & 4 deletions src/tilesets/shadow.bg
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

HMHN HCHDDODPICIDFEFFECEJEAEBEC FAFBCACBBB BAAAAAABAB
HOHPDMDN DODP FGFHEDEG ED FCFDCBCABD BCABABABAB
EIEI EJ EJEJEI EJEIEIEJ EIEIEJEJEGEIEIEHEFEEEJEJ
EIEIEJ EJEJ EIEJ EJEIEIEIEIEJEJEEEIEIEFEJEJEHEG
EIEI EJ EJEJEI EJEIEIEJ EIEIEJEJEGEIEIEHEFEEEJEJIGIHIGIH
EIEIEJ EJEJ EIEJ EJEIEIEIEIEJEJEEEIEIEFEJEJEHEG EJEJ
EEEIEIEFEJ EJ EGEH EGEIEIEH EEEF EJEJ
EJ EJEGEIEIEH EEEF EEEIEIEF EJEJ EGEH
GAGBGEGF GC GF GE GFEIGEEJ JEJF FMFNFIFJ
GCGFGGGH GAGIGB GE GF GGGJGH GGGIGB JEJF FOFP
GAGBGEGF GC GF GE GFEIGEEJ IGIH JEJF FMFNFIFJ
GCGFGGGH GAGIGB GE GF GGGJGH GGGIGB IEIF JEJF FOFP
IEDKDKIFIEIFDIDJIEDKDKIFDIDFDEDJDIDFDEDJDKDKDEDFDIDJDKDKIEIFDEDF
IGDLDLIHDIDJIGIHDIDHDGDJIGDLDLIHDIDHDGDJDGDHDLDLDIDJDLDLIGIHDGDH
EK EKEKEKEMENIFIEIGIH DADKDKIFIEDBDIDJ
Expand Down

0 comments on commit 88c2f79

Please sign in to comment.