1 Answer

Multi Sources Checked

Building custom mouse support for an IBM PC/XT is a fascinating challenge, bridging the world of early 1980s hardware with the expectations of modern interactive computing. If you’re aiming to implement your own mouse event handler—whether for gaming, graphical software, or just for the satisfaction of classic hardware hacking—you’ll need to navigate hardware limitations, protocol quirks, and software compatibility headaches unique to the era. Short answer: To implement a custom mouse event handler on an IBM PC/XT, you typically need to interface with a serial (RS-232) or bus mouse at the hardware level, write or adapt device driver code (often in 8088 assembly), and create a software interrupt handler (such as for INT 33h) that interprets mouse signals, updates cursor state, and communicates with your application or DOS environment.

Let’s break down exactly how this can be achieved, what obstacles you’ll face, and what concrete steps and details you’ll need to keep in mind.

Understanding the XT Mouse Landscape

When the IBM PC/XT was released, mice were not standard peripherals. Most XT-class machines shipped without any mouse support in the BIOS, and there was no standardized mouse port as later seen on PS/2-era machines. According to multiple discussions at vcfed.org and historical retrospectives, the most common mouse types available for XT machines were the Microsoft Bus Mouse (which required a dedicated ISA card) and serial mice that connected to the RS-232 ports. “Serial mice were also very popular then. You need an RS232 port for those,” as noted by users on vcfed.org, confirming the period-correct setup.

IBM itself only released its own branded mouse for the RT PC in 1986, shortly before the PS/2 line arrived with dedicated mouse ports (as krebizfan notes on vcfed.org). For most XT systems, if you wanted mouse input, you bought a Microsoft or Logitech serial mouse, or occasionally a bus mouse with its own card (see mcamafia.de via vcfed.org).

The Hardware Side: Serial, Bus, or PS/2?

If you’re working with original XT hardware, your best bet is the serial mouse route. These mice communicate over standard COM ports, using a relatively simple protocol (typically 1200 baud, 7 or 8 data bits, no parity). The Microsoft serial mouse protocol, for example, uses three-byte packets with bits encoding X and Y movement, and button states.

Bus mice are a bit more involved, requiring a dedicated card and special I/O port reads to get their status, but the overall principle is similar—you read movement and button status, decode it, and act accordingly.

Modern PS/2 and USB mice are much trickier. As described in detail on bit-hack.net, “Those mice use a very different protocol,” and the XT BIOS “lacked support for such modern peripherals.” PS/2 is a bidirectional protocol and requires more complex host-side logic to poll the mouse and interpret its responses. Attempting to connect a PS/2 mouse directly to an XT is not practical unless you build or buy a dedicated hardware protocol converter—often based on a microcontroller (as discussed extensively on vcfed.org).

For a custom build, you could theoretically use a microcontroller (such as an Arduino Pro Mini or STM32F103 board, both “stupid cheap—and 5V tolerant,” according to vcfed.org) to translate modern mouse signals (USB or PS/2) into serial mouse protocol, then feed that into your XT’s serial port. There are community projects converting PS/2 to serial, and even more ambitious ones tackling USB to XT/AT keyboard conversion, but USB mice are especially problematic since they often lack “legacy” modes required for simple adapters (vcfed.org).

Writing the Mouse Event Handler: Assembly, Interrupts, and DOS

Once you’ve got a mouse connected—whether through a serial port, bus card, or a custom protocol converter—the next challenge is writing the software to actually use it. Here’s where you need to roll up your sleeves and get into 8088 assembly or low-level C.

The standard approach in DOS-era software is to install an interrupt handler, typically on INT 33h, which is the de facto mouse services interrupt. Many DOS mouse drivers (like Microsoft MOUSE.COM) provide this interface: programs issue INT 33h calls to show/hide the cursor, get position, read button state, and so on. But on a bare XT with no mouse driver, you need to provide this handler yourself.

That means you’ll need to:

- Initialize the serial port (COM1 or COM2) to the correct baud rate and settings for your mouse. - Write a routine to read incoming bytes from the serial port, interpret the packet structure (often three bytes per update), and decode X/Y deltas and button state. - Maintain internal state: current mouse position, button status, and possibly bounds checking so the cursor doesn’t leave the screen. - Hook INT 33h (or another interrupt of your choosing) so that your application, or any other DOS program that expects a mouse, can call your handler to get mouse events. - Optionally, provide routines to draw a graphical cursor, since BIOS text mode cursors do not exist in graphics modes (as Stack Overflow’s discussions clarify). You’ll need to “draw the cursor by yourself, I’m afraid,” and handle erasing/redrawing as the cursor moves.

For example, if your application runs in 640x350 EGA graphics mode, the BIOS won’t provide a text cursor. You’ll need to write code that manipulates video memory directly, drawing a custom cursor graphic wherever the mouse moves. Stack Overflow users suggest XOR’ing an 8x14 rectangle at the cursor position to create a blinking effect, but you must be careful to restore the background as the cursor moves or when the screen updates, possibly intercepting INT 10h calls to keep everything in sync.

