About me

My photo
Vanløse, Copenhagen, Denmark
Mathematician. Working programmer/system developer. Nerd. Married. Father of 3.

23.3.14

Using GALs to replace small, sparse and/or redundant bipolar PROMs (Galaga bootleg)

If you've done repairs on some of the earlier arcade games (Galaga, Donkey Kong, Pac-Land etc.), you're likely to have encountered the type of components known as bipolar PROMs. These are PROMs based on TTL technology and are one-time-programmable (OTP), as you literally burn fuses when you program them. They are often pretty small in capacity but very fast, and on many boards, they are used for things like address decoding, sprite selection, pallets etc.
Now this whole project started out with me repairing an original Namco/Bally Midway Galaga for my friend Muerto. During this, I found, that a bipolar PROM used for selecting sprites from the sprite-ROMs (i think?!) had a dead pin. Luckily, I had a bootleg Galaga containing the same PROM sitting on the shelf, and replacing with that solved the problem. But now I just a non-working bootleg.
Now as bipolar PROMs are pretty old technology, blank ones are not easy and also a bit expensive to acquire; they will easily cost you $10 (or more) a piece + P&P on eBay. Also because of the technology being old, most new (even high end) programmers doesn't support programming them either; many doesn't even support reading them. So that means that you'll have to get some expensive hard-to-get vintage programmer and also expensive parts to get you PCB with broken bipolar PROMs up'n'running again. As I was not willing to spend that much green on a bootleg (that I btw had gotten for free at some point), I started thinking about alternatives to bipolar PROMs.
The first thing the pops into mind, is trying to use some kind of EPROM. But when you try to look at the specs side by side, you'll quickly realize, that most EPROMs are much bigger in capacity (and while that is not a direct problem, it seems like a bit of a waste), but more seriously, the speeds of EPROMs are often about a factor 10 slower than the bipolar PROMs! So EPROMs were out...
Next I started looking at different PLDs and found, that the speeds of standard PALs and GALs are often comparable to that of bipolar PROMs or a bit faster. Moreover, almost any cheap ass modern universal programmer supports programming GALs, you can get new GALs for about $1 a piece on eBay, and you can erase them electronically and reprogram them.

I actually had 2 defective bipolar PROMs on the bootleg Galaga, that needed replacing. That was because when I realized how easy it was to read these in my Top2005+ using my own software u2pa, I wanted to


on the Galaga PCB. But when I tried to get the one labeled "5" at position 5N out, I accidentally broke off the GND-pin. The break was so near the plastic, that a normal pin transplant wasn't an option, so enter Mr. Dremel. I managed to cut the plastic down so I could solder a bit of wire on the broken pin; it was good enough for dumping


but not at all durable enough to put back in the socket. This PROM must be involved in the final stages of the picture generation, cause when it's not in it's socket, all you get is a blank screen. I decided to start with that one, as it's a TI TBP18S030 (equivalent to the better known Philips N82S123),


that only holds 32 bytes (= 256 bits).
Now in order to get started, I needed some way to generate the equivalent equations, so I wrote a little QAD method that generated the Boolean equations in the format of WinCUPL, and hooked it up to the u2pa CLI


If we start by looking at the raw dump


we'll see, that the 2 lines of bytes, are actually pretty redundant, and that's good, as we want to fit then into a logic unit. Next we take the raw WinCUPL equations generated by u2pa


cut them out, and make them into a real WinCUPL project. And I have to admit, that I was a bit surprised to find, that it compiled to a GAL16V8 right away };-P


At this point, the observant reader should already have noticed, that all the outputs of the GAL are on the "wrong" side, compared to the data pins on the bipolar PROM. Some kind of adaptor had to be made in order to make it fit onto the Galaga PCB. I choose this configuration of pins


Again the observant reader might have discovered, that if you turn the GAL 180 degrees, you can get all but one pin to match the PROM (not including the Vcc and Gnd of cause).
When I dumped the GAL using u2pa with the above configuration and compared it to the original


it was a perfect match };-P
So I started soldering up a small adaptor



Actually pretty easy, as almost all the pins match up };-P I dumped it as per the original PROM and still got the same correct result. So I cut it up



installed it in the socket


and BAM! had picture back on screen };-P


