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:
hrydgard 2009-02-28 01:26:56 +00:00
parent 2783f24cfe
commit 4bdb4aa0d1
77 changed files with 1610 additions and 1479 deletions

View File

@ -546,6 +546,14 @@
RelativePath=".\Src\ABI.h" RelativePath=".\Src\ABI.h"
> >
</File> </File>
<File
RelativePath=".\Src\CDUtils.cpp"
>
</File>
<File
RelativePath=".\Src\CDUtils.h"
>
</File>
<File <File
RelativePath=".\Src\ChunkFile.cpp" RelativePath=".\Src\ChunkFile.cpp"
> >
@ -566,6 +574,18 @@
RelativePath=".\Src\Common.h" RelativePath=".\Src\Common.h"
> >
</File> </File>
<File
RelativePath=".\Src\CommonFuncs.h"
>
</File>
<File
RelativePath=".\Src\CommonPaths.h"
>
</File>
<File
RelativePath=".\Src\CommonTypes.h"
>
</File>
<File <File
RelativePath=".\Src\ConsoleWindow.cpp" RelativePath=".\Src\ConsoleWindow.cpp"
> >
@ -582,14 +602,6 @@
RelativePath=".\Src\CPUDetect.h" RelativePath=".\Src\CPUDetect.h"
> >
</File> </File>
<File
RelativePath=".\Src\CDUtils.cpp"
>
</File>
<File
RelativePath=".\Src\CDUtils.h"
>
</File>
<File <File
RelativePath=".\Src\DynamicLibrary.cpp" RelativePath=".\Src\DynamicLibrary.cpp"
> >
@ -650,6 +662,10 @@
RelativePath=".\Src\IniFile.h" RelativePath=".\Src\IniFile.h"
> >
</File> </File>
<File
RelativePath=".\Src\Log.h"
>
</File>
<File <File
RelativePath=".\Src\MappedFile.cpp" RelativePath=".\Src\MappedFile.cpp"
> >
@ -682,12 +698,16 @@
RelativePath=".\Src\MemoryUtil.h" RelativePath=".\Src\MemoryUtil.h"
> >
</File> </File>
<File
RelativePath=".\Src\Misc.cpp"
>
</File>
<File <File
RelativePath=".\Src\MsgHandler.cpp" RelativePath=".\Src\MsgHandler.cpp"
> >
</File> </File>
<File <File
RelativePath=".\Src\Paths.h" RelativePath=".\Src\MsgHandler.h"
> >
</File> </File>
<File <File

View File

@ -22,7 +22,6 @@
using namespace Gen; using namespace Gen;
// Shared code between Win64 and Unix64 // Shared code between Win64 and Unix64
// ====================================
// Sets up a __cdecl function. // Sets up a __cdecl function.
void XEmitter::ABI_EmitPrologue(int maxCallParams) void XEmitter::ABI_EmitPrologue(int maxCallParams)
@ -53,14 +52,14 @@ void XEmitter::ABI_EmitEpilogue(int maxCallParams)
RET(); RET();
#else #else
#error Arch not supported #error Arch not supported
#endif #endif
} }
#ifdef _M_IX86 // All32 #ifdef _M_IX86 // All32
// Shared code between Win32 and Unix32 // Shared code between Win32 and Unix32
// ====================================
void XEmitter::ABI_CallFunction(void *func) { void XEmitter::ABI_CallFunction(void *func) {
ABI_AlignStack(0); ABI_AlignStack(0);
CALL(func); CALL(func);
@ -160,8 +159,9 @@ void XEmitter::ABI_RestoreStack(unsigned int frameSize) {
} }
} }
#else #else //64bit
// Common functions
void XEmitter::ABI_CallFunction(void *func) { void XEmitter::ABI_CallFunction(void *func) {
CALL(func); CALL(func);
} }
@ -221,7 +221,6 @@ void XEmitter::ABI_RestoreStack(unsigned int /*frameSize*/) {
#ifdef _WIN32 #ifdef _WIN32
// Win64 Specific Code // Win64 Specific Code
// ====================================
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() { void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
//we only want to do this once //we only want to do this once
PUSH(RBX); PUSH(RBX);
@ -249,7 +248,6 @@ void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
} }
// Win64 Specific Code // Win64 Specific Code
// ====================================
void XEmitter::ABI_PushAllCallerSavedRegsAndAdjustStack() { void XEmitter::ABI_PushAllCallerSavedRegsAndAdjustStack() {
PUSH(RCX); PUSH(RCX);
PUSH(RDX); PUSH(RDX);
@ -277,7 +275,6 @@ void XEmitter::ABI_PopAllCallerSavedRegsAndAdjustStack() {
#else #else
// Unix64 Specific Code // Unix64 Specific Code
// ====================================
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() { void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
PUSH(RBX); PUSH(RBX);
PUSH(RBP); PUSH(RBP);
@ -322,7 +319,8 @@ void XEmitter::ABI_PopAllCallerSavedRegsAndAdjustStack() {
POP(RCX); POP(RCX);
} }
#endif #endif // WIN32
#endif // 32bit
#endif

View File

@ -45,8 +45,7 @@
// Callee-save: RBX RBP R12 R13 R14 R15 // Callee-save: RBX RBP R12 R13 R14 R15
// Parameters: RDI RSI RDX RCX R8 R9 // Parameters: RDI RSI RDX RCX R8 R9
#ifdef _M_IX86 #ifdef _M_IX86 // 32 bit calling convention, shared by all
// 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 // 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. // choose regs to put stuff in.
@ -54,21 +53,19 @@
#define ABI_PARAM2 RDX #define ABI_PARAM2 RDX
// There are no ABI_PARAM* here, since args are pushed. // 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. // 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 #else // 64 bit calling convention
// === 64-bit Windows - the really exotic calling convention ==================================
#ifdef _WIN32 // 64-bit Windows - the really exotic calling convention
#define ABI_PARAM1 RCX #define ABI_PARAM1 RCX
#define ABI_PARAM2 RDX #define ABI_PARAM2 RDX
#define ABI_PARAM3 R8 #define ABI_PARAM3 R8
#define ABI_PARAM4 R9 #define ABI_PARAM4 R9
#else
// === 64-bit Unix (hopefully MacOSX too) ===================================================== #else //64-bit Unix (hopefully MacOSX too)
#define ABI_PARAM1 RDI #define ABI_PARAM1 RDI
#define ABI_PARAM2 RSI #define ABI_PARAM2 RSI
@ -83,3 +80,4 @@
#endif // _JIT_ABI_H #endif // _JIT_ABI_H

View File

@ -35,29 +35,29 @@
static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx) unsigned int *ecx, unsigned int *edx)
{ {
#ifdef _LP64 #ifdef _LP64
__asm__("cpuid" __asm__("cpuid"
: "=a" (*eax), : "=a" (*eax),
"=b" (*ebx), "=b" (*ebx),
"=c" (*ecx), "=c" (*ecx),
"=d" (*edx) "=d" (*edx)
: "a" (*eax) : "a" (*eax)
); );
#else #else
// Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to be // 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. // restored at the end of the asm block.
__asm__( __asm__(
"pushl %%ebx;" "pushl %%ebx;"
"cpuid;" "cpuid;"
"movl %%ebx,%1;" "movl %%ebx,%1;"
"popl %%ebx;" "popl %%ebx;"
: "=a" (*eax), : "=a" (*eax),
"=r" (*ebx), "=r" (*ebx),
"=c" (*ecx), "=c" (*ecx),
"=d" (*edx) "=d" (*edx)
: "a" (*eax) : "a" (*eax)
); );
#endif #endif
} }
void __cpuid(int info[4], int x) void __cpuid(int info[4], int x)
@ -78,6 +78,7 @@ void __cpuid(int info[4], int x)
CPUInfo cpu_info; CPUInfo cpu_info;
// Detects the various cpu features
void CPUInfo::Detect() void CPUInfo::Detect()
{ {
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
@ -88,26 +89,26 @@ void CPUInfo::Detect()
OS64bit = true; OS64bit = true;
#endif #endif
num_cores = 1; num_cores = 1;
#ifdef _WIN32 #ifdef _WIN32
#ifdef _M_IX86 #ifdef _M_IX86
BOOL f64 = FALSE; bool f64 = false;
OS64bit = IsWow64Process(GetCurrentProcess(), &f64) && f64; OS64bit = IsWow64Process(GetCurrentProcess(), (PBOOL)(&f64)) && f64;
#endif #endif
#endif #endif
// Set obvious defaults, for extra safety // Set obvious defaults, for extra safety
if (Mode64bit) if (Mode64bit) {
{
bSSE = true; bSSE = true;
bSSE2 = true; bSSE2 = true;
bLongMode = 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]; int cpu_id[4];
memset(cpu_string, 0, sizeof(cpu_string)); memset(cpu_string, 0, sizeof(cpu_string));
// Detect CPU's CPUID capabilities, and grab cpu string // Detect CPU's CPUID capabilities, and grab cpu string
__cpuid(cpu_id, 0x00000000); __cpuid(cpu_id, 0x00000000);
u32 max_std_fn = cpu_id[0]; // EAX u32 max_std_fn = cpu_id[0]; // EAX
@ -122,10 +123,10 @@ void CPUInfo::Detect()
vendor = VENDOR_AMD; vendor = VENDOR_AMD;
else else
vendor = VENDOR_OTHER; vendor = VENDOR_OTHER;
// Set reasonable default brand string even if brand string not available. // Set reasonable default brand string even if brand string not available.
strcpy(brand_string, cpu_string); strcpy(brand_string, cpu_string);
// Detect family and other misc stuff. // Detect family and other misc stuff.
bool HTT = false; bool HTT = false;
int logical_cpu_count = 1; 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 CPUInfo::Summarize()
{ {
std::string sum; std::string sum;

View File

@ -15,6 +15,7 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
// Detect the cpu, so we'll know which optimizations to use
#ifndef _CPUDETECT_H #ifndef _CPUDETECT_H
#define _CPUDETECT_H #define _CPUDETECT_H
@ -30,13 +31,13 @@ enum CPUVendor
struct CPUInfo struct CPUInfo
{ {
CPUVendor vendor; CPUVendor vendor;
char cpu_string[0x21]; char cpu_string[0x21];
char brand_string[0x41]; char brand_string[0x41];
bool OS64bit; bool OS64bit;
bool CPU64bit; bool CPU64bit;
bool Mode64bit; bool Mode64bit;
bool hyper_threaded; bool hyper_threaded;
int num_cores; int num_cores;
@ -51,8 +52,11 @@ struct CPUInfo
bool bSSE4A; bool bSSE4A;
bool bLAHFSAHF64; bool bLAHFSAHF64;
bool bLongMode; bool bLongMode;
// Detects the various cpu features
void Detect(); void Detect();
// Turn the cpu info into a string we can show
std::string Summarize(); std::string Summarize();
}; };

View File

@ -34,6 +34,7 @@
#include <string> #include <string>
#include "Common.h" #include "Common.h"
#include "FileUtil.h"
template <class T> template <class T>
struct LinkedListItem : public T struct LinkedListItem : public T
@ -41,15 +42,11 @@ struct LinkedListItem : public T
LinkedListItem<T> *next; LinkedListItem<T> *next;
}; };
// Wrapper class
class PointerWrap class PointerWrap
{ {
public: public:
/* READ is when we read from the save state file, WRITE is when we write to the enum Mode {
save state file. This enumareted list is also defined in pluginspecs.h. Didn't
want to couple them. */
enum Mode
{
MODE_READ = 1, MODE_READ = 1,
MODE_WRITE, MODE_WRITE,
MODE_MEASURE, MODE_MEASURE,
@ -68,8 +65,7 @@ public:
void DoVoid(void *data, int size) void DoVoid(void *data, int size)
{ {
switch (mode) switch (mode) {
{
case MODE_READ: memcpy(data, *ptr, size); break; case MODE_READ: memcpy(data, *ptr, size); break;
case MODE_WRITE: memcpy(*ptr, data, size); break; case MODE_WRITE: memcpy(*ptr, data, size); break;
case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
@ -84,22 +80,21 @@ public:
// TODO // TODO
PanicAlert("Do(map<>) does not yet work."); PanicAlert("Do(map<>) does not yet work.");
} }
// Store vectors. // Store vectors.
template<class T> template<class T>
void Do(std::vector<T> &x) { void Do(std::vector<T> &x) {
// TODO // TODO
PanicAlert("Do(vector<>) does not yet work."); PanicAlert("Do(vector<>) does not yet work.");
} }
// Store strings. // Store strings.
void Do(std::string &x) void Do(std::string &x)
{ {
int stringLen = (int)x.length() + 1; int stringLen = (int)x.length() + 1;
Do(stringLen); Do(stringLen);
switch (mode) switch (mode) {
{
case MODE_READ: x = (char*)*ptr; break; case MODE_READ: x = (char*)*ptr; break;
case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
case MODE_MEASURE: break; case MODE_MEASURE: break;
@ -110,33 +105,29 @@ public:
void DoBuffer(u8** pBuffer, u32& _Size) void DoBuffer(u8** pBuffer, u32& _Size)
{ {
Do(_Size); Do(_Size);
if (_Size > 0) if (_Size > 0) {
{ switch (mode) {
switch (mode)
{
case MODE_READ: *pBuffer = new u8[_Size]; memcpy(*pBuffer, *ptr, _Size); break; case MODE_READ: *pBuffer = new u8[_Size]; memcpy(*pBuffer, *ptr, _Size); break;
case MODE_WRITE: memcpy(*ptr, *pBuffer, _Size); break; case MODE_WRITE: memcpy(*ptr, *pBuffer, _Size); break;
case MODE_MEASURE: break; case MODE_MEASURE: break;
} }
} } else {
else
{
*pBuffer = NULL; *pBuffer = NULL;
} }
(*ptr) += _Size; (*ptr) += _Size;
} }
template<class T> template<class T>
void DoArray(T *x, int count) { void DoArray(T *x, int count) {
DoVoid((void *)x, sizeof(T) * count); DoVoid((void *)x, sizeof(T) * count);
} }
template<class T> template<class T>
void Do(T &x) { void Do(T &x) {
DoVoid((void *)&x, sizeof(x)); DoVoid((void *)&x, sizeof(x));
} }
template<class T> template<class T>
void DoLinkedList(LinkedListItem<T> **list_start) { void DoLinkedList(LinkedListItem<T> **list_start) {
// TODO // TODO
@ -148,85 +139,129 @@ public:
class CChunkFileReader class CChunkFileReader
{ {
public: public:
// Load file template
template<class T> 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) INFO_LOG(COMMON, "ChunkReader: Loading %s" , _rFilename.c_str());
{
// get size
fseek(pFile, 0, SEEK_END);
size_t FileSize = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
if (FileSize < sizeof(SChunkHeader)) if (! File::Exists(_rFilename.c_str()))
{ return false;
fclose(pFile);
return false; // Check file size
} u64 fileSize = File::GetSize(_rFilename.c_str());
u64 headerSize = sizeof(SChunkHeader);
// read the header if (fileSize < headerSize) {
SChunkHeader Header; ERROR_LOG(COMMON,"ChunkReader: File too small");
fread(&Header, sizeof(SChunkHeader), 1, pFile); return false;
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;
} }
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> template<class T>
static bool Save(const std::string& _rFilename, int _Revision, T& _class) static bool Save(const std::string& _rFilename, int _Revision, T& _class)
{ {
FILE* pFile = fopen(_rFilename.c_str(), "wb"); FILE* pFile;
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);
SChunkHeader Header; INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str());
Header.Compress = 0;
Header.Revision = _Revision; if (! (pFile = fopen(_rFilename.c_str(), "wb"))) {
Header.ExpectedSize = (int)sz; ERROR_LOG(COMMON,"ChunkReader: Error opening file for write");
return false;
fwrite(&Header, sizeof(SChunkHeader), 1, pFile);
fwrite(buffer, sz, 1, pFile);
fclose(pFile);
return true;
} }
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: private:
struct SChunkHeader struct SChunkHeader
{ {

View File

@ -18,51 +18,28 @@
#ifndef _COMMON_H #ifndef _COMMON_H
#define _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 <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.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. // Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
// This probably wouldn't break anyone either, but hey // This probably wouldn't break anyone either, but hey
@ -72,325 +49,73 @@
#define STACKALIGN #define STACKALIGN
#endif #endif
// Function Cross-Compatibility
#ifdef _WIN32 #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 // Memory leak check defines
// By default, MS' stdio implementation does not support 64-bit offsets. #define _CRTDBG_MAP_ALLOC
// This little hack fixes that, keeping the code portable to linux where fseek and fread #define _CRTDBG_MAP_ALLOC_NEW
// do support 64-bit offsets in modern distributions. #define CHECK_HEAP_INTEGRITY()
#define fseek _fseeki64
#define ftell _ftelli64
#define atoll _atoi64 #define POSIX 0
#define NOMINMAX
#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
// Alignment // 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 namespace
#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
{ {
inline u8 swap8(u8 _data) {return(_data);} // 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.
#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
#ifndef _SECURE_SCL #ifndef _SECURE_SCL
#error Please define _SECURE_SCL=0 in the project settings #error Please define _SECURE_SCL=0 in the project settings
#else #else
template <bool> struct CompileTimeAssert; template <bool> struct CompileTimeAssert;
template<> struct CompileTimeAssert<true> {}; template<> struct CompileTimeAssert<true> {};
CompileTimeAssert<_SECURE_SCL==0> x; CompileTimeAssert<_SECURE_SCL==0> x;
#endif #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 #else // Not windows
#define SLEEP(x) Sleep(x)
#else
#define SLEEP(x) usleep(x*1000)
#endif
#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

View File

@ -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

View File

@ -1,130 +1,159 @@
#ifndef PATHS_H // Copyright (C) 2003-2008 Dolphin Project.
#define PATHS_H
// This program is free software: you can redistribute it and/or modify
#ifdef _WIN32 // it under the terms of the GNU General Public License as published by
#define PLUGIN_PREFIX "" // the Free Software Foundation, version 2.0.
#define PLUGIN_SUFFIX ".dll"
#else // This program is distributed in the hope that it will be useful,
#ifdef __APPLE__ // but WITHOUT ANY WARRANTY; without even the implied warranty of
#define PLUGIN_PREFIX "lib" // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#define PLUGIN_SUFFIX ".dylib" // GNU General Public License 2.0 for more details.
#else
#define PLUGIN_PREFIX "lib" // A copy of the GPL 2.0 should have been included with the program.
#define PLUGIN_SUFFIX ".so" // If not, see http://www.gnu.org/licenses/
#endif
#endif // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#define DIR_SEP "/"
#define DIR_SEP_CHR '/' #ifndef COMMON_PATHS_H
#define COMMON_PATHS_H
#define PLUGINS_DIR "Plugins"
#define ROOT_DIR "." // Library suffix/prefix
#define USERDATA_DIR "User" #ifdef _WIN32
#define SYSDATA_DIR "Sys" #define PLUGIN_PREFIX ""
#define PLUGIN_SUFFIX ".dll"
// Dirs in both User and Sys #elif defined __APPLE__
#define EUR_DIR "EUR" #define PLUGIN_PREFIX "lib"
#define USA_DIR "USA" #define PLUGIN_SUFFIX ".dylib"
#define JAP_DIR "JAP" #else
#define PLUGIN_PREFIX "lib"
// Dirs in User #define PLUGIN_SUFFIX ".so"
#define GC_USER_DIR "GC" #endif
#define WII_USER_DIR "Wii"
#define WII_SYSCONF_DIR "shared2/sys" // Directory seperators, do we need this?
#define CONFIG_DIR "Config" #define DIR_SEP "/"
#define GAMECONFIG_DIR "GameConfig" #define DIR_SEP_CHR '/'
#define MAPS_DIR "Maps"
#define CACHE_DIR "Cache" #define PLUGINS_DIR "Plugins"
#define STATESAVES_DIR "StateSaves" #define ROOT_DIR "."
#define SCREENSHOTS_DIR "ScreenShots" #define USERDATA_DIR "User"
#define DUMP_DIR "Dump" #define SYSDATA_DIR "Sys"
#define LOGS_DIR "Logs"
#define MAIL_LOGS_DIR "Mail" // Where data directory is
#ifdef _WIN32
// Dirs in Sys #define DOLPHIN_DATA_DIR "Dolphin"
#define GC_SYS_DIR "GC" #elif defined __APPLE__
#define WII_SYS_DIR "Wii" #define DOLPHIN_DATA_DIR "Library/Application Support/Dolphin"
#else
// Filenames #define DOLPHIN_DATA_DIR ".dolphin"
#define DOLPHIN_CONFIG "Dolphin.ini" #endif
#define DEBUGGER_CONFIG "Debugger.ini"
#define TOTALDB "totaldb.dsy" // Dirs in both User and Sys
#define EUR_DIR "EUR"
#define DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX #define USA_DIR "USA"
#define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX #define JAP_DIR "JAP"
#define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_PadSimple" PLUGIN_SUFFIX
#define DEFAULT_WIIMOTE_PLUGIN PLUGIN_PREFIX "Plugin_Wiimote" PLUGIN_SUFFIX // Dirs in User
#define GC_USER_DIR "GC"
#define FONT_ANSI "font_ansi.bin" #define WII_USER_DIR "Wii"
#define FONT_SJIS "font_sjis.bin" #define WII_SYSCONF_DIR "shared2/sys"
#define CONFIG_DIR "Config"
#define DSP_ROM "dsp_rom.bin" #define GAMECONFIG_DIR "GameConfig"
#define DSP_COEF "dsp_coef.bin" #define MAPS_DIR "Maps"
#define CACHE_DIR "Cache"
#define GC_IPL "IPL.bin" #define STATESAVES_DIR "StateSaves"
#define GC_SRAM "SRAM.raw" #define SCREENSHOTS_DIR "ScreenShots"
#define GC_MEMCARDA "MemoryCardA" #define DUMP_DIR "Dump"
#define GC_MEMCARDB "MemoryCardB" #define LOGS_DIR "Logs"
#define MAIL_LOGS_DIR "Mail"
#define WII_EUR_SETTING "setting-eur.txt"
#define WII_USA_SETTING "setting-usa.txt" // Dirs in Sys
#define WII_JAP_SETTING "setting-jpn.txt" #define GC_SYS_DIR "GC"
#define WII_SYSCONF "SYSCONF" #define WII_SYS_DIR "Wii"
#define MEMORY_DUMP_FILE "mainram.dump" // Filenames
#define DOLPHIN_CONFIG "Dolphin.ini"
// Shorts - dirs #define DEBUGGER_CONFIG "Debugger.ini"
// User dirs #define LOGGER_CONFIG "Logger.ini"
#define FULL_USERDATA_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP #define TOTALDB "totaldb.dsy"
#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 DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX
//#define GC_USER_USA_DIR FULL_GC_USER_DIR USA_DIR #define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX
//#define GC_USER_JAP_DIR FULL_GC_USER_DIR JAP_DIR #define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_PadSimple" PLUGIN_SUFFIX
#define DEFAULT_WIIMOTE_PLUGIN PLUGIN_PREFIX "Plugin_Wiimote" PLUGIN_SUFFIX
#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 FONT_ANSI "font_ansi.bin"
#define FONT_SJIS "font_sjis.bin"
#define FULL_GAMECONFIG_DIR FULL_USERDATA_DIR GAMECONFIG_DIR DIR_SEP
#define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP #define DSP_ROM "dsp_rom.bin"
#define FULL_CACHE_DIR FULL_USERDATA_DIR CACHE_DIR DIR_SEP #define DSP_COEF "dsp_coef.bin"
#define FULL_STATESAVES_DIR FULL_USERDATA_DIR STATESAVES_DIR DIR_SEP
#define FULL_SCREENSHOTS_DIR FULL_USERDATA_DIR SCREENSHOTS_DIR DIR_SEP #define GC_IPL "IPL.bin"
#define FULL_DUMP_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP #define GC_SRAM "SRAM.raw"
#define FULL_LOGS_DIR FULL_USERDATA_DIR LOGS_DIR DIR_SEP #define GC_MEMCARDA "MemoryCardA"
#define FULL_MAIL_LOGS_DIR FULL_LOGS_DIR MAIL_LOGS_DIR DIR_SEP #define GC_MEMCARDB "MemoryCardB"
#define FULL_MAPS_DIR FULL_USERDATA_DIR MAPS_DIR DIR_SEP
#define WII_EUR_SETTING "setting-eur.txt"
// Sys dirs #define WII_USA_SETTING "setting-usa.txt"
#define FULL_SYSDATA_DIR ROOT_DIR DIR_SEP SYSDATA_DIR DIR_SEP #define WII_JAP_SETTING "setting-jpn.txt"
#define WII_SYSCONF "SYSCONF"
#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 MEMORY_DUMP_FILE "mainram.dump"
//#define GC_SYS_USA_DIR FULL_GC_SYS_DIR USA_DIR
//#define GC_SYS_JAP_DIR FULL_GC_SYS_DIR JAP_DIR // Shorts - dirs
// User dirs
#define FULL_WII_SYS_DIR FULL_SYSDATA_DIR WII_SYS_DIR DIR_SEP #define FULL_USERDATA_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP
// Shorts - files #define FULL_GC_USER_DIR FULL_USERDATA_DIR GC_USER_DIR DIR_SEP
// User files //#define GC_USER_EUR_DIR FULL_GC_USER_DIR EUR_DIR
#define CONFIG_FILE FULL_CONFIG_DIR DOLPHIN_CONFIG //#define GC_USER_USA_DIR FULL_GC_USER_DIR USA_DIR
#define DEBUGGER_CONFIG_FILE FULL_CONFIG_DIR DEBUGGER_CONFIG //#define GC_USER_JAP_DIR FULL_GC_USER_DIR JAP_DIR
#define TOTALDB_FILE FULL_SYSDATA_DIR TOTALDB #define FULL_WII_USER_DIR FULL_USERDATA_DIR WII_USER_DIR DIR_SEP
#define MAINRAM_DUMP_FILE FULL_DUMP_DIR MEMORY_DUMP_FILE #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 GC_SRAM_FILE FULL_USERDATA_DIR GC_USER_DIR DIR_SEP GC_SRAM
#define FULL_GAMECONFIG_DIR FULL_USERDATA_DIR GAMECONFIG_DIR DIR_SEP
// Sys files #define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP
#define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI #define FULL_CACHE_DIR FULL_USERDATA_DIR CACHE_DIR DIR_SEP
#define FONT_SJIS_FILE FULL_GC_SYS_DIR FONT_SJIS #define FULL_STATESAVES_DIR FULL_USERDATA_DIR STATESAVES_DIR DIR_SEP
#define FULL_SCREENSHOTS_DIR FULL_USERDATA_DIR SCREENSHOTS_DIR DIR_SEP
#define DSP_ROM_FILE FULL_GC_SYS_DIR DSP_ROM #define FULL_DUMP_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP
#define DSP_COEF_FILE FULL_GC_SYS_DIR DSP_COEF #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 WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING #define FULL_MAPS_DIR FULL_USERDATA_DIR MAPS_DIR DIR_SEP
#define WII_USA_SETTING_FILE FULL_WII_SYS_DIR WII_USA_SETTING
#define WII_JAP_SETTING_FILE FULL_WII_SYS_DIR WII_JAP_SETTING // Sys dirs
#define WII_SYSCONF_FILE FULL_WII_USER_DIR WII_SYSCONF_DIR DIR_SEP WII_SYSCONF #define FULL_SYSDATA_DIR ROOT_DIR DIR_SEP SYSDATA_DIR DIR_SEP
#define FULL_WII_MENU_DIR FULL_WII_USER_DIR "title" DIR_SEP "00000001" DIR_SEP "00000002" DIR_SEP "content" #define FULL_GC_SYS_DIR FULL_SYSDATA_DIR GC_SYS_DIR DIR_SEP
//#define GC_SYS_EUR_DIR FULL_GC_SYS_DIR EUR_DIR
#endif // PATHS_H //#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

View File

@ -1,57 +1,58 @@
// Copyright (C) 2003-2008 Dolphin Project. // Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0. // the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details. // GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program. // A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/ // If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
// This header contains type definitions that are shared between the Dolphin
// 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
// core and the plugin specs. Any definitions that are only used by the core // should be placed in "Common.h" instead.
// should be placed in "Common.h" instead.
#ifndef _COMMONTYPES_H
#ifndef _COMMONTYPES_H #define _COMMONTYPES_H
#define _COMMONTYPES_H
#ifdef _WIN32
#ifdef _WIN32
#include <tchar.h>
#include <tchar.h>
typedef unsigned __int8 u8;
typedef unsigned __int8 u8; typedef unsigned __int16 u16;
typedef unsigned __int16 u16; typedef unsigned __int32 u32;
typedef unsigned __int32 u32; typedef unsigned __int64 u64;
typedef unsigned __int64 u64;
typedef signed __int8 s8;
typedef signed __int8 s8; typedef signed __int16 s16;
typedef signed __int16 s16; typedef signed __int32 s32;
typedef signed __int32 s32; typedef signed __int64 s64;
typedef signed __int64 s64;
#else
#else
typedef unsigned char u8;
typedef unsigned char u8; typedef unsigned short u16;
typedef unsigned short u16; typedef unsigned int u32;
typedef unsigned int u32; typedef unsigned long long u64;
typedef unsigned long long u64;
typedef char s8;
typedef char s8; typedef short s16;
typedef short s16; typedef int s32;
typedef int s32; typedef long long s64;
typedef long long s64;
// For using windows lock code
#define TCHAR char #define TCHAR char
#define LONG int
#endif // _WIN32
#endif // _WIN32
#endif // _COMMONTYPES_H
#endif // _COMMONTYPES_H

View File

@ -15,8 +15,10 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // 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 #include <string.h> // System
#ifdef _WIN32 #ifdef _WIN32
@ -32,113 +34,116 @@
#include "DynamicLibrary.h" #include "DynamicLibrary.h"
#include "ConsoleWindow.h" #include "ConsoleWindow.h"
DynamicLibrary::DynamicLibrary() DynamicLibrary::DynamicLibrary()
{ {
library = 0; library = 0;
} }
std::string GetLastErrorAsString() // Gets the last dll error as string
const char *DllGetLastError()
{ {
#ifdef _WIN32 #ifdef _WIN32
LPVOID lpMsgBuf = 0; return GetLastErrorMsg();
DWORD error = GetLastError(); #else // not win32
FormatMessage( return dlerror();
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, #endif // WIN32
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
} }
/* Function: Loading means loading the dll with LoadLibrary() to get an /* Loads the dll with LoadLibrary() or dlopen. This function is called on
instance to the dll. This is done when Dolphin is started to determine start to scan for plugin, and before opening the Config and Debugging
which dlls are good, and before opening the Config and Debugging windows windows. It is also called from core to load the plugins when the
from Plugin.cpp and before opening the dll for running the emulation in emulation starts.
Video_...cpp in Core. Since this is fairly slow, TODO: think about
implementing some sort of cache. Returns 0 on failure and 1 on success
Called from: The Dolphin Core */ TODO: think about implementing some sort of cache for the plugin info.
*/
int DynamicLibrary::Load(const char* filename) int DynamicLibrary::Load(const char* filename)
{ {
if (!filename || strlen(filename) == 0)
{ INFO_LOG(COMMON, "DL: Loading dynamic library %s", filename);
LOG(MASTER_LOG, "Missing filename of dynamic library to load");
PanicAlert("Missing filename of dynamic library to load"); if (!filename || strlen(filename) == 0) {
ERROR_LOG(COMMON, "DL: Missing filename to load");
return 0; return 0;
} }
if (IsLoaded())
{ if (IsLoaded()) {
LOG(MASTER_LOG, "Trying to load already loaded library %s", filename); INFO_LOG(COMMON, "DL: library %s already loaded", filename);
return 2; return 1;
} }
Console::Print("LoadLibrary: %s", filename);
#ifdef _WIN32 #ifdef _WIN32
library = LoadLibrary(filename); library = LoadLibrary(filename);
#else #else
// RTLD_NOW: resolve all symbols on load
// RTLD_LOCAL: don't resolve symbols for other libraries
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
#endif #endif
Console::Print(" %p\n", library);
if (!library) DEBUG_LOG(COMMON, "DL: LoadLibrary: %s(%p)", filename, library);
{
LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); if (!library) {
PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str()); ERROR_LOG(COMMON, "DL: Error loading DLL %s: %s", filename,
DllGetLastError());
return 0; return 0;
} }
library_file = filename; library_file = filename;
INFO_LOG(COMMON, "DL: Done loading dynamic library %s", filename);
return 1; 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 DynamicLibrary::Unload()
{ {
int retval; INFO_LOG(COMMON, "DL: Unloading dynamic library %s", library_file.c_str());
if (!IsLoaded()) int retval;
{ if (!IsLoaded()) { // library != null
PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str()); ERROR_LOG(COMMON, "DL: Unload failed for %s: not loaded",
return 0; 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 #ifdef _WIN32
retval = FreeLibrary(library); retval = FreeLibrary(library);
#else #else
retval = dlclose(library) ? 0 : 1; retval = dlclose(library)?0:1;
#endif #endif
if (!retval) if (! retval) {
{ ERROR_LOG(COMMON, "DL: Unload failed %s: %s",
PanicAlert("Error unloading DLL %s: %s", library_file.c_str(), library_file.c_str(),
GetLastErrorAsString().c_str()); DllGetLastError());
} }
library = 0; library = 0;
return retval;
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* DynamicLibrary::Get(const char* funcname) const
{ {
void* retval; void* retval;
INFO_LOG(COMMON, "DL: Getting symbol %s: %s", library_file.c_str(),
funcname);
if (!library) if (!library)
{ {
PanicAlert("Can't find function %s - Library not loaded."); ERROR_LOG(COMMON, "DL: Get failed %s - Library not loaded");
return NULL; return NULL;
} }
@ -150,9 +155,14 @@ void* DynamicLibrary::Get(const char* funcname) const
if (!retval) if (!retval)
{ {
LOG(MASTER_LOG, "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",
PanicAlert("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str()); funcname, library_file.c_str(),
DllGetLastError());
} }
INFO_LOG(COMMON, "DL: Done getting symbol %s: %s", library_file.c_str(),
funcname);
return retval; return retval;
} }

View File

@ -24,19 +24,31 @@
#include <string> #include <string>
// Abstracts the (few) differences between dynamically loading DLLs under Windows /* Abstracts the (few) differences between dynamically loading DLLs under
// and .so / .dylib under Linux/MacOSX. Windows and .so / .dylib under Linux/MacOSX. */
class DynamicLibrary class DynamicLibrary
{ {
public: public:
DynamicLibrary(); DynamicLibrary();
// Loads the library filename
int Load(const char *filename); int Load(const char *filename);
// Unload the current library
int Unload(); int Unload();
// Gets a pointer to the function symbol of funcname by getting it from the
// share object
void *Get(const char *funcname) const; void *Get(const char *funcname) const;
// Returns true is the library is loaded
bool IsLoaded() const { return library != 0; } bool IsLoaded() const { return library != 0; }
private: private:
// name of the library file
std::string library_file; std::string library_file;
// Library handle
#ifdef _WIN32 #ifdef _WIN32
HINSTANCE library; HINSTANCE library;
#else #else
@ -44,4 +56,4 @@ private:
#endif #endif
}; };
#endif #endif // DYNAMICLIBRARY

View File

@ -32,106 +32,118 @@
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#if defined(__APPLE__)
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFUrl.h>
#include <CoreFoundation/CFBundle.h>
#include <sys/param.h>
#endif
#include <fstream> #include <fstream>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef S_ISDIR #ifndef S_ISDIR
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
#endif #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 namespace File
{ {
// =======================================================
// Remove any ending forward slashes from directory paths // Remove any ending forward slashes from directory paths
// ------------- // Modifies argument.
inline void StripTailDirSlashes(std::string& fname) inline char *StripTailDirSlashes(char *fname)
{ {
// Make sure it's not a blank string int len = (int)strlen(fname);
if(fname.length() > 0) int i = len - 1;
{ if (len > 1)
while(fname.at(fname.length() - 1) == DIR_SEP_CHR) while (fname[i] == DIR_SEP_CHR)
fname.resize(fname.length() - 1); fname[i--] = '\0';
} return fname;
} }
// =============
// Returns true if file filename exists
bool Exists(const char *filename) bool Exists(const char *filename)
{ {
struct stat file_info; struct stat file_info;
char *copy = StripTailDirSlashes(strdup(filename));
int result = stat(copy, &file_info);
std::string copy = filename; if (result < 0)
StripTailDirSlashes(copy); {
WARN_LOG(COMMON, "Exist: stat failed on %s: %s", filename,
GetLastErrorMsg());
}
free(copy);
int result = stat(copy.c_str(), &file_info);
return (result == 0); return (result == 0);
} }
// Returns true if filename is a directory
bool IsDirectory(const char *filename) bool IsDirectory(const char *filename)
{ {
struct stat file_info; struct stat file_info;
std::string copy = filename;
StripTailDirSlashes(copy);
int result = stat(copy.c_str(), &file_info); char *copy = StripTailDirSlashes(strdup(filename));
if (result == 0)
return S_ISDIR(file_info.st_mode); int result = stat(copy, &file_info);
else free(copy);
if (result < 0) {
WARN_LOG(COMMON, "IsDirectory: stat failed on %s: %s",
filename, GetLastErrorMsg());
return false; 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) bool Delete(const char *filename)
{ {
if (!Exists(filename)) INFO_LOG(COMMON, "Delete: file %s\n", filename);
return false;
if (IsDirectory(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; return false;
}
#ifdef _WIN32 #ifdef _WIN32
DeleteFile(filename); if (!DeleteFile(filename)) {
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
filename, GetLastErrorMsg());
return false;
}
#else #else
unlink(filename); if (unlink(filename) == -1) {
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
filename, GetLastErrorMsg());
return false;
}
#endif #endif
return true; 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. // Returns true if successful, or path already exists.
bool CreateDir(const char *path) bool CreateDir(const char *path)
{ {
INFO_LOG(COMMON, "CreateDir: directory %s\n", path);
#ifdef _WIN32 #ifdef _WIN32
if (::CreateDirectory(path, NULL)) if (::CreateDirectory(path, NULL))
return true; return true;
DWORD error = GetLastError(); DWORD error = GetLastError();
if (error == ERROR_ALREADY_EXISTS) if (error == ERROR_ALREADY_EXISTS) {
{ WARN_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: already exists", path);
// PanicAlert("%s already exists", path);
return true; return true;
} }
PanicAlert("Error creating directory %s: %i", path, error); ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %i", path, error);
return false; return false;
#else #else
if (mkdir(path, 0755) == 0) if (mkdir(path, 0755) == 0)
@ -139,434 +151,374 @@ bool CreateDir(const char *path)
int err = errno; int err = errno;
if (err == EEXIST) if (err == EEXIST) {
{ WARN_LOG(COMMON, "CreateDir: mkdir failed on %s: already exists", path);
// PanicAlert("%s already exists", path);
return true; 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; return false;
#endif #endif
} }
// Create several dirs // Creates the full path of fullPath returns true on success
bool CreateDirectoryStructure(const std::string& _rFullPath) bool CreateFullPath(const char *fullPath)
{ {
int PanicCounter = 10; int panicCounter = 100;
INFO_LOG(COMMON, "CreateFullPath: path %s\n", fullPath);
size_t Position = 0;
while(true) const char *position = fullPath;
{ while (true) {
// Find next sub path, support both \ and / directory separators // Find next sub path, support both \ and / directory separators
{ position = strchr(position, DIR_SEP_CHR);
size_t nextPosition = _rFullPath.find(DIR_SEP_CHR, Position);
Position = nextPosition;
if (Position == std::string::npos) // we're done, yay!
return true; if (! position)
return true;
Position++;
} position++;
// Create next sub path // Create next sub path
std::string SubPath = _rFullPath.substr(0, Position); int sLen = (int)(position - fullPath);
if (!SubPath.empty()) if (sLen > 0) {
{ char *subPath = strndup(fullPath, sLen);
if (!File::IsDirectory(SubPath.c_str())) if (!File::IsDirectory(subPath)) {
{ File::CreateDir(subPath);
File::CreateDir(SubPath.c_str());
LOG(WII_IPC_FILEIO, " CreateSubDir %s", SubPath.c_str());
} }
free(subPath);
} }
// A safety check // A safety check
PanicCounter--; panicCounter--;
if (PanicCounter <= 0) if (panicCounter <= 0) {
{ ERROR_LOG(COMMON, "CreateFullPath: directory stracture too deep");
PanicAlert("CreateDirectoryStruct creates way to much dirs...");
return false; return false;
} }
} }
} }
// Deletes a directory filename, returns true on success
bool DeleteDir(const char *filename) 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; return false;
}
#ifdef _WIN32 #ifdef _WIN32
return ::RemoveDirectory (filename) ? true : false; if (::RemoveDirectory(filename))
return true;
#else #else
if (rmdir(filename) == 0) if (rmdir(filename) == 0)
return true; return true;
int err = errno;
PanicAlert("Error removing directory %s",strerror(err));
return false;
#endif #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) 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) bool Copy(const char *srcFilename, const char *destFilename)
{ {
INFO_LOG(COMMON, "Copy: %s --> %s",
srcFilename, destFilename);
#ifdef _WIN32 #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 #else
// buffer size
#define BSIZE 1024 #define BSIZE 1024
int rnum, wnum, err; char buffer[BSIZE];
char buffer[BSIZE];
FILE *output, *input;
if (! (input = fopen(srcFilename, "r"))) {
err = errno;
PanicAlert("Error copying from %s: %s", srcFilename, strerror(err));
return false;
}
if (! (output = fopen(destFilename, "w"))) { // Open input file
err = errno; FILE *input = fopen(srcFilename, "rb");
PanicAlert("Error copying to %s: %s", destFilename, strerror(err)); if (!input)
return false; {
} ERROR_LOG(COMMON, "Copy: input failed %s --> %s: %s",
srcFilename, destFilename, GetLastErrorMsg());
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");
return false; return false;
}
} }
fclose(input);
fclose(output);
return true; // open output file
/* FILE *output = fopen(destFilename, "wb");
std::ifstream ifs(srcFilename, std::ios::binary); if (!output)
std::ofstream ofs(destFilename, std::ios::binary); {
fclose(input);
ofs << ifs.rdbuf(); ERROR_LOG(COMMON, "Copy: output failed %s --> %s: %s",
srcFilename, destFilename, GetLastErrorMsg());
return false;
}
ifs.close(); // copy loop
ofs.close(); while (!feof(input))
{
return true;*/ // 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 #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]; // Make sure we only need to do it once
#ifdef _WIN32 static char path[MAX_PATH] = {0};
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path))) if (strlen(path) > 0)
{ return path;
//return std::string(path);
/* I dont understand this, I got "E:\Documents and Settings\All Users\Application Data" #ifdef WIN32
from this */ char homedir[MAX_PATH];
return std::string(""); if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)))
} return NULL;
return std::string("");
#else #else
char *homedir = getenv("HOME"); char *homedir = getenv("HOME");
if (!homedir) if (!homedir)
return std::string(""); return NULL;
#ifdef __APPLE__
snprintf(path, sizeof(path), "%s/Library/Application Support/Dolphin", homedir);
#else
snprintf(path, sizeof(path), "%s/.dolphin", homedir); // XXX changeme as appropriate
#endif #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;
} }
// Returns the size of filename (64bit)
//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
u64 GetSize(const char *filename) u64 GetSize(const char *filename)
{ {
if (!Exists(filename)) if (!Exists(filename)) {
WARN_LOG(COMMON, "GetSize: failed %s: No such file"
,filename);
return 0; 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 (IsDirectory(filename)) {
if (stat(filename, &buf) == 0) { WARN_LOG(COMMON, "GetSize: failed %s: is a directory"
return buf.st_size; ,filename);
} return 0;
int err = errno; }
PanicAlert("Error accessing %s: %s", filename, strerror(err)); // on windows it's actually _stat64 defined in commonFuncs
#endif struct stat64 buf;
return 0; if (stat64(filename, &buf) == 0) {
return buf.st_size;
}
ERROR_LOG(COMMON, "GetSize: Stat failed %s: %s",
filename, GetLastErrorMsg());
return 0;
} }
#ifdef _WIN32 // creates an empty file filename, returns true on success
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
bool CreateEmptyFile(const char *filename) bool CreateEmptyFile(const char *filename)
{ {
FILE* pFile = fopen(filename, "wb"); INFO_LOG(COMMON, "CreateEmptyFile: %s", filename);
if (pFile == NULL)
return false;
FILE *pFile = fopen(filename, "wb");
if (!pFile) {
ERROR_LOG(COMMON, "CreateEmptyFile: failed %s: %s",
filename, GetLastErrorMsg());
return false;
}
fclose(pFile); fclose(pFile);
return true; 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 #ifdef _WIN32
// Find the first file in the directory.
bool Result = false;
WIN32_FIND_DATA ffd; WIN32_FIND_DATA ffd;
std::string searchName = _Directory + "\\*"; char searchName[MAX_PATH + 3];
HANDLE hFind = FindFirstFile(searchName.c_str(), &ffd); strncpy(searchName, directory, MAX_PATH);
strcat(searchName, "\\*");
if (hFind != INVALID_HANDLE_VALUE) HANDLE hFind = FindFirstFile(searchName, &ffd);
{ if (hFind == INVALID_HANDLE_VALUE) {
do FindClose(hFind);
{ return foundEntries;
// 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);
} }
// windows loop
if (!File::DeleteDir(_Directory.c_str())) do {
goto error_jmp; FSTEntry entry;
virtualName = ffd.cFileName;
Result = true;
error_jmp:
FindClose(hFind);
return Result;
#else #else
// taken from http://www.dreamincode.net/code/snippet2700.htm struct dirent dirent, *result = NULL;
DIR *pdir = NULL;
pdir = opendir (_Directory.c_str()); DIR *dirp = opendir(directory);
struct dirent *pent = NULL; if (!dirp)
return 0;
if (pdir == NULL) {
return false;
}
char file[256]; // non windows loop
while (!readdir_r(dirp, &dirent, &result) && result) {
int counter = 1; FSTEntry entry;
virtualName = result->d_name;
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());
#endif #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]; INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory);
_rDirectory = getcwd(tmpBuffer, MAX_PATH); #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 } // namespace

View File

@ -20,45 +20,73 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <string.h>
#include "Common.h" #include "Common.h"
/*
This namespace has various generic functions related to files and paths.
*/
namespace File namespace File
{ {
// FileSystem tree node/
struct FSTEntry struct FSTEntry
{ {
bool isDirectory; 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 physicalName; // name on disk
std::string virtualName; // name in FST names table std::string virtualName; // name in FST names table
std::vector<FSTEntry> children; std::vector<FSTEntry> children;
}; };
std::string SanitizePath(const char *filename); // Returns true if file filename exists
bool Exists(const char *filename); bool Exists(const char *filename);
// Returns true if filename is a directory
bool IsDirectory(const char *filename); bool IsDirectory(const char *filename);
bool IsDisk(const char *filename);
bool CreateDir(const char *filename); // Returns the size of filename (64bit)
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);
u64 GetSize(const char *filename); 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); bool CreateEmptyFile(const char *filename);
u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry); // Scans the directory tree gets, starting from _Directory and adds the
// results into parentEntry. Returns the number of files+directories found
bool DeleteDirRecursively(const std::string& _Directory); u32 ScanDirectoryTree(const char *directory, FSTEntry& parentEntry);
void GetCurrentDirectory(std::string& _rDirectory);
bool SetCurrentDirectory(const std::string& _rDirectory); // deletes the given directory and anything under it. Returns true on success.
bool DeleteDirRecursively(const char *directory);
#if defined(__APPLE__)
std::string GetPluginsDirectory(); // Returns the current directory, caller should free
#endif 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 } // namespace
#endif #endif

View File

@ -14,6 +14,7 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifndef _HASH_H #ifndef _HASH_H
#define _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 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 u32 HashEctor(const u8* ptr, int length); // JUNK. DO NOT USE FOR NEW THINGS
#endif #endif

View File

@ -459,10 +459,10 @@ bool IniFile::Get(const char* sectionName, const char* key, std::vector<std::str
return false; return false;
} }
u32 subEnd;
// ignore starting , if any // ignore starting , if any
u32 subStart = temp.find_first_not_of(","); size_t subStart = temp.find_first_not_of(",");
size_t subEnd;
// split by , // split by ,
while (subStart != std::string::npos) { while (subStart != std::string::npos) {

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -17,6 +17,7 @@ files = [
"FileUtil.cpp", "FileUtil.cpp",
"MappedFile.cpp", "MappedFile.cpp",
"MathUtil.cpp", "MathUtil.cpp",
"Misc.cpp",
"MemArena.cpp", "MemArena.cpp",
"MemoryUtil.cpp", "MemoryUtil.cpp",
"Plugin.cpp", "Plugin.cpp",

View File

@ -80,10 +80,10 @@ u32 Ascii2Hex(std::string _Text)
if (Length > 4) if (Length > 4)
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 // 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 the value
return Result; return Result;

View File

@ -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/", 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[7], (u8)pTitleID[6], (u8)pTitleID[5], (u8)pTitleID[4],
(u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]); (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 Memory::Write_U64( ContentLoader.GetTitleID(), 0x0000318c); // NAND Load Title ID
@ -121,3 +121,4 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename)
return true; return true;
} }

View File

@ -64,14 +64,7 @@
#ifndef _WIN32 #ifndef _WIN32
#define WINAPI #define WINAPI
#endif #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 namespace Core
{ {
@ -355,7 +348,7 @@ THREAD_RETURN CpuThread(void *pArg)
return 0; return 0;
} }
////////////////////////////////////////// //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Initalize plugins and create emulation thread // Initalize plugins and create emulation thread
@ -497,10 +490,7 @@ THREAD_RETURN EmuThread(void *pArg)
// Spawn the CPU thread // Spawn the CPU thread
Common::Thread *cpuThread = NULL; Common::Thread *cpuThread = NULL;
//////////////////////////////////////////////////////////////////////////
// ENTER THE VIDEO THREAD LOOP // ENTER THE VIDEO THREAD LOOP
//////////////////////////////////////////////////////////////////////////
if (!_CoreParameter.bUseDualCore) if (!_CoreParameter.bUseDualCore)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -534,6 +524,7 @@ THREAD_RETURN EmuThread(void *pArg)
//Console::Print("Video loop [Video Thread]: Stopped\n"); //Console::Print("Video loop [Video Thread]: Stopped\n");
return 0; return 0;
} }
void EmuThreadEnd() void EmuThreadEnd()
{ {
CPluginManager &Plugins = CPluginManager::GetInstance(); CPluginManager &Plugins = CPluginManager::GetInstance();
@ -559,18 +550,6 @@ void EmuThreadEnd()
// We have now exited the Video Loop and will shut down // 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 // Write message
if (g_pUpdateFPSDisplay != NULL) if (g_pUpdateFPSDisplay != NULL)
g_pUpdateFPSDisplay("Stopping..."); g_pUpdateFPSDisplay("Stopping...");
@ -760,14 +739,13 @@ void Callback_PADLog(const TCHAR* _szMessage)
// __________________________________________________________________________________________________ // __________________________________________________________________________________________________
// Callback_ISOName: Let the DSP plugin get the game name // Callback_ISOName: Let the DSP plugin get the game name
// //
//std::string Callback_ISOName(void) const char *Callback_ISOName()
const char *Callback_ISOName(void)
{ {
SCoreStartupParameter& params = SConfig::GetInstance().m_LocalCoreStartupParameter; SCoreStartupParameter& params = SConfig::GetInstance().m_LocalCoreStartupParameter;
if (params.m_strName.length() > 0) if (params.m_strName.length() > 0)
return (const char *)params.m_strName.c_str(); return params.m_strName.c_str();
else else
return (const char *)""; return "";
} }
// __________________________________________________________________________________________________ // __________________________________________________________________________________________________
@ -800,4 +778,3 @@ const SCoreStartupParameter& GetStartupParameter() {
} }
} // end of namespace Core } // end of namespace Core

View File

@ -110,7 +110,7 @@ void PrintCallstack(LogTypes::LOG_TYPE type)
{ {
u32 addr = Memory::ReadUnchecked_U32(PowerPC::ppcState.gpr[1]); // SP 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) { if (LR == 0) {
LOGVP(type, 1, " LR = 0 - this is bad\n"); 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) void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const char* _title)
{ {
LOGP(type, _title); LOGP(type, _title);
for (u32 j=0; j<_Size;) for (u32 j = 0; j < _Size;)
{ {
std::string Temp; std::string Temp;
for (int i=0; i<16; i++) for (int i = 0; i < 16; i++)
{ {
char Buffer[128]; char Buffer[128];
sprintf(Buffer, "%02x ", _pData[j++]); 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) if (j >= _Size)
break; break;
} }
LOGP(type, " Data: %s", Temp.c_str()); LOGP(type, " Data: %s", Temp.c_str());
} }
} }

View File

@ -36,8 +36,8 @@ void Update();
// Calls by DSP plugin // Calls by DSP plugin
u32 Callback_GetStreaming(short* _pDestBuffer, u32 _numSamples); u32 Callback_GetStreaming(short* _pDestBuffer, u32 _numSamples);
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress); void Read32(u32& _uReturnValue, const u32 _iAddress);
void HWCALL Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);
// Get the audio rates (48000 or 32000 only) // Get the audio rates (48000 or 32000 only)
u32 GetAISampleRate(); u32 GetAISampleRate();

View File

@ -62,10 +62,10 @@ void Shutdown();
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
// Read // Read
void HWCALL Read16(u16& _rReturnValue, const u32 _Address); void Read16(u16& _rReturnValue, const u32 _Address);
void HWCALL Write16(const u16 _Data, const u32 _Address); void Write16(const u16 _Data, const u32 _Address);
void HWCALL Read32(u32& _rReturnValue, const u32 _Address); void Read32(u32& _rReturnValue, const u32 _Address);
void HWCALL Write32(const u32 _Data, const u32 _Address); void Write32(const u32 _Data, const u32 _Address);
// for CGPFIFO // for CGPFIFO
void CatchUpGPU(); void CatchUpGPU();
@ -86,3 +86,4 @@ bool IsCommandProcessorNotUsed();
#endif #endif

View File

@ -39,12 +39,12 @@ void GenerateDSPInterrupt(DSPInterruptType _DSPInterruptType, bool _bSet = true)
void GenerateDSPInterruptFromPlugin(DSPInterruptType _DSPInterruptType, bool _bSet = true); void GenerateDSPInterruptFromPlugin(DSPInterruptType _DSPInterruptType, bool _bSet = true);
// Read32 // Read32
void HWCALL Read16(u16& _uReturnValue, const u32 _uAddress); void Read16(u16& _uReturnValue, const u32 _uAddress);
void HWCALL Read32(u32& _uReturnValue, const u32 _uAddress); void Read32(u32& _uReturnValue, const u32 _uAddress);
// Write // Write
void HWCALL Write16(const u16 _uValue, const u32 _uAddress); void Write16(const u16 _uValue, const u32 _uAddress);
void HWCALL Write32(const u32 _uValue, const u32 _uAddress); void Write32(const u32 _uValue, const u32 _uAddress);
// Audio/DSP Plugin Helper // Audio/DSP Plugin Helper
u8 ReadARAM(const u32 _uAddress); u8 ReadARAM(const u32 _uAddress);
@ -58,3 +58,4 @@ void UpdateAudioDMA();
#endif #endif

View File

@ -40,12 +40,13 @@ bool DVDRead(u32 _iDVDOffset, u32 _iRamAddress, u32 _iLength);
bool DVDReadADPCM(u8* _pDestBuffer, u32 _iNumSamples); bool DVDReadADPCM(u8* _pDestBuffer, u32 _iNumSamples);
// Read32 // Read32
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress); void Read32(u32& _uReturnValue, const u32 _iAddress);
// Write32 // Write32
void HWCALL Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);
} // end of namespace DVDInterface } // end of namespace DVDInterface
#endif #endif

View File

@ -30,8 +30,8 @@ void DoState(PointerWrap &p);
void Update(); void Update();
void UpdateInterrupts(); void UpdateInterrupts();
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress); void Read32(u32& _uReturnValue, const u32 _iAddress);
void HWCALL Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);
} // end of namespace ExpansionInterface } // end of namespace ExpansionInterface

View File

@ -45,19 +45,18 @@ void CheckGatherPipe();
bool IsEmpty(); bool IsEmpty();
// Write // Write
void HWCALL Write8(const u8 _iValue, const u32 _iAddress); void Write8(const u8 _iValue, const u32 _iAddress);
void HWCALL Write16(const u16 _iValue, const u32 _iAddress); void Write16(const u16 _iValue, const u32 _iAddress);
void HWCALL Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);
void HWCALL Write64(const u64 _iValue, const u32 _iAddress); void Write64(const u64 _iValue, const u32 _iAddress);
// These expect pre-byteswapped values // These expect pre-byteswapped values
// Also there's an upper limit of about 512 per batch // Also there's an upper limit of about 512 per batch
// Most likely these should be inlined into JIT instead // Most likely these should be inlined into JIT instead
void HWCALL FastWrite8(const u8 _iValue); void FastWrite8(const u8 _iValue);
void HWCALL FastWrite16(const u16 _iValue); void FastWrite16(const u16 _iValue);
void HWCALL FastWrite32(const u32 _iValue); void FastWrite32(const u32 _iValue);
void HWCALL FastWrite64(const u64 _iValue); void FastWrite64(const u64 _iValue);
}; };
#endif #endif

View File

@ -140,18 +140,18 @@ readFn64 hwReadWii64[NUMHWMEMFUN];
u32 CheckDTLB(u32 _Address, XCheckTLBFlag _Flag); u32 CheckDTLB(u32 _Address, XCheckTLBFlag _Flag);
template <class T> 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> 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_SHIFT 10
#define PAGE_SIZE (1 << PAGE_SHIFT) #define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SHIFT - 1) #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 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_Write_Memory(T _Data, const u32 _Address) { *(T*)&P[_Address & PAGE_MASK] = _Data; }
///////////////////////////// /////////////////////////////

View File

@ -18,38 +18,30 @@
#ifndef _MEMMAP_H #ifndef _MEMMAP_H
#define _MEMMAP_H #define _MEMMAP_H
///////////////////////////////////////////////////////////////////////////////////
// Includes // Includes
// ----------------
#include <string> #include <string>
#include "Common.h" #include "Common.h"
////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// Global declarations // Global declarations
// ----------------
class PointerWrap; class PointerWrap;
typedef void (HWCALL *writeFn8 )(const u8, const u32); typedef void (*writeFn8 )(const u8, const u32);
typedef void (HWCALL *writeFn16)(const u16,const u32); typedef void (*writeFn16)(const u16,const u32);
typedef void (HWCALL *writeFn32)(const u32,const u32); typedef void (*writeFn32)(const u32,const u32);
typedef void (HWCALL *writeFn64)(const u64,const u32); typedef void (*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 (*readFn8 )(u8&, const u32);
typedef void (*readFn16)(u16&, const u32);
typedef void (*readFn32)(u32&, const u32);
typedef void (*readFn64)(u64&, const u32);
namespace Memory namespace Memory
{ {
// Base is a pointer to the base of the memory map. Yes, some MMU tricks are used to set up /* Base is a pointer to the base of the memory map. Yes, some MMU tricks
// a full GC or Wii memory map in process memory. are used to set up a full GC or Wii memory map in process memory. on
// on 32-bit, you have to mask your offsets with 0x3FFFFFFF. This means that some things are mirrored, 32-bit, you have to mask your offsets with 0x3FFFFFFF. This means that
// but eh... it works. some things are mirrored, but eh... it works. */
extern u8 *base; extern u8 *base;
extern u8* m_pRAM; extern u8* m_pRAM;
extern u8* m_pL1Cache; extern u8* m_pL1Cache;
@ -83,9 +75,7 @@ namespace Memory
void Clear(); void Clear();
bool AreMemoryBreakpointsActivated(); bool AreMemoryBreakpointsActivated();
///////////////////////////////////////////////////////////////////////////////////
// ONLY for use by GUI // ONLY for use by GUI
// ----------------
u8 ReadUnchecked_U8(const u32 _Address); u8 ReadUnchecked_U8(const u32 _Address);
u32 ReadUnchecked_U32(const u32 _Address); u32 ReadUnchecked_U32(const u32 _Address);
@ -111,26 +101,19 @@ namespace Memory
} }
u32 Read_Opcode(const u32 _Address); u32 Read_Opcode(const u32 _Address);
////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// For use by emulator // For use by emulator
// ----------------
// =================================
/* Local byteswap shortcuts. They are placed inline so that they may hopefully be executed faster /* Local byteswap shortcuts. They are placed inline so that they may hopefully be executed faster
than otherwise */ than otherwise */
// ----------------
inline u8 bswap(u8 val) {return val;} inline u8 bswap(u8 val) {return val;}
inline u16 bswap(u16 val) {return Common::swap16(val);} inline u16 bswap(u16 val) {return Common::swap16(val);}
inline u32 bswap(u32 val) {return Common::swap32(val);} inline u32 bswap(u32 val) {return Common::swap32(val);}
inline u64 bswap(u64 val) {return Common::swap64(val);} inline u64 bswap(u64 val) {return Common::swap64(val);}
// ================= // =================
// =================================
// Read and write functions // Read and write functions
// ----------------
#define NUMHWMEMFUN 64 #define NUMHWMEMFUN 64
#define HWSHIFT 10 #define HWSHIFT 10
#define HW_MASK 0x3FF #define HW_MASK 0x3FF
@ -153,11 +136,8 @@ namespace Memory
void DMA_LCToMemory(const u32 _iMemAddr, const u32 _iCacheAddr, const u32 _iNumBlocks); 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 DMA_MemoryToLC(const u32 _iCacheAddr, const u32 _iMemAddr, const u32 _iNumBlocks);
void Memset(const u32 _Address, const u8 _Data, const u32 _iLength); void Memset(const u32 _Address, const u8 _Data, const u32 _iLength);
// =================
// =================================
// TLB functions // TLB functions
// ----------------
void SDRUpdated(); void SDRUpdated();
enum XCheckTLBFlag enum XCheckTLBFlag
{ {
@ -169,9 +149,6 @@ namespace Memory
u32 CheckDTLB(u32 _Address, XCheckTLBFlag _Flag); u32 CheckDTLB(u32 _Address, XCheckTLBFlag _Flag);
extern u32 pagetable_base; extern u32 pagetable_base;
extern u32 pagetable_hashmask; extern u32 pagetable_hashmask;
// ================
/////////////////////////////
}; };
#endif #endif

View File

@ -24,11 +24,12 @@ namespace MemoryInterface
{ {
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
void HWCALL Read16(u16& _uReturnValue, const u32 _iAddress); void Read16(u16& _uReturnValue, const u32 _iAddress);
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress); void Read32(u32& _uReturnValue, const u32 _iAddress);
void HWCALL Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);
void HWCALL Write16(const u16 _iValue, const u32 _iAddress); void Write16(const u16 _iValue, const u32 _iAddress);
} // end of namespace MemoryInterface } // end of namespace MemoryInterface
#endif #endif

View File

@ -103,10 +103,10 @@ public:
static void SetInterrupt(InterruptCause _causemask, bool _bSet=true); static void SetInterrupt(InterruptCause _causemask, bool _bSet=true);
// Read32 // Read32
static void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress); static void Read32(u32& _uReturnValue, const u32 _iAddress);
// Write32 // 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) // SetResetButton (you have to release the button again to make a reset)
static void SetResetButton(bool _bSet); static void SetResetButton(bool _bSet);
@ -114,3 +114,4 @@ public:
#endif #endif

View File

@ -26,11 +26,11 @@ void Init();
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
// Read // Read
void HWCALL Read16(u16& _uReturnValue, const u32 _iAddress); void Read16(u16& _uReturnValue, const u32 _iAddress);
// Write // Write
void HWCALL Write16(const u16 _iValue, const u32 _iAddress); void Write16(const u16 _iValue, const u32 _iAddress);
void HWCALL Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);
// gfx plugin support // gfx plugin support
void SetToken(const u16 _token, const int _bSetTokenAcknowledge); void SetToken(const u16 _token, const int _bSetTokenAcknowledge);
@ -41,3 +41,4 @@ bool AllowIdleSkipping();
#endif #endif

View File

@ -33,8 +33,8 @@ void UpdateDevices();
void RemoveDevice(int _iDeviceNumber); void RemoveDevice(int _iDeviceNumber);
void AddDevice(const TSIDevices _device, int _iDeviceNumber); void AddDevice(const TSIDevices _device, int _iDeviceNumber);
void HWCALL Read32(u32& _uReturnValue, const u32 _iAddress); void Read32(u32& _uReturnValue, const u32 _iAddress);
void HWCALL Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);
}; // end of namespace SerialInterface }; // end of namespace SerialInterface

View File

@ -179,7 +179,9 @@ void IPC_HLE_UpdateCallback(u64 userdata, int cyclesLate)
void VICallback(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(); VideoInterface::Update();
CoreTiming::ScheduleEvent(VI_PERIOD-cyclesLate, et_VI); CoreTiming::ScheduleEvent(VI_PERIOD-cyclesLate, et_VI);
} }

View File

@ -33,11 +33,11 @@ namespace VideoInterface
void Init(); void Init();
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
void HWCALL Read16(u16& _uReturnValue, const u32 _uAddress); void Read16(u16& _uReturnValue, const u32 _uAddress);
void HWCALL Read32(u32& _uReturnValue, const u32 _uAddress); void Read32(u32& _uReturnValue, const u32 _uAddress);
void HWCALL Write16(const u16 _uValue, const u32 _uAddress); void Write16(const u16 _uValue, const u32 _uAddress);
void HWCALL Write32(const u32 _uValue, const u32 _uAddress); void Write32(const u32 _uValue, const u32 _uAddress);
void GenerateVIInterrupt(VIInterruptType _VIInterrupt); void GenerateVIInterrupt(VIInterruptType _VIInterrupt);
@ -63,3 +63,4 @@ namespace VideoInterface
#endif #endif

View File

@ -22,17 +22,17 @@
namespace WII_IOBridge namespace WII_IOBridge
{ {
void HWCALL Read8(u8& _rReturnValue, const u32 _Address) void Read8(u8& _rReturnValue, const u32 _Address)
{ {
_dbg_assert_(WII_IOB, 0); _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); _dbg_assert_(WII_IOB, 0);
} }
void HWCALL Read32(u32& _rReturnValue, const u32 _Address) void Read32(u32& _rReturnValue, const u32 _Address)
{ {
switch(_Address & 0xFFFF) 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); _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); _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); _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) 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) //switch(_Address)
//{ //{

View File

@ -29,17 +29,18 @@ void DoState(PointerWrap &p);
void Update(); void Update();
void HWCALL Read8(u8& _rReturnValue, const u32 _Address); void Read8(u8& _rReturnValue, const u32 _Address);
void HWCALL Read16(u16& _rReturnValue, const u32 _Address); void Read16(u16& _rReturnValue, const u32 _Address);
void HWCALL Read32(u32& _rReturnValue, const u32 _Address); void Read32(u32& _rReturnValue, const u32 _Address);
void HWCALL Read64(u64& _rReturnValue, const u32 _Address); void Read64(u64& _rReturnValue, const u32 _Address);
void HWCALL Write8(const u8 _Value, const u32 _Address); void Write8(const u8 _Value, const u32 _Address);
void HWCALL Write16(const u16 _Value, const u32 _Address); void Write16(const u16 _Value, const u32 _Address);
void HWCALL Write32(const u32 _Value, const u32 _Address); void Write32(const u32 _Value, const u32 _Address);
void HWCALL Write64(const u64 _Value, const u32 _Address); void Write64(const u64 _Value, const u32 _Address);
} // end of namespace AudioInterface } // end of namespace AudioInterface
#endif #endif

View File

@ -121,7 +121,7 @@ void Shutdown()
{ {
} }
void HWCALL Read32(u32& _rReturnValue, const u32 _Address) void Read32(u32& _rReturnValue, const u32 _Address)
{ {
switch(_Address & 0xFFFF) 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) switch(_Address & 0xFFFF)
{ {
@ -265,3 +265,4 @@ void GenerateReply(u32 _AnswerAddress)
} // end of namespace IPC } // end of namespace IPC

View File

@ -32,11 +32,12 @@ bool IsReady();
void GenerateReply(u32 _AnswerAddress); void GenerateReply(u32 _AnswerAddress);
void GenerateAck(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 } // end of namespace AudioInterface
#endif #endif

View File

@ -266,7 +266,7 @@ void CopySettingsFile(std::string DeviceName)
// Check if the target dir exists, otherwise create it // Check if the target dir exists, otherwise create it
std::string TargetDir = Target.substr(0, Target.find_last_of(DIR_SEP)); 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())) if (File::Copy(Source.c_str(), Target.c_str()))
{ {

View File

@ -14,6 +14,7 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifndef _WII_IPC_HLE_DEVICE_ERROR_H_ #ifndef _WII_IPC_HLE_DEVICE_ERROR_H_
#define _WII_IPC_HLE_DEVICE_ERROR_H_ #define _WII_IPC_HLE_DEVICE_ERROR_H_

View File

@ -21,7 +21,7 @@
// File description // File description
// ------------- // -------------
/* Here we handle /dev/es requests. We have cases for these functions, the exact /* 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) 0x20 GetTitleID (ES_GetTitleID) (Input: none, Output: 8 bytes)
0x1d GetDataDir (ES_GetDataDir) (Input: 8 bytes, Output: 30 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 // Prepare the out buffer(s) with zeroes as a safety precaution
// to avoid returning bad values // 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, Memory::Memset(Buffer.PayloadBuffer[i].m_Address, 0,
Buffer.PayloadBuffer[i].m_Size); Buffer.PayloadBuffer[i].m_Size);
} }
switch(Buffer.Parameter) switch (Buffer.Parameter)
{ {
case IOCTL_ES_OPENTITLECONTENT: // 0x09 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); u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address+8); u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address+8);
m_ContenAccessMap[CFD].m_Position = 0; m_ContentAccessMap[CFD].m_Position = 0;
m_ContenAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index); m_ContentAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index);
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap[CFD].m_pContent != NULL); _dbg_assert_(WII_IPC_ES, m_ContentAccessMap[CFD].m_pContent != NULL);
Memory::Write_U32(CFD, _CommandAddress + 0x4); Memory::Write_U32(CFD, _CommandAddress + 0x4);
@ -121,9 +121,9 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
u32 CFD = AccessIdentID++; u32 CFD = AccessIdentID++;
u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address); u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address);
m_ContenAccessMap[CFD].m_Position = 0; m_ContentAccessMap[CFD].m_Position = 0;
m_ContenAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index); m_ContentAccessMap[CFD].m_pContent = AccessContentDevice().GetContentByIndex(Index);
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap[CFD].m_pContent != NULL); _dbg_assert_(WII_IPC_ES, m_ContentAccessMap[CFD].m_pContent != NULL);
Memory::Write_U32(CFD, _CommandAddress + 0x4); 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 Size = Buffer.PayloadBuffer[0].m_Size;
u32 Addr = Buffer.PayloadBuffer[0].m_Address; u32 Addr = Buffer.PayloadBuffer[0].m_Address;
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap.find(CFD) != m_ContenAccessMap.end()); _dbg_assert_(WII_IPC_ES, m_ContentAccessMap.find(CFD) != m_ContentAccessMap.end());
SContentAccess& rContent = m_ContenAccessMap[CFD]; SContentAccess& rContent = m_ContentAccessMap[CFD];
u8* pSrc = &rContent.m_pContent->m_pData[rContent.m_Position]; u8* pSrc = &rContent.m_pContent->m_pData[rContent.m_Position];
u8* pDest = Memory::GetPointer(Addr); 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); _dbg_assert_(WII_IPC_ES, Buffer.NumberInBuffer == 1);
u32 CFD = Memory::Read_U32(Buffer.InBuffer[0].m_Address); u32 CFD = Memory::Read_U32(Buffer.InBuffer[0].m_Address);
CContenAccessMap::iterator itr = m_ContenAccessMap.find(CFD); CContentAccessMap::iterator itr = m_ContentAccessMap.find(CFD);
m_ContenAccessMap.erase(itr); m_ContentAccessMap.erase(itr);
LOG(WII_IPC_ES, "ES: IOCTL_ES_CLOSECONTENT: CFD %x", CFD); 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 Addr = Memory::Read_U32(Buffer.InBuffer[1].m_Address);
u32 Mode = Memory::Read_U32(Buffer.InBuffer[2].m_Address); u32 Mode = Memory::Read_U32(Buffer.InBuffer[2].m_Address);
_dbg_assert_(WII_IPC_ES, m_ContenAccessMap.find(CFD) != m_ContenAccessMap.end()); _dbg_assert_(WII_IPC_ES, m_ContentAccessMap.find(CFD) != m_ContentAccessMap.end());
SContentAccess& rContent = m_ContenAccessMap[CFD]; SContentAccess& rContent = m_ContentAccessMap[CFD];
switch(Mode) switch (Mode)
{ {
case 0: // SET case 0: // SET
rContent.m_Position = Addr; rContent.m_Position = Addr;
@ -300,10 +300,10 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
// TitleIDs.push_back(0x0001000248414341); // TitleIDs.push_back(0x0001000248414341);
// TitleIDs.push_back(0x0001000146414b45); // 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); 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; break;

View File

@ -103,8 +103,8 @@ private:
DiscIO::SNANDContent* m_pContent; DiscIO::SNANDContent* m_pContent;
}; };
typedef std::map<u32, SContentAccess> CContenAccessMap; typedef std::map<u32, SContentAccess> CContentAccessMap;
CContenAccessMap m_ContenAccessMap; CContentAccessMap m_ContentAccessMap;
DiscIO::CNANDContentLoader* m_pContentLoader; DiscIO::CNANDContentLoader* m_pContentLoader;

View File

@ -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/", 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]); (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]);
File::CreateDirectoryStructure(Path); File::CreateFullPath(Path);
} }
Memory::Write_U32(GetDeviceID(), _CommandAddress+4); 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()); LOG(WII_IPC_FILEIO, "FS: CREATE_DIR %s", DirName.c_str());
DirName += DIR_SEP; 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()); _dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName.c_str()), "FS: CREATE_DIR %s failed", DirName.c_str());
return FS_RESULT_OK; return FS_RESULT_OK;
@ -428,7 +428,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
Offset += 64; Offset += 64;
// try to make the basis directory // try to make the basis directory
File::CreateDirectoryStructure(FilenameRename); File::CreateFullPath(FilenameRename.c_str());
// if there is already a filedelete it // if there is already a filedelete it
if (File::Exists(FilenameRename.c_str())) 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 // 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()); bool Result = File::CreateEmptyFile(Filename.c_str());
if (!Result) if (!Result)
{ {

View File

@ -352,7 +352,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
// return reply buffer size // return reply buffer size
Memory::Write_U32(sizeof(UACLHeader) + frame.size, m_pACLBuffer->m_Address + 0x4); Memory::Write_U32(sizeof(UACLHeader) + frame.size, m_pACLBuffer->m_Address + 0x4);
delete frame.data; delete [] frame.data;
m_AclFrameQue.pop(); m_AclFrameQue.pop();
u32 Addr = m_pACLBuffer->m_Address; u32 Addr = m_pACLBuffer->m_Address;
@ -383,7 +383,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
if (m_AclFrameQue.empty()) 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()) if (m_WiiMotes[i].Update())
break; break;

View File

@ -469,7 +469,7 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size)
break; break;
case L2CAP_CONF_RSP: case L2CAP_CONF_RSP:
CommandCofigurationResponse(pCommand->ident, _pData, pCommand->len); CommandConfigurationResponse(pCommand->ident, _pData, pCommand->len);
break; break;
case L2CAP_COMMAND_REJ: case L2CAP_COMMAND_REJ:
@ -633,13 +633,13 @@ void CWII_IPC_HLE_WiiMote::CommandConnectionResponse(u8 _Ident, u8* _pData, u32
m_HIDInterruptChannel_Connected = true; 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; l2cap_conf_rsp* rsp = (l2cap_conf_rsp*)_pData;
_dbg_assert_(WII_IPC_WIIMOTE, _Size == sizeof(l2cap_conf_rsp)); _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, " SCID: 0x%04x", rsp->scid);
LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", rsp->flags); LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", rsp->flags);
LOG(WII_IPC_WIIMOTE, " Result: 0x%04x", rsp->result); LOG(WII_IPC_WIIMOTE, " Result: 0x%04x", rsp->result);

View File

@ -186,7 +186,7 @@ private:
void CommandCofigurationReq(u8 _Ident, u8* _pData, u32 _Size); void CommandCofigurationReq(u8 _Ident, u8* _pData, u32 _Size);
void CommandConnectionResponse(u8 _Ident, u8* _pData, u32 _Size); void CommandConnectionResponse(u8 _Ident, u8* _pData, u32 _Size);
void CommandDisconnectionReq(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);
////////////////// //////////////////

View File

@ -120,6 +120,7 @@ void LogManager::Init()
for(int i = 0; i <= LogManager::VERBOSITY_LEVELS; i++) 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::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::BOOT + i*100] = new CDebugger_Log("BOOT", "Boot", i);
m_Log[LogTypes::PIXELENGINE + i*100] = new CDebugger_Log("PE", "PixelEngine", 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); m_Log[LogTypes::COMMANDPROCESSOR + i*100] = new CDebugger_Log("CP", "CommandProc", i);
@ -189,7 +190,7 @@ void LogManager::Shutdown()
m_bInitialized = false; m_bInitialized = false;
// Delete all loggers // 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++) 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; static u32 count = 0;
char* Msg2 = (char*)alloca(strlen(_fmt)+512); 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. // 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 // 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 // added a simple caching function so that we don't search again if we get the same
// question again. // question again.
std::string symbol; const char *symbol;
if ((v == 0 || v == 1) && lastPC != PC && LogManager::m_LogSettings->bResolve) 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; lastSymbol = symbol;
lastPC = PC; 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 else
{ {
@ -275,7 +270,7 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
Common::Timer::GetTimeFormatted().c_str(), Common::Timer::GetTimeFormatted().c_str(),
PowerPC::ppcState.DebugCount, PowerPC::ppcState.DebugCount,
m_Log[_type]->m_szShortName_, // (CONSOLE etc) 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); 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 // Check if we should do a unified write to a single file
if(m_LogSettings->bUnify) if (m_LogSettings->bUnify)
{ {
// prepare the right id // prepare the right id
int id = VERBOSITY_LEVELS*100 + type; int id = VERBOSITY_LEVELS*100 + type;

View File

@ -61,6 +61,7 @@ files = ["Console.cpp",
"IPC_HLE/WII_IPC_HLE.cpp", "IPC_HLE/WII_IPC_HLE.cpp",
"IPC_HLE/WII_IPC_HLE_Device_DI.cpp", "IPC_HLE/WII_IPC_HLE_Device_DI.cpp",
"IPC_HLE/WII_IPC_HLE_Device_FileIO.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_fs.cpp",
"IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp", "IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp",
"IPC_HLE/WII_IPC_HLE_Device_net.cpp", "IPC_HLE/WII_IPC_HLE_Device_net.cpp",

View File

@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
/////////////////////////////
// What does SJP stand for???
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Include // Include
@ -105,7 +107,6 @@ void CCodeWindow::CreateSymbolsMenu()
pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _T("&Patch HLE functions")); pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _T("&Patch HLE functions"));
pMenuBar->Append(pSymbolsMenu, _T("&Symbols")); pMenuBar->Append(pSymbolsMenu, _T("&Symbols"));
wxMenu *pJitMenu = new wxMenu; wxMenu *pJitMenu = new wxMenu;
pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache")); pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache"));
pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage")); pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage"));

View File

@ -23,6 +23,7 @@
namespace DiscIO namespace DiscIO
{ {
IFileSystem::IFileSystem(const IVolume *_rVolume) IFileSystem::IFileSystem(const IVolume *_rVolume)
: m_rVolume(_rVolume) : m_rVolume(_rVolume)
{} {}
@ -47,4 +48,5 @@ IFileSystem* CreateFileSystem(const IVolume* _rVolume)
return pFileSystem; return pFileSystem;
} }
} // namespace } // namespace

View File

@ -67,10 +67,10 @@ CNANDContentLoader::CNANDContentLoader(const std::string& _rName)
SNANDContent* CNANDContentLoader::GetContentByIndex(int _Index) 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) if (m_TitleMetaContent[i].m_Index == _Index)
return &m_TileMetaContent[i]; return &m_TitleMetaContent[i];
} }
return NULL; return NULL;
} }
@ -79,7 +79,7 @@ bool CNANDContentLoader::CreateFromWAD(const std::string& _rName)
{ {
DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str()); DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str());
if (pReader == NULL) if (pReader == NULL)
return false; return false;
if (!ParseWAD(*pReader)) if (!ParseWAD(*pReader))
{ {
@ -89,6 +89,7 @@ bool CNANDContentLoader::CreateFromWAD(const std::string& _rName)
delete pReader; delete pReader;
return true; return true;
} }
bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath) bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
{ {
std::string TMDFileName(_rPath); std::string TMDFileName(_rPath);
@ -108,12 +109,11 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
m_BootIndex = Common::swap16(pTMD + 0x01e0); m_BootIndex = Common::swap16(pTMD + 0x01e0);
m_TitleID = Common::swap64(pTMD + 0x018C); 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_ContentID = Common::swap32(pTMD + 0x01e4 + 0x24*i);
rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 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; u8* p = pDataApp;
m_TileMetaContent.resize(numEntries); m_TitleMetaContent.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_ContentID = Common::swap32(pTMD + 0x01e4 + 0x24*i);
rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 0x24*i); rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 0x24*i);

View File

@ -42,16 +42,12 @@ public:
CNANDContentLoader(const std::string& _rName); CNANDContentLoader(const std::string& _rName);
bool IsValid() const { return m_Valid; } bool IsValid() const { return m_Valid; }
u64 GetTitleID() const { return m_TitleID; } u64 GetTitleID() const { return m_TitleID; }
u32 GetBootIndex() const { return m_BootIndex; } u32 GetBootIndex() const { return m_BootIndex; }
size_t GetContentSize() const { return m_TitleMetaContent.size(); }
size_t GetContentSize() const { return m_TileMetaContent.size(); }
SNANDContent* GetContentByIndex(int _Index); SNANDContent* GetContentByIndex(int _Index);
static bool IsWiiWAD(const std::string& _rName); static bool IsWiiWAD(const std::string& _rName);
private: private:
@ -59,7 +55,7 @@ private:
u64 m_TitleID; u64 m_TitleID;
u32 m_BootIndex; u32 m_BootIndex;
std::vector<SNANDContent> m_TileMetaContent; std::vector<SNANDContent> m_TitleMetaContent;
bool CreateFromDirectory(const std::string& _rPath); bool CreateFromDirectory(const std::string& _rPath);
bool CreateFromWAD(const std::string& _rName); bool CreateFromWAD(const std::string& _rName);

View File

@ -424,7 +424,7 @@ void CVolumeDirectory::WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u
{ {
u32 myOffset = fstOffset; u32 myOffset = fstOffset;
u32 myEntryNum = myOffset / ENTRY_SIZE; 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); WriteEntryName(nameOffset, entry.virtualName);
for(std::vector<File::FSTEntry>::const_iterator iter = entry.children.begin(); iter != entry.children.end(); ++iter) 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 else
{ {
// put entry in FST // 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); WriteEntryName(nameOffset, entry.virtualName);
// write entry to virtual disk // 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 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); m_totalNameSize += ComputeNameSize(parentEntry);
return foundEntries; return foundEntries;
} }

View File

@ -724,7 +724,7 @@ void CConfigMain::WiiSettingsChanged(wxCommandEvent& event)
break; break;
case ID_WII_IPL_AR: // IPL settings case ID_WII_IPL_AR: // IPL settings
SConfig::GetInstance().m_LocalCoreStartupParameter.bWidescreen = WiiAspectRatio->GetSelection(); SConfig::GetInstance().m_LocalCoreStartupParameter.bWidescreen = WiiAspectRatio->GetSelection() ? true : false;
break; break;
case ID_WII_IPL_SSV: case ID_WII_IPL_SSV:
m_SYSCONF[IPL_SSV] = WiiScreenSaver->IsChecked(); m_SYSCONF[IPL_SSV] = WiiScreenSaver->IsChecked();

View File

@ -419,8 +419,7 @@ void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
void CFrame::DoOpen(bool Boot) void CFrame::DoOpen(bool Boot)
{ {
std::string currentDir; std::string currentDir = File::GetCurrentDirectory();
File::GetCurrentDirectory(currentDir);
wxString path = wxFileSelector( wxString path = wxFileSelector(
_T("Select the file to load"), _T("Select the file to load"),
@ -438,13 +437,12 @@ void CFrame::DoOpen(bool Boot)
return; return;
} }
std::string currentDir2; std::string currentDir2 = File::GetCurrentDirectory();
File::GetCurrentDirectory(currentDir2);
if (currentDir != currentDir2) if (currentDir != currentDir2)
{ {
PanicAlert("Current dir changed has been changeg from %s to %s after wxFileSelector!",currentDir.c_str(),currentDir2.c_str()); 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(); TheToolBar->Realize();
} }

View File

@ -111,16 +111,16 @@ void HandleGLError();
#ifdef _WIN32 #ifdef _WIN32
#define ERROR_LOG(...) {LOG(VIDEO, __VA_ARGS__)} //#define ERROR_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
#define INFO_LOG(...) {LOG(VIDEO, __VA_ARGS__)} //#define INFO_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
#define PRIM_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 #else
#define ERROR_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)} //#define ERROR_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
#define INFO_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)} //#define INFO_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
#define PRIM_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 #endif
#ifdef LOGGING #ifdef LOGGING

View File

@ -245,7 +245,7 @@ void Initialize(void *init)
} }
else else
{ {
PanicAlert("Cannot recognize backend %s", g_Config.sBackend); PanicAlert("Cannot recognize backend %s", g_Config.sBackend.c_str());
return; return;
} }
@ -260,7 +260,7 @@ void Initialize(void *init)
if (!soundStream->Start()) if (!soundStream->Start())
{ {
PanicAlert("Could not initialize backend %s, falling back to NULL", PanicAlert("Could not initialize backend %s, falling back to NULL",
g_Config.sBackend); g_Config.sBackend.c_str());
delete soundStream; delete soundStream;
soundStream = new NullSound(48000, Mixer); soundStream = new NullSound(48000, Mixer);
soundStream->Start(); soundStream->Start();
@ -269,7 +269,7 @@ void Initialize(void *init)
else else
{ {
PanicAlert("Sound backend %s is not valid, falling back to NULL", PanicAlert("Sound backend %s is not valid, falling back to NULL",
g_Config.sBackend); g_Config.sBackend.c_str());
delete soundStream; delete soundStream;
soundStream = new NullSound(48000, Mixer); soundStream = new NullSound(48000, Mixer);
soundStream->Start(); soundStream->Start();

View File

@ -294,7 +294,7 @@ void BPWritten(int addr, int changes, int newval)
if (!Renderer::SetScissorRect()) if (!Renderer::SetScissorRect())
{ {
if (addr == BPMEM_SCISSORBR) { if (addr == BPMEM_SCISSORBR) {
ERROR_LOG("bad scissor!\n"); ERROR_LOG(VIDEO, "bad scissor!\n");
} }
} }
} }

View File

@ -415,20 +415,20 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
if (vi == NULL) { if (vi == NULL) {
vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl); vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
GLWin.doubleBuffered = False; GLWin.doubleBuffered = False;
ERROR_LOG("Only Singlebuffered Visual!\n"); ERROR_LOG(VIDEO, "Only Singlebuffered Visual!\n");
} }
else { else {
GLWin.doubleBuffered = True; GLWin.doubleBuffered = True;
ERROR_LOG("Got Doublebuffered Visual!\n"); ERROR_LOG(VIDEO, "Got Doublebuffered Visual!\n");
} }
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion); 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 */ /* create a GLX context */
GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE); GLWin.ctx = glXCreateContext(GLWin.dpy, vi, 0, GL_TRUE);
if(!GLWin.ctx) 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 exit(0); // TODO: Don't bring down entire Emu
} }
/* create a color map */ /* create a color map */
@ -450,7 +450,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
// set best mode to current // set best mode to current
bestMode = 0; 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); XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes);
if (modeNum > 0 && modes != NULL) { 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); XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0);
dpyWidth = modes[bestMode]->hdisplay; dpyWidth = modes[bestMode]->hdisplay;
dpyHeight = modes[bestMode]->vdisplay; dpyHeight = modes[bestMode]->vdisplay;
ERROR_LOG("Resolution %dx%d\n", dpyWidth, dpyHeight); ERROR_LOG(VIDEO, "Resolution %dx%d\n", dpyWidth, dpyHeight);
XFree(modes); XFree(modes);
/* create a fullscreen window */ /* create a fullscreen window */
@ -484,7 +484,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime); GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime);
} }
else { 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" "\"XFree86-VidModeExtension\" extension is missing, add\n"
"Load \"extmod\"\n" "Load \"extmod\"\n"
"to your X configuration file (under the Module Section)\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); glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y, XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth); &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)) { if (glXIsDirect(GLWin.dpy, GLWin.ctx)) {
ERROR_LOG("you have Direct Rendering!"); ERROR_LOG(VIDEO, "you have Direct Rendering!");
} else { } else {
ERROR_LOG("no Direct Rendering possible!"); ERROR_LOG(VIDEO, "no Direct Rendering possible!");
} }
// better for pad plugin key input (thc) // better for pad plugin key input (thc)
@ -781,7 +781,7 @@ void OpenGL_Shutdown()
{ {
if (!glXMakeCurrent(GLWin.dpy, None, NULL)) 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); XUnmapWindow(GLWin.dpy, GLWin.win);
glXDestroyContext(GLWin.dpy, GLWin.ctx); glXDestroyContext(GLWin.dpy, GLWin.ctx);
@ -807,9 +807,9 @@ void HandleGLError()
{ {
GLint loc = 0; GLint loc = 0;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &loc); glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &loc);
ERROR_LOG("program error at %d: ", loc); ERROR_LOG(VIDEO, "program error at %d: ", loc);
ERROR_LOG((char*)pstr); ERROR_LOG(VIDEO, (char*)pstr);
ERROR_LOG("\n"); ERROR_LOG(VIDEO, "\n");
} }
// check the error status of this framebuffer */ // check the error status of this framebuffer */
@ -824,40 +824,40 @@ void HandleGLError()
case GL_FRAMEBUFFER_COMPLETE_EXT: case GL_FRAMEBUFFER_COMPLETE_EXT:
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: 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; break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: 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; break;
// case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: // 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; // break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: 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; break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: 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; break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: 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; break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: 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; break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: 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; break;
default: default:
ERROR_LOG("*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT()!\n"); ERROR_LOG(VIDEO, "*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT()!\n");
break; break;
} }
} }
void HandleCgError(CGcontext ctx, CGerror err, void* appdata) 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); const char* listing = cgGetLastListing(g_cgcontext);
if (listing != NULL) { if (listing != NULL) {
ERROR_LOG(" last listing: %s\n", listing); ERROR_LOG(VIDEO, " last listing: %s\n", listing);
} }
} }

View File

@ -67,10 +67,10 @@
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
#endif #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) #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 #else
#define GL_REPORT_ERRORD() #define GL_REPORT_ERRORD()
#endif #endif

View File

@ -60,7 +60,7 @@ void PixelShaderCache::Init()
int maxinst, maxattribs; 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_INSTRUCTIONS_ARB, (GLint *)&maxinst);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, (GLint *)&maxattribs); 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]; char pmatrixprog[1024];
sprintf(pmatrixprog, "!!ARBfp1.0" sprintf(pmatrixprog, "!!ARBfp1.0"
@ -80,7 +80,7 @@ void PixelShaderCache::Init()
GLenum err = GL_NO_ERROR; GLenum err = GL_NO_ERROR;
GL_REPORT_ERROR(); GL_REPORT_ERROR();
if (err != GL_NO_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); glDeleteProgramsARB(1, &s_ColorMatrixProgram);
s_ColorMatrixProgram = 0; s_ColorMatrixProgram = 0;
} }
@ -139,7 +139,7 @@ FRAGMENTSHADER* PixelShaderCache::GetShader()
// printf("Compiling pixel shader. size = %i\n", strlen(code)); // printf("Compiling pixel shader. size = %i\n", strlen(code));
if (!code || !CompilePixelShader(newentry.shader, 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; return NULL;
} }
@ -178,8 +178,8 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
const char* opts[] = {"-profileopts", stropt, "-O2", "-q", NULL}; const char* opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgfProf, "main", opts); CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgfProf, "main", opts);
if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) { if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) {
ERROR_LOG("Failed to create ps %s:\n", cgGetLastListing(g_cgcontext)); ERROR_LOG(VIDEO, "Failed to create ps %s:\n", cgGetLastListing(g_cgcontext));
ERROR_LOG(pstrprogram); ERROR_LOG(VIDEO, pstrprogram);
return false; return false;
} }
@ -209,8 +209,8 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
GLenum err = GL_NO_ERROR; GLenum err = GL_NO_ERROR;
GL_REPORT_ERROR(); GL_REPORT_ERROR();
if (err != GL_NO_ERROR) { if (err != GL_NO_ERROR) {
ERROR_LOG(pstrprogram); ERROR_LOG(VIDEO, pstrprogram);
ERROR_LOG(pcompiledprog); ERROR_LOG(VIDEO, pcompiledprog);
} }
cgDestroyProgram(tempprog); cgDestroyProgram(tempprog);

View File

@ -126,9 +126,9 @@ bool Renderer::Init()
const char* ptoken = (const char*)glGetString(GL_EXTENSIONS); const char* ptoken = (const char*)glGetString(GL_EXTENSIONS);
if (ptoken == NULL) return false; if (ptoken == NULL) return false;
INFO_LOG("Supported OpenGL Extensions:\n"); INFO_LOG(VIDEO, "Supported OpenGL Extensions:\n");
INFO_LOG(ptoken); // write to the log file INFO_LOG(VIDEO, ptoken); // write to the log file
INFO_LOG("\n"); INFO_LOG(VIDEO, "\n");
if (GLEW_EXT_blend_func_separate && GLEW_EXT_blend_equation_separate) if (GLEW_EXT_blend_func_separate && GLEW_EXT_blend_equation_separate)
g_bBlendSeparate = true; g_bBlendSeparate = true;
@ -140,24 +140,24 @@ bool Renderer::Init()
s_bFullscreen = g_Config.bFullscreen; s_bFullscreen = g_Config.bFullscreen;
if (glewInit() != GLEW_OK) { 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; return false;
} }
if (!GLEW_EXT_framebuffer_object) { 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; bSuccess = false;
} }
if (!GLEW_EXT_secondary_color) { 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; bSuccess = false;
} }
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)&numvertexattribs); glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)&numvertexattribs);
if (numvertexattribs < 11) { 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; bSuccess = false;
} }
@ -168,12 +168,12 @@ bool Renderer::Init()
if (WGLEW_EXT_swap_control) if (WGLEW_EXT_swap_control)
wglSwapIntervalEXT(0); wglSwapIntervalEXT(0);
else 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 #elif defined(HAVE_X11) && HAVE_X11
if (glXSwapIntervalSGI) if (glXSwapIntervalSGI)
glXSwapIntervalSGI(0); glXSwapIntervalSGI(0);
else 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 #else
//TODO //TODO
@ -184,7 +184,7 @@ bool Renderer::Init()
GLint max_texture_size; GLint max_texture_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&max_texture_size); glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&max_texture_size);
if (max_texture_size < 1024) { 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(); GL_REPORT_ERROR();
@ -195,7 +195,7 @@ bool Renderer::Init()
glGenFramebuffersEXT(1, (GLuint *)&s_uFramebuffer); glGenFramebuffersEXT(1, (GLuint *)&s_uFramebuffer);
if (s_uFramebuffer == 0) { 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); _assert_(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT);
@ -283,7 +283,7 @@ bool Renderer::Init()
} }
if (s_ZBufferTarget == 0) 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? // Why is this left here?
//glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, s_DepthTarget); //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) // load the effect, find the best profiles (if any)
if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) { if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) {
ERROR_LOG("arbvp1 not supported\n"); ERROR_LOG(VIDEO, "arbvp1 not supported\n");
return false; return false;
} }
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) { if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) {
ERROR_LOG("arbfp1 not supported\n"); ERROR_LOG(VIDEO, "arbfp1 not supported\n");
return false; return false;
} }
@ -313,24 +313,24 @@ bool Renderer::Init()
cgGLSetOptimalOptions(g_cgvProf); cgGLSetOptimalOptions(g_cgvProf);
cgGLSetOptimalOptions(g_cgfProf); 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]; int nenvvertparams, nenvfragparams, naddrregisters[2];
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvvertparams); 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_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_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]); 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(VIDEO, "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 address register parameters: vert=%d, frag=%d\n", naddrregisters[0], naddrregisters[1]);
if (nenvvertparams < 238) if (nenvvertparams < 238)
ERROR_LOG("not enough vertex shader environment constants!!\n"); ERROR_LOG(VIDEO, "not enough vertex shader environment constants!!\n");
#ifndef _DEBUG #ifndef _DEBUG
cgGLSetDebugMode(GL_FALSE); cgGLSetDebugMode(GL_FALSE);
#endif #endif
if (cgGetError() != CG_NO_ERROR) { if (cgGetError() != CG_NO_ERROR) {
ERROR_LOG("cg error\n"); ERROR_LOG(VIDEO, "cg error\n");
return false; return false;
} }
@ -591,7 +591,7 @@ bool Renderer::SetScissorRect()
rc_bottom *= MValueY; rc_bottom *= MValueY;
if (rc_bottom > 480 * MValueY) rc_bottom = 480 * 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_left, rc_top,
rc_right, rc_bottom, Renderer::GetTargetHeight(), rc_right, rc_bottom, Renderer::GetTargetHeight(),
xoff, yoff xoff, yoff
@ -1333,7 +1333,7 @@ void UpdateViewport()
// [4] = yorig + height/2 + 342 // [4] = yorig + height/2 + 342
// [5] = 16777215 * farz // [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, rawViewport[3]-rawViewport[0]-342, rawViewport[4]+rawViewport[1]-342,
2 * rawViewport[0], 2 * rawViewport[1], 2 * rawViewport[0], 2 * rawViewport[1],
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/ (rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/

View File

@ -68,7 +68,7 @@ void CreateRgbToYuyvProgram()
"}\n"; "}\n";
if (!PixelShaderCache::CompilePixelShader(s_rgbToYuyvProgram, FProgram)) { 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"; "}\n";
if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram)) { 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)) { if (!PixelShaderCache::CompilePixelShader(s_encodingPrograms[format], shader)) {
const char* error = cgGetLastListing(g_cgcontext); 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");
} }
} }

View File

@ -101,10 +101,10 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode)
(g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST); (g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
if (newmode.wrap_s == 2 || newmode.wrap_t == 2) 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) 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 { else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 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; colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
break; break;
default: 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; colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break; break;
} }
@ -556,7 +556,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
} }
break; break;
default: 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; colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break; break;
} }
@ -598,7 +598,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
break; break;
default: 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; colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break; break;
} }

View File

@ -226,7 +226,7 @@ void Flush()
} }
} }
else { else {
ERROR_LOG("error loading tex\n"); ERROR_LOG(VIDEO, "error loading tex\n");
TextureMngr::DisableStage(i); // disable since won't be used TextureMngr::DisableStage(i); // disable since won't be used
} }
} }

View File

@ -97,7 +97,7 @@ VERTEXSHADER* VertexShaderCache::GetShader(u32 components)
#endif #endif
if (!code || !VertexShaderCache::CompileVertexShader(entry.shader, code)) { 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; return NULL;
} }
@ -137,13 +137,13 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL}; const char *opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts); CGprogram tempprog = cgCreateProgram(g_cgcontext, CG_SOURCE, pstrprogram, g_cgvProf, "main", opts);
if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) { if (!cgIsProgram(tempprog) || cgGetError() != CG_NO_ERROR) {
ERROR_LOG("Failed to load vs %s:\n", cgGetLastListing(g_cgcontext)); ERROR_LOG(VIDEO, "Failed to load vs %s:\n", cgGetLastListing(g_cgcontext));
ERROR_LOG(pstrprogram); ERROR_LOG(VIDEO, pstrprogram);
return false; return false;
} }
//ERROR_LOG(pstrprogram); //ERROR_LOG(VIDEO, pstrprogram);
//ERROR_LOG("id: %d\n", g_Config.iSaveTargetId); //ERROR_LOG(VIDEO, "id: %d\n", g_Config.iSaveTargetId);
char* pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM); char* pcompiledprog = (char*)cgGetProgramString(tempprog, CG_COMPILED_PROGRAM);
char* plocal = strstr(pcompiledprog, "program.local"); char* plocal = strstr(pcompiledprog, "program.local");
@ -161,8 +161,8 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
GLenum err = GL_NO_ERROR; GLenum err = GL_NO_ERROR;
GL_REPORT_ERROR(); GL_REPORT_ERROR();
if (err != GL_NO_ERROR) { if (err != GL_NO_ERROR) {
ERROR_LOG(pstrprogram); ERROR_LOG(VIDEO, pstrprogram);
ERROR_LOG(pcompiledprog); ERROR_LOG(VIDEO, pcompiledprog);
} }
cgDestroyProgram(tempprog); cgDestroyProgram(tempprog);

View File

@ -142,7 +142,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
case 0x1015: case 0x1015:
case 0x1016: case 0x1016:
case 0x1017: case 0x1017:
DEBUG_LOG("xf addr: %x=%x\n", address, data); DEBUG_LOG(VIDEO, "xf addr: %x=%x\n", address, data);
break; break;
case 0x1018: case 0x1018:
//_assert_msg_(GX_XF, 0, "XF matrixindex0"); //_assert_msg_(GX_XF, 0, "XF matrixindex0");
@ -195,7 +195,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
case 0x104d: case 0x104d:
case 0x104e: case 0x104e:
case 0x104f: case 0x104f:
DEBUG_LOG("xf addr: %x=%x\n", address, data); DEBUG_LOG(VIDEO, "xf addr: %x=%x\n", address, data);
break; break;
case 0x1050: xfregs.texcoords[0].postmtxinfo.hex = data; break; case 0x1050: xfregs.texcoords[0].postmtxinfo.hex = data; break;
case 0x1051: xfregs.texcoords[1].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; case 0x1057: xfregs.texcoords[7].postmtxinfo.hex = data; break;
default: default:
DEBUG_LOG("xf addr: %x=%x\n", address, data); DEBUG_LOG(VIDEO, "xf addr: %x=%x\n", address, data);
break; break;
} }
} }

View File

@ -238,7 +238,7 @@
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32" AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32"
GenerateManifest="false" GenerateManifest="false"
GenerateDebugInformation="false" GenerateDebugInformation="true"
SubSystem="0" SubSystem="0"
OptimizeReferences="0" OptimizeReferences="0"
EnableCOMDATFolding="0" EnableCOMDATFolding="0"
@ -321,7 +321,7 @@
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64" AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64"
GenerateManifest="false" GenerateManifest="false"
GenerateDebugInformation="false" GenerateDebugInformation="true"
SubSystem="0" SubSystem="0"
OptimizeReferences="0" OptimizeReferences="0"
EnableCOMDATFolding="0" EnableCOMDATFolding="0"

View File

@ -499,9 +499,9 @@ void ConfigDialog::CreateGUIControls()
// Search for devices and add them to the device list // Search for devices and add them to the device list
wxArrayString StrJoyname; // The string array 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())); StrJoyname.Add(wxString::FromAscii(WiiMoteEmu::joyinfo[x].Name.c_str()));
} }
else else
@ -518,8 +518,10 @@ void ConfigDialog::CreateGUIControls()
StrTilt.Add(wxString::FromAscii("Triggers")); StrTilt.Add(wxString::FromAscii("Triggers"));
// The range is in degrees and are set at even 5 degrees values // The range is in degrees and are set at even 5 degrees values
wxArrayString StrTiltRangeRoll, StrTiltRangePitch; 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++)
for (int i = 0; i < 37; i++) StrTiltRangePitch.Add(wxString::Format(wxT("%i"), i*5)); 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 // The Trigger type list
wxArrayString StrTriggerType; wxArrayString StrTriggerType;

View File

@ -109,7 +109,7 @@ void ConfigDialog::SetButtonTextAll(int id, char text[128])
for (int i = 0; i < 1; i++) for (int i = 0; i < 1; i++)
{ {
// Safety check to avoid crash // 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) if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Page].ID].Name)
SetButtonText(id, text, i); SetButtonText(id, text, i);
}; };
@ -123,7 +123,7 @@ void ConfigDialog::SaveButtonMappingAll(int Slot)
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
// This can occur when no gamepad is detected // 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) if (WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name == WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Slot].ID].Name)
SaveButtonMapping(i, false, Slot); SaveButtonMapping(i, false, Slot);
} }
@ -160,7 +160,7 @@ void ConfigDialog::UpdateGUIButtonMapping(int controller)
m_TiltInvertPitch[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bPitchInvert); m_TiltInvertPitch[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bPitchInvert);
// Wiimote // Wiimote
#ifdef _WIN32 #ifdef _WIN32
m_bWmA[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.A).c_str())); 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_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())); 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_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_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())); 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()); //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 /* 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 -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. */ 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 // 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 // Set other settings
//WiiMoteEmu::PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection(); //WiiMoteEmu::PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection();
WiiMoteEmu::PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection(); WiiMoteEmu::PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection();

View File

@ -363,24 +363,24 @@ void ConfigDialog::ConvertToString()
file.Load(FULL_CONFIG_DIR "WiimoteMovement.ini"); file.Load(FULL_CONFIG_DIR "WiimoteMovement.ini");
std::string TmpStr = "", TmpIR = "", TmpTime = ""; 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 // 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).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).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()); 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()); //Console::Print("%s\n", TmpStr.c_str());
// Write the IR data // Write the IR data
TmpIR += ArrayToString(m_vRecording.at(i).IR, IRBytes, 0, 30, false); 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. // Write the timestamps. The upper limit is 99 seconds.
int Time = (int)((m_vRecording.at(i).Time - m_vRecording.at(0).Time) * 1000); int Time = (int)((m_vRecording.at(i).Time - m_vRecording.at(0).Time) * 1000);
TmpTime += StringFromFormat("%05i", Time); 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. /* 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. */ This limit should never be hit because of the recording limit below. I keep it here just in case. */

View File

@ -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); g_RecordingCurrentTime[Wm] *= ((25.0 + (double)VRecording.at(g_RecordingPlaying[Wm]).PlaybackSpeed * 25.0) / 100.0);
// Select reading // 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]) if (VRecording.at(g_RecordingPlaying[Wm]).Recording.at(i).Time > g_RecordingCurrentTime[Wm])
{ {
g_RecordingPoint[Wm] = i; g_RecordingPoint[Wm] = i;

View File

@ -1061,7 +1061,7 @@ int GetUpdateRate()
//Console::Print("Time: %i %f\n", Time, GetDoubleTime()); //Console::Print("Time: %i %f\n", Time, GetDoubleTime());
int TotalTime = 0; 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); TotalTime += g_UpdateTimeList.at(i);
g_UpdateRate = TotalTime / 5; g_UpdateRate = TotalTime / 5;