X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fbakapi.c;h=60676d0866711888ded3c6432aab0e89758b5cd5;hb=6021fc3f27b895d382fbd30488ead35657e39196;hp=c1124f3b75983a126faa048adaba49f157da6bcb;hpb=1e3913850a672c67670874d48cc4b17421104569;p=16.git diff --git a/src/bakapi.c b/src/bakapi.c index c1124f3b..60676d08 100755 --- a/src/bakapi.c +++ b/src/bakapi.c @@ -1,186 +1,406 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 - * - * This file is part of Project 16. - * - * Project 16 is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Project 16 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You screen.heightould have received a copy of the GNU General Public License - * along with this program. If not, see , or - * write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include "src/bakapi.h" - -/* - * BAKAPEE! - */ -global_game_variables_t gvar; -static bakapee_t bakapee; -word key,d,xpos,ypos,xdir,ydir; -int ch=0x0; - -void -main(int argc, char *argvar[]) -{ - // main variables values - d=4; // switch variable - key=2; // default screensaver number - xpos=TILEWH*2; - ypos=TILEWH*2; - xdir=1; - ydir=1; - -#ifdef MXLIB - VGAmodeX(1, &gvar); -#else - mxSetMode(3); -#endif - bakapee.xx = rand()&0%gvar.video.page[0].width; - bakapee.yy = rand()&0%gvar.video.page[0].height; - bakapee.gq = 0; - bakapee.sx=0; - bakapee.sy=0; - 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); - textInit(); - - //modexPalUpdate(bmp.palette); //____ - //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____ - //getch(); //____ - - modexShowPage(&gvar.video.page[0]); - -// screen savers -#ifdef BOINK - while(d>0) // on! - { - if(!kbhit()) - { // conditions of screen saver - ding(&gvar.video.page[0], &bakapee, key); - } - else - { - #ifndef MXLIB - mxChangeMode(0); -#else - VGAmodeX(0, &gvar); -#endif - // user imput switch - fprintf(stderr, "xx=%d yy=%d\n", bakapee.xx, bakapee.yy); - 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(scanf("%d", &key) != 1) - { - printf("%d\n", key); - } - getch(); - //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); -#ifdef MXLIB - VGAmodeX(1, &gvar); -#else - mxChangeMode(3); -#endif - modexShowPage(&gvar.video.page[0]); - } - } - } -#else - while(1) - { // conditions of screen saver - while(!kbhit()) - { - ding(&gvar.video.page[0], &bakapee, key); - } - //end of screen savers - /*for(int x = 0; x < gvar.video.page[0].width; ++x) - { - modexputPixel(&page, x, 0, 15); - mxPutPixel(x, gvar.video.page[0].height-1, 15); - } - for (int y = 0; y < VH; ++y) - { - mxPutPixel(0, y, 15); - mxPutPixel(gvar.video.page[0].width-1, y, 15); - } - for (int x = 0; x < VW; ++x) - { - mxPutPixel(x, 0, 15); - mxPutPixel(x, VH-1, 15); - } - for (int y = 240; y < VH; ++y) - { - mxPutPixel(0, y, 15); - mxPutPixel(VW-1, y, 15); - }*/ - pdump(&gvar.video.page[0]); - getch(); - //text box - /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background - mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box - //+(QUADWH*6) - mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4"); - mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================"); - mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~ - getch(); - mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background - getch();++++*/ - while(!kbhit()) - { - //for(int i=0;i(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500); - //mxWaitRetrace(); -//mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos); -//++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2); -//xpos=ypos=TILEWH*2; - //????modexPanPage(&gvar.video.page[0], 32, 32); - //} - if( (xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;} - if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change - //}// direction! -//mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos); -//mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2); - } - ch=getch(); - if(ch==0x71)break; // 'q' - if(ch==0x1b)break; // 'ESC' - } -// VGAmodeX(0, &gvar); -#endif - printf("bakapi ver. 1.04.13.04\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v3\n"); -} -//pee! +/* Project 16 Source Code~ + * Copyright (C) 2012-2018 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You screen.heightould have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "src/bakapi.h" + +/* + * BAKAPEE! + */ +static bakapee_t bakapee; +word key,d,xpos,ypos,xdir,ydir; +sword vgamodex_mode = 1; // 1 = 320x240 with buffer +void TL_VidInit(global_game_variables_t *gvar){} +//int ch=0x0; + + +void +main(int argc, char *argvar[]) +{ + static global_game_variables_t gvar; + struct glob_game_vars *ggvv; + char *a; + int i,c; + word panq=1, pand=0,showding=0; + boolean panswitch=0,bptest=1,runding=1; + + ggvv=&gvar; + + // allow changing default mode from command line + for (i=1;i < argc;) { + a = argvar[i++]; + + if (*a == '-') { + do { a++; } while (*a == '-'); + + if (!strcmp(a,"mx")) { + // (based on src/lib/modex16.c) + // 1 = 320x240 + // 2 = 160x120 + // 3 = 320x200 + // 4 = 192x144 + // 5 = 256x192 + vgamodex_mode = (sword)strtoul(argvar[i++],NULL,0); + } + else { + fprintf(stderr,"Unknown switch %s\n",a); + return; + } + } + else { + fprintf(stderr,"Unknown command arg %s\n",a); + return; + } + } + + // initiate doslib // + TL_DosLibStartup(&gvar); + + // main variables values + d=4; // switch variable + key=2; // default screensaver number + xpos=TILEWHD; ypos=TILEWHD; xdir=1; ydir=1; + + 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. + // 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. + bakapee.xx = rand()&0%gvar.video.page[0].width; bakapee.yy = rand()&0%gvar.video.page[0].height; + bakapee.gq = 0; bakapee.sx=bakapee.sy=0; bakapee.bakax=bakapee.bakay=0; bakapee.coor=0; + //once where #defines + bakapee.tile=0; bakapee.bonk=400; bakapee.lgq=32; bakapee.hgq=55; + + switch(WCPU_detectcpu()) + { + case 0: + bakapee.tile=1; + break; + default: + bakapee.tile=0; + break; + } + + // setup camera and screen~ // + SETUPPAGEBAKAPI + + VL_ShowPage(&gvar.video.page[0], 1, 0); + BAKAPIINITFIZZTEST + + while (bptest) + { +/* if (key > 0) + {*/ + while (!kbhit() && runding) + { + //{ word w; for(w=0;w<(gvar.video.page[0].width*gvar.video.page[0].height);w++) {}} + ding(&gvar.video.page[showding], &bakapee, 4); + } + if (kbhit()) +// { + getch(); // eat keyboard input +// break; +// } +// }*/ + + { + + c = getch(); + switch (c) + { + case 27: // Escape key // + case '0': + default: + bptest = false; + break; + case 'b': // test tile change // + switch (bakapee.tile) + { + case 0: + bakapee.tile=1; + break; + case 1: + bakapee.tile=0; + break; + } + break; + case 'r': + runding = false; + BAKAPIINITFIZZTEST + break; + case 'e': + runding = 1; + break; + case 'z': + runding = false; + FIZZFADEFUN +// runding = true; + break; + case '3': + case '4': + runding = 1; + showding = c - '0' - 3; + break; + case '1': + case '2': + // case '5': + // case '6': + // case '9': + key = c - '0' - 1; + VL_ShowPage(&gvar.video.page[key], 1, 0); + break; + } + } + } + + +//while(!kbhit()){} + +// screen savers +//#ifdef BOINK + while(d>0) // on! + { + /* run screensaver routine until keyboard input */ + while (key > 0) { + if (kbhit()) { + if(!panswitch) + { + getch(); // eat keyboard input + break; + }else c=getch(); + } + + if(!panswitch){ + if(key==9) + { + ding(&gvar.video.page[1], &bakapee, 4); + ding(&gvar.video.page[0], &bakapee, 4); + FIZZFADEFUN + }else ding(&gvar.video.page[0], &bakapee, key); } + else ding(&gvar.video.page[0], &bakapee, 2); + if(panswitch!=0) + { + //right movement + if((c==0x4d && pand == 0) || pand == 2) + { + if(pand == 0){ pand = 2; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dx++; + VL_ShowPage(&gvar.video.page[0], 0, 0); + panq++; + } else { panq = 1; pand = 0; } + } + //left movement + if((c==0x4b && pand == 0) || pand == 4) + { + if(pand == 0){ pand = 4; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dx--; + VL_ShowPage(&gvar.video.page[0], 0, 0); + panq++; + } else { panq = 1; pand = 0; } + } + //down movement + if((c==0x50 && pand == 0) || pand == 3) + { + if(pand == 0){ pand = 3; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dy++; + VL_ShowPage(&gvar.video.page[0], 0, 0); + panq++; + } else { panq = 1; pand = 0; } + } + //up movement + if((c==0x48 && pand == 0) || pand == 1) + { + if(pand == 0){ pand = 1; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dy--; + VL_ShowPage(&gvar.video.page[0], 0, 0); + panq++; + } else { panq = 1; pand = 0; } + } + if((c==0x4d && pand == 0) || pand == 2) + { + if(pand == 0){ pand = 2; } + if(panq<=(TILEWH/(4))) + { + gvar.video.page[0].dx++; + VL_ShowPage(&gvar.video.page[0], 0, 0); + panq++; + } else { panq = 1; pand = 0; } + } + if(c==0x01+1) + { + VL_ShowPage(&gvar.video.page[0], 0, 0); + } + if(c==0x02+1) + { + VL_ShowPage(&gvar.video.page[1], 0, 0); + } + if(c==0x71 || c==0xb1 || c=='p') + { + //getch(); // eat keyboard input + panswitch=0; + break; // 'q' or 'ESC' or 'p' + } + } + } + + { + + // 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. + VGAmodeX(0, 0, &gvar); + clrscr(); //added to clear screen wwww + // user imput switch + //fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile); + //fprintf(stderr, "dx=%d dy=%d ", gvar.video.page[0].dx, gvar.video.page[0].dy); + printf("Tiled mode is "); + switch (bakapee.tile) + { + case 0: + printf("off. "); + break; + case 1: + printf("on. "); + break; + } + printf("Pan mode is "); + switch (panswitch) + { + case 0: + printf("off."); + break; + case 1: + printf("on."); + break; + } + printf("\n"); + printf("Incrementation of color happens at every %uth plot.\n", bakapee.bonk); + printf("Enter 1, 2, 3, 4, 5, 6, 8, or 9 to run a screensaver, or enter 0 to quit.\n"); +pee: + c = getch(); + switch (c) { + case 27: /* Escape key */ + case '0': + d=0; + break; + case 'p': // test pan + switch (panswitch) + { + case 0: + panswitch=1; + break; + case 1: + panswitch=0; + break; + } + key=0; + goto pee; + 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 '8': + c+=8; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '9': + key = c - '0'; + VGAmodeX(vgamodex_mode, 0, &gvar); + SETUPPAGEBAKAPI + // 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. + VL_ShowPage(&gvar.video.page[0], 0, 0); + break; + case '-': + if(bakapee.bonk>0) + bakapee.bonk-=100; + break; + case '=': + case '+': + if(bakapee.bonk<1000) + bakapee.bonk+=100; + break; + default: + key=0; + break; + } + } + } + clrscr(); //added to clear screen wwww +#if 0 +//#else // !defined(BOINK) +// FIXME: Does not compile. Do you want to remove this? +// INFO: This is a testing section for textrendering and panning for project 16 --sparky4 + while(1) + { // conditions of screen saver +// while(!kbhit()) +// { +// ding(&gvar.video.page[0], &bakapee, key); +// } + //end of screen savers + //pdump(&gvar.video.page[0]); + +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4"); +// mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================"); + + ding(&gvar.video.page[0], &bakapee, key); + modexPanPage(&gvar.video.page[0], xpos, ypos); + c = getch(); + +// xpos+=xdir; +// ypos+=ydir; +// if( (xpos>(gvar.video.page[0].sw-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;} +// if( (ypos>(gvar.video.page[0].sh-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} +// ch=getch(); + if(ch==0x71)break; // 'q' + if(ch==0x1b)break; // 'ESC' + } + VGAmodeX(0, 1, &gvar); +#endif // defined(BOINK) +// printf("page.width=%u ", gvar.video.page[0].width); printf("page.height=%u\n", gvar.video.page[0].height); + printf("bakapi ver. 1.04.16.04\nis made by sparky4i†ƒÖ…j feel free to use it ^^\nLicence: GPL v3\n"); + printf("compiled on 2016/04/04\n"); +// printf("[%u]%dx%d [%dx%d] %u %u %u\n[%u %u %u]", key, bakapee.bakax, bakapee.bakay, bakapee.xx, bakapee.yy, +//bakapee.coor, bakapee.tile, bakapee.gq, bakapee.bonk, bakapee.lgq, bakapee.hgq); +} +//pee!