Space Invaders audio rewrite


james1095

Recommended Posts

If you play a real Space Invaders cabinet, you might notice that the sounds of the FPGA Arcade implementation are not right. Grant Searle noticed this after building the original circuit with real hardware and re-wrote the audio code to provide sounds far more true to the analog sound circuits in the original game. Posted here with his permission to use as you like. I made a slight change to fix the width of the output signal but otherwise this is his code. Just throw it into the source folder replacing the original file of the same name. Then make one minor change in the sound board instantiation in the top level changing S1 and S2 to P3 and P5. I found I had to select Project> Cleanup Project Files otherwise I was getting a cryptic error.

 

I've tried out the new sound code and found it to be a big improvement. So far I've only actually loaded and run it on an Altera board but it compiles fine in Xilinx ISE so I'm pretty sure it will just work.

invaders_audio.vhd

Link to comment
Share on other sites

I might go through and change the input names to the sound module to make it a drop-in for the old one requiring no changes to the top level code, I'm not sure if anyone cares.

 

I've got an improved version of the Galaxian sound code that I also got from Grant. It eliminates the needless use of playing sampled sounds from ROM and synthesizes all of the sound effects entirely in VHDL. It requires a few more changes to the top level to hook up the currently missing sounds but it sounds great on my Altera board. I just need to finish porting it over to the Papilio code and test it and then I'll post it so somebody can check it in. I compiled the Papilio Galaxian from source this morning and it's running fast and displays two side by side screens so I must have screwed something up somewhere. Didn't have time to investigate yet.

 

I can't figure out why Galaxian was coded to play sampled sounds in the first place. The VHDL to synthesize all of the sound hardware is not very complicated, I think it's even simpler than the sampled audio and it doesn't require a sample ROM.

Link to comment
Share on other sites

Galaxian being coded for samples was initially probably because of floorspace on the fpga, nobody just had the dedication to finish it before Grant :)

Alex actually did add some more than minor corrections to the original, not sure if Grant used any of his code.

 

If you're seeing double you should probably check out a later version, the latest papilio arcade definitely doesn't have the issue.

(i should know, my initials were on the commit that caused it :/)

Link to comment
Share on other sites

I don't think the rewritten audio code takes up any more space on the FPGA than the sample based code, I can check though.

 

Ah ok, I'll grab the latest version then, I didn't realize it was in active development. I also assumed that anyone checking in changes would.. You know.. test the code prior to checking it in. :D

Link to comment
Share on other sites

Actually I realized I've got the files here so I'll attach the new Galaxian sound code in case anyone wants to get a head start and try it out before I have a chance to sort it out. I'm attaching the top level file too to show the minor changes that needs. Note that it's currently set up for Altera which is a bit more flexible in what you can put in the entity instantiation. For Xilinx you will need to assign "('0'&W_SDAT_A(7 downto 1)) + W_SDAT_B" to a separate signal and assign that to dac_i.

 

I've got this sound code working on my Papilio so I should be able to help out if any issues occur, but I don't expect there will be. Oh and please don't bug Grant about this stuff, he's very busy and was gracious enough to share the code but I don't think he wants to get tangled up supporting other platforms.

mc_sound_b.vhd

Galaxian.vhd

Link to comment
Share on other sites

I posted the new code, I can grab the latest Galaxian this weekend and roll it in if nobody else has a chance to get to it first. I don't have a Git repository to post it on though.

 

 

 

Did you get the Multicomp working on the Papilio? I spent a while trying to get that to work but never got it working quite right, I suspect there were timing issues. A few times I got it to compile and work properly but other times I'd get a bunch of gibberish on the screen. I was able to get the 6502 and 6809 machines working just fine through the serial interface but the Z80 wouldn't boot. Eventually I got tired of screwing with it, I built a custom daughterboard for the same $18 FPGA boards Grant used and have been using that instead, it worked out very well.

 

Another issue I ran into is the code for the display uses modulo division and Xilinx only lets you do that on numbers that are multiples of 2. I worked out some other methods that worked in most cases but there were still a few situations where the result was not right. I don't recall exactly where I left off.

Link to comment
Share on other sites

While we're discussing the arcade code, something I did with Space Invaders that might make sense for the other games is to put the PS/2 keyboard decoder back on. I connected both the discrete pins/buttons and the output of the PS/2 decoder to the button signals so you can seemlessly use either a keyboard or plug in a joystick. Generally I much prefer real arcade controls but sometimes it's easier to just grab a keyboard and plug it in, and the arcade megawing already has a PS/2 port.

Link to comment
Share on other sites

I had the multicomp running with z80 as far as i can remember yes, but spent the majority of time playing with 6809.

 

 

As for adding PS/2 controls - i think at least A2601 in papilio arcade has it, can't remember if i had any other reason than plain laziness for not including that in the others.

Since we now have 2 people thinking it's not a bad idea i might as well plug the interface to rest of the games too  .. manicminerman really deserves keyboard controls anyway even if they 

are not the rubbery kind like on a real speccy :D

 

+ we've been working on/off with Felix to add snes/nes pad control, code is more or less ready but not yet in.

Link to comment
Share on other sites

ok, had some time to play and got the new sound working ok.

Keyboard not so much unfortunately ... i'll update my github once i get that sorted out.

 

If anyone wants bitfiles for romvault i can attach them here.

 

I guess not many people have been playing galaxians, the controls were reversed on papilio duo   :)

Link to comment
Share on other sites

ok, updated my git repo with the new sound (and ps/2 keyboard) for galaxian.

Papilio one/pro bitfiles for RV are completely untested, only galaxians verified on DUO so mrdonight might well be broken (please do report).

 

fwiw papilio one (s3) was the only one requiring the dac input via an aux variable, the 'new' parser for s6 was happy with the 'Altera syntax'

 

..my apologies for the state of the sources, they do work but they all look absolutely horrible, can't promise anything good will happen to them unless

i magically manage to retire from real work.

Having said that - Jack would probably be more than happy if someone finds the time to fix or clean up something so please do 

submit fixes/additions.

Link to comment
Share on other sites

Cool, glad to hear that's worked out, hopefully others enjoy the improvements. I put the new Galaxian sound code into my own build over the weekend and played it for a while. At first the background drone was only pulsing at the highest speed but then I realized I'd forgotten to insert the code in the top level that controls the speed and with that added it sounds great. I may look into cleaning up the code here at some point, I'm a bit OCD about everything being tidy like that. I don't personally use the Papilio source though, In most cases I just take the original code and port it myself and create my own collection of bitfiles that have the ROMs all rolled in.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.