Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch "Use Sonic CD Jump Sound" in "Audio/Sonic 1" by "Lave sIime" does "Replaces Sonic 1's jump sound effect with Sonic CD's unique one."
{
#lib "AudioRedirection"
#lib "RSDK"

AudioRedirection.AddSoundReplacement(RSDK.Game.Sonic1, "Global/Jump.wav", "SFX_SCD_F02_Jump");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch "Use Sonic CD Jump Sound" in "Audio/Sonic 2" by "Lave sIime" does "Replaces Sonic 2's jump sound effect with Sonic CD's unique one."
{
#lib "AudioRedirection"
#lib "RSDK"

AudioRedirection.AddSoundReplacement(RSDK.Game.Sonic2, "Global/Jump.ogg", "SFX_SCD_F02_Jump");
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
Code "Disable Super Music" in "Audio/Sonic 3 & Knuckles" by "MegAmi" does
/*
Forces the flag for the Super music in Sonic 3 & Knuckles to be disabled.

Notes;
- Due to how the Super music is coded, it may still play in some instances, such as after the AIZ Act 1 bombing cutscene.
*/
Code "Disable Super Music" in "Audio/Sonic 3 & Knuckles" by "MegAmi & Lave sIime" does "Forces the Super music in Sonic 3 & Knuckles to be disabled."
//
#lib "RSDK"

static bool _isInitialised = false;
//
{
if (!_isInitialised)
{
// 2.0.2: 0x1401D555A
Memory.WriteForceJump(ScanSignature("\x75\x07\xB9\x09\x00\x00\x00\xEB\x02\x33\xC9", "x?xxxxxx?xx"));

// 2.0.2: 0x1401D4DA0
Memory.WriteForceJump(ScanSignature("\x75\x50\xBB\x28\x00\x00\x00\x66\x0F\x1F\x84\x00\x00\x00\x00\x00", "x?xxxxxxxxxxxxxx"));

_isInitialised = true;
}

if (RSDK.GetRSDKGlobalsPtr() == 0)
return;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch "Use Sonic CD Jump Sound" in "Audio/Sonic 3 & Knuckles" by "Lave sIime" does "Replaces Sonic 3's jump sound effect with Sonic CD's unique one."
{
#lib "AudioRedirection"
#lib "RSDK"

AudioRedirection.AddSoundReplacement(RSDK.Game.Sonic3k, "Global/Jump.wav", "SFX_SCD_F02_Jump");
}
49 changes: 49 additions & 0 deletions Source/Sonic Origins/Audio/Sonic CD/Random Soundtrack Region.hmm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Patch "Random Soundtrack Region" in "Audio/Sonic CD" by "Lave sIime" does
/*
Individually randomizes the soundtrack region for every applicable song in the game.

Notes;
- Act Results timings and Invincibility duration will still be controlled by the in-game soundtrack setting.
*/
{
#include "Helpers" noemit
private static Random _rand = new Random();

static class MusicTrackHook
{
UNMANAGED_FUNCTION(string, SetMusicTrack, string filePath)
{
// Nothing too complicated - if we start with a region prefix, then just replace it with a random one
if (filePath != null && (filePath.StartsWith("US") || filePath.StartsWith("JP")))
{
filePath = ((_rand.NextDouble() > 0.5) ? "US" : "JP") + filePath.Substring(2);

// Special exception: JP/TimeAttack.ogg exists but there's no US version, so replace it with the DA Garden theme (as does the base game already)
if (filePath == "JP/TimeAttack.ogg")
filePath = "US/DAGarden.ogg";
}

return filePath;
}
}

WriteAsmHook
(
$@"
push rax
push rdx
push r9

mov rax, {MusicTrackHook._fpSetMusicTrack}
call rax
mov rcx, rax

pop r9
pop rdx
pop rax
",
/* 2.0.2: 0x1400A468F */
ScanSignature("\x57\x48\x83\xEC\x20\x8B\xC2\x41\x0F\xB6\xF0\x83\xE0\x0F", "xxxxxxxxxxxxxx"),
HookBehavior.After
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch "Use Sonic 1 Jump Sound" in "Audio/Sonic CD" by "Lave sIime" does "Replaces Sonic CD's unique jump sound effect with the one used in Sonic 1."
{
#lib "AudioRedirection"
#lib "RSDK"

AudioRedirection.AddSoundReplacement(RSDK.Game.SonicCD, "Global/Jump.wav", "SFX_A0_Jump");
}
7 changes: 7 additions & 0 deletions Source/Sonic Origins/Fixes/Sonic 2/Fix Insta-Shield Sound.hmm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch "Fix Insta-Shield Sound" in "Fixes/Sonic 2" by "Lave sIime" does "Fixes the Insta-Shield playing the wrong sound effect in Sonic 2."
{
#lib "AudioRedirection"
#lib "RSDK"

AudioRedirection.AddSoundReplacement(RSDK.Game.Sonic2, "Global/InstaShield.ogg", "S015_S42_InstaShield");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch "Fix Knuckles Landing Sound" in "Fixes/Sonic 2" by "Lave sIime" does "Fixes Knuckles playing the wrong sound effect when landing from a glide in Sonic 2."
{
#lib "AudioRedirection"
#lib "RSDK"

AudioRedirection.AddSoundReplacement(RSDK.Game.Sonic2, "Global/Landing.ogg", "RSDK-1---Landing");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Patch "Fix Missing Menu Fail Sound" in "Fixes/Sonic 3 & Knuckles" by "Lave sIime" does "Fixes the missing Fail sound after trying to input an invalid stage code in the Blue Spheres menu."
{
#lib "AudioRedirection"
#lib "RSDK"

AudioRedirection.AddSoundReplacement(RSDK.Game.Sonic3k, "Stage/Fail.wav", "S127_SB2_Fail");
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ Notes;
HookBehavior.Replace
);

// Fix the Super Peel Out always sending the player right in reverse gravity
WriteAsmHook
(
$@"
neg eax

; original instruction: cmp byte ptr [rbx + 0x56], 00
; instead of comparing the entire byte, let's check only the low bit (aka the x flip bit, ignoring the y flip bit)
movzx edx, byte ptr [rbx + 0x56]
and dl, 01
cmovne ecx, eax

xor edx, edx
mov [rbx + 0x34], ecx
",
/* Player::State_Peelout - 2.0.2: 0x1401EB828 */
ScanSignature
(
"\xF7\xD8\x80\x7B\x56\x00\x0F\x45\xC8\x33\xD2\x89\x4B\x34",
"xxxxxxxxxxxxxx"
),
HookBehavior.Replace
);

_isInitialised = true;
}

Expand Down
17 changes: 5 additions & 12 deletions Source/Sonic Origins/Libraries/AudioRedirection.hmm
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,10 @@ Library "AudioRedirection" by "Lave sIime"
mov rax, {GET_UNMANAGED_FUNCTION_PTR(MusicReplacement)}
call rax

; replacement found?
; if we didn't find a replacement, let's stick with the original result
test rax, rax
jnz found
cmovz rax, rbx

; nope, let's stick with the original result
mov rax, rbx

found:
pop r11
pop r10
mov rbx, [r11 + 0x10]
Expand All @@ -319,17 +315,14 @@ Library "AudioRedirection" by "Lave sIime"
(
$@"
mov rcx, rsi
mov rdi, rax
mov rax, {GET_UNMANAGED_FUNCTION_PTR(SoundReplacement)}
call rax

; replacement found?
; if we didn't find a replacement, let's stick with the original result
test rax, rax
jnz found

; nope, let's stick with the original result
mov rax, rdi
cmovz rax, rdi

found:
mov rbx, [rsp + 0x30]
mov rbp, [rsp + 0x38]
mov rsi, [rsp + 0x40]
Expand Down
Loading