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