clueless wrote:
How do games like Zelda, Metroid, Final Fantasy and Crystalis play "background" music while your character wanders around?
For you, the player, it may seem like it's all happening at the same time, but the program actually alternates between updating the game's state (read input, move characters, etc) and updating the music channels. The NES keeps outputting even when you are not doing anything related to sound, based on the last settings written to the sound registers.
As Bregalad said, sound updates are usually performed once per frame, since there are 60 frames per second (NTSC) the sound channels are updated that many times. Between sound updates (when all other updates are performed), the NES just keeps outputting sound based on the last parameters you sent it.
Also, a sound effect isn't initialized at the exact moment the event that generated it happened (e.g. a monster starts blowing up). At that moment, the code will probably tell the music engine which sound effect must be played, but that won't happen until the music engine is executed again. A speed as high as 60 frames per second results in very short intervals between updates, short enough for us humans not to notice these small delays, and think it's all happening at once.
Quote:
Is DMC typically used for one-off sounds, like getting hit by an enemy, or discharging an energy bolt from your sword?
That is up to the programmer. Some will reserve channels exclusively for sound effects, but that might make the music sound too poor with just standard NES audio (no mappers). Because of that, sound effects usually steal some sound channels temporally from the music, and gives them back when they end. Pay attention and you will notice that in many games some instruments of the music simply stop when there are sound effects. We usually don't notice that because the sound effect seems more important, as it is related to something that's happening on the screen, while the music is just background.
Quote:
Or is it better to avoid DMC entirely?
Well, there are some problems with it, such as the corrupted controller reads discovered recently. It also seems to affect the timing of other operations, such as sprite DMA. I don't remember many games that used it during the main game. It's mostly used for drums, but so is the noise channel.
Quote:
How much CPU time is typically required to keep a back-ground music track running (ie, keep the "buffer" if you will, saturated)?
Like blargg said, there is no buffer. It will keep generating sound based on the last parameters written to it. Music only exists because the sound engines change those parameters in a timely fashion.
How much CPU time a sound engine uses varies a lot from one to another. It's the same as asking "how much time does the logic of a platformer take?", that's too vague. It greatly depends on how many features there are and how well optimized the code is.