My ambition is that Snake, Racer and the setting of the clock in Mandelbrot should all work in this setup. I don't know if that is all realistic, and it very likely requires total assimilation of the PS2keyboard module.
I finally got around to work on this. PS/2 support in BabelFish was completely rewritten and I have just pushed all changes. I hope I didn't break something for the Nano and Micro configurations. Please let me know.
1. PS/2 iterface updates:
- Parity checks on the keyboard data, and properly lowering the PS/2 clock line when busy talking to the Gigatron.
- Better mapping of arrow keys to game controller signals. Support long presses, and holding more than one down at the same time.
- The A button can be activated as [Delete] or [BackSpace] or [End]
- The B button can be activated as [Insert] or [Home]
- The Select button can be activated as [PageDown]
- The Start button can be activated as [PageUp]. So if you press [PageUp] for >2 seconds, the Gigatron resets
- Simply hitting [Ctrl]+[Alt]+[Delete] will conveniently do this tedious holding down for you
- Regular keys are sent as ASCII codes to the Gigatron for 3 consecutive frames (about 50 ms)
- The function keys are mapped to non-ASCII codes $C1..$CC (F1..F12)
- [Ctrl] + function key will send one of the built-in applications to Loader, see below (this used to be the [Escape] key)
Nine GT1 files, all from Apps/ and Contrib/, are stored in the BabelFish memory for immediate sending to Loader. (I will certainly add Gigatris and frogstroll to the list once they appear in the repo...)
- Tiny BASIC
- WozMon
- Terminal (TV Typewriter)
- Blinky
- Bricks game [xbx]
- Lines demo [at67]
- Game of Life demo [at67]
- Starfield demo [at67]
- Tetris game [at67]
For example, to start Tetris, first start Loader and then hit [Ctrl] + [F9].
Of these, 6-9 are absent in the ATtiny85 configuration because it doesn't have sufficient non-volatile memory.
What is not in there:
- Switching between key maps. It (still) defaults to the US layout. The tables are still compatible with the Arduino PS2Keyboard library however.
- Sending PS/2 commands back into the keyboard (so the keyboard leds, caps lock, num lock etcetera all do nothing)
- Actual handling of parity errors by requesting the keyboard to resend (mind that, in reality, parity errors don't really happen...)
PS/2 support is now good enough that typing seems quite reliable, you can get high scores in Snake, Racer is more or less playable, you can set the clock in Mandelbrot and force a Gigatron reset. So in principle the keyboard can take over all game controller functions.
2. The USB serial interface commands were a bit expanded as well:
Code: Select all
:Commands are
: V Show configuration
: H Show this help
: R Reset Gigatron
: L Start Loader
: P[<n>] Transfer object file from PROGMEM slot <n> [1..12]
: U Transfer object file from USB
: .<text> Send text line as ASCII key strokes
: C Toggle echo mode (default off)
: T Enter terminal mode
: W/A/S/D Up/left/down/right arrow
: Z/X A/B button
: Q/E Select/start button
'P' now takes an optional argument to specify the program slot. (Same as the function key number).
'.' sends the rest of the line directly to the Gigatron as ASCII (handy for sending BASIC programs?)
'T' enters terminal mode. This sends all key strokes from your computer directly into the Gigatron. With this you can connect using a terminal program and type directly from your PC/laptop into the Gigatron. For example to type BASIC or even play Snake. Use a true terminal program for the best experience, such as PuTTY, screen or picocom. This doesn't work with the Arduino IDE Serial Monitor, because it doesn't have a "raw" mode. Hit [Ctrl]+[D] to leave the terminal mode and go back to the BabelFish command prompt.
For example, this is how I connect to BabelFish with a terminal program:
Code: Select all
screen /dev/tty.usbmodem1411 115200
Code: Select all
picocom -b 115200 /dev/tty.usbmodem1411
115200 is the baud rate that BabelFish uses. The /dev/tty* name can be a bit different for your computer and operating system. By default there is no echoing of the characters you typed. With the 'C' command you can toggle echo mode ON and OFF. You have to leave terminal mode first to give this command. Echo is useful when typing in BASIC, and a bit annoying when playing Snake.
'V' now also shows the echo status and some useful information about the configuration, such as pin assignment:
Code: Select all
:BabelFish platform=ArduinoUno
:Pins:
: Gigatron data=13 latch=12 pulse=11
: Keyboard clock=3 data=4
: Controller data=-1
:PROGMEM slots:
: 1) Tiny BASIC
[... snip ...]
:Echo off
:Type 'H' for help
:Gigatron OK
With all this, the 'W', 'A', 'S', 'D', 'Z', 'X', 'Q' and 'E' commands are less useful now, but we kept them in anyway.
3. Finally sendGt1.py got a small update
Sending files over USB should be more reliable for platforms that intercept the XOFF character. sendGt1.py detects when it is talking to an updated BabelFish, and then will escape these characters.