mirror of
https://github.com/stevenhowes/CTheEscape.git
synced 2026-05-26 15:53:29 +01:00
Free memory from PCM samples between missions.
This commit is contained in:
Binary file not shown.
@@ -52,8 +52,12 @@ o.Graphics: c.Graphics
|
||||
o.Graphics: C:h.swis
|
||||
o.Graphics: C:h.kernel
|
||||
o.Graphics: C:h.kernel
|
||||
o.Intro: c.Intro
|
||||
o.Intro: h.Graphics
|
||||
o.CTheEscape: c.CTheEscape
|
||||
o.CTheEscape: C:h.swis
|
||||
o.CTheEscape: C:h.kernel
|
||||
o.CTheEscape: C:h.kernel
|
||||
o.CTheEscape: h.Sound
|
||||
o.CTheEscape: h.Graphics
|
||||
o.CTheEscape: c.CTheEscape
|
||||
o.CTheEscape: C:h.swis
|
||||
o.CTheEscape: C:h.kernel
|
||||
@@ -65,6 +69,8 @@ o.Sound: C:h.swis
|
||||
o.Sound: C:h.kernel
|
||||
o.Sound: C:h.kernel
|
||||
o.Sound: h.Sound
|
||||
o.Intro: c.Intro
|
||||
o.Intro: h.Graphics
|
||||
o.Mission1: c.Mission1
|
||||
o.Mission1: h.Graphics
|
||||
o.Mission1: h.Sound
|
||||
|
||||
@@ -57,6 +57,12 @@ o.MapEdit: C:h.kernel
|
||||
o.MapEdit: C:h.kernel
|
||||
o.MapEdit: h.Sound
|
||||
o.MapEdit: h.Graphics
|
||||
o.MapEdit: c.MapEdit
|
||||
o.MapEdit: C:h.swis
|
||||
o.MapEdit: C:h.kernel
|
||||
o.MapEdit: C:h.kernel
|
||||
o.MapEdit: h.Sound
|
||||
o.MapEdit: h.Graphics
|
||||
o.Graphics: c.Graphics
|
||||
o.Graphics: C:h.swis
|
||||
o.Graphics: C:h.kernel
|
||||
|
||||
@@ -72,6 +72,8 @@ int main(int argc, char *argv[])
|
||||
sound_set_voice(7,"DataVox-Voice");
|
||||
sound_set_voice(8,"DataVox-Voice");
|
||||
|
||||
sound_pcm_nullsamples();
|
||||
|
||||
// Set initial display mode
|
||||
display_mode(DISPLAY_MODE);
|
||||
screen_clear();
|
||||
@@ -92,6 +94,9 @@ int main(int argc, char *argv[])
|
||||
screen_clear();
|
||||
|
||||
#ifndef SKIP_MISSION1
|
||||
// Unload any audio samples we dont need
|
||||
sound_pcm_clearsamples();
|
||||
|
||||
// Mission 1
|
||||
while(lastoutcome == 1)
|
||||
{
|
||||
@@ -109,6 +114,9 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
#ifndef SKIP_MISSION2
|
||||
// Unload any audio samples we dont need
|
||||
sound_pcm_clearsamples();
|
||||
|
||||
lastoutcome = 1;
|
||||
|
||||
load_sprites("Tiles",&tilebuffer);
|
||||
|
||||
@@ -198,6 +198,30 @@ int sound_composition_incomplete()
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sound_pcm_nullsamples()
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<PCMSAMPLE_MAX; i++)
|
||||
{
|
||||
pcmsamples[i].data = NULL;
|
||||
pcmsamples[i].length = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void sound_pcm_clearsamples()
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < PCMSAMPLE_MAX; i++)
|
||||
{
|
||||
if(pcmsamples[i].data)
|
||||
{
|
||||
free(pcmsamples[i].data);
|
||||
pcmsamples[i].data = NULL;
|
||||
pcmsamples[i].length = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sound_pcm_unset(enum pcmchannel_e channel)
|
||||
{
|
||||
inreg.r[0] = channel;
|
||||
@@ -207,6 +231,13 @@ void sound_pcm_unset(enum pcmchannel_e channel)
|
||||
|
||||
void sound_pcm_playsample(enum pcmchannel_e channel, enum pcmsample_e sample)
|
||||
{
|
||||
if(!pcmsamples[sample].data)
|
||||
{
|
||||
screen_nobuffer();
|
||||
while(1)
|
||||
printf("PCM sample %d played without load\n",sample);
|
||||
}
|
||||
|
||||
inreg.r[0] = channel;
|
||||
inreg.r[1] = pcmsamples[sample].data;
|
||||
inreg.r[2] = pcmsamples[sample].data + pcmsamples[sample].length;
|
||||
@@ -237,6 +268,13 @@ void sound_pcm_playsample(enum pcmchannel_e channel, enum pcmsample_e sample)
|
||||
|
||||
void sound_pcm_playsample_ifidle(enum pcmchannel_e channel, enum pcmsample_e sample)
|
||||
{
|
||||
if(!pcmsamples[sample].data)
|
||||
{
|
||||
screen_nobuffer();
|
||||
while(1)
|
||||
printf("PCM sample %d played without load\n",sample);
|
||||
}
|
||||
|
||||
inreg.r[0] = channel;
|
||||
_kernel_swi (DataVox_ReadAddress, &inreg, &outreg);
|
||||
if(!outreg.r[1])
|
||||
@@ -247,6 +285,9 @@ void sound_pcm_loadsample(enum pcmsample_e sample, char* filename)
|
||||
{
|
||||
int length;
|
||||
|
||||
if(pcmsamples[sample].data)
|
||||
return;
|
||||
|
||||
// Attempt to get file info
|
||||
inreg.r[0] = 5;
|
||||
inreg.r[1] = (int) filename;
|
||||
|
||||
Reference in New Issue
Block a user