blob: 260c7a5e65299b73a22da460cc58fa702a3b0178 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/* *************************************
* Includes
* *************************************/
#include "Sfx.h"
/* *************************************
* Defines
* *************************************/
#define MAX_VOLUME SPU_MAXVOL
#define SILENT 0
#define NUMBER_OF_VOICES 24
/* *************************************
* Local Prototypes
* *************************************/
/* *************************************
* Local Variables
* *************************************/
static uint8_t voiceIndex = 0;
void SfxPlaySound(SsVag * sound)
{
SsPlayVag(sound, sound->cur_voice, MAX_VOLUME, MAX_VOLUME);
}
bool SfxUploadSound(char * file_path, SsVag * vag)
{
if(SystemLoadFile(file_path) == false)
{
return false;
}
if(voiceIndex < NUMBER_OF_VOICES)
{
SsReadVag(vag,SystemGetBufferAddress());
SsUploadVag(vag);
vag->cur_voice = voiceIndex;
voiceIndex++;
}
else
{
dprintf("Maximum number of SPU voices exceeded!\n");
return false; //Maximum voices exceeded
}
return true;
}
void SfxPlayTrack(MUSIC_TRACKS track)
{
#ifndef NO_CDDA
SsCdVol(0x7FFF,0x7FFF);
SsEnableCd();
CdPlayTrack(track);
dprintf("Track number %d playing...\n",track);
#endif // NO_CDDA
}
void SfxStopMusic(void)
{
#ifndef NO_CDDA
uint64_t timer = SystemGetGlobalTimer();
uint16_t CDVol = 0x7FFF;
uint8_t time_step = 5;
while (CDVol > 0x3F)
{
CDVol>>=1;
SsCdVol(CDVol,CDVol);
while(SystemGetGlobalTimer() < (timer + time_step) );
timer = SystemGetGlobalTimer();
}
CdSendCommand(CdlMute,0);
#endif
}
|