It is currently Sat Dec 16, 2017 11:57 am

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Tue Sep 15, 2015 7:01 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2429
I've looked up the data format for .spc music files, and the format expects both the contents of RAM and what's in the registers themselves? How is it possible to load both at the same time?

The spc700 needs it's registers to copy memory, while it needs it's memory to load it's registers.


Top
 Profile  
 
PostPosted: Tue Sep 15, 2015 7:09 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6534
Location: Seattle
SPC files are comprehensive dumps for emulators, not bare data to be uploaded to the coprocessor.

You might be able to get away with taking the last 0xFF00 bytes (not including the DSP parameters or registers) and just try uploading that. Maybe.


Top
 Profile  
 
PostPosted: Tue Sep 15, 2015 7:22 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19350
Location: NE Indiana, USA (NTSC)
If you have composed original music for your game and are using a homebrew music engine, the music engine's manual and build process should be able to tell you 1. how much you actually need to upload and 2. how to change songs.

If all you have is a random SPC rip, and you're fine with not being able to change songs until reset, then in the majority of the cases, you should be able to load the DSP and timer registers through the IPL, and then just above the top of stack, add some code:
Code:
  MOV X,#<here
  MOV SP,X
  MOV A,#a_value
  MOV X,#x_value
  MOV Y,#y_value
  MOV $00,#ram_0000
  MOV $01,#ram_0001
  RETI
here:
  .byte psw_value
  .addr pc_value


Top
 Profile  
 
PostPosted: Wed Sep 16, 2015 1:24 am 
Offline

Joined: Thu Feb 07, 2013 1:15 am
Posts: 96
Location: Sweden
Blargg has that covered. The final stages of how the CPU state is transferred is really rather masterful...

I can't find the original source right now, but I've adapted his code to my SNES framework here:
https://github.com/Optiroc/libSFX/blob/master/libSFX/CPU/SMP.s
(with some other relevant snippets in libSFX/CPU_SMP.i and libSFX/SMP/System.s700)


Top
 Profile  
 
PostPosted: Wed Sep 16, 2015 7:36 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Quote:
How is it possible to load both at the same time?

By not loading both at the same time. What I do in my SPC loader is to divide the loading process into two stages:

Stage 1: a routine is copied to the first page of SPC RAM, which will receive data going into the SPC RAM range $00f8..$ffff.

Stage 2: another routine is copied to address XXXX in SPC RAM, which will recieve data going into the SPC RAM range $00..$f1, initialize EDL and FLG, initialize A/X/Y/SP/PSW, and finally jump to the init address.

(My way of finding address XXXX is to search the RAM dump part of the SPC file for free RAM somewhere in the range $0100..$ff9f, where a free chunk is defined as a string of adequate length that contains only the value $00 or $ff (i.e. either 00000000.. or FFFFFFFF..)).


Top
 Profile  
 
PostPosted: Wed Sep 16, 2015 8:08 am 
Offline

Joined: Thu Feb 07, 2013 1:15 am
Posts: 96
Location: Sweden
mic_ wrote:
Quote:
How is it possible to load both at the same time?

By not loading both at the same time. What I do in my SPC loader is to divide the loading process into two stages:

Stage 1: a routine is copied to the first page of SPC RAM, which will receive data going into the SPC RAM range $00f8..$ffff.

Stage 2: another routine is copied to address XXXX in SPC RAM, which will recieve data going into the SPC RAM range $00..$f1, initialize EDL and FLG, initialize A/X/Y/SP/PSW, and finally jump to the init address.

(My way of finding address XXXX is to search the RAM dump part of the SPC file for free RAM somewhere in the range $0100..$ff9f, where a free chunk is defined as a string of adequate length that contains only the value $00 or $ff (i.e. either 00000000.. or FFFFFFFF..)).

That's how I used to do it as well, before finding Blargg's ingenious piece of code which can transfer the complete state dump without any fiddling with (hopefully) unused memory and such.

How is it done? The last pieces of state is transferred by setting up a loop within the 4 I/O registers, and by carefully timing writes to the registers from the S-CPU side the needed instructions (mov a,#value, mov $dest, a and so on) are executed.


Top
 Profile  
 
PostPosted: Wed Sep 16, 2015 8:21 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19350
Location: NE Indiana, USA (NTSC)
What tool are you using to create this .spc file? Or do you plan to play only one song after reset and no sound effects?


Top
 Profile  
 
PostPosted: Wed Sep 16, 2015 11:20 am 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2429
SNESmod and SNES-GSS both output in .spc files.


Top
 Profile  
 
PostPosted: Wed Sep 16, 2015 11:29 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19350
Location: NE Indiana, USA (NTSC)
In that case, there ought to be no paradox. The manuals for SNESmod and SNES-GSS should help you figure out what parts need to be uploaded and what parts don't. If they don't, file bugs against the manuals.


Top
 Profile  
 
PostPosted: Sat Sep 19, 2015 2:11 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2429
https://github.com/DanielOaks/sneskit/b ... nesmod.asm

Found it. Boy it's hard to find the information I need.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group