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"]
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!
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
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;
#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())
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!
#include "src/lib/bakapee.h"
-#define BOINK
+#define BOINK // what does this mean? --J.C.
#endif /*__BAKAPI_H_*/
\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
{\r
boolean MousePresent;\r
boolean JoysPresent[MaxJoys];\r
-// boolean JoyPadPresent[MaxPads];\r
boolean Keyboard[NumCodes];\r
boolean Paused;\r
char LastASCII;\r
\r
KeyboardDef KbdDefs[MaxKbds];\r
JoystickDef JoyDefs[MaxJoys];\r
-// JoypadDef JoypadDefs[MaxPads];\r
} inpu;\r
\r
//extern inconfig inpu;\r
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
|| ((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
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
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
//#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
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
joyMultXL,joyMultYL,\r
joyMultXH,joyMultYH;\r
} JoystickDef;\r
-// typedef struct\r
-// {\r
-// boolean w;\r
-// } JoypadDef;\r
\r
typedef struct\r
{\r
{\r
boolean MousePresent;\r
boolean JoysPresent[MaxJoys];\r
- boolean JoyPadPresent[MaxPads];\r
boolean Keyboard[NumCodes];\r
boolean Paused;\r
char LastASCII;\r
\r
KeyboardDef KbdDefs[MaxKbds];\r
JoystickDef JoyDefs[MaxJoys];\r
- JoypadDef JoypadDefs[MaxPads];\r
} inpu;*/\r
\r
#ifdef DEMO0\r
\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