diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index 149082c6bb..a1021c6aaa 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -1,7 +1,7 @@ + + + + diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index 6b3551d99c..f385d24caf 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -28,6 +28,7 @@ files = [ "PluginWiimote.cpp", "PluginVideo.cpp", "PluginPAD.cpp", + "SDCardUtil.cpp", "StringUtil.cpp", "Thread.cpp", "Thunk.cpp", diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 545c87efa9..bb77e49e96 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -1,7 +1,7 @@ - - - - - - - - - -namespace SDInterface -{ - bool IsCardInserted(); - void SetSourceType(bool isDumpFile); - void SetSourcePath(const std::string path); -} - -#endif - diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp index 10f7876e3e..4bf6cc2513 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp @@ -17,15 +17,14 @@ #include "Common.h" +#include "SDCardUtil.h" + #include "WII_IPC_HLE_Device_sdio_slot0.h" #include "../HW/CPU.h" #include "../HW/Memmap.h" -#include "HW/SDInterface.h" #include "../Core.h" -using namespace SDInterface; - CWII_IPC_HLE_Device_sdio_slot0::CWII_IPC_HLE_Device_sdio_slot0(u32 _DeviceID, const std::string& _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) { @@ -46,9 +45,21 @@ bool CWII_IPC_HLE_Device_sdio_slot0::Open(u32 _CommandAddress, u32 _Mode) { INFO_LOG(WII_IPC_SD, "Open"); - m_Card = fopen("sd.raw", "r+b"); + char filename[16] = "sd.raw"; + m_Card = fopen(filename, "r+b"); if(!m_Card) - ERROR_LOG(WII_IPC_SD, "Failed to open SD Card image"); + { + WARN_LOG(WII_IPC_SD, "Failed to open SD Card image, trying to create a new 128MB image..."); + if (SDCardCreate(128, filename)) + { + WARN_LOG(WII_IPC_SD, "Successfully created %s", filename); + m_Card = fopen(filename, "r+b"); + } + if(!m_Card) + { + ERROR_LOG(WII_IPC_SD, "Could not open SD Card image or create a new one, are you running from a read-only directory?"); + } + } Memory::Write_U32(GetDeviceID(), _CommandAddress + 0x4); return true; @@ -58,7 +69,8 @@ bool CWII_IPC_HLE_Device_sdio_slot0::Close(u32 _CommandAddress) { INFO_LOG(WII_IPC_SD, "Close"); - fclose(m_Card); + if(m_Card) + fclose(m_Card); Memory::Write_U32(0, _CommandAddress + 0x4); return true; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h index bceb55fe81..01bcd6a92b 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h @@ -15,7 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -// PRELIMINARY - doesn't work yet +// PRELIMINARY - seems to fully work with libogc, writing has yet to be tested #ifndef _WII_IPC_HLE_DEVICE_SDIO_SLOT0_H_ #define _WII_IPC_HLE_DEVICE_SDIO_SLOT0_H_ diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index cd894f7b6d..2011b8cb26 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -59,7 +59,6 @@ files = ["ActionReplay.cpp", "HW/VideoInterface.cpp", "HW/WII_IOB.cpp", "HW/WII_IPC.cpp", - "IPC_HLE/HW/SDInterface.cpp", "IPC_HLE/WII_IPC_HLE.cpp", "IPC_HLE/WII_IPC_HLE_Device_DI.cpp", "IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp",