logo
 drop

Main

Community

Submissions

Help

71258572 visitors

Author Topic: SPC700 Help!  (Read 955 times)

wiiqwertyuiop

  • Newbie
  • *
  • Posts: 20
  • Up, up, and away!!
    • View Profile
    • Hyrule Hacking
SPC700 Help!
« on: March 03, 2012, 05:01:08 pm »
Ok, I started making my own (SNES) ROM and everything seems to be working fine so far, GFX were a little tricky but I got it, but there is one things I still don't know how to do: insert SFX/music and then play them. My main problem is not uploading them, as I ('m pretty sure I) know how to do that, I'm just not sure WHAT to upload, or how to get them to play really (like how does storing, lets say #$01 to $2140 play the correct sound effect?). I've looked around pretty much everywhere really and I can't seem to find what I'm looking for, so any help is appreciated!
Into Zelda hacking, or want to start getting into it? Join this: Link. I'm looking for mods!

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5731
    • View Profile
    • Nightcrawler's Translation Corporation
Re: SPC700 Help!
« Reply #1 on: March 03, 2012, 06:44:47 pm »
There is no answer to that question. You need to write your own SPC700 program that will run and monitor the ports coming from the CPU side. What to send, what to do with those values, and how something is played over the DSP is entirely up to your program. You would make a program that looks for $01 to come across the port and then it would decide if it needs to load new samples, communicate further with the CPU, access the DSP registers, change songs, volume etc. It is entirely driven by your program on the CPU side and your program on the SPC700 side. It's all up to you to decide. You have the DSP registers at your disposal from the SPC700 to generate sound, and you can do that however you'd like. BRR samples are mentioned in the documentation. That's just the required format for the WAV instrument (or streaming) samples. That's about the only thing required by the system. Everything else is up to you. :)

I choose to write a MIDI driver for the SPC700 to play original compositions I made via MIDI on my keyboard. You can choose to use a custom format, a tracker format, or near anything. The thing is you have to code a program to decipher it and play on the DSP registers. You can also look at other SPC files for a wealth of information. They contain the sample data, song data, and spc700 program needed to play it.  It will take you some time to understand it all. It's just not a simple thing to do. But, it's very flexible.

Hardware and register information:
http://www.romhacking.net/documents/197/
http://www.romhacking.net/documents/191/

Reasonable example of a program on the SPC700 side that does some interesting things.
http://www.romhacking.net/documents/177/
TransCorp - Over 15 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Herakles IV SFC/SNES Translations

wiiqwertyuiop

  • Newbie
  • *
  • Posts: 20
  • Up, up, and away!!
    • View Profile
    • Hyrule Hacking
Re: SPC700 Help!
« Reply #2 on: March 03, 2012, 08:38:05 pm »
Hm.. i think im getting it. So basically I write some SPC700 code that checks for certain values and plays the correct sound effect/song, insert it in my ROM, and then upload to the SPC700?

Also thanks for those links! I'll be sure to look at them!
Into Zelda hacking, or want to start getting into it? Join this: Link. I'm looking for mods!

FinS

  • Full Member
  • ***
  • Posts: 182
    • View Profile
    • nothing much
Re: SPC700 Help!
« Reply #3 on: March 03, 2012, 08:56:13 pm »
Quote from: Nightcrawler
I choose to write a MIDI driver for the SPC700 to play original compositions I made via MIDI on my keyboard.
I would like to know more. Did you insert sound samples into the rom for each sample you were using or did you insert a whole midi soundbank? Would you be able to share any asm or notes for your midi driver? I would one day like to do something like this but I fear it's beyond my abilities now.

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5731
    • View Profile
    • Nightcrawler's Translation Corporation
Re: SPC700 Help!
« Reply #4 on: March 04, 2012, 05:05:31 pm »
wiiqwertyuiop:
The very first thing you're going to do is upload your SPC program to the chip.  It starts up with the boot ROM that does nothing but allow you to follow it's communication protocol to upload your program and begin execution of it. The program is going to be in binary form in your ROM. After it passes off execution, the system doesn't do anything. Your programs on both sides are responsible for whatever communication protocol, commands, and switching you want.

FinS:
I did it a few years ago. My implementation was pretty bare bones to facilitate my needs. I only used samples for the instruments I was using, and I got them from another game and did not convert any midi soundbanks to BRR. I was using it for splash screens, so I didn't need logic for switching sound effects, songs and what not. It was once and done. Parsing the MIDI file format, and proper timing was the hardest part. I think I limited to type 1 only MIDIs, (or whichever were the simplest form). I also limited myself to a subset of MIDI commands as implementing the full specification is daunting. I still have some unresolved timing bugs and I still have difficulty fully understanding ADSR/envelopes and the DSP synthesis to adjust the sound properly. I can share some source for specific areas of interest. Send me a PM if interested.

« Last Edit: March 05, 2012, 08:25:02 am by Nightcrawler »
TransCorp - Over 15 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Herakles IV SFC/SNES Translations

Bregalad

  • Hero Member
  • *****
  • Posts: 1587
  • Location: Jongny VD, Switzerland
    • View Profile
Re: SPC700 Help!
« Reply #5 on: March 05, 2012, 04:00:44 am »
There's probably no way you can ever fit a whole GM sound bank in SPC's 64k memory, even if you choose the lamest quality samples.

If you're going to write your own sound engine for the SPC (you should) then the hardest part is to find an assembler. WLA-SPC700 which I think is the only available assembler for the SPC700 is full of bugs. I wrote my own SPC sound engine but I lost the source (I still have the test SPC though but it's not of much use).
If you're doing to do that be sure to first compile a standalone SPC file that plays some testing music or sound effect, and when you get this working you should do the communication part that downloads it from the 65816.

Other than that the SPC is nothing complicated really. Some instructions are poorly documented, but the most common instructions are similar to 6502, just written differently.

Nightcrawler

  • Hero Member
  • *****
  • Posts: 5731
    • View Profile
    • Nightcrawler's Translation Corporation
Re: SPC700 Help!
« Reply #6 on: March 05, 2012, 08:39:04 am »
There's probably no way you can ever fit a whole GM sound bank in SPC's 64k memory, even if you choose the lamest quality samples.

You don't need to. The full set needs only be in the ROM. You only have 8 channels on the SNES. You're going to be quite limited in how many instruments you're going to be able to use at any one time, or even for a given song. So, you only need a handful of samples in memory at any one time. If you're crafty enough, you could probably even swap samples out on the fly over a given amount of time/notes.

You're probably never going to be able to create something where you could play any MIDI of any type (Why would you want to with the 8 channel limitation anyway?). However, if you have a reasonable target, or if your compositions followed an established set of rules from your engine, you could do quite a bit.
TransCorp - Over 15 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Herakles IV SFC/SNES Translations

Bregalad

  • Hero Member
  • *****
  • Posts: 1587
  • Location: Jongny VD, Switzerland
    • View Profile
Re: SPC700 Help!
« Reply #7 on: March 06, 2012, 03:53:31 am »
It's true that, technically, you only need 8 samples in memory at once, but doing a program that transfers instruments between the 65816 and the SPC700 during music playback with such a limited serial protocol is definitely not something I'd do as my first SPC700 project !