Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Any 8bit repairs, images, cool things, upgrades etc.
User avatar
stephen_usher
Site sponsor
Site sponsor
Posts: 7376
Joined: 13 Nov 2017 19:19
Location: Oxford, UK.

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by stephen_usher »

I think that I've worked it out:

BC1 = WR and !A2 and I/O request
BC2 = I/O request and !A3 and !A4
A8 = BC2

A9 low if A0, A1, A6, A7 high, A5 low

110xxx11 = base 195

During I/O request.

BC1 high if write and A2 low
BC2 high if A3 and A4 low, low if either A3 or A4 high

BC1 high addresses 195/203/211/219
BC2 high addresses 195/199

Port 195 = BC1 high, BC2 high
Port 199 = BC1 low, BC2 high
Port 203 = BC1 high, BC2 low
Port 211 = BC1 high, BC2 low
Port 219 = BC1 high, BC2 low

Knowing this, the only useful port numbers, given that BC2 has to be high otherwise the AY-3-8910 is high impedance, are ports 195 and 199.

The truth table for the AY is:

Code: Select all

BDIR		0		0		1		1
BC1		0		1		0		1
BC2		1		1		1		1
		Inactive	Read		Write		Latch register address
Port		IN 195		IN 199		OUT 195		OUT 199
Could someone sanity check this please.
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
stephen_usher
Site sponsor
Site sponsor
Posts: 7376
Joined: 13 Nov 2017 19:19
Location: Oxford, UK.

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by stephen_usher »

On another site I was directed to this: https://logic.ly/demo/ which is really useful!

It seems that I did get the logic correct after all.
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
stephen_usher
Site sponsor
Site sponsor
Posts: 7376
Joined: 13 Nov 2017 19:19
Location: Oxford, UK.

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by stephen_usher »

A quick update on this project..... Well... It's been a journey.

I designed a logically identical PCB and had it made. When they arrived I put one together and.... it didn't work... at all.

In one configuration of the jumpers nothing would happen in one way and with the other configuration it wouldn't quite do nothing. The output from the 74LS27 for the AY-A8 & BC2 line was low voltage and all sorts of wrong things. Putting pull-ups allowed me to get some sounds out, but not the right ones.

Now after a couple of months with on and off trial and error, including replacing the whole of the address decode logic with a GAL, I've got to the point where it almost works most of the time... by disabling most of the address decode logic.

Timing is everything...

Yes, I believe that I've got to the point where it's down the variation of timing for individual chips!

In the last couple of days I reverted the card from using the GAL back to discrete logic and after using a different 74LS27 chip from the original the symptoms have changed.

With the GAL I was getting some sound which was as if some of the bits being read by the AY chip were just plain wrong meaning that it was consistently selecting the wrong register and writing the wrong data. Which bits were bad varied but it was sort of deterministic.

Going back to discrete logic with that different LS27 now more of the data was correct, just missing a few bits.

Thinking this through, I guessed a timing problem. So decided to put a delay on the BC2 line... 4ns using an LS04... and the symptoms changed to be the same as with the GAL. Another 4ns and all hell let loose with jumping display and totally wrong sounds. Delaying the /A9 line made little difference. Enabling the A8 and /A9 pins on the AY permanently allowed the card to work almost correctly (90% working, 90% of the time). The /A9 signal is generated by a TI 74LS30 to do address decoding.

So, timing on this card is *SO* tight that only delaying the BC2 signal by a mere 4ns makes it misbehave and the /A9 generation makes it miss bits.

It wasn't a surprise then that checking on the original card the chips are not TI ones... My guess is that the timing is such that TI parts are too slow and the data disappears from the data bus before the AY latches it.

How can this be? Easy, unlike most chips the AY doesn't latch data into its registers triggered by the assertion of the select signals it does it AFTER. The datasheet specifies that the data must stay on the bus for at least 100ns AFTER the chip select signals go away. In other words, you have to HOPE that the data stays on the Z80's bus for 100ns AFTER the OUT instruction has completed and the CPU is starting to get ready to read the next instruction.
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
rubber_jonnie
Site Admin
Site Admin
Posts: 14888
Joined: 17 Aug 2017 19:40
Location: Essex

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by rubber_jonnie »

stephen_usher wrote: 28 Aug 2025 20:54
Timing is everything...

Yes, I believe that I've got to the point where it's down the variation of timing for individual chips!
I can well believe this after my experience with my OSI 600. Just changing one chip to a different manufacturer was all the difference between the display working and it not.

I hope you can get to a point where it's all working as expected :)
Collector of many retro things!
800XL and 65XE both with Ultimate1MB,VBXL/XE & PokeyMax, SIDE3, SDrive Max, 2x 1010 cassette, 2x 1050 one with Happy mod, 3x 2600 Jr, 7800 and Lynx II
Approx 20 STs, including a 520 STM, 520 STFMs, 3x Mega ST, MSTE & 2x 32 Mhz boosted STEs
Plus the rest, totalling around 50 machines including a QL, 3x BBC Model B, Electron, Spectrums, ZX81 etc...
User avatar
stephen_usher
Site sponsor
Site sponsor
Posts: 7376
Joined: 13 Nov 2017 19:19
Location: Oxford, UK.

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by stephen_usher »

