diff --git a/qtBuildSystem/Mu/emuwrapper.cpp b/qtBuildSystem/Mu/emuwrapper.cpp
index 7ebd1b5..654f878 100644
--- a/qtBuildSystem/Mu/emuwrapper.cpp
+++ b/qtBuildSystem/Mu/emuwrapper.cpp
@@ -236,6 +236,10 @@ QPixmap EmuWrapper::getFramebuffer(){
return QPixmap::fromImage(QImage((uchar*)emuDoubleBuffer, emuVideoWidth, emuVideoHeight, emuVideoWidth * sizeof(uint16_t), QImage::Format_RGB16));
}
+bool EmuWrapper::getPowerButtonLed(){
+ return palmMisc.powerButtonLed;
+}
+
uint64_t EmuWrapper::getEmulatorMemory(uint32_t address, uint8_t size){
uint64_t data = UINT64_MAX;//invalid access
//until SPI and UART destructive reads are implemented all reads to mapped addresses are safe, SPI is now implemented, this needs to be fixed
diff --git a/qtBuildSystem/Mu/emuwrapper.h b/qtBuildSystem/Mu/emuwrapper.h
index 0415e7f..54fe971 100644
--- a/qtBuildSystem/Mu/emuwrapper.h
+++ b/qtBuildSystem/Mu/emuwrapper.h
@@ -55,6 +55,7 @@ public:
uint16_t screenHeight() const{return emuVideoHeight;}
bool newFrameReady() const{return emuNewFrameReady;}
QPixmap getFramebuffer();
+ bool getPowerButtonLed();
uint64_t getEmulatorMemory(uint32_t address, uint8_t size);
};
diff --git a/qtBuildSystem/Mu/mainwindow.cpp b/qtBuildSystem/Mu/mainwindow.cpp
index 72da3e1..35bdbc9 100644
--- a/qtBuildSystem/Mu/mainwindow.cpp
+++ b/qtBuildSystem/Mu/mainwindow.cpp
@@ -109,6 +109,8 @@ void MainWindow::updateDisplay(){
if(emu.newFrameReady()){
ui->display->setPixmap(emu.getFramebuffer().scaled(QSize(ui->display->size().width() * 0.95, ui->display->size().height() * 0.95), Qt::KeepAspectRatio, Qt::SmoothTransformation));
ui->display->update();
+
+ ui->powerButtonLed->setStyleSheet(emu.getPowerButtonLed() ? "background: lime" : "");
}
if(emu.debugEventOccured()){
diff --git a/qtBuildSystem/Mu/mainwindow.ui b/qtBuildSystem/Mu/mainwindow.ui
index 9d953c4..9f31003 100644
--- a/qtBuildSystem/Mu/mainwindow.ui
+++ b/qtBuildSystem/Mu/mainwindow.ui
@@ -15,6 +15,22 @@
+ -
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+ Current Touch Data
+
+
+
-
@@ -273,6 +289,19 @@
+ -
+
+
+ QFrame::Box
+
+
+ LED
+
+
+ Qt::AlignCenter
+
+
+
@@ -295,22 +324,6 @@
- -
-
-
- true
-
-
-
- 0
- 0
-
-
-
- Current Touch Data
-
-
-
diff --git a/src/emulator.c b/src/emulator.c
index 31f7eff..67b9bfe 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -703,7 +703,7 @@ void emulatorSaveState(uint8_t* data){
offset += sizeof(uint16_t);
//misc
- writeStateValueBool(data + offset, palmMisc.alarmLed);
+ writeStateValueBool(data + offset, palmMisc.powerButtonLed);
offset += sizeof(uint8_t);
writeStateValueBool(data + offset, palmMisc.lcdOn);
offset += sizeof(uint8_t);
@@ -846,7 +846,7 @@ void emulatorLoadState(uint8_t* data){
offset += sizeof(uint16_t);
//misc
- palmMisc.alarmLed = readStateValueBool(data + offset);
+ palmMisc.powerButtonLed = readStateValueBool(data + offset);
offset += sizeof(uint8_t);
palmMisc.lcdOn = readStateValueBool(data + offset);
offset += sizeof(uint8_t);
diff --git a/src/emulator.h b/src/emulator.h
index 9512120..987785b 100644
--- a/src/emulator.h
+++ b/src/emulator.h
@@ -105,7 +105,7 @@ typedef struct{
}sdcard_t;
typedef struct{
- bool alarmLed;
+ bool powerButtonLed;
bool lcdOn;
bool backlightOn;
bool vibratorOn;
diff --git a/src/hardwareRegisters.c b/src/hardwareRegisters.c
index 7412e4e..7bdb0e7 100644
--- a/src/hardwareRegisters.c
+++ b/src/hardwareRegisters.c
@@ -30,7 +30,6 @@ static void checkInterrupts();
static void checkPortDInterrupts();
static void recalculateCpuSpeed();
static void pllWakeCpuIfOff();
-static void updateAlarmLedStatus();
#include "hardwareRegistersAccessors.c.h"
#include "hardwareRegistersTiming.c.h"
@@ -50,8 +49,8 @@ bool sed1376ClockConnected(){
}
void refreshInputState(){
- //update alarm LED state if palmMisc.batteryCharging changed
- updateAlarmLedStatus();
+ //update power button LED state if palmMisc.batteryCharging changed
+ updatePowerButtonLedStatus();
//update touchscreen state
if(!(registerArrayRead8(PFSEL) & 0x02)){
@@ -366,21 +365,6 @@ static void checkPortDInterrupts(){
checkInterrupts();
}
-static void updateAlarmLedStatus(){
- bool pinLineOn = registerArrayRead8(PBDATA) & registerArrayRead8(PBSEL) & registerArrayRead8(PBDIR) & 0x40;
- if(pinLineOn != palmMisc.batteryCharging)
- palmMisc.alarmLed = true;
- else
- palmMisc.alarmLed = false;
-}
-
-static void updateVibratorStatus(){
- if(registerArrayRead8(PKDATA) & registerArrayRead8(PKSEL) & registerArrayRead8(PKDIR) & 0x10)
- palmMisc.vibratorOn = true;
- else
- palmMisc.vibratorOn = false;
-}
-
void printUnknownHwAccess(uint32_t address, uint32_t value, uint32_t size, bool isWrite){
if(isWrite)
debugLog("CPU wrote %d bits of 0x%08X to register 0x%03X, PC 0x%08X.\n", size, value, address, m68k_get_reg(NULL, M68K_REG_PPC));
@@ -672,7 +656,7 @@ void setHwRegister8(uint32_t address, uint8_t value){
case PBDIR:
case PBDATA:
registerArrayWrite8(address, value);
- updateAlarmLedStatus();
+ updatePowerButtonLedStatus();
break;
case PDSEL:
@@ -1147,7 +1131,7 @@ void resetHwRegisters(){
registerArrayWrite16(SDCTRL, 0x003C);
//add register settings to misc I/O
- updateAlarmLedStatus();
+ updatePowerButtonLedStatus();
updateVibratorStatus();
recalculateCpuSpeed();
diff --git a/src/hardwareRegistersAccessors.c.h b/src/hardwareRegistersAccessors.c.h
index 3e59add..59a3fd5 100644
--- a/src/hardwareRegistersAccessors.c.h
+++ b/src/hardwareRegistersAccessors.c.h
@@ -449,3 +449,12 @@ static inline uint16_t getPwmc1(){
return returnValue;
}
+
+//updaters
+static inline void updatePowerButtonLedStatus(){
+ palmMisc.powerButtonLed = (bool)(registerArrayRead8(PBDATA) & registerArrayRead8(PBSEL) & registerArrayRead8(PBDIR) & 0x40) != palmMisc.batteryCharging;
+}
+
+static inline void updateVibratorStatus(){
+ palmMisc.vibratorOn = registerArrayRead8(PKDATA) & registerArrayRead8(PKSEL) & registerArrayRead8(PKDIR) & 0x10;
+}