I have been able to play with the real Sinclair for a few days now and have been able to time some instructions and notice some glitches.
The following glitches have been coded in the emulator:
1) When the calculator is busy, the display is off and the decimal point stays lit. The decimal point gets brighter than normal when the rest of the digits are off. This results in an interesting effect when a simple operation, like addition is performed. The display blinks briefly, and the dot flashes briefly.
2) When numeric keys are being pressed, the first digit in the display seems to count quickly through all the digits before returning through its previous value. When a 1 is shown, it looks like an 8 or a 0 is briefly flashed.
3) Pressing the C key makes the display get a little dimmer than normal. The C key is an interesting one. It is wired to the CPU, but the code does not do anything with it. Somehow it performs a hardware reset. We simulate that in software by setting the program counter to 0 and then letting the first 8 instructions execute. This clears the A register, resulting in 00000 00 being shown on the screen.
The instruction timing issue has been resolved by having the step() function take a fixed amount of time to execute regardless of which instruction runs. The snippet below shows that the current time in microseconds is measured at the start and the end of the function. The execution time is measured and if it is less than a certain value, the difference is computed and we delay for the desired amount. Looking at the code below, the line where the subtraction is performed would probably be better prior to the IF statement so it always executes. Another way to solve this problem is to make steptime larger than needed, so this subtraction is always performed.
The execution time was determined by comparing exectime with maxexectime and outputing exectime if it was greater than the previous maxexectime. This code was deleted once it was determined that the slowest instruction took 145uS to execute. The initialization code sets steptime to 148 when the program starts. When the C key is pressed, steptime is reduced so the step() function executes faster and a smaller digit refresh delay makes the display dimmer.
void step()
{
...
unsigned long entrytime = micros();
...
switch (opcode)
{
case 0: // AABA: A+B -> A
displayInstruction(1);
add(SinclairData.a, SinclairData.b, SinclairData.a);
break;
case 1: // AAKA: A+K -> A
...
byte exectime = micros() - entrytime;
if (exectime < SinclairData.steptime)
{
delayMicroseconds(SinclairData.steptime - exectime);
}
}
All the V1 PCBs are assembled and the green wire fixes done in wirewrap under the Arduino Nano. They are listed in our Tindie Store in an attempt to recoup some of the costs of purchasing the original calculators, the PCB and the supplies needed to assemble this.
Time for a quick instagram post:
https://www.instagram.com/p/BfUR9a8Hs0i/
This project will be on hold for a few weeks while working on this big insanity, 367 switches
https://hackaday.io/project/78869-smaller-simone-giertzs-good-habit-tracker
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.