Most of the inner workings of the V-Tech Genius Leader / PreComputer have been discovered. Even some lesser known functionality, which is hidden inside a proprietary silicon, is understood. Especially, how the LCD, the keyboard matrix, printer port and most of bank switching works.
Now for the philosophical question: What should we do with it?
When talking to people, most of them agree that getting an own operating system to work is priority 1. But on which OS to focus on is not fully clear. Personally, I would prefer CP/M, since it is the Z80 operating system with the most impact and support.
There are two problems with CP/M on this "toy hardware":
- CP/M requires a disk drive. The V-Tech computers don't have one. But since we do have a cartridge port and proof-of-concept memory-mapped I/O, as well as a working serial port, getting some sort of SD card reader or serial storage medium to work should not be a big problem. In the meantime we can use bank-switched ROM/PROMS/SRAM or load software from the serial port (already working!)
- CP/M requires RAM to start at memory address 0x0000, since this is how CP/M programs interface with the BIOS/BDOS drivers. See: http://www.primrosebank.net/computers/cpm/cpm_structure.htm
The latter problem is a bit more tricky. See, on power-up the Z80 CPU jumps to address 0x0000 and starts executing the instructions located there. That's why there is a big system ROM located at that address.
Bank switching the system ROM
After thinking long and hard, I decided to leave the "non-invasive" route and add a little hardware modification to my beloved Genius Leader 4000 Quadro. I opened it up and put wires to the "Chip Select" lines of the ROM, the RAM and the cartridge port. Fortunately, these 3 lines are conveniently located on one corner of the PCB (near the cartridge port) and each go through a wire bridge. It is really simple to cut these bridges and add some wires, so they can be connected/disconnected at will:
On its own, this is not a very helpful mod :)
But now you can insert a ROM cartridge and use a different "Chip Select" pin (the new "internal ROM ~CS" instead of the default "cartridge ~CS" on Pin 35). A slight modification in your code (segment now needs to be 0x0000 instead of 0x8000) and your external ROM cartridge can now act as the internal system ROM! That means: Now we have a full 32kB of additional address space without de-soldering the internal ROM!
But be aware that the internal system ROM also contains crucial hardware initialization functions which now need to be done in our own ROM. This includes the LCD initialization sequence, resetting all the MUXes and bank switchers and -most importantly- reacting to interrupts and polling the keyboard matrix.
My current implementation works fine in the MAME gl4000 emulator, but still has some issues with the LCD (one line is not showing - using a non-standard DDRAM mapping) and the keyboard is not working reliably. This still needs some more research to get right. But enough to continue with some more experiments...
Booting from RAM
But now for the really tricky part: As I said, CP/M needs RAM to be at 0x0000. But since RAM is -usually- volatile, we can not simply solder in a SRAM IC and call it a day. It won't boot, since it is empty.
My current idea is to use the battery backed SRAM cartridge VTech Super Speicher 32KB for that. It contains a 32 kilobyte SRAM IC, as well as a coin cell battery and a few transistors (to invert signals and switch from internal to external power).
It should be possible to boot from a custom system ROM (mapped to 0x0000) while having the SRAM connected to the cartridge slot (mapped to 0x8000). Then, prepare/bootstrap the RAM contents to contain the initial jump instructions. When this is done, ROM and SRAM would "swap places" (remember, the "Super Speicher" is battery backed and won't lose its contents) and the system should now be forced to "boot from RAM".
At least that's the theory.
I tried it yesterday in the late, late evening. And while the initial bootstrapping of the SRAM worked, the system did not boot from SRAM once I swapped it in as "system ROM". The screen just went weird (reset loop?) It seems like there is still some interrupt or timing issue... But I won't give up just yet!
Also, creating the ROM image is not trivial, since it needs to contain code segments that are compiled for the 0x0000 segment, as well as code that is run, once it is mapped to the cartridge port at 0x8000. The current build tool chain now contains some calls to "dd" to extract and merge parts of different binary images. Stuff you shouldn't be doing on a Sunday night at 2am...
Do you have any better ideas to get CP/M running? (e.g. re-locating programs to use 0x8000 instead of 0x0000?) Let me know!
Update: It flippin' works!
I can't believe it: I just fiddled around with the initialization sequence a bit more and... HEUREKA! IT BOOTS FROM SRAM!
Of course, this is not a real CP/M system, yet. But I had to give it a name anyway, so I just went straight for it. "Aim high!", they say ;-)
So: This solves the main issue of getting CP/M up and running: Booting from address 0x0000. I am pretty sure, we will find an even more elegant solution of disabling the internal system ROM (using the "A17" and "A18" lines? Or using the software controlled CAPSLOCK LED for it?). But soldering 2 wires to well-accessible parts of the PCB is already quite easy to pull off.
And suddenly, there is the biggest question yet:
When will it play the original ZORK?
Soon, I hope! Will we master it in 2019? For the holidays? Let's find out together!