Skip to content
Merged
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 MarathonRecomp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ set(MARATHON_RECOMP_PATCHES_CXX_SOURCES
"patches/frontend_listener.cpp"
"patches/misc_patches.cpp"
"patches/player_patches.cpp"
"patches/SaveDataTask_patches.cpp"
"patches/TitleTask_patches.cpp"
"patches/video_patches.cpp"
)
Expand Down
11 changes: 11 additions & 0 deletions MarathonRecomp/api/Marathon.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "CSD/Manager/csdmSubjectBase.h"
#include "CSD/Platform/csdTexList.h"
#include "Sonicteam/Actor.h"
#include "Sonicteam/AlertWindowTask.h"
#include "Sonicteam/AppMarathon.h"
#include "Sonicteam/AudioEngineXenon.h"
#include "Sonicteam/Camera/CameraMode.h"
Expand All @@ -26,6 +27,9 @@
#include "Sonicteam/DocMarathonState.h"
#include "Sonicteam/GameImp.h"
#include "Sonicteam/GameMode.h"
#include "Sonicteam/HUDCALLBACK.h"
#include "Sonicteam/HUDLoading.h"
#include "Sonicteam/ImageFilter.h"
#include "Sonicteam/MovieObject.h"
#include "Sonicteam/MovieObjectWmv.h"
#include "Sonicteam/MovieTask.h"
Expand Down Expand Up @@ -54,12 +58,17 @@
#include "Sonicteam/Player/State/Machine2.h"
#include "Sonicteam/Player/State/Object2.h"
#include "Sonicteam/Player/State/TailsContext.h"
#include "Sonicteam/SaveDataTask.h"
#include "Sonicteam/SaveDataTaskXENON.h"
#include "Sonicteam/SelectWindowTask.h"
#include "Sonicteam/SoX/AI/StateMachine.h"
#include "Sonicteam/SoX/Audio/IAudioEngine.h"
#include "Sonicteam/SoX/Component.h"
#include "Sonicteam/SoX/Engine/Doc.h"
#include "Sonicteam/SoX/Engine/DocMode.h"
#include "Sonicteam/SoX/Engine/Task.h"
#include "Sonicteam/SoX/Graphics/Technique.h"
#include "Sonicteam/SoX/Graphics/TechniqueFXL.h"
#include "Sonicteam/SoX/Graphics/Device.h"
#include "Sonicteam/SoX/Graphics/Xenon/DeviceXenon.h"
#include "Sonicteam/SoX/Graphics/Xenon/TextureXenon.h"
Expand All @@ -71,6 +80,8 @@
#include "Sonicteam/SoX/Physics/Havok/WorldHavok.h"
#include "Sonicteam/SoX/Physics/World.h"
#include "Sonicteam/SoX/RefCountObject.h"
#include "Sonicteam/StdImageFilters/BurnoutBlurFilter.h"
#include "Sonicteam/StdImageFilters/SingleTechniqueFilter.h"
#include "Sonicteam/System/CreateStatic.h"
#include "Sonicteam/System/Singleton.h"
#include "Sonicteam/TitleTask.h"
Expand Down
21 changes: 21 additions & 0 deletions MarathonRecomp/api/Sonicteam/AlertWindowTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include <Marathon.inl>
#include <boost/smart_ptr/shared_ptr.h>
#include <Sonicteam/SelectWindowTask.h>

namespace Sonicteam
{
class AlertWindowTask : public SoX::Engine::Task
{
public:
be<uint32_t> m_HasSelectWindow;
MARATHON_INSERT_PADDING(0x2C);
be<uint32_t> m_Operation;
MARATHON_INSERT_PADDING(0x14);
boost::anonymous_shared_ptr m_spOptions[3];
MARATHON_INSERT_PADDING(4);
be<uint32_t> m_OptionCount;
xpointer<SelectWindowTask> m_pSelectWindowTask;
};
}
25 changes: 23 additions & 2 deletions MarathonRecomp/api/Sonicteam/GameImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ namespace Sonicteam
class GameImp : public SoX::MessageReceiver
{
public:
enum GameState : uint32_t
{
GameState_MainMenu,
GameState_Stage,
GameState_Event,
GameState_Movie,
GameState_Result,
GameState_Message,
GameState_6,
GameState_Save,
GameState_ReturnToMainMenu
};

struct PlayerData
{
be<uint32_t> ActorID;
Expand All @@ -28,9 +41,17 @@ namespace Sonicteam
MARATHON_INSERT_PADDING(0x10);
};

MARATHON_INSERT_PADDING(0xE3C);
MARATHON_INSERT_PADDING(4);
be<GameState> m_GameState;
xpointer<DocMarathonState> m_pDoc;
be<uint32_t> m_Flags;
MARATHON_INSERT_PADDING(0xE2C);
PlayerData m_PlayerData[4];
MARATHON_INSERT_PADDING(0xA4C);
MARATHON_INSERT_PADDING(0x200);
bool m_IsStage;
MARATHON_INSERT_PADDING(0x0C);
be<uint32_t> m_Field1180;
MARATHON_INSERT_PADDING(0x838);
xpointer<SoX::Physics::World> m_pPhysicsWorld;
xpointer<void> m_pMyCollisionFilter;

Expand Down
10 changes: 10 additions & 0 deletions MarathonRecomp/api/Sonicteam/HUDCALLBACK.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

namespace Sonicteam
{
class HUDCALLBACK
{
public:
xpointer<void> m_pVftable;
};
}
13 changes: 13 additions & 0 deletions MarathonRecomp/api/Sonicteam/HUDLoading.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <Marathon.inl>

namespace Sonicteam
{
class HUDLoading : public SoX::RefCountObject, public SoX::Engine::Task
{
public:
MARATHON_INSERT_PADDING(0x5C);
be<uint32_t> m_Flags;
};
}
13 changes: 13 additions & 0 deletions MarathonRecomp/api/Sonicteam/ImageFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <Marathon.inl>

namespace Sonicteam
{
class ImageFilter
{
public:
xpointer<void> m_pVftable;
MARATHON_INSERT_PADDING(4);
};
}
15 changes: 15 additions & 0 deletions MarathonRecomp/api/Sonicteam/SaveDataTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <Marathon.inl>

namespace Sonicteam
{
class SaveDataTask : public SoX::Engine::Task
{
public:
xpointer<const char> m_pFileName;
MARATHON_INSERT_PADDING(0x24);
be<uint32_t> m_Flags;
MARATHON_INSERT_PADDING(4);
};
}
30 changes: 30 additions & 0 deletions MarathonRecomp/api/Sonicteam/SaveDataTaskXENON.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <Marathon.inl>

namespace Sonicteam
{
class SaveDataTaskXENON : public SaveDataTask
{
public:
enum SaveDataOperation : uint32_t
{
SaveDataOperation_AlertOverwrite,
SaveDataOperation_AlertNoSaveData,
SaveDataOperation_AlertSelectDevice,
SaveDataOperation_SelectStorageDevice,
SaveDataOperation_WriteSaveData,
SaveDataOperation_ReadSaveData,
SaveDataOperation_AlertSaveFailed,
SaveDataOperation_AlertLoadFailed,
SaveDataOperation_8,
SaveDataOperation_9
};

xpointer<AlertWindowTask> m_pAlertWindowTask;
MARATHON_INSERT_PADDING(8);
bool m_IsAccessSuccess;
xpointer<void> m_pTextBook;
be<SaveDataOperation> m_Operation;
};
}
16 changes: 16 additions & 0 deletions MarathonRecomp/api/Sonicteam/SelectWindowTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <Marathon.inl>
#include <Sonicteam/HUDCALLBACK.h>

namespace Sonicteam
{
class SelectWindowTask : public SoX::Engine::Task, public HUDCALLBACK
{
public:
MARATHON_INSERT_PADDING(0x40);
be<uint32_t> m_ChosenIndex;
MARATHON_INSERT_PADDING(0x28);
be<uint32_t> m_SelectedIndex;
};
}
12 changes: 12 additions & 0 deletions MarathonRecomp/api/Sonicteam/SoX/Graphics/Technique.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <Marathon.inl>

namespace Sonicteam::SoX::Graphics
{
class Technique : public RefCountObject
{
public:
xpointer<void> m_pShader;
};
}
16 changes: 16 additions & 0 deletions MarathonRecomp/api/Sonicteam/SoX/Graphics/TechniqueFXL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <Marathon.inl>

namespace Sonicteam::SoX::Graphics
{
class TechniqueFXL : public Technique
{
public:
xpointer<void> m_pShader;
MARATHON_INSERT_PADDING(0x10);
xpointer<TechniqueFXL> m_pThis;
MARATHON_INSERT_PADDING(4);
stdx::string m_TechniqueName;
};
}
17 changes: 17 additions & 0 deletions MarathonRecomp/api/Sonicteam/StdImageFilters/BurnoutBlurFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Marathon.inl>
#include <Sonicteam/StdImageFilters/SingleTechniqueFilter.h>

namespace Sonicteam::StdImageFilters
{
class BurnoutBlurFilter : public SingleTechniqueFilter
{
public:
MARATHON_INSERT_PADDING(0x14);
be<float> m_Magnitude;
xpointer<SoX::Graphics::TechniqueFXL> m_p1xBlurTechnique;
xpointer<SoX::Graphics::TechniqueFXL> m_p4xBlurTechnique;
xpointer<SoX::Graphics::TechniqueFXL> m_p8xBlurTechnique;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <Marathon.inl>

namespace Sonicteam::StdImageFilters
{
class SingleTechniqueFilter : public ImageFilter
{
public:
MARATHON_INSERT_PADDING(0x10);
};
}
11 changes: 11 additions & 0 deletions MarathonRecomp/locale/config_locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ CONFIG_DEFINE_LOCALE(ControlTutorial)
{ ELanguage::Italian, { "Tutorial dei comandi", "Mostra i tutorial dei comandi durante il gioco.\n\nIl tutorial per l'attacco critico del Werehog non verrà influenzato da questa opzione." } }
};

// Japanese Notes: This localization should include furigana.
CONFIG_DEFINE_LOCALE(Autosave)
{
{ ELanguage::English, { "Autosave", "Save the game automatically at manual save points." } },
{ ELanguage::Japanese, { "", "" } },
{ ELanguage::German, { "", "" } },
{ ELanguage::French, { "", "" } },
{ ELanguage::Spanish, { "", "" } },
{ ELanguage::Italian, { "", "" } }
};

// Japanese Notes: This localization should include furigana.
CONFIG_DEFINE_LOCALE(AchievementNotifications)
{
Expand Down
74 changes: 74 additions & 0 deletions MarathonRecomp/patches/SaveDataTask_patches.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <api/Marathon.h>
#include <user/config.h>

static Sonicteam::SaveDataTaskXENON::SaveDataOperation g_currentAlert{};

// Sonicteam::SaveDataTaskXENON::RunOperation (speculatory)
PPC_FUNC_IMPL(__imp__sub_8238CB18);
PPC_FUNC(sub_8238CB18)
{
// Redirect storage device lost alert to load failed alert.
// The user should never see this alert, but if they do, it should make a bit more sense.
if (ctx.r4.u32 == Sonicteam::SaveDataTaskXENON::SaveDataOperation_AlertSelectDevice)
ctx.r4.u32 = Sonicteam::SaveDataTaskXENON::SaveDataOperation_AlertLoadFailed;

// Update current alert to operations that only display
// messages so we can keep track of the last message displayed.
if (ctx.r4.u32 < 3 && ctx.r4.u32 >= 6 && ctx.r4.u32 < 8)
g_currentAlert = (Sonicteam::SaveDataTaskXENON::SaveDataOperation)ctx.r4.u32;

// Redirect overwrite alert to just save the game, if requested.
if (Config::Autosave && ctx.r4.u32 == Sonicteam::SaveDataTaskXENON::SaveDataOperation_AlertOverwrite)
ctx.r4.u32 = Sonicteam::SaveDataTaskXENON::SaveDataOperation_WriteSaveData;

// Redirect storage device select operation to access the save data.
// This option is replaced with a "Retry" option, so it should attempt to access it again.
if (ctx.r4.u32 == Sonicteam::SaveDataTaskXENON::SaveDataOperation_SelectStorageDevice)
{
if (g_currentAlert == Sonicteam::SaveDataTaskXENON::SaveDataOperation_AlertLoadFailed)
{
ctx.r4.u32 = Sonicteam::SaveDataTaskXENON::SaveDataOperation_ReadSaveData;
}
else
{
ctx.r4.u32 = Sonicteam::SaveDataTaskXENON::SaveDataOperation_WriteSaveData;
}
}

__imp__sub_8238CB18(ctx, base);
}

void SaveAlertThreeOptionRemoveDeviceSelect(PPCRegister& r5)
{
auto options = (uint64_t*)g_memory.Translate(r5.u32 + 8);

// The "Select storage device." option is always the
// second index for the three option alert windows.
options[2] = 0;
}

// Load system message.
PPC_FUNC_IMPL(__imp__sub_825ECB48);
PPC_FUNC(sub_825ECB48)
{
auto* pMessage = (const char*)(base + ctx.r5.u32);
void* pNewMessage = nullptr;

if (strcmp(pMessage, "msg_deviceselect") == 0)
{
constexpr const char* MSG_RETRY = "msg_retry";

pNewMessage = g_userHeap.Alloc(strlen(MSG_RETRY) + 1);

strcpy((char*)pNewMessage, MSG_RETRY);

ctx.r5.u32 = g_memory.MapVirtual(pNewMessage);
}

__imp__sub_825ECB48(ctx, base);

if (!pNewMessage)
return;

g_userHeap.Free(pNewMessage);
}
4 changes: 2 additions & 2 deletions MarathonRecomp/patches/player_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ PPC_FUNC(sub_8221A7D8)
__imp__sub_8221A7D8(ctx, base);
}

// Sonicteam::Player::State::*Context IDynamicLink::Init, Removed
// SonicTeam::Player::Score::ctor
// SonicTeam::Player::Score::Score
PPC_FUNC_IMPL(__imp__sub_821E8C48);
PPC_FUNC(sub_821E8C48)
{
Expand All @@ -53,6 +52,7 @@ PPC_FUNC(sub_821E8C48)
}

auto pPlayer = (Sonicteam::Player::Object*)(base + ctx.r4.u32);

if (pPlayer->m_PlayerLua == "player/tails.lua")
{
auto pSonicGauge = GuestToHostFunction<Sonicteam::Player::SonicGauge*>(sub_8223F208, g_userHeap.Alloc(sizeof(Sonicteam::Player::SonicGauge)));
Expand Down
1 change: 1 addition & 0 deletions MarathonRecomp/user/config_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_DEFINE_ENUM_LOCALISED("System", EVoiceLanguage, VoiceLanguage, EVoiceLang
CONFIG_DEFINE_LOCALISED("System", bool, Subtitles, true);
CONFIG_DEFINE_LOCALISED("System", bool, Hints, true);
CONFIG_DEFINE_LOCALISED("System", bool, ControlTutorial, true);
CONFIG_DEFINE_LOCALISED("System", bool, Autosave, true);
CONFIG_DEFINE_LOCALISED("System", bool, AchievementNotifications, true);
CONFIG_DEFINE("System", bool, ShowConsole, false);

Expand Down
Loading
Loading