Skip to content
Closed
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/api/Marathon.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
#include "Sonicteam/SoX/Graphics/Technique.h"
#include "Sonicteam/SoX/Graphics/TechniqueFXL.h"
#include "Sonicteam/SoX/Graphics/Transforms.h"
#include "Sonicteam/SoX/Graphics/Vertex.h"
#include "Sonicteam/SoX/Graphics/Xenon/DeviceXenon.h"
#include "Sonicteam/SoX/Graphics/Xenon/TextureXenon.h"
#include "Sonicteam/SoX/IResource.h"
Expand Down
14 changes: 2 additions & 12 deletions MarathonRecomp/api/Sonicteam/CObjBalloonIconDrawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@

#include <Marathon.inl>
#include <Sonicteam/SoX/Scenery/Drawable.h>
#include <Sonicteam/SoX/Graphics/Vertex.h>
#include <Sonicteam/MyGraphicsDevice.h>

namespace Sonicteam
{
class CObjBalloonIconDrawable : public SoX::Scenery::Drawable
{
public:
struct Vertex
{
be<float> X;
be<float> Y;
MARATHON_INSERT_PADDING(0x10);
be<uint32_t> Colour; // ARGB8888
be<float> U;
be<float> V;
MARATHON_INSERT_PADDING(0x18);
};

xpointer<MyGraphicsDevice> m_pMyGraphicsDevice;
MARATHON_INSERT_PADDING(0x24);
Vertex m_Vertices[4]; // BL, TL, BR, TR
SoX::Graphics::Vertex m_Vertices[4]; // BL, TL, BR, TR
};
}
17 changes: 17 additions & 0 deletions MarathonRecomp/api/Sonicteam/SoX/Graphics/Vertex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Marathon.inl>
#include <Sonicteam/SoX/Math/Vector.h>

namespace Sonicteam::SoX::Graphics
{
struct Vertex
{
Math::Vector3 m_position;
MARATHON_INSERT_PADDING(0xB);
be<uint32_t> m_colour; // ARGB8888
Math::Vector2 m_uv;
Math::Vector2 m_unknown;
MARATHON_INSERT_PADDING(0x10);
};
}
20 changes: 5 additions & 15 deletions MarathonRecomp/api/Sonicteam/TextEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <Marathon.inl>
#include <Sonicteam/CsdLink.h>
#include <Sonicteam/SoX/Graphics/Vertex.h>
#include <stdx/wstring.h>

