Skip to content
Draft
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
Binary file modified patches/ips/fast_reload.ips
Binary file not shown.
Binary file modified patches/ips/new_game.ips
Binary file not shown.
Binary file added patches/ips/savestate.ips
Binary file not shown.
1 change: 1 addition & 0 deletions patches/rom_map/Bank 85.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ AD00 - AD40: ; crash_handle_springball.asm
AD43 - AEDB: ; reserve_backward_fill.asm
AEE0 - B599: ; crash_handle_base.asm
B600 - B93E: ; map_area.asm
C000 - C400: ; savestate.asm
4 changes: 3 additions & 1 deletion patches/rom_map/SRAM.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ $704400-704800: (reserved in case we expand the temporary tileset graphics)
$703000-707400: backup of RAM $7E5000-$7E5400 and $7E7000-$7EB000, used only during unpause (decompression.asm)
$707400-707800: room map tile graphics (map_area.asm)
$707800-707F00: room name map tiles, used only during pause menu (map_area.asm/pause_menu_objectives.asm)
$707F00-708A00: [FREE]
$707F00-707F0A: savestate.asm
708A00: [FREE]
$710000-770200: savestate.asm
53 changes: 33 additions & 20 deletions patches/src/fast_reload.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Fast reload on death
; Based on patch by total: https://metroidconstruction.com/resource.php?id=421
; Compile with "asar" (https://github.com/RPGHacker/asar/releases)

arch 65816

!deathhook82 = $82DDC7 ;$82 used for death hook (game state $19)

Expand All @@ -13,6 +13,8 @@
!bank_85_free_space_start = $859880
!bank_85_free_space_end = $859980

!savestate_button_combo = $82FE78 ; This should be inside free space, and also consistent with reference in customize.rs
!loadstate_button_combo = $82FE7A ; This should be inside free space, and also consistent with reference in customize.rs
!spin_lock_button_combo = $82FE7C ; This should be inside free space, and also consistent with reference in customize.rs
!reload_button_combo = $82FE7E ; This should be inside free space, and also consistent with reference in customize.rs
!freespacea0 = $a0fe00 ;$A0 used for instant save reload
Expand Down Expand Up @@ -62,25 +64,25 @@ org $85811E

org !bank_85_free_space_start
SupportedStates:
dw #$0007 ; Main gameplay fading in
dw #$0008 ; Main gameplay
dw #$0009 ; Hit a door block
dw #$000a ; Loading next room
dw #$000b ; Loading next room
dw #$000c ; Pausing, normal gameplay but darkening
dw #$000d ; Pausing, loading pause menu
dw #$000e ; Paused, loading pause menu
dw #$000f ; Paused, objective/map/equipment screens
dw #$0012 ; Unpausing, normal gameplay but brightening
dw #$0013 ; Death sequence, start
dw #$0014 ; Death sequence, black out surroundings
dw #$0015 ; Death sequence, wait for music
dw #$0016 ; Death sequence, pre-flashing
dw #$0017 ; Death sequence, flashing
dw #$0018 ; Death sequence, explosion white out
dw #$001b ; Reserve tanks auto.
dw #$0027 ; Ending and credits. Cinematic. (reboot only)
dw #$ffff
dw $0007 ; Main gameplay fading in
dw $0008 ; Main gameplay
dw $0009 ; Hit a door block
dw $000a ; Loading next room
dw $000b ; Loading next room
dw $000c ; Pausing, normal gameplay but darkening
dw $000d ; Pausing, loading pause menu
dw $000e ; Paused, loading pause menu
dw $000f ; Paused, objective/map/equipment screens
dw $0012 ; Unpausing, normal gameplay but brightening
dw $0013 ; Death sequence, start
dw $0014 ; Death sequence, black out surroundings
dw $0015 ; Death sequence, wait for music
dw $0016 ; Death sequence, pre-flashing
dw $0017 ; Death sequence, flashing
dw $0018 ; Death sequence, explosion white out
dw $001b ; Reserve tanks auto.
dw $0027 ; Ending and credits. Cinematic. (reboot only)
dw $ffff

hook_main:
jsl $808338 ; run hi-jacked instruction
Expand Down Expand Up @@ -140,6 +142,17 @@ hook_main:
and !reload_button_combo ; L + R + Select + Start
bne .reset ; Reset only if at least one of the inputs is newly pressed
.noreset
lda $8B
cmp !savestate_button_combo
bne .nosavestate
jsl $85c000 ; save state
bra .btn_leave
.nosavestate
lda $8B
cmp !loadstate_button_combo
bne .btn_leave
jsl $85c003 ; load state
.btn_leave
plp
rtl
.reset:
Expand Down
2 changes: 1 addition & 1 deletion patches/src/map_area.asm
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ load_bg3_map_tilemap_wrapper:

assert pc() <= $85A290
org $85A290
; must match the reference in fix_kraid_hud.asm
; must match the reference in fix_kraid_hud.asm, savestate.asm
load_bg3_map_tiles_wrapper:
jsr load_bg3_map_tiles
rtl
Expand Down
5 changes: 5 additions & 0 deletions patches/src/new_game.asm
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ startup:
sta $702700, X
txa
bne .copy_revealed

; Initialize SRAM savestate counters
lda #$0000
sta $707F08 ; saves
sta $707F0A ; loads

.skip_init:

Expand Down
Loading
Loading