SPC to ROM

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
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

SPC to ROM

Post by Nach »

Anyone have source code to convert an SPC file to an SNES ROM?

Anyone skilled enough to write up such a tool and willing to donate the source?
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
OptiRoc
Rookie
Posts: 18
Joined: Mon Jan 10, 2005 12:31 am

Post by OptiRoc »

Alpha-II made a tool called SPC2ROM a while back. It's available here.

I'm quite certain the source used to be downloadable as well, since I'm quite certain I based an improved version of the tool on it. :) It's all on another computer right now, but I'll look into it. The tool available doesn't produce very reliable results, and while I made some improvements there was still the need of manually tweaking some flags to get every tune playing correctly.
kieran_
Mugwump
Posts: 824
Joined: Fri Jul 30, 2004 9:05 pm

Post by kieran_ »

I remember that tool... Worked quite well.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

OptiRoc wrote:Alpha-II made a tool called SPC2ROM a while back. It's available here.
Well, without source, it's useless to me.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
OptiRoc
Rookie
Posts: 18
Joined: Mon Jan 10, 2005 12:31 am

Post by OptiRoc »

What are you going to use it for? (I'm just evaluating my motivation to get the tool properly polished :twisted:)
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

OptiRoc wrote:What are you going to use it for? (I'm just evaluating my motivation to get the tool properly polished :twisted:)
Let's just say I want to add some crazy features to ZSNES.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

The source seems to be here.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
byuu

Post by byuu »

Well, SPCs are just RAM dumps of the SPC processor with a header to tell it where to begin execution and somesuch. You should be able to write a small routine fairly easily to copy the SPC data into the SPCRAM area and jump into it.
The major problem I don't understand is how you play more than one SPC without resetting the SNES entirely. Once you give control to the SPC files' code, how do you make the SPC return to the IPLROM to load another SPC?
anewuser
Rookie
Posts: 43
Joined: Wed Jul 28, 2004 4:22 am
Location: x.x

Post by anewuser »

Nach wrote:Let's just say I want to add some crazy features to ZSNES.
Took me a while to figure out the kitchensync, and I didn´t even figured it out. I just read it in the forum. Now we have toaster support, whatever that is. Oh boy, I wonder what will be next!
[url=http://www.fsf.org/resources/formats/playogg]PlayOgg[/url]
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

anewuser wrote:
Nach wrote:Let's just say I want to add some crazy features to ZSNES.
Took me a while to figure out the kitchensync, and I didn´t even figured it out. I just read it in the forum. Now we have toaster support, whatever that is. Oh boy, I wonder what will be next!
So is this a good or bad time to tell you ZSNESW is now Microsoft Smart Home compatible?
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
anewuser
Rookie
Posts: 43
Joined: Wed Jul 28, 2004 4:22 am
Location: x.x

Post by anewuser »

...Head explodes because of the teasing... :lol:

I wonder what that is, even if I won´t ever use it.
[url=http://www.fsf.org/resources/formats/playogg]PlayOgg[/url]
kode54
Zealot
Posts: 1140
Joined: Wed Jul 28, 2004 3:31 am
Contact:

Post by kode54 »

Like woah, source code here.
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

byuusan wrote:Well, SPCs are just RAM dumps of the SPC processor with a header to tell it where to begin execution and somesuch. You should be able to write a small routine fairly easily to copy the SPC data into the SPCRAM area and jump into it.
The major problem I don't understand is how you play more than one SPC without resetting the SNES entirely. Once you give control to the SPC files' code, how do you make the SPC return to the IPLROM to load another SPC?
If memory serves me correctly, your SPC program can still check the ports from the main CPU. I think it's up to you to collaborate exchanging data from that point on. You'd check for a certain values coming from the port periodically from the ROM, and that would initiate the data transfer. You'd have code to handle this on both the ROM side and SPC side.
[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.
kevman
Redneck Gamer-Mod
Posts: 433
Joined: Wed Aug 04, 2004 2:15 am
Location: Pittsburgh

Post by kevman »

But wouldn't that require modifying each SPC file before its loaded into the SPC? I don't think that'd be practical...

Not sure, but I don't think you know that SPC2ROM takes ONE spc and converts it...

Even so, why not have a hard reset? If the SNES can reset itself, including the SPC computer, then just use an itty bitty SRAM file to keep track of whats going on and have it reset itelf to change SPC files...

Also, SPC2ROM loads its own program inside the SPC file in unused space to be executed before the song you want to play. This way you can restore the register values. If you can somehow make that part of the main program loop, you'd be set.
SHREIK!!!!!!! DDdddnnnnnnaaaa! GESTAHLLLLLLLLLL!!!!!!!!

Steelers now officially own your ass.
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Nach wrote:
OptiRoc wrote:What are you going to use it for? (I'm just evaluating my motivation to get the tool properly polished :twisted:)
Let's just say I want to add some crazy features to ZSNES.
I had this awesome idea for a crazy feature last night in the shower, but now I can't remember it. :(
[u][url=http://bash.org/?577451]#577451[/url][/u]
byuu

Post by byuu »

But wouldn't that require modifying each SPC file before its loaded into the SPC? I don't think that'd be practical...
That's exactly the point I was making. Not practical.
Even so, why not have a hard reset? If the SNES can reset itself, including the SPC computer, then just use an itty bitty SRAM file to keep track of whats going on and have it reset itelf to change SPC files...
The SNES cannot reset itself via code; the reset line is controlled by hardware only.
Also, SPC2ROM loads its own program inside the SPC file in unused space to be executed before the song you want to play. This way you can restore the register values. If you can somehow make that part of the main program loop, you'd be set.
You transfer all control to the SPC. Unless you modify that SPC, there's no way to regain control of it. The SPC may have a special code you can write to $2140-$2143 on the SNES side to make the SPC700 jump to the IPL ROM code at $ffc0, but again: this would vary for every SPC.
caitsith2
New Member
Posts: 8
Joined: Tue Aug 03, 2004 9:27 am

Post by caitsith2 »

Also, SPC2ROM loads its own program inside the SPC file in unused space to be executed before the song you want to play. This way you can restore the register values. If you can somehow make that part of the main program loop, you'd be set.
You transfer all control to the SPC. Unless you modify that SPC, there's no way to regain control of it. The SPC may have a special code you can write to $2140-$2143 on the SNES side to make the SPC700 jump to the IPL ROM code at $ffc0, but again: this would vary for every SPC.
Even then, not all games have commands to soft reset the APU, for another load, which means you have to either modify the spc to handle loading that command, or find a way to manipulate the IO ports, to overwrite a section of code, the section of interest being the part jumped to, when finished loading. If the code was very well written, then that may not be possible, and as a result, the only option left, is to modify the spc, before loading it.

Specifically, the modifying code must check for a specific sequence on the IO ports, and if not found, continue running. If it is found, it is then to write a certain bit, to turn IPL rom back on, write the Key Off register with 0xFF, then jump to the IPL. Failure to write the Key Off register may result in a possible headache, because of the tone that won't stop playing until something else is loaded. Of course, if you forget to write the register, it can still be done from the IPL code, just make the first write go to 0x00F2, and write for the next 2 bytes, the Key Off register, then 0xFF, then start a new transfer.
Post Reply