diff options
author | Arisotura <thetotalworm@gmail.com> | 2022-03-06 22:47:21 +0100 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2022-03-07 21:08:54 +0100 |
commit | 2eec033c72c3afe4beda619297ff66ba97e97472 (patch) | |
tree | 35c07cd92ec71e22b0a3a9af7438879d641214c6 /src | |
parent | 532b1c967a683136f0bc29616109ff79aa2de099 (diff) |
save battery levels to config
Diffstat (limited to 'src')
-rw-r--r-- | src/SPI.cpp | 3 | ||||
-rw-r--r-- | src/frontend/qt_sdl/Config.cpp | 8 | ||||
-rw-r--r-- | src/frontend/qt_sdl/Config.h | 4 | ||||
-rw-r--r-- | src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp | 19 | ||||
-rw-r--r-- | src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h | 2 | ||||
-rw-r--r-- | src/frontend/qt_sdl/ROMManager.cpp | 18 |
6 files changed, 49 insertions, 5 deletions
diff --git a/src/SPI.cpp b/src/SPI.cpp index 009fb32..a2c4538 100644 --- a/src/SPI.cpp +++ b/src/SPI.cpp @@ -618,7 +618,7 @@ void Reset() Registers[4] = 0x40; RegMasks[0] = 0x7F; - RegMasks[1] = 0x01; + RegMasks[1] = 0x00; RegMasks[2] = 0x01; RegMasks[3] = 0x03; RegMasks[4] = 0x0F; @@ -663,6 +663,7 @@ void Write(u8 val, u32 hold) if (DataPos == 1) { + // TODO: DSi-specific registers in DSi mode u32 regid = Index & 0x07; if (Index & 0x80) diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 03dcda8..7a0ec69 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -135,6 +135,10 @@ int MouseHideSeconds; bool PauseLostFocus; +bool DSBatteryLevelOkay; +int DSiBatteryLevel; +bool DSiBatteryCharging; + const char* kConfigFile = "melonDS.ini"; @@ -305,6 +309,10 @@ ConfigEntry ConfigFile[] = {"MouseHideSeconds", 0, &MouseHideSeconds, 5}, {"PauseLostFocus", 1, &PauseLostFocus, false}, + {"DSBatteryLevelOkay", 1, &DSBatteryLevelOkay, true}, + {"DSiBatteryLevel", 0, &DSiBatteryLevel, 0xF}, + {"DSiBatteryCharging", 1, &DSiBatteryCharging, true}, + {"", -1, nullptr, 0} }; diff --git a/src/frontend/qt_sdl/Config.h b/src/frontend/qt_sdl/Config.h index 42fdac3..f2f8ddc 100644 --- a/src/frontend/qt_sdl/Config.h +++ b/src/frontend/qt_sdl/Config.h @@ -169,6 +169,10 @@ extern bool MouseHide; extern int MouseHideSeconds; extern bool PauseLostFocus; +extern bool DSBatteryLevelOkay; +extern int DSiBatteryLevel; +extern bool DSiBatteryCharging; + void Load(); void Save(); diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp index 49b1a55..499c176 100644 --- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp +++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp @@ -22,6 +22,7 @@ #include "SPI.h" #include "DSi_I2C.h" #include "NDS.h" +#include "Config.h" #include "types.h" @@ -40,8 +41,8 @@ PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent), { ui->grpDSBattery->setEnabled(false); - oldDSiBatteryCharging = DSi_BPTWL::GetBatteryCharging(); oldDSiBatteryLevel = DSi_BPTWL::GetBatteryLevel(); + oldDSiBatteryCharging = DSi_BPTWL::GetBatteryCharging(); } else { @@ -74,12 +75,24 @@ PowerManagementDialog::~PowerManagementDialog() void PowerManagementDialog::done(int r) { - if (r != QDialog::Accepted) + if (r == QDialog::Accepted) + { + if (NDS::ConsoleType == 1) + { + Config::DSiBatteryLevel = DSi_BPTWL::GetBatteryLevel(); + Config::DSiBatteryCharging = DSi_BPTWL::GetBatteryCharging(); + } + else + { + Config::DSBatteryLevelOkay = SPI_Powerman::GetBatteryLevelOkay(); + } + } + else { if (NDS::ConsoleType == 1) { - DSi_BPTWL::SetBatteryCharging(oldDSiBatteryCharging); DSi_BPTWL::SetBatteryLevel(oldDSiBatteryLevel); + DSi_BPTWL::SetBatteryCharging(oldDSiBatteryCharging); } else { diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h index 0c7b853..f335a5e 100644 --- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h +++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h @@ -67,8 +67,8 @@ private: bool inited; bool oldDSBatteryLevel; - bool oldDSiBatteryCharging; u8 oldDSiBatteryLevel; + bool oldDSiBatteryCharging; void updateDSBatteryLevelControls(); }; diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp index 15fa26f..d24e21a 100644 --- a/src/frontend/qt_sdl/ROMManager.cpp +++ b/src/frontend/qt_sdl/ROMManager.cpp @@ -31,6 +31,8 @@ #include "NDS.h" #include "DSi.h" +#include "SPI.h" +#include "DSi_I2C.h" namespace ROMManager @@ -405,11 +407,25 @@ ARCodeFile* GetCheatFile() } +void SetBatteryLevels() +{ + if (NDS::ConsoleType == 1) + { + DSi_BPTWL::SetBatteryLevel(Config::DSiBatteryLevel); + DSi_BPTWL::SetBatteryCharging(Config::DSiBatteryCharging); + } + else + { + SPI_Powerman::SetBatteryLevelOkay(Config::DSBatteryLevelOkay); + } +} + void Reset() { NDS::SetConsoleType(Config::ConsoleType); if (Config::ConsoleType == 1) EjectGBACart(); NDS::Reset(); + SetBatteryLevels(); if ((CartType != -1) && NDSSave) { @@ -453,6 +469,7 @@ bool LoadBIOS() BaseAssetName = "";*/ NDS::Reset(); + SetBatteryLevels(); return true; } @@ -537,6 +554,7 @@ bool LoadROM(QStringList filepath, bool reset) NDS::SetConsoleType(Config::ConsoleType); NDS::EjectCart(); NDS::Reset(); + SetBatteryLevels(); } u32 savelen = 0; |