mirror of
https://notabug.org/scuti/lib3ddevil1
synced 2024-11-25 16:28:57 +05:30
90 lines
2.5 KiB
C
90 lines
2.5 KiB
C
#ifndef DEVIL1TEX_H
|
|
#define DEVIL1TEX_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
// disable struct padding
|
|
// to easily impose struct on plain data.
|
|
#pragma pack(push, 1)
|
|
|
|
struct TexturePack {
|
|
char id[4];
|
|
int32_t batchNumber;
|
|
uint32_t firstBatchOffset; // <format=hex>
|
|
uint32_t unknownA;
|
|
};
|
|
|
|
struct TextureBatchDescriptor{
|
|
int32_t batchIdx;
|
|
uint32_t hash; // <format=hex>
|
|
uint32_t texNumber;
|
|
uint32_t unknownA[8]; // <format=hex>
|
|
uint32_t textureSize; // <format=hex>
|
|
uint32_t unknownB[30];
|
|
};
|
|
|
|
struct Texture {
|
|
// size of array is defined by descriptor
|
|
// textureSize
|
|
unsigned char *data;
|
|
};
|
|
|
|
struct TextureBatch {
|
|
// quantity of textures are defined by descriptor
|
|
// texNumber
|
|
struct Texture *batch;
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
typedef struct {
|
|
void (* const printheader) (struct TexturePack*);
|
|
void (* const printbatchdesc)(struct TextureBatchDescriptor*);
|
|
bool (* const getbatchdesc) (struct TextureBatchDescriptor**,
|
|
unsigned int,
|
|
const char *,
|
|
unsigned int);
|
|
bool (* const getbatch) (struct TextureBatch**,
|
|
unsigned int,
|
|
const char*,
|
|
unsigned int);
|
|
bool (* const gettextures) (struct Texture*,
|
|
unsigned int,
|
|
const char*,
|
|
const unsigned int);
|
|
} fn_devil1tex;
|
|
extern fn_devil1tex const DEVIL1TEX;
|
|
|
|
// -------------------------------------------------------+
|
|
// Functions
|
|
// -------------------------------------------------------+
|
|
|
|
// Print Texture Pack Header.
|
|
static void printtph(struct TexturePack*);
|
|
|
|
// Print Texture Batch Descriptor.
|
|
static void printtbd(struct TextureBatchDescriptor*);
|
|
|
|
// Get Texture Batch Descriptor.
|
|
// ** = 'pass by reference' of a pointer to struct
|
|
static bool gettexdescriptor(struct TextureBatchDescriptor**,
|
|
unsigned int,
|
|
const char *,
|
|
unsigned int);
|
|
|
|
// Get Texture Batch.
|
|
// ** = 'pass by reference' of a pointer to struct
|
|
static bool gettexbatch(struct TextureBatch**,
|
|
unsigned int,
|
|
const char*,
|
|
unsigned int);
|
|
|
|
// Unpack Texture Batch
|
|
static bool unpacktexbatch(struct Texture*,
|
|
unsigned int,
|
|
const char*,
|
|
const unsigned int);
|
|
|
|
#endif
|