2018-04-04 14:06:28 +05:30
|
|
|
#include "devil1tex.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
void printtph (struct TexturePack *tp) {
|
|
|
|
if (tp != NULL) {
|
|
|
|
printf("id: \t %c %c %c %c \n", tp -> id[3],
|
|
|
|
tp -> id[2],
|
|
|
|
tp -> id[1],
|
|
|
|
tp -> id[0]);
|
|
|
|
printf("batch#: \t %i \n", tp -> batchNumber);
|
|
|
|
printf("1st batch: \t %i \n", tp -> firstBatchOffset);
|
|
|
|
printf("unknownA: \t %i\n", tp -> unknownA);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-04 22:42:29 +05:30
|
|
|
void printtbd(struct TextureBatchDescriptor *bd) {
|
|
|
|
if (bd != NULL) {
|
|
|
|
printf("batch index: \t %i \n", bd -> batchIdx);
|
|
|
|
printf("hash: \t %u \n", bd -> hash);
|
|
|
|
printf("textures: \t %i\n", bd -> texNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-04 14:06:28 +05:30
|
|
|
// get texture pack descriptors
|
2018-04-04 22:42:29 +05:30
|
|
|
void gettbd (struct TextureBatchDescriptor **descriptors,
|
|
|
|
const char *filedata,
|
|
|
|
unsigned int filesize) {
|
|
|
|
if (descriptors == NULL || filedata == NULL || filesize <= 0) {
|
2018-04-04 14:06:28 +05:30
|
|
|
return;
|
|
|
|
}
|
2018-04-04 22:42:29 +05:30
|
|
|
struct TexturePack *tp = NULL;
|
|
|
|
tp = (struct TexturePack*)filedata;
|
|
|
|
if (filesize <= (sizeof(struct TextureBatchDescriptor)
|
|
|
|
* tp -> batchNumber
|
|
|
|
+ sizeof(struct TexturePack))){
|
|
|
|
fprintf(stderr,
|
|
|
|
"File Error: file size to struct sizes ratio.\n");
|
2018-04-04 14:06:28 +05:30
|
|
|
return;
|
|
|
|
}
|
2018-04-04 22:42:29 +05:30
|
|
|
unsigned int index = sizeof(struct TexturePack);
|
2018-04-04 14:06:28 +05:30
|
|
|
// Batch Descriptors are structured one after another.
|
|
|
|
// therefore the next one is at
|
|
|
|
// current index + sizeof(TextureBatchDescriptor)
|
|
|
|
unsigned int i = 0;
|
|
|
|
do {
|
2018-04-04 22:42:29 +05:30
|
|
|
index = sizeof(struct TextureBatchDescriptor) * i
|
|
|
|
+ sizeof(struct TexturePack);
|
2018-04-04 14:06:28 +05:30
|
|
|
printf("batch descriptor start: %x\n", index);
|
2018-04-04 22:42:29 +05:30
|
|
|
descriptors[i] = (struct TextureBatchDescriptor*)
|
|
|
|
(filedata + index);
|
|
|
|
i++;
|
|
|
|
} while(i < (tp -> batchNumber));
|
2018-04-04 14:06:28 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
|