#!/usr/bin/perl -w 

# Outputs compileable .c file based on raw input.  Agnostic about 
# raw encoding; creates unsigned char bytes. 

die "Usage: a.pl <raw input> <output .c> <texture name>\n" unless $#ARGV==2;

$in = shift;
$out = shift;
$name = shift;
$idx=0;




open(INFILE, "<$in") or die "Can't open $in: $!";
open(OUTFILE, ">$out") or die "Can't open $out: $!";

printf (OUTFILE "unsigned char %s[]={ \n", $name); 

while( read(INFILE, $byte, 1) != 0 ) {
    $r = vec($byte, 0, 8);
    printf OUTFILE "0x%02x, ", $r;
    $idx++;
    if ($idx%13==0) {
        printf OUTFILE "\n";
    }
}

print (OUTFILE "\n};" );


close INFILE;
close OUTFILE;

