This software and its source code (if available) are licensed under the Apache-2.0 license (unless otherwise specified) which DOES NOT APPLY to any third-party code (such as zlib for example) and borrowed Assembler code (ripped code from other software executable files).
#pragma pack(push, 1)
typedef struct {
uint16_t magic; /* must be 2118 */
uint8_t flags; /* must be 1 */
uint16_t count;
} mio_head;
typedef struct {
uint8_t data1[6];
uint32_t width;
uint32_t height;
uint8_t data2[17];
uint32_t isize;
} mio_item; /* 35 */
#pragma pack(pop)
int conv_mio(FILE *fl, uint32_t sz, char *f) {
uint32_t i, l;
mio_head head;
mio_item item;
char s[260];
uint8_t *p;
fseek(fl, 0, SEEK_SET);
readdata(fl, &head, sizeof(head));
if (
(sz <= sizeof(head)) || (head.magic != 2118) || (head.flags != 1) || (!head.count) ||
(sz <= (sizeof(head) + (head.count * sizeof(item))))
) {
return(3);
}
newext(f, "");
for (i = 0; i < head.count; i++) {
sprintf(s, "%s.%03u.tga", f, i + 1);
readdata(fl, &item, sizeof(item));
for (l = 0; l < 6; l++) {
printf("0x%02X ", item.data1[l]);
}
printf("\n");
for (l = 0; l < 17; l++) {
printf("0x%02X ", item.data2[l]);
}
printf("\n%s\n", s);
l = sizeof(tga_head) + (item.width * item.height * 2);
p = (uint8_t *) malloc(item.isize + l);
if (p) {
tga_init(&p[item.isize], item.width, item.height);
readdata(fl, p, item.isize);
spr_unpack(p, item.isize, &p[item.isize + sizeof(tga_head)], item.width, item.height);
dumpdata(s, &p[item.isize], l);
free(p);
} else {
fseek(fl, ftell(fl) + item.isize, SEEK_SET);
}
}
return(0);
}