mirror of
https://github.com/libretro/Mu.git
synced 2026-05-06 20:34:20 +00:00
Fix bootloader buffer crash and button inversion and sed1376 getting disconnnected, add port k
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.6.0, 2018-04-12T11:02:35. -->
|
||||
<!-- Written by QtCreator 4.6.0, 2018-04-12T12:56:16. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -68,7 +68,7 @@ void emulatorInit(uint8_t* palmRomDump, uint8_t* palmBootDump, uint32_t specialF
|
||||
//memory
|
||||
memset(palmRam, 0x00, RAM_SIZE);
|
||||
memcpy(palmRom, palmRomDump, ROM_SIZE);
|
||||
if(palmBootloader)
|
||||
if(palmBootDump)
|
||||
memcpy(palmBootloader, palmBootDump, BOOTLOADER_SIZE);
|
||||
else
|
||||
memset(palmBootloader, 0x00, BOOTLOADER_SIZE);
|
||||
@@ -107,6 +107,7 @@ void emulatorInit(uint8_t* palmRomDump, uint8_t* palmBootDump, uint32_t specialF
|
||||
//misc attributes
|
||||
palmMisc.batteryCharging = false;
|
||||
palmMisc.batteryLevel = 100;
|
||||
palmMisc.inDock = false;
|
||||
|
||||
//config
|
||||
palmClockMultiplier = (specialFeatures & FEATURE_FAST_CPU) ? 2.0 : 1.0;//overclock
|
||||
@@ -166,7 +167,7 @@ uint32_t emulatorGetStateSize(){
|
||||
size += sizeof(uint8_t) * 2;//palmSdCard
|
||||
size += sizeof(uint64_t) * 4;//32.32 fixed point double precision timers
|
||||
size += sizeof(uint32_t);//clk32Counter
|
||||
size += sizeof(uint8_t) * 6;//palmMisc
|
||||
size += sizeof(uint8_t) * 7;//palmMisc
|
||||
size += sizeof(uint32_t);//palmSpecialFeatures
|
||||
|
||||
return size;
|
||||
@@ -235,6 +236,8 @@ void emulatorSaveState(uint8_t* data){
|
||||
offset += sizeof(uint8_t);
|
||||
writeStateValueUint8(data + offset, palmMisc.batteryLevel);
|
||||
offset += sizeof(uint8_t);
|
||||
writeStateValueUint8(data + offset, palmMisc.inDock);
|
||||
offset += sizeof(uint8_t);
|
||||
|
||||
//features
|
||||
writeStateValueUint32(data + offset, palmSpecialFeatures);
|
||||
@@ -297,6 +300,8 @@ void emulatorLoadState(uint8_t* data){
|
||||
offset += sizeof(uint8_t);
|
||||
palmMisc.batteryLevel = readStateValueUint8(data + offset);
|
||||
offset += sizeof(uint8_t);
|
||||
palmMisc.inDock = readStateValueUint8(data + offset);
|
||||
offset += sizeof(uint8_t);
|
||||
|
||||
//features
|
||||
palmSpecialFeatures = readStateValueUint32(data + offset);
|
||||
|
||||
@@ -79,6 +79,7 @@ typedef struct{
|
||||
bool vibratorOn;
|
||||
bool batteryCharging;
|
||||
uint8_t batteryLevel;
|
||||
bool inDock;
|
||||
}misc_hw_t;
|
||||
|
||||
//cpu
|
||||
|
||||
@@ -71,17 +71,17 @@ static inline uint8_t getPortDValue(){
|
||||
|
||||
if((requestedRow & 0x20) == 0){
|
||||
//kbd row 0
|
||||
portDValue |= palmInput.buttonCalender | palmInput.buttonAddress << 1 | palmInput.buttonTodo << 2 | palmInput.buttonNotes << 3;
|
||||
portDValue |= !palmInput.buttonCalender | !palmInput.buttonAddress << 1 | !palmInput.buttonTodo << 2 | !palmInput.buttonNotes << 3;
|
||||
}
|
||||
|
||||
if((requestedRow & 0x40) == 0){
|
||||
//kbd row 1
|
||||
portDValue |= palmInput.buttonUp | palmInput.buttonDown << 1;
|
||||
portDValue |= !palmInput.buttonUp | !palmInput.buttonDown << 1;
|
||||
}
|
||||
|
||||
if((requestedRow & 0x80) == 0){
|
||||
//kbd row 2
|
||||
portDValue |= palmInput.buttonPower | palmInput.buttonContrast << 1 | palmInput.buttonAddress << 3;
|
||||
portDValue |= !palmInput.buttonPower | !palmInput.buttonContrast << 1 | !palmInput.buttonAddress << 3;
|
||||
}
|
||||
|
||||
portDValue &= ~portDDir;//only use above pin values for inputs
|
||||
@@ -91,6 +91,18 @@ static inline uint8_t getPortDValue(){
|
||||
return portDValue;
|
||||
}
|
||||
|
||||
static inline uint8_t getPortKValue(){
|
||||
uint8_t portKValue = 0x00;//ports always read the chip pins even if they are set to output
|
||||
uint8_t portKData = registerArrayRead8(PKDATA);
|
||||
uint8_t portKDir = registerArrayRead8(PKDIR);
|
||||
uint8_t portKSel = registerArrayRead8(PKSEL);
|
||||
|
||||
portKValue |= !palmMisc.inDock << 2 & ~portKDir & portKSel;
|
||||
portKValue |= portKData & portKDir & portKSel;
|
||||
|
||||
return portKValue;
|
||||
}
|
||||
|
||||
static inline void checkPortDInts(){
|
||||
uint8_t portDValue = getPortDValue();
|
||||
uint8_t portDIntEnable = registerArrayRead8(PDIRQEN);
|
||||
@@ -611,7 +623,14 @@ unsigned int getHwRegister8(unsigned int address){
|
||||
|
||||
case PDDATA:
|
||||
return getPortDValue();
|
||||
|
||||
case PKDATA:
|
||||
return getPortKValue();
|
||||
|
||||
//i/o direction
|
||||
case PDDIR:
|
||||
case PKDIR:
|
||||
|
||||
//select between gpio or special function
|
||||
case PBSEL:
|
||||
case PCSEL:
|
||||
@@ -656,12 +675,15 @@ unsigned int getHwRegister16(unsigned int address){
|
||||
address &= 0x00000FFF;
|
||||
switch(address){
|
||||
|
||||
//32 bit register accessed as 16 bit
|
||||
//32 bit registers accessed as 16 bit
|
||||
case IMR:
|
||||
case IMR + 2:
|
||||
case IPR:
|
||||
case IPR + 2:
|
||||
|
||||
case PLLCR:
|
||||
case PLLFSR:
|
||||
case DRAMC:
|
||||
case SDCTRL:
|
||||
case RTCISR:
|
||||
case RTCCTL:
|
||||
@@ -743,16 +765,22 @@ void setHwRegister8(unsigned int address, unsigned int value){
|
||||
registerArrayWrite8(address, value & 0xF0);
|
||||
break;
|
||||
|
||||
case PDDATA:
|
||||
registerArrayWrite8(address, value);
|
||||
checkPortDInts();
|
||||
break;
|
||||
|
||||
case PDPOL:
|
||||
case PDIRQEN:
|
||||
case PDIRQEG:
|
||||
//write without the top 4 bits
|
||||
registerArrayWrite8(address, value & 0x0F);
|
||||
checkPortDInts();
|
||||
break;
|
||||
|
||||
case PFSEL:
|
||||
//this is the clock output pin for the sed1376, if its disabled so is the lcd controller
|
||||
setSed1376Attached(CAST_TO_BOOL(value & 0x04));
|
||||
setSed1376Attached(!CAST_TO_BOOL(value & 0x04));
|
||||
registerArrayWrite8(PFSEL, value);
|
||||
break;
|
||||
|
||||
@@ -814,7 +842,6 @@ void setHwRegister8(unsigned int address, unsigned int value){
|
||||
|
||||
//port data value, nothing attached to port
|
||||
case PCDATA:
|
||||
case PDDATA:
|
||||
case PEDATA:
|
||||
case PFDATA:
|
||||
case PJDATA:
|
||||
|
||||
Reference in New Issue
Block a user