]> 4ch.mooo.com Git - 16.git/blob - src/bakapi.c
=error= ww src/lib/modex16.h(86): Error! E1024: Declared symbol 'modexEnter' is not...
[16.git] / src / bakapi.c
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You screen.heightould have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22
23 #include "src/bakapi.h"
24
25 /*
26  * BAKAPEE!
27  */
28 global_game_variables_t gvar;
29 static bakapee_t bakapee;
30 word key,d,xpos,ypos,xdir,ydir;
31 sword vgamodex_mode = 1; // 320x240 default
32 int ch=0x0;
33
34 void
35 main(int argc, char *argvar[])
36 {
37         char *a;
38         int i;
39
40         // allow changing default mode from command line
41         for (i=1;i < argc;) {
42                 a = argvar[i++];
43
44                 if (*a == '-') {
45                         do { a++; } while (*a == '-');
46
47                         if (!strcmp(a,"mx")) {
48                                 // (based on src/lib/modex16.c)
49                                 // 1 = 320x240
50                                 // 2 = 160x120
51                                 // 3 = 320x200
52                                 // 4 = 192x144
53                                 // 5 = 256x192
54                                 vgamodex_mode = (sword)strtoul(argvar[i++],NULL,0);
55                         }
56                         else {
57                                 fprintf(stderr,"Unknown switch %s\n",a);
58                                 return;
59                         }
60                 }
61                 else {
62                         fprintf(stderr,"Unknown command arg %s\n",a);
63                         return;
64                 }
65         }
66
67         // DOSLIB: check our environment
68         probe_dos();
69
70         // DOSLIB: what CPU are we using?
71         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.
72         //      So this code by itself shouldn't care too much what CPU it's running on. Except that other
73         //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for
74         //      the CPU to carry out tasks. --J.C.
75         cpu_probe();
76
77         // DOSLIB: check for VGA
78         if (!probe_vga()) {
79                 printf("VGA probe failed\n");
80                 return;
81         }
82         // hardware must be VGA or higher!
83         if (!(vga_state.vga_flags & VGA_IS_VGA)) {
84                 printf("This program requires VGA or higher graphics hardware\n");
85                 return;
86         }
87
88         // main variables values
89         d=4; // switch variable
90         key=2; // default screensaver number
91         xpos=TILEWH*2;
92         ypos=TILEWH*2;
93         xdir=1;
94         ydir=1;
95
96         VGAmodeX(vgamodex_mode, 1, &gvar); // TODO: Suggestion: Instead of magic numbers for the first param, might I suggest defining an enum or some #define constants that are easier to remember? --J.C.
97                 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
98                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
99
100         bakapee.xx = rand()&0%gvar.video.page[0].width;
101         bakapee.yy = rand()&0%gvar.video.page[0].height;
102         bakapee.gq = 0;
103         bakapee.sx=0;
104         bakapee.sy=0;
105         bakapee.bakax=0;
106         bakapee.bakay=0;
107         bakapee.coor=0;
108         bakapee.tile=0;
109
110         /* setup camera and screen~ */
111         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
112         gvar.video.page[0].width += (TILEWH*2);
113         gvar.video.page[0].height += (TILEWH*2);
114         textInit();
115
116         //modexPalUpdate(bmp.palette); //____
117         //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
118         //getch(); //____
119
120         modexShowPage(&gvar.video.page[0]);
121
122 // screen savers
123 #ifdef BOINK
124         while(d>0)      // on!
125         {
126                 /* run screensaver routine until keyboard input */
127                 while (key > 0) {
128                         if (kbhit()) {
129                                 getch(); // eat keyboard input
130                                 break;
131                         }
132
133                         ding(&gvar.video.page[0], &bakapee, key);
134                 }
135
136                 {
137                         int c;
138
139                 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
140                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
141                         VGAmodeX(0, 0, &gvar);
142                         // user imput switch
143                         //fprintf(stderr, "xx=%d        yy=%d   tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
144                         printf("Tiled mode is ");
145                         switch (bakapee.tile)
146                         {
147                                 case 0:
148                                         printf("off.\n");
149                                 break;
150                                 case 1:
151                                         printf("on.\n");
152                                 break;
153                         }
154                         printf("Enter 1, 2, 3, 4, 5, 6, 8, or 9 to run a screensaver, or enter 0 to quit.\n");
155
156                         c = getch();
157                         switch (c) {
158                                 case 27: /* Escape key */
159                                 case '0':
160                                         d=0;
161                                         break;
162                                 case 'b': // test tile change
163                                         switch (bakapee.tile)
164                                         {
165                                                 case 0:
166                                                         bakapee.tile=1;
167                                                 break;
168                                                 case 1:
169                                                         bakapee.tile=0;
170                                                 break;
171                                         }
172                                         key=0;
173                                         break;
174                                 case '8':
175                                         c+=8;
176                                 case '1':
177                                 case '2':
178                                 case '3':
179                                 case '4':
180                                 case '5':
181                                 case '6':
182                                 case '9':
183                                         key = c - '0';
184                                         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
185                                         gvar.video.page[0].width += (TILEWH*2);
186                                         gvar.video.page[0].height += (TILEWH*2);
187                                         VGAmodeX(vgamodex_mode, 0, &gvar);
188                 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
189                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
190                                         modexShowPage(&gvar.video.page[0]);
191                                         break;
192                                 default:
193                                         key=0;
194                                         break;
195                         }
196                 }
197         }
198 #else // !defined(BOINK)
199 // FIXME: Does not compile. Do you want to remove this?
200 // TODO: This is a testing sextion for textrendering and panning for project 16 --sparky4
201         while(1)
202         { // conditions of screen saver
203                 while(!kbhit())
204                 {
205                         ding(&gvar.video.page[0], &bakapee, key);
206                 }
207                 //end of screen savers
208                 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
209                 {
210                         modexputPixel(&page, x, 0, 15);
211                         mxPutPixel(x, gvar.video.page[0].height-1, 15);
212                         }
213                 for (int y = 0; y < VH; ++y)
214                         {
215                                 mxPutPixel(0, y, 15);
216                                 mxPutPixel(gvar.video.page[0].width-1, y, 15);
217                         }
218                 for (int x = 0; x < VW; ++x)
219                         {
220                                 mxPutPixel(x, 0, 15);
221                                 mxPutPixel(x, VH-1, 15);
222                         }
223                 for (int y = 240; y < VH; ++y)
224                         {
225                                 mxPutPixel(0, y, 15);
226                                 mxPutPixel(VW-1, y, 15);
227                         }*/
228                 pdump(&gvar.video.page[0]);
229                 getch();
230                 //text box
231                 /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background
232                 mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box
233                 //+(QUADWH*6)
234                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
235                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "|    |Chikyuu:$line1");
236                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "|    |$line2");
237                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "|    |$line3");
238                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "|    |$line4");
239                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-8,  "========================================");
240                 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
241                 getch();
242                 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
243                 getch();++++*/
244                 while(!kbhit())
245                 {
246                         //for(int i=0;i<TILEWH;i++){
247                                 ding(&gvar.video.page[0], &bakapee, key);
248                                 modexPanPage(&gvar.video.page[0], xpos, ypos);
249 //++++mxFillBox(384, 304, 384, 304, 10, OP_SET);
250 //mxBitBlt(xpos, ypos, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
251 //++++mxBitBlt(TILEWH*2, TILEWH*2, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
252                                 //for(word o = 0; o<TILEWH; o++){
253                                         xpos+=xdir;
254                                         ypos+=ydir;
255                                         //if(ypos==1 || (ypos==(BH-gvar.video.page[0].height-1)))delay(500);
256                                         //if((xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500);
257                                         //mxWaitRetrace();
258 //mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
259 //++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
260 //xpos=ypos=TILEWH*2;
261                                         //????modexPanPage(&gvar.video.page[0], 32, 32);
262                                 //}
263                                 if( (xpos>(VW-gvar.video.page[0].width-1))  || (xpos<1)){xdir=-xdir;}
264                                 if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
265                         //}//    direction!
266 //mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
267 //mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
268                 }
269         ch=getch();
270         if(ch==0x71)break; // 'q'
271         if(ch==0x1b)break; // 'ESC'
272         }
273 //      VGAmodeX(0, &gvar);
274 #endif // defined(BOINK)
275         printf("bakapi ver. 1.04.16.04\nis made by sparky4\81i\81\86\83Ö\81\85\81j feel free to use it ^^\nLicence: GPL v3\n");
276         printf("compiled on %s\n", VERSION);
277 }
278 //pee!