CPCWiki forum

General Category => Amstrad CPC hardware => Topic started by: SerErris on 21:20, 05 September 23

Title: AY-3-8912 hardware emulator replacement
Post by: SerErris on 21:20, 05 September 23
Hi,

I stumbled on two resources to actually emulate a AY-3-8912 on an ATMega8.

The first is the bassis of this approache from here:
https://www.avray.ru/

It does all the heavy lifting in terms of AY Sound emulation. But it does not emulate the IO port, so for a CPC that would be unsable.

But wait, there is more.

Someone did the rest and implemented it including the fully functional IO port.
https://www.vretrodesign.com/products/ay-3-8912-functional-equivalent

That looks very promising.

I did order one of those and will run a test, if that is actually working fully in a CPC environment.

From the website:
Features include:

That sounds absoultely promising.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: eto on 11:30, 06 September 23
I also saw that yesterday on Facebook. I wonder what microcontroller is used on the other type. 
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 17:42, 06 September 23
The microcontroller is always the same, it is just different software - e.g. software that simply does not implement the IO bus vs. software that does.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: genesis8 on 10:03, 07 September 23
For the second link (with IO), the description mentions another version : https://www.vretrodesign.com/products/ay-3-8912a-ts-replacement-ic-turbo-sound-version (https://www.vretrodesign.com/products/ay-3-8912a-ts-replacement-ic-turbo-sound-version) (turbo sound) only for the ZX Spectrum.

I just checked, Turbo Sound is just a second AY, so it should be only a problem of no current software on Amstrad CPC to use it and not a hardware problem.

This replacement and you would have 2 AY, as it is the case if you use a Play2CPC.

Is there someone who will come to the Benediction Coding Party 3 and willing to test the turbo sound version in his CPC if I buy one ?
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 23:12, 09 September 23
The question is if you can address the second one ... I am not sure how that is achieved in a TS inside the Speccy.

Everything is possible with a hardware mod, but I am not sure if it can be done with just replacing the AY-3-8912 with the TS version in a CPC.

Looking this up, it looks like the Turbosound is an external card for the spectrum. That obviously would work with a CPC in some way, but you need hardware design first to run it (similar to the Play2CPC).
Title: Re: AY-3-8912 hardware emulator replacement
Post by: robcfg on 11:37, 10 September 23
@SerErris , it looks definitely promising!

I've taken a look at their website, and it's being advertised on the CPC section, it should handle the I/O port as well, which is nice.

Please let us know how it goes when you test it!
Title: Re: AY-3-8912 hardware emulator replacement
Post by: eto on 12:47, 10 September 23
If I am not mistaken, on the Speccy the second AY uses a different I/O port. This is closer to what the Playcity/Play2CPC is doing.

Since it's emulation anyway, it would probably be possible to add new modes to the AY emulation so you can address 6 channels directly. However, as with all these kind of gimmicks, it will not be adopted if it requires desoldering ICs.  
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 19:28, 10 September 23
Quote from: eto on 12:47, 10 September 23However, as with all these kind of gimmicks, it will not be adopted if it requires desoldering ICs. 
Yep this will be one of two things:
1. replacement of a broken AY (then in its original form)
2. addition as an external module.

The later one should be pretty much simple to achieve. As I said already it is just a new hardware card and software to use it. The Dual AY itself is already done. 
Title: Re: AY-3-8912 hardware emulator replacement
Post by: andycadley on 22:38, 10 September 23
From that page (don't know if they've updated it recently):

Note: the AY-3-8912A-TS is not compatible with the CPC range Amstrad computers.

The TurboSound on the Speccy is just another AY on another two addresses. So I'd imagine they've included some sneaky address decoding to make it work when just plugged into the AY socket and I doubt that would play well with the CPC scheme where the AY is not directly addressable.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 11:00, 11 September 23
I am not 100% sure what they do on the TS version. It could be, that they use the A8 input. This could add an additional address bit or select multiple of those chips (2) ... You can let one chip react on A8 high and the other on A8 low.

On CPC this line connected to +5V so always high. 

Also On Spectrum 128 the same line is connected to +5V so always high.

A main difference however is that the spectrum is connecting the CPU directly to the sound chip, vs CPC going through the PIO. 

That should not make any difference ...

Some time went on:
I researched how the turbo sound works, and that should work the exact same way on CPC.

The original Turbosound board has an AND gate + two D-Flipflops on it, that enables it to use it to select on or the other and using the A8 to activate it (or not). So A8 does not need any external connection as it is driven internally by the card. 

