Improved timer and mouse emulation in nevermore

In this post we’ll be taking a look at my latest hackery on Alistair Bridgewater’s ‘nevermore’ emulator for the TI-Explorer.

8253/8254 Timer emulation & RTC fixes

I’ve hacked sufficiently on the programmable interval timer (PIT) emulation such that the timer now passes the extended PROM tests. This required deriving the 1MHz input and timer daisy chain from timer 1 to timer 2 from the 7MHz microcycle clock, and posting the right events in the event generator. There’s still some nuance I’m not convinced I understand with when a timer is enabled after loading its counting registers, but I think I have the logic mostly correct.

Hacking the timers also required improving the logic for the real time clock (RTC). The RTC is driven from a separate 32768Hz crystal, and in the test logic gets compared against the long interval timer to measure when 30mSec has passed. The test logic verifies that both the RTC compare interrupt and the long interval timer fire at the 30mSec mark.

nevermore-9-22-2021-1.png

It appears that when Lisp is loaded in the emulator, the emulation is going so fast that the key-repeat is triggered in the Lisp’s keyboard handling. We can work around this, however, since some mouse emulation support has been added.

Mouse Emulation

Mouse action and buttons sort-of work, thought there still appears to be some scaling and acceleration issues.

In sib-xlib.lisp I added :pointer-motion, :button-press, and :button-release to the event mask, and trap the appropriate events in check-events. There’s a bit more work in converting X button events into the proper values in sib-keyswitch-data-register, then post to event 10 in the Event Generator. Mostly. I don’t quite understand the logic here, as interrupts are turned on yet event 10 isn’t initialized yet by the microcode…. nevertheless it works.

This is sufficient to get the mouse pointer moving around. Even though the X and Explorer pointers get desynched, it’s straightforward to push the Explorer pointer around to the edges to force the pointers to agree enough to cover all of the Explorer window area. I think that if I read back the position from the Explorer registers and set the X pointer position, I can get the dots to connect. I’d probably have to add some additional logic to turn pointer tracking on and off, as well.

Now that we’ve got some spiffy mouse action, we can use the Explorer menus to turn off the initial repeat delay in Explorer. Double-click Right mouse to raise the System Menu, then select ‘User Profile’. It will take a moment for the User Profile editor to come up. Then select ‘Input Variables’ from the Variables currently displayed: section below at the bottom of the screen, then set TV:INITIAL-REPEAT-DELAY to 0.

nevermore-9-22-2021-2.png

Figure 1: Editing TV:INITIAL-REPEAT-DELAY via the User Profile editor.

To save the current configuration for the current run, just select the Exit action.

All this allows us a lot more opportunity to dig around in the Explorer and see what works and what’s still broken.

Note that the changes to TV:INITIAL-REPEAT-DELAY won’t persist, so one will have to make the change at every boot of the emulation.

Next Steps

There’s a lot remaining to do, but I think it’s useful to put the work in context of some eventual goals. What I’d like to do is write a verilog implementation of the micro machine, and run a (modified) Explorer on an FPGA. I spent a little while off in Unix-land with https://lisp-machine.org/self-hosting-unix-system-v-release-4-i386/ and http://cpu-ns32k.net/, getting a feel for what the art of the possible might be, and even have an Altera Cyclone V GX board on order to play with Udo Möller’s M32632 verilog implementation of the National Semiconductor NS32532 chip.

Along the lines of an FPGA implementation I think there’s some ideas that can be leveraged from the Squeak Smalltalk VMMaker, where the virtual machine is composed in a stripped down version of the language, then translated to verilog. Sadly I’m still a pretty crufty Lisp programmer so, something like that would be an adventure…