00001 #ifndef _PA_Sound9
00002 #define _PA_Sound9
00003
00004
00005
00013 #include "../Sound9.h"
00014 #include "PA_GBFS.h"
00015 #include "PA_FS.h"
00016 #include <PA9.h>
00017
00018
00019
00020 #define SND_MEM_POOL_SIZE 256*1024
00021
00022
00023
00024 extern TransferSound snd;
00025 extern u32 *sndMemPool;
00026
00027 typedef struct{
00028 u8 volume;
00029 s32 freq;
00030 s16 format;
00031 } PA_SoundOptions;
00032
00033 extern PA_SoundOptions PA_SoundOption;
00034
00035 extern u32 *FS_mod;
00036 extern u32 *FS_wav[16];
00037
00038
00039
00040
00041
00042
00043
00044
00065 void PA_SetDefaultSound(u8 volume, s32 freq, s16 format);
00066
00067
00073 extern inline void PA_InitSound(void) {
00074 SndInit9 ();
00075 sndMemPool = (u32*)0x2200000;
00076 SndSetMemPool(sndMemPool, SND_MEM_POOL_SIZE);
00077 PA_SetDefaultSound(127, 11025, 0);
00078 FS_mod = NULL;
00079 u8 i;
00080 for (i = 0; i < 16; i++) FS_wav[i] = NULL;
00081 }
00082
00083
00084
00108 void PA_PlaySoundEx(u8 PA_Channel, const void* data, s32 length, u8 volume, s32 freq, s16 format);
00109
00130 extern inline void PA_PlayGBFSSoundEx(u8 PA_Channel, u16 FS_wav_number, u8 volume, s32 freq, s16 format){
00131 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1;
00132 free(FS_wav[PA_Channel]);
00133 FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00134
00135 DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00136
00137 PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00138 }
00139
00140
00141
00162 extern inline void PA_PlayFSSoundEx(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, s32 freq, s16 format){
00163 PA_Malloc((void**)&FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length+4);
00164
00165 s32 i;
00166 s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1;
00167 for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00168
00169 PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00170 }
00171
00172
00193 extern inline void PA_PlaySound(u8 PA_Channel, const void* data, s32 length, u8 volume, s32 freq){
00194 PA_PlaySoundEx(PA_Channel, data, length, volume, freq, 0);
00195 }
00196
00214 extern inline void PA_PlayGBFSSound(u8 PA_Channel, u16 FS_wav_number, u8 volume, s32 freq){
00215 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1;
00216 free(FS_wav[PA_Channel]);
00217 FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00218
00219 DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00220
00221 PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00222 }
00223
00224
00225
00243 extern inline void PA_PlayFSSound(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, s32 freq){
00244 PA_Malloc((void**)(&FS_wav[PA_Channel]), PA_FSFile[PAFS_wav_number].Length+4);
00245
00246 s32 i;
00247 s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1;
00248 for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00249
00250 PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00251 }
00252
00253
00254
00267 #define PA_PlaySimpleSound(PA_Channel, sound) PA_PlaySoundEx(PA_Channel, (void*)sound, (u32)sound##_size, PA_SoundOption.volume, PA_SoundOption.freq, PA_SoundOption.format)
00268
00269
00281 extern inline void PA_PlayGBFSSimpleSound(u8 PA_Channel, u16 FS_wav_number){
00282 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1;
00283 free(FS_wav[PA_Channel]);
00284 FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00285
00286 DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00287
00288 PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, PA_SoundOption.volume, PA_SoundOption.freq);
00289 }
00290
00291
00292
00293
00305 extern inline void PA_PlayFSSimpleSound(u8 PA_Channel, u16 PAFS_wav_number){
00306 PA_Malloc((void**)(&FS_wav[PA_Channel]), PA_FSFile[PAFS_wav_number].Length+4);
00307
00308 s32 i;
00309 s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1;
00310 for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00311
00312 PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length, PA_SoundOption.volume, PA_SoundOption.freq);
00313 }
00314
00315
00316
00317
00318
00319
00328 #define PA_PlayMod(mod_snd) SndPlayMOD((u8*)mod_snd)
00329
00330
00339 extern inline void PA_PlayGBFSMod(u16 FS_mod_number){
00340 s32 length = (PA_GBFSfile[FS_mod_number].Length >> 2) + 1;
00341 free(FS_mod);
00342 FS_mod = (u32*)malloc(length << 2);
00343
00344 DMA_Copy(PA_GBFSfile[FS_mod_number].File, FS_mod, length, DMA_32NOW);
00345
00346 PA_PlayMod(FS_mod);
00347 }
00348
00349
00358 extern inline void PA_PlayFSMod(u16 PAFS_mod_number){
00359 PA_Malloc((void**)((u32)(&FS_mod)), PA_FSFile[PAFS_mod_number].Length+4);
00360
00361 s32 i;
00362 s32 length = (PA_FSFile[PAFS_mod_number].Length>>2) + 1;
00363 for (i = 0; i < length; i++) FS_mod[i] = ((u32*)PA_PAFSFile(PAFS_mod_number))[i];
00364
00365 PA_PlayMod(FS_mod);
00366 }
00367
00368
00369
00370
00371
00372
00373
00379 #define PA_StopMod() SndStopMOD()
00380
00381
00390 #define PA_PauseMod(bool) SndPauseMOD(bool)
00391
00392
00394
00395
00396
00397 #endif
00398
00399