Author Topic: Need DSP information  (Read 5191 times)

0 Members and 1 Guest are viewing this topic.

Offline dieudunet1977

  • Newbie
  • *
  • Posts: 4
  • NEO newbie
Need DSP information
« on: April 05, 2011, 09:17:10 PM »
Hello,

  I'm working since 4 months on a SNES mario/megaman like game.
  Today, I need information about HDMA And DSP Register to be able to include Sound in it.

  I've already include music from a sample found on this forum, but I'm totally lost about the way to include Sound.

  I suppose the use of HDMA is mandatory to dynamicly upload sound in DSP memory but does someone know where to find a documentation/sample for this kind of function ?

  I use WLA-DX as compiler.

thank you in advance

 ~sm-63.gif~.gif

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: Need DSP information
« Reply #1 on: April 05, 2011, 09:50:50 PM »
Huh?   ~sm-64.gif~.gif

No, you use HDMA to write to the PPU during hblank. So you can change stuff like color addition/subtraction, scrolling, mode7 parameters per scanline, or on specific scanlines.

The DSP is controlled by the S-SMP (i.e. the SPC-700), which is an 8-bit processor that runs its own code (which you'll have to write, unless you use someone else's sound engine).

Here are some documents:
http://ekid.nintendev.com/snes/spctech.htm
http://fdwr.tripod.com/docs/snesmap.txt

And here is some code


Offline dieudunet1977

  • Newbie
  • *
  • Posts: 4
  • NEO newbie
Re: Need DSP information
« Reply #2 on: April 05, 2011, 10:36:55 PM »
Arfff. Huge documentation.

I spend 4 month discovering the Motorola chips and now I need to investigate this one...

Well, just one question before trying to understands all of that:

does the Snes support dynamic upload into the DSP memory ? or all the sound must be load as the ROM start ?

thank you in advance

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: Need DSP information
« Reply #3 on: April 05, 2011, 10:57:06 PM »
I would think the typical way of doing things is to upload the sound driver when the game starts. Then you upload music / sound effect data while loading a level, and during gameplay you send play/pause/stop messages to your sound driver through the communication ports.

The SNES main CPU (i.e. the S-CPU) can't write directly to the S-DSP. It's possible to stream sample data from ROM by having the S-CPU writing samples to the communication ports at closely timed intervals and having some code on the S-SMP side that takes these samples and places them in the sample buffers. Tales of Phantasia does this for its opening theme. It's very time-consuming though, so it's not suitable for in-game use.

Offline dieudunet1977

  • Newbie
  • *
  • Posts: 4
  • NEO newbie
Re: Need DSP information
« Reply #4 on: April 06, 2011, 04:52:56 PM »
OK.

One last things. As far as I know, the DSP Music memory is 65k

I get the donkey Kong music and included it in my game using a sample code found on this forum. And , at the beginning of the game I upload the 2 bank in DSP Memory.

But in this case, I get no memory left for sound...

This means I should fragment the Music and free some sound space ?

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: Need DSP information
« Reply #5 on: April 06, 2011, 05:09:20 PM »
64 kB.

An .spc file is just a dump of the SPC RAM and registers, so it will contain whatever code and data that was in the RAM at that moment. The file probably contains some of the sound effects used by the game as well, but where they're stored exactly depends on the game. You'll have to reverse-engineer the sound driver of the game if you want to be able to use music from it (beyond just playing a single song).

Offline dieudunet

  • Jr. Member
  • **
  • Posts: 51
    • dieudunet
Re: Need DSP information
« Reply #6 on: May 10, 2011, 05:40:50 PM »
Hello _mic,

 I'm still in trouble with this SPC700 chips...

 Following the sample and after some test I have include and understand how to send / Play Music (from snes music) on the SNES.

 Now I can't understand how to store(even if storing should work the same way as music ) /play sound . There seems to be no sample (best way to understand) on the Net and I was wondering if you have one ?

My first goal is to store Music and Sound at the beginning of the SNES Code and to play it when it(s needed.

I don't know if you can help me

Best Regards

Matthieu
C is for N00b
ASM rules

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: Need DSP information
« Reply #7 on: May 10, 2011, 07:11:22 PM »
I'm afraid I don't understand the question.
Do you want to know the sample format (BRR)? If so, you can find an encoder here and information here

Offline dieudunet

  • Jr. Member
  • **
  • Posts: 51
    • dieudunet
Re: Need DSP information
« Reply #8 on: May 10, 2011, 08:02:48 PM »
Thank you this was a part of the answer.

the others question is :
  Do you know where (if) I can find a sample code that implement the Music AND Sound at the same time ???
  Because currently, I can play music, but I have no idea for a way to play sound

thank you in advance
C is for N00b
ASM rules

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: Need DSP information
« Reply #9 on: May 10, 2011, 08:16:05 PM »
You need to do something like this on the sound processor (pseudo-code):

Code: [Select]
command = *COMM_REGx;
switch (command) {
  case PAUSE:
    ...
    break;
  case LOAD_NEW_SONG:
    ...
    break;
  case PLAY_SOUND_EFFECT:
    effect = *COMM_REGy;
    play_sample(samplePointers[effect], freeChannel);
    ...
    break;
}

If you have no free channels (i.e. all 8 channels are used for music playback) you need to make sure that the music engine doesn't use that channel until the sound effect has finished playing (can be implemented using a timer, or by polling ENVX).

Offline dieudunet

  • Jr. Member
  • **
  • Posts: 51
    • dieudunet
Re: Need DSP information
« Reply #10 on: May 10, 2011, 08:47:44 PM »
Ok thanks I will try this after conversion to asembly

You don't have this kind of code in Asm ?
C is for N00b
ASM rules