Skip to content

Commit 14af499

Browse files
committed
radermap & radermap_mask resize fix
radermap now to properly resize depthstencil_1_4 do not support resize otherwise may cause issue with reflections
1 parent 46f065e commit 14af499

File tree

11 files changed

+99
-18
lines changed

11 files changed

+99
-18
lines changed

MarathonRecomp/api/Marathon.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@
8585
#include "Sonicteam/NoSyncThread.h"
8686
#include "Sonicteam/ObjectVehicle.h"
8787
#include "Sonicteam/ObjectVehicleBike.h"
88+
#include "Sonicteam/Particles/Particle.h"
89+
#include "Sonicteam/Particles/ParticleRef.h"
8890
#include "Sonicteam/PauseAdapter.h"
8991
#include "Sonicteam/PauseTask.h"
92+
#include "Sonicteam/Player/Effect/ParticleJoint.h"
9093
#include "Sonicteam/Player/GroundRayListener.h"
9194
#include "Sonicteam/Player/ICollisionListener.h"
9295
#include "Sonicteam/Player/ICollisionListenerTemplate.h"

MarathonRecomp/api/Sonicteam/DocMarathonImp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ namespace Sonicteam
2121
bool m_VFrame;
2222
MARATHON_INSERT_PADDING(0x4);
2323
xpointer<RenderTargetContainer> m_pRenderTargetContainer;
24-
MARATHON_INSERT_PADDING(0x55B50);
24+
MARATHON_INSERT_PADDING(0x187C);
25+
xpointer<void> m_pGameRaderMapManager;
26+
MARATHON_INSERT_PADDING(0x542D0);
2527
be<uint32_t> m_PlayerControllerID[4];
2628
};
2729
}

MarathonRecomp/api/Sonicteam/GameImp.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <Sonicteam/SoX/Scenery/Camera.h>
99
#include <Sonicteam/SoX/Scenery/CameraImp.h>
1010
#include <Sonicteam/SoX/RefSharedPointer.h>
11+
#include <Sonicteam/SoX/LinkNode.h>
12+
#include <Sonicteam/PopupScreenTask.h>
1113
#include <Sonicteam/Game.h>
1214
#include <Sonicteam/TextBook.h>
1315
#include <stdx/vector.h>
@@ -84,7 +86,9 @@ namespace Sonicteam
8486
xpointer<TextBook> m_pHintTextBook;
8587
MARATHON_INSERT_PADDING(4);
8688
xpointer<Mission::Core> m_pMissionCore;
87-
MARATHON_INSERT_PADDING(0x2A4);
89+
MARATHON_INSERT_PADDING(0x248);
90+
SoX::LinkRef<Sonicteam::PopupScreenTask> m_lrPopulScreenTask;
91+
MARATHON_INSERT_PADDING(0x4C);
8892
SoX::RefSharedPointer<SoX::Physics::World> m_spPhysicsWorld;
8993
xpointer<void> m_pMyCollisionFilter;
9094

MarathonRecomp/api/Sonicteam/HUDPopupScreen.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
#include <Marathon.inl>
44
#include <Sonicteam/SoX/Graphics/TechniqueFXL.h>
55
#include <Sonicteam/MyTexture.h>
6+
#include <Sonicteam/SoX/RefSharedPointer.h>
7+
#include <Sonicteam/SoX/RefCountObject.h>
8+
#include <Sonicteam/CsdObject.h>
69
#include <stdx/string.h>
710

