/* getint reads 4 bytes from file and returns it */ int getint(FILE *file) { int returnval = 0; returnval += getc(file); returnval += getc(file)*0x100; returnval += getc(file)*0x10000; returnval += getc(file)*0x1000000; return returnval; } int getword(FILE *file) { int returnval = 0; returnval += getc(file); returnval += getc(file)*0x100; return returnval; } /* writeword writes word to file */ void writeword(FILE *tga, short word) { char tmp[2]; tmp[0] = word; word = word >>8; tmp[1] = word; putc(tmp[0], tga); putc(tmp[1], tga); } int skipheader(FILE *rw) { int sectionsize; fseek(rw, 0x4, SEEK_CUR); sectionsize = getint(rw); fseek(rw, 0x4, SEEK_CUR); return sectionsize; } short readnibble(FILE *txd, unsigned char byte) { unsigned char first, sec; first = byte >> 4; sec = byte << 4; sec >>= 4; return sec + (first << 8); }