summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/OpcodeDecoding.h
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-04-30 14:57:12 -0700
committerPokechu22 <Pokechu022@gmail.com>2021-12-18 12:51:56 -0800
commit3aaeb2b9ef3f6b9cde69c77ecdf96e8defc996d5 (patch)
treebacb645dba78c7acb3165407ef904a3a890eeb12 /Source/Core/VideoCommon/OpcodeDecoding.h
parent3fc12431c5ed7a0df1e9bd4c538405a44f6561de (diff)
Convert OpcodeDecoder::Opcode and OpcodeDecoder::Primitive to enum class
Diffstat (limited to 'Source/Core/VideoCommon/OpcodeDecoding.h')
-rw-r--r--Source/Core/VideoCommon/OpcodeDecoding.h32
1 files changed, 23 insertions, 9 deletions
diff --git a/Source/Core/VideoCommon/OpcodeDecoding.h b/Source/Core/VideoCommon/OpcodeDecoding.h
index 98e5a292de..df1059f221 100644
--- a/Source/Core/VideoCommon/OpcodeDecoding.h
+++ b/Source/Core/VideoCommon/OpcodeDecoding.h
@@ -4,6 +4,7 @@
#pragma once
#include "Common/CommonTypes.h"
+#include "Common/EnumFormatter.h"
class DataReader;
@@ -12,7 +13,7 @@ namespace OpcodeDecoder
// Global flag to signal if FifoRecorder is active.
extern bool g_record_fifo_data;
-enum
+enum class Opcode
{
GX_NOP = 0x00,
GX_UNKNOWN_RESET = 0x01,
@@ -27,20 +28,20 @@ enum
GX_CMD_CALL_DL = 0x40,
GX_CMD_UNKNOWN_METRICS = 0x44,
- GX_CMD_INVL_VC = 0x48
-};
+ GX_CMD_INVL_VC = 0x48,
-enum
-{
- GX_PRIMITIVE_MASK = 0x78,
- GX_PRIMITIVE_SHIFT = 3,
- GX_VAT_MASK = 0x07
+ GX_PRIMITIVE_START = 0x80,
+ GX_PRIMITIVE_END = 0xbf,
};
+constexpr u8 GX_PRIMITIVE_MASK = 0x78;
+constexpr u32 GX_PRIMITIVE_SHIFT = 3;
+constexpr u8 GX_VAT_MASK = 0x07;
+
// These values are the values extracted using GX_PRIMITIVE_MASK
// and GX_PRIMITIVE_SHIFT.
// GX_DRAW_QUADS_2 behaves the same way as GX_DRAW_QUADS.
-enum
+enum class Primitive : u8
{
GX_DRAW_QUADS = 0x0, // 0x80
GX_DRAW_QUADS_2 = 0x1, // 0x88
@@ -58,3 +59,16 @@ template <bool is_preprocess = false>
u8* Run(DataReader src, u32* cycles, bool in_display_list);
} // namespace OpcodeDecoder
+
+template <>
+struct fmt::formatter<OpcodeDecoder::Primitive>
+ : EnumFormatter<OpcodeDecoder::Primitive::GX_DRAW_POINTS>
+{
+ static constexpr array_type names = {
+ "GX_DRAW_QUADS", "GX_DRAW_QUADS_2 (nonstandard)",
+ "GX_DRAW_TRIANGLES", "GX_DRAW_TRIANGLE_STRIP",
+ "GX_DRAW_TRIANGLE_FAN", "GX_DRAW_LINES",
+ "GX_DRAW_LINE_STRIP", "GX_DRAW_POINTS",
+ };
+ formatter() : EnumFormatter(names) {}
+};