Random fixes and cleanups

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5297 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX 2010-04-08 16:59:35 +00:00
parent b452bf7051
commit f727139ebf
22 changed files with 555 additions and 573 deletions

View File

@ -74,17 +74,13 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
size_t dot_pos = _searchString.rfind("."); size_t dot_pos = _searchString.rfind(".");
if (dot_pos == std::string::npos) if (dot_pos == std::string::npos)
{
return; return;
}
std::string ext = _searchString.substr(dot_pos); std::string ext = _searchString.substr(dot_pos);
DIR* dir = opendir(_strPath.c_str()); DIR* dir = opendir(_strPath.c_str());
if (!dir) if (!dir)
{
return; return;
}
dirent* dp; dirent* dp;
@ -93,19 +89,17 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
dp = readdir(dir); dp = readdir(dir);
if (!dp) if (!dp)
{
break; break;
}
std::string s(dp->d_name); std::string s(dp->d_name);
if ( (s.size() > ext.size()) && (!strcasecmp(s.substr(s.size() - ext.size()).c_str(), ext.c_str())) ) if ( (s.size() > ext.size()) && (!strcasecmp(s.substr(s.size() - ext.size()).c_str(), ext.c_str())) )
{ {
std::string full_name; std::string full_name;
if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR) if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR)
full_name = _strPath + s; full_name = _strPath + s;
else else
full_name = _strPath + DIR_SEP + s; full_name = _strPath + DIR_SEP + s;
m_FileNames.push_back(full_name); m_FileNames.push_back(full_name);
} }
@ -118,5 +112,5 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
const CFileSearch::XStringVector& CFileSearch::GetFileNames() const const CFileSearch::XStringVector& CFileSearch::GetFileNames() const
{ {
return(m_FileNames); return m_FileNames;
} }

View File

@ -23,21 +23,17 @@
class CFileSearch class CFileSearch
{ {
public: public:
typedef std::vector<std::string>XStringVector;
typedef std::vector<std::string>XStringVector; CFileSearch(const XStringVector& _rSearchStrings, const XStringVector& _rDirectories);
const XStringVector& GetFileNames() const;
CFileSearch(const XStringVector& _rSearchStrings, const XStringVector& _rDirectories); private:
const XStringVector& GetFileNames() const; void FindFiles(const std::string& _searchString, const std::string& _strPath);
XStringVector m_FileNames;
private:
void FindFiles(const std::string& _searchString, const std::string& _strPath);
XStringVector m_FileNames;
}; };
#endif // _FILESEARCH_H_ #endif // _FILESEARCH_H_

View File

@ -123,7 +123,7 @@ bool Delete(const char *filename)
} }
#else #else
if (unlink(filename) == -1) { if (unlink(filename) == -1) {
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", WARN_LOG(COMMON, "Delete: unlink failed on %s: %s",
filename, GetLastErrorMsg()); filename, GetLastErrorMsg());
return false; return false;
} }
@ -594,7 +594,6 @@ std::string GetPluginsDirectory()
INFO_LOG(COMMON, "GetPluginsDirectory: Setting to %s:", pluginsDir.c_str()); INFO_LOG(COMMON, "GetPluginsDirectory: Setting to %s:", pluginsDir.c_str());
return pluginsDir; return pluginsDir;
} }
// Returns the path to where the sys file are // Returns the path to where the sys file are

View File

@ -35,8 +35,6 @@ int total;
const char *filter = "0123456789ABCDEFGHJKMNPQRTUVWXYZILOS"; const char *filter = "0123456789ABCDEFGHJKMNPQRTUVWXYZILOS";
u32 genseeds[0x20]; u32 genseeds[0x20];
//u8 globalvar=0;
//u8 globalvar2=0;
const u8 bitstringlen[0x08] = { const u8 bitstringlen[0x08] = {
@ -408,9 +406,7 @@ bool batchdecrypt(u32 *codes, u16 size)
int GetVal(const char *flt, char chr) int GetVal(const char *flt, char chr)
{ {
int ret; int ret = (int)(strchr(flt,chr) - flt);
ret = (int)(strchr(flt,chr) - flt);
switch (ret) switch (ret)
{ {
case 32: // 'I' case 32: // 'I'
@ -424,7 +420,6 @@ int GetVal(const char *flt, char chr)
ret = 5; ret = 5;
break; break;
} }
return ret; return ret;
} }
@ -516,4 +511,5 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry> &ops)
} }
} }
} }
} //namespace ActionReplay } //namespace ActionReplay

View File

