2020-10-18 15:08:41 +00:00
# pragma once
2021-02-16 16:03:45 +00:00
enum class datFieldTypes : int16_t
2020-10-24 15:30:45 +00:00
{
ShortValue = 0 ,
//, does not have the 32bits size value, but a 16bits value(see above).
Bitmap8bit = 1 ,
// 8 bpp bitmap
Unknown2 = 2 ,
GroupName = 3 ,
// Group name
Unknown4 = 4 ,
Palette = 5 ,
// Palette(1 color is 1 DWORD, only present 1 time in PINBALL.DAT ,with a data size of 1024 bytes for 256 colors.Some colors are 0 ,because their indexes are reserved by Windows.)
Unknown6 = 6 ,
Unknown7 = 7 ,
Unknown8 = 8 ,
String = 9 ,
// String(content)
ShortArray = 10 ,
// Array of 16bits integer values
FloatArray = 11 ,
// Array of 32bits floating point values(collision box, ...)
Bitmap16bit = 12 ,
// 16 bpp bitmap(Heightmap ? )
} ;
2021-01-28 15:01:26 +00:00
enum class bmp8Flags : unsigned char
{
RawBmpUnaligned = 1 < < 0 ,
2021-01-31 14:29:53 +00:00
DibBitmap = 1 < < 1 ,
Spliced = 1 < < 2 ,
2021-01-28 15:01:26 +00:00
} ;
2020-10-18 15:08:41 +00:00
# pragma pack(push)
# pragma pack(1)
2020-10-24 15:30:45 +00:00
struct datFileHeader
2020-10-18 15:08:41 +00:00
{
char FileSignature [ 21 ] ;
char AppName [ 50 ] ;
char Description [ 100 ] ;
int FileSize ;
unsigned short NumberOfGroups ;
int SizeOfBody ;
unsigned short Unknown ;
} ;
# pragma pack(pop)
static_assert ( sizeof ( datFileHeader ) = = 183 , " Wrong size of datFileHeader " ) ;
2020-10-24 15:30:45 +00:00
struct datEntryData
{
datFieldTypes EntryType ;
int FieldSize ;
char * Buffer ;
} ;
struct datGroupData
{
2021-02-16 16:03:45 +00:00
int16_t EntryCount ;
2020-10-24 15:30:45 +00:00
datEntryData Entries [ 1 ] ;
} ;
2020-10-18 15:08:41 +00:00
struct datFileStruct
{
unsigned short NumberOfGroups ;
char * Description ;
2020-10-24 15:30:45 +00:00
datGroupData * * GroupData ;
2020-10-18 15:08:41 +00:00
} ;
2020-10-24 15:30:45 +00:00
# pragma pack(push)
# pragma pack(1)
struct dat8BitBmpHeader
2020-10-18 15:08:41 +00:00
{
2021-01-31 14:29:53 +00:00
char Resolution ;
2021-02-16 16:03:45 +00:00
int16_t Width ;
int16_t Height ;
int16_t XPosition ;
int16_t YPosition ;
2020-10-24 15:30:45 +00:00
int Size ;
2021-01-28 15:01:26 +00:00
bmp8Flags Flags ;
bool IsFlagSet ( bmp8Flags flag )
{
return static_cast < char > ( Flags ) & static_cast < char > ( flag ) ;
}
2020-10-18 15:08:41 +00:00
} ;
2020-10-24 15:30:45 +00:00
# pragma pack(pop)
static_assert ( sizeof ( dat8BitBmpHeader ) = = 14 , " Wrong size of dat8BitBmpHeader " ) ;
2021-01-29 13:42:05 +00:00
# pragma pack(push, 1)
struct __declspec ( align ( 1 ) ) dat16BitBmpHeader
{
2021-02-16 16:03:45 +00:00
int16_t Width ;
int16_t Height ;
int16_t Stride ;
2021-01-29 13:42:05 +00:00
int Unknown0 ;
2021-02-16 16:03:45 +00:00
int16_t Unknown1_0 ;
int16_t Unknown1_1 ;
2021-01-29 13:42:05 +00:00
} ;
# pragma pack(pop)
static_assert ( sizeof ( dat16BitBmpHeader ) = = 14 , " Wrong size of zmap_header_type " ) ;
2020-10-18 15:08:41 +00:00
class partman
{
public :
2021-01-31 14:29:53 +00:00
static datFileStruct * load_records ( LPCSTR lpFileName , int resolution , bool fullTiltMode ) ;
2020-10-24 15:30:45 +00:00
static void unload_records ( datFileStruct * datFile ) ;
static char * field_nth ( datFileStruct * datFile , int groupIndex , datFieldTypes targetEntryType , int skipFirstN ) ;
static char * field ( datFileStruct * datFile , int groupIndex , datFieldTypes entryType ) ;
static int field_size_nth ( datFileStruct * datFile , int groupIndex , datFieldTypes targetEntryType , int skipFirstN ) ;
static int field_size ( datFileStruct * datFile , int groupIndex , datFieldTypes targetEntryType ) ;
static int record_labeled ( datFileStruct * datFile , LPCSTR targetGroupName ) ;
static char * field_labeled ( datFileStruct * datFile , LPCSTR lpString , datFieldTypes fieldType ) ;
2020-10-18 15:08:41 +00:00
private :
static short _field_size [ ] ;
2020-10-24 15:30:45 +00:00
static char _lread_char ( HFILE hFile ) ;
static int _lread_long ( HFILE hFile ) ;
2020-10-18 15:08:41 +00:00
} ;