From 3aaeb2b9ef3f6b9cde69c77ecdf96e8defc996d5 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 30 Apr 2021 14:57:12 -0700 Subject: Convert OpcodeDecoder::Opcode and OpcodeDecoder::Primitive to enum class --- Source/Core/VideoCommon/OpcodeDecoding.h | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'Source/Core/VideoCommon/OpcodeDecoding.h') 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 u8* Run(DataReader src, u32* cycles, bool in_display_list); } // namespace OpcodeDecoder + +template <> +struct fmt::formatter + : EnumFormatter +{ + 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) {} +}; -- cgit v1.2.3