Merge large parts of nakeee's "Soap" branch into trunk, after fixing a few crash bugs in FileUtil.cpp.
Not really anything interesting, just some better comments, some slightly more portable/cleaner code in places. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2459 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
2783f24cfe
commit
4bdb4aa0d1
|
@ -546,6 +546,14 @@
|
|||
RelativePath=".\Src\ABI.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\CDUtils.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\CDUtils.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\ChunkFile.cpp"
|
||||
>
|
||||
|
@ -566,6 +574,18 @@
|
|||
RelativePath=".\Src\Common.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\CommonFuncs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\CommonPaths.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\CommonTypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\ConsoleWindow.cpp"
|
||||
>
|
||||
|
@ -582,14 +602,6 @@
|
|||
RelativePath=".\Src\CPUDetect.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\CDUtils.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\CDUtils.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\DynamicLibrary.cpp"
|
||||
>
|
||||
|
@ -650,6 +662,10 @@
|
|||
RelativePath=".\Src\IniFile.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Log.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\MappedFile.cpp"
|
||||
>
|
||||
|
@ -682,12 +698,16 @@
|
|||
RelativePath=".\Src\MemoryUtil.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Misc.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\MsgHandler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Paths.h"
|
||||
RelativePath=".\Src\MsgHandler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
using namespace Gen;
|
||||
|
||||
// Shared code between Win64 and Unix64
|
||||
// ====================================
|
||||
|
||||
// Sets up a __cdecl function.
|
||||
void XEmitter::ABI_EmitPrologue(int maxCallParams)
|
||||
|
@ -53,14 +52,14 @@ void XEmitter::ABI_EmitEpilogue(int maxCallParams)
|
|||
RET();
|
||||
#else
|
||||
#error Arch not supported
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _M_IX86 // All32
|
||||
|
||||
// Shared code between Win32 and Unix32
|
||||
// ====================================
|
||||
|
||||
void XEmitter::ABI_CallFunction(void *func) {
|
||||
ABI_AlignStack(0);
|
||||
CALL(func);
|
||||
|
@ -160,8 +159,9 @@ void XEmitter::ABI_RestoreStack(unsigned int frameSize) {
|
|||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#else //64bit
|
||||
|
||||
// Common functions
|
||||
void XEmitter::ABI_CallFunction(void *func) {
|
||||
CALL(func);
|
||||
}
|
||||
|
@ -221,7 +221,6 @@ void XEmitter::ABI_RestoreStack(unsigned int /*frameSize*/) {
|
|||
#ifdef _WIN32
|
||||
|
||||
// Win64 Specific Code
|
||||
// ====================================
|
||||
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
|
||||
//we only want to do this once
|
||||
PUSH(RBX);
|
||||
|
@ -249,7 +248,6 @@ void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
|
|||
}
|
||||
|
||||
// Win64 Specific Code
|
||||
// ====================================
|
||||
void XEmitter::ABI_PushAllCallerSavedRegsAndAdjustStack() {
|
||||
PUSH(RCX);
|
||||
PUSH(RDX);
|
||||
|
@ -277,7 +275,6 @@ void XEmitter::ABI_PopAllCallerSavedRegsAndAdjustStack() {
|
|||
|
||||
#else
|
||||
// Unix64 Specific Code
|
||||
// ====================================
|
||||
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
|
||||
PUSH(RBX);
|
||||
PUSH(RBP);
|
||||
|
@ -322,7 +319,8 @@ void XEmitter::ABI_PopAllCallerSavedRegsAndAdjustStack() {
|
|||
POP(RCX);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // WIN32
|
||||
|
||||
#endif // 32bit
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@
|
|||
// Callee-save: RBX RBP R12 R13 R14 R15
|
||||
// Parameters: RDI RSI RDX RCX R8 R9
|
||||
|
||||
#ifdef _M_IX86
|
||||
// 32 bit calling convention, shared by all
|
||||
#ifdef _M_IX86 // 32 bit calling convention, shared by all
|
||||
|
||||
// 32-bit don't pass parameters in regs, but these are convenient to have anyway when we have to
|
||||
// choose regs to put stuff in.
|
||||
|
@ -54,21 +53,19 @@
|
|||
#define ABI_PARAM2 RDX
|
||||
|
||||
// There are no ABI_PARAM* here, since args are pushed.
|
||||
|
||||
// === 32-bit bog standard cdecl, shared between linux and windows ============================
|
||||
// 32-bit bog standard cdecl, shared between linux and windows
|
||||
// MacOSX 32-bit is same as System V with a few exceptions that we probably don't care much about.
|
||||
#else
|
||||
// 64 bit calling convention
|
||||
|
||||
#ifdef _WIN32
|
||||
// === 64-bit Windows - the really exotic calling convention ==================================
|
||||
#else // 64 bit calling convention
|
||||
|
||||
#ifdef _WIN32 // 64-bit Windows - the really exotic calling convention
|
||||
|
||||
#define ABI_PARAM1 RCX
|
||||
#define ABI_PARAM2 RDX
|
||||
#define ABI_PARAM3 R8
|
||||
#define ABI_PARAM4 R9
|
||||
#else
|
||||
// === 64-bit Unix (hopefully MacOSX too) =====================================================
|
||||
|
||||
#else //64-bit Unix (hopefully MacOSX too)
|
||||
|
||||
#define ABI_PARAM1 RDI
|
||||
#define ABI_PARAM2 RSI
|
||||
|
@ -83,3 +80,4 @@
|
|||
|
||||
#endif // _JIT_ABI_H
|
||||
|
||||
|
||||
|
|
|
@ -35,29 +35,29 @@
|
|||
static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
|
||||
unsigned int *ecx, unsigned int *edx)
|
||||
{
|
||||
#ifdef _LP64
|
||||
#ifdef _LP64
|
||||
__asm__("cpuid"
|
||||
: "=a" (*eax),
|
||||
"=b" (*ebx),
|
||||
"=c" (*ecx),
|
||||
"=d" (*edx)
|
||||
: "a" (*eax)
|
||||
);
|
||||
#else
|
||||
: "=a" (*eax),
|
||||
"=b" (*ebx),
|
||||
"=c" (*ecx),
|
||||
"=d" (*edx)
|
||||
: "a" (*eax)
|
||||
);
|
||||
#else
|
||||
// Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to be
|
||||
// restored at the end of the asm block.
|
||||
__asm__(
|
||||
"pushl %%ebx;"
|
||||
"cpuid;"
|
||||
"movl %%ebx,%1;"
|
||||
"popl %%ebx;"
|
||||
: "=a" (*eax),
|
||||
"=r" (*ebx),
|
||||
"=c" (*ecx),
|
||||
"=d" (*edx)
|
||||
: "a" (*eax)
|
||||
);
|
||||
#endif
|
||||
"pushl %%ebx;"
|
||||
"cpuid;"
|
||||
"movl %%ebx,%1;"
|
||||
"popl %%ebx;"
|
||||
: "=a" (*eax),
|
||||
"=r" (*ebx),
|
||||
"=c" (*ecx),
|
||||
"=d" (*edx)
|
||||
: "a" (*eax)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void __cpuid(int info[4], int x)
|
||||
|
@ -78,6 +78,7 @@ void __cpuid(int info[4], int x)
|
|||
|
||||
CPUInfo cpu_info;
|
||||
|
||||
// Detects the various cpu features
|
||||
void CPUInfo::Detect()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
|
@ -88,26 +89,26 @@ void CPUInfo::Detect()
|
|||
OS64bit = true;
|
||||
#endif
|
||||
num_cores = 1;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _M_IX86
|
||||
BOOL f64 = FALSE;
|
||||
OS64bit = IsWow64Process(GetCurrentProcess(), &f64) && f64;
|
||||
bool f64 = false;
|
||||
OS64bit = IsWow64Process(GetCurrentProcess(), (PBOOL)(&f64)) && f64;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// Set obvious defaults, for extra safety
|
||||
if (Mode64bit)
|
||||
{
|
||||
if (Mode64bit) {
|
||||
bSSE = true;
|
||||
bSSE2 = true;
|
||||
bLongMode = true;
|
||||
}
|
||||
|
||||
// Assume CPU supports the CPUID instruction. Those that don't can barely boot modern OS:es anyway.
|
||||
|
||||
// Assume CPU supports the CPUID instruction. Those that don't can barely
|
||||
// boot modern OS:es anyway.
|
||||
int cpu_id[4];
|
||||
memset(cpu_string, 0, sizeof(cpu_string));
|
||||
|
||||
|
||||
// Detect CPU's CPUID capabilities, and grab cpu string
|
||||
__cpuid(cpu_id, 0x00000000);
|
||||
u32 max_std_fn = cpu_id[0]; // EAX
|
||||
|
@ -122,10 +123,10 @@ void CPUInfo::Detect()
|
|||
vendor = VENDOR_AMD;
|
||||
else
|
||||
vendor = VENDOR_OTHER;
|
||||
|
||||
|
||||
// Set reasonable default brand string even if brand string not available.
|
||||
strcpy(brand_string, cpu_string);
|
||||
|
||||
|
||||
// Detect family and other misc stuff.
|
||||
bool HTT = false;
|
||||
int logical_cpu_count = 1;
|
||||
|
@ -182,6 +183,7 @@ void CPUInfo::Detect()
|
|||
}
|
||||
}
|
||||
|
||||
// Turn the cpu info into a string we can show
|
||||
std::string CPUInfo::Summarize()
|
||||
{
|
||||
std::string sum;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
// Detect the cpu, so we'll know which optimizations to use
|
||||
#ifndef _CPUDETECT_H
|
||||
#define _CPUDETECT_H
|
||||
|
||||
|
@ -30,13 +31,13 @@ enum CPUVendor
|
|||
struct CPUInfo
|
||||
{
|
||||
CPUVendor vendor;
|
||||
|
||||
|
||||
char cpu_string[0x21];
|
||||
char brand_string[0x41];
|
||||
bool OS64bit;
|
||||
bool CPU64bit;
|
||||
bool Mode64bit;
|
||||
|
||||
|
||||
bool hyper_threaded;
|
||||
int num_cores;
|
||||
|
||||
|
@ -51,8 +52,11 @@ struct CPUInfo
|
|||
bool bSSE4A;
|
||||
bool bLAHFSAHF64;
|
||||
bool bLongMode;
|
||||
|
||||
|
||||
// Detects the various cpu features
|
||||
void Detect();
|
||||
|
||||
// Turn the cpu info into a string we can show
|
||||
std::string Summarize();
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "Common.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
template <class T>
|
||||
struct LinkedListItem : public T
|
||||
|
@ -41,15 +42,11 @@ struct LinkedListItem : public T
|
|||
LinkedListItem<T> *next;
|
||||
};
|
||||
|
||||
|
||||
// Wrapper class
|
||||
class PointerWrap
|
||||
{
|
||||
public:
|
||||
/* READ is when we read from the save state file, WRITE is when we write to the
|
||||
save state file. This enumareted list is also defined in pluginspecs.h. Didn't
|
||||
want to couple them. */
|
||||
enum Mode
|
||||
{
|
||||
enum Mode {
|
||||
MODE_READ = 1,
|
||||
MODE_WRITE,
|
||||
MODE_MEASURE,
|
||||
|
@ -68,8 +65,7 @@ public:
|
|||
|
||||
void DoVoid(void *data, int size)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case MODE_READ: memcpy(data, *ptr, size); break;
|
||||
case MODE_WRITE: memcpy(*ptr, data, size); break;
|
||||
case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
|
||||
|
@ -84,22 +80,21 @@ public:
|
|||
// TODO
|
||||
PanicAlert("Do(map<>) does not yet work.");
|
||||
}
|
||||
|
||||
|
||||
// Store vectors.
|
||||
template<class T>
|
||||
void Do(std::vector<T> &x) {
|
||||
// TODO
|
||||
PanicAlert("Do(vector<>) does not yet work.");
|
||||
}
|
||||
|
||||
|
||||
// Store strings.
|
||||
void Do(std::string &x)
|
||||
{
|
||||
int stringLen = (int)x.length() + 1;
|
||||
Do(stringLen);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
|
||||
switch (mode) {
|
||||
case MODE_READ: x = (char*)*ptr; break;
|
||||
case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
|
||||
case MODE_MEASURE: break;
|
||||
|
@ -110,33 +105,29 @@ public:
|
|||
void DoBuffer(u8** pBuffer, u32& _Size)
|
||||
{
|
||||
Do(_Size);
|
||||
|
||||
if (_Size > 0)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
|
||||
if (_Size > 0) {
|
||||
switch (mode) {
|
||||
case MODE_READ: *pBuffer = new u8[_Size]; memcpy(*pBuffer, *ptr, _Size); break;
|
||||
case MODE_WRITE: memcpy(*ptr, *pBuffer, _Size); break;
|
||||
case MODE_MEASURE: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*pBuffer = NULL;
|
||||
}
|
||||
(*ptr) += _Size;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void DoArray(T *x, int count) {
|
||||
void DoArray(T *x, int count) {
|
||||
DoVoid((void *)x, sizeof(T) * count);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Do(T &x) {
|
||||
DoVoid((void *)&x, sizeof(x));
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void DoLinkedList(LinkedListItem<T> **list_start) {
|
||||
// TODO
|
||||
|
@ -148,85 +139,129 @@ public:
|
|||
class CChunkFileReader
|
||||
{
|
||||
public:
|
||||
// Load file template
|
||||
template<class T>
|
||||
static bool Load(const std::string& _rFilename, int _Revision, T& _class)
|
||||
static bool Load(const std::string& _rFilename, int _Revision, T& _class)
|
||||
{
|
||||
FILE* pFile = fopen(_rFilename.c_str(), "rb");
|
||||
if (pFile)
|
||||
{
|
||||
// get size
|
||||
fseek(pFile, 0, SEEK_END);
|
||||
size_t FileSize = ftell(pFile);
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
|
||||
INFO_LOG(COMMON, "ChunkReader: Loading %s" , _rFilename.c_str());
|
||||
|
||||
if (FileSize < sizeof(SChunkHeader))
|
||||
{
|
||||
fclose(pFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the header
|
||||
SChunkHeader Header;
|
||||
fread(&Header, sizeof(SChunkHeader), 1, pFile);
|
||||
if (Header.Revision != _Revision)
|
||||
{
|
||||
fclose(pFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// get size
|
||||
int sz = (int)(FileSize - sizeof(SChunkHeader));
|
||||
if (Header.ExpectedSize != sz)
|
||||
{
|
||||
fclose(pFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the state
|
||||
u8* buffer = new u8[sz];
|
||||
fread(buffer, 1, sz, pFile);
|
||||
fclose(pFile);
|
||||
|
||||
u8 *ptr = buffer;
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_READ);
|
||||
_class.DoState(p);
|
||||
delete [] buffer;
|
||||
|
||||
return true;
|
||||
if (! File::Exists(_rFilename.c_str()))
|
||||
return false;
|
||||
|
||||
// Check file size
|
||||
u64 fileSize = File::GetSize(_rFilename.c_str());
|
||||
u64 headerSize = sizeof(SChunkHeader);
|
||||
if (fileSize < headerSize) {
|
||||
ERROR_LOG(COMMON,"ChunkReader: File too small");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
FILE* pFile;
|
||||
if (! (pFile = fopen(_rFilename.c_str(), "rb"))) {
|
||||
ERROR_LOG(COMMON,"ChunkReader: Can't open file for reading");
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the header
|
||||
SChunkHeader header;
|
||||
if (fread(&header, 1, headerSize, pFile) != headerSize) {
|
||||
fclose(pFile);
|
||||
ERROR_LOG(COMMON,"ChunkReader: Bad header size");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check revision
|
||||
if (header.Revision != _Revision) {
|
||||
fclose(pFile);
|
||||
ERROR_LOG(COMMON,"ChunkReader: Wrong file revision, got %d expected %d",
|
||||
header.Revision, _Revision);
|
||||
return false;
|
||||
}
|
||||
|
||||
// get size
|
||||
int sz = (int)(fileSize - headerSize);
|
||||
if (header.ExpectedSize != sz) {
|
||||
fclose(pFile);
|
||||
ERROR_LOG(COMMON,"ChunkReader: Bad file size, got %d expected %d",
|
||||
sz, header.ExpectedSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the state
|
||||
u8* buffer = new u8[sz];
|
||||
if ((int)fread(buffer, 1, sz, pFile) != sz) {
|
||||
fclose(pFile);
|
||||
ERROR_LOG(COMMON,"ChunkReader: Error reading file");
|
||||
return false;
|
||||
}
|
||||
|
||||
// done reading
|
||||
if (fclose(pFile)) {
|
||||
ERROR_LOG(COMMON,"ChunkReader: Error closing file! might be corrupted!");
|
||||
// should never happen!
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 *ptr = buffer;
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_READ);
|
||||
_class.DoState(p);
|
||||
delete [] buffer;
|
||||
|
||||
INFO_LOG(COMMON, "ChunkReader: Done loading %s" , _rFilename.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Save file template
|
||||
template<class T>
|
||||
static bool Save(const std::string& _rFilename, int _Revision, T& _class)
|
||||
{
|
||||
FILE* pFile = fopen(_rFilename.c_str(), "wb");
|
||||
if (pFile)
|
||||
{
|
||||
u8 *ptr = 0;
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||
_class.DoState(p);
|
||||
size_t sz = (size_t)ptr;
|
||||
u8 *buffer = new u8[sz];
|
||||
ptr = buffer;
|
||||
p.SetMode(PointerWrap::MODE_WRITE);
|
||||
_class.DoState(p);
|
||||
FILE* pFile;
|
||||
|
||||
SChunkHeader Header;
|
||||
Header.Compress = 0;
|
||||
Header.Revision = _Revision;
|
||||
Header.ExpectedSize = (int)sz;
|
||||
|
||||
fwrite(&Header, sizeof(SChunkHeader), 1, pFile);
|
||||
fwrite(buffer, sz, 1, pFile);
|
||||
fclose(pFile);
|
||||
|
||||
return true;
|
||||
INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str());
|
||||
|
||||
if (! (pFile = fopen(_rFilename.c_str(), "wb"))) {
|
||||
ERROR_LOG(COMMON,"ChunkReader: Error opening file for write");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
// Get data
|
||||
u8 *ptr = 0;
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||
_class.DoState(p);
|
||||
size_t sz = (size_t)ptr;
|
||||
u8 *buffer = new u8[sz];
|
||||
ptr = buffer;
|
||||
p.SetMode(PointerWrap::MODE_WRITE);
|
||||
_class.DoState(p);
|
||||
|
||||
// Create header
|
||||
SChunkHeader header;
|
||||
header.Compress = 0;
|
||||
header.Revision = _Revision;
|
||||
header.ExpectedSize = (int)sz;
|
||||
|
||||
// Write to file
|
||||
if (fwrite(&header, sizeof(SChunkHeader), 1, pFile) != 1) {
|
||||
ERROR_LOG(COMMON,"ChunkReader: Failed writing header");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fwrite(buffer, sz, 1, pFile) != 1) {
|
||||
ERROR_LOG(COMMON,"ChunkReader: Failed writing data");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fclose(pFile)) {
|
||||
ERROR_LOG(COMMON,"ChunkReader: Error closing file! might be corrupted!");
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(COMMON,"ChunkReader: Done writing %s",
|
||||
_rFilename.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
struct SChunkHeader
|
||||
{
|
||||
|
|
|
@ -18,51 +18,28 @@
|
|||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Settings
|
||||
// -----------------
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#define _CRTDBG_MAP_ALLOC_NEW
|
||||
#define CHECK_HEAP_INTEGRITY()
|
||||
//////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
// -----------------
|
||||
#ifdef _WIN32
|
||||
#ifdef _DEBUG
|
||||
#include <crtdbg.h>
|
||||
#undef CHECK_HEAP_INTEGRITY
|
||||
#define CHECK_HEAP_INTEGRITY() {if (!_CrtCheckMemory()) PanicAlert("memory corruption detected. see log.");}
|
||||
#endif
|
||||
|
||||
/* Turn on logging with debugging, _DEBUG and DEBUGFAST are still added through
|
||||
preprocessor definitions only */
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#define LOGGING
|
||||
#endif
|
||||
|
||||
#include "../../../PluginSpecs/CommonTypes.h"
|
||||
#define HAVE_WIIUSE 1
|
||||
#define HAVE_WX 1
|
||||
#else
|
||||
#include "CommonTypes.h"
|
||||
#include "Config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Paths.h"
|
||||
///////////////////////////////////
|
||||
// Force enable logging in the right modes. For some reason, something had changed
|
||||
// so that debugfast no longer logged.
|
||||
#ifdef _DEBUG
|
||||
#undef LOGGING
|
||||
#define LOGGING 1
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGFAST
|
||||
#undef LOGGING
|
||||
#define LOGGING 1
|
||||
#endif
|
||||
|
||||
#include "Log.h"
|
||||
#include "CommonTypes.h"
|
||||
#include "MsgHandler.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "CommonFuncs.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Settings
|
||||
// -----------------
|
||||
|
||||
// Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
|
||||
// This probably wouldn't break anyone either, but hey
|
||||
|
@ -72,325 +49,73 @@
|
|||
#define STACKALIGN
|
||||
#endif
|
||||
|
||||
|
||||
// Function Cross-Compatibility
|
||||
#ifdef _WIN32
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define unlink _unlink
|
||||
#define snprintf _snprintf
|
||||
#else
|
||||
#define _stricmp strcasecmp
|
||||
#define _strnicmp strncasecmp
|
||||
#define _unlink unlink
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
// Check MSC ver
|
||||
#if !defined _MSC_VER || _MSC_VER <= 1000
|
||||
#error needs at least version 1000 of MSC
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// By default, MS' stdio implementation does not support 64-bit offsets.
|
||||
// This little hack fixes that, keeping the code portable to linux where fseek and fread
|
||||
// do support 64-bit offsets in modern distributions.
|
||||
#define fseek _fseeki64
|
||||
#define ftell _ftelli64
|
||||
// Memory leak check defines
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#define _CRTDBG_MAP_ALLOC_NEW
|
||||
#define CHECK_HEAP_INTEGRITY()
|
||||
|
||||
#define atoll _atoi64
|
||||
|
||||
#define POSIX 0
|
||||
#define NOMINMAX
|
||||
|
||||
#if _M_IX86
|
||||
#define Crash() {__asm int 3}
|
||||
#else
|
||||
#if _MSC_VER > 1000
|
||||
extern "C" {
|
||||
__declspec(dllimport) void __stdcall DebugBreak(void);
|
||||
}
|
||||
#define Crash() {DebugBreak();}
|
||||
#else
|
||||
#error fixme
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif __GNUC__
|
||||
#define POSIX 1
|
||||
#define MAX_PATH 260
|
||||
#define stricmp strcasecmp
|
||||
#define Crash() {asm ("int $3");}
|
||||
#ifdef _LP64
|
||||
#define _M_X64 1
|
||||
#else
|
||||
#define _M_IX86 1
|
||||
#endif
|
||||
#endif
|
||||
#define POSIX 0
|
||||
#define NOMINMAX
|
||||
|
||||
// Alignment
|
||||
#define GC_ALIGNED16(x) __declspec(align(16)) x
|
||||
#define GC_ALIGNED32(x) __declspec(align(32)) x
|
||||
#define GC_ALIGNED64(x) __declspec(align(64)) x
|
||||
#define GC_ALIGNED16_DECL(x) __declspec(align(16)) x
|
||||
#define GC_ALIGNED64_DECL(x) __declspec(align(64)) x
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// Since they are always around on windows
|
||||
#define HAVE_WIIUSE 1
|
||||
#define HAVE_WX 1
|
||||
|
||||
#define GC_ALIGNED16(x) __declspec(align(16)) x
|
||||
#define GC_ALIGNED32(x) __declspec(align(32)) x
|
||||
#define GC_ALIGNED64(x) __declspec(align(64)) x
|
||||
#define GC_ALIGNED16_DECL(x) __declspec(align(16)) x
|
||||
#define GC_ALIGNED64_DECL(x) __declspec(align(64)) x
|
||||
|
||||
#else
|
||||
|
||||
#define GC_ALIGNED16(x) __attribute((aligned(16))) x
|
||||
#define GC_ALIGNED32(x) __attribute((aligned(16))) x
|
||||
#define GC_ALIGNED64(x) __attribute((aligned(64))) x
|
||||
#define GC_ALIGNED16_DECL(x) __attribute((aligned(16))) x
|
||||
#define GC_ALIGNED64_DECL(x) __attribute((aligned(64))) x
|
||||
|
||||
#endif
|
||||
|
||||
// Various Windows compatibility
|
||||
|
||||
#if !defined(_WIN32)
|
||||
inline u32 _rotl(u32 x, int shift) {
|
||||
shift &= 31;
|
||||
if (!shift) return x;
|
||||
return (x << shift) | (x >> (32 - shift));
|
||||
}
|
||||
|
||||
inline u32 _rotr(u32 x, int shift) {
|
||||
shift &= 31;
|
||||
if (!shift) return x;
|
||||
return (x >> shift) | (x << (32 - shift));
|
||||
}
|
||||
|
||||
#define LONG int
|
||||
|
||||
|
||||
#ifndef __forceinline
|
||||
#define __forceinline inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_M_IX86) && defined (_WIN32)
|
||||
#define HWCALL __cdecl
|
||||
#else
|
||||
#define HWCALL
|
||||
#endif
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
template<class T>
|
||||
inline T min(const T& a, const T& b) {return a > b ? b : a;}
|
||||
template<class T>
|
||||
inline T max(const T& a, const T& b) {return a > b ? a : b;}
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// **************************************************************************************
|
||||
// Utility functions
|
||||
// **************************************************************************************
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Byte ordering
|
||||
// -----------------
|
||||
namespace Common
|
||||
namespace
|
||||
{
|
||||
inline u8 swap8(u8 _data) {return(_data);}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
inline u16 swap16(u16 _data) {return(_byteswap_ushort(_data));}
|
||||
inline u32 swap32(u32 _data) {return(_byteswap_ulong(_data));}
|
||||
inline u64 swap64(u64 _data) {return(_byteswap_uint64(_data));}
|
||||
|
||||
#elif __linux__
|
||||
}
|
||||
#include <byteswap.h>
|
||||
namespace Common
|
||||
{
|
||||
inline u16 swap16(u16 _data) {return(bswap_16(_data));}
|
||||
inline u32 swap32(u32 _data) {return(bswap_32(_data));}
|
||||
inline u64 swap64(u64 _data) {return(bswap_64(_data));}
|
||||
|
||||
|
||||
#else
|
||||
inline u16 swap16(u16 data) {return((data >> 8) | (data << 8));}
|
||||
inline u32 swap32(u32 data) {return((swap16(data) << 16) | swap16(data >> 16));}
|
||||
inline u64 swap64(u64 data) {return(((u64)swap32(data) << 32) | swap32(data >> 32));}
|
||||
#endif
|
||||
|
||||
inline u16 swap16(u8* _pData) {return(swap16(*(u16*)_pData));}
|
||||
inline u32 swap32(u8* _pData) {return(swap32(*(u32*)_pData));}
|
||||
inline u64 swap64(u8* _pData) {return(swap64(*(u64*)_pData));}
|
||||
|
||||
|
||||
} // end of namespace Common
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Message alerts
|
||||
// -----------------
|
||||
enum MSG_TYPE
|
||||
{
|
||||
INFORMATION,
|
||||
QUESTION,
|
||||
WARNING,
|
||||
};
|
||||
|
||||
typedef bool (*MsgAlertHandler)(const char* caption, const char* text,
|
||||
bool yes_no, int Style);
|
||||
void RegisterMsgAlertHandler(MsgAlertHandler handler);
|
||||
extern bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...);
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SuccessAlert(format, ...) MsgAlert("Information", false, INFORMATION, format, __VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert("Warning", false, WARNING, format, __VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert("Warning", true, WARNING, format, __VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert("Question", true, QUESTION, format, __VA_ARGS__)
|
||||
#else
|
||||
#define SuccessAlert(format, ...) MsgAlert("SUCCESS", false, INFORMATION, format, ##__VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert("PANIC", false, WARNING, format, ##__VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert("PANIC", true, WARNING, format, ##__VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert("ASK", true, QUESTION, format, ##__VA_ARGS__)
|
||||
#endif
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Logging
|
||||
// -----------------
|
||||
|
||||
// dummy class
|
||||
class LogTypes
|
||||
{
|
||||
public:
|
||||
enum LOG_TYPE
|
||||
{
|
||||
MASTER_LOG,
|
||||
BOOT,
|
||||
PIXELENGINE,
|
||||
COMMANDPROCESSOR,
|
||||
VIDEOINTERFACE,
|
||||
SERIALINTERFACE,
|
||||
PERIPHERALINTERFACE,
|
||||
MEMMAP,
|
||||
DSPINTERFACE,
|
||||
STREAMINGINTERFACE,
|
||||
DVDINTERFACE,
|
||||
GPFIFO,
|
||||
EXPANSIONINTERFACE,
|
||||
AUDIO_INTERFACE,
|
||||
GEKKO,
|
||||
HLE,
|
||||
DSPHLE,
|
||||
VIDEO,
|
||||
AUDIO,
|
||||
DYNA_REC,
|
||||
CONSOLE,
|
||||
OSREPORT,
|
||||
WII_IOB,
|
||||
WII_IPC,
|
||||
WII_IPC_HLE,
|
||||
WII_IPC_DVD,
|
||||
WII_IPC_ES,
|
||||
WII_IPC_FILEIO,
|
||||
WII_IPC_SD,
|
||||
WII_IPC_NET,
|
||||
WII_IPC_WIIMOTE,
|
||||
ACTIONREPLAY,
|
||||
NUMBER_OF_LOGS
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef LOGGING
|
||||
extern void __Log(int logNumber, const char* text, ...);
|
||||
extern void __Logv(int log, int v, const char *format, ...);
|
||||
|
||||
void Host_UpdateLogDisplay();
|
||||
|
||||
// Logging macros. LOGGING is turned on from earlier in this file
|
||||
|
||||
#ifdef _WIN32
|
||||
#define LOG(t, ...) __Log(LogTypes::t, __VA_ARGS__);
|
||||
#define LOGV(t,v, ...) __Log(LogTypes::t + (v)*100, __VA_ARGS__);
|
||||
#define LOGP(t, ...) __Log(t, __VA_ARGS__);
|
||||
#define LOGVP(t,v, ...) __Log(t + (v)*100, __VA_ARGS__);
|
||||
#else
|
||||
#define LOG(t, ...) __Log(LogTypes::t, ##__VA_ARGS__);
|
||||
#define LOGV(t,v, ...) __Log(LogTypes::t + (v)*100, ##__VA_ARGS__);
|
||||
#define LOGP(t, ...) __Log(t, ##__VA_ARGS__);
|
||||
#define LOGVP(t,v, ...) __Log(t + (v)*100, ##__VA_ARGS__);
|
||||
#endif
|
||||
|
||||
#define _dbg_assert_(_t_, _a_) \
|
||||
if (!(_a_)){\
|
||||
LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
|
||||
__LINE__, __FILE__, __TIME__); \
|
||||
if (!PanicYesNo("*** Assertion (see log)***\n")){Crash();} \
|
||||
}
|
||||
#define _dbg_assert_msg_(_t_, _a_, ...)\
|
||||
if (!(_a_)){\
|
||||
LOG(_t_, __VA_ARGS__); \
|
||||
if (!PanicYesNo(__VA_ARGS__)){Crash();} \
|
||||
}
|
||||
#define _dbg_update_() Host_UpdateLogDisplay();
|
||||
|
||||
#else
|
||||
|
||||
#define LOG(_t_, ...)
|
||||
#define LOGV(_t_,_v_, ...)
|
||||
#define LOGP(_t_, ...)
|
||||
#define LOGVP(_t_,_v_, ...)
|
||||
#define _dbg_clear_()
|
||||
#ifndef _dbg_assert_
|
||||
#define _dbg_assert_(_t_, _a_) ;
|
||||
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) ;
|
||||
#endif
|
||||
#define _dbg_update_() ;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
||||
#define _assert_msg_(_t_, _a_, _fmt_, ...)\
|
||||
if (!(_a_)){\
|
||||
if (!PanicYesNo(_fmt_, __VA_ARGS__)){Crash();} \
|
||||
}
|
||||
#else
|
||||
#define _assert_(a)
|
||||
#define _assert_msg_(...)
|
||||
#endif
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Compile time asserts
|
||||
// -----------------
|
||||
namespace
|
||||
{
|
||||
|
||||
// it is very risky to mix _SECURE_SCL=0 and _SECURE_SCL=1 compiled libraries
|
||||
// it is possible that you overwrite memory if you do it
|
||||
#ifdef _WIN32
|
||||
// it is VERY DANGEROUS to mix _SECURE_SCL=0 and _SECURE_SCL=1 compiled libraries.
|
||||
// You will get bizarre crash bugs whenever you use STL.
|
||||
#ifndef _SECURE_SCL
|
||||
#error Please define _SECURE_SCL=0 in the project settings
|
||||
#error Please define _SECURE_SCL=0 in the project settings
|
||||
#else
|
||||
template <bool> struct CompileTimeAssert;
|
||||
template<> struct CompileTimeAssert<true> {};
|
||||
CompileTimeAssert<_SECURE_SCL==0> x;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
///////////////////////////////////////
|
||||
|
||||
// Debug definions
|
||||
#if defined(_DEBUG)
|
||||
#include <crtdbg.h>
|
||||
#undef CHECK_HEAP_INTEGRITY
|
||||
#define CHECK_HEAP_INTEGRITY() {if (!_CrtCheckMemory()) PanicAlert("memory corruption detected. see log.");}
|
||||
#endif // end DEBUG/FAST
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SLEEP(x) Sleep(x)
|
||||
#else
|
||||
#define SLEEP(x) usleep(x*1000)
|
||||
#endif
|
||||
#else // Not windows
|
||||
|
||||
#endif // _COMMON_H
|
||||
#include "Config.h" // Scons defines
|
||||
// General defines
|
||||
#define POSIX 1
|
||||
#define MAX_PATH 260
|
||||
|
||||
// Windows compatibility
|
||||
#define __forceinline inline
|
||||
|
||||
#ifdef _LP64
|
||||
#define _M_X64 1
|
||||
#else
|
||||
#define _M_IX86 1
|
||||
#endif
|
||||
// Alignment
|
||||
#define GC_ALIGNED16(x) __attribute((aligned(16))) x
|
||||
#define GC_ALIGNED32(x) __attribute((aligned(16))) x
|
||||
#define GC_ALIGNED64(x) __attribute((aligned(64))) x
|
||||
#define GC_ALIGNED16_DECL(x) __attribute((aligned(16))) x
|
||||
#define GC_ALIGNED64_DECL(x) __attribute((aligned(64))) x
|
||||
#endif // WIN32
|
||||
|
||||
#endif // COMMON_H
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
// 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 COMMONFUNCS_H
|
||||
#define COMMONFUNCS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SLEEP(x) Sleep(x)
|
||||
#else
|
||||
#define SLEEP(x) usleep(x*1000)
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <errno.h>
|
||||
#include <byteswap.h>
|
||||
// go to debugger mode
|
||||
#define Crash() {asm ("int $3");}
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
inline u32 _rotl(u32 x, int shift) {
|
||||
shift &= 31;
|
||||
if (!shift) return x;
|
||||
return (x << shift) | (x >> (32 - shift));
|
||||
}
|
||||
|
||||
inline u32 _rotr(u32 x, int shift) {
|
||||
shift &= 31;
|
||||
if (!shift) return x;
|
||||
return (x >> shift) | (x << (32 - shift));
|
||||
}
|
||||
#define SLEEP(x) usleep(x*1000)
|
||||
#else // WIN32
|
||||
// Function Cross-Compatibility
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define unlink _unlink
|
||||
#define snprintf _snprintf
|
||||
char* strndup (char const *s, size_t n);
|
||||
|
||||
// 64 bit offsets for windows
|
||||
#define fseek _fseeki64
|
||||
#define ftell _ftelli64
|
||||
#define atoll _atoi64
|
||||
#define stat64 _stat64
|
||||
#define SLEEP(x) Sleep(x)
|
||||
|
||||
#if _M_IX86
|
||||
#define Crash() {__asm int 3}
|
||||
#else
|
||||
extern "C" {
|
||||
__declspec(dllimport) void __stdcall DebugBreak(void);
|
||||
}
|
||||
#define Crash() {DebugBreak();}
|
||||
#endif // M_IX86
|
||||
#endif // WIN32 ndef
|
||||
|
||||
// Dolphin's min and max functions
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
template<class T>
|
||||
inline T min(const T& a, const T& b) {return a > b ? b : a;}
|
||||
template<class T>
|
||||
inline T max(const T& a, const T& b) {return a > b ? a : b;}
|
||||
|
||||
// Generic function to get last error message.
|
||||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
// Defined in Misc.cpp.
|
||||
const char* GetLastErrorMsg();
|
||||
|
||||
namespace Common
|
||||
{
|
||||
inline u8 swap8(u8 _data) {return _data;}
|
||||
|
||||
#ifdef _WIN32
|
||||
inline u16 swap16(u16 _data) {return _byteswap_ushort(_data);}
|
||||
inline u32 swap32(u32 _data) {return _byteswap_ulong (_data);}
|
||||
inline u64 swap64(u64 _data) {return _byteswap_uint64(_data);}
|
||||
#elif __linux__
|
||||
inline u16 swap16(u16 _data) {return bswap_16(_data);}
|
||||
inline u32 swap32(u32 _data) {return bswap_32(_data);}
|
||||
inline u64 swap64(u64 _data) {return bswap_64(_data);}
|
||||
#else
|
||||
// Slow generic implementation.
|
||||
inline u16 swap16(u16 data) {return (data >> 8) | (data << 8);}
|
||||
inline u32 swap32(u32 data) {return (swap16(data) << 16) | swap16(data >> 16);}
|
||||
inline u64 swap64(u64 data) {return ((u64)swap32(data) << 32) | swap32(data >> 32);}
|
||||
#endif
|
||||
|
||||
inline u16 swap16(const u8* _pData) {return swap16(*(const u16*)_pData);}
|
||||
inline u32 swap32(const u8* _pData) {return swap32(*(const u32*)_pData);}
|
||||
inline u64 swap64(const u8* _pData) {return swap64(*(const u64*)_pData);}
|
||||
|
||||
} // namespace Common
|
||||
|
||||
#endif // COMMONFUNCS
|
|
@ -1,130 +1,159 @@
|
|||
#ifndef PATHS_H
|
||||
#define PATHS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PLUGIN_PREFIX ""
|
||||
#define PLUGIN_SUFFIX ".dll"
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
#define PLUGIN_PREFIX "lib"
|
||||
#define PLUGIN_SUFFIX ".dylib"
|
||||
#else
|
||||
#define PLUGIN_PREFIX "lib"
|
||||
#define PLUGIN_SUFFIX ".so"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DIR_SEP "/"
|
||||
#define DIR_SEP_CHR '/'
|
||||
|
||||
#define PLUGINS_DIR "Plugins"
|
||||
#define ROOT_DIR "."
|
||||
#define USERDATA_DIR "User"
|
||||
#define SYSDATA_DIR "Sys"
|
||||
|
||||
// Dirs in both User and Sys
|
||||
#define EUR_DIR "EUR"
|
||||
#define USA_DIR "USA"
|
||||
#define JAP_DIR "JAP"
|
||||
|
||||
// Dirs in User
|
||||
#define GC_USER_DIR "GC"
|
||||
#define WII_USER_DIR "Wii"
|
||||
#define WII_SYSCONF_DIR "shared2/sys"
|
||||
#define CONFIG_DIR "Config"
|
||||
#define GAMECONFIG_DIR "GameConfig"
|
||||
#define MAPS_DIR "Maps"
|
||||
#define CACHE_DIR "Cache"
|
||||
#define STATESAVES_DIR "StateSaves"
|
||||
#define SCREENSHOTS_DIR "ScreenShots"
|
||||
#define DUMP_DIR "Dump"
|
||||
#define LOGS_DIR "Logs"
|
||||
#define MAIL_LOGS_DIR "Mail"
|
||||
|
||||
// Dirs in Sys
|
||||
#define GC_SYS_DIR "GC"
|
||||
#define WII_SYS_DIR "Wii"
|
||||
|
||||
// Filenames
|
||||
#define DOLPHIN_CONFIG "Dolphin.ini"
|
||||
#define DEBUGGER_CONFIG "Debugger.ini"
|
||||
#define TOTALDB "totaldb.dsy"
|
||||
|
||||
#define DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX
|
||||
#define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX
|
||||
#define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_PadSimple" PLUGIN_SUFFIX
|
||||
#define DEFAULT_WIIMOTE_PLUGIN PLUGIN_PREFIX "Plugin_Wiimote" PLUGIN_SUFFIX
|
||||
|
||||
#define FONT_ANSI "font_ansi.bin"
|
||||
#define FONT_SJIS "font_sjis.bin"
|
||||
|
||||
#define DSP_ROM "dsp_rom.bin"
|
||||
#define DSP_COEF "dsp_coef.bin"
|
||||
|
||||
#define GC_IPL "IPL.bin"
|
||||
#define GC_SRAM "SRAM.raw"
|
||||
#define GC_MEMCARDA "MemoryCardA"
|
||||
#define GC_MEMCARDB "MemoryCardB"
|
||||
|
||||
#define WII_EUR_SETTING "setting-eur.txt"
|
||||
#define WII_USA_SETTING "setting-usa.txt"
|
||||
#define WII_JAP_SETTING "setting-jpn.txt"
|
||||
#define WII_SYSCONF "SYSCONF"
|
||||
|
||||
#define MEMORY_DUMP_FILE "mainram.dump"
|
||||
|
||||
// Shorts - dirs
|
||||
// User dirs
|
||||
#define FULL_USERDATA_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP
|
||||
#define FULL_GC_USER_DIR FULL_USERDATA_DIR GC_USER_DIR DIR_SEP
|
||||
//#define GC_USER_EUR_DIR FULL_GC_USER_DIR EUR_DIR
|
||||
//#define GC_USER_USA_DIR FULL_GC_USER_DIR USA_DIR
|
||||
//#define GC_USER_JAP_DIR FULL_GC_USER_DIR JAP_DIR
|
||||
|
||||
#define FULL_WII_USER_DIR FULL_USERDATA_DIR WII_USER_DIR DIR_SEP
|
||||
#define FULL_WII_ROOT_DIR FULL_USERDATA_DIR WII_USER_DIR // This is the "root" for Wii fs, so that it may be used with created devices
|
||||
|
||||
#define FULL_GAMECONFIG_DIR FULL_USERDATA_DIR GAMECONFIG_DIR DIR_SEP
|
||||
#define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP
|
||||
#define FULL_CACHE_DIR FULL_USERDATA_DIR CACHE_DIR DIR_SEP
|
||||
#define FULL_STATESAVES_DIR FULL_USERDATA_DIR STATESAVES_DIR DIR_SEP
|
||||
#define FULL_SCREENSHOTS_DIR FULL_USERDATA_DIR SCREENSHOTS_DIR DIR_SEP
|
||||
#define FULL_DUMP_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP
|
||||
#define FULL_LOGS_DIR FULL_USERDATA_DIR LOGS_DIR DIR_SEP
|
||||
#define FULL_MAIL_LOGS_DIR FULL_LOGS_DIR MAIL_LOGS_DIR DIR_SEP
|
||||
#define FULL_MAPS_DIR FULL_USERDATA_DIR MAPS_DIR DIR_SEP
|
||||
|
||||
// Sys dirs
|
||||
#define FULL_SYSDATA_DIR ROOT_DIR DIR_SEP SYSDATA_DIR DIR_SEP
|
||||
|
||||
#define FULL_GC_SYS_DIR FULL_SYSDATA_DIR GC_SYS_DIR DIR_SEP
|
||||
//#define GC_SYS_EUR_DIR FULL_GC_SYS_DIR EUR_DIR
|
||||
//#define GC_SYS_USA_DIR FULL_GC_SYS_DIR USA_DIR
|
||||
//#define GC_SYS_JAP_DIR FULL_GC_SYS_DIR JAP_DIR
|
||||
|
||||
#define FULL_WII_SYS_DIR FULL_SYSDATA_DIR WII_SYS_DIR DIR_SEP
|
||||
|
||||
// Shorts - files
|
||||
// User files
|
||||
#define CONFIG_FILE FULL_CONFIG_DIR DOLPHIN_CONFIG
|
||||
#define DEBUGGER_CONFIG_FILE FULL_CONFIG_DIR DEBUGGER_CONFIG
|
||||
|
||||
#define TOTALDB_FILE FULL_SYSDATA_DIR TOTALDB
|
||||
#define MAINRAM_DUMP_FILE FULL_DUMP_DIR MEMORY_DUMP_FILE
|
||||
#define GC_SRAM_FILE FULL_USERDATA_DIR GC_USER_DIR DIR_SEP GC_SRAM
|
||||
|
||||
// Sys files
|
||||
#define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI
|
||||
#define FONT_SJIS_FILE FULL_GC_SYS_DIR FONT_SJIS
|
||||
|
||||
#define DSP_ROM_FILE FULL_GC_SYS_DIR DSP_ROM
|
||||
#define DSP_COEF_FILE FULL_GC_SYS_DIR DSP_COEF
|
||||
|
||||
#define WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING
|
||||
#define WII_USA_SETTING_FILE FULL_WII_SYS_DIR WII_USA_SETTING
|
||||
#define WII_JAP_SETTING_FILE FULL_WII_SYS_DIR WII_JAP_SETTING
|
||||
#define WII_SYSCONF_FILE FULL_WII_USER_DIR WII_SYSCONF_DIR DIR_SEP WII_SYSCONF
|
||||
|
||||
#define FULL_WII_MENU_DIR FULL_WII_USER_DIR "title" DIR_SEP "00000001" DIR_SEP "00000002" DIR_SEP "content"
|
||||
|
||||
#endif // PATHS_H
|
||||
// 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 COMMON_PATHS_H
|
||||
#define COMMON_PATHS_H
|
||||
|
||||
// Library suffix/prefix
|
||||
#ifdef _WIN32
|
||||
#define PLUGIN_PREFIX ""
|
||||
#define PLUGIN_SUFFIX ".dll"
|
||||
#elif defined __APPLE__
|
||||
#define PLUGIN_PREFIX "lib"
|
||||
#define PLUGIN_SUFFIX ".dylib"
|
||||
#else
|
||||
#define PLUGIN_PREFIX "lib"
|
||||
#define PLUGIN_SUFFIX ".so"
|
||||
#endif
|
||||
|
||||
// Directory seperators, do we need this?
|
||||
#define DIR_SEP "/"
|
||||
#define DIR_SEP_CHR '/'
|
||||
|
||||
#define PLUGINS_DIR "Plugins"
|
||||
#define ROOT_DIR "."
|
||||
#define USERDATA_DIR "User"
|
||||
#define SYSDATA_DIR "Sys"
|
||||
|
||||
// Where data directory is
|
||||
#ifdef _WIN32
|
||||
#define DOLPHIN_DATA_DIR "Dolphin"
|
||||
#elif defined __APPLE__
|
||||
#define DOLPHIN_DATA_DIR "Library/Application Support/Dolphin"
|
||||
#else
|
||||
#define DOLPHIN_DATA_DIR ".dolphin"
|
||||
#endif
|
||||
|
||||
// Dirs in both User and Sys
|
||||
#define EUR_DIR "EUR"
|
||||
#define USA_DIR "USA"
|
||||
#define JAP_DIR "JAP"
|
||||
|
||||
// Dirs in User
|
||||
#define GC_USER_DIR "GC"
|
||||
#define WII_USER_DIR "Wii"
|
||||
#define WII_SYSCONF_DIR "shared2/sys"
|
||||
#define CONFIG_DIR "Config"
|
||||
#define GAMECONFIG_DIR "GameConfig"
|
||||
#define MAPS_DIR "Maps"
|
||||
#define CACHE_DIR "Cache"
|
||||
#define STATESAVES_DIR "StateSaves"
|
||||
#define SCREENSHOTS_DIR "ScreenShots"
|
||||
#define DUMP_DIR "Dump"
|
||||
#define LOGS_DIR "Logs"
|
||||
#define MAIL_LOGS_DIR "Mail"
|
||||
|
||||
// Dirs in Sys
|
||||
#define GC_SYS_DIR "GC"
|
||||
#define WII_SYS_DIR "Wii"
|
||||
|
||||
// Filenames
|
||||
#define DOLPHIN_CONFIG "Dolphin.ini"
|
||||
#define DEBUGGER_CONFIG "Debugger.ini"
|
||||
#define LOGGER_CONFIG "Logger.ini"
|
||||
#define TOTALDB "totaldb.dsy"
|
||||
|
||||
#define DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX
|
||||
#define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX
|
||||
#define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_PadSimple" PLUGIN_SUFFIX
|
||||
#define DEFAULT_WIIMOTE_PLUGIN PLUGIN_PREFIX "Plugin_Wiimote" PLUGIN_SUFFIX
|
||||
|
||||
#define FONT_ANSI "font_ansi.bin"
|
||||
#define FONT_SJIS "font_sjis.bin"
|
||||
|
||||
#define DSP_ROM "dsp_rom.bin"
|
||||
#define DSP_COEF "dsp_coef.bin"
|
||||
|
||||
#define GC_IPL "IPL.bin"
|
||||
#define GC_SRAM "SRAM.raw"
|
||||
#define GC_MEMCARDA "MemoryCardA"
|
||||
#define GC_MEMCARDB "MemoryCardB"
|
||||
|
||||
#define WII_EUR_SETTING "setting-eur.txt"
|
||||
#define WII_USA_SETTING "setting-usa.txt"
|
||||
#define WII_JAP_SETTING "setting-jpn.txt"
|
||||
#define WII_SYSCONF "SYSCONF"
|
||||
|
||||
#define MEMORY_DUMP_FILE "mainram.dump"
|
||||
|
||||
// Shorts - dirs
|
||||
// User dirs
|
||||
#define FULL_USERDATA_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP
|
||||
|
||||
#define FULL_GC_USER_DIR FULL_USERDATA_DIR GC_USER_DIR DIR_SEP
|
||||
//#define GC_USER_EUR_DIR FULL_GC_USER_DIR EUR_DIR
|
||||
//#define GC_USER_USA_DIR FULL_GC_USER_DIR USA_DIR
|
||||
//#define GC_USER_JAP_DIR FULL_GC_USER_DIR JAP_DIR
|
||||
|
||||
#define FULL_WII_USER_DIR FULL_USERDATA_DIR WII_USER_DIR DIR_SEP
|
||||
#define FULL_WII_ROOT_DIR FULL_USERDATA_DIR WII_USER_DIR // This is the "root" for Wii fs, so that it may be used with created devices
|
||||
|
||||
#define FULL_GAMECONFIG_DIR FULL_USERDATA_DIR GAMECONFIG_DIR DIR_SEP
|
||||
#define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP
|
||||
#define FULL_CACHE_DIR FULL_USERDATA_DIR CACHE_DIR DIR_SEP
|
||||
#define FULL_STATESAVES_DIR FULL_USERDATA_DIR STATESAVES_DIR DIR_SEP
|
||||
#define FULL_SCREENSHOTS_DIR FULL_USERDATA_DIR SCREENSHOTS_DIR DIR_SEP
|
||||
#define FULL_DUMP_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP
|
||||
#define FULL_LOGS_DIR FULL_USERDATA_DIR LOGS_DIR DIR_SEP
|
||||
#define FULL_MAIL_LOGS_DIR FULL_LOGS_DIR MAIL_LOGS_DIR DIR_SEP
|
||||
#define FULL_MAPS_DIR FULL_USERDATA_DIR MAPS_DIR DIR_SEP
|
||||
|
||||
// Sys dirs
|
||||
#define FULL_SYSDATA_DIR ROOT_DIR DIR_SEP SYSDATA_DIR DIR_SEP
|
||||
|
||||
#define FULL_GC_SYS_DIR FULL_SYSDATA_DIR GC_SYS_DIR DIR_SEP
|
||||
//#define GC_SYS_EUR_DIR FULL_GC_SYS_DIR EUR_DIR
|
||||
//#define GC_SYS_USA_DIR FULL_GC_SYS_DIR USA_DIR
|
||||
//#define GC_SYS_JAP_DIR FULL_GC_SYS_DIR JAP_DIR
|
||||
|
||||
#define FULL_WII_SYS_DIR FULL_SYSDATA_DIR WII_SYS_DIR DIR_SEP
|
||||
|
||||
// Shorts - files
|
||||
// User files
|
||||
#define CONFIG_FILE FULL_CONFIG_DIR DOLPHIN_CONFIG
|
||||
#define DEBUGGER_CONFIG_FILE FULL_CONFIG_DIR DEBUGGER_CONFIG
|
||||
#define LOGGER_CONFIG_FILE FULL_CONFIG_DIR LOGGER_CONFIG
|
||||
|
||||
#define TOTALDB_FILE FULL_SYSDATA_DIR TOTALDB
|
||||
#define MAINRAM_DUMP_FILE FULL_DUMP_DIR MEMORY_DUMP_FILE
|
||||
#define GC_SRAM_FILE FULL_USERDATA_DIR GC_USER_DIR DIR_SEP GC_SRAM
|
||||
|
||||
// Sys files
|
||||
#define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI
|
||||
#define FONT_SJIS_FILE FULL_GC_SYS_DIR FONT_SJIS
|
||||
|
||||
#define DSP_ROM_FILE FULL_GC_SYS_DIR DSP_ROM
|
||||
#define DSP_COEF_FILE FULL_GC_SYS_DIR DSP_COEF
|
||||
|
||||
#define WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING
|
||||
#define WII_USA_SETTING_FILE FULL_WII_SYS_DIR WII_USA_SETTING
|
||||
#define WII_JAP_SETTING_FILE FULL_WII_SYS_DIR WII_JAP_SETTING
|
||||
#define WII_SYSCONF_FILE FULL_WII_USER_DIR WII_SYSCONF_DIR DIR_SEP WII_SYSCONF
|
||||
|
||||
#define FULL_WII_MENU_DIR FULL_WII_USER_DIR "title" DIR_SEP "00000001" DIR_SEP "00000002" DIR_SEP "content"
|
||||
|
||||
#endif // COMMON_PATHS_H
|
|
@ -1,57 +1,58 @@
|
|||
// 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/
|
||||
|
||||
|
||||
|
||||
// This header contains type definitions that are shared between the Dolphin
|
||||
// core and the plugin specs. Any definitions that are only used by the core
|
||||
// should be placed in "Common.h" instead.
|
||||
|
||||
#ifndef _COMMONTYPES_H
|
||||
#define _COMMONTYPES_H
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
typedef unsigned __int8 u8;
|
||||
typedef unsigned __int16 u16;
|
||||
typedef unsigned __int32 u32;
|
||||
typedef unsigned __int64 u64;
|
||||
|
||||
typedef signed __int8 s8;
|
||||
typedef signed __int16 s16;
|
||||
typedef signed __int32 s32;
|
||||
typedef signed __int64 s64;
|
||||
|
||||
#else
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
#define TCHAR char
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
#endif // _COMMONTYPES_H
|
||||
// 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/
|
||||
|
||||
|
||||
// This header contains type definitions that are shared between the Dolphin
|
||||
// core and the plugin specs. Any definitions that are only used by the core
|
||||
// should be placed in "Common.h" instead.
|
||||
|
||||
#ifndef _COMMONTYPES_H
|
||||
#define _COMMONTYPES_H
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
typedef unsigned __int8 u8;
|
||||
typedef unsigned __int16 u16;
|
||||
typedef unsigned __int32 u32;
|
||||
typedef unsigned __int64 u64;
|
||||
|
||||
typedef signed __int8 s8;
|
||||
typedef signed __int16 s16;
|
||||
typedef signed __int32 s32;
|
||||
typedef signed __int64 s64;
|
||||
|
||||
#else
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
// For using windows lock code
|
||||
#define TCHAR char
|
||||
#define LONG int
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
#endif // _COMMONTYPES_H
|
|
@ -15,8 +15,10 @@
|
|||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
// All plugins from Core > Plugins are loaded and unloaded with this class when
|
||||
// Dolphin is started and stopped.
|
||||
/*
|
||||
All plugins from Core > Plugins are loaded and unloaded with this class when
|
||||
Dolpin is started and stopped.
|
||||
*/
|
||||
|
||||
#include <string.h> // System
|
||||
#ifdef _WIN32
|
||||
|
@ -32,113 +34,116 @@
|
|||
#include "DynamicLibrary.h"
|
||||
#include "ConsoleWindow.h"
|
||||
|
||||
|
||||
DynamicLibrary::DynamicLibrary()
|
||||
{
|
||||
library = 0;
|
||||
}
|
||||
|
||||
std::string GetLastErrorAsString()
|
||||
// Gets the last dll error as string
|
||||
const char *DllGetLastError()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
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;
|
||||
#else
|
||||
static std::string errstr;
|
||||
char *tmp = dlerror();
|
||||
if (tmp)
|
||||
errstr = tmp;
|
||||
|
||||
return errstr;
|
||||
#endif
|
||||
return GetLastErrorMsg();
|
||||
#else // not win32
|
||||
return dlerror();
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
/* Function: 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.
|
||||
|
||||
Called from: The Dolphin Core */
|
||||
/* Loads the dll with LoadLibrary() or dlopen. This function is called on
|
||||
start to scan for plugin, and before opening the Config and Debugging
|
||||
windows. It is also called from core to load the plugins when the
|
||||
emulation starts.
|
||||
|
||||
Returns 0 on failure and 1 on success
|
||||
|
||||
TODO: think about implementing some sort of cache for the plugin info.
|
||||
*/
|
||||
int DynamicLibrary::Load(const char* filename)
|
||||
{
|
||||
if (!filename || strlen(filename) == 0)
|
||||
{
|
||||
LOG(MASTER_LOG, "Missing filename of dynamic library to load");
|
||||
PanicAlert("Missing filename of dynamic library to load");
|
||||
|
||||
INFO_LOG(COMMON, "DL: Loading dynamic library %s", filename);
|
||||
|
||||
if (!filename || strlen(filename) == 0) {
|
||||
ERROR_LOG(COMMON, "DL: Missing filename to load");
|
||||
return 0;
|
||||
}
|
||||
if (IsLoaded())
|
||||
{
|
||||
LOG(MASTER_LOG, "Trying to load already loaded library %s", filename);
|
||||
return 2;
|
||||
|
||||
if (IsLoaded()) {
|
||||
INFO_LOG(COMMON, "DL: library %s already loaded", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Console::Print("LoadLibrary: %s", filename);
|
||||
#ifdef _WIN32
|
||||
library = LoadLibrary(filename);
|
||||
#else
|
||||
// RTLD_NOW: resolve all symbols on load
|
||||
// RTLD_LOCAL: don't resolve symbols for other libraries
|
||||
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||
#endif
|
||||
Console::Print(" %p\n", 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());
|
||||
|
||||
DEBUG_LOG(COMMON, "DL: LoadLibrary: %s(%p)", filename, library);
|
||||
|
||||
if (!library) {
|
||||
ERROR_LOG(COMMON, "DL: Error loading DLL %s: %s", filename,
|
||||
DllGetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
library_file = filename;
|
||||
|
||||
INFO_LOG(COMMON, "DL: Done loading dynamic library %s", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Frees one instances of the dynamic library. Note that on most systems use
|
||||
reference count to decide when to actually remove the library from memory.
|
||||
|
||||
Return 0 on failure and 1 on success
|
||||
*/
|
||||
int DynamicLibrary::Unload()
|
||||
{
|
||||
int retval;
|
||||
if (!IsLoaded())
|
||||
{
|
||||
PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str());
|
||||
return 0;
|
||||
}
|
||||
INFO_LOG(COMMON, "DL: Unloading dynamic library %s", library_file.c_str());
|
||||
int retval;
|
||||
if (!IsLoaded()) { // library != null
|
||||
ERROR_LOG(COMMON, "DL: Unload failed for %s: not loaded",
|
||||
library_file.c_str());
|
||||
PanicAlert("DL: Unload failed %s: not loaded",
|
||||
library_file.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Console::Print("FreeLibrary: %s %p\n", library_file.c_str(), library);
|
||||
DEBUG_LOG(COMMON, "DL: FreeLibrary: %s %p\n",
|
||||
library_file.c_str(), library);
|
||||
#ifdef _WIN32
|
||||
retval = FreeLibrary(library);
|
||||
retval = FreeLibrary(library);
|
||||
#else
|
||||
retval = dlclose(library) ? 0 : 1;
|
||||
retval = dlclose(library)?0:1;
|
||||
#endif
|
||||
|
||||
if (!retval)
|
||||
{
|
||||
PanicAlert("Error unloading DLL %s: %s", library_file.c_str(),
|
||||
GetLastErrorAsString().c_str());
|
||||
}
|
||||
library = 0;
|
||||
return retval;
|
||||
if (! retval) {
|
||||
ERROR_LOG(COMMON, "DL: Unload failed %s: %s",
|
||||
library_file.c_str(),
|
||||
DllGetLastError());
|
||||
}
|
||||
library = 0;
|
||||
|
||||
INFO_LOG(COMMON, "DL: Done unloading dynamic library %s",
|
||||
library_file.c_str());
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Returns the address where symbol funcname is loaded or NULL on failure
|
||||
void* DynamicLibrary::Get(const char* funcname) const
|
||||
{
|
||||
void* retval;
|
||||
|
||||
INFO_LOG(COMMON, "DL: Getting symbol %s: %s", library_file.c_str(),
|
||||
funcname);
|
||||
|
||||
if (!library)
|
||||
{
|
||||
PanicAlert("Can't find function %s - Library not loaded.");
|
||||
ERROR_LOG(COMMON, "DL: Get failed %s - Library not loaded");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -150,9 +155,14 @@ void* DynamicLibrary::Get(const char* funcname) const
|
|||
|
||||
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());
|
||||
ERROR_LOG(COMMON, "DL: Symbol %s missing in %s (error: %s)\n",
|
||||
funcname, library_file.c_str(),
|
||||
DllGetLastError());
|
||||
}
|
||||
|
||||
INFO_LOG(COMMON, "DL: Done getting symbol %s: %s", library_file.c_str(),
|
||||
funcname);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,19 +24,31 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
// Abstracts the (few) differences between dynamically loading DLLs under Windows
|
||||
// and .so / .dylib under Linux/MacOSX.
|
||||
/* Abstracts the (few) differences between dynamically loading DLLs under
|
||||
Windows and .so / .dylib under Linux/MacOSX. */
|
||||
class DynamicLibrary
|
||||
{
|
||||
public:
|
||||
DynamicLibrary();
|
||||
|
||||
// Loads the library filename
|
||||
int Load(const char *filename);
|
||||
|
||||
// Unload the current library
|
||||
int Unload();
|
||||
|
||||
// Gets a pointer to the function symbol of funcname by getting it from the
|
||||
// share object
|
||||
void *Get(const char *funcname) const;
|
||||
|
||||
// Returns true is the library is loaded
|
||||
bool IsLoaded() const { return library != 0; }
|
||||
|
||||
private:
|
||||
// name of the library file
|
||||
std::string library_file;
|
||||
|
||||
// Library handle
|
||||
#ifdef _WIN32
|
||||
HINSTANCE library;
|
||||
#else
|
||||
|
@ -44,4 +56,4 @@ private:
|
|||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // DYNAMICLIBRARY
|
||||
|
|
|
@ -32,106 +32,118 @@
|
|||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
#include <CoreFoundation/CFString.h>
|
||||
#include <CoreFoundation/CFUrl.h>
|
||||
#include <CoreFoundation/CFBundle.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/*
|
||||
This namespace has various generic functions related to files and paths.
|
||||
The code still needs a ton of cleanup.
|
||||
REMEMBER: strdup considered harmful!
|
||||
*/
|
||||
namespace File
|
||||
{
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Remove any ending forward slashes from directory paths
|
||||
// -------------
|
||||
inline void StripTailDirSlashes(std::string& fname)
|
||||
// Modifies argument.
|
||||
inline char *StripTailDirSlashes(char *fname)
|
||||
{
|
||||
// Make sure it's not a blank string
|
||||
if(fname.length() > 0)
|
||||
{
|
||||
while(fname.at(fname.length() - 1) == DIR_SEP_CHR)
|
||||
fname.resize(fname.length() - 1);
|
||||
}
|
||||
int len = (int)strlen(fname);
|
||||
int i = len - 1;
|
||||
if (len > 1)
|
||||
while (fname[i] == DIR_SEP_CHR)
|
||||
fname[i--] = '\0';
|
||||
return fname;
|
||||
}
|
||||
// =============
|
||||
|
||||
|
||||
// Returns true if file filename exists
|
||||
bool Exists(const char *filename)
|
||||
{
|
||||
struct stat file_info;
|
||||
|
||||
char *copy = StripTailDirSlashes(strdup(filename));
|
||||
int result = stat(copy, &file_info);
|
||||
|
||||
std::string copy = filename;
|
||||
StripTailDirSlashes(copy);
|
||||
if (result < 0)
|
||||
{
|
||||
WARN_LOG(COMMON, "Exist: stat failed on %s: %s", filename,
|
||||
GetLastErrorMsg());
|
||||
}
|
||||
free(copy);
|
||||
|
||||
int result = stat(copy.c_str(), &file_info);
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
// Returns true if filename is a directory
|
||||
bool IsDirectory(const char *filename)
|
||||
{
|
||||
struct stat file_info;
|
||||
std::string copy = filename;
|
||||
StripTailDirSlashes(copy);
|
||||
|
||||
int result = stat(copy.c_str(), &file_info);
|
||||
if (result == 0)
|
||||
return S_ISDIR(file_info.st_mode);
|
||||
else
|
||||
char *copy = StripTailDirSlashes(strdup(filename));
|
||||
|
||||
int result = stat(copy, &file_info);
|
||||
free(copy);
|
||||
|
||||
if (result < 0) {
|
||||
WARN_LOG(COMMON, "IsDirectory: stat failed on %s: %s",
|
||||
filename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
return S_ISDIR(file_info.st_mode);
|
||||
}
|
||||
|
||||
// Deletes a given filename, return true on success
|
||||
// Doesn't supports deleting a directory
|
||||
bool Delete(const char *filename)
|
||||
{
|
||||
if (!Exists(filename))
|
||||
return false;
|
||||
if (IsDirectory(filename))
|
||||
INFO_LOG(COMMON, "Delete: file %s\n", filename);
|
||||
|
||||
// Return true because we care about the file no
|
||||
// being there, not the actual delete.
|
||||
if (!Exists(filename)) {
|
||||
WARN_LOG(COMMON, "Delete: %s does not exists", filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
// We can't delete a directory
|
||||
if (IsDirectory(filename)) {
|
||||
WARN_LOG(COMMON, "Delete: %s is a directory", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
DeleteFile(filename);
|
||||
if (!DeleteFile(filename)) {
|
||||
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
|
||||
filename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
unlink(filename);
|
||||
if (unlink(filename) == -1) {
|
||||
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
|
||||
filename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string SanitizePath(const char *filename)
|
||||
{
|
||||
|
||||
std::string copy = filename;
|
||||
#ifdef _WIN32
|
||||
for (size_t i = 0; i < copy.size(); i++)
|
||||
if (copy[i] == '/')
|
||||
copy[i] = '\\';
|
||||
#else
|
||||
// Should we do the otherway around?
|
||||
#endif
|
||||
return copy;
|
||||
}
|
||||
|
||||
// Returns true if successful, or path already exists.
|
||||
bool CreateDir(const char *path)
|
||||
{
|
||||
INFO_LOG(COMMON, "CreateDir: directory %s\n", path);
|
||||
#ifdef _WIN32
|
||||
if (::CreateDirectory(path, NULL))
|
||||
return true;
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
// PanicAlert("%s already exists", path);
|
||||
if (error == ERROR_ALREADY_EXISTS) {
|
||||
WARN_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: already exists", path);
|
||||
return true;
|
||||
}
|
||||
PanicAlert("Error creating directory %s: %i", path, error);
|
||||
ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %i", path, error);
|
||||
return false;
|
||||
#else
|
||||
if (mkdir(path, 0755) == 0)
|
||||
|
@ -139,434 +151,374 @@ bool CreateDir(const char *path)
|
|||
|
||||
int err = errno;
|
||||
|
||||
if (err == EEXIST)
|
||||
{
|
||||
// PanicAlert("%s already exists", path);
|
||||
if (err == EEXIST) {
|
||||
WARN_LOG(COMMON, "CreateDir: mkdir failed on %s: already exists", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
PanicAlert("Error creating directory %s: %s", path, strerror(err));
|
||||
ERROR_LOG(COMMON, "CreateDir: mkdir failed on %s: %s", path, strerror(err));
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// Create several dirs
|
||||
bool CreateDirectoryStructure(const std::string& _rFullPath)
|
||||
// Creates the full path of fullPath returns true on success
|
||||
bool CreateFullPath(const char *fullPath)
|
||||
{
|
||||
int PanicCounter = 10;
|
||||
|
||||
size_t Position = 0;
|
||||
while(true)
|
||||
{
|
||||
int panicCounter = 100;
|
||||
INFO_LOG(COMMON, "CreateFullPath: path %s\n", fullPath);
|
||||
|
||||
const char *position = fullPath;
|
||||
while (true) {
|
||||
// Find next sub path, support both \ and / directory separators
|
||||
{
|
||||
size_t nextPosition = _rFullPath.find(DIR_SEP_CHR, Position);
|
||||
Position = nextPosition;
|
||||
position = strchr(position, DIR_SEP_CHR);
|
||||
|
||||
if (Position == std::string::npos)
|
||||
return true;
|
||||
|
||||
Position++;
|
||||
}
|
||||
// we're done, yay!
|
||||
if (! position)
|
||||
return true;
|
||||
|
||||
position++;
|
||||
|
||||
// Create next sub path
|
||||
std::string SubPath = _rFullPath.substr(0, Position);
|
||||
if (!SubPath.empty())
|
||||
{
|
||||
if (!File::IsDirectory(SubPath.c_str()))
|
||||
{
|
||||
File::CreateDir(SubPath.c_str());
|
||||
LOG(WII_IPC_FILEIO, " CreateSubDir %s", SubPath.c_str());
|
||||
int sLen = (int)(position - fullPath);
|
||||
if (sLen > 0) {
|
||||
char *subPath = strndup(fullPath, sLen);
|
||||
if (!File::IsDirectory(subPath)) {
|
||||
File::CreateDir(subPath);
|
||||
}
|
||||
free(subPath);
|
||||
}
|
||||
|
||||
// A safety check
|
||||
PanicCounter--;
|
||||
if (PanicCounter <= 0)
|
||||
{
|
||||
PanicAlert("CreateDirectoryStruct creates way to much dirs...");
|
||||
panicCounter--;
|
||||
if (panicCounter <= 0) {
|
||||
ERROR_LOG(COMMON, "CreateFullPath: directory stracture too deep");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Deletes a directory filename, returns true on success
|
||||
bool DeleteDir(const char *filename)
|
||||
{
|
||||
INFO_LOG(COMMON, "DeleteDir: directory %s", filename);
|
||||
|
||||
if (!File::IsDirectory(filename))
|
||||
// check if a directory
|
||||
if (!File::IsDirectory(filename)) {
|
||||
ERROR_LOG(COMMON, "DeleteDir: Not a directory %s",
|
||||
filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
return ::RemoveDirectory (filename) ? true : false;
|
||||
if (::RemoveDirectory(filename))
|
||||
return true;
|
||||
#else
|
||||
if (rmdir(filename) == 0)
|
||||
return true;
|
||||
|
||||
int err = errno;
|
||||
|
||||
PanicAlert("Error removing directory %s",strerror(err));
|
||||
return false;
|
||||
if (rmdir(filename) == 0)
|
||||
return true;
|
||||
#endif
|
||||
ERROR_LOG(COMMON, "DeleteDir: %s: %s",
|
||||
filename, GetLastErrorMsg());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// renames file srcFilename to destFilename, returns true on success
|
||||
bool Rename(const char *srcFilename, const char *destFilename)
|
||||
{
|
||||
return (rename(srcFilename, destFilename) == 0);
|
||||
INFO_LOG(COMMON, "Rename: %s --> %s",
|
||||
srcFilename, destFilename);
|
||||
if (rename(srcFilename, destFilename) == 0)
|
||||
return true;
|
||||
ERROR_LOG(COMMON, "Rename: failed %s --> %s: %s",
|
||||
srcFilename, destFilename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
// copies file srcFilename to destFilename, returns true on success
|
||||
bool Copy(const char *srcFilename, const char *destFilename)
|
||||
{
|
||||
INFO_LOG(COMMON, "Copy: %s --> %s",
|
||||
srcFilename, destFilename);
|
||||
#ifdef _WIN32
|
||||
return (CopyFile(srcFilename, destFilename, FALSE) == TRUE) ? true : false;
|
||||
if (CopyFile(srcFilename, destFilename, FALSE))
|
||||
return true;
|
||||
|
||||
ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s",
|
||||
srcFilename, destFilename, GetLastErrorMsg());
|
||||
return false;
|
||||
#else
|
||||
|
||||
// buffer size
|
||||
#define BSIZE 1024
|
||||
|
||||
int rnum, wnum, err;
|
||||
char buffer[BSIZE];
|
||||
FILE *output, *input;
|
||||
|
||||
if (! (input = fopen(srcFilename, "r"))) {
|
||||
err = errno;
|
||||
PanicAlert("Error copying from %s: %s", srcFilename, strerror(err));
|
||||
return false;
|
||||
}
|
||||
char buffer[BSIZE];
|
||||
|
||||
if (! (output = fopen(destFilename, "w"))) {
|
||||
err = errno;
|
||||
PanicAlert("Error copying to %s: %s", destFilename, strerror(err));
|
||||
return false;
|
||||
}
|
||||
|
||||
while(! feof(input)) {
|
||||
if((rnum = fread(buffer, sizeof(char), BSIZE, input)) != BSIZE) {
|
||||
if(ferror(input) != 0){
|
||||
PanicAlert("can't read source file\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if((wnum = fwrite(buffer, sizeof(char), rnum, output))!= rnum){
|
||||
PanicAlert("can't write output file\n");
|
||||
// Open input file
|
||||
FILE *input = fopen(srcFilename, "rb");
|
||||
if (!input)
|
||||
{
|
||||
ERROR_LOG(COMMON, "Copy: input failed %s --> %s: %s",
|
||||
srcFilename, destFilename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(input);
|
||||
fclose(output);
|
||||
|
||||
return true;
|
||||
/*
|
||||
std::ifstream ifs(srcFilename, std::ios::binary);
|
||||
std::ofstream ofs(destFilename, std::ios::binary);
|
||||
|
||||
ofs << ifs.rdbuf();
|
||||
// open output file
|
||||
FILE *output = fopen(destFilename, "wb");
|
||||
if (!output)
|
||||
{
|
||||
fclose(input);
|
||||
ERROR_LOG(COMMON, "Copy: output failed %s --> %s: %s",
|
||||
srcFilename, destFilename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
ifs.close();
|
||||
ofs.close();
|
||||
|
||||
return true;*/
|
||||
// copy loop
|
||||
while (!feof(input))
|
||||
{
|
||||
// read input
|
||||
int rnum = fread(buffer, sizeof(char), BSIZE, input);
|
||||
if (rnum != BSIZE)
|
||||
{
|
||||
if (ferror(input) != 0) {
|
||||
ERROR_LOG(COMMON,
|
||||
"Copy: failed reading from source, %s --> %s: %s",
|
||||
srcFilename, destFilename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// write output
|
||||
int wnum = fwrite(buffer, sizeof(char), rnum, output)
|
||||
if (wnum != rnum)
|
||||
{
|
||||
ERROR_LOG(COMMON,
|
||||
"Copy: failed writing to output, %s --> %s: %s",
|
||||
srcFilename, destFilename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// close flushs
|
||||
fclose(input);
|
||||
fclose(output);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string GetUserDirectory()
|
||||
// Returns a pointer to a string with a Dolphin data dir in the user's home directory.
|
||||
// To be used in "multi-user" mode (that is, installed).
|
||||
const char *GetUserDirectory()
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
#ifdef _WIN32
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
|
||||
{
|
||||
//return std::string(path);
|
||||
// Make sure we only need to do it once
|
||||
static char path[MAX_PATH] = {0};
|
||||
if (strlen(path) > 0)
|
||||
return path;
|
||||
|
||||
/* I dont understand this, I got "E:\Documents and Settings\All Users\Application Data"
|
||||
from this */
|
||||
return std::string("");
|
||||
}
|
||||
return std::string("");
|
||||
#ifdef WIN32
|
||||
char homedir[MAX_PATH];
|
||||
if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)))
|
||||
return NULL;
|
||||
#else
|
||||
char *homedir = getenv("HOME");
|
||||
if (!homedir)
|
||||
return std::string("");
|
||||
#ifdef __APPLE__
|
||||
snprintf(path, sizeof(path), "%s/Library/Application Support/Dolphin", homedir);
|
||||
#else
|
||||
snprintf(path, sizeof(path), "%s/.dolphin", homedir); // XXX changeme as appropriate
|
||||
return NULL;
|
||||
#endif
|
||||
#endif
|
||||
return std::string(path);
|
||||
|
||||
snprintf(path, sizeof(path), "%s" DIR_SEP DOLPHIN_DATA_DIR, homedir);
|
||||
INFO_LOG(COMMON, "GetUserDirectory: Setting to %s:", path);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
//osx specific functions
|
||||
#if defined(__APPLE__)
|
||||
|
||||
std::string GetBundleDirectory()
|
||||
{
|
||||
|
||||
// Plugin path will be Dolphin.app/Contents/PlugIns
|
||||
CFURLRef BundleRef;
|
||||
char AppBundlePath[MAXPATHLEN];
|
||||
|
||||
// Get the main bundle for the app
|
||||
BundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
|
||||
CFStringRef BundlePath = CFURLCopyFileSystemPath(BundleRef, kCFURLPOSIXPathStyle);
|
||||
CFStringGetFileSystemRepresentation(BundlePath, AppBundlePath, sizeof(AppBundlePath));
|
||||
|
||||
CFRelease(BundleRef);
|
||||
CFRelease(BundlePath);
|
||||
|
||||
return AppBundlePath;
|
||||
|
||||
|
||||
}
|
||||
std::string GetPluginsDirectory()
|
||||
{
|
||||
|
||||
CFURLRef PluginDirRef;
|
||||
char PluginPath[MAXPATHLEN];
|
||||
|
||||
PluginDirRef = CFBundleCopyBuiltInPlugInsURL(CFBundleGetMainBundle());
|
||||
|
||||
CFStringRef PluginDirPath = CFURLCopyFileSystemPath(PluginDirRef, kCFURLPOSIXPathStyle);
|
||||
CFStringGetFileSystemRepresentation(PluginDirPath, PluginPath, sizeof(PluginPath));
|
||||
|
||||
CFRelease(PluginDirRef);
|
||||
CFRelease(PluginDirPath);
|
||||
|
||||
std::string PluginsDir = GetBundleDirectory();
|
||||
PluginsDir += DIR_SEP;
|
||||
PluginsDir += PluginPath;
|
||||
|
||||
return PluginsDir;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
// Returns the size of filename (64bit)
|
||||
u64 GetSize(const char *filename)
|
||||
{
|
||||
if (!Exists(filename))
|
||||
if (!Exists(filename)) {
|
||||
WARN_LOG(COMMON, "GetSize: failed %s: No such file"
|
||||
,filename);
|
||||
return 0;
|
||||
#ifdef _WIN32
|
||||
// stat doesn't support 64-bit file sizes on Win32.
|
||||
FILE *pFile = fopen(filename, "rb");
|
||||
if (pFile)
|
||||
{
|
||||
fseek(pFile, 0, SEEK_END);
|
||||
u64 pos = ftell(pFile);
|
||||
fclose(pFile);
|
||||
return pos;
|
||||
}
|
||||
#else
|
||||
struct stat buf;
|
||||
if (stat(filename, &buf) == 0) {
|
||||
return buf.st_size;
|
||||
}
|
||||
int err = errno;
|
||||
PanicAlert("Error accessing %s: %s", filename, strerror(err));
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
if (IsDirectory(filename)) {
|
||||
WARN_LOG(COMMON, "GetSize: failed %s: is a directory"
|
||||
,filename);
|
||||
return 0;
|
||||
}
|
||||
// on windows it's actually _stat64 defined in commonFuncs
|
||||
struct stat64 buf;
|
||||
if (stat64(filename, &buf) == 0) {
|
||||
return buf.st_size;
|
||||
}
|
||||
|
||||
ERROR_LOG(COMMON, "GetSize: Stat failed %s: %s",
|
||||
filename, GetLastErrorMsg());
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static bool ReadFoundFile(const WIN32_FIND_DATA& ffd, FSTEntry& entry)
|
||||
{
|
||||
// ignore files starting with a .
|
||||
if(strncmp(ffd.cFileName, ".", 1) == 0)
|
||||
return false;
|
||||
|
||||
entry.virtualName = ffd.cFileName;
|
||||
|
||||
if(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
entry.isDirectory = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.isDirectory = false;
|
||||
entry.size = ffd.nFileSizeLow;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry)
|
||||
{
|
||||
// Find the first file in the directory.
|
||||
WIN32_FIND_DATA ffd;
|
||||
std::string searchName = _Directory + "\\*";
|
||||
HANDLE hFind = FindFirstFile(searchName.c_str(), &ffd);
|
||||
|
||||
u32 foundEntries = 0;
|
||||
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
do
|
||||
{
|
||||
FSTEntry entry;
|
||||
|
||||
if(ReadFoundFile(ffd, entry))
|
||||
{
|
||||
entry.physicalName = _Directory + "\\" + entry.virtualName;
|
||||
if(entry.isDirectory)
|
||||
{
|
||||
u32 childEntries = ScanDirectoryTree(entry.physicalName, entry);
|
||||
entry.size = childEntries;
|
||||
foundEntries += childEntries;
|
||||
}
|
||||
|
||||
++foundEntries;
|
||||
|
||||
parentEntry.children.push_back(entry);
|
||||
}
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
}
|
||||
|
||||
FindClose(hFind);
|
||||
|
||||
return foundEntries;
|
||||
}
|
||||
#else
|
||||
u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry)
|
||||
{
|
||||
u32 foundEntries = 0;
|
||||
|
||||
struct dirent dirent, *result = NULL;
|
||||
|
||||
// Find the first file in the directory.
|
||||
DIR *dirp = opendir(_Directory.c_str());
|
||||
|
||||
while (!readdir_r(dirp, &dirent, &result) && result) {
|
||||
FSTEntry entry;
|
||||
if (result->d_name[0]=='.') continue;
|
||||
entry.virtualName = result->d_name;
|
||||
entry.physicalName = _Directory + "/" + entry.virtualName;
|
||||
if (IsDirectory(entry.physicalName.c_str())) {
|
||||
entry.isDirectory = true;
|
||||
entry.size = ScanDirectoryTree(entry.physicalName, entry);
|
||||
foundEntries += entry.size;
|
||||
} else {
|
||||
entry.isDirectory = false;
|
||||
entry.size = GetSize(entry.physicalName.c_str());
|
||||
}
|
||||
|
||||
++foundEntries;
|
||||
|
||||
parentEntry.children.push_back(entry);
|
||||
}
|
||||
closedir(dirp);
|
||||
|
||||
return foundEntries;
|
||||
}
|
||||
#endif
|
||||
|
||||
// creates an empty file filename, returns true on success
|
||||
bool CreateEmptyFile(const char *filename)
|
||||
{
|
||||
FILE* pFile = fopen(filename, "wb");
|
||||
if (pFile == NULL)
|
||||
return false;
|
||||
INFO_LOG(COMMON, "CreateEmptyFile: %s", filename);
|
||||
|
||||
FILE *pFile = fopen(filename, "wb");
|
||||
if (!pFile) {
|
||||
ERROR_LOG(COMMON, "CreateEmptyFile: failed %s: %s",
|
||||
filename, GetLastErrorMsg());
|
||||
return false;
|
||||
}
|
||||
fclose(pFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DeleteDirRecursively(const std::string& _Directory)
|
||||
// Scans the directory tree gets, starting from _Directory and adds the
|
||||
// results into parentEntry. Returns the number of files+directories found
|
||||
u32 ScanDirectoryTree(const char *directory, FSTEntry& parentEntry)
|
||||
{
|
||||
INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory);
|
||||
// How many files + directories we found
|
||||
u32 foundEntries = 0;
|
||||
char *virtualName;
|
||||
#ifdef _WIN32
|
||||
|
||||
bool Result = false;
|
||||
|
||||
// Find the first file in the directory.
|
||||
WIN32_FIND_DATA ffd;
|
||||
std::string searchName = _Directory + "\\*";
|
||||
HANDLE hFind = FindFirstFile(searchName.c_str(), &ffd);
|
||||
char searchName[MAX_PATH + 3];
|
||||
strncpy(searchName, directory, MAX_PATH);
|
||||
strcat(searchName, "\\*");
|
||||
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
do
|
||||
{
|
||||
// check for "." and ".."
|
||||
if (((ffd.cFileName[0] == '.') && (ffd.cFileName[1] == 0x00)) ||
|
||||
((ffd.cFileName[0] == '.') && (ffd.cFileName[1] == '.') && (ffd.cFileName[2] == 0x00)))
|
||||
continue;
|
||||
|
||||
// build path
|
||||
std::string newPath(_Directory);
|
||||
newPath += '\\';
|
||||
newPath += ffd.cFileName;
|
||||
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (!File::DeleteDirRecursively(newPath))
|
||||
goto error_jmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!File::Delete(newPath.c_str()))
|
||||
goto error_jmp;
|
||||
}
|
||||
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
HANDLE hFind = FindFirstFile(searchName, &ffd);
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
FindClose(hFind);
|
||||
return foundEntries;
|
||||
}
|
||||
|
||||
if (!File::DeleteDir(_Directory.c_str()))
|
||||
goto error_jmp;
|
||||
|
||||
Result = true;
|
||||
|
||||
error_jmp:
|
||||
|
||||
FindClose(hFind);
|
||||
|
||||
return Result;
|
||||
// windows loop
|
||||
do {
|
||||
FSTEntry entry;
|
||||
virtualName = ffd.cFileName;
|
||||
#else
|
||||
// taken from http://www.dreamincode.net/code/snippet2700.htm
|
||||
DIR *pdir = NULL;
|
||||
pdir = opendir (_Directory.c_str());
|
||||
struct dirent *pent = NULL;
|
||||
|
||||
if (pdir == NULL) {
|
||||
return false;
|
||||
}
|
||||
struct dirent dirent, *result = NULL;
|
||||
|
||||
DIR *dirp = opendir(directory);
|
||||
if (!dirp)
|
||||
return 0;
|
||||
|
||||
char file[256];
|
||||
|
||||
int counter = 1;
|
||||
|
||||
while ((pent = readdir(pdir))) {
|
||||
if (counter > 2) {
|
||||
for (int i = 0; i < 256; i++) file[i] = '\0';
|
||||
strcat(file, _Directory.c_str());
|
||||
if (pent == NULL) {
|
||||
return false;
|
||||
}
|
||||
strcat(file, pent->d_name);
|
||||
if (IsDirectory(file) == true) {
|
||||
DeleteDir(file);
|
||||
} else {
|
||||
remove(file);
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
return DeleteDir(_Directory.c_str());
|
||||
// non windows loop
|
||||
while (!readdir_r(dirp, &dirent, &result) && result) {
|
||||
FSTEntry entry;
|
||||
virtualName = result->d_name;
|
||||
#endif
|
||||
// check for "." and ".."
|
||||
if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
|
||||
((virtualName[0] == '.') && (virtualName[1] == '.') &&
|
||||
(virtualName[2] == '\0')))
|
||||
continue;
|
||||
entry.virtualName = virtualName;
|
||||
entry.physicalName = directory;
|
||||
entry.physicalName += DIR_SEP + entry.virtualName;
|
||||
|
||||
if (IsDirectory(entry.physicalName.c_str())) {
|
||||
entry.isDirectory = true;
|
||||
// is a directory, lets go inside
|
||||
entry.size = ScanDirectoryTree(entry.physicalName.c_str(), entry);
|
||||
foundEntries += (u32)entry.size;
|
||||
} else { // is a file
|
||||
entry.isDirectory = false;
|
||||
entry.size = GetSize(entry.physicalName.c_str());
|
||||
}
|
||||
++foundEntries;
|
||||
// Push into the tree
|
||||
parentEntry.children.push_back(entry);
|
||||
#ifdef _WIN32
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
FindClose(hFind);
|
||||
#else
|
||||
}
|
||||
closedir(dirp);
|
||||
#endif
|
||||
// Return number of entries found.
|
||||
return foundEntries;
|
||||
}
|
||||
|
||||
void GetCurrentDirectory(std::string& _rDirectory)
|
||||
|
||||
// deletes the given directory and anything under it. Returns true on
|
||||
// success.
|
||||
bool DeleteDirRecursively(const char *directory)
|
||||
{
|
||||
char tmpBuffer[MAX_PATH+1];
|
||||
_rDirectory = getcwd(tmpBuffer, MAX_PATH);
|
||||
INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory);
|
||||
#ifdef _WIN32
|
||||
// Find the first file in the directory.
|
||||
WIN32_FIND_DATA ffd;
|
||||
char searchName[MAX_PATH + 3] = {0};
|
||||
|
||||
strncpy(searchName, directory, MAX_PATH);
|
||||
strcat(searchName, "\\*");
|
||||
|
||||
HANDLE hFind = FindFirstFile(searchName, &ffd);
|
||||
|
||||
if (hFind == INVALID_HANDLE_VALUE) {
|
||||
FindClose(hFind);
|
||||
return false;
|
||||
}
|
||||
|
||||
// windows loop
|
||||
do {
|
||||
char *virtualName = ffd.cFileName;
|
||||
#else
|
||||
struct dirent dirent, *result = NULL;
|
||||
DIR *dirp = opendir(directory);
|
||||
if (!dirp)
|
||||
return false;
|
||||
|
||||
// non windows loop
|
||||
while (!readdir_r(dirp, &dirent, &result) && result) {
|
||||
char *virtualName = result->d_name;
|
||||
#endif
|
||||
|
||||
// check for "." and ".."
|
||||
if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
|
||||
((virtualName[0] == '.') && (virtualName[1] == '.') &&
|
||||
(virtualName[2] == '\0')))
|
||||
continue;
|
||||
|
||||
char newPath[MAX_PATH];
|
||||
sprintf(newPath, "%s%c%s", directory, DIR_SEP_CHR, virtualName);
|
||||
if (IsDirectory(newPath)) {
|
||||
if (!DeleteDirRecursively(newPath))
|
||||
return false;
|
||||
} else {
|
||||
if (!File::Delete(newPath))
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
} while (FindNextFile(hFind, &ffd) != 0);
|
||||
FindClose(hFind);
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
File::DeleteDir(directory);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetCurrentDirectory(const std::string& _rDirectory)
|
||||
// Returns the current directory, caller should free
|
||||
const char *GetCurrentDirectory()
|
||||
{
|
||||
return chdir(_rDirectory.c_str()) == 0;
|
||||
const char *dir;
|
||||
// Get the current working directory (getcwd uses malloc)
|
||||
if (!(dir = getcwd(NULL, 0))) {
|
||||
|
||||
ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s",
|
||||
GetLastErrorMsg());
|
||||
return NULL;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
// Sets the current directory to the given directory
|
||||
bool SetCurrentDirectory(const char *_rDirectory)
|
||||
{
|
||||
return chdir(_rDirectory) == 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -20,45 +20,73 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
/*
|
||||
This namespace has various generic functions related to files and paths.
|
||||
*/
|
||||
namespace File
|
||||
{
|
||||
|
||||
|
||||
// FileSystem tree node/
|
||||
struct FSTEntry
|
||||
{
|
||||
bool isDirectory;
|
||||
u32 size; // file length or number of entries from children
|
||||
u64 size; // file length or number of entries from children
|
||||
std::string physicalName; // name on disk
|
||||
std::string virtualName; // name in FST names table
|
||||
std::vector<FSTEntry> children;
|
||||
};
|
||||
|
||||
std::string SanitizePath(const char *filename);
|
||||
|
||||
// Returns true if file filename exists
|
||||
bool Exists(const char *filename);
|
||||
|
||||
// Returns true if filename is a directory
|
||||
bool IsDirectory(const char *filename);
|
||||
bool IsDisk(const char *filename);
|
||||
bool CreateDir(const char *filename);
|
||||
bool CreateDirectoryStructure(const std::string& _rFullPath);
|
||||
bool Delete(const char *filename);
|
||||
bool DeleteDir(const char *filename);
|
||||
bool Rename(const char *srcFilename, const char *destFilename);
|
||||
bool Copy(const char *srcFilename, const char *destFilename);
|
||||
|
||||
// Returns the size of filename (64bit)
|
||||
u64 GetSize(const char *filename);
|
||||
std::string GetUserDirectory();
|
||||
|
||||
// Returns true if successful, or path already exists.
|
||||
bool CreateDir(const char *filename);
|
||||
|
||||
// Creates the full path of fullPath returns true on success
|
||||
bool CreateFullPath(const char *fullPath);
|
||||
|
||||
// Deletes a given filename, return true on success
|
||||
// Doesn't supports deleting a directory
|
||||
bool Delete(const char *filename);
|
||||
|
||||
// Deletes a directory filename, returns true on success
|
||||
bool DeleteDir(const char *filename);
|
||||
|
||||
// renames file srcFilename to destFilename, returns true on success
|
||||
bool Rename(const char *srcFilename, const char *destFilename);
|
||||
|
||||
// copies file srcFilename to destFilename, returns true on success
|
||||
bool Copy(const char *srcFilename, const char *destFilename);
|
||||
|
||||
// creates an empty file filename, returns true on success
|
||||
bool CreateEmptyFile(const char *filename);
|
||||
|
||||
u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry);
|
||||
|
||||
bool DeleteDirRecursively(const std::string& _Directory);
|
||||
void GetCurrentDirectory(std::string& _rDirectory);
|
||||
bool SetCurrentDirectory(const std::string& _rDirectory);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
std::string GetPluginsDirectory();
|
||||
#endif
|
||||
|
||||
|
||||
// Scans the directory tree gets, starting from _Directory and adds the
|
||||
// results into parentEntry. Returns the number of files+directories found
|
||||
u32 ScanDirectoryTree(const char *directory, FSTEntry& parentEntry);
|
||||
|
||||
// deletes the given directory and anything under it. Returns true on success.
|
||||
bool DeleteDirRecursively(const char *directory);
|
||||
|
||||
// Returns the current directory, caller should free
|
||||
const char *GetCurrentDirectory();
|
||||
|
||||
// Set the current directory to given directory
|
||||
bool SetCurrentDirectory(const char *directory);
|
||||
|
||||
// Returns a pointer to a string with the dolphin data dir
|
||||
const char *GetUserDirectory();
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _HASH_H
|
||||
#define _HASH_H
|
||||
|
||||
|
@ -24,5 +25,4 @@ u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightl
|
|||
u32 HashFNV(const u8* ptr, int length); // Another fast and decent hash
|
||||
u32 HashEctor(const u8* ptr, int length); // JUNK. DO NOT USE FOR NEW THINGS
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -459,10 +459,10 @@ bool IniFile::Get(const char* sectionName, const char* key, std::vector<std::str
|
|||
return false;
|
||||
}
|
||||
|
||||
u32 subEnd;
|
||||
|
||||
// ignore starting , if any
|
||||
u32 subStart = temp.find_first_not_of(",");
|
||||
size_t subStart = temp.find_first_not_of(",");
|
||||
size_t subEnd;
|
||||
|
||||
// split by ,
|
||||
while (subStart != std::string::npos) {
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
// 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 _LOG_H
|
||||
#define _LOG_H
|
||||
|
||||
namespace LogTypes
|
||||
{
|
||||
|
||||
enum LOG_TYPE {
|
||||
ACTIONREPLAY,
|
||||
AUDIO,
|
||||
AUDIO_INTERFACE,
|
||||
BOOT,
|
||||
COMMANDPROCESSOR,
|
||||
COMMON,
|
||||
CONSOLE,
|
||||
DSPHLE,
|
||||
DSPINTERFACE,
|
||||
DVDINTERFACE,
|
||||
DYNA_REC,
|
||||
EXPANSIONINTERFACE,
|
||||
GEKKO,
|
||||
GPFIFO,
|
||||
HLE,
|
||||
MASTER_LOG,
|
||||
MEMMAP,
|
||||
OSREPORT,
|
||||
PERIPHERALINTERFACE,
|
||||
PIXELENGINE,
|
||||
SERIALINTERFACE,
|
||||
STREAMINGINTERFACE,
|
||||
VIDEO,
|
||||
VIDEOINTERFACE,
|
||||
WII_IOB,
|
||||
WII_IPC,
|
||||
WII_IPC_DVD,
|
||||
WII_IPC_ES,
|
||||
WII_IPC_FILEIO,
|
||||
WII_IPC_HLE,
|
||||
WII_IPC_NET,
|
||||
WII_IPC_SD,
|
||||
WII_IPC_WIIMOTE,
|
||||
|
||||
NUMBER_OF_LOGS // Must be last
|
||||
};
|
||||
|
||||
enum LOG_LEVELS {
|
||||
LERROR, // Bad errors - that still don't deserve a PanicAlert.
|
||||
LWARNING, // Something is suspicious.
|
||||
LINFO, // General information.
|
||||
LDEBUG, // Strictly for detailed debugging - might make things slow.
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#ifdef LOGGING
|
||||
|
||||
extern void __Log(int logNumber, const char* text, ...);
|
||||
extern void __Logv(int log, int v, const char *format, ...);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define LOG(t, ...) __Log(LogTypes::t, __VA_ARGS__);
|
||||
#define LOGV(t, v, ...) __Log(LogTypes::t + (v)*100, __VA_ARGS__);
|
||||
#define LOGP(t, ...) __Log(t, __VA_ARGS__);
|
||||
#define LOGVP(t, v, ...) __Log(t + (v)*100, __VA_ARGS__);
|
||||
#define ERROR_LOG(t, ...) {LOGV(t, LogTypes::LERROR, __VA_ARGS__)}
|
||||
#define WARN_LOG(t, ...) {LOGV(t, LogTypes::LINFO, __VA_ARGS__)}
|
||||
#define INFO_LOG(t, ...) {LOGV(t, LogTypes::LWARNING, __VA_ARGS__)}
|
||||
#define DEBUG_LOG(t ,...) {LOGV(t, LogTypes::LDEBUG, __VA_ARGS__)}
|
||||
|
||||
#else
|
||||
|
||||
#define LOG(t, ...) __Log(LogTypes::t, ##__VA_ARGS__);
|
||||
#define LOGV(t,v, ...) __Log(LogTypes::t + (v)*100, ##__VA_ARGS__);
|
||||
#define LOGP(t, ...) __Log(t, ##__VA_ARGS__);
|
||||
#define LOGVP(t,v, ...) __Log(t + (v)*100, ##__VA_ARGS__);
|
||||
#define ERROR_LOG(t,...) {LOGV(t, LogTypes::LERROR, ##__VA_ARGS__)}
|
||||
#define WARN_LOG(t,...) {LOGV(t, LogTypes::LINFO, ##__VA_ARGS__)}
|
||||
#define INFO_LOG(t,...) {LOGV(t, LogTypes::LWARNING, ##__VA_ARGS__)}
|
||||
#define DEBUG_LOG(t,...) {LOGV(t, LogTypes::LDEBUG, ##__VA_ARGS__)}
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
#define _dbg_assert_(_t_, _a_) \
|
||||
if (!(_a_)) {\
|
||||
LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
|
||||
__LINE__, __FILE__, __TIME__); \
|
||||
if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \
|
||||
}
|
||||
#define _dbg_assert_msg_(_t_, _a_, ...)\
|
||||
if (!(_a_)) {\
|
||||
LOG(_t_, __VA_ARGS__); \
|
||||
if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
|
||||
}
|
||||
#define _dbg_update_() Host_UpdateLogDisplay();
|
||||
|
||||
#else
|
||||
|
||||
#define LOG(_t_, ...)
|
||||
#define LOGV(_t_, _v_, ...)
|
||||
#define LOGP(_t_, ...)
|
||||
#define LOGVP(_t_, _v_, ...)
|
||||
|
||||
#define _dbg_clear_()
|
||||
#define _dbg_update_() ;
|
||||
|
||||
#ifndef _dbg_assert_
|
||||
#define _dbg_assert_(_t_, _a_) ;
|
||||
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) ;
|
||||
#endif
|
||||
|
||||
#define ERROR_LOG(t, ...) ;
|
||||
#define WARN_LOG(t, ...) ;
|
||||
#define INFO_LOG(t ,...) ;
|
||||
#define DEBUG_LOG(t, ...) ;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
||||
#define _assert_msg_(_t_, _a_, _fmt_, ...)\
|
||||
if (!(_a_)) {\
|
||||
if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
|
||||
}
|
||||
#else
|
||||
#define _assert_(a)
|
||||
#define _assert_msg_(...)
|
||||
#endif
|
||||
|
||||
#endif // LOG_H
|
|
@ -0,0 +1,50 @@
|
|||
// 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"
|
||||
|
||||
// Generic function to get last error message.
|
||||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
const char *GetLastErrorMsg()
|
||||
{
|
||||
// FIXME : not thread safe.
|
||||
// Caused by sloppy use in logging in FileUtil.cpp, primarily. What to do, what to do ...
|
||||
static char errStr[255] = {0};
|
||||
#ifdef _WIN32
|
||||
DWORD dw = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) errStr, 254, NULL );
|
||||
#else
|
||||
// Thread safe (XSI-compliant)
|
||||
strerror_r(errno, errStr, 255);
|
||||
#endif
|
||||
return errStr;
|
||||
}
|
||||
|
||||
char *strndup (char const *s, size_t n)
|
||||
{
|
||||
size_t len = strnlen(s, n);
|
||||
char *dup = (char *)malloc(len + 1);
|
||||
|
||||
if (dup == NULL)
|
||||
return NULL;
|
||||
|
||||
dup[len] = '\0';
|
||||
return (char *)memcpy(dup, s, len);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
// 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 MSGHANDLER_H
|
||||
#define MSGHANDLER_H
|
||||
// Message alerts
|
||||
enum MSG_TYPE
|
||||
{
|
||||
INFORMATION,
|
||||
QUESTION,
|
||||
WARNING,
|
||||
};
|
||||
|
||||
typedef bool (*MsgAlertHandler)(const char* caption, const char* text,
|
||||
bool yes_no, int Style);
|
||||
void RegisterMsgAlertHandler(MsgAlertHandler handler);
|
||||
extern bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...);
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SuccessAlert(format, ...) MsgAlert("Information", false, INFORMATION, format, __VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert("Warning", false, WARNING, format, __VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert("Warning", true, WARNING, format, __VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert("Question", true, QUESTION, format, __VA_ARGS__)
|
||||
#else
|
||||
#define SuccessAlert(format, ...) MsgAlert("SUCCESS", false, INFORMATION, format, ##__VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert("PANIC", false, WARNING, format, ##__VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert("PANIC", true, WARNING, format, ##__VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert("ASK", true, QUESTION, format, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif //MSGHANDLER
|
|
@ -17,6 +17,7 @@ files = [
|
|||
"FileUtil.cpp",
|
||||
"MappedFile.cpp",
|
||||
"MathUtil.cpp",
|
||||
"Misc.cpp",
|
||||
"MemArena.cpp",
|
||||
"MemoryUtil.cpp",
|
||||
"Plugin.cpp",
|
||||
|
|
|
@ -80,10 +80,10 @@ u32 Ascii2Hex(std::string _Text)
|
|||
if (Length > 4)
|
||||
Length = 4;
|
||||
|
||||
for (int i = 0; i < Length; i++)
|
||||
for (int i = 0; i < (int)Length; i++)
|
||||
{
|
||||
// Add up the values, for example RSPE becomes, 0x52000000, then 0x52530000 and so on
|
||||
Result += _Text.c_str()[i] << (Length - 1 - i)*8;
|
||||
Result += _Text.c_str()[i] << ((Length - 1 - i) * 8);
|
||||
}
|
||||
// Return the value
|
||||
return Result;
|
||||
|
|
|
@ -104,7 +104,7 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename)
|
|||
sprintf(Path, FULL_WII_USER_DIR "title//%02x%02x%02x%02x/%02x%02x%02x%02x/data/nocopy/",
|
||||
(u8)pTitleID[7], (u8)pTitleID[6], (u8)pTitleID[5], (u8)pTitleID[4],
|
||||
(u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]);
|
||||
File::CreateDirectoryStructure(Path);
|
||||
File::CreateFullPath(Path);
|
||||
|
||||
Memory::Write_U64( ContentLoader.GetTitleID(), 0x0000318c); // NAND Load Title ID
|
||||
|
||||
|
@ -121,3 +121,4 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,14 +64,7 @@
|
|||
#ifndef _WIN32
|
||||
#define WINAPI
|
||||
#endif
|
||||
////////////////////////////////////////
|
||||
|
||||
|
||||
// The idea behind the recent restructure is to fix various stupid problems.
|
||||
// glXMakeCurrent/ wglMakeCurrent takes a context and makes it current on the current thread.
|
||||
// So it's fine to init ogl on one thread, and then make it current and start blasting on another.
|
||||
|
||||
|
||||
|
||||
namespace Core
|
||||
{
|
||||
|
||||
|
@ -355,7 +348,7 @@ THREAD_RETURN CpuThread(void *pArg)
|
|||
return 0;
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Initalize plugins and create emulation thread
|
||||
|
@ -497,10 +490,7 @@ THREAD_RETURN EmuThread(void *pArg)
|
|||
// Spawn the CPU thread
|
||||
Common::Thread *cpuThread = NULL;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ENTER THE VIDEO THREAD LOOP
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (!_CoreParameter.bUseDualCore)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -534,6 +524,7 @@ THREAD_RETURN EmuThread(void *pArg)
|
|||
//Console::Print("Video loop [Video Thread]: Stopped\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EmuThreadEnd()
|
||||
{
|
||||
CPluginManager &Plugins = CPluginManager::GetInstance();
|
||||
|
@ -559,18 +550,6 @@ void EmuThreadEnd()
|
|||
|
||||
// We have now exited the Video Loop and will shut down
|
||||
|
||||
// does this comment still apply?
|
||||
/* JP: Perhaps not, but it's not the first time one of these waiting loops have failed. They seem inherently
|
||||
dysfunctional because they can hang the very thread they are waiting for, so they should be replaced by timers like I did
|
||||
in the Wiimote plugin. Or any alterantive that does not hang the thread it's waiting for. Sleep() hangs the other thread to,
|
||||
just like a loop, so that is not an option. */
|
||||
/* Check if we are using single core and are rendering to the main window. In that case we must avoid the WaitForSingleObject()
|
||||
loop in the cpu thread thread, because it will hang on occation, perhaps one time in three or so. I had this problem in the Wiimote plugin, what happened was that if I entered the
|
||||
WaitForSingleObject loop or any loop at all in the main thread, the separate thread would halt at a place where it called a function in
|
||||
the wxDialog class. The solution was to wait for the thread to stop with a timer from the wxDialog, and the proceed to shutdown.
|
||||
Perhaps something like that can be done here to? I just don't exactly how since in single core mode there should only be one
|
||||
thread right? So how can WaitForSingleObject() hang in it? */
|
||||
|
||||
// Write message
|
||||
if (g_pUpdateFPSDisplay != NULL)
|
||||
g_pUpdateFPSDisplay("Stopping...");
|
||||
|
@ -760,14 +739,13 @@ void Callback_PADLog(const TCHAR* _szMessage)
|
|||
// __________________________________________________________________________________________________
|
||||
// Callback_ISOName: Let the DSP plugin get the game name
|
||||
//
|
||||
//std::string Callback_ISOName(void)
|
||||
const char *Callback_ISOName(void)
|
||||
const char *Callback_ISOName()
|
||||
{
|
||||
SCoreStartupParameter& params = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
||||
if (params.m_strName.length() > 0)
|
||||
return (const char *)params.m_strName.c_str();
|
||||
return params.m_strName.c_str();
|
||||
else
|
||||
return (const char *)"";
|
||||
return "";
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
|
@ -800,4 +778,3 @@ const SCoreStartupParameter& GetStartupParameter() {
|
|||
}
|
||||
|
||||
} // end of namespace Core
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void PrintCallstack(LogTypes::LOG_TYPE type)
|
|||
{
|
||||
u32 addr = Memory::ReadUnchecked_U32(PowerPC::ppcState.gpr[1]); // SP
|
||||
|
||||
LOGVP(type, 1, "\n == STACK TRACE - SP = %08x ==\n", PowerPC::ppcState.gpr[1]);
|
||||
LOGVP(type, 1, "\n == STACK TRACE - SP = %08x ==\n", PowerPC::ppcState.gpr[1]);
|
||||
|
||||
if (LR == 0) {
|
||||
LOGVP(type, 1, " LR = 0 - this is bad\n");
|
||||
|
@ -137,10 +137,10 @@ void PrintCallstack(LogTypes::LOG_TYPE type)
|
|||
void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const char* _title)
|
||||
{
|
||||
LOGP(type, _title);
|
||||
for (u32 j=0; j<_Size;)
|
||||
for (u32 j = 0; j < _Size;)
|
||||
{
|
||||
std::string Temp;
|
||||
for (int i=0; i<16; i++)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
char Buffer[128];
|
||||
sprintf(Buffer, "%02x ", _pData[j++]);
|
||||
|
@ -149,7 +149,6 @@ void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const ch
|
|||
if (j >= _Size)
|
||||
break;
|
||||
}
|
||||
|
||||
LOGP(type, " Data: %s", Temp.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ void Update();
|
|||
// Calls by DSP plugin
|
||||
u32 Callback_GetStreaming(short* _pDestBuffer, u32 _numSamples);
|
||||
|
||||
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
|
||||
// Get the audio rates (48000 or 32000 only)
|
||||
u32 GetAISampleRate();
|
||||
|
|
|
@ -62,10 +62,10 @@ void Shutdown();
|
|||
void DoState(PointerWrap &p);
|
||||
|
||||
// Read
|
||||
void HWCALL Read16(u16& _rReturnValue, const u32 _Address);
|
||||
void HWCALL Write16(const u16 _Data, const u32 _Address);
|
||||
void HWCALL Read32(u32& _rReturnValue, const u32 _Address);
|
||||
void HWCALL Write32(const u32 _Data, const u32 _Address);
|
||||
void Read16(u16& _rReturnValue, const u32 _Address);
|
||||
void Write16(const u16 _Data, const u32 _Address);
|
||||
void Read32(u32& _rReturnValue, const u32 _Address);
|
||||
void Write32(const u32 _Data, const u32 _Address);
|
||||
|
||||
// for CGPFIFO
|
||||
void CatchUpGPU();
|
||||
|
@ -86,3 +86,4 @@ bool IsCommandProcessorNotUsed();
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ void GenerateDSPInterrupt(DSPInterruptType _DSPInterruptType, bool _bSet = true)
|
|||
void GenerateDSPInterruptFromPlugin(DSPInterruptType _DSPInterruptType, bool _bSet = true);
|
||||
|
||||
// Read32
|
||||
void HWCALL Read16(u16& _uReturnValue, const u32 _uAddress);
|
||||
void HWCALL Read32(u32& _uReturnValue, const u32 _uAddress);
|
||||
void Read16(u16& _uReturnValue, const u32 _uAddress);
|
||||
void Read32(u32& _uReturnValue, const u32 _uAddress);
|
||||
|
||||
// Write
|
||||
void HWCALL Write16(const u16 _uValue, const u32 _uAddress);
|
||||
void HWCALL Write32(const u32 _uValue, const u32 _uAddress);
|
||||
void Write16(const u16 _uValue, const u32 _uAddress);
|
||||
void Write32(const u32 _uValue, const u32 _uAddress);
|
||||
|
||||
// Audio/DSP Plugin Helper
|
||||
u8 ReadARAM(const u32 _uAddress);
|
||||
|
@ -58,3 +58,4 @@ void UpdateAudioDMA();
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -40,12 +40,13 @@ bool DVDRead(u32 _iDVDOffset, u32 _iRamAddress, u32 _iLength);
|
|||
bool DVDReadADPCM(u8* _pDestBuffer, u32 _iNumSamples);
|
||||
|
||||
// Read32
|
||||
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
|
||||
// Write32
|
||||
void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
|
||||
} // end of namespace DVDInterface
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ void DoState(PointerWrap &p);
|
|||
void Update();
|
||||
void UpdateInterrupts();
|
||||
|
||||
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
|
||||
} // end of namespace ExpansionInterface
|
||||
|
||||
|
|
|
@ -45,19 +45,18 @@ void CheckGatherPipe();
|
|||
bool IsEmpty();
|
||||
|
||||
// Write
|
||||
void HWCALL Write8(const u8 _iValue, const u32 _iAddress);
|
||||
void HWCALL Write16(const u16 _iValue, const u32 _iAddress);
|
||||
void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void HWCALL Write64(const u64 _iValue, const u32 _iAddress);
|
||||
void Write8(const u8 _iValue, const u32 _iAddress);
|
||||
void Write16(const u16 _iValue, const u32 _iAddress);
|
||||
void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void Write64(const u64 _iValue, const u32 _iAddress);
|
||||
|
||||
// These expect pre-byteswapped values
|
||||
// Also there's an upper limit of about 512 per batch
|
||||
// Most likely these should be inlined into JIT instead
|
||||
void HWCALL FastWrite8(const u8 _iValue);
|
||||
void HWCALL FastWrite16(const u16 _iValue);
|
||||
void HWCALL FastWrite32(const u32 _iValue);
|
||||
void HWCALL FastWrite64(const u64 _iValue);
|
||||
|
||||
void FastWrite8(const u8 _iValue);
|
||||
void FastWrite16(const u16 _iValue);
|
||||
void FastWrite32(const u32 _iValue);
|
||||
void FastWrite64(const u64 _iValue);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -140,18 +140,18 @@ readFn64 hwReadWii64[NUMHWMEMFUN];
|
|||
u32 CheckDTLB(u32 _Address, XCheckTLBFlag _Flag);
|
||||
|
||||
template <class T>
|
||||
void HWCALL HW_Default_Write(const T _Data, const u32 _Address){ LOG(MASTER_LOG, "Illegal HW Write%i %08x", sizeof(T)*8, _Address);_dbg_assert_(MEMMAP, 0);}
|
||||
void HW_Default_Write(const T _Data, const u32 _Address){ LOG(MASTER_LOG, "Illegal HW Write%i %08x", sizeof(T)*8, _Address);_dbg_assert_(MEMMAP, 0);}
|
||||
|
||||
template <class T>
|
||||
void HWCALL HW_Default_Read(T _Data, const u32 _Address){ LOG(MASTER_LOG, "Illegal HW Read%i %08x", sizeof(T)*8, _Address); _dbg_assert_(MEMMAP, 0);}
|
||||
void HW_Default_Read(T _Data, const u32 _Address){ LOG(MASTER_LOG, "Illegal HW Read%i %08x", sizeof(T)*8, _Address); _dbg_assert_(MEMMAP, 0);}
|
||||
|
||||
|
||||
#define PAGE_SHIFT 10
|
||||
#define PAGE_SIZE (1 << PAGE_SHIFT)
|
||||
#define PAGE_MASK (PAGE_SHIFT - 1)
|
||||
|
||||
template <class T, u8* P> void HWCALL HW_Read_Memory(T &_Data, const u32 _Address) { _Data = *(T*)&P[_Address & PAGE_MASK]; }
|
||||
template <class T, u8* P> void HWCALL HW_Write_Memory(T _Data, const u32 _Address) { *(T*)&P[_Address & PAGE_MASK] = _Data; }
|
||||
template <class T, u8* P> void HW_Read_Memory(T &_Data, const u32 _Address) { _Data = *(T*)&P[_Address & PAGE_MASK]; }
|
||||
template <class T, u8* P> void HW_Write_Memory(T _Data, const u32 _Address) { *(T*)&P[_Address & PAGE_MASK] = _Data; }
|
||||
/////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -18,38 +18,30 @@
|
|||
#ifndef _MEMMAP_H
|
||||
#define _MEMMAP_H
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ----------------
|
||||
#include <string>
|
||||
#include "Common.h"
|
||||
////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Global declarations
|
||||
// ----------------
|
||||
class PointerWrap;
|
||||
|
||||
typedef void (HWCALL *writeFn8 )(const u8, const u32);
|
||||
typedef void (HWCALL *writeFn16)(const u16,const u32);
|
||||
typedef void (HWCALL *writeFn32)(const u32,const u32);
|
||||
typedef void (HWCALL *writeFn64)(const u64,const u32);
|
||||
|
||||
typedef void (HWCALL *readFn8 )(u8&, const u32);
|
||||
typedef void (HWCALL *readFn16)(u16&, const u32);
|
||||
typedef void (HWCALL *readFn32)(u32&, const u32);
|
||||
typedef void (HWCALL *readFn64)(u64&, const u32);
|
||||
////////////////////////////
|
||||
typedef void (*writeFn8 )(const u8, const u32);
|
||||
typedef void (*writeFn16)(const u16,const u32);
|
||||
typedef void (*writeFn32)(const u32,const u32);
|
||||
typedef void (*writeFn64)(const u64,const u32);
|
||||
|
||||
typedef void (*readFn8 )(u8&, const u32);
|
||||
typedef void (*readFn16)(u16&, const u32);
|
||||
typedef void (*readFn32)(u32&, const u32);
|
||||
typedef void (*readFn64)(u64&, const u32);
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
// Base is a pointer to the base of the memory map. Yes, some MMU tricks are used to set up
|
||||
// a full GC or Wii memory map in process memory.
|
||||
// on 32-bit, you have to mask your offsets with 0x3FFFFFFF. This means that some things are mirrored,
|
||||
// but eh... it works.
|
||||
/* Base is a pointer to the base of the memory map. Yes, some MMU tricks
|
||||
are used to set up a full GC or Wii memory map in process memory. on
|
||||
32-bit, you have to mask your offsets with 0x3FFFFFFF. This means that
|
||||
some things are mirrored, but eh... it works. */
|
||||
|
||||
extern u8 *base;
|
||||
extern u8* m_pRAM;
|
||||
extern u8* m_pL1Cache;
|
||||
|
@ -83,9 +75,7 @@ namespace Memory
|
|||
void Clear();
|
||||
bool AreMemoryBreakpointsActivated();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// ONLY for use by GUI
|
||||
// ----------------
|
||||
u8 ReadUnchecked_U8(const u32 _Address);
|
||||
u32 ReadUnchecked_U32(const u32 _Address);
|
||||
|
||||
|
@ -111,26 +101,19 @@ namespace Memory
|
|||
}
|
||||
|
||||
u32 Read_Opcode(const u32 _Address);
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// For use by emulator
|
||||
// ----------------
|
||||
|
||||
// =================================
|
||||
/* Local byteswap shortcuts. They are placed inline so that they may hopefully be executed faster
|
||||
than otherwise */
|
||||
// ----------------
|
||||
inline u8 bswap(u8 val) {return val;}
|
||||
inline u16 bswap(u16 val) {return Common::swap16(val);}
|
||||
inline u32 bswap(u32 val) {return Common::swap32(val);}
|
||||
inline u64 bswap(u64 val) {return Common::swap64(val);}
|
||||
// =================
|
||||
|
||||
// =================================
|
||||
// Read and write functions
|
||||
// ----------------
|
||||
#define NUMHWMEMFUN 64
|
||||
#define HWSHIFT 10
|
||||
#define HW_MASK 0x3FF
|
||||
|
@ -153,11 +136,8 @@ namespace Memory
|
|||
void DMA_LCToMemory(const u32 _iMemAddr, const u32 _iCacheAddr, const u32 _iNumBlocks);
|
||||
void DMA_MemoryToLC(const u32 _iCacheAddr, const u32 _iMemAddr, const u32 _iNumBlocks);
|
||||
void Memset(const u32 _Address, const u8 _Data, const u32 _iLength);
|
||||
// =================
|
||||
|
||||
// =================================
|
||||
// TLB functions
|
||||
// ----------------
|
||||
void SDRUpdated();
|
||||
enum XCheckTLBFlag
|
||||
{
|
||||
|
@ -169,9 +149,6 @@ namespace Memory
|
|||
u32 CheckDTLB(u32 _Address, XCheckTLBFlag _Flag);
|
||||
extern u32 pagetable_base;
|
||||
extern u32 pagetable_hashmask;
|
||||
// ================
|
||||
|
||||
/////////////////////////////
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,11 +24,12 @@ namespace MemoryInterface
|
|||
{
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
void HWCALL Read16(u16& _uReturnValue, const u32 _iAddress);
|
||||
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void HWCALL Write16(const u16 _iValue, const u32 _iAddress);
|
||||
void Read16(u16& _uReturnValue, const u32 _iAddress);
|
||||
void Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void Write16(const u16 _iValue, const u32 _iAddress);
|
||||
} // end of namespace MemoryInterface
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -103,10 +103,10 @@ public:
|
|||
static void SetInterrupt(InterruptCause _causemask, bool _bSet=true);
|
||||
|
||||
// Read32
|
||||
static void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
static void Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
|
||||
// Write32
|
||||
static void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
static void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
|
||||
// SetResetButton (you have to release the button again to make a reset)
|
||||
static void SetResetButton(bool _bSet);
|
||||
|
@ -114,3 +114,4 @@ public:
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ void Init();
|
|||
void DoState(PointerWrap &p);
|
||||
|
||||
// Read
|
||||
void HWCALL Read16(u16& _uReturnValue, const u32 _iAddress);
|
||||
void Read16(u16& _uReturnValue, const u32 _iAddress);
|
||||
|
||||
// Write
|
||||
void HWCALL Write16(const u16 _iValue, const u32 _iAddress);
|
||||
void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void Write16(const u16 _iValue, const u32 _iAddress);
|
||||
void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
|
||||
// gfx plugin support
|
||||
void SetToken(const u16 _token, const int _bSetTokenAcknowledge);
|
||||
|
@ -41,3 +41,4 @@ bool AllowIdleSkipping();
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ void UpdateDevices();
|
|||
void RemoveDevice(int _iDeviceNumber);
|
||||
void AddDevice(const TSIDevices _device, int _iDeviceNumber);
|
||||
|
||||
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void HWCALL Write32(const u32 _iValue, const u32 _iAddress);
|
||||
void Read32(u32& _uReturnValue, const u32 _iAddress);
|
||||
void Write32(const u32 _iValue, const u32 _iAddress);
|
||||
|
||||
}; // end of namespace SerialInterface
|
||||
|
||||
|
|
|
@ -179,7 +179,9 @@ void IPC_HLE_UpdateCallback(u64 userdata, int cyclesLate)
|
|||
|
||||
void VICallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
WII_IPC_HLE_Interface::Update();
|
||||
if (Core::GetStartupParameter().bWii)
|
||||
WII_IPC_HLE_Interface::Update();
|
||||
|
||||
VideoInterface::Update();
|
||||
CoreTiming::ScheduleEvent(VI_PERIOD-cyclesLate, et_VI);
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ namespace VideoInterface
|
|||
void Init();
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
void HWCALL Read16(u16& _uReturnValue, const u32 _uAddress);
|
||||
void HWCALL Read32(u32& _uReturnValue, const u32 _uAddress);
|
||||
void Read16(u16& _uReturnValue, const u32 _uAddress);
|
||||
void Read32(u32& _uReturnValue, const u32 _uAddress);
|
||||
|
||||
void HWCALL Write16(const u16 _uValue, const u32 _uAddress);
|
||||
void HWCALL Write32(const u32 _uValue, const u32 _uAddress);
|
||||
void Write16(const u16 _uValue, const u32 _uAddress);
|
||||
void Write32(const u32 _uValue, const u32 _uAddress);
|
||||
|
||||
void GenerateVIInterrupt(VIInterruptType _VIInterrupt);
|
||||
|
||||
|
@ -63,3 +63,4 @@ namespace VideoInterface
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -22,17 +22,17 @@
|
|||
namespace WII_IOBridge
|
||||
{
|
||||
|
||||
void HWCALL Read8(u8& _rReturnValue, const u32 _Address)
|
||||
void Read8(u8& _rReturnValue, const u32 _Address)
|
||||
{
|
||||
_dbg_assert_(WII_IOB, 0);
|
||||
}
|
||||
|
||||
void HWCALL Read16(u16& _rReturnValue, const u32 _Address)
|
||||
void Read16(u16& _rReturnValue, const u32 _Address)
|
||||
{
|
||||
_dbg_assert_(WII_IOB, 0);
|
||||
}
|
||||
|
||||
void HWCALL Read32(u32& _rReturnValue, const u32 _Address)
|
||||
void Read32(u32& _rReturnValue, const u32 _Address)
|
||||
{
|
||||
switch(_Address & 0xFFFF)
|
||||
{
|
||||
|
@ -82,22 +82,22 @@ void HWCALL Read32(u32& _rReturnValue, const u32 _Address)
|
|||
}
|
||||
}
|
||||
|
||||
void HWCALL Read64(u64& _rReturnValue, const u32 _Address)
|
||||
void Read64(u64& _rReturnValue, const u32 _Address)
|
||||
{
|
||||
_dbg_assert_(WII_IOB, 0);
|
||||
}
|
||||
|
||||
void HWCALL Write8(const u8 _Value, const u32 _Address)
|
||||
void Write8(const u8 _Value, const u32 _Address)
|
||||
{
|
||||
_dbg_assert_(WII_IOB, 0);
|
||||
}
|
||||
|
||||
void HWCALL Write16(const u16 _Value, const u32 _Address)
|
||||
void Write16(const u16 _Value, const u32 _Address)
|
||||
{
|
||||
_dbg_assert_(WII_IOB, 0);
|
||||
}
|
||||
|
||||
void HWCALL Write32(const u32 _Value, const u32 _Address)
|
||||
void Write32(const u32 _Value, const u32 _Address)
|
||||
{
|
||||
switch(_Address & 0xFFFF)
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ void HWCALL Write32(const u32 _Value, const u32 _Address)
|
|||
}
|
||||
}
|
||||
|
||||
void HWCALL Write64(const u64 _Value, const u32 _Address)
|
||||
void Write64(const u64 _Value, const u32 _Address)
|
||||
{
|
||||
//switch(_Address)
|
||||
//{
|
||||
|
|
|
@ -29,17 +29,18 @@ void DoState(PointerWrap &p);
|
|||
|
||||
void Update();
|
||||
|
||||
void HWCALL Read8(u8& _rReturnValue, const u32 _Address);
|
||||
void HWCALL Read16(u16& _rReturnValue, const u32 _Address);
|
||||
void HWCALL Read32(u32& _rReturnValue, const u32 _Address);
|
||||
void HWCALL Read64(u64& _rReturnValue, const u32 _Address);
|
||||
void Read8(u8& _rReturnValue, const u32 _Address);
|
||||
void Read16(u16& _rReturnValue, const u32 _Address);
|
||||
void Read32(u32& _rReturnValue, const u32 _Address);
|
||||
void Read64(u64& _rReturnValue, const u32 _Address);
|
||||
|
||||
void HWCALL Write8(const u8 _Value, const u32 _Address);
|
||||
void HWCALL Write16(const u16 _Value, const u32 _Address);
|
||||
void HWCALL Write32(const u32 _Value, const u32 _Address);
|
||||
void HWCALL Write64(const u64 _Value, const u32 _Address);
|
||||
void Write8(const u8 _Value, const u32 _Address);
|
||||
void Write16(const u16 _Value, const u32 _Address);
|
||||
void Write32(const u32 _Value, const u32 _Address);
|
||||
void Write64(const u64 _Value, const u32 _Address);
|
||||
|
||||
} // end of namespace AudioInterface
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ void Shutdown()
|
|||
{
|
||||
}
|
||||
|
||||
void HWCALL Read32(u32& _rReturnValue, const u32 _Address)
|
||||
void Read32(u32& _rReturnValue, const u32 _Address)
|
||||
{
|
||||
switch(_Address & 0xFFFF)
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ void HWCALL Read32(u32& _rReturnValue, const u32 _Address)
|
|||
}
|
||||
}
|
||||
|
||||
void HWCALL Write32(const u32 _Value, const u32 _Address)
|
||||
void Write32(const u32 _Value, const u32 _Address)
|
||||
{
|
||||
switch(_Address & 0xFFFF)
|
||||
{
|
||||
|
@ -265,3 +265,4 @@ void GenerateReply(u32 _AnswerAddress)
|
|||
|
||||
} // end of namespace IPC
|
||||
|
||||
|
||||
|
|
|
@ -32,11 +32,12 @@ bool IsReady();
|
|||
void GenerateReply(u32 _AnswerAddress);
|
||||
void GenerateAck(u32 _AnswerAddress);
|
||||
|
||||
void HWCALL Read32(u32& _rReturnValue, const u32 _Address);
|
||||
void Read32(u32& _rReturnValue, const u32 _Address);
|
||||
|
||||
void HWCALL Write32(const u32 _Value, const u32 _Address);
|
||||
void Write32(const u32 _Value, const u32 _Address);
|
||||
|
||||
} // end of namespace AudioInterface
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ void CopySettingsFile(std::string DeviceName)
|
|||
|
||||
// Check if the target dir exists, otherwise create it
|
||||
std::string TargetDir = Target.substr(0, Target.find_last_of(DIR_SEP));
|
||||
if(!File::IsDirectory(TargetDir.c_str())) File::CreateDirectoryStructure(Target.c_str());
|
||||
if(!File::IsDirectory(TargetDir.c_str())) File::CreateFullPath(Target.c_str());
|
||||
|
||||
if (File::Copy(Source.c_str(), Target.c_str()))
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _WII_IPC_HLE_DEVICE_ERROR_H_
|
||||
#define _WII_IPC_HLE_DEVICE_ERROR_H_
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// File description
|
||||
// -------------
|
||||
/* Here we handle /dev/es requests. We have cases for these functions, the exact
|
||||
DevKitPro name is en parenthesis:
|
||||
DevKitPro/libogc name is in parenthesis:
|
||||
|
||||
0x20 GetTitleID (ES_GetTitleID) (Input: none, Output: 8 bytes)
|
||||
0x1d GetDataDir (ES_GetDataDir) (Input: 8 bytes, Output: 30 bytes)
|
||||
|
@ -91,13 +91,13 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
|||
|
||||
// Prepare the out buffer(s) with zeroes as a safety precaution
|
||||
// to avoid returning bad values
|
||||
for(u32 i = 0; i < Buffer.NumberPayloadBuffer; i++)
|
||||
for (u32 i = 0; i < Buffer.NumberPayloadBuffer; i++)
|
||||
{
|
||||
Memory::Memset(Buffer.PayloadBuffer[i].m_Address, 0,
|
||||
Buffer.PayloadBuffer[i].m_Size);
|
||||
}
|
||||
|
||||
switch(Buffer.Parameter)
|
||||
switch (Buffer.Parameter)
|
||||
{
|
||||
case IOCTL_ES_OPENTITLECONTENT: // 0x09
|
||||
{
|
||||
|
@ -105,9 +105,9 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
|||
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
|
||||
u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address+8);
|
||||
|
||||
m_ContenAccessMap[CFD].m_Position = 0;
|
||||
m_ContenAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index);
|
||||
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap[CFD].m_pContent != NULL);
|
||||
m_ContentAccessMap[CFD].m_Position = 0;
|
||||
m_ContentAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index);
|
||||
_dbg_assert_(WII_IPC_ES, m_ContentAccessMap[CFD].m_pContent != NULL);
|
||||
|
||||
Memory::Write_U32(CFD, _CommandAddress + 0x4);
|
||||
|
||||
|
@ -121,9 +121,9 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
|||
u32 CFD = AccessIdentID++;
|
||||
u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address);
|
||||
|
||||
m_ContenAccessMap[CFD].m_Position = 0;
|
||||
m_ContenAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index);
|
||||
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap[CFD].m_pContent != NULL);
|
||||
m_ContentAccessMap[CFD].m_Position = 0;
|
||||
m_ContentAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index);
|
||||
_dbg_assert_(WII_IPC_ES, m_ContentAccessMap[CFD].m_pContent != NULL);
|
||||
|
||||
Memory::Write_U32(CFD, _CommandAddress + 0x4);
|
||||
|
||||
|
@ -140,8 +140,8 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
|||
u32 Size = Buffer.PayloadBuffer[0].m_Size;
|
||||
u32 Addr = Buffer.PayloadBuffer[0].m_Address;
|
||||
|
||||
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap.find(CFD) != m_ContenAccessMap.end());
|
||||
SContentAccess& rContent = m_ContenAccessMap[CFD];
|
||||
_dbg_assert_(WII_IPC_ES, m_ContentAccessMap.find(CFD) != m_ContentAccessMap.end());
|
||||
SContentAccess& rContent = m_ContentAccessMap[CFD];
|
||||
|
||||
u8* pSrc = &rContent.m_pContent->m_pData[rContent.m_Position];
|
||||
u8* pDest = Memory::GetPointer(Addr);
|
||||
|
@ -169,8 +169,8 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
|||
_dbg_assert_(WII_IPC_ES, Buffer.NumberInBuffer == 1);
|
||||
u32 CFD = Memory::Read_U32(Buffer.InBuffer[0].m_Address);
|
||||
|
||||
CContenAccessMap::iterator itr = m_ContenAccessMap.find(CFD);
|
||||
m_ContenAccessMap.erase(itr);
|
||||
CContentAccessMap::iterator itr = m_ContentAccessMap.find(CFD);
|
||||
m_ContentAccessMap.erase(itr);
|
||||
|
||||
LOG(WII_IPC_ES, "ES: IOCTL_ES_CLOSECONTENT: CFD %x", CFD);
|
||||
|
||||
|
@ -185,10 +185,10 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
|||
u32 Addr = Memory::Read_U32(Buffer.InBuffer[1].m_Address);
|
||||
u32 Mode = Memory::Read_U32(Buffer.InBuffer[2].m_Address);
|
||||
|
||||
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap.find(CFD) != m_ContenAccessMap.end());
|
||||
SContentAccess& rContent = m_ContenAccessMap[CFD];
|
||||
_dbg_assert_(WII_IPC_ES, m_ContentAccessMap.find(CFD) != m_ContentAccessMap.end());
|
||||
SContentAccess& rContent = m_ContentAccessMap[CFD];
|
||||
|
||||
switch(Mode)
|
||||
switch (Mode)
|
||||
{
|
||||
case 0: // SET
|
||||
rContent.m_Position = Addr;
|
||||
|
@ -300,10 +300,10 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
|||
// TitleIDs.push_back(0x0001000248414341);
|
||||
// TitleIDs.push_back(0x0001000146414b45);
|
||||
|
||||
for (size_t i=0; i<TitleIDs.size();i++)
|
||||
for (int i = 0; i < (int)TitleIDs.size(); i++)
|
||||
{
|
||||
Memory::Write_U64(TitleIDs[i], Buffer.PayloadBuffer[0].m_Address + i*8);
|
||||
LOGV(WII_IPC_ES, 0, "IOCTL_ES_GETTITLES: %08x/%08x", TitleIDs[i]>>32, TitleIDs[i]);
|
||||
LOGV(WII_IPC_ES, 0, "IOCTL_ES_GETTITLES: %08x/%08x", TitleIDs[i] >> 32, TitleIDs[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -103,8 +103,8 @@ private:
|
|||
DiscIO::SNANDContent* m_pContent;
|
||||
};
|
||||
|
||||
typedef std::map<u32, SContentAccess> CContenAccessMap;
|
||||
CContenAccessMap m_ContenAccessMap;
|
||||
typedef std::map<u32, SContentAccess> CContentAccessMap;
|
||||
CContentAccessMap m_ContentAccessMap;
|
||||
|
||||
DiscIO::CNANDContentLoader* m_pContentLoader;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
|
|||
sprintf(Path, FULL_WII_USER_DIR "title/00010000/%02x%02x%02x%02x/data/nocopy/",
|
||||
(u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]);
|
||||
|
||||
File::CreateDirectoryStructure(Path);
|
||||
File::CreateFullPath(Path);
|
||||
}
|
||||
|
||||
Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
|
||||
|
@ -313,7 +313,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
|
|||
LOG(WII_IPC_FILEIO, "FS: CREATE_DIR %s", DirName.c_str());
|
||||
|
||||
DirName += DIR_SEP;
|
||||
File::CreateDirectoryStructure(DirName );
|
||||
File::CreateFullPath(DirName.c_str());
|
||||
_dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName.c_str()), "FS: CREATE_DIR %s failed", DirName.c_str());
|
||||
|
||||
return FS_RESULT_OK;
|
||||
|
@ -428,7 +428,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
|
|||
Offset += 64;
|
||||
|
||||
// try to make the basis directory
|
||||
File::CreateDirectoryStructure(FilenameRename);
|
||||
File::CreateFullPath(FilenameRename.c_str());
|
||||
|
||||
// if there is already a filedelete it
|
||||
if (File::Exists(FilenameRename.c_str()))
|
||||
|
@ -480,7 +480,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
|
|||
}
|
||||
|
||||
// create the file
|
||||
File::CreateDirectoryStructure(Filename); // just to be sure
|
||||
File::CreateFullPath(Filename.c_str()); // just to be sure
|
||||
bool Result = File::CreateEmptyFile(Filename.c_str());
|
||||
if (!Result)
|
||||
{
|
||||
|
|
|
@ -352,7 +352,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
|||
// return reply buffer size
|
||||
Memory::Write_U32(sizeof(UACLHeader) + frame.size, m_pACLBuffer->m_Address + 0x4);
|
||||
|
||||
delete frame.data;
|
||||
delete [] frame.data;
|
||||
m_AclFrameQue.pop();
|
||||
|
||||
u32 Addr = m_pACLBuffer->m_Address;
|
||||
|
@ -383,7 +383,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
|||
|
||||
if (m_AclFrameQue.empty())
|
||||
{
|
||||
for (size_t i=0; i<m_WiiMotes.size(); i++)
|
||||
for (size_t i = 0; i < m_WiiMotes.size(); i++)
|
||||
{
|
||||
if (m_WiiMotes[i].Update())
|
||||
break;
|
||||
|
|
|
@ -469,7 +469,7 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size)
|
|||
break;
|
||||
|
||||
case L2CAP_CONF_RSP:
|
||||
CommandCofigurationResponse(pCommand->ident, _pData, pCommand->len);
|
||||
CommandConfigurationResponse(pCommand->ident, _pData, pCommand->len);
|
||||
break;
|
||||
|
||||
case L2CAP_COMMAND_REJ:
|
||||
|
@ -633,13 +633,13 @@ void CWII_IPC_HLE_WiiMote::CommandConnectionResponse(u8 _Ident, u8* _pData, u32
|
|||
m_HIDInterruptChannel_Connected = true;
|
||||
}
|
||||
|
||||
void CWII_IPC_HLE_WiiMote::CommandCofigurationResponse(u8 _Ident, u8* _pData, u32 _Size)
|
||||
void CWII_IPC_HLE_WiiMote::CommandConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size)
|
||||
{
|
||||
l2cap_conf_rsp* rsp = (l2cap_conf_rsp*)_pData;
|
||||
|
||||
_dbg_assert_(WII_IPC_WIIMOTE, _Size == sizeof(l2cap_conf_rsp));
|
||||
|
||||
LOG(WII_IPC_WIIMOTE, " CommandCofigurationResponse");
|
||||
LOG(WII_IPC_WIIMOTE, " CommandConfigurationResponse");
|
||||
LOG(WII_IPC_WIIMOTE, " SCID: 0x%04x", rsp->scid);
|
||||
LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", rsp->flags);
|
||||
LOG(WII_IPC_WIIMOTE, " Result: 0x%04x", rsp->result);
|
||||
|
|
|
@ -186,7 +186,7 @@ private:
|
|||
void CommandCofigurationReq(u8 _Ident, u8* _pData, u32 _Size);
|
||||
void CommandConnectionResponse(u8 _Ident, u8* _pData, u32 _Size);
|
||||
void CommandDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size);
|
||||
void CommandCofigurationResponse(u8 _Ident, u8* _pData, u32 _Size);
|
||||
void CommandConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size);
|
||||
|
||||
|
||||
//////////////////
|
||||
|
|
|
@ -120,6 +120,7 @@ void LogManager::Init()
|
|||
for(int i = 0; i <= LogManager::VERBOSITY_LEVELS; i++)
|
||||
{
|
||||
m_Log[LogTypes::MASTER_LOG + i*100] = new CDebugger_Log("*", "Master Log", i);
|
||||
m_Log[LogTypes::COMMON + i*100] = new CDebugger_Log("COMMON", "Common Lib", i);
|
||||
m_Log[LogTypes::BOOT + i*100] = new CDebugger_Log("BOOT", "Boot", i);
|
||||
m_Log[LogTypes::PIXELENGINE + i*100] = new CDebugger_Log("PE", "PixelEngine", i);
|
||||
m_Log[LogTypes::COMMANDPROCESSOR + i*100] = new CDebugger_Log("CP", "CommandProc", i);
|
||||
|
@ -189,7 +190,7 @@ void LogManager::Shutdown()
|
|||
m_bInitialized = false;
|
||||
|
||||
// Delete all loggers
|
||||
for (int i=0; i<LogTypes::NUMBER_OF_LOGS; i++)
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
||||
{
|
||||
for (int j = 0; j < VERBOSITY_LEVELS; j++)
|
||||
{
|
||||
|
@ -239,17 +240,11 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
|
|||
static u32 count = 0;
|
||||
char* Msg2 = (char*)alloca(strlen(_fmt)+512);
|
||||
|
||||
|
||||
// Here's the old symbol request
|
||||
//Debugger::FindSymbol(PC);
|
||||
// const Debugger::Symbol& symbol = Debugger::GetSymbol(Index);
|
||||
//symbol.GetName().c_str(),
|
||||
|
||||
// Warning: Getting the function name this often is very demanding on the CPU.
|
||||
// I have limited it to the two lowest verbosity levels because of that. I've also
|
||||
// added a simple caching function so that we don't search again if we get the same
|
||||
// question again.
|
||||
std::string symbol;
|
||||
const char *symbol;
|
||||
|
||||
if ((v == 0 || v == 1) && lastPC != PC && LogManager::m_LogSettings->bResolve)
|
||||
{
|
||||
|
@ -257,9 +252,9 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
|
|||
lastSymbol = symbol;
|
||||
lastPC = PC;
|
||||
}
|
||||
else if(lastPC == PC && LogManager::m_LogSettings->bResolve)
|
||||
else if (lastPC == PC && LogManager::m_LogSettings->bResolve)
|
||||
{
|
||||
symbol = lastSymbol;
|
||||
symbol = lastSymbol.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -275,7 +270,7 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
|
|||
Common::Timer::GetTimeFormatted().c_str(),
|
||||
PowerPC::ppcState.DebugCount,
|
||||
m_Log[_type]->m_szShortName_, // (CONSOLE etc)
|
||||
symbol.c_str(), PC, // current PC location (name, address)
|
||||
symbol, PC, // current PC location (name, address)
|
||||
Msg, eol);
|
||||
}
|
||||
|
||||
|
@ -289,7 +284,7 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
|
|||
// ---------------
|
||||
|
||||
// Check if we should do a unified write to a single file
|
||||
if(m_LogSettings->bUnify)
|
||||
if (m_LogSettings->bUnify)
|
||||
{
|
||||
// prepare the right id
|
||||
int id = VERBOSITY_LEVELS*100 + type;
|
||||
|
|
|
@ -61,6 +61,7 @@ files = ["Console.cpp",
|
|||
"IPC_HLE/WII_IPC_HLE.cpp",
|
||||
"IPC_HLE/WII_IPC_HLE_Device_DI.cpp",
|
||||
"IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp",
|
||||
"IPC_HLE/WII_IPC_HLE_Device_es.cpp",
|
||||
"IPC_HLE/WII_IPC_HLE_Device_fs.cpp",
|
||||
"IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp",
|
||||
"IPC_HLE/WII_IPC_HLE_Device_net.cpp",
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
/////////////////////////////
|
||||
// What does SJP stand for???
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
|
@ -105,7 +107,6 @@ void CCodeWindow::CreateSymbolsMenu()
|
|||
pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _T("&Patch HLE functions"));
|
||||
pMenuBar->Append(pSymbolsMenu, _T("&Symbols"));
|
||||
|
||||
|
||||
wxMenu *pJitMenu = new wxMenu;
|
||||
pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache"));
|
||||
pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage"));
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
namespace DiscIO
|
||||
{
|
||||
|
||||
IFileSystem::IFileSystem(const IVolume *_rVolume)
|
||||
: m_rVolume(_rVolume)
|
||||
{}
|
||||
|
@ -47,4 +48,5 @@ IFileSystem* CreateFileSystem(const IVolume* _rVolume)
|
|||
|
||||
return pFileSystem;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -67,10 +67,10 @@ CNANDContentLoader::CNANDContentLoader(const std::string& _rName)
|
|||
|
||||
SNANDContent* CNANDContentLoader::GetContentByIndex(int _Index)
|
||||
{
|
||||
for (size_t i=0; i<m_TileMetaContent.size(); i++)
|
||||
for (size_t i=0; i<m_TitleMetaContent.size(); i++)
|
||||
{
|
||||
if (m_TileMetaContent[i].m_Index == _Index)
|
||||
return &m_TileMetaContent[i];
|
||||
if (m_TitleMetaContent[i].m_Index == _Index)
|
||||
return &m_TitleMetaContent[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ bool CNANDContentLoader::CreateFromWAD(const std::string& _rName)
|
|||
{
|
||||
DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str());
|
||||
if (pReader == NULL)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
if (!ParseWAD(*pReader))
|
||||
{
|
||||
|
@ -89,6 +89,7 @@ bool CNANDContentLoader::CreateFromWAD(const std::string& _rName)
|
|||
delete pReader;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
|
||||
{
|
||||
std::string TMDFileName(_rPath);
|
||||
|
@ -108,12 +109,11 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
|
|||
m_BootIndex = Common::swap16(pTMD + 0x01e0);
|
||||
m_TitleID = Common::swap64(pTMD + 0x018C);
|
||||
|
||||
m_TitleMetaContent.resize(numEntries);
|
||||
|
||||
m_TileMetaContent.resize(numEntries);
|
||||
|
||||
for (u32 i=0; i<numEntries; i++)
|
||||
for (u32 i = 0; i < numEntries; i++)
|
||||
{
|
||||
SNANDContent& rContent = m_TileMetaContent[i];
|
||||
SNANDContent& rContent = m_TitleMetaContent[i];
|
||||
|
||||
rContent.m_ContentID = Common::swap32(pTMD + 0x01e4 + 0x24*i);
|
||||
rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 0x24*i);
|
||||
|
@ -216,11 +216,11 @@ bool CNANDContentLoader::ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u
|
|||
|
||||
u8* p = pDataApp;
|
||||
|
||||
m_TileMetaContent.resize(numEntries);
|
||||
m_TitleMetaContent.resize(numEntries);
|
||||
|
||||
for (u32 i=0; i<numEntries; i++)
|
||||
{
|
||||
SNANDContent& rContent = m_TileMetaContent[i];
|
||||
SNANDContent& rContent = m_TitleMetaContent[i];
|
||||
|
||||
rContent.m_ContentID = Common::swap32(pTMD + 0x01e4 + 0x24*i);
|
||||
rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 0x24*i);
|
||||
|
|
|
@ -42,16 +42,12 @@ public:
|
|||
CNANDContentLoader(const std::string& _rName);
|
||||
|
||||
bool IsValid() const { return m_Valid; }
|
||||
|
||||
u64 GetTitleID() const { return m_TitleID; }
|
||||
|
||||
u32 GetBootIndex() const { return m_BootIndex; }
|
||||
|
||||
size_t GetContentSize() const { return m_TileMetaContent.size(); }
|
||||
|
||||
size_t GetContentSize() const { return m_TitleMetaContent.size(); }
|
||||
SNANDContent* GetContentByIndex(int _Index);
|
||||
|
||||
static bool IsWiiWAD(const std::string& _rName);
|
||||
static bool IsWiiWAD(const std::string& _rName);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -59,7 +55,7 @@ private:
|
|||
u64 m_TitleID;
|
||||
u32 m_BootIndex;
|
||||
|
||||
std::vector<SNANDContent> m_TileMetaContent;
|
||||
std::vector<SNANDContent> m_TitleMetaContent;
|
||||
|
||||
bool CreateFromDirectory(const std::string& _rPath);
|
||||
bool CreateFromWAD(const std::string& _rName);
|
||||
|
|
|
@ -424,7 +424,7 @@ void CVolumeDirectory::WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u
|
|||
{
|
||||
u32 myOffset = fstOffset;
|
||||
u32 myEntryNum = myOffset / ENTRY_SIZE;
|
||||
WriteEntryData(fstOffset, DIRECTORY_ENTRY, nameOffset, parentEntryNum, myEntryNum + entry.size + 1);
|
||||
WriteEntryData(fstOffset, DIRECTORY_ENTRY, nameOffset, parentEntryNum, (u32)(myEntryNum + entry.size + 1));
|
||||
WriteEntryName(nameOffset, entry.virtualName);
|
||||
|
||||
for(std::vector<File::FSTEntry>::const_iterator iter = entry.children.begin(); iter != entry.children.end(); ++iter)
|
||||
|
@ -435,7 +435,7 @@ void CVolumeDirectory::WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u
|
|||
else
|
||||
{
|
||||
// put entry in FST
|
||||
WriteEntryData(fstOffset, FILE_ENTRY, nameOffset, dataOffset, entry.size);
|
||||
WriteEntryData(fstOffset, FILE_ENTRY, nameOffset, dataOffset, (u32)entry.size);
|
||||
WriteEntryName(nameOffset, entry.virtualName);
|
||||
|
||||
// write entry to virtual disk
|
||||
|
@ -466,7 +466,7 @@ static u32 ComputeNameSize(const File::FSTEntry& parentEntry)
|
|||
|
||||
u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, File::FSTEntry& parentEntry)
|
||||
{
|
||||
u32 foundEntries = ScanDirectoryTree(_Directory, parentEntry);
|
||||
u32 foundEntries = ScanDirectoryTree(_Directory.c_str(), parentEntry);
|
||||
m_totalNameSize += ComputeNameSize(parentEntry);
|
||||
return foundEntries;
|
||||
}
|
||||
|
|
|
@ -724,7 +724,7 @@ void CConfigMain::WiiSettingsChanged(wxCommandEvent& event)
|
|||
break;
|
||||
|
||||
case ID_WII_IPL_AR: // IPL settings
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bWidescreen = WiiAspectRatio->GetSelection();
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bWidescreen = WiiAspectRatio->GetSelection() ? true : false;
|
||||
break;
|
||||
case ID_WII_IPL_SSV:
|
||||
m_SYSCONF[IPL_SSV] = WiiScreenSaver->IsChecked();
|
||||
|
|
|
@ -419,8 +419,7 @@ void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
|
|||
|
||||
void CFrame::DoOpen(bool Boot)
|
||||
{
|
||||
std::string currentDir;
|
||||
File::GetCurrentDirectory(currentDir);
|
||||
std::string currentDir = File::GetCurrentDirectory();
|
||||
|
||||
wxString path = wxFileSelector(
|
||||
_T("Select the file to load"),
|
||||
|
@ -438,13 +437,12 @@ void CFrame::DoOpen(bool Boot)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string currentDir2;
|
||||
File::GetCurrentDirectory(currentDir2);
|
||||
std::string currentDir2 = File::GetCurrentDirectory();
|
||||
|
||||
if (currentDir != currentDir2)
|
||||
{
|
||||
PanicAlert("Current dir changed has been changeg from %s to %s after wxFileSelector!",currentDir.c_str(),currentDir2.c_str());
|
||||
File::SetCurrentDirectory(currentDir);
|
||||
File::SetCurrentDirectory(currentDir.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -839,3 +837,4 @@ void CFrame::UpdateGUI()
|
|||
TheToolBar->Realize();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,16 +111,16 @@ void HandleGLError();
|
|||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ERROR_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
|
||||
#define INFO_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
|
||||
//#define ERROR_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
|
||||
//#define INFO_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
|
||||
#define PRIM_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
|
||||
#define DEBUG_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
|
||||
//#define DEBUG_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
|
||||
|
||||
#else
|
||||
#define ERROR_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
|
||||
#define INFO_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
|
||||
//#define ERROR_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
|
||||
//#define INFO_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
|
||||
#define PRIM_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
|
||||
#define DEBUG_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
|
||||
//#define DEBUG_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
|
||||
#endif
|
||||
|
||||
#ifdef LOGGING
|
||||
|
|
|
@ -245,7 +245,7 @@ void Initialize(void *init)
|
|||
}
|
||||
else
|
||||
{
|
||||
PanicAlert("Cannot recognize backend %s", g_Config.sBackend);
|
||||
PanicAlert("Cannot recognize backend %s", g_Config.sBackend.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ void Initialize(void *init)
|
|||
if (!soundStream->Start())
|
||||
{
|
||||
PanicAlert("Could not initialize backend %s, falling back to NULL",
|
||||
g_Config.sBackend);
|
||||
g_Config.sBackend.c_str());
|
||||
delete soundStream;
|
||||
soundStream = new NullSound(48000, Mixer);
|
||||
soundStream->Start();
|
||||
|
@ -269,7 +269,7 @@ void Initialize(void *init)
|
|||
else
|
||||
{
|
||||
PanicAlert("Sound backend %s is not valid, falling back to NULL",
|
||||
g_Config.sBackend);
|
||||
g_Config.sBackend.c_str());
|
||||
delete soundStream;
|
||||
soundStream = new NullSound(48000, Mixer);
|
||||
soundStream->Start();
|
||||
|
|
|
@ -294,7 +294,7 @@ void BPWritten(int addr, int changes, int newval)
|
|||
if (!Renderer::SetScissorRect())
|
||||
{
|
||||
if (addr == BPMEM_SCISSORBR) {
|
||||
ERROR_LOG("bad scissor!\n");
|
||||
ERROR_LOG(VIDEO, "bad scissor!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -415,20 +415,20 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||
if (vi == NULL) {
|
||||
vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
|
||||
GLWin.doubleBuffered = False;
|
||||
ERROR_LOG("Only Singlebuffered Visual!\n");
|
||||
ERROR_LOG(VIDEO, "Only Singlebuffered Visual!\n");
|
||||
}
|
||||
else {
|
||||
GLWin.doubleBuffered = True;
|
||||
ERROR_LOG("Got Doublebuffered Visual!\n");
|
||||
ERROR_LOG(VIDEO, "Got Doublebuffered Visual!\n");
|
||||
}
|
||||
|
||||
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
||||
ERROR_LOG("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
|
||||
ERROR_LOG(VIDEO, "glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
|
||||
/* create a GLX context */
|
||||
GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE);
|
||||
if(!GLWin.ctx)
|
||||
{
|
||||
ERROR_LOG("Couldn't Create GLX context.Quit");
|
||||
ERROR_LOG(VIDEO, "Couldn't Create GLX context.Quit");
|
||||
exit(0); // TODO: Don't bring down entire Emu
|
||||
}
|
||||
/* create a color map */
|
||||
|
@ -450,7 +450,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||
|
||||
// set best mode to current
|
||||
bestMode = 0;
|
||||
ERROR_LOG("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion, vidModeMinorVersion);
|
||||
ERROR_LOG(VIDEO, "XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion, vidModeMinorVersion);
|
||||
XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes);
|
||||
|
||||
if (modeNum > 0 && modes != NULL) {
|
||||
|
@ -467,7 +467,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||
XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0);
|
||||
dpyWidth = modes[bestMode]->hdisplay;
|
||||
dpyHeight = modes[bestMode]->vdisplay;
|
||||
ERROR_LOG("Resolution %dx%d\n", dpyWidth, dpyHeight);
|
||||
ERROR_LOG(VIDEO, "Resolution %dx%d\n", dpyWidth, dpyHeight);
|
||||
XFree(modes);
|
||||
|
||||
/* create a fullscreen window */
|
||||
|
@ -484,7 +484,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||
GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime);
|
||||
}
|
||||
else {
|
||||
ERROR_LOG("Failed to start fullscreen. If you received the \n"
|
||||
ERROR_LOG(VIDEO, "Failed to start fullscreen. If you received the \n"
|
||||
"\"XFree86-VidModeExtension\" extension is missing, add\n"
|
||||
"Load \"extmod\"\n"
|
||||
"to your X configuration file (under the Module Section)\n");
|
||||
|
@ -565,11 +565,11 @@ bool OpenGL_MakeCurrent()
|
|||
glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
|
||||
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
|
||||
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
|
||||
ERROR_LOG("GLWin Depth %d", GLWin.depth)
|
||||
ERROR_LOG(VIDEO, "GLWin Depth %d", GLWin.depth)
|
||||
if (glXIsDirect(GLWin.dpy, GLWin.ctx)) {
|
||||
ERROR_LOG("you have Direct Rendering!");
|
||||
ERROR_LOG(VIDEO, "you have Direct Rendering!");
|
||||
} else {
|
||||
ERROR_LOG("no Direct Rendering possible!");
|
||||
ERROR_LOG(VIDEO, "no Direct Rendering possible!");
|
||||
}
|
||||
|
||||
// better for pad plugin key input (thc)
|
||||
|
@ -781,7 +781,7 @@ void OpenGL_Shutdown()
|
|||
{
|
||||
if (!glXMakeCurrent(GLWin.dpy, None, NULL))
|
||||
{
|
||||
ERROR_LOG("Could not release drawing context.\n");
|
||||
ERROR_LOG(VIDEO, "Could not release drawing context.\n");
|
||||
}
|
||||
XUnmapWindow(GLWin.dpy, GLWin.win);
|
||||
glXDestroyContext(GLWin.dpy, GLWin.ctx);
|
||||
|
@ -807,9 +807,9 @@ void HandleGLError()
|
|||
{
|
||||
GLint loc = 0;
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &loc);
|
||||
ERROR_LOG("program error at %d: ", loc);
|
||||
ERROR_LOG((char*)pstr);
|
||||
ERROR_LOG("\n");
|
||||
ERROR_LOG(VIDEO, "program error at %d: ", loc);
|
||||
ERROR_LOG(VIDEO, (char*)pstr);
|
||||
ERROR_LOG(VIDEO, "\n");
|
||||
}
|
||||
|
||||
// check the error status of this framebuffer */
|
||||
|
@ -824,40 +824,40 @@ void HandleGLError()
|
|||
case GL_FRAMEBUFFER_COMPLETE_EXT:
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
|
||||
ERROR_LOG("Error! missing a required image/buffer attachment!\n");
|
||||
ERROR_LOG(VIDEO, "Error! missing a required image/buffer attachment!\n");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
|
||||
ERROR_LOG("Error! has no images/buffers attached!\n");
|
||||
ERROR_LOG(VIDEO, "Error! has no images/buffers attached!\n");
|
||||
break;
|
||||
// case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
|
||||
// ERROR_LOG("Error! has an image/buffer attached in multiple locations!\n");
|
||||
// ERROR_LOG(VIDEO, "Error! has an image/buffer attached in multiple locations!\n");
|
||||
// break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
|
||||
ERROR_LOG("Error! has mismatched image/buffer dimensions!\n");
|
||||
ERROR_LOG(VIDEO, "Error! has mismatched image/buffer dimensions!\n");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
|
||||
ERROR_LOG("Error! colorbuffer attachments have different types!\n");
|
||||
ERROR_LOG(VIDEO, "Error! colorbuffer attachments have different types!\n");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
|
||||
ERROR_LOG("Error! trying to draw to non-attached color buffer!\n");
|
||||
ERROR_LOG(VIDEO, "Error! trying to draw to non-attached color buffer!\n");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
|
||||
ERROR_LOG("Error! trying to read from a non-attached color buffer!\n");
|
||||
ERROR_LOG(VIDEO, "Error! trying to read from a non-attached color buffer!\n");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
||||
ERROR_LOG("Error! format is not supported by current graphics card/driver!\n");
|
||||
ERROR_LOG(VIDEO, "Error! format is not supported by current graphics card/driver!\n");
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG("*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT()!\n");
|
||||
ERROR_LOG(VIDEO, "*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT()!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
|
||||
{
|
||||
ERROR_LOG("Cg error: %s\n", cgGetErrorString(err));
|
||||
ERROR_LOG(VIDEO, "Cg error: %s\n", cgGetErrorString(err));
|
||||
const char* listing = cgGetLastListing(g_cgcontext);
|
||||
if (listing != NULL) {
|
||||
ERROR_LOG(" last listing: %s\n", listing);
|
||||
ERROR_LOG(VIDEO, " last listing: %s\n", listing);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,10 +67,10 @@
|
|||
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
|
||||
#endif
|
||||
|
||||
#define GL_REPORT_ERROR() { err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG("%s:%d: gl error 0x%x\n", __FILE__, (int)__LINE__, err); HandleGLError(); } }
|
||||
#define GL_REPORT_ERROR() { err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG(VIDEO, "%s:%d: gl error 0x%x\n", __FILE__, (int)__LINE__, err); HandleGLError(); } }
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#define GL_REPORT_ERRORD() { GLenum err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG("%s:%d: gl error 0x%x\n", __FILE__, (int)__LINE__, err); HandleGLError(); } }
|
||||
#define GL_REPORT_ERRORD() { GLenum err = glGetError(); if( err != GL_NO_ERROR ) { ERROR_LOG(VIDEO, "%s:%d: gl error 0x%x\n", __FILE__, (int)__LINE__, err); HandleGLError(); } }
|
||||
#else
|
||||
#define GL_REPORT_ERRORD()
|
||||
#endif
|
||||
|
|
|
@ -60,7 +60,7 @@ void PixelShaderCache::Init()
|
|||
int maxinst, maxattribs;
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&maxinst);
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, (GLint *)&maxattribs);
|
||||
ERROR_LOG("pixel max_alu=%d, max_inst=%d, max_attrib=%d\n", s_nMaxPixelInstructions, maxinst, maxattribs);
|
||||
ERROR_LOG(VIDEO, "pixel max_alu=%d, max_inst=%d, max_attrib=%d\n", s_nMaxPixelInstructions, maxinst, maxattribs);
|
||||
|
||||
char pmatrixprog[1024];
|
||||
sprintf(pmatrixprog, "!!ARBfp1.0"
|
||||
|
@ -80,7 +80,7 @@ void PixelShaderCache::Init()
|
|||
GLenum err = GL_NO_ERROR;
|
||||
GL_REPORT_ERROR();
|
||||
if (err != GL_NO_ERROR) {
|
||||
ERROR_LOG("Failed to create color matrix fragment program\n");
|
||||
ERROR_LOG(VIDEO, "Failed to create color matrix fragment program\n");
|
||||
glDeleteProgramsARB(1, &s_ColorMatrixProgram);
|
||||
s_ColorMatrixProgram = 0;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ FRAGMENTSHADER* PixelShaderCache::GetShader()
|
|||
|
||||
// printf("Compiling pixel shader. size = %i\n", strlen(code));
|
||||
if (!code || !CompilePixelShader(newentry.shader, code)) {
|
||||
ERROR_LOG("failed to create pixel shader\n");
|
||||
ERROR_LOG(VIDEO, "failed to create pixel shader\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -178,8 +178,8 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
|||
const char* opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
||||
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgfProf, "main", opts);
|
||||
if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) {
|
||||
ERROR_LOG("Failed to create ps %s:\n", cgGetLastListing(g_cgcontext));
|
||||
ERROR_LOG(pstrprogram);
|
||||
ERROR_LOG(VIDEO, "Failed to create ps %s:\n", cgGetLastListing(g_cgcontext));
|
||||
ERROR_LOG(VIDEO, pstrprogram);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -209,8 +209,8 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
|||
GLenum err = GL_NO_ERROR;
|
||||
GL_REPORT_ERROR();
|
||||
if (err != GL_NO_ERROR) {
|
||||
ERROR_LOG(pstrprogram);
|
||||
ERROR_LOG(pcompiledprog);
|
||||
ERROR_LOG(VIDEO, pstrprogram);
|
||||
ERROR_LOG(VIDEO, pcompiledprog);
|
||||
}
|
||||
|
||||
cgDestroyProgram(tempprog);
|
||||
|
|
|
@ -126,9 +126,9 @@ bool Renderer::Init()
|
|||
const char* ptoken = (const char*)glGetString(GL_EXTENSIONS);
|
||||
if (ptoken == NULL) return false;
|
||||
|
||||
INFO_LOG("Supported OpenGL Extensions:\n");
|
||||
INFO_LOG(ptoken); // write to the log file
|
||||
INFO_LOG("\n");
|
||||
INFO_LOG(VIDEO, "Supported OpenGL Extensions:\n");
|
||||
INFO_LOG(VIDEO, ptoken); // write to the log file
|
||||
INFO_LOG(VIDEO, "\n");
|
||||
|
||||
if (GLEW_EXT_blend_func_separate && GLEW_EXT_blend_equation_separate)
|
||||
g_bBlendSeparate = true;
|
||||
|
@ -140,24 +140,24 @@ bool Renderer::Init()
|
|||
s_bFullscreen = g_Config.bFullscreen;
|
||||
|
||||
if (glewInit() != GLEW_OK) {
|
||||
ERROR_LOG("glewInit() failed!\nDoes your video card support OpenGL 2.x?");
|
||||
ERROR_LOG(VIDEO, "glewInit() failed!\nDoes your video card support OpenGL 2.x?");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GLEW_EXT_framebuffer_object) {
|
||||
ERROR_LOG("*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********\nDoes your video card support OpenGL 2.x?");
|
||||
ERROR_LOG(VIDEO, "*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********\nDoes your video card support OpenGL 2.x?");
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
if (!GLEW_EXT_secondary_color) {
|
||||
ERROR_LOG("*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********\nDoes your video card support OpenGL 2.x?");
|
||||
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********\nDoes your video card support OpenGL 2.x?");
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)&numvertexattribs);
|
||||
|
||||
if (numvertexattribs < 11) {
|
||||
ERROR_LOG("*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********\nDoes your video card support OpenGL 2.x?", numvertexattribs);
|
||||
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********\nDoes your video card support OpenGL 2.x?", numvertexattribs);
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
|
@ -168,12 +168,12 @@ bool Renderer::Init()
|
|||
if (WGLEW_EXT_swap_control)
|
||||
wglSwapIntervalEXT(0);
|
||||
else
|
||||
ERROR_LOG("no support for SwapInterval (framerate clamped to monitor refresh rate)\nDoes your video card support OpenGL 2.x?");
|
||||
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)\nDoes your video card support OpenGL 2.x?");
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
if (glXSwapIntervalSGI)
|
||||
glXSwapIntervalSGI(0);
|
||||
else
|
||||
ERROR_LOG("no support for SwapInterval (framerate clamped to monitor refresh rate)\n");
|
||||
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)\n");
|
||||
#else
|
||||
|
||||
//TODO
|
||||
|
@ -184,7 +184,7 @@ bool Renderer::Init()
|
|||
GLint max_texture_size;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&max_texture_size);
|
||||
if (max_texture_size < 1024) {
|
||||
ERROR_LOG("GL_MAX_TEXTURE_SIZE too small at %i - must be at least 1024", max_texture_size);
|
||||
ERROR_LOG(VIDEO, "GL_MAX_TEXTURE_SIZE too small at %i - must be at least 1024", max_texture_size);
|
||||
}
|
||||
|
||||
GL_REPORT_ERROR();
|
||||
|
@ -195,7 +195,7 @@ bool Renderer::Init()
|
|||
|
||||
glGenFramebuffersEXT(1, (GLuint *)&s_uFramebuffer);
|
||||
if (s_uFramebuffer == 0) {
|
||||
ERROR_LOG("failed to create the renderbuffer\nDoes your video card support OpenGL 2.x?");
|
||||
ERROR_LOG(VIDEO, "failed to create the renderbuffer\nDoes your video card support OpenGL 2.x?");
|
||||
}
|
||||
|
||||
_assert_(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
|
@ -283,7 +283,7 @@ bool Renderer::Init()
|
|||
}
|
||||
|
||||
if (s_ZBufferTarget == 0)
|
||||
ERROR_LOG("disabling ztarget mrt feature (max mrt=%d)\n", nMaxMRT);
|
||||
ERROR_LOG(VIDEO, "disabling ztarget mrt feature (max mrt=%d)\n", nMaxMRT);
|
||||
|
||||
// Why is this left here?
|
||||
//glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget);
|
||||
|
@ -299,12 +299,12 @@ bool Renderer::Init()
|
|||
|
||||
// load the effect, find the best profiles (if any)
|
||||
if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) {
|
||||
ERROR_LOG("arbvp1 not supported\n");
|
||||
ERROR_LOG(VIDEO, "arbvp1 not supported\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) {
|
||||
ERROR_LOG("arbfp1 not supported\n");
|
||||
ERROR_LOG(VIDEO, "arbfp1 not supported\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -313,24 +313,24 @@ bool Renderer::Init()
|
|||
cgGLSetOptimalOptions(g_cgvProf);
|
||||
cgGLSetOptimalOptions(g_cgfProf);
|
||||
|
||||
//ERROR_LOG("max buffer sizes: %d %d\n", cgGetProgramBufferMaxSize(g_cgvProf), cgGetProgramBufferMaxSize(g_cgfProf));
|
||||
//ERROR_LOG(VIDEO, "max buffer sizes: %d %d\n", cgGetProgramBufferMaxSize(g_cgvProf), cgGetProgramBufferMaxSize(g_cgfProf));
|
||||
int nenvvertparams, nenvfragparams, naddrregisters[2];
|
||||
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvvertparams);
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvfragparams);
|
||||
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[0]);
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[1]);
|
||||
DEBUG_LOG("max program env parameters: vert=%d, frag=%d\n", nenvvertparams, nenvfragparams);
|
||||
DEBUG_LOG("max program address register parameters: vert=%d, frag=%d\n", naddrregisters[0], naddrregisters[1]);
|
||||
DEBUG_LOG(VIDEO, "max program env parameters: vert=%d, frag=%d\n", nenvvertparams, nenvfragparams);
|
||||
DEBUG_LOG(VIDEO, "max program address register parameters: vert=%d, frag=%d\n", naddrregisters[0], naddrregisters[1]);
|
||||
|
||||
if (nenvvertparams < 238)
|
||||
ERROR_LOG("not enough vertex shader environment constants!!\n");
|
||||
ERROR_LOG(VIDEO, "not enough vertex shader environment constants!!\n");
|
||||
|
||||
#ifndef _DEBUG
|
||||
cgGLSetDebugMode(GL_FALSE);
|
||||
#endif
|
||||
|
||||
if (cgGetError() != CG_NO_ERROR) {
|
||||
ERROR_LOG("cg error\n");
|
||||
ERROR_LOG(VIDEO, "cg error\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ bool Renderer::SetScissorRect()
|
|||
rc_bottom *= MValueY;
|
||||
if (rc_bottom > 480 * MValueY) rc_bottom = 480 * MValueY;
|
||||
|
||||
/*LOG("Scissor: lt=(%d,%d), rb=(%d,%d,%i), off=(%d,%d)\n",
|
||||
/*LOG(VIDEO, "Scissor: lt=(%d,%d), rb=(%d,%d,%i), off=(%d,%d)\n",
|
||||
rc_left, rc_top,
|
||||
rc_right, rc_bottom, Renderer::GetTargetHeight(),
|
||||
xoff, yoff
|
||||
|
@ -1333,7 +1333,7 @@ void UpdateViewport()
|
|||
// [4] = yorig + height/2 + 342
|
||||
// [5] = 16777215 * farz
|
||||
|
||||
/*INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",
|
||||
/*INFO_LOG(VIDEO, "view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",
|
||||
rawViewport[3]-rawViewport[0]-342, rawViewport[4]+rawViewport[1]-342,
|
||||
2 * rawViewport[0], 2 * rawViewport[1],
|
||||
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
|
||||
|
|
|
@ -68,7 +68,7 @@ void CreateRgbToYuyvProgram()
|
|||
"}\n";
|
||||
|
||||
if (!PixelShaderCache::CompilePixelShader(s_rgbToYuyvProgram, FProgram)) {
|
||||
ERROR_LOG("Failed to create RGB to YUYV fragment program\n");
|
||||
ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ void CreateYuyvToRgbProgram()
|
|||
"}\n";
|
||||
|
||||
if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram)) {
|
||||
ERROR_LOG("Failed to create YUYV to RGB fragment program\n");
|
||||
ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ FRAGMENTSHADER& GetOrCreateEncodingShader(u32 format)
|
|||
|
||||
if (!PixelShaderCache::CompilePixelShader(s_encodingPrograms[format], shader)) {
|
||||
const char* error = cgGetLastListing(g_cgcontext);
|
||||
ERROR_LOG("Failed to create encoding fragment program\n");
|
||||
ERROR_LOG(VIDEO, "Failed to create encoding fragment program\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,10 +101,10 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode)
|
|||
(g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
|
||||
|
||||
if (newmode.wrap_s == 2 || newmode.wrap_t == 2)
|
||||
DEBUG_LOG("cannot support mirrorred repeat mode\n");
|
||||
DEBUG_LOG(VIDEO, "cannot support mirrorred repeat mode\n");
|
||||
|
||||
if (newmode.wrap_s == 1 || newmode.wrap_t == 1)
|
||||
DEBUG_LOG("cannot support repeat mode\n");
|
||||
DEBUG_LOG(VIDEO, "cannot support repeat mode\n");
|
||||
}
|
||||
else {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
|
@ -531,7 +531,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
|||
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG("Unknown copy zbuf format: 0x%x\n", copyfmt);
|
||||
ERROR_LOG(VIDEO, "Unknown copy zbuf format: 0x%x\n", copyfmt);
|
||||
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
|||
}
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG("Unknown copy intensity format: 0x%x\n", copyfmt);
|
||||
ERROR_LOG(VIDEO, "Unknown copy intensity format: 0x%x\n", copyfmt);
|
||||
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
|||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG("Unknown copy color format: 0x%x\n", copyfmt);
|
||||
ERROR_LOG(VIDEO, "Unknown copy color format: 0x%x\n", copyfmt);
|
||||
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ void Flush()
|
|||
}
|
||||
}
|
||||
else {
|
||||
ERROR_LOG("error loading tex\n");
|
||||
ERROR_LOG(VIDEO, "error loading tex\n");
|
||||
TextureMngr::DisableStage(i); // disable since won't be used
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ VERTEXSHADER* VertexShaderCache::GetShader(u32 components)
|
|||
#endif
|
||||
|
||||
if (!code || !VertexShaderCache::CompileVertexShader(entry.shader, code)) {
|
||||
ERROR_LOG("failed to create vertex shader\n");
|
||||
ERROR_LOG(VIDEO, "failed to create vertex shader\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -137,13 +137,13 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
|||
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
||||
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts);
|
||||
if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) {
|
||||
ERROR_LOG("Failed to load vs %s:\n", cgGetLastListing(g_cgcontext));
|
||||
ERROR_LOG(pstrprogram);
|
||||
ERROR_LOG(VIDEO, "Failed to load vs %s:\n", cgGetLastListing(g_cgcontext));
|
||||
ERROR_LOG(VIDEO, pstrprogram);
|
||||
return false;
|
||||
}
|
||||
|
||||
//ERROR_LOG(pstrprogram);
|
||||
//ERROR_LOG("id: %d\n", g_Config.iSaveTargetId);
|
||||
//ERROR_LOG(VIDEO, pstrprogram);
|
||||
//ERROR_LOG(VIDEO, "id: %d\n", g_Config.iSaveTargetId);
|
||||
|
||||
char* pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
|
||||
char* plocal = strstr(pcompiledprog, "program.local");
|
||||
|
@ -161,8 +161,8 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
|||
GLenum err = GL_NO_ERROR;
|
||||
GL_REPORT_ERROR();
|
||||
if (err != GL_NO_ERROR) {
|
||||
ERROR_LOG(pstrprogram);
|
||||
ERROR_LOG(pcompiledprog);
|
||||
ERROR_LOG(VIDEO, pstrprogram);
|
||||
ERROR_LOG(VIDEO, pcompiledprog);
|
||||
}
|
||||
|
||||
cgDestroyProgram(tempprog);
|
||||
|
|
|
@ -142,7 +142,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
|
|||
case 0x1015:
|
||||
case 0x1016:
|
||||
case 0x1017:
|
||||
DEBUG_LOG("xf addr: %x=%x\n", address, data);
|
||||
DEBUG_LOG(VIDEO, "xf addr: %x=%x\n", address, data);
|
||||
break;
|
||||
case 0x1018:
|
||||
//_assert_msg_(GX_XF, 0, "XF matrixindex0");
|
||||
|
@ -195,7 +195,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
|
|||
case 0x104d:
|
||||
case 0x104e:
|
||||
case 0x104f:
|
||||
DEBUG_LOG("xf addr: %x=%x\n", address, data);
|
||||
DEBUG_LOG(VIDEO, "xf addr: %x=%x\n", address, data);
|
||||
break;
|
||||
case 0x1050: xfregs.texcoords[0].postmtxinfo.hex = data; break;
|
||||
case 0x1051: xfregs.texcoords[1].postmtxinfo.hex = data; break;
|
||||
|
@ -207,7 +207,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
|
|||
case 0x1057: xfregs.texcoords[7].postmtxinfo.hex = data; break;
|
||||
|
||||
default:
|
||||
DEBUG_LOG("xf addr: %x=%x\n", address, data);
|
||||
DEBUG_LOG(VIDEO, "xf addr: %x=%x\n", address, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@
|
|||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="false"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="0"
|
||||
OptimizeReferences="0"
|
||||
EnableCOMDATFolding="0"
|
||||
|
@ -321,7 +321,7 @@
|
|||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="false"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="0"
|
||||
OptimizeReferences="0"
|
||||
EnableCOMDATFolding="0"
|
||||
|
|
|
@ -499,9 +499,9 @@ void ConfigDialog::CreateGUIControls()
|
|||
|
||||
// Search for devices and add them to the device list
|
||||
wxArrayString StrJoyname; // The string array
|
||||
if(WiiMoteEmu::NumGoodPads > 0)
|
||||
if (WiiMoteEmu::NumGoodPads > 0)
|
||||
{
|
||||
for(int x = 0; x < WiiMoteEmu::joyinfo.size(); x++)
|
||||
for (int x = 0; x < (int)WiiMoteEmu::joyinfo.size(); x++)
|
||||
StrJoyname.Add(wxString::FromAscii(WiiMoteEmu::joyinfo[x].Name.c_str()));
|
||||
}
|
||||
else
|
||||
|
@ -518,8 +518,10 @@ void ConfigDialog::CreateGUIControls()
|
|||
StrTilt.Add(wxString::FromAscii("Triggers"));
|
||||
// The range is in degrees and are set at even 5 degrees values
|
||||
wxArrayString StrTiltRangeRoll, StrTiltRangePitch;
|
||||
for (int i = 0; i < 37; i++) StrTiltRangeRoll.Add(wxString::Format(wxT("%i"), i*5));
|
||||
for (int i = 0; i < 37; i++) StrTiltRangePitch.Add(wxString::Format(wxT("%i"), i*5));
|
||||
for (int i = 0; i < 37; i++)
|
||||
StrTiltRangeRoll.Add(wxString::Format(wxT("%i"), i*5));
|
||||
for (int i = 0; i < 37; i++)
|
||||
StrTiltRangePitch.Add(wxString::Format(wxT("%i"), i*5));
|
||||
|
||||
// The Trigger type list
|
||||
wxArrayString StrTriggerType;
|
||||
|
|
|
@ -109,7 +109,7 @@ void ConfigDialog::SetButtonTextAll(int id, char text[128])
|
|||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
// Safety check to avoid crash
|
||||
if(WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID)
|
||||
if ((int)WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID)
|
||||
if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Page].ID].Name)
|
||||
SetButtonText(id, text, i);
|
||||
};
|
||||
|
@ -123,7 +123,7 @@ void ConfigDialog::SaveButtonMappingAll(int Slot)
|
|||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
// This can occur when no gamepad is detected
|
||||
if(WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID)
|
||||
if ((int)WiiMoteEmu::joyinfo.size() > WiiMoteEmu::PadMapping[i].ID)
|
||||
if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Slot].ID].Name)
|
||||
SaveButtonMapping(i, false, Slot);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ void ConfigDialog::UpdateGUIButtonMapping(int controller)
|
|||
m_TiltInvertPitch[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bPitchInvert);
|
||||
|
||||
// Wiimote
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
m_bWmA[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.A).c_str()));
|
||||
m_bWmB[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.B).c_str()));
|
||||
m_bWm1[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.One).c_str()));
|
||||
|
@ -209,7 +209,7 @@ void ConfigDialog::UpdateGUIButtonMapping(int controller)
|
|||
m_bCcRu[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Cc.Ru).c_str()));
|
||||
m_bCcRr[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Cc.Rr).c_str()));
|
||||
m_bCcRd[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Cc.Rd).c_str()));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Console::Print("m_bWmA[%i] = %i = %s\n", controller, WiiMoteEmu::PadMapping[controller].Wm.A, InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.A).c_str());
|
||||
}
|
||||
|
@ -232,9 +232,11 @@ void ConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int From
|
|||
/* Set physical device Id. GetSelection() should never be -1 here so we don't check that it's zero or higher. If it's possible that it can be
|
||||
-1 that's a bug that should be fixed. Because the m_Joyname[] combo box should always show <No Gamepad Detected>, or a gamepad name, not a
|
||||
a blank selection. */
|
||||
if(!DontChangeId) WiiMoteEmu::PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
|
||||
if (!DontChangeId)
|
||||
WiiMoteEmu::PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
|
||||
// Set enabled or disable status
|
||||
if(FromSlot == controller) WiiMoteEmu::PadMapping[controller].enabled = true; //m_Joyattach[FromSlot]->GetValue(); // Only enable one
|
||||
if (FromSlot == controller)
|
||||
WiiMoteEmu::PadMapping[controller].enabled = true; //m_Joyattach[FromSlot]->GetValue(); // Only enable one
|
||||
// Set other settings
|
||||
//WiiMoteEmu::PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection();
|
||||
WiiMoteEmu::PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection();
|
||||
|
|
|
@ -363,24 +363,24 @@ void ConfigDialog::ConvertToString()
|
|||
file.Load(FULL_CONFIG_DIR "WiimoteMovement.ini");
|
||||
std::string TmpStr = "", TmpIR = "", TmpTime = "";
|
||||
|
||||
for (int i = 0; i < m_vRecording.size(); i++)
|
||||
for (int i = 0; i < (int)m_vRecording.size(); i++)
|
||||
{
|
||||
// Write the movement data
|
||||
TmpStr += StringFromFormat("%s", m_vRecording.at(i).x >= 0 ? StringFromFormat("+%03i", m_vRecording.at(i).x).c_str() : StringFromFormat("%04i", m_vRecording.at(i).x).c_str());
|
||||
TmpStr += StringFromFormat("%s", m_vRecording.at(i).y >= 0 ? StringFromFormat("+%03i", m_vRecording.at(i).y).c_str() : StringFromFormat("%04i", m_vRecording.at(i).y).c_str());
|
||||
TmpStr += StringFromFormat("%s", m_vRecording.at(i).z >= 0 ? StringFromFormat("+%03i", m_vRecording.at(i).z).c_str() : StringFromFormat("%04i", m_vRecording.at(i).z).c_str());
|
||||
if(i < (m_vRecording.size() - 1)) TmpStr += ",";
|
||||
if (i < ((int)m_vRecording.size() - 1)) TmpStr += ",";
|
||||
|
||||
//Console::Print("%s\n", TmpStr.c_str());
|
||||
|
||||
// Write the IR data
|
||||
TmpIR += ArrayToString(m_vRecording.at(i).IR, IRBytes, 0, 30, false);
|
||||
if(i < (m_vRecording.size() - 1)) TmpIR += ",";
|
||||
if (i < ((int)m_vRecording.size() - 1)) TmpIR += ",";
|
||||
|
||||
// Write the timestamps. The upper limit is 99 seconds.
|
||||
int Time = (int)((m_vRecording.at(i).Time - m_vRecording.at(0).Time) * 1000);
|
||||
TmpTime += StringFromFormat("%05i", Time);
|
||||
if(i < (m_vRecording.size() - 1)) TmpTime += ",";
|
||||
if (i < ((int)m_vRecording.size() - 1)) TmpTime += ",";
|
||||
|
||||
/* Break just short of the IniFile.cpp byte limit so that we don't crash file.Load() the next time.
|
||||
This limit should never be hit because of the recording limit below. I keep it here just in case. */
|
||||
|
|
|
@ -171,7 +171,7 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm)
|
|||
g_RecordingCurrentTime[Wm] *= ((25.0 + (double)VRecording.at(g_RecordingPlaying[Wm]).PlaybackSpeed * 25.0) / 100.0);
|
||||
|
||||
// Select reading
|
||||
for (int i = 0; i < VRecording.at(g_RecordingPlaying[Wm]).Recording.size(); i++)
|
||||
for (int i = 0; i < (int)VRecording.at(g_RecordingPlaying[Wm]).Recording.size(); i++)
|
||||
if (VRecording.at(g_RecordingPlaying[Wm]).Recording.at(i).Time > g_RecordingCurrentTime[Wm])
|
||||
{
|
||||
g_RecordingPoint[Wm] = i;
|
||||
|
|
|
@ -1061,7 +1061,7 @@ int GetUpdateRate()
|
|||
//Console::Print("Time: %i %f\n", Time, GetDoubleTime());
|
||||
|
||||
int TotalTime = 0;
|
||||
for (int i = 0; i < g_UpdateTimeList.size(); i++)
|
||||
for (int i = 0; i < (int)g_UpdateTimeList.size(); i++)
|
||||
TotalTime += g_UpdateTimeList.at(i);
|
||||
g_UpdateRate = TotalTime / 5;
|
||||
|
||||
|
|
Loading…
Reference in New Issue