Where Can I Find Any Good SPC Information

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
undisbeliever
Rookie
Posts: 35
Joined: Sat Aug 21, 2004 2:31 am
Location: is an eight lettered word

Where Can I Find Any Good SPC Information

Post by undisbeliever »

Can you help me find any good (programming wise) information on the SPC format and programing information. I am trying to find information about it's programming stucture

can anyone help me.
Dolphin
Rookie
Posts: 39
Joined: Thu Aug 26, 2004 8:55 pm

Post by Dolphin »

The only place I know is to examine zsnes source code. Or look at the spc players for linux, because they will definatly come with source code.
neviksti
Lurker
Posts: 122
Joined: Thu Jul 29, 2004 6:15 am

Post by neviksti »

SPC format:
http://www.snesmusic.org/files/spc_file_format.txt

But that isn't really relavant to programming the SPC700 (unless you are going to try to make it play a SPC, which isn't that easy since that was not the purpose of an SPC file).

As for SPC700 programming info, the spc700_apu_manual.txt file in my starter kit tells you more than enough except one crucial part: the bootstrap ROM.

The bootstrap ROM is a 64byte ROM that is mapped into $FFC0-$FFFF on reset (and until you turn it off) in the SPC700's memory. It runs a little program that allows you to load code/data into the APU memory, and when you are done, it can jump execution to another point in the memory.

Understanding this bootstrap program is important, and it is fairly simple. Sadly, I don't have a copy of the ROM on this computer. It should (hopefully) be fairly easy to find in the zsnes source. If you have trouble, let me know and I can try to retrieve my copy of the ROM (disassembled) and some examples as well, from my old computer.
d4s
Rookie
Posts: 28
Joined: Wed Sep 08, 2004 12:05 pm

Post by d4s »

with a little help from neviksti and ville helin, i've
managed to compile a working brr stream receiver and player with wla-spc700.

although im no expert on the topic (i started programming in assembler
1-2 months ago), i guess working sourcecode in combination with nevikstis docs should help you enough and answer all questions.

personally, i started coding on the spc700 by dis- and reassembling existing
spc music files with spc disassembler by yousei, however, i wouldnt recommend using it.
it fucks up in lots of ways, some opcodes are interpreted wrong,(dont remember wich) others have their operands reversed(mov and adc, at least).
well, i can send it over if you want, although id like to ask you to not give it away.

oh, and if theres a decent spc disassembler(for *.spc files or blocks) out there, id like to get ahold of it, cause i dont have any atm.

[edit]
the bootstrap rom can be found in some doc by yoshi, here it is:

; this routine is a copy of the SPC700's RESET routine, which was discussed
; in the famidev development group intensely already.
; It basically gets the SPC data from the CPU (65c816)'s RAM into the
; SPC700's ram.


0B9B CD EF MOV X,#$EF ; normally starts at $ffc0
0B9D BD MOV SP,X ;
0B9E E8 00 MOV A,#$00 ;
0BA0 C6 MOV (X),A ;
0BA1 1D DEC X ;
0BA2 D0 FC BNE $0BA0 ;
0BA4 8F AA F4 MOV $AA,#$F4 ;write AA to port0,
0BA7 8F BB F5 MOV $BB,#$F5 ;BB to port1
0BAA 78 CC F4 CMP $CC,#$F4 ;wait for port0 to become CC
0BAD D0 FB BNE $0BAA ;
0BAF 2F 19 BRA $0BCA ;
0BB1 EB F4 MOV Y,$F4 ;
0BB3 D0 FC BNE $0BB1 ;
0BB5 7E F4 CMP Y,$F4 ;
0BB7 D0 0B BNE $0BC4 ;
0BB9 E4 F5 MOV A,$F5 ;
0BBB CB F4 MOV $F4,Y ;
0BBD D7 00 MOV [$00]+Y,A ;
0BBF FC INC Y ;
0BC0 D0 F3 BNE $0BB5 ;
0BC2 AB 01 INC $01 ;
0BC4 10 EF BPL $0BB5 ;
0BC6 7E F4 CMP Y,$F4 ;
0BC8 10 EB BPL $0BB5 ;
0BCA BA F6 MOVW YA,$F6 ;
0BCC DA 00 MOVW $00,YA ;
0BCE BA F4 MOVW YA,$F4 ;
0BD0 C4 F4 MOV $F4,A ;
0BD2 DD MOV A,Y ;
0BD3 5D MOV X,A ;
0BD4 D0 DB BNE $0BB1 ;
0BD6 1F 00 00 JMP [$0000+X] ;
0BD9 C0 DI ; reset vector
0BDA FF STOP ;

from the looks of it, this code also has reversed operands the wrong way.
check offset 0BA4, logical would be this:

move byte AA to port0 ($F4)

instead it reads:

move byte F4 to adress AA,

wich is clearly wrong.
or am i overlooking something?



anyway, from the 65816s point of view, you basically wait for port0,1 to become AABB, then write CC to port0.(or another one, i dont remember)
you then shove a block of data through the spc ports in the following format:

.DW length of block
.DW offset in spc ram to copy the block to

your compiled code and sample/music data

.DW $0000 termination code
.DW start adress to jump to after


you can see what goes to wich ports exactly by examining
the ipl rom, its relatively easy, as neviksti said.


[edit2]
if you want to reset the spc, enabling the ipl rom via the control reg and then jumping to ffc0 should be fine, although i did it the save way and
muted all channels, reset the dsp, clear all ports and then jumped to the ipl rom.
well, whatever.
debugging spc code in realtime works best with snemul for me, although its a fairly old emulator.


i was really happy when i found out that my code worked on both emulators and a real snes, cause i feared it wouldnt work on a snes in case the timing of spc/65816 wasnt 100% accurately emulated and because of my more-hacking-than-programming-style of coding.
plus, i dont have no idea how to debug stuff on a real snes, especially on the spc. ~_=

i wonder how sceners like alphatech or twk and pan did it back in the days.
these people were the true heroes of the snes. ;)
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

Here is an SPC diassembler and cross assembler.

I haven't gotten around to trying this out personally, but I have used Byuu's other tools and they are good and I would expect no less from this.

http://setsuna.the2d.com/?page=utils
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
d4s
Rookie
Posts: 28
Joined: Wed Sep 08, 2004 12:05 pm

Post by d4s »

wow, awesome!
havent tried the exe yet, but from the looks of the source
and the examples, all opcodes in question should be fine.
i just wonder why i didnt find that one on my own. ~_=
anyway, thanks, that should do the job
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

Don't beat on yourself for that. You won't find any of Byuu's tools on any other sites(aside from xas which was now replaced by his xkas). And you probably wouldn't even find that SPC assembler in a search engine being that it's so new and only one one page.

He tries to keep low profile now a days.
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
illegal eagle
Savestate Pimp
Posts: 129
Joined: Thu Jul 29, 2004 2:15 pm
Contact:

Post by illegal eagle »

DSPC might also be worth a try.
"Other people can give you more suggestions as I just lost all my motivation to respond further to this post."
[i] - Nightcrawler[/i]

[url=http://www.geocities.com/illegal_eagle_2003/]vSNES v2.00[/url]: My SNES savestate viewer.
undisbeliever
Rookie
Posts: 35
Joined: Sat Aug 21, 2004 2:31 am
Location: is an eight lettered word

Post by undisbeliever »

No The best SPC diassembler and player is SPC Tool.

It took me a while to find it myself.
It not only looks good but has the ability to disasmemble SPC's while you play it.

While you are running it just press the F7 key to activate its debugger.


There are only two problems.
  • The graphics rely on some obscene VESA mode that may cause it to look weird.
    It will not run on XP
The URL is http://www.snesmusic.org/files/spctl061.zip.

Also the WLA-DX micro assembler can assemble SPC files,

If you guys can get anymore information out of it then, please contact me. I an currentaly find it extreamly annoying designing a game engiene without any sound.
neviksti
Lurker
Posts: 122
Joined: Thu Jul 29, 2004 6:15 am

Post by neviksti »

What all do you want out of a music engine?

I have one fairly complete (SNES and SPC code), but am lacking the tools to go with it (PC side). It shouldn't be too hard to finish if need be.

I didn't put BRR streaming in, but I could add it if necessary.

I figure the game graphics and object handling will take awhile, so you're not in any rush I hope? I won't have time to work on it for a few weeks.
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

neviksti wrote:What all do you want out of a music engine?
An engine that I wrote myself ;) I'm in it for the learning experience!
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
neviksti
Lurker
Posts: 122
Joined: Thu Jul 29, 2004 6:15 am

Post by neviksti »

The perfect answer. :)

So are you working on one? Or is it just on the "things to do wish list"...
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

It's still on that 'things to do eventually' list. I'm still drowing in work on my translation projects. All the sudden all of my projects have translators now which I never expected to happen so quickly since they are hard to find. So I am scurrying to code script dumpers and decompressors trying to dump scripts so they have something to do before they change their mind!

And of course, those of us out in the working world don't have much time for hobbies so time is always limited and there's more to do than time to do it.

My plan was to start learning the SPC700 for a splash screen intro for the next completed translation project. At this point, that looks to be Wozz and it could be completed in the next few months if the translator comes out of hiding with the remainder of the script. I was at 75% done last I heard from him, but that was a long time ago.
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
Post Reply