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