This commit is contained in:
abaresk 2024-11-11 10:50:10 -08:00 committed by GitHub
commit 659073867e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 76 additions and 12 deletions

View File

@ -266,6 +266,22 @@ void A_MRC(ARM* cpu)
void A_SVC(ARM* cpu) void A_SVC(ARM* cpu)
{ {
// Print from game. Execute `svc 0xFC` with the null-terminated string address in `r0`.
if ((cpu->CurInstr & 0xFF) == 0xFC && cpu->NDS.GetDebugPrint())
{
u32 addr = cpu->R[0];
std::string output;
for (;;)
{
u32 c;
cpu->DataRead8(addr++, &c);
if (!c) break;
output += c;
}
Platform::Log(LogLevel::Info, "%s", output.c_str());
return;
}
u32 oldcpsr = cpu->CPSR; u32 oldcpsr = cpu->CPSR;
cpu->CPSR &= ~0xBF; cpu->CPSR &= ~0xBF;
cpu->CPSR |= 0x93; cpu->CPSR |= 0x93;
@ -278,6 +294,22 @@ void A_SVC(ARM* cpu)
void T_SVC(ARM* cpu) void T_SVC(ARM* cpu)
{ {
// Print from game. Execute `svc 0xFC` with the null-terminated string address in `r0`.
if ((cpu->CurInstr & 0xFF) == 0xFC && cpu->NDS.GetDebugPrint())
{
u32 addr = cpu->R[0];
std::string output;
for (;;)
{
u32 c;
cpu->DataRead8(addr++, &c);
if (!c) break;
output += c;
}
Platform::Log(LogLevel::Info, "%s", output.c_str());
return;
}
u32 oldcpsr = cpu->CPSR; u32 oldcpsr = cpu->CPSR;
cpu->CPSR &= ~0xBF; cpu->CPSR &= ~0xBF;
cpu->CPSR |= 0x93; cpu->CPSR |= 0x93;

View File

@ -752,6 +752,11 @@ void NDS::SetGBASave(const u8* savedata, u32 savelen)
} }
void NDS::SetDebugPrint(bool enabled) noexcept
{
DebugPrint = enabled;
}
void NDS::LoadGBAAddon(int type) void NDS::LoadGBAAddon(int type)
{ {
GBACartSlot.LoadAddon(UserData, type); GBACartSlot.LoadAddon(UserData, type);

View File

@ -275,6 +275,7 @@ protected:
std::array<u8, ARM7BIOSSize> ARM7BIOS; std::array<u8, ARM7BIOSSize> ARM7BIOS;
bool ARM9BIOSNative; bool ARM9BIOSNative;
bool ARM7BIOSNative; bool ARM7BIOSNative;
bool DebugPrint;
public: // TODO: Encapsulate the rest of these members public: // TODO: Encapsulate the rest of these members
u16 ARM7BIOSProt; u16 ARM7BIOSProt;
@ -384,6 +385,9 @@ public: // TODO: Encapsulate the rest of these members
u32 GetGBASaveLength() const { return GBACartSlot.GetSaveMemoryLength(); } u32 GetGBASaveLength() const { return GBACartSlot.GetSaveMemoryLength(); }
void SetGBASave(const u8* savedata, u32 savelen); void SetGBASave(const u8* savedata, u32 savelen);
bool GetDebugPrint() const { return DebugPrint; }
void SetDebugPrint(bool enabled) noexcept;
void LoadGBAAddon(int type); void LoadGBAAddon(int type);
std::unique_ptr<GBACart::CartCommon> EjectGBACart() { return GBACartSlot.EjectCart(); } std::unique_ptr<GBACart::CartCommon> EjectGBACart() { return GBACartSlot.EjectCart(); }

View File

@ -308,6 +308,8 @@ LegacyEntry LegacyFile[] =
{"DSiFullBIOSBoot", 1, "DSi.FullBIOSBoot", true}, {"DSiFullBIOSBoot", 1, "DSi.FullBIOSBoot", true},
{"DebugPrintEnabled", 1, "DS.DebugPrintEnabled", true},
#ifdef GDBSTUB_ENABLED #ifdef GDBSTUB_ENABLED
{"GdbEnabled", 1, "Gdb.Enabled", false}, {"GdbEnabled", 1, "Gdb.Enabled", false},
{"GdbPortARM7", 0, "Gdb.ARM7.Port", true}, {"GdbPortARM7", 0, "Gdb.ARM7.Port", true},

View File

@ -1384,6 +1384,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
dsi->EjectGBACart(); dsi->EjectGBACart();
} }
} }
nds->SetDebugPrint(globalCfg.GetBool("DS.DebugPrintEnabled"));
renderLock.unlock(); renderLock.unlock();
return true; return true;

View File

@ -61,6 +61,8 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
lastBIOSFolder = cfg.GetQString("LastBIOSFolder"); lastBIOSFolder = cfg.GetQString("LastBIOSFolder");
ui->cbDebugPrintEnabled->setChecked(cfg.GetBool("DS.DebugPrintEnabled"));
ui->chkExternalBIOS->setChecked(cfg.GetBool("Emu.ExternalBIOSEnable")); ui->chkExternalBIOS->setChecked(cfg.GetBool("Emu.ExternalBIOSEnable"));
ui->txtBIOS9Path->setText(cfg.GetQString("DS.BIOS9Path")); ui->txtBIOS9Path->setText(cfg.GetQString("DS.BIOS9Path"));
ui->txtBIOS7Path->setText(cfg.GetQString("DS.BIOS7Path")); ui->txtBIOS7Path->setText(cfg.GetQString("DS.BIOS7Path"));
@ -108,6 +110,8 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new
ui->cbGdbBOSA9->setDisabled(true); ui->cbGdbBOSA9->setDisabled(true);
#endif #endif
ui->cbDebugPrintEnabled->setChecked(cfg.GetBool("DS.DebugPrintEnabled"));
on_chkEnableJIT_toggled(); on_chkEnableJIT_toggled();
on_cbGdbEnabled_toggled(); on_cbGdbEnabled_toggled();
on_chkExternalBIOS_toggled(); on_chkExternalBIOS_toggled();
@ -272,6 +276,8 @@ void EmuSettingsDialog::done(int r)
cfg.SetBool("DLDI.FolderSync", ui->cbDLDIFolder->isChecked()); cfg.SetBool("DLDI.FolderSync", ui->cbDLDIFolder->isChecked());
cfg.SetQString("DLDI.FolderPath", ui->txtDLDIFolder->text()); cfg.SetQString("DLDI.FolderPath", ui->txtDLDIFolder->text());
cfg.SetBool("DS.DebugPrintEnabled", ui->cbDebugPrintEnabled->isChecked());
cfg.SetQString("DSi.BIOS9Path", ui->txtDSiBIOS9Path->text()); cfg.SetQString("DSi.BIOS9Path", ui->txtDSiBIOS9Path->text());
cfg.SetQString("DSi.BIOS7Path", ui->txtDSiBIOS7Path->text()); cfg.SetQString("DSi.BIOS7Path", ui->txtDSiBIOS7Path->text());
cfg.SetQString("DSi.FirmwarePath", ui->txtDSiFirmwarePath->text()); cfg.SetQString("DSi.FirmwarePath", ui->txtDSiFirmwarePath->text());

View File

@ -573,14 +573,14 @@
<string>Devtools</string> <string>Devtools</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_16"> <widget class="QLabel" name="label_16">
<property name="text"> <property name="text">
<string>ARM9 port</string> <string>ARM9 port</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="6" column="0">
<spacer name="verticalSpacer_4"> <spacer name="verticalSpacer_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -593,7 +593,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_17"> <widget class="QLabel" name="label_17">
<property name="text"> <property name="text">
<string>ARM7 port</string> <string>ARM7 port</string>
@ -607,28 +607,42 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="7"> <item row="0" column="2" colspan="3">
<widget class="QLabel" name="label_18"> <widget class="QCheckBox" name="cbDebugPrintEnabled">
<property name="text"> <property name="text">
<string>Note: melonDS must be restarted in order for these changes to have effect</string> <string>Enable debug print</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="7"> <item row="1" column="0" colspan="7">
<widget class="QLabel" name="label_19"> <widget class="QLabel" name="label_18">
<property name="text"> <property name="text">
<string>Note: GDB stub cannot be used together with the JIT recompiler</string> <string>Note: GDB stub cannot be used together with the JIT recompiler</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="6"> <item row="2" column="0" colspan="7">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Note: Debug print outputs to terminal on SVC 0xFC</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="7">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Note: melonDS must be restarted in order for these changes to have effect</string>
</property>
</widget>
</item>
<item row="3" column="6">
<widget class="QCheckBox" name="cbGdbBOSA9"> <widget class="QCheckBox" name="cbGdbBOSA9">
<property name="text"> <property name="text">
<string>Break on startup</string> <string>Break on startup</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="5"> <item row="3" column="1" colspan="5">
<widget class="QSpinBox" name="intGdbPortA9"> <widget class="QSpinBox" name="intGdbPortA9">
<property name="minimum"> <property name="minimum">
<number>1000</number> <number>1000</number>
@ -641,7 +655,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" colspan="5"> <item row="4" column="1" colspan="5">
<widget class="QSpinBox" name="intGdbPortA7"> <widget class="QSpinBox" name="intGdbPortA7">
<property name="minimum"> <property name="minimum">
<number>1000</number> <number>1000</number>
@ -654,7 +668,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="6"> <item row="4" column="6">
<widget class="QCheckBox" name="cbGdbBOSA7"> <widget class="QCheckBox" name="cbGdbBOSA7">
<property name="text"> <property name="text">
<string>Break on startup</string> <string>Break on startup</string>