tb1/tb1_snes/tools/bin2byte.c
Vince Weaver dbaf404ec3 snes: rename tb_snes to tb1_snes
I kept typing it wrong anyway, and hey, git makes rename easy
2013-01-22 09:53:01 -05:00

30 lines
533 B
C

/* converts an .incbin type binary include into an ascii text one */
#include <stdio.h>
int main(int argc, char **argv) {
unsigned char blah;
int result,count=0;
while(1) {
result=fread(&blah,1,1,stdin);
if (result<1) break;
if (count%16==0) {
fprintf(stdout,".byte ");
}
fprintf(stdout,"$%02x",blah);
if (count%16!=15) {
fprintf(stdout,",");
}
else {
fprintf(stdout,"\n");
}
count++;
}
return 0;
}