#55538 - TheMikaus - Thu Sep 29, 2005 4:18 am
This is the file I have set up (I'm using a recent copy of devKitArm and libgba)
When you call playSound with a pointer to the wave file (generated by wav2gba) no sound comes out at all. natta.
Any ideas? or links? I just need to fix this block of code to play the sound. I didn't want to use AAS or krawall or anything like that.
Thanks in advance.
When you call playSound with a pointer to the wave file (generated by wav2gba) no sound comes out at all. natta.
Any ideas? or links? I just need to fix this block of code to play the sound. I didn't want to use AAS or krawall or anything like that.
Thanks in advance.
Code: |
#include "sound.h"
#include "gba_interrupt.h" //Sound registers //Values #define Sound_Enabled 0x00000080 #define Sound_Output_Ratio_25 0x0000 #define Sound_Output_Ratio_50 0x0001 #define Sound_Output_Ration_100 0x002 #define DirectSoundA_Output_Ratio_50 0x0000 #define DirectSoundA_Output_Ratio_100 0x0004 #define DirectSoundA_Output_To_Right 0x0100 #define DirectSoundA_Output_To_Left 0x0200 #define DirectSoundA_Output_To_Both 0x0300 #define DirectSoundA_Timer0 0x0000 #define DirectSoundA_Timer1 0x0400 #define DirectSoundA_FIFO_Reset 0x0800 #define DirectSoundB_Output_Ratio_50 0x0000 #define DirectSoundB_Output_Ratio_100 0x0008 #define DirectSoundB_Output_To_Right 0x1000 #define DirectSoundB_Output_To_Left 0x200 #define DirectSoundB_Output_To_Both 0x3000 #define DirectSoundB_Timer0 0x0000 #define DirectSoundB_Timer1 0x4000 #define DirectSoundB_FIFO_Reset 0x8000 #define Register_Timer0D *(volatile unsigned short *)0x4000100 #define Register_Timer0Cnt *(volatile unsigned short *)0x4000102 #define Register_DMA1Source *(volatile unsigned int *)0x40000BC #define Register_DMA1Destination *(volatile unsigned int *)0x40000C0 #define Register_DMA1Cnt_H (*(volatile unsigned short *)0x40000C6) #define Timer_Enable 0x80 #define DMA_Dest_Fixed 64 #define DMA_Repeat 512 #define DMA_32 1024 #define DMA_Enable 32768 #define DMA_Timing_Sync_To_Display 4096 | 8192 #define Register_SGCNT0_H *(volatile unsigned short *)0x4000082 #define Register_SGCNT1 *(volatile unsigned short *)0x400084 #define DSound_A_Right_Channel 256 #define DSound_A_Left_Channel 512 #define DSound_A_FIFO_Reset 2048 #define Sound_Master_Enable 128 unsigned short sound_length; void VblankInterrupt() { sound_length--; if(sound_length == 0) { //Turn off DMA and Timer Register_Timer0Cnt = 0; Register_DMA1Cnt_H = 0; } } void InitSound() { InitInterrupt(); SetInterrupt(Int_Vblank, VblankInterrupt); EnableInterrupt(Int_Vblank); //Set up the sound registers too Register_SGCNT0_H = DSound_A_Right_Channel | DSound_A_Left_Channel | DSound_A_FIFO_Reset; Register_SGCNT1 = Sound_Master_Enable; REG_IME = 1; } void playSound(unsigned long * source, unsigned long size) { unsigned short samples = (16777216 / 8000); Register_DMA1Source = (unsigned int)source; Register_DMA1Destination = (unsigned int)0x40000a0; Register_DMA1Cnt_H = DMA_Dest_Fixed | DMA_Repeat | DMA_32 | DMA_Timing_Sync_To_Display | DMA_Enable; Register_Timer0D = 65536 - samples; sound_length = (size / samples) * 15.57; Register_Timer0Cnt = Timer_Enable; } |