Author Topic: SPC playback  (Read 8250 times)

0 Members and 1 Guest are viewing this topic.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #15 on: March 22, 2010, 11:53:50 PM »
You could use it with SNESC as long as SNESC can assemble code written for WLA-DX, or link against object files created by WLA-DX (which I assume that it can, since SNESC seems to use wlalink). But you'd have to make sure that it conforms to the 65816 ABI (like how parameters are passed between functions, which registers you need to preserve etc.).

I've no idea about those kinds of things on the 65816 since I've only programmed it in assembly language without any external libraries, so I can write my code whichever way I want to.  >:D


Offline AndiNo

  • Newbie
  • *
  • Posts: 17
  • NEO newbie
Re: SPC playback
« Reply #16 on: March 23, 2010, 05:08:35 AM »
My current setup includes WLA 65816 v9.4 and WLALINK v5.7 (modified by Ulrich Hecht for the SNES SDK). (I'm not using the latest version of the SDK, maybe later versions include newer tools.) So that would work I guess, however I'm completely unsure about the rest. I only know "API", what's an "ABI"?
I'm far from the point of adding sound into my game, however would it be possible to come back to you if there are any questions (assuming you have any infos)?
It might be a bit offtopic, but how does SNES sound differ from its music? With your program loading music seems to be pretty easy but how would you go about loading/playing sounds? If I understand correctly there are programs to convert XM and MOD files to SPC files. Is there a way to do this with MIDI files, too? To me these formats seem very similar...
I hope this weren't too many questions, excuse me if so :)

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: SPC playback
« Reply #17 on: March 25, 2010, 02:58:06 AM »
ABI = Application Binary Interface. It means which registers hold what values (if any) on a function call, what the stack looks like, and what registers (if any) need to be saved/restored by the function.

For example, the ABI for 68000 is registers d2-d7 and a2-a6 must be saved/restored if the function uses them, the return address if first on the stack followed by all parameters from left to right (lower stack address to higher stack address). The return value (if any) is placed into d0. The stack is cleaned up by the caller, not the function called.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #18 on: April 15, 2010, 08:00:24 PM »
Is anyone working on the Neo Ultra Menu (the PC software)? If someone made sure that .SPC files were recognized by the software as a separate file type and stored properly on the GBA card, then I could try integrating SPC playback into the Myth menu.
This requires that one can reset the SNES through the Myth in software, though. Because when the SPC is playing some random song there's no good way of doing any further communication with the SPC, except by resetting the system.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SPC playback
« Reply #19 on: April 16, 2010, 01:30:56 AM »
Siven Yu is one of the main engineers of N2UM , maybe you should PM him.But you should also pm madmonkey since im sure he'll be interested in adding SNES mode in the opensource programmer  ~sm-51.gif~.gif

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SPC playback
« Reply #20 on: April 16, 2010, 02:40:43 AM »
...when the SPC is playing some random song there's no good way of doing any further communication with the SPC, except by resetting the system.
??? So how do games play different tunes at different parts of the game?



Also, do you have any plans to port the spc player to snesc?

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #21 on: April 16, 2010, 02:46:29 AM »
Quote
So how do games play different tunes at different parts of the game?
The person who wrote the sound driver for a specific game surely knows how to communicate with it. But for me to know how to communicate with the sound driver for any given game is a totally different story, since there's no standard method that I know of.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #22 on: April 17, 2010, 05:03:01 AM »
Just as a proof of concept: http://www.youtube.com/watch?v=UH_ddj17EKs

This version of the menu isn't available yet because there are some issues I need to solve for this feature to be usable. And the Neo2 Ultra Menu PC software doesn't recognize SPC files yet, so putting SPC files on the Myth cart isn't straightforward atm.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SPC playback
« Reply #23 on: April 17, 2010, 09:18:01 AM »
Just as a proof of concept: http://www.youtube.com/watch?v=UH_ddj17EKs

This version of the menu isn't available yet because there are some issues I need to solve for this feature to be usable. And the Neo2 Ultra Menu PC software doesn't recognize SPC files yet, so putting SPC files on the Myth cart isn't straightforward atm.

That's really cool   ;D :D

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SPC playback
« Reply #24 on: June 23, 2010, 04:12:33 AM »
So...

Is it possible [easily] to use your spc player in a snesc project?

PS, excellent work on the myth menu btw.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SPC playback
« Reply #25 on: June 23, 2010, 04:28:26 AM »
It would be with some small changes. I think AndiNo has used my SPC uploading code with the C compiler, so he should know exactly what the needed changes were.

Offline AndiNo

  • Newbie
  • *
  • Posts: 17
  • NEO newbie
Re: SPC playback
« Reply #26 on: June 23, 2010, 10:08:55 PM »
Ok, I had to take a good look again to see what I did back then :)
I assume you have the createROM.bat file that I included in my SDK package. You only need to change two lines:
1) Insert this line after the other assembler calls:
Code: [Select]
..\bin\wla-65816.exe -vio spcplay.asm spcplay.obj(I don't remember the meaning of the "v" option)

2) Change this line:
Code: [Select]
..\bin\wlalink.exe -dvSo data.obj snesc.obj input.obj init.obj graph.obj str.obj snesc.smcto this:
Code: [Select]
..\bin\wlalink.exe -vSo data.obj snesc.obj input.obj init.obj graph.obj str.obj spcplay.obj snesc.smcNotice that the "d" option was removed. If you don't do that the linker will treat the music data as unnecessary data and will not include it in your ROM. That's what I remember...

You have to declare the function
Code: [Select]
void LoadSPC();somewhere in your headers. Then you can just use
Code: [Select]
LoadSPC(); in your code to start playing the music.

