mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
save battery levels to config
This commit is contained in:
parent
3ec40c3dc8
commit
a437a76f35
@ -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)
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -158,6 +158,10 @@ extern bool MouseHide;
|
||||
extern int MouseHideSeconds;
|
||||
extern bool PauseLostFocus;
|
||||
|
||||
extern bool DSBatteryLevelOkay;
|
||||
extern int DSiBatteryLevel;
|
||||
extern bool DSiBatteryCharging;
|
||||
|
||||
|
||||
void Load();
|
||||
void Save();
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -67,8 +67,8 @@ private:
|
||||
|
||||
bool inited;
|
||||
bool oldDSBatteryLevel;
|
||||
bool oldDSiBatteryCharging;
|
||||
u8 oldDSiBatteryLevel;
|
||||
bool oldDSiBatteryCharging;
|
||||
|
||||
void updateDSBatteryLevelControls();
|
||||
};
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user