How does it work? For address you send over FE or FF, which selects Chip0 or Chip1 to actually work on it. If you just send 00-0F, it will go to the previous selected chip. So only one chip actually works with the processor, and you would need to select it first and then send the whole instruction to it as normal.

As I said, that exact same thing will work with CPC. However you still need the full IO port mapped, otherwise the CPC keyboard will not work anymore.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: eto on 12:39, 11 September 23
Quote from: SerErris on 19:28, 10 September 23
Quote from: eto on 12:47, 10 September 23However, as with all these kind of gimmicks, it will not be adopted if it requires desoldering ICs. 
Yep this will be one of two things:
1. replacement of a broken AY (then in its original form)
2. addition as an external module.

The later one should be pretty much simple to achieve. As I said already it is just a new hardware card and software to use it. The Dual AY itself is already done.
The later one is what the sound-part of the PlayCity is doing. https://www.cpcwiki.eu/index.php/PlayCity

Maybe it's possible to make a Playcity compatible version of the Dual AY as this is already supported by some software.

Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 20:51, 11 September 23
I would say, but this just on a very simple expansion board and you have 9 channels ... the two are directly programmed with IO vs. the exiting one is programmed via the PIO chip.

That should actually work, however is leading us away from the original aim of a replacement AY.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: zhulien on 13:51, 12 September 23
I have a terasic t-rex and that has sound, it's an FPGA so someone has at least implemented AY's in FPGA.  I wonder how many AY's can fit in a single FPGA?  Someone could perhaps make a 10 AY FPGA sound card with compatability to PlayCity.

Having said that, some nice sound drivers for PlayCity and internal CPC Audio will eventually be done by someone, ideally different options: 9 front channels (6 music, 3 soundeffects), 6 front channels (music or soundeffects mixed), 3 back channels (sound effects) - so we can have surround sound in CPC games.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 12:15, 17 September 23
Sure someone has implemented in an FPGA, as there is a working (multiple) computers on MISTER project (Atari, Amstrad, Arcade machines etc).

The number of AYs depend on the FPGA :-) 

However the FPGA implementation is 321 lines of verilog code

It has some registers:
1. address register 8bit
2. PSG registers 16*8bit
3. dout register (8bit) (this is for reading the registers)
4. some auxiliary internal bits (also regs in verilog)
   in total about 4+1+3+17+5+3+12+1+16+5+2
5.Die Outputregister A,B,C = 3x6 bit.

In total, if I did not count or add wrong, this is 231 flipflops, depending on the FPGA architecture that is 231 LUTs or Macrocells.

So this can be even implemented in a small CPLD with 256 Cells. 

FPGAs can have that much of them in a single chip:
Intel Cyclone V 110k LUTs = 476
Lattice iCE40 from 384 Cells to 7680 Cells. The smallest one can just hold one chip, but the largest one can hold 33

This is not calculating any more complex logic then required by the LUTs here, but I doubt, that this is actually an issue and the LUTs we need for FlipFlops are already enough to have the rest of the logic fit.
The iCE401K could host 5 of those chips, fits in a 7x7 mm QFN package and cost in larger numbers $4.66 - 

The beauty of an FPGA implementation would be, that you could set each chip to an indivudal address, so you could directly address the chips, which is not possible with the real chips, as they all react to the same address (0000). 

But the FPGA can be programmed to react on addresses 0 to 4 and you can directly programm each individually. 



Title: Re: AY-3-8912 hardware emulator replacement
Post by: BSC on 07:12, 18 September 23
Sounds like a nice learning project. What would you guys recommend as a playground to start with? I imagine some kind of IDE where I could edit the verilog (or other relevant types of) code, then run a simulation of the FPGA to see if it works as expected. Maybe paired with tools like virtual oscilloscopes etc. 
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 13:21, 18 September 23
I can only recommend the following (to learn verilog and FPGA):

First get yourself a Terasic DE10-nano or lite. Lite is better for the course, nano is better because it is the base hardware of the MISTer project.

In the MISTer project you have pretty much anything from the 80s now running on an FPGA including AMIGA, ST, C64, Amstrad and what not. Also consoles and even Arcade machines.

I would really just jump right away into "Computer Architetecture Tutorial Using an FPGA" by Robert Dunne. This is available as ebook or book. 

It will build on the DE10-lite, because of switches and LEDs. where the DE10-nano has very few switches, buttons and LEDs. But other than that it does not make any difference.

You programm it with Quartus Lite and that includes a simulator as well.

The downside is: Hardware cost you ~150€ and if you go DE10-Standard it will even go up to ~500€. But the later one is really if you want to develop more - so maybe something later.

A good starting simulator can be found here:
https://edaplayground.com/

I can also recommend to get a copy of "Designing Video Game Hardware in Verilog" from Steven Hugg
https://www.amazon.com/gp/product/1728619440/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1728619440&linkCode=as2&tag=ws8b-20

It is a very good introduction to Verilog but as well into understanding digital cirquitry. It comes with its own simulator, that even can simulate the video output etc.

https://8bitworkshop.com

The book is USD10 (as ebook) and they are using the Lattice iCE40 USB stick, which is very cheap and simple to use.
You can get it from mouser and other sources for USD50.

From my personal experience:
Looking at ready made code (without any comments in it) you will have a hard time to understand what they are doing. 

So better start from ground up, and after you have the basics - get into understanding on how they implemented a CPC.

The great thing about VHDL is, that you actually build everything together like a real computer. So you do have a mainboard, and it has chips. All the chips are getting connected and thats it. Obviously you need to implement all the chips, but that is just going level after level into more detail, or even reuse what others have done.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: zhulien on 15:39, 18 September 23
If you can put 3 AY's, 2 SIDs and 2 8bit DACs into a single FPGA at a cheapish price, that would make a really awesome soundcard.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 23:07, 23 September 23
It arrived today ... from NZ. Was not aware that it is produced in NZ, but that was quite fast shipping and explained the shipping cost. However I needed to pay customs on my own.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: Rabs on 17:54, 03 October 23
Quote from: SerErris on 23:07, 23 September 23It arrived today ... from NZ. Was not aware that it is produced in NZ, but that was quite fast shipping and explained the shipping cost. However I needed to pay customs on my own.
How did you get on? Looks like I have a problem AY to replace on a 6128. Thinking of using this as an alternative to an expensive real AY replacement.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: eto on 19:01, 03 October 23
Quote from: Rabs on 17:54, 03 October 23
Quote from: SerErris on 23:07, 23 September 23It arrived today ... from NZ. Was not aware that it is produced in NZ, but that was quite fast shipping and explained the shipping cost. However I needed to pay customs on my own.
How did you get on? Looks like I have a problem AY to replace on a 6128. Thinking of using this as an alternative to an expensive real AY replacement.
You can replace it with a 8910A:

https://www.cpcwiki.eu/forum/amstrad-cpc-hardware/ay-3-8910-adapter-for-amstrad-cpc-to-stop-exploitation-for-ay-3-8912!/msg224245/#msg224245
Title: Re: AY-3-8912 hardware emulator replacement
Post by: Rabs on 19:44, 03 October 23
Thanks, I would but the 8910 seems more expensive in the UK on eBay. Anyway, after replacing the membrane, which was broken (end fell off when I removed it from the connector), and scoping out the PIO Port A to see the pulses from the AY as I press a key and convincing my self it was broken, it started to work! Maybe I could offer a service to fix broken AYs by just looking at them  :) .
Title: Re: AY-3-8912 hardware emulator replacement
Post by: BSC on 20:17, 03 October 23
Quote from: SerErris on 13:21, 18 September 23I can only recommend the following (to learn verilog and FPGA): [long list of interesting things]
Thank you very much, SerErris, that was really interesting and I checked out all your links and suggestions. Now I only need to find (a way to free up) some time .. :)
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 22:58, 03 October 23
Hi, I had no time to work on it, maybe next week.

I also need to think of some good music examples to validate the sound quality.

Any good examples, that can test the soundchip?

I would also love some very atomic tests, that can test individual parts and do a real comparison.

Maybe my own basic sound test can be used for that.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 22:10, 05 October 23
Okay,

I just opened my newest CPC464 and removed the AY and socketed it. I also took the chance and replaced the two Elkos and gave it a good clean. Also removed the printer port mod and relocated the reset button cables to the underside of the PCB. So it is not that obvious anymore and also not partially blocking the expansion port.

Anyhow I did a first g test run and it looks pretty good and also sounds through the small speaker rather good.

I will post some pictures and sound comparisons tomorrow
Title: Re: AY-3-8912 hardware emulator replacement
Post by: Rabs on 22:52, 05 October 23
I have one on order.