A Practical Example: Mouse Handler Skeleton

Suppose you’re writing this in assembly. You’d set up your serial port, then establish an interrupt-driven or polled loop to read mouse packets. For each packet, extract X and Y movement and button status, update your internal coordinates, and possibly trigger a redraw of the cursor. When your handler is called (via INT 33h), you’d return the current state in AX, BX, CX, or DX registers according to the DOS mouse API conventions.

If you want your handler to be compatible with DOS applications expecting INT 33h, you’ll need to implement at least the basic functions: show/hide cursor, get position and button state, set position, and so forth. Documentation for the Microsoft Mouse Driver API is widely available and provides a template for the interface.

Integrating With Games and Applications

Some games and DOS applications (like Monkey Island, as referenced on bit-hack.net) expect a specific mouse driver to be loaded, or they interact directly with the hardware. If you want your handler to be drop-in compatible, you must mimic the behavior of Microsoft’s MOUSE.COM or similar drivers. This means careful attention to interrupt vectors, register usage, and keeping your handler re-entrant and efficient.

If you’re writing a custom application (for example, your own game or graphics program), you can bypass the DOS mouse API and interact with your handler directly, possibly for greater performance or custom features. However, this limits compatibility with existing software.

Special Considerations: Timing, Compatibility, and Testing

The IBM PC/XT’s 8088 CPU is relatively slow by modern standards, so your handler must be efficient. Serial mouse data can arrive at any time, and you must be ready to service the port quickly to avoid losing packets. This is why many commercial mouse drivers use hardware interrupts (triggered by the UART) to read incoming data.

If you’re using a microcontroller to translate PS/2 or USB mouse data, make sure the output is faithful to the expected serial protocol. Some universal mice have a hardware switch to select serial or PS/2 mode, as discussed on vcfed.org: “I have a universal mouse that can be used as either a Serial Mouse (adapter required) or PS/2 mouse at the flick of the switch underneath.” However, most modern USB mice lack this hardware compatibility and cannot be used with simple passive adapters.

Testing is essential. Be prepared for odd behavior: missed movements, jittery cursor, or loss of synchronization between mouse and screen. Use diagnostic tools, and consider writing a simple test program that displays live mouse coordinates and button states.

Modern Approaches: Emulation and FPGA

For those building hybrid or replica XT systems using FPGAs, as described on bit-hack.net, mouse support can be implemented at the hardware emulation level. This allows you to create a custom interface (for example, mapping PS/2 or even USB mouse input to a virtual serial port), and then use your handler as if it were running on original hardware. However, “the BIOS I was also lacked support for such modern peripherals,” and the “PS/2 is a bidirectional protocol, and the mouse has to be asked by the PC to broadcast updates, otherwise we will not receive any.” This means you must implement both the hardware interface and the software stack yourself.

Concrete Steps and Key Details

Let’s summarize the nuts and bolts using checkable details from the sources:

- The original XT did not have a mouse port. Serial mice or Microsoft Bus Mouse (with ISA card) were standard (vcfed.org, bit-hack.net). - Serial mouse protocol is typically 1200 baud, 7 data bits, no parity, 1 stop bit. - Mouse drivers (like Microsoft MOUSE.COM) hook INT 33h to provide a standard API for DOS applications (stackoverflow.com). - In graphics modes, BIOS does not draw a cursor; your handler must draw and erase the cursor manually (stackoverflow.com). - Microcontrollers like Arduino Pro Mini or STM32F103 are commonly used to bridge modern mice to XT protocols, especially for keyboard but also for mouse (vcfed.org). - Early IBM-branded mice were rare and not designed specifically for the XT; most users relied on third-party serial or bus mice (vcfed.org). - PS/2 and USB mouse support requires protocol translation, not just passive adapters, and most modern mice don’t support legacy protocols (bit-hack.net, vcfed.org). - To maintain compatibility, your handler should mimic the Microsoft Mouse Driver’s INT 33h interface. - Efficient interrupt-driven handlers are needed on the 8088 to avoid missing serial data. - For FPGA/XT replicas, you can map PS/2 input to a virtual serial port and run your handler as if it’s reading a real serial mouse (bit-hack.net).

Final Thoughts

Implementing a custom mouse handler for the IBM PC/XT demands a mix of low-level hardware knowledge, careful attention to ancient protocols, and a willingness to write or adapt device driver code in 8088 assembly. While the job is challenging—especially if you want to use modern mice—it’s entirely feasible, and there’s a rich community of enthusiasts and open-source projects to draw inspiration from. As one vcfed.org user put it, “You can do anything with a microcontroller—all it takes is—CODE.” By understanding the historical context, available hardware, and needed software interfaces, you can bring the humble XT into the world of point-and-click.

Welcome to Betateta | The Knowledge Source — where questions meet answers, assumptions get debugged, and curiosity gets compiled. Ask away, challenge the hive mind, and brace yourself for insights, debates, or the occasional "Did you even Google that?"
...