mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 15:49:25 +01:00
Just submitting some boring minor cleanup and improved error msgs, to isolate my next change.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@92 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
9d312559cf
commit
27a141ecca
@ -24,6 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
#include "StringUtil.h"
|
||||||
#include "DynamicLibrary.h"
|
#include "DynamicLibrary.h"
|
||||||
|
|
||||||
DynamicLibrary::DynamicLibrary()
|
DynamicLibrary::DynamicLibrary()
|
||||||
@ -31,6 +32,29 @@ DynamicLibrary::DynamicLibrary()
|
|||||||
library = 0;
|
library = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string GetLastErrorAsString()
|
||||||
|
{
|
||||||
|
LPVOID lpMsgBuf = 0;
|
||||||
|
DWORD error = GetLastError();
|
||||||
|
FormatMessage(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
error,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||||
|
(LPTSTR) &lpMsgBuf,
|
||||||
|
0, NULL);
|
||||||
|
std::string s;
|
||||||
|
if (lpMsgBuf)
|
||||||
|
{
|
||||||
|
s = ((char *)lpMsgBuf);
|
||||||
|
LocalFree(lpMsgBuf);
|
||||||
|
} else {
|
||||||
|
s = StringFromFormat("(unknown error %08x)", error);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool DynamicLibrary::Load(const char* filename)
|
bool DynamicLibrary::Load(const char* filename)
|
||||||
{
|
{
|
||||||
@ -48,6 +72,9 @@ bool DynamicLibrary::Load(const char* filename)
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
library = LoadLibrary(filename);
|
library = LoadLibrary(filename);
|
||||||
|
if (!library) {
|
||||||
|
//PanicAlert("Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str());
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||||
|
|
||||||
@ -55,12 +82,10 @@ bool DynamicLibrary::Load(const char* filename)
|
|||||||
{
|
{
|
||||||
PanicAlert(dlerror());
|
PanicAlert(dlerror());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Successfully loaded %s", filename);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
if (library) {
|
||||||
|
library_file = filename;
|
||||||
|
}
|
||||||
return(library != 0);
|
return(library != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,11 +111,14 @@ void* DynamicLibrary::Get(const char* funcname) const
|
|||||||
{
|
{
|
||||||
void* retval;
|
void* retval;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
if (!library)
|
||||||
|
{
|
||||||
|
PanicAlert("Can't find function %s - Library not loaded.");
|
||||||
|
}
|
||||||
retval = GetProcAddress(library, funcname);
|
retval = GetProcAddress(library, funcname);
|
||||||
|
|
||||||
if (!retval)
|
if (!retval)
|
||||||
{
|
{
|
||||||
// PanicAlert("Did not find function %s in DLL", funcname);
|
PanicAlert("Did not find function %s in library %s.", funcname, library_file.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return(retval);
|
return(retval);
|
||||||
@ -103,7 +131,6 @@ void* DynamicLibrary::Get(const char* funcname) const
|
|||||||
printf("%s\n", dlerror());
|
printf("%s\n", dlerror());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class DynamicLibrary
|
class DynamicLibrary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -35,7 +37,7 @@ class DynamicLibrary
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string library_file;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HINSTANCE library;
|
HINSTANCE library;
|
||||||
#else
|
#else
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#else
|
||||||
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool File::Exists(const std::string &filename)
|
bool File::Exists(const std::string &filename)
|
||||||
@ -9,7 +11,9 @@ bool File::Exists(const std::string &filename)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return GetFileAttributes(filename.c_str()) != INVALID_FILE_ATTRIBUTES;
|
return GetFileAttributes(filename.c_str()) != INVALID_FILE_ATTRIBUTES;
|
||||||
#else
|
#else
|
||||||
return true; //TODO
|
struct stat file_info;
|
||||||
|
int result = stat(filename.c_str(), &file_info);
|
||||||
|
return result == 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,14 +21,16 @@ bool File::IsDirectory(const std::string &filename) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (GetFileAttributes(filename.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
return (GetFileAttributes(filename.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
#else
|
#else
|
||||||
return false; //TODO
|
// TODO: Insert POSIX code here.
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SanitizePath(const std::string &filename) {
|
std::string SanitizePath(const std::string &filename) {
|
||||||
std::string copy = filename;
|
std::string copy = filename;
|
||||||
for (int i = 0; i < copy.size(); i++)
|
for (int i = 0; i < copy.size(); i++)
|
||||||
if (copy[i] == '/') copy[i] = '\\';
|
if (copy[i] == '/')
|
||||||
|
copy[i] = '\\';
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +44,8 @@ void File::Launch(const std::string &filename)
|
|||||||
shex.lpFile = win_filename.c_str();
|
shex.lpFile = win_filename.c_str();
|
||||||
shex.nShow = SW_SHOWNORMAL;
|
shex.nShow = SW_SHOWNORMAL;
|
||||||
ShellExecuteEx(&shex);
|
ShellExecuteEx(&shex);
|
||||||
|
#else
|
||||||
|
// TODO: Insert GNOME/KDE code here.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +59,8 @@ void File::Explore(const std::string &path)
|
|||||||
shex.lpFile = win_path.c_str();
|
shex.lpFile = win_path.c_str();
|
||||||
shex.nShow = SW_SHOWNORMAL;
|
shex.nShow = SW_SHOWNORMAL;
|
||||||
ShellExecuteEx(&shex);
|
ShellExecuteEx(&shex);
|
||||||
|
#else
|
||||||
|
// TODO: Insert GNOME/KDE code here.
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,19 +69,16 @@ bool File::CreateDir(const std::string &path)
|
|||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (::CreateDirectory(path.c_str(), NULL))
|
if (::CreateDirectory(path.c_str(), NULL))
|
||||||
|
return true;
|
||||||
|
DWORD error = GetLastError();
|
||||||
|
if (error == ERROR_ALREADY_EXISTS)
|
||||||
{
|
{
|
||||||
|
PanicAlert("%s already exists", path.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
PanicAlert("Error creating directory: %i", error);
|
||||||
{
|
return false;
|
||||||
DWORD error = GetLastError();
|
#else
|
||||||
if (error == ERROR_ALREADY_EXISTS)
|
// TODO: Insert POSIX code here.
|
||||||
{
|
|
||||||
PanicAlert("%s already exists", path.c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PanicAlert("Error creating directory: %i", error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x501
|
#define _WIN32_WINNT 0x501
|
||||||
|
#endif
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
#define _WIN32_IE 0x0500 // Default value is 0x0400
|
||||||
#endif
|
#endif
|
||||||
|
@ -74,20 +74,20 @@ namespace Gen
|
|||||||
inline void Write16(u16 value)
|
inline void Write16(u16 value)
|
||||||
{
|
{
|
||||||
*(u16*)code = value;
|
*(u16*)code = value;
|
||||||
code+=2;
|
code += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Write32(u32 value)
|
inline void Write32(u32 value)
|
||||||
{
|
{
|
||||||
*(u32*)code = value;
|
*(u32*)code = value;
|
||||||
code+=4;
|
code += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Write64(u64 value)
|
inline void Write64(u64 value)
|
||||||
{
|
{
|
||||||
_dbg_assert_msg_(DYNA_REC,!mode32,"!mode32");
|
_dbg_assert_msg_(DYNA_REC,!mode32,"!mode32");
|
||||||
*(u64*)code = value;
|
*(u64*)code = value;
|
||||||
code+=8;
|
code += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteModRM( int mod, int rm, int reg )
|
void WriteModRM( int mod, int rm, int reg )
|
||||||
@ -99,7 +99,6 @@ namespace Gen
|
|||||||
{
|
{
|
||||||
Write8((u8)((scale << 6) | ((index & 7) << 3) | (base & 7)));
|
Write8((u8)((scale << 6) | ((index & 7) << 3) | (base & 7)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OpArg::WriteRex(bool op64, int customOp) const
|
void OpArg::WriteRex(bool op64, int customOp) const
|
||||||
{
|
{
|
||||||
@ -1198,7 +1197,6 @@ namespace Gen
|
|||||||
|
|
||||||
void PMOVMSKB(X64Reg dest, OpArg arg) {WriteSSEOp(64, 0xD7, true, dest, arg); }
|
void PMOVMSKB(X64Reg dest, OpArg arg) {WriteSSEOp(64, 0xD7, true, dest, arg); }
|
||||||
|
|
||||||
|
|
||||||
// Prefixes
|
// Prefixes
|
||||||
|
|
||||||
void LOCK() { Write8(0xF0); }
|
void LOCK() { Write8(0xF0); }
|
||||||
|
@ -94,8 +94,10 @@ Common::Event emuThreadGoing;
|
|||||||
// Called from GUI thread
|
// Called from GUI thread
|
||||||
bool Init(const SCoreStartupParameter _CoreParameter)
|
bool Init(const SCoreStartupParameter _CoreParameter)
|
||||||
{
|
{
|
||||||
if (g_pThread != NULL)
|
if (g_pThread != NULL) {
|
||||||
|
PanicAlert("ERROR: Emu Thread already running. Report this bug.");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LogManager::Init();
|
LogManager::Init();
|
||||||
Host_SetWaitCursor(true);
|
Host_SetWaitCursor(true);
|
||||||
@ -330,7 +332,7 @@ THREAD_RETURN EmuThread(void *pArg)
|
|||||||
|
|
||||||
HW::Shutdown();
|
HW::Shutdown();
|
||||||
|
|
||||||
LOG(MASTER_LOG,"EmuThread exited");
|
LOG(MASTER_LOG, "EmuThread exited");
|
||||||
//The CPU should return when a game is stopped and cleanup should be done here,
|
//The CPU should return when a game is stopped and cleanup should be done here,
|
||||||
//so we can restart the plugins (or load new ones) for the next game
|
//so we can restart the plugins (or load new ones) for the next game
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Boot/Boot.h"
|
#include "Boot/Boot.h"
|
||||||
|
#include "FileUtil.h"
|
||||||
#include "StringUtil.h"
|
#include "StringUtil.h"
|
||||||
#include "CoreParameter.h"
|
#include "CoreParameter.h"
|
||||||
#include "VolumeCreator.h"
|
#include "VolumeCreator.h"
|
||||||
@ -142,6 +143,10 @@ bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios)
|
|||||||
m_strMemoryCardA = BaseDataPath + "/MemoryCardA.raw";
|
m_strMemoryCardA = BaseDataPath + "/MemoryCardA.raw";
|
||||||
m_strMemoryCardB = BaseDataPath + "/MemoryCardB.raw";
|
m_strMemoryCardB = BaseDataPath + "/MemoryCardB.raw";
|
||||||
m_strSRAM = BaseDataPath + "/SRAM.raw";
|
m_strSRAM = BaseDataPath + "/SRAM.raw";
|
||||||
|
if (!File::Exists(m_strBios)) {
|
||||||
|
LOG(BOOT, "BIOS file %s not found - using HLE.", m_strBios.c_str());
|
||||||
|
bHLEBios = true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -512,8 +512,7 @@ void CInterpreter::mulhwux(UGeckoInstruction _inst)
|
|||||||
{
|
{
|
||||||
u32 a = m_GPR[_inst.RA];
|
u32 a = m_GPR[_inst.RA];
|
||||||
u32 b = m_GPR[_inst.RB];
|
u32 b = m_GPR[_inst.RB];
|
||||||
u32 d;
|
u32 d = (u32)(((u64)a * (u64)b) >> 32);
|
||||||
d = (u32)(((u64)a * (u64)b) >> 32);
|
|
||||||
m_GPR[_inst.RD] = d;
|
m_GPR[_inst.RD] = d;
|
||||||
if (_inst.Rc) Helper_UpdateCR0(m_GPR[_inst.RD]);
|
if (_inst.Rc) Helper_UpdateCR0(m_GPR[_inst.RD]);
|
||||||
}
|
}
|
||||||
@ -522,8 +521,7 @@ void CInterpreter::mullwx(UGeckoInstruction _inst)
|
|||||||
{
|
{
|
||||||
u32 a = m_GPR[_inst.RA];
|
u32 a = m_GPR[_inst.RA];
|
||||||
u32 b = m_GPR[_inst.RB];
|
u32 b = m_GPR[_inst.RB];
|
||||||
u32 d;
|
u32 d = (u32)((s32)a * (s32)b);
|
||||||
d = (u32)((s32)a * (s32)b);
|
|
||||||
m_GPR[_inst.RD] = d;
|
m_GPR[_inst.RD] = d;
|
||||||
|
|
||||||
if (_inst.OE) PanicAlert("OE: mullwx");
|
if (_inst.OE) PanicAlert("OE: mullwx");
|
||||||
|
@ -394,15 +394,6 @@ void CInterpreter::lswx(UGeckoInstruction _inst)
|
|||||||
bFirst = false;
|
bFirst = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInterpreter::lwarx(UGeckoInstruction _inst)
|
|
||||||
{
|
|
||||||
m_GPR[_inst.RD] = Memory::Read_U32(Helper_Get_EA_X(_inst));
|
|
||||||
//static bool bFirst = true;
|
|
||||||
//if (bFirst)
|
|
||||||
// MessageBox(NULL, "lwarx", "Instruction unimplemented", MB_OK);
|
|
||||||
//bFirst = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CInterpreter::lwbrx(UGeckoInstruction _inst)
|
void CInterpreter::lwbrx(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
m_GPR[_inst.RD] = Common::swap32(Memory::Read_U32(Helper_Get_EA_X(_inst)));
|
m_GPR[_inst.RD] = Common::swap32(Memory::Read_U32(Helper_Get_EA_X(_inst)));
|
||||||
@ -594,12 +585,28 @@ void CInterpreter::stwbrx(UGeckoInstruction _inst)
|
|||||||
Memory::Write_U32(Common::swap32(m_GPR[_inst.RS]), uAddress);
|
Memory::Write_U32(Common::swap32(m_GPR[_inst.RS]), uAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// The following two instructions are for inter-cpu communications. On a single CPU, they cannot
|
||||||
|
// fail unless an interrupt happens in between, which usually won't happen with the JIT, so we just pretend
|
||||||
|
// they are regular loads and stores for now. If this proves to be a problem, we could add a reservation flag.
|
||||||
|
void CInterpreter::lwarx(UGeckoInstruction _inst)
|
||||||
|
{
|
||||||
|
m_GPR[_inst.RD] = Memory::Read_U32(Helper_Get_EA_X(_inst));
|
||||||
|
//static bool bFirst = true;
|
||||||
|
//if (bFirst)
|
||||||
|
// MessageBox(NULL, "lwarx", "Instruction unimplemented", MB_OK);
|
||||||
|
//bFirst = false;
|
||||||
|
}
|
||||||
|
|
||||||
void CInterpreter::stwcxd(UGeckoInstruction _inst)
|
void CInterpreter::stwcxd(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
|
// This instruction, to
|
||||||
static bool bFirst = true;
|
static bool bFirst = true;
|
||||||
if (bFirst)
|
if (bFirst)
|
||||||
PanicAlert("stwcxd - Instruction unimplemented");
|
PanicAlert("stwcxd - suspicious instruction");
|
||||||
bFirst = false;
|
bFirst = false;
|
||||||
|
u32 uAddress = Helper_Get_EA_X(_inst);
|
||||||
|
Memory::Write_U32(m_GPR[_inst.RS], uAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInterpreter::stwux(UGeckoInstruction _inst)
|
void CInterpreter::stwux(UGeckoInstruction _inst)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user