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()
{
memset(OutputBuffer, 0, 2*OutputBufferSize*2);
OutputReadOffset = 0;
OutputWriteOffset = 0;
}
void DoSavestate(Savestate* file)

View File

@ -65,6 +65,10 @@ int LoadBIOS();
// note: loading a ROM to the NDS slot resets emulation
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
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 res;

View File

@ -55,7 +55,7 @@
char* EmuDirectory;
void Stop(bool internal);
void emuStop();
namespace Platform
@ -133,7 +133,7 @@ void DeInit()
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(windowEmuPause()), mainWindow->actPause, SLOT(trigger()));
connect(this, SIGNAL(windowEmuReset()), mainWindow->actReset, SLOT(trigger()));
emit windowEmuStop();
}
void EmuThread::run()
@ -140,7 +138,6 @@ void EmuThread::run()
}
Input::Init();
/*Touching = false;*/
u32 nframes = 0;
u32 starttick = SDL_GetTicks();
@ -376,7 +373,6 @@ void EmuThread::emuPause()
EmuRunning = 2;
while (EmuStatus != 2);
//emit windowEmuPause();
if (audioDevice) SDL_PauseAudioDevice(audioDevice, 1);
}
@ -384,7 +380,6 @@ void EmuThread::emuUnpause()
{
EmuRunning = PrevEmuStatus;
//emit windowEmuUnpause();
if (audioDevice) SDL_PauseAudioDevice(audioDevice, 0);
}
@ -703,6 +698,18 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
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);
actScreenRotation[Config::ScreenRotation]->setChecked(true);
@ -1051,7 +1058,10 @@ void MainWindow::onReset()
void MainWindow::onStop()
{
//
if (!RunningSomething) return;
emuThread->emuPause();
NDS::Stop();
}
@ -1168,6 +1178,8 @@ void MainWindow::onEmuStart()
void MainWindow::onEmuStop()
{
emuThread->emuPause();
for (int i = 0; i < 9; i++)
{
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)
{