-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw_wad.h
78 lines (66 loc) · 1.66 KB
/
w_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
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* WAD I/O
*/
#ifndef W_WAD_H
#define W_WAD_H
#include <stdint.h>
#include <stdio.h>
/*
* WAD file format
*
* +-----------+
* | HEADER |
* +-----------+
* | LUMPS | data
* | |
* | |
* | |
* +-----------+
* | DIRECTORY | lump name, size and location,
* | | one entry for each lump
* +-----------+
*
* when loading WADs, all lumps descriptions are placed in a lumpinfo_t array
* in the order they were loaded
*/
/* WAD header */
typedef struct {
char id[4]; // IWAD or PWAD, (internal and patch WAD)
uint32_t numlumps; // number of lumps in directory
uint32_t infotableofs; // location of the first directory entry
} wadinfo_t;
/* directory entry */
typedef struct {
uint32_t filepos; // lump location
uint32_t size; // lump size
char name[8]; // lump name
} direntry_t;
/* lump info struct */
typedef struct {
char name[8]; // lump name
uint32_t wad_index; // wad file index containing this lump
uint32_t position; // lump position in file
uint32_t size; // lump size
} lumpinfo_t;
/*
* loads all provided files and fills lumpinfo
*/
void w_init_files(char** files);
/*
* gets the lumpinfo index for the specified lump name,
* returns -1 if not found
*/
int w_get_lump_num(char* name);
/*
* returns the size of the specififed lump
*/
int w_get_lump_length(int lump);
/*
* allocates a buffer, loads lump contents, and returns a pointer to the buffer
*/
void* w_load_lump(int lump);
/*
* logs all lumps in the loaded files
*/
void w_log_lumpinfo();
#endif // W_WAD_H