@ -25,7 +25,7 @@
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------
// Codes Types: // Code Types:
// (Unconditonal) Normal Codes (0): this one has subtypes inside // (Unconditonal) Normal Codes (0): this one has subtypes inside
// (Conditional) Normal Codes (1 - 7): these just compare values and set the line skip info // (Conditional) Normal Codes (1 - 7): these just compare values and set the line skip info
// Zero Codes: any code with no address. These codes are used to do special operations like memory copy, etc // Zero Codes: any code with no address. These codes are used to do special operations like memory copy, etc
@ -45,15 +45,16 @@
namespace ActionReplay namespace ActionReplay
{ {
enum enum
{ {
// Zero Code Types // Zero Code Types
ZCODE_END = 0x00, ZCODE_END = 0x00,
ZCODE_NORM = 0x02, ZCODE_NORM = 0x02,
ZCODE_ROW = 0x03, ZCODE_ROW = 0x03,
ZCODE_04 = 0x04, ZCODE_04 = 0x04,
// Conditonal Codes // Conditonal Codes
CONDTIONAL_IF_EQUAL = 0x01, CONDTIONAL_IF_EQUAL = 0x01,
CONDTIONAL_IF_NOT_EQUAL = 0x02, CONDTIONAL_IF_NOT_EQUAL = 0x02,
CONDTIONAL_IF_LESS_THAN_SIGNED = 0x03, CONDTIONAL_IF_LESS_THAN_SIGNED = 0x03,
@ -68,7 +69,7 @@ enum
DATATYPE_32BIT = 0x02, DATATYPE_32BIT = 0x02,
DATATYPE_32BIT_FLOAT = 0x03, DATATYPE_32BIT_FLOAT = 0x03,
// Normal Code 0 Subtypes // Normal Code 0 Subtypes
SUB_RAM_WRITE = 0x00, SUB_RAM_WRITE = 0x00,
SUB_WRITE_POINTER = 0x01, SUB_WRITE_POINTER = 0x01,
SUB_ADD_CODE = 0x02, SUB_ADD_CODE = 0x02,
@ -101,7 +102,7 @@ void LoadCodes(IniFile &ini, bool forceLoad)
{ {
// Parses the Action Replay section of a game ini file. // Parses the Action Replay section of a game ini file.
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats
&& !forceLoad) && !forceLoad)
return; return;
std::vector<std::string> lines; std::vector<std::string> lines;
@ -132,7 +133,7 @@ void LoadCodes(IniFile &ini, bool forceLoad)
currentCode.ops.clear(); currentCode.ops.clear();
encryptedLines.clear(); encryptedLines.clear();
} }
if (line.size() > 1) if (line.size() > 1)
{ {
if (line[0] == '+') if (line[0] == '+')
@ -217,7 +218,7 @@ void LogInfo(const char *format, ...)
if (logSelf) if (logSelf)
{ {
std::string text = temp; std::string text = temp;
text += "\n"; text += '\n';
arLog.push_back(text.c_str()); arLog.push_back(text.c_str());
} }
} }
@ -238,12 +239,12 @@ void RunAllActive()
} }
} }
if (!b_RanOnce) b_RanOnce = true;
b_RanOnce = true;
} }
} }
bool RunCode(const ARCode &arcode) { bool RunCode(const ARCode &arcode)
{
// The mechanism is different than what the real AR uses, so there may be compatibility problems. // The mechanism is different than what the real AR uses, so there may be compatibility problems.
u8 cmd; u8 cmd;
u32 addr; u32 addr;
@ -260,7 +261,7 @@ bool RunCode(const ARCode &arcode) {
LogInfo("Code Name: %s", code.name.c_str()); LogInfo("Code Name: %s", code.name.c_str());
LogInfo("Number of codes: %i", code.ops.size()); LogInfo("Number of codes: %i", code.ops.size());
for (iter = code.ops.begin(); iter != code.ops.end(); ++iter) for (iter = code.ops.begin(); iter != code.ops.end(); ++iter)
{ {
// If conditional mode has been set to true, then run our code execution control // If conditional mode has been set to true, then run our code execution control
@ -281,8 +282,7 @@ bool RunCode(const ARCode &arcode) {
if (!skip && count > 0) count--; // execute n lines if (!skip && count > 0) count--; // execute n lines
// if -2 : execute all lines // if -2 : execute all lines
if (b_RanOnce) b_RanOnce = false;
b_RanOnce = false;
} }
cmd = iter->cmd_addr >> 24; // AR command cmd = iter->cmd_addr >> 24; // AR command
@ -460,30 +460,32 @@ bool Subtype_RamWriteAndFill(u32 addr, u32 data)
switch (size) switch (size)
{ {
case DATATYPE_8BIT: case DATATYPE_8BIT:
{
LogInfo("8-bit Write");
LogInfo("--------");
u32 repeat = data >> 8;
for (u32 i = 0; i <= repeat; i++)
{ {
LogInfo("8-bit Write"); Memory::Write_U8(data & 0xFF, new_addr + i);
LogInfo("--------"); LogInfo("Wrote %08x to address %08x", data & 0xFF, new_addr + i);
u32 repeat = data >> 8;
for (u32 i = 0; i <= repeat; i++) {
Memory::Write_U8(data & 0xFF, new_addr + i);
LogInfo("Wrote %08x to address %08x", data & 0xFF, new_addr + i);
}
LogInfo("--------");
break;
} }
LogInfo("--------");
break;
}
case DATATYPE_16BIT: case DATATYPE_16BIT:
{
LogInfo("16-bit Write");
LogInfo("--------");
u32 repeat = data >> 16;
for (u32 i = 0; i <= repeat; i++)
{ {
LogInfo("16-bit Write"); Memory::Write_U16(data & 0xFFFF, new_addr + i * 2);
LogInfo("--------"); LogInfo("Wrote %08x to address %08x", data & 0xFFFF, new_addr + i * 2);
u32 repeat = data >> 16;
for (u32 i = 0; i <= repeat; i++) {
Memory::Write_U16(data & 0xFFFF, new_addr + i * 2);
LogInfo("Wrote %08x to address %08x", data & 0xFFFF, new_addr + i * 2);
}
LogInfo("--------");
break;
} }
LogInfo("--------");
break;
}
case DATATYPE_32BIT_FLOAT: case DATATYPE_32BIT_FLOAT:
case DATATYPE_32BIT: // Dword write case DATATYPE_32BIT: // Dword write
LogInfo("32bit Write"); LogInfo("32bit Write");
@ -509,36 +511,36 @@ bool Subtype_WriteToPointer(u32 addr, u32 data)
switch (size) switch (size)
{ {
case DATATYPE_8BIT: case DATATYPE_8BIT:
{ {
LogInfo("Write 8-bit to pointer"); LogInfo("Write 8-bit to pointer");
LogInfo("--------"); LogInfo("--------");
u32 ptr = Memory::Read_U32(new_addr); u32 ptr = Memory::Read_U32(new_addr);
u8 thebyte = data & 0xFF; u8 thebyte = data & 0xFF;
u32 offset = data >> 8; u32 offset = data >> 8;
LogInfo("Pointer: %08x", ptr); LogInfo("Pointer: %08x", ptr);
LogInfo("Byte: %08x", thebyte); LogInfo("Byte: %08x", thebyte);
LogInfo("Offset: %08x", offset); LogInfo("Offset: %08x", offset);
Memory::Write_U8(thebyte, ptr + offset); Memory::Write_U8(thebyte, ptr + offset);
LogInfo("Wrote %08x to address %08x", thebyte, ptr + offset); LogInfo("Wrote %08x to address %08x", thebyte, ptr + offset);
LogInfo("--------"); LogInfo("--------");
break; break;
} }
case DATATYPE_16BIT: case DATATYPE_16BIT:
{ {
LogInfo("Write 16-bit to pointer"); LogInfo("Write 16-bit to pointer");
LogInfo("--------"); LogInfo("--------");
u32 ptr = Memory::Read_U32(new_addr); u32 ptr = Memory::Read_U32(new_addr);
u16 theshort = data & 0xFFFF; u16 theshort = data & 0xFFFF;
u32 offset = (data >> 16) << 1; u32 offset = (data >> 16) << 1;
LogInfo("Pointer: %08x", ptr); LogInfo("Pointer: %08x", ptr);
LogInfo("Byte: %08x", theshort); LogInfo("Byte: %08x", theshort);
LogInfo("Offset: %08x", offset); LogInfo("Offset: %08x", offset);
Memory::Write_U16(theshort, ptr + offset); Memory::Write_U16(theshort, ptr + offset);
LogInfo("Wrote %08x to address %08x", theshort, ptr + offset); LogInfo("Wrote %08x to address %08x", theshort, ptr + offset);
LogInfo("--------"); LogInfo("--------");
break; break;
} }
case DATATYPE_32BIT_FLOAT: case DATATYPE_32BIT_FLOAT:
case DATATYPE_32BIT: case DATATYPE_32BIT:
LogInfo("Write 32-bit to pointer"); LogInfo("Write 32-bit to pointer");
@ -558,7 +560,7 @@ bool Subtype_WriteToPointer(u32 addr, u32 data)
bool Subtype_AddCode(u32 addr, u32 data) bool Subtype_AddCode(u32 addr, u32 data)
{ {
// Used to incrment a value in memory // Used to increment a value in memory
u32 new_addr = (addr & 0x81FFFFFF); u32 new_addr = (addr & 0x81FFFFFF);
u8 size = (addr >> 25) & 0x03; u8 size = (addr >> 25) & 0x03;
LogInfo("Hardware Address: %08x", new_addr); LogInfo("Hardware Address: %08x", new_addr);
@ -587,21 +589,21 @@ bool Subtype_AddCode(u32 addr, u32 data)
LogInfo("--------"); LogInfo("--------");
break; break;
case DATATYPE_32BIT_FLOAT: case DATATYPE_32BIT_FLOAT:
{ {
LogInfo("32-bit floating Add"); LogInfo("32-bit floating Add");
LogInfo("--------"); LogInfo("--------");
u32 read = Memory::Read_U32(new_addr); u32 read = Memory::Read_U32(new_addr);
float fread = *((float*)&read); float fread = *((float*)&read);
fread += (float)data; fread += (float)data;
u32 newval = *((u32*)&fread); u32 newval = *((u32*)&fread);
Memory::Write_U32(newval, new_addr); Memory::Write_U32(newval, new_addr);
LogInfo("Old Value %08x", read); LogInfo("Old Value %08x", read);
LogInfo("Increment %08x", data); LogInfo("Increment %08x", data);
LogInfo("New value %08x", newval); LogInfo("New value %08x", newval);
LogInfo("--------"); LogInfo("--------");
break; break;
} }
default: default:
LogInfo("Bad Size"); LogInfo("Bad Size");
PanicAlert("Action Replay Error: Invalid size(%08x : address = %08x) in Add Code (%s)", size, addr, code.name.c_str()); PanicAlert("Action Replay Error: Invalid size(%08x : address = %08x) in Add Code (%s)", size, addr, code.name.c_str());
@ -639,57 +641,59 @@ bool ZeroCode_FillAndSlide(u32 val_last, u32 addr, u32 data) // This needs more
switch (size) switch (size)
{ {
case DATATYPE_8BIT: case DATATYPE_8BIT:
LogInfo("8-bit Write"); LogInfo("8-bit Write");
LogInfo("--------"); LogInfo("--------");
for (int i = 0; i < write_num; i++) for (int i = 0; i < write_num; i++)
{ {
Memory::Write_U8(val & 0xFF, curr_addr); Memory::Write_U8(val & 0xFF, curr_addr);
curr_addr += addr_incr; curr_addr += addr_incr;
val += val_incr; val += val_incr;
LogInfo("Write %08x to address %08x", val & 0xFF, curr_addr); LogInfo("Write %08x to address %08x", val & 0xFF, curr_addr);
LogInfo("Value Update: %08x", val); LogInfo("Value Update: %08x", val);
LogInfo("Current Hardware Address Update: %08x", curr_addr); LogInfo("Current Hardware Address Update: %08x", curr_addr);
} }
LogInfo("--------"); LogInfo("--------");
break; break;
case DATATYPE_16BIT: case DATATYPE_16BIT:
LogInfo("16-bit Write"); LogInfo("16-bit Write");
LogInfo("--------"); LogInfo("--------");
for (int i=0; i < write_num; i++) { for (int i=0; i < write_num; i++)
Memory::Write_U16(val & 0xFFFF, curr_addr); {
LogInfo("Write %08x to address %08x", val & 0xFFFF, curr_addr); Memory::Write_U16(val & 0xFFFF, curr_addr);
curr_addr += addr_incr * 2; LogInfo("Write %08x to address %08x", val & 0xFFFF, curr_addr);
val += val_incr; curr_addr += addr_incr * 2;
LogInfo("Value Update: %08x", val); val += val_incr;
LogInfo("Current Hardware Address Update: %08x", curr_addr); LogInfo("Value Update: %08x", val);
} LogInfo("Current Hardware Address Update: %08x", curr_addr);
LogInfo("--------"); }
break; LogInfo("--------");
case DATATYPE_32BIT: break;
LogInfo("32-bit Write"); case DATATYPE_32BIT:
LogInfo("--------"); LogInfo("32-bit Write");
for (int i = 0; i < write_num; i++) { LogInfo("--------");
Memory::Write_U32(val, curr_addr); for (int i = 0; i < write_num; i++)
LogInfo("Write %08x to address %08x", val, curr_addr); {
curr_addr += addr_incr * 4; Memory::Write_U32(val, curr_addr);
val += val_incr; LogInfo("Write %08x to address %08x", val, curr_addr);
LogInfo("Value Update: %08x", val); curr_addr += addr_incr * 4;
LogInfo("Current Hardware Address Update: %08x", curr_addr); val += val_incr;
} LogInfo("Value Update: %08x", val);
LogInfo("--------"); LogInfo("Current Hardware Address Update: %08x", curr_addr);
break; }
default: LogInfo("--------");
LogInfo("Bad Size"); break;
PanicAlert("Action Replay Error: Invalid size (%08x : address = %08x) in Fill and Slide (%s)", size, new_addr, code.name.c_str()); default:
return false; LogInfo("Bad Size");
PanicAlert("Action Replay Error: Invalid size (%08x : address = %08x) in Fill and Slide (%s)", size, new_addr, code.name.c_str());
return false;
} }
return true; return true;
} }
// Looks like this is new?? // Looks like this is new?? - untested
bool ZeroCode_MemoryCopy(u32 val_last, u32 addr, u32 data) // Has not been tested bool ZeroCode_MemoryCopy(u32 val_last, u32 addr, u32 data)
{ {
u32 addr_dest = val_last | 0x06000000; u32 addr_dest = val_last | 0x06000000;
u32 addr_src = (addr & 0x01FFFFFF) | 0x80000000; u32 addr_src = (addr & 0x01FFFFFF) | 0x80000000;
@ -704,7 +708,8 @@ bool ZeroCode_MemoryCopy(u32 val_last, u32 addr, u32 data) // Has not been teste
{ // Memory Copy With Pointers Support { // Memory Copy With Pointers Support
LogInfo("Memory Copy With Pointers Support"); LogInfo("Memory Copy With Pointers Support");
LogInfo("--------"); LogInfo("--------");
for (int i = 0; i < 138; i++) { for (int i = 0; i < 138; i++)
{
Memory::Write_U8(Memory::Read_U8(addr_src + i), addr_dest + i); Memory::Write_U8(Memory::Read_U8(addr_src + i), addr_dest + i);
LogInfo("Wrote %08x to address %08x", Memory::Read_U8(addr_src + i), addr_dest + i); LogInfo("Wrote %08x to address %08x", Memory::Read_U8(addr_src + i), addr_dest + i);
} }

View File

@ -23,14 +23,16 @@
namespace ActionReplay namespace ActionReplay
{ {
struct AREntry { struct AREntry
{
AREntry() {} AREntry() {}
AREntry(u32 _addr, u32 _value) : cmd_addr(_addr), value(_value) {} AREntry(u32 _addr, u32 _value) : cmd_addr(_addr), value(_value) {}
u32 cmd_addr; u32 cmd_addr;
u32 value; u32 value;
}; };
struct ARCode { struct ARCode
{
std::string name; std::string name;
std::vector<AREntry> ops; std::vector<AREntry> ops;
bool active; bool active;

View File

@ -49,30 +49,29 @@
void CBoot::Load_FST(bool _bIsWii) void CBoot::Load_FST(bool _bIsWii)
{ {
if (VolumeHandler::IsValid()) if (!VolumeHandler::IsValid()) return;
{
// copy first 20 bytes of disc to start of Mem 1
VolumeHandler::ReadToPtr(Memory::GetPointer(0x80000000), 0, 0x20);
// copy of game id // copy first 20 bytes of disc to start of Mem 1
Memory::Write_U32(Memory::Read_U32(0x80000000), 0x80003180); VolumeHandler::ReadToPtr(Memory::GetPointer(0x80000000), 0, 0x20);
// copy of game id
Memory::Write_U32(Memory::Read_U32(0x80000000), 0x80003180);
u32 shift = 0; u32 shift = 0;
if (_bIsWii) if (_bIsWii)
shift = 2; shift = 2;
u32 fstOffset = VolumeHandler::Read32(0x0424) << shift; u32 fstOffset = VolumeHandler::Read32(0x0424) << shift;
u32 fstSize = VolumeHandler::Read32(0x0428) << shift; u32 fstSize = VolumeHandler::Read32(0x0428) << shift;
u32 maxFstSize = VolumeHandler::Read32(0x042c) << shift; u32 maxFstSize = VolumeHandler::Read32(0x042c) << shift;
u32 arenaHigh = 0x817FFFF4 - maxFstSize; u32 arenaHigh = 0x817FFFF4 - maxFstSize;
Memory::Write_U32(arenaHigh, 0x00000034); Memory::Write_U32(arenaHigh, 0x00000034);
// load FST // load FST
VolumeHandler::ReadToPtr(Memory::GetPointer(arenaHigh), fstOffset, fstSize); VolumeHandler::ReadToPtr(Memory::GetPointer(arenaHigh), fstOffset, fstSize);
Memory::Write_U32(arenaHigh, 0x00000038); Memory::Write_U32(arenaHigh, 0x00000038);
Memory::Write_U32(maxFstSize, 0x0000003c); Memory::Write_U32(maxFstSize, 0x0000003c);
}
} }
void CBoot::UpdateDebugger_MapLoaded(const char *_gameID) void CBoot::UpdateDebugger_MapLoaded(const char *_gameID)
@ -86,18 +85,18 @@ std::string CBoot::GenerateMapFilename()
SCoreStartupParameter& _StartupPara = SConfig::GetInstance().m_LocalCoreStartupParameter; SCoreStartupParameter& _StartupPara = SConfig::GetInstance().m_LocalCoreStartupParameter;
switch (_StartupPara.m_BootType) switch (_StartupPara.m_BootType)
{ {
case SCoreStartupParameter::BOOT_WII_NAND: case SCoreStartupParameter::BOOT_WII_NAND:
{ {
const DiscIO::INANDContentLoader& Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(_StartupPara.m_strFilename); const DiscIO::INANDContentLoader& Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(_StartupPara.m_strFilename);
if (Loader.IsValid()) if (Loader.IsValid())
{ {
u64 TitleID = Loader.GetTitleID(); u64 TitleID = Loader.GetTitleID();
char tmpBuffer[32]; char tmpBuffer[32];
sprintf(tmpBuffer, "%08x_%08x", (u32)(TitleID >> 32) & 0xFFFFFFFF , (u32)TitleID & 0xFFFFFFFF ); sprintf(tmpBuffer, "%08x_%08x", (u32)(TitleID >> 32) & 0xFFFFFFFF , (u32)TitleID & 0xFFFFFFFF );
return std::string(File::GetUserPath(D_MAPS_IDX)) + std::string(tmpBuffer) + ".map"; return std::string(File::GetUserPath(D_MAPS_IDX)) + std::string(tmpBuffer) + ".map";
} }
} break;
break; }
case SCoreStartupParameter::BOOT_ELF: case SCoreStartupParameter::BOOT_ELF:
case SCoreStartupParameter::BOOT_DOL: case SCoreStartupParameter::BOOT_DOL:
@ -122,7 +121,7 @@ bool CBoot::LoadMapFromFilename(const std::string &_rFilename, const char *_game
if (_gameID != NULL) if (_gameID != NULL)
{ {
BuildCompleteFilename(strMapFilename, "maps", std::string(_gameID) + ".map"); BuildCompleteFilename(strMapFilename, "maps", std::string(_gameID) + ".map");
success = g_symbolDB.LoadMap(strMapFilename.c_str()); success = g_symbolDB.LoadMap(strMapFilename.c_str());
} }
} }
else else
@ -160,173 +159,171 @@ bool CBoot::Load_BS2(const std::string& _rBootROMFilename)
// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp // Third boot step after BootManager and Core. See Call schedule in BootManager.cpp
bool CBoot::BootUp() bool CBoot::BootUp()
{ {
SCoreStartupParameter& _StartupPara = SCoreStartupParameter& _StartupPara =
SConfig::GetInstance().m_LocalCoreStartupParameter; SConfig::GetInstance().m_LocalCoreStartupParameter;
NOTICE_LOG(BOOT, "Booting %s", _StartupPara.m_strFilename.c_str()); NOTICE_LOG(BOOT, "Booting %s", _StartupPara.m_strFilename.c_str());
g_symbolDB.Clear(); g_symbolDB.Clear();
VideoInterface::Preset(_StartupPara.bNTSC); VideoInterface::Preset(_StartupPara.bNTSC);
switch (_StartupPara.m_BootType) switch (_StartupPara.m_BootType)
{ {
// GCM and Wii // GCM and Wii
// =================================================================================== case SCoreStartupParameter::BOOT_ISO:
case SCoreStartupParameter::BOOT_ISO: {
{ DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_StartupPara.m_strFilename);
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_StartupPara.m_strFilename); if (pVolume == NULL)
if (pVolume == NULL) break;
break;
bool isoWii = DiscIO::IsVolumeWiiDisc(pVolume); bool isoWii = DiscIO::IsVolumeWiiDisc(pVolume);
if (isoWii != _StartupPara.bWii) if (isoWii != _StartupPara.bWii)
{ {
PanicAlert("Warning - starting ISO in wrong console mode!"); PanicAlert("Warning - starting ISO in wrong console mode!");
} }
char gameID[7]; char gameID[7];
memcpy(gameID, pVolume->GetUniqueID().c_str(), 6); memcpy(gameID, pVolume->GetUniqueID().c_str(), 6);
gameID[6] = 0; gameID[6] = 0;
// setup the map from ISOFile ID // setup the map from ISOFile ID
VolumeHandler::SetVolumeName(_StartupPara.m_strFilename); VolumeHandler::SetVolumeName(_StartupPara.m_strFilename);
VideoInterface::SetRegionReg((char)VolumeHandler::GetVolume()->GetUniqueID().at(3)); VideoInterface::SetRegionReg((char)VolumeHandler::GetVolume()->GetUniqueID().at(3));
DVDInterface::SetDiscInside(VolumeHandler::IsValid()); DVDInterface::SetDiscInside(VolumeHandler::IsValid());
_StartupPara.bWii = VolumeHandler::IsWii(); _StartupPara.bWii = VolumeHandler::IsWii();
// HLE BS2 or not // HLE BS2 or not
if (_StartupPara.bHLE_BS2) if (_StartupPara.bHLE_BS2)
{ {
EmulatedBS2(_StartupPara.bWii); EmulatedBS2(_StartupPara.bWii);
} }
else if (!Load_BS2(_StartupPara.m_strBootROM)) else if (!Load_BS2(_StartupPara.m_strBootROM))
{ {
// If we can't load the bootrom file we HLE it instead // If we can't load the bootrom file we HLE it instead
EmulatedBS2(_StartupPara.bWii); EmulatedBS2(_StartupPara.bWii);
} }
/* Try to load the symbol map if there is one, and then scan it for /* Try to load the symbol map if there is one, and then scan it for
and eventually replace code */ and eventually replace code */
if (LoadMapFromFilename(_StartupPara.m_strFilename, gameID)) if (LoadMapFromFilename(_StartupPara.m_strFilename, gameID))
HLE::PatchFunctions(); HLE::PatchFunctions();
// We don't need the volume any more
delete pVolume;
break;
}
// DOL
case SCoreStartupParameter::BOOT_DOL:
{
// Check if we have gotten a Wii file or not
bool dolWii = CDolLoader::IsDolWii(_StartupPara.m_strFilename.c_str());
if (dolWii != _StartupPara.bWii)
{
PanicAlert("Warning - starting DOL in wrong console mode!");
}
bool BS2Success = false;
if (dolWii)
{
BS2Success = EmulatedBS2(dolWii);
}
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
{
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
BS2Success = EmulatedBS2(dolWii);
}
if (!_StartupPara.m_strDVDRoot.empty())
{
NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str());
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, dolWii, _StartupPara.m_strApploader, _StartupPara.m_strFilename);
BS2Success = EmulatedBS2(dolWii);
}
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
if (!BS2Success)
{
CDolLoader dolLoader(_StartupPara.m_strFilename.c_str());
PC = dolLoader.GetEntryPoint();
}
if (LoadMapFromFilename(_StartupPara.m_strFilename))
HLE::PatchFunctions();
// We don't need the volume any more
delete pVolume;
}
break; break;
}
// DOL // ELF
// =================================================================================== case SCoreStartupParameter::BOOT_ELF:
case SCoreStartupParameter::BOOT_DOL: {
{ if(!File::Exists(_StartupPara.m_strFilename.c_str()))
// Check if we have gotten a Wii file or not {
bool dolWii = CDolLoader::IsDolWii(_StartupPara.m_strFilename.c_str()); PanicAlert("The file you specified (%s) does not exist",
if (dolWii != _StartupPara.bWii) _StartupPara.m_strFilename.c_str());
{ return false;
PanicAlert("Warning - starting DOL in wrong console mode!"); }
}
bool BS2Success = false; // Check if we have gotten a Wii file or not
bool elfWii = IsElfWii(_StartupPara.m_strFilename.c_str());
if (elfWii != _StartupPara.bWii)
{
PanicAlert("Warning - starting ELF in wrong console mode!");
}
if (dolWii) bool BS2Success = false;
{
BS2Success = EmulatedBS2(dolWii);
}
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
{
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
BS2Success = EmulatedBS2(dolWii);
}
if (!_StartupPara.m_strDVDRoot.empty()) if (elfWii)
{ {
NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str()); BS2Success = EmulatedBS2(elfWii);
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, dolWii, _StartupPara.m_strApploader, _StartupPara.m_strFilename); }
BS2Success = EmulatedBS2(dolWii); else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
} {
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
BS2Success = EmulatedBS2(elfWii);
}
DVDInterface::SetDiscInside(VolumeHandler::IsValid()); // load image or create virtual drive from directory
if (!_StartupPara.m_strDVDRoot.empty())
{
NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str());
// TODO: auto-convert elf to dol, so we can load them :)
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, elfWii);
BS2Success = EmulatedBS2(elfWii);
}
else if (!_StartupPara.m_strDefaultGCM.empty())
{
NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultGCM.c_str());
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
}
else VolumeHandler::SetVolumeDirectory(_StartupPara.m_strFilename, elfWii);
if (!BS2Success) DVDInterface::SetDiscInside(VolumeHandler::IsValid());
{
CDolLoader dolLoader(_StartupPara.m_strFilename.c_str());
PC = dolLoader.GetEntryPoint();
}
if (LoadMapFromFilename(_StartupPara.m_strFilename)) if (BS2Success)
HLE::PatchFunctions(); {
} HLE::PatchFunctions();
break; }
else // Poor man's bootup
// ELF {
// =================================================================================== Load_FST(elfWii);
case SCoreStartupParameter::BOOT_ELF: Boot_ELF(_StartupPara.m_strFilename.c_str());
{ }
if(!File::Exists(_StartupPara.m_strFilename.c_str())) UpdateDebugger_MapLoaded();
{ Dolphin_Debugger::AddAutoBreakpoints();
PanicAlert("The file you specified (%s) does not exist", break;
_StartupPara.m_strFilename.c_str()); }
return false;
}
// Check if we have gotten a Wii file or not
bool elfWii = IsElfWii(_StartupPara.m_strFilename.c_str());
if (elfWii != _StartupPara.bWii)
{
PanicAlert("Warning - starting ELF in wrong console mode!");
}
bool BS2Success = false;
if (elfWii)
{
BS2Success = EmulatedBS2(elfWii);
}
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
{
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
BS2Success = EmulatedBS2(elfWii);
}
// load image or create virtual drive from directory
if (!_StartupPara.m_strDVDRoot.empty()) {
NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str());
// TODO: auto-convert elf to dol, so we can load them :)
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, elfWii);
BS2Success = EmulatedBS2(elfWii);
}
else if (!_StartupPara.m_strDefaultGCM.empty()) {
NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultGCM.c_str());
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
}
else
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strFilename, elfWii);
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
if (BS2Success)
{
HLE::PatchFunctions();
}
else // Poor man's bootup
{
Load_FST(elfWii);
Boot_ELF(_StartupPara.m_strFilename.c_str());
}
UpdateDebugger_MapLoaded();
Dolphin_Debugger::AddAutoBreakpoints();
}
break;
// Wii WAD // Wii WAD
// ===================================================================================
case SCoreStartupParameter::BOOT_WII_NAND: case SCoreStartupParameter::BOOT_WII_NAND:
Boot_WiiWAD(_StartupPara.m_strFilename.c_str()); Boot_WiiWAD(_StartupPara.m_strFilename.c_str());
if (LoadMapFromFilename(_StartupPara.m_strFilename)) if (LoadMapFromFilename(_StartupPara.m_strFilename))
HLE::PatchFunctions(); HLE::PatchFunctions();
// load default image or create virtual drive from directory // load default image or create virtual drive from directory
if (!_StartupPara.m_strDVDRoot.empty()) if (!_StartupPara.m_strDVDRoot.empty())
@ -335,33 +332,31 @@ bool CBoot::BootUp()
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM); VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
DVDInterface::SetDiscInside(VolumeHandler::IsValid()); DVDInterface::SetDiscInside(VolumeHandler::IsValid());
break; break;
// Bootstrap 2 (AKA: Initial Program Loader, "BIOS") // Bootstrap 2 (AKA: Initial Program Loader, "BIOS")
// =================================================================================== case SCoreStartupParameter::BOOT_BS2:
case SCoreStartupParameter::BOOT_BS2: {
{ DVDInterface::SetDiscInside(VolumeHandler::IsValid());
DVDInterface::SetDiscInside(VolumeHandler::IsValid()); if (Load_BS2(_StartupPara.m_strBootROM))
if (Load_BS2(_StartupPara.m_strBootROM)) {
{ if (LoadMapFromFilename(_StartupPara.m_strFilename))
if (LoadMapFromFilename(_StartupPara.m_strFilename)) HLE::PatchFunctions();
HLE::PatchFunctions(); }
} else
else {
{ return false;
return false; }
} break;
} }
break;
default: default:
{ {
PanicAlert("Tried to load an unknown file type."); PanicAlert("Tried to load an unknown file type.");
return false; return false;
} }
} }
Host_UpdateLogDisplay(); Host_UpdateLogDisplay();
return true; return true;
} }

