reimplement Stop

This commit is contained in:
Arisotura 2020-05-20 22:58:04 +02:00
parent 2ebb21ce3b
commit a9b275bc25
5 changed files with 54 additions and 8 deletions

View File

@ -116,6 +116,9 @@ void Reset()
void Stop() void Stop()
{ {
memset(OutputBuffer, 0, 2*OutputBufferSize*2); memset(OutputBuffer, 0, 2*OutputBufferSize*2);
OutputReadOffset = 0;
OutputWriteOffset = 0;
} }
void DoSavestate(Savestate* file) void DoSavestate(Savestate* file)

View File

@ -65,6 +65,10 @@ int LoadBIOS();
// note: loading a ROM to the NDS slot resets emulation // note: loading a ROM to the NDS slot resets emulation
int LoadROM(const char* file, int slot); int LoadROM(const char* file, int slot);
// unload the ROM loaded in the specified cart slot
// simulating ejection of the cartridge
void UnloadROM(int slot);
// reset execution of the current ROM // reset execution of the current ROM
int Reset(); int Reset();

View File

@ -202,6 +202,20 @@ int LoadROM(const char* file, int slot)
} }
} }
void UnloadROM(int slot)
{
if (slot == ROMSlot_NDS)
{
// TODO!
}
else if (slot == ROMSlot_GBA)
{
GBACart::Eject();
}
ROMPath[slot][0] = '\0';
}
int Reset() int Reset()
{ {
int res; int res;

View File

@ -55,7 +55,7 @@
char* EmuDirectory; char* EmuDirectory;
void Stop(bool internal); void emuStop();
namespace Platform namespace Platform
@ -133,7 +133,7 @@ void DeInit()
void StopEmu() void StopEmu()
{ {
//Stop(true); emuStop();
} }

View File

@ -115,8 +115,6 @@ EmuThread::EmuThread(QObject* parent) : QThread(parent)
connect(this, SIGNAL(windowEmuStop()), mainWindow, SLOT(onEmuStop())); connect(this, SIGNAL(windowEmuStop()), mainWindow, SLOT(onEmuStop()));
connect(this, SIGNAL(windowEmuPause()), mainWindow->actPause, SLOT(trigger())); connect(this, SIGNAL(windowEmuPause()), mainWindow->actPause, SLOT(trigger()));
connect(this, SIGNAL(windowEmuReset()), mainWindow->actReset, SLOT(trigger())); connect(this, SIGNAL(windowEmuReset()), mainWindow->actReset, SLOT(trigger()));
emit windowEmuStop();
} }
void EmuThread::run() void EmuThread::run()
@ -140,7 +138,6 @@ void EmuThread::run()
} }
Input::Init(); Input::Init();
/*Touching = false;*/
u32 nframes = 0; u32 nframes = 0;
u32 starttick = SDL_GetTicks(); u32 starttick = SDL_GetTicks();
@ -376,7 +373,6 @@ void EmuThread::emuPause()
EmuRunning = 2; EmuRunning = 2;
while (EmuStatus != 2); while (EmuStatus != 2);
//emit windowEmuPause();
if (audioDevice) SDL_PauseAudioDevice(audioDevice, 1); if (audioDevice) SDL_PauseAudioDevice(audioDevice, 1);
} }
@ -384,7 +380,6 @@ void EmuThread::emuUnpause()
{ {
EmuRunning = PrevEmuStatus; EmuRunning = PrevEmuStatus;
//emit windowEmuUnpause();
if (audioDevice) SDL_PauseAudioDevice(audioDevice, 0); if (audioDevice) SDL_PauseAudioDevice(audioDevice, 0);
} }
@ -703,6 +698,18 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
panel->setMinimumSize(256, 384); panel->setMinimumSize(256, 384);
for (int i = 0; i < 9; i++)
{
actSaveState[i]->setEnabled(false);
actLoadState[i]->setEnabled(false);
}
actUndoStateLoad->setEnabled(false);
actPause->setEnabled(false);
actReset->setEnabled(false);
actStop->setEnabled(false);
actSavestateSRAMReloc->setChecked(Config::SavestateRelocSRAM != 0); actSavestateSRAMReloc->setChecked(Config::SavestateRelocSRAM != 0);
actScreenRotation[Config::ScreenRotation]->setChecked(true); actScreenRotation[Config::ScreenRotation]->setChecked(true);
@ -1051,7 +1058,10 @@ void MainWindow::onReset()
void MainWindow::onStop() void MainWindow::onStop()
{ {
// if (!RunningSomething) return;
emuThread->emuPause();
NDS::Stop();
} }
@ -1168,6 +1178,8 @@ void MainWindow::onEmuStart()
void MainWindow::onEmuStop() void MainWindow::onEmuStop()
{ {
emuThread->emuPause();
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
actSaveState[i]->setEnabled(false); actSaveState[i]->setEnabled(false);
@ -1181,6 +1193,19 @@ void MainWindow::onEmuStop()
} }
void emuStop()
{
RunningSomething = false;
Frontend::UnloadROM(Frontend::ROMSlot_NDS);
Frontend::UnloadROM(Frontend::ROMSlot_GBA);
emit emuThread->windowEmuStop();
//OSD::AddMessage(0xFFC040, "Shutdown");
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {