- Ja carrega els patch, pero les textures es veuen mal. Arreglant mil coses del motor que tenia a foc pintar textures de 64x64

This commit is contained in:
2026-02-27 08:05:24 +01:00
parent 8dbcd4fcb7
commit 8e46fa85b2
4 changed files with 58 additions and 20 deletions

21
wad.cpp
View File

@@ -124,11 +124,12 @@ namespace wad {
uint16_t *patches = &((uint16_t*)texture_info)[5];
for (int i=0; i<patch_count; ++i) {
const int originx = patches[i*10+0];
const int originy = patches[i*10+1];
const int patch_index = patches[i*10+2];
const int originx = patches[i*5+0];
const int originy = patches[i*5+1];
const int patch_index = patches[i*5+2];
const char *patch_name = patch_names[patch_index].c_str();
draw::surface_t *patch = loadPatch(patch_name);
draw::drawsurf(originx, originy, patch, surf);
}
free(textures_lump);
@@ -143,8 +144,22 @@ namespace wad {
uint8_t *patch_lump = load(name);
const int patch_width = ((uint16_t*)patch_lump)[0];
const int patch_height = ((uint16_t*)patch_lump)[1];
printf("%ix%i\n", patch_width, patch_height);
draw::surface_t *surf = draw::newsurf(patch_width, patch_height);
uint32_t *offsets = (uint32_t*)(patch_lump+8);
for (int i=0; i<patch_width; ++i) {
uint8_t *post = patch_lump+offsets[i];
while(true) {
if (post[0] == 0xff) break;
const int offset = post[0];
const int length = post[1];
for (int j=0;j<length;++j) {
draw::putpsurf(surf, i, offset+j, post[3+j]);
}
post = post+4+length;
}
}
//https://www.doomwiki.org/wiki/Picture_format
free(patch_lump);