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 {
char magic[16];
uint8_t unused[8];
uint16_t flags;
uint16_t width;
uint16_t height;
uint32_t isize;
} img_head; /* 34 */
#pragma pack(pop)
int conv_img(FILE *fl, uint32_t sz, char *f) {
img_head head;
uint32_t l;
uint8_t *p;
char s[260];
fseek(fl, 0, SEEK_SET);
readdata(fl, &head, sizeof(head));
if (
(sz <= sizeof(head)) ||
(!CheckMagic("RUSH Image File.", head.magic)) ||
(sz != (sizeof(head) + head.isize)) ||
(!head.width) || (!head.height) || (!head.isize)
) {
return(3);
}
l = sizeof(tga_head) + (head.width * head.height * 2);
p = (uint8_t *) malloc(head.isize + l);
if (!p) {
return(4);
}
strcpy(s, f);
printf("%s -> ", s);
newext(s, ".tga");
printf("%s\n", s);
readdata(fl, p, head.isize);
tga_init(&p[head.isize], head.width, head.height);
spr_unpack(p, head.isize, &p[head.isize + sizeof(tga_head)], head.width, head.height);
dumpdata(s, &p[head.isize], l);
free(p);
return(0);
}