mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 07:39:56 -06:00
Add support for changing the DS and DSi battery level
The DS battery level is configured via the SPI Power Management Device, and the DSi's is configured via the I2C BPTWL. Add support for changing these registers and add the "Power Management" dialog in the UI.
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
#include "DSi_I2C.h"
|
||||
#include "DSi_Camera.h"
|
||||
#include "ARM.h"
|
||||
#include "SPI.h"
|
||||
|
||||
|
||||
namespace DSi_BPTWL
|
||||
@ -82,6 +83,19 @@ void DoSavestate(Savestate* file)
|
||||
|
||||
u8 GetBootFlag() { return Registers[0x70]; }
|
||||
|
||||
bool GetBatteryCharging() { return Registers[0x20] >> 7; }
|
||||
void SetBatteryCharging(bool charging)
|
||||
{
|
||||
Registers[0x20] = (((charging ? 0x8 : 0x0) << 4) | (Registers[0x20] & 0x0F));
|
||||
}
|
||||
|
||||
u8 GetBatteryLevel() { return Registers[0x20] & 0xF; }
|
||||
void SetBatteryLevel(u8 batteryLevel)
|
||||
{
|
||||
Registers[0x20] = ((Registers[0x20] & 0xF0) | (batteryLevel & 0x0F));
|
||||
SPI_Powerman::SetBatteryLevelOkay(batteryLevel > batteryLevel_Low ? true : false);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
//printf("BPTWL: start\n");
|
||||
|
Reference in New Issue
Block a user