Posts

Showing posts from May, 2023

Exploring CGA Wait States

Image
In order to accurately emulate cycle-counted demo effects such as the Kefrens bars effect in 8088MPH, or the end credits in Area 5150, there are essentially four prerequisites: Cycle-accurate 8088 CPU emulation including processor instruction queue emulation Cycle-accurate CGA CRTC emulation Accurate DMA emulation for DRAM refresh Accurate CGA wait state emulation Item #3 was covered in my last blog entry . This article will discuss the last item, CGA wait state emulation. ISA Peripherals and I/O CH RDY The number of wait states that the CPU inserts on each access to the CGA memory depends on the amount of time that the CGA card suppresses the I/O CH RDY signal, which is on ISA bus pin A10.  ISA bus pinout, courtesy Wikipedia This signal reaches the motherboard and is passed through miscellaneous TTL logic (on Sheet 2 of the Technical Reference) to eventually connect to the RDY pin on the 8284 clock generator, which in turn produces the READY signal to the CPU. When READY is low during

Exploring DMA on the IBM PC

Image
DMA, or Direct Memory Access, is a scheme that allows peripherals access to system memory without the assistance of the CPU, which normally would require the use of 'mov' instructions to shuffle data around. With DMA, a hard disk controller can read and write to memory itself.  However, the CPU and the DMA-requesting device must not attempt to use the memory bus at the same time. Some sort of coordination is required, and there are as many schemes to accomplish this as there are computer architectures. Here we will discuss the DMA design and implementation of the original IBM PC and XT. DMA and Emulation Emulating the IBM PC using the IBM BIOS requires implementing the Intel 8237A DMA controller. There's not much of a way around it - DMA was used by the floppy drive controller and the BIOS will not attempt PIO mode, so unless you are content to fiddle around in ROM BASIC for eternity you will need DMA at some point. The easiest thing for an emulator author to do is just hav

Introduction

Image
Over the past year, I have been writing an emulator for the original IBM PC Model 5150, and its slightly more advanced brother, the IBM XT Model 5160. These systems are the original ancestors of the modern PC, both released in the early 1980's. This project is both my first emulator, and my first project in the Rust programming language. A lot to learn all at once. I would recommend that most people starting out in emulation begin with writing a 'Chip-8' emulator. The Chip-8 is a fantasy 8-bit console with a simple instruction set. There are a wealth of learning resources and tutorials available to guide someone through emulating it.   I had a tiny bit of assembly language experience from reading Randall Hyde's Art of Assembly ages ago, and in the 00's had reverse-engineered a bytecode interpreter for an adventure game engine (that would eventually make its way into ScummVM ), so I felt I had enough experience to feel confident enough approaching PC emulation direc