diff options
| author | hrydgard <hrydgard@gmail.com> | 2008-12-25 15:56:36 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2008-12-25 15:56:36 +0000 |
| commit | dcc48d6c417192dec95aa0d0562d6cc2f3cfa18a (patch) | |
| tree | f64ccb07691d1df7c508403421655d882086b49d /Source/Core | |
| parent | 3fd665502e7956ebd97391c0f4cc907d70358968 (diff) | |
just a bunch of random code cleanup i did on the train bored, plus a d3d implementation of NativeVertexFormat which isn't actually used yet.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1658 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/Src/DynamicLibrary.cpp | 41 | ||||
| -rw-r--r-- | Source/Core/Common/Src/DynamicLibrary.h | 26 | ||||
| -rw-r--r-- | Source/Core/Common/Src/MsgHandler.cpp | 58 | ||||
| -rw-r--r-- | Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp | 18 | ||||
| -rw-r--r-- | Source/Core/Core/Src/MemTools.cpp | 5 | ||||
| -rw-r--r-- | Source/Core/DolphinWX/Src/PluginManager.cpp | 13 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/NativeVertexFormat.h | 14 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/XFBConvert.h | 8 |
8 files changed, 97 insertions, 86 deletions
diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index 84d9816f1d..b3c7faf728 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -24,6 +24,7 @@ #endif #include "Common.h" +#include "FileUtil.h" #include "StringUtil.h" #include "DynamicLibrary.h" @@ -32,11 +33,10 @@ DynamicLibrary::DynamicLibrary() library = 0; } - std::string GetLastErrorAsString() { #ifdef _WIN32 - LPVOID lpMsgBuf = 0; + LPVOID lpMsgBuf = 0; DWORD error = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -64,13 +64,11 @@ std::string GetLastErrorAsString() #endif } - -// ------------------------------------------------------------------ -/* Loading means loading the dll with LoadLibrary() to get an instance to the dll. - This is done when Dolphin is started to determine which dlls are good, and - before opening the Config and Debugging windows from Plugin.cpp and - before opening the dll for running the emulation in Video_...cpp in Core. */ -// ----------------------- +// Loading means loading the dll with LoadLibrary() to get an instance to the dll. +// This is done when Dolphin is started to determine which dlls are good, and +// before opening the Config and Debugging windows from Plugin.cpp and +// before opening the dll for running the emulation in Video_...cpp in Core. +// Since this is fairly slow, TODO: think about implementing some sort of cache. int DynamicLibrary::Load(const char* filename) { if (!filename || strlen(filename) == 0) @@ -80,7 +78,6 @@ int DynamicLibrary::Load(const char* filename) return 0; } LOG(MASTER_LOG, "Trying to load library %s", filename); - if (IsLoaded()) { LOG(MASTER_LOG, "Trying to load already loaded library %s", filename); @@ -93,9 +90,17 @@ int DynamicLibrary::Load(const char* filename) library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); #endif - if (!library) { + if (!library) + { LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); - PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str()); + if (File::Exists(filename)) + { + PanicAlert("Error loading DLL %s: %s\n\nAre you missing SDL.DLL or another file that this plugin may depend on?", filename, GetLastErrorAsString().c_str()); + } + else + { + PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str()); + } return 0; } @@ -108,11 +113,9 @@ int DynamicLibrary::Unload() { int retval; if (!IsLoaded()) { - LOG(MASTER_LOG, "Error unloading DLL %s: not loaded", library_file.c_str()); PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str()); return 0; } - #ifdef _WIN32 retval = FreeLibrary(library); @@ -120,8 +123,6 @@ int DynamicLibrary::Unload() retval = dlclose(library)?0:1; #endif if (!retval) { - LOG(MASTER_LOG, "Error unloading DLL %s: %s", library_file.c_str(), - GetLastErrorAsString().c_str()); PanicAlert("Error unloading DLL %s: %s", library_file.c_str(), GetLastErrorAsString().c_str()); } @@ -135,8 +136,8 @@ void* DynamicLibrary::Get(const char* funcname) const void* retval; if (!library) { - LOG(MASTER_LOG, "Can't find function %s - Library not loaded."); - PanicAlert("Can't find function %s - Library not loaded."); + PanicAlert("Can't find function %s - Library not loaded."); + return NULL; } #ifdef _WIN32 retval = GetProcAddress(library, funcname); @@ -145,8 +146,8 @@ void* DynamicLibrary::Get(const char* funcname) const #endif if (!retval) { - LOG(MASTER_LOG, "Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str()); - PanicAlert("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str()); + LOG(MASTER_LOG, "Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str()); + PanicAlert("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str()); } return retval; diff --git a/Source/Core/Common/Src/DynamicLibrary.h b/Source/Core/Common/Src/DynamicLibrary.h index 86718b4ce2..5dd47b8575 100644 --- a/Source/Core/Common/Src/DynamicLibrary.h +++ b/Source/Core/Common/Src/DynamicLibrary.h @@ -24,23 +24,23 @@ #include <string> +// Abstracts the (few) differences between dynamically loading DLLs under Windows +// and .so / .dylib under Linux/MacOSX. class DynamicLibrary { - public: - - DynamicLibrary(); - int Load(const char* filename); - int Unload(); - void* Get(const char* funcname) const; - - bool IsLoaded() const {return(library != 0);} - - private: - std::string library_file; +public: + DynamicLibrary(); + int Load(const char *filename); + int Unload(); + void *Get(const char *funcname) const; + bool IsLoaded() const { return library != 0; } + +private: + std::string library_file; #ifdef _WIN32 - HINSTANCE library; + HINSTANCE library; #else - void* library; + void *library; #endif }; diff --git a/Source/Core/Common/Src/MsgHandler.cpp b/Source/Core/Common/Src/MsgHandler.cpp index 9485c31b23..c3a9cae59d 100644 --- a/Source/Core/Common/Src/MsgHandler.cpp +++ b/Source/Core/Common/Src/MsgHandler.cpp @@ -24,44 +24,44 @@ bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no); static MsgAlertHandler msg_handler = DefaultMsgHandler; -void RegisterMsgAlertHandler(MsgAlertHandler handler) { - msg_handler = handler; +void RegisterMsgAlertHandler(MsgAlertHandler handler) +{ + msg_handler = handler; } -bool MsgAlert(const char* caption, bool yes_no, - const char* format, ...) { - - char buffer[2048]; - va_list args; - bool ret = false; +bool MsgAlert(const char* caption, bool yes_no, const char* format, ...) +{ + char buffer[2048]; + va_list args; + bool ret = false; - va_start(args, format); - CharArrayFromFormatV(buffer, 2048, format, args); + va_start(args, format); + CharArrayFromFormatV(buffer, 2048, format, args); - LOG(MASTER_LOG, "%s: %s", caption, buffer); + LOG(MASTER_LOG, "%s: %s", caption, buffer); - if (msg_handler) { - ret = msg_handler(caption, buffer, yes_no); - } - - va_end(args); - return ret; -} + if (msg_handler) + { + ret = msg_handler(caption, buffer, yes_no); + } -bool DefaultMsgHandler(const char* caption, const char* text, - bool yes_no) { + va_end(args); + return ret; +} +bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no) +{ #ifdef _WIN32 - if (yes_no) - return IDYES == MessageBox(0, text, caption, - MB_ICONQUESTION | MB_YESNO); - else { - MessageBox(0, text, caption, MB_ICONWARNING); - return true; - } + if (yes_no) + return IDYES == MessageBox(0, text, caption, + MB_ICONQUESTION | MB_YESNO); + else { + MessageBox(0, text, caption, MB_ICONWARNING); + return true; + } #else - printf("%s\n", text); - return true; + printf("%s\n", text); + return true; #endif } diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp index efe4713876..73c4f075e2 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp @@ -74,7 +74,7 @@ CEXIIPL::CEXIIPL() : } else { - PanicAlert("Error: failed to load font_ansi.bin. Fonts may bug"); + PanicAlert("Error: failed to load font_ansi.bin.\nFonts in a few games may not work, or crash the game."); } pStream = fopen(FONT_SJIS_FILE, "rb"); @@ -89,7 +89,8 @@ CEXIIPL::CEXIIPL() : } else { - PanicAlert("Error: failed to load font_sjis.bin. Fonts may bug"); + // Heh, BIOS fonts don't really work in JAP games anyway ... we get bogus characters. + PanicAlert("Error: failed to load font_sjis.bin.\nFonts in a few Japanese games may not work or crash the game."); } memcpy(m_pIPL, iplver, sizeof(iplver)); @@ -120,7 +121,6 @@ CEXIIPL::~CEXIIPL() if (m_count > 0) { m_szBuffer[m_count] = 0x00; - //MessageBox(NULL, m_szBuffer, "last message", MB_OK); } if (m_pIPL != NULL) @@ -130,19 +130,19 @@ CEXIIPL::~CEXIIPL() } // SRAM - FILE* pStream = NULL; - pStream = fopen(Core::GetStartupParameter().m_strSRAM.c_str(), "wb"); - if (pStream != NULL) + FILE *file = fopen(Core::GetStartupParameter().m_strSRAM.c_str(), "wb"); + if (file) { - fwrite(m_SRAM, 1, 64, pStream); - fclose(pStream); + fwrite(m_SRAM, 1, 64, file); + fclose(file); } } void CEXIIPL::SetCS(int _iCS) { if (_iCS) - { // cs transition to high + { + // cs transition to high m_uPosition = 0; } } diff --git a/Source/Core/Core/Src/MemTools.cpp b/Source/Core/Core/Src/MemTools.cpp index e217fb52e3..c46f76b88c 100644 --- a/Source/Core/Core/Src/MemTools.cpp +++ b/Source/Core/Core/Src/MemTools.cpp @@ -63,10 +63,7 @@ LONG NTAPI Handler(PEXCEPTION_POINTERS pPtrs) int accessType = (int)pPtrs->ExceptionRecord->ExceptionInformation[0]; if (accessType == 8) //Rule out DEP { - if (PowerPC::state == PowerPC::CPU_POWERDOWN) - return EXCEPTION_CONTINUE_SEARCH; - MessageBox(0, _T("Tried to execute code that's not marked executable. This is likely a JIT bug.\n"), 0, 0); - return EXCEPTION_CONTINUE_SEARCH; + return (DWORD)EXCEPTION_CONTINUE_SEARCH; } //Where in the x86 code are we? diff --git a/Source/Core/DolphinWX/Src/PluginManager.cpp b/Source/Core/DolphinWX/Src/PluginManager.cpp index fd235905cc..ac9a9ddbab 100644 --- a/Source/Core/DolphinWX/Src/PluginManager.cpp +++ b/Source/Core/DolphinWX/Src/PluginManager.cpp @@ -58,7 +58,7 @@ CPluginManager::~CPluginManager() // ---------------------------------------- -// Create list of avaliable plugins +// Create list of available plugins // ------------- void CPluginManager::ScanForPlugins(wxWindow* _wxWindow) { @@ -145,10 +145,11 @@ void CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, bool Type, //int ret = PluginVideo::LoadPlugin(_rFilename); //int ret = PluginDSP::LoadPlugin(_rFilename); - if(Type) + if (Type) { //Common::CPlugin::Debug((HWND)_Parent); - if(!PluginVideo::IsLoaded()) PluginVideo::LoadPlugin(_rFilename); + if (!PluginVideo::IsLoaded()) + PluginVideo::LoadPlugin(_rFilename); PluginVideo::Debug((HWND)_Parent, Show); } else @@ -162,7 +163,6 @@ void CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, bool Type, //m_DllDebugger(NULL); } - // ---------------------------------------- // Get dll info // ------------- @@ -179,6 +179,9 @@ CPluginInfo::CPluginInfo(const char *_rFileName) Common::CPlugin::Release(); } + /* + The DLL loading code provides enough error messages already. Possibly make some return codes + and handle messages here instead? else { if (!File::Exists(_rFileName)) { @@ -186,7 +189,7 @@ CPluginInfo::CPluginInfo(const char *_rFileName) } else { PanicAlert("Failed to load plugin %s - unknown error.\n", _rFileName); } - } + }*/ } diff --git a/Source/Core/VideoCommon/Src/NativeVertexFormat.h b/Source/Core/VideoCommon/Src/NativeVertexFormat.h index bcfb9fd95d..bad74a8b63 100644 --- a/Source/Core/VideoCommon/Src/NativeVertexFormat.h +++ b/Source/Core/VideoCommon/Src/NativeVertexFormat.h @@ -89,14 +89,16 @@ struct PortableVertexDeclaration // all the data loading code must always be made compatible. class NativeVertexFormat { - u8* m_compiledCode; - PortableVertexDeclaration vtx_decl; +protected: + NativeVertexFormat() {} + public: - NativeVertexFormat(); - ~NativeVertexFormat(); + virtual ~NativeVertexFormat() {} + + virtual void Initialize(const PortableVertexDeclaration &vtx_decl) = 0; + virtual void SetupVertexPointers() const = 0; - void Initialize(const PortableVertexDeclaration &vtx_decl); - void SetupVertexPointers() const; + static NativeVertexFormat *Create(); // TODO: move these in under private: u32 m_components; // VB_HAS_X. Bitmask telling what vertex components are present. diff --git a/Source/Core/VideoCommon/Src/XFBConvert.h b/Source/Core/VideoCommon/Src/XFBConvert.h index f1a41a245e..a1b6a5704a 100644 --- a/Source/Core/VideoCommon/Src/XFBConvert.h +++ b/Source/Core/VideoCommon/Src/XFBConvert.h @@ -20,8 +20,16 @@ #include "Common.h" +// This must be called once before calling the two conversion functions +// below. void InitXFBConvTables(); +// These implementations could likely be made considerably faster by +// reducing precision so that intermediate calculations are done in +// 15-bit precision instead of 32-bit. However, this would complicate +// the code and since we have a GPU implementation too, there really +// isn't much point. + // Converts 4:2:2 YUV (YUYV) data to 32-bit RGBA data. void ConvertFromXFB(u32 *dst, const u8* _pXFB, int width, int height); |
