/******************************************/ /* Converts Elktronics Video ID EPROMS to */ /* 256x192 X Bit Maps */ /* 28-July-1995 KD2BD Software */ /* Copyright 1998 by John A. Magliacane */ /******************************************/ #include #include FILE *infile, *outfile; int rotate (x) int x; { int output=0; if ((x==0) || (x==255)) output=x; else { if (x&128) output+=1; if (x&64) output+=2; if (x&32) output+=4; if (x&16) output+=8; if (x&8) output+=16; if (x&4) output+=32; if (x&2) output+=64; if (x&1) output+=128; } return (output); } void main (argc,argv) int argc; char *argv[]; { int count, input, output, length, line=0; char flag, endchar, namenoext[20], outfilename[20]; if (argc==2) infile=fopen(argv[1],"rb"); else { fprintf(stderr,"Usage: prom2xbm infile\n"); exit(1); } printf("\nReading from %s...",argv[1]); length=strlen(argv[1]); for (count=0, flag=1; ((count!=length)&&flag); count++) { namenoext[count]=argv[1][count]; if (argv[1][count]=='.') { flag=0; count--; } } namenoext[count]='1'; namenoext[count+1]=0; strcpy(outfilename,namenoext); strcat(outfilename,".xbm\0"); printf("\nWriting to %s...",outfilename); outfile=fopen(outfilename,"wb"); fprintf(outfile,"#define %s_width 256\n",namenoext); fprintf(outfile,"#define %s_height 192\n",namenoext); fprintf(outfile,"static char %s_bits[] = {\n ",namenoext); for (count=0; count<6144; count++) { fscanf(infile,"%c",&input); if (count!=6144) endchar=','; else endchar='}'; fprintf(outfile," 0x%.2x%c",rotate(input)^255, endchar); line++; if (line==12) { fprintf(outfile,"\n "); line=0; } } fprintf(outfile, ";\n"); fclose(outfile); length=strlen(argv[1]); for (count=0, flag=1; ((count!=length)&&flag); count++) { namenoext[count]=argv[1][count]; if (argv[1][count]=='.') { flag=0; count--; } } namenoext[count]='2'; namenoext[count+1]=0; strcpy(outfilename,namenoext); strcat(outfilename,".xbm\0"); printf("\nWriting to %s...\n", outfilename); outfile=fopen(outfilename,"wb"); fprintf(outfile,"#define %s_width 256\n",namenoext); fprintf(outfile,"#define %s_height 192\n",namenoext); fprintf(outfile,"static char %s_bits[] = {\n ",namenoext); /* Skip over color bar and blank space on EPROM */ for (count=6144; count!=8192; count++) fscanf(infile,"%c",&input); for (count=8192; count!=14337; count++) { fscanf(infile,"%c",&input); if (count!=14336) endchar=','; else endchar='}'; fprintf(outfile," 0x%.2x%c",rotate(input)^255, endchar); line++; if (line==12) { fprintf(outfile,"\n "); line=0; } } fprintf(outfile, ";\n"); fclose(outfile); fclose(infile); exit(0); }