OSDN Git Service

font testing system is now compact!!
[proj16/16.git] / src / fonttest.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 #include <stdio.h>\r
23 #include <conio.h>\r
24 #include "lib/types.h"\r
25 #include "lib/16text.h"\r
26 \r
27 void main(int argc, char near *argv[])\r
28 {\r
29     int i;\r
30     int j;\r
31         char l[16];\r
32     char c;\r
33     word s, o, t, w;\r
34     word addr = (word) l;\r
35     textInit();\r
36 \r
37     //print the addresses of the fonts\r
38     printf("ROM FONT Addresses\n");\r
39     for(i=0; i<4; i++) {\r
40         printf("%d: %x:%x\n", i, romFonts[i].seg, romFonts[i].off);\r
41     }\r
42 \r
43         printf("*argv[1]=%d\n", *argv[1]);\r
44 \r
45     printf("Character: ");\r
46     scanf("%c", &c);\r
47 \r
48         if(*argv[1]!=1)\r
49         switch(*argv[1])\r
50         {\r
51                 case 48:\r
52                         t=0;\r
53                         w=14;\r
54                 break;\r
55                 case 49:\r
56                         t=1;\r
57                         w=8;\r
58                 break;\r
59                 case 50:\r
60                         t=2;\r
61                         w=8;\r
62                 break;\r
63                 case 51:\r
64                         t=3;\r
65                         w=16;\r
66                 break;\r
67                 default:\r
68                         t=3;\r
69                         w=16;\r
70                 break;\r
71         }\r
72         else\r
73         {\r
74                 t=3;\r
75                 w=16;   \r
76         }\r
77 \r
78 \r
79     s=romFonts[t].seg;\r
80     o=romFonts[t].off;\r
81 \r
82     //load the letter 'A'\r
83     __asm {\r
84                 MOV DI, addr\r
85                 MOV SI, o\r
86                 MOV ES, s\r
87                 SUB AH, AH\r
88                 MOV AL, c       ; the letter\r
89                 MOV CX, w\r
90                 MUL CX\r
91                 ADD SI, AX      ;the address of charcter\r
92         L1:     MOV AX, ES:SI\r
93                 MOV DS:DI, AX\r
94                 INC SI\r
95                 INC DI\r
96                 DEC CX\r
97                 JNZ L1\r
98     }\r
99 \r
100     //render the letter in ascii art\r
101     for(i=0; i<w; i++) {\r
102         j=1<<8;\r
103         while(j) {\r
104             printf("%c", l[i] & j ? '*':' ');\r
105             j>>=1;\r
106         }\r
107         printf("\n");\r
108     }\r
109 }\r