Part 7 – The Mouse!
After implementing a pointer-shaped sprite, I naturally just had to bring that sprite under mouse control! So that’s exactly what I’ve done this time round.
The peripheral controller has expanded somewhat, and now provides three programmable timers, and two PS/2 ports.
Since the DE1 board only has a single PS/2 socket, I’ve used the second socket that’s part of the Minimig joystick/mouse adapter I posted a few weeks ago. (The adapter has since taken up residence in a plastic box.)
The PS/2 ports occupy a single word each, at 0x810008 and 0x81000A, respectively, and the arrival of a byte at either port triggers an interrupt. (The low-level PS/2 communiciation is handled by an open-source component borrowed from the Chameleon hwtest project.)
The timers probably deserve a little bit of explanation too. They’re very simple – there are four counters, t0 through t3. There’s a divisor register for all four counters, at 0x810010 through 0x810016, and a control word at 0x81000e which contains interrupt enable bits and status bits for counters t1 through t3. T0 acts as a prescalar for the other three timers, so with the system clock set to 112.5MHz, setting T0’s divisor to 1125 gives the other three timers a 100KHz base clock.
Another major change this time is that the project no longer launches straight into the graphics test. Instead it boots into a simple bootrom which listens on the UART at 115,200 baud, 8N1.
Using these settings, it’s possible to user HyperTerminal to upload an S-Record (as produced by Easy68k) into the memory. The Firmware directory contains a handful of test projects – the most interesting of which is FrameBufferTest.S68. This is essentially the old graphics test, but with the sprite under PS/2 mouse control.
Full source and binary is, as always, available here for anyone who might be interested.