Compare commits

..

2 Commits

Author SHA1 Message Date
DeaTh-G 92ccc1f298 Make advertise logo overlay aspect ratio aware 2026-02-01 18:24:25 +01:00
Hyper 5e8695a157 Fix Werehog rotating into walls when leaving them at HFR (#1570) 2026-02-01 14:09:38 +03:00
6 changed files with 34 additions and 67 deletions
+3
View File
@@ -89,6 +89,9 @@ PPC_FUNC(sub_822C1130)
if (Config::EnableObjectCollisionDebugView)
*SWA::SGlobals::ms_IsObjectCollisionRender = true;
if (Config::EnableStageCollisionDebugView)
*SWA::SGlobals::ms_IsCollisionRender = true;
__imp__sub_822C1130(ctx, base);
}
@@ -1686,3 +1686,13 @@ void EndingTextPositionMidAsmHook(PPCRegister& r31, PPCRegister& f13)
else if (align == ALIGN_LEFT)
f13.f64 += 133.0 * (1.0 - g_aspectRatioNarrowScale);
}
// Offsets calculated by converting the 4:3 values to 16:9 space and then substracting the differences from the original 16:9 position.
// Afterward fact checked by overlaying a capture from the original hardware at 4:3 and a capture from recomp at 4:3.
void AdvertiseLogoPlacementMidAsmHook(PPCRegister& f0, PPCRegister& f13, PPCRegister& f12, PPCRegister& f11)
{
f0.f64 += -133.0f / 1280.0f * (1.0 - g_aspectRatioNarrowScale);
f13.f64 += 3.5f / 720.0f * (1.0 - g_aspectRatioNarrowScale);
f12.f64 += -133.0f / 1280.0f * (1.0 - g_aspectRatioNarrowScale);
f11.f64 += 3.5f / 720.0f * (1.0 - g_aspectRatioNarrowScale);
}
+8
View File
@@ -195,3 +195,11 @@ bool SparkleLocusMidAsmHook()
// This has the side effect of the locus particle eventually snapping to the rest position during pause, but it's better than vertices exploding.
return App::s_deltaTime < (1.0 / 60.0);
}
void CEvilSonicContext_CStateWall_LeaveRotationMidAsmHook(PPCRegister& f1)
{
// The code in the Werehog's "wall" state for leaving walls adds a constant
// value of 0.05 to his transform every frame. This makes the value respect
// delta time whilst maintaining the original behaviour at 30 FPS.
f1.f64 = f1.f64 * (std::min(App::s_deltaTime, 1.0 / 15.0) / (1.0 / 30.0));
}
-52
View File
@@ -1,4 +1,3 @@
#include "misc_patches.h"
#include <api/SWA.h>
#include <ui/game_window.h>
#include <user/achievement_manager.h>
@@ -194,54 +193,3 @@ PPC_FUNC(sub_824EE620)
ctx.r3.u32 = PersistentStorageManager::ShouldDisplayDLCMessage(true);
}
bool StageCollisionDebugViewMidAsmHook(PPCRegister& r27)
{
if (Config::EnableStageCollisionDebugView)
{
r27.u32 = true;
return true;
}
return false;
}
// The game is set up so that after parsing the Stage.set.xml it checks if TerrainInfoFile is found or not.
// Based on the result of that it will either draw terrain or debug collision (if enabled).
//
// The XMLs in the game are populated like this generally speaking:
// <Terrain>
// <TerrainInfoFile>terrain</TerrainInfoFile>
// <GIAtlas>1</GIAtlas>
// </Terrain>
// <Terrain>
// <RigidBodyContainer>collision</RigidBodyContainer>
// <IsCollisionRender>false</IsCollisionRender>
// </Terrain>
//
// In some cases however, the information in these two Terrain blocks is combined into one block,
// which makes the logic checking TerrainInfoFile's contents only fire once, and with success only, as such
// the logic for drawing collision will never execute.
//
// To combat this we check if both types returned with some value from the XML file, which indicates that its
// a single Terrain block, and if so we store that information so we can later on re-use to manually fire the
// logic controlling the drawing of the debug collision view.
void StageCollisionDebugViewStoreXmlTypeMidAsmHook(PPCRegister& r1)
{
uint8_t* base = g_memory.base;
const char* rigidBodyContainer = (const char*)(base + PPC_LOAD_U32(r1.u32 + 108));
const char* terrainInfoFile = (const char*)(base + PPC_LOAD_U32(r1.u32 + 132));
if (*rigidBodyContainer != '\0' && *terrainInfoFile != '\0')
{
g_singleTerrainBlockXml = true;
}
}
bool StageCollisionDebugViewSingleTerrainBlockXmlMidAsmHook()
{
bool runCollisionViewDrawLogic = g_singleTerrainBlockXml;
g_singleTerrainBlockXml = false;
return runCollisionViewDrawLogic;
}
-3
View File
@@ -1,3 +0,0 @@
#pragma once
static bool g_singleTerrainBlockXml = false;
+13 -12
View File
@@ -1142,18 +1142,19 @@ name = "EndingTextPositionMidAsmHook"
address = 0x82580168
registers = ["r31", "f13"]
# Wall Leave - Left
[[midasm_hook]]
name = "StageCollisionDebugViewMidAsmHook"
address = 0x825648F8
registers = ["r27"]
jump_address_on_true = 0x825648FC
name = "CEvilSonicContext_CStateWall_LeaveRotationMidAsmHook"
address = 0x824067BC
registers = ["f1"]
# Wall Leave - Right
[[midasm_hook]]
name = "CEvilSonicContext_CStateWall_LeaveRotationMidAsmHook"
address = 0x82406774
registers = ["f1"]
[[midasm_hook]]
name = "StageCollisionDebugViewStoreXmlTypeMidAsmHook"
address = 0x8256422C
registers = ["r1"]
[[midasm_hook]]
name = "StageCollisionDebugViewSingleTerrainBlockXmlMidAsmHook"
address = 0x82564B00
jump_address_on_true = 0x82564764
name = "AdvertiseLogoPlacementMidAsmHook"
address = 0x82B729A0
registers = ["f0", "f13", "f12", "f11"]