mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-05-01 06:08:00 +03:00
vars: pull sample variables
This commit is contained in:
parent
f5d33c2a1e
commit
461073a241
4 changed files with 25 additions and 21 deletions
|
@ -37,6 +37,10 @@ void (*EffectRoutines[])(ITEM_INFO *item) = {
|
|||
|
||||
bool SoundIsActive = true;
|
||||
int32_t MnSoundMasterVolume;
|
||||
int16_t SampleLUT[MAX_SAMPLES];
|
||||
SAMPLE_INFO *SampleInfos;
|
||||
SAMPLE_DATA **SampleData;
|
||||
int32_t NumSampleData;
|
||||
|
||||
int32_t NoInputCount = 0;
|
||||
int32_t IDelay;
|
||||
|
|
|
@ -80,13 +80,10 @@ extern INPUT_STATE InputDB;
|
|||
extern int32_t KeyChange;
|
||||
|
||||
extern bool SoundIsActive;
|
||||
#define SampleLUT ARRAY_(0x0045EB60, int16_t, [MAX_SAMPLES])
|
||||
#define SampleInfos VAR_U_(0x0045ED60, SAMPLE_INFO*)
|
||||
#define SampleData VAR_U_(0x0045B954, SAMPLE_DATA**)
|
||||
#define NumSampleData VAR_U_(0x0045B96C, int32_t)
|
||||
#define NumSampleInfos VAR_U_(0x0045A210, int32_t)
|
||||
#define NumSamples VAR_U_(0x0045E964, int32_t)
|
||||
#define DecibelLUT ARRAY_(0x0045F1E0, int32_t, [DECIBEL_LUT_SIZE])
|
||||
extern int16_t SampleLUT[MAX_SAMPLES];
|
||||
extern SAMPLE_INFO *SampleInfos;
|
||||
extern SAMPLE_DATA** SampleData;
|
||||
extern int32_t NumSampleData;
|
||||
#define CDTrack VAR_I_(0x004534DC, int16_t, -1)
|
||||
#define CDTrackLooped VAR_I_(0x0045B97C, int16_t, -1)
|
||||
#define CDLoop VAR_U_(0x0045B94C, int32_t)
|
||||
|
|
|
@ -558,16 +558,17 @@ static int32_t LoadSamples(MYFILE *fp)
|
|||
}
|
||||
|
||||
FileRead(SampleLUT, sizeof(int16_t), MAX_SAMPLES, fp);
|
||||
FileRead(&NumSampleInfos, sizeof(int32_t), 1, fp);
|
||||
LOG_INFO("%d sample infos", NumSampleInfos);
|
||||
if (!NumSampleInfos) {
|
||||
int32_t num_sample_infos;
|
||||
FileRead(&num_sample_infos, sizeof(int32_t), 1, fp);
|
||||
LOG_INFO("%d sample infos", num_sample_infos);
|
||||
if (!num_sample_infos) {
|
||||
S_ExitSystem("No Sample Infos");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SampleInfos =
|
||||
game_malloc(sizeof(SAMPLE_INFO) * NumSampleInfos, GBUF_SAMPLE_INFOS);
|
||||
FileRead(SampleInfos, sizeof(SAMPLE_INFO), NumSampleInfos, fp);
|
||||
game_malloc(sizeof(SAMPLE_INFO) * num_sample_infos, GBUF_SAMPLE_INFOS);
|
||||
FileRead(SampleInfos, sizeof(SAMPLE_INFO), num_sample_infos, fp);
|
||||
|
||||
int32_t sample_data_size;
|
||||
FileRead(&sample_data_size, sizeof(int32_t), 1, fp);
|
||||
|
@ -580,26 +581,27 @@ static int32_t LoadSamples(MYFILE *fp)
|
|||
char *sample_data = game_malloc(sample_data_size, GBUF_SAMPLES);
|
||||
FileRead(sample_data, sizeof(char), sample_data_size, fp);
|
||||
|
||||
FileRead(&NumSamples, sizeof(int32_t), 1, fp);
|
||||
LOG_INFO("%d samples", NumSamples);
|
||||
if (!NumSamples) {
|
||||
int32_t num_samples;
|
||||
FileRead(&num_samples, sizeof(int32_t), 1, fp);
|
||||
LOG_INFO("%d samples", num_samples);
|
||||
if (!num_samples) {
|
||||
S_ExitSystem("No Samples");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t *sample_offsets =
|
||||
game_malloc(sizeof(int32_t) * NumSamples, GBUF_SAMPLE_OFFSETS);
|
||||
FileRead(sample_offsets, sizeof(int32_t), NumSamples, fp);
|
||||
game_malloc(sizeof(int32_t) * num_samples, GBUF_SAMPLE_OFFSETS);
|
||||
FileRead(sample_offsets, sizeof(int32_t), num_samples, fp);
|
||||
|
||||
char **sample_pointers =
|
||||
game_malloc(sizeof(char *) * NumSamples, GBUF_SAMPLE_OFFSETS);
|
||||
for (int i = 0; i < NumSamples; i++) {
|
||||
game_malloc(sizeof(char *) * num_samples, GBUF_SAMPLE_OFFSETS);
|
||||
for (int i = 0; i < num_samples; i++) {
|
||||
sample_pointers[i] = sample_data + sample_offsets[i];
|
||||
}
|
||||
|
||||
SoundLoadSamples(sample_pointers, NumSamples);
|
||||
SoundLoadSamples(sample_pointers, num_samples);
|
||||
|
||||
game_free(sizeof(char *) * NumSamples, GBUF_SAMPLE_OFFSETS);
|
||||
game_free(sizeof(char *) * num_samples, GBUF_SAMPLE_OFFSETS);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef struct WAVE_FILE_HEADER {
|
|||
#pragma pack(pop)
|
||||
|
||||
static DUPE_SOUND_BUFFER *DupeSoundBufferList = NULL;
|
||||
static int32_t DecibelLUT[DECIBEL_LUT_SIZE];
|
||||
|
||||
int32_t ConvertVolumeToDecibel(int32_t volume)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue