]> 4ch.mooo.com Git - 16.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorJonathan Campbell <jonathan@castus.tv>
Mon, 4 Apr 2016 06:47:21 +0000 (23:47 -0700)
committerJonathan Campbell <jonathan@castus.tv>
Mon, 4 Apr 2016 06:47:21 +0000 (23:47 -0700)
git_con.fig
makefile
src/bakapi.c
src/bakapi.h
src/lib/16_in.c
src/lib/16_in.h
src/lib/bakapee.h

index 265a082eb4b294a4f49a46400f393ed6b8c7031f..927bd4df91ff632c75c4dc1200c5e0fb3ccc9d97 100755 (executable)
@@ -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"]
index d77bf7c0a0a808fd74ff512bad362f257337a5f1..af0fa557811f3eec1400bcff246403e5d9735e6e 100755 (executable)
--- 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!
index eccaa3550e504272bceff3ed9a11b4647e2f0ec5..1b839a21bb0d8b9c7c0aa5d43267746e928d0b15 100755 (executable)
 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\81i\81\86\83Ö\81\85\81j feel free to use it ^^\nLicence: GPL v3\n");
 }
 //pee!
index 635d3ee8ef2c291e0b28f1765033cc6b131b71f9..70b2f2aba7ecc3b12d49fe8813209439ad02cf4b 100755 (executable)
@@ -25,6 +25,6 @@
 
 #include "src/lib/bakapee.h"
 
-#define BOINK
+#define BOINK // what does this mean? --J.C.
 
 #endif /*__BAKAPI_H_*/
index 925eaeebd976ec8e27d02afd617d8d51c2f0fe96..66c98dd6936b55fa262243f7951c830bf3b5db67 100755 (executable)
@@ -38,7 +38,7 @@
 \r
 #include "src/lib/16_in.h"\r
 \r
-byte testkeyin=0,testcontrolnoisy=0,testctrltype=0;\r
+boolean testkeyin=0,testcontrolnoisy=0,testctrltype=0;\r
 \r
 /*\r
 =============================================================================\r
@@ -51,7 +51,6 @@ struct inconfig
 {\r
        boolean                 MousePresent;\r
        boolean                 JoysPresent[MaxJoys];\r
-//     boolean                 JoyPadPresent[MaxPads];\r
        boolean         Keyboard[NumCodes];\r
        boolean         Paused;\r
        char            LastASCII;\r
@@ -59,7 +58,6 @@ struct inconfig
 \r
        KeyboardDef     KbdDefs[MaxKbds];\r
        JoystickDef     JoyDefs[MaxJoys];\r
-//     JoypadDef       JoypadDefs[MaxPads];\r
 } inpu;\r
 \r
 //extern inconfig inpu;\r
@@ -380,6 +378,41 @@ static     word    lasttime;
        IN_GetJoyAbs(joy,&x,&y);\r
        def = inpu.JoyDefs + joy;\r
 \r
+       //TODO: inject p16 input controls!\r
+       //which is this\r
+       /*                      if(DIRECTIONIFELSE)\r
+                       {\r
+                       if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){\r
+                               if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]))\r
+                                       my = motion_Up;\r
+                               if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up]))\r
+                                       my = motion_Down;\r
+                       }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){\r
+                               if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]))\r
+                                       mx = motion_Left;\r
+                               if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left]))// || player[pn].pdir != 1)\r
+                                       mx = motion_Right;\r
+                       }else\r
+                               //if(mx+my!=1 && mx+my!=-1 && mx!=my!=0)\r
+                               {       //2 keys pressed\r
+                                       switch (player[pn].pdir)\r
+                                       {\r
+                                               case 0:\r
+                                               case 4:\r
+                                                       if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) dir = DirTable[1];\r
+                                                       else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) dir = DirTable[3];\r
+                                               break;\r
+                                               case 1:\r
+                                               case 3:\r
+                                                       if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) dir = DirTable[0];\r
+                                                       else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) dir = DirTable[4];\r
+                                               break;\r
+                                               default:\r
+                                               break;\r
+                                       }\r
+                                       if(testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c      ", dirchar(player[pn].pdir)); }\r
+                               }//else printf("                                ");\r
+                       }*/\r
        if (x < def->threshMinX)\r
        {\r
                if (x < def->joyMinX)\r
@@ -678,8 +711,6 @@ IN_Default(boolean gotit,player_t *player,ControlType nt)
        ||      ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0])\r
        ||      ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1])\r
        ||      ((nt == ctrl_Mouse) && !inpu.MousePresent)\r
