2018-04-04 14:06:28 +05:30
|
|
|
#ifndef DEVIL1TEX_H
|
|
|
|
#define DEVIL1TEX_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-04-06 10:22:56 +05:30
|
|
|
#include <stdbool.h>
|
2018-04-06 10:31:12 +05:30
|
|
|
|
2018-04-04 14:06:28 +05:30
|
|
|
// disable struct padding
|
|
|
|
// to easily impose struct on plain data.
|
2018-04-06 10:31:12 +05:30
|
|
|
#pragma pack(push, 1)
|
2018-04-04 14:06:28 +05:30
|
|
|
|
|
|
|
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)
|
|
|
|
|
2018-04-18 08:33:06 +05:30
|
|
|
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;
|
|
|
|
|
2018-04-06 10:31:12 +05:30
|
|
|
// -------------------------------------------------------+
|
|
|
|
// Functions
|
|
|
|
// -------------------------------------------------------+
|
|
|
|
|
|
|
|
// Print Texture Pack Header.
|
2018-04-18 08:33:06 +05:30
|
|
|
static void printtph(struct TexturePack*);
|
2018-04-04 14:06:28 +05:30
|
|
|
|
2018-04-06 10:31:12 +05:30
|
|
|
// Print Texture Batch Descriptor.
|
2018-04-18 08:33:06 +05:30
|
|
|
static void printtbd(struct TextureBatchDescriptor*);
|
2018-04-04 22:42:29 +05:30
|
|
|
|
2018-04-06 10:31:12 +05:30
|
|
|
// Get Texture Batch Descriptor.
|
|
|
|
// ** = 'pass by reference' of a pointer to struct
|
2018-04-18 08:33:06 +05:30
|
|
|
static bool gettexdescriptor(struct TextureBatchDescriptor**,
|
2018-04-06 10:22:56 +05:30
|
|
|
unsigned int,
|
|
|
|
const char *,
|
|
|
|
unsigned int);
|
|
|
|
|
2018-04-06 10:31:12 +05:30
|
|
|
// Get Texture Batch.
|
|
|
|
// ** = 'pass by reference' of a pointer to struct
|
2018-04-18 08:33:06 +05:30
|
|
|
static bool gettexbatch(struct TextureBatch**,
|
2018-04-06 10:22:56 +05:30
|
|
|
unsigned int,
|
|
|
|
const char*,
|
|
|
|
unsigned int);
|
|
|
|
|
2018-04-06 10:31:12 +05:30
|
|
|
// Unpack Texture Batch
|
2018-04-18 08:33:06 +05:30
|
|
|
static bool unpacktexbatch(struct Texture*,
|
2018-04-06 10:22:56 +05:30
|
|
|
unsigned int,
|
|
|
|
const char*,
|
|
|
|
const unsigned int);
|
|
|
|
|
2018-04-04 14:06:28 +05:30
|
|
|
#endif
|