Sunday, 8 January 2023

Testing the AY-3-8910 / YM2149 Sound Card for RC2014 (and Minstrel 4D)

In a previous post, I built an AY-3-8910 / YM2149 Sound Card for RC2014 (and Minstrel 4D)

In that post, I tested the card using the game Valkyr, which has built in support for a similar device, and has been patched to use this card.

Today, I want to try a few more things, and also look at some of the other supported chips and some of the potential problems associated with sourcing them.

Play

George Beckett has a repository of Forth programs which support this card (including the aforementioned patched version of Valkyr). https://github.com/markgbeckett/jupiter_ace

One of those is "play", which can be used to play a series of notes, given by their letters (c, d, e, etc.) with # and & for sharps and flats.

A special version has been provided for the Minstrel 4D. Unlike the original, this has Forth and assmembly in a single dictionary ("playd"). This can be loaded from the SD card menu on the Minstrel 4D. Note here the menu scans the file for a dictionary and identifies it is called "play", even though the file is called playd.TAP.

Select option 2 to load it (we don't want to run "play" directly, so we don't use the first option).

I am still pleased with the loading lines on the Minstrel 4D. For those not in the know, the Jupiter Ace didn't do that, you just has to sit and wait and hope the program loaded.

Once that is loaded, you can use it to create words that will play tunes (see the notes on George's page for more info).

Typing over serial is really useful for this sort of thing, you can just select the text from github and paste it into a terminal window and have it typed into the 4D automatically. You can then save if to SD if you wish to enjoy Hall of the Mountain King at a later date. Or you can add it to your own program and have it playing over the title screen (see notes about relocatable code if you do).

Audio Output

These chips are three channel, mixed down to two for a stereo output. The YM2149 seems to suit the mixer on the board better, compare the tune from the start of Valkyr.

On the AY-3-8192, there is more bleed through.

You can also see that during the gameplay. There look to be three types of sounds, one on each channel, you can see that more clearly on the Yamaha chips.

The laser firing noises are on channel 3, which is mixed equally to left and right, and different ship and explosion noises are on channel 1 and 2 (left and right).

On the AY-3 chip it seems a bit more jumbled up.

Either way, it enhances the game play.

Sourcing chips

This card supports a variety of different, but largely compatible chips. Unfortunately, none of those are still in production, so you have to rely on the likes of ebay, and as I am sure you are aware, all may not be as it seems.

Here I initially assembled four chips to test. These are as follows:

  • GI AY-3-8910A, datecode 8547
  • Yamaha YM2149F, datecode 8903
  • Microchip AY-3-8910, datecode 0827
  • Microchip AY-3-8910A, datecode 1030

I have had the GI and Yamaha chips for a long time, and I have no reason to think that they are not genuine chips.

The "Microchip" ones, less so, these are from ebay. I have not been able to find a date when they stopped making these, but I suspect they are both dated a bit late. I'm not entirely sure if Microchip only produced their improved AY-3-8930 / AY8930, or if they did actually produce Microchip branded AY-3-8910 and AY-3-8910A chips.

Just based on the packaging, with the two release marks, the dot for pin 1 and no notch, I think the Microchip AY-3-8910 dated 0827 is in fact a Yamaha YM2149F. It has gone through an unfortunate process where it has been sanded down, painted black and laser etched to look like a Microchip device.

This is confirmed by the first test, which is the output level. The original Yamaha device outputs sit at about 2V at rest, and the 0827 Microchip matches that.

The other Microchip chip looks and acts like the AY3-8910, with a notch for pin 1, and there are two release marks and a dot for pin 1 which are still just visible, the result of the chip being sanded down.

Comparing it to the original GI chip and a contemporary Microchip PIC, it is clear the font and logo are wrong, but the release holes don't quite match either of the other chips. It does however have a low output, around the 0.2V expected from the GI chips. So it looks like the 1030 Microchip is actually an AY-3-8910A, just remarked with a later date.


Register test

There is another way to tell. Some of the control registers are not fully used. Register 0 and 1 together provide a 12 bit tone period. Register 0 uses all 8 bit, but register 1 uses only 4 bits. In theory, the GI chips will always return 0 for the unused bits, but the Yamaha chips will store and return all the bits written, even though they are not being used.

In this test program, I am selecting a register, writing 0 and reading back and displaying the value, then writing 255 and reading and displaying that.

First off, select register 0, write 0, read 0. Good start.

Write 255, read 255, as expected.

OK, so that is working.

Now it is time for register 1 (which is only 4 bits).

Select register 1, write 0 and read 0, so far so good.

Write 255 and read 15.

Ah, so that would suggest this is an AY chip, as it has read 0 for the upper 4 bits, and the value written for the lower bits.

I did have a long section here about how the unusual interface to these sound chips works, but this post is already way too long and I am barely half way through, so I will move that to a separate post -

http://blog.tynemouthsoftware.co.uk/2023/01/driving-ay-3-8910-ym2149-from-8-bit.html

Briefly then, most of the other chips used in the 8 bit era were designed for the 65 or 68 series chips or the 8080/Z80, but these were designed to be used with the more obscure GI CP1600 and early GI  PIC microcontrollers (before the Microchip takeover of GI, and before the Atmel takeover of Microchip).

These had a shared address and data bus, hence the odd way you have to select the register then write the data. On the CPC464 and Oric, the chip is connected to the outputs of an IO chip, rather than direct to the databus, to be able to drive this. On the Spectrum +2, it is driven from a latch forming a simple output port. On this RC2014 card, it is being driven direct, so there are a few oddities, like reading data back via the register port.

OK, time to test the other three chips. I expect to get 255 for both registers.

Well, that is what I expected, unfortunately, I also got 15 for both the (theoretically) Yamaha chips.

Not sure what is going on there.

At this point, I was doing a lot of powering on and off (soft power on is great, isn't it?), and swapping chips, so I had fitted a ZIF socket to the board to make that easier.

I was making changes to the code in a text editor and pasting the text over serial to the Minstrel 4D. When doing that a lot, it is useful to disable the menu at power on, so it boots straight into Forth, ready to type in the code. Go to settings, and press A to disable it.

You can still get to the menu by pressing the Menu button, and then go to settings and turn it back on by pressing A again when you're finished.

I reached out to Ed Brindley, who designed the RC2014 card, and he also expected to see different results from the Yamaha chips. However, he also ran some tests and seem to confirm the results I was getting, 15 way being read back, from all the chips.

He was testing all registers, so I wrote some more forth to test all 16 registers. ("YM2149" and "Real" are printed at the start to make it easier to know which results are which, I changed that to match the chip being tested).

216 CONSTANT REGPORT
208 CONSTANT DATPORT

: REGS
  CLS
  ." YM2149" CR
  ." Real" CR
  CR

  16 0
  DO
    I .
    I 10 < IF ."  " THEN
    I REGPORT OUT
    255 DATPORT OUT
    I REGPORT OUT
    REGPORT IN .
    CR
  LOOP
  CR
;       

(is there any interest in going into a bit more detail of the Forth used here, line by line, for those new to the language?)

All these test programs on here are available on my github - https://github.com/tynemouthsoftware/Forth.

I ran this with a real YM2149 and the results were as before, only the allocated bits were returned, the rest were 0.

I repeated that on each of the types of chips I had, and the results were all exactly the same on every chip.

I also added an AY-3-8192 to that test, using the adapter board that came with the kit from Z80kits.com.

Now it is of course possible that all my chips are actually AY-3-8910, some of which have been remarked as YM2149, but that seems unlikely.

More chips to test

To be sure, I dug around in my spare boards to find some more chips.

First up, another AY-3-8912A, this one from a dead ZX Spectrum +2.

I found a couple of scrap boards with YM2149 chips on, one from an Atari ST.

And one from an MSX.

Do you spot anything about the MSX board?

Yes, the position is marked for an 8910, but the Yamaha YM2149 is fitted instead. It also has the full part number on the back.

The MSX board had already been raided for parts, so I desoldered the YM2149 from there.

Both of these chips were factory soldered to boards in the 1980s, so I have no reason to think that they are not real chips.

OK, as expected, the AY-3-8192 returns 15 for register 1, only the used bits.

Oh, so does the YM2149.

OK, so that seems to confirm that this "reading back extra bits" thing doesn't work.

I fed this back to Ed, who did a bit more digging, and it turns out that the behaviour is different if you write 31 rather than 255 to the port.

So I tried writing 31 instead, and got 31 back.

I didn't take a screenshot, I just updated my test program and ran that and it worked!

I ran the same test on an AY-3- 8910 and that was also correctly detected.

So the information about the extra bits was correct, just with a caveat. If you write 31 to register 1, you will get 31 back on a Yamaha YM2149, and 15 back on an AY-3-8910/2. All other bits and values work the same on both devices. Excellent, we have a test program.

216 CONSTANT REGPORT
208 CONSTANT DATPORT

: DETECT
  CLS
  1 REGPORT OUT
  31 DATPORT OUT
  REGPORT IN 31 < 
  IF ." AY-3-8910/2"
  ELSE ." YM2149" 
  THEN
  ."  Detected"
  CR
  CR
;       

Conclusion

After all that, and testing many different chips, I can confirm that at least with these particular chips, all the chips with the notch on the end were AY-3-8910, and the ones without the notch were all YM2149, despite what the marking say.

Yamaha YM2149 chips

I believe all three of these are Yamaha YM2149 chips.

  • The package has a round depression for pin 1, and no notch on the end
  • The audio outputs have around 2V offset voltage
  • When you write 31 to register 1, you read 31 back

It seems both of these chips started out life looking pretty similar. You can sort of see why they would do the remarking. The old, scratched, chip with the less popular part number, and older date code is far less likely to sell than the one that has been sanded, painted, and laser etched with a largely compatible, more popular part number, and a more recent date code.

Whoever is doing this, please stop it.

AY-3-8910/2 chips

I believe all of these are GI AY-3-8910 and 8912 chips.

  • The package has a round depression for pin 1, and a notch on the end
  • The audio outputs have around 0V offset voltage
  • When you write 31 to register 1, you read 15 back

It is not clear if the two chips remarked as Microchip were originally Microchip, or were old GI chips like the rest.

You can just see the remains of the pin 1 dot in the right light. Not much left after the original top later has been sanded down.

If you don't believe me about the sanding, see for example this AT28C64B chip where not all of the original top was sanded off before it was remarked.

See this video for much more information about the remarking of chips: https://www.youtube.com/watch?v=k72SFBOZ_lw


Conclusion to the conclusion

So, after all of that, which chip am I leaving in the board?

Well, the Yamaha YM2149 seems to sound better to me. I am using the old scratch one, I just gave it a bit of a clean up with some Meguiar's Plast-RX, which is good at getting out light surface scratches, and it turned out reasonably presentable.

I think that is all I have to say on this for the moment, that turned out to be a lot more than expected, I hope you found it interesting.

Thanks to George Beckett and Ed Brindley for their help with this post


Advertisements

Minstrel 4D

The Minstrel 4D kits are shipping now, you can order one from The Future Was 8 bit

https://www.thefuturewas8bit.com/minstrel4d.html

More info in a previous post:

http://blog.tynemouthsoftware.co.uk/2022/08/minstrel-4d-overview.html


Z80 Kits

The YM2149 Sound Card is available from Z80Kits.com

https://z80kits.com/shop/ym2149-sound-card/


Patreon

You can support me via Patreon, and get access to advance previews and behind the scenes updates. These are often in more detail than I can fit in here, this post contains bits from three Patreon posts, and there is a forth and fifth to follow. This also includes access to my Patreon only Discord server for even more regular updates.

https://www.patreon.com/tynemouthsoftware