811
namespace Sonicteam
912
{
10-
class HUDPopupScreen : public SoX::Engine::Task
13+
class HUDPopupScreen : public SoX::RefCountObject, public SoX::Engine::Task
1114
{
1215
public:
1316
enum HUDPopupScreenState : uint32_t
@@ -18,8 +21,8 @@ namespace Sonicteam
1821
};
1922

2023
xpointer<CsdObject> m_pCsdObject;
21-
xpointer<MyTexture> m_pMainTexture;
22-
xpointer<MyTexture> m_pMaskTexture;
24+
SoX::RefSharedPointer<MyTexture> m_pMainTexture;
25+
SoX::RefSharedPointer<MyTexture> m_pMaskTexture;
2326
xpointer<SoX::Graphics::TechniqueFXL> m_pTechnique;
2427
stdx::string m_SceneName;
2528
stdx::string m_SpriteName;

MarathonRecomp/api/Sonicteam/HUDRaderMap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <Marathon.inl>
4+
#include <Sonicteam/HUDPopupScreen.h>
45

56
namespace Sonicteam
67
{
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include <Marathon.inl>
4+
#include <Sonicteam/SoX/Engine/Task.h>
5+
#include <Sonicteam/SoX/RefSharedPointer.h>
6+
#include <Sonicteam/HUDPopupScreen.h>
7+
8+
namespace Sonicteam
9+
{
10+
class PopupScreenTask : public SoX::Engine::Task
11+
{
12+
public:
13+
SoX::RefSharedPointer<HUDPopupScreen> m_spHUDPopupScreen;
14+
15+
template <typename HUDPopupType>
16+
HUDPopupType* GetHUDPopupScreen()
17+
{
18+
return static_cast<HUDPopupType*>(m_spHUDPopupScreen.get());
19+
}
20+
};
21+
22+
}

MarathonRecomp/api/Sonicteam/SoX/ApplicationXenon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ namespace Sonicteam::SoX
119119

120120
MARATHON_INSERT_PADDING(0x60);
121121

122-
static ApplicationXenon* GetInstance();
122+
//static ApplicationXenon* GetInstance();
123123
};
124124
//0x384
125125
}
126126

127-
#include <Sonicteam/SoX/ApplicationXenon.inl>
127+
//#include <Sonicteam/SoX/ApplicationXenon.inl>

MarathonRecomp/api/Sonicteam/SoX/Graphics/Device.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@ namespace Sonicteam::SoX::Graphics
1111
{
1212
public:
1313
xpointer<void> m_pVftable;
14-
MARATHON_INSERT_PADDING(0x3C);
14+
MARATHON_INSERT_PADDING(0x14);
15+
be<uint32_t> m_DBRFlag;
16+
MARATHON_INSERT_PADDING(0x24);
1517
Math::Matrix4x4 m_Field40;
1618
be<float> m_Field80;
17-
MARATHON_INSERT_PADDING(0x3C);
19+
be<float> m_Field84; //viewport?
20+
MARATHON_INSERT_PADDING(0x4);
21+
be<uint32_t> m_Width1;
22+
be<uint32_t> m_Height1;
23+
be<uint32_t> m_Field94;
24+
be<uint32_t> m_Field98;
25+
be<uint32_t> m_Width2;
26+
be<uint32_t> m_Height2;
27+
MARATHON_INSERT_PADDING(0x1C);
1828
SoX::RefSharedPointer<SoX::RefCountObject> m_FrameBufferObject;
1929
MARATHON_INSERT_PADDING(0xC);
2030
};

MarathonRecomp/api/Sonicteam/SoX/RefSharedPointer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ namespace Sonicteam::SoX
1818
m_ptr = nullptr;
1919
}
2020

21-
explicit RefSharedPointer(T* value) : m_ptr(value)
21+
RefSharedPointer(T* value) : m_ptr(value)
2222
{
2323
if (m_ptr.get())
24-
m_ptr->AddRef();
24+
m_ptr->AddReference();
2525
}
2626

2727
explicit RefSharedPointer(xpointer<T> value) : m_ptr(value)
2828
{
2929
if (m_ptr.get())
30-
m_ptr->AddRef();
30+
m_ptr->AddReference();
3131
}
3232

3333
RefSharedPointer(const RefSharedPointer& other) : m_ptr(other.m_ptr)
3434
{
3535
if (m_ptr.get())
36-
m_ptr->AddRef();
36+
m_ptr->AddReference();
3737
}
3838

3939
RefSharedPointer(RefSharedPointer&& other) noexcept : m_ptr(std::move(other.m_ptr))
@@ -56,7 +56,7 @@ namespace Sonicteam::SoX
5656
m_ptr = other.m_ptr;
5757

5858
if (m_ptr.get())
59-
m_ptr->AddRef();
59+
m_ptr->AddReference();
6060
}
6161

6262
return *this;

MarathonRecomp/gpu/video.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ static std::unique_ptr<RenderCommandSemaphore> g_renderSemaphores[NUM_FRAMES];
374374
static uint32_t g_backBufferIndex;
375375
static std::unique_ptr<GuestSurface> g_backBufferHolder;
376376
static GuestSurface* g_backBuffer;
377+
static std::vector<std::pair<GuestSurface*, uint32_t>> g_surfaceCache;
377378

378379
static std::unique_ptr<RenderTexture> g_intermediaryBackBufferTexture;
379380
static uint32_t g_intermediaryBackBufferTextureWidth;
@@ -3199,6 +3200,8 @@ void Video::Present()
31993200
be<uint32_t> usage;
32003201
};
32013202

3203+
g_surfaceCache.clear();
3204+
32023205
auto pFormatConfig = (GraphicsFormatConfig*)(g_memory.base + 0x82B7BD20);
32033206

32043207
// Kill Auto Surfaces
@@ -3305,8 +3308,9 @@ void Video::Present()
33053308
surfaceParams = (params.r10 & 2) == 0 ? &pMyGraphicDevice->m_SurfaceParamA : &pMyGraphicDevice->m_SurfaceParamC;
33063309
}
33073310

3308-
auto gSurface = CreateSurface(params.width, params.height, pFormatConfig[params.r8].SurfaceFormat, 0, surfaceParams);
3309-
GuestToHostFunction<void>(sub_82592E98, surface.second.get(), gSurface, params.width, params.height);
3311+
//Until cache system is gone for good
3312+
//auto gSurface = CreateSurface(params.width, params.height, pFormatConfig[params.r8].SurfaceFormat, 0, surfaceParams);
3313+
//GuestToHostFunction<void>(sub_82592E98, surface.second.get(), gSurface, params.width, params.height);
33103314
}
33113315

33123316
printf("----------------------------[Textures]-----------------------------------\n");
@@ -3380,6 +3384,21 @@ void Video::Present()
33803384
pRenderTargetContainer->m_mspPostEffect.clear();
33813385
pRenderTargetContainer->m_mspPostEffectAfter.clear();
33823386

3387+
3388+
3389+
if (auto it = pResourceManager->m_mResource[pTextureManager->m_MgrIndex].find("radermap");
3390+
it != pResourceManager->m_mResource[pTextureManager->m_MgrIndex].end())
3391+
{
3392+
if (auto pPopup = pApp->GetGame()->m_lrPopulScreenTask.m_pElement)
3393+
{
3394+
auto pHUDRaderMap = pPopup->GetHUDPopupScreen<Sonicteam::HUDRaderMap>();
3395+
pHUDRaderMap->m_pMainTexture.reset();
3396+
pHUDRaderMap->m_pMaskTexture.reset();
3397+
}
3398+
}
3399+
3400+
3401+
33833402
// framebuffer_tile should properly reference framebuffer0's GuestTexture
33843403
// PROPER FIX OPTIONS:
33853404
// 1. Allocate new texture to the same pointer instead of this workaround
@@ -3396,8 +3415,25 @@ void Video::Present()
33963415

33973416
// Refresh Lua Render
33983417
// 0x82B814F8 (stdx::string) gCurrentRenderScript
3418+
33993419
GuestToHostFunction<void>(sub_8260DF88, pDocState, 0x82B814F8, 1);
3420+
auto SetResource = [&](auto* spTextureTo, const char* name) {
3421+
if (auto it = pResourceManager->m_mResource[pTextureManager->m_MgrIndex].find(name);
3422+
it != pResourceManager->m_mResource[pTextureManager->m_MgrIndex].end()) {
3423+
*spTextureTo = static_cast<Sonicteam::MyTexture*>(it->second.get());
3424+
}
3425+
};
34003426

3427+
if (pResourceManager->m_mResource[pTextureManager->m_MgrIndex].find("radermap") != pResourceManager->m_mResource[pTextureManager->m_MgrIndex].end())
3428+
{
3429+
if (auto pPopup = pApp->GetGame()->m_lrPopulScreenTask.m_pElement) {
3430+
auto pHUDRaderMap = pPopup->GetHUDPopupScreen<Sonicteam::HUDRaderMap>();
3431+
SetResource(&pHUDRaderMap->m_pMainTexture, "radermap");
3432+
SetResource(&pHUDRaderMap->m_pMaskTexture, "radermap_mask");
3433+
}
3434+
}
3435+
3436+
34013437
// TODO: Fix particle not updating position or disappearing after Lua refresh
34023438
}
34033439

@@ -3714,7 +3750,6 @@ static GuestBuffer* CreateIndexBuffer(uint32_t length, uint32_t, uint32_t format
37143750
return buffer;
37153751
}
37163752

3717-
static std::vector<std::pair<GuestSurface*, uint32_t>> g_surfaceCache;
37183753

37193754
// TODO: Singleplayer (possibly) uses the same memory location in EDRAM for HDR and FB0 surfaces,
37203755
// so we just remember who was created first and use that instead of creating a new one.

0 commit comments

Comments
 (0)