From 482ea5c0e75e413d02544624f556f7d0f4aaeed3 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Fri, 20 Mar 2009 19:12:04 +0000 Subject: [PATCH] Make the OptimizeQuantizers option apply to the IL build. More cleanup. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2696 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/ConsoleListener.cpp | 104 ++++++------------ Source/Core/Common/Src/LogManager.cpp | 26 ++--- Source/Core/Common/Src/LogManager.h | 67 +++++------ Source/Core/Core/Src/HW/EXI_Channel.h | 7 +- .../Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp | 4 +- .../PowerPC/Jit64IL/Jit_LoadStorePaired.cpp | 4 +- Source/Core/DolphinWX/Src/FrameTools.cpp | 19 ++-- Source/Core/DolphinWX/Src/LogWindow.cpp | 73 ++++++------ Source/Core/DolphinWX/Src/LogWindow.h | 5 +- Source/Core/DolphinWX/Src/WxUtils.cpp | 63 +++++++---- Source/Core/DolphinWX/Src/WxUtils.h | 31 +++++- 11 files changed, 203 insertions(+), 200 deletions(-) diff --git a/Source/Core/Common/Src/ConsoleListener.cpp b/Source/Core/Common/Src/ConsoleListener.cpp index 137fc9782b..1e87cb7711 100644 --- a/Source/Core/Common/Src/ConsoleListener.cpp +++ b/Source/Core/Common/Src/ConsoleListener.cpp @@ -27,19 +27,15 @@ #include "LogManager.h" // Common -// Inits as a Listener -ConsoleListener::ConsoleListener() : Listener("console") -{ -} - ConsoleListener::~ConsoleListener() { Close(); } +//150, 100, "Dolphin Log Console" // Open console window - width and height is the size of console window // Name is the window title -void ConsoleListener::Open(int Width, int Height, char * Name) +void ConsoleListener::Open(int width, int height, char *title) { #ifdef _WIN32 // Open the console window and create the window handle for GetStdHandle() @@ -49,15 +45,15 @@ void ConsoleListener::Open(int Width, int Height, char * Name) m_hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); // Set the console window title - SetConsoleTitle(Name); + SetConsoleTitle(title); // Set the total letter space - COORD co = {Width, Height}; + COORD co = {width, height}; SetConsoleScreenBufferSize(m_hStdOut, co); /* Set the window size in number of letters. The height is hard coded here because it can be changed with MoveWindow() later */ - SMALL_RECT coo = {0,0, (Width - 1),50}; // Top, left, right, bottom + SMALL_RECT coo = {0,0, (width - 1), 50}; // Top, left, right, bottom SetConsoleWindowInfo(m_hStdOut, TRUE, &coo); #endif } @@ -88,46 +84,45 @@ bool ConsoleListener::IsOpen() void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char *text) { #if defined(_WIN32) - DWORD cCharsWritten; // We will get a value back here - WORD color; - - switch (level) - { - case ERROR_LEVEL: // light red - color = FOREGROUND_RED | FOREGROUND_INTENSITY; - break; + DWORD cCharsWritten; // We will get a value back here + WORD color; + + switch (level) + { + case ERROR_LEVEL: // light red + color = FOREGROUND_RED | FOREGROUND_INTENSITY; + break; - case WARNING_LEVEL: // light yellow - color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; - break; + case WARNING_LEVEL: // light yellow + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; - case NOTICE_LEVEL: // light green - color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; - break; + case NOTICE_LEVEL: // light green + color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; - case INFO_LEVEL: // cyan - color = FOREGROUND_GREEN | FOREGROUND_BLUE; - break; + case INFO_LEVEL: // cyan + color = FOREGROUND_GREEN | FOREGROUND_BLUE; + break; - case DEBUG_LEVEL: // light gray - color = FOREGROUND_INTENSITY; - break; + case DEBUG_LEVEL: // light gray + color = FOREGROUND_INTENSITY; + break; - default: // white - color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; - break; - } - SetConsoleTextAttribute(m_hStdOut, color); + default: // white + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; + break; + } + SetConsoleTextAttribute(m_hStdOut, color); - WriteConsole(m_hStdOut, text, (DWORD)strlen(text), &cCharsWritten, NULL); + WriteConsole(m_hStdOut, text, (DWORD)strlen(text), &cCharsWritten, NULL); #else - fprintf(stderr, "%s", text); + fprintf(stderr, "%s", text); #endif } - // Clear console screen -void ConsoleListener::ClearScreen() +void ConsoleListener::ClearScreen() { #if defined(_WIN32) COORD coordScreen = { 0, 0 }; @@ -147,36 +142,3 @@ void ConsoleListener::ClearScreen() SetConsoleCursorPosition(hConsole, coordScreen); #endif } - - -// Get window handle of console window to be able to resize it. We use -// GetConsoleTitle() and FindWindow() to locate the console window handle. -#if defined(_WIN32) -HWND GetHwnd(void) -{ -#define MY_BUFSIZE 1024 // Buffer size for console window titles - HWND hwndFound; // This is what is returned to the caller - char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated WindowTitle - char pszOldWindowTitle[MY_BUFSIZE]; // Contains original WindowTitle - - // Fetch current window title. - GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); - - // Format a "unique" NewWindowTitle - wsprintf(pszNewWindowTitle, "%d/%d", GetTickCount(), GetCurrentProcessId()); - - // Change current window title - SetConsoleTitle(pszNewWindowTitle); - - // Ensure window title has been updated - Sleep(40); - - // Look for NewWindowTitle - hwndFound = FindWindow(NULL, pszNewWindowTitle); - - // Restore original window title - SetConsoleTitle(pszOldWindowTitle); - - return(hwndFound); -} -#endif // _WIN32 diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp index 096a9f2f6d..af102f0870 100644 --- a/Source/Core/Common/Src/LogManager.cpp +++ b/Source/Core/Common/Src/LogManager.cpp @@ -91,18 +91,18 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, } -void LogManager::removeListener(LogTypes::LOG_TYPE type, Listener *listener) { +void LogManager::removeListener(LogTypes::LOG_TYPE type, LogListener *listener) { logMutex->Enter(); m_Log[type]->removeListener(listener); logMutex->Leave(); } // LogContainer -void LogContainer::addListener(Listener *listener) { - std::vector::iterator i; +void LogContainer::addListener(LogListener *listener) { bool exists = false; - for(i=listeners.begin();i!=listeners.end();i++) { + std::vector::iterator i; + for(i = listeners.begin(); i != listeners.end(); i++) { if ((*i) == listener) { exists = true; break; @@ -113,9 +113,9 @@ void LogContainer::addListener(Listener *listener) { listeners.push_back(listener); } -void LogContainer::removeListener(Listener *listener) { - std::vector::iterator i; - for(i=listeners.begin();i!=listeners.end();i++) { +void LogContainer::removeListener(LogListener *listener) { + std::vector::iterator i; + for(i = listeners.begin(); i != listeners.end(); i++) { if ((*i) == listener) { listeners.erase(i); break; @@ -123,9 +123,9 @@ void LogContainer::removeListener(Listener *listener) { } } -bool LogContainer::isListener(Listener *listener) { - std::vector::iterator i; - for(i=listeners.begin();i!=listeners.end();i++) { +bool LogContainer::isListener(LogListener *listener) const { + std::vector::const_iterator i; + for(i = listeners.begin(); i != listeners.end(); i++) { if ((*i) == listener) { return true; } @@ -134,13 +134,13 @@ bool LogContainer::isListener(Listener *listener) { } void LogContainer::trigger(LogTypes::LOG_LEVELS level, const char *msg) { - std::vector::const_iterator i; - for(i=listeners.begin();i!=listeners.end();i++) { + std::vector::const_iterator i; + for (i = listeners.begin(); i != listeners.end(); i++) { (*i)->Log(level, msg); } } -FileLogListener::FileLogListener(const char *filename) : Listener("File") { +FileLogListener::FileLogListener(const char *filename) { m_filename = strndup(filename, 255); m_logfile = fopen(filename, "a+"); setEnable(true); diff --git a/Source/Core/Common/Src/LogManager.h b/Source/Core/Common/Src/LogManager.h index e93db2e47b..26e8bc88ff 100644 --- a/Source/Core/Common/Src/LogManager.h +++ b/Source/Core/Common/Src/LogManager.h @@ -32,17 +32,15 @@ #define MAX_MSGLEN 512 -class Listener { +// pure virtual interface (well, except the destructor which we just leave empty). +class LogListener { public: - Listener(const char *name) : m_name(name) {} + virtual ~LogListener() {} virtual void Log(LogTypes::LOG_LEVELS, const char *msg) = 0; - virtual const char *getName() { return m_name; } - -private: - const char *m_name; + virtual const char *getName() const = 0; }; -class FileLogListener : public Listener { +class FileLogListener : public LogListener { public: FileLogListener(const char *filename); ~FileLogListener(); @@ -60,17 +58,18 @@ public: void setEnable(bool enable) { m_enable = enable; } + + const char *getName() const { return "file"; } + private: char *m_filename; FILE *m_logfile; bool m_enable; - }; -class ConsoleListener : public Listener +class ConsoleListener : public LogListener { public: - ConsoleListener(); ~ConsoleListener(); void Open(int Width = 100, int Height = 100, @@ -80,6 +79,8 @@ public: void Log(LogTypes::LOG_LEVELS, const char *text); void ClearScreen(); + const char *getName() const { return "console"; } + private: #ifdef _WIN32 HWND GetHwnd(void); @@ -89,7 +90,6 @@ private: class LogContainer { public: - LogContainer(const char* shortName, const char* fullName, bool enable = false) : m_enable(enable) { strncpy(m_fullName, fullName, 128); @@ -97,26 +97,16 @@ public: m_level = LogTypes::LWARNING; } - const char *getShortName() { - return m_shortName; - } + const char *getShortName() const { return m_shortName; } + const char *getFullName() const { return m_fullName; } - const char *getFullName() { - return m_fullName; - } - - bool isListener(Listener *listener); - - void addListener(Listener *listener); - - void removeListener(Listener *listener); + bool isListener(LogListener *listener) const; + void addListener(LogListener *listener); + void removeListener(LogListener *listener); void trigger(LogTypes::LOG_LEVELS, const char *msg); - bool isEnable() { - return m_enable; - } - + bool isEnable() const { return m_enable; } void setEnable(bool enable) { m_enable = enable; } @@ -135,29 +125,25 @@ private: bool m_enable; LogTypes::LOG_LEVELS m_level; - std::vector listeners; + std::vector listeners; }; class LogManager { private: - LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; Common::CriticalSection* logMutex; FileLogListener *m_fileLog; ConsoleListener *m_consoleLog; - static LogManager *m_logManager; // FIXME: find a way without singletone - + static LogManager *m_logManager; // Singleton. Ugh. public: - static u32 GetMaxLevel() { - return LOGLEVEL; - } + static u32 GetMaxLevel() { return LOGLEVEL; } void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *fmt, ...); - void setLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level){ + void setLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) { m_Log[type]->setLevel(level); } @@ -165,23 +151,23 @@ public: m_Log[type]->setEnable(enable); } - const char *getShortName(LogTypes::LOG_TYPE type) { + const char *getShortName(LogTypes::LOG_TYPE type) const { return m_Log[type]->getShortName(); } - const char *getFullName(LogTypes::LOG_TYPE type) { + const char *getFullName(LogTypes::LOG_TYPE type) const { return m_Log[type]->getFullName(); } - bool isListener(LogTypes::LOG_TYPE type, Listener *listener) { + bool isListener(LogTypes::LOG_TYPE type, LogListener *listener) const { return m_Log[type]->isListener(listener); } - void addListener(LogTypes::LOG_TYPE type, Listener *listener) { + void addListener(LogTypes::LOG_TYPE type, LogListener *listener) { m_Log[type]->addListener(listener); } - void removeListener(LogTypes::LOG_TYPE type, Listener *listener); + void removeListener(LogTypes::LOG_TYPE type, LogListener *listener); FileLogListener *getFileListener() { return m_fileLog; @@ -194,7 +180,6 @@ public: static LogManager* GetInstance() { if (! m_logManager) m_logManager = new LogManager(); - return m_logManager; } diff --git a/Source/Core/Core/Src/HW/EXI_Channel.h b/Source/Core/Core/Src/HW/EXI_Channel.h index e28f59d82c..c4ff4e96f4 100644 --- a/Source/Core/Core/Src/HW/EXI_Channel.h +++ b/Source/Core/Core/Src/HW/EXI_Channel.h @@ -21,6 +21,10 @@ #include "EXI_Device.h" +#ifdef _WIN32 +#pragma warning(disable:4201) +#endif + class CEXIChannel { private: @@ -51,7 +55,7 @@ private: unsigned EXT : 1; //19 // External Insertion Status (1: External EXI device present) unsigned ROMDIS : 1; //18 // ROM Disable unsigned :18; - }; + }; // DO NOT obey the warning and give this struct a name. Things will fail. UEXI_STATUS() {hex = 0;} UEXI_STATUS(u32 _hex) {hex = _hex;} }; @@ -110,4 +114,3 @@ public: }; #endif - 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 3236d8dd80..a2f1668416 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 @@ -178,11 +178,11 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) if (Loader.IsValid()) { const std::vector& rContent = Loader.GetContent(); - for (size_t i=0; iShow(); else m_pStatusBar->Hide(); @@ -770,7 +773,8 @@ void CFrame::OnToggleLogWindow(wxCommandEvent& event) void CFrame::ToggleLogWindow(bool check) { - if (SConfig::GetInstance().m_InterfaceLogWindow = check == true) + SConfig::GetInstance().m_InterfaceLogWindow = check; + if (SConfig::GetInstance().m_InterfaceLogWindow) m_LogWindow->Show(); else m_LogWindow->Hide(); @@ -788,7 +792,8 @@ void CFrame::OnToggleConsole(wxCommandEvent& event) void CFrame::ToggleConsole(bool check) { ConsoleListener *console = LogManager::GetInstance()->getConsoleListener(); - if (SConfig::GetInstance().m_InterfaceConsole = check == true) + SConfig::GetInstance().m_InterfaceConsole = check; + if (SConfig::GetInstance().m_InterfaceConsole) console->Open(); else console->Close(); diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index 4947c294db..8aa6f841f6 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -27,7 +27,7 @@ #include "Console.h" // milliseconds between msgQueue flushes to wxTextCtrl -#define UPDATETIME 100 +#define UPDATETIME 200 BEGIN_EVENT_TABLE(CLogWindow, wxDialog) EVT_CLOSE(CLogWindow::OnClose) @@ -44,8 +44,7 @@ END_EVENT_TABLE() CLogWindow::CLogWindow(wxWindow* parent) : wxDialog(parent, wxID_ANY, wxT("Log/Console"), wxPoint(100, 700), wxSize(800, 270), - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), - Listener("LogWindow") + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { m_logManager = LogManager::GetInstance(); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) @@ -351,43 +350,51 @@ void CLogWindow::NotifyUpdate() void CLogWindow::UpdateLog() { + if (!msgQueue.size()) + return; m_logTimer->Stop(); + wxString collected_text; + // rough estimate. + collected_text.reserve(100 * msgQueue.size()); u32 msgQueueSize = msgQueue.size(); - for (u32 i = 0; i < msgQueueSize; i++) + for (unsigned int i = 0; i < msgQueueSize; i++) { +#ifndef _WIN32 // FIXME This looks horrible on windows: SetForegroundColour changes // ALL text in the control, and SetDefaultStyle doesn't work at all -// switch (msgQueue.front().first) -// { -// // red -// case ERROR_LEVEL: -// m_log->SetForegroundColour(*wxRED); -// break; -// // yellow -// case WARNING_LEVEL: -// m_log->SetForegroundColour(wxColour(255, 255, 0)); -// break; -// // green -// case NOTICE_LEVEL: -// m_log->SetForegroundColour(*wxGREEN); -// break; -// // cyan -// case INFO_LEVEL: -// m_log->SetForegroundColour(*wxCYAN); -// break; -// // light gray -// case DEBUG_LEVEL: -// m_log->SetForegroundColour(wxColour(211, 211, 211)); -// break; -// // white -// default: -// m_log->SetForegroundColour(*wxWHITE); -// break; -// } - - m_log->AppendText(msgQueue.front().second); + switch (msgQueue.front().first) + { + // red + case ERROR_LEVEL: + m_log->SetForegroundColour(*wxRED); + break; + // yellow + case WARNING_LEVEL: + m_log->SetForegroundColour(wxColour(255, 255, 0)); + break; + // green + case NOTICE_LEVEL: + m_log->SetForegroundColour(*wxGREEN); + break; + // cyan + case INFO_LEVEL: + m_log->SetForegroundColour(*wxCYAN); + break; + // light gray + case DEBUG_LEVEL: + m_log->SetForegroundColour(wxColour(211, 211, 211)); + break; + // white + default: + m_log->SetForegroundColour(*wxWHITE); + break; + } +#endif + collected_text.Append(msgQueue.front().second); msgQueue.pop(); } + if (collected_text.size()) + m_log->AppendText(collected_text); m_logTimer->Start(UPDATETIME); } diff --git a/Source/Core/DolphinWX/Src/LogWindow.h b/Source/Core/DolphinWX/Src/LogWindow.h index 00075e0e72..f9d6c5d7ea 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.h +++ b/Source/Core/DolphinWX/Src/LogWindow.h @@ -40,7 +40,8 @@ class wxTextCtrl; class wxCheckListBox; class wxString; -class CLogWindow : public wxDialog,Listener +// Uses multiple inheritance - only sane because LogListener is a pure virtual interface. +class CLogWindow : public wxDialog, LogListener { public: CLogWindow(wxWindow* parent); @@ -77,6 +78,8 @@ private: void UpdateChecks(); void UpdateLog(); + // LogListener + const char *getName() const { return "LogWindow"; } }; #endif /*LOGWINDOW_H_*/ diff --git a/Source/Core/DolphinWX/Src/WxUtils.cpp b/Source/Core/DolphinWX/Src/WxUtils.cpp index bdb5dfefba..c300bf074b 100644 --- a/Source/Core/DolphinWX/Src/WxUtils.cpp +++ b/Source/Core/DolphinWX/Src/WxUtils.cpp @@ -1,29 +1,48 @@ +// Copyright (C) 2003-2008 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 "Common.h" + #include #include + namespace WxUtils { - // Launch a file according to its mime type - void Launch(const char *filename) - { - if (! ::wxLaunchDefaultBrowser(wxString::FromAscii(filename))) { - // WARN_LOG - } +// Launch a file according to its mime type +void Launch(const char *filename) +{ + if (! ::wxLaunchDefaultBrowser(wxString::FromAscii(filename))) { + // WARN_LOG } - - // Launch an file explorer window on a certain path - void Explore(const char *path) - { - wxString wxPath = wxString::FromAscii(path); - - // Default to file - if (! wxPath.Contains(wxT("://"))) { - wxPath = wxT("file://") + wxPath; - } - - if (! ::wxLaunchDefaultBrowser(wxPath)) { - // WARN_LOG - } - } - } + +// Launch an file explorer window on a certain path +void Explore(const char *path) +{ + wxString wxPath = wxString::FromAscii(path); + + // Default to file + if (! wxPath.Contains(wxT("://"))) { + wxPath = wxT("file://") + wxPath; + } + + if (! ::wxLaunchDefaultBrowser(wxPath)) { + // WARN_LOG + } +} + +} // namespace diff --git a/Source/Core/DolphinWX/Src/WxUtils.h b/Source/Core/DolphinWX/Src/WxUtils.h index 90d44ba922..a607440730 100644 --- a/Source/Core/DolphinWX/Src/WxUtils.h +++ b/Source/Core/DolphinWX/Src/WxUtils.h @@ -1,12 +1,31 @@ +// Copyright (C) 2003-2008 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 WXUTILS_H #define WXUTILS_H namespace WxUtils { - // Launch a file according to its mime type - void Launch(const char *filename); - - // Launch an file explorer window on a certain path - void Explore(const char *path); + +// Launch a file according to its mime type +void Launch(const char *filename); + +// Launch an file explorer window on a certain path +void Explore(const char *path); -} // NameSpace WxUtils +} // namespace + #endif // WXUTILS