98 lines
2.2 KiB
C
98 lines
2.2 KiB
C
#ifndef HMT_PARSER_H_
|
|
#define HMT_PARSER_H_
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "RS_images.h"
|
|
|
|
/////////////////////////////
|
|
///// Define HMT types //////
|
|
/////////////////////////////
|
|
|
|
/**
|
|
* @brief Material struct inside HMT file type
|
|
*
|
|
* Actual RE material struct:\n
|
|
* 4B material entry count MC\n
|
|
* 4B offset after material entries / offset to textures\n
|
|
* MC * material entry (36B)\n
|
|
* [\n
|
|
* 2B int material/texture type:\n
|
|
* 1 - material with texture\n
|
|
* 2 - material without texture\n
|
|
* 2B int texture index\n
|
|
* 4B float (scale factor?)\n
|
|
* 4B float (always 1.0)\n
|
|
* 4B int zero\n
|
|
* 4B int 0x0A\n
|
|
* 16B name\n
|
|
* ]\n
|
|
*
|
|
* @image html hmt_materialDef.png
|
|
*/
|
|
typedef struct HMTMaterial {
|
|
short type_; /**< Material type:\n 1 = Material with texture\n 2 = Material without texture */
|
|
short texture_index;
|
|
float unknow1,unknow2;
|
|
int zero;
|
|
int hex_a;
|
|
char *name[16];
|
|
}HMT_MATERIAL;
|
|
|
|
/**
|
|
* @brief Texture struct inside HMT file type
|
|
*
|
|
* Actual RE texture struct:\n
|
|
* 4B int texcount Tc\n
|
|
* TC * texture entry 52B\n
|
|
* [\n
|
|
* 4B int pixel offset\n
|
|
* 28B zero\n
|
|
* 4B int palette offset, 0 = no palette\n
|
|
* 4B int texname offset\n
|
|
* 2B int width\n
|
|
* 2B int height\n
|
|
* 8B texture format [\n
|
|
* 1B int : always 1?\n
|
|
* 1B int : bits per sample?\n
|
|
* 1B int : subtype:\n
|
|
* -0 - palette 16x3B RGB, 4bit per pixel\n
|
|
* -1 - 256x3B palette RGB, 8bit per pixel\n
|
|
* -3 - RGBA 32bpp\n
|
|
* -4 - greyscale, 4bpp\n
|
|
* -5 - grayscale, 8bpp\n
|
|
* 1B int ? 0, 0x40, 0x80\n
|
|
* 4B RGBA transparent color?\n
|
|
* ]\n
|
|
* ]\n
|
|
*
|
|
* @image html hmt_textureDef.png
|
|
*/
|
|
typedef struct HMTTexture {
|
|
int data_offset;
|
|
int palette_offset;
|
|
int textureName_offset;
|
|
unsigned long width, height;
|
|
char *name[16];
|
|
RS_IMAGE image;
|
|
}HMT_TEXTURE;
|
|
|
|
/**
|
|
* @brief HMT file struct
|
|
*/
|
|
typedef struct HMTFile {
|
|
int material_count;
|
|
int texture_offset;
|
|
int texture_count;
|
|
HMT_MATERIAL *materials_list;
|
|
HMT_TEXTURE *textures_list;
|
|
}HMT_FILE;
|
|
|
|
|
|
/////////////////////////////
|
|
///// Declare functions /////
|
|
/////////////////////////////
|
|
int exportToPNM(FILE *f, RS_IMAGE *img);
|
|
|
|
#endif
|