diff --git a/src/DebugDump.cpp b/src/DebugDump.cpp index e0983507..05ea066c 100644 --- a/src/DebugDump.cpp +++ b/src/DebugDump.cpp @@ -35,7 +35,7 @@ BufferedLog::BufferedLog(u32 _mode) : m_mode(_mode) m_logBuffer.resize(1024*1024); m_log.rdbuf()->pubsetbuf(&m_logBuffer.front(), m_logBuffer.size()); } catch(std::bad_alloc&) { - LOG(LOG_ERROR, "Failed to alloc memory for log buffer\n"); + LOG(LOG_ERROR, "Failed to alloc memory for log buffer"); } wchar_t logPath[PLUGIN_PATH_SIZE + 16]; diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 6ff4a2c7..79cb923d 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -1115,12 +1115,12 @@ bool FrameBufferList::RdpUpdate::update(RdpUpdateResult & _result) s32 vactivelines = v_sync - (ispal ? 44 : 34); if (vactivelines > PRESCALE_HEIGHT) { - LOG(LOG_VERBOSE, "VI_V_SYNC_REG too big\n"); + LOG(LOG_VERBOSE, "VI_V_SYNC_REG too big"); return false; } if (vactivelines < 0) { - LOG(LOG_VERBOSE, "vactivelines lesser than 0\n"); + LOG(LOG_VERBOSE, "vactivelines lesser than 0"); return false; } diff --git a/src/FrameBufferInfo.cpp b/src/FrameBufferInfo.cpp index f79e3818..c12a9418 100644 --- a/src/FrameBufferInfo.cpp +++ b/src/FrameBufferInfo.cpp @@ -50,7 +50,7 @@ namespace FBInfo { void FBInfo::WriteList(FrameBufferModifyEntry *plist, u32 size) { - LOG(LOG_WARNING, "FBWList size=%u\n", size); + LOG(LOG_WARNING, "FBWList size=%u", size); } void FBInfo::Read(u32 addr) diff --git a/src/GBI.cpp b/src/GBI.cpp index 63bea12d..898d225d 100644 --- a/src/GBI.cpp +++ b/src/GBI.cpp @@ -180,7 +180,7 @@ void GBIInfo::_flushCommands() void GBIInfo::_makeCurrent(MicrocodeInfo * _pCurrent) { if (_pCurrent->type == NONE) { - LOG(LOG_ERROR, "[GLideN64]: error - unknown ucode!!!\n"); + LOG(LOG_ERROR, "[GLideN64]: error - unknown ucode!!!"); return; } @@ -369,7 +369,7 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize) current.NoN = info.NoN; current.negativeY = info.negativeY; current.fast3DPersp = info.fast3DPerspNorm; - LOG(LOG_VERBOSE, "Load microcode type: %d crc: 0x%08x romname: %s\n", current.type, uc_crc, RSP.romname); + LOG(LOG_VERBOSE, "Load microcode type: %d crc: 0x%08x romname: %s", current.type, uc_crc, RSP.romname); _makeCurrent(¤t); return; } @@ -457,7 +457,7 @@ void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize) if (type != NONE) { current.type = type; - LOG(LOG_VERBOSE, "Load microcode (%s) type: %d crc: 0x%08x romname: %s\n", uc_str, current.type, uc_crc, RSP.romname); + LOG(LOG_VERBOSE, "Load microcode (%s) type: %d crc: 0x%08x romname: %s", uc_str, current.type, uc_crc, RSP.romname); _makeCurrent(¤t); return; } diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_Utils.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_Utils.cpp index 9e91ca35..e27e4aed 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_Utils.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_Utils.cpp @@ -37,7 +37,7 @@ bool Utils::checkShaderCompileStatus(GLuint obj) GLsizei nLogSize = nShaderLogSize; glGetShaderInfoLog(obj, nShaderLogSize, &nLogSize, shader_log); shader_log[nLogSize] = 0; - LOG(LOG_ERROR, "shader_compile error: %s\n", shader_log); + LOG(LOG_ERROR, "shader_compile error: %s", shader_log); return false; } #endif @@ -53,7 +53,7 @@ bool Utils::checkProgramLinkStatus(GLuint obj) GLsizei nLogSize = nShaderLogSize; GLchar shader_log[nShaderLogSize]; glGetProgramInfoLog(obj, nShaderLogSize, &nLogSize, shader_log); - LOG(LOG_ERROR, "shader_link error: %s\n", shader_log); + LOG(LOG_ERROR, "shader_link error: %s", shader_log); return false; } #endif diff --git a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Command.cpp b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Command.cpp index 5b93abaa..31c31768 100644 --- a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Command.cpp +++ b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Command.cpp @@ -18,7 +18,7 @@ namespace opengl { auto error = ptrGetError(); if (error != GL_NO_ERROR) { std::stringstream errorString; - errorString << " OpenGL error: 0x" << std::hex << error << ", on function: " << m_functionName << std::endl; + errorString << " OpenGL error: 0x" << std::hex << error << ", on function: " << m_functionName; LOG(LOG_ERROR, errorString.str().c_str()); throw std::runtime_error(errorString.str().c_str()); } @@ -39,7 +39,7 @@ namespace opengl { #ifdef GL_DEBUG if (m_logIfSynced) { std::stringstream errorString; - errorString << " Executing synced: " << m_functionName << std::endl; + errorString << " Executing synced: " << m_functionName; LOG(LOG_ERROR, errorString.str().c_str()); } #endif diff --git a/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp b/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp index 608f3061..5330ee3a 100644 --- a/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp +++ b/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp @@ -50,7 +50,7 @@ DisplayWindow & DisplayWindow::get() void DisplayWindowMupen64plus::_setAttributes() { - LOG(LOG_VERBOSE, "[gles2GlideN64]: _setAttributes\n"); + LOG(LOG_VERBOSE, "[gles2GlideN64]: _setAttributes"); FunctionWrapper::CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_CORE); FunctionWrapper::CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3); @@ -90,11 +90,11 @@ bool DisplayWindowMupen64plus::_start() const m64p_video_flags flags = M64VIDEOFLAG_SUPPORT_RESIZING; if (FunctionWrapper::CoreVideo_SetVideoMode(m_screenWidth, m_screenHeight, 0, m_bFullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, flags) != M64ERR_SUCCESS) { //printf("(EE) Error setting videomode %dx%d\n", m_screenWidth, m_screenHeight); - LOG(LOG_ERROR, "[gles2GlideN64]: Error setting videomode %dx%d\n", m_screenWidth, m_screenHeight); + LOG(LOG_ERROR, "[gles2GlideN64]: Error setting videomode %dx%d", m_screenWidth, m_screenHeight); FunctionWrapper::CoreVideo_Quit(); return false; } - LOG(LOG_VERBOSE, "[gles2GlideN64]: Create setting videomode %dx%d\n", m_screenWidth, m_screenHeight); + LOG(LOG_VERBOSE, "[gles2GlideN64]: Create setting videomode %dx%d", m_screenWidth, m_screenHeight); char caption[128]; # ifdef _DEBUG diff --git a/src/Graphics/OpenGLContext/opengl_GLInfo.cpp b/src/Graphics/OpenGLContext/opengl_GLInfo.cpp index 8275e5e6..9f2de976 100644 --- a/src/Graphics/OpenGLContext/opengl_GLInfo.cpp +++ b/src/Graphics/OpenGLContext/opengl_GLInfo.cpp @@ -24,11 +24,11 @@ void GLInfo::init() { glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); glGetIntegerv(GL_MINOR_VERSION, &minorVersion); } - LOG(LOG_VERBOSE, "%s major version: %d\n", isGLESX ? "OpenGL ES" : "OpenGL", majorVersion); - LOG(LOG_VERBOSE, "%s minor version: %d\n", isGLESX ? "OpenGL ES" : "OpenGL", minorVersion); + LOG(LOG_VERBOSE, "%s major version: %d", isGLESX ? "OpenGL ES" : "OpenGL", majorVersion); + LOG(LOG_VERBOSE, "%s minor version: %d", isGLESX ? "OpenGL ES" : "OpenGL", minorVersion); - LOG(LOG_VERBOSE, "OpenGL vendor: %s\n", glGetString(GL_VENDOR)); + LOG(LOG_VERBOSE, "OpenGL vendor: %s", glGetString(GL_VENDOR)); const GLubyte * strRenderer = glGetString(GL_RENDERER); const GLubyte * strDriverVersion = glGetString(GL_VERSION); @@ -47,7 +47,7 @@ void GLInfo::init() { renderer = Renderer::PowerVR; else if (strstr((const char*)strRenderer, "NVIDIA Tegra") != nullptr) renderer = Renderer::Tegra; - LOG(LOG_VERBOSE, "OpenGL renderer: %s\n", strRenderer); + LOG(LOG_VERBOSE, "OpenGL renderer: %s", strRenderer); int numericVersion = majorVersion * 10 + minorVersion; if (isGLES2) { @@ -127,13 +127,13 @@ void GLInfo::init() { #ifndef OS_ANDROID if (isGLES2 && config.frameBufferEmulation.copyToRDRAM > Config::ctSync) { config.frameBufferEmulation.copyToRDRAM = Config::ctDisable; - LOG(LOG_WARNING, "Async color buffer copies are not supported on GLES2\n"); + LOG(LOG_WARNING, "Async color buffer copies are not supported on GLES2"); } #endif if (isGLES2 && config.generalEmulation.enableLOD) { if (!Utils::isExtensionSupported(*this, "GL_EXT_shader_texture_lod") || !Utils::isExtensionSupported(*this, "GL_OES_standard_derivatives")) { config.generalEmulation.enableLOD = 0; - LOG(LOG_WARNING, "LOD emulation not possible on this device\n"); + LOG(LOG_WARNING, "LOD emulation not possible on this device"); } } @@ -156,7 +156,7 @@ void GLInfo::init() { if (config.frameBufferEmulation.N64DepthCompare != 0) { if (!imageTextures && !ext_fetch) { config.frameBufferEmulation.N64DepthCompare = 0; - LOG(LOG_WARNING, "Your GPU does not support the extensions needed for N64 Depth Compare.\n"); + LOG(LOG_WARNING, "Your GPU does not support the extensions needed for N64 Depth Compare."); } } } diff --git a/src/Graphics/OpenGLContext/opengl_Utils.cpp b/src/Graphics/OpenGLContext/opengl_Utils.cpp index b8dbe500..0279af9d 100644 --- a/src/Graphics/OpenGLContext/opengl_Utils.cpp +++ b/src/Graphics/OpenGLContext/opengl_Utils.cpp @@ -137,16 +137,16 @@ bool Utils::isFramebufferError() // printf("FBO Undefined\n"); // break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - LOG(LOG_ERROR, "[GlideN64]: FBO Incomplete Attachment\n"); + LOG(LOG_ERROR, "[GlideN64]: FBO Incomplete Attachment"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - LOG(LOG_ERROR, "[GlideN64]: FBO Missing Attachment\n"); + LOG(LOG_ERROR, "[GlideN64]: FBO Missing Attachment"); break; // case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER : // printf("FBO Incomplete Draw Buffer\n"); // break; case GL_FRAMEBUFFER_UNSUPPORTED: - LOG(LOG_ERROR, "[GlideN64]: FBO Unsupported\n"); + LOG(LOG_ERROR, "[GlideN64]: FBO Unsupported"); break; case GL_FRAMEBUFFER_COMPLETE: //LOG(LOG_VERBOSE, "[GlideN64]: FBO OK\n"); @@ -158,7 +158,7 @@ bool Utils::isFramebufferError() // printf("framebuffer INCOMPLETE_FORMATS\n"); // break; default: - LOG(LOG_ERROR, "[GlideN64]: FBO Problem?\n"); + LOG(LOG_ERROR, "[GlideN64]: FBO Problem?"); } return e != GL_FRAMEBUFFER_COMPLETE; diff --git a/src/Log.cpp b/src/Log.cpp index 7482306e..557fc798 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -6,35 +6,111 @@ #include "PluginAPI.h" #include "wst.h" #include +#include +#include +#include +#include +#include +#include std::mutex g_logMutex; +std::wofstream fileOutput; -void LOG(u16 type, const char * format, ...) { - if (type > LOG_LEVEL) +std::wstring getFormattedTime() +{ + using namespace std::chrono; + + // get current time + auto now = system_clock::now(); + + // get number of milliseconds for the current second + // (remainder after division into seconds) + auto ms = duration_cast(now.time_since_epoch()) % 1000; + + // convert to std::time_t in order to convert to std::tm (broken time) + auto timer = system_clock::to_time_t(now); + + // convert to broken time + std::tm bt = *std::localtime(&timer); + + std::wstringstream oss; + + oss << std::put_time(&bt, L"%Y/%m/%d,%H:%M:%S"); // HH:MM:SS + oss << L'.' << std::setfill(L'0') << std::setw(3) << ms.count(); + + return oss.str(); +} + +void LogDebug(const char* _fileName, int _line, u16 _type, const char* _format, ...) { + + static const char* logLevelText[] = { + "NONE", + "ERROR", + "MINIMAL", + "WARNING", + "VERBOSE", + "APIFUNC", + }; + + if (_type > LOG_LEVEL) return; + std::wstring formattedTimeOfLog = getFormattedTime(); + std::unique_lock lock(g_logMutex); - wchar_t logPath[PLUGIN_PATH_SIZE + 16]; - api().GetUserDataPath(logPath); - gln_wcscat(logPath, wst("/gliden64.log")); + if (!fileOutput.is_open()) { + class SetLocale + { + public: + SetLocale() : m_locale(setlocale(LC_CTYPE, NULL)) { setlocale(LC_CTYPE, ""); } + ~SetLocale() { setlocale(LC_CTYPE, m_locale.c_str()); } + private: + std::string m_locale; + } setLocale; -#ifdef OS_WINDOWS - FILE *dumpFile = _wfopen(logPath, wst("a+")); -#else - constexpr size_t bufSize = PLUGIN_PATH_SIZE * 6; - char cbuf[bufSize]; - wcstombs(cbuf, logPath, bufSize); - FILE *dumpFile = fopen(cbuf, "a+"); -#endif //OS_WINDOWS + wchar_t logPath[PLUGIN_PATH_SIZE + 16]; + api().GetUserDataPath(logPath); - if (dumpFile == nullptr) + // Convert wchar string to multibyte string + // Use large enough buffer to hold multibyte conversion of wchar string + char logPathChar[PLUGIN_PATH_SIZE * 4]; + std::wcstombs(logPathChar, logPath, sizeof(logPathChar)); + + std::stringstream logPathStream; + logPathStream << logPathChar << "/" << "gliden64.log"; + fileOutput.open(logPathStream.str().c_str(), std::wofstream::out | std::wofstream::app); + } + + if (!fileOutput.is_open()) return; - va_list va; - va_start(va, format); - vfprintf(dumpFile, format, va); - fclose(dumpFile); - va_end(va); + + // initialize use of the variable argument array + va_list vaArgs; + va_start(vaArgs, _format); + + // reliably acquire the size from a copy of + // the variable argument array + // and a functionally reliable call + // to mock the formatting + va_list vaCopy; + va_copy(vaCopy, vaArgs); + const int iLen = std::vsnprintf(NULL, 0, _format, vaCopy); + va_end(vaCopy); + + // return a formatted string without + // risking memory mismanagement + // and without assuming any compiler + // or platform specific behavior + std::vector zc(iLen + 1); + std::vsnprintf(zc.data(), zc.size(), _format, vaArgs); + va_end(vaArgs); + + std::time_t t = std::time(nullptr); + std::wstringstream lcFormatString; + lcFormatString << formattedTimeOfLog << "," << _fileName << ":" << _line << "," << logLevelText[_type] << ", \"" << zc.data() << "\"" << std::endl; + fileOutput << lcFormatString.str(); + fileOutput.flush(); } #if defined(OS_WINDOWS) && !defined(MINGW) diff --git a/src/Log.h b/src/Log.h index 9b7d954c..c567224f 100644 --- a/src/Log.h +++ b/src/Log.h @@ -14,7 +14,15 @@ #include "Types.h" -void LOG(u16 type, const char * format, ...); +#ifdef OS_WINDOWS +#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) +#else +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +#endif //OS_WINDOWS + +#define LOG(...) LogDebug(__FILENAME__, __LINE__, __VA_ARGS__) + +void LogDebug(const char* _fileName, int _line, u16 _type, const char* _format, ...); #else diff --git a/src/TextDrawer.cpp b/src/TextDrawer.cpp index d5c6f7a9..57e017a4 100644 --- a/src/TextDrawer.cpp +++ b/src/TextDrawer.cpp @@ -188,7 +188,7 @@ struct Atlas { gfxContext.setTextureUnpackAlignment(curUnpackAlignment); - LOG(LOG_VERBOSE, "Generated a %d x %d (%d kb) texture atlas\n", w, h, w * h / 1024); + LOG(LOG_VERBOSE, "Generated a %d x %d (%d kb) texture atlas", w, h, w * h / 1024); } ~Atlas() { diff --git a/src/common/CommonAPIImpl_common.cpp b/src/common/CommonAPIImpl_common.cpp index 73e39586..46b8485b 100644 --- a/src/common/CommonAPIImpl_common.cpp +++ b/src/common/CommonAPIImpl_common.cpp @@ -152,7 +152,7 @@ private: void PluginAPI::ProcessDList() { - LOG(LOG_APIFUNC, "ProcessDList\n"); + LOG(LOG_APIFUNC, "ProcessDList"); #ifdef RSPTHREAD _callAPICommand(ProcessDListCommand()); #else @@ -162,7 +162,7 @@ void PluginAPI::ProcessDList() void PluginAPI::ProcessRDPList() { - LOG(LOG_APIFUNC, "ProcessRDPList\n"); + LOG(LOG_APIFUNC, "ProcessRDPList"); #ifdef RSPTHREAD _callAPICommand(ProcessRDPListCommand()); #else @@ -177,7 +177,7 @@ void PluginAPI::RomClosed() m_bRomOpen = false; - LOG(LOG_APIFUNC, "RomClosed\n"); + LOG(LOG_APIFUNC, "RomClosed"); #ifdef RSPTHREAD _callAPICommand(RomClosedCommand( &m_rspThreadMtx, @@ -196,7 +196,7 @@ void PluginAPI::RomClosed() void PluginAPI::RomOpen() { - LOG(LOG_APIFUNC, "RomOpen\n"); + LOG(LOG_APIFUNC, "RomOpen"); #ifdef RSPTHREAD m_pluginThreadMtx.lock(); m_pRspThread = new std::thread(RSP_ThreadProc, &m_rspThreadMtx, &m_pluginThreadMtx, &m_rspThreadCv, &m_pluginThreadCv, &m_pCommand); @@ -219,7 +219,7 @@ void PluginAPI::ShowCFB() void PluginAPI::UpdateScreen() { - LOG(LOG_APIFUNC, "UpdateScreen\n"); + LOG(LOG_APIFUNC, "UpdateScreen"); #ifdef RSPTHREAD _callAPICommand(ProcessUpdateScreenCommand()); #else @@ -265,7 +265,7 @@ void PluginAPI::_initiateGFX(const GFX_INFO & _gfxInfo) const { void PluginAPI::ChangeWindow() { - LOG(LOG_APIFUNC, "ChangeWindow\n"); + LOG(LOG_APIFUNC, "ChangeWindow"); dwnd().setToggleFullscreen(); if (!m_bRomOpen) dwnd().closeWindow(); diff --git a/src/gSP.cpp b/src/gSP.cpp index 516dc803..586003b1 100644 --- a/src/gSP.cpp +++ b/src/gSP.cpp @@ -935,7 +935,7 @@ void gSPVertex(u32 a, u32 n, u32 v0) DebugMsg(DEBUG_NORMAL, "gSPVertex n = %i, v0 = %i, from %08x\n", n, v0, a); if ((n + v0) > INDEXMAP_SIZE) { - LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i\n", v0, n); + LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i", v0, n); DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "//Using Vertex outside buffer v0 = %i, n = %i\n", v0, n); return; } @@ -1005,7 +1005,7 @@ void gSPCIVertex( u32 a, u32 n, u32 v0 ) DebugMsg(DEBUG_NORMAL, "gSPCIVertex n = %i, v0 = %i, from %08x\n", n, v0, a); if ((n + v0) > INDEXMAP_SIZE) { - LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i\n", v0, n); + LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i", v0, n); DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "//Using Vertex outside buffer v0 = %i, n = %i\n", v0, n); return; } @@ -1060,7 +1060,7 @@ void gSPDMAVertex( u32 a, u32 n, u32 v0 ) DebugMsg(DEBUG_NORMAL, "gSPDMAVertex n = %i, v0 = %i, from %08x\n", n, v0, a); if ((n + v0) > INDEXMAP_SIZE) { - LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i\n", v0, n); + LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i", v0, n); DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "//Using Vertex outside buffer v0 = %i, n = %i\n", v0, n); return; } @@ -1111,7 +1111,7 @@ void gSPCBFDVertex( u32 a, u32 n, u32 v0 ) DebugMsg(DEBUG_NORMAL, "gSPCBFDVertex n = %i, v0 = %i, from %08x\n", n, v0, a); if ((n + v0) > INDEXMAP_SIZE) { - LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i\n", v0, n); + LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i", v0, n); DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "//Using Vertex outside buffer v0 = %i, n = %i\n", v0, n); return; } @@ -1188,7 +1188,7 @@ void gSPF3DAMVertex(u32 a, u32 n, u32 v0) DebugMsg(DEBUG_NORMAL, "gSPF3DAMVertex n = %i, v0 = %i, from %08x\n", n, v0, a); if ((n + v0) > INDEXMAP_SIZE) { - LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i\n", v0, n); + LOG(LOG_ERROR, "Using Vertex outside buffer v0=%i, n=%i", v0, n); DebugMsg(DEBUG_NORMAL | DEBUG_ERROR, "//Using Vertex outside buffer v0 = %i, n = %i\n", v0, n); return; } diff --git a/src/uCodes/ZSort.cpp b/src/uCodes/ZSort.cpp index 9d413fcb..d7d667ca 100644 --- a/src/uCodes/ZSort.cpp +++ b/src/uCodes/ZSort.cpp @@ -185,7 +185,7 @@ void ZSort_Obj( u32 _w0, u32 _w1 ) void ZSort_Interpolate( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSort_Interpolate Ignored\n"); + LOG(LOG_VERBOSE, "ZSort_Interpolate Ignored"); } void ZSort_XFMLight( u32 _w0, u32 _w1 ) @@ -238,7 +238,7 @@ void ZSort_XFMLight( u32 _w0, u32 _w1 ) void ZSort_LightingL( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSort_LightingL Ignored\n"); + LOG(LOG_VERBOSE, "ZSort_LightingL Ignored"); } @@ -294,7 +294,7 @@ void ZSort_Lighting( u32 _w0, u32 _w1 ) void ZSort_MTXRNSP( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSort_MTXRNSP Ignored\n"); + LOG(LOG_VERBOSE, "ZSort_MTXRNSP Ignored"); } void ZSort_MTXCAT(u32 _w0, u32 _w1) @@ -391,22 +391,22 @@ void ZSort_MultMPMTX( u32 _w0, u32 _w1 ) void ZSort_LinkSubDL( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSort_LinkSubDL Ignored\n"); + LOG(LOG_VERBOSE, "ZSort_LinkSubDL Ignored"); } void ZSort_SetSubDL( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSort_SetSubDL Ignored\n"); + LOG(LOG_VERBOSE, "ZSort_SetSubDL Ignored"); } void ZSort_WaitSignal( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSort_WaitSignal Ignored\n"); + LOG(LOG_VERBOSE, "ZSort_WaitSignal Ignored"); } void ZSort_SendSignal( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSort_SendSignal Ignored\n"); + LOG(LOG_VERBOSE, "ZSort_SendSignal Ignored"); } static @@ -457,7 +457,7 @@ void ZSort_MoveMem( u32 _w0, u32 _w1 ) break; case GZM_OTHERMODE: - LOG(LOG_VERBOSE, "MoveMem Othermode Ignored\n"); + LOG(LOG_VERBOSE, "MoveMem Othermode Ignored"); break; case GZM_VIEWPORT: // VIEWPORT @@ -499,7 +499,7 @@ void ZSort_MoveMem( u32 _w0, u32 _w1 ) break; default: - LOG(LOG_ERROR, "ZSort_MoveMem UNKNOWN %d\n", idx); + LOG(LOG_ERROR, "ZSort_MoveMem UNKNOWN %d", idx); } } diff --git a/src/uCodes/ZSortBOSS.cpp b/src/uCodes/ZSortBOSS.cpp index 2578726c..8625812e 100644 --- a/src/uCodes/ZSortBOSS.cpp +++ b/src/uCodes/ZSortBOSS.cpp @@ -60,7 +60,7 @@ void ZSortBOSS_EndMainDL( u32, u32 ) *REG.SP_STATUS &= ~0x80; // clear sig0 } } - LOG(LOG_VERBOSE, "ZSortBOSS_EndMainDL\n"); + LOG(LOG_VERBOSE, "ZSortBOSS_EndMainDL"); } void ZSortBOSS_EndSubDL( u32, u32 ) @@ -77,7 +77,7 @@ void ZSortBOSS_EndSubDL( u32, u32 ) RSP.PCi = 0; gstate.subdl = PROCESSED; } - LOG(LOG_VERBOSE, "ZSortBOSS_EndSubDL\n"); + LOG(LOG_VERBOSE, "ZSortBOSS_EndSubDL"); } void ZSortBOSS_WaitSignal( u32 , u32 ) @@ -98,7 +98,7 @@ void ZSortBOSS_WaitSignal( u32 , u32 ) else gstate.waiting_for_signal = false; - LOG(LOG_VERBOSE, "ZSortBOSS_WaitSignal\n"); + LOG(LOG_VERBOSE, "ZSortBOSS_WaitSignal"); } void ZSortBOSS_MoveWord( u32 _w0, u32 _w1 ) @@ -110,13 +110,13 @@ void ZSortBOSS_MoveWord( u32 _w0, u32 _w1 ) } memcpy((DMEM + (_w0 & 0xfff)), &_w1, sizeof(u32)); - LOG(LOG_VERBOSE, "ZSortBOSS_MoveWord (Write 0x%08x to DMEM: 0x%04x)\n", _w1, (_w0 & 0xfff)); + LOG(LOG_VERBOSE, "ZSortBOSS_MoveWord (Write 0x%08x to DMEM: 0x%04x)", _w1, (_w0 & 0xfff)); } void ZSortBOSS_ClearBuffer( u32, u32 ) { memset((DMEM + 0xc20), 0, 512); - LOG(LOG_VERBOSE, "ZSortBOSS_ClearBuffer (Write 0x0 to DMEM: 0x0c20 -> 0x0e20)\n"); + LOG(LOG_VERBOSE, "ZSortBOSS_ClearBuffer (Write 0x0 to DMEM: 0x0c20 -> 0x0e20)"); } static @@ -145,7 +145,7 @@ void ZSortBOSS_MoveMem( u32 _w0, u32 _w1 ) assert((addr & 3) == 0); assert((_w0 & 3) == 0); - LOG(LOG_VERBOSE, "ZSortBOSS_MoveMem (R/W: %d, RDRAM: 0x%08x, DMEM: 0x%04x; len: %d)\n", flag, addr, (_w0 & 0xfff), len); + LOG(LOG_VERBOSE, "ZSortBOSS_MoveMem (R/W: %d, RDRAM: 0x%08x, DMEM: 0x%04x; len: %d)", flag, addr, (_w0 & 0xfff), len); // model matrix if((_w0 & 0xfff) == 0x830) { @@ -290,7 +290,7 @@ void ZSortBOSS_MTXCAT(u32 _w0, u32 _w1) assert(d != nullptr); memcpy(*d, m, 64); - LOG(LOG_VERBOSE, "ZSortBOSS_MTXCAT (S: 0x%04x, T: 0x%04x, D: 0x%04x)\n", S, T, D); + LOG(LOG_VERBOSE, "ZSortBOSS_MTXCAT (S: 0x%04x, T: 0x%04x, D: 0x%04x)", S, T, D); } void ZSortBOSS_MultMPMTX( u32 _w0, u32 _w1 ) @@ -347,7 +347,7 @@ void ZSortBOSS_MultMPMTX( u32 _w0, u32 _w1 ) daddr[i] = v; } - LOG(LOG_VERBOSE, "ZSortBOSS_MultMPMTX (src: 0x%04x, dest: 0x%04x, num: %d)\n", src, dst, num); + LOG(LOG_VERBOSE, "ZSortBOSS_MultMPMTX (src: 0x%04x, dest: 0x%04x, num: %d)", src, dst, num); } static @@ -495,7 +495,7 @@ void ZSortBOSS_TransposeMTX( u32, u32 _w1 ) } } - LOG(LOG_VERBOSE, "ZSortBOSS_TransposeMTX (MTX: 0x%04x)\n", (_w1 & 0xfff)); + LOG(LOG_VERBOSE, "ZSortBOSS_TransposeMTX (MTX: 0x%04x)", (_w1 & 0xfff)); } void ZSortBOSS_Lighting( u32 _w0, u32 _w1 ) @@ -545,7 +545,7 @@ void ZSortBOSS_Lighting( u32 _w0, u32 _w1 ) ((s16*)DMEM)[(tdest++)^1] = (s16)vtx.t; } - LOG(LOG_VERBOSE, "ZSortBOSS_Lighting (0x%08x, 0x%08x)\n", _w0, _w1); + LOG(LOG_VERBOSE, "ZSortBOSS_Lighting (0x%08x, 0x%08x)", _w0, _w1); } static @@ -622,7 +622,7 @@ void ZSortBOSS_TransformLights( u32 _w0, u32 _w1 ) addr += 24; } - LOG(LOG_VERBOSE, "ZSortBOSS_TransformLights (0x%08x, 0x%08x)\n", _w0, _w1); + LOG(LOG_VERBOSE, "ZSortBOSS_TransformLights (0x%08x, 0x%08x)", _w0, _w1); } void ZSortBOSS_Audio1( u32 _w0, u32 _w1 ) @@ -631,7 +631,7 @@ void ZSortBOSS_Audio1( u32 _w0, u32 _w1 ) u32 val = ((u32*)DMEM)[(_w0 & 0xfff) >> 2]; ((u32*)DMEM)[0] = val; memcpy(RDRAM+addr, DMEM, 0x8); - LOG(LOG_VERBOSE, "ZSortBOSS_Audio1 (0x%08x, 0x%08x)\n", _w0, _w1); + LOG(LOG_VERBOSE, "ZSortBOSS_Audio1 (0x%08x, 0x%08x)", _w0, _w1); } void ZSortBOSS_Audio2( u32 _w0, u32 _w1 ) @@ -680,7 +680,7 @@ void ZSortBOSS_Audio2( u32 _w0, u32 _w1 ) } } - LOG(LOG_VERBOSE, "ZSortBOSS_Audio2 (0x%08x, 0x%08x)\n", _w0, _w1); + LOG(LOG_VERBOSE, "ZSortBOSS_Audio2 (0x%08x, 0x%08x)", _w0, _w1); } void ZSortBOSS_Audio3( u32 _w0, u32 _w1 ) @@ -701,7 +701,7 @@ void ZSortBOSS_Audio3( u32 _w0, u32 _w1 ) memcpy(DMEM, (RDRAM + addr), 0x8); memcpy((DMEM+8), &addr, sizeof(addr)); - LOG(LOG_VERBOSE, "ZSortBOSS_Audio3 (0x%08x, 0x%08x)\n", _w0, _w1); + LOG(LOG_VERBOSE, "ZSortBOSS_Audio3 (0x%08x, 0x%08x)", _w0, _w1); } void ZSortBOSS_Audio4( u32 _w0, u32 _w1 ) @@ -723,7 +723,7 @@ void ZSortBOSS_Audio4( u32 _w0, u32 _w1 ) int index = (r9 & 0xf) << 1; if(index > 6) { - LOG(LOG_VERBOSE, "ZSortBOSS_Audio4: Index out of bound\n"); + LOG(LOG_VERBOSE, "ZSortBOSS_Audio4: Index out of bound"); break; } @@ -771,7 +771,7 @@ void ZSortBOSS_Audio4( u32 _w0, u32 _w1 ) } } - LOG(LOG_VERBOSE, "ZSortBOSS_Audio4 (0x%08x, 0x%08x)\n", _w0, _w1); + LOG(LOG_VERBOSE, "ZSortBOSS_Audio4 (0x%08x, 0x%08x)", _w0, _w1); } // RDP Commands @@ -779,7 +779,7 @@ void ZSortBOSS_UpdateMask( u32 _w0, u32 _w1 ) { gstate.updatemask[0] = _w0 | 0xff000000; gstate.updatemask[1] = _w1; - LOG(LOG_VERBOSE, "ZSortBOSS_UpdateMask (mask0: 0x%08x, mask1: 0x%08x)\n", gstate.updatemask[0], gstate.updatemask[1]); + LOG(LOG_VERBOSE, "ZSortBOSS_UpdateMask (mask0: 0x%08x, mask1: 0x%08x)", gstate.updatemask[0], gstate.updatemask[1]); } void ZSortBOSS_SetOtherMode_L( u32 _w0, u32 _w1 ) @@ -794,7 +794,7 @@ void ZSortBOSS_SetOtherMode_L( u32 _w0, u32 _w1 ) gDPSetOtherMode( _SHIFTR( w0, 0, 24 ), // mode0 w1 ); // mode1 - LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode_L (mode0: 0x%08x, mode1: 0x%08x)\n", gDP.otherMode.h, gDP.otherMode.l); + LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode_L (mode0: 0x%08x, mode1: 0x%08x)", gDP.otherMode.h, gDP.otherMode.l); } void ZSortBOSS_SetOtherMode_H( u32 _w0, u32 _w1 ) @@ -809,7 +809,7 @@ void ZSortBOSS_SetOtherMode_H( u32 _w0, u32 _w1 ) gDPSetOtherMode( _SHIFTR( w0, 0, 24 ), // mode0 w1 ); // mode1 - LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode_H (mode0: 0x%08x, mode1: 0x%08x)\n", gDP.otherMode.h, gDP.otherMode.l); + LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode_H (mode0: 0x%08x, mode1: 0x%08x)", gDP.otherMode.h, gDP.otherMode.l); } void ZSortBOSS_SetOtherMode( u32 _w0, u32 _w1 ) @@ -823,7 +823,7 @@ void ZSortBOSS_SetOtherMode( u32 _w0, u32 _w1 ) gDPSetOtherMode( _SHIFTR( w0, 0, 24 ), // mode0 w1 ); // mode1 - LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode (mode0: 0x%08x, mode1: 0x%08x)\n", gDP.otherMode.h, gDP.otherMode.l); + LOG(LOG_VERBOSE, "ZSortBOSS_SetOtherMode (mode0: 0x%08x, mode1: 0x%08x)", gDP.otherMode.h, gDP.otherMode.l); } void ZSortBOSS_TriangleCommand( u32, u32 _w1 ) @@ -836,12 +836,12 @@ void ZSortBOSS_TriangleCommand( u32, u32 _w1 ) gSP.texture.tile = _w1 & 0x7; gSPSetGeometryMode(G_SHADING_SMOOTH | G_SHADE); - LOG(LOG_VERBOSE, "ZSortBOSS_TriangleCommand (cmd: 0x%02x, level: %d, tile: %d)\n", ((_w1 >> 8) & 0x3f), gSP.texture.level, gSP.texture.tile); + LOG(LOG_VERBOSE, "ZSortBOSS_TriangleCommand (cmd: 0x%02x, level: %d, tile: %d)", ((_w1 >> 8) & 0x3f), gSP.texture.level, gSP.texture.tile); } void ZSortBOSS_FlushRDPCMDBuffer( u32, u32 ) { - LOG(LOG_VERBOSE, "ZSortBOSS_FlushRDPCMDBuffer Ignored\n"); + LOG(LOG_VERBOSE, "ZSortBOSS_FlushRDPCMDBuffer Ignored"); } void ZSortBOSS_Reserved( u32, u32 )