Skip to content

Commit

Permalink
Merge PRGA_Reset into PRGC_Title
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Aug 5, 2024
1 parent 49602ab commit 6a9707e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
11 changes: 5 additions & 6 deletions src/linker.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,11 @@ SEGMENTS {
PRGA_Machine: load=PRGA_15, type=ro;
PRGA_Objects: load=PRGA_17, type=ro;
PRGA_Pause: load=PRGA_19, type=ro;
PRGA_Reset: load=PRGA_1B, type=ro;
PRGA_Room: load=PRGA_1D, type=ro;
PRGA_Terrain: load=PRGA_2F, type=ro;
PRGA_Pcm0: load=PRGA_21, type=ro;
PRGA_Pcm1: load=PRGA_23, type=ro;
PRGA_Pcm2: load=PRGA_25, type=ro;
PRGA_Room: load=PRGA_1B, type=ro;
PRGA_Terrain: load=PRGA_1D, type=ro;
PRGA_Pcm0: load=PRGA_1F, type=ro;
PRGA_Pcm1: load=PRGA_21, type=ro;
PRGA_Pcm2: load=PRGA_23, type=ro;
# Fixed-bank PRG segments:
PRG8: load=PRG8, type=ro;
PRGE_Pcm: load=PRGE, type=ro, align=$100;
Expand Down
6 changes: 1 addition & 5 deletions src/mmc3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Zp_MainSelect_bMmc3Bank: .res 1

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

.SEGMENT "PRGE_Reset"
.SEGMENT "PRG8"

;;; Switches PRGA banks to the given bank number. This is called by the
;;; main_prga macro in mmc3.inc. Putting these few loads and stores in a
Expand All @@ -42,10 +42,6 @@ Zp_MainSelect_bMmc3Bank: .res 1
;;; adds up to a significant space savings. (PRGC and CHR bank switches are
;;; less common, so we don't bother for those.)
;;;
;;; This function must be in PRGE rather than PRG8, so that it can be used in
;;; Main_Reset to initialize the MMC3 (PRG8 can't be used until the MMC3 has
;;; been initialized).
;;;
;;; @param A The PRGA bank number to switch to.
;;; @preserve X, Y, T0+
.PROC FuncM_SwitchPrgaBank
Expand Down
21 changes: 15 additions & 6 deletions src/reset.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
.IMPORT Func_AudioReset
.IMPORT Func_ClearRestOfOam
.IMPORT Int_NoopIrq
.IMPORT Main_Title
.IMPORT MainC_Title_Menu
.IMPORT Ppu_ChrBgFontLower
.IMPORT Ppu_ChrObjAnnaNormal
.IMPORTZP Zp_Active_sIrq
Expand All @@ -52,15 +52,24 @@ kSharedBgColor = $0f ; black
;; Initialize stack pointer.
dex ; now x is $ff
txs
;; Set mapper PRG ROM bank for $a000 and jump to rest of reset code.
jmp_prga MainA_Reset_Ext
;; Initialize the MMC and load PRGC_Title. Since all NMI/IRQ interrupts
;; are disabled at this point, we can just do this directly rather than
;; using the main_prgc_bank macro, which uses extra instructions in order
;; to be interrupt-safe.
lda #kSelectPrgc
sta Hw_Mmc3BankSelect_wo
lda #<.bank(MainC_Title_Reset)
sta Hw_Mmc3BankData_wo
;; Jump to the rest of the reset code (stored in a swappable bank, to save
;; valuable space in PRG8 and PRGE).
jmp MainC_Title_Reset
.ENDPROC

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

.SEGMENT "PRGA_Reset"
.SEGMENT "PRGC_Title"

.PROC MainA_Reset_Ext
.PROC MainC_Title_Reset
;; Enable SRAM, but disable writes for now.
lda #bMmc3PrgRam::Enable | bMmc3PrgRam::DenyWrites
sta Hw_Mmc3PrgRamProtect_wo
Expand Down Expand Up @@ -153,7 +162,7 @@ _Finish:
sta Hw_PpuCtrl_wo ; enable VBlank NMI
sta Hw_Mmc3IrqEnable_wo ; enable HBlank IRQ
cli ; enable maskable (IRQ) interrupts
jmp Main_Title
jmp MainC_Title_Menu
.ENDPROC

;;;=========================================================================;;;
12 changes: 1 addition & 11 deletions src/title.asm
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,6 @@ Ram_TitleLetterOffset_i8_arr: .res .sizeof(DataC_Title_Letters_u8_arr)

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

.SEGMENT "PRG8"

;;; Mode for displaying the title screen.
;;; @prereq Rendering is disabled.
.EXPORT Main_Title
.PROC Main_Title
jmp_prgc MainC_Title_Menu
.ENDPROC

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

.SEGMENT "PRGC_Title"

;;; The tile ID grid for the game title (stored in row-major order).
Expand Down Expand Up @@ -277,6 +266,7 @@ Ram_TitleLetterOffset_i8_arr: .res .sizeof(DataC_Title_Letters_u8_arr)
;;; Mode for displaying the title screen.
;;; @prereq PRGC_Title is loaded.
;;; @prereq Rendering is disabled.
.EXPORT MainC_Title_Menu
.PROC MainC_Title_Menu
jsr FuncC_Title_InitAndFadeIn
_GameLoop:
Expand Down

0 comments on commit 6a9707e

Please sign in to comment.