mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
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
This commit is contained in:
@ -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;
|
||||
|
@ -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:
|
||||
public:
|
||||
DynamicLibrary();
|
||||
int Load(const char *filename);
|
||||
int Unload();
|
||||
void *Get(const char *funcname) const;
|
||||
bool IsLoaded() const { return library != 0; }
|
||||
|
||||
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;
|
||||
private:
|
||||
std::string library_file;
|
||||
#ifdef _WIN32
|
||||
HINSTANCE library;
|
||||
HINSTANCE library;
|
||||
#else
|
||||
void* library;
|
||||
void *library;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DefaultMsgHandler(const char* caption, const char* text,
|
||||
bool yes_no) {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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?
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,14 +89,16 @@ struct PortableVertexDeclaration
|
||||
// all the data loading code must always be made compatible.
|
||||
class NativeVertexFormat
|
||||
{
|
||||
u8* m_compiledCode;
|
||||
PortableVertexDeclaration vtx_decl;
|
||||
public:
|
||||
NativeVertexFormat();
|
||||
~NativeVertexFormat();
|
||||
protected:
|
||||
NativeVertexFormat() {}
|
||||
|
||||
void Initialize(const PortableVertexDeclaration &vtx_decl);
|
||||
void SetupVertexPointers() const;
|
||||
public:
|
||||
virtual ~NativeVertexFormat() {}
|
||||
|
||||
virtual void Initialize(const PortableVertexDeclaration &vtx_decl) = 0;
|
||||
virtual void SetupVertexPointers() const = 0;
|
||||
|
||||
static NativeVertexFormat *Create();
|
||||
|
||||
// TODO: move these in under private:
|
||||
u32 m_components; // VB_HAS_X. Bitmask telling what vertex components are present.
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user