From 73db402010fc74c6db94cd0c8ebc2a59e41eb5f7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 Jul 2019 20:43:20 -0400 Subject: [PATCH] Core/FifoAnalyzer: Convert DecodeMode enum into an enum class Makes the enumeration elements strongly typed. --- Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp | 4 ++-- Source/Core/Core/FifoPlayer/FifoAnalyzer.h | 6 +++--- Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp | 6 +++--- Source/Core/Core/FifoPlayer/FifoRecorder.cpp | 4 +++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp index c0b1bd2e9c..f2a369a84f 100644 --- a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp @@ -188,7 +188,7 @@ u32 AnalyzeCommand(const u8* data, DecodeMode mode) int array = 0xc + (cmd - OpcodeDecoder::GX_LOAD_INDX_A) / 8; u32 value = ReadFifo32(data); - if (mode == DECODE_RECORD) + if (mode == DecodeMode::Record) FifoRecordAnalyzer::ProcessLoadIndexedXf(value, array); break; } @@ -229,7 +229,7 @@ u32 AnalyzeCommand(const u8* data, DecodeMode mode) int vertexSize = offset; int numVertices = ReadFifo16(data); - if (mode == DECODE_RECORD && numVertices > 0) + if (mode == DecodeMode::Record && numVertices > 0) { for (int i = 0; i < 12; ++i) { diff --git a/Source/Core/Core/FifoPlayer/FifoAnalyzer.h b/Source/Core/Core/FifoPlayer/FifoAnalyzer.h index 550fe15489..52fbeb7179 100644 --- a/Source/Core/Core/FifoPlayer/FifoAnalyzer.h +++ b/Source/Core/Core/FifoPlayer/FifoAnalyzer.h @@ -10,10 +10,10 @@ namespace FifoAnalyzer { -enum DecodeMode +enum class DecodeMode { - DECODE_RECORD, - DECODE_PLAYBACK, + Record, + Playback, }; u32 AnalyzeCommand(const u8* data, DecodeMode mode); diff --git a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp index 0458fe2fde..4b8da762bc 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp @@ -63,9 +63,9 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file, ++nextMemUpdate; } - bool wasDrawing = s_DrawingObject; - - u32 cmdSize = FifoAnalyzer::AnalyzeCommand(&frame.fifoData[cmdStart], DECODE_PLAYBACK); + const bool wasDrawing = s_DrawingObject; + const u32 cmdSize = + FifoAnalyzer::AnalyzeCommand(&frame.fifoData[cmdStart], DecodeMode::Playback); #if LOG_FIFO_CMDS CmdData cmdData; diff --git a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp index f85eeb9aef..96329d695b 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp @@ -77,12 +77,14 @@ void FifoRecorder::WriteGPCommand(const u8* data, u32 size) { // Assumes data contains all information for the command // Calls FifoRecorder::UseMemory - u32 analyzed_size = FifoAnalyzer::AnalyzeCommand(data, FifoAnalyzer::DECODE_RECORD); + const u32 analyzed_size = FifoAnalyzer::AnalyzeCommand(data, FifoAnalyzer::DecodeMode::Record); // Make sure FifoPlayer's command analyzer agrees about the size of the command. if (analyzed_size != size) + { PanicAlert("FifoRecorder: Expected command to be %i bytes long, we were given %i bytes", analyzed_size, size); + } // Copy data to buffer size_t currentSize = m_FifoData.size();