From 86e585a66ad3b3120fb47626d25cee39bf82eda9 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 16 Aug 2009 08:26:57 +0000 Subject: [PATCH] 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 --- Source/Core/Core/Src/HW/EXI.cpp | 7 ++++++- Source/Core/Core/Src/HW/EXI_Channel.h | 5 ++--- Source/Core/Core/Src/HW/EXI_Device.cpp | 18 ------------------ Source/Core/Core/Src/HW/EXI_Device.h | 13 +++++++------ Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp | 14 ++++++++++---- Source/Core/Core/Src/HW/EXI_DeviceIPL.h | 3 ++- .../Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp | 11 ++++++++++- Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.h | 1 + Source/Core/DolphinWX/Src/MemcardManager.cpp | 9 ++++----- 9 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Source/Core/Core/Src/HW/EXI.cpp b/Source/Core/Core/Src/HW/EXI.cpp index acbc77bc42..b1f936d290 100644 --- a/Source/Core/Core/Src/HW/EXI.cpp +++ b/Source/Core/Core/Src/HW/EXI.cpp @@ -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) diff --git a/Source/Core/Core/Src/HW/EXI_Channel.h b/Source/Core/Core/Src/HW/EXI_Channel.h index ff336197d8..bf77907d22 100644 --- a/Source/Core/Core/Src/HW/EXI_Channel.h +++ b/Source/Core/Core/Src/HW/EXI_Channel.h @@ -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; diff --git a/Source/Core/Core/Src/HW/EXI_Device.cpp b/Source/Core/Core/Src/HW/EXI_Device.cpp index 714481cf50..82d9568dd6 100644 --- a/Source/Core/Core/Src/HW/EXI_Device.cpp +++ b/Source/Core/Core/Src/HW/EXI_Device.cpp @@ -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 --- ////////////////////////////////////////////////////////////////////////// diff --git a/Source/Core/Core/Src/HW/EXI_Device.h b/Source/Core/Core/Src/HW/EXI_Device.h index a2c171df1c..3a09717219 100644 --- a/Source/Core/Core/Src/HW/EXI_Device.h +++ b/Source/Core/Core/Src/HW/EXI_Device.h @@ -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 diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp index d8a777510a..04b784b25f 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp @@ -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 diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.h b/Source/Core/Core/Src/HW/EXI_DeviceIPL.h index 5d961064ae..6eb95ab34b 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.h +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.h @@ -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: diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp index 3984557839..76e97e1cfe 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp @@ -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); +} \ No newline at end of file diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.h b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.h index 4fd7be967a..46420e6616 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.h +++ b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.h @@ -38,6 +38,7 @@ public: void Update(); bool IsInterruptSet(); bool IsPresent(); + void DoState(PointerWrap &p); inline const std::string &GetFileName() const { return m_strFilename; }; diff --git a/Source/Core/DolphinWX/Src/MemcardManager.cpp b/Source/Core/DolphinWX/Src/MemcardManager.cpp index 9c2f21a582..80b3c384a2 100644 --- a/Source/Core/DolphinWX/Src/MemcardManager.cpp +++ b/Source/Core/DolphinWX/Src/MemcardManager.cpp @@ -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()); } } }