Monday, September 22, 2008

Sound and multiple processors

I've been quiet on here...partially because I haven't had a lot of time for Anguna the past week, and partially because I've started on sound, which meant I had to do a bit of reading before proceeding.

Turns out, there's all sorts of funky stuff you learn when you get into sound on the DS. For example, the DS has two processors: an ARM7 and and ARM9. The GBA had an ARM7, so the ARM7 is used when playing GBA games on the DS. And the ARM9 is the "main" processor used by the DS for DS games. But the fun part is that you can use both processors from your DS code. But unlike fancy desktop computer programming, it's not as simple as forking or creating a new thread from your code. You actually have to write it as two separate programs. One runs on the ARM9, and one runs on the ARM7. The DS has facilities for them to communicate with each other, so your two processes can talk to each other. The other oddness is that certain hardware features can or can't be accessed from the different processors. The full range of audio hardware can (as far as I can tell, which may be wrong) only be accessed from the ARM7. The video stuff can only be accessed from the ARM9. Weird.

So far, I've been writing everything on the ARM9, because you can do most "normal" simple stuff from it. But now that I'm diving into the audio stuff, I've had to use the ARM7 as well.

The good news is that I've found an audio library (mikmod for ds) that will do a lot of the audio work for me. So although I'm running on both processors now, I don't have to touch and learn a lot of the nitty-gritty of audio programming and inter-processor communication.

So far, my music (which come from .xm files, which are a type of mod file (which is a file format for sequencing music out of audio samples)) is working quite well. Sound effects are a slightly different story. The code for playing them seems to be fine, but I've been running into problems when I compile and link them in: somehow the start and ending points for them got messed up, so when you try to play one effect, you might get another, or you might hear all 10 of them played back to back. So I'll need to figure out what's going on there. Hopefully the wonderful community at the gbadev.org forums can help out.

No comments:

NES Anguna

Well, I had a little bit of time still, while Frankengraphics is finishing up her game Project Blue, to have a little downtime on Halcyon, s...