mirror of
https://github.com/libretro/Mu.git
synced 2026-09-23 23:25:04 +00:00
Can now run with or without the bootloader in the Qt port
Also clean up ads7846 functions
This commit is contained in:
@@ -129,7 +129,7 @@ uint32_t EmuWrapper::init(QString romPath, QString bootloaderPath, uint32_t feat
|
||||
return EMU_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if(bootloaderPath != ""){
|
||||
if(bootloaderPath != "" && bootloaderFile.exists()){
|
||||
if(bootloaderFile.open(QFile::ReadOnly)){
|
||||
bootloaderData = bootloaderFile.readAll();
|
||||
bootloaderFile.close();
|
||||
@@ -141,6 +141,10 @@ uint32_t EmuWrapper::init(QString romPath, QString bootloaderPath, uint32_t feat
|
||||
return EMU_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
else{
|
||||
bootloaderBuff.data = NULL;
|
||||
bootloaderBuff.size = 0;
|
||||
}
|
||||
|
||||
error = emulatorInit(romBuff, bootloaderBuff, features);
|
||||
if(error == EMU_ERROR_NONE){
|
||||
|
||||
@@ -10,21 +10,29 @@ bool ads7846PenIrqEnabled;
|
||||
uint16_t ads7846OutputValue;
|
||||
|
||||
|
||||
void ads7846SendBit(bool bit){
|
||||
static inline bool ads7846GetAdcBit(){
|
||||
//a new control byte can be sent while receiving data
|
||||
//this is valid behavior as long as the start of the last control byte was 16 or more clock cycles ago
|
||||
bool bit = ads7846OutputValue & 0x8000;
|
||||
ads7846OutputValue <<= 1;
|
||||
return bit;
|
||||
}
|
||||
|
||||
bool ads7846ExchangeBit(bool bitIn){
|
||||
if(ads7846BitsToNextControl > 0)
|
||||
ads7846BitsToNextControl--;
|
||||
|
||||
if(ads7846BitsToNextControl == 0){
|
||||
//check for control bit
|
||||
if(bit){
|
||||
if(bitIn){
|
||||
ads7846ControlByte = 0x01;
|
||||
ads7846BitsToNextControl = 16;
|
||||
}
|
||||
return;
|
||||
return ads7846GetAdcBit();
|
||||
}
|
||||
else if(ads7846BitsToNextControl < 8){
|
||||
ads7846ControlByte <<= 1;
|
||||
ads7846ControlByte |= bit;
|
||||
ads7846ControlByte |= bitIn;
|
||||
}
|
||||
|
||||
if(ads7846BitsToNextControl == 7){
|
||||
@@ -103,17 +111,14 @@ void ads7846SendBit(bool bit){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ads7846GetAdcBit();
|
||||
}
|
||||
|
||||
bool ads7846RecieveBit(){
|
||||
bool bit;
|
||||
|
||||
//a new control byte can be sent while receiving data
|
||||
//this is valid behavior as long as there has been 16 clock cycles since the start of the last control byte
|
||||
|
||||
bit = ads7846OutputValue & 0x8000;
|
||||
ads7846OutputValue <<= 1;
|
||||
return bit;
|
||||
bool ads7846Busy(){
|
||||
if(ads7846BitsToNextControl == 8)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ads7846Reset(){
|
||||
|
||||
@@ -7,7 +7,7 @@ extern uint8_t ads7846ControlByte;
|
||||
extern bool ads7846PenIrqEnabled;
|
||||
extern uint16_t ads7846OutputValue;
|
||||
|
||||
void ads7846SendBit(bool bit);
|
||||
bool ads7846RecieveBit();
|
||||
bool ads7846ExchangeBit(bool bitIn);
|
||||
bool ads7846Busy();
|
||||
|
||||
void ads7846Reset();
|
||||
|
||||
@@ -250,9 +250,9 @@ static inline void setSpiCont2(uint16_t value){
|
||||
|
||||
for(uint8_t bits = 0; bits < bitCount; bits++){
|
||||
//the Palm m515 seems to invert received bits
|
||||
ads7846SendBit(spi2Data & 0x8000);
|
||||
bool newBit = ads7846ExchangeBit(spi2Data & 0x8000);
|
||||
spi2Data <<= 1;
|
||||
spi2Data |= !ads7846RecieveBit();
|
||||
spi2Data |= !newBit;
|
||||
}
|
||||
registerArrayWrite16(SPIDATA2, spi2Data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user