]> 4ch.mooo.com Git - 16.git/blob - src/fonttes0.c
FONT IS RENDERABLE!!! to a degree...
[16.git] / src / fonttes0.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"
26 #include "lib/modex16.h"\r
27 \r
28 void main(int argc, char near *argv[])\r
29 {\r
30     int i, xp;\r
31     int j;\r
32         char l[16];\r
33     char c;\r
34     word s, o, t, w;\r
35     word addr = (word) l;
36     //byte *pal, *pal2, fond;
37         //bitmap_t fontdata;
38         page_t page;\r
39     textInit();\r
40 \r
41     //print the addresses of the fonts\r
42     printf("ROM FONT Addresses\n");\r
43     for(i=0; i<4; i++) {\r
44         printf("%d: %x:%x\n", i, romFonts[i].seg, romFonts[i].off);\r
45     }\r
46 \r
47         printf("*argv[1]=%d\n", *argv[1]);\r
48 \r
49     printf("Character: ");\r
50     scanf("%c", &c);\r
51 \r
52         if(*argv[1]!=1)\r
53         switch(*argv[1])\r
54         {\r
55                 case 48:\r
56                         t=0;\r
57                         w=14;\r
58                 break;\r
59                 case 49:\r
60                         t=1;\r
61                         w=8;\r
62                 break;\r
63                 case 50:\r
64                         t=2;\r
65                         w=8;\r
66                 break;\r
67                 case 51:\r
68                         t=3;\r
69                         w=16;\r
70                 break;\r
71                 default:\r
72                         t=3;\r
73                         w=16;\r
74                 break;\r
75         }\r
76         else\r
77         {\r
78                 t=3;\r
79                 w=16;   \r
80         }\r
81 \r
82 \r
83     s=romFonts[t].seg;\r
84     o=romFonts[t].off;\r
85 \r
86     //load the letter 'A'\r
87     __asm {\r
88                 MOV DI, addr\r
89                 MOV SI, o\r
90                 MOV ES, s\r
91                 SUB AH, AH\r
92                 MOV AL, c       ; the letter\r
93                 MOV CX, w\r
94                 MUL CX\r
95                 ADD SI, AX      ;the address of charcter\r
96         L1:     MOV AX, ES:SI\r
97                 MOV DS:DI, AX\r
98                 INC SI\r
99                 INC DI\r
100                 DEC CX\r
101                 JNZ L1\r
102     }
103
104     //load our palette\r
105     //modexLoadPalFile("data/default.pal", &pal2);
106
107         /*fontdata.width=8;
108         fontdata.height=w;
109         fontdata.palette=pal2;
110
111         fontdata.data=malloc(256);
112
113         for(i=0; i<w; i++)
114         {\r
115                 j=1<<8;\r
116                 while(j)
117                 {
118                         fond=(byte)l[i] & j ? '1':'0';
119                         fontdata.data=&(fond);
120                         printf("%02x ", *(fontdata.data));\r
121                         j>>=1;\r
122                 }
123                 printf("\n");\r
124         }
125
126         printf("\n\nok hit a key~\n");
127         while(!getch())\r
128         {\r
129                 //DrawPBuf(&page, 0, 0, p, 0);\r
130         }*/\r
131 \r
132     // save the palette\r
133     /*pal  = modexNewPal();\r
134     modexPalSave(pal);\r
135     modexFadeOff(4, pal);\r
136     modexPalBlack();\r
137 */\r
138     modexEnter();\r
139 /*    modexPalBlack();*/\r
140 \r
141     // set up the page, but with 16 pixels on all borders in offscreen mem\r
142     page=modexDefaultPage();\r
143     //page.width += 32;\r
144     //page.height += 32;
145         modexShowPage(&page);
146         modexClearRegion(&page, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 1);
147         // fade in\r
148         //modexFadeOn(4, pal2);
149
150         //render the letter in ascii art\r
151         for(i=0; i<w; i++)
152         {\r
153                 j=1<<8;
154                 xp=0;\r
155                 while(j)
156                 {
157                         //printf("j=%d\n", j);\r
158                         //printf("%c", l[i] & j ? '*':' ');
159                         //====printf("%02x ", l[i] & j);
160                         //printf("l[i]=%d       ", l[i]);
161                         //printf("j=%d  ", j);
162                         //printf("%02x\n", l[i] & j);
163                                 modexClearRegion(&page, xp, i*4, 4, 4, l[i] & j ? 15:0);
164 //while(!getch());
165                         xp+=4;
166                         j>>=1;
167                 }\r
168                 //====
169                 //printf("\n");
170         }
171         //modexDrawSprite(&page, 0, 0, &fontdata);
172         while(!getch())\r
173         {\r
174                 //DrawPBuf(&page, 0, 0, p, 0);\r
175         }
176
177         // fade back to text mode\r
178         /*modexFadeOff(4, pal2);\r
179         modexPalBlack();*/\r
180         modexLeave();\r
181         /*modexPalBlack();\r
182         modexFadeOn(4, pal);*/
183         //render the letter in ascii art\r
184         for(i=0; i<w; i++)
185         {\r
186                 j=1<<8;\r
187                 while(j)
188                 {
189                         printf("%c", l[i] & j ? '*':' ');
190                         //====printf("%02x ", l[i] & j);
191 //while(!getch());
192                 j>>=1;
193                 }\r
194                 printf("\n");
195         }
196         printf("\ni=%d\n", i);
197         printf("j=%d\n", j);
198
199 }\r