diff --git a/src/burn/drv/cave/d_donpachi.cpp b/src/burn/drv/cave/d_donpachi.cpp index ecfa06104..18f8cfaa1 100644 --- a/src/burn/drv/cave/d_donpachi.cpp +++ b/src/burn/drv/cave/d_donpachi.cpp @@ -853,20 +853,20 @@ STD_ROM_FN(donpachihk) static struct BurnSampleInfo DonpachiSampleDesc[] = { #ifdef USE_SAMPLE_HACK #if !defined ROM_VERIFY - { "02 - Sortie Instruction.wav", SAMPLE_AUTOLOOP }, - { "03 - Silent Outpost Base.wav", SAMPLE_AUTOLOOP }, - { "04 - Gale Force.wav", SAMPLE_AUTOLOOP }, - { "05 - God of Destruction.wav", SAMPLE_AUTOLOOP }, - { "06 - Advance Through the Sky.wav", SAMPLE_AUTOLOOP }, - { "07 - The Battle Intensifies.wav", SAMPLE_AUTOLOOP }, - { "08 - An Equal Match.wav", SAMPLE_AUTOLOOP }, - { "09 - It's All Up To Me!!.wav", SAMPLE_NOLOOP }, - { "10 - Chief's Congratulations.wav", SAMPLE_NOLOOP }, - { "11 - Breakthrough.wav", SAMPLE_NOLOOP }, - { "12 - Pressure.wav", SAMPLE_AUTOLOOP }, - { "13 - My Duty is Done.wav", SAMPLE_AUTOLOOP }, - { "14 - Eternal Soldier.wav", SAMPLE_AUTOLOOP }, - { "15 - Chase in the Dark.wav", SAMPLE_AUTOLOOP }, + { "02 - Sortie Instruction.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "03 - Silent Outpost Base.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "04 - Gale Force.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "05 - God of Destruction.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "06 - Advance Through the Sky.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "07 - The Battle Intensifies.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "08 - An Equal Match.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "09 - It's All Up To Me!!.wav", SAMPLE_NOLOOP | SAMPLE_NOSTORE }, + { "10 - Chief's Congratulations.wav", SAMPLE_NOLOOP | SAMPLE_NOSTORE }, + { "11 - Breakthrough.wav", SAMPLE_NOLOOP | SAMPLE_NOSTORE }, + { "12 - Pressure.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "13 - My Duty is Done.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "14 - Eternal Soldier.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, + { "15 - Chase in the Dark.wav", SAMPLE_AUTOLOOP | SAMPLE_NOSTORE }, #endif #endif { "", 0 } diff --git a/src/burn/snd/samples.cpp b/src/burn/snd/samples.cpp index 6d6e24101..4c61bf847 100644 --- a/src/burn/snd/samples.cpp +++ b/src/burn/snd/samples.cpp @@ -66,7 +66,11 @@ static void make_raw(UINT8 *src, UINT32 len) sample_ptr->data = (UINT8*)malloc(converted_len * 4); - // up/down sample everything and convert to raw 16 bit stereo +// if (sample_rate == nBurnSoundRate) // copy! +// { +// memcpy (sample_ptr->data, ptr, converted_len * 4); +// } +// else // up/down sample everything and convert to raw 16 bit stereo { INT16 *data = (INT16*)sample_ptr->data; INT16 *poin = (INT16*)ptr; @@ -108,6 +112,8 @@ static void make_raw(UINT8 *src, UINT32 len) sample_ptr->position = 0; } +void BurnSampleInitOne(INT32); // below... + void BurnSamplePlay(INT32 sample) { #if defined FBA_DEBUG @@ -120,6 +126,12 @@ void BurnSamplePlay(INT32 sample) if (sample_ptr->flags & SAMPLE_IGNORE) return; + if (sample_ptr->flags & SAMPLE_NOSTORE) { + BurnSampleInitOne(sample); + } + + bprintf (0, _T("play5\n")); + sample_ptr->playing = 1; sample_ptr->position = 0; } @@ -154,8 +166,13 @@ void BurnSampleStop(INT32 sample) if (!DebugSnd_SamplesInitted) bprintf(PRINT_ERROR, _T("BurnSampleStop called without init\n")); #endif + bprintf (0, _T("stop1\n")); + if (sample >= nTotalSamples) return; + bprintf (0, _T("stop2\n")); + + sample_ptr = &samples[sample]; sample_ptr->playing = 0; sample_ptr->position = 0; @@ -220,11 +237,6 @@ void BurnSampleReset() for (INT32 i = 0; i < nTotalSamples; i++) { BurnSampleStop(i); - - if (sample_ptr->flags & SAMPLE_AUTOLOOP) { - BurnSampleSetLoop(i, true); - BurnSamplePlay(i); - } } } @@ -300,6 +312,13 @@ void BurnSampleInit(INT32 bAdd /*add sample to stream?*/) if (si.nFlags == 0) break; + if (si.nFlags & SAMPLE_NOSTORE) { + sample_ptr->flags = si.nFlags; + sample_ptr->data = NULL; + bprintf (0, _T("NOSTORE %d.\n"),i); + continue; + } + sprintf (path, "%s%s", szTempPath, setname); destination = NULL; @@ -307,9 +326,8 @@ void BurnSampleInit(INT32 bAdd /*add sample to stream?*/) ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { - make_raw((UINT8*)destination, length); - sample_ptr->flags = si.nFlags; + make_raw((UINT8*)destination, length); } else { sample_ptr->flags = SAMPLE_IGNORE; } @@ -329,6 +347,67 @@ void BurnSampleInit(INT32 bAdd /*add sample to stream?*/) } } +void BurnSampleInitOne(INT32 sample) +{ + if (sample >= nTotalSamples) { + return; + } + + { + struct sample_format *clr_ptr = &samples[0]; + + int i = 0; + while (i < nTotalSamples) { + + if (clr_ptr->data != NULL && clr_ptr->playing == 0 && i != sample && (clr_ptr->flags & SAMPLE_NOSTORE)) { + free(clr_ptr->data); + clr_ptr->data = NULL; + } + + clr_ptr++, i++; + } + } + + if ((sample_ptr->flags & SAMPLE_NOSTORE) == 0) { + return; + } + + INT32 length; + char path[256]; + char setname[128]; + void *destination = NULL; + char szTempPath[MAX_PATH]; + sprintf(szTempPath, _TtoA(SAMPLE_DIRECTORY)); + + strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); + sprintf(path, "%s%s.zip", szTempPath, setname); + + struct BurnSampleInfo si; + BurnDrvGetSampleInfo(&si, sample); + char *szSampleName = NULL; + BurnDrvGetSampleName(&szSampleName, sample, 0); + sample_ptr = &samples[sample]; + + if (sample_ptr->playing || sample_ptr->data != NULL || sample_ptr->flags == SAMPLE_IGNORE) { + return; + } + + sprintf (path, "%s%s", szTempPath, setname); + + destination = NULL; + length = 0; + ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); + + if (length) { + make_raw((UINT8*)destination, length); + } + + if (destination) { + free (destination); + destination = NULL; + } +} + void BurnSampleSetRoute(INT32 sample, INT32 nIndex, double nVolume, INT32 nRouteDir) { #if defined FBA_DEBUG diff --git a/src/burn/snd/samples.h b/src/burn/snd/samples.h index e3e75fa73..abce5050d 100644 --- a/src/burn/snd/samples.h +++ b/src/burn/snd/samples.h @@ -1,6 +1,10 @@ -#define SAMPLE_IGNORE 0x01 // don't ever play this sample -#define SAMPLE_AUTOLOOP 0x02 // start the looping on start -#define SAMPLE_NOLOOP 0x04 // don't allow this to loop +#define SAMPLE_IGNORE (1<<0) // don't ever play this sample +#define SAMPLE_AUTOLOOP (1<<1) // start the looping on start +#define SAMPLE_NOLOOP (1<<2) // don't allow this to loop + +// Change this to 0 to 1 if using samples in a low-ram environment. +// May cause momentary stutter while sample loads. +#define SAMPLE_NOSTORE (0<<3) // only keep in memory while playing void BurnSamplePlay(INT32 sample); void BurnSamplePause(INT32 sample);