Skip to content

Commit 1fe9d41

Browse files
committed
Implemented Hints and Control Tutorial options
These may need further review in terms of blocking hints initiated by volumes that suggest things to the player and hints about bosses after death.
1 parent e4cc2ca commit 1fe9d41

File tree

11 files changed

+106
-29
lines changed

11 files changed

+106
-29
lines changed

MarathonRecomp/api/Marathon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "Sonicteam/Camera/CameraModeManager.h"
2626
#include "Sonicteam/Camera/Cameraman.h"
2727
#include "Sonicteam/Camera/SonicCamera.h"
28+
#include "Sonicteam/CommonObjectHint.h"
2829
#include "Sonicteam/CsdLink.h"
2930
#include "Sonicteam/CsdManager.h"
3031
#include "Sonicteam/CsdObject.h"
@@ -122,6 +123,7 @@
122123
#include "Sonicteam/Player/Unit/ITestCase.h"
123124
#include "Sonicteam/Player/Weapon/SonicWeapons.h"
124125
#include "Sonicteam/Player/Zock.h"
126+
#include "Sonicteam/PropFixture.h"
125127
#include "Sonicteam/RaderMapManager.h"
126128
#include "Sonicteam/SaveDataTask.h"
127129
#include "Sonicteam/SaveDataTaskXENON.h"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
3+
#include <Marathon.inl>
4+
#include <Sonicteam/PropFixture.h>
5+
6+
namespace Sonicteam
7+
{
8+
class CommonObjectHint : public PropFixture
9+
{
10+
public:
11+
enum CommonObjectHintType : uint32_t
12+
{
13+
CommonObjectHintType_HintRing,
14+
CommonObjectHintType_HintVolume
15+
};
16+
17+
MARATHON_INSERT_PADDING(4);
18+
char m_MessageName[20];
19+
MARATHON_INSERT_PADDING(0x40);
20+
be<CommonObjectHintType> m_Type;
21+
bool m_IsFastAnim;
22+
bool m_IsHitAnim;
23+
MARATHON_INSERT_PADDING(2);
24+
be<float> m_HitTime;
25+
};
26+
27+
MARATHON_ASSERT_OFFSETOF(CommonObjectHint, m_MessageName, 0x184);
28+
MARATHON_ASSERT_OFFSETOF(CommonObjectHint, m_Type, 0x1D8);
29+
MARATHON_ASSERT_OFFSETOF(CommonObjectHint, m_IsFastAnim, 0x1DC);
30+
MARATHON_ASSERT_OFFSETOF(CommonObjectHint, m_IsHitAnim, 0x1DD);
31+
MARATHON_ASSERT_OFFSETOF(CommonObjectHint, m_HitTime, 0x1E0);
32+
}

MarathonRecomp/api/Sonicteam/GameImp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ namespace Sonicteam
7979
stdx::vector<stdx::vector<boost::shared_ptr<SoX::Scenery::Camera>>> m_vvspCameras;
8080
MARATHON_INSERT_PADDING(0x1B4);
8181
xpointer<SoX::Audio::Cue> m_pBgmCue;
82-
MARATHON_INSERT_PADDING(0x61C);
82+
MARATHON_INSERT_PADDING(0x36C);
83+
xpointer<TextBook> m_pHintTextBook;
84+
MARATHON_INSERT_PADDING(0x2AC);
8385
SoX::RefSharedPointer<SoX::Physics::World> m_spPhysicsWorld;
8486
xpointer<void> m_pMyCollisionFilter;
8587

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include <Marathon.inl>
4+
#include <Sonicteam/Fixture.h>
5+
6+
namespace Sonicteam
7+
{
8+
class PropFixture : public Fixture
9+
{
10+
public:
11+
MARATHON_INSERT_PADDING(4);
12+
};
13+
}

MarathonRecomp/api/Sonicteam/SoX/Audio/Cue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace Sonicteam::SoX::Audio
2828

2929
void SetPause(bool isPaused)
3030
{
31-
GuestToHostFunction<int>(((Vftable*)m_pVftable.get())->fpSetPause.get(), this, isPaused);
31+
GuestToHostFunction<int>(((Vftable*)m_pVftable.get())->fpSetPause, this, isPaused);
3232
}
3333
};
3434
}

MarathonRecomp/api/Sonicteam/SoX/MessageReceiver.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ namespace Sonicteam::SoX
1616

1717
xpointer<Vftable> m_pVftable;
1818

19+
void Destroy(uint8_t flags = 1)
20+
{
21+
GuestToHostFunction<int>(m_pVftable->fpDestroy, this, flags);
22+
}
23+
1924
bool OnMessageReceived(IMessage* pMessage)
2025
{
2126
return GuestToHostFunction<bool>(m_pVftable->fpOnMessageReceived, this, pMessage);

MarathonRecomp/gpu/video.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3273,26 +3273,26 @@ void Video::ComputeViewportDimensions()
32733273

32743274
switch (Config::AspectRatio)
32753275
{
3276-
case EAspectRatio::Wide:
3277-
{
3278-
if (aspectRatio > WIDE_ASPECT_RATIO)
3279-
{
3280-
s_viewportWidth = height * 16 / 9;
3281-
s_viewportHeight = height;
3282-
}
3283-
else
3276+
case EAspectRatio::Original:
32843277
{
3285-
s_viewportWidth = width;
3286-
s_viewportHeight = width * 9 / 16;
3287-
}
3278+
if (aspectRatio > WIDE_ASPECT_RATIO)
3279+
{
3280+
s_viewportWidth = height * 16 / 9;
3281+
s_viewportHeight = height;
3282+
}
3283+
else
3284+
{
3285+
s_viewportWidth = width;
3286+
s_viewportHeight = width * 9 / 16;
3287+
}
32883288

3289-
break;
3290-
}
3289+
break;
3290+
}
32913291

3292-
default:
3293-
s_viewportWidth = width;
3294-
s_viewportHeight = height;
3295-
break;
3292+
default:
3293+
s_viewportWidth = width;
3294+
s_viewportHeight = height;
3295+
break;
32963296
}
32973297

32983298
AspectRatioPatches::ComputeOffsets();

MarathonRecomp/patches/misc_patches.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <ui/black_bar.h>
33
#include <user/config.h>
44
#include <user/achievement_manager.h>
5+
#include <app.h>
56

67
// TODO (Hyper): implement achievements menu.
78
void AchievementManagerUnlockMidAsmHook(PPCRegister& id)
@@ -103,9 +104,36 @@ void PedestrianAnimationLOD(PPCRegister& val)
103104
val.u32 = 0;
104105
}
105106

106-
bool DisableHints()
107+
// Sonicteam::CommonObjectHint::Update
108+
PPC_FUNC_IMPL(__imp__sub_822CE930);
109+
PPC_FUNC(sub_822CE930)
107110
{
108-
return !Config::Hints;
111+
auto pCommonObjectHint = (Sonicteam::CommonObjectHint*)(base + ctx.r3.u32);
112+
113+
if (!Config::Hints && pCommonObjectHint->m_Type == Sonicteam::CommonObjectHint::CommonObjectHintType_HintRing)
114+
{
115+
pCommonObjectHint->Destroy();
116+
return;
117+
}
118+
119+
if (!Config::ControlTutorial)
120+
{
121+
guest_stack_var<int> stack{};
122+
123+
auto pspTextCard = GuestToHostFunction<boost::shared_ptr<Sonicteam::TextCard>*>(sub_825ECB48,
124+
stack.get(), App::s_pApp->GetGame()->m_pHintTextBook.get(), (const char*)&pCommonObjectHint->m_MessageName);
125+
126+
if (auto pTextCard = pspTextCard->get())
127+
{
128+
if (pTextCard->m_pVariables && strstr(pTextCard->m_pVariables, "picture(button_"))
129+
{
130+
pCommonObjectHint->Destroy();
131+
return;
132+
}
133+
}
134+
}
135+
136+
__imp__sub_822CE930(ctx, base);
109137
}
110138

111139
PPC_FUNC_IMPL(__imp__sub_824A6EA8);

MarathonRecomp/user/config.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ CONFIG_DEFINE_ENUM_TEMPLATE(EWindowState)
317317

318318
CONFIG_DEFINE_ENUM_TEMPLATE(EAspectRatio)
319319
{
320-
{ "Auto", EAspectRatio::Auto },
321-
{ "16:9", EAspectRatio::Wide }
320+
{ "Auto", EAspectRatio::Auto },
321+
{ "Original", EAspectRatio::Original }
322322
};
323323

324324
CONFIG_DEFINE_ENUM_TEMPLATE(ETripleBuffering)

MarathonRecomp/user/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ enum class EWindowState : uint32_t
8181
enum class EAspectRatio : uint32_t
8282
{
8383
Auto,
84-
Wide
84+
Original
8585
};
8686

8787
enum class ETripleBuffering : uint32_t

0 commit comments

Comments
 (0)