Work towards issue 1229; initial framework for including exi devices in savestates.

Another Unicode fix :( - exporting gci works again

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3999 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2009-08-16 08:26:57 +00:00
parent f2c561f4d0
commit 86e585a66a
9 changed files with 42 additions and 39 deletions

View File

@ -64,7 +64,12 @@ void Shutdown()
void DoState(PointerWrap &p)
{
// TODO: descend all the devices recursively.
// TODO: Complete DoState for each IEXIDevice
g_Channels[0].GetDevice(1)->DoState(p);
g_Channels[0].GetDevice(2)->DoState(p);
g_Channels[0].GetDevice(4)->DoState(p);
g_Channels[1].GetDevice(1)->DoState(p);
g_Channels[2].GetDevice(1)->DoState(p);
}
void ChangeDeviceCallback(u64 userdata, int cyclesLate)

View File

@ -82,9 +82,6 @@ private:
u32 m_DMALength;
u32 m_ImmData;
// get device
IEXIDevice* GetDevice(u8 _CHIP_SELECT);
// Devices
enum
{
@ -94,6 +91,8 @@ private:
IEXIDevice* m_pDevices[NUM_DEVICES];
public:
// get device
IEXIDevice* GetDevice(u8 _CHIP_SELECT);
// channelId for debugging
u32 m_ChannelId;

View File

@ -74,24 +74,6 @@ void IEXIDevice::DMARead(u32 _uAddr, u32 _uSize)
}
};
bool IEXIDevice::IsPresent()
{
return false;
}
void IEXIDevice::Update()
{
}
bool IEXIDevice::IsInterruptSet()
{
return false;
}
void IEXIDevice::SetCS(int _iCS)
{
}
//////////////////////////////////////////////////////////////////////////
// --- class CEXIDummy ---
//////////////////////////////////////////////////////////////////////////

View File

@ -19,12 +19,13 @@
#define _EXIDEVICE_H
#include "Common.h"
#include "ChunkFile.h"
class IEXIDevice
{
private:
// Byte transfer function for this device
virtual void TransferByte(u8&) {};
virtual void TransferByte(u8&) {}
public:
// Immediate copy functions
@ -35,16 +36,16 @@ public:
virtual void DMAWrite(u32 _uAddr, u32 _uSize);
virtual void DMARead (u32 _uAddr, u32 _uSize);
virtual bool IsPresent();
virtual void SetCS(int _iCS);
virtual bool IsPresent() {return false;}
virtual void SetCS(int) {}
virtual void DoState(PointerWrap&) {}
// Update
virtual void Update();
virtual void Update() {}
// Is generating interrupt ?
virtual bool IsInterruptSet();
virtual bool IsInterruptSet() {return false;}
virtual ~IEXIDevice() {};
};
enum TEXIDevices

View File

@ -120,6 +120,12 @@ CEXIIPL::~CEXIIPL()
fclose(file);
}
}
void CEXIIPL::DoState(PointerWrap &p)
{
// commented out to not break current savestates
// TODO: uncomment when adding the next savestate change
//p.DoArray(m_RTC, 4);
}
void CEXIIPL::LoadFileToIPL(const char* filename, u32 offset)
{
@ -164,7 +170,7 @@ void CEXIIPL::TransferByte(u8& _uByte)
if (m_uPosition < 4)
{
m_uAddress <<= 8;
m_uAddress |= _uByte;
m_uAddress |= _uByte;
m_uRWOffset = 0;
_uByte = 0xFF;
@ -296,7 +302,7 @@ void CEXIIPL::TransferByte(u8& _uByte)
}
m_uRWOffset++;
}
m_uPosition++;
m_uPosition++;
}
u32 CEXIIPL::GetGCTime()
@ -307,7 +313,7 @@ u32 CEXIIPL::GetGCTime()
// (mb2): I think we can get rid of the IPL bias.
// I know, it's another hack so I let the previous code for a while.
#if 0
// Get SRAM bias
// Get SRAM bias
u32 Bias;
for (int i=0; i<4; i++)
@ -315,7 +321,7 @@ u32 CEXIIPL::GetGCTime()
((u8*)&Bias)[i] = sram_dump[0xc + (i^3)];
}
// Get the time ...
// Get the time ...
u64 ltime = Common::Timer::GetTimeSinceJan1970();
return ((u32)ltime - cJanuary2000 - Bias);
#else

View File

@ -28,7 +28,8 @@ public:
virtual ~CEXIIPL();
virtual void SetCS(int _iCS);
bool IsPresent();
static u32 GetGCTime();
static u32 GetGCTime();
void DoState(PointerWrap &p);
private:

View File

@ -21,6 +21,8 @@
#include "../Core.h"
#include "../CoreTiming.h"
#include "../ConfigManager.h"
#include "EXI.h"
#include "EXI_Device.h"
#include "EXI_DeviceMemoryCard.h"
@ -179,7 +181,6 @@ CEXIMemoryCard::~CEXIMemoryCard()
bool CEXIMemoryCard::IsPresent()
{
//return false;
return true;
}
@ -419,3 +420,11 @@ void CEXIMemoryCard::TransferByte(u8 &byte)
m_uPosition++;
DEBUG_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: < %02x", byte);
}
void CEXIMemoryCard::DoState(PointerWrap &p)
{
int slot = 0;
if (GetFileName() == SConfig::GetInstance().m_strMemoryCardA)
slot = 1;
ExpansionInterface::ChangeDevice(slot, slot ? EXIDEVICE_MEMORYCARD_B : EXIDEVICE_MEMORYCARD_A, 0);
}

View File

@ -38,6 +38,7 @@ public:
void Update();
bool IsInterruptSet();
bool IsPresent();
void DoState(PointerWrap &p);
inline const std::string &GetFileName() const { return m_strFilename; };

View File

@ -595,7 +595,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
memoryCard[slot]->DEntry_GameCode(index,tempC);
memoryCard[slot]->DEntry_FileName(index,tempC2);
sprintf(tempC, "%s_%s.gci", tempC, tempC2);
wxString temp = wxFileSelector(wxT("Export save as.."), wxString::FromAscii(DefaultIOPath.c_str()),
wxString fileName = wxFileSelector(wxT("Export save as.."), wxString::FromAscii(DefaultIOPath.c_str()),
wxString::FromAscii(tempC), wxT(".gci"), wxString::Format
(
wxT("Native GCI files (*.gci)|*.gci|")
@ -606,12 +606,11 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
),
wxFD_OVERWRITE_PROMPT|wxFD_SAVE);
if (temp.length() > 0)
if (fileName.length() > 0)
{
const char * fileName = temp.mb_str();
if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, fileName, NULL), -1))
if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, fileName.mb_str(), NULL), -1))
{
File::Delete(temp.mb_str());
File::Delete(fileName.mb_str());
}
}
}