136 lines
3.3 KiB
C
136 lines
3.3 KiB
C
/**
|
|
* @file hmt_struct.h
|
|
* @date 26/08/2022
|
|
* @author JackCarterSmith
|
|
* @copyright GPL-v3.0
|
|
* @brief HMT file mapping definition.
|
|
*
|
|
*/
|
|
|
|
#ifndef RSPTEXTURELIB_HMT_STRUCT_H_
|
|
#define RSPTEXTURELIB_HMT_STRUCT_H_
|
|
|
|
|
|
/*
|
|
* long = 64bits??? (8 Bytes)
|
|
* int = 32bits (4 Bytes)
|
|
* short = 16bits (2 Bytes)
|
|
* char = 8bits (1 Bytes)
|
|
*/
|
|
|
|
#if defined(_MSC_VER)
|
|
#define PACK
|
|
#elif defined(__GNUC__)
|
|
#define PACK __attribute__((packed))
|
|
#endif
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// Declaration of Memory Mapped Structure
|
|
// Caution: the place of variable is important for correct mapping!
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma pack(push, 1)
|
|
#endif
|
|
|
|
typedef struct PACK hmtfile_header1 {
|
|
unsigned int materials_count;
|
|
unsigned int textures_offset;
|
|
} T_HMTFILE_HEADER1;
|
|
|
|
typedef struct PACK hmtfile_header2 {
|
|
unsigned int textures_count;
|
|
} T_HMTFILE_HEADER2;
|
|
|
|
typedef struct PACK hmtfile_material {
|
|
unsigned short type; // 1 - Material with texture / 2 - Material without texture
|
|
unsigned short texture_index;
|
|
|
|
float reserved0; // misc. Diffuse? Transparent?
|
|
float reserved1; // Always 1.0f Ambient?
|
|
|
|
unsigned int reserved2; // Zero Specular?
|
|
unsigned int reserved3; // 0x0A
|
|
|
|
unsigned char name[16];
|
|
} T_HMTFILE_MATERIAL;
|
|
|
|
typedef struct PACK hmtfile_texture_format {
|
|
unsigned char reserved0; // Always 1 ?
|
|
unsigned char sample_bitsize;
|
|
unsigned char type;
|
|
/*
|
|
0 - palette 16x3B RGB, 4bit per pixel
|
|
1 - 256x3B palette RGB, 8bit per pixel
|
|
3 - RGBA 32bpp
|
|
4 - greyscale, 4bpp
|
|
5 - grayscale, 8bpp
|
|
*/
|
|
unsigned char unknown0; // 0x40 / 0x80
|
|
unsigned int transparent_color; //TODO: replace by T_PIXEL type
|
|
} T_HMTFILE_TEXTURE_FORMAT;
|
|
|
|
typedef struct PACK hmtfile_texture_header {
|
|
unsigned int pixels_offset;
|
|
|
|
unsigned int reserved0; // 28B zeros
|
|
unsigned int reserved1;
|
|
unsigned int reserved2;
|
|
unsigned int reserved3;
|
|
unsigned int reserved4;
|
|
unsigned int reserved5;
|
|
unsigned int reserved6;
|
|
|
|
unsigned int palette_offset; // 0 = no palette
|
|
unsigned int texname_offset;
|
|
|
|
unsigned short tex_width;
|
|
unsigned short tex_height;
|
|
|
|
T_HMTFILE_TEXTURE_FORMAT tex_format;
|
|
} T_HMTFILE_TEXTURE_HEADER;
|
|
|
|
typedef struct PACK hmtfile_image_attributes {
|
|
unsigned short width; // Must be increased to a multiple of 2 if odd.
|
|
unsigned short height;
|
|
|
|
unsigned char reserved0; // 0x01
|
|
|
|
unsigned char bit_per_pixel; // 0 - 4bits / 1 - 8bits
|
|
unsigned char subtype; // 3 - RGBA / 4 - greyscale / 5 - ov_rdir
|
|
unsigned char reserved1; // 0x80/128
|
|
} T_HMTFILE_IMAGE_ATTRIBUTES;
|
|
|
|
typedef struct PACK hmtfile_image {
|
|
unsigned int data_size;
|
|
unsigned int pixels_offset;
|
|
|
|
unsigned int reserved0; // 32B zeros
|
|
unsigned int reserved1;
|
|
unsigned int reserved2;
|
|
unsigned int reserved3;
|
|
unsigned int reserved4;
|
|
unsigned int reserved5;
|
|
unsigned int reserved6;
|
|
unsigned int reserved7;
|
|
|
|
unsigned int desc_offset;
|
|
|
|
T_HMTFILE_IMAGE_ATTRIBUTES attributes;
|
|
|
|
unsigned int transparent_color; //TODO: replace by T_PIXEL type
|
|
unsigned int unknown0;
|
|
} T_HMTFILE_IMAGE;
|
|
|
|
typedef struct PACK hmtfile_texture {
|
|
unsigned char name[16]; // Normally = material name
|
|
unsigned int RGB_palette; //TODO: to define
|
|
unsigned int pixels_samples; //TODO: to define
|
|
} T_HMTFILE_TEXTURE;
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma pack(pop)
|
|
#endif
|
|
|
|
#endif /* RSPTEXTURELIB_HMT_STRUCT_H_ */
|