BUT there is one problem (at least I think I had it the last time I tried this): When I called the "LoadSPC" function from my code my ROM froze. I think I didn't find a way around this.
PS: I'm not sure about this, but I think mic_ sent me some changes that had to be applied to loadspc.asm in order to use it with the C compiler. Tell me if you need this, too.
After all I think you will still have some work to do before you can use it fully with snesc...

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SPC playback
« Reply #27 on: June 23, 2010, 10:44:07 PM »
Quote
BUT there is one problem (at least I think I had it the last time I tried this): When I called the "LoadSPC" function from my code my ROM froze. I think I didn't find a way around this.

Probably because you don't reserve the registers when entering the function & restoring them back before returning from the function.

Offline AndiNo

  • Newbie
  • *
  • Posts: 17
  • NEO newbie
Re: SPC playback
« Reply #28 on: June 24, 2010, 01:55:52 AM »
Coming to think of it - you're probably right :)
But I'm currently doing other stuff again.
@spinal
Please tell us if that fixes the problem (if it comes up).

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SPC playback
« Reply #29 on: June 24, 2010, 02:29:46 AM »
I couldn't get it to compile. I guess I did something wrong, if I knew what I was doing it might help a little :P

here is my output...
Code: [Select]

C:\SNES\Negative_Joe>REM C -> ASM / S

C:\SNES\Negative_Joe>..\bin\816-tcc.exe -Wall -I../include -o snesc.ps -c snesc.c
snesc.c:95: warning: implicit declaration of function 'disablescreen'

C:\SNES\Negative_Joe>..\bin\816-tcc.exe -Wall -I../include -o input.ps -c input.c

C:\SNES\Negative_Joe>..\bin\816-tcc.exe -Wall -I../include -o init.ps -c init.c


C:\SNES\Negative_Joe>..\bin\816-tcc.exe -Wall -I../include -o graph.ps -c graph.c
graph.c:71: warning: assignment makes pointer from integer without a cast

C:\SNES\Negative_Joe>..\bin\816-tcc.exe -Wall -I../include -o str.ps -c str.c

C:\SNES\Negative_Joe>REM Optimize ASM files

C:\SNES\Negative_Joe>..\bin\816-opt.py snesc.ps  1>snesc.s
optimization pass 1: 414 optimizations performed
optimization pass 2: 160 optimizations performed
optimization pass 3: 11 optimizations performed
optimization pass 4: 0 optimizations performed
585 optimizations performed in total

C:\SNES\Negative_Joe>..\bin\816-opt.py input.ps  1>input.s
optimization pass 1: 6 optimizations performed
optimization pass 2: 2 optimizations performed
optimization pass 3: 0 optimizations performed
8 optimizations performed in total

C:\SNES\Negative_Joe>..\bin\816-opt.py init.ps  1>init.s
optimization pass 1: 116 optimizations performed
optimization pass 2: 48 optimizations performed
optimization pass 3: 4 optimizations performed
optimization pass 4: 1 optimizations performed
optimization pass 5: 0 optimizations performed
169 optimizations performed in total

C:\SNES\Negative_Joe>..\bin\816-opt.py graph.ps  1>graph.s
optimization pass 1: 85 optimizations performed
optimization pass 2: 34 optimizations performed
optimization pass 3: 3 optimizations performed
optimization pass 4: 0 optimizations performed
122 optimizations performed in total

C:\SNES\Negative_Joe>..\bin\816-opt.py str.ps  1>str.s
optimization pass 1: 38 optimizations performed
optimization pass 2: 9 optimizations performed
optimization pass 3: 1 optimizations performed
optimization pass 4: 1 optimizations performed
optimization pass 5: 0 optimizations performed
49 optimizations performed in total

C:\SNES\Negative_Joe>REM ASM -> OBJ

C:\SNES\Negative_Joe>..\bin\wla-65816.exe -io data.asm data.obj

C:\SNES\Negative_Joe>..\bin\wla-65816.exe -io snesc.s snesc.obj

C:\SNES\Negative_Joe>..\bin\wla-65816.exe -io input.s input.obj

C:\SNES\Negative_Joe>..\bin\wla-65816.exe -io init.s init.obj

C:\SNES\Negative_Joe>..\bin\wla-65816.exe -io graph.s graph.obj

C:\SNES\Negative_Joe>..\bin\wla-65816.exe -io str.s str.obj

C:\SNES\Negative_Joe>..\bin\wla-65816.exe -vio spcplay.asm spcplay.obj
Pass 1...
Directive checks...
Internal pass 1...
Internal pass 2...
Free space at $0000-$7fb1.
Free space at $7fb6-$7fbf.
Free space at $7fdc-$7fff.
Free space at $8008-$bfff.
Free space at $c080-$1ffff.
Bank 00 has 32736 bytes (99.90%) free.
Bank 01 has 32632 bytes (99.58%) free.
Bank 02 has 32768 bytes (100.0%) free.
Bank 03 has 32768 bytes (100.0%) free.
130904 unused bytes of total 131072.
Total 131072 additional bytes (from headers and footers).
Total size 262144 bytes.

C:\SNES\Negative_Joe>..\bin\wlalink.exe -vSo data.obj snesc.obj input.obj init.o
bj graph.obj str.obj spcplay.obj joe.smc
OBTAIN_ROMBANKS: Using the biggest selected amount of ROM banks (8).
OBTAIN_MEMORYMAP: The object files are compiled for different memory architectures.

C:\SNES\Negative_Joe>REM delete files

C:\SNES\Negative_Joe>del *.ps

C:\SNES\Negative_Joe>del *.s

C:\SNES\Negative_Joe>del *.obj

C:\SNES\Negative_Joe>del *.sym
Could Not Find C:\SNES\Negative_Joe\*.sym

C:\SNES\Negative_Joe>