]> 4ch.mooo.com Git - 16.git/blob - src/fontgfx.c
don't use printf. use modexprint. explain why. fontgfx shows grid of
[16.git] / src / fontgfx.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123\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 #include <hw/cpu/cpu.h>\r
29 #include <hw/dos/dos.h>\r
30 #include <hw/vga/vga.h>\r
31 #include <hw/vga/vgatty.h>\r
32 \r
33 global_game_variables_t gvar;\r
34 \r
35 void main(int argc, char near *argv[])\r
36 {\r
37         struct vga_mode_params cm;\r
38         //JMOJI\r
39         static byte e;\r
40         //word ri;\r
41         byte pee[6]; // must be large enough for sprintf("%zc",...) and sprintf("%u",(byte value))\r
42         static byte ibmlogo[]="IIIIIII  BBBBBBBBB    MMMMM       MMMMM\n\\r
43 IIIIIII  BBBBBBBBBBB  MMMMMM     MMMMMM\n\\r
44   III     BBB    BBB   MMMMMM   MMMMMM\n\\r
45   III     BBBBBBBBB    MMMMMMM MMMMMMM\n\\r
46   III     BBBBBBBBB    MMM MMMMMMM MMM\n\\r
47   III     BBB    BBB   MMM  MMMMM  MMM\n\\r
48 IIIIIII  BBBBBBBBBBB  MMMM   MMM   MMMM\n\\r
49 IIIIIII  BBBBBBBBB    MMMM    M    MMMM\n\\r
50 ";\r
51         static byte rose[]="                                              :. ,..\n\\r
52                                             .' :~.':_.,\n\\r
53                                           .'   ::.::'.'\n\\r
54                                          :     ::'  .:\n\\r
55                                        `.:    .:  .:/\n\\r
56                                         `::--.:'.::'\n\\r
57                                           |. _:===-'\n\\r
58                                          / /\n\\r
59                         ,---.---.    __,','\n\\r
60                        (~`.  \   )   )','.,---..\n\\r
61                         `v`\ | ,' .-'.:,'_____   `.\n\\r
62                             )|/.-~.--~~--.   ~~~-. \ \n\\r
63                           _/-'_.-~        ""---.._`.|\n\\r
64                      _.-~~_.-~                    ""'\n\\r
65               _..--~~_.(~~\n\\r
66    __...---~~~_..--~~\n\\r
67 ,'___...---~~~\n\\r
68 ";\r
69 //      static byte *rosa;\r
70         static word chx, chy, colpee;\r
71         static word z;\r
72         textInit();\r
73 \r
74         // DOSLIB: check our environment\r
75         probe_dos();\r
76 \r
77         // DOSLIB: what CPU are we using?\r
78         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
79         //      So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
80         //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
81         //      the CPU to carry out tasks. --J.C.\r
82         cpu_probe();\r
83 \r
84         // DOSLIB: check for VGA\r
85         if (!probe_vga()) {\r
86                 printf("VGA probe failed\n");\r
87                 return;\r
88         }\r
89         // hardware must be VGA or higher!\r
90         if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
91                 printf("This program requires VGA or higher graphics hardware\n");\r
92                 return;\r
93         }\r
94         VGAmodeX(1, 1, &gvar);\r
95 //      __asm{\r
96 //              mov     AH,12H\r
97 //              mov     BL,30h\r
98 //              mov     AL,04h\r
99 //              int 10\r
100 //              mov     ax,1123h\r
101 //              int     10h\r
102 //              ;mov    ax,1112h                ; load 8x8 character set into RAM\r
103 //              ;int    10h\r
104 //      }\r
105         /* setup camera and screen~ */\r
106         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);\r
107         gvar.video.page[0].width += (16*2);\r
108         gvar.video.page[0].height += (16*2);\r
109         modexShowPage(&gvar.video.page[0]);\r
110         vga_read_crtc_mode(&cm);\r
111         // NTS: We're in Mode-X now. printf() is useless. Do not use printf(). Or INT 10h text printing. Or DOS console output.\r
112         //modexprint(16, 16, 1, 15, "wwww");\r
113         //getch();\r
114         chx=0;\r
115         chy=0;\r
116 //      colpee=32;\r
117 //      bios_cls();\r
118         /* position the cursor to home */\r
119 //      vga_moveto(0,0);\r
120 //      vga_sync_bios_cursor();\r
121         for(e=0x00, z=0; e<=0xFE; e++, z++)\r
122         {\r
123                 //if(chx+8>(gvar.video.page[0].width/2))\r
124                 if((z)+1>16)\r
125                 {\r
126                         chx=0;\r
127                         chy+=8;\r
128                         sprintf(pee,"%u", colpee);\r
129                         modexprint(&gvar.video.page[0], 200, 200, 1, 47, 0, &pee, 1);\r
130                         z=0;\r
131 //                      printf("\n");\r
132                         //getch();\r
133                 }\r
134                 sprintf(pee, "%zc", e);\r
135                 modexprint(&gvar.video.page[0], chx, chy, 1, 0, colpee, &e, 1);\r
136                 chx+=9;\r
137                 colpee++;\r
138 //              if(colpee>=32+24) colpee=32;\r
139         }\r
140         getch();\r
141         //modexprint(100, 100, 1, 47, 0, "wwww");\r
142 //      modexprint(0, 0, 1, 0, colpee, &rose);\r
143 //++++  modexprint(&gvar.video.page[0], 0, 0, 0, 0, colpee, &ibmlogo);\r
144 //      modexprintbig(&gvar.video.page[0], 0, 0, 1, colpee, 0, "IBM");\r
145 //      modexprint(0, 0, 1, 0, colpee, ROSE);\r
146 //++++  getch();\r
147         VGAmodeX(0, 1, &gvar);\r
148 //      rosa=malloc(sizeof(ROSE));\r
149 //      (*rosa)=(byte)ROSE;\r
150         printf("\n%s\n", rose);\r
151         //printf("\nh=%d\n", '8');\r
152 //      printf("\n%c\n", e);\r
153         printf("cm.offset=%d\n", cm.offset);\r
154         printf("vga_state.vga_stride=%d\n", vga_state.vga_stride);\r
155 }\r