Close
0%
0%

ESP8266 PC-XT Emulator

Improved version of the MCUHacker01's ESP8266 PC-XT Emulator

WSWS
Public Chat
Similar projects worth following
My build of MCUHacker01's ESP8266 PCXT Emulator.

A few years ago, I came across an ESP8266 PC-XT Emulator project by MCUHacker01 and I was amazed by how a small ESP8266 could be used to boot up a DOS. I was quite busy with other projects so I decided to revisit this later. Recently, I had some free time, so I decided to exercise my brain and try to continue with the project.

I understand that many experts have already switched to ESP32 for PC-XT emulation, and there are a few great projects with VGA output and faster speed.  I am planning to try out those projects in the future as well! However, for the time being, I will just make do with those ESP8266 boards that I have and try get the most of out them.

A week ago, I came across an Hackaday.io article by Steve L, who was actually working on the very same project since 2018/2019. Since the project is on Hackaday.io, I decided to post my project here as well. I wish I had come across his project logs earlier, as many of the issues that I encountered were actually described in full details in Steve's project- I could have saved lots of time trying to figure out how to solve them. However, I was also lucky to be able to get through those issues by myself and learnt so much about how an IBM PC-XT works, and also went a bit further than Steve.

The main breakthrough came with the addition of ESP-PSRAM64H SPI PSRAM. However, as I could only get the ESP8266 and the PSRAM to communicate with single line SPI protocol, the RAM access speed was not great. Comparing to the "Standard" IBM PC-XT @ 4.77MHz, the final emulator had a speed varying from 30% to 80% (maybe 90%). Because most games require lots of RAM access, they ran very slowly. Some simple games, such as PC-man and Paratrooper (my personal favourite when I was a kid), ran at almost FULL speed! Besides, I could also do some work with Lotus 1-2-3, although the limited number of GPIOs on ESP8266 mean I would not be able to emulate a printer port to print out what I have done.

Speaking of the I/O ports, I also managed to emulate a serial port using the remaining 2 GPIOs. As there was no more GPIO that I could use (although I did consider recruiting GPIO10), there was no hardware flow control. The slow emulator could only take in serial data at a rate of closer to 300bps. I managed to connect the Serial I/O port (3F8) to an ESP01s Serial Wifi Modem, wrote a simple terminal program with QBASIC, and connected to some BBSes!

Another ESP01s was needed for the Wifi connection as the main ESP8266 Wifi function had been set to deep sleep. ESP8266 Wifi radio consumes Heap, slows down the emulator and generates too many interrupts that seriously affected the video generation.

Please kindly leave your comments if you managed to build one successfully! I will try my best to help if you have any problem getting the emulator to work. Also, please share your improved code, so we can make it even better.

---   

Youtube Videos:

---

List of Features added:

- Added PSRAM as the emulator RAM.

- Disk image address change to 0x100000. Possible of a 1.44M or 2.88M floppy disk image;

- Video mode 2 and 3, 80x25 text mode: Text is still white, and I added a 1-bit background (black or grey);

- Added video mode 0 and 1, 40 x25 text mode: White text, 1-bit background (black or grey);

- Added video mode 4 and 5, 320x200: 2-bit greyscale;

- Added video mode 6, 640x200: B/W only;

- Included character ROM for ASCII 128-255;

- Added cursor display for video mode 0, 1, 2 and 3; 

- Reactivated built-in BASIC ROM;

- Enabled disk WRITE; 

- Added accurate timer ticks (18.2 ticks/second);

- Added PC speaker output (using PWM feature of EPS8266);

- Added PS2 Keyboard code;

- Added Serial port (COM1) emulation;

- Rewrote the MMU swap for the emulated RAM;

---   

RAM:

The addition of the PSRAM was the game changer. Although I couldn't get hold of the ESP-PSRAM64H, but I managed to buy some LY68L6400 (I was told they are actually...

Read more »

plain - 10.59 kB - 12/11/2021 at 13:50

Download

plain - 258.65 kB - 12/11/2021 at 13:50

Download

plain - 1.66 kB - 12/11/2021 at 13:50

Download

plain - 9.45 kB - 12/11/2021 at 13:50

Download

plain - 5.40 kB - 12/11/2021 at 13:50

Download

View all 9 files

  • 1 × ESP8266 NodeMCU ESP8266 project board
  • 1 × ESP-PSRAM64H or LY68L6400 SPI PSRAM

  • Flash ROM upgrade, addition of 12MB HDD and Windows 3.0

    WS01/26/2022 at 08:03 0 comments

    26-Jan-2022: Over the weekend, I finally had some free time to spare. Therefore, I removed the shield on the ESP8266 module and replaced the 4MB flash ROM with a 16MB W25Q128 flash ROM. With the extra capacity and a few lines of codes, I fitted a 12MB "Hard Disk" to the emulator. After marking the drive "Active" using FDISK, and initialising it with FORMAT /s, the emulator can now boot up from the new "Hard Disk".

    Out of curiosity, I also spent some time installing Windows 3.0 onto the new drive. It took me about 2 hours to complete the installation. Although it was not easy to navigate without a mouse, Windows 3.0 worked perfectly with my keyboard! However, as expected, it was extremely SLOW- It would take about 5 minutes just to get to Program Manager. Nevertheless, it was pure fun! A picture of the WIndows 3.0 "About" dialogue box is included. 

View project log

Enjoy this project?

Share

Discussions

Steve L wrote 12/29/2021 at 00:28 point

One of the things that might be a "gotcha" to anyone trying this is the keyboard. I have found that old-time, period correct keyboards (old Dell's, for example) will work with this code and hardware, but "newly manufactured" PS/2 keyboards (and/or keyboards sold as "PS/2 compatible" with a USB to PS/2 adapter) may not work. A clue to a non-working keyboard may be  a continuously flashing light on the ESP chip upon bootup of the code. I have not investigated this further,.

  Are you sure? yes | no

WS wrote 12/29/2021 at 12:44 point

Thanks Steve for trying out the code. The current PS/2 keyboard code only receive data from the keyboard without sending command/ack to the keyboard. This is the reason that it only works with pure PS/2 keyboard. Also, the Caps/Num/Scroll Locks are not working because of the lack of two-way communication.

I suspect that most PS/2-compatible USB keyboards start as a low-speed USB device, with D+ low and D- high. However, ESP8266 requires both lines (GPIO0 and GPIO2) to stay high at boot. Therefore, the ESP will not start and keep resetting (hence the flashing light).

To solve this, we might need to figure out the command to be sent to the keyboard, and perhaps also need to use a different set of GPIOs for the keyboard.

  Are you sure? yes | no

Steve L wrote 12/26/2021 at 00:37 point

I had been thinking along the lines of using PSRAM when I stopped working on this, so I had added a PSRAM I got off of an ESP32 camera board (not a cheap way to get one, but I wanted a spare camera anyway, and at the time there was almost no other way to get a PSRAM).  I put in on a DIP adapter and tested it, it was good to SPI to 70 Mhz with my test code. I never integrated this into my code. I took the code you wrote here, modified my board to use the keyboard and PSRAM select pins that you used, and it worked at 70 Mhz. Then I tried it at 80 Mhz, and it also worked. Don't know why my test software was so demanding.

As of right now, I didn't implement the speaker or serial port hardware;  my board isn't really big enough for those so I might make a daughterboard for it, but your code worked! Congrats!


BTW, I thought that I would try "FreeDOS",  and there were some compatibility problems (or possibly the limitations of the emulation). MS-DOS 6.22 worked pretty well albeit slowly on INT driven input and output.


I was thinking of trying the IBM BIOS, but a problem with that is that AFAIK the only way to get into ROM Basic with an original XT is to have no other bootable devices. So, if I decide to try to use that, it will take some kind of emulation dependent key state to signal this for convenience. Also, the original PC BIOS wouldn't boot without a keyboard as I recall.

  Are you sure? yes | no

bob099 wrote 12/26/2021 at 01:48 point

ROMOS might give you some hints to solve some problems.

https://rayer.g6.cz/romos/romose.htm

  Are you sure? yes | no

WS wrote 12/29/2021 at 12:53 point

Thanks Steve and bob. 

I am glad that the PSRAM code works for your setup. 80MHz is the max clock freq for ESP8266 peripheral SPI (at both 80MHz and 160MHz clock speed). If we want to go faster, we will need to figure out how to change the SPI protocol to the QIO mode.

I have not tried "FreeDOS", since I have only been using MS-DOS since I first started using the original IBM PC. I agree that the incompatibility is likely a limitation of the emulation (FAKE86). 

Besides, I have been using the BIOS provided in the original code. Maybe the "FreeDOS" will work better with original IBM BIOS. I will look for a copy of the BIOS and FreeDOS to test out the emulator.  

  Are you sure? yes | no

Ken Yap wrote 12/17/2021 at 07:27 point

It's really quite amazing, when you think of the advances in computing. A MCU board costing a few bucks emulating a decades old machine that cost hundreds to thousands of bucks in its day. 🤔

  Are you sure? yes | no

WS wrote 12/17/2021 at 15:38 point

Yes, indeed! However, I must admit that we are only doing a partial emulation and there are so much more that original machine can do. I really admire those engineers who built the original PC-XT in the 1980s! 

  Are you sure? yes | no

Steve L wrote 12/16/2021 at 22:09 point

I lost interest in this with focus on other emulators that I was working on, and I wasn't sure if getting this working was technically possible by anyone, much less me. My code was too awful to share. Congratulations on making this work! I was working with the original XT BIOS and BASIC ROMS to make this emulation as authentic as possible.

The code originally written by MCUHacker01 has been invaluable for me in other projects.

  Are you sure? yes | no

WS wrote 12/17/2021 at 14:52 point

Thanks Steve! I find your other projects really interesting as well! I did try your term8008 project and it works really well.

If you have the time and opportunity to try out my code, please kindly provide me some feedback. I am planning to port the project to ESP32 too, but I guess it won't be too soon in the future...

  Are you sure? yes | no

aldolo wrote 12/11/2021 at 05:04 point

nice. is the source code available?

  Are you sure? yes | no

WS wrote 12/11/2021 at 05:52 point

Thanks. I will share the code very soon. Still trying to complete the description part...

Besides, I will need to tidy up the code- lots of comments which are actually meant for myself.

EDIT: Source Code is now uploaded.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates