make it work for the DSi SD card too
This commit is contained in:
parent
8fd2aa15f3
commit
5d039c5688
|
@ -57,15 +57,11 @@ ConfigEntry ConfigFile[] =
|
||||||
{"BIOS9Path", 1, BIOS9Path, 0, "", 1023},
|
{"BIOS9Path", 1, BIOS9Path, 0, "", 1023},
|
||||||
{"BIOS7Path", 1, BIOS7Path, 0, "", 1023},
|
{"BIOS7Path", 1, BIOS7Path, 0, "", 1023},
|
||||||
{"FirmwarePath", 1, FirmwarePath, 0, "", 1023},
|
{"FirmwarePath", 1, FirmwarePath, 0, "", 1023},
|
||||||
//{"DLDIEnable", 0, &DLDIEnable, 0, NULL, 0},
|
|
||||||
//{"DLDISDPath", 1, DLDISDPath, 0, "", 1023},
|
|
||||||
|
|
||||||
{"DSiBIOS9Path", 1, DSiBIOS9Path, 0, "", 1023},
|
{"DSiBIOS9Path", 1, DSiBIOS9Path, 0, "", 1023},
|
||||||
{"DSiBIOS7Path", 1, DSiBIOS7Path, 0, "", 1023},
|
{"DSiBIOS7Path", 1, DSiBIOS7Path, 0, "", 1023},
|
||||||
{"DSiFirmwarePath", 1, DSiFirmwarePath, 0, "", 1023},
|
{"DSiFirmwarePath", 1, DSiFirmwarePath, 0, "", 1023},
|
||||||
{"DSiNANDPath", 1, DSiNANDPath, 0, "", 1023},
|
{"DSiNANDPath", 1, DSiNANDPath, 0, "", 1023},
|
||||||
//{"DSiSDEnable", 0, &DSiSDEnable, 0, NULL, 0},
|
|
||||||
//{"DSiSDPath", 1, DSiSDPath, 0, "", 1023},
|
|
||||||
|
|
||||||
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
|
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
|
||||||
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
|
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
|
||||||
|
|
|
@ -44,15 +44,11 @@ void Save();
|
||||||
extern char BIOS9Path[1024];
|
extern char BIOS9Path[1024];
|
||||||
extern char BIOS7Path[1024];
|
extern char BIOS7Path[1024];
|
||||||
extern char FirmwarePath[1024];
|
extern char FirmwarePath[1024];
|
||||||
//extern int DLDIEnable;
|
|
||||||
//extern char DLDISDPath[1024];
|
|
||||||
|
|
||||||
extern char DSiBIOS9Path[1024];
|
extern char DSiBIOS9Path[1024];
|
||||||
extern char DSiBIOS7Path[1024];
|
extern char DSiBIOS7Path[1024];
|
||||||
extern char DSiFirmwarePath[1024];
|
extern char DSiFirmwarePath[1024];
|
||||||
extern char DSiNANDPath[1024];
|
extern char DSiNANDPath[1024];
|
||||||
//extern int DSiSDEnable;
|
|
||||||
//extern char DSiSDPath[1024];
|
|
||||||
|
|
||||||
extern int RandomizeMAC;
|
extern int RandomizeMAC;
|
||||||
extern int AudioBitrate;
|
extern int AudioBitrate;
|
||||||
|
|
|
@ -112,13 +112,24 @@ void DSi_SDHost::Reset()
|
||||||
DSi_MMCStorage* sd;
|
DSi_MMCStorage* sd;
|
||||||
DSi_MMCStorage* mmc;
|
DSi_MMCStorage* mmc;
|
||||||
|
|
||||||
/*if (Config::DSiSDEnable)
|
if (Platform::GetConfigBool(Platform::DSiSD_Enable))
|
||||||
{
|
{
|
||||||
sd = new DSi_MMCStorage(this, false, DSi::SDIOFile);
|
std::string folderpath;
|
||||||
|
if (Platform::GetConfigBool(Platform::DSiSD_FolderSync))
|
||||||
|
folderpath = Platform::GetConfigString(Platform::DSiSD_FolderPath);
|
||||||
|
else
|
||||||
|
folderpath = "";
|
||||||
|
|
||||||
|
sd = new DSi_MMCStorage(this,
|
||||||
|
false,
|
||||||
|
Platform::GetConfigString(Platform::DSiSD_ImagePath),
|
||||||
|
(u64)Platform::GetConfigInt(Platform::DSiSD_ImageSize) * 1024 * 1024,
|
||||||
|
Platform::GetConfigBool(Platform::DSiSD_ReadOnly),
|
||||||
|
folderpath);
|
||||||
u8 sd_cid[16] = {0xBD, 0x12, 0x34, 0x56, 0x78, 0x03, 0x4D, 0x30, 0x30, 0x46, 0x50, 0x41, 0x00, 0x00, 0x15, 0x00};
|
u8 sd_cid[16] = {0xBD, 0x12, 0x34, 0x56, 0x78, 0x03, 0x4D, 0x30, 0x30, 0x46, 0x50, 0x41, 0x00, 0x00, 0x15, 0x00};
|
||||||
sd->SetCID(sd_cid);
|
sd->SetCID(sd_cid);
|
||||||
}
|
}
|
||||||
else*/
|
else
|
||||||
sd = nullptr;
|
sd = nullptr;
|
||||||
|
|
||||||
mmc = new DSi_MMCStorage(this, true, DSi::SDMMCFile);
|
mmc = new DSi_MMCStorage(this, true, DSi::SDMMCFile);
|
||||||
|
@ -427,7 +438,10 @@ u16 DSi_SDHost::Read(u32 addr)
|
||||||
if (!Num)
|
if (!Num)
|
||||||
{
|
{
|
||||||
if (Ports[0]) // basic check of whether the SD card is inserted
|
if (Ports[0]) // basic check of whether the SD card is inserted
|
||||||
ret |= 0x00B0;
|
{
|
||||||
|
ret |= 0x0030;
|
||||||
|
if (!Ports[0]->ReadOnly) ret |= 0x0080;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret |= 0x0008;
|
ret |= 0x0008;
|
||||||
}
|
}
|
||||||
|
@ -715,14 +729,34 @@ void DSi_SDHost::CheckSwapFIFO()
|
||||||
|
|
||||||
#define MMC_DESC (Internal?"NAND":"SDcard")
|
#define MMC_DESC (Internal?"NAND":"SDcard")
|
||||||
|
|
||||||
DSi_MMCStorage::DSi_MMCStorage(DSi_SDHost* host, bool internal, FILE* file) : DSi_SDDevice(host)
|
DSi_MMCStorage::DSi_MMCStorage(DSi_SDHost* host, bool internal, FILE* file)
|
||||||
|
: DSi_SDDevice(host)
|
||||||
{
|
{
|
||||||
Internal = internal;
|
Internal = internal;
|
||||||
File = file;
|
File = file;
|
||||||
|
SD = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
DSi_MMCStorage::DSi_MMCStorage(DSi_SDHost* host, bool internal, std::string filename, u64 size, bool readonly, std::string sourcedir)
|
||||||
|
: DSi_SDDevice(host)
|
||||||
|
{
|
||||||
|
Internal = internal;
|
||||||
|
File = nullptr;
|
||||||
|
|
||||||
|
SD = new FATStorage(filename, size, readonly, sourcedir);
|
||||||
|
SD->Open();
|
||||||
|
|
||||||
|
ReadOnly = readonly;
|
||||||
}
|
}
|
||||||
|
|
||||||
DSi_MMCStorage::~DSi_MMCStorage()
|
DSi_MMCStorage::~DSi_MMCStorage()
|
||||||
{}
|
{
|
||||||
|
if (SD)
|
||||||
|
{
|
||||||
|
SD->Close();
|
||||||
|
delete SD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DSi_MMCStorage::Reset()
|
void DSi_MMCStorage::Reset()
|
||||||
{
|
{
|
||||||
|
@ -948,13 +982,17 @@ u32 DSi_MMCStorage::ReadBlock(u64 addr)
|
||||||
len = Host->GetTransferrableLen(len);
|
len = Host->GetTransferrableLen(len);
|
||||||
|
|
||||||
u8 data[0x200];
|
u8 data[0x200];
|
||||||
if (File)
|
if (SD)
|
||||||
|
{
|
||||||
|
SD->ReadSectors((u32)(addr >> 9), 1, data);
|
||||||
|
}
|
||||||
|
else if (File)
|
||||||
{
|
{
|
||||||
fseek(File, addr, SEEK_SET);
|
fseek(File, addr, SEEK_SET);
|
||||||
fread(data, 1, len, File);
|
fread(&data[addr & 0x1FF], 1, len, File);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Host->DataRX(data, len);
|
return Host->DataRX(&data[addr & 0x1FF], len);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 DSi_MMCStorage::WriteBlock(u64 addr)
|
u32 DSi_MMCStorage::WriteBlock(u64 addr)
|
||||||
|
@ -963,12 +1001,26 @@ u32 DSi_MMCStorage::WriteBlock(u64 addr)
|
||||||
len = Host->GetTransferrableLen(len);
|
len = Host->GetTransferrableLen(len);
|
||||||
|
|
||||||
u8 data[0x200];
|
u8 data[0x200];
|
||||||
if ((len = Host->DataTX(data, len)))
|
if (len < 0x200)
|
||||||
{
|
{
|
||||||
if (File)
|
if (SD)
|
||||||
|
{
|
||||||
|
SD->ReadSectors((u32)(addr >> 9), 1, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((len = Host->DataTX(&data[addr & 0x1FF], len)))
|
||||||
|
{
|
||||||
|
if (!ReadOnly)
|
||||||
|
{
|
||||||
|
if (SD)
|
||||||
|
{
|
||||||
|
SD->WriteSectors((u32)(addr >> 9), 1, data);
|
||||||
|
}
|
||||||
|
else if (File)
|
||||||
{
|
{
|
||||||
fseek(File, addr, SEEK_SET);
|
fseek(File, addr, SEEK_SET);
|
||||||
fwrite(data, 1, len, File);
|
fwrite(&data[addr & 0x1FF], 1, len, File);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "FIFO.h"
|
#include "FIFO.h"
|
||||||
|
#include "FATStorage.h"
|
||||||
|
|
||||||
|
|
||||||
class DSi_SDDevice;
|
class DSi_SDDevice;
|
||||||
|
@ -102,7 +103,7 @@ private:
|
||||||
class DSi_SDDevice
|
class DSi_SDDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DSi_SDDevice(DSi_SDHost* host) { Host = host; IRQ = false; }
|
DSi_SDDevice(DSi_SDHost* host) { Host = host; IRQ = false; ReadOnly = false; }
|
||||||
virtual ~DSi_SDDevice() {}
|
virtual ~DSi_SDDevice() {}
|
||||||
|
|
||||||
virtual void Reset() = 0;
|
virtual void Reset() = 0;
|
||||||
|
@ -111,6 +112,7 @@ public:
|
||||||
virtual void ContinueTransfer() = 0;
|
virtual void ContinueTransfer() = 0;
|
||||||
|
|
||||||
bool IRQ;
|
bool IRQ;
|
||||||
|
bool ReadOnly;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DSi_SDHost* Host;
|
DSi_SDHost* Host;
|
||||||
|
@ -121,6 +123,7 @@ class DSi_MMCStorage : public DSi_SDDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DSi_MMCStorage(DSi_SDHost* host, bool internal, FILE* file);
|
DSi_MMCStorage(DSi_SDHost* host, bool internal, FILE* file);
|
||||||
|
DSi_MMCStorage(DSi_SDHost* host, bool internal, std::string filename, u64 size, bool readonly, std::string sourcedir);
|
||||||
~DSi_MMCStorage();
|
~DSi_MMCStorage();
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
@ -135,6 +138,7 @@ public:
|
||||||
private:
|
private:
|
||||||
bool Internal;
|
bool Internal;
|
||||||
FILE* File;
|
FILE* File;
|
||||||
|
FATStorage* SD;
|
||||||
|
|
||||||
u8 CID[16];
|
u8 CID[16];
|
||||||
u8 CSD[16];
|
u8 CSD[16];
|
||||||
|
|
Loading…
Reference in New Issue