Right, so that was a adventure and a half!
So it seems someone had been telling me porkies at some point...
Long story short, there is now a new compiled from the most recent STOS sources for BASIC208.PRG. I've simply called it 209 because there are just so many versions of it it is just crazy to keep calling them all the same name.
It would help if people could try STOS from here
https://www.exxosforum.co.uk/atari/STOS ... OS1904.zip
and try the 209 loader on ST, STe, Falcon etc. things to make sure is that the mouse and keyboard work in editor and that it exits cleanly back to the desktop. One of the original faults was that when going back to guest upon the Falcon the colours would all get messed up.. Of course different TOS versions and the keyboard tables in different places hence the need to check them. If the new loader works on every machine I will add it to my website as a update..
Now for the technicals...
STOS Keyboard Fix for ST536 / Custom TOS 2.06 Builds
The Problem
When running STOS on the ST536 accelerator with a custom-built TOS 2.06 ROM, shifted keys did not work correctly. Pressing Shift+A, Shift+/, or any Shift+number key produced either no character or the wrong character. Unshifted keys, Caps Lock, and mouse input all worked normally.
The problem appeared to be hardware-related at first, as it only occurred with the ST536 accelerator board and not with a stock 68000. Extensive testing of the m6800 bus module, CPLD firmware, and bus timing revealed no hardware fault.
The Investigation
Testing showed:
- The GEM desktop and accessories handled shifted keys correctly
- Only STOS was affected
- STOS's INKEY$ function returned ASCII=0 for shifted keypresses, while the scancode was always correct
- The TOS keytable pointer at address $10F2 (the shifted keytable pointer within the _curkeytbl structure) was being overwritten during STOS operation, specifically after every PRINT statement
- A fresh boot showed the shift keytable correctly pointing to ROM ($E33738), but after STOS ran, it pointed to an address in the TPA ($3742C) where the data had been overwritten by STOS's own code
A diagnostic tool (KEYTEST.TOS) was written to dump the keytable pointers, memory boundaries, and table data. Running this before and after STOS confirmed the corruption. The tool also tested LINE-A, Keytbl, Kbdvbase, Getrez, and Cconws calls to determine if any standard TOS function was responsible — none were.
Further testing revealed:
- Original unpatched TOS 2.06 ROM: STOS worked correctly
- EmuTOS: STOS worked correctly
- Custom-built TOS 2.06 (with startup.S/floppy.S patches): STOS failed
This narrowed the problem to an interaction between STOS and the custom TOS build.
The Root Cause
The STOS loader (BASIC208.TOS) contains a data table of TOS internal addresses used to set up the "adaptation table" — a structure passed to STOS modules (SPRIT, WINDO, MUSIC, BASIC) containing pointers to TOS internal variables such as the mouse coordinate buffer, keyboard IOREC, VDI tables, and interrupt vectors.
The binary version of BASIC208.TOS on the floppy had these addresses
hardcoded from a previous TOS build. When the TOS 2.06 ROM was rebuilt with patches to startup.S and floppy.S, the BSS (uninitialised data) section shifted by $B32 (2866) bytes. This moved all TOS internal variable addresses, including the _curkeytbl keytable structure from its original position to $10EE.
The stale hardcoded addresses in BASIC208.TOS now pointed to wrong memory locations. During STOS operation, writes through these incorrect pointers accidentally overwrote the _curkeytbl+4 entry at $10F2, which holds the pointer to the shifted keytable. TOS's keyboard interrupt handler then read the corrupted pointer and looked up key translations from garbage memory instead of the ROM keytable, producing ASCII 0 for shifted keys.
On the original unpatched TOS 2.06, the BSS layout was different and _curkeytbl was at a different address that didn't collide with the stale pointers, which is why the problem only appeared with the custom build.
The Fix
The BASIC208.S source file already contained the correct approach: using runtime XBIOS and LINE-A calls to determine TOS internal addresses dynamically, rather than relying on hardcoded values. Specifically:
- Iorec(1) (XBIOS 14) for the keyboard buffer IOREC pointer
- LINE-A $A000 for mouse and VDI table addresses
- Direct basepage/memory inspection for other values
The fix was simply to
recompile BASIC208.S from source to produce a new BASIC208.TOS, replacing the binary with its stale hardcoded addresses.
The source required minor case-sensitivity fixes for the GenST assembler:
Code: Select all
START → start
Cmdline → CMDLINE
exit → EXIT
Copy_Path → Copy_path
adapt+2 → Adapt+2
Extend → extend
name → NAME
After reassembly and replacing BASIC208.TOS on the STOS floppy, all shifted keys work correctly.
Lessons Learned
- When rebuilding TOS from source, any program that uses hardcoded TOS internal addresses must also be rebuilt. The BSS layout changes whenever code is added or removed, shifting all variable addresses.
- Runtime address discovery is always preferable to hardcoded addresses. The BASIC208.S source already used the correct approach (XBIOS/BIOS calls); only the binary had been hand-patched with shortcuts.
- What appears to be a hardware timing issue can have a purely software root cause. The symptom (shifted keys failing only on the accelerator) initially pointed to bus timing, ACIA overrun, or 6800 bus cycle problems. The real cause was a stale address table in a 35-year-old BASIC loader.
Credits
Debugging and analysis performed collaboratively between Chris (exxos) and Claude (Anthropic), April 2026.