]> hackdaworld.org Git - my-code/arm.git/blob - betty/font2b.c
the interrupt routines
[my-code/arm.git] / betty / font2b.c
1 /*
2  * font2b.c - convert linux console 8x8 font data to betty lcd ram layout
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  * usage:
7  *
8  * first you have to adjust this file two times (see comments!)
9  * don't forget to rebuild.
10  * 
11  * ./font2b > default_font.h
12  *
13  * ONLY 8x8 FONTS SUPPORTED!
14  *
15  */
16
17 #define _GNU_SOURCE
18 #include <stdio.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include <fcntl.h>
22 #include <unistd.h>
23
24 // put your font data here!
25 #include "/usr/src/linux/drivers/video/console/font_pearl_8x8.c"
26
27 #define CHAR 1
28 #define BINARY 2
29
30 int main(int argc,char **argv) {
31
32         unsigned char *font_data;
33         int font,col,row;
34         unsigned char buf;
35         unsigned char stat;
36         int fd=0;
37
38         // adjust the font data pointer here!
39         font_data=(unsigned char *)fontdata_pearl8x8;
40
41         stat=CHAR;
42         if(argc==2) {
43                 fd=open(argv[1],O_WRONLY|O_CREAT);
44                 if(fd<0) {
45                         perror("file open");
46                         return fd;
47                 }
48                 stat=BINARY;
49         }
50
51         if(stat==CHAR)
52                 printf("const unsigned char default_font[%d]={\n",256*8);
53
54         for(font=0;font<=0xff;font++) {
55
56                 /* print the font number */
57                 if(stat==CHAR) {
58                         printf("\t/* %d 0x%02x",font,font);
59                         if((font>0x1f)&(font<0x7f))
60                                 printf(" %c */\n",font);
61                         else
62                                 printf(" */\n");
63                 }
64
65                 /* print the array content of the font */
66                 for(col=0;col<8;col++) {
67                         buf=0;
68                         for(row=0;row<8;row++)
69                                 buf|=(((font_data[font*8+row]>>(7-col))&1)<<row);
70                         if(stat==CHAR) {
71                                 if(col==0)
72                                         printf("\t");
73                                 printf("0x%02x",buf);
74                                 if((font!=0xff)|(col!=7))
75                                         printf(",");
76                         }
77                         else {
78                                 write(fd,&buf,1);
79                         }
80                 }
81                 if(stat==CHAR)
82                         printf("\n");
83         }
84
85         /* end */
86         if(stat==CHAR)
87                 printf("};\n");
88         else
89                 close(fd);
90
91         return 0;
92 }