First of all, I wrote simple win32 application to make sure that I have enough information to start with this project. After seeing the calculator screen working I started preparing hardware.
I took 128x64 pixels LCD, STM32F407, breadboard, lot of buttons, some more parts for link connection and hardware was quickly prepared. Hardware signals (keyboard and link) are connected in the same signal order as on original hardware so no signal remapping is needed. The only modification to input or output data is shift.
This project uses Z80 simulator source originally written by Ian Collier. I saw this source as a part of Palm ZX Spectrum simulator for the first time. I used it for CP/M simulator and made some changes to be more accurate regarding flags processing. This is the core of calculator simulation.
Another part is LCD translation from TI-86 layout. LCD uses another layout so the display area is checked with every system tick and lines which have been modified are translated and sent to LCD. This part is written in ARM assembly to be more efficient. Translated data are sent using DMA.
Quite big challenge was power consumption. STM32F4xx can run up to 168MHz, but such fast memory has bad standby current (about 140uA for this device). Final solution now is: RAM is written to flash memory and MCU goes to deep sleep with RAM off. This backup is done some time (about 1 hour) after powering off so the flash is not re-written much. This solution has atvantage of RAM being backed-up for case of battery replacement.
Calculator replica has built-in gray link adapter. This is connected to USB CDC driver. This feature took quite a lot of time. Unfortunately not for code itself - after quite long time debugging I have found that TI connect doesn't support gray link on higher port numbers. After changing COM port number below 8 it started working.
CPU runs from internal 16MHz HSI oscillator (idle mode). If more power is needed, it runs from 64MHz PLL (USB or calculation mode). 16MHz and 64MHz is choosen to keep peripheral clock with the same frequency (16MHz) when switching between various modes.
To better understand TI-86 function, I had to write my own disassembler. This tool supports TI-86 ROM banking and allows to keep track of call names through long call ROM functions. This helped me to find one never seen feature of TI-86 hardware: battery monitoring. TI-86 replica emulates this hardware feature and reports low battery regarding measured battery voltage.
I also learned new features of ARM tools but unfortunately it led me to fighting with bug (objcopy and bug 1147). ROM contents is converted using objcopy directly to object file. If this bug is still there, manual editing is needed for object file (see comment in makefile). ROM file is not part of source files and has to be downloaded directly from your calculator.
I have to say that this replica is really usable tool and it has some advantages over original hardware (USB connection, LCD backlight). It would be nice to re-use some non-fuctional TI-86 as source for machanical parts, although I am not sure about real space for replica components.