-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwad.h
65 lines (44 loc) · 1.44 KB
/
wad.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef WAD_H_INCLUDED
#define WAD_H_INCLUDED
#include <stdint.h>
#define WAD_MAGIC "WAD3"
#define WAD_TEXTURE_TYPE_QPIC 0x42
#define WAD_TEXTURE_TYPE_MIPTEX 0x43
#define WAD_TEXTURE_TYPE_FONT 0x45
typedef struct {
uint32_t texture_offset;
uint32_t texture_compressed_size;
uint32_t texture_size;
uint8_t texture_type;
uint8_t compression_type;
uint16_t padding;
char texture_name[16];
} WAD_LUMP_ITEM;
typedef struct {
char texture_name[16];
uint32_t width;
uint32_t height;
uint32_t image_offset; /* Offset relative to imageData */
uint32_t mipmap_1_offset; /* Offset relative to mipmap1Data */
uint32_t mipmap_2_offset; /* Offset relative to mipmap2Data */
uint32_t mipmap_3_offset; /* Offset relative to mipmap3Data */
uint8_t *image_data; /* size = width * height */
uint8_t *mipmap_1_data; /* size = (width / 2) * (height / 2) */
uint8_t *mipmap_2_data; /* size = (width / 4) * (height / 4) */
uint8_t *mipmap_3_data; /* size = (width / 8) * (height / 8) */
uint8_t unknown_byte_1; /* Unknown byte, always 0x00 */
uint8_t unknown_byte_2; /* Unknown byte, always 0x01 */
uint8_t color_map[256*3];
} WAD_TEXTURE;
typedef struct {
uint32_t textures_count;
uint32_t lumps_offset;
WAD_TEXTURE **textures;
WAD_LUMP_ITEM **lumps;
} WAD;
WAD wad_init(void);
int wad_update(WAD *wad);
int wad_open_file(WAD *wad, char *path);
int wad_save_file(WAD *wad, char *path);
void wad_free(WAD *wad);
#endif // WAD_H_INCLUDED