add menu items for running the firmware and for quitting.
This commit is contained in:
parent
0913576ef5
commit
63efc2e02a
|
@ -40,6 +40,9 @@ extern bool SavestateLoaded;
|
||||||
// initialize the ROM handling utility
|
// initialize the ROM handling utility
|
||||||
void Init_ROM();
|
void Init_ROM();
|
||||||
|
|
||||||
|
// load the BIOS/firmware and boot from it
|
||||||
|
bool LoadBIOS();
|
||||||
|
|
||||||
// load a ROM file to the specified cart slot
|
// load a ROM file to the specified cart slot
|
||||||
// note: loading a ROM to the NDS slot resets emulation
|
// note: loading a ROM to the NDS slot resets emulation
|
||||||
bool LoadROM(const char* file, int slot);
|
bool LoadROM(const char* file, int slot);
|
||||||
|
|
|
@ -57,6 +57,22 @@ void SetupSRAMPath(int slot)
|
||||||
strncpy(SRAMPath[slot] + strlen(ROMPath[slot]) - 3, "sav", 3);
|
strncpy(SRAMPath[slot] + strlen(ROMPath[slot]) - 3, "sav", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LoadBIOS()
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
// original code in the libui frontend called NDS::LoadGBAROM() if needed
|
||||||
|
// should this be carried over here?
|
||||||
|
// is that behavior consistent with that of LoadROM() below?
|
||||||
|
|
||||||
|
ROMPath[ROMSlot_NDS][0] = '\0';
|
||||||
|
SRAMPath[ROMSlot_NDS][0] = '\0';
|
||||||
|
|
||||||
|
NDS::LoadBIOS();
|
||||||
|
|
||||||
|
// TODO: error reporting?
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool LoadROM(const char* file, int slot)
|
bool LoadROM(const char* file, int slot)
|
||||||
{
|
{
|
||||||
char oldpath[1024];
|
char oldpath[1024];
|
||||||
|
|
|
@ -394,10 +394,17 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||||
QMenuBar* menubar = new QMenuBar();
|
QMenuBar* menubar = new QMenuBar();
|
||||||
{
|
{
|
||||||
QMenu* menu = menubar->addMenu("File");
|
QMenu* menu = menubar->addMenu("File");
|
||||||
QAction* act;
|
|
||||||
|
|
||||||
act = menu->addAction("Open file...");
|
actOpenROM = menu->addAction("Open file...");
|
||||||
connect(act, &QAction::triggered, this, &MainWindow::onOpenFile);
|
connect(actOpenROM, &QAction::triggered, this, &MainWindow::onOpenFile);
|
||||||
|
|
||||||
|
actBootFirmware = menu->addAction("Launch DS menu");
|
||||||
|
connect(actBootFirmware, &QAction::triggered, this, &MainWindow::onBootFirmware);
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
actQuit = menu->addAction("Quit");
|
||||||
|
connect(actQuit, &QAction::triggered, this, &MainWindow::onQuit);
|
||||||
}
|
}
|
||||||
setMenuBar(menubar);
|
setMenuBar(menubar);
|
||||||
|
|
||||||
|
@ -411,6 +418,12 @@ MainWindow::~MainWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::keyPressEvent(QKeyEvent* event)
|
||||||
|
{
|
||||||
|
printf("key press. %d %d %08X %08X\n", event->key(), event->nativeScanCode(), event->modifiers(), event->nativeModifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::onOpenFile()
|
void MainWindow::onOpenFile()
|
||||||
{
|
{
|
||||||
emuThread->emuPause(true);
|
emuThread->emuPause(true);
|
||||||
|
@ -465,6 +478,31 @@ void MainWindow::onOpenFile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onBootFirmware()
|
||||||
|
{
|
||||||
|
// TODO: ensure the firmware is actually bootable!!
|
||||||
|
// TODO: check the whole GBA cart shito
|
||||||
|
|
||||||
|
emuThread->emuPause(true);
|
||||||
|
|
||||||
|
bool res = Frontend::LoadBIOS();
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
// TODO!
|
||||||
|
|
||||||
|
emuThread->emuUnpause();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emuThread->emuRun();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onQuit()
|
||||||
|
{
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::onTitleUpdate(QString title)
|
void MainWindow::onTitleUpdate(QString title)
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,13 +75,22 @@ public:
|
||||||
explicit MainWindow(QWidget* parent = nullptr);
|
explicit MainWindow(QWidget* parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onOpenFile();
|
void onOpenFile();
|
||||||
|
void onBootFirmware();
|
||||||
|
void onQuit();
|
||||||
|
|
||||||
void onTitleUpdate(QString title);
|
void onTitleUpdate(QString title);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindowPanel* panel;
|
MainWindowPanel* panel;
|
||||||
|
|
||||||
|
QAction* actOpenROM;
|
||||||
|
QAction* actBootFirmware;
|
||||||
|
QAction* actQuit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAIN_H
|
#endif // MAIN_H
|
||||||
|
|
Loading…
Reference in New Issue