Well, the F series chips arrived and...

The 74F27 made a difference. No more glitch in the audio as my test program wrote 0x0a to the course channel A frequency divider.

The 74F30, controlling the /A9 line didn't make any real difference. I wonder if this is possibly less a timing issue and more an address line not being good enough issue. It doesn't matter a great deal as if I remove it the /A9 line is continuously enabled. The address decode logic is compromised but the BC2 line, controlled by the 74F27 is enough to allow the card to work.
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
rubber_jonnie
Site Admin
Site Admin
Posts: 14888
Joined: 17 Aug 2017 19:40
Location: Essex

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by rubber_jonnie »

stephen_usher wrote: 02 Sep 2025 11:38 Well, the F series chips arrived and...

The 74F27 made a difference. No more glitch in the audio as my test program wrote 0x0a to the course channel A frequency divider.

The 74F30, controlling the /A9 line didn't make any real difference. I wonder if this is possibly less a timing issue and more an address line not being good enough issue. It doesn't matter a great deal as if I remove it the /A9 line is continuously enabled. The address decode logic is compromised but the BC2 line, controlled by the 74F27 is enough to allow the card to work.
Seems like quite the project this one...
Collector of many retro things!
800XL and 65XE both with Ultimate1MB,VBXL/XE & PokeyMax, SIDE3, SDrive Max, 2x 1010 cassette, 2x 1050 one with Happy mod, 3x 2600 Jr, 7800 and Lynx II
Approx 20 STs, including a 520 STM, 520 STFMs, 3x Mega ST, MSTE & 2x 32 Mhz boosted STEs
Plus the rest, totalling around 50 machines including a QL, 3x BBC Model B, Electron, Spectrums, ZX81 etc...
User avatar
stephen_usher
Site sponsor
Site sponsor
Posts: 7376
Joined: 13 Nov 2017 19:19
Location: Oxford, UK.

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by stephen_usher »

Well, I think that I'm going to leave it there. It works "well enough" and I'm not sure that it ever would have worked reliably given the mismatch between how the Z80 works and the AY works. It just luck in the timing that it works at all. It's as if there's a small , accidental overlap between extremes of what the Z80 does most of the time and the AY requires that allows it to operate.
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
rubber_jonnie
Site Admin
Site Admin
Posts: 14888
Joined: 17 Aug 2017 19:40
Location: Essex

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by rubber_jonnie »

You just got another mention on More Fun Fixing it for this sound card :)
Collector of many retro things!
800XL and 65XE both with Ultimate1MB,VBXL/XE & PokeyMax, SIDE3, SDrive Max, 2x 1010 cassette, 2x 1050 one with Happy mod, 3x 2600 Jr, 7800 and Lynx II
Approx 20 STs, including a 520 STM, 520 STFMs, 3x Mega ST, MSTE & 2x 32 Mhz boosted STEs
Plus the rest, totalling around 50 machines including a QL, 3x BBC Model B, Electron, Spectrums, ZX81 etc...
User avatar
stephen_usher
Site sponsor
Site sponsor
Posts: 7376
Joined: 13 Nov 2017 19:19
Location: Oxford, UK.

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by stephen_usher »

rubber_jonnie wrote: 28 Sep 2025 16:45 You just got another mention on More Fun Fixing it for this sound card :)
I know... he's trying to recreate it exactly, with the help of The Board Folk. It'll be his learning KiCAD project.
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
rubber_jonnie
Site Admin
Site Admin
Posts: 14888
Joined: 17 Aug 2017 19:40
Location: Essex

Re: Trying to reverse engineer the William Stuart Systems ZX81 sound card.

Post by rubber_jonnie »

stephen_usher wrote: 28 Sep 2025 17:14
rubber_jonnie wrote: 28 Sep 2025 16:45 You just got another mention on More Fun Fixing it for this sound card :)
I know... he's trying to recreate it exactly, with the help of The Board Folk. It'll be his learning KiCAD project.
Nice, and one I hope to follow, will be interesting given the fun and games you had with it.
Collector of many retro things!
800XL and 65XE both with Ultimate1MB,VBXL/XE & PokeyMax, SIDE3, SDrive Max, 2x 1010 cassette, 2x 1050 one with Happy mod, 3x 2600 Jr, 7800 and Lynx II
Approx 20 STs, including a 520 STM, 520 STFMs, 3x Mega ST, MSTE & 2x 32 Mhz boosted STEs
Plus the rest, totalling around 50 machines including a QL, 3x BBC Model B, Electron, Spectrums, ZX81 etc...

Return to “8 BIT CORNER”

Who is online

Users browsing this forum: ClaudeBot and 10 guests