mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
fix more shit
now it doesn't shit itself on startup if the BIOS paths are wrong
This commit is contained in:
parent
13b4cea171
commit
1787235e09
@ -154,6 +154,13 @@ EmuInstance::~EmuInstance()
|
||||
|
||||
audioDeInit();
|
||||
inputDeInit();
|
||||
|
||||
NDS::Current = nullptr;
|
||||
if (nds)
|
||||
{
|
||||
saveRTCData();
|
||||
delete nds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1105,6 +1112,30 @@ void EmuInstance::setBatteryLevels()
|
||||
}
|
||||
}
|
||||
|
||||
void EmuInstance::loadRTCData()
|
||||
{
|
||||
auto file = Platform::OpenLocalFile("rtc.bin", Platform::FileMode::Read);
|
||||
if (file)
|
||||
{
|
||||
RTC::StateData state;
|
||||
Platform::FileRead(&state, sizeof(state), 1, file);
|
||||
Platform::CloseFile(file);
|
||||
nds->RTC.SetState(state);
|
||||
}
|
||||
}
|
||||
|
||||
void EmuInstance::saveRTCData()
|
||||
{
|
||||
auto file = Platform::OpenLocalFile("rtc.bin", Platform::FileMode::Write);
|
||||
if (file)
|
||||
{
|
||||
RTC::StateData state;
|
||||
nds->RTC.GetState(state);
|
||||
Platform::FileWrite(&state, sizeof(state), 1, file);
|
||||
Platform::CloseFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
void EmuInstance::setDateTime()
|
||||
{
|
||||
QDateTime hosttime = QDateTime::currentDateTime();
|
||||
@ -1238,7 +1269,11 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
|
||||
if ((!nds) || (consoleType != nds->ConsoleType))
|
||||
{
|
||||
NDS::Current = nullptr;
|
||||
if (nds) delete nds;
|
||||
if (nds)
|
||||
{
|
||||
saveRTCData();
|
||||
delete nds;
|
||||
}
|
||||
|
||||
if (consoleType == 1)
|
||||
nds = new DSi(std::move(dsiargs.value()), this);
|
||||
@ -1247,6 +1282,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
|
||||
|
||||
NDS::Current = nds;
|
||||
nds->Reset();
|
||||
loadRTCData();
|
||||
//emuThread->updateVideoRenderer(); // not actually needed?
|
||||
}
|
||||
else
|
||||
|
@ -168,7 +168,6 @@ private:
|
||||
std::optional<melonDS::FATStorageArgs> getSDCardArgs(const std::string& key) noexcept;
|
||||
std::optional<melonDS::FATStorage> loadSDCard(const std::string& key) noexcept;
|
||||
void setBatteryLevels();
|
||||
void setDateTime();
|
||||
void reset();
|
||||
bool bootToMenu();
|
||||
melonDS::u32 decompressROM(const melonDS::u8* inContent, const melonDS::u32 inSize, std::unique_ptr<melonDS::u8[]>& outContent);
|
||||
@ -223,6 +222,10 @@ private:
|
||||
bool hotkeyPressed(int id) { return hotkeyPress & (1<<id); }
|
||||
bool hotkeyReleased(int id) { return hotkeyRelease & (1<<id); }
|
||||
|
||||
void loadRTCData();
|
||||
void saveRTCData();
|
||||
void setDateTime();
|
||||
|
||||
bool deleting;
|
||||
|
||||
int instanceID;
|
||||
|
@ -102,9 +102,8 @@ void EmuThread::run()
|
||||
{
|
||||
Config::Table& globalCfg = emuInstance->getGlobalConfig();
|
||||
u32 mainScreenPos[3];
|
||||
Platform::FileHandle* file;
|
||||
|
||||
emuInstance->updateConsole(nullptr, nullptr);
|
||||
//emuInstance->updateConsole(nullptr, nullptr);
|
||||
// No carts are inserted when melonDS first boots
|
||||
|
||||
mainScreenPos[0] = 0;
|
||||
@ -112,7 +111,7 @@ void EmuThread::run()
|
||||
mainScreenPos[2] = 0;
|
||||
autoScreenSizing = 0;
|
||||
|
||||
videoSettingsDirty = false;
|
||||
//videoSettingsDirty = false;
|
||||
|
||||
if (emuInstance->usesOpenGL())
|
||||
{
|
||||
@ -127,7 +126,8 @@ void EmuThread::run()
|
||||
videoRenderer = 0;
|
||||
}
|
||||
|
||||
updateRenderer();
|
||||
//updateRenderer();
|
||||
videoSettingsDirty = true;
|
||||
|
||||
u32 nframes = 0;
|
||||
double perfCountsSec = 1.0 / SDL_GetPerformanceFrequency();
|
||||
@ -138,15 +138,6 @@ void EmuThread::run()
|
||||
u32 winUpdateCount = 0, winUpdateFreq = 1;
|
||||
u8 dsiVolumeLevel = 0x1F;
|
||||
|
||||
file = Platform::OpenLocalFile("rtc.bin", Platform::FileMode::Read);
|
||||
if (file)
|
||||
{
|
||||
RTC::StateData state;
|
||||
Platform::FileRead(&state, sizeof(state), 1, file);
|
||||
Platform::CloseFile(file);
|
||||
emuInstance->nds->RTC.SetState(state);
|
||||
}
|
||||
|
||||
char melontitle[100];
|
||||
|
||||
bool fastforward = false;
|
||||
@ -453,17 +444,6 @@ void EmuThread::run()
|
||||
|
||||
handleMessages();
|
||||
}
|
||||
|
||||
file = Platform::OpenLocalFile("rtc.bin", Platform::FileMode::Write);
|
||||
if (file)
|
||||
{
|
||||
RTC::StateData state;
|
||||
emuInstance->nds->RTC.GetState(state);
|
||||
Platform::FileWrite(&state, sizeof(state), 1, file);
|
||||
Platform::CloseFile(file);
|
||||
}
|
||||
|
||||
NDS::Current = nullptr;
|
||||
}
|
||||
|
||||
void EmuThread::sendMessage(Message msg)
|
||||
|
@ -947,9 +947,6 @@ void ScreenPanelGL::drawScreenGL()
|
||||
{
|
||||
if (!glContext) return;
|
||||
|
||||
auto nds = emuInstance->getNDS();
|
||||
if (!nds) return;
|
||||
|
||||
auto emuThread = emuInstance->getEmuThread();
|
||||
|
||||
glContext->MakeCurrent();
|
||||
@ -968,50 +965,54 @@ void ScreenPanelGL::drawScreenGL()
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
glUseProgram(screenShaderProgram);
|
||||
glUniform2f(screenShaderScreenSizeULoc, w / factor, h / factor);
|
||||
if (emuThread->emuIsActive())
|
||||
{
|
||||
auto nds = emuInstance->getNDS();
|
||||
|
||||
int frontbuf = emuThread->FrontBuffer;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glUseProgram(screenShaderProgram);
|
||||
glUniform2f(screenShaderScreenSizeULoc, w / factor, h / factor);
|
||||
|
||||
int frontbuf = emuThread->FrontBuffer;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
#ifdef OGLRENDERER_ENABLED
|
||||
if (nds->GPU.GetRenderer3D().Accelerated)
|
||||
{
|
||||
// hardware-accelerated render
|
||||
nds->GPU.GetRenderer3D().BindOutputTexture(frontbuf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// regular render
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
|
||||
if (nds->GPU.Framebuffer[frontbuf][0] && nds->GPU.Framebuffer[frontbuf][1])
|
||||
if (nds->GPU.GetRenderer3D().Accelerated)
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nds->GPU.Framebuffer[frontbuf][0].get());
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192+2, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nds->GPU.Framebuffer[frontbuf][1].get());
|
||||
// hardware-accelerated render
|
||||
nds->GPU.GetRenderer3D().BindOutputTexture(frontbuf);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// regular render
|
||||
glBindTexture(GL_TEXTURE_2D, screenTexture);
|
||||
|
||||
if (nds->GPU.Framebuffer[frontbuf][0] && nds->GPU.Framebuffer[frontbuf][1])
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nds->GPU.Framebuffer[frontbuf][0].get());
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192 + 2, 256, 192, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nds->GPU.Framebuffer[frontbuf][1].get());
|
||||
}
|
||||
}
|
||||
|
||||
screenSettingsLock.lock();
|
||||
|
||||
GLint filter = this->filter ? GL_LINEAR : GL_NEAREST;
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, screenVertexBuffer);
|
||||
glBindVertexArray(screenVertexArray);
|
||||
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
glUniformMatrix2x3fv(screenShaderTransformULoc, 1, GL_TRUE, screenMatrix[i]);
|
||||
glDrawArrays(GL_TRIANGLES, screenKind[i] == 0 ? 0 : 2 * 3, 2 * 3);
|
||||
}
|
||||
|
||||
screenSettingsLock.unlock();
|
||||
}
|
||||
|
||||
screenSettingsLock.lock();
|
||||
|
||||
GLint filter = this->filter ? GL_LINEAR : GL_NEAREST;
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, screenVertexBuffer);
|
||||
glBindVertexArray(screenVertexArray);
|
||||
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
glUniformMatrix2x3fv(screenShaderTransformULoc, 1, GL_TRUE, screenMatrix[i]);
|
||||
glDrawArrays(GL_TRIANGLES, screenKind[i] == 0 ? 0 : 2*3, 2*3);
|
||||
}
|
||||
|
||||
screenSettingsLock.unlock();
|
||||
|
||||
osdUpdate();
|
||||
if (osdEnabled)
|
||||
{
|
||||
|
@ -1009,6 +1009,9 @@ bool MainWindow::verifySetup()
|
||||
|
||||
bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
|
||||
{
|
||||
if (file.isEmpty() && gbafile.isEmpty())
|
||||
return false;
|
||||
|
||||
if (!verifySetup())
|
||||
{
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user