The Galagas still didn't look right, but that was expected. So now on to the next PROM...
This one is a TI TBP24S10 (equivalent to the better known Philips N82S129), a 4 x 256 bit PROM. As I'd only read ROMs that had a number of outputs being 8 or 16 until now, I had to make a little adjustment to the coding of u2pa to make it work. The dump in MAME is made by just saving whole bytes padded with zeros, so I choose to do the same and use this configuration


Even though this PROM potentially contained 1024 bits of data, only the first part actually had non-zero entries


So I was still pretty confident, that this would fit onto a GAL. So ran my equation generator, and made a WinCUPL project with a GAL16V8. But when trying to compile


I got "excessive number of product terms" on all 4 outputs. Now at this point, being all new to WinCUPL, I didn't knew, that minimization was not 'on' by default, but that you have to turn it on (you should use Expresso) in the compiler options (this was something porchy told me later on)


So I started 'hand reducing' the equations. Actually now afterwards, I find it kind of cool, as you get a whole new feel for the equations, and they have a very satisfying aesthetic look (oh yeah, just go ahead and call me crazy; but being both a mathematician and a computer scientist, I can't help it };-P).
One of the first things I noticed from just looking at the raw dump in a binary editor was, that every 4th entry was F (1111). So every time A0 and A1 was 0, all 4 outputs was 1, meaning that all entries from the 4 outputs starting with 00 could be removed, and replaced by a single line for every output
 Dn = !A0 & !A1 & !(A2 &  A3 &  A4 &  A5) & !A6 & !A7
where the "!(A2 &  A3 &  A4 &  A5)" part is because, we want this to stop when we reach the point, where all entries are 0.
Next I found quite a few pairs of entries, where the only difference between the two, was that one started with 01 and the other with 10. Now these can of cause be combined into one starting with (A0 # A1) (XOR).
So now I was down to a respectable number of equations for each output, but when I compiled I still got "excessive number of product terms" for 3 of the outputs. It was actually also at this point, that I turned on minimizing, but that didn't do any difference at all }:-S
Then I got the idea of trying a bigger GAL with more available product terms per output, namely a GAL22V10. And when changing to that, it frakking compiled without errors };-P For this GAL-replacement, I'd choosen this pin configuration


That way, it could act like a drop-in replacement (with part of the IC hanging out to the back of the socket, though) if I just connected pin 8 and 12 for proper grounding.
My only problem now, was that I didn't have any of those gorram 22V10. So I ordered some on eBay and waited.... and Waited.... and WAITED!.... and FINALLY


they arrived from China };-P I rushed to program one, dump it with u2pa, and test it against the original image


A perfect match! Sweet! };-P Next up was the big test on the actual board


(using a little jumper wire for ground connection), AAAAAAAND


IT WORKED! The Galagas were now back to normal!
To finish this up nicely, I choose to desolder the old socket from the board, and install a slightly bigger one, with pin 8 and 12 interconnected



Of course there wasn't holes on the PCB for the extra pins, so these were just removed


By the way, after I finished this project, I actually (by mere coincidence while googling... I don't know why it hadn't occurred to me to google "bipolar prom gal" before, but it hadn't) found this page by retroclinic. Here he uses a truth table instead of (as I) equations, so I decided to try that out also, as it somehow seems easier. So I made a tiny addition to my processing method, so it could output a truth table as well. But when I compiled and programmed the resulting jed-file for the first GAL16V8 and dumped again, I actually got some differences compared to original image; a few bit were flipped. First I thought, that it was my simple method to generate the truth table that had a bug, but I've been over the code several times, and I can't find any errors (if you find one, please let me know, and I'll fix it). So my theory at the moment is, that I've found a bug in the WinCUPL compiler. So I think I'll stick to equations in the future... being a mathematician, I actually also fancy them more };-P

Should you ever want to try this at home yourself, the dumps of the bipolar PROMs for games containing them, is often part of the MAME ROMs. If you want to try my equation generator, it's now a part of u2pa; the help entry can be seen with the command
~>u2pa help bdump process
Remember, that if you own a Top2005+, u2pa also has support for reading a lot of bipolar PROMs now.

WinCUPL can be downloaded here.

Last but not least, the pld's and the jed's I produced for Galaga, can be downloaded here.

I wish to thank porchy for his big help and support on this project, as I didn't knew much about GALs or WinCUPL when I started out.