I'VE GOTTEN SOUND TO WORK!!!
I am posting this so that anyone who stumbles across this thread on Google will not be left hanging
Sorry in advance for this being long, the goal is for it to be comprehensive more than anything.
- NOTE: My specific solution is for ca65, not wla dx; however, I'm sure the crux of it carries over.
So first I made the track in SNES GSS. Then I did File > Export
and it produced 4 files:
- 1. spc700.bin - the driver file for the SPC700
2. music_1.bin - the music data
3. sounds.asm - unused, I deleted this because I didn't need it
4. sounds.h - unused, I deleted this one too for the same reason
- NOTE: Originally when I would do File > Export it wouldn't work (it said I/O Error 123). I think the issue was I needed to do File > Save and Export first. I had done File > Save earlier but I guess that doesn't cut it. Anyways, if you also find yourself in a spot like that, simply do snesgss.exe filename.gsm -e [optional export path]. That also produces those 4 files I mentioned earlier.
- NOTE: By the way, when you do File > Export, a dialog pops up which lets you choose where to save the binary files. If you do File > Save and Export, it exports the binary files in the same folder you save the .gsm file.
My driver file was quite small since I used the sawtooth and triangle waveforms that came with SNES GSS (located in the instruments
folder). As a result, it fit in one ROM bank.
The secret sauce came from this Kung Fu Master port (Github link)
written by Antihero Software. Thanks to KungFuFurby for linking me to that! (Post is earlier in this thread)
The files I needed were src/snesgss.asm
. I downloaded them and added them to my project folder. snesgss.asm
had all the subroutines I needed to call. snesgss.inc
contained the .import
directives needed to access these subroutines.
- NOTE: These files were written for the ca65 assembler. Unfortunately, they will not work if you're using wla dx. You could port it over manually, or in that post by KungFuFurby, the other two repos use wla dx assembler (I believe).
- EXTREMELY IMPORTANT NOTE: If you search online you will see some posts on this forum itself that say that the first two bytes of spc700.bin contain the size of the driver file and as a result should NOT be transferred to the SPC700. This is 100% correct however do NOT fix this by opening up a hex editor and deleting the first two bytes! The snessgss.asm file takes care of this for you by having the .incbin directive skip over the first two bytes. Basically, don't touch spc700.bin!!
I had to make one change in snesgss.asm
. On line 169, there's a macro expansion:
Code: Select all
_GSSDataGenerator "../ressource/music", 1, "BANK7"
The first parameter (the string) was the location of spc700.bin
and music_1.bin relative
. I changed that string to "music"
- NOTE: You need to keep spc700.bin and music_1.bin in the same directory for the macro expansion to work!
The next parameter was the number of songs. I kept that as 1
Finally, the last parameter was the bank to put all the data in. I changed it to "BANK4"
cuz I only was using banks 1-3 up until that point.
- NOTE: if spc700.bin and music_1.bin don't fit in a bank together (i.e. their combined sizes is > 32 KB) then you'll have to modify the macro to break up the files and place them into 2 separate banks.
Moving on, at the top of my main.asm
I added .include "snesgss.inc"
. Then to my startup routine, I added the following lines of code to my startup routine:
Code: Select all
lda #$00 ; Play music_1.bin
These lines needed to go after SNES initialization (of course) but before VBlank is enabled!!!
(dear god is that an important point).
Finally, I had to modify my build.sh
bash script (I'm on a Mac) to look like this:
Code: Select all
ca65 -v snesgss.asm
ca65 -v main.asm
ld65 -C lorom128.cfg -o game.smc main.o snesgss.o -v
rm -rf main.o
Basically I had to compile snesgss.asm
separately and then link the produced object file.
After all that, I ran my build script and was greeted with glorious audio!
Of course I was just trying to play a single song that loops over and over. Changing songs, playing sound effects, and other APU functionality I have not messed with and probably won't for this current project. Hopefully this all is useful to someone some day (it sure would've been useful to me
P.S. If anyone needs more detail about what I did, go ahead and just reply to this thread. I get email notifications, so I'll see that and reply (probably)
P.P.S. If anyone spots any errors please reply to the thread so newcomers don't do the wrong thing and waste time banging their head against the wall! I can update my post if needed too.
For anyone wondering, here is a SNES GSS repo: https://github.com/nathancassano/snesgss. The README does a pretty good job describing how to use it. See Update 2!
There's also a video of a guy teaching you how to use it: https://vimeo.com/119986872
Those two together should be enough to figure out how to create the music.
As calima points out in this thread, the repo I linked has an old version of SNES GSS (version 1.22 to be exact). This is a very outdated version. Instead you should get version 1.42 from Shiru's website: https://shiru.untergrund.net/software.shtml
Here's what you miss out if you use that Github repo instead of the one from Shiru's website:
v1.42 20.02.17 - Instrument selection in the main menu
v1.41 25.05.14 - MIDI input device can be changed in the config file
v1.4 24.05.14 - paste over; shifting markers and labels in multichannel Expand/Shrink; MIDI input support
v1.31 03.04.14 - song duration estimate, displayed in the window header
v1.3 02.04.14 - Output monitor[/u] and built-in tuner; minor fixes
v1.23 01.04.14 - SPC700 driver fix to remove noise burst on initialize heard on the real HW and latest snes9x versions
Definitely get the newest version!
As far as I can tell it works almost exactly like the version in the video (which is actually version 1.2, even older than mine!).