diff --git a/Data/User/Wii/shared2/wc24/mbox/Readme.txt b/Data/User/Wii/shared2/wc24/mbox/Readme.txt index 39f60615b6..6813fc73c1 100644 --- a/Data/User/Wii/shared2/wc24/mbox/Readme.txt +++ b/Data/User/Wii/shared2/wc24/mbox/Readme.txt @@ -1,4 +1,4 @@ -The Mailbox here has been shrunk, the real file size: - -WC24RECV.MBX 0x00700000 -WC24SEND.MBX 0x00200000 \ No newline at end of file +The Mailbox here has been shrunk, the real file size: + +WC24RECV.MBX 0x00700000 +WC24SEND.MBX 0x00200000 diff --git a/Source/Core/AudioCommon/Src/WaveFile.cpp b/Source/Core/AudioCommon/Src/WaveFile.cpp index e481d84f16..2364d6fabb 100644 --- a/Source/Core/AudioCommon/Src/WaveFile.cpp +++ b/Source/Core/AudioCommon/Src/WaveFile.cpp @@ -74,7 +74,7 @@ bool WaveFileWriter::Start(const char *filename) // We are now at offset 44 if (ftello(file) != 44) - PanicAlert("wrong offset: %lli", ftello(file)); + PanicAlert("wrong offset: %lld", (long long)ftello(file)); return true; } diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index 2953c2b3ba..ec8e42edf4 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -70,7 +70,7 @@ public: case MODE_READ: memcpy(data, *ptr, size); break; case MODE_WRITE: memcpy(*ptr, data, size); break; case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything - case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at 0x%X) != %d (0x%X) (at 0x%X).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; + case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; default: break; // throw an error? } (*ptr) += size; @@ -136,7 +136,7 @@ public: case MODE_READ: x = (char*)*ptr; break; case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; case MODE_MEASURE: break; - case MODE_VERIFY: _dbg_assert_msg_(COMMON, !strcmp(x.c_str(), (char*)*ptr), "Savestate verification failure: \"%s\" != \"%s\" (at 0x%X).\n", x.c_str(), (char*)*ptr, ptr); break; + case MODE_VERIFY: _dbg_assert_msg_(COMMON, !strcmp(x.c_str(), (char*)*ptr), "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", x.c_str(), (char*)*ptr, ptr); break; } (*ptr) += stringLen; } @@ -150,7 +150,7 @@ public: case MODE_READ: delete[] *pBuffer; *pBuffer = new u8[_Size]; memcpy(*pBuffer, *ptr, _Size); break; case MODE_WRITE: memcpy(*ptr, *pBuffer, _Size); break; case MODE_MEASURE: break; - case MODE_VERIFY: if(*pBuffer) for(u32 i = 0; i < _Size; i++) _dbg_assert_msg_(COMMON, (*pBuffer)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at 0x%X) != %d (0x%X) (at 0x%X).\n", (*pBuffer)[i], (*pBuffer)[i], &(*pBuffer)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; + case MODE_VERIFY: if(*pBuffer) for(u32 i = 0; i < _Size; i++) _dbg_assert_msg_(COMMON, (*pBuffer)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", (*pBuffer)[i], (*pBuffer)[i], &(*pBuffer)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; } } else { *pBuffer = NULL; diff --git a/Source/Core/Common/Src/ConsoleListener.cpp b/Source/Core/Common/Src/ConsoleListener.cpp index 4240061933..93922a4537 100644 --- a/Source/Core/Common/Src/ConsoleListener.cpp +++ b/Source/Core/Common/Src/ConsoleListener.cpp @@ -245,14 +245,14 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool COORD Coo = GetCoordinates(OldCursor, LBufWidth); SetConsoleCursorPosition(hConsole, Coo); - if (SLog.length() > 0) Log(LogTypes::LNOTICE, SLog.c_str()); + if (SLog.length() > 0) Log(NOTICE_LEVEL, SLog.c_str()); // Resize the window too if (Resize) MoveWindow(GetConsoleWindow(), Left,Top, (Width + 100),Height, true); #endif } -void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text) +void ConsoleListener::Log(enum LOG_LEVEL Level, const char *Text) { #if defined(_WIN32) /* diff --git a/Source/Core/Common/Src/ConsoleListener.h b/Source/Core/Common/Src/ConsoleListener.h index 2e8bffcf4b..ed36aebb68 100644 --- a/Source/Core/Common/Src/ConsoleListener.h +++ b/Source/Core/Common/Src/ConsoleListener.h @@ -40,7 +40,7 @@ public: #ifdef _WIN32 COORD GetCoordinates(int BytesRead, int BufferWidth); #endif - void Log(LogTypes::LOG_LEVELS, const char *Text); + void Log(enum LOG_LEVEL level, const char *Text); void ClearScreen(bool Cursor = true); const char *getName() const { return "Console"; } diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index ee9fa6facd..0a239b6551 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -337,7 +337,8 @@ u64 GetSize(const char *filename) // on windows it's actually _stat64 defined in commonFuncs struct stat64 buf; if (stat64(filename, &buf) == 0) { - DEBUG_LOG(COMMON, "GetSize: %s: %lld", filename, buf.st_size); + DEBUG_LOG(COMMON, "GetSize: %s: %lld", + filename, (long long)buf.st_size); return buf.st_size; } diff --git a/Source/Core/Common/Src/Log.h b/Source/Core/Common/Src/Log.h index a6289ec332..5d08e0da19 100644 --- a/Source/Core/Common/Src/Log.h +++ b/Source/Core/Common/Src/Log.h @@ -18,17 +18,6 @@ #ifndef _LOG_H_ #define _LOG_H_ -#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and OSReports. -#define ERROR_LEVEL 2 // Critical errors -#define WARNING_LEVEL 3 // Something is suspicious. -#define INFO_LEVEL 4 // General information. -#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. - -#ifdef __cplusplus -namespace LogTypes -{ -#endif - enum LOG_TYPE { ACTIONREPLAY, AUDIO, @@ -48,7 +37,7 @@ enum LOG_TYPE { EXPANSIONINTERFACE, POWERPC, GPFIFO, - HLE, + OSHLE, MASTER_LOG, MEMMAP, MEMCARD_MANAGER, @@ -77,37 +66,21 @@ enum LOG_TYPE { NUMBER_OF_LOGS // Must be last }; -// FIXME: should this be removed? -enum LOG_LEVELS { - LNOTICE = NOTICE_LEVEL, - LERROR = ERROR_LEVEL, - LWARNING = WARNING_LEVEL, - LINFO = INFO_LEVEL, - LDEBUG = DEBUG_LEVEL, +enum LOG_LEVEL { + NOTICE_LEVEL = 1, // VERY important information that is NOT errors. Like startup and OSReports + ERROR_LEVEL = 2, // Critical errors + WARNING_LEVEL = 3, // Something is suspicious + INFO_LEVEL = 4, // General information + DEBUG_LEVEL = 5, // Detailed debugging - might make things slow }; -#ifdef __cplusplus -#define LOGTYPES_LEVELS LogTypes::LOG_LEVELS -#define LOGTYPES_TYPE LogTypes::LOG_TYPE -#else -#define LOGTYPES_LEVELS enum LOG_LEVELS -#define LOGTYPES_TYPE enum LOG_TYPE -#endif - -#ifdef __cplusplus -} // namespace - -extern "C" { -#endif -void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, +extern "C" +void GenericLog(enum LOG_LEVEL level, enum LOG_TYPE type, const char *file, int line, const char *fmt, ...) #ifdef __GNUC__ __attribute__((format(printf, 5, 6))) #endif ; -#ifdef __cplusplus -}; -#endif #if defined LOGGING || defined _DEBUG || defined DEBUGFAST #define MAX_LOGLEVEL DEBUG_LEVEL @@ -120,16 +93,20 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, #ifdef GEKKO #define GENERIC_LOG(t, v, ...) #else - // Let the compiler optimize this out -#define GENERIC_LOG(t, v, ...) {if (v <= MAX_LOGLEVEL) {GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__);}} +#define GENERIC_LOG(t, v, ...) { \ + if (v <= MAX_LOGLEVEL) \ + GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \ + } +//#define GENERIC_LOG(t, v, ...) { if (v <= MAX_LOGLEVEL) +// GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); } #endif -#define ERROR_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } -#define WARN_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } -#define NOTICE_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } -#define INFO_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } -#define DEBUG_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } +#define ERROR_LOG(t,...) { GENERIC_LOG(t, ERROR_LEVEL, __VA_ARGS__) } +#define WARN_LOG(t,...) { GENERIC_LOG(t, WARNING_LEVEL, __VA_ARGS__) } +#define NOTICE_LOG(t,...) { GENERIC_LOG(t, NOTICE_LEVEL, __VA_ARGS__) } +#define INFO_LOG(t,...) { GENERIC_LOG(t, INFO_LEVEL, __VA_ARGS__) } +#define DEBUG_LOG(t,...) { GENERIC_LOG(t, DEBUG_LEVEL, __VA_ARGS__) } #if MAX_LOGLEVEL >= DEBUG_LEVEL #define _dbg_assert_(_t_, _a_) \ diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp index 0122066abb..f920b46c72 100644 --- a/Source/Core/Common/Src/LogManager.cpp +++ b/Source/Core/Common/Src/LogManager.cpp @@ -23,7 +23,7 @@ #include "Thread.h" #include "FileUtil.h" -void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, +void GenericLog(enum LOG_LEVEL level, enum LOG_TYPE type, const char *file, int line, const char* fmt, ...) { va_list args; @@ -40,54 +40,54 @@ LogManager::LogManager() { logMutex = new Common::CriticalSection(1); // create log files - m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log"); - m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot"); - m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common"); - m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO"); - m_Log[LogTypes::FILEMON] = new LogContainer("FileMon", "File Monitor"); - m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad"); - m_Log[LogTypes::PIXELENGINE] = new LogContainer("PE", "PixelEngine"); - m_Log[LogTypes::COMMANDPROCESSOR] = new LogContainer("CP", "CommandProc"); - m_Log[LogTypes::VIDEOINTERFACE] = new LogContainer("VI", "VideoInt"); - m_Log[LogTypes::SERIALINTERFACE] = new LogContainer("SI", "SerialInt"); - m_Log[LogTypes::PROCESSORINTERFACE] = new LogContainer("PI", "ProcessorInt"); - m_Log[LogTypes::MEMMAP] = new LogContainer("MI", "MI & memmap"); - m_Log[LogTypes::SP1] = new LogContainer("SP1", "Serial Port 1"); - m_Log[LogTypes::STREAMINGINTERFACE] = new LogContainer("Stream", "StreamingInt"); - m_Log[LogTypes::DSPINTERFACE] = new LogContainer("DSP", "DSPInterface"); - m_Log[LogTypes::DVDINTERFACE] = new LogContainer("DVD", "DVDInterface"); - m_Log[LogTypes::GPFIFO] = new LogContainer("GP", "GPFifo"); - m_Log[LogTypes::EXPANSIONINTERFACE] = new LogContainer("EXI", "ExpansionInt"); - m_Log[LogTypes::AUDIO_INTERFACE] = new LogContainer("AI", "AudioInt"); - m_Log[LogTypes::POWERPC] = new LogContainer("PowerPC", "IBM CPU"); - m_Log[LogTypes::HLE] = new LogContainer("HLE", "HLE"); - m_Log[LogTypes::DSPHLE] = new LogContainer("DSPHLE", "DSP HLE"); - m_Log[LogTypes::DSPLLE] = new LogContainer("DSPLLE", "DSP LLE"); - m_Log[LogTypes::DSP_MAIL] = new LogContainer("DSPMails", "DSP Mails"); - m_Log[LogTypes::VIDEO] = new LogContainer("Video", "Video Plugin"); - m_Log[LogTypes::AUDIO] = new LogContainer("Audio", "Audio Plugin"); - m_Log[LogTypes::DYNA_REC] = new LogContainer("JIT", "Dynamic Recompiler"); - m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console"); - m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport"); - m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote Plugin"); - m_Log[LogTypes::WII_IOB] = new LogContainer("WII_IOB", "WII IO Bridge"); - m_Log[LogTypes::WII_IPC] = new LogContainer("WII_IPC", "WII IPC"); - m_Log[LogTypes::WII_IPC_HLE] = new LogContainer("WII_IPC_HLE", "WII IPC HLE"); - m_Log[LogTypes::WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD"); - m_Log[LogTypes::WII_IPC_ES] = new LogContainer("WII_IPC_ES", "WII IPC ES"); - m_Log[LogTypes::WII_IPC_FILEIO] = new LogContainer("WII_IPC_FILEIO","WII IPC FILEIO"); - m_Log[LogTypes::WII_IPC_SD] = new LogContainer("WII_IPC_SD", "WII IPC SD"); - m_Log[LogTypes::WII_IPC_STM] = new LogContainer("WII_IPC_STM", "WII IPC STM"); - m_Log[LogTypes::WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET"); - m_Log[LogTypes::WII_IPC_WIIMOTE] = new LogContainer("WII_IPC_WIIMOTE","WII IPC WIIMOTE"); - m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay"); - m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); - m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); + m_Log[MASTER_LOG] = new LogContainer("*", "Master Log"); + m_Log[BOOT] = new LogContainer("BOOT", "Boot"); + m_Log[COMMON] = new LogContainer("COMMON", "Common"); + m_Log[DISCIO] = new LogContainer("DIO", "Disc IO"); + m_Log[FILEMON] = new LogContainer("FileMon", "File Monitor"); + m_Log[PAD] = new LogContainer("PAD", "Pad"); + m_Log[PIXELENGINE] = new LogContainer("PE", "PixelEngine"); + m_Log[COMMANDPROCESSOR] = new LogContainer("CP", "CommandProc"); + m_Log[VIDEOINTERFACE] = new LogContainer("VI", "VideoInt"); + m_Log[SERIALINTERFACE] = new LogContainer("SI", "SerialInt"); + m_Log[PROCESSORINTERFACE] = new LogContainer("PI", "ProcessorInt"); + m_Log[MEMMAP] = new LogContainer("MI", "MI & memmap"); + m_Log[SP1] = new LogContainer("SP1", "Serial Port 1"); + m_Log[STREAMINGINTERFACE] = new LogContainer("Stream", "StreamingInt"); + m_Log[DSPINTERFACE] = new LogContainer("DSP", "DSPInterface"); + m_Log[DVDINTERFACE] = new LogContainer("DVD", "DVDInterface"); + m_Log[GPFIFO] = new LogContainer("GP", "GPFifo"); + m_Log[EXPANSIONINTERFACE] = new LogContainer("EXI", "ExpansionInt"); + m_Log[AUDIO_INTERFACE] = new LogContainer("AI", "AudioInt"); + m_Log[POWERPC] = new LogContainer("PowerPC", "IBM CPU"); + m_Log[OSHLE] = new LogContainer("HLE", "HLE"); + m_Log[DSPHLE] = new LogContainer("DSPHLE", "DSP HLE"); + m_Log[DSPLLE] = new LogContainer("DSPLLE", "DSP LLE"); + m_Log[DSP_MAIL] = new LogContainer("DSPMails", "DSP Mails"); + m_Log[VIDEO] = new LogContainer("Video", "Video Plugin"); + m_Log[AUDIO] = new LogContainer("Audio", "Audio Plugin"); + m_Log[DYNA_REC] = new LogContainer("JIT", "Dynamic Recompiler"); + m_Log[CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console"); + m_Log[OSREPORT] = new LogContainer("OSREPORT", "OSReport"); + m_Log[WIIMOTE] = new LogContainer("Wiimote", "Wiimote Plugin"); + m_Log[WII_IOB] = new LogContainer("WII_IOB", "WII IO Bridge"); + m_Log[WII_IPC] = new LogContainer("WII_IPC", "WII IPC"); + m_Log[WII_IPC_HLE] = new LogContainer("WII_IPC_HLE", "WII IPC HLE"); + m_Log[WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD"); + m_Log[WII_IPC_ES] = new LogContainer("WII_IPC_ES", "WII IPC ES"); + m_Log[WII_IPC_FILEIO] = new LogContainer("WII_IPC_FILEIO", "WII IPC FILEIO"); + m_Log[WII_IPC_SD] = new LogContainer("WII_IPC_SD", "WII IPC SD"); + m_Log[WII_IPC_STM] = new LogContainer("WII_IPC_STM", "WII IPC STM"); + m_Log[WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET"); + m_Log[WII_IPC_WIIMOTE] = new LogContainer("WII_IPC_WIIMOTE", "WII IPC WIIMOTE"); + m_Log[ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay"); + m_Log[MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); + m_Log[NETPLAY] = new LogContainer("NETPLAY", "Netplay"); m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX)); m_consoleLog = new ConsoleListener(); - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { m_Log[i]->setEnable(true); m_Log[i]->addListener(m_fileLog); m_Log[i]->addListener(m_consoleLog); @@ -95,12 +95,12 @@ LogManager::LogManager() { } LogManager::~LogManager() { - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { - m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); - m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_consoleLog); + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { + m_logManager->removeListener(i, m_fileLog); + m_logManager->removeListener(i, m_consoleLog); } - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + for (int i = 0; i < NUMBER_OF_LOGS; ++i) delete m_Log[i]; delete m_fileLog; @@ -108,9 +108,8 @@ LogManager::~LogManager() { delete logMutex; } -void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, - const char *file, int line, const char *format, - va_list args) { +void LogManager::Log(enum LOG_LEVEL level, enum LOG_TYPE type, + const char *file, int line, const char *format, va_list args) { char temp[MAX_MSGLEN]; char msg[MAX_MSGLEN * 2]; @@ -132,7 +131,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, logMutex->Leave(); } -void LogManager::removeListener(LogTypes::LOG_TYPE type, LogListener *listener) { +void LogManager::removeListener(int type, LogListener *listener) { logMutex->Enter(); m_Log[type]->removeListener(listener); logMutex->Leave(); @@ -153,7 +152,7 @@ LogContainer::LogContainer(const char* shortName, const char* fullName, bool ena : m_enable(enable) { strncpy(m_fullName, fullName, 128); strncpy(m_shortName, shortName, 32); - m_level = LogTypes::LWARNING; + m_level = MAX_LOGLEVEL; } // LogContainer @@ -172,7 +171,7 @@ bool LogContainer::isListener(LogListener *listener) const { return listeners.end() != std::find(listeners.begin(), listeners.end(), listener); } -void LogContainer::trigger(LogTypes::LOG_LEVELS level, const char *msg) { +void LogContainer::trigger(enum LOG_LEVEL level, const char *msg) { std::vector::const_iterator i; for (i = listeners.begin(); i != listeners.end(); ++i) { (*i)->Log(level, msg); @@ -191,10 +190,10 @@ FileLogListener::~FileLogListener() { fclose(m_logfile); } -void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) { +void FileLogListener::Log(enum LOG_LEVEL, const char *msg) { if (!m_enable || !isValid()) return; - fwrite(msg, strlen(msg) * sizeof(char), 1, m_logfile); + fwrite(msg, strlen(msg) * sizeof(char), 1, m_logfile); fflush(m_logfile); } diff --git a/Source/Core/Common/Src/LogManager.h b/Source/Core/Common/Src/LogManager.h index 7e247925c4..70cbbd2cb6 100644 --- a/Source/Core/Common/Src/LogManager.h +++ b/Source/Core/Common/Src/LogManager.h @@ -33,7 +33,7 @@ class LogListener { public: virtual ~LogListener() {} - virtual void Log(LogTypes::LOG_LEVELS, const char *msg) = 0; + virtual void Log(enum LOG_LEVEL level, const char *msg) = 0; virtual const char *getName() const = 0; }; @@ -42,7 +42,7 @@ public: FileLogListener(const char *filename); ~FileLogListener(); - void Log(LogTypes::LOG_LEVELS, const char *msg); + void Log(enum LOG_LEVEL level, const char *msg); bool isValid() { return (m_logfile != NULL); @@ -75,18 +75,18 @@ public: void addListener(LogListener *listener); void removeListener(LogListener *listener); - void trigger(LogTypes::LOG_LEVELS, const char *msg); + void trigger(enum LOG_LEVEL level, const char *msg); bool isEnable() const { return m_enable; } void setEnable(bool enable) { m_enable = enable; } - LogTypes::LOG_LEVELS getLevel() const { + enum LOG_LEVEL getLevel() const { return m_level; } - void setLevel(LogTypes::LOG_LEVELS level) { + void setLevel(enum LOG_LEVEL level) { m_level = level; } @@ -94,7 +94,7 @@ private: char m_fullName[128]; char m_shortName[32]; bool m_enable; - LogTypes::LOG_LEVELS m_level; + enum LOG_LEVEL m_level; std::vector listeners; }; @@ -109,7 +109,7 @@ namespace Common { class LogManager : NonCopyable { private: - LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; + LogContainer *m_Log[NUMBER_OF_LOGS]; Common::CriticalSection *logMutex; FileLogListener *m_fileLog; ConsoleListener *m_consoleLog; @@ -121,38 +121,38 @@ public: static u32 GetMaxLevel() { return MAX_LOGLEVEL; } - void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, + void Log(enum LOG_LEVEL level, enum LOG_TYPE type, const char *file, int line, const char *fmt, va_list args); - void setLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) { + void setLogLevel(int type, LOG_LEVEL level) { m_Log[type]->setLevel(level); } - void setEnable(LogTypes::LOG_TYPE type, bool enable) { + void setEnable(int type, bool enable) { m_Log[type]->setEnable(enable); } - bool isEnable(LogTypes::LOG_TYPE type) { + bool isEnable(int type) { return m_Log[type]->isEnable(); } - const char *getShortName(LogTypes::LOG_TYPE type) const { + const char *getShortName(int type) const { return m_Log[type]->getShortName(); } - const char *getFullName(LogTypes::LOG_TYPE type) const { + const char *getFullName(int type) const { return m_Log[type]->getFullName(); } - bool isListener(LogTypes::LOG_TYPE type, LogListener *listener) const { + bool isListener(int type, LogListener *listener) const { return m_Log[type]->isListener(listener); } - void addListener(LogTypes::LOG_TYPE type, LogListener *listener) { + void addListener(int type, LogListener *listener) { m_Log[type]->addListener(listener); } - void removeListener(LogTypes::LOG_TYPE type, LogListener *listener); + void removeListener(int type, LogListener *listener); FileLogListener *getFileListener() { return m_fileLog; diff --git a/Source/Core/Common/Src/SymbolDB.cpp b/Source/Core/Common/Src/SymbolDB.cpp index 4fd814ea71..93ec43ff24 100644 --- a/Source/Core/Common/Src/SymbolDB.cpp +++ b/Source/Core/Common/Src/SymbolDB.cpp @@ -22,9 +22,13 @@ void SymbolDB::List() { for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter) { - DEBUG_LOG(HLE,"%s @ %08x: %i bytes (hash %08x) : %i calls", iter->second.name.c_str(), iter->second.address, iter->second.size, iter->second.hash,iter->second.numCalls); + DEBUG_LOG(OSHLE, "%s @ %08x: %i bytes (hash %08x) : %i calls", + iter->second.name.c_str(), iter->second.address, + iter->second.size, iter->second.hash, + iter->second.numCalls); } - INFO_LOG(HLE,"%i functions known in this program above.", functions.size()); + INFO_LOG(OSHLE, "%lu functions known in this program above.", + functions.size()); } void SymbolDB::Clear(const char *prefix) diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp index 76de6cfbd3..16624b6388 100644 --- a/Source/Core/Common/Src/Thread.cpp +++ b/Source/Core/Common/Src/Thread.cpp @@ -356,7 +356,8 @@ namespace Common if (ret) ERROR_LOG(COMMON, "%s: pthread_create(%p, %p, %p, %p) failed: %s\n", __FUNCTION__, &thread_id, &attr, function, arg, strerror(ret)); - INFO_LOG(COMMON, "created new thread %lu (func=%p, arg=%p)\n", thread_id, function, arg); + INFO_LOG(COMMON, "created new thread %lu (func=%p, arg=%p)\n", + (unsigned long)thread_id, function, arg); } @@ -372,9 +373,13 @@ namespace Common { void* exit_status; int ret = pthread_join(thread_id, &exit_status); - if (ret) ERROR_LOG(COMMON, "error joining thread %lu: %s\n", thread_id, strerror(ret)); + if (ret) ERROR_LOG(COMMON, + "error joining thread %lu: %s\n", + (unsigned long)thread_id, strerror(ret)); if (exit_status) - ERROR_LOG(COMMON, "thread %lu exited with status %d\n", thread_id, *(int *)exit_status); + ERROR_LOG(COMMON, + "thread %lu exited with status %d\n", + (unsigned long)thread_id, *(int *)exit_status); thread_id = 0; } } diff --git a/Source/Core/Common/Src/x64Emitter.cpp b/Source/Core/Common/Src/x64Emitter.cpp index 01469ad293..39c43bc498 100644 --- a/Source/Core/Common/Src/x64Emitter.cpp +++ b/Source/Core/Common/Src/x64Emitter.cpp @@ -171,7 +171,7 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg) const s64 distance = (s64)offset - (s64)ripAddr; if (distance >= 0x0000000080000000LL || distance < -0x0000000080000000LL) { - PanicAlert("WriteRest: op out of range (%p uses %p)", ripAddr, offset); + PanicAlert("WriteRest: op out of range (0x%llx uses 0x%llx)", ripAddr, offset); } s32 offs = (s32)distance; emit->Write32((u32)offs); diff --git a/Source/Core/Core/Src/ActionReplay.cpp b/Source/Core/Core/Src/ActionReplay.cpp index 83a1f825ac..1261100af4 100644 --- a/Source/Core/Core/Src/ActionReplay.cpp +++ b/Source/Core/Core/Src/ActionReplay.cpp @@ -238,7 +238,7 @@ void LogInfo(const char *format, ...) { if (!b_RanOnce) { - if (LogManager::GetMaxLevel() >= LogTypes::LINFO || logSelf) + if (LogManager::GetMaxLevel() >= INFO_LEVEL || logSelf) { char* temp = (char*)alloca(strlen(format)+512); va_list args; @@ -448,7 +448,7 @@ ARCode GetARCode(size_t index) { if (index > arCodes.size()) { - PanicAlert("GetARCode: Index is greater than ar code list size %i", index); + PanicAlert("GetARCode: Index is greater than ar code list size %lu", index); return ARCode(); } return arCodes[index]; @@ -458,7 +458,7 @@ void SetARCode_IsActive(bool active, size_t index) { if (index > arCodes.size()) { - PanicAlert("SetARCode_IsActive: Index is greater than ar code list size %i", index); + PanicAlert("SetARCode_IsActive: Index is greater than ar code list size %lu", index); return; } arCodes[index].active = active; diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 76c9c1eb64..bfd0e5ca76 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -407,7 +407,7 @@ THREAD_RETURN EmuThread(void *pArg) PowerPC::SetMode(PowerPC::MODE_INTERPRETER); // Spawn the CPU thread - _dbg_assert_(HLE, cpuThread == NULL); + _dbg_assert_(OSHLE, cpuThread == NULL); // ENTER THE VIDEO THREAD LOOP if (_CoreParameter.bCPUThread) { @@ -710,7 +710,7 @@ void Callback_VideoRequestWindowSize(int& x, int& y, int& width, int& height) // WARNING - THIS MAY BE EXECUTED FROM DSP THREAD void Callback_DSPLog(const TCHAR* _szMessage, int _v) { - GENERIC_LOG(LogTypes::AUDIO, (LogTypes::LOG_LEVELS)_v, "%s", _szMessage); + GENERIC_LOG(AUDIO, (enum LOG_LEVEL)_v, "%s", _szMessage); } diff --git a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp index 3edde92883..e252c06f48 100644 --- a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp +++ b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp @@ -127,7 +127,7 @@ void PrintCallstack() } } -void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) +void PrintCallstack(enum LOG_TYPE type, enum LOG_LEVEL level) { u32 addr = Memory::ReadUnchecked_U32(PowerPC::ppcState.gpr[1]); // SP @@ -157,9 +157,9 @@ void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) } } -void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const char* _title) +void PrintDataBuffer(enum LOG_TYPE type, u8* _pData, size_t _Size, const char* _title) { - GENERIC_LOG(type, LogTypes::LDEBUG, "%s", _title); + DEBUG_LOG(type, "%s", _title); for (u32 j = 0; j < _Size;) { std::string Temp; @@ -172,7 +172,7 @@ void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const ch if (j >= _Size) break; } - GENERIC_LOG(type, LogTypes::LDEBUG, " Data: %s", Temp.c_str()); + DEBUG_LOG(type, " Data: %s", Temp.c_str()); } } diff --git a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.h b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.h index 5ce7144540..20ebb4c3a8 100644 --- a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.h +++ b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.h @@ -34,8 +34,8 @@ struct CallstackEntry bool GetCallstack(std::vector &output); void PrintCallstack(); -void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level); -void PrintDataBuffer(LogTypes::LOG_TYPE _Log, u8* _pData, size_t _Size, const char* _title); +void PrintCallstack(enum LOG_TYPE type, enum LOG_LEVEL level); +void PrintDataBuffer(enum LOG_TYPE _Log, u8* _pData, size_t _Size, const char* _title); void AddAutoBreakpoints(); diff --git a/Source/Core/Core/Src/HLE/HLE.cpp b/Source/Core/Core/Src/HLE/HLE.cpp index a3c912ef2f..14b4a0e89e 100644 --- a/Source/Core/Core/Src/HLE/HLE.cpp +++ b/Source/Core/Core/Src/HLE/HLE.cpp @@ -127,7 +127,7 @@ void PatchFunctions() orig_instruction[addr] = Memory::ReadUnchecked_U32(addr); Memory::Write_U32(HLEPatchValue | i, addr); } - INFO_LOG(HLE,"Patching %s %08x", OSPatches[i].m_szPatchName, symbol->address); + INFO_LOG(OSHLE, "Patching %s %08x", OSPatches[i].m_szPatchName, symbol->address); } } @@ -137,7 +137,7 @@ void PatchFunctions() if (symbol > 0) { PowerPC::breakpoints.Add(symbol->address, false); - INFO_LOG(HLE,"Adding BP to %s %08x", OSBreakPoints[i].m_szPatchName, symbol->address); + INFO_LOG(OSHLE, "Adding BP to %s %08x", OSBreakPoints[i].m_szPatchName, symbol->address); } } diff --git a/Source/Core/Core/Src/HW/EXI_DeviceEthernet.cpp b/Source/Core/Core/Src/HW/EXI_DeviceEthernet.cpp index a39173159e..7c4b4ab717 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceEthernet.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceEthernet.cpp @@ -40,7 +40,7 @@ void DEBUGPRINT (const char * format, ...) #endif printf("%s\n", buffer); #else - INFO_LOG(SP1, buffer); + INFO_LOG(SP1, "%s", buffer); #endif va_end(args); } diff --git a/Source/Core/Core/Src/HW/Memmap.cpp b/Source/Core/Core/Src/HW/Memmap.cpp index dc9f853ba7..36bc8eacb4 100644 --- a/Source/Core/Core/Src/HW/Memmap.cpp +++ b/Source/Core/Core/Src/HW/Memmap.cpp @@ -121,10 +121,10 @@ readFn64 hwReadWii64[NUMHWMEMFUN]; // Default read and write functions template -void HW_Default_Write(const T _Data, const u32 _Address){ ERROR_LOG(MASTER_LOG, "Illegal HW Write%i %08x", sizeof(T)*8, _Address);_dbg_assert_(MEMMAP, 0);} +void HW_Default_Write(const T _Data, const u32 _Address){ ERROR_LOG(MASTER_LOG, "Illegal HW Write%lu %08x", sizeof(T)*8, _Address);_dbg_assert_(MEMMAP, 0);} template -void HW_Default_Read(T _Data, const u32 _Address){ ERROR_LOG(MASTER_LOG, "Illegal HW Read%i %08x", sizeof(T)*8, _Address); _dbg_assert_(MEMMAP, 0);} +void HW_Default_Read(T _Data, const u32 _Address){ ERROR_LOG(MASTER_LOG, "Illegal HW Read%lu %08x", sizeof(T)*8, _Address); _dbg_assert_(MEMMAP, 0);} #define PAGE_SHIFT 10 #define PAGE_SIZE (1 << PAGE_SHIFT) @@ -623,7 +623,7 @@ u8 *GetPointer(const u32 _Address) case 0xCC: case 0xCD: - _dbg_assert_msg_(MEMMAP, 0, "Memory", "GetPointer from IO Bridge doesnt work"); + _dbg_assert_msg_(MEMMAP, 0, "GetPointer from IO Bridge doesnt work"); return NULL; default: if (bFakeVMEM) diff --git a/Source/Core/Core/Src/HW/MemmapFunctions.cpp b/Source/Core/Core/Src/HW/MemmapFunctions.cpp index 435fd04dc2..5173a48aba 100644 --- a/Source/Core/Core/Src/HW/MemmapFunctions.cpp +++ b/Source/Core/Core/Src/HW/MemmapFunctions.cpp @@ -229,10 +229,10 @@ inline void WriteToHardware(u32 em_address, const T data, u32 effective_address, // TODO figure out a way to send data without falling into the template trap if (em_address & 0x00400000) { CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(POKE_Z, x, y, (u32)data); - DEBUG_LOG(MEMMAP, "EFB Z Write %08x @ %i, %i", data, x, y); + DEBUG_LOG(MEMMAP, "EFB Z Write %08x @ %i, %i", (u32)data, x, y); } else { CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(POKE_COLOR, x, y,(u32)data); - DEBUG_LOG(MEMMAP, "EFB Color Write %08x @ %i, %i", data, x, y); + DEBUG_LOG(MEMMAP, "EFB Color Write %08x @ %i, %i", (u32)data, x, y); } return; } @@ -256,7 +256,7 @@ inline void WriteToHardware(u32 em_address, const T data, u32 effective_address, } else { - ERROR_LOG(MEMMAP, "hwwrite [%08x] := %08x (PC: %08x)", em_address, data, PC); + ERROR_LOG(MEMMAP, "hwwrite [%08x] := %08x (PC: %08x)", em_address, (u32)data, PC); _dbg_assert_msg_(MEMMAP,0,"Memory - Unknown HW address %08x", em_address); } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index d7fb08f5c6..599f6bda4d 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -458,7 +458,7 @@ void Update() request_queue.pop(); #if MAX_LOGLEVEL >= DEBUG_LEVEL - Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HLE, LogTypes::LDEBUG); + Dolphin_Debugger::PrintCallstack(WII_IPC_HLE, DEBUG_LEVEL); #endif } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h index 7dd451be97..b8fd7c42f7 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h @@ -162,8 +162,8 @@ protected: // Write out the IPC struct from _CommandAddress to _NumberOfCommands numbers // of 4 byte commands. void DumpCommands(u32 _CommandAddress, size_t _NumberOfCommands = 8, - LogTypes::LOG_TYPE LogType = LogTypes::WII_IPC_HLE, - LogTypes::LOG_LEVELS Verbosity = LogTypes::LDEBUG) + enum LOG_TYPE LogType = WII_IPC_HLE, + enum LOG_LEVEL Verbosity = DEBUG_LEVEL) { GENERIC_LOG(LogType, Verbosity, "CommandDump of %s", GetDeviceName().c_str()); @@ -175,8 +175,8 @@ protected: } void DumpAsync(u32 BufferVector, u32 NumberInBuffer, u32 NumberOutBuffer, - LogTypes::LOG_TYPE LogType = LogTypes::WII_IPC_HLE, - LogTypes::LOG_LEVELS Verbosity = LogTypes::LDEBUG) + enum LOG_TYPE LogType = WII_IPC_HLE, + enum LOG_LEVEL Verbosity = DEBUG_LEVEL) { GENERIC_LOG(LogType, Verbosity, "======= DumpAsync ======"); @@ -186,7 +186,7 @@ protected: u32 InBuffer = Memory::Read_U32(BufferOffset); BufferOffset += 4; u32 InBufferSize = Memory::Read_U32(BufferOffset); BufferOffset += 4; - GENERIC_LOG(LogType, LogTypes::LINFO, "%s - IOCtlV InBuffer[%i]:", + INFO_LOG(LogType, "%s - IOCtlV InBuffer[%i]:", GetDeviceName().c_str(), i); std::string Temp; @@ -197,7 +197,7 @@ protected: Temp.append(Buffer); } - GENERIC_LOG(LogType, LogTypes::LDEBUG, " Buffer: %s", Temp.c_str()); + DEBUG_LOG(LogType, " Buffer: %s", Temp.c_str()); } for (u32 i = 0; i < NumberOutBuffer; i++) @@ -205,9 +205,9 @@ protected: u32 OutBuffer = Memory::Read_U32(BufferOffset); BufferOffset += 4; u32 OutBufferSize = Memory::Read_U32(BufferOffset); BufferOffset += 4; - GENERIC_LOG(LogType, LogTypes::LINFO, "%s - IOCtlV OutBuffer[%i]:", + INFO_LOG(LogType, "%s - IOCtlV OutBuffer[%i]:", GetDeviceName().c_str(), i); - GENERIC_LOG(LogType, LogTypes::LINFO, " OutBuffer: 0x%08x (0x%x):", + INFO_LOG(LogType, " OutBuffer: 0x%08x (0x%x):", OutBuffer, OutBufferSize); #if defined(MAX_LOGLEVEL) && MAX_LOGLEVEL >= INFO_LEVEL diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index e8d492c69b..cfab8fef96 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -218,7 +218,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) else { Memory::Write_U32((u32)rNANDCOntent.GetContentSize(), _CommandAddress + 0x4); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Unable to open content %d", rNANDCOntent.GetContentSize()); + INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Unable to open content %lu", rNANDCOntent.GetContentSize()); } return true; @@ -399,7 +399,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) Memory::Write_U32((u32)m_TitleIDs.size(), Buffer.PayloadBuffer[0].m_Address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECNT: Number of Titles %i", m_TitleIDs.size()); + INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECNT: Number of Titles %lu", m_TitleIDs.size()); Memory::Write_U32(0, _CommandAddress + 0x4); @@ -751,7 +751,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) default: WARN_LOG(WII_IPC_ES, "CWII_IPC_HLE_Device_es: 0x%x", Buffer.Parameter); - DumpCommands(_CommandAddress, 8, LogTypes::WII_IPC_ES); + DumpCommands(_CommandAddress, 8, WII_IPC_ES); INFO_LOG(WII_IPC_ES, "command.Parameter: 0x%08x", Buffer.Parameter); break; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp index 2b8dbbc61a..a7a2dbc7ac 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp @@ -151,7 +151,7 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress) if ((CommandBuffer.InBuffer.size() == 1) && (CommandBuffer.PayloadBuffer.size() == 1)) { size_t numFile = FileSearch.GetFileNames().size(); - INFO_LOG(WII_IPC_FILEIO, "\t%i Files found", numFile); + INFO_LOG(WII_IPC_FILEIO, "\t%lu Files found", numFile); Memory::Write_U32((u32)numFile, CommandBuffer.PayloadBuffer[0].m_Address); } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp index bf0d83ca08..9738869867 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp @@ -188,9 +188,9 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress) } // INFO_LOG(WII_IPC_SD, "InBuffer"); -// DumpCommands(BufferIn, BufferInSize / 4, LogTypes::WII_IPC_SD); +// DumpCommands(BufferIn, BufferInSize / 4, WII_IPC_SD); // INFO_LOG(WII_IPC_SD, "OutBuffer"); -// DumpCommands(BufferOut, BufferOutSize/4, LogTypes::WII_IPC_SD); +// DumpCommands(BufferOut, BufferOutSize/4, WII_IPC_SD); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); @@ -226,7 +226,7 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtlV(u32 _CommandAddress) break; } - //DumpAsync(CommandBuffer.BufferVector, CommandBuffer.NumberInBuffer, CommandBuffer.NumberPayloadBuffer, LogTypes::WII_IPC_SD); + //DumpAsync(CommandBuffer.BufferVector, CommandBuffer.NumberInBuffer, CommandBuffer.NumberPayloadBuffer, WII_IPC_SD); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); @@ -361,7 +361,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS } else { - ERROR_LOG(WII_IPC_SD, "Read Failed - read %x, error %i, eof? %i", + ERROR_LOG(WII_IPC_SD, "Read Failed - read %lx, error %i, eof? %i", nRead, ferror(m_Card), feof(m_Card)); rwFail = 1; } @@ -396,7 +396,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS size_t nWritten = fwrite(buffer, req.bsize, req.blocks, m_Card); if (nWritten != req.blocks) { - ERROR_LOG(WII_IPC_SD, "Write Failed - wrote %x, error %i, eof? %i", + ERROR_LOG(WII_IPC_SD, "Write Failed - wrote %lx, error %i, eof? %i", nWritten, ferror(m_Card), feof(m_Card)); rwFail = 1; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h index e28a9d92d5..76819d9316 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_stm.h @@ -94,7 +94,7 @@ public: case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes) INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str()); INFO_LOG(WII_IPC_STM, " IOCTL_STM_VIDIMMING"); - //DumpCommands(BufferIn, BufferInSize / 4, LogTypes::WII_IPC_STM); + //DumpCommands(BufferIn, BufferInSize / 4, WII_IPC_STM); //Memory::Write_U32(1, BufferOut); //ReturnValue = 1; break; @@ -182,7 +182,7 @@ public: DEBUG_LOG(WII_IPC_STM, "BufferOut: 0x%08x", BufferOut); DEBUG_LOG(WII_IPC_STM, "BufferOutSize: 0x%08x", BufferOutSize); - DumpCommands(BufferIn, BufferInSize/4, LogTypes::WII_IPC_STM); + DumpCommands(BufferIn, BufferInSize/4, WII_IPC_STM); } break; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index b8ae5032e3..aebd1a9069 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -300,7 +300,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLPacket(u16 _ConnectionHandle, u } else { - DEBUG_LOG(WII_IPC_WIIMOTE, "ACL endpoint not currently valid, queueing(%i)...", m_ACLQ.size()); + DEBUG_LOG(WII_IPC_WIIMOTE, "ACL endpoint not currently valid, queueing(%lu)...", m_ACLQ.size()); m_ACLQ.push(ACLQ(_pData, _Size, _ConnectionHandle)); } } @@ -330,10 +330,10 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::AddEventToQueue(const SQueuedEvent& _e } else // push new one, pop oldest { - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queueing(%i)...", m_EventQueue.size()); + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queueing(%lu)...", m_EventQueue.size()); m_EventQueue.push(_event); const SQueuedEvent& event = m_EventQueue.front(); - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x being written from queue(%i) to %08x...", + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x being written from queue(%lu) to %08x...", ((hci_event_hdr_t*)event.m_buffer)->event, m_EventQueue.size()-1, m_HCIEndpoint.m_address); m_HCIEndpoint.FillBuffer(event.m_buffer, event.m_size); m_HCIEndpoint.SetRetVal(event.m_size); @@ -345,7 +345,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::AddEventToQueue(const SQueuedEvent& _e } else { - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queueing(%i)...", m_EventQueue.size()); + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queueing(%lu)...", m_EventQueue.size()); m_EventQueue.push(_event); } } @@ -357,7 +357,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() { // an endpoint has become available, and we have a stored response. const SQueuedEvent& event = m_EventQueue.front(); - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x being written from queue(%i) to %08x...", + DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x being written from queue(%lu) to %08x...", ((hci_event_hdr_t*)event.m_buffer)->event, m_EventQueue.size()-1, m_HCIEndpoint.m_address); m_HCIEndpoint.FillBuffer(event.m_buffer, event.m_size); m_HCIEndpoint.SetRetVal(event.m_size); @@ -373,7 +373,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() if (!m_ACLQ.empty() && m_ACLEndpoint.IsValid() && m_EventQueue.empty()) { const ACLQ& acl_data = m_ACLQ.front(); - DEBUG_LOG(WII_IPC_WIIMOTE, "ACL packet being written from queue(%i) to %08x", + DEBUG_LOG(WII_IPC_WIIMOTE, "ACL packet being written from queue(%lu) to %08x", m_ACLQ.size()-1, m_ACLEndpoint.m_address); hci_acldata_hdr_t* pHeader = (hci_acldata_hdr_t*)Memory::GetPointer(m_ACLEndpoint.m_buffer); @@ -1728,7 +1728,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandVendorSpecific_FC4F(u8* _Input, INFO_LOG(WII_IPC_WIIMOTE, "Command: CommandVendorSpecific_FC4F: (callstack WUDiRemovePatch)"); INFO_LOG(WII_IPC_WIIMOTE, "input (size 0x%x):", _Size); - Dolphin_Debugger::PrintDataBuffer(LogTypes::WII_IPC_WIIMOTE, _Input, _Size, "Data: "); + Dolphin_Debugger::PrintDataBuffer(WII_IPC_WIIMOTE, _Input, _Size, "Data: "); SendEventCommandComplete(0xFC4F, &Reply, sizeof(hci_status_rp)); } @@ -1740,7 +1740,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandVendorSpecific_FC4C(u8* _Input, INFO_LOG(WII_IPC_WIIMOTE, "Command: CommandVendorSpecific_FC4C:"); INFO_LOG(WII_IPC_WIIMOTE, "input (size 0x%x):", _Size); - Dolphin_Debugger::PrintDataBuffer(LogTypes::WII_IPC_WIIMOTE, _Input, _Size, "Data: "); + Dolphin_Debugger::PrintDataBuffer(WII_IPC_WIIMOTE, _Input, _Size, "Data: "); SendEventCommandComplete(0xFC4C, &Reply, sizeof(hci_status_rp)); } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp index 60f1f95c19..04170b70ec 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp @@ -64,7 +64,7 @@ bool CWII_IPC_HLE_Device_usb_kbd::Write(u32 _CommandAddress) { INFO_LOG(WII_IPC_STM, "Ignoring write to CWII_IPC_HLE_Device_usb_kbd"); #if defined(_DEBUG) || defined(DEBUGFAST) - DumpCommands(_CommandAddress, 10, LogTypes::WII_IPC_STM, LogTypes::LDEBUG); + DumpCommands(_CommandAddress, 10, WII_IPC_STM, DEBUG_LEVEL); #endif return true; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index e8ca0a0370..21c0b9e001 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -756,12 +756,12 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 Transact pHeader->length = (u16)(Offset - sizeof(l2cap_hdr_t)); m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); - // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), "test response: "); + // Debugger::PrintDataBuffer(WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), "test response: "); } void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) { - // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, _pData, _Size, "HandleSDP: "); + // Debugger::PrintDataBuffer(WIIMOTE, _pData, _Size, "HandleSDP: "); CBigEndianBuffer buffer(_pData); @@ -847,7 +847,7 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng // send .... m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); - //Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), "m_pHost->SendACLPacket: "); + //Debugger::PrintDataBuffer(WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), "m_pHost->SendACLPacket: "); } void CWII_IPC_HLE_WiiMote::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Branch.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Branch.cpp index 0fd810436b..0a14573b49 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Branch.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Branch.cpp @@ -127,7 +127,7 @@ void Interpreter::rfi(UGeckoInstruction _inst) void Interpreter::rfid(UGeckoInstruction _inst) { - _dbg_assert_msg_(POWERPC,0,"Instruction unimplemented (does this instruction even exist?)","rfid"); + _dbg_assert_msg_(POWERPC, 0, "rfid instruction unimplemented (does this instruction even exist?)"); m_EndBlock = true; } diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp index 4da0b0b4e3..512a17492a 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp @@ -109,7 +109,7 @@ void Interpreter::Helper_Quantize(const u32 _Addr, const double _fValue, break; default: - _dbg_assert_msg_(POWERPC,0,"PS dequantize","Unknown type to read"); + _dbg_assert_msg_(POWERPC, 0, "PS dequantize - unknown type to read"); break; } } @@ -146,7 +146,7 @@ float Interpreter::Helper_Dequantize(const u32 _Addr, const EQuantizeType _quant break; default: - _dbg_assert_msg_(POWERPC,0,"PS dequantize","Unknown type to read"); + _dbg_assert_msg_(POWERPC, 0, "PS dequantize - unknown type to read"); fResult = 0; break; } diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp index 4d2a907408..bd5a3c6db9 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/IR.cpp @@ -1325,7 +1325,7 @@ void IRBuilder::WriteToFile(u64 codeHash) { if (isImm(*inst)) { fprintf(file, " 0x%08x", GetImmValue(inst)); } else { - fprintf(file, " %10u", i - (I - inst)); + fprintf(file, " %10u", i - (unsigned int)(I - inst)); } } @@ -1335,7 +1335,7 @@ void IRBuilder::WriteToFile(u64 codeHash) { if (isImm(*inst)) { fprintf(file, " 0x%08x", GetImmValue(inst)); } else { - fprintf(file, " %10u", i - (I - inst)); + fprintf(file, " %10u", i - (unsigned int)(I - inst)); } } diff --git a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp index d6671d2240..f354ea4291 100644 --- a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp @@ -700,7 +700,7 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB *func_db) { if (iter->second.address == 4) { - WARN_LOG(HLE, "weird function"); + WARN_LOG(OSHLE, "weird function"); continue; } AnalyzeFunction2(&(iter->second)); @@ -750,8 +750,11 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB *func_db) else unniceSize /= numUnNice; - INFO_LOG(HLE, "Functions analyzed. %i leafs, %i nice, %i unnice. %i timer, %i rfi. %i are branchless leafs.",numLeafs,numNice,numUnNice,numTimer,numRFI,numStraightLeaf); - INFO_LOG(HLE, "Average size: %i (leaf), %i (nice), %i(unnice)", leafSize, niceSize, unniceSize); + INFO_LOG(OSHLE, "Functions analyzed. %i leafs, %i nice, %i unnice." + "%i timer, %i rfi. %i are branchless leafs.", numLeafs, + numNice, numUnNice, numTimer, numRFI, numStraightLeaf); + INFO_LOG(OSHLE, "Average size: %i (leaf), %i (nice), %i(unnice)", + leafSize, niceSize, unniceSize); } } // namespace diff --git a/Source/Core/Core/Src/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/Src/PowerPC/PPCSymbolDB.cpp index b22fc70425..a061f001af 100644 --- a/Source/Core/Core/Src/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCSymbolDB.cpp @@ -58,7 +58,7 @@ Symbol *PPCSymbolDB::AddFunction(u32 startAddr) u32 targetEnd = PPCAnalyst::AnalyzeFunction(startAddr, tempFunc); if (targetEnd == 0) return 0; //found a dud :( - //LOG(HLE,"Symbol found at %08x",startAddr); + //LOG(OSHLE, "Symbol found at %08x", startAddr); functions[startAddr] = tempFunc; tempFunc.type = Symbol::SYMBOL_FUNCTION; checksumToFunction[tempFunc.hash] = &(functions[startAddr]); @@ -144,7 +144,7 @@ void PPCSymbolDB::FillInCallers() } else { - //LOG(HLE,"FillInCallers tries to fill data in an unknown function 0x%08x.", FunctionAddress); + //LOG(OSHLE, "FillInCallers tries to fill data in an unknown function 0x%08x.", FunctionAddress); // TODO - analyze the function instead. } } @@ -157,7 +157,7 @@ void PPCSymbolDB::PrintCalls(u32 funcAddr) const if (iter != functions.end()) { const Symbol &f = iter->second; - INFO_LOG(HLE, "The function %s at %08x calls:", f.name.c_str(), f.address); + INFO_LOG(OSHLE, "The function %s at %08x calls:", f.name.c_str(), f.address); for (std::vector::const_iterator fiter = f.calls.begin(); fiter!=f.calls.end(); ++fiter) { XFuncMap::const_iterator n = functions.find(fiter->function); diff --git a/Source/Core/Core/Src/PowerPC/PowerPC.cpp b/Source/Core/Core/Src/PowerPC/PowerPC.cpp index adfab31dff..1deba951a4 100644 --- a/Source/Core/Core/Src/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/Src/PowerPC/PowerPC.cpp @@ -381,7 +381,7 @@ void CheckExceptions() INFO_LOG(POWERPC, "EXCEPTION_EXTERNAL_INT"); Common::AtomicAnd(ppcState.Exceptions, ~EXCEPTION_EXTERNAL_INT); - _dbg_assert_msg_(POWERPC, (SRR1 & 0x02) != 0, "GEKKO", "EXTERNAL_INT unrecoverable???"); + _dbg_assert_msg_(POWERPC, (SRR1 & 0x02) != 0, "EXTERNAL_INT unrecoverable???"); } else if (exceptions & EXCEPTION_DECREMENTER) { diff --git a/Source/Core/Core/Src/PowerPC/SignatureDB.cpp b/Source/Core/Core/Src/PowerPC/SignatureDB.cpp index c0b28efa56..6888b688f1 100644 --- a/Source/Core/Core/Src/PowerPC/SignatureDB.cpp +++ b/Source/Core/Core/Src/PowerPC/SignatureDB.cpp @@ -63,7 +63,7 @@ bool SignatureDB::Save(const char *filename) FILE *f = fopen(filename,"wb"); if (!f) { - ERROR_LOG(HLE, "Database save failed"); + ERROR_LOG(OSHLE, "Database save failed"); return false; } int fcount = (int)database.size(); @@ -78,7 +78,7 @@ bool SignatureDB::Save(const char *filename) fwrite(&temp, sizeof(temp), 1, f); } fclose(f); - INFO_LOG(HLE,"Database save successful"); + INFO_LOG(OSHLE, "Database save successful"); return true; } @@ -101,9 +101,9 @@ void SignatureDB::List() { for (FuncDB::iterator iter = database.begin(); iter != database.end(); ++iter) { - INFO_LOG(HLE,"%s : %i bytes, hash = %08x",iter->second.name.c_str(), iter->second.size, iter->first); + INFO_LOG(OSHLE, "%s : %i bytes, hash = %08x", iter->second.name.c_str(), iter->second.size, iter->first); } - INFO_LOG(HLE, "%i functions known in current database.", database.size()); + INFO_LOG(OSHLE, "%lu functions known in current database.", database.size()); } void SignatureDB::Clear() @@ -123,12 +123,12 @@ void SignatureDB::Apply(PPCSymbolDB *symbol_db) if (iter->second.size == (unsigned int)function->size) { function->name = iter->second.name; - INFO_LOG(HLE, "Found %s at %08x (size: %08x)!", iter->second.name.c_str(), function->address, function->size); + INFO_LOG(OSHLE, "Found %s at %08x (size: %08x)!", iter->second.name.c_str(), function->address, function->size); } else { function->name = iter->second.name; - ERROR_LOG(HLE, "Wrong sizzze! Found %s at %08x (size: %08x instead of %08x)!", iter->second.name.c_str(), function->address, function->size, iter->second.size); + ERROR_LOG(OSHLE, "Wrong sizzze! Found %s at %08x (size: %08x instead of %08x)!", iter->second.name.c_str(), function->address, function->size, iter->second.size); } } } diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 5dd4b3ba29..f93d1d614a 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -357,7 +357,7 @@ void LoadStateCallback(u64 userdata, int cyclesLate) buffer = new u8[sz]; int x; if ((x = (int)fread(buffer, 1, sz, f)) != (int)sz) - PanicAlert("wtf? %d %d", x, sz); + PanicAlert("wtf? %d %lu", x, sz); } fclose(f); @@ -457,7 +457,7 @@ void VerifyStateCallback(u64 userdata, int cyclesLate) buffer = new u8[sz]; int x; if ((x = (int)fread(buffer, 1, sz, f)) != (int)sz) - PanicAlert("wtf? %d %d", x, sz); + PanicAlert("wtf? %d %lu", x, sz); } fclose(f); diff --git a/Source/Core/DSPCore/Src/Jit/DSPJitCCUtil.cpp b/Source/Core/DSPCore/Src/Jit/DSPJitCCUtil.cpp index f4abd88a15..0fb91a84fb 100644 --- a/Source/Core/DSPCore/Src/Jit/DSPJitCCUtil.cpp +++ b/Source/Core/DSPCore/Src/Jit/DSPJitCCUtil.cpp @@ -1,211 +1,211 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -// Additional copyrights go to Duddie and Tratax (c) 2004 - - -// HELPER FUNCTIONS - -#include "../DSPIntUtil.h" -#include "../DSPEmitter.h" -#include "x64Emitter.h" -#include "ABI.h" -using namespace Gen; - -// In: RAX: s64 _Value, -// Clobbers RDX -void DSPEmitter::Update_SR_Register64(bool carry, bool overflow) -{ -#ifdef _M_X64 -// g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK; - AND(16, MDisp(R11, DSP_REG_SR * 2), Imm16(~SR_CMP_MASK)); - - // 0x01 - // g_dsp.r[DSP_REG_SR] |= SR_CARRY; - if (carry) - { - OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_CARRY)); - } - - // 0x02 and 0x80 - // g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW; - // g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW_STICKY; - if (overflow) - { - OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_OVERFLOW | SR_OVERFLOW_STICKY)); - } - -// // 0x04 -// if (_Value == 0) g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO; - TEST(64, R(RAX), R(RAX)); - FixupBranch notZero = J_CC(CC_NZ); - OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_ARITH_ZERO)); - SetJumpTarget(notZero); - -// // 0x08 -// if (_Value < 0) g_dsp.r[DSP_REG_SR] |= SR_SIGN; - FixupBranch greaterThanEqual = J_CC(CC_NS); - OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_SIGN)); - SetJumpTarget(greaterThanEqual); - -// // 0x10 -// if (_Value != (s32)_Value) g_dsp.r[DSP_REG_SR] |= SR_OVER_S32; - MOVSX(64, 32, RDX, R(RAX)); - CMP(64, R(RDX), R(RAX)); - FixupBranch noOverS32 = J_CC(CC_E); - OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_OVER_S32)); - SetJumpTarget(noOverS32); - -// // 0x20 - Checks if top bits of m are equal -// if (((_Value & 0xc0000000) == 0) || ((_Value & 0xc0000000) == 0xc0000000)) - AND(32, R(EAX), Imm32(0xc0000000)); - CMP(32, R(EAX), Imm32(0)); - FixupBranch zeroC = J_CC(CC_E); - CMP(32, R(EAX), Imm32(0xc0000000)); - FixupBranch cC = J_CC(CC_NE); - SetJumpTarget(zeroC); -// g_dsp.r[DSP_REG_SR] |= SR_TOP2BITS; - OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_TOP2BITS)); - SetJumpTarget(cC); -#endif -} - - -//void DSPEmitter::Update_SR_Register16(s16 _Value, bool carry, bool overflow, bool overS32) -//{ -// g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK; - -// // 0x01 -// if (carry) -// { -// g_dsp.r[DSP_REG_SR] |= SR_CARRY; -// } - -// // 0x02 and 0x80 -// if (overflow) -// { -// g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW; -// g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW_STICKY; -// } - -// // 0x04 -// if (_Value == 0) -// { -// g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO; -// } - -// // 0x08 -// if (_Value < 0) -// { -// g_dsp.r[DSP_REG_SR] |= SR_SIGN; -// } - -// // 0x10 -// if (overS32) -// { -// g_dsp.r[DSP_REG_SR] |= SR_OVER_S32; -// } - -// // 0x20 - Checks if top bits of m are equal -// if ((((u16)_Value >> 14) == 0) || (((u16)_Value >> 14) == 3)) -// { -// g_dsp.r[DSP_REG_SR] |= SR_TOP2BITS; -// } -//} - -//void DSPEmitter::Update_SR_LZ(bool value) { - -// if (value == true) -// g_dsp.r[DSP_REG_SR] |= SR_LOGIC_ZERO; -// else -// g_dsp.r[DSP_REG_SR] &= ~SR_LOGIC_ZERO; -//} - -//inline int GetMultiplyModifier() -//{ -// return (g_dsp.r[DSP_REG_SR] & SR_MUL_MODIFY)?1:2; -//} - -//inline bool isCarry() { -// return (g_dsp.r[DSP_REG_SR] & SR_CARRY) ? true : false; -//} - -//inline bool isOverflow() { -// return (g_dsp.r[DSP_REG_SR] & SR_OVERFLOW) ? true : false; -//} - -//inline bool isOverS32() { -// return (g_dsp.r[DSP_REG_SR] & SR_OVER_S32) ? true : false; -//} - -//inline bool isLess() { -// return (!(g_dsp.r[DSP_REG_SR] & SR_OVERFLOW) != !(g_dsp.r[DSP_REG_SR] & SR_SIGN)); -//} - -//inline bool isZero() { -// return (g_dsp.r[DSP_REG_SR] & SR_ARITH_ZERO) ? true : false; -//} - -//inline bool isLogicZero() { -// return (g_dsp.r[DSP_REG_SR] & SR_LOGIC_ZERO) ? true : false; -//} - -//inline bool isConditionA() { -// return (((g_dsp.r[DSP_REG_SR] & SR_OVER_S32) || (g_dsp.r[DSP_REG_SR] & SR_TOP2BITS)) && !(g_dsp.r[DSP_REG_SR] & SR_ARITH_ZERO)) ? true : false; -//} - -//see DSPCore.h for flags -//bool CheckCondition(u8 _Condition) -//{ -// switch (_Condition & 0xf) -// { -// case 0xf: // Always true. -// return true; -// case 0x0: // GE - Greater Equal -// return !isLess(); -// case 0x1: // L - Less -// return isLess(); -// case 0x2: // G - Greater -// return !isLess() && !isZero(); -// case 0x3: // LE - Less Equal -// return isLess() || isZero(); -// case 0x4: // NZ - Not Zero -// return !isZero(); -// case 0x5: // Z - Zero -// return isZero(); -// case 0x6: // NC - Not carry -// return !isCarry(); -// case 0x7: // C - Carry -// return isCarry(); -// case 0x8: // ? - Not over s32 -// return !isOverS32(); -// case 0x9: // ? - Over s32 -// return isOverS32(); -// case 0xa: // ? -// return isConditionA(); -// case 0xb: // ? -// return !isConditionA(); -// case 0xc: // LNZ - Logic Not Zero -// return !isLogicZero(); -// case 0xd: // LZ - Logic Zero -// return isLogicZero(); -// case 0xe: // 0 - Overflow -// return isOverflow(); -// default: -// return true; -// } -//} +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +// Additional copyrights go to Duddie and Tratax (c) 2004 + + +// HELPER FUNCTIONS + +#include "../DSPIntUtil.h" +#include "../DSPEmitter.h" +#include "x64Emitter.h" +#include "ABI.h" +using namespace Gen; + +// In: RAX: s64 _Value, +// Clobbers RDX +void DSPEmitter::Update_SR_Register64(bool carry, bool overflow) +{ +#ifdef _M_X64 +// g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK; + AND(16, MDisp(R11, DSP_REG_SR * 2), Imm16(~SR_CMP_MASK)); + + // 0x01 + // g_dsp.r[DSP_REG_SR] |= SR_CARRY; + if (carry) + { + OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_CARRY)); + } + + // 0x02 and 0x80 + // g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW; + // g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW_STICKY; + if (overflow) + { + OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_OVERFLOW | SR_OVERFLOW_STICKY)); + } + +// // 0x04 +// if (_Value == 0) g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO; + TEST(64, R(RAX), R(RAX)); + FixupBranch notZero = J_CC(CC_NZ); + OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_ARITH_ZERO)); + SetJumpTarget(notZero); + +// // 0x08 +// if (_Value < 0) g_dsp.r[DSP_REG_SR] |= SR_SIGN; + FixupBranch greaterThanEqual = J_CC(CC_NS); + OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_SIGN)); + SetJumpTarget(greaterThanEqual); + +// // 0x10 +// if (_Value != (s32)_Value) g_dsp.r[DSP_REG_SR] |= SR_OVER_S32; + MOVSX(64, 32, RDX, R(RAX)); + CMP(64, R(RDX), R(RAX)); + FixupBranch noOverS32 = J_CC(CC_E); + OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_OVER_S32)); + SetJumpTarget(noOverS32); + +// // 0x20 - Checks if top bits of m are equal +// if (((_Value & 0xc0000000) == 0) || ((_Value & 0xc0000000) == 0xc0000000)) + AND(32, R(EAX), Imm32(0xc0000000)); + CMP(32, R(EAX), Imm32(0)); + FixupBranch zeroC = J_CC(CC_E); + CMP(32, R(EAX), Imm32(0xc0000000)); + FixupBranch cC = J_CC(CC_NE); + SetJumpTarget(zeroC); +// g_dsp.r[DSP_REG_SR] |= SR_TOP2BITS; + OR(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_TOP2BITS)); + SetJumpTarget(cC); +#endif +} + + +//void DSPEmitter::Update_SR_Register16(s16 _Value, bool carry, bool overflow, bool overS32) +//{ +// g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK; + +// // 0x01 +// if (carry) +// { +// g_dsp.r[DSP_REG_SR] |= SR_CARRY; +// } + +// // 0x02 and 0x80 +// if (overflow) +// { +// g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW; +// g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW_STICKY; +// } + +// // 0x04 +// if (_Value == 0) +// { +// g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO; +// } + +// // 0x08 +// if (_Value < 0) +// { +// g_dsp.r[DSP_REG_SR] |= SR_SIGN; +// } + +// // 0x10 +// if (overS32) +// { +// g_dsp.r[DSP_REG_SR] |= SR_OVER_S32; +// } + +// // 0x20 - Checks if top bits of m are equal +// if ((((u16)_Value >> 14) == 0) || (((u16)_Value >> 14) == 3)) +// { +// g_dsp.r[DSP_REG_SR] |= SR_TOP2BITS; +// } +//} + +//void DSPEmitter::Update_SR_LZ(bool value) { + +// if (value == true) +// g_dsp.r[DSP_REG_SR] |= SR_LOGIC_ZERO; +// else +// g_dsp.r[DSP_REG_SR] &= ~SR_LOGIC_ZERO; +//} + +//inline int GetMultiplyModifier() +//{ +// return (g_dsp.r[DSP_REG_SR] & SR_MUL_MODIFY)?1:2; +//} + +//inline bool isCarry() { +// return (g_dsp.r[DSP_REG_SR] & SR_CARRY) ? true : false; +//} + +//inline bool isOverflow() { +// return (g_dsp.r[DSP_REG_SR] & SR_OVERFLOW) ? true : false; +//} + +//inline bool isOverS32() { +// return (g_dsp.r[DSP_REG_SR] & SR_OVER_S32) ? true : false; +//} + +//inline bool isLess() { +// return (!(g_dsp.r[DSP_REG_SR] & SR_OVERFLOW) != !(g_dsp.r[DSP_REG_SR] & SR_SIGN)); +//} + +//inline bool isZero() { +// return (g_dsp.r[DSP_REG_SR] & SR_ARITH_ZERO) ? true : false; +//} + +//inline bool isLogicZero() { +// return (g_dsp.r[DSP_REG_SR] & SR_LOGIC_ZERO) ? true : false; +//} + +//inline bool isConditionA() { +// return (((g_dsp.r[DSP_REG_SR] & SR_OVER_S32) || (g_dsp.r[DSP_REG_SR] & SR_TOP2BITS)) && !(g_dsp.r[DSP_REG_SR] & SR_ARITH_ZERO)) ? true : false; +//} + +//see DSPCore.h for flags +//bool CheckCondition(u8 _Condition) +//{ +// switch (_Condition & 0xf) +// { +// case 0xf: // Always true. +// return true; +// case 0x0: // GE - Greater Equal +// return !isLess(); +// case 0x1: // L - Less +// return isLess(); +// case 0x2: // G - Greater +// return !isLess() && !isZero(); +// case 0x3: // LE - Less Equal +// return isLess() || isZero(); +// case 0x4: // NZ - Not Zero +// return !isZero(); +// case 0x5: // Z - Zero +// return isZero(); +// case 0x6: // NC - Not carry +// return !isCarry(); +// case 0x7: // C - Carry +// return isCarry(); +// case 0x8: // ? - Not over s32 +// return !isOverS32(); +// case 0x9: // ? - Over s32 +// return isOverS32(); +// case 0xa: // ? +// return isConditionA(); +// case 0xb: // ? +// return !isConditionA(); +// case 0xc: // LNZ - Logic Not Zero +// return !isLogicZero(); +// case 0xd: // LZ - Logic Zero +// return isLogicZero(); +// case 0xe: // 0 - Overflow +// return isOverflow(); +// default: +// return true; +// } +//} diff --git a/Source/Core/DSPCore/Src/Jit/DSPJitMultiplier.cpp b/Source/Core/DSPCore/Src/Jit/DSPJitMultiplier.cpp index b54995020b..f3be50d33b 100644 --- a/Source/Core/DSPCore/Src/Jit/DSPJitMultiplier.cpp +++ b/Source/Core/DSPCore/Src/Jit/DSPJitMultiplier.cpp @@ -1,774 +1,774 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -// Additional copyrights go to Duddie and Tratax (c) 2004 - - -// Multiplier and product register control - -#include "../DSPIntUtil.h" -#include "../DSPEmitter.h" -#include "x64Emitter.h" -#include "ABI.h" -using namespace Gen; - -// Only MULX family instructions have unsigned/mixed support. -// Returns s64 in EAX -// In: RSI = u16 a, RDI = u16 b, RCX = u8 sign -void DSPEmitter::get_multiply_prod() -{ -#ifdef _M_X64 -// if ((sign == 1) && (g_dsp.r[DSP_REG_SR] & SR_MUL_UNSIGNED)) //unsigned - MOV(16, R(RDX), MDisp(R11, DSP_REG_SR * 2)); // TODO check 16bit - AND(16, R(RDX), Imm16(SR_MUL_UNSIGNED)); - TEST(16, R(RDX), R(RDX)); - FixupBranch sign3 = J_CC(CC_Z); - TEST(32, R(ECX), Imm32(1)); - FixupBranch sign1 = J_CC(CC_Z); -// prod = (u32)(a * b); - MOV(64, R(EAX), R(RDI)); - MUL(16, R(ESI)); - FixupBranch mult2 = J(); - SetJumpTarget(sign1); - TEST(32, R(ECX), Imm32(2)); - FixupBranch sign2 = J_CC(CC_Z); -// else if ((sign == 2) && (g_dsp.r[DSP_REG_SR] & SR_MUL_UNSIGNED)) //mixed -// prod = a * (s16)b; - MOVSX(64, 16, RDI, R(RDI)); - MOV(64, R(EAX), R(RDI)); - MUL(16, R(ESI)); -// else - SetJumpTarget(sign2); - SetJumpTarget(sign3); -// prod = (s16)a * (s16)b; //signed - MOV(64, R(EAX), R(RDI)); - IMUL(64, R(ESI)); - -// Conditionally multiply by 2. - SetJumpTarget(mult2); -// if ((g_dsp.r[DSP_REG_SR] & SR_MUL_MODIFY) == 0) - TEST(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_MUL_MODIFY)); - FixupBranch noMult2 = J_CC(CC_NZ); -// prod <<= 1; - SHL(64, R(EAX), Imm8(1)); - SetJumpTarget(noMult2); -// return prod; -#endif -} - -// Returns s64 in RAX -// In: RSI = s16 a, RDI = s16 b -void DSPEmitter::multiply() -{ -#ifdef _M_X64 -// prod = (s16)a * (s16)b; //signed - MOV(64, R(EAX), R(RDI)); - IMUL(64, R(ESI)); - -// Conditionally multiply by 2. -// if ((g_dsp.r[DSP_REG_SR] & SR_MUL_MODIFY) == 0) - TEST(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_MUL_MODIFY)); - FixupBranch noMult2 = J_CC(CC_NZ); -// prod <<= 1; - SHL(64, R(EAX), Imm8(1)); - SetJumpTarget(noMult2); -// return prod; -#endif -} - -// Returns s64 in RAX -// Clobbers RDX -void DSPEmitter::multiply_add() -{ -// s64 prod = dsp_get_long_prod() + dsp_get_multiply_prod(a, b, sign); - multiply(); - MOV(64, R(RDX), R(RAX)); - get_long_prod(); - ADD(64, R(RAX), R(RDX)); -// return prod; -} - -// Returns s64 in RAX -// Clobbers RDX -void DSPEmitter::multiply_sub() -{ -// s64 prod = dsp_get_long_prod() - dsp_get_multiply_prod(a, b, sign); - multiply(); - MOV(64, R(RDX), R(RAX)); - get_long_prod(); - SUB(64, R(RAX), R(RDX)); -// return prod; -} - -//inline s64 dsp_multiply_mulx(u8 axh0, u8 axh1, u16 val1, u16 val2) -//{ -// s64 result; - -// if ((axh0==0) && (axh1==0)) -// result = dsp_multiply(val1, val2, 1); // unsigned support ON if both ax?.l regs are used -// else if ((axh0==0) && (axh1==1)) -// result = dsp_multiply(val1, val2, 2); // mixed support ON (u16)axl.0 * (s16)axh.1 -// else if ((axh0==1) && (axh1==0)) -// result = dsp_multiply(val2, val1, 2); // mixed support ON (u16)axl.1 * (s16)axh.0 -// else -// result = dsp_multiply(val1, val2, 0); // unsigned support OFF if both ax?.h regs are used - -// return result; -//} - -//---- - -// CLRP -// 1000 0100 xxxx xxxx -// Clears product register $prod. -// Magic numbers taken from duddie's doc - -// 00ff_(fff0 + 0010)_0000 = 0100_0000_0000, conveniently, lower 40bits = 0 - -// It's not ok, to just zero all of them, correct values should be set because of -// direct use of prod regs by AX/AXWII (look @that part of ucode). -void DSPEmitter::clrp(const UDSPInstruction opc) -{ -#ifdef _M_X64 -// g_dsp.r[DSP_REG_PRODL] = 0x0000; - MOV(64, R(R11), ImmPtr(&g_dsp.r)); - MOV(16, MDisp(R11, DSP_REG_PRODL * 2), Imm16(0x0000)); -// g_dsp.r[DSP_REG_PRODM] = 0xfff0; - MOV(16, MDisp(R11, DSP_REG_PRODM * 2), Imm16(0xfff0)); -// g_dsp.r[DSP_REG_PRODH] = 0x00ff; - MOV(16, MDisp(R11, DSP_REG_PRODH * 2), Imm16(0x00ff)); -// g_dsp.r[DSP_REG_PRODM2] = 0x0010; - MOV(16, MDisp(R11, DSP_REG_PRODM2 * 2), Imm16(0x0010)); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::clrp, opc); -#endif -} - -// TSTPROD -// 1000 0101 xxxx xxxx -// Test prod regs value. - -// flags out: --xx xx0x -void DSPEmitter::tstprod(const UDSPInstruction opc) -{ -#ifdef _M_X64 -// s64 prod = dsp_get_long_prod(); - get_long_prod(); -// Update_SR_Register64(prod); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::tstprod, opc); -#endif -} - -//---- - -// MOVP $acD -// 0110 111d xxxx xxxx -// Moves multiply product from $prod register to accumulator $acD register. - -// flags out: --xx xx0x -void DSPEmitter::movp(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 dreg = (opc >> 8) & 0x1; - -// s64 acc = dsp_get_long_prod(); - get_long_prod(); -// dsp_set_long_acc(dreg, acc); - set_long_acc(dreg); -// Update_SR_Register64(acc); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::movp, opc); -#endif -} - -// MOVNP $acD -// 0111 111d xxxx xxxx -// Moves negative of multiply product from $prod register to accumulator -// $acD register. - -// flags out: --xx xx0x -void DSPEmitter::movnp(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 dreg = (opc >> 8) & 0x1; - -// s64 acc = -dsp_get_long_prod(); - get_long_prod(); - NEG(64, R(EAX)); -// dsp_set_long_acc(dreg, acc); - set_long_acc(dreg); -// Update_SR_Register64(acc); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::movnp, opc); -#endif -} - -// MOVPZ $acD -// 1111 111d xxxx xxxx -// Moves multiply product from $prod register to accumulator $acD -// register and sets (rounds) $acD.l to 0 - -// flags out: --xx xx0x -void DSPEmitter::movpz(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 dreg = (opc >> 8) & 0x01; - -// s64 acc = dsp_get_long_prod_round_prodl(); - get_long_prod_round_prodl(); -// dsp_set_long_acc(dreg, acc); - set_long_acc(dreg); -// Update_SR_Register64(acc); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::movpz, opc); -#endif -} - -// ADDPAXZ $acD, $axS -// 1111 10sd xxxx xxxx -// Adds secondary accumulator $axS to product register and stores result -// in accumulator register. Low 16-bits of $acD ($acD.l) are set (round) to 0. - -// flags out: --xx xx0x -//void DSPEmitter::addpaxz(const UDSPInstruction opc) -//{ -// u8 dreg = (opc >> 8) & 0x1; -// u8 sreg = (opc >> 9) & 0x1; - -// s64 oldprod = dsp_get_long_prod(); -// s64 prod = dsp_get_long_prod_round_prodl(); -// s64 ax = dsp_get_long_acx(sreg); -// s64 res = prod + (ax & ~0xffff); - -// zeroWriteBackLog(); - -// dsp_set_long_acc(dreg, res); -// res = dsp_get_long_acc(dreg); -// Update_SR_Register64(res, isCarry(oldprod, res), false); -//} - -//---- - -// MULAXH -// 1000 0011 xxxx xxxx -// Multiply $ax0.h by $ax0.h -void DSPEmitter::mulaxh(const UDSPInstruction opc) -{ -#ifdef _M_X64 -// s64 prod = dsp_multiply(dsp_get_ax_h(0), dsp_get_ax_h(0)); - MOV(64, R(R11), ImmPtr(&g_dsp.r)); - MOVSX(64, 16, RSI, MDisp(R11, DSP_REG_AXH0 * 2)); - MOV(64, R(RDI), R(RSI)); - multiply(); -// dsp_set_long_prod(prod); - set_long_prod(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulaxh, opc); -#endif -} - -//---- - -// MUL $axS.l, $axS.h -// 1001 s000 xxxx xxxx -// Multiply low part $axS.l of secondary accumulator $axS by high part -// $axS.h of secondary accumulator $axS (treat them both as signed). -void DSPEmitter::mul(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 sreg = (opc >> 11) & 0x1; - -// u16 axl = dsp_get_ax_l(sreg); - MOV(64, R(R11), ImmPtr(&g_dsp.r)); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(sreg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); -// s64 prod = dsp_multiply(axh, axl); - multiply(); -// dsp_set_long_prod(prod); - set_long_prod(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mul, opc); -#endif -} - -// MULAC $axS.l, $axS.h, $acR -// 1001 s10r xxxx xxxx -// Add product register to accumulator register $acR. Multiply low part -// $axS.l of secondary accumulator $axS by high part $axS.h of secondary -// accumulator $axS (treat them both as signed). - -// flags out: --xx xx0x -void DSPEmitter::mulac(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 rreg = (opc >> 8) & 0x1; - u8 sreg = (opc >> 11) & 0x1; - -// s64 acc = dsp_get_long_acc(rreg) + dsp_get_long_prod(); - get_long_acc(rreg); - MOV(64, R(RDX), R(RAX)); - get_long_prod(); - ADD(64, R(RAX), R(RDX)); - PUSH(64, R(RAX)); -// u16 axl = dsp_get_ax_l(sreg); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(sreg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); -// s64 prod = dsp_multiply(axl, axh); - multiply(); -// dsp_set_long_prod(prod); - set_long_prod(); -// dsp_set_long_acc(rreg, acc); - POP(64, R(RAX)); - set_long_acc(rreg); -// Update_SR_Register64(dsp_get_long_acc(rreg)); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulac, opc); -#endif -} - -// MULMV $axS.l, $axS.h, $acR -// 1001 s11r xxxx xxxx -// Move product register to accumulator register $acR. Multiply low part -// $axS.l of secondary accumulator $axS by high part $axS.h of secondary -// accumulator $axS (treat them both as signed). - -// flags out: --xx xx0x -void DSPEmitter::mulmv(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 rreg = (opc >> 8) & 0x1; - -// s64 acc = dsp_get_long_prod(); - get_long_prod(); - PUSH(64, R(RAX)); - mul(opc); -// dsp_set_long_acc(rreg, acc); - POP(64, R(RAX)); - set_long_acc(rreg); -// Update_SR_Register64(dsp_get_long_acc(rreg)); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulmv, opc); -#endif -} - -// MULMVZ $axS.l, $axS.h, $acR -// 1001 s01r xxxx xxxx -// Move product register to accumulator register $acR and clear (round) low part -// of accumulator register $acR.l. Multiply low part $axS.l of secondary -// accumulator $axS by high part $axS.h of secondary accumulator $axS (treat -// them both as signed). - -// flags out: --xx xx0x -void DSPEmitter::mulmvz(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 rreg = (opc >> 8) & 0x1; - -// s64 acc = dsp_get_long_prod_round_prodl(); - get_long_prod_round_prodl(); - PUSH(64, R(RAX)); - mul(opc); -// dsp_set_long_acc(rreg, acc); - POP(64, R(RAX)); - set_long_acc(rreg); -// Update_SR_Register64(dsp_get_long_acc(rreg)); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulmvz, opc); -#endif -} - -//---- - -// MULX $ax0.S, $ax1.T -// 101s t000 xxxx xxxx -// Multiply one part $ax0 by one part $ax1. -// Part is selected by S and T bits. Zero selects low part, one selects high part. -//void DSPEmitter::mulx(const UDSPInstruction opc) -//{ -// u8 treg = ((opc >> 11) & 0x1); -// u8 sreg = ((opc >> 12) & 0x1); - -// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); -// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); -// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); - -// zeroWriteBackLog(); - -// dsp_set_long_prod(prod); -//} - -// MULXAC $ax0.S, $ax1.T, $acR -// 101s t01r xxxx xxxx -// Add product register to accumulator register $acR. Multiply one part -// $ax0 by one part $ax1. Part is selected by S and -// T bits. Zero selects low part, one selects high part. - -// flags out: --xx xx0x -//void DSPEmitter::mulxac(const UDSPInstruction opc) -//{ -// u8 rreg = (opc >> 8) & 0x1; -// u8 treg = (opc >> 11) & 0x1; -// u8 sreg = (opc >> 12) & 0x1; - -// s64 acc = dsp_get_long_acc(rreg) + dsp_get_long_prod(); -// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); -// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); -// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); -// -// zeroWriteBackLog(); - -// dsp_set_long_prod(prod); -// dsp_set_long_acc(rreg, acc); -// Update_SR_Register64(dsp_get_long_acc(rreg)); -//} - -// MULXMV $ax0.S, $ax1.T, $acR -// 101s t11r xxxx xxxx -// Move product register to accumulator register $acR. Multiply one part -// $ax0 by one part $ax1. Part is selected by S and -// T bits. Zero selects low part, one selects high part. - -// flags out: --xx xx0x -//void DSPEmitter::mulxmv(const UDSPInstruction opc) -//{ -// u8 rreg = ((opc >> 8) & 0x1); -// u8 treg = (opc >> 11) & 0x1; -// u8 sreg = (opc >> 12) & 0x1; - -// s64 acc = dsp_get_long_prod(); -// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); -// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); -// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); - -// zeroWriteBackLog(); - -// dsp_set_long_prod(prod); -// dsp_set_long_acc(rreg, acc); -// Update_SR_Register64(dsp_get_long_acc(rreg)); -//} - -// MULXMV $ax0.S, $ax1.T, $acR -// 101s t01r xxxx xxxx -// Move product register to accumulator register $acR and clear (round) low part -// of accumulator register $acR.l. Multiply one part $ax0 by one part $ax1 -// Part is selected by S and T bits. Zero selects low part, -// one selects high part. - -// flags out: --xx xx0x -//void DSPEmitter::mulxmvz(const UDSPInstruction opc) -//{ -// u8 rreg = (opc >> 8) & 0x1; -// u8 treg = (opc >> 11) & 0x1; -// u8 sreg = (opc >> 12) & 0x1; - -// s64 acc = dsp_get_long_prod_round_prodl(); -// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); -// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); -// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); - -// zeroWriteBackLog(); - -// dsp_set_long_prod(prod); -// dsp_set_long_acc(rreg, acc); -// Update_SR_Register64(dsp_get_long_acc(rreg)); -//} - -//---- - -// MULC $acS.m, $axT.h -// 110s t000 xxxx xxxx -// Multiply mid part of accumulator register $acS.m by high part $axS.h of -// secondary accumulator $axS (treat them both as signed). -void DSPEmitter::mulc(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 treg = (opc >> 11) & 0x1; - u8 sreg = (opc >> 12) & 0x1; - -// u16 accm = dsp_get_acc_m(sreg); - MOV(64, R(R11), ImmPtr(&g_dsp.r)); - MOVSX(64, 16, ESI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(treg); - MOVSX(64, 16, EDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); -// s64 prod = dsp_multiply(accm, axh); - multiply(); -// dsp_set_long_prod(prod); - set_long_prod(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulc, opc); -#endif -} - -// MULCAC $acS.m, $axT.h, $acR -// 110s t10r xxxx xxxx -// Multiply mid part of accumulator register $acS.m by high part $axS.h of -// secondary accumulator $axS (treat them both as signed). Add product -// register before multiplication to accumulator $acR. - -// flags out: --xx xx0x -void DSPEmitter::mulcac(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 rreg = (opc >> 8) & 0x1; - u8 treg = (opc >> 11) & 0x1; - u8 sreg = (opc >> 12) & 0x1; - -// s64 acc = dsp_get_long_acc(rreg) + dsp_get_long_prod(); - get_long_acc(rreg); - MOV(64, R(RDX), R(RAX)); - get_long_prod(); - ADD(64, R(RAX), R(RDX)); - PUSH(64, R(RAX)); -// u16 accm = dsp_get_acc_m(sreg); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(treg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); -// s64 prod = dsp_multiply(accm, axh); - multiply(); -// dsp_set_long_prod(prod); - set_long_prod(); -// dsp_set_long_acc(rreg, acc); - POP(64, R(RAX)); - set_long_acc(rreg); -// Update_SR_Register64(dsp_get_long_acc(rreg)); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulcac, opc); -#endif -} - -// MULCMV $acS.m, $axT.h, $acR -// 110s t11r xxxx xxxx -// Multiply mid part of accumulator register $acS.m by high part $axT.h of -// secondary accumulator $axT (treat them both as signed). Move product -// register before multiplication to accumulator $acR. -// possible mistake in duddie's doc axT.h rather than axS.h - -// flags out: --xx xx0x -void DSPEmitter::mulcmv(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 rreg = (opc >> 8) & 0x1; - u8 treg = (opc >> 11) & 0x1; - u8 sreg = (opc >> 12) & 0x1; - -// s64 acc = dsp_get_long_prod(); - get_long_prod(); - PUSH(64, R(RAX)); -// u16 accm = dsp_get_acc_m(sreg); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(treg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); -// s64 prod = dsp_multiply(accm, axh); - multiply(); -// dsp_set_long_prod(prod); - set_long_prod(); -// dsp_set_long_acc(rreg, acc); - POP(64, R(RAX)); - set_long_acc(rreg); -// Update_SR_Register64(dsp_get_long_acc(rreg)); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulcmv, opc); -#endif -} - -// MULCMVZ $acS.m, $axT.h, $acR -// 110s t01r xxxx xxxx -// (fixed possible bug in duddie's description, s->t) -// Multiply mid part of accumulator register $acS.m by high part $axT.h of -// secondary accumulator $axT (treat them both as signed). Move product -// register before multiplication to accumulator $acR, set (round) low part of -// accumulator $acR.l to zero. - -// flags out: --xx xx0x -void DSPEmitter::mulcmvz(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 rreg = (opc >> 8) & 0x1; - u8 treg = (opc >> 11) & 0x1; - u8 sreg = (opc >> 12) & 0x1; - - MOV(64, R(R11), ImmPtr(&g_dsp.r)); -// s64 acc = dsp_get_long_prod_round_prodl(); - get_long_prod_round_prodl(); - PUSH(64, R(RAX)); -// u16 accm = dsp_get_acc_m(sreg); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(treg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); -// s64 prod = dsp_multiply(accm, axh); - multiply(); -// dsp_set_long_prod(prod); - set_long_prod(); -// dsp_set_long_acc(rreg, acc); - POP(64, R(RAX)); - set_long_acc(rreg); -// Update_SR_Register64(dsp_get_long_acc(rreg)); - Update_SR_Register64(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::mulcmvz, opc); -#endif -} - -//---- - -// MADDX ax0.S ax1.T -// 1110 00st xxxx xxxx -// Multiply one part of secondary accumulator $ax0 (selected by S) by -// one part of secondary accumulator $ax1 (selected by T) (treat them both as -// signed) and add result to product register. -//void DSPEmitter::maddx(const UDSPInstruction opc) -//{ -// u8 treg = (opc >> 8) & 0x1; -// u8 sreg = (opc >> 9) & 0x1; - -// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); -// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); -// s64 prod = dsp_multiply_add(val1, val2); -// -// zeroWriteBackLog(); - -// dsp_set_long_prod(prod); -//} - -// MSUBX $(0x18+S*2), $(0x19+T*2) -// 1110 01st xxxx xxxx -// Multiply one part of secondary accumulator $ax0 (selected by S) by -// one part of secondary accumulator $ax1 (selected by T) (treat them both as -// signed) and subtract result from product register. -//void DSPEmitter::msubx(const UDSPInstruction opc) -//{ -// u8 treg = (opc >> 8) & 0x1; -// u8 sreg = (opc >> 9) & 0x1; - -// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); -// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); -// s64 prod = dsp_multiply_sub(val1, val2); - -// zeroWriteBackLog(); - -// dsp_set_long_prod(prod); -//} - -// MADDC $acS.m, $axT.h -// 1110 10st xxxx xxxx -// Multiply middle part of accumulator $acS.m by high part of secondary -// accumulator $axT.h (treat them both as signed) and add result to product -// register. -void DSPEmitter::maddc(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 treg = (opc >> 8) & 0x1; - u8 sreg = (opc >> 9) & 0x1; - - MOV(64, R(R11), ImmPtr(&g_dsp.r)); -// u16 accm = dsp_get_acc_m(sreg); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(treg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); -// s64 prod = dsp_multiply_add(accm, axh); - multiply_add(); -// dsp_set_long_prod(prod); - set_long_prod(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::maddc, opc); -#endif -} - -// MSUBC $acS.m, $axT.h -// 1110 11st xxxx xxxx -// Multiply middle part of accumulator $acS.m by high part of secondary -// accumulator $axT.h (treat them both as signed) and subtract result from -// product register. -void DSPEmitter::msubc(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 treg = (opc >> 8) & 0x1; - u8 sreg = (opc >> 9) & 0x1; -// -// u16 accm = dsp_get_acc_m(sreg); - MOV(64, R(R11), ImmPtr(&g_dsp.r)); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(treg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); -// s64 prod = dsp_multiply_sub(accm, axh); - multiply_sub(); -// dsp_set_long_prod(prod); - set_long_prod(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::msubc, opc); -#endif -} - -// MADD $axS.l, $axS.h -// 1111 001s xxxx xxxx -// Multiply low part $axS.l of secondary accumulator $axS by high part -// $axS.h of secondary accumulator $axS (treat them both as signed) and add -// result to product register. -void DSPEmitter::madd(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 sreg = (opc >> 8) & 0x1; - - MOV(64, R(R11), ImmPtr(&g_dsp.r)); -// u16 axl = dsp_get_ax_l(sreg); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(sreg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); -// s64 prod = dsp_multiply_add(axl, axh); - multiply_add(); -// dsp_set_long_prod(prod); - set_long_prod(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::madd, opc); -#endif -} - -// MSUB $axS.l, $axS.h -// 1111 011s xxxx xxxx -// Multiply low part $axS.l of secondary accumulator $axS by high part -// $axS.h of secondary accumulator $axS (treat them both as signed) and -// subtract result from product register. -void DSPEmitter::msub(const UDSPInstruction opc) -{ -#ifdef _M_X64 - u8 sreg = (opc >> 8) & 0x1; -// -// u16 axl = dsp_get_ax_l(sreg); - MOV(64, R(R11), ImmPtr(&g_dsp.r)); - MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); -// u16 axh = dsp_get_ax_h(sreg); - MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); -// s64 prod = dsp_multiply_sub(axl, axh); - multiply_sub(); -// dsp_set_long_prod(prod); - set_long_prod(); -#else - ABI_CallFunctionC((void *)&DSPInterpreter::msub, opc); -#endif -} +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +// Additional copyrights go to Duddie and Tratax (c) 2004 + + +// Multiplier and product register control + +#include "../DSPIntUtil.h" +#include "../DSPEmitter.h" +#include "x64Emitter.h" +#include "ABI.h" +using namespace Gen; + +// Only MULX family instructions have unsigned/mixed support. +// Returns s64 in EAX +// In: RSI = u16 a, RDI = u16 b, RCX = u8 sign +void DSPEmitter::get_multiply_prod() +{ +#ifdef _M_X64 +// if ((sign == 1) && (g_dsp.r[DSP_REG_SR] & SR_MUL_UNSIGNED)) //unsigned + MOV(16, R(RDX), MDisp(R11, DSP_REG_SR * 2)); // TODO check 16bit + AND(16, R(RDX), Imm16(SR_MUL_UNSIGNED)); + TEST(16, R(RDX), R(RDX)); + FixupBranch sign3 = J_CC(CC_Z); + TEST(32, R(ECX), Imm32(1)); + FixupBranch sign1 = J_CC(CC_Z); +// prod = (u32)(a * b); + MOV(64, R(EAX), R(RDI)); + MUL(16, R(ESI)); + FixupBranch mult2 = J(); + SetJumpTarget(sign1); + TEST(32, R(ECX), Imm32(2)); + FixupBranch sign2 = J_CC(CC_Z); +// else if ((sign == 2) && (g_dsp.r[DSP_REG_SR] & SR_MUL_UNSIGNED)) //mixed +// prod = a * (s16)b; + MOVSX(64, 16, RDI, R(RDI)); + MOV(64, R(EAX), R(RDI)); + MUL(16, R(ESI)); +// else + SetJumpTarget(sign2); + SetJumpTarget(sign3); +// prod = (s16)a * (s16)b; //signed + MOV(64, R(EAX), R(RDI)); + IMUL(64, R(ESI)); + +// Conditionally multiply by 2. + SetJumpTarget(mult2); +// if ((g_dsp.r[DSP_REG_SR] & SR_MUL_MODIFY) == 0) + TEST(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_MUL_MODIFY)); + FixupBranch noMult2 = J_CC(CC_NZ); +// prod <<= 1; + SHL(64, R(EAX), Imm8(1)); + SetJumpTarget(noMult2); +// return prod; +#endif +} + +// Returns s64 in RAX +// In: RSI = s16 a, RDI = s16 b +void DSPEmitter::multiply() +{ +#ifdef _M_X64 +// prod = (s16)a * (s16)b; //signed + MOV(64, R(EAX), R(RDI)); + IMUL(64, R(ESI)); + +// Conditionally multiply by 2. +// if ((g_dsp.r[DSP_REG_SR] & SR_MUL_MODIFY) == 0) + TEST(16, MDisp(R11, DSP_REG_SR * 2), Imm16(SR_MUL_MODIFY)); + FixupBranch noMult2 = J_CC(CC_NZ); +// prod <<= 1; + SHL(64, R(EAX), Imm8(1)); + SetJumpTarget(noMult2); +// return prod; +#endif +} + +// Returns s64 in RAX +// Clobbers RDX +void DSPEmitter::multiply_add() +{ +// s64 prod = dsp_get_long_prod() + dsp_get_multiply_prod(a, b, sign); + multiply(); + MOV(64, R(RDX), R(RAX)); + get_long_prod(); + ADD(64, R(RAX), R(RDX)); +// return prod; +} + +// Returns s64 in RAX +// Clobbers RDX +void DSPEmitter::multiply_sub() +{ +// s64 prod = dsp_get_long_prod() - dsp_get_multiply_prod(a, b, sign); + multiply(); + MOV(64, R(RDX), R(RAX)); + get_long_prod(); + SUB(64, R(RAX), R(RDX)); +// return prod; +} + +//inline s64 dsp_multiply_mulx(u8 axh0, u8 axh1, u16 val1, u16 val2) +//{ +// s64 result; + +// if ((axh0==0) && (axh1==0)) +// result = dsp_multiply(val1, val2, 1); // unsigned support ON if both ax?.l regs are used +// else if ((axh0==0) && (axh1==1)) +// result = dsp_multiply(val1, val2, 2); // mixed support ON (u16)axl.0 * (s16)axh.1 +// else if ((axh0==1) && (axh1==0)) +// result = dsp_multiply(val2, val1, 2); // mixed support ON (u16)axl.1 * (s16)axh.0 +// else +// result = dsp_multiply(val1, val2, 0); // unsigned support OFF if both ax?.h regs are used + +// return result; +//} + +//---- + +// CLRP +// 1000 0100 xxxx xxxx +// Clears product register $prod. +// Magic numbers taken from duddie's doc + +// 00ff_(fff0 + 0010)_0000 = 0100_0000_0000, conveniently, lower 40bits = 0 + +// It's not ok, to just zero all of them, correct values should be set because of +// direct use of prod regs by AX/AXWII (look @that part of ucode). +void DSPEmitter::clrp(const UDSPInstruction opc) +{ +#ifdef _M_X64 +// g_dsp.r[DSP_REG_PRODL] = 0x0000; + MOV(64, R(R11), ImmPtr(&g_dsp.r)); + MOV(16, MDisp(R11, DSP_REG_PRODL * 2), Imm16(0x0000)); +// g_dsp.r[DSP_REG_PRODM] = 0xfff0; + MOV(16, MDisp(R11, DSP_REG_PRODM * 2), Imm16(0xfff0)); +// g_dsp.r[DSP_REG_PRODH] = 0x00ff; + MOV(16, MDisp(R11, DSP_REG_PRODH * 2), Imm16(0x00ff)); +// g_dsp.r[DSP_REG_PRODM2] = 0x0010; + MOV(16, MDisp(R11, DSP_REG_PRODM2 * 2), Imm16(0x0010)); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::clrp, opc); +#endif +} + +// TSTPROD +// 1000 0101 xxxx xxxx +// Test prod regs value. + +// flags out: --xx xx0x +void DSPEmitter::tstprod(const UDSPInstruction opc) +{ +#ifdef _M_X64 +// s64 prod = dsp_get_long_prod(); + get_long_prod(); +// Update_SR_Register64(prod); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::tstprod, opc); +#endif +} + +//---- + +// MOVP $acD +// 0110 111d xxxx xxxx +// Moves multiply product from $prod register to accumulator $acD register. + +// flags out: --xx xx0x +void DSPEmitter::movp(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 dreg = (opc >> 8) & 0x1; + +// s64 acc = dsp_get_long_prod(); + get_long_prod(); +// dsp_set_long_acc(dreg, acc); + set_long_acc(dreg); +// Update_SR_Register64(acc); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::movp, opc); +#endif +} + +// MOVNP $acD +// 0111 111d xxxx xxxx +// Moves negative of multiply product from $prod register to accumulator +// $acD register. + +// flags out: --xx xx0x +void DSPEmitter::movnp(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 dreg = (opc >> 8) & 0x1; + +// s64 acc = -dsp_get_long_prod(); + get_long_prod(); + NEG(64, R(EAX)); +// dsp_set_long_acc(dreg, acc); + set_long_acc(dreg); +// Update_SR_Register64(acc); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::movnp, opc); +#endif +} + +// MOVPZ $acD +// 1111 111d xxxx xxxx +// Moves multiply product from $prod register to accumulator $acD +// register and sets (rounds) $acD.l to 0 + +// flags out: --xx xx0x +void DSPEmitter::movpz(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 dreg = (opc >> 8) & 0x01; + +// s64 acc = dsp_get_long_prod_round_prodl(); + get_long_prod_round_prodl(); +// dsp_set_long_acc(dreg, acc); + set_long_acc(dreg); +// Update_SR_Register64(acc); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::movpz, opc); +#endif +} + +// ADDPAXZ $acD, $axS +// 1111 10sd xxxx xxxx +// Adds secondary accumulator $axS to product register and stores result +// in accumulator register. Low 16-bits of $acD ($acD.l) are set (round) to 0. + +// flags out: --xx xx0x +//void DSPEmitter::addpaxz(const UDSPInstruction opc) +//{ +// u8 dreg = (opc >> 8) & 0x1; +// u8 sreg = (opc >> 9) & 0x1; + +// s64 oldprod = dsp_get_long_prod(); +// s64 prod = dsp_get_long_prod_round_prodl(); +// s64 ax = dsp_get_long_acx(sreg); +// s64 res = prod + (ax & ~0xffff); + +// zeroWriteBackLog(); + +// dsp_set_long_acc(dreg, res); +// res = dsp_get_long_acc(dreg); +// Update_SR_Register64(res, isCarry(oldprod, res), false); +//} + +//---- + +// MULAXH +// 1000 0011 xxxx xxxx +// Multiply $ax0.h by $ax0.h +void DSPEmitter::mulaxh(const UDSPInstruction opc) +{ +#ifdef _M_X64 +// s64 prod = dsp_multiply(dsp_get_ax_h(0), dsp_get_ax_h(0)); + MOV(64, R(R11), ImmPtr(&g_dsp.r)); + MOVSX(64, 16, RSI, MDisp(R11, DSP_REG_AXH0 * 2)); + MOV(64, R(RDI), R(RSI)); + multiply(); +// dsp_set_long_prod(prod); + set_long_prod(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulaxh, opc); +#endif +} + +//---- + +// MUL $axS.l, $axS.h +// 1001 s000 xxxx xxxx +// Multiply low part $axS.l of secondary accumulator $axS by high part +// $axS.h of secondary accumulator $axS (treat them both as signed). +void DSPEmitter::mul(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 sreg = (opc >> 11) & 0x1; + +// u16 axl = dsp_get_ax_l(sreg); + MOV(64, R(R11), ImmPtr(&g_dsp.r)); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(sreg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); +// s64 prod = dsp_multiply(axh, axl); + multiply(); +// dsp_set_long_prod(prod); + set_long_prod(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mul, opc); +#endif +} + +// MULAC $axS.l, $axS.h, $acR +// 1001 s10r xxxx xxxx +// Add product register to accumulator register $acR. Multiply low part +// $axS.l of secondary accumulator $axS by high part $axS.h of secondary +// accumulator $axS (treat them both as signed). + +// flags out: --xx xx0x +void DSPEmitter::mulac(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 rreg = (opc >> 8) & 0x1; + u8 sreg = (opc >> 11) & 0x1; + +// s64 acc = dsp_get_long_acc(rreg) + dsp_get_long_prod(); + get_long_acc(rreg); + MOV(64, R(RDX), R(RAX)); + get_long_prod(); + ADD(64, R(RAX), R(RDX)); + PUSH(64, R(RAX)); +// u16 axl = dsp_get_ax_l(sreg); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(sreg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); +// s64 prod = dsp_multiply(axl, axh); + multiply(); +// dsp_set_long_prod(prod); + set_long_prod(); +// dsp_set_long_acc(rreg, acc); + POP(64, R(RAX)); + set_long_acc(rreg); +// Update_SR_Register64(dsp_get_long_acc(rreg)); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulac, opc); +#endif +} + +// MULMV $axS.l, $axS.h, $acR +// 1001 s11r xxxx xxxx +// Move product register to accumulator register $acR. Multiply low part +// $axS.l of secondary accumulator $axS by high part $axS.h of secondary +// accumulator $axS (treat them both as signed). + +// flags out: --xx xx0x +void DSPEmitter::mulmv(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 rreg = (opc >> 8) & 0x1; + +// s64 acc = dsp_get_long_prod(); + get_long_prod(); + PUSH(64, R(RAX)); + mul(opc); +// dsp_set_long_acc(rreg, acc); + POP(64, R(RAX)); + set_long_acc(rreg); +// Update_SR_Register64(dsp_get_long_acc(rreg)); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulmv, opc); +#endif +} + +// MULMVZ $axS.l, $axS.h, $acR +// 1001 s01r xxxx xxxx +// Move product register to accumulator register $acR and clear (round) low part +// of accumulator register $acR.l. Multiply low part $axS.l of secondary +// accumulator $axS by high part $axS.h of secondary accumulator $axS (treat +// them both as signed). + +// flags out: --xx xx0x +void DSPEmitter::mulmvz(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 rreg = (opc >> 8) & 0x1; + +// s64 acc = dsp_get_long_prod_round_prodl(); + get_long_prod_round_prodl(); + PUSH(64, R(RAX)); + mul(opc); +// dsp_set_long_acc(rreg, acc); + POP(64, R(RAX)); + set_long_acc(rreg); +// Update_SR_Register64(dsp_get_long_acc(rreg)); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulmvz, opc); +#endif +} + +//---- + +// MULX $ax0.S, $ax1.T +// 101s t000 xxxx xxxx +// Multiply one part $ax0 by one part $ax1. +// Part is selected by S and T bits. Zero selects low part, one selects high part. +//void DSPEmitter::mulx(const UDSPInstruction opc) +//{ +// u8 treg = ((opc >> 11) & 0x1); +// u8 sreg = ((opc >> 12) & 0x1); + +// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); +// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); +// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); + +// zeroWriteBackLog(); + +// dsp_set_long_prod(prod); +//} + +// MULXAC $ax0.S, $ax1.T, $acR +// 101s t01r xxxx xxxx +// Add product register to accumulator register $acR. Multiply one part +// $ax0 by one part $ax1. Part is selected by S and +// T bits. Zero selects low part, one selects high part. + +// flags out: --xx xx0x +//void DSPEmitter::mulxac(const UDSPInstruction opc) +//{ +// u8 rreg = (opc >> 8) & 0x1; +// u8 treg = (opc >> 11) & 0x1; +// u8 sreg = (opc >> 12) & 0x1; + +// s64 acc = dsp_get_long_acc(rreg) + dsp_get_long_prod(); +// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); +// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); +// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); +// +// zeroWriteBackLog(); + +// dsp_set_long_prod(prod); +// dsp_set_long_acc(rreg, acc); +// Update_SR_Register64(dsp_get_long_acc(rreg)); +//} + +// MULXMV $ax0.S, $ax1.T, $acR +// 101s t11r xxxx xxxx +// Move product register to accumulator register $acR. Multiply one part +// $ax0 by one part $ax1. Part is selected by S and +// T bits. Zero selects low part, one selects high part. + +// flags out: --xx xx0x +//void DSPEmitter::mulxmv(const UDSPInstruction opc) +//{ +// u8 rreg = ((opc >> 8) & 0x1); +// u8 treg = (opc >> 11) & 0x1; +// u8 sreg = (opc >> 12) & 0x1; + +// s64 acc = dsp_get_long_prod(); +// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); +// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); +// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); + +// zeroWriteBackLog(); + +// dsp_set_long_prod(prod); +// dsp_set_long_acc(rreg, acc); +// Update_SR_Register64(dsp_get_long_acc(rreg)); +//} + +// MULXMV $ax0.S, $ax1.T, $acR +// 101s t01r xxxx xxxx +// Move product register to accumulator register $acR and clear (round) low part +// of accumulator register $acR.l. Multiply one part $ax0 by one part $ax1 +// Part is selected by S and T bits. Zero selects low part, +// one selects high part. + +// flags out: --xx xx0x +//void DSPEmitter::mulxmvz(const UDSPInstruction opc) +//{ +// u8 rreg = (opc >> 8) & 0x1; +// u8 treg = (opc >> 11) & 0x1; +// u8 sreg = (opc >> 12) & 0x1; + +// s64 acc = dsp_get_long_prod_round_prodl(); +// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); +// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); +// s64 prod = dsp_multiply_mulx(sreg, treg, val1, val2); + +// zeroWriteBackLog(); + +// dsp_set_long_prod(prod); +// dsp_set_long_acc(rreg, acc); +// Update_SR_Register64(dsp_get_long_acc(rreg)); +//} + +//---- + +// MULC $acS.m, $axT.h +// 110s t000 xxxx xxxx +// Multiply mid part of accumulator register $acS.m by high part $axS.h of +// secondary accumulator $axS (treat them both as signed). +void DSPEmitter::mulc(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 treg = (opc >> 11) & 0x1; + u8 sreg = (opc >> 12) & 0x1; + +// u16 accm = dsp_get_acc_m(sreg); + MOV(64, R(R11), ImmPtr(&g_dsp.r)); + MOVSX(64, 16, ESI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(treg); + MOVSX(64, 16, EDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); +// s64 prod = dsp_multiply(accm, axh); + multiply(); +// dsp_set_long_prod(prod); + set_long_prod(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulc, opc); +#endif +} + +// MULCAC $acS.m, $axT.h, $acR +// 110s t10r xxxx xxxx +// Multiply mid part of accumulator register $acS.m by high part $axS.h of +// secondary accumulator $axS (treat them both as signed). Add product +// register before multiplication to accumulator $acR. + +// flags out: --xx xx0x +void DSPEmitter::mulcac(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 rreg = (opc >> 8) & 0x1; + u8 treg = (opc >> 11) & 0x1; + u8 sreg = (opc >> 12) & 0x1; + +// s64 acc = dsp_get_long_acc(rreg) + dsp_get_long_prod(); + get_long_acc(rreg); + MOV(64, R(RDX), R(RAX)); + get_long_prod(); + ADD(64, R(RAX), R(RDX)); + PUSH(64, R(RAX)); +// u16 accm = dsp_get_acc_m(sreg); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(treg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); +// s64 prod = dsp_multiply(accm, axh); + multiply(); +// dsp_set_long_prod(prod); + set_long_prod(); +// dsp_set_long_acc(rreg, acc); + POP(64, R(RAX)); + set_long_acc(rreg); +// Update_SR_Register64(dsp_get_long_acc(rreg)); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulcac, opc); +#endif +} + +// MULCMV $acS.m, $axT.h, $acR +// 110s t11r xxxx xxxx +// Multiply mid part of accumulator register $acS.m by high part $axT.h of +// secondary accumulator $axT (treat them both as signed). Move product +// register before multiplication to accumulator $acR. +// possible mistake in duddie's doc axT.h rather than axS.h + +// flags out: --xx xx0x +void DSPEmitter::mulcmv(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 rreg = (opc >> 8) & 0x1; + u8 treg = (opc >> 11) & 0x1; + u8 sreg = (opc >> 12) & 0x1; + +// s64 acc = dsp_get_long_prod(); + get_long_prod(); + PUSH(64, R(RAX)); +// u16 accm = dsp_get_acc_m(sreg); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(treg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); +// s64 prod = dsp_multiply(accm, axh); + multiply(); +// dsp_set_long_prod(prod); + set_long_prod(); +// dsp_set_long_acc(rreg, acc); + POP(64, R(RAX)); + set_long_acc(rreg); +// Update_SR_Register64(dsp_get_long_acc(rreg)); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulcmv, opc); +#endif +} + +// MULCMVZ $acS.m, $axT.h, $acR +// 110s t01r xxxx xxxx +// (fixed possible bug in duddie's description, s->t) +// Multiply mid part of accumulator register $acS.m by high part $axT.h of +// secondary accumulator $axT (treat them both as signed). Move product +// register before multiplication to accumulator $acR, set (round) low part of +// accumulator $acR.l to zero. + +// flags out: --xx xx0x +void DSPEmitter::mulcmvz(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 rreg = (opc >> 8) & 0x1; + u8 treg = (opc >> 11) & 0x1; + u8 sreg = (opc >> 12) & 0x1; + + MOV(64, R(R11), ImmPtr(&g_dsp.r)); +// s64 acc = dsp_get_long_prod_round_prodl(); + get_long_prod_round_prodl(); + PUSH(64, R(RAX)); +// u16 accm = dsp_get_acc_m(sreg); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(treg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); +// s64 prod = dsp_multiply(accm, axh); + multiply(); +// dsp_set_long_prod(prod); + set_long_prod(); +// dsp_set_long_acc(rreg, acc); + POP(64, R(RAX)); + set_long_acc(rreg); +// Update_SR_Register64(dsp_get_long_acc(rreg)); + Update_SR_Register64(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::mulcmvz, opc); +#endif +} + +//---- + +// MADDX ax0.S ax1.T +// 1110 00st xxxx xxxx +// Multiply one part of secondary accumulator $ax0 (selected by S) by +// one part of secondary accumulator $ax1 (selected by T) (treat them both as +// signed) and add result to product register. +//void DSPEmitter::maddx(const UDSPInstruction opc) +//{ +// u8 treg = (opc >> 8) & 0x1; +// u8 sreg = (opc >> 9) & 0x1; + +// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); +// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); +// s64 prod = dsp_multiply_add(val1, val2); +// +// zeroWriteBackLog(); + +// dsp_set_long_prod(prod); +//} + +// MSUBX $(0x18+S*2), $(0x19+T*2) +// 1110 01st xxxx xxxx +// Multiply one part of secondary accumulator $ax0 (selected by S) by +// one part of secondary accumulator $ax1 (selected by T) (treat them both as +// signed) and subtract result from product register. +//void DSPEmitter::msubx(const UDSPInstruction opc) +//{ +// u8 treg = (opc >> 8) & 0x1; +// u8 sreg = (opc >> 9) & 0x1; + +// u16 val1 = (sreg == 0) ? dsp_get_ax_l(0) : dsp_get_ax_h(0); +// u16 val2 = (treg == 0) ? dsp_get_ax_l(1) : dsp_get_ax_h(1); +// s64 prod = dsp_multiply_sub(val1, val2); + +// zeroWriteBackLog(); + +// dsp_set_long_prod(prod); +//} + +// MADDC $acS.m, $axT.h +// 1110 10st xxxx xxxx +// Multiply middle part of accumulator $acS.m by high part of secondary +// accumulator $axT.h (treat them both as signed) and add result to product +// register. +void DSPEmitter::maddc(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 treg = (opc >> 8) & 0x1; + u8 sreg = (opc >> 9) & 0x1; + + MOV(64, R(R11), ImmPtr(&g_dsp.r)); +// u16 accm = dsp_get_acc_m(sreg); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(treg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); +// s64 prod = dsp_multiply_add(accm, axh); + multiply_add(); +// dsp_set_long_prod(prod); + set_long_prod(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::maddc, opc); +#endif +} + +// MSUBC $acS.m, $axT.h +// 1110 11st xxxx xxxx +// Multiply middle part of accumulator $acS.m by high part of secondary +// accumulator $axT.h (treat them both as signed) and subtract result from +// product register. +void DSPEmitter::msubc(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 treg = (opc >> 8) & 0x1; + u8 sreg = (opc >> 9) & 0x1; +// +// u16 accm = dsp_get_acc_m(sreg); + MOV(64, R(R11), ImmPtr(&g_dsp.r)); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_ACM0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(treg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + treg) * 2)); +// s64 prod = dsp_multiply_sub(accm, axh); + multiply_sub(); +// dsp_set_long_prod(prod); + set_long_prod(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::msubc, opc); +#endif +} + +// MADD $axS.l, $axS.h +// 1111 001s xxxx xxxx +// Multiply low part $axS.l of secondary accumulator $axS by high part +// $axS.h of secondary accumulator $axS (treat them both as signed) and add +// result to product register. +void DSPEmitter::madd(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 sreg = (opc >> 8) & 0x1; + + MOV(64, R(R11), ImmPtr(&g_dsp.r)); +// u16 axl = dsp_get_ax_l(sreg); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(sreg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); +// s64 prod = dsp_multiply_add(axl, axh); + multiply_add(); +// dsp_set_long_prod(prod); + set_long_prod(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::madd, opc); +#endif +} + +// MSUB $axS.l, $axS.h +// 1111 011s xxxx xxxx +// Multiply low part $axS.l of secondary accumulator $axS by high part +// $axS.h of secondary accumulator $axS (treat them both as signed) and +// subtract result from product register. +void DSPEmitter::msub(const UDSPInstruction opc) +{ +#ifdef _M_X64 + u8 sreg = (opc >> 8) & 0x1; +// +// u16 axl = dsp_get_ax_l(sreg); + MOV(64, R(R11), ImmPtr(&g_dsp.r)); + MOVSX(64, 16, RSI, MDisp(R11, (DSP_REG_AXL0 + sreg) * 2)); +// u16 axh = dsp_get_ax_h(sreg); + MOVSX(64, 16, RDI, MDisp(R11, (DSP_REG_AXH0 + sreg) * 2)); +// s64 prod = dsp_multiply_sub(axl, axh); + multiply_sub(); +// dsp_set_long_prod(prod); + set_long_prod(); +#else + ABI_CallFunctionC((void *)&DSPInterpreter::msub, opc); +#endif +} diff --git a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp index 54c681c43a..d8b8917795 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp @@ -44,7 +44,7 @@ CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem) else m_IsValid = true; } } - else WARN_LOG(DISCIO, "Invalid opening.bnr size: %0x", FileSize); + else WARN_LOG(DISCIO, "Invalid opening.bnr size: %0lx", FileSize); } diff --git a/Source/Core/DiscIO/Src/FileMonitor.cpp b/Source/Core/DiscIO/Src/FileMonitor.cpp index 1b3ccb0be8..dc51d4d3a6 100644 --- a/Source/Core/DiscIO/Src/FileMonitor.cpp +++ b/Source/Core/DiscIO/Src/FileMonitor.cpp @@ -98,7 +98,7 @@ void ReadGC(std::string FileName) void CheckFile(std::string File, u64 Size) { // Don't do anything if the log is unselected - if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON)) return; + if (!LogManager::GetInstance()->isEnable(FILEMON)) return; // Do nothing if we found the same file again if (CurrentFile == File) return; @@ -124,7 +124,7 @@ void FindFilename(u64 offset) // Don't do anything if a game is not running if (Core::GetState() != Core::CORE_RUN) return; // Or if the log is unselected - if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON)) return; + if (!LogManager::GetInstance()->isEnable(FILEMON)) return; if (!FileAccess) return; if (!pFileSystem || ISOFile != SConfig::GetInstance().m_LastFilename) diff --git a/Source/Core/DolphinWX/Src/GeckoCodeDiag.cpp b/Source/Core/DolphinWX/Src/GeckoCodeDiag.cpp index e276d31131..b75bef8524 100644 --- a/Source/Core/DolphinWX/Src/GeckoCodeDiag.cpp +++ b/Source/Core/DolphinWX/Src/GeckoCodeDiag.cpp @@ -240,7 +240,7 @@ void CodeConfigPanel::DownloadCodes(wxCommandEvent&) if (gcodes.size()) { - PanicAlert("Downloaded %i codes.", gcodes.size()); + PanicAlert("Downloaded %lu codes.", gcodes.size()); // append the codes to the code list std::vector::const_iterator diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index acbbd23095..52ad8b542e 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -55,8 +55,8 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos, #endif { m_LogManager = LogManager::GetInstance(); - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) - m_LogManager->addListener((LogTypes::LOG_TYPE)i, this); + for (int i = 0; i < NUMBER_OF_LOGS; ++i) + m_LogManager->addListener(i, this); m_fileLog = m_LogManager->getFileListener(); m_console = m_LogManager->getConsoleListener(); @@ -151,9 +151,9 @@ void CLogWindow::CreateGUIControls() CLogWindow::~CLogWindow() { - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { - m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this); + m_LogManager->removeListener(i, this); } m_LogTimer->Stop(); delete m_LogTimer; @@ -193,8 +193,8 @@ void CLogWindow::SaveSettings() ini.Set("Options", "WriteToFile", m_writeFile); ini.Set("Options", "WriteToConsole", m_writeConsole); ini.Set("Options", "WriteToWindow", m_writeWindow); - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) - ini.Set("Logs", m_LogManager->getShortName((LogTypes::LOG_TYPE)i), m_checks->IsChecked(i)); + for (int i = 0; i < NUMBER_OF_LOGS; ++i) + ini.Set("Logs", m_LogManager->getShortName(i), m_checks->IsChecked(i)); ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX)); } @@ -222,26 +222,26 @@ void CLogWindow::LoadSettings() m_writeConsoleCB->SetValue(m_writeConsole); ini.Get("Options", "WriteToWindow", &m_writeWindow, true); m_writeWindowCB->SetValue(m_writeWindow); - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { bool enable; - ini.Get("Logs", m_LogManager->getShortName((LogTypes::LOG_TYPE)i), &enable, true); + ini.Get("Logs", m_LogManager->getShortName(i), &enable, true); if (m_writeWindow && enable) - m_LogManager->addListener((LogTypes::LOG_TYPE)i, this); + m_LogManager->addListener(i, this); else - m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this); + m_LogManager->removeListener(i, this); if (m_writeFile && enable) - m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog); + m_LogManager->addListener(i, m_fileLog); else - m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); + m_LogManager->removeListener(i, m_fileLog); if (m_writeConsole && enable) - m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_console); + m_LogManager->addListener(i, m_console); else - m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_console); - m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity)); + m_LogManager->removeListener(i, m_console); + m_LogManager->setLogLevel(i, (enum LOG_LEVEL)verbosity); } UpdateChecks(); } @@ -270,7 +270,7 @@ void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event)) void CLogWindow::OnToggleAll(wxCommandEvent& WXUNUSED (event)) { static bool enableAll = false; - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { ToggleLog(i, enableAll); } @@ -289,20 +289,20 @@ void CLogWindow::UpdateChecks() // if you don't do it (at least the win version) m_checks->Freeze(); - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + for (int i = 0; i < NUMBER_OF_LOGS; i++) { - m_checks->Append(wxString::FromAscii(m_LogManager->getFullName( (LogTypes::LOG_TYPE)i ))); + m_checks->Append(wxString::FromAscii(m_LogManager->getFullName(i))); } m_checks->Thaw(); } m_checks->Freeze(); - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + for (int i = 0; i < NUMBER_OF_LOGS; i++) { m_checks->Check(i, - m_LogManager->isListener((LogTypes::LOG_TYPE)i, this) || - m_LogManager->isListener((LogTypes::LOG_TYPE)i, m_console) || - m_LogManager->isListener((LogTypes::LOG_TYPE)i, m_fileLog)); + m_LogManager->isListener(i, this) || + m_LogManager->isListener(i, m_console) || + m_LogManager->isListener(i, m_fileLog)); } m_checks->Thaw(); } @@ -324,7 +324,7 @@ void CLogWindow::PopulateRight() wxTextCtrl* CLogWindow::CreateTextCtrl(wxPanel* parent, wxWindowID id, long Style) { wxTextCtrl* TC = new wxTextCtrl(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, Style); - TC->SetBackgroundColour(*wxBLACK); + TC->SetBackgroundColour(*wxLIGHT_GREY); if (m_FontChoice) { if (m_FontChoice->GetSelection() < (int)LogFont.size()) @@ -344,9 +344,9 @@ void CLogWindow::OnOptionsCheck(wxCommandEvent& event) { // get selection int v = m_verbosity->GetSelection() + 1; - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + for (int i = 0; i < NUMBER_OF_LOGS; i++) { - m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)v); + m_LogManager->setLogLevel(i, (enum LOG_LEVEL)v); } } break; @@ -385,43 +385,43 @@ void CLogWindow::OnOptionsCheck(wxCommandEvent& event) break; case IDM_WRITEFILE: - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { m_writeFile = event.IsChecked(); if (m_checks->IsChecked(i)) { if (m_writeFile) - m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog); + m_LogManager->addListener(i, m_fileLog); else - m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); + m_LogManager->removeListener(i, m_fileLog); } } break; case IDM_WRITEWINDOW: - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { m_writeWindow = event.IsChecked(); if (m_checks->IsChecked(i)) { if (m_writeWindow) - m_LogManager->addListener((LogTypes::LOG_TYPE)i, this); + m_LogManager->addListener(i, this); else - m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this); + m_LogManager->removeListener(i, this); } } break; case IDM_WRITECONSOLE: - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + for (int i = 0; i < NUMBER_OF_LOGS; ++i) { m_writeConsole = event.IsChecked(); if (m_checks->IsChecked(i)) { if (m_writeConsole) - m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_console); + m_LogManager->addListener(i, m_console); else - m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_console); + m_LogManager->removeListener(i, m_console); } } break; @@ -440,7 +440,7 @@ void CLogWindow::OnLogCheck(wxCommandEvent& event) void CLogWindow::ToggleLog(int _logType, bool enable) { - LogTypes::LOG_TYPE logType = (LogTypes::LOG_TYPE)_logType; + enum LOG_TYPE logType = (enum LOG_TYPE)_logType; m_checks->Check(_logType, enable); @@ -489,7 +489,7 @@ void CLogWindow::UpdateLog() { switch (msgQueue.front().first) { - // red + // red case ERROR_LEVEL: m_Log->SetDefaultStyle(wxTextAttr(*wxRED)); break; @@ -528,7 +528,7 @@ void CLogWindow::UpdateLog() m_LogTimer->Start(UPDATETIME); } -void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text) +void CLogWindow::Log(enum LOG_LEVEL level, const char *text) { m_LogSection.Enter(); if (msgQueue.size() >= 100) diff --git a/Source/Core/DolphinWX/Src/LogWindow.h b/Source/Core/DolphinWX/Src/LogWindow.h index 68c2f4d439..b5ac1621ca 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.h +++ b/Source/Core/DolphinWX/Src/LogWindow.h @@ -60,7 +60,7 @@ public: void SaveSettings(); void LoadSettings(); - void Log(LogTypes::LOG_LEVELS, const char *text); + void Log(enum LOG_LEVEL level, const char *text); int x, y, winpos; diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index c85ed91787..fb4275929c 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -197,7 +197,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) } - _assert_msg_(COMMANDPROCESSOR, _fifo.CPReadWriteDistance - distToSend >= 0 , + _assert_msg_(COMMANDPROCESSOR, (s32)_fifo.CPReadWriteDistance - distToSend >= 0 , "Negative fifo.CPReadWriteDistance = %i in FIFO Loop !\nThat can produce inestabilty in the game. Please report it.", _fifo.CPReadWriteDistance - distToSend); Common::AtomicStore(_fifo.CPReadPointer, readPtr); diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index bd3e4611ba..9854f560a5 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -58,7 +58,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode) for (int i = 0; i < 8; i += 2) ((u8*)&uid->values[1])[i / 2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf) << 4); - u32 enableZTexture = (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc || g_ActiveConfig.bEnablePerPixelDepth)? 1 : 0; + u32 enableZTexture = (bpmem.ztex2.op != (ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc) || g_ActiveConfig.bEnablePerPixelDepth)? 1 : 0; uid->values[2] = (u32)bpmem.fog.c_proj_fsel.fsel | ((u32)bpmem.fog.c_proj_fsel.proj << 3) | @@ -466,7 +466,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt; } } - DepthTextureEnable = bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc || g_ActiveConfig.bEnablePerPixelDepth ; + DepthTextureEnable = bpmem.ztex2.op != (ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc) || g_ActiveConfig.bEnablePerPixelDepth ; // Declare samplers if(ApiType != API_D3D11) diff --git a/Source/Core/VideoUICommon/VideoUICommon.vcproj b/Source/Core/VideoUICommon/VideoUICommon.vcproj index 7eeecede0e..266705ee39 100644 --- a/Source/Core/VideoUICommon/VideoUICommon.vcproj +++ b/Source/Core/VideoUICommon/VideoUICommon.vcproj @@ -1,426 +1,426 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp index aceaf0ec58..c37c4435d7 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp @@ -1,143 +1,143 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#include "VideoConfigDialog.h" - -#include "FileUtil.h" - -#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s) - -// template instantiation -template class BoolSetting; - -template <> -SettingCheckBox::BoolSetting(wxWindow* parent, const wxString& label, bool &setting, bool reverse, long style) : - wxCheckBox(parent, -1, label, wxDefaultPosition, wxDefaultSize, style), - m_setting(setting), - m_reverse(reverse) -{ - SetValue(m_setting ^ m_reverse); - _connect_macro_(this, SettingCheckBox::UpdateValue, wxEVT_COMMAND_CHECKBOX_CLICKED, this); -} - -template -IntegerSetting::IntegerSetting(wxWindow* parent, const wxString& label, T& setting, int minVal, int maxVal, long style) : - wxSpinCtrl(parent, -1, label, wxDefaultPosition, wxDefaultSize, style), - m_setting(setting) -{ - SetRange(minVal, maxVal); - SetValue(m_setting); - _connect_macro_(this, IntegerSetting::UpdateValue, wxEVT_COMMAND_SPINCTRL_UPDATED, this); -} - - -VideoConfigDialog::VideoConfigDialog(wxWindow* parent, const std::string& title, const std::string& _ininame) : - wxDialog(parent, -1, - wxString(wxT("Dolphin ")).append(wxString::FromAscii(title.c_str())).append(wxT(" Graphics Configuration")), - wxDefaultPosition, wxDefaultSize), - vconfig(g_Config), - ininame(_ininame) -{ - vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); - - wxNotebook* const notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize); - - // -- GENERAL -- - { - wxPanel* const page_general= new wxPanel(notebook, -1, wxDefaultPosition); - notebook->AddPage(page_general, wxT("General")); - wxBoxSizer* const szr_general = new wxBoxSizer(wxVERTICAL); - - // - rendering - { - wxStaticBoxSizer* const group_rendering = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Rendering")); - szr_general->Add(group_rendering, 0, wxEXPAND | wxALL, 5); - wxGridSizer* const szr_rendering = new wxGridSizer(2, 5, 5); - group_rendering->Add(szr_rendering, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - - szr_rendering->Add(new SettingCheckBox(page_general, wxT("Hardware rasterization"), vconfig.bHwRasterizer)); - } - - // - info - { - wxStaticBoxSizer* const group_info = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Overlay Information")); - szr_general->Add(group_info, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - wxGridSizer* const szr_info = new wxGridSizer(2, 5, 5); - group_info->Add(szr_info, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - - szr_info->Add(new SettingCheckBox(page_general, wxT("Various Statistics"), vconfig.bShowStats)); - } - - // - utility - { - wxStaticBoxSizer* const group_utility = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Utility")); - szr_general->Add(group_utility, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5); - group_utility->Add(szr_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - - szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Textures"), vconfig.bDumpTextures)); - szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Objects"), vconfig.bDumpObjects)); - szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Frames"), vconfig.bDumpFrames)); - - // - debug only - wxStaticBoxSizer* const group_debug_only_utility = new wxStaticBoxSizer(wxHORIZONTAL, page_general, wxT("Debug Only")); - group_utility->Add(group_debug_only_utility, 0, wxEXPAND | wxBOTTOM, 5); - wxGridSizer* const szr_debug_only_utility = new wxGridSizer(2, 5, 5); - group_debug_only_utility->Add(szr_debug_only_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - - szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump TEV Stages"), vconfig.bDumpTevStages)); - szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump Texture Fetches"), vconfig.bDumpTevTextureFetches)); - } - - // - misc - { - wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Drawn Object Range")); - szr_general->Add(group_misc, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - wxFlexGridSizer* const szr_misc = new wxFlexGridSizer(2, 5, 5); - group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); - - szr_misc->Add(new U32Setting(page_general, wxT("Start"), vconfig.drawStart, 0, 100000)); - szr_misc->Add(new U32Setting(page_general, wxT("End"), vconfig.drawEnd, 0, 100000)); - } - - page_general->SetSizerAndFit(szr_general); - } - - wxButton* const btn_close = new wxButton(this, -1, wxT("Close"), wxDefaultPosition); - _connect_macro_(btn_close, VideoConfigDialog::Event_ClickClose, wxEVT_COMMAND_BUTTON_CLICKED, this); - - Connect(-1, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VideoConfigDialog::Event_Close), (wxObject*)0, this); - - wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL); - szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5); - szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5); - - SetSizerAndFit(szr_main); - Center(); -} - -void VideoConfigDialog::Event_ClickClose(wxCommandEvent&) -{ - Close(); -} - -void VideoConfigDialog::Event_Close(wxCloseEvent& ev) -{ - g_Config.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); - - ev.Skip(); -} +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "VideoConfigDialog.h" + +#include "FileUtil.h" + +#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s) + +// template instantiation +template class BoolSetting; + +template <> +SettingCheckBox::BoolSetting(wxWindow* parent, const wxString& label, bool &setting, bool reverse, long style) : + wxCheckBox(parent, -1, label, wxDefaultPosition, wxDefaultSize, style), + m_setting(setting), + m_reverse(reverse) +{ + SetValue(m_setting ^ m_reverse); + _connect_macro_(this, SettingCheckBox::UpdateValue, wxEVT_COMMAND_CHECKBOX_CLICKED, this); +} + +template +IntegerSetting::IntegerSetting(wxWindow* parent, const wxString& label, T& setting, int minVal, int maxVal, long style) : + wxSpinCtrl(parent, -1, label, wxDefaultPosition, wxDefaultSize, style), + m_setting(setting) +{ + SetRange(minVal, maxVal); + SetValue(m_setting); + _connect_macro_(this, IntegerSetting::UpdateValue, wxEVT_COMMAND_SPINCTRL_UPDATED, this); +} + + +VideoConfigDialog::VideoConfigDialog(wxWindow* parent, const std::string& title, const std::string& _ininame) : + wxDialog(parent, -1, + wxString(wxT("Dolphin ")).append(wxString::FromAscii(title.c_str())).append(wxT(" Graphics Configuration")), + wxDefaultPosition, wxDefaultSize), + vconfig(g_Config), + ininame(_ininame) +{ + vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); + + wxNotebook* const notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize); + + // -- GENERAL -- + { + wxPanel* const page_general= new wxPanel(notebook, -1, wxDefaultPosition); + notebook->AddPage(page_general, wxT("General")); + wxBoxSizer* const szr_general = new wxBoxSizer(wxVERTICAL); + + // - rendering + { + wxStaticBoxSizer* const group_rendering = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Rendering")); + szr_general->Add(group_rendering, 0, wxEXPAND | wxALL, 5); + wxGridSizer* const szr_rendering = new wxGridSizer(2, 5, 5); + group_rendering->Add(szr_rendering, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_rendering->Add(new SettingCheckBox(page_general, wxT("Hardware rasterization"), vconfig.bHwRasterizer)); + } + + // - info + { + wxStaticBoxSizer* const group_info = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Overlay Information")); + szr_general->Add(group_info, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxGridSizer* const szr_info = new wxGridSizer(2, 5, 5); + group_info->Add(szr_info, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_info->Add(new SettingCheckBox(page_general, wxT("Various Statistics"), vconfig.bShowStats)); + } + + // - utility + { + wxStaticBoxSizer* const group_utility = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Utility")); + szr_general->Add(group_utility, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5); + group_utility->Add(szr_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Textures"), vconfig.bDumpTextures)); + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Objects"), vconfig.bDumpObjects)); + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Frames"), vconfig.bDumpFrames)); + + // - debug only + wxStaticBoxSizer* const group_debug_only_utility = new wxStaticBoxSizer(wxHORIZONTAL, page_general, wxT("Debug Only")); + group_utility->Add(group_debug_only_utility, 0, wxEXPAND | wxBOTTOM, 5); + wxGridSizer* const szr_debug_only_utility = new wxGridSizer(2, 5, 5); + group_debug_only_utility->Add(szr_debug_only_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump TEV Stages"), vconfig.bDumpTevStages)); + szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump Texture Fetches"), vconfig.bDumpTevTextureFetches)); + } + + // - misc + { + wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Drawn Object Range")); + szr_general->Add(group_misc, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxFlexGridSizer* const szr_misc = new wxFlexGridSizer(2, 5, 5); + group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_misc->Add(new U32Setting(page_general, wxT("Start"), vconfig.drawStart, 0, 100000)); + szr_misc->Add(new U32Setting(page_general, wxT("End"), vconfig.drawEnd, 0, 100000)); + } + + page_general->SetSizerAndFit(szr_general); + } + + wxButton* const btn_close = new wxButton(this, -1, wxT("Close"), wxDefaultPosition); + _connect_macro_(btn_close, VideoConfigDialog::Event_ClickClose, wxEVT_COMMAND_BUTTON_CLICKED, this); + + Connect(-1, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VideoConfigDialog::Event_Close), (wxObject*)0, this); + + wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL); + szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5); + szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5); + + SetSizerAndFit(szr_main); + Center(); +} + +void VideoConfigDialog::Event_ClickClose(wxCommandEvent&) +{ + Close(); +} + +void VideoConfigDialog::Event_Close(wxCloseEvent& ev) +{ + g_Config.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); + + ev.Skip(); +} diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h index 4611cd7cf9..513550b2cf 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h @@ -1,83 +1,83 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#ifndef _PLUGIN_VIDEOSOFTWARE_CONFIG_DIAG_H_ -#define _PLUGIN_VIDEOSOFTWARE_CONFIG_DIAG_H_ - -#include -#include - -#include "VideoConfig.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -template -class BoolSetting : public W -{ -public: - BoolSetting(wxWindow* parent, const wxString& label, bool &setting, bool reverse = false, long style = 0); - - void UpdateValue(wxCommandEvent& ev) - { - m_setting = (ev.GetInt() != 0) ^ m_reverse; - ev.Skip(); - } -private: - bool& m_setting; - const bool m_reverse; -}; - -template -class IntegerSetting : public wxSpinCtrl -{ -public: - IntegerSetting(wxWindow* parent, const wxString& label, T& setting, int minVal, int maxVal, long style = 0); - - void UpdateValue(wxCommandEvent& ev) - { - m_setting = ev.GetInt(); - ev.Skip(); - } -private: - T& m_setting; -}; - -typedef BoolSetting SettingCheckBox; -typedef IntegerSetting U32Setting; - -class VideoConfigDialog : public wxDialog -{ -public: - VideoConfigDialog(wxWindow* parent, const std::string &title, const std::string& ininame); - -protected: - void Event_ClickClose(wxCommandEvent&); - void Event_Close(wxCloseEvent&); - - VideoConfig& vconfig; - std::string ininame; -}; - -#endif +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _PLUGIN_VIDEOSOFTWARE_CONFIG_DIAG_H_ +#define _PLUGIN_VIDEOSOFTWARE_CONFIG_DIAG_H_ + +#include +#include + +#include "VideoConfig.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +class BoolSetting : public W +{ +public: + BoolSetting(wxWindow* parent, const wxString& label, bool &setting, bool reverse = false, long style = 0); + + void UpdateValue(wxCommandEvent& ev) + { + m_setting = (ev.GetInt() != 0) ^ m_reverse; + ev.Skip(); + } +private: + bool& m_setting; + const bool m_reverse; +}; + +template +class IntegerSetting : public wxSpinCtrl +{ +public: + IntegerSetting(wxWindow* parent, const wxString& label, T& setting, int minVal, int maxVal, long style = 0); + + void UpdateValue(wxCommandEvent& ev) + { + m_setting = ev.GetInt(); + ev.Skip(); + } +private: + T& m_setting; +}; + +typedef BoolSetting SettingCheckBox; +typedef IntegerSetting U32Setting; + +class VideoConfigDialog : public wxDialog +{ +public: + VideoConfigDialog(wxWindow* parent, const std::string &title, const std::string& ininame); + +protected: + void Event_ClickClose(wxCommandEvent&); + void Event_Close(wxCloseEvent&); + + VideoConfig& vconfig; + std::string ininame; +}; + +#endif