View File

@ -51,9 +51,9 @@ bool CDolLoader::Initialize(u8* _pBuffer, u32 _Size)
p[i] = Common::swap32(p[i]); p[i] = Common::swap32(p[i]);
// load all text (code) sections // load all text (code) sections
for(int i = 0; i < DOL_NUM_TEXT; i++) for (int i = 0; i < DOL_NUM_TEXT; i++)
{ {
if(m_dolheader.textOffset[i] != 0) if (m_dolheader.textOffset[i] != 0)
{ {
u8* pTemp = &_pBuffer[m_dolheader.textOffset[i]]; u8* pTemp = &_pBuffer[m_dolheader.textOffset[i]];
for (u32 num = 0; num < m_dolheader.textSize[i]; num++) for (u32 num = 0; num < m_dolheader.textSize[i]; num++)
@ -62,9 +62,9 @@ bool CDolLoader::Initialize(u8* _pBuffer, u32 _Size)
} }
// load all data sections // load all data sections
for(int i = 0; i < DOL_NUM_DATA; i++) for (int i = 0; i < DOL_NUM_DATA; i++)
{ {
if(m_dolheader.dataOffset[i] != 0) if (m_dolheader.dataOffset[i] != 0)
{ {
u8* pTemp = &_pBuffer[m_dolheader.dataOffset[i]]; u8* pTemp = &_pBuffer[m_dolheader.dataOffset[i]];
for (u32 num = 0; num < m_dolheader.dataSize[i]; num++) for (u32 num = 0; num < m_dolheader.dataSize[i]; num++)

View File

@ -59,13 +59,14 @@ bool CBoot::Boot_ELF(const char *filename)
{ {
if (LoadMapFromFilename(filename)) if (LoadMapFromFilename(filename))
HLE::PatchFunctions(); HLE::PatchFunctions();
} else { }
else
{
HLE::PatchFunctions(); HLE::PatchFunctions();
} }
PC = reader.GetEntryPoint(); PC = reader.GetEntryPoint();
delete [] mem; delete []mem;
return true; return true;
} }

View File

@ -123,7 +123,8 @@ bool CBoot::Install_WiiWAD(const char* _pFilename)
sprintf(APPFileName, "%s%08x.app", ContentPath, Content.m_ContentID); sprintf(APPFileName, "%s%08x.app", ContentPath, Content.m_ContentID);
FILE* pAPPFile = fopen(APPFileName, "wb"); FILE* pAPPFile = fopen(APPFileName, "wb");
if (pAPPFile == NULL) { if (pAPPFile == NULL)
{
PanicAlert("WAD installation failed: error creating %s", APPFileName); PanicAlert("WAD installation failed: error creating %s", APPFileName);
return false; return false;
} }

View File

@ -94,7 +94,7 @@ ElfReader::ElfReader(void *ptr)
const char *ElfReader::GetSectionName(int section) const const char *ElfReader::GetSectionName(int section) const
{ {
if (sections[section].sh_type == SHT_NULL) if (sections[section].sh_type == SHT_NULL)
return 0; return NULL;
int nameOffset = sections[section].sh_name; int nameOffset = sections[section].sh_name;
char *ptr = (char*)GetSectionDataPtr(header->e_shstrndx); char *ptr = (char*)GetSectionDataPtr(header->e_shstrndx);
@ -102,7 +102,7 @@ const char *ElfReader::GetSectionName(int section) const
if (ptr) if (ptr)
return ptr + nameOffset; return ptr + nameOffset;
else else
return 0; return NULL;
} }
void addrToHiLo(u32 addr, u16 &hi, s16 &lo) void addrToHiLo(u32 addr, u16 &hi, s16 &lo)
@ -207,7 +207,7 @@ SectionID ElfReader::GetSectionByName(const char *name, int firstSection) const
{ {
const char *secname = GetSectionName(i); const char *secname = GetSectionName(i);
if (secname != 0 && strcmp(name, secname) == 0) if (secname != NULL && strcmp(name, secname) == 0)
return i; return i;
} }
return -1; return -1;

View File

@ -57,95 +57,90 @@ void SConfig::SaveSettings()
{ {
NOTICE_LOG(BOOT, "Saving Settings to %s", File::GetUserPath(F_DOLPHINCONFIG_IDX)); NOTICE_LOG(BOOT, "Saving Settings to %s", File::GetUserPath(F_DOLPHINCONFIG_IDX));
IniFile ini; IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); // yes we must load first to not kill unknown stuff ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); // load first to not kill unknown stuff
// General // General
ini.Set("General", "LastFilename", m_LastFilename);
// ISO folders
ini.Set("General", "GCMPathes", (int)m_ISOFolder.size());
for (size_t i = 0; i < m_ISOFolder.size(); i++)
{ {
ini.Set("General", "LastFilename", m_LastFilename); TCHAR tmp[16];
sprintf(tmp, "GCMPath%i", (int)i);
// ISO folders ini.Set("General", tmp, m_ISOFolder[i]);
ini.Set("General", "GCMPathes", (int)m_ISOFolder.size());
for (size_t i = 0; i < m_ISOFolder.size(); i++)
{
TCHAR tmp[16];
sprintf(tmp, "GCMPath%i", (int)i);
ini.Set("General", tmp, m_ISOFolder[i]);
}
ini.Set("General", "RecersiveGCMPaths", m_RecursiveISOFolder);
} }
ini.Set("General", "RecersiveGCMPaths", m_RecursiveISOFolder);
// Interface
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop);
ini.Set("Interface", "UsePanicHandlers", m_LocalCoreStartupParameter.bUsePanicHandlers);
ini.Set("Interface", "HideCursor", m_LocalCoreStartupParameter.bHideCursor);
ini.Set("Interface", "AutoHideCursor", m_LocalCoreStartupParameter.bAutoHideCursor);
ini.Set("Interface", "Theme", m_LocalCoreStartupParameter.iTheme);
ini.Set("Interface", "MainWindowPosX", m_LocalCoreStartupParameter.iPosX);
ini.Set("Interface", "MainWindowPosY", m_LocalCoreStartupParameter.iPosY);
ini.Set("Interface", "MainWindowWidth", m_LocalCoreStartupParameter.iWidth);
ini.Set("Interface", "MainWindowHeight", m_LocalCoreStartupParameter.iHeight);
ini.Set("Interface", "Language", m_InterfaceLanguage);
ini.Set("Interface", "ShowToolbar", m_InterfaceToolbar);
ini.Set("Interface", "ShowStatusbar", m_InterfaceStatusbar);
ini.Set("Interface", "ShowLogWindow", m_InterfaceLogWindow);
ini.Set("Interface", "ShowConsole", m_InterfaceConsole);
// Game List Control
ini.Set("GameList", "ListDrives", m_ListDrives);
ini.Set("GameList", "ListWad", m_ListWad);
ini.Set("GameList", "ListWii", m_ListWii);
ini.Set("GameList", "ListGC", m_ListGC);
ini.Set("GameList", "ListJap", m_ListJap);
ini.Set("GameList", "ListPal", m_ListPal);
ini.Set("GameList", "ListUsa", m_ListUsa);
ini.Set("GameList", "ListFrance", m_ListFrance);
ini.Set("GameList", "ListItaly", m_ListItaly);
ini.Set("GameList", "ListKorea", m_ListKorea);
ini.Set("GameList", "ListTaiwan", m_ListTaiwan);
ini.Set("GameList", "ListUnknown", m_ListUnknown);
// Core
ini.Set("Core", "HLE_BS2", m_LocalCoreStartupParameter.bHLE_BS2);
ini.Set("Core", "CPUCore", m_LocalCoreStartupParameter.iCPUCore);
ini.Set("Core", "CPUThread", m_LocalCoreStartupParameter.bCPUThread);
ini.Set("Core", "DSPThread", m_LocalCoreStartupParameter.bDSPThread);
ini.Set("Core", "SkipIdle", m_LocalCoreStartupParameter.bSkipIdle);
ini.Set("Core", "LockThreads", m_LocalCoreStartupParameter.bLockThreads);
ini.Set("Core", "DefaultGCM", m_LocalCoreStartupParameter.m_strDefaultGCM);
ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot);
ini.Set("Core", "Apploader", m_LocalCoreStartupParameter.m_strApploader);
ini.Set("Core", "EnableCheats", m_LocalCoreStartupParameter.bEnableCheats);
ini.Set("Core", "SelectedLanguage", m_LocalCoreStartupParameter.SelectedLanguage);
ini.Set("Core", "MemcardA", m_strMemoryCardA);
ini.Set("Core", "MemcardB", m_strMemoryCardB);
ini.Set("Core", "SlotA", m_EXIDevice[0]);
ini.Set("Core", "SlotB", m_EXIDevice[1]);
ini.Set("Core", "SerialPort1", m_EXIDevice[2]);
char sidevicenum[16];
for (int i = 0; i < 4; ++i)
{ {
// Interface sprintf(sidevicenum, "SIDevice%i", i);
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop); ini.Set("Core", sidevicenum, m_SIDevice[i]);
ini.Set("Interface", "UsePanicHandlers", m_LocalCoreStartupParameter.bUsePanicHandlers);
ini.Set("Interface", "HideCursor", m_LocalCoreStartupParameter.bHideCursor);
ini.Set("Interface", "AutoHideCursor", m_LocalCoreStartupParameter.bAutoHideCursor);
ini.Set("Interface", "Theme", m_LocalCoreStartupParameter.iTheme);
ini.Set("Interface", "MainWindowPosX", m_LocalCoreStartupParameter.iPosX);
ini.Set("Interface", "MainWindowPosY", m_LocalCoreStartupParameter.iPosY);
ini.Set("Interface", "MainWindowWidth", m_LocalCoreStartupParameter.iWidth);
ini.Set("Interface", "MainWindowHeight", m_LocalCoreStartupParameter.iHeight);
ini.Set("Interface", "Language", m_InterfaceLanguage);
ini.Set("Interface", "ShowToolbar", m_InterfaceToolbar);
ini.Set("Interface", "ShowStatusbar", m_InterfaceStatusbar);
ini.Set("Interface", "ShowLogWindow", m_InterfaceLogWindow);
ini.Set("Interface", "ShowConsole", m_InterfaceConsole);
// Game List Control
ini.Set("GameList", "ListDrives", m_ListDrives);
ini.Set("GameList", "ListWad", m_ListWad);
ini.Set("GameList", "ListWii", m_ListWii);
ini.Set("GameList", "ListGC", m_ListGC);
ini.Set("GameList", "ListJap", m_ListJap);
ini.Set("GameList", "ListPal", m_ListPal);
ini.Set("GameList", "ListUsa", m_ListUsa);
ini.Set("GameList", "ListFrance", m_ListFrance);
ini.Set("GameList", "ListItaly", m_ListItaly);
ini.Set("GameList", "ListKorea", m_ListKorea);
ini.Set("GameList", "ListTaiwan", m_ListTaiwan);
ini.Set("GameList", "ListUnknown", m_ListUnknown);
// Core
ini.Set("Core", "HLE_BS2", m_LocalCoreStartupParameter.bHLE_BS2);
ini.Set("Core", "CPUCore", m_LocalCoreStartupParameter.iCPUCore);
ini.Set("Core", "CPUThread", m_LocalCoreStartupParameter.bCPUThread);
ini.Set("Core", "DSPThread", m_LocalCoreStartupParameter.bDSPThread);
ini.Set("Core", "SkipIdle", m_LocalCoreStartupParameter.bSkipIdle);
ini.Set("Core", "LockThreads", m_LocalCoreStartupParameter.bLockThreads);
ini.Set("Core", "DefaultGCM", m_LocalCoreStartupParameter.m_strDefaultGCM);
ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot);
ini.Set("Core", "Apploader", m_LocalCoreStartupParameter.m_strApploader);
ini.Set("Core", "EnableCheats", m_LocalCoreStartupParameter.bEnableCheats);
ini.Set("Core", "SelectedLanguage", m_LocalCoreStartupParameter.SelectedLanguage);
ini.Set("Core", "MemcardA", m_strMemoryCardA);
ini.Set("Core", "MemcardB", m_strMemoryCardB);
ini.Set("Core", "SlotA", m_EXIDevice[0]);
ini.Set("Core", "SlotB", m_EXIDevice[1]);
ini.Set("Core", "SerialPort1", m_EXIDevice[2]);
char sidevicenum[16];
for (int i = 0; i < 4; ++i)
{
sprintf(sidevicenum, "SIDevice%i", i);
ini.Set("Core", sidevicenum, m_SIDevice[i]);
}
ini.Set("Core", "WiiSDCard", m_WiiSDCard);
ini.Set("Core", "WiiKeyboard", m_WiiKeyboard);
ini.Set("Core", "RunCompareServer", m_LocalCoreStartupParameter.bRunCompareServer);
ini.Set("Core", "RunCompareClient", m_LocalCoreStartupParameter.bRunCompareClient);
ini.Set("Core", "FrameLimit", m_Framelimit);
// Plugins
ini.Set("Core", "GFXPlugin", m_LocalCoreStartupParameter.m_strVideoPlugin);
ini.Set("Core", "DSPPlugin", m_LocalCoreStartupParameter.m_strDSPPlugin);
ini.Set("Core", "PadPlugin", m_LocalCoreStartupParameter.m_strPadPlugin[0]);
ini.Set("Core", "WiiMotePlugin",m_LocalCoreStartupParameter.m_strWiimotePlugin[0]);
} }
ini.Set("Core", "WiiSDCard", m_WiiSDCard);
ini.Set("Core", "WiiKeyboard", m_WiiKeyboard);
ini.Set("Core", "RunCompareServer", m_LocalCoreStartupParameter.bRunCompareServer);
ini.Set("Core", "RunCompareClient", m_LocalCoreStartupParameter.bRunCompareClient);
ini.Set("Core", "FrameLimit", m_Framelimit);
// Plugins
ini.Set("Core", "GFXPlugin", m_LocalCoreStartupParameter.m_strVideoPlugin);
ini.Set("Core", "DSPPlugin", m_LocalCoreStartupParameter.m_strDSPPlugin);
ini.Set("Core", "PadPlugin", m_LocalCoreStartupParameter.m_strPadPlugin[0]);
ini.Set("Core", "WiiMotePlugin",m_LocalCoreStartupParameter.m_strWiimotePlugin[0]);
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX)); ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
m_SYSCONF->Save(); m_SYSCONF->Save();
} }

