Fix sed1376 PIP ending too early

Since I am unable to find out what is wrong with the touch screen I just ported the POSE EvtEnqueuePenPoint hack, it will be removed in the future if possible.
This commit is contained in:
meepingsnesroms
2018-06-09 15:48:44 -07:00
parent 701b53bf9d
commit bbb7c7c038
7 changed files with 97 additions and 32 deletions

View File

@@ -23,16 +23,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# ios {
# QMAKE_INFO_PLIST = ios-resources/Info.plist
# QMAKE_INFO_PLIST = ios/Info.plist
# }
macx {
QMAKE_INFO_PLIST = macos-resources/Info.plist
QMAKE_INFO_PLIST = macos/Info.plist
}
CONFIG(debug, debug|release){
DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER EMU_LOG_REGISTER_ACCESS_UNKNOWN
# DEFINES += EMU_OPCODE_LEVEL_DEBUG EMU_LOG_APIS
DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER
# DEFINES += EMU_OPCODE_LEVEL_DEBUG EMU_LOG_APIS EMU_LOG_REGISTER_ACCESS_UNKNOWN
}
QMAKE_CFLAGS += -std=c99

View File

@@ -327,6 +327,28 @@ uint32_t callTrap(bool fallthrough, const char* name, const char* prototype, ...
return trapReturn;
}
void sendTouchEvents(){
static input_t lastFrameInput = {0};
bool locationChanged = lastFrameInput.touchscreenX != palmInput.touchscreenX || lastFrameInput.touchscreenY != palmInput.touchscreenY;
bool pressedChanged = lastFrameInput.touchscreenTouched != palmInput.touchscreenTouched;
//proto: Err EvtEnqueuePenPoint(PointType *ptP);
//PointType is int16, int16
if(locationChanged || pressedChanged){
if(palmInput.touchscreenTouched){
m68k_write_memory_16(0xFFFFFFE0 - 4, palmInput.touchscreenX);
m68k_write_memory_16(0xFFFFFFE0 - 2, palmInput.touchscreenY);
}
else{
m68k_write_memory_16(0xFFFFFFE0 - 4, (uint16_t)-1);
m68k_write_memory_16(0xFFFFFFE0 - 2, (uint16_t)-1);
}
callTrap(false, "sysTrapEvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
}
lastFrameInput = palmInput;
}
uint32_t makePalmString(const char* str){
uint32_t strLength = strlen(str) + 1;
uint32_t strData = callTrap(false, "sysTrapMemPtrNew", "p(l)", strLength);
@@ -348,32 +370,16 @@ void sinfulExecution(){
if(!alreadyRun){
bool hasBooted = !memcmp(palmFramebuffer, finishedBooting.pixel_data, 160 * 160 * 2);
if(hasBooted){
/*proto: Err SysAppLaunch(UInt16 cardNo, LocalID dbID, UInt16 launchFlags,
UInt16 cmd, MemPtr cmdPBP, UInt32 *resultP)
SYS_TRAP(sysTrapSysAppLaunch);
/*proto:Err SysAppLaunch(UInt16 cardNo, LocalID dbID, UInt16 launchFlags,
UInt16 cmd, MemPtr cmdPBP, UInt32 *resultP);
*/
/*
uint32_t palmString = makePalmString("Calculator");
uint32_t palmString = makePalmString("Memo Pad");
if(palmString != 0){
uint32_t localId = callTrap(false, "sysTrapDmFindDatabase", "l(wp)", 0, palmString);
callTrap(true, "sysTrapSysAppLaunch", "w(wlwwpp)", 0, localId, 0, 0, 0, 0);
//dont free palmString yet
}
*/
//capture a single touch read
debugClearLogs();
callTrap(false, "sysTrapHwrIRQ5Handler", "v()");
debugLog("Touch Capture Finished\n");
/*
int16_t xPos;
int16_t yPos;
uint8_t touched;
callTrap(false, "sysTrapEvtGetPen", "v(WWB)", &xPos, &yPos, &touched);
*/
//debugLog("Touch Position:X:%d, Y:%d, Touched:%d\n", xPos, yPos, touched);
alreadyRun = true;
}
@@ -863,6 +869,7 @@ uint32_t emulatorInstallPrcPdb(buffer_t file){
void emulateFrame(){
refreshInputState();
sendTouchEvents();
while(palmCycleCounter < CRYSTAL_FREQUENCY / EMU_FPS){
if(palmCrystalCycles != 0.0 && !lowPowerStopActive){
@@ -891,6 +898,7 @@ bool emulateUntilDebugEventOrFrameEnd(){
#if defined(EMU_DEBUG) && defined(EMU_OPCODE_LEVEL_DEBUG)
invalidBehaviorAbort = false;
refreshInputState();
sendTouchEvents();
while(palmCycleCounter < CRYSTAL_FREQUENCY / EMU_FPS){
if(palmCrystalCycles != 0.0 && !lowPowerStopActive){
@@ -916,15 +924,11 @@ bool emulateUntilDebugEventOrFrameEnd(){
sed1376Render();
//launch app when framebuffer == touchscreen calibrate
sinfulExecution();
return invalidBehaviorAbort;
#else
emulateFrame();
//launch app when framebuffer == touchscreen calibrate
//sinfulExecution();
sinfulExecution();
return false;
#endif

View File

@@ -48,12 +48,14 @@ bool sed1376ClockConnected(){
}
void refreshInputState(){
/*
uint16_t icr = registerArrayRead16(ICR);
bool penIrqPin = !(ads7846PenIrqEnabled && palmInput.touchscreenTouched);//penIrqPin pulled low on touch
//IRQ set as pin function and triggered
if(!(registerArrayRead8(PFSEL) & 0x02) && penIrqPin == (bool)(icr & 0x0080))
setIprIsrBit(INT_IRQ5);
*/
/*
//IRQ set as pin function and triggered, the pen IRQ triggers when going low to high or high to low

View File

@@ -255,8 +255,8 @@ static inline void setSpiCont2(uint16_t value){
}
registerArrayWrite16(SPIDATA2, spi2Data);
debugLog("SPI2 transfer, ENABLE:%s, XCH:%s, IRQ:%s, IRQEN:%s, BITCOUNT:%d\n", boolString(value & 0x0200), boolString(value & 0x0100), boolString(value & 0x0080), boolString(value & 0x0400), (value & 0x000F) + 1);
debugLog("SPI2 transfer, before:0x%04X, after:0x%04X, PC:0x%08X\n", oldSpi2Data, spi2Data, m68k_get_reg(NULL, M68K_REG_PPC));
//debugLog("SPI2 transfer, ENABLE:%s, XCH:%s, IRQ:%s, IRQEN:%s, BITCOUNT:%d\n", boolString(value & 0x0200), boolString(value & 0x0100), boolString(value & 0x0080), boolString(value & 0x0400), (value & 0x000F) + 1);
//debugLog("SPI2 transfer, before:0x%04X, after:0x%04X, PC:0x%08X\n", oldSpi2Data, spi2Data, m68k_get_reg(NULL, M68K_REG_PPC));
//unset XCH, transfers are instant since timing is not emulated
value &= 0xFEFF;

View File

@@ -139,6 +139,8 @@ uint8_t sed1376GetRegister(uint8_t address){
case GPIO_CONT_0:
case GPIO_CONF_1:
case GPIO_CONT_1:
case MEM_CLK:
case PIXEL_CLK:
//simple read, no actions needed
return sed1376Registers[address];
@@ -302,8 +304,8 @@ void sed1376Render(){
if(pictureInPictureEnabled){
uint16_t pipStartX = sed1376Registers[PIP_X_START_1] << 8 | sed1376Registers[PIP_X_START_0];
uint16_t pipStartY = sed1376Registers[PIP_Y_START_1] << 8 | sed1376Registers[PIP_Y_START_0];
uint16_t pipEndX = sed1376Registers[PIP_X_END_1] << 8 | sed1376Registers[PIP_X_END_0];
uint16_t pipEndY = sed1376Registers[PIP_Y_END_1] << 8 | sed1376Registers[PIP_Y_END_0];
uint16_t pipEndX = (sed1376Registers[PIP_X_END_1] << 8 | sed1376Registers[PIP_X_END_0]) + 1;
uint16_t pipEndY = (sed1376Registers[PIP_Y_END_1] << 8 | sed1376Registers[PIP_Y_END_0]) + 1;
if(rotation == 0 || rotation == 180){
pipStartX *= 32 / bitDepth;
pipEndX *= 32 / bitDepth;

View File

@@ -0,0 +1,57 @@
SED1376 register write 0x00 to 0x11, PC 0x10003346.(printed 1 times)
SED1376 register write 0x17 to 0x12, PC 0x1000335A.(printed 1 times)
SED1376 register write 0x13 to 0x14, PC 0x10003362.(printed 1 times)
SED1376 register write 0x0D to 0x16, PC 0x10003376.(printed 1 times)
SED1376 register write 0x00 to 0x17, PC 0x1000337E.(printed 1 times)
SED1376 register write 0xF0 to 0x18, PC 0x10003398.(printed 1 times)
SED1376 register write 0x00 to 0x19, PC 0x100033A0.(printed 1 times)
SED1376 register write 0x9F to 0x1C, PC 0x100033A6.(printed 1 times)
SED1376 register write 0x00 to 0x1D, PC 0x100033AE.(printed 1 times)
SED1376 register write 0x28 to 0x1E, PC 0x100033C2.(printed 1 times)
SED1376 register write 0x00 to 0x1F, PC 0x100033CA.(printed 1 times)
SED1376 register write 0x81 to 0x20, PC 0x100033DE.(printed 1 times)
SED1376 register write 0xB0 to 0x22, PC 0x100033E6.(printed 1 times)
SED1376 register write 0x00 to 0x23, PC 0x100033EE.(printed 1 times)
SED1376 register write 0x01 to 0x24, PC 0x10003402.(printed 1 times)
SED1376 register write 0x00 to 0x26, PC 0x1000340A.(printed 1 times)
SED1376 register write 0x00 to 0x27, PC 0x10003410.(printed 1 times)
SED1376 register write 0x00 to 0xB0, PC 0x100032C2.(printed 1 times)
SED1376 register write 0xCF to 0xB1, PC 0x100032C8.(printed 1 times)
SED1376 register write 0x00 to 0x11, PC 0x10085A62.(printed 1 times)
SED1376 register write 0x17 to 0x12, PC 0x10085A76.(printed 1 times)
SED1376 register write 0x13 to 0x14, PC 0x10085A7E.(printed 1 times)
SED1376 register write 0x0D to 0x16, PC 0x10085A92.(printed 1 times)
SED1376 register write 0x00 to 0x17, PC 0x10085A9A.(printed 1 times)
SED1376 register write 0xF0 to 0x18, PC 0x10085AB4.(printed 1 times)
SED1376 register write 0x00 to 0x19, PC 0x10085ABC.(printed 1 times)
SED1376 register write 0x9F to 0x1C, PC 0x10085AC2.(printed 1 times)
SED1376 register write 0x00 to 0x1D, PC 0x10085ACA.(printed 1 times)
SED1376 register write 0x28 to 0x1E, PC 0x10085ADE.(printed 1 times)
SED1376 register write 0x00 to 0x1F, PC 0x10085AE6.(printed 1 times)
SED1376 register write 0x81 to 0x20, PC 0x10085AFA.(printed 1 times)
SED1376 register write 0xB0 to 0x22, PC 0x10085B02.(printed 1 times)
SED1376 register write 0x00 to 0x23, PC 0x10085B0A.(printed 1 times)
SED1376 register write 0x01 to 0x24, PC 0x10085B1E.(printed 1 times)
SED1376 register write 0x00 to 0x26, PC 0x10085B26.(printed 1 times)
SED1376 register write 0x00 to 0x27, PC 0x10085B2C.(printed 1 times)
SED1376 register write 0x00 to 0xB0, PC 0x100859DE.(printed 1 times)
SED1376 register write 0xCF to 0xB1, PC 0x100859E4.(printed 1 times)
SED1376 register write 0x00 to 0x11, PC 0x10085A62.(printed 1 times)
SED1376 register write 0x17 to 0x12, PC 0x10085A76.(printed 1 times)
SED1376 register write 0x13 to 0x14, PC 0x10085A7E.(printed 1 times)
SED1376 register write 0x0D to 0x16, PC 0x10085A92.(printed 1 times)
SED1376 register write 0x00 to 0x17, PC 0x10085A9A.(printed 1 times)
SED1376 register write 0xF0 to 0x18, PC 0x10085AB4.(printed 1 times)
SED1376 register write 0x00 to 0x19, PC 0x10085ABC.(printed 1 times)
SED1376 register write 0x9F to 0x1C, PC 0x10085AC2.(printed 1 times)
SED1376 register write 0x00 to 0x1D, PC 0x10085ACA.(printed 1 times)
SED1376 register write 0x28 to 0x1E, PC 0x10085ADE.(printed 1 times)
SED1376 register write 0x00 to 0x1F, PC 0x10085AE6.(printed 1 times)
SED1376 register write 0x81 to 0x20, PC 0x10085AFA.(printed 1 times)
SED1376 register write 0xB0 to 0x22, PC 0x10085B02.(printed 1 times)
SED1376 register write 0x00 to 0x23, PC 0x10085B0A.(printed 1 times)
SED1376 register write 0x01 to 0x24, PC 0x10085B1E.(printed 1 times)
SED1376 register write 0x00 to 0x26, PC 0x10085B26.(printed 1 times)
SED1376 register write 0x00 to 0x27, PC 0x10085B2C.(printed 1 times)
SED1376 register write 0x00 to 0xB0, PC 0x100859DE.(printed 1 times)
SED1376 register write 0xCF to 0xB1, PC 0x100859E4.(printed 1 times)