So, my fun little project has yielded some results. I built myself a little interface board (ugly as heck but it works) that lets me connect a Raspberry Pi to my Gottlieb System 80b machine via the wiring harness that connects to the soundboard. No modifications need to be made to the machine's wiring - I can pull this out and put the soundboard back in any time. It sends the control signals to the Pi's GPIO header for processing, 5v from the game to power the Pi, and the audio output from the Pi to the game's audio amp.
I wrote a little Python script (also ugly since I had never used Python before) that decodes the signals and plays the appropriate sound effect (stored as a wav file). The script is still a little rough around the edges since it needs more logic around which sounds are allowed to overlap each other and which ones should stop the previous sound before starting, but all the basics are there and it plays the right sounds at the right times, just like the original soundboard.
Once I figure out if there's a pattern to what is allowed to play over each other (I already figured out the easy ones - background music), I'll use that info to finish up the standard emulation script. I'm also planning to work on an enhanced version of the script that will be selectable via a switch I'll be adding to the board. The enhanced version will ignore music changing signals and play random selections from a playlist, plus monitor for contextual information about the game - like if no sound has been triggered in 30 seconds and the game over sound wasn't the last thing played, play a sound or something. I might also add a header to the board to allow, with a couple of extra wires run through the machine, the two buttons on the front of the cabinet (normally used for selecting initials if you get a high score) to skip forward and backward through the musical playlist.
By the way, the crazy resistor in the pic below is there because I figured out at the last minute that I needed a pull up resistor for one of the signal lines (but none of the other four, oddly enough). It will find a permanent home later.
My ugly sys80b to Raspberry Pi adapter
My ugly code (sorry the tabs disappeared, also not the most recent but not far off):
import pygame.mixer
from time import sleep
import RPi.GPIO as GPIO
from sys import exit
#import sys
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #1
GPIO.setup(37, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #2
GPIO.setup(35, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #4
GPIO.setup(33, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #8
GPIO.setup(31, GPIO.IN, pull_up_down=GPIO.PUD_UP) #16
GPIO.setup(29, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #reset
#GPIO.setup(7, GPIO.IN) #aux input 1
#GPIO.setup(11, GPIO.IN) #aux input 2
#GPIO.setup(13, GPIO.IN) #aux input 3
#GPIO.setup(15, GPIO.IN) #aux input 4
pygame.mixer.init(22050, -16, 2, 1024)
TOTALSOUNDS = 31
SOUNDFOLDER = "./sounds/"
SOUNDNAME = "sound"
SOUNDEXT = ".wav"
pygame.mixer.set_num_channels(3)
snd = [""]
soundChannel = [pygame.mixer.Channel(0), pygame.mixer.Channel(1), pygame.mixer.Channel(2)] #[""]
sndMatrix = ["0","0","0","0","0"]
lastplayed = 1
debounce = 0
reset = 0
snch = 1
sloop = 0
for x in range(1, TOTALSOUNDS+1):
snd = snd + [pygame.mixer.Sound(SOUNDFOLDER+SOUNDNAME+str(x)+SOUNDEXT)]
print "Soundboard Ready."
soundChannel[1].play(snd[18])
while True:
try:
if (GPIO.input(40) == True):
sndMatrix[0] = "0"
else:
sndMatrix[0] = "1"
if (GPIO.input(37) == True):
sndMatrix[1] = "0"
else:
sndMatrix[1] = "1"
if (GPIO.input(35) == True):
sndMatrix[2] = "0"
else:
sndMatrix[2] = "1"
if (GPIO.input(33) == True):
sndMatrix[3] = "0"
else:
sndMatrix[3] = "1"
if (GPIO.input(31) == True):
sndMatrix[4] = "0"
else:
sndMatrix[4] = "1"
if (GPIO.input(29) == True):
reset = 0
else:
reset = 1
sndtoplay = sndMatrix[4]+sndMatrix[3]+sndMatrix[2]+sndMatrix[1]+sndMatrix[0]
# #temp keyboard code
# sndtoplay = sys.stdin.readline()
# if "r" in sndtoplay:
# reset = 1
# sndval = 0
# else:
# sndval = int(sndtoplay,2)
# #end temp keyboard code - uncomment next line
sndval = int(sndtoplay,2)
snch = 1
sloop = 0
sleepval = 0.001
if sndval == 16:
continue
if sndval < 9:
snch = 0
if sndval <> debounce:
debounce = sndval
continue
if sndval > 8 and sndval < 16:
snch = 2
sloop = -1
sleepval = 0.005
if sndval == 12: #end game music, don't loop
sloop = 0
if sndval > 15 and sndval < TOTALSOUNDS:
if sndval <> debounce:
debounce = sndval
continue
if reset == 1:
soundChannel[lastplayed].stop()
reset = 0
print "stop "+str(lastplayed)
if sndval > 0 and sndval < TOTALSOUNDS:
if soundChannel[snch].get_sound() == snd[sndval]:
print ('.'),
sleep(sleepval)
continue
if sndval > 0 and sndval < 8:
soundChannel[0].play(snd[sndval],sloop)
lastplayed = snch
soundChannel[1].stop()
#soundChannel[1].fadeout(1000)
print "play "+str(sndval)
elif sndval == 8:
soundChannel[0].play(snd[sndval],sloop)
print "play "+str(sndval)
elif sndval > 8 and sndval < TOTALSOUNDS:
soundChannel[snch].play(snd[sndval],sloop)
lastplayed = snch
print "play "+str(sndval)
elif sndval == TOTALSOUNDS:
pygame.mixer.stop()
print ('!'),
elif sndval > TOTALSOUNDS or sndval < 0:
print "invalid code - "+str(sndval)
#print sndtoplay
sleep(sleepval)
except KeyboardInterrupt:
exit()
Post edited by jhanson: Updated code