diff --git a/patches/ips/trimmed_fanfare.ips b/patches/ips/trimmed_fanfare.ips new file mode 100644 index 000000000..6196d328f Binary files /dev/null and b/patches/ips/trimmed_fanfare.ips differ diff --git a/patches/rom_map/Bank 84.txt b/patches/rom_map/Bank 84.txt index d2728ae48..f9ae260dc 100644 --- a/patches/rom_map/Bank 84.txt +++ b/patches/rom_map/Bank 84.txt @@ -13,7 +13,8 @@ F580 - F58D: ; mb_left_entrance.asm F590 - F59D: ; horizontal_door_fix.asm F5A0 - F5B5: ; energy_station_reserves.asm F5C0 - F62F: ; wall_doors.asm -F630 - F6CF: [FREE] +F630 - F68F: ; trimmed_fanfare.asm +F690 - F6CF: [FREE] F6D0 - F6F9: ; missile_refill_all.asm F700 - F721: ; nothing_item.asm F730 - F7F1: ; stats.asm diff --git a/patches/rom_map/RAM.txt b/patches/rom_map/RAM.txt index e6f1723ec..97a1939d0 100644 --- a/patches/rom_map/RAM.txt +++ b/patches/rom_map/RAM.txt @@ -48,7 +48,8 @@ $7EF596: vanilla_bugfixes.asm $7EF597-$7EF599: split_speed.asm $7EF59A-$7EF59C: reserve_backward_fill.asm $7EF59C-$7EF59E: crash_handle_xmode.asm -$7EF59E-$7EFE00: [FREE] +$7EF59E-$7EF5A0: trimmed_fanfare.asm +$7EF5A0-$7EFE00: [FREE] $7EFE00: map area (copy of $1F5B to be saved to SRAM) $7EFE02: map area explored mask $7EFE04: copy of $1F5D (to be saved to SRAM for escape autosave) diff --git a/patches/src/trimmed_fanfare.asm b/patches/src/trimmed_fanfare.asm new file mode 100644 index 000000000..dea725797 --- /dev/null +++ b/patches/src/trimmed_fanfare.asm @@ -0,0 +1,63 @@ +; Fanfare fix by Stag Shot / nn44 +; +; Fixes potential fanfare overlap with trimmed setting in rooms with two items. + +lorom + +!bank_84_free_space_start = $84F630 +!bank_84_free_space_end = $84F68F + +!ram_music_backup = $7EF59E + +org $82e126 + jml check_music + nop #3 + +org $848c01 + jsl clear_music + +org $858491 + dw $00F0 ; 4s + +org !bank_84_free_space_start +check_music: + lda !ram_music_backup + cmp #$ffff ; music backup active? + bne .normal_ret + jml $82e134 ; skip rest of func + +.normal_ret + lda #$0000 ; replaced code + jsl $808ff7 ; + jml $82e12d + +clear_music: + phy + pha ; music track + cmp #$0002 + bne .leave ; fanfare? + lda $7f5 ; current music + cmp #$0002 + bne .leave_2 ; in middle of previous fanfare? + lda #$0000 + jsl $808fc1 ; stop music (8-frame delay) + pla + jsl $808fc1 ; fanfare (8-frame delay) + lda !ram_music_backup ; previous music + ldy #$0168 ; 6s + jsl $808ff7 ; music (delayed) + lda #$ffff ; clear music track + sta !ram_music_backup + bra .leave_3 + +.leave + lda $7f5 +.leave_2 + sta !ram_music_backup ; save music track + pla ; music track + jsl $808fc1 ; replaced code +.leave_3 + ply + rtl + +assert pc() <= !bank_84_free_space_end diff --git a/rust/maprando/src/patch.rs b/rust/maprando/src/patch.rs index f764f8d43..f35bf1fcb 100644 --- a/rust/maprando/src/patch.rs +++ b/rust/maprando/src/patch.rs @@ -712,7 +712,8 @@ impl Patcher<'_> { } Fanfares::Trimmed => { // reduce fanfare dialogue box duration (240 frames) - self.rom.write_u16(snes2pc(0x858491), 0xF0)?; + patches.push("trimmed_fanfare"); + patches.push("vanilla_fanfare_stop_sounds"); } Fanfares::Off => { patches.push("itemsounds"); diff --git a/scripts/build_ips.py b/scripts/build_ips.py index a174ef9f4..6fb7c0da4 100644 --- a/scripts/build_ips.py +++ b/scripts/build_ips.py @@ -162,6 +162,10 @@ def check_range(filename, other_filename, overlap_start, overlap_end): ['hud_expansion_opaque', 0xB6CE00, 0xB6D000], ['hud_expansion_opaque', 0xB6E800, 0xB6F000] ], + 'trimmed_fanfare': [ + ['itemsounds', 0x82E126, 0x82E12C], + ['itemsounds', 0x858491, 0x858493], + ], } failed = False