diff --git a/src/Config.cpp b/src/Config.cpp
index 23ed2659..2e855f11 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -31,15 +31,15 @@ const char* kConfigFile = "melonDS.ini";
char BIOS9Path[1024];
char BIOS7Path[1024];
char FirmwarePath[1024];
-int DLDIEnable;
-char DLDISDPath[1024];
+//int DLDIEnable;
+//char DLDISDPath[1024];
char DSiBIOS9Path[1024];
char DSiBIOS7Path[1024];
char DSiFirmwarePath[1024];
char DSiNANDPath[1024];
-int DSiSDEnable;
-char DSiSDPath[1024];
+//int DSiSDEnable;
+//char DSiSDPath[1024];
int RandomizeMAC;
int AudioBitrate;
@@ -57,15 +57,15 @@ ConfigEntry ConfigFile[] =
{"BIOS9Path", 1, BIOS9Path, 0, "", 1023},
{"BIOS7Path", 1, BIOS7Path, 0, "", 1023},
{"FirmwarePath", 1, FirmwarePath, 0, "", 1023},
- {"DLDIEnable", 0, &DLDIEnable, 0, NULL, 0},
- {"DLDISDPath", 1, DLDISDPath, 0, "", 1023},
+ //{"DLDIEnable", 0, &DLDIEnable, 0, NULL, 0},
+ //{"DLDISDPath", 1, DLDISDPath, 0, "", 1023},
{"DSiBIOS9Path", 1, DSiBIOS9Path, 0, "", 1023},
{"DSiBIOS7Path", 1, DSiBIOS7Path, 0, "", 1023},
{"DSiFirmwarePath", 1, DSiFirmwarePath, 0, "", 1023},
{"DSiNANDPath", 1, DSiNANDPath, 0, "", 1023},
- {"DSiSDEnable", 0, &DSiSDEnable, 0, NULL, 0},
- {"DSiSDPath", 1, DSiSDPath, 0, "", 1023},
+ //{"DSiSDEnable", 0, &DSiSDEnable, 0, NULL, 0},
+ //{"DSiSDPath", 1, DSiSDPath, 0, "", 1023},
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
{"AudioBitrate", 0, &AudioBitrate, 0, NULL, 0},
diff --git a/src/Config.h b/src/Config.h
index a0c7ea80..33b6733f 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -44,15 +44,15 @@ void Save();
extern char BIOS9Path[1024];
extern char BIOS7Path[1024];
extern char FirmwarePath[1024];
-extern int DLDIEnable;
-extern char DLDISDPath[1024];
+//extern int DLDIEnable;
+//extern char DLDISDPath[1024];
extern char DSiBIOS9Path[1024];
extern char DSiBIOS7Path[1024];
extern char DSiFirmwarePath[1024];
extern char DSiNANDPath[1024];
-extern int DSiSDEnable;
-extern char DSiSDPath[1024];
+//extern int DSiSDEnable;
+//extern char DSiSDPath[1024];
extern int RandomizeMAC;
extern int AudioBitrate;
diff --git a/src/DSi_SD.cpp b/src/DSi_SD.cpp
index 121d57b2..1de6075f 100644
--- a/src/DSi_SD.cpp
+++ b/src/DSi_SD.cpp
@@ -112,13 +112,13 @@ void DSi_SDHost::Reset()
DSi_MMCStorage* sd;
DSi_MMCStorage* mmc;
- if (Config::DSiSDEnable)
+ /*if (Config::DSiSDEnable)
{
sd = new DSi_MMCStorage(this, false, DSi::SDIOFile);
u8 sd_cid[16] = {0xBD, 0x12, 0x34, 0x56, 0x78, 0x03, 0x4D, 0x30, 0x30, 0x46, 0x50, 0x41, 0x00, 0x00, 0x15, 0x00};
sd->SetCID(sd_cid);
}
- else
+ else*/
sd = nullptr;
mmc = new DSi_MMCStorage(this, true, DSi::SDMMCFile);
diff --git a/src/FATStorage.cpp b/src/FATStorage.cpp
index e646ee6c..f55f5334 100644
--- a/src/FATStorage.cpp
+++ b/src/FATStorage.cpp
@@ -31,6 +31,8 @@ FATStorage::FATStorage()
//bool res = Build("dldi", 0x20000000, "melonDLDI.bin");
bool res = Build("dldi", 0x3F000000, "melonDLDI.bin");
printf("FATStorage result: %d\n", res);
+
+ File = nullptr;
}
FATStorage::~FATStorage()
@@ -40,31 +42,70 @@ FATStorage::~FATStorage()
}
+bool FATStorage::Open()
+{
+ File = Platform::OpenLocalFile(FilePath.c_str(), "r+b");
+ if (!File)
+ {
+ File = nullptr;
+ return false;
+ }
+}
+
+void FATStorage::Close()
+{
+ if (File) fclose(File);
+ File = nullptr;
+}
+
+
+u32 FATStorage::ReadSectors(u32 start, u32 num, u8* data)
+{
+ return ReadSectorsInternal(File, FileSize, start, num, data);
+}
+
+u32 FATStorage::WriteSectors(u32 start, u32 num, u8* data)
+{
+ return WriteSectorsInternal(File, FileSize, start, num, data);
+}
+
+
FILE* FATStorage::FF_File;
u64 FATStorage::FF_FileSize;
UINT FATStorage::FF_ReadStorage(BYTE* buf, LBA_t sector, UINT num)
{
- if (!FF_File) return 0;
+ return ReadSectorsInternal(FF_File, FF_FileSize, sector, num, buf);
+}
- u64 addr = sector * 0x200ULL;
+UINT FATStorage::FF_WriteStorage(BYTE* buf, LBA_t sector, UINT num)
+{
+ return WriteSectorsInternal(FF_File, FF_FileSize, sector, num, buf);
+}
+
+
+u32 FATStorage::ReadSectorsInternal(FILE* file, u64 filelen, u32 start, u32 num, u8* data)
+{
+ if (!file) return 0;
+
+ u64 addr = start * 0x200ULL;
u32 len = num * 0x200;
- if ((addr+len) > FF_FileSize)
+ if ((addr+len) > filelen)
{
- if (addr >= FF_FileSize) return 0;
- len = FF_FileSize - addr;
+ if (addr >= filelen) return 0;
+ len = filelen - addr;
num = len >> 9;
}
- fseek(FF_File, addr, SEEK_SET);
+ fseek(file, addr, SEEK_SET);
- u32 res = fread(buf, 0x200, num, FF_File);
+ u32 res = fread(data, 0x200, num, file);
if (res < num)
{
- if (feof(FF_File))
+ if (feof(file))
{
- memset(&buf[0x200*res], 0, 0x200*(num-res));
+ memset(&data[0x200*res], 0, 0x200*(num-res));
return num;
}
}
@@ -72,23 +113,23 @@ UINT FATStorage::FF_ReadStorage(BYTE* buf, LBA_t sector, UINT num)
return res;
}
-UINT FATStorage::FF_WriteStorage(BYTE* buf, LBA_t sector, UINT num)
+u32 FATStorage::WriteSectorsInternal(FILE* file, u64 filelen, u32 start, u32 num, u8* data)
{
- if (!FF_File) return 0;
+ if (!file) return 0;
- u64 addr = sector * 0x200ULL;
+ u64 addr = start * 0x200ULL;
u32 len = num * 0x200;
- if ((addr+len) > FF_FileSize)
+ if ((addr+len) > filelen)
{
- if (addr >= FF_FileSize) return 0;
- len = FF_FileSize - addr;
+ if (addr >= filelen) return 0;
+ len = filelen - addr;
num = len >> 9;
}
- fseek(FF_File, addr, SEEK_SET);
+ fseek(file, addr, SEEK_SET);
- u32 res = fwrite(buf, 0x200, num, FF_File);
+ u32 res = fwrite(data, 0x200, num, file);
return res;
}
diff --git a/src/FATStorage.h b/src/FATStorage.h
index 4d664376..e0f0faea 100644
--- a/src/FATStorage.h
+++ b/src/FATStorage.h
@@ -34,6 +34,12 @@ public:
FATStorage();
~FATStorage();
+ bool Open();
+ void Close();
+
+ u32 ReadSectors(u32 start, u32 num, u8* data);
+ u32 WriteSectors(u32 start, u32 num, u8* data);
+
private:
std::string FilePath;
std::string IndexPath;
@@ -46,6 +52,9 @@ private:
static UINT FF_ReadStorage(BYTE* buf, LBA_t sector, UINT num);
static UINT FF_WriteStorage(BYTE* buf, LBA_t sector, UINT num);
+ static u32 ReadSectorsInternal(FILE* file, u64 filelen, u32 start, u32 num, u8* data);
+ static u32 WriteSectorsInternal(FILE* file, u64 filelen, u32 start, u32 num, u8* data);
+
void LoadIndex();
void SaveIndex();
diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp
index 33ec5bf2..f15af659 100644
--- a/src/NDSCart.cpp
+++ b/src/NDSCart.cpp
@@ -1164,23 +1164,23 @@ u8 CartRetailBT::SPIWrite(u8 val, u32 pos, bool last)
CartHomebrew::CartHomebrew(u8* rom, u32 len, u32 chipid) : CartCommon(rom, len, chipid)
{
- test = nullptr;
- if (Config::DLDIEnable)
+ //if (Config::DLDIEnable)
+ if (true)
{
- ApplyDLDIPatch(melonDLDI, sizeof(melonDLDI));
- test = new FATStorage();
- SDFile = Platform::OpenLocalFile(/*Config::DLDISDPath*/"melonDLDI.bin", "r+b");
+ ApplyDLDIPatch(melonDLDI, sizeof(melonDLDI), true);
+ SD = new FATStorage();
+ SD->Open();
}
else
- SDFile = nullptr;
+ SD = nullptr;
}
CartHomebrew::~CartHomebrew()
{
- if (SDFile) fclose(SDFile);
- if (test)
+ if (SD)
{
- delete test;
+ SD->Close();
+ delete SD;
}
}
@@ -1188,12 +1188,7 @@ void CartHomebrew::Reset()
{
CartCommon::Reset();
- if (SDFile) fclose(SDFile);
-
- if (Config::DLDIEnable)
- SDFile = Platform::OpenLocalFile(/*Config::DLDISDPath*/"melonDLDI.bin", "r+b");
- else
- SDFile = nullptr;
+ // TODO??? something about the FATStorage thing?
}
void CartHomebrew::DoSavestate(Savestate* file)
@@ -1226,13 +1221,7 @@ int CartHomebrew::ROMCommandStart(u8* cmd, u8* data, u32 len)
case 0xC0: // SD read
{
u32 sector = (cmd[1]<<24) | (cmd[2]<<16) | (cmd[3]<<8) | cmd[4];
- u64 addr = sector * 0x200ULL;
-//printf("SD READ: %08X, %p\n", sector, SDFile);
- if (SDFile)
- {
- fseek(SDFile, addr, SEEK_SET);
- fread(data, len, 1, SDFile);
- }
+ if (SD) SD->ReadSectors(sector, len>>9, data);
}
return 0;
@@ -1255,13 +1244,7 @@ void CartHomebrew::ROMCommandFinish(u8* cmd, u8* data, u32 len)
case 0xC1:
{
u32 sector = (cmd[1]<<24) | (cmd[2]<<16) | (cmd[3]<<8) | cmd[4];
- u64 addr = sector * 0x200ULL;
-
- if (SDFile)
- {
- fseek(SDFile, addr, SEEK_SET);
- fwrite(data, len, 1, SDFile);
- }
+ if (SD && true) SD->WriteSectors(sector, len>>9, data);
}
break;
@@ -1270,7 +1253,7 @@ void CartHomebrew::ROMCommandFinish(u8* cmd, u8* data, u32 len)
}
}
-void CartHomebrew::ApplyDLDIPatch(const u8* patch, u32 patchlen)
+void CartHomebrew::ApplyDLDIPatch(const u8* patch, u32 patchlen, bool readonly)
{
u32 offset = *(u32*)&ROM[0x20];
u32 size = *(u32*)&ROM[0x2C];
@@ -1387,6 +1370,19 @@ void CartHomebrew::ApplyDLDIPatch(const u8* patch, u32 patchlen)
memset(&binary[dldioffset+fixstart], 0, fixend-fixstart);
}
+ if (readonly)
+ {
+ // clear the can-write feature flag
+ binary[dldioffset+0x64] &= ~0x02;
+
+ // make writeSectors() return failure
+ u32 writesec_addr = *(u32*)&binary[dldioffset+0x74];
+ writesec_addr -= memaddr;
+ writesec_addr += dldioffset;
+ *(u32*)&binary[writesec_addr+0x00] = 0xE3A00000; // mov r0, #0
+ *(u32*)&binary[writesec_addr+0x04] = 0xE12FFF1E; // bx lr
+ }
+
printf("applied DLDI patch\n");
}
diff --git a/src/NDSCart.h b/src/NDSCart.h
index ef3601ec..63d2c0e3 100644
--- a/src/NDSCart.h
+++ b/src/NDSCart.h
@@ -179,11 +179,10 @@ public:
void ROMCommandFinish(u8* cmd, u8* data, u32 len) override;
private:
- void ApplyDLDIPatch(const u8* patch, u32 len);
+ void ApplyDLDIPatch(const u8* patch, u32 patchlen, bool readonly);
void ReadROM_B7(u32 addr, u32 len, u8* data, u32 offset);
- FILE* SDFile;
- FATStorage* test;
+ FATStorage* SD;
};
extern u16 SPICnt;
diff --git a/src/frontend/Util_ROM.cpp b/src/frontend/Util_ROM.cpp
index 19023fbf..d35ab866 100644
--- a/src/frontend/Util_ROM.cpp
+++ b/src/frontend/Util_ROM.cpp
@@ -220,14 +220,14 @@ int SetupDSiNAND()
DSi::SDMMCFile = f;
- if (Config::DSiSDEnable)
+ /*if (Config::DSiSDEnable)
{
f = Platform::OpenLocalFile(Config::DSiSDPath, "r+b");
if (f)
DSi::SDIOFile = f;
else
DSi::SDIOFile = Platform::OpenLocalFile(Config::DSiSDPath, "w+b");
- }
+ }*/
return Load_OK;
}
@@ -507,7 +507,7 @@ void AnimatedROMIcon(u8 (&data)[8][512], u16 (&palette)[8][16], u16 (&sequence)[
{
for (int x = 0; x < 32; x++)
{
- for (int y = 0; y < 32/2; y++)
+ for (int y = 0; y < 32/2; y++)
{
std::swap(frame[x * 32 + y], frame[x * 32 + (32 - 1 - y)]);
}
@@ -517,7 +517,7 @@ void AnimatedROMIcon(u8 (&data)[8][512], u16 (&palette)[8][16], u16 (&sequence)[
{
for (int x = 0; x < 32/2; x++)
{
- for (int y = 0; y < 32; y++)
+ for (int y = 0; y < 32; y++)
{
std::swap(frame[x * 32 + y], frame[(32 - 1 - x) * 32 + y]);
}
diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.cpp b/src/frontend/qt_sdl/EmuSettingsDialog.cpp
index dd8ec1e5..58de03b5 100644
--- a/src/frontend/qt_sdl/EmuSettingsDialog.cpp
+++ b/src/frontend/qt_sdl/EmuSettingsDialog.cpp
@@ -44,15 +44,11 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
ui->txtBIOS9Path->setText(Config::BIOS9Path);
ui->txtBIOS7Path->setText(Config::BIOS7Path);
ui->txtFirmwarePath->setText(Config::FirmwarePath);
- ui->cbDLDIEnable->setChecked(Config::DLDIEnable != 0);
- ui->txtDLDISDPath->setText(Config::DLDISDPath);
ui->txtDSiBIOS9Path->setText(Config::DSiBIOS9Path);
ui->txtDSiBIOS7Path->setText(Config::DSiBIOS7Path);
ui->txtDSiFirmwarePath->setText(Config::DSiFirmwarePath);
ui->txtDSiNANDPath->setText(Config::DSiNANDPath);
- ui->cbDSiSDEnable->setChecked(Config::DSiSDEnable != 0);
- ui->txtDSiSDPath->setText(Config::DSiSDPath);
ui->cbxConsoleType->addItem("DS");
ui->cbxConsoleType->addItem("DSi (experimental)");
@@ -78,6 +74,45 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
#endif
on_chkEnableJIT_toggled();
+
+ const int imgsizes[] = {256, 512, 1024, 2048, 4096, 0};
+
+ ui->cbxDLDISize->addItem("Auto");
+ ui->cbxDSiSDSize->addItem("Auto");
+
+ for (int i = 0; imgsizes[i] != 0; i++)
+ {
+ int sizedisp = imgsizes[i];
+ QString sizelbl;
+ if (sizedisp >= 1024)
+ {
+ sizedisp >>= 10;
+ sizelbl = QString("%1 GB").arg(sizedisp);
+ }
+ else
+ {
+ sizelbl = QString("%1 MB").arg(sizedisp);
+ }
+
+ ui->cbxDLDISize->addItem(sizelbl);
+ ui->cbxDSiSDSize->addItem(sizelbl);
+ }
+
+ ui->cbDLDIEnable->setChecked(Config::DLDIEnable != 0);
+ ui->txtDLDISDPath->setText(Config::DLDISDPath);
+ ui->cbxDLDISize->setCurrentIndex(Config::DLDISize);
+ ui->cbDLDIReadOnly->setChecked(Config::DLDIReadOnly != 0);
+ ui->cbDLDIFolder->setChecked(Config::DLDIFolderSync != 0);
+ ui->txtDLDIFolder->setText(Config::DLDIFolderPath);
+ on_cbDLDIEnable_toggled();
+
+ ui->cbDSiSDEnable->setChecked(Config::DSiSDEnable != 0);
+ ui->txtDSiSDPath->setText(Config::DSiSDPath);
+ ui->cbxDSiSDSize->setCurrentIndex(Config::DSiSDSize);
+ ui->cbDSiSDReadOnly->setChecked(Config::DSiSDReadOnly != 0);
+ ui->cbDSiSDFolder->setChecked(Config::DSiSDFolderSync != 0);
+ ui->txtDSiSDFolder->setText(Config::DSiSDFolderPath);
+ on_cbDSiSDEnable_toggled();
}
EmuSettingsDialog::~EmuSettingsDialog()
@@ -148,14 +183,25 @@ void EmuSettingsDialog::done(int r)
std::string bios9Path = ui->txtBIOS9Path->text().toStdString();
std::string bios7Path = ui->txtBIOS7Path->text().toStdString();
std::string firmwarePath = ui->txtFirmwarePath->text().toStdString();
+
int dldiEnable = ui->cbDLDIEnable->isChecked() ? 1:0;
std::string dldiSDPath = ui->txtDLDISDPath->text().toStdString();
+ int dldiSize = ui->cbxDLDISize->currentIndex();
+ int dldiReadOnly = ui->cbDLDIReadOnly->isChecked() ? 1:0;
+ int dldiFolderSync = ui->cbDLDIFolder->isChecked() ? 1:0;
+ std::string dldiFolderPath = ui->txtDLDIFolder->text().toStdString();
+
std::string dsiBios9Path = ui->txtDSiBIOS9Path->text().toStdString();
std::string dsiBios7Path = ui->txtDSiBIOS7Path->text().toStdString();
std::string dsiFirmwarePath = ui->txtDSiFirmwarePath->text().toStdString();
std::string dsiNANDPath = ui->txtDSiNANDPath->text().toStdString();
+
int dsiSDEnable = ui->cbDSiSDEnable->isChecked() ? 1:0;
std::string dsiSDPath = ui->txtDSiSDPath->text().toStdString();
+ int dsiSDSize = ui->cbxDSiSDSize->currentIndex();
+ int dsiSDReadOnly = ui->cbDSiSDReadOnly->isChecked() ? 1:0;
+ int dsiSDFolderSync = ui->cbDSiSDFolder->isChecked() ? 1:0;
+ std::string dsiSDFolderPath = ui->txtDSiSDFolder->text().toStdString();
if (consoleType != Config::ConsoleType
|| directBoot != Config::DirectBoot
@@ -171,12 +217,20 @@ void EmuSettingsDialog::done(int r)
|| strcmp(Config::FirmwarePath, firmwarePath.c_str()) != 0
|| dldiEnable != Config::DLDIEnable
|| strcmp(Config::DLDISDPath, dldiSDPath.c_str()) != 0
+ || dldiSize != Config::DLDISize
+ || dldiReadOnly != Config::DLDIReadOnly
+ || dldiFolderSync != Config::DLDIFolderSync
+ || strcmp(Config::DLDIFolderPath, dldiFolderPath.c_str()) != 0
|| strcmp(Config::DSiBIOS9Path, dsiBios9Path.c_str()) != 0
|| strcmp(Config::DSiBIOS7Path, dsiBios7Path.c_str()) != 0
|| strcmp(Config::DSiFirmwarePath, dsiFirmwarePath.c_str()) != 0
|| strcmp(Config::DSiNANDPath, dsiNANDPath.c_str()) != 0
|| dsiSDEnable != Config::DSiSDEnable
- || strcmp(Config::DSiSDPath, dsiSDPath.c_str()) != 0)
+ || strcmp(Config::DSiSDPath, dsiSDPath.c_str()) != 0
+ || dsiSDSize != Config::DSiSDSize
+ || dsiSDReadOnly != Config::DSiSDReadOnly
+ || dsiSDFolderSync != Config::DSiSDFolderSync
+ || strcmp(Config::DSiSDFolderPath, dsiSDFolderPath.c_str()) != 0)
{
if (RunningSomething
&& QMessageBox::warning(this, "Reset necessary to apply changes",
@@ -187,15 +241,25 @@ void EmuSettingsDialog::done(int r)
strncpy(Config::BIOS9Path, bios9Path.c_str(), 1023); Config::BIOS9Path[1023] = '\0';
strncpy(Config::BIOS7Path, bios7Path.c_str(), 1023); Config::BIOS7Path[1023] = '\0';
strncpy(Config::FirmwarePath, firmwarePath.c_str(), 1023); Config::FirmwarePath[1023] = '\0';
+
Config::DLDIEnable = dldiEnable;
strncpy(Config::DLDISDPath, dldiSDPath.c_str(), 1023); Config::DLDISDPath[1023] = '\0';
+ Config::DLDISize = dldiSize;
+ Config::DLDIReadOnly = dldiReadOnly;
+ Config::DLDIFolderSync = dldiFolderSync;
+ strncpy(Config::DLDIFolderPath, dldiFolderPath.c_str(), 1023); Config::DLDIFolderPath[1023] = '\0';
strncpy(Config::DSiBIOS9Path, dsiBios9Path.c_str(), 1023); Config::DSiBIOS9Path[1023] = '\0';
strncpy(Config::DSiBIOS7Path, dsiBios7Path.c_str(), 1023); Config::DSiBIOS7Path[1023] = '\0';
strncpy(Config::DSiFirmwarePath, dsiFirmwarePath.c_str(), 1023); Config::DSiFirmwarePath[1023] = '\0';
strncpy(Config::DSiNANDPath, dsiNANDPath.c_str(), 1023); Config::DSiNANDPath[1023] = '\0';
+
Config::DSiSDEnable = dsiSDEnable;
strncpy(Config::DSiSDPath, dsiSDPath.c_str(), 1023); Config::DSiSDPath[1023] = '\0';
+ Config::DSiSDSize = dsiSDSize;
+ Config::DSiSDReadOnly = dsiSDReadOnly;
+ Config::DSiSDFolderSync = dsiSDFolderSync;
+ strncpy(Config::DSiSDFolderPath, dsiSDFolderPath.c_str(), 1023); Config::DSiSDFolderPath[1023] = '\0';
#ifdef JIT_ENABLED
Config::JIT_Enable = jitEnable;
@@ -279,6 +343,20 @@ void EmuSettingsDialog::on_btnDSiBIOS7Browse_clicked()
ui->txtDSiBIOS7Path->setText(file);
}
+void EmuSettingsDialog::on_cbDLDIEnable_toggled()
+{
+ bool disabled = !ui->cbDLDIEnable->isChecked();
+ ui->txtDLDISDPath->setDisabled(disabled);
+ ui->btnDLDISDBrowse->setDisabled(disabled);
+ ui->cbxDLDISize->setDisabled(disabled);
+ ui->cbDLDIReadOnly->setDisabled(disabled);
+ ui->cbDLDIFolder->setDisabled(disabled);
+
+ if (!disabled) disabled = !ui->cbDLDIFolder->isChecked();
+ ui->txtDLDIFolder->setDisabled(disabled);
+ ui->btnDLDIFolderBrowse->setDisabled(disabled);
+}
+
void EmuSettingsDialog::on_btnDLDISDBrowse_clicked()
{
QString file = QFileDialog::getOpenFileName(this,
@@ -291,6 +369,24 @@ void EmuSettingsDialog::on_btnDLDISDBrowse_clicked()
ui->txtDLDISDPath->setText(file);
}
+void EmuSettingsDialog::on_cbDLDIFolder_toggled()
+{
+ bool disabled = !ui->cbDLDIFolder->isChecked();
+ ui->txtDLDIFolder->setDisabled(disabled);
+ ui->btnDLDIFolderBrowse->setDisabled(disabled);
+}
+
+void EmuSettingsDialog::on_btnDLDIFolderBrowse_clicked()
+{
+ QString dir = QFileDialog::getExistingDirectory(this,
+ "Select DLDI SD folder...",
+ EmuDirectory);
+
+ if (dir.isEmpty()) return;
+
+ ui->txtDLDIFolder->setText(dir);
+}
+
void EmuSettingsDialog::on_btnDSiFirmwareBrowse_clicked()
{
QString file = QFileDialog::getOpenFileName(this,
@@ -315,6 +411,20 @@ void EmuSettingsDialog::on_btnDSiNANDBrowse_clicked()
ui->txtDSiNANDPath->setText(file);
}
+void EmuSettingsDialog::on_cbDSiSDEnable_toggled()
+{
+ bool disabled = !ui->cbDSiSDEnable->isChecked();
+ ui->txtDSiSDPath->setDisabled(disabled);
+ ui->btnDSiSDBrowse->setDisabled(disabled);
+ ui->cbxDSiSDSize->setDisabled(disabled);
+ ui->cbDSiSDReadOnly->setDisabled(disabled);
+ ui->cbDSiSDFolder->setDisabled(disabled);
+
+ if (!disabled) disabled = !ui->cbDSiSDFolder->isChecked();
+ ui->txtDSiSDFolder->setDisabled(disabled);
+ ui->btnDSiSDFolderBrowse->setDisabled(disabled);
+}
+
void EmuSettingsDialog::on_btnDSiSDBrowse_clicked()
{
QString file = QFileDialog::getOpenFileName(this,
@@ -327,6 +437,24 @@ void EmuSettingsDialog::on_btnDSiSDBrowse_clicked()
ui->txtDSiSDPath->setText(file);
}
+void EmuSettingsDialog::on_cbDSiSDFolder_toggled()
+{
+ bool disabled = !ui->cbDSiSDFolder->isChecked();
+ ui->txtDSiSDFolder->setDisabled(disabled);
+ ui->btnDSiSDFolderBrowse->setDisabled(disabled);
+}
+
+void EmuSettingsDialog::on_btnDSiSDFolderBrowse_clicked()
+{
+ QString dir = QFileDialog::getExistingDirectory(this,
+ "Select DSi SD folder...",
+ EmuDirectory);
+
+ if (dir.isEmpty()) return;
+
+ ui->txtDSiSDFolder->setText(dir);
+}
+
void EmuSettingsDialog::on_chkEnableJIT_toggled()
{
bool disabled = !ui->chkEnableJIT->isChecked();
diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.h b/src/frontend/qt_sdl/EmuSettingsDialog.h
index d24a9f28..c38bf569 100644
--- a/src/frontend/qt_sdl/EmuSettingsDialog.h
+++ b/src/frontend/qt_sdl/EmuSettingsDialog.h
@@ -58,13 +58,21 @@ private slots:
void on_btnBIOS9Browse_clicked();
void on_btnBIOS7Browse_clicked();
void on_btnFirmwareBrowse_clicked();
+
+ void on_cbDLDIEnable_toggled();
void on_btnDLDISDBrowse_clicked();
+ void on_cbDLDIFolder_toggled();
+ void on_btnDLDIFolderBrowse_clicked();
void on_btnDSiBIOS9Browse_clicked();
void on_btnDSiBIOS7Browse_clicked();
void on_btnDSiFirmwareBrowse_clicked();
void on_btnDSiNANDBrowse_clicked();
+
+ void on_cbDSiSDEnable_toggled();
void on_btnDSiSDBrowse_clicked();
+ void on_cbDSiSDFolder_toggled();
+ void on_btnDSiSDFolderBrowse_clicked();
void on_chkEnableJIT_toggled();
diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.ui b/src/frontend/qt_sdl/EmuSettingsDialog.ui
index e670c88d..8bf41caf 100644
--- a/src/frontend/qt_sdl/EmuSettingsDialog.ui
+++ b/src/frontend/qt_sdl/EmuSettingsDialog.ui
@@ -7,7 +7,7 @@
0
0
575
- 254
+ 351
@@ -196,6 +196,20 @@
DSi-mode
+ -
+
+
+ DSi ARM9 BIOS:
+
+
+
+ -
+
+
+ <html><head/><body><p>DSi-mode firmware (used for DS-mode backwards compatibility)</p><p><br/></p><p>Size should be 128 KB</p></body></html>
+
+
+
-
@@ -203,7 +217,52 @@
- -
+
-
+
+
+ <html><head/><body><p>Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.</p></body></html>
+
+
+ Sync SD to folder:
+
+
+
+ -
+
+
+ Browse...
+
+
+
+ -
+
+
+ <html><head/><body><p>SD image file for emulating the DSi's SD card. A blank image file will be created if it doesn't already exist.</p></body></html>
+
+
+
+ -
+
+
+ SD card image:
+
+
+
+ -
+
+
+ <html><head/><body><p>Size of the SD image.</p><p><br/></p><p>If set to Auto:</p><p>* if an image file exists, the volume size will be that of the image file</p><p>* if no image file exists and folder sync is enabled, the volume size will be determined from the synced folder's contents</p><p>* otherwise, the volume size will default to 512 MB</p></body></html>
+
+
+
+ -
+
+
+ Image size:
+
+
+
+ -
Browse...
@@ -217,24 +276,10 @@
- -
-
-
- Browse...
-
-
-
- -
-
-
- DSi ARM7 BIOS:
-
-
-
- -
-
-
- Browse...
+
-
+
+
+ <html><head/><body><p>Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.</p></body></html>
@@ -252,13 +297,6 @@
- -
-
-
- DSi SD card:
-
-
-
-
@@ -272,6 +310,16 @@
+ -
+
+
+ <html><head/><body><p>Simulate a SD card being inserted in the DSi's SD slot.</p></body></html>
+
+
+ Enable DSi SD card
+
+
+
-
@@ -279,37 +327,6 @@
- -
-
-
- DSi ARM9 BIOS:
-
-
-
- -
-
-
- <html><head/><body><p>DSi-mode firmware (used for DS-mode backwards compatibility)</p><p><br/></p><p>Size should be 128 KB</p></body></html>
-
-
-
- -
-
-
- <html><head/><body><p>SD image file for emulating the DSi's SD card</p></body></html>
-
-
-
- -
-
-
- <html><head/><body><p>Simulate a SD card being inserted in the DSi's SD slot. Requires a SD card image.</p></body></html>
-
-
- Enable DSi SD card
-
-
-
-
@@ -317,6 +334,44 @@
+ -
+
+
+ <html><head/><body><p>Make the emulated SD card read-only.</p></body></html>
+
+
+ Read-only SD
+
+
+
+ -
+
+
+ Browse...
+
+
+
+ -
+
+
+ DSi ARM7 BIOS:
+
+
+
+ -
+
+
+ Browse...
+
+
+
+ -
+
+
+
+
+
+
@@ -392,16 +447,6 @@
DLDI
- -
-
-
- <html><head/><body><p>Enable the built-in DLDI driver, to let homebrew access files from a given SD image.</p></body></html>
-
-
- Enable DLDI (for homebrew)
-
-
-
-
@@ -409,17 +454,62 @@
- -
-
-
- -
-
+
-
+
- DLDI SD card:
+ Browse...
+
+
+
+ -
+
+
+ <html><head/><body><p>Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.</p></body></html>
-
+
+
+ Image size:
+
+
+
+ -
+
+
+ <html><head/><body><p>Sync the emulated SD card to the given folder. The folder's contents will be copied to the SD image, and any change made to the SD image will be reflected to the folder.</p></body></html>
+
+
+ Sync SD to folder:
+
+
+
+ -
+
+
+ <html><head/><body><p>Size of the SD image.</p><p><br/></p><p>If set to Auto:</p><p>* if an image file exists, the volume size will be that of the image file</p><p>* if no image file exists and folder sync is enabled, the volume size will be determined from the synced folder's contents</p><p>* otherwise, the volume size will default to 512 MB</p></body></html>
+
+
+
+ -
+
+
+ <html><head/><body><p>Enable the built-in DLDI driver, to let homebrew access files from an emulated SD card.</p></body></html>
+
+
+ Enable DLDI (for homebrew)
+
+
+
+ -
+
+
+ <html><head/><body><p>SD card image file to be used for DLDI. A blank image file will be created if it doesn't already exist.</p></body></html>
+
+
+
+ -
Qt::Vertical
@@ -432,6 +522,23 @@
+ -
+
+
+ SD card image:
+
+
+
+ -
+
+
+ <html><head/><body><p>Make the emulated SD card read-only.</p></body></html>
+
+
+ Read-only SD
+
+
+
diff --git a/src/frontend/qt_sdl/PlatformConfig.cpp b/src/frontend/qt_sdl/PlatformConfig.cpp
index 40f55bae..e01e4c95 100644
--- a/src/frontend/qt_sdl/PlatformConfig.cpp
+++ b/src/frontend/qt_sdl/PlatformConfig.cpp
@@ -63,6 +63,20 @@ int ShowOSD;
int ConsoleType;
int DirectBoot;
+int DLDIEnable;
+char DLDISDPath[1024];
+int DLDISize;
+int DLDIReadOnly;
+int DLDIFolderSync;
+char DLDIFolderPath[1024];
+
+int DSiSDEnable;
+char DSiSDPath[1024];
+int DSiSDSize;
+int DSiSDReadOnly;
+int DSiSDFolderSync;
+char DSiSDFolderPath[1024];
+
int SocketBindAnyAddr;
char LANDevice[128];
int DirectLAN;
@@ -172,6 +186,20 @@ ConfigEntry PlatformConfigFile[] =
{"ConsoleType", 0, &ConsoleType, 0, NULL, 0},
{"DirectBoot", 0, &DirectBoot, 1, NULL, 0},
+ {"DLDIEnable", 0, &DLDIEnable, 0, NULL, 0},
+ {"DLDISDPath", 1, DLDISDPath, 0, "dldi.bin", 1023},
+ {"DLDISize", 0, &DLDISize, 0, NULL, 0},
+ {"DLDIReadOnly", 0, &DLDIReadOnly, 0, NULL, 0},
+ {"DLDIFolderSync", 0, &DLDIFolderSync, 0, NULL, 0},
+ {"DLDIFolderPath", 1, DLDIFolderPath, 0, "", 1023},
+
+ {"DSiSDEnable", 0, &DSiSDEnable, 0, NULL, 0},
+ {"DSiSDPath", 1, DSiSDPath, 0, "dsisd.bin", 1023},
+ {"DSiSDSize", 0, &DSiSDSize, 0, NULL, 0},
+ {"DSiSDReadOnly", 0, &DSiSDReadOnly, 0, NULL, 0},
+ {"DSiSDFolderSync", 0, &DSiSDFolderSync, 0, NULL, 0},
+ {"DSiSDFolderPath", 1, DSiSDFolderPath, 0, "", 1023},
+
{"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0},
{"LANDevice", 1, LANDevice, 0, "", 127},
{"DirectLAN", 0, &DirectLAN, 0, NULL, 0},
diff --git a/src/frontend/qt_sdl/PlatformConfig.h b/src/frontend/qt_sdl/PlatformConfig.h
index 202e36ae..3e7bf850 100644
--- a/src/frontend/qt_sdl/PlatformConfig.h
+++ b/src/frontend/qt_sdl/PlatformConfig.h
@@ -79,6 +79,20 @@ extern int ShowOSD;
extern int ConsoleType;
extern int DirectBoot;
+extern int DLDIEnable;
+extern char DLDISDPath[1024];
+extern int DLDISize;
+extern int DLDIReadOnly;
+extern int DLDIFolderSync;
+extern char DLDIFolderPath[1024];
+
+extern int DSiSDEnable;
+extern char DSiSDPath[1024];
+extern int DSiSDSize;
+extern int DSiSDReadOnly;
+extern int DSiSDFolderSync;
+extern char DSiSDFolderPath[1024];
+
extern int SocketBindAnyAddr;
extern char LANDevice[128];
extern int DirectLAN;