SpaceCadetPinball/SpaceCadetPinball/loader.h

111 lines
2.8 KiB
C
Raw Normal View History

2020-10-25 15:17:26 +01:00
#pragma once
2020-11-08 16:37:59 +01:00
#include "gdrv.h"
2021-01-23 11:33:30 +01:00
#include "maths.h"
2020-11-08 16:37:59 +01:00
#include "zdrv.h"
2020-10-25 15:17:26 +01:00
class DatFile;
2020-10-25 15:17:26 +01:00
struct errorMsg
{
int Code;
const char* Message;
};
struct soundListStruct
{
Mix_Chunk* WavePtr;
2020-10-25 15:17:26 +01:00
int GroupIndex;
int Loaded;
2020-12-25 14:46:06 +01:00
float Duration;
2020-10-25 15:17:26 +01:00
};
struct visualKickerStruct
2020-10-30 13:26:00 +01:00
{
2021-01-23 11:33:30 +01:00
float Threshold;
float Boost;
float ThrowBallMult;
2022-05-20 10:51:00 +02:00
vector3 ThrowBallDirection;
2021-01-23 11:33:30 +01:00
float ThrowBallAngleMult;
int HardHitSoundId;
2020-10-30 13:26:00 +01:00
};
struct visualStruct
2020-10-30 13:26:00 +01:00
{
2021-01-23 11:33:30 +01:00
float Smoothness;
float Elasticity;
2020-12-20 12:13:12 +01:00
int FloatArrCount;
2020-10-30 13:26:00 +01:00
float* FloatArr;
2021-01-23 11:33:30 +01:00
int SoftHitSoundId;
2020-10-30 13:26:00 +01:00
visualKickerStruct Kicker;
2021-01-28 16:01:26 +01:00
int CollisionGroup;
2020-10-30 13:26:00 +01:00
int SoundIndex4;
int SoundIndex3;
2020-11-08 16:37:59 +01:00
gdrv_bitmap8* Bitmap;
zmap_header_type* ZMap;
2020-10-30 13:26:00 +01:00
};
#pragma pack(push)
#pragma pack(1)
// WAVE file header format
struct WaveHeader
{
unsigned char riff[4]; // RIFF string
unsigned int overall_size; // overall size of file in bytes
unsigned char wave[4]; // WAVE string
unsigned char fmt_chunk_marker[4]; // fmt string with trailing null char
unsigned int length_of_fmt; // length of the format data
unsigned short format_type; // format type. 1-PCM, 3- IEEE float, 6 - 8bit A law, 7 - 8bit mu law
unsigned short channels; // no.of channels
unsigned int sample_rate; // sampling rate (blocks per second)
unsigned int byterate; // SampleRate * NumChannels * BitsPerSample/8
unsigned short block_align; // NumChannels * BitsPerSample/8
unsigned short bits_per_sample; // bits per sample, 8- 8bits, 16- 16 bits etc
unsigned char data_chunk_header[4]; // DATA string or FLLR string
unsigned int data_size; // NumSamples * NumChannels * BitsPerSample/8 - size of the next chunk that will be read
};
#pragma pack(pop)
static_assert(sizeof(WaveHeader) == 44, "Wrong size of WaveHeader");
2020-10-25 15:17:26 +01:00
class loader
{
public:
static int error(int errorCode, int captionCode);
2020-10-30 13:26:00 +01:00
static void default_vsi(visualStruct* visual);
2020-10-25 15:17:26 +01:00
static int get_sound_id(int groupIndex);
2020-10-30 13:26:00 +01:00
static void unload();
static void loadfrom(DatFile* datFile);
2020-10-25 15:17:26 +01:00
static int query_handle(LPCSTR lpString);
static short query_visual_states(int groupIndex);
2020-10-30 13:26:00 +01:00
static int material(int groupIndex, visualStruct* visual);
static int kicker(int groupIndex, visualKickerStruct* kicker);
static int state_id(int groupIndex, int groupIndexOffset);
static int query_visual(int groupIndex, int groupIndexOffset, visualStruct* visual);
2020-10-25 15:17:26 +01:00
static char* query_name(int groupIndex);
static float* query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue);
static float query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue, float defVal);
static int16_t* query_iattribute(int groupIndex, int firstValue, int* arraySize);
2020-12-25 14:46:06 +01:00
static float play_sound(int soundIndex);
static DatFile* loader_table;
private:
static errorMsg loader_errors[];
static DatFile* sound_record_table;
2020-10-25 15:17:26 +01:00
static int sound_count;
static int loader_sound_count;
static soundListStruct sound_list[65];
};