summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions')
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.cpp47
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.h22
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp36
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h17
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp59
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.h24
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.cpp20
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.h14
8 files changed, 239 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.cpp
new file mode 100644
index 0000000000..cc724c0480
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.cpp
@@ -0,0 +1,47 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.h"
+
+std::unique_ptr<MoveAction> MoveAction::Create(const picojson::value& json_data)
+{
+ Common::Vec3 position_offset;
+ const auto& x = json_data.get("X");
+ if (x.is<double>())
+ {
+ position_offset.x = static_cast<float>(x.get<double>());
+ }
+
+ const auto& y = json_data.get("Y");
+ if (y.is<double>())
+ {
+ position_offset.y = static_cast<float>(y.get<double>());
+ }
+
+ const auto& z = json_data.get("Z");
+ if (z.is<double>())
+ {
+ position_offset.z = static_cast<float>(z.get<double>());
+ }
+ return std::make_unique<MoveAction>(position_offset);
+}
+
+MoveAction::MoveAction(Common::Vec3 position_offset) : m_position_offset(position_offset)
+{
+}
+
+void MoveAction::OnProjection(Common::Matrix44* matrix)
+{
+ if (!matrix)
+ return;
+
+ *matrix *= Common::Matrix44::Translate(m_position_offset);
+}
+
+void MoveAction::OnProjectionAndTexture(Common::Matrix44* matrix)
+{
+ if (!matrix)
+ return;
+
+ *matrix *= Common::Matrix44::Translate(m_position_offset);
+}
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.h
new file mode 100644
index 0000000000..768d6a9f38
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/MoveAction.h
@@ -0,0 +1,22 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <memory>
+
+#include <picojson.h>
+
+#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h"
+
+class MoveAction final : public GraphicsModAction
+{
+public:
+ static std::unique_ptr<MoveAction> Create(const picojson::value& json_data);
+ explicit MoveAction(Common::Vec3 position_offset);
+ void OnProjection(Common::Matrix44* matrix) override;
+ void OnProjectionAndTexture(Common::Matrix44* matrix) override;
+
+private:
+ Common::Vec3 m_position_offset;
+};
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp
new file mode 100644
index 0000000000..e6f7d6b659
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp
@@ -0,0 +1,36 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h"
+
+#include "Common/Logging/Log.h"
+
+void PrintAction::OnDrawStarted(bool*)
+{
+ INFO_LOG_FMT(VIDEO, "OnDrawStarted Called");
+}
+
+void PrintAction::OnEFB(bool*, u32 texture_width, u32 texture_height, u32* scaled_width,
+ u32* scaled_height)
+{
+ if (!scaled_width || !scaled_height)
+ return;
+
+ INFO_LOG_FMT(VIDEO, "OnEFB Called. Original [{}, {}], Scaled [{}, {}]", texture_width,
+ texture_height, *scaled_width, *scaled_height);
+}
+
+void PrintAction::OnProjection(Common::Matrix44*)
+{
+ INFO_LOG_FMT(VIDEO, "OnProjection Called");
+}
+
+void PrintAction::OnProjectionAndTexture(Common::Matrix44*)
+{
+ INFO_LOG_FMT(VIDEO, "OnProjectionAndTexture Called");
+}
+
+void PrintAction::OnTextureLoad()
+{
+ INFO_LOG_FMT(VIDEO, "OnTextureLoad Called");
+}
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h
new file mode 100644
index 0000000000..6d8c123b68
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h
@@ -0,0 +1,17 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h"
+
+class PrintAction final : public GraphicsModAction
+{
+public:
+ void OnDrawStarted(bool* skip) override;
+ void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
+ u32* scaled_height) override;
+ void OnProjection(Common::Matrix44* matrix) override;
+ void OnProjectionAndTexture(Common::Matrix44* matrix) override;
+ void OnTextureLoad() override;
+};
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp
new file mode 100644
index 0000000000..d0cac24acb
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.cpp
@@ -0,0 +1,59 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.h"
+
+std::unique_ptr<ScaleAction> ScaleAction::Create(const picojson::value& json_data)
+{
+ Common::Vec3 scale;
+ const auto& x = json_data.get("X");
+ if (x.is<double>())
+ {
+ scale.x = static_cast<float>(x.get<double>());
+ }
+
+ const auto& y = json_data.get("Y");
+ if (y.is<double>())
+ {
+ scale.y = static_cast<float>(y.get<double>());
+ }
+
+ const auto& z = json_data.get("Z");
+ if (z.is<double>())
+ {
+ scale.z = static_cast<float>(z.get<double>());
+ }
+ return std::make_unique<ScaleAction>(scale);
+}
+
+ScaleAction::ScaleAction(Common::Vec3 scale) : m_scale(scale)
+{
+}
+
+void ScaleAction::OnEFB(bool*, u32 texture_width, u32 texture_height, u32* scaled_width,
+ u32* scaled_height)
+{
+ if (scaled_width && m_scale.x > 0)
+ *scaled_width = texture_width * m_scale.x;
+
+ if (scaled_height && m_scale.y > 0)
+ *scaled_height = texture_height * m_scale.y;
+}
+
+void ScaleAction::OnProjection(Common::Matrix44* matrix)
+{
+ if (!matrix)
+ return;
+ auto& the_matrix = *matrix;
+ the_matrix.data[0] = the_matrix.data[0] * m_scale.x;
+ the_matrix.data[5] = the_matrix.data[5] * m_scale.y;
+}
+
+void ScaleAction::OnProjectionAndTexture(Common::Matrix44* matrix)
+{
+ if (!matrix)
+ return;
+ auto& the_matrix = *matrix;
+ the_matrix.data[0] = the_matrix.data[0] * m_scale.x;
+ the_matrix.data[5] = the_matrix.data[5] * m_scale.y;
+}
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.h
new file mode 100644
index 0000000000..cbe8744941
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/ScaleAction.h
@@ -0,0 +1,24 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <memory>
+
+#include <picojson.h>
+
+#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h"
+
+class ScaleAction final : public GraphicsModAction
+{
+public:
+ static std::unique_ptr<ScaleAction> Create(const picojson::value& json_data);
+ explicit ScaleAction(Common::Vec3 scale);
+ void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
+ u32* scaled_height) override;
+ void OnProjection(Common::Matrix44* matrix) override;
+ void OnProjectionAndTexture(Common::Matrix44* matrix) override;
+
+private:
+ Common::Vec3 m_scale;
+};
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.cpp
new file mode 100644
index 0000000000..ae3551497f
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.cpp
@@ -0,0 +1,20 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.h"
+
+void SkipAction::OnDrawStarted(bool* skip)
+{
+ if (!skip)
+ return;
+
+ *skip = true;
+}
+
+void SkipAction::OnEFB(bool* skip, u32, u32, u32*, u32*)
+{
+ if (!skip)
+ return;
+
+ *skip = true;
+}
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.h
new file mode 100644
index 0000000000..5cd204a89d
--- /dev/null
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.h
@@ -0,0 +1,14 @@
+// Copyright 2022 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h"
+
+class SkipAction final : public GraphicsModAction
+{
+public:
+ void OnDrawStarted(bool* skip) override;
+ void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
+ u32* scaled_height) override;
+};