#include "wad.h" #include #include #include #include #include #include #include namespace wad { char file[13]; filelump_t *directory; uint32_t numlumps; struct patch_t { }; std::unordered_map flats; std::unordered_map textures; std::unordered_map patches; std::vector patch_names; //char (*patch_names)[8]; void init(const char *filename) { strcpy(file, filename); FILE *f = fopen(filename, "rb"); char header[4]; fread(header, 4, 1, f);// printf("header: %*.s\n", 4, header); uint32_t infotableofs; fread(&numlumps, 4, 1, f);// printf("num lumps: %i\n", numlumps); fread(&infotableofs, 4, 1, f);// printf("directory offset: %i\n\n", infotableofs); directory = (filelump_t*)malloc(sizeof(filelump_t)*numlumps); fseek(f, infotableofs, SEEK_SET); for (int i=0; ipixels[x+y*64] = flat[i++]; free(flat); flats[name] = surf; return surf; } draw::surface_t *loadTexture(const char *name) { if (textures.find(name) != textures.end()) return textures[name]; uint8_t *textures_lump = load("TEXTURE1"); int num_textures_in_lump = ((uint32_t*)textures_lump)[0]; uint32_t *offsets = &((uint32_t*)textures_lump)[1]; int i = 0; while (i