Author Topic: SPC playback  (Read 8501 times)

0 Members and 1 Guest are viewing this topic.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #30 on: June 24, 2010, 05:45:18 AM »
You should probably compile all of the source files with the same header. Don't use the header.asm that came with my SPC loading code if it differs from the hdr.asm that SNESSDK uses. Just get rid of it an replace it with the SNESSDK header.

And after you get it to build correctly there's also this:

Remove the first 3 instructions in LoadSPC (stz/sei/sta) and replace them with this code:

Code: [Select]
php
phb
sep   #$20
stz     REG_NMI_TIMEN   
sei                 
stz   spcSongNr
lda   #0
pha
plb


And right before the RTS-instruction at the end of the LoadSPC function, insert these instructions:

Code: [Select]
plb
plp

Offline AndiNo

  • Newbie
  • *
  • Posts: 17
  • NEO newbie
Re: SPC playback
« Reply #31 on: June 24, 2010, 03:56:24 PM »
Yes that's right. I had to change the headers to get it compile. I think mic_'s solution should do it.
Basically you can see if it worked if there is not so much free space left on the ROM banks which you see in the log.

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SPC playback
« Reply #32 on: June 25, 2010, 03:17:26 AM »
ok, I got it compiling, sorry about all the hand holding guys, but how do I get it to return to my code after calling LoadSPC(); I gave up on asm almost instantly so looking through the code has revealed very little to me.

On a similar note though, it was mentioned a little way back about exiting from playing spc music and that each game probably had its own way of doing that. Are there any clues anywhere about stopping an spc created with xmsnes. Also is there a simple way to do sfx at all?

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #33 on: June 25, 2010, 04:01:27 AM »
It should return automatically. It's possible that you need to change the RTS at the end of LoadSPC into an RTL when calling it from C.

For details about XMSNES you should probably ask the author.

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SPC playback
« Reply #34 on: June 25, 2010, 04:11:00 AM »
It's possible that you need to change the RTS at the end of LoadSPC into an RTL when calling it from C.

Didn't help I'm afraid :( still froze.

Offline AndiNo

  • Newbie
  • *
  • Posts: 17
  • NEO newbie
Re: SPC playback
« Reply #35 on: June 25, 2010, 05:18:43 PM »
As I said, that was exactly my problem, too. What about this?
Probably because you don't reserve the registers when entering the function & restoring them back before returning from the function.
Maybe mic_ has already done this in his "patch" he posted here. Other than that I have no idea. In the end I had the same questions as you now. Maybe you'll find a solution :)

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #36 on: June 25, 2010, 05:35:23 PM »
If your program relies on interrupts you should keep in mind that my SPC loader disables interrupts so that they won't trigger while communicating with the SPC. So if you need them you have to re-enable them after you've called LoadSPC.

Other than that I don't know what could've gone wrong. You could step through the program using the BSNES debugger to see where it's stuck.