From 6810227cbcb2c53b707795e7353a5de041fd4f96 Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:27:09 -0800 Subject: [PATCH 1/8] add "tools/asar" to gitignore on non-Windows platforms, this isn't caught by tools/*.exe --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a6351deb..1985ae96 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.sw[op] build/ tools/*.exe +tools/asar .vscode/launch.json .vscode/tasks.json /names/custom_names.txt From 4f4f95bdfccdfa7ba108907962aa5c4f4598074f Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:29:40 -0800 Subject: [PATCH 2/8] Add boot-to-menu functionality Add an option to boot directly to the InfoHUD menu instead of the Nintendo splash. The sound engine is also loaded asynchronously in the menu, elimiating the delay for it to initialize. This reduces the time from power-on to practice menu to about half a second. The option is under the Cutscenes menu. --- src/cutscenes.asm | 24 ++++++ src/defines.asm | 5 +- src/init.asm | 15 ++++ src/mainmenu.asm | 6 +- src/menu.asm | 190 ++++++++++++++++++++++++++++++++++++++++++++-- src/symbols.asm | 2 + 6 files changed, 233 insertions(+), 9 deletions(-) diff --git a/src/cutscenes.asm b/src/cutscenes.asm index 6b977cf7..afe3e7ea 100644 --- a/src/cutscenes.asm +++ b/src/cutscenes.asm @@ -6,6 +6,14 @@ org $8BB240 endif JSR cutscenes_load_ceres_arrival +if !FEATURE_PAL +org $8B9287 +else +org $8B92DE +endif + JSR cutscenes_quickboot_hijack + NOP + if !FEATURE_PAL org $8B92B5 else @@ -108,6 +116,22 @@ endif org $8BF800 print pc, " cutscenes start" +cutscenes_quickboot_hijack: +{ + JSL $80834B ; hijacked code + + LDA !sram_cutscenes : AND !CUTSCENE_QUICKBOOT : BNE .quickboot + RTS + +.quickboot + PLA ; pop return address + PLB + PLA ; saved processor status and 1 byte of next return address + PLA ; remainder of next return address + + JML $808482 ; finish boot code; another hijack will launch the menu +} + cutscenes_nintendo_splash: { LDX #$0078 diff --git a/src/defines.asm b/src/defines.asm index 338048b3..f943272e 100644 --- a/src/defines.asm +++ b/src/defines.asm @@ -93,7 +93,9 @@ !ram_lag_counter = !WRAM_START+$7E !ram_kraid_adjust_timer = !WRAM_START+$80 -!WRAM_PERSIST_START = !ram_kraid_adjust_timer+$02 +!ram_quickboot_spc_state = !WRAM_START+$82 + +!WRAM_PERSIST_START = !ram_quickboot_spc_state+$02 ; ---------------------------------------------------------- ; Variables below this point are PERSISTENT -- they maintain ; their value across savestates. Use this section for @@ -705,6 +707,7 @@ endif !CUTSCENE_SKIP_GAMEOVER = #$1000 !CUTSCENE_FAST_BOWLING = #$2000 !CUTSCENE_KRAID_DEATH_CAMERA = #$4000 +!CUTSCENE_QUICKBOOT = #$8000 !SUPPRESS_CRATERIA_LIGHTNING = #$0001 !SUPPRESS_ESCAPE_FLASHING = #$0002 diff --git a/src/init.asm b/src/init.asm index 847b907d..21290a16 100644 --- a/src/init.asm +++ b/src/init.asm @@ -24,6 +24,9 @@ warnpc $8084AF org $8084AF .end_clear_bank +org $80856E + JML init_post_boot + org $81F000 print pc, " init start" @@ -243,5 +246,17 @@ init_controller_bindings: RTL } +init_post_boot: +{ + ; Is quickboot enabled? + LDA !sram_cutscenes : AND !CUTSCENE_QUICKBOOT : BEQ .done + + ; Boot to the infohud menu + JML cm_boot + + .done + JML $82893D ; hijacked code: start main game loop +} + print pc, " init end" warnpc $81FF00 ; Special thanks diff --git a/src/mainmenu.asm b/src/mainmenu.asm index 34173291..d18c1b99 100644 --- a/src/mainmenu.asm +++ b/src/mainmenu.asm @@ -2934,6 +2934,7 @@ game_debugfixscrolloffsets: ; --------------- CutscenesMenu: + dw #cutscenes_quickboot dw #cutscenes_skip_splash dw #cutscenes_skip_intro dw #cutscenes_skip_ceres_arrival @@ -2955,8 +2956,11 @@ CutscenesMenu: dw #$0000 %cm_header("CUTSCENES AND EFFECTS") +cutscenes_quickboot: + %cm_toggle_bit("Boot to Menu", !sram_cutscenes, !CUTSCENE_QUICKBOOT, #0) + cutscenes_skip_splash: - %cm_toggle_bit("Fast Nintendo splash", !sram_cutscenes, !CUTSCENE_SKIP_SPLASH, #0) + %cm_toggle_bit("Fast Nintendo Splash", !sram_cutscenes, !CUTSCENE_SKIP_SPLASH, #0) cutscenes_skip_intro: %cm_toggle_bit("Skip Intro", !sram_cutscenes, !CUTSCENE_SKIP_INTRO, #0) diff --git a/src/menu.asm b/src/menu.asm index e54f2247..89298140 100644 --- a/src/menu.asm +++ b/src/menu.asm @@ -2,10 +2,6 @@ org $85FD00 print pc, " menu bank85 start" -wait_for_lag_frame_long: - JSR $8136 - RTL - initialize_ppu_long: PHP : %a16() LDA $7E33EA : STA !ram_cgram_cache+$2E @@ -41,6 +37,8 @@ cm_start: PHB : PHX : PHY PHK : PLB + LDA #$0000 : STA !ram_quickboot_spc_state + ; Ensure sound is enabled when menu is open LDA !DISABLE_SOUNDS : PHA STZ !DISABLE_SOUNDS @@ -94,6 +92,36 @@ cm_start: RTL } +cm_boot: +{ + PHK : PLB + LDA #cm_spc_init : STA !ram_quickboot_spc_state + + %a8() + LDA #$5A : STA $2109 ; BG3 tilemap base address + LDA #$04 : STA $212C ; Enable BG3; disable all else + %a16() + JSR cm_init + JSL cm_draw + JSR cm_loop + + .spc_loop + JSR cm_wait_for_lag_frame + LDA !ram_quickboot_spc_state : BNE .spc_loop + + .done + LDA !ram_custom_preset : BNE .preset_load + LDA !ram_load_preset : BEQ .main_game_loop + + .preset_load + JSL preset_load + + .main_game_loop + PEA $8282 : PLB : PLB + %a8() + JML $828944 +} + cm_init: { ; Setup registers @@ -134,6 +162,28 @@ cm_set_etanks_and_reserve: RTL } +cm_wait_for_lag_frame: +{ + PHP : %ai16() + LDA !ram_quickboot_spc_state : TAX + + LDA $05B8 ; lag frame counter + ; (it's only 8 bits, but it's OK if we mix it up with the variable after) + .loop + CMP $05B8 + BNE .done + + CPX #$0000 : BEQ .loop + PHA : PHP : PHB : JSR cm_jump_x : PLB : PLP + LDA !ram_quickboot_spc_state : TAX : PLA + BRA .loop + + .done + PLP : RTS +} + +cm_jump_x: + DEX : PHX : RTS ; ---------- ; Drawing @@ -507,7 +557,7 @@ cm_tilemap_menu: cm_tilemap_transfer: { - JSL wait_for_lag_frame_long ; Wait for lag frame + JSR cm_wait_for_lag_frame ; Wait for lag frame %a16() LDA #$5800 : STA $2116 ; VRAM addr @@ -1560,7 +1610,7 @@ menu_ctrl_clear_input_display: cm_loop: { %ai16() - JSL wait_for_lag_frame_long + JSR cm_wait_for_lag_frame JSL $808F0C ; Music queue JSL $8289EF ; Sound fx queue JSL MenuRNG @@ -2021,7 +2071,7 @@ kb_main_loop: RTL .new_input - JSL wait_for_lag_frame_long + JSR cm_wait_for_lag_frame JSL $808F0C ; Music queue JSL $8289EF ; Sound fx queue JSR kb_handle_inputs @@ -3461,6 +3511,132 @@ MenuRNG2: RTL } +!cm_spc_db = $30 +!cm_spc_data = $31 +!cm_spc_index = $33 +!cm_spc_len = $34 + +cm_spc_init: { + ; wait for SPC to be ready + LDA #$BBAA : CMP $2140 : BNE .return + + %a8() + LDA #$CC + STA !cm_spc_index + + %a16() + LDA #$CFCF + STA !cm_spc_db + LDA #$8000 + STA !cm_spc_data + + LDA #cm_spc_next_block + STA !ram_quickboot_spc_state + +.return +RTS +} + +cm_spc_next_block: { + %a8() + PHB : LDA !cm_spc_db : PHA : PLB + LDY !cm_spc_data + + ; Get block size + LDA #$01 + LDX $0000, y + BNE .not_last : LDA #$00 + .not_last + INY : BNE + : JSR cm_spc_inc_bank + + INY : BNE + : JSR cm_spc_inc_bank + + STX !cm_spc_len + + ; Get block address + LDX $0000, y + INY : BNE + : JSR cm_spc_inc_bank + + INY : BNE + : JSR cm_spc_inc_bank + + PLB : STX $2142 + + STA $2141 + + %a16() + LDA #cm_spc_next_block_wait + STA !ram_quickboot_spc_state + + RTS +} + +cm_spc_inc_bank: { + PHA : LDA !cm_spc_db : INC A : STA !cm_spc_db + PHA : PLB : PLA + LDY #$8000 + RTS +} + +cm_spc_next_block_wait: { + %a8() + LDA !cm_spc_index : STA $2140 : CMP $2140 : BNE .return + + STZ !cm_spc_index + %a16() + LDA !cm_spc_len : BEQ .eof + LDA #cm_spc_transfer + STA !ram_quickboot_spc_state + STY !cm_spc_data + RTS + + .eof + LDA #$0000 + STA !ram_quickboot_spc_state + + .return + RTS +} + +cm_spc_transfer: { + ; Determine how many bytes to transfer + LDA !cm_spc_len : TAX + SBC #$0040 : BCC .last + LDX #$0040 : STA !cm_spc_len + BRA .setup + .last + STZ !cm_spc_len + + .setup + %a8() + PHB : LDA !cm_spc_db : PHA : PLB + LDY !cm_spc_data + + LDA !cm_spc_index + + %a8() + .transfer_loop + XBA : LDA $0000, y : XBA + + %a16() : STA $002140 : %a8() + + .wait_loop + CMP $002140 : BNE .wait_loop + + INC A + INY : BNE + : JSR cm_spc_inc_bank + + + DEX : BNE .transfer_loop + + LDX !cm_spc_len : BNE .timeout + ; Done with the transfer! + CLC : ADC #$03 : STA !cm_spc_index : STY !cm_spc_data + %a16() : LDA #cm_spc_next_block : STA !ram_quickboot_spc_state + + PLB + RTS + + .timeout + STA !cm_spc_index : STY !cm_spc_data + + PLB + RTS +} ; ---------- ; Resources diff --git a/src/symbols.asm b/src/symbols.asm index 61c05c72..3fca2962 100644 --- a/src/symbols.asm +++ b/src/symbols.asm @@ -94,6 +94,8 @@ ram_auto_save_state = !ram_auto_save_state ; !WRAM_START+$7C ram_lag_counter = !ram_lag_counter ; !WRAM_START+$7E ram_kraid_adjust_timer = !ram_kraid_adjust_timer ; !WRAM_START+$80 +ram_quickboot_spc_state = !ram_quickboot_spc_state ; !WRAM_START+$82 + ; ---------------------------------------------------------- ; Variables below this point are PERSISTENT -- they maintain ; their value across savestates. Use this section for From 6fa1902463b3a93e38f6f58e149b33c8dd9b7adf Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:38:48 -0800 Subject: [PATCH 3/8] Use last selected save file to determine initial controller bindings --- src/init.asm | 40 ++++++++++++++-------------------------- src/mainmenu.asm | 1 - src/presets.asm | 1 - 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/init.asm b/src/init.asm index 21290a16..ab8ff6e8 100644 --- a/src/init.asm +++ b/src/init.asm @@ -220,34 +220,22 @@ init_menu_customization: RTL } -init_controller_bindings: -{ - ; check if any non-dpad bindings are set - LDX #$000A - LDA.w !IH_INPUT_SHOT+$0C - .loopBindings - ORA.w !IH_INPUT_SHOT,X - DEX #2 : BPL .loopBindings - AND #$FFF0 : BNE .done - - ; load default dpad bindings - LDA #$0800 : STA.w !INPUT_BIND_UP - LSR : STA.w !INPUT_BIND_DOWN - LSR : STA.w !INPUT_BIND_LEFT - LSR : STA.w !INPUT_BIND_RIGHT - - ; load default non-dpad bindings - LDX #$000C - .loopTable - LDA.l ControllerLayoutTable,X : STA.w !IH_INPUT_SHOT,X - DEX #2 : BPL .loopTable - - .done - RTL -} - init_post_boot: { + ; Load the last selected file slot (so that the user's controller + ; bindings will apply if they load a preset without loading a save file) + LDA $701FEC ; Selected save slot + STA !CURRENT_SAVE_FILE + CMP #$0003 : BCC .valid_index + LDA #$0000 + .valid_index + JSL $818085 ; Load save file + BCC .check_quickboot + + ; No valid save; load a new file (for default controller bindings) + JSR $B2CB + + .check_quickboot ; Is quickboot enabled? LDA !sram_cutscenes : AND !CUTSCENE_QUICKBOOT : BEQ .done diff --git a/src/mainmenu.asm b/src/mainmenu.asm index d18c1b99..c5fb7e26 100644 --- a/src/mainmenu.asm +++ b/src/mainmenu.asm @@ -1817,7 +1817,6 @@ action_teleport: STZ $0E18 ; Set elevator to inactive STZ $1C1F ; Clear message box index - JSL init_controller_bindings LDA !SAMUS_HP_MAX : BNE .branch LDA #$001F : STA !SAMUS_HP diff --git a/src/presets.asm b/src/presets.asm index 39aa1433..847ceba9 100644 --- a/src/presets.asm +++ b/src/presets.asm @@ -569,7 +569,6 @@ endif TDC : STA !ram_transition_flag JSL init_heat_damage_ram JSL init_physics_ram - JSL init_controller_bindings LDA #$E737 : STA $099C ; Pointer to next frame's room transition code = $82:E737 From a06a4881222f8402df2204690fa41dcff60b77fd Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:15:53 -0800 Subject: [PATCH 4/8] Disable sounds while SPC is booting ...to prevent conflicting SPC register writes. I don't think this could cause any problems, but it's best to be safe. --- src/menu.asm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/menu.asm b/src/menu.asm index 89298140..1d5ed076 100644 --- a/src/menu.asm +++ b/src/menu.asm @@ -97,6 +97,9 @@ cm_boot: PHK : PLB LDA #cm_spc_init : STA !ram_quickboot_spc_state + ; Disable sounds until we boot the SPC + LDA #$0001 : STA !DISABLE_SOUNDS + %a8() LDA #$5A : STA $2109 ; BG3 tilemap base address LDA #$04 : STA $212C ; Enable BG3; disable all else @@ -3586,8 +3589,8 @@ cm_spc_next_block_wait: { RTS .eof - LDA #$0000 - STA !ram_quickboot_spc_state + LDA #$0000 : STA !ram_quickboot_spc_state + STZ !DISABLE_SOUNDS .return RTS From 9fc1e0f2cd8733a93761013c12b2420d2a8399e8 Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Sat, 2 Mar 2024 00:22:28 -0800 Subject: [PATCH 5/8] remove "Skip Nintendo Splash" option --- src/cutscenes.asm | 20 -------------------- src/defines.asm | 2 +- src/mainmenu.asm | 4 ---- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/cutscenes.asm b/src/cutscenes.asm index afe3e7ea..c806c7e1 100644 --- a/src/cutscenes.asm +++ b/src/cutscenes.asm @@ -14,14 +14,6 @@ endif JSR cutscenes_quickboot_hijack NOP -if !FEATURE_PAL -org $8B92B5 -else -org $8B930C -endif - JSL cutscenes_nintendo_splash - NOP : NOP - org $80AE5C JSR cutscenes_door_transition @@ -132,18 +124,6 @@ cutscenes_quickboot_hijack: JML $808482 ; finish boot code; another hijack will launch the menu } -cutscenes_nintendo_splash: -{ - LDX #$0078 - LDA !sram_cutscenes - AND !CUTSCENE_SKIP_SPLASH - BEQ .done - LDX #$0001 - .done - STX $0DE2 - RTL -} - cutscenes_add_elevator_speed: { LDA !sram_fast_elevators : BEQ .slow diff --git a/src/defines.asm b/src/defines.asm index f943272e..052d3813 100644 --- a/src/defines.asm +++ b/src/defines.asm @@ -704,10 +704,10 @@ endif !CUTSCENE_FAST_PHANTOON = #$0200 !CUTSCENE_FAST_KRAID = #$0400 !CUTSCENE_SKIP_SPLASH = #$0800 +!CUTSCENE_QUICKBOOT = #$0800 !CUTSCENE_SKIP_GAMEOVER = #$1000 !CUTSCENE_FAST_BOWLING = #$2000 !CUTSCENE_KRAID_DEATH_CAMERA = #$4000 -!CUTSCENE_QUICKBOOT = #$8000 !SUPPRESS_CRATERIA_LIGHTNING = #$0001 !SUPPRESS_ESCAPE_FLASHING = #$0002 diff --git a/src/mainmenu.asm b/src/mainmenu.asm index c5fb7e26..28821651 100644 --- a/src/mainmenu.asm +++ b/src/mainmenu.asm @@ -2934,7 +2934,6 @@ game_debugfixscrolloffsets: CutscenesMenu: dw #cutscenes_quickboot - dw #cutscenes_skip_splash dw #cutscenes_skip_intro dw #cutscenes_skip_ceres_arrival dw #cutscenes_skip_g4 @@ -2958,9 +2957,6 @@ CutscenesMenu: cutscenes_quickboot: %cm_toggle_bit("Boot to Menu", !sram_cutscenes, !CUTSCENE_QUICKBOOT, #0) -cutscenes_skip_splash: - %cm_toggle_bit("Fast Nintendo Splash", !sram_cutscenes, !CUTSCENE_SKIP_SPLASH, #0) - cutscenes_skip_intro: %cm_toggle_bit("Skip Intro", !sram_cutscenes, !CUTSCENE_SKIP_INTRO, #0) From 8afc098d6e44d5490c983610232058a0f84c84c1 Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Sat, 2 Mar 2024 00:25:23 -0800 Subject: [PATCH 6/8] enable quickboot by default for dev builds --- src/init.asm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/init.asm b/src/init.asm index ab8ff6e8..85227f4b 100644 --- a/src/init.asm +++ b/src/init.asm @@ -97,7 +97,12 @@ init_sram: TDC : STA !sram_top_display_mode STA !sram_room_layout INC : STA !sram_healthalarm - LDA #$0003 : STA !sram_cutscenes + +if !FEATURE_DEV + LDA !CUTSCENE_QUICKBOOT : STA !sram_cutscenes +else + LDA !CUTSCENE_QUICKBOOT|$0003 : STA !sram_cutscenes +endif .sram_upgrade_CtoD TDC : STA !sram_preset_options From 248a4145dde49ea26f58e416e84ceca21a42696c Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:43:57 -0800 Subject: [PATCH 7/8] fix broken logic this is what i get for committing at 1am --- src/init.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.asm b/src/init.asm index 85227f4b..a271a7d9 100644 --- a/src/init.asm +++ b/src/init.asm @@ -99,9 +99,9 @@ init_sram: INC : STA !sram_healthalarm if !FEATURE_DEV - LDA !CUTSCENE_QUICKBOOT : STA !sram_cutscenes -else LDA !CUTSCENE_QUICKBOOT|$0003 : STA !sram_cutscenes +else + LDA #$0003 : STA !sram_cutscenes endif .sram_upgrade_CtoD From e348c5867324e116c9c33b57d757546f02cb5aac Mon Sep 17 00:00:00 2001 From: Jonathan Keller <19418817+NobodyNada@users.noreply.github.com> Date: Mon, 4 Mar 2024 01:35:07 -0800 Subject: [PATCH 8/8] Don't try to load SPC again after a soft reset --- src/cutscenes.asm | 7 +++++-- src/defines.asm | 9 ++++++--- src/init.asm | 7 +++++-- src/menu.asm | 9 +++++++-- src/symbols.asm | 4 ++-- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/cutscenes.asm b/src/cutscenes.asm index c806c7e1..adc3f622 100644 --- a/src/cutscenes.asm +++ b/src/cutscenes.asm @@ -11,7 +11,7 @@ org $8B9287 else org $8B92DE endif - JSR cutscenes_quickboot_hijack + JSR cutscenes_nintendo_logo_hijack NOP @@ -108,11 +108,12 @@ endif org $8BF800 print pc, " cutscenes start" -cutscenes_quickboot_hijack: +cutscenes_nintendo_logo_hijack: { JSL $80834B ; hijacked code LDA !sram_cutscenes : AND !CUTSCENE_QUICKBOOT : BNE .quickboot + STA !ram_quickboot_spc_state ; A is 0 RTS .quickboot @@ -121,6 +122,8 @@ cutscenes_quickboot_hijack: PLA ; saved processor status and 1 byte of next return address PLA ; remainder of next return address + LDA #$0001 : STA !ram_quickboot_spc_state + JML $808482 ; finish boot code; another hijack will launch the menu } diff --git a/src/defines.asm b/src/defines.asm index 052d3813..95f54e13 100644 --- a/src/defines.asm +++ b/src/defines.asm @@ -93,9 +93,7 @@ !ram_lag_counter = !WRAM_START+$7E !ram_kraid_adjust_timer = !WRAM_START+$80 -!ram_quickboot_spc_state = !WRAM_START+$82 - -!WRAM_PERSIST_START = !ram_quickboot_spc_state+$02 +!WRAM_PERSIST_START = !ram_kraid_adjust_timer+$02 ; ---------------------------------------------------------- ; Variables below this point are PERSISTENT -- they maintain ; their value across savestates. Use this section for @@ -159,6 +157,11 @@ !ram_itempickups_hidden = !WRAM_PERSIST_START+$62 !ram_frames_held = !WRAM_PERSIST_START+$64 +!ram_quickboot_spc_state = !WRAM_PERSIST_START+$66 + ; 0: SPC load completed/not requested + ; 1: SPC load requested + ; ROM address: routine to perform next initialization step + ; ^ FREE SPACE ^ up to +$7A (!WRAM_START+$FC - !WRAM_PERSIST_START) ; ----------------------- diff --git a/src/init.asm b/src/init.asm index a271a7d9..e6eece9c 100644 --- a/src/init.asm +++ b/src/init.asm @@ -6,7 +6,8 @@ org $808455 ; hijack when clearing bank 7E org $808490 - PHA + ; Save quickboot state since it needs to distinguish between a soft and hard reset + LDY.w !ram_quickboot_spc_state LDX #$3FFE .clear_bank_loop STZ $0000,X @@ -16,9 +17,11 @@ org $808490 DEX : DEX BPL .clear_bank_loop JSL init_nonzero_wram - PLA + + STY.w !ram_quickboot_spc_state BRA .end_clear_bank + warnpc $8084AF org $8084AF diff --git a/src/menu.asm b/src/menu.asm index 1d5ed076..35deca9d 100644 --- a/src/menu.asm +++ b/src/menu.asm @@ -95,10 +95,12 @@ cm_start: cm_boot: { PHK : PLB + LDA !ram_quickboot_spc_state : BEQ .skip_spc LDA #cm_spc_init : STA !ram_quickboot_spc_state ; Disable sounds until we boot the SPC LDA #$0001 : STA !DISABLE_SOUNDS +.skip_spc %a8() LDA #$5A : STA $2109 ; BG3 tilemap base address @@ -110,7 +112,7 @@ cm_boot: .spc_loop JSR cm_wait_for_lag_frame - LDA !ram_quickboot_spc_state : BNE .spc_loop + LDA !ram_quickboot_spc_state : BMI .spc_loop .done LDA !ram_custom_preset : BNE .preset_load @@ -176,7 +178,7 @@ cm_wait_for_lag_frame: CMP $05B8 BNE .done - CPX #$0000 : BEQ .loop + CPX #$0000 : BPL .loop PHA : PHP : PHB : JSR cm_jump_x : PLB : PLP LDA !ram_quickboot_spc_state : TAX : PLA BRA .loop @@ -3523,6 +3525,8 @@ cm_spc_init: { ; wait for SPC to be ready LDA #$BBAA : CMP $2140 : BNE .return + LDA #$FFFF : STA $0617 ; disable soft rest + %a8() LDA #$CC STA !cm_spc_index @@ -3591,6 +3595,7 @@ cm_spc_next_block_wait: { .eof LDA #$0000 : STA !ram_quickboot_spc_state STZ !DISABLE_SOUNDS + STZ $0617 .return RTS diff --git a/src/symbols.asm b/src/symbols.asm index 3fca2962..aedfcdb8 100644 --- a/src/symbols.asm +++ b/src/symbols.asm @@ -94,8 +94,6 @@ ram_auto_save_state = !ram_auto_save_state ; !WRAM_START+$7C ram_lag_counter = !ram_lag_counter ; !WRAM_START+$7E ram_kraid_adjust_timer = !ram_kraid_adjust_timer ; !WRAM_START+$80 -ram_quickboot_spc_state = !ram_quickboot_spc_state ; !WRAM_START+$82 - ; ---------------------------------------------------------- ; Variables below this point are PERSISTENT -- they maintain ; their value across savestates. Use this section for @@ -159,6 +157,8 @@ ram_itempickups_chozo = !ram_itempickups_chozo ; !WRAM_PERSIST_START+$60 ram_itempickups_hidden = !ram_itempickups_hidden ; !WRAM_PERSIST_START+$62 ram_frames_held = !ram_frames_held ; !WRAM_PERSIST_START+$64 +ram_quickboot_spc_state = !ram_quickboot_spc_state ; !WRAM_PERSIST_START+$66 + ; ^ FREE SPACE ^ up to +$7A (!WRAM_START+$FC - !WRAM_PERSIST_START) ; -----------------------