Kjetil's Information Center: A Blog About My Projects

Commodore PC 20-III Emulator Update

I have made some quick updates to my pc20iii emulator. Two notable bugs have been fixed that caused some software to crash, and support has been added to do passthrough of the RS-232 COM port to a real TTY on the Linux host.

The first interesting bug was that sometimes DMA writes from the floppy drive would overwrite the memory, typically the stack, when it shouldn't have. This happened because a DMA write can be initiated while the DMA controller is in "verify" mode, and then it should not do any writes. Adding preliminary support for the DMA mode register solved this issue.

The second interesting bug was that the ESC instructions on the 8088 CPU was not correctly handled. While not actually supported in version 0.1, I had mistakenly assumed the instructions were only 1 byte, but it can actually vary in size, so in some cases the wrong opcodes would be fetched. Properly handling the ModR/M byte fixed this. The ESC instructions are typically used to talk to the 8087 floating point unit, so software that tried to probe that could crash.

The COM port passthrough supports the typical standard baud rates and will forward the baud rate set by the software inside the emulator out to the host. Note that hardware flow control is currently not supported, so the incoming CD/DSR/CTS signals are just set high while the outgoing RTS/DTR signals are ignored. Large FIFOs are implemented in both directions to handle variations in speed compared to the inside of the emulator and the outside world. Trace can also be dumped in the debugger, which is handy for sniffing traffic.

Some adjustments were done to the curses keyboard handling. The F11 key is no longer just sending the "Alt" key but is toggled on to be sent together with the next key, making more combination key presses possible. Some "Ctrl" key combinations are now also possible, as long as they are passed on to the emulator program.

Here is a screenshot of CheckIt 3.0 doing a very inaccurate CPU speed benchmark:

Emulator fake CPU speed benchmark.


You can download the updated version 0.2 here or check the Git repository.

Topic: Open Source, by Kjetil @ 03/05-2024, Article Link