gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > Problems with audio and emulators

#23823 - cappeca - Thu Jul 22, 2004 11:10 am

I'm learning how to put audio samples in a GBA game. So far I've tried the documents in the gbadev.org site, and it... kinda worked. The code is the usual:

Code:

      /* Inicializa o som */
      REG_SOUNDCNT_X = SND_ENABLED;
      REG_SOUNDCNT_L = 0;

      /* enable and reset Direct Sound channel A, at full volume,
       using Timer 0 to determine frequency */
      REG_SOUNDCNT_H = SND_OUTPUT_RATIO_100 |
                       DSA_OUTPUT_RATIO_100 |
                       DSA_OUTPUT_TO_BOTH   |
                       DSA_TIMER0           |
                       DSA_FIFO_RESET;

      /* set the timer to overflow at the appropriate frequency and start it */
      REG_TM0Dv   = TIMER_INTERVAL;
      REG_TM0CNTv = TIMER_ENABLED;

      /* start the DMA transfer (assume that pSample is a (signed char*)
        pointer to the buffer containing our sound data) */
      REG_DMA1SAD = (u32)CLIQUE_DATA;
      REG_DMA1DAD = (u32)REG_FIFO_A;
      REG_DMA1CNT = ENABLE_DMA | START_ON_FIFO_EMPTY | WORD_DMA | DMA_REPEAT;


It works perfectly in Boycott Advance (0.2.6), distorted in Mappy (0.9), and not at all in Visual Boy Advance (1.7.1) or in the real hardware. Do you guys know about anything these emulators automatically do that I'm probably missing for the GBA?

Thanks.

#23825 - cappeca - Thu Jul 22, 2004 11:54 am

Never mind, I found an old post where I had answered this myself. Some registers must be declared volatile to work.

Cesar.