OSDN Git Service

Added the start of the text system library.
[proj16/16.git] / src / FTEST.C
1 #include <stdio.h>\r
2 #include "lib/types.h"\r
3 #include "lib/text.h"\r
4 \r
5 main() {\r
6     int i;\r
7     int j;\r
8     char l[16];\r
9     char c;\r
10     word s, o;\r
11     word addr = (word) l;\r
12     textInit();\r
13 \r
14     //print the addresses of the fonts\r
15     printf("ROM FONT Addresses\n");\r
16     for(i=0; i<4; i++) {\r
17         printf("%d: %x:%x\n", i, romFonts[i].seg, romFonts[i].off);\r
18     }\r
19 \r
20     printf("Character: ");\r
21     scanf("%c", &c);\r
22 \r
23     s=romFonts[ROM_FONT_8x16].seg;\r
24     o=romFonts[ROM_FONT_8x16].off;\r
25 \r
26     //load the letter 'A'\r
27     __asm {\r
28                 MOV DI, addr\r
29                 MOV SI, o\r
30                 MOV ES, s\r
31                 SUB BH, BH\r
32                 MOV BL, c       ; the letter\r
33                 SHL BX, 1\r
34                 SHL BX, 1\r
35                 SHL BX, 1\r
36                 SHL BX, 1\r
37                 ADD SI, BX      ;the address of A\r
38                 MOV CX, 16\r
39         L1:     MOV AX, ES:SI\r
40                 MOV DS:DI, AX\r
41                 INC SI\r
42                 INC DI\r
43                 DEC CX\r
44                 JNZ L1\r
45     }\r
46 \r
47     //render the letter in ascii art\r
48     for(i=0; i<16; i++) {\r
49         j=1<<8;\r
50         while(j) {\r
51             printf("%c", l[i] & j ? '*':' ');\r
52             j>>=1;\r
53         }\r
54         printf("\n");\r
55     }\r
56 }\r