Skip to content

Add boot-to-menu functionality #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.sw[op]
build/
tools/*.exe
tools/asar
.vscode/launch.json
.vscode/tasks.json
/names/custom_names.txt
33 changes: 20 additions & 13 deletions src/cutscenes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ endif
JSR cutscenes_load_ceres_arrival

if !FEATURE_PAL
org $8B92B5
org $8B9287
else
org $8B930C
org $8B92DE
endif
JSL cutscenes_nintendo_splash
NOP : NOP
JSR cutscenes_nintendo_logo_hijack
NOP


org $80AE5C
Expand Down Expand Up @@ -108,16 +108,23 @@ endif
org $8BF800
print pc, " cutscenes start"

cutscenes_nintendo_splash:
cutscenes_nintendo_logo_hijack:
{
LDX #$0078
LDA !sram_cutscenes
AND !CUTSCENE_SKIP_SPLASH
BEQ .done
LDX #$0001
.done
STX $0DE2
RTL
JSL $80834B ; hijacked code

LDA !sram_cutscenes : AND !CUTSCENE_QUICKBOOT : BNE .quickboot
STA !ram_quickboot_spc_state ; A is 0
RTS

.quickboot
PLA ; pop return address
PLB
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
}

cutscenes_add_elevator_speed:
Expand Down
6 changes: 6 additions & 0 deletions src/defines.asm
Original file line number Diff line number Diff line change
Expand Up @@ -157,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)

; -----------------------
Expand Down Expand Up @@ -702,6 +707,7 @@ 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
Expand Down
57 changes: 34 additions & 23 deletions src/init.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,14 +17,19 @@ 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
.end_clear_bank

org $80856E
JML init_post_boot


org $81F000
print pc, " init start"
Expand Down Expand Up @@ -94,7 +100,12 @@ init_sram:
TDC : STA !sram_top_display_mode
STA !sram_room_layout
INC : STA !sram_healthalarm

if !FEATURE_DEV
LDA !CUTSCENE_QUICKBOOT|$0003 : STA !sram_cutscenes
else
LDA #$0003 : STA !sram_cutscenes
endif

.sram_upgrade_CtoD
TDC : STA !sram_preset_options
Expand Down Expand Up @@ -217,30 +228,30 @@ init_menu_customization:
RTL
}

init_controller_bindings:
init_post_boot:
{
; 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
; 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

; Boot to the infohud menu
JML cm_boot

.done
RTL
JML $82893D ; hijacked code: start main game loop
}

print pc, " init end"
Expand Down
7 changes: 3 additions & 4 deletions src/mainmenu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -2934,7 +2933,7 @@ game_debugfixscrolloffsets:
; ---------------

CutscenesMenu:
dw #cutscenes_skip_splash
dw #cutscenes_quickboot
dw #cutscenes_skip_intro
dw #cutscenes_skip_ceres_arrival
dw #cutscenes_skip_g4
Expand All @@ -2955,8 +2954,8 @@ CutscenesMenu:
dw #$0000
%cm_header("CUTSCENES AND EFFECTS")

cutscenes_skip_splash:
%cm_toggle_bit("Fast Nintendo splash", !sram_cutscenes, !CUTSCENE_SKIP_SPLASH, #0)
cutscenes_quickboot:
%cm_toggle_bit("Boot to Menu", !sram_cutscenes, !CUTSCENE_QUICKBOOT, #0)

cutscenes_skip_intro:
%cm_toggle_bit("Skip Intro", !sram_cutscenes, !CUTSCENE_SKIP_INTRO, #0)
Expand Down
Loading