8
//enum types {SYNTAX,FILEOPENIN,FILEOPENOUT,WRONGBMP} error;
11
void main(int argc, char** argv){
13
FILE *infile, *outfile;
15
unsigned short int dataMatrix[64][12];
16
unsigned short int buffer;
19
printf("Bmp2Z80 v1.0 by Peter Martijn Kuipers (central@hyperfield.com)\nUsage bmp2z80 inputfile outputfile\n\n");
20
printf("inputfile : A monochrome windows bitmap with dimensions 96 x 64\n");
21
printf("outputfile : the name of the file to write the .db codes to\n\n");
22
printf("Publised under the Gnu Public License\n");
26
if(( infile = fopen(argv[1], "r") ) == NULL){ //opening inputfile
27
printf("Error opening inputfile\n");
31
if(( outfile = fopen(argv[2], "w") ) == NULL){ //opening outputfile
32
printf("Error opening outputfile\n");
35
setmode(fileno(infile), O_BINARY); // set in and ouput to binary, so we won't get weird output
36
setmode(fileno(outfile), O_BINARY); //
38
for(i=0;i<=61;i++){ // read the bitmap header, and pick out the size
39
buffer = fgetc(infile); //
40
if((i == 0x12 && buffer != 0x60) || (i == 0x16 && buffer != 0x40)){
41
printf("The input bitmap has an incorrect format.\nThe correct format = 96 x 64 monochrome\n");
46
for(row=63;row>=0;row--){ //get all of the rows and columns, starting with the rows left under,
47
for(col=0;col<=11;col++){ //the columns are left to right and the rows bottom up in a bitmap
48
buffer = fgetc(infile); //
49
buffer = buffer ^ 255; //
50
dataMatrix[row][col] = buffer; //
55
fclose(infile); // ach ja, we hebben hem toch niet meer nodig
58
for(row=0;row<64;row++){ //place all of the .db statements, one per row
59
fprintf(outfile," .db $%X,$%X,$%X,$%X,$%X,$%X,$%X,$%X,$%X,$%X,$%X,$%X\n"
75
fclose(outfile); //we're done