diff --git a/Source/Core/Core/Src/HW/HW.cpp b/Source/Core/Core/Src/HW/HW.cpp index 33ea6fdcf4..2089e41f6a 100644 --- a/Source/Core/Core/Src/HW/HW.cpp +++ b/Source/Core/Core/Src/HW/HW.cpp @@ -38,6 +38,7 @@ #include "SystemTimers.h" #include "../IPC_HLE/WII_IPC_HLE.h" #include "../State.h" +#include "../PowerPC/PPCAnalyst.h" #define CURVERSION 0x0001 @@ -46,6 +47,7 @@ namespace HW void Init() { CoreTiming::Init(); + PPCAnalyst::Init(); Thunk_Init(); // not really hw, but this way we know it's inited first :P State_Init(); @@ -86,6 +88,7 @@ namespace HW State_Shutdown(); Thunk_Shutdown(); CoreTiming::Shutdown(); + PPCAnalyst::Shutdown(); } void DoState(PointerWrap &p) diff --git a/Source/Core/Core/Src/LogManager.cpp b/Source/Core/Core/Src/LogManager.cpp index dc07f58e53..0ccad1e621 100644 --- a/Source/Core/Core/Src/LogManager.cpp +++ b/Source/Core/Core/Src/LogManager.cpp @@ -23,7 +23,7 @@ #include "Debugger/Debugger_SymbolMap.h" -LogManager::SMessage LogManager::m_Messages[MAX_MESSAGES]; +LogManager::SMessage *LogManager::m_Messages; int LogManager::m_nextMessages = 0; CDebugger_Log* LogManager::m_Log[LogTypes::NUMBER_OF_LOGS]; @@ -81,6 +81,7 @@ void CDebugger_Log::Shutdown() void LogManager::Init() { + m_Messages = new SMessage[MAX_MESSAGES]; m_bDirty = true; // create Logs @@ -109,7 +110,7 @@ void LogManager::Init() m_Log[LogTypes::WII_IOB] = new CDebugger_Log("WII_IOB", "WII IO Bridge"); m_Log[LogTypes::WII_IPC] = new CDebugger_Log("WII_IPC", "WII IPC"); m_Log[LogTypes::WII_IPC_HLE] = new CDebugger_Log("WII_IPC_HLE", "WII IPC HLE"); - m_Log[LogTypes::WIIMOTE] = new CDebugger_Log("WIIMOTE", "WIIMOTE"); + m_Log[LogTypes::WIIMOTE] = new CDebugger_Log("WIIMOTE", "WIIMOTE"); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { @@ -147,6 +148,8 @@ void LogManager::Shutdown() m_Log[i] = NULL; } } + + delete [] m_Messages; } diff --git a/Source/Core/Core/Src/LogManager.h b/Source/Core/Core/Src/LogManager.h index 24501be9a0..1fb10be8cd 100644 --- a/Source/Core/Core/Src/LogManager.h +++ b/Source/Core/Core/Src/LogManager.h @@ -84,7 +84,7 @@ public: private: friend class CDebugger_LogWindow; friend class CLogWindow; - static SMessage m_Messages[MAX_MESSAGES]; + static SMessage *m_Messages; static int m_nextMessages; static int m_activeLog; static bool m_bDirty; diff --git a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp index 9be4c6ed48..23e91242cc 100644 --- a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp @@ -38,7 +38,22 @@ namespace PPCAnalyst { using namespace std; // VERY ugly. TODO: remove. -PPCAnalyst::CodeOp codebuffer[20000]; +PPCAnalyst::CodeOp *codebuffer; + +enum { + CODEBUFFER_SIZE = 32000, +}; + +void Init() +{ + codebuffer = new PPCAnalyst::CodeOp[CODEBUFFER_SIZE]; +} + +void Shutdown() +{ + delete [] codebuffer; +} + void AnalyzeFunction2(Symbol &func); u32 EvaluateBranchTarget(UGeckoInstruction instr, u32 pc); @@ -441,7 +456,7 @@ CodeOp *Flatten(u32 address, u32 &realsize, BlockStats &st, BlockRegStats &gpa, for (int j = 0; j < 2; j++) code[i].regsOut[j] = -1; - code[i].fregOut=-1; + code[i].fregOut = -1; int numOut = 0; int numIn = 0; diff --git a/Source/Core/Core/Src/PowerPC/PPCAnalyst.h b/Source/Core/Core/Src/PowerPC/PPCAnalyst.h index 5d996cc2de..5200d0a953 100644 --- a/Source/Core/Core/Src/PowerPC/PPCAnalyst.h +++ b/Source/Core/Core/Src/PowerPC/PPCAnalyst.h @@ -31,59 +31,64 @@ struct Symbol; namespace PPCAnalyst { - struct CodeOp //16B - { - UGeckoInstruction inst; - u32 address; - u32 branchTo; //if 0, not a branch - int branchToIndex; //index of target block - u8 regsOut[2]; - u8 regsIn[3]; - u8 fregOut; - u8 fregsIn[3]; - bool isBranchTarget; - bool wantsCR0; - bool wantsCR1; - bool wantsPS1; - bool outputCR0; - bool outputCR1; - bool outputPS1; - const u8 *x86ptr; - }; - struct BlockStats - { - bool isFirstBlockOfFunction; - bool isLastBlockOfFunction; - int numCycles; - }; +struct CodeOp //16B +{ + UGeckoInstruction inst; + u32 address; + u32 branchTo; //if 0, not a branch + int branchToIndex; //index of target block + u8 regsOut[2]; + u8 regsIn[3]; + u8 fregOut; + u8 fregsIn[3]; + bool isBranchTarget; + bool wantsCR0; + bool wantsCR1; + bool wantsPS1; + bool outputCR0; + bool outputCR1; + bool outputPS1; + const u8 *x86ptr; +}; - struct BlockRegStats - { - short firstRead[32]; - short firstWrite[32]; - short lastRead[32]; - short lastWrite[32]; - short numReads[32]; - short numWrites[32]; +struct BlockStats +{ + bool isFirstBlockOfFunction; + bool isLastBlockOfFunction; + int numCycles; +}; - bool any; - bool anyTimer; +struct BlockRegStats +{ + short firstRead[32]; + short firstWrite[32]; + short lastRead[32]; + short lastWrite[32]; + short numReads[32]; + short numWrites[32]; - int GetTotalNumAccesses(int reg) {return numReads[reg] + numWrites[reg];} - int GetUseRange(int reg) { - return max(lastRead[reg], lastWrite[reg]) - - min(firstRead[reg], firstWrite[reg]);} - }; + bool any; + bool anyTimer; - void ShuffleUp(CodeOp *code, int first, int last); + int GetTotalNumAccesses(int reg) {return numReads[reg] + numWrites[reg];} + int GetUseRange(int reg) { + return max(lastRead[reg], lastWrite[reg]) - + min(firstRead[reg], firstWrite[reg]);} +}; - CodeOp *Flatten(u32 address, u32 &realsize, BlockStats &st, BlockRegStats &gpa, BlockRegStats &fpa); +void Init(); +void Shutdown(); - void LogFunctionCall(u32 addr); +void ShuffleUp(CodeOp *code, int first, int last); + +CodeOp *Flatten(u32 address, u32 &realsize, BlockStats &st, BlockRegStats &gpa, BlockRegStats &fpa); + +void LogFunctionCall(u32 addr); + +void FindFunctions(u32 startAddr, u32 endAddr, SymbolDB *func_db); +bool AnalyzeFunction(u32 startAddr, Symbol &func, int max_size = 0); - void FindFunctions(u32 startAddr, u32 endAddr, SymbolDB *func_db); - bool AnalyzeFunction(u32 startAddr, Symbol &func, int max_size = 0); } // namespace #endif