Made SFX loading more similar to the original
This commit is contained in:
parent
c284afdadd
commit
113c3fc124
3 changed files with 38 additions and 32 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "CommonDefines.h"
|
#include "CommonDefines.h"
|
||||||
#include "Draw.h"
|
#include "Draw.h"
|
||||||
|
#include "Sound.h"
|
||||||
|
#include "PixTone.h"
|
||||||
|
|
||||||
bool LoadGenericData()
|
bool LoadGenericData()
|
||||||
{
|
{
|
||||||
|
@ -51,6 +53,34 @@ bool LoadGenericData()
|
||||||
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_1);
|
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_1);
|
||||||
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_2);
|
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_2);
|
||||||
MakeSurface_Generic(WINDOW_WIDTH, 240, SURFACE_ID_CREDIT_CAST);
|
MakeSurface_Generic(WINDOW_WIDTH, 240, SURFACE_ID_CREDIT_CAST);
|
||||||
|
|
||||||
|
char path[0x100];
|
||||||
|
uint8_t *buf = nullptr;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
for (unsigned int n = 0; n < SOUND_NO; n++)
|
||||||
|
{
|
||||||
|
sprintf(path, "%2.2X.pxt", n);
|
||||||
|
|
||||||
|
if (LoadPxt(path, &buf, &len))
|
||||||
|
{
|
||||||
|
lpSECONDARYBUFFER[n] = new SOUNDBUFFER(len);
|
||||||
|
|
||||||
|
uint8_t *sBuf;
|
||||||
|
size_t sLen;
|
||||||
|
lpSECONDARYBUFFER[n]->Lock(&sBuf, &sLen);
|
||||||
|
memcpy(sBuf, buf, sLen);
|
||||||
|
lpSECONDARYBUFFER[n]->Unlock();
|
||||||
|
lpSECONDARYBUFFER[n]->SetFrequency(22050);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Free buffer, we're done with it
|
||||||
|
if (buf)
|
||||||
|
{
|
||||||
|
free(buf);
|
||||||
|
buf = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "PixTone.h"
|
#include "PixTone.h"
|
||||||
|
|
||||||
int8_t gWaveModelTable[6][0x100];
|
int8_t gWaveModelTable[6][0x100];
|
||||||
|
bool wave_tables_made;
|
||||||
|
|
||||||
void MakeWaveTables()
|
void MakeWaveTables()
|
||||||
{
|
{
|
||||||
|
@ -72,6 +73,13 @@ double fgetv(FILE *fp) // Load a numeric value from text file; one per line.
|
||||||
|
|
||||||
bool MakePixelWaveData(const std::vector<double>& pxtData, uint8_t *data)
|
bool MakePixelWaveData(const std::vector<double>& pxtData, uint8_t *data)
|
||||||
{
|
{
|
||||||
|
//Make wave tables if not created already
|
||||||
|
if (!wave_tables_made)
|
||||||
|
{
|
||||||
|
MakeWaveTables();
|
||||||
|
wave_tables_made = true;
|
||||||
|
}
|
||||||
|
|
||||||
//Get some envelope stuff
|
//Get some envelope stuff
|
||||||
char envelopeTable[0x100];
|
char envelopeTable[0x100];
|
||||||
memset(envelopeTable, 0, sizeof(envelopeTable));
|
memset(envelopeTable, 0, sizeof(envelopeTable));
|
||||||
|
|
|
@ -268,38 +268,6 @@ bool InitDirectSound()
|
||||||
|
|
||||||
//Start organya
|
//Start organya
|
||||||
StartOrganya();
|
StartOrganya();
|
||||||
|
|
||||||
//Load sound effects
|
|
||||||
MakeWaveTables();
|
|
||||||
|
|
||||||
char path[0x100];
|
|
||||||
uint8_t *buf = nullptr;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
for (unsigned int n = 0; n < SOUND_NO; n++)
|
|
||||||
{
|
|
||||||
sprintf(path, "%2.2X.pxt", n);
|
|
||||||
|
|
||||||
if (LoadPxt(path, &buf, &len))
|
|
||||||
{
|
|
||||||
lpSECONDARYBUFFER[n] = new SOUNDBUFFER(len);
|
|
||||||
|
|
||||||
uint8_t *sBuf;
|
|
||||||
size_t sLen;
|
|
||||||
lpSECONDARYBUFFER[n]->Lock(&sBuf, &sLen);
|
|
||||||
memcpy(sBuf, buf, sLen);
|
|
||||||
lpSECONDARYBUFFER[n]->Unlock();
|
|
||||||
lpSECONDARYBUFFER[n]->SetFrequency(22050);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Free buffer, we're done with it
|
|
||||||
if (buf)
|
|
||||||
{
|
|
||||||
free(buf);
|
|
||||||
buf = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue