mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-21 05:09:46 -06:00
RTC revamp (#1867)
* get this started * implement DSi RTC commands * set up RTC clock timer. lay down basic idea of a clock. * make the date/time registers writable * move RTC state to its own structure, to make it easier to deal with * more RTC work lay base for date/time dialog * get the bulk of the RTC functionality going * much simpler design for RTC stuff * aha, that is what it is * start working on the RTC IRQ * implement all types of RTC IRQ * start refining sleep mode. code still kinda sucks. * implement keypad IRQ * refine it some more * shut the fuck uuuuuupppppppppppppp
This commit is contained in:
@ -58,6 +58,7 @@
|
||||
#include "main.h"
|
||||
#include "Input.h"
|
||||
#include "CheatsDialog.h"
|
||||
#include "DateTimeDialog.h"
|
||||
#include "EmuSettingsDialog.h"
|
||||
#include "InputConfig/InputConfigDialog.h"
|
||||
#include "VideoSettingsDialog.h"
|
||||
@ -90,6 +91,7 @@
|
||||
#include "LocalMP.h"
|
||||
#include "Config.h"
|
||||
#include "DSi_I2C.h"
|
||||
#include "RTC.h"
|
||||
|
||||
#include "Savestate.h"
|
||||
|
||||
@ -313,6 +315,7 @@ void EmuThread::deinitOpenGL()
|
||||
void EmuThread::run()
|
||||
{
|
||||
u32 mainScreenPos[3];
|
||||
Platform::FileHandle* file;
|
||||
|
||||
NDS::Init();
|
||||
|
||||
@ -352,6 +355,15 @@ 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);
|
||||
RTC::SetState(state);
|
||||
}
|
||||
|
||||
char melontitle[100];
|
||||
|
||||
while (EmuRunning != emuStatus_Exit)
|
||||
@ -650,6 +662,15 @@ void EmuThread::run()
|
||||
}
|
||||
}
|
||||
|
||||
file = Platform::OpenLocalFile("rtc.bin", Platform::FileMode::Write);
|
||||
if (file)
|
||||
{
|
||||
RTC::StateData state;
|
||||
RTC::GetState(state);
|
||||
Platform::FileWrite(&state, sizeof(state), 1, file);
|
||||
Platform::CloseFile(file);
|
||||
}
|
||||
|
||||
EmuStatus = emuStatus_Exit;
|
||||
|
||||
GPU::DeInitRenderer();
|
||||
@ -1525,6 +1546,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||
actPowerManagement = menu->addAction("Power management");
|
||||
connect(actPowerManagement, &QAction::triggered, this, &MainWindow::onOpenPowerManagement);
|
||||
|
||||
actDateTime = menu->addAction("Date and time");
|
||||
connect(actDateTime, &QAction::triggered, this, &MainWindow::onOpenDateTime);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
actEnableCheats = menu->addAction("Enable cheats");
|
||||
@ -1787,6 +1811,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||
actStop->setEnabled(false);
|
||||
actFrameStep->setEnabled(false);
|
||||
|
||||
actDateTime->setEnabled(true);
|
||||
actPowerManagement->setEnabled(false);
|
||||
|
||||
actSetupCheats->setEnabled(false);
|
||||
@ -2737,6 +2762,16 @@ void MainWindow::onFrameStep()
|
||||
emuThread->emuFrameStep();
|
||||
}
|
||||
|
||||
void MainWindow::onOpenDateTime()
|
||||
{
|
||||
DateTimeDialog* dlg = DateTimeDialog::openDlg(this);
|
||||
}
|
||||
|
||||
void MainWindow::onOpenPowerManagement()
|
||||
{
|
||||
PowerManagementDialog* dlg = PowerManagementDialog::openDlg(this);
|
||||
}
|
||||
|
||||
void MainWindow::onEnableCheats(bool checked)
|
||||
{
|
||||
Config::EnableCheats = checked?1:0;
|
||||
@ -2824,11 +2859,6 @@ void MainWindow::onEmuSettingsDialogFinished(int res)
|
||||
actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
|
||||
}
|
||||
|
||||
void MainWindow::onOpenPowerManagement()
|
||||
{
|
||||
PowerManagementDialog* dlg = PowerManagementDialog::openDlg(this);
|
||||
}
|
||||
|
||||
void MainWindow::onOpenInputConfig()
|
||||
{
|
||||
emuThread->emuPause();
|
||||
@ -3148,6 +3178,7 @@ void MainWindow::onEmuStart()
|
||||
actStop->setEnabled(true);
|
||||
actFrameStep->setEnabled(true);
|
||||
|
||||
actDateTime->setEnabled(false);
|
||||
actPowerManagement->setEnabled(true);
|
||||
|
||||
actTitleManager->setEnabled(false);
|
||||
@ -3169,6 +3200,7 @@ void MainWindow::onEmuStop()
|
||||
actStop->setEnabled(false);
|
||||
actFrameStep->setEnabled(false);
|
||||
|
||||
actDateTime->setEnabled(true);
|
||||
actPowerManagement->setEnabled(false);
|
||||
|
||||
actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
|
||||
|
Reference in New Issue
Block a user