~ubuntu-branches/ubuntu/breezy/tiemu/breezy

« back to all changes in this revision

Viewing changes to src/hid/img/test/bmp2z80.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien BLACHE
  • Date: 2005-06-02 16:50:15 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050602165015-59ab24414tl2wzol
Tags: 1.99+svn1460-1
* New snapshot.
* debian/control:
  + Updated build-depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <stdlib.h>
3
 
#include <fcntl.h>
4
 
#include <io.h>
5
 
 
6
 
void main(int,char**);
7
 
 
8
 
//enum types {SYNTAX,FILEOPENIN,FILEOPENOUT,WRONGBMP} error;
9
 
 
10
 
 
11
 
void main(int argc, char** argv){
12
 
 
13
 
        FILE *infile, *outfile;
14
 
   int i,row,col;
15
 
   unsigned short int dataMatrix[64][12];
16
 
   unsigned short int buffer;
17
 
 
18
 
        if(argc < 3){
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");
23
 
      exit(1);
24
 
                }
25
 
 
26
 
   if(( infile = fopen(argv[1], "r") ) == NULL){  //opening inputfile
27
 
      printf("Error opening inputfile\n");
28
 
      exit(2);
29
 
                }
30
 
 
31
 
   if(( outfile = fopen(argv[2], "w") ) == NULL){ //opening outputfile
32
 
      printf("Error opening outputfile\n");
33
 
      exit(2);
34
 
                }
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);    //
37
 
 
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");
42
 
         exit(3);
43
 
         }
44
 
      }
45
 
 
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; //
51
 
         }
52
 
      }
53
 
 
54
 
 
55
 
   fclose(infile); // ach ja, we hebben hem toch niet meer nodig
56
 
 
57
 
 
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"
60
 
                ,dataMatrix[row][0]
61
 
                ,dataMatrix[row][1]
62
 
                ,dataMatrix[row][2]
63
 
            ,dataMatrix[row][3]
64
 
            ,dataMatrix[row][4]
65
 
            ,dataMatrix[row][5]
66
 
            ,dataMatrix[row][6]
67
 
            ,dataMatrix[row][7]
68
 
            ,dataMatrix[row][8]
69
 
            ,dataMatrix[row][9]
70
 
            ,dataMatrix[row][10]
71
 
            ,dataMatrix[row][11]
72
 
            );
73
 
      }
74
 
 
75
 
   fclose(outfile); //we're done
76
 
        exit(0);
77
 
        }