hey look, it runs shit now!

This commit is contained in:
Arisotura 2020-04-27 22:32:33 +02:00
parent 931da1c66f
commit 3c883a2152
3 changed files with 58 additions and 6 deletions

View File

@ -42,7 +42,7 @@ void Init_ROM();
// 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(char* file, int slot); bool LoadROM(const char* file, int slot);
// get the filename associated with the given savestate slot // get the filename associated with the given savestate slot
void GetSavestateName(int slot, char* filename, int len); void GetSavestateName(int slot, char* filename, int len);

View File

@ -57,7 +57,7 @@ void SetupSRAMPath(int slot)
strncpy(SRAMPath[slot] + strlen(ROMPath[slot]) - 3, "sav", 3); strncpy(SRAMPath[slot] + strlen(ROMPath[slot]) - 3, "sav", 3);
} }
bool LoadROM(char* file, int slot) bool LoadROM(const char* file, int slot)
{ {
char oldpath[1024]; char oldpath[1024];
char oldsram[1024]; char oldsram[1024];

View File

@ -35,13 +35,15 @@
#include "types.h" #include "types.h"
#include "version.h" #include "version.h"
#include "FrontendUtil.h"
#include "NDS.h" #include "NDS.h"
#include "GBACart.h"
#include "GPU.h" #include "GPU.h"
#include "SPU.h" #include "SPU.h"
#include "Wifi.h" #include "Wifi.h"
#include "Platform.h" #include "Platform.h"
#include "Config.h" #include "Config.h"
#include "PlatformConfig.h"
#include "Savestate.h" #include "Savestate.h"
@ -102,7 +104,7 @@ void EmuThread::run()
char melontitle[100]; char melontitle[100];
SDL_mutex* titlemutex = SDL_CreateMutex(); SDL_mutex* titlemutex = SDL_CreateMutex();
void* titledata[2] = {melontitle, titlemutex}; void* titledata[2] = {melontitle, titlemutex};
printf("emu thread start: %d\n", EmuRunning);
while (EmuRunning != 0) while (EmuRunning != 0)
{ {
/*ProcessInput(); /*ProcessInput();
@ -389,8 +391,56 @@ MainWindow::~MainWindow()
void MainWindow::onOpenFile() void MainWindow::onOpenFile()
{ {
QString filename = QFileDialog::getOpenFileName(this, "Open ROM", "", "DS ROMs (*.nds *.srl);;Any file (*.*)"); emuThread->emuPause(true);
printf("fark: %p %d %s\n", filename, filename.isEmpty(), filename.toStdString().c_str());
QString filename = QFileDialog::getOpenFileName(this,
"Open ROM",
Config::LastROMFolder,
"DS ROMs (*.nds *.srl);;GBA ROMs (*.gba);;Any file (*.*)");
if (filename.isEmpty())
{
emuThread->emuUnpause();
return;
}
// this shit is stupid
char file[1024];
strncpy(file, filename.toStdString().c_str(), 1023); file[1023] = '\0';
int pos = strlen(file)-1;
while (file[pos] != '/' && file[pos] != '\\' && pos > 0) pos--;
strncpy(Config::LastROMFolder, file, pos);
Config::LastROMFolder[pos] = '\0';
char* ext = &file[strlen(file)-3];
int slot; bool res;
if (!strcasecmp(ext, "gba"))
{
slot = 1;
res = Frontend::LoadROM(file, Frontend::ROMSlot_GBA);
}
else
{
slot = 0;
res = Frontend::LoadROM(file, Frontend::ROMSlot_NDS);
}
if (!res)
{
QMessageBox::critical(this,
"melonDS",
"Failed to load the ROM.\n\nMake sure the file is accessible and isn't used by another application.");
emuThread->emuUnpause();
}
else if (slot == 1)
{
// checkme
emuThread->emuUnpause();
}
else
{
emuThread->emuRun();
}
} }
@ -557,6 +607,8 @@ int main(int argc, char** argv)
} }
#endif #endif
RunningSomething = false;
mainWindow = new MainWindow(); mainWindow = new MainWindow();
mainWindow->show(); mainWindow->show();