REV 3 - REV 5 - The beginning (ST536)

All about the ST536 030 ST booster.
User avatar
exxos
Site Admin
Site Admin
Posts: 28614
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by exxos »

I've just come across a really weird keyboard issue :roll: the odd thing is that only acts up in STOS.

Basically the shift key works, and all the letters work, but if I hold down shift and press the letter, nothing appears on the screen.. So the keys both work individually but not together ?!

I found a small text editor ACC, and repeated the tests on the gem desktop, and everything works fine. So this would seem to be a bug in STOS somewhere.
User avatar
exxos
Site Admin
Site Admin
Posts: 28614
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by exxos »

So according to AI after testing all day..
The issue is that your TOS patches shifted the BSS by $B32 bytes, placing _curkeytbl at $10EE. On the original TOS, _curkeytbl was at a different address. STOS writes to $10EE through some indirect path that we haven't been able to trace, but it only causes a problem because _curkeytbl now sits at that address.
So there's something naughty going on in STOS.. But where... If AI can't trace through the entire STOS code base and find it, then no hope of me figuring it out ! :lol: :roll:
User avatar
exxos
Site Admin
Site Admin
Posts: 28614
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by exxos »

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.

BASIC209.zip
(1.88 KiB) Downloaded 11 times

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
  1. 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.
  2. 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.
  3. 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.
User avatar
exxos
Site Admin
Site Admin
Posts: 28614
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by exxos »

I have been also poking around the floppy routines and it looks like track seak and verify is actually required.
The WD1772 seek command has two modes:
Without verify ($10) — the chip just counts step pulses to reach the target track and assumes it arrived correctly. Fast but purely mechanical — it trusts the stepper motor.

With verify ($14) — after stepping, the WD1772 waits for the disk to rotate and reads an ID address mark from the track to confirm it actually arrived at the correct track. Slower (up to one full rotation ~200ms) but guaranteed correct.

On vintage drives with well-worn mechanics and consistent step timing, no-verify works reliably because the stepper motor is predictable.

On new drives the step timing, head settle time, and track-to-track spacing may differ slightly from what the original hardware expected. Without verify the WD1772 has no way to know the head didn't quite land on the right track, so it starts reading and gets garbage data from the adjacent track — hence the clunk (retry seek) and "data may be damaged" error.

The irony is that the original TOS restore command ($00) does verify track 0, but regular seeks don't. Adding verify to regular seeks would fix the new drive issue at the cost of being slower — which is probably the right trade-off for reliability.
I basically turned off the verify timing and started to get drive clunks which are not expected like it is having difficulty reading the track. So I have put the verify back in the floppy routines. Strictly speaking it should not be really needed but maybe the ageing drives even though "new", may need a little bit of extra time and help correctly read the floppy contents.

This would never actually be a issue on floppy emulators because there is no physical movement which would need any verification in the first place.

I have also added in a longer 30 second timeout to turning the floppy motor off. One of the main annoyances is like when you bring up a file selector and it lists all the files, the floppy motor then turns off while you are moving the mouse to select the file you want. So then when you click it you then have to wait another couple of seconds for the motor to spin up again. That sort of thing is just annoyed me for a long time. The default timeout was 5 seconds and I have just simply changed it to 30 seconds now. Hopefully it be marginally quicker and a little less annoying now..
ijor
Posts: 836
Joined: Fri Nov 30, 2018 8:45 pm

Re: REV 3 - REV 5 - The beginning (ST536)

Post by ijor »

exxos wrote: Thu Apr 09, 2026 7:11 pm The WD1772 seek command has two modes:
Without verify ($10) — the chip just counts step pulses to reach the target track and assumes it arrived correctly. Fast but purely mechanical — it trusts the stepper motor.

With verify ($14) — after stepping, the WD1772 waits for the disk to rotate and reads an ID address mark from the track to confirm it actually arrived at the correct track. Slower (up to one full rotation ~200ms) but guaranteed correct.

On vintage drives with well-worn mechanics and consistent step timing, no-verify works reliably because the stepper motor is predictable.

On new drives the step timing, head settle time, and track-to-track spacing may differ slightly from what the original hardware expected. Without verify the WD1772 has no way to know the head didn't quite land on the right track, so it starts reading and gets garbage data from the adjacent track — hence the clunk (retry seek) and "data may be damaged" error.

The irony is that the original TOS restore command ($00) does verify track 0, but regular seeks don't. Adding verify to regular seeks would fix the new drive issue at the cost of being slower — which is probably the right trade-off for reliability.
Trust me @exxos, the AI (which I assume wrote that content) has no idea what's talking about. For starters it is not exact that command $00 verify the track, it "only" verifies that the track zero sensor is activated.

More important, it makes no sense whatsoever that modern drives have a different stepping distance, not even slightly. How could that work at all if that's was true? It is not that the drive can make micro adjustments to the stepper if verifies fails. If that different step distance makes the head to not land right on the track, it will always will be misaligned, and will never be able to read the track correctly.

Also step rate and head settle delay improved in new drives, not the other way around. Especially if you use HD drives.

Now, that doesn't mean that old and aging drives might not start to develop all sort of problems. But probably the main reason would be that the head requires some kind of recalibration. But that would be precisely on old drives after being used so much, not on newer drives. Of course, some newer unbranded drives might be of lesser quality.

And perhaps more significant, the main reason for errors is in the disk, not in the drive. Even the restore and reseek concept comes from the idea that the head seeking movement might clean better the disk surface. It is very unlikely that the stepping motor would actually fail under normal conditions.

Anyway, on most cases seek with verify is not worth. It is better strategy just to restore and reseek only on read errors. So you use the actual reading for verification, no need to perform a separate process. The actual timing you lose with verification depends a lot on how the disk was formatted. On a TOS formatted disk that would be very inefficient. Fast Copy has a "smart" formatting option to deal specifically with this. Disks formatted with that Fast Copy option can verify almost without penalty.
http://github.com/ijor/fx68k 68000 cycle exact FPGA core
FX CAST Cycle Accurate Atari ST core
http://pasti.fxatari.com
User avatar
exxos
Site Admin
Site Admin
Posts: 28614
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by exxos »

@ijor We talking about the 3ms and 6ms step rates here. TOS206 defaults to 6ms for some odd reason. TOS104 defaults to 3ms. As to what drives support what rates, I don't really care about TBH. Sony drives support both, but I use 3ms anway. With my HD controller I set it on the fly depending on DD or HD. Its all really well known stuff and makes perfect sense to me.

I suspect the extra verify steps just give the heads more settling time which is why it works better rather than reseaking and verifying the actual track itself. However you look at it, it works a lot better. So that's what I still stick to.
ijor
Posts: 836
Joined: Fri Nov 30, 2018 8:45 pm

Re: REV 3 - REV 5 - The beginning (ST536)

Post by ijor »

exxos wrote: Thu Apr 09, 2026 8:09 pm @ijor We talking about the 3ms and 6ms step rates here.
You like to defend AI :) I don't think that's what the AI was talking about that. Or at least, not only about that. AI was claiming that the track to track radial distance might have changed in newer drives, that's something completely different than the step rate. And that doesn't makes any sense whatsoever.

It was also claiming that the restore command ($00) verifies the track, but it misunderstands the purpose of the restore command, which is not to read a track at all.
TOS206 defaults to 6ms for some odd reason. TOS104 defaults to 3ms.
I understand that TOS 2.06 uses 6ms step rate setting for HD drives, because it assumes the clock would be doubled when it steps, and then it would really step at 3ms. At least that's the idea, I believe.
As to what drives support what rates, I don't really care about TBH. Sony drives support both, but I use 3ms anway.
It doesn't work that way. Drives don't exactly support a specific set of step rates. Drives require a minimum delay between individual step pulses. That means that any drive that supports 3ms step rate (as most "standard" 3.5 ones do), it automatically also supports any step rate higher (slower, like 6ms, or 12ms) than 3ms.
With my HD controller I set it on the fly depending on DD or HD. Its all really well known stuff and makes perfect sense to me. Its all really well known stuff and makes perfect sense to me.
That, yes, but that was not what AI was claiming in the quote above. :)
I suspect the extra verify steps just give the heads more settling time which is why it works better rather than reseaking and verifying the actual track itself.
I'm not sure how the verify step could help with the settling time. Settling time is usually not a problem. And if it is, then either the FDC will not find the sector header at all in the first revolution, but it will find it in the next one. Or if it finds the header but it provokes a reading error, TOS will retry once (or twice, don't remember for sure if this depends on the TOS version) before reseeking. Either way this would give plenty of time for the head to settle.

In theory you would get one less retry with this. Not very likely, but not completely unreasonable as the previous AI analysis. Either way, in the worst case it would be more efficient to just increase the number of retries before reseeking.
http://github.com/ijor/fx68k 68000 cycle exact FPGA core
FX CAST Cycle Accurate Atari ST core
http://pasti.fxatari.com
User avatar
exxos
Site Admin
Site Admin
Posts: 28614
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by exxos »

ijor wrote: Fri Apr 10, 2026 3:33 am You like to defend AI :) I don't think that's what the AI was talking about that. Or at least, not only about that. AI was claiming that the track to track radial distance might have changed in newer drives, that's something completely different than the step rate. And that doesn't makes any sense whatsoever.
I never even read that part of what AI said to be honest.

I really don't see why you keep focusing on the negatives all the time like your on some sort of personal crusade to bash AI and myself for using it. What's the alternative? Go Google for information which always leads to people arguing or no information about anything anyway? It doesn't always get things right no, I never claimed it did. Frankly it gets the job done 95% of the time and every problem solved is a win in my book.

You always seem to gloss over the good points as well. Earlier I posted it fixed a 35 year old bug in STOS. It's fixed bugs in TOS which have been there since day 1. It's helped me diagnose and fix ip6 issues on the server. It's found various server issues in lighting speed and fixed them. It's wrote scripts to take the boring takes out of sorting out my BOM and what I need to order. It's found issues in my webstore and fixed them. Plus considering how large TOS and STOS codebase is, it's nothing short of a miracle it's found and fixed the issues in little time.

If you don't like AI, that's your choice. I dont really care. But AI has helped me solve so many things it's frankly mind blowing. The server wouldnt even be online if it wasn't for AI. There's a lot of good stuff in the pipeline which people are working on which they couldn't do before. Myself included. Keeping your apparent narrative of its wrong all the time, to me is nothing short of absurd. AI gets better all the time. I will continue to praise it even if you and others want to do otherwise.
User avatar
stephen_usher
Site sponsor
Site sponsor
Posts: 7454
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by stephen_usher »

The issue is that if there are things that the AI is saying which are obviously wrong to those who are well versed in the subject how much can you trust the rest of the "information" it's giving you?

I think this is the point that Ijor is trying to make.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
User avatar
exxos
Site Admin
Site Admin
Posts: 28614
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

Re: REV 3 - REV 5 - The beginning (ST536)

Post by exxos »

stephen_usher wrote: Fri Apr 10, 2026 10:32 am The issue is that if there are things that the AI is saying which are obviously wrong to those who are well versed in the subject how much can you trust the rest of the "information" it's giving you?

I think this is the point that Ijor is trying to make.
I’m not disputing the specific technical corrections ijor made . Some details in the original AI quote were imprecise and got clarified, that’s fair.

But in the same context, the constant framing that the AI “has no idea what it’s talking about”, is “hallucinating”, or that you can’t trust anything it says is equally misleading.

I use it as a fast idea generator / rubber duck. It doesn’t always get every datasheet detail perfect first time (nobody does), corrections are needed sometimes that's just how it is, but it’s helped spark real fixes that worked in testing . Painting it as “always wrong” or broadly untrustworthy ignores the 95% where it’s been genuinely useful and the fact that I always test and refine the suggestions myself. That’s the balanced view, not a crusade against the tool.
Post Reply

Return to “ST536 030 ST ACCELERATOR”