After finding the definition of keys[] and figuring out how to make keystrokes visible to the CPU code, the simulator is now reading the keys. Since the first two digits are still not operational, they have been shifted two digits to the right. This is for the moment a 3 digits of precision calculator.
The following CPU code shows what needs to be done to simulate a keypress. The external code at the appropriate time must put the value KN on the keyStrobe. The appropriate time is decided by the value of dActive, a variable that holds the position of the digit currently being displayed.
case 26: // AKCN: A+K -> A until key down on N or D11 [sic]
// Patent says sets condition if key down, but real behavior
// is to set condition if addition overflows (i.e. no key down)
//SinclairData.display = 0; //comment this line to glitch the display when a number key is pressed (SINCLAIR behavior: actual hardware behavior)
add(SinclairData.a, getMask(), SinclairData.a);
if (SinclairData.keyStrobe == KN)
{
displayInstruction(27);
// Advance to next instruction
}
else if (SinclairData.dActive != 10)
{
displayInstruction(28);
// Hold at current instruction and continue scan
nextAddress = SinclairData.address;
}
else
{
displayInstruction(29);
// For state d10, fall through
}
break;
Here are the key definitions. Each column corresponds to a dActive value of 1 to 10. To simulate that the key 3 is pressed, the external code must wait for dActive == 3 and then set keyStrobe to KN. To simulate a 0, wait for dActive == 9 and then set keyStrobe to KO
const char keysKN[10] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', 0};
const char keysKO[10] = {'C', 'v', '+', '-', '/', 'X', '^', 'E', '0', 0};
//const char keysKP[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
Time for a quick tweet:
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.