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
36 main(int argc, char *argvar[])
\r
38 static global_game_variables_t gvar;
\r
39 struct glob_game_vars *ggvv;
\r
42 word panq=1, pand=0,showding=0;
\r
43 boolean panswitch=0,bptest=1,runding=1;
\r
47 // allow changing default mode from command line
\r
48 for (i=1;i < argc;) {
\r
52 do { a++; } while (*a == '-');
\r
54 if (!strcmp(a,"mx")) {
\r
55 // (based on src/lib/modex16.c)
\r
61 vgamodex_mode = (sword)strtoul(argvar[i++],NULL,0);
\r
64 fprintf(stderr,"Unknown switch %s\n",a);
\r
69 fprintf(stderr,"Unknown command arg %s\n",a);
\r
74 // initiate doslib //
\r
75 TL_DosLibStartup(&gvar);
\r
77 // main variables values
\r
78 d=4; // switch variable
\r
79 key=2; // default screensaver number
\r
80 xpos=TILEWHD; ypos=TILEWHD; xdir=1; ydir=1;
\r
82 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
83 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
\r
84 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
\r
85 bakapee.xx = rand()&0%gvar.video.page[0].width; bakapee.yy = rand()&0%gvar.video.page[0].height;
\r
86 bakapee.gq = 0; bakapee.sx=bakapee.sy=0; bakapee.bakax=bakapee.bakay=0; bakapee.coor=0;
\r
87 //once where #defines
\r
88 bakapee.tile=0; bakapee.bonk=400; bakapee.lgq=32; bakapee.hgq=55;
\r
90 switch(WCPU_detectcpu())
\r
100 // setup camera and screen~ //
\r
103 VL_ShowPage(&gvar.video.page[0], 1, 0);
\r
110 while (!kbhit() && runding)
\r
112 //{ word w; for(w=0;w<(gvar.video.page[0].width*gvar.video.page[0].height);w++) {}}
\r
113 ding(&gvar.video.page[showding], &bakapee, 4);
\r
117 getch(); // eat keyboard input
\r
127 case 27: // Escape key //
\r
132 case 'b': // test tile change //
\r
133 switch (bakapee.tile)
\r
158 showding = c - '0' - 3;
\r
166 VL_ShowPage(&gvar.video.page[key], 1, 0);
\r
173 //while(!kbhit()){}
\r
179 /* run screensaver routine until keyboard input */
\r
184 getch(); // eat keyboard input
\r
192 ding(&gvar.video.page[1], &bakapee, 4);
\r
193 ding(&gvar.video.page[0], &bakapee, 4);
\r
195 }else ding(&gvar.video.page[0], &bakapee, key); }
\r
196 else ding(&gvar.video.page[0], &bakapee, 2);
\r
200 if((c==0x4d && pand == 0) || pand == 2)
\r
202 if(pand == 0){ pand = 2; }
\r
203 if(panq<=(TILEWH/(4)))
\r
205 gvar.video.page[0].dx++;
\r
206 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
208 } else { panq = 1; pand = 0; }
\r
211 if((c==0x4b && pand == 0) || pand == 4)
\r
213 if(pand == 0){ pand = 4; }
\r
214 if(panq<=(TILEWH/(4)))
\r
216 gvar.video.page[0].dx--;
\r
217 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
219 } else { panq = 1; pand = 0; }
\r
222 if((c==0x50 && pand == 0) || pand == 3)
\r
224 if(pand == 0){ pand = 3; }
\r
225 if(panq<=(TILEWH/(4)))
\r
227 gvar.video.page[0].dy++;
\r
228 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
230 } else { panq = 1; pand = 0; }
\r
233 if((c==0x48 && pand == 0) || pand == 1)
\r
235 if(pand == 0){ pand = 1; }
\r
236 if(panq<=(TILEWH/(4)))
\r
238 gvar.video.page[0].dy--;
\r
239 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
241 } else { panq = 1; pand = 0; }
\r
243 if((c==0x4d && pand == 0) || pand == 2)
\r
245 if(pand == 0){ pand = 2; }
\r
246 if(panq<=(TILEWH/(4)))
\r
248 gvar.video.page[0].dx++;
\r
249 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
251 } else { panq = 1; pand = 0; }
\r
255 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
259 VL_ShowPage(&gvar.video.page[1], 0, 0);
\r
261 if(c==0x71 || c==0xb1 || c=='p')
\r
263 //getch(); // eat keyboard input
\r
265 break; // 'q' or 'ESC' or 'p'
\r
272 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
\r
273 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
\r
274 VGAmodeX(0, 0, &gvar);
\r
275 clrscr(); //added to clear screen wwww
\r
276 // user imput switch
\r
277 //fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
\r
278 //fprintf(stderr, "dx=%d dy=%d ", gvar.video.page[0].dx, gvar.video.page[0].dy);
\r
279 printf("Tiled mode is ");
\r
280 switch (bakapee.tile)
\r
289 printf("Pan mode is ");
\r
300 printf("Incrementation of color happens at every %uth plot.\n", bakapee.bonk);
\r
301 printf("Enter 1, 2, 3, 4, 5, 6, 8, or 9 to run a screensaver, or enter 0 to quit.\n");
\r
305 case 27: /* Escape key */
\r
309 case 'p': // test pan
\r
322 case 'b': // test tile change
\r
323 switch (bakapee.tile)
\r
344 VGAmodeX(vgamodex_mode, 0, &gvar);
\r
346 // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
\r
347 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
\r
348 VL_ShowPage(&gvar.video.page[0], 0, 0);
\r
356 if(bakapee.bonk<1000)
\r
365 clrscr(); //added to clear screen wwww
\r
367 //#else // !defined(BOINK)
\r
368 // FIXME: Does not compile. Do you want to remove this?
\r
369 // INFO: This is a testing section for textrendering and panning for project 16 --sparky4
\r
371 { // conditions of screen saver
\r
374 // ding(&gvar.video.page[0], &bakapee, key);
\r
376 //end of screen savers
\r
377 //pdump(&gvar.video.page[0]);
\r
379 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
\r
380 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1");
\r
381 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2");
\r
382 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3");
\r
383 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4");
\r
384 // mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================");
\r
386 ding(&gvar.video.page[0], &bakapee, key);
\r
387 modexPanPage(&gvar.video.page[0], xpos, ypos);
\r
392 // if( (xpos>(gvar.video.page[0].sw-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;}
\r
393 // if( (ypos>(gvar.video.page[0].sh-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;}
\r
395 if(ch==0x71)break; // 'q'
\r
396 if(ch==0x1b)break; // 'ESC'
\r
398 VGAmodeX(0, 1, &gvar);
\r
399 #endif // defined(BOINK)
\r
400 // printf("page.width=%u ", gvar.video.page[0].width); printf("page.height=%u\n", gvar.video.page[0].height);
\r
401 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
402 printf("compiled on 2016/04/04\n");
\r
403 // printf("[%u]%dx%d [%dx%d] %u %u %u\n[%u %u %u]", key, bakapee.bakax, bakapee.bakay, bakapee.xx, bakapee.yy,
\r
404 //bakapee.coor, bakapee.tile, bakapee.gq, bakapee.bonk, bakapee.lgq, bakapee.hgq);
\r