home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
348.lha
/
chatterbox_v1.0
/
sources
/
deferredload.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-02-14
|
2KB
|
79 lines
int sample_was_in_cache;
struct deferred_load_info deferred_stuff;
Sample *Load8SVX();
DeferredStuffCleanup()
{
int i;
for (i = 0; i < MAX_GAB_ITEMS; i++)
{
if (deferred_stuff.filename[i])
{
FreeMem(deferred_stuff.filename[i],strlen(deferred_stuff.filename[i]) + 1);
deferred_stuff.filename[i] = NULL;
}
}
deferred_stuff.n_deferred_items = 0;
}
InitDeferredStuff()
{
int i;
for (i = 0; i < MAX_GAB_ITEMS; i++)
{
deferred_stuff.filename[i] = NULL;
}
add_cleanup(DeferredStuffCleanup);
}
AddDeferredSound(s)
char *s;
{
char *t;
if (deferred_stuff.n_deferred_items >= MAX_GAB_ITEMS)
{
printf("too many deferred timer sounds, '%s' ignored\n",s);
return;
}
/* note: normally you would need to allocmem strlen(s)+1 to leave
* room for the terminating NULL character, but in this case we
* have a blank in column one that we don't want, so that accounts
* for the extra char needed to be allocated */
if ((t = AllocMem(strlen(s),0)) == NULL)
panic("couldn't alloc mem for deferred sound");
strcpy(t,&s[1]);
deferred_stuff.filename[deferred_stuff.n_deferred_items++] = t;
}
PlayDeferredSound()
{
Sample *sampleptr;
int one_i_want;
one_i_want = rando(deferred_stuff.n_deferred_items);
sampleptr = Load8SVX(deferred_stuff.filename[one_i_want]);
if (sampleptr == NULL)
return;
/* if the sample wasn't in the RAM cache, we wan't to purge it
* when finished (code that receives the play_complete message
* checks this bit) */
if (!sample_was_in_cache)
sampleptr->sample_flags |= PURGE_SAMPLE_AFTER_PLAYING;
PlayChannelSample(sampleptr,64,rando(2));
}