Add proper support for power button LED

This commit is contained in:
meepingsnesroms
2018-06-18 16:40:05 -07:00
parent fafa4ba218
commit bd94671cbc
8 changed files with 52 additions and 39 deletions

View File

@@ -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

View File

@@ -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);
};

View File

@@ -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()){

View File

@@ -15,6 +15,22 @@
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="0">
<widget class="QLabel" name="touchscreenState">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Current Touch Data</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QWidget" name="controlPanel" native="true">
<property name="enabled">
@@ -273,6 +289,19 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="powerButtonLed">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>LED</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -295,22 +324,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="touchscreenState">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Current Touch Data</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@@ -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);

View File

@@ -105,7 +105,7 @@ typedef struct{
}sdcard_t;
typedef struct{
bool alarmLed;
bool powerButtonLed;
bool lcdOn;
bool backlightOn;
bool vibratorOn;

View File

@@ -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();

View File

@@ -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;
}