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[])
40 // allow changing default mode from command line
45 do { a++; } while (*a == '-');
47 if (!strcmp(a,"mx")) {
48 // (based on src/lib/modex16.c)
54 vgamodex_mode = (sword)strtoul(argvar[i++],NULL,0);
57 fprintf(stderr,"Unknown switch %s\n",a);
62 fprintf(stderr,"Unknown command arg %s\n",a);
67 // DOSLIB: check our environment
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.
77 // DOSLIB: check for VGA
79 printf("VGA probe failed\n");
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");
88 // main variables values
89 d=4; // switch variable
90 key=2; // default screensaver number
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.
100 bakapee.xx = rand()&0%gvar.video.page[0].width;
101 bakapee.yy = rand()&0%gvar.video.page[0].height;
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);
116 //modexPalUpdate(bmp.palette); //____
117 //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
120 modexShowPage(&gvar.video.page[0]);
126 /* run screensaver routine until keyboard input */
129 getch(); // eat keyboard input
133 ding(&gvar.video.page[0], &bakapee, key);
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);
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)
154 printf("Enter 1, 2, 3, 4, 5, 6, 8, or 9 to run a screensaver, or enter 0 to quit.\n");
158 case 27: /* Escape key */
162 case 'b': // test tile change
163 switch (bakapee.tile)
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]);
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
202 { // conditions of screen saver
205 ding(&gvar.video.page[0], &bakapee, key);
207 //end of screen savers
208 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
210 modexputPixel(&page, x, 0, 15);
211 mxPutPixel(x, gvar.video.page[0].height-1, 15);
213 for (int y = 0; y < VH; ++y)
215 mxPutPixel(0, y, 15);
216 mxPutPixel(gvar.video.page[0].width-1, y, 15);
218 for (int x = 0; x < VW; ++x)
220 mxPutPixel(x, 0, 15);
221 mxPutPixel(x, VH-1, 15);
223 for (int y = 240; y < VH; ++y)
225 mxPutPixel(0, y, 15);
226 mxPutPixel(VW-1, y, 15);
228 pdump(&gvar.video.page[0]);
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
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~
242 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
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++){
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);
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);
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
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);
270 if(ch==0x71)break; // 'q'
271 if(ch==0x1b)break; // 'ESC'
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);