Although cheaper than a real AY, with the addition of shipping it works out about the same, but I am interested to see how it performs.

Thanks for the info.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 12:01, 06 October 23
Some more pics:

Mainboard with modifications and before I removed them, Mainboard with the VRetro Chip in the socket. and the back side chips with more visible detail.
modded_CPC.jpg
socketed_AY_Emu.jpg
Emu_chips.jpg
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 15:31, 06 October 23
Here are the sound examples.

put in my AY3test.bas (the first two tracks) to be able to compare both and then the logon demo from 2017 with both versions and a version where I switch in between both. It is hard to recognize the difference. You tell me, what you hear.

Yes there is a difference and I can hear it, but I do not want to Bias you.

https://soundcloud.com/christoph-linden/sets/cpc-ay3-clone-tests?si=689a384ac2f347dc947069098a6c469c&utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing

Also it looks like there is another issue with the chip.

When I use my basic program and the program ends, it has data in the keyboard input buffer, that should not exist as I am obviously not typing anything. It is also every time the exact data coming out.

That is strange. Something to follow up with the developer.

Under Basic it is also not stable ... It delivers different results every time. By chance the recording has a pretty decent run .. but it can deliver all kind of beeps and blips.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: vRetro on 23:56, 06 October 23
Hi All,

First an introduction. I'm Charlie Ingley (vRetro Design in New Zealand: https://vretrodesign.com) and make (amongst other things - mainly ULA replacements for Sinclair machines)  the AY-3-8912 replacement. I understand that SerErris is having a few issues with the chip and I'll be working with him to understand more fully what the problem is and find a solution.  Before release, the AY3 replacement was tested extensively across both Amstrad and Sinclair variants but there will always be some unforseen situations that can prompt odd behaviour.  Testing the full capabilities of these clone devices is a difficult task and I appreciate any feedback especially if it leads to a more robust and compatible product.

Always happy to answer any questions about the things I develop.

Charlie   
Title: Re: AY-3-8912 hardware emulator replacement
Post by: genesis8 on 09:54, 07 October 23
Quote from: vRetro on 23:56, 06 October 23Hi All,

First an introduction. I'm Charlie Ingley (vRetro Design in New Zealand: https://vretrodesign.com) and make (amongst other things - mainly ULA replacements for Sinclair machines)  the AY-3-8912 replacement. I understand that SerErris is having a few issues with the chip and I'll be working with him to understand more fully what the problem is and find a solution.  Before release, the AY3 replacement was tested extensively across both Amstrad and Sinclair variants but there will always be some unforseen situations that can prompt odd behaviour.  Testing the full capabilities of these clone devices is a difficult task and I appreciate any feedback especially if it leads to a more robust and compatible product.

Always happy to answer any questions about the things I develop.

Charlie 
Hi,

nice to have you here, and thanks for your help. I was just going to write about your AY replacement on my Amstrad CPC web site :-)


Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 17:30, 10 October 23
Quote from: vRetro on 23:56, 06 October 23Hi All,

First an introduction. I'm Charlie Ingley (vRetro Design in New Zealand: https://vretrodesign.com) and make (amongst other things - mainly ULA replacements for Sinclair machines)  the AY-3-8912 replacement. I understand that SerErris is having a few issues with the chip and I'll be working with him to understand more fully what the problem is and find a solution.  Before release, the AY3 replacement was tested extensively across both Amstrad and Sinclair variants but there will always be some unforseen situations that can prompt odd behaviour.  Testing the full capabilities of these clone devices is a difficult task and I appreciate any feedback especially if it leads to a more robust and compatible product.

Always happy to answer any questions about the things I develop.

Charlie 

After some great input from Charlie I desoldered another AY3 from one of my other 464s. It has the same board and pretty much the same chips. Anyhow there is not a lot between the AY3 and the 8255.

And surprise surprise, the AYC (Clone) works correctly on my CPC-B. CPC-A does print a set of characters (actually the same as you put no AY3 in the socket at all) on random ocasion and also has sound glitches.

We are still analysing of what is different between both CPCs. Both work fine with an Original AY3 and even CPC-A (the first I tested) works with both AY3s I now have. But it does not work with the AYC.

@Bryce, do you have any idea on what could cause the AY to glitch in a way that the CPC interprets the datalines the same way as it would not be socketed at all?

AFAIK the only thing that the 8255 looks at are the 8 data lines from the AY. If nothing is connected, why will it give this kind of output?
AY3 unconnected.jpg

That is btw. just the BASIC interpretation of the output.

I have written a Testscript that is checking the input from the keyboard and prints it in hex form.

So it is always the exact pattern .. Any idea what would cause this pattern?

AY3test2_screenshot.jpg

Title: Re: AY-3-8912 hardware emulator replacement
Post by: SkulleateR on 19:07, 10 October 23
Maybe it's the same issue as with the 8910 + pcb adapter in a CPC6128 ?

If you replace the 8912 with a 8910 + adapter there, you need to solder in the resistor network below the chip to get this to work :)
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 00:15, 11 October 23
I would think, that this is different

Keyboard input is working, which it would not without the pull downs
Also it works in one 464 erfectly fine, but has quirks in another
Title: Re: AY-3-8912 hardware emulator replacement
Post by: darkhalf on 07:30, 11 October 23
Potentially inputs have some after key press ripples on the input lines. If you monitor with a scope you may see this. Note AY8912 GE version has internal pull resistors. Perhaps the pull-ups are required to remove ripples
Title: Re: AY-3-8912 hardware emulator replacement
Post by: robcfg on 09:03, 11 October 23
Wouldn't it be the same that happens with AY-3-8912 and AY-3_8912A chips usually found on the Plus series machines?

That's why these machines have a resistor array by the sound chip.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SkulleateR on 11:55, 11 October 23
Quote from: robcfg on 09:03, 11 October 23Wouldn't it be the same that happens with AY-3-8912 and AY-3_8912A chips usually found on the Plus series machines?

That's why these machines have a resistor array by the sound chip.
That's what I was talking about ;) Same applies to the 8910+Adapter ... no Pull-Ups -> Garbage letters on screen ...
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 13:08, 11 October 23
Okay, the keyboard "ripple" has nothing to do with Pullups. The pullups are required to identify a key press. Key press means the line goes low. As it is disconnected without any key pressed, it can only get high with the pull up.

So without pullup it would not work at all, as the line would be floating.

However the symptom is exactly this.

So if you do not place any AY in the socket, you get the exact same strange keyboard output.

So it looks like the lines are actually floating at the point when the 8255 reads from the AY. That does not mean that any line on the data input port of the AY is floating. It just means, that the AY has not connected the line to the bus, and is floating. 

I suspecting the BC1 and BDIR lines to be not as stable. What is surprising me, that it works on one CPC and not on another, which actually have the same exact chips in both places (actually those that are relevant). 

I now put out the big weapons and check BC1 BDIR with OSC and the whole thing with a logic analyzer to understand what is going on.

From protocoll level how it should work:
As long as I do not press any character, I should get FF as the byte value for the input register of the AY, that should be output to the DataLines on requesting R14 value with BDIR = read.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 18:53, 12 October 23
Okay, it looks like a timing issue. The AVR is just to fast for the old timings of the CPC.

VRetro is working on a patch.

The issue is with recognizing BC1 and BDIR lines. The both go up, when you want to select a register. In my CPC BC1 goes high between 5-10 ns before BDIR which is then interpreted as READ command instead of the supposed REG SELECT.

So what should be written goes to the wrong register and if we want to read from a register, that will return whatever register has been selected before.

Next testing will be with updated (less tight) timings
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 13:00, 20 October 23
Finally,

lets close this out.

vRetro has update the firmware of the AY-3-Clone with more releaxed timings now and this works brilliant in all my CPCs.

So this is really a good replacement to the every shrinking amount of working AY-3s. It is also pretty much accurate. I could not hear any difference in voice or envelopes or anything alike. The only one difference is that the noise frequency is slightly brighter than the original one. But that is so close that even I knowing about it have a hard time to identify it in the changing stream.

So all in all, well done works perfectly now.

Regards
Ser
Title: Re: AY-3-8912 hardware emulator replacement
Post by: Rabs on 11:53, 27 October 23
Received my AY replacement. Inserted into a 6128 and works great. Can't tell any difference but only limited testing at moment. Ran a few games 'Adams  Family' etc and the sound is great. Well done @vRetro and thanks.
Title: Re: AY-3-8912 hardware emulator replacement
Post by: SerErris on 17:49, 05 November 23
That is also my experience, you cannot tell the difference. The noise frequency might be also my single AY-3 as there may be some tolerances. 

The replacement will have much lower tolerances than anything produced back in the day.

But from the sound, there is literally nothing I can make out that sounds different.
Powered by SMFPacks Menu Editor Mod