1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\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
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
16 * You screen.heightould 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
23 #include "src/bakapi.h"
\r
28 static bakapee_t bakapee;
\r
29 word key,d,xpos,ypos,xdir,ydir;
\r
30 sword vgamodex_mode = 1; // 1 = 320x240 with buffer
\r
31 void TL_VidInit(global_game_variables_t *gvar){}
\r
34 #define SETUPPAGEBAKAPI \
\r
35 gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0], &gvar.video); \
\r
36 gvar.video.page[1] = modexNextPage(&gvar.video.page[0]);
\r
40 main(int argc, char *argvar[])
\r
42 static global_game_variables_t gvar;
\r
43 struct glob_game_vars *ggvv;
\r
46 word panq=1, pand=0;
\r
47 boolean panswitch=0;
\r
52 // allow changing default mode from command line
\r
53 for (i=1;i < argc;) {
\r
57 do { a++; } while (*a == '-');
\r
59 if (!strcmp(a,"mx")) {
\r
60 // (based on src/lib/modex16.c)
\r
66 vgamodex_mode = (sword)strtoul(argvar[i++],NULL,0);
\r
69 fprintf(stderr,"Unknown switch %s\n",a);
\r
74 fprintf(stderr,"Unknown command arg %s\n",a);
\r
79 // DOSLIB: check our environment
\r
82 // DOSLIB: what CPU are we using?
\r
83 // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.
\r
84 // So this code by itself shouldn't care too much what CPU it's running on. Except that other
\r
85 // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for
\r
86 // the CPU to carry out tasks. --J.C.
\r
89 // DOSLIB: check for VGA
\r
91 printf("VGA probe failed\n");
\r
94 // hardware must be VGA or higher!
\r
95 if (!(vga_state.vga_flags & VGA_IS_VGA)) {
\r
96 printf("This program requires VGA or higher graphics hardware\n");
\r
101 // main variables values
\r
102 d=4; // switch variable
\r
103 key=2; // default screensaver number
\r
109 VGAmodeX(vgamodex_mode, 0, &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.
\r
110 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
\r
111 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
\r
113 bakapee.xx = rand()&0%gvar.video.page[0].width;
\r
114 bakapee.yy = rand()&0%gvar.video.page[0].height;
\r
116 bakapee.sx= bakapee.sy=0;
\r
117 bakapee.bakax= bakapee.bakay=0;
\r
120 //once where #defines
\r
126 switch(WCPU_detectcpu())
\r
136 /* setup camera and screen~ */
\r
139 //modexPalUpdate(bmp.palette); //____
\r
140 //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
\r
142 VL_SetLineWidth (40, &gvar);
\r
144 VL_ShowPage(&gvar.video.page[showpage], 0, 0);
\r
147 for(w=0;w<64000;w++)
\r
149 ding(&gvar.video.page[showpage], &bakapee, 4);
\r
150 ding(&gvar.video.page[1], &bakapee, 4);
\r
152 if(!baka_FizzleFade (gvar.video.ofs.bufferofs, gvar.video.ofs.displayofs, vga_state.vga_width, vga_state.vga_height, 70, true, &gvar))
\r
153 //ding(&gvar.video.page[showpage], &bakapee, 9);
\r
154 modexprint(&gvar.video.page[0], gvar.video.page[0].sw/2, gvar.video.page[0].sh/2, 1, 0, 47, 0, 1, "bakapi ok");
\r
163 /* run screensaver routine until keyboard input */
\r
168 getch(); // eat keyboard input
\r
173 if(!panswitch) ding(&gvar.video.page[0], &bakapee, key);
\r
174 else ding(&gvar.video.page[0], &bakapee, 2);
\r
178 if((c==0x4d && pand == 0) || pand == 2)
\r
180 if(pand == 0){ pand = 2; }
\r
181 if(panq<=(TILEWH/(4)))
\r
183 gvar.video.page[0].dx++;
\r
184 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
186 } else { panq = 1; pand = 0; }
\r
189 if((c==0x4b && pand == 0) || pand == 4)
\r
191 if(pand == 0){ pand = 4; }
\r
192 if(panq<=(TILEWH/(4)))
\r
194 gvar.video.page[0].dx--;
\r
195 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
197 } else { panq = 1; pand = 0; }
\r
200 if((c==0x50 && pand == 0) || pand == 3)
\r
202 if(pand == 0){ pand = 3; }
\r
203 if(panq<=(TILEWH/(4)))
\r
205 gvar.video.page[0].dy++;
\r
206 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
208 } else { panq = 1; pand = 0; }
\r
211 if((c==0x48 && pand == 0) || pand == 1)
\r
213 if(pand == 0){ pand = 1; }
\r
214 if(panq<=(TILEWH/(4)))
\r
216 gvar.video.page[0].dy--;
\r
217 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
219 } else { panq = 1; pand = 0; }
\r
221 if((c==0x4d && pand == 0) || pand == 2)
\r
223 if(pand == 0){ pand = 2; }
\r
224 if(panq<=(TILEWH/(4)))
\r
226 gvar.video.page[0].dx++;
\r
227 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
229 } else { panq = 1; pand = 0; }
\r
233 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
237 VL_ShowPage(&gvar.video.page[1], 0, 0);
\r
239 if(c==0x71 || c==0xb1 || c=='p')
\r
241 //getch(); // eat keyboard input
\r
243 break; // 'q' or 'ESC' or 'p'
\r
250 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
\r
251 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
\r
252 VGAmodeX(0, 0, &gvar);
\r
253 // user imput switch
\r
254 //fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
\r
255 //fprintf(stderr, "dx=%d dy=%d ", gvar.video.page[0].dx, gvar.video.page[0].dy);
\r
256 printf("Tiled mode is ");
\r
257 switch (bakapee.tile)
\r
266 printf("Pan mode is ");
\r
276 printf(" Showing page %u", showpage);
\r
278 printf("Incrementation of color happens at every %uth plot.\n", bakapee.bonk);
\r
279 printf("Enter 1, 2, 3, 4, 5, 6, 8, or 9 to run a screensaver, or enter 0 to quit.\n");
\r
283 case 27: /* Escape key */
\r
287 case 'p': // test pan
\r
299 case 'b': // test tile change
\r
300 switch (bakapee.tile)
\r
333 VGAmodeX(vgamodex_mode, 0, &gvar);
\r
334 VL_ShowPage(&gvar.video.page[showpage], 0, 0);
\r
336 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
\r
337 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
\r
338 VL_ShowPage(&gvar.video.page[showpage], 0, 0);
\r
346 if(bakapee.bonk<1000)
\r
353 clrscr(); //added to clear screen wwww
\r
357 //#else // !defined(BOINK)
\r
358 // FIXME: Does not compile. Do you want to remove this?
\r
359 // INFO: This is a testing section for textrendering and panning for project 16 --sparky4
\r
361 { // conditions of screen saver
\r
364 // ding(&gvar.video.page[0], &bakapee, key);
\r
366 //end of screen savers
\r
367 //pdump(&gvar.video.page[0]);
\r
369 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
\r
370 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1");
\r
371 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2");
\r
372 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3");
\r
373 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4");
\r
374 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================");
\r
376 ding(&gvar.video.page[0], &bakapee, key);
\r
377 modexPanPage(&gvar.video.page[0], xpos, ypos);
\r
382 // if( (xpos>(gvar.video.page[0].sw-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;}
\r
383 // if( (ypos>(gvar.video.page[0].sh-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;}
\r
385 if(ch==0x71)break; // 'q'
\r
386 if(ch==0x1b)break; // 'ESC'
\r
388 VGAmodeX(0, 1, &gvar);
\r
389 #endif // defined(BOINK)
\r
390 // printf("page.width=%u ", gvar.video.page[0].width); printf("page.height=%u\n", gvar.video.page[0].height);
\r
391 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");
\r
392 printf("compiled on 2016/04/04\n");
\r
393 // printf("[%u]%dx%d [%dx%d] %u %u %u\n[%u %u %u]", key, bakapee.bakax, bakapee.bakay, bakapee.xx, bakapee.yy,
\r
394 //bakapee.coor, bakapee.tile, bakapee.gq, bakapee.bonk, bakapee.lgq, bakapee.hgq);
\r