ESP8266 PCXT Emulator Build Notes

Note: This has been made 100% functional by WS,  project at:


https://hackaday.io/project/183023-esp8266-pc-xt-emulator


WS's code works, and I will probably not be going further on any development here. I may attempt to add keyboard out capabilities so that more keyboards will work properly and other BIOS's that require a working keyboard can be used. This might require changing GPIO assignments and may also require removing the serial I/O emulation. The ESP8266 has many "gotchas" on the GPIO's and what you can do with them (and when, especially in the boot process).


Pics or it didn't happen, so I added photos of WS' code working. I made a case for my project over Christmas. I couldn't get the nice 1/4" oak that I use for project boxes so I used poplar.  Because of my "old school" construction techniques, ways, and equipment, I used a MAX232 to convert the serial I/O to RS-232 and a DB-9 connector.


I saw this project here on Hackaday ( https://hackaday.com/2018/02/26/pc-xt-emulator-on-esp8266/ ) and I just had to try it, to complement my 8008 and 8080 ESP8266 emulators. For you "kids", the original PC or PCXT with any kind of RAM or disks was very expensive, way beyond what a young person would buy straight out of college such as myself. The only way I could afford one was to solder up a bare board with parts, install it into a wooden box, build a (linear) power supply for it (I didn't have a prayer of building a switcher from scratch 35 years ago), get a (quite expensive) CGA card for it, and hook it up to a surplus black and white "monitor" that I had (which was basically de-contented, tuner-less 9" Admiral TV guts inside from the late 1960's). So, this machine emulates my first PC fairly closely.

 The emulator works, and it's amazing. The video is pretty darned good on my 9" Sony studio monitor.  The circuit on MCUhacker's website is missing a value for the output cap; I used 100uF and the video was fine. The video code itself will be very useful for me in other projects, although I can't believe that it would be compatible with highly interrupt driven WiFi (but, who knows). The emulator version posted on MCUhacker's site is incomplete and has a few oddities and bugs. I thought that I'd try to "fix" (i.e., "hack") it with my limited skills.

I had a bit of compiling trouble  due to some formatting issues in the code, but I straightened those out. I could not get the boot to MS-DOS working, but I'm saving that for last.

I knew that the keyboard was missing, so I thought that I'd put together some PS/2 code, and then combine it with a PCXT converter (both of which exist on GitHub). This was trickier than expected. The PCXT code was missing some key translations, so to speak, so I added them; a bigger problem was the levels between the +5 keyboard and the 3.3V of the ESP8266. Nonetheless, with 200 ohms between them and 4.7K pull downs at the ESP8266, I believe that I got this to (mostly) work, by making "fake open collector" outputs at the ESP8266. The keyboard pulls up to +5 through probably 10K resistors; when I want a "1" on the line, I turn the ESP8266 into an input and those resistors pull up to +5; when I want a 0, I turn it into an output which "shorts" the resistors to low. The keyboard to ESP communication works OK, but I cannot get the communication working yet from the ESP to the keyboard. Nonetheless , it worked, although the code is "big" and pushed the already strained size of the emulator up to using 88% of the RAM (although the tables are in ROM). I will work on shrinking this later.

The keyboard code was integrated into the emulator code via new "ports" for 0x60 and 0x61 (the 8155). I removed the fake int 16 handler. The "boot self test" 0xAA keycode creating procedure was also written.
After doing this, I can report that the emulator's speed is rather good computationally and good in writing video through int 10h (through direct RAM access, it's extremely fast and flicker free).

The second problem I tackled (not really a "problem") were the funny squiggles on the BIOS screen next to the "equipment list" (CPU, video) upon boot-up. I noticed this also when running ROM BASIC. It occurred to me that this involved line drawing characters, which were missing in the emulator's table. I actually found a source for these that I believe to be accurate, added this to the preexisting character lookup (only up to 0x7F) and now I could see the proper line drawing characters and BASIC didn't have them anymore either.  I'm unsure if this is a BIOS shortcoming or an emulator shortcoming (there is an interrupt that points to the location of this table in RAM, but in the BIOS, AFAIK, it points to zero, nonexistent). So, I wonder what this BIOS looks like when installed in a real machine with a CGA board - but who would do that even in the late 80's, much less, nowadays?

The third problem I faced was that for some reason, BASIC believed that it had a 12-line screen and scrolling did some very funny things. I puzzled over this, wrote some test code to prove that it was not in the video generation code itself, wrote additional emulation for the "planar board" DIP switches to read the way I wanted them to read (CGA installed), but still no luck. I even bumped the screen memory from 4000 to 4096 (25x80 = 2000; who knows what the BIOS might do with those 96 bytes). Still, nothing. 

It wound up, that in CPU.C, changing the " & 2047" to "& 4095" on the memory read and write to the CGA memory space solved this problem and now BASIC shows the full 25 lines.

So, where I stand is:

*The keyboard needs to be gone through so that every key on the XT can be emulated
* MAYBE I can get the caps lock/scroll lock lights working (on my Dell keyboard, the numeric lock LED is handled by the keyboard itself).
*The disk won't boot for some reason