namespace Sonicteam
Expand All @@ -12,17 +13,6 @@ namespace Sonicteam
class TextEntity : public CsdLink
{
public:
struct Vertex
{
be<float> X;
be<float> Y;
MARATHON_INSERT_PADDING(0x10);
be<uint32_t> Colour; // ARGB8888
be<float> U;
be<float> V;
MARATHON_INSERT_PADDING(0x18);
};

MARATHON_INSERT_PADDING(4);
boost::shared_ptr<TextFont> m_spTextFont;
boost::shared_ptr<TextBoard> m_spTextBoard;
Expand All @@ -47,10 +37,10 @@ namespace Sonicteam
bool m_FieldDC;
bool m_FieldDD;
MARATHON_INSERT_PADDING(2);
xpointer<void> m_FieldE0; // Only present when there's character vertices.
xpointer<void> m_FieldE4; // Only present when there's image vertices.
xpointer<Vertex> m_pCharacterVertices; // BL/TL/TR BL/TR/BR (two triangles per character)
xpointer<Vertex> m_pImageVertices; // BL/TL/TR BL/TR/BR (two triangles per image)
xpointer<void> m_FieldE0; // Only present when there's character vertices.
xpointer<void> m_FieldE4; // Only present when there's image vertices.
xpointer<SoX::Graphics::Vertex> m_pCharacterVertices; // BL/TL/TR BL/TR/BR (two triangles per character)
xpointer<SoX::Graphics::Vertex> m_pImageVertices; // BL/TL/TR BL/TR/BR (two triangles per image)
be<uint32_t> m_CharacterVertexCount;
be<uint32_t> m_ImageVertexCount;
be<uint32_t> m_TextLength;
Expand Down
39 changes: 39 additions & 0 deletions MarathonRecomp/gpu/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ static Backend g_backend;
#endif

static bool g_triangleStripWorkaround = false;
static bool g_conditionalSurveyActive = false;
static bool g_conditionalRenderingActive = false;

static std::unique_ptr<RenderInterface> g_interface;
static std::unique_ptr<RenderDevice> g_device;
Expand Down Expand Up @@ -4961,6 +4963,9 @@ static void DrawPrimitive(GuestDevice* device, uint32_t primitiveType, uint32_t
LocalRenderCommandQueue queue;
FlushRenderStateForMainThread(device, queue);

if (g_conditionalRenderingActive)
return;

auto& cmd = queue.enqueue();
cmd.type = RenderCommandType::DrawPrimitive;
cmd.drawPrimitive.primitiveType = primitiveType;
Expand All @@ -4987,6 +4992,9 @@ static void DrawIndexedPrimitive(GuestDevice* device, uint32_t primitiveType, in
LocalRenderCommandQueue queue;
FlushRenderStateForMainThread(device, queue);

if (g_conditionalRenderingActive)
return;

auto& cmd = queue.enqueue();
cmd.type = RenderCommandType::DrawIndexedPrimitive;
cmd.drawIndexedPrimitive.primitiveType = primitiveType;
Expand All @@ -5012,6 +5020,9 @@ static void DrawPrimitiveUP(GuestDevice* device, uint32_t primitiveType, uint32_
LocalRenderCommandQueue queue;
FlushRenderStateForMainThread(device, queue);

if (g_conditionalRenderingActive)
return;

auto& cmd = queue.enqueue();
cmd.type = RenderCommandType::DrawPrimitiveUP;
cmd.drawPrimitiveUP.primitiveType = primitiveType;
Expand Down Expand Up @@ -8437,3 +8448,31 @@ GUEST_FUNCTION_STUB(sub_8254D7B0); // BeginConditional
GUEST_FUNCTION_STUB(sub_8254D9D0); // BeginConditional
GUEST_FUNCTION_STUB(sub_8254DB90); // BeginConditional
GUEST_FUNCTION_STUB(sub_8254DD40); // SetScreenExtentQueryMode

PPC_FUNC_IMPL(__imp__sub_82636BF8);
PPC_FUNC(sub_82636BF8) {
g_conditionalSurveyActive = true;

__imp__sub_82636BF8(ctx, base);
}

PPC_FUNC_IMPL(__imp__sub_82636C08);
PPC_FUNC(sub_82636C08) {
g_conditionalSurveyActive = false;

__imp__sub_82636C08(ctx, base);
}

PPC_FUNC_IMPL(__imp__sub_82636C10);
PPC_FUNC(sub_82636C10) {
g_conditionalRenderingActive = true;

__imp__sub_82636C10(ctx, base);
}

PPC_FUNC_IMPL(__imp__sub_82636C18);
PPC_FUNC(sub_82636C18) {
g_conditionalRenderingActive = false;

__imp__sub_82636C18(ctx, base);
}
44 changes: 22 additions & 22 deletions MarathonRecomp/patches/aspect_ratio_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,14 +1316,14 @@ PPC_FUNC(sub_82352220)
if (g_aspectRatio > WIDE_ASPECT_RATIO)
scale = g_aspectRatio / WIDE_ASPECT_RATIO;

pCObjBalloonIconDrawable->m_Vertices[0].X = -1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[0].Y = 0.0f;
pCObjBalloonIconDrawable->m_Vertices[1].X = -1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[1].Y = g_aspectRatio / scale;
pCObjBalloonIconDrawable->m_Vertices[2].X = 1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[2].Y = 0.0f;
pCObjBalloonIconDrawable->m_Vertices[3].X = 1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[3].Y = g_aspectRatio / scale;
pCObjBalloonIconDrawable->m_Vertices[0].m_position.X = -1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[0].m_position.Y = 0.0f;
pCObjBalloonIconDrawable->m_Vertices[1].m_position.X = -1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[1].m_position.Y = g_aspectRatio / scale;
pCObjBalloonIconDrawable->m_Vertices[2].m_position.X = 1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[2].m_position.Y = 0.0f;
pCObjBalloonIconDrawable->m_Vertices[3].m_position.X = 1.0f / scale;
pCObjBalloonIconDrawable->m_Vertices[3].m_position.Y = g_aspectRatio / scale;

__imp__sub_82352220(ctx, base);
}
Expand Down Expand Up @@ -1489,42 +1489,42 @@ void ReplaceTextVariables(Sonicteam::TextEntity* pTextEntity)
auto& v4 = pTextEntity->m_pImageVertices[vi + 4];
auto& v5 = pTextEntity->m_pImageVertices[vi + 5];

auto centreX = (v0.X + v2.X) / 2.0f;
auto centreX = (v0.m_position.X + v2.m_position.X) / 2.0f;
auto widthAdjust = (float)newParams.Width / (float)baseParams.Width;
auto adjust = [&](auto& vertex)
{
vertex.X = centreX + (vertex.X - centreX) * widthAdjust;
vertex.m_position.X = centreX + (vertex.m_position.X - centreX) * widthAdjust;
};

// Bottom Left (Triangle 1)
adjust(v0);
v0.U = min.x;
v0.V = min.y;
v0.m_uv.X = min.x;
v0.m_uv.Y = min.y;

// Top Left (Triangle 1)
adjust(v1);
v1.U = min.x;
v1.V = max.y;
v1.m_uv.X = min.x;
v1.m_uv.Y = max.y;

// Top Right (Triangle 1)
adjust(v2);
v2.U = max.x;
v2.V = max.y;
v2.m_uv.X = max.x;
v2.m_uv.Y = max.y;

// Bottom Left (Triangle 2)
adjust(v3);
v3.U = min.x;
v3.V = min.y;
v3.m_uv.X = min.x;
v3.m_uv.Y = min.y;

// Top Right (Triangle 2)
adjust(v4);
v4.U = max.x;
v4.V = max.y;
v4.m_uv.X = max.x;
v4.m_uv.Y = max.y;

// Bottom Right (Triangle 2)
adjust(v5);
v5.U = max.x;
v5.V = min.y;
v5.m_uv.X = max.x;
v5.m_uv.Y = min.y;

pictureIndex++;
}
Expand Down
Loading