-//     ||      ((nt == ctrl_Joypad1) && !inpu.JoyPadPresent[0])\r
-//     ||      ((nt == ctrl_Joypad2) && !inpu.JoyPadPresent[1])\r
        )\r
                nt = ctrl_Keyboard1;\r
        inpu.KbdDefs[0].button0 = 0x1c;\r
@@ -898,8 +929,6 @@ register    KeyboardDef     *def;
                                buttons += 1 << 1;\r
                        realdelta = false;\r
                        break;\r
-//             case ctrl_Joypad1:\r
-//             case ctrl_Joypad2:\r
                case ctrl_Joystick1:\r
                case ctrl_Joystick2:\r
                        INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false);\r
@@ -939,7 +968,6 @@ register    KeyboardDef     *def;
        conpee=(((my + 1) * 2) + (mx + 1))-1;\r
        player[pn].info.dir = DirTable[conpee];\r
 \r
-       //TODO: overwriting direction must be added\r
        if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee];\r
        if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None)))\r
        {\r
index 9b2705859385605f403125987974f19bf8c860ae..0990a55089d68ccdcf3b3cd786c7d0ab991e324c 100755 (executable)
@@ -42,7 +42,7 @@
 //#define TESTCONTROLNOISY\r
 #endif\r
 \r
-extern byte testkeyin,testcontrolnoisy,testctrltype;\r
+extern boolean testkeyin,testcontrolnoisy,testctrltype;\r
 \r
 //if else for gfxtesting and direction\r
 //player[pn].d == 2 ||\r
@@ -169,8 +169,6 @@ typedef     enum            {
                                                ctrl_Joystick,\r
                                                        ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
                                                ctrl_Mouse,\r
-//                                             ctrl_Joypad,\r
-//                                                     ctrl_Joypad1 = ctrl_Joypad,ctrl_Joypad2\r
                                        } ControlType;\r
 typedef        enum            {\r
                                                motion_Left = -1,motion_Up = -1,\r
@@ -211,10 +209,6 @@ typedef    struct          {
                                                                        joyMultXL,joyMultYL,\r
                                                                        joyMultXH,joyMultYH;\r
                                        } JoystickDef;\r
-// typedef     struct\r
-// {\r
-//     boolean w;\r
-// } JoypadDef;\r
 \r
 typedef        struct\r
 {\r
@@ -252,7 +246,6 @@ typedef     struct
 {\r
        boolean                 MousePresent;\r
        boolean                 JoysPresent[MaxJoys];\r
-       boolean                 JoyPadPresent[MaxPads];\r
        boolean         Keyboard[NumCodes];\r
        boolean         Paused;\r
        char            LastASCII;\r
@@ -260,7 +253,6 @@ typedef     struct
 \r
        KeyboardDef     KbdDefs[MaxKbds];\r
        JoystickDef     JoyDefs[MaxJoys];\r
-       JoypadDef       JoypadDefs[MaxPads];\r
 } inpu;*/\r
 \r
 #ifdef DEMO0\r
index c7f352661e9c06a7ddc72b0c40e4ea3b178c13ac..e06c0b8f51378b9b33dcf2a16dfc0ece7fa66bfa 100755 (executable)
 \r
 #include "src/lib/16_head.h"\r
 #include "src/lib/modex16.h"\r
+#include <hw/cpu/cpu.h>\r
+#include <hw/dos/dos.h>\r
+#include <hw/vga/vga.h>\r
 //#include "src/lib/modex/modex.h"\r
-#include "16/x/modex.h"\r
+//#include "16/x/modex.h"\r
 \r
 #define TILEWH 16\r
 #define QUADWH                 TILEWH/2\r