#4294 - rome - Wed Mar 26, 2003 6:52 pm
my GBA dma routine loop sound works perfectly in Virtual Game Boy emulator (sounds play in loop), but when i pass the rom to flash cartridge and play it on real GBA hardware, the sound runs and dont return the Cursor to play the same sound (loop the sound). can anyone help me?
Code: |
void InterruptProcess(void) { // timer 1 irq will be triggered when sound reaches the end if(REG_IF & INT_TIMER1) { // reset the sound source DMA transfer REG_DM1SAD = (unsigned long)p_data; } REG_IF |= REG_IF; } int main (void) { REG_INTERUPT = (u32)&InterruptProcess; // len keep the file size in bytes len = GetFileSize(0); // p_data keep the pointer to data p_data = (char *)GetFileData(0); //play a mono sound at 16khz //uses timer 0 as sampling rate source //uses timer 1 to count the samples played in order to stop the sound REG_SGCNT0_H=0x0b0F; //enable DS A&B + fifo reset + use timer0 + max volume to L and R REG_SGCNT1=0x0080; //turn sound chip on REG_DM1SAD=(unsigned long)p_data; //dma1 source REG_DM1DAD=0x040000a0; //write to FIFO A address REG_DM1CNT_H=0xB640; //DMA enabled + starton fifo req + 32 bit + repeat + increment source, leave dest (FIFO dest) REG_TM1D=0xFFFF - len; //0xffff-the number of samples to play REG_TM1CNT=0xC4; // init timer cascade and generate irq REG_IE=0x10; //enable irq for timer 1 REG_IME=1; //master enable interrupts REG_TM0D=0xFBE8; //16khz playback freq REG_TM0CNT=0x0080; //enable timer0 at 16 khz while (1) { } } |