1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
4 * This file is part of Project 16.
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.
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.
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.
23 #include "src/bakapi.h"
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
35 main(int argc, char *argvar[])
42 // allow changing default mode from command line
47 do { a++; } while (*a == '-');
49 if (!strcmp(a,"mx")) {
50 // (based on src/lib/modex16.c)
56 vgamodex_mode = (sword)strtoul(argvar[i++],NULL,0);
59 fprintf(stderr,"Unknown switch %s\n",a);
64 fprintf(stderr,"Unknown command arg %s\n",a);
69 // DOSLIB: check our environment
72 // DOSLIB: what CPU are we using?
73 // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.
74 // So this code by itself shouldn't care too much what CPU it's running on. Except that other
75 // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for
76 // the CPU to carry out tasks. --J.C.
79 // DOSLIB: check for VGA
81 printf("VGA probe failed\n");
84 // hardware must be VGA or higher!
85 if (!(vga_state.vga_flags & VGA_IS_VGA)) {
86 printf("This program requires VGA or higher graphics hardware\n");
90 // main variables values
91 d=4; // switch variable
92 key=2; // default screensaver number
98 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.
99 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
100 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
102 bakapee.xx = rand()&0%gvar.video.page[0].width;
103 bakapee.yy = rand()&0%gvar.video.page[0].height;
112 /* setup camera and screen~ */
113 gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
114 gvar.video.page[0].width += (TILEWH*2);
115 gvar.video.page[0].height += (TILEWH*2);
118 //modexPalUpdate(bmp.palette); //____
119 //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
122 modexShowPage(&gvar.video.page[0]);
129 /* run screensaver routine until keyboard input */
134 getch(); // eat keyboard input
139 if(!panswitch) ding(&gvar.video.page[0], &bakapee, key);
140 else ding(&gvar.video.page[0], &bakapee, 2);
144 if((c==0x4d && pand == 0) || pand == 2)
146 if(pand == 0){ pand = 2; }
147 if(panq<=(TILEWH/(4)))
149 gvar.video.page[0].dx++;
150 modexShowPage(&gvar.video.page[0]);
152 } else { panq = 1; pand = 0; }
155 if((c==0x4b && pand == 0) || pand == 4)
157 if(pand == 0){ pand = 4; }
158 if(panq<=(TILEWH/(4)))
160 gvar.video.page[0].dx--;
161 modexShowPage(&gvar.video.page[0]);
163 } else { panq = 1; pand = 0; }
166 if((c==0x50 && pand == 0) || pand == 3)
168 if(pand == 0){ pand = 3; }
169 if(panq<=(TILEWH/(4)))
171 gvar.video.page[0].dy++;
172 modexShowPage(&gvar.video.page[0]);
174 } else { panq = 1; pand = 0; }
177 if((c==0x48 && pand == 0) || pand == 1)
179 if(pand == 0){ pand = 1; }
180 if(panq<=(TILEWH/(4)))
182 gvar.video.page[0].dy--;
183 modexShowPage(&gvar.video.page[0]);
185 } else { panq = 1; pand = 0; }
187 if(c==0x71 || c==0xb1 || c=='p')
189 //getch(); // eat keyboard input
191 break; // 'q' or 'ESC' or 'p'
198 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
199 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
200 VGAmodeX(0, 0, &gvar);
202 //fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
203 fprintf(stderr, "dx=%d dy=%d ", gvar.video.page[0].dx, gvar.video.page[0].dy);
204 printf("Tiled mode is ");
205 switch (bakapee.tile)
215 printf("Pan mode is ");
225 printf("Enter 1, 2, 3, 4, 5, 6, 8, or 9 to run a screensaver, or enter 0 to quit.\n");
229 case 27: /* Escape key */
233 case 'p': // test pan
245 case 'b': // test tile change
246 switch (bakapee.tile)
267 gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
268 gvar.video.page[0].width += (TILEWH*2);
269 gvar.video.page[0].height += (TILEWH*2);
270 VGAmodeX(vgamodex_mode, 0, &gvar);
271 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
272 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
273 modexShowPage(&gvar.video.page[0]);
281 #else // !defined(BOINK)
282 // FIXME: Does not compile. Do you want to remove this?
283 // TODO: This is a testing sextion for textrendering and panning for project 16 --sparky4
285 { // conditions of screen saver
288 // ding(&gvar.video.page[0], &bakapee, key);
290 //end of screen savers
291 //pdump(&gvar.video.page[0]);
293 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
294 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1");
295 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2");
296 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3");
297 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4");
298 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================");
300 ding(&gvar.video.page[0], &bakapee, key);
301 modexPanPage(&gvar.video.page[0], xpos, ypos);
306 // if( (xpos>(gvar.video.page[0].sw-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;}
307 // if( (ypos>(gvar.video.page[0].sh-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;}
309 if(ch==0x71)break; // 'q'
310 if(ch==0x1b)break; // 'ESC'
312 VGAmodeX(0, 1, &gvar);
313 #endif // defined(BOINK)
314 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");
315 printf("compiled on 2016/04/04\n");