X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fbakapi.c;h=7724507f7bb81d55f7bcbbb3d8c4d3bdc45a910b;hb=bbd8b6304d5203fcf3ec4aac96362b25ea5c6095;hp=1f7cd159c8bda4946527fb4716cd86ff6960a340;hpb=ae047ad3be09d38573b5cab895472e31ef7d47c7;p=16.git diff --git a/src/bakapi.c b/src/bakapi.c index 1f7cd159..7724507f 100755 --- a/src/bakapi.c +++ b/src/bakapi.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 * * This file is part of Project 16. * @@ -33,6 +33,27 @@ int ch=0x0; void main(int argc, char *argvar[]) { + // DOSLIB: check our environment + probe_dos(); + + // DOSLIB: what CPU are we using? + // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS. + // So this code by itself shouldn't care too much what CPU it's running on. Except that other + // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for + // the CPU to carry out tasks. --J.C. + cpu_probe(); + + // DOSLIB: check for VGA + if (!probe_vga()) { + printf("VGA probe failed\n"); + return; + } + // hardware must be VGA or higher! + if (!(vga_state.vga_flags & VGA_IS_VGA)) { + printf("This program requires VGA or higher graphics hardware\n"); + return; + } + // main variables values d=4; // switch variable key=2; // default screensaver number @@ -41,7 +62,12 @@ main(int argc, char *argvar[]) xdir=1; ydir=1; - VGAmodeX(1, &gvar); +#ifdef MXLIB + VGAmodeX(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. +#else +# 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. + // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C. +#endif bakapee.xx = rand()&0%gvar.video.page[0].width; bakapee.yy = rand()&0%gvar.video.page[0].height; bakapee.gq = 0; @@ -50,11 +76,12 @@ main(int argc, char *argvar[]) bakapee.bakax=0; bakapee.bakay=0; bakapee.coor=0; + bakapee.tile=0; /* setup camera and screen~ */ gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); - //gvar.video.page[0].width += (TILEWH*2); - //gvar.video.page[0].height += (TILEWH*2); + gvar.video.page[0].width += (TILEWH*2); + gvar.video.page[0].height += (TILEWH*2); textInit(); //modexPalUpdate(bmp.palette); //____ @@ -67,28 +94,73 @@ main(int argc, char *argvar[]) #ifdef BOINK while(d>0) // on! { - if(!kbhit()) - { // conditions of screen saver + /* run screensaver routine until keyboard input */ + while (key > 0) { + if (kbhit()) { + getch(); // eat keyboard input + break; + } + ding(&gvar.video.page[0], &bakapee, key); } - else + { + int c; + +# ifndef MXLIB +# 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. + // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C. +# else VGAmodeX(0, &gvar); - //modexLeave(); +# endif // user imput switch - printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n", getch()); // prompt the user - scanf("%d", &key); - //if(key==3){xx=yy=0;} // crazy screen saver wwww - if(key==0){ d=0; }else{ - gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); - gvar.video.page[0].width += (TILEWH*2); - gvar.video.page[0].height += (TILEWH*2); - VGAmodeX(1, &gvar); - modexShowPage(&gvar.video.page[0]); + fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile); + printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n"); + + c = getch(); + switch (c) { + case 27: /* Escape key */ + case '0': + d=0; + break; + case 'b': // test tile change + switch (bakapee.tile) + { + case 0: + bakapee.tile=1; + break; + case 1: + bakapee.tile=0; + break; + } + key=0; + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + key = c - '0'; +# ifdef MXLIB + gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); + gvar.video.page[0].width += (TILEWH*2); + gvar.video.page[0].height += (TILEWH*2); + VGAmodeX(1, &gvar); +# else +# 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. + // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C. +# endif + modexShowPage(&gvar.video.page[0]); + break; + default: + key=0; + break; } } } -#else +#else // !defined(BOINK) +// FIXME: Does not compile. Do you want to remove this? while(1) { // conditions of screen saver while(!kbhit()) @@ -162,7 +234,7 @@ main(int argc, char *argvar[]) if(ch==0x1b)break; // 'ESC' } // VGAmodeX(0, &gvar); -#endif +#endif // defined(BOINK) printf("bakapi ver. 1.04.13.04\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v3\n"); } //pee!