From: Jonathan Campbell Date: Mon, 4 Apr 2016 06:47:21 +0000 (-0700) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=d71e4ebbd3770b48eee2b2cc18288b97aad4e1e4;hp=e214f9f13d153470d660793cb716d2fe377b97f2;p=16.git Merge remote-tracking branch 'upstream/master' --- diff --git a/git_con.fig b/git_con.fig index 265a082e..927bd4df 100755 --- a/git_con.fig +++ b/git_con.fig @@ -4,14 +4,11 @@ bare = false logallrefupdates = true [remote "origin"] - url = https://github.com/joncampbell123/16.git + url = https://github.com/sparky4/16 fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master -[remote "upstream"] - url = https://github.com/sparky4/16.git - fetch = +refs/heads/*:refs/remotes/upstream/* [submodule "src/lib/doslib"] url = https://github.com/joncampbell123/doslib.git [submodule "src/lib/jsmn"] diff --git a/makefile b/makefile index d77bf7c0..af0fa557 100755 --- a/makefile +++ b/makefile @@ -96,8 +96,8 @@ all: $(EXEC) joytest.exe 16.exe: 16.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) $(16LIBOBJS) gfx.lib wcl $(FLAGS) $(16FLAGS) 16.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) $(16LIBOBJS) gfx.lib -fm=16.map -bakapi.exe: bakapi.$(OBJ) gfx.lib# modex.lib - wcl $(FLAGS) $(BAKAPIFLAGS) bakapi.$(OBJ) gfx.lib -fm=bakapi.map +bakapi.exe: bakapi.$(OBJ) gfx.lib $(DOSLIBLIBS) + wcl $(FLAGS) $(BAKAPIFLAGS) bakapi.$(OBJ) gfx.lib $(DOSLIBLIBS) -fm=bakapi.map #modex.lib # #Test Executables! diff --git a/src/bakapi.c b/src/bakapi.c index eccaa355..1b839a21 100755 --- a/src/bakapi.c +++ b/src/bakapi.c @@ -28,11 +28,63 @@ global_game_variables_t gvar; static bakapee_t bakapee; word key,d,xpos,ypos,xdir,ydir; +sword vgamodex_mode = 1; // 320x240 default int ch=0x0; void main(int argc, char *argvar[]) { + char *a; + int i; + + // 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; + } + } + + // 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 @@ -42,9 +94,10 @@ main(int argc, char *argvar[]) ydir=1; #ifdef MXLIB - VGAmodeX(1, &gvar); + 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. #else - mxSetMode(3); +# 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; @@ -72,41 +125,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 + { - #ifndef MXLIB - mxChangeMode(0); -#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); -#endif +# 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]); + 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(vgamodex_mode, &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()) @@ -180,7 +265,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! diff --git a/src/bakapi.h b/src/bakapi.h index 635d3ee8..70b2f2ab 100755 --- a/src/bakapi.h +++ b/src/bakapi.h @@ -25,6 +25,6 @@ #include "src/lib/bakapee.h" -#define BOINK +#define BOINK // what does this mean? --J.C. #endif /*__BAKAPI_H_*/ diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 925eaeeb..66c98dd6 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -38,7 +38,7 @@ #include "src/lib/16_in.h" -byte testkeyin=0,testcontrolnoisy=0,testctrltype=0; +boolean testkeyin=0,testcontrolnoisy=0,testctrltype=0; /* ============================================================================= @@ -51,7 +51,6 @@ struct inconfig { boolean MousePresent; boolean JoysPresent[MaxJoys]; -// boolean JoyPadPresent[MaxPads]; boolean Keyboard[NumCodes]; boolean Paused; char LastASCII; @@ -59,7 +58,6 @@ struct inconfig KeyboardDef KbdDefs[MaxKbds]; JoystickDef JoyDefs[MaxJoys]; -// JoypadDef JoypadDefs[MaxPads]; } inpu; //extern inconfig inpu; @@ -380,6 +378,41 @@ static word lasttime; IN_GetJoyAbs(joy,&x,&y); def = inpu.JoyDefs + joy; + //TODO: inject p16 input controls! + //which is this + /* if(DIRECTIONIFELSE) + { + if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ + if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) + my = motion_Up; + if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) + my = motion_Down; + }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){ + if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) + mx = motion_Left; + if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left]))// || player[pn].pdir != 1) + mx = motion_Right; + }else + //if(mx+my!=1 && mx+my!=-1 && mx!=my!=0) + { //2 keys pressed + switch (player[pn].pdir) + { + case 0: + case 4: + if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) dir = DirTable[1]; + else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) dir = DirTable[3]; + break; + case 1: + case 3: + if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) dir = DirTable[0]; + else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) dir = DirTable[4]; + break; + default: + break; + } + if(testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } + }//else printf(" "); + }*/ if (x < def->threshMinX) { if (x < def->joyMinX) @@ -678,8 +711,6 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0]) || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) || ((nt == ctrl_Mouse) && !inpu.MousePresent) -// || ((nt == ctrl_Joypad1) && !inpu.JoyPadPresent[0]) -// || ((nt == ctrl_Joypad2) && !inpu.JoyPadPresent[1]) ) nt = ctrl_Keyboard1; inpu.KbdDefs[0].button0 = 0x1c; @@ -898,8 +929,6 @@ register KeyboardDef *def; buttons += 1 << 1; realdelta = false; break; -// case ctrl_Joypad1: -// case ctrl_Joypad2: case ctrl_Joystick1: case ctrl_Joystick2: INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false); @@ -939,7 +968,6 @@ register KeyboardDef *def; conpee=(((my + 1) * 2) + (mx + 1))-1; player[pn].info.dir = DirTable[conpee]; - //TODO: overwriting direction must be added if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee]; if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) { diff --git a/src/lib/16_in.h b/src/lib/16_in.h index 9b270585..0990a550 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -42,7 +42,7 @@ //#define TESTCONTROLNOISY #endif -extern byte testkeyin,testcontrolnoisy,testctrltype; +extern boolean testkeyin,testcontrolnoisy,testctrltype; //if else for gfxtesting and direction //player[pn].d == 2 || @@ -169,8 +169,6 @@ typedef enum { ctrl_Joystick, ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, ctrl_Mouse, -// ctrl_Joypad, -// ctrl_Joypad1 = ctrl_Joypad,ctrl_Joypad2 } ControlType; typedef enum { motion_Left = -1,motion_Up = -1, @@ -211,10 +209,6 @@ typedef struct { joyMultXL,joyMultYL, joyMultXH,joyMultYH; } JoystickDef; -// typedef struct -// { -// boolean w; -// } JoypadDef; typedef struct { @@ -252,7 +246,6 @@ typedef struct { boolean MousePresent; boolean JoysPresent[MaxJoys]; - boolean JoyPadPresent[MaxPads]; boolean Keyboard[NumCodes]; boolean Paused; char LastASCII; @@ -260,7 +253,6 @@ typedef struct KeyboardDef KbdDefs[MaxKbds]; JoystickDef JoyDefs[MaxJoys]; - JoypadDef JoypadDefs[MaxPads]; } inpu;*/ #ifdef DEMO0 diff --git a/src/lib/bakapee.h b/src/lib/bakapee.h index c7f35266..e06c0b8f 100755 --- a/src/lib/bakapee.h +++ b/src/lib/bakapee.h @@ -25,8 +25,11 @@ #include "src/lib/16_head.h" #include "src/lib/modex16.h" +#include +#include +#include //#include "src/lib/modex/modex.h" -#include "16/x/modex.h" +//#include "16/x/modex.h" #define TILEWH 16 #define QUADWH TILEWH/2