View File

@ -111,11 +111,7 @@ struct SConfig
static void Shutdown(); static void Shutdown();
private: private:
// constructor
SConfig(); SConfig();
// destructor
~SConfig(); ~SConfig();
static SConfig* m_Instance; static SConfig* m_Instance;

View File

@ -104,7 +104,8 @@ void Patch(u32 address, const char *hle_func_name)
{ {
for (u32 i = 0; i < sizeof(OSPatches) / sizeof(SPatch); i++) for (u32 i = 0; i < sizeof(OSPatches) / sizeof(SPatch); i++)
{ {
if (!strcmp(OSPatches[i].m_szPatchName, hle_func_name)) { if (!strcmp(OSPatches[i].m_szPatchName, hle_func_name))
{
u32 HLEPatchValue = (1 & 0x3f) << 26; u32 HLEPatchValue = (1 & 0x3f) << 26;
Memory::Write_U32(HLEPatchValue | i, address); Memory::Write_U32(HLEPatchValue | i, address);
return; return;
@ -121,7 +122,8 @@ void PatchFunctions()
if (symbol > 0) if (symbol > 0)
{ {
u32 HLEPatchValue = (1 & 0x3f) << 26; u32 HLEPatchValue = (1 & 0x3f) << 26;
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4) { for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
{
orig_instruction[addr] = Memory::ReadUnchecked_U32(addr); orig_instruction[addr] = Memory::ReadUnchecked_U32(addr);
Memory::Write_U32(HLEPatchValue | i, addr); Memory::Write_U32(HLEPatchValue | i, addr);
} }
@ -166,4 +168,4 @@ u32 GetOrigInstruction(u32 addr)
return 0; return 0;
} }
} } // end of namespace HLE

View File

@ -26,7 +26,7 @@ namespace HLE_Misc
{ {
// Helper to quickly read the floating point value at a memory location. // Helper to quickly read the floating point value at a memory location.
inline float F(u32 addr) inline float F(u32 addr)
{ {
u32 mem = Memory::ReadFast32(addr); u32 mem = Memory::ReadFast32(addr);
return *((float*)&mem); return *((float*)&mem);

View File

@ -117,20 +117,20 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
case 'd': case 'd':
case 'i': case 'i':
{ {
//u64 Double = Memory::Read_U64(Parameter); //u64 Double = Memory::Read_U64(Parameter);
_rOutBuffer += StringFromFormat(ArgumentBuffer, Parameter); _rOutBuffer += StringFromFormat(ArgumentBuffer, Parameter);
}
break; break;
}
case 'f': case 'f':
{ {
_rOutBuffer += StringFromFormat(ArgumentBuffer, _rOutBuffer += StringFromFormat(ArgumentBuffer,
rPS0(FloatingParameterCounter)); rPS0(FloatingParameterCounter));
FloatingParameterCounter++; FloatingParameterCounter++;
ParameterCounter--; ParameterCounter--;
}
break; break;
}
case 'p': case 'p':
// Override, so 64bit dolphin prints 32bit pointers, since the ppc is 32bit :) // Override, so 64bit dolphin prints 32bit pointers, since the ppc is 32bit :)
@ -153,4 +153,4 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
_rOutBuffer.resize(_rOutBuffer.length() - 1); _rOutBuffer.resize(_rOutBuffer.length() - 1);
} }
} } // end of namespace HLE_OS

View File

@ -105,58 +105,58 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
u32 ReturnValue = 0; u32 ReturnValue = 0;
switch (Parameter) switch (Parameter)
{ {
case IOCTL_NWC24_SUSPEND_SCHEDULAR: case IOCTL_NWC24_SUSPEND_SCHEDULAR:
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
break; break;
case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
break; break;
case IOCTL_NWC24_UNK_3: // NWC24iResumeForCloseLib case IOCTL_NWC24_UNK_3: // NWC24iResumeForCloseLib
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNK_3 - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNK_3 - NI");
break; break;
case IOCTL_NWC24_STARTUP_SOCKET: // NWC24iStartupSocket case IOCTL_NWC24_STARTUP_SOCKET: // NWC24iStartupSocket
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
break; break;
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
break; break;
case IOCTL_NWC24_UNLOCK_SOCKET: case IOCTL_NWC24_UNLOCK_SOCKET:
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
break; break;
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes) case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
memcpy(Memory::GetPointer(BufferOut), m_UserID.c_str(), m_UserID.length() + 1); memcpy(Memory::GetPointer(BufferOut), m_UserID.c_str(), m_UserID.length() + 1);
break; break;
case IOCTL_NWC24_GET_SCHEDULAR_STAT: case IOCTL_NWC24_GET_SCHEDULAR_STAT:
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
break; break;
case IOCTL_NWC24_SAVE_MAIL_NOW: case IOCTL_NWC24_SAVE_MAIL_NOW:
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
break; break;
case IOCTL_NWC24_REQUEST_SHUTDOWN: case IOCTL_NWC24_REQUEST_SHUTDOWN:
// if ya set the IOS version to a very high value this happens ... // if ya set the IOS version to a very high value this happens ...
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI"); INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI");
break; break;
default: default:
INFO_LOG(WII_IPC_NET, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", INFO_LOG(WII_IPC_NET, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize); Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize);
break; break;
} }
// g_ReplyQueueLater.push(std::pair<u32, std::string>(_CommandAddress, GetDeviceName())); // g_ReplyQueueLater.push(std::pair<u32, std::string>(_CommandAddress, GetDeviceName()));
Memory::Write_U32(ReturnValue, _CommandAddress + 4); Memory::Write_U32(ReturnValue, _CommandAddress + 4);
return true; return true;
@ -240,7 +240,7 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
u32 addr = CommandBuffer.PayloadBuffer.at(0).m_Address; u32 addr = CommandBuffer.PayloadBuffer.at(0).m_Address;
Memory::WriteBigEData((const u8*)&m_Ifconfig, addr, 8); Memory::WriteBigEData((const u8*)&m_Ifconfig, addr, 8);
addr += 8; addr += 8;
for (unsigned int i = 0;i < 3; i++) for (unsigned int i = 0; i < 3; i++)
{ {
netcfg_connection_t *conn = &m_Ifconfig.connection[i]; netcfg_connection_t *conn = &m_Ifconfig.connection[i];
@ -349,10 +349,12 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
// Handle /dev/net/ip/top requests // Handle /dev/net/ip/top requests
CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{} {
}
CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top() CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top()
{} {
}
bool CWII_IPC_HLE_Device_net_ip_top::Open(u32 _CommandAddress, u32 _Mode) bool CWII_IPC_HLE_Device_net_ip_top::Open(u32 _CommandAddress, u32 _Mode)
{ {
@ -417,58 +419,57 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn,
break; break;
case IOCTL_SO_SOCKET: case IOCTL_SO_SOCKET:
{ {
u32 AF = Memory::Read_U32(_BufferIn); u32 AF = Memory::Read_U32(_BufferIn);
u32 TYPE = Memory::Read_U32(_BufferIn + 0x04); u32 TYPE = Memory::Read_U32(_BufferIn + 0x04);
u32 PROT = Memory::Read_U32(_BufferIn + 0x04 * 2); u32 PROT = Memory::Read_U32(_BufferIn + 0x04 * 2);
// u32 Unk1 = Memory::Read_U32(_BufferIn + 0x04 * 3); // u32 Unk1 = Memory::Read_U32(_BufferIn + 0x04 * 3);
u32 Socket = (u32)socket(AF, TYPE, PROT); u32 Socket = (u32)socket(AF, TYPE, PROT);
return Common::swap32(Socket); // So it doesn't get mangled later on return Common::swap32(Socket); // So it doesn't get mangled later on
}
break; break;
}
case IOCTL_SO_BIND: case IOCTL_SO_BIND:
{ {
bind_params *addr = (bind_params*)Memory::GetPointer(_BufferIn); bind_params *addr = (bind_params*)Memory::GetPointer(_BufferIn);
GC_sockaddr_in addrPC; GC_sockaddr_in addrPC;
memcpy(&addrPC, addr->name, sizeof(GC_sockaddr_in)); memcpy(&addrPC, addr->name, sizeof(GC_sockaddr_in));
sockaddr_in address; sockaddr_in address;
address.sin_family = addrPC.sin_family; address.sin_family = addrPC.sin_family;
address.sin_addr.s_addr = addrPC.sin_addr.s_addr_; address.sin_addr.s_addr = addrPC.sin_addr.s_addr_;
address.sin_port = htons(addrPC.sin_port); address.sin_port = htons(addrPC.sin_port);
int Return = bind(addr->socket, (sockaddr*)&address, sizeof(address)); int Return = bind(addr->socket, (sockaddr*)&address, sizeof(address));
return Return; return Return;
//int bind(int s, struct sockaddr *addr, int addrlen); //int bind(int s, struct sockaddr *addr, int addrlen);
}
break; break;
}
case IOCTL_SO_LISTEN: case IOCTL_SO_LISTEN:
{ {
u32 S = Memory::Read_U32(_BufferIn); u32 S = Memory::Read_U32(_BufferIn);
u32 BACKLOG = Memory::Read_U32(_BufferIn + 0x04); u32 BACKLOG = Memory::Read_U32(_BufferIn + 0x04);
u32 Return = listen(S, BACKLOG); u32 Return = listen(S, BACKLOG);
return Return; return Return;
}
break; break;
}
case IOCTL_SO_ACCEPT: case IOCTL_SO_ACCEPT:
{ {
//TODO: (Sonic)Check if this is correct //TODO: (Sonic)Check if this is correct
u32 S = Memory::Read_U32(_BufferIn); u32 S = Memory::Read_U32(_BufferIn);
socklen_t addrlen; socklen_t addrlen;
struct sockaddr_in address; struct sockaddr_in address;
u32 Return = (u32)accept(S, (struct sockaddr *)&address, &addrlen); u32 Return = (u32)accept(S, (struct sockaddr *)&address, &addrlen);
GC_sockaddr_in *addr = (GC_sockaddr_in*)Memory::GetPointer(BufferOut); GC_sockaddr_in *addr = (GC_sockaddr_in*)Memory::GetPointer(BufferOut);
addr->sin_family = (u8)address.sin_family; addr->sin_family = (u8)address.sin_family;
addr->sin_addr.s_addr_ = address.sin_addr.s_addr; addr->sin_addr.s_addr_ = address.sin_addr.s_addr;
addr->sin_port = address.sin_port; addr->sin_port = address.sin_port;
socklen_t *Len = (socklen_t *)Memory::GetPointer(BufferOut + 0x04); socklen_t *Len = (socklen_t *)Memory::GetPointer(BufferOut + 0x04);
*Len = addrlen; *Len = addrlen;
return Return; return Return;
//int accept(int s, struct sockaddr *addr, int *addrlen); //int accept(int s, struct sockaddr *addr, int *addrlen);
///dev/net/ip/top::IOCtl request 0x1 (BufferIn: (000318c0, 4), BufferOut: (00058a4c, 8) ///dev/net/ip/top::IOCtl request 0x1 (BufferIn: (000318c0, 4), BufferOut: (00058a4c, 8)
} }
break;
case IOCTL_SO_GETHOSTID: case IOCTL_SO_GETHOSTID:
return 127 << 24 | 1; return 127 << 24 | 1;
@ -504,6 +505,5 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 _CommandAddress)
} }
Memory::Write_U32(ReturnValue, _CommandAddress+4); Memory::Write_U32(ReturnValue, _CommandAddress+4);
return true; return true;
} }

View File

@ -150,7 +150,7 @@ void InstallExceptionHandler()
#endif #endif
} }
#else // _WIN32) #else // _WIN32
// //
// backtrace useful function // backtrace useful function
@ -165,7 +165,7 @@ void print_trace(const char * msg)
size = backtrace(array, 100); size = backtrace(array, 100);
strings = backtrace_symbols(array, size); strings = backtrace_symbols(array, size);
printf("%s Obtained %zd stack frames.\n", msg, size); printf("%s Obtained %u stack frames.\n", msg, size);
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
printf("--> %s\n", strings[i]); printf("--> %s\n", strings[i]);
free(strings); free(strings);

