mirror of
https://github.com/libretro/Mu.git
synced 2026-09-23 07:05:37 +00:00
Clean up old code, test PENIRQ readability
This commit is contained in:
@@ -748,13 +748,11 @@ var watchPenIrq(){
|
||||
if(firstRun){
|
||||
firstRun = false;
|
||||
writeArbitraryMemory8(HW_REG_ADDR(PFDIR), readArbitraryMemory8(HW_REG_ADDR(PFDIR)) & 0xFD);
|
||||
writeArbitraryMemory8(HW_REG_ADDR(PFSEL), readArbitraryMemory8(HW_REG_ADDR(PFSEL)) | 0x02);
|
||||
debugSafeScreenClear(C_WHITE);
|
||||
}
|
||||
|
||||
if(getButtonPressed(buttonBack)){
|
||||
firstRun = true;
|
||||
writeArbitraryMemory8(HW_REG_ADDR(PFSEL), readArbitraryMemory8(HW_REG_ADDR(PFSEL)) & 0xFD);
|
||||
exitSubprogram();
|
||||
}
|
||||
|
||||
|
||||
3643
postBootProof.png.c
3643
postBootProof.png.c
File diff suppressed because it is too large
Load Diff
@@ -375,58 +375,6 @@ void freePalmString(uint32_t address){
|
||||
callFunction(false, 0x00000000, "MemChunkFree", "w(p)", address);
|
||||
}
|
||||
|
||||
#if 0
|
||||
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, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
}
|
||||
|
||||
lastFrameInput = palmInput;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#include "../../postBootProof.png.c"//contains finishedBooting.pixel_data
|
||||
|
||||
void sinfulExecution(){
|
||||
//jump directly to an application using SysAppLaunch, very evil and inaccurate, will be removed before version 1.0
|
||||
static bool alreadyRun = false;
|
||||
|
||||
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);
|
||||
*/
|
||||
|
||||
uint32_t palmString = makePalmString("Memo Pad");
|
||||
if(palmString != 0){
|
||||
uint32_t localId = callTrap(false, "DmFindDatabase", "l(wp)", 0, palmString);
|
||||
callTrap(true, "SysAppLaunch", "w(wlwwpp)", 0, localId, 0, 0, 0, 0);
|
||||
//dont free palmString yet
|
||||
//SysUIAppSwitch
|
||||
}
|
||||
|
||||
alreadyRun = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void sandboxInit(){
|
||||
inSandbox = false;
|
||||
#if defined(EMU_SANDBOX_OPCODE_LEVEL_DEBUG)
|
||||
@@ -476,6 +424,52 @@ void sandboxTest(uint32_t test){
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SANDBOX_SEND_OS_TOUCH:{
|
||||
//press
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, palmInput.touchscreenX);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, palmInput.touchscreenY);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
|
||||
//release
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, (uint16_t)-1);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, (uint16_t)-1);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case SANDBOX_SEND_OS_TOUCH_CALIBRATE:{
|
||||
//press, top left
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, 11/*x*/);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, 11/*y*/);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
|
||||
//release
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, (uint16_t)-1/*x*/);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, (uint16_t)-1/*y*/);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
|
||||
//press, bottom right
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, 159 - 11/*x*/);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, 159 - 11/*y*/);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
|
||||
//release
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, (uint16_t)-1/*x*/);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, (uint16_t)-1/*y*/);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
|
||||
//press, upper middle
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, 159 / 2/*x*/);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, 159 / 2 - 13/*y*/);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
|
||||
//release
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 4, (uint16_t)-1/*x*/);
|
||||
m68k_write_memory_16(0xFFFFFFE0 - 2, (uint16_t)-1/*y*/);
|
||||
callFunction(false, 0x00000000, "EvtEnqueuePenPoint", "w(p)", 0xFFFFFFE0 - 4);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
debugLog("Sandbox: Test %d finished\n", test);
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
enum{
|
||||
SANDBOX_TEST_OS_VER = 0,
|
||||
SANDBOX_TEST_TOUCH_READ
|
||||
SANDBOX_TEST_TOUCH_READ,
|
||||
SANDBOX_SEND_OS_TOUCH,
|
||||
SANDBOX_SEND_OS_TOUCH_CALIBRATE
|
||||
};
|
||||
|
||||
typedef struct{
|
||||
|
||||
@@ -535,22 +535,39 @@ void emulateFrame(){
|
||||
refreshInputState();
|
||||
|
||||
//hack, this is just an easy way to use the sandbox without attaching it to the emulator frontend
|
||||
static bool allowRun1 = true;
|
||||
static bool allowRun2 = true;
|
||||
|
||||
if(palmInput.buttonUp){
|
||||
static bool runOnce = false;
|
||||
palmInput.buttonUp = false;
|
||||
if(!runOnce){
|
||||
//sandboxTest(SANDBOX_TEST_OS_VER);
|
||||
sandboxTest(SANDBOX_TEST_TOUCH_READ);
|
||||
runOnce = true;
|
||||
|
||||
if(allowRun1){
|
||||
sandboxTest(SANDBOX_SEND_OS_TOUCH);
|
||||
allowRun1 = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
allowRun1 = true;
|
||||
}
|
||||
|
||||
if(palmInput.buttonDown){
|
||||
palmInput.buttonDown = false;
|
||||
|
||||
if(allowRun2){
|
||||
sandboxTest(SANDBOX_SEND_OS_TOUCH_CALIBRATE);
|
||||
allowRun2 = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
allowRun2 = true;
|
||||
}
|
||||
|
||||
while(palmCycleCounter < CRYSTAL_FREQUENCY / EMU_FPS){
|
||||
if(palmCrystalCycles != 0.0 && !lowPowerStopActive){
|
||||
//the frequency can change mid frame and get stuck in an infinite loop because of a divide by 0.0
|
||||
//+= m68k_execute(palmCrystalCycles{old value} * palmClockMultiplier) / (palmCrystalCycles{new value of 0.0} * palmClockMultiplier) == infinity
|
||||
double currentFrequency = palmCrystalCycles;
|
||||
palmCycleCounter += m68k_execute(currentFrequency * palmClockMultiplier) / (currentFrequency * palmClockMultiplier);
|
||||
palmCycleCounter += (double)m68k_execute(currentFrequency * palmClockMultiplier) / (currentFrequency * palmClockMultiplier);
|
||||
}
|
||||
else{
|
||||
palmCycleCounter += 1.0;
|
||||
|
||||
@@ -264,12 +264,16 @@ static inline void setSpiCont2(uint16_t value){
|
||||
uint8_t bitCount = (value & 0x000F) + 1;
|
||||
uint16_t startBit = 1 << (bitCount - 1);
|
||||
uint16_t spi2Data = registerArrayRead16(SPIDATA2);
|
||||
bool ads7846ChipSelect = getPortGValue() & 0x04;
|
||||
bool ads7846ChipSelect = !(getPortGValue() & 0x04);//this is unproven, but having it high makes the ADS7846 not work on hardware
|
||||
//uint16_t oldSpi2Data = spi2Data;
|
||||
|
||||
//the input data is shifted into the unused bits if the transfer is less than 16 bits
|
||||
for(uint8_t bits = 0; bits < bitCount; bits++){
|
||||
bool newBit = ads7846ExchangeBit(spi2Data & startBit);
|
||||
bool newBit = true;
|
||||
|
||||
if(ads7846ChipSelect)
|
||||
newBit = ads7846ExchangeBit(spi2Data & startBit);
|
||||
|
||||
//debugLog("Sent Bit:%d\n", (bool)(spi2Data & startBit));
|
||||
spi2Data <<= 1;
|
||||
spi2Data |= newBit;
|
||||
@@ -453,8 +457,8 @@ static inline uint8_t getPortFValue(){
|
||||
bool penIrqPin = !(ads7846PenIrqEnabled && palmInput.touchscreenTouched);//penIrqPin pulled low on touch
|
||||
|
||||
portFValue |= penIrqPin << 1;
|
||||
portFValue |= 0xFD;//floating pins are high
|
||||
portFValue &= ~portFDir & portFSel;
|
||||
portFValue |= 0x85;//bit 7 & 2-0 have pull ups, bits 6-3 have pull downs, bit 2 is occupied by PENIRQ
|
||||
portFValue &= ~portFDir & (portFSel | 0x02);//IRQ5 is readable even when PFSEL bit 2 is false
|
||||
portFValue |= portFData & portFDir & portFSel;
|
||||
|
||||
return portFValue;
|
||||
|
||||
@@ -35,7 +35,7 @@ power button must be pushed twice to turn the CPU back on(when debugging it work
|
||||
STOP opcode may be causing issues with the power button(it may be setting a separate CPU disable option)
|
||||
|
||||
Debug tools:
|
||||
missing icons
|
||||
missing home screen icons
|
||||
|
||||
Memory:
|
||||
Sdcard can't be read or written to
|
||||
@@ -51,6 +51,7 @@ SED1376:
|
||||
swivelview register
|
||||
|
||||
ADS7846:
|
||||
verify chip select
|
||||
channels can't be read in single reference mode in hwTestSuite
|
||||
channels are not implemented properly in the emulator
|
||||
electrical noise on lines(conversions probably should have +-20 added to values)
|
||||
@@ -59,6 +60,7 @@ Channels 3 and 4(they need to be scaled differently)
|
||||
|
||||
|
||||
Fixed:
|
||||
PENIRQ can be read even when PFSEL bit 1 is false
|
||||
early on I swapped RGB16 R and B, the LUT register addresses for red and blue were swapped though, red actually is the top 5 bits
|
||||
Allow IMR to mask interrupts after they are created
|
||||
ADC7846 temperature sensors
|
||||
|
||||
Reference in New Issue
Block a user