Anyway, at the time it seemed like a good idea to have a program which intercepted WRCHV and emulated (say) a VT100, allowing the CP/M program to remain unmodified. The problem was just tricky enough and time was limited enough that I never got it off the ground back then. Inspired by all the recent Matchbox goodness, I've now revisited this idea and produced a hacky proof of concept which just does enough to handle a few minutes' play on The Hitchiker's Guide To The Galaxy. (I have never actually executed the code on real hardware, though; I've been using B-Em to test it.)
If anyone would like to have a quick play with it, I've attached a zip file which contains the source code (for beebasm) and the generated SSD image. The SSD image contains the ROM (which has to run from sideways RAM at present, as it uses SWR for workspace) and a simple BBC BASIC program to exercise the control codes. (This works fine with 6502 BBC BASIC and no second processor; that's how I've been doing a lot of my testing.) So you can do something like:
*SRLOAD TERMROM 8000 7 Q
[observe the garbled display; press a key to finish the test]
[observe the gloriously formatted text; press a key and it will erase part of the screen]
You can enable this from within CP/M using the 'STAR' command: STAR T
(Why '*T'? Because I didn't want to spend any time writing a proper command parser. It's case-sensitive too, so '*t' won't work either.)
This is a very hacky implementation and if you give it escape sequences it doesn't recognise it could well crash or swallow all terminal output indefinitely.
Having now satisfied myself that I can do this, I am wondering:
- has this already been done properly?
- is this potentially useful?
- is there any fundamental flaw in this approach I've overlooked?
- does anyone have an interesting CP/M program which needs half-decent terminal emulation I could use as a test case?
PS Maybe I've just got smarter as I've got older , but this seemed a lot easier to write today than it did fifteen years ago. I suspect increased quantities of obscure technical documentation on the internet combined with screens big enough to read a document and work on something simultaneously help a lot...
Edited to add: Attached an updated version, it's still pretty half baked, but I've at least got a vaguely sane bit of code to interpret escape sequences using a state machine now. It should also make a half-decent attempt at letting ordinary Acorn VDU sequences pass through unmolested. (The new scrolling region implementation is incomplete and completely broken, but the VT100 control codes which worked before still work.)
ETA2: I've continued to fiddle with this. I'm actually fairly optimistic a pretty decent VT102 emulation can be implemented in this way. I am back at work tomorrow so that might slow progress, but right now I'm trying to restructure the code so it's not quite such a dog's dinner and get the basic emulation complete, then with luck I can hook up an emulated BeebEm machine running my code as a serial terminal to my Unix box and give vttest a whirl. I'm still not sure if it's useful, but it's currently sufficiently fascinating that I almost don't care. If anyone does have any interesting CP/M software I could try as a test case I'd be interested though.