View File

@ -89,11 +89,11 @@ void DoState(PointerWrap &p)
} }
// Begin with video plugin, so that it gets a chance to clear it's caches and writeback modified things to RAM // Begin with video plugin, so that it gets a chance to clear it's caches and writeback modified things to RAM
CPluginManager &pm = CPluginManager::GetInstance(); CPluginManager &pm = CPluginManager::GetInstance();
pm.GetVideo()->DoState(p.GetPPtr(), p.GetMode()); pm.GetVideo()->DoState(p.GetPPtr(), p.GetMode());
pm.GetDSP()->DoState(p.GetPPtr(), p.GetMode()); pm.GetDSP()->DoState(p.GetPPtr(), p.GetMode());
pm.GetPad(0)->DoState(p.GetPPtr(), p.GetMode()); pm.GetPad(0)->DoState(p.GetPPtr(), p.GetMode());
if (Core::g_CoreStartupParameter.bWii) if (Core::g_CoreStartupParameter.bWii)
pm.GetWiimote(0)->DoState(p.GetPPtr(), p.GetMode()); pm.GetWiimote(0)->DoState(p.GetPPtr(), p.GetMode());
PowerPC::DoState(p); PowerPC::DoState(p);
HW::DoState(p); HW::DoState(p);
CoreTiming::DoState(p); CoreTiming::DoState(p);
@ -161,7 +161,8 @@ THREAD_RETURN CompressAndDumpState(void *pArgs)
delete saveArg; delete saveArg;
// Moving to last overwritten save-state // Moving to last overwritten save-state
if (File::Exists(cur_filename.c_str())) { if (File::Exists(cur_filename.c_str()))
{
if (File::Exists((std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str())) if (File::Exists((std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str()))
File::Delete((std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str()); File::Delete((std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str());
@ -170,9 +171,10 @@ THREAD_RETURN CompressAndDumpState(void *pArgs)
} }
FILE *f = fopen(filename.c_str(), "wb"); FILE *f = fopen(filename.c_str(), "wb");
if (f == NULL) { if (f == NULL)
{
Core::DisplayMessage("Could not save state", 2000); Core::DisplayMessage("Could not save state", 2000);
delete [] buffer; delete []buffer;
return 0; return 0;
} }
@ -181,11 +183,13 @@ THREAD_RETURN CompressAndDumpState(void *pArgs)
header.sz = bCompressed ? sz : 0; header.sz = bCompressed ? sz : 0;
fwrite(&header, sizeof(state_header), 1, f); fwrite(&header, sizeof(state_header), 1, f);
if (bCompressed) { if (bCompressed)
{
lzo_uint cur_len = 0; lzo_uint cur_len = 0;
lzo_uint i = 0; lzo_uint i = 0;
for (;;) { for (;;)
{
if ((i + IN_LEN) >= sz) if ((i + IN_LEN) >= sz)
cur_len = sz - i; cur_len = sz - i;
else else
@ -202,7 +206,6 @@ THREAD_RETURN CompressAndDumpState(void *pArgs)
break; break;
i += cur_len; i += cur_len;
} }
} }
else else
{ {
@ -210,8 +213,7 @@ THREAD_RETURN CompressAndDumpState(void *pArgs)
} }
fclose(f); fclose(f);
delete []buffer;
delete [] buffer;
Core::DisplayMessage(StringFromFormat("Saved State to %s", Core::DisplayMessage(StringFromFormat("Saved State to %s",
filename.c_str()).c_str(), 2000); filename.c_str()).c_str(), 2000);
@ -288,7 +290,6 @@ void LoadStateCallback(u64 userdata, int cyclesLate)
gameID), 2000); gameID), 2000);
fclose(f); fclose(f);
return; return;
} }
@ -300,14 +301,15 @@ void LoadStateCallback(u64 userdata, int cyclesLate)
lzo_uint i = 0; lzo_uint i = 0;
buffer = new u8[sz]; buffer = new u8[sz];
if (!buffer) { if (!buffer)
{
PanicAlert("Error allocating buffer"); PanicAlert("Error allocating buffer");
return; return;
} }
while (true) while (true)
{ {
lzo_uint cur_len = 0; lzo_uint cur_len = 0; // number of bytes to read
lzo_uint new_len = 0; lzo_uint new_len = 0; // number of bytes to write
if (fread(&cur_len, 1, sizeof(int), f) == 0) if (fread(&cur_len, 1, sizeof(int), f) == 0)
break; break;
if (feof(f)) if (feof(f))
@ -324,7 +326,6 @@ void LoadStateCallback(u64 userdata, int cyclesLate)
return; return;
} }
// The size of the data to read to our buffer is 'new_len'
i += new_len; i += new_len;
} }
} }

