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
97 VGAmodeX(vgamodex_mode, &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 # error REMOVED // 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]);
128 /* run screensaver routine until keyboard input */
131 getch(); // eat keyboard input
135 ding(&gvar.video.page[0], &bakapee, key);
142 # error REMOVED // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
143 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
148 fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
149 printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n");
153 case 27: /* Escape key */
157 case 'b': // test tile change
158 switch (bakapee.tile)
177 gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
178 gvar.video.page[0].width += (TILEWH*2);
179 gvar.video.page[0].height += (TILEWH*2);
180 VGAmodeX(vgamodex_mode, &gvar);
182 # error REMOVED // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
183 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
185 modexShowPage(&gvar.video.page[0]);
193 #else // !defined(BOINK)
194 // FIXME: Does not compile. Do you want to remove this?
196 { // conditions of screen saver
199 ding(&gvar.video.page[0], &bakapee, key);
201 //end of screen savers
202 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
204 modexputPixel(&page, x, 0, 15);
205 mxPutPixel(x, gvar.video.page[0].height-1, 15);
207 for (int y = 0; y < VH; ++y)
209 mxPutPixel(0, y, 15);
210 mxPutPixel(gvar.video.page[0].width-1, y, 15);
212 for (int x = 0; x < VW; ++x)
214 mxPutPixel(x, 0, 15);
215 mxPutPixel(x, VH-1, 15);
217 for (int y = 240; y < VH; ++y)
219 mxPutPixel(0, y, 15);
220 mxPutPixel(VW-1, y, 15);
222 pdump(&gvar.video.page[0]);
225 /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background
226 mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box
228 mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
229 mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1");
230 mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2");
231 mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3");
232 mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4");
233 mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================");
234 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
236 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
240 //for(int i=0;i<TILEWH;i++){
241 ding(&gvar.video.page[0], &bakapee, key);
242 modexPanPage(&gvar.video.page[0], xpos, ypos);
243 //++++mxFillBox(384, 304, 384, 304, 10, OP_SET);
244 //mxBitBlt(xpos, ypos, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
245 //++++mxBitBlt(TILEWH*2, TILEWH*2, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
246 //for(word o = 0; o<TILEWH; o++){
249 //if(ypos==1 || (ypos==(BH-gvar.video.page[0].height-1)))delay(500);
250 //if((xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500);
252 //mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
253 //++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
254 //xpos=ypos=TILEWH*2;
255 //????modexPanPage(&gvar.video.page[0], 32, 32);
257 if( (xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;}
258 if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
260 //mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
261 //mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
264 if(ch==0x71)break; // 'q'
265 if(ch==0x1b)break; // 'ESC'
267 // VGAmodeX(0, &gvar);
268 #endif // defined(BOINK)
269 printf("bakapi ver. 1.04.13.04\nis made by sparky4
\81i
\81\86\83Ö
\81\85\81j feel free to use it ^^\nLicence: GPL v3\n");