View File

@ -53,7 +53,7 @@ void StopTrace()
if (tracefile) if (tracefile)
{ {
fclose(tracefile); fclose(tracefile);
tracefile = 0; tracefile = NULL;
} }
} }
@ -143,5 +143,5 @@ int SyncTrace()
return 1; return 1;
} }
}
} // end of namespace Core

View File

@ -23,7 +23,8 @@ namespace VolumeHandler
DiscIO::IVolume* g_pVolume = NULL; DiscIO::IVolume* g_pVolume = NULL;
DiscIO::IVolume *GetVolume() { DiscIO::IVolume *GetVolume()
{
return g_pVolume; return g_pVolume;
} }
@ -50,7 +51,7 @@ bool SetVolumeName(const std::string& _rFullPath)
g_pVolume = DiscIO::CreateVolumeFromFilename(_rFullPath); g_pVolume = DiscIO::CreateVolumeFromFilename(_rFullPath);
return g_pVolume != NULL; return (g_pVolume != NULL);
} }
void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii, const std::string& _rApploader, const std::string& _rDOL) void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii, const std::string& _rApploader, const std::string& _rDOL)
@ -82,7 +83,6 @@ bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength)
g_pVolume->Read(_dwOffset, _dwLength, ptr); g_pVolume->Read(_dwOffset, _dwLength, ptr);
return true; return true;
} }
return false; return false;
} }
@ -93,13 +93,12 @@ bool RAWReadToPtr( u8* ptr, u64 _dwOffset, u64 _dwLength )
g_pVolume->RAWRead(_dwOffset, _dwLength, ptr); g_pVolume->RAWRead(_dwOffset, _dwLength, ptr);
return true; return true;
} }
return false; return false;
} }
bool IsValid() bool IsValid()
{ {
return g_pVolume != NULL; return (g_pVolume != NULL);
} }
bool IsWii() bool IsWii()
@ -110,4 +109,4 @@ bool IsWii()
return false; return false;
} }
} // namespace } // end of namespace VolumeHandler

View File

@ -42,6 +42,6 @@ DiscIO::IVolume *GetVolume();
void EjectVolume(); void EjectVolume();
} // namespace } // end of namespace VolumeHandler
#endif #endif