From: sparky4 Date: Thu, 8 Dec 2016 19:53:33 +0000 (-0600) Subject: reverted input and stuff back... walk() is broken badly X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=658eba1768f70e0ce6cb01bb817709c1caf91834;p=16.git reverted input and stuff back... walk() is broken badly --- diff --git a/MEMINFO.16W b/MEMINFO.16W new file mode 100755 index 00000000..e69de29b diff --git a/SCROLL.16L b/SCROLL.16L new file mode 100755 index 00000000..5f541f38 --- /dev/null +++ b/SCROLL.16L @@ -0,0 +1,2 @@ +WARNING: Failed to initialize DEBUG output +chkmap ok pip[0].page->tilesw=22 pip[0].page->tw=20 diff --git a/src/0.c b/src/0.c index 4da93c71..e9dc876e 100755 --- a/src/0.c +++ b/src/0.c @@ -10,7 +10,7 @@ static unsigned char palette[768]; global_game_variables_t gvar; -player_t player[1]; +player_t player[MaxPlayers]; int main(int argc,char **argv) { struct vrl1_vgax_header *vrl_header; @@ -25,7 +25,7 @@ int main(int argc,char **argv) { IN_Startup(); IN_Default(0,&player,ctrl_Joystick); - IN_initplayer(&player);//, 0); + IN_initplayer(&player, 0); if (argc < 3) { fprintf(stderr,"drawvrl \n"); @@ -134,7 +134,7 @@ int main(int argc,char **argv) { while(!IN_KeyDown(sc_Escape)) { - IN_ReadControl(/*0,*/&player); + IN_ReadControl(0,&player); if(IN_KeyDown(2)) modexShowPage(&(gvar.video.page[0])); if(IN_KeyDown(3)) modexShowPage(&(gvar.video.page[1])); if(IN_KeyDown(68)) //f10 diff --git a/src/16.c b/src/16.c index b7850faa..6ad5334f 100755 --- a/src/16.c +++ b/src/16.c @@ -78,7 +78,7 @@ main(int argc, char *argv[]) start_timer(&gvar); while(ENGI_EXIT != engi_stat) { - IN_ReadControl(/*0,*/&player); + IN_ReadControl(0,&player); if(IN_KeyDown(sc_Escape)) engi_stat = ENGI_EXIT; shinku(&gvar); _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); diff --git a/src/inputest.c b/src/inputest.c index 52d36283..cd566a34 100755 --- a/src/inputest.c +++ b/src/inputest.c @@ -33,12 +33,14 @@ main(int argc, char *argv[]) //extern struct inconfig inpu; dbg_testkeyin=0; dbg_testcontrolnoisy=1; - dbg_noplayerinpu=1; + dbg_noplayerinpu=0; if(!dbg_noplayerinpu) { IN_Startup(); - IN_Default(0,&player,ctrl_Joystick1); - IN_SetControlType(/*0,*/&player,ctrl_Joystick1); + //IN_Default(0,&player,ctrl_Joystick1); + //IN_SetControlType(0,&player,ctrl_Joystick1); + IN_Default(0,&player,ctrl_Keyboard1); + IN_SetControlType(0,&player,ctrl_Keyboard1); } player[0].q=1; player[0].d=2; @@ -50,11 +52,11 @@ main(int argc, char *argv[]) booleantest(); //printf("nibble size is %u\n", sizeof(nibble)); if(!dbg_noplayerinpu){ - printf("dbg_testkeyin=%u dbg_testcontrolnoisy=%u dbg_noplayerinpu=%u\nloop if this is not responsive then please KILL or reset machine sorry!!\n", dbg_testkeyin, dbg_testcontrolnoisy, dbg_noplayerinpu); + //printf("dbg_testkeyin=%u dbg_testcontrolnoisy=%u dbg_noplayerinpu=%u\nloop if this is not responsive then please KILL or reset machine sorry!!\n", dbg_testkeyin, dbg_testcontrolnoisy, dbg_noplayerinpu); while(!IN_KeyDown(sc_Escape)) { shinkutxt(&gvar); - IN_ReadControl(/*0,*/&player); + IN_ReadControl(0, &player); #define INC_PER_FRAME if(player[0].q&1) player[0].persist_aniframe++; if(player[0].persist_aniframe>4) player[0].persist_aniframe = 1; switch(player[0].d) { diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 69324ee2..e5d2ec1b 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -506,7 +506,7 @@ INL_StartKbd() IN_ClearKeysDown(); OldKeyVect = _dos_getvect(KeyInt); - //_dos_setvect(KeyInt,INL_KeyService); + _dos_setvect(KeyInt,INL_KeyService); } /////////////////////////////////////////////////////////////////////////// @@ -682,7 +682,7 @@ IN_Startup() void IN_Default(boolean gotit,player_t *player,ControlType nt) { - //int i; + int i; if ( (!gotit) @@ -701,8 +701,9 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) //in.KbdDefs[0].downleft = 0x4f; inpu.KbdDefs[0].down = 0x50; //in.KbdDefs[0].downright = 0x51; - IN_SetControlType(player,nt); - player->d=2; + IN_SetControlType(0,player,nt); + for(i=0; i>MaxPlayers;i++) + player[i].d=2; } /////////////////////////////////////////////////////////////////////////// @@ -813,7 +814,7 @@ IN_ReadCursor(CursorInfo *info) // /////////////////////////////////////////////////////////////////////////// void near -IN_ReadControl(player_t *player) +IN_ReadControl(int pn,player_t *player) { boolean realdelta; #if DEMO0 @@ -853,7 +854,7 @@ register KeyboardDef *def; else { #endif - switch (type = player->Controls) + switch (type = player[pn].Controls) { case ctrl_Keyboard1: case ctrl_Keyboard2: @@ -868,7 +869,7 @@ register KeyboardDef *def; else if (Keyboard[def->downright]) mx = motion_Right,my = motion_Down;*/ //TODO: make this into a function that the joystick AND keyboard can use wwww - if(DIRECTIONIFELSE)//(player->info.dir == 2) + if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) { if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) @@ -881,7 +882,7 @@ register KeyboardDef *def; if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) mx = motion_Right; }else{ //2 keys pressed - switch (player->pdir) + switch (player[pn].pdir) { case 0: case 4: @@ -897,7 +898,7 @@ register KeyboardDef *def; break; } #ifdef __DEBUG_InputMgr__ - //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player->pdir)); } + //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } #endif } } @@ -935,23 +936,23 @@ register KeyboardDef *def; dy = my;// * 127; } - player->info.x = dx; - player->info.xaxis = mx; - player->info.y = dy; - player->info.yaxis = my; - player->info.button0 = buttons & (1 << 0); - player->info.button1 = buttons & (1 << 1); - player->info.button2 = buttons & (1 << 2); - player->info.button3 = buttons & (1 << 3); -// player->info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; + player[pn].info.x = dx; + player[pn].info.xaxis = mx; + player[pn].info.y = dy; + player[pn].info.yaxis = my; + player[pn].info.button0 = buttons & (1 << 0); + player[pn].info.button1 = buttons & (1 << 1); + player[pn].info.button2 = buttons & (1 << 2); + player[pn].info.button3 = buttons & (1 << 3); +// player[pn].info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; conpee=(((my + 1) * 2) + (mx + 1))-1; - player->info.dir = DirTable[conpee]; + player[pn].info.dir = DirTable[conpee]; - if(DirTable[conpee]!=2) player->pdir=DirTable[conpee]; - if(player->q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) + if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee]; + if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) { - if(dir==2) player->d = player->info.dir; - else player->d = DirTable[dir]; + if(dir==2) player[pn].d = player[pn].info.dir; + else player[pn].d = DirTable[dir]; } #if DEMO0 @@ -981,13 +982,13 @@ register KeyboardDef *def; #endif #ifdef __DEBUG_InputMgr__ if(dbg_testcontrolnoisy > 0) -if(player->info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player->q>1) +if(player[pn].info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player[pn].q>1) { - //printf("b1=%u b2=%u b3=%u b4=%u ", player->info.button0, player->info.button1, player->info.button2, player->info.button3); - //printf("q=%d ", player->q); + //printf("b1=%u b2=%u b3=%u b4=%u ", player[pn].info.button0, player[pn].info.button1, player[pn].info.button2, player[pn].info.button3); + //printf("q=%d ", player[pn].q); //printf("cpee=%c ", dirchar(conpee)); - printf("pdir=%c d=%c dir=%c ", dirchar(player->pdir), dirchar(player->d), dirchar(player->info.dir)); - /*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player->info.x, player->info.y, player->info.xaxis, player->info.yaxis); + printf("pdir=%c d=%c dir=%c ", dirchar(player[pn].pdir), dirchar(player[pn].d), dirchar(player[pn].info.dir)); + /*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player[pn].info.x, player[pn].info.y, player[pn].info.xaxis, player[pn].info.yaxis); //else if(!realdelta) printf("%c%d %c%d %c%d %c%d", dirchar(0), inpu.Keyboard[def->up], dirchar(4), inpu.Keyboard[def->down], dirchar(1), inpu.Keyboard[def->left], dirchar(3), inpu.Keyboard[def->right]); printf("\n"); } @@ -1001,10 +1002,10 @@ if(player->info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || i // /////////////////////////////////////////////////////////////////////////// void -IN_SetControlType(player_t *player,ControlType type) +IN_SetControlType(word pn,player_t *player,ControlType type) { // DEBUG - check that requested type is present? - player->Controls = type; + player[pn].Controls = type; } #if DEMO0 @@ -1266,16 +1267,20 @@ boolean IN_qb(byte kee) } //init player! -void IN_initplayer(player_t *player) +void IN_initplayer(player_t *player, word pn) { - player->x = player->tx*TILEWH; - player->y = player->ty*TILEWH; - player->triggerx = player->tx; - player->triggery = player->ty+1; - player->q=1; - player->d=2; - player->hp=4; - player->speed=4; - player->persist_aniframe=0; - player->spt=(TILEWH/(player->speed)); //speed per tile wwww + player[pn].x = player[pn].tx*TILEWH; + player[pn].y = player[pn].ty*TILEWH; + player[pn].triggerx = player[pn].tx; + player[pn].triggery = player[pn].ty+1; +/* player[0].info.x = player[0].tx; + player[0].info.xaxis = player[0].tx*TILEWH; + player[0].info.y = player[0].ty; + player[0].info.yaxis = player[0].ty*TILEWH;*/ + player[pn].q=1; + player[pn].d=2; + player[pn].hp=4; + player[pn].speed=4; + player[pn].persist_aniframe=0; + player[pn].spt=(TILEWH/(player[pn].speed)); //speed per tile wwww } diff --git a/src/lib/16_in.h b/src/lib/16_in.h index 4b0030cd..9e4bfc2e 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -40,8 +40,8 @@ //if else for gfxtesting and direction //player[pn].d == 2 || //player[pn].d != 2 || -#define DIRECTIONIFELSE (player->info.dir == 2)//(player[pn].info.dir == 2) -//#define NDIRECTIONIFELSE (player->info.dir != 2)//(player[pn].info.dir != 2) +#define DIRECTIONIFELSE (player[pn].info.dir == 2) +//#define NDIRECTIONIFELSE (player[pn].info.dir != 2) #define KeyInt 9 // The keyboard ISR number @@ -50,7 +50,7 @@ #define JoyScaleShift 8 #define MaxJoyValue 5000 -#define MaxPlayers 1 +#define MaxPlayers 2//futre plans for multiple playable charaters and being able to alternate #define MaxKbds 2 #define MaxJoys 2 #define MaxPads 2 @@ -232,7 +232,7 @@ typedef struct int persist_aniframe; /* gonna be increased to 1 before being used, so 0 is ok for default */ CursorInfo info; ControlType Controls; - int dx, dy, delta; + int dx, dy, delta; //TODO: what is this? ^^ } player_t; /* @@ -285,8 +285,8 @@ extern void IN_SetKeyHook(void (*hook)()); extern void IN_ClearKeysDown(); //static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); extern void IN_ReadCursor(CursorInfo *info); -extern void near IN_ReadControl(player_t *player); -extern void IN_SetControlType(player_t *player,ControlType type); +extern void near IN_ReadControl(int pn,player_t *player); +extern void IN_SetControlType(word pn,player_t *player,ControlType type); #if DEMO0 extern boolean IN_StartDemoRecord(word bufsize); extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); @@ -303,6 +303,6 @@ extern boolean IN_UserInput(dword delay,boolean clear); extern boolean IN_KeyDown(byte code); extern void IN_ClearKey(byte code); extern boolean IN_qb(byte kee); -void IN_initplayer(player_t *player); +void IN_initplayer(player_t *player, word pn); #endif diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 137b0bfb..2ea3f9fe 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -65,9 +65,10 @@ typedef struct { } planar_buf_t; typedef struct { - int dx, dy; //backwards compait - nibble id; /* the Identification number of the page~ For layering~ */ + /*nibble*/word id; /* the Identification number of the page~ For layering~ */ byte far* data; /* the data for the page */ + word dx; /* col we are viewing on the virtual screen */ + word dy; /* row we are viewing on the virtual screen */ word sw; /* screen width */ word sh; /* screen heigth */ word tw; /* screen width in tiles */ diff --git a/src/lib/_6_in.c b/src/lib/_6_in.c deleted file mode 100755 index 72dcadf5..00000000 --- a/src/lib/_6_in.c +++ /dev/null @@ -1,1290 +0,0 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -// -// ID Engine -// ID_IN.c - Input Manager -// v1.0d1w -// By Jason Blochowiak -// Open Watcom port by sparky4 -// - -// -// This module handles dealing with the various input devices -// -// Depends on: Memory Mgr (for demo recording), Sound Mgr (for timing stuff), -// User Mgr (for command line parms) -// -// Globals: -// LastScan - The keyboard scan code of the last key pressed -// LastASCII - The ASCII value of the last key pressed -// DEBUG - there are more globals -// - -#include "src/lib/16_in.h" - -#ifdef __DEBUG_InputMgr__ -boolean dbg_testkeyin=0,dbg_testcontrolnoisy=0; -#endif - -static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ - -/* -============================================================================= - - GLOBAL VARIABLES - -============================================================================= -*/ -struct inconfig -{ - boolean MousePresent; - boolean JoysPresent[MaxJoys]; - boolean Keyboard[NumCodes]; - boolean Paused; - char LastASCII; - ScanCode LastScan; - - KeyboardDef KbdDefs[MaxKbds]; - JoystickDef JoyDefs[MaxJoys]; -} inpu; - -//extern inconfig inpu; -//inpu.KbdDefs = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/}; - -/* -============================================================================= - - LOCAL VARIABLES - -============================================================================= -*/ - -#ifdef __cplusplus /* Function must be declared C style */ -extern "C" { -#endif - -static struct instat { - boolean IN_Started; - boolean CapsLock; - ScanCode CurCode,LastCode; -} inst; - -static void (*INL_KeyHook)(void); -static void interrupt (*OldKeyVect)(void); -static char *ParmStringsIN[] = {"nojoys","nomouse",nil}; - -static byte far ASCIINames[] = // Unshifted ASCII for scan codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0 - 'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1 - 'd','f','g','h','j','k','l',';',39 ,'`',0 ,92 ,'z','x','c','v', // 2 - 'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4 - '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - far ShiftNames[] = // Shifted ASCII for scan codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0 - 'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0 ,'A','S', // 1 - 'D','F','G','H','J','K','L',':',34 ,'~',0 ,'|','Z','X','C','V', // 2 - 'B','N','M','<','>','?',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4 - '2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - far SpecialNames[] = // ASCII for 0xe0 prefixed codes - { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2 - 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6 - 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7 - }, - *ScanNames[] = // Scan code names with single chars - { - "?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?", - "Q","W","E","R","T","Y","U","I","O","P","[","]","|","?","A","S", - "D","F","G","H","J","K","L",";","\"","?","?","?","Z","X","C","V", - "B","N","M",",",".","/","?","?","?","?","?","?","?","?","?","?", - "?","?","?","?","?","?","?","?","\xf","?","-","\x15","5","\x11","+","?", - "\x13","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?", - "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?", - "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?" - }, // DEBUG - consolidate these - far ExtScanCodes[] = // Scan codes with >1 char names - { - 1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e, - 0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36, - 0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48, - 0x50,0x4b,0x4d,0x00 - }, - *ExtScanNames[] = // Names corresponding to ExtScanCodes - { - "Esc","BkSp","Tab","Ctrl","LShft","Space","CapsLk","F1","F2","F3","F4", - "F5","F6","F7","F8","F9","F10","F11","F12","ScrlLk","Enter","RShft", - "PrtSc","Alt","Home","PgUp","End","PgDn","Ins","Del","NumLk","Up", - "Down","Left","Right","" - }; - -static Direction DirTable[] = // Quick lookup for total direction - { - //dir_Nortinest, - dir_North, - dir_West, - dir_None, - dir_East, - dir_South - //dir_NorthEast, - //dir_Soutinest, - //,dir_SouthEast - }; -#ifdef __cplusplus -} -#endif - -// Internal routines - -/////////////////////////////////////////////////////////////////////////// -// -// INL_KeyService() - Handles a keyboard interrupt (key up/down) -// -/////////////////////////////////////////////////////////////////////////// -void interrupt -INL_KeyService() -{ -static boolean special; - byte k,c; - register byte temp; - - k = inp(0x60); // Get the scan code - - // Tell the XT keyboard controller to clear the key - outp(0x61,(temp = inp(0x61)) | 0x80); - outp(0x61,temp); - - if (k == 0xe0) // Special key prefix - special = true; - else if (k == 0xe1) // Handle Pause key - inpu.Paused = true; - else - { - if (k & 0x80) // Break code - { - k &= 0x7f; - -// DEBUG - handle special keys: ctl-alt-delete, print scrn - - inpu.Keyboard[k] = false; - } - else // Make code - { - inst.LastCode = inst.CurCode; - inst.CurCode = inpu.LastScan = k; - inpu.Keyboard[k] = true; - - if (special) - c = SpecialNames[k]; - else - { - if (k == sc_CapsLock) - { - inst.CapsLock ^= true; - // DEBUG - make caps lock light work - } - - if (inpu.Keyboard[sc_LShift] || inpu.Keyboard[sc_RShift]) // If shifted - { - c = ShiftNames[k]; - if ((c >= 'A') && (c <= 'Z') && inst.CapsLock) - c += 'a' - 'A'; - } - else - { - c = ASCIINames[k]; - if ((c >= 'a') && (c <= 'z') && inst.CapsLock) - c -= 'a' - 'A'; - } - } - if (c) - inpu.LastASCII = c; - } - - special = false; - } - - if (INL_KeyHook && !special) - INL_KeyHook(); -#ifdef __DEBUG_InputMgr__ - if(dbg_testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inpu.Keyboard[k]); -#endif - outp(0x20,0x20); -} - -void -Mouse(int x) -{ - //union REGS CPURegs; - //x = CPURegs.x.ax; - __asm { - mov ax,x - int MouseInt - } - //int86(MouseInt,&CPURegs,&CPURegs); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the -// mouse driver -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_GetMouseDelta(int *x,int *y) -{ - union REGS CPURegs; - Mouse(MDelta); - *x = CPURegs.x.cx; - *y = CPURegs.x.dx; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetMouseButtons() - Gets the status of the mouse buttons from the -// mouse driver -// -/////////////////////////////////////////////////////////////////////////// -static word -INL_GetMouseButtons(void) -{ - union REGS CPURegs; - word buttons; - - Mouse(MButtons); - buttons = CPURegs.x.bx; - return(buttons); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetJoyAbs() - Reads the absolute position of the specified joystick -// -/////////////////////////////////////////////////////////////////////////// -void -IN_GetJoyAbs(word joy,word *xp,word *yp) -{ - byte xb,yb, - xs,ys; - word x,y; - - x = y = 0; - xs = joy? 2 : 0; // Find shift value for x axis - xb = 1 << xs; // Use shift value to get x bit mask - ys = joy? 3 : 1; // Do the same for y axis - yb = 1 << ys; - -// Read the absolute joystick values - __asm { - pushf // Save some registers - push si - push di - cli // Make sure an interrupt doesn't screw the timings - - - mov dx,0x201 - in al,dx - out dx,al // Clear the resistors - - mov ah,[xb] // Get masks into registers - mov ch,[yb] - - xor si,si // Clear count registers - xor di,di - xor bh,bh // Clear high byte of bx for later - - push bp // Don't mess up stack frame - mov bp,MaxJoyValue -#ifdef __BORLANDC__ - } -#endif -loo: -#ifdef __BORLANDC__ - __asm { -#endif - in al,dx // Get bits indicating whether all are finished - - dec bp // Check bounding register - jz done // We have a silly value - abort - - mov bl,al // Duplicate the bits - and bl,ah // Mask off useless bits (in [xb]) - add si,bx // Possibly increment count register - mov cl,bl // Save for testing later - - mov bl,al - and bl,ch // [yb] - add di,bx - - add cl,bl - jnz loo // If both bits were 0, drop out -#ifdef __BORLANDC__ - } -#endif -done: -#ifdef __BORLANDC__ - __asm { -#endif - pop bp - - mov cl,[xs] // Get the number of bits to shift - shr si,cl // and shift the count that many times - - mov cl,[ys] - shr di,cl - - mov [x],si // Store the values into the variables - mov [y],di - - pop di - pop si - popf // Restore the registers - } - - *xp = x; - *yp = y; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetJoyDelta() - Returns the relative movement of the specified -// joystick (from +/-127, scaled adaptively) -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive) -{ - word x,y; - word time; - word TimeCount = *clockw; - JoystickDef *def; -static word lasttime; - - IN_GetJoyAbs(joy,&x,&y); - def = inpu.JoyDefs + joy; - - if (x < def->threshMinX) - { - if (x < def->joyMinX) - x = def->joyMinX; - - x = -(x - def->threshMinX); - x *= def->joyMultXL; - x >>= JoyScaleShift; - *dx = (x > 127)? -127 : -x; - } - else if (x > def->threshMaxX) - { - if (x > def->joyMaxX) - x = def->joyMaxX; - - x = x - def->threshMaxX; - x *= def->joyMultXH; - x >>= JoyScaleShift; - *dx = (x > 127)? 127 : x; - } - else - *dx = 0; - - if (y < def->threshMinY) - { - if (y < def->joyMinY) - y = def->joyMinY; - - y = -(y - def->threshMinY); - y *= def->joyMultYL; - y >>= JoyScaleShift; - *dy = (y > 127)? -127 : -y; - } - else if (y > def->threshMaxY) - { - if (y > def->joyMaxY) - y = def->joyMaxY; - - y = y - def->threshMaxY; - y *= def->joyMultYH; - y >>= JoyScaleShift; - *dy = (y > 127)? 127 : y; - } - else - *dy = 0; - - if (adaptive) - { - time = (TimeCount - lasttime) / 2; - if (time) - { - if (time > 8) - time = 8; - *dx *= time; - *dy *= time; - } - } - lasttime = TimeCount; -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_GetJoyButtons() - Returns the button status of the specified -// joystick -// -/////////////////////////////////////////////////////////////////////////// -static word -INL_GetJoyButtons(word joy) -{ -register word result; - - result = inp(0x201); // Get all the joystick buttons - result >>= joy? 6 : 4; // Shift into bits 0-1 - result &= 3; // Mask off the useless bits - result ^= 3; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetJoyButtonsDB() - Returns the de-bounced button status of the -// specified joystick -// -/////////////////////////////////////////////////////////////////////////// -word -IN_GetJoyButtonsDB(word joy) -{ - word TimeCount = *clockw; - word lasttime; - word result1,result2; - - do - { - result1 = INL_GetJoyButtons(joy); - lasttime = TimeCount; - while(TimeCount == lasttime) - result2 = INL_GetJoyButtons(joy); - } while(result1 != result2); - return(result1); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartKbd() - Sets up my keyboard stuff for use -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_StartKbd() -{ - INL_KeyHook = 0; // Clear key hook - - IN_ClearKeysDown(); - - OldKeyVect = _dos_getvect(KeyInt); - _dos_setvect(KeyInt,INL_KeyService); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutKbd() - Restores keyboard control to the BIOS -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutKbd(void) -{ - pokeb(0x40,0x17,peekb(0x40,0x17) & 0xfaf0); // Clear ctrl/alt/shift flags - - _dos_setvect(KeyInt,OldKeyVect); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartMouse() - Detects and sets up the mouse -// -/////////////////////////////////////////////////////////////////////////// -static boolean -INL_StartMouse(void) -{ - union REGS CPURegs; - if(_dos_getvect(MouseInt)) - { - Mouse(MReset); - if(CPURegs.x.ax == 0xffff) - return(true); - } - return(false); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutMouse() - Cleans up after the mouse -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutMouse(void) -{ -} - -// -// INL_SetJoyScale() - Sets up scaling values for the specified joystick -// -static void -INL_SetJoyScale(word joy) -{ - JoystickDef *def; - - def = &(inpu.JoyDefs[joy]); - def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX); - def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX); - def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY); - def->joyMultYH = JoyScaleMax / (def->joyMaxY - def->threshMaxY); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetupJoy() - Sets up thresholding values and calls INL_SetJoyScale() -// to set up scaling values -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy) -{ - word d,r; - JoystickDef *def; - - def = &(inpu.JoyDefs[joy]); - - def->joyMinX = minx; - def->joyMaxX = maxx; - r = maxx - minx; - d = r / 3; - def->threshMinX = ((r / 2) - d) + minx; - def->threshMaxX = ((r / 2) + d) + minx; - - def->joyMinY = miny; - def->joyMaxY = maxy; - r = maxy - miny; - d = r / 3; - def->threshMinY = ((r / 2) - d) + miny; - def->threshMaxY = ((r / 2) + d) + miny; - - INL_SetJoyScale(joy); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_StartJoy() - Detects & auto-configures the specified joystick -// The auto-config assumes the joystick is centered -// -/////////////////////////////////////////////////////////////////////////// -static boolean -INL_StartJoy(word joy) -{ - word x,y; - - IN_GetJoyAbs(joy,&x,&y); - - if - ( - ((x == 0) || (x > MaxJoyValue - 10)) - || ((y == 0) || (y > MaxJoyValue - 10)) - ) - return(false); - else - { - IN_SetupJoy(joy,0,x * 2,0,y * 2); - return(true); - } -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_ShutJoy() - Cleans up the joystick stuff -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_ShutJoy(word joy) -{ - inpu.JoysPresent[joy] = false; -} - -// Public routines - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Startup() - Starts up the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Startup() -{ - boolean checkjoys,checkmouse; - word i; - - if (inst.IN_Started) - return; - - checkjoys = true; - checkmouse = true; - for (i = 1;i < _argc;i++) - { - switch (US_CheckParm(_argv[i],ParmStringsIN)) - { - case 0: - checkjoys = false; - break; - case 1: - checkmouse = false; - break; - } - } - - INL_StartKbd(); - inpu.MousePresent = checkmouse? INL_StartMouse() : false; - - for (i = 0;i < MaxJoys;i++) - inpu.JoysPresent[i] = checkjoys? INL_StartJoy(i) : false; - - inst.IN_Started = true; - -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Default() - Sets up default conditions for the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Default(boolean gotit,player_t *player,ControlType nt) -{ - int i; - if - ( - (!gotit) - || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0]) - || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) - || ((nt == ctrl_Mouse) && !inpu.MousePresent) - ) - nt = ctrl_Keyboard1; - inpu.KbdDefs[0].button0 = 0x1c; - inpu.KbdDefs[0].button1 = 0x38; - //in.KbdDefs[0].upleft = 0x47; - inpu.KbdDefs[0].up = 0x48; - //in.KbdDefs[0].upright = 0x49; - inpu.KbdDefs[0].left = 0x4b; - inpu.KbdDefs[0].right = 0x4d; - //in.KbdDefs[0].downleft = 0x4f; - inpu.KbdDefs[0].down = 0x50; - //in.KbdDefs[0].downright = 0x51; - IN_SetControlType(0,player,nt); - for(i=0; i>MaxPlayers;i++) - player[i].d=2; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Shutdown() - Shuts down the Input Mgr -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Shutdown() -{ - word i; - - if (!inst.IN_Started) - return; - - INL_ShutMouse(); - for (i = 0;i < MaxJoys;i++) - INL_ShutJoy(i); - INL_ShutKbd(); - - inst.IN_Started = false; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetKeyHook() - Sets the routine that gets called by INL_KeyService() -// everytime a real make/break code gets hit -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetKeyHook(void (*hook)()) -{ - INL_KeyHook = hook; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ClearKeyDown() - Clears the keyboard array -// -/////////////////////////////////////////////////////////////////////////// -void -IN_ClearKeysDown() -{ - //int i; - - inpu.LastScan = sc_None; - inpu.LastASCII = key_None; - memset (inpu.Keyboard,0,sizeof(inpu.Keyboard)); -} - -/////////////////////////////////////////////////////////////////////////// -// -// INL_AdjustCursor() - Internal routine of common code from IN_ReadCursor() -// -/////////////////////////////////////////////////////////////////////////// -static void -INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy) -{ - if (buttons & (1 << 0)) - info->button0 = true; - if (buttons & (1 << 1)) - info->button1 = true; - - info->x += dx; - info->y += dy; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ReadCursor() - Reads the input devices and fills in the cursor info -// struct -// -/////////////////////////////////////////////////////////////////////////// -void -IN_ReadCursor(CursorInfo *info) -{ - word i, - buttons; - int dx,dy; - - info->x = info->y = 0; - info->button0 = info->button1 = false; - - if (inpu.MousePresent) - { - buttons = INL_GetMouseButtons(); - INL_GetMouseDelta(&dx,&dy); - INL_AdjustCursor(info,buttons,dx,dy); - } - - for (i = 0;i < MaxJoys;i++) - { - if (!inpu.JoysPresent[i]) - continue; - - buttons = INL_GetJoyButtons(i); - INL_GetJoyDelta(i,&dx,&dy,true); - dx /= 64; - dy /= 64; - INL_AdjustCursor(info,buttons,dx,dy); - } -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_ReadControl() - Reads the device associated with the specified -// player and fills in the control info struct -// -/////////////////////////////////////////////////////////////////////////// -void near -IN_ReadControl(int pn,player_t *player) -{ - boolean realdelta; -#if DEMO0 - byte dbyte; -#endif - word buttons; - int dx,dy; - Motion mx,my; - ControlType type; - sword conpee; - byte dir=DirTable[2]; -register KeyboardDef *def; - - dx = dy = 0; - mx = my = motion_None; - buttons = 0; - -#if DEMO0 - if (DemoMode == demo_Playback) - { - dbyte = DemoBuffer[DemoOffset + 1]; - my = (dbyte & 3) - 1; - mx = ((dbyte >> 2) & 3) - 1; - buttons = (dbyte >> 4) & 3; - - if (!(--DemoBuffer[DemoOffset])) - { - DemoOffset += 2; - if (DemoOffset >= DemoSize) - DemoMode = demo_PlayDone; - } - - realdelta = false; - } - else if (DemoMode == demo_PlayDone) - Quit("Demo playback exceeded"); - else - { -#endif - switch (type = player[pn].Controls) - { - case ctrl_Keyboard1: - case ctrl_Keyboard2: - def = &(inpu.KbdDefs[type - ctrl_Keyboard]); - -/* if (Keyboard[def->upleft]) - mx = motion_Left,my = motion_Up; - else if (Keyboard[def->upright]) - mx = motion_Right,my = motion_Up; - else if (Keyboard[def->downleft]) - mx = motion_Left,my = motion_Down; - else if (Keyboard[def->downright]) - mx = motion_Right,my = motion_Down;*/ -//TODO: make this into a function that the joystick AND keyboard can use wwww - if(DIRECTIONIFELSE)//(player[pn].info.dir == 2) - { - 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])) - mx = motion_Right; - }else{ //2 keys pressed - switch (player[pn].pdir) - { - case 0: - case 4: - if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])){ dir = DirTable[1]; }//mx = motion_Left; } - else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])){ dir = DirTable[3]; }//mx = motion_Right; } - break; - case 1: - case 3: - if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])){ dir = DirTable[0]; }//my = motion_Up; } - else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])){ dir = DirTable[4]; }//my = motion_Down; } - break; - default: - break; - } -#ifdef __DEBUG_InputMgr__ - //if(dbg_testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } -#endif - } - } - //input from player - if (inpu.Keyboard[def->button0]) - buttons += 1 << 0; - if (inpu.Keyboard[def->button1]) - buttons += 1 << 1; - realdelta = false; - break; - case ctrl_Joystick1: - case ctrl_Joystick2: - INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false); - buttons = INL_GetJoyButtons(type - ctrl_Joystick); - realdelta = true; - break; - case ctrl_Mouse: - INL_GetMouseDelta(&dx,&dy); - buttons = INL_GetMouseButtons(); - realdelta = true; - break; - } -#ifdef DEMO0 - } -#endif - - if (realdelta) - { - mx = (dx < 0)? motion_Left : ((dx > 0)? motion_Right : motion_None); - my = (dy < 0)? motion_Up : ((dy > 0)? motion_Down : motion_None); - } - else - { - dx = mx;// * 127; - dy = my;// * 127; - } - - player[pn].info.x = dx; - player[pn].info.xaxis = mx; - player[pn].info.y = dy; - player[pn].info.yaxis = my; - player[pn].info.button0 = buttons & (1 << 0); - player[pn].info.button1 = buttons & (1 << 1); - player[pn].info.button2 = buttons & (1 << 2); - player[pn].info.button3 = buttons & (1 << 3); -// player[pn].info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; - conpee=(((my + 1) * 2) + (mx + 1))-1; - player[pn].info.dir = DirTable[conpee]; - - if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee]; - if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None))) - { - if(dir==2) player[pn].d = player[pn].info.dir; - else player[pn].d = DirTable[dir]; - } - -#if DEMO0 - if (DemoMode == demo_Record) - { - // Pack the control info into a byte - dbyte = (buttons << 4) | ((mx + 1) << 2) | (my + 1); - - if - ( - (DemoBuffer[DemoOffset + 1] == dbyte) - && (DemoBuffer[DemoOffset] < 255) - ) - (DemoBuffer[DemoOffset])++; - else - { - if (DemoOffset || DemoBuffer[DemoOffset]) - DemoOffset += 2; - - if (DemoOffset >= DemoSize) - Quit("Demo buffer overflow"); - - DemoBuffer[DemoOffset] = 1; - DemoBuffer[DemoOffset + 1] = dbyte; - } - } -#endif -#ifdef __DEBUG_InputMgr__ -if(dbg_testcontrolnoisy > 0) -if(player[pn].info.dir!=2/*(inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])*/ || player[pn].q>1) -{ - //printf("b1=%u b2=%u b3=%u b4=%u ", player[pn].info.button0, player[pn].info.button1, player[pn].info.button2, player[pn].info.button3); - //printf("q=%d ", player[pn].q); - //printf("cpee=%c ", dirchar(conpee)); - printf("pdir=%c d=%c dir=%c ", dirchar(player[pn].pdir), dirchar(player[pn].d), dirchar(player[pn].info.dir)); - /*if(realdelta) */printf("dx=%d dy=%d mx=%d my=%d", player[pn].info.x, player[pn].info.y, player[pn].info.xaxis, player[pn].info.yaxis); - //else if(!realdelta) printf("%c%d %c%d %c%d %c%d", dirchar(0), inpu.Keyboard[def->up], dirchar(4), inpu.Keyboard[def->down], dirchar(1), inpu.Keyboard[def->left], dirchar(3), inpu.Keyboard[def->right]); - printf("\n"); -} -#endif -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_SetControlType() - Sets the control type to be used by the specified -// player -// -/////////////////////////////////////////////////////////////////////////// -void -IN_SetControlType(word pn,player_t *player,ControlType type) -{ - // DEBUG - check that requested type is present? - player[pn].Controls = type; -} - -#if DEMO0 -/////////////////////////////////////////////////////////////////////////// -// -// IN_StartDemoRecord() - Starts the demo recording, using a buffer the -// size passed. Returns if the buffer allocation was successful -// -/////////////////////////////////////////////////////////////////////////// -boolean -IN_StartDemoRecord(word bufsize) -{ - if (!bufsize) - return(false); - - MM_GetPtr((memptr *)&DemoBuffer,bufsize); - DemoMode = demo_Record; - DemoSize = bufsize & ~1; - DemoOffset = 0; - DemoBuffer[0] = DemoBuffer[1] = 0; - - return(true); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_StartDemoPlayback() - Plays back the demo pointed to of the given size -// -/////////////////////////////////////////////////////////////////////////// -void -IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize) -{ - DemoBuffer = buffer; - DemoMode = demo_Playback; - DemoSize = bufsize & ~1; - DemoOffset = 0; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_StopDemo() - Turns off demo mode -// -/////////////////////////////////////////////////////////////////////////// -void -IN_StopDemo(void) -{ - if ((DemoMode == demo_Record) && DemoOffset) - DemoOffset += 2; - - DemoMode = demo_Off; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_FreeDemoBuffer() - Frees the demo buffer, if it's been allocated -// -/////////////////////////////////////////////////////////////////////////// -void -IN_FreeDemoBuffer(void) -{ - if (DemoBuffer) - MM_FreePtr((memptr *)&DemoBuffer); -} -#endif - - -/////////////////////////////////////////////////////////////////////////// -// -// IN_GetScanName() - Returns a string containing the name of the -// specified scan code -// -/////////////////////////////////////////////////////////////////////////// -byte * -IN_GetScanName(ScanCode scan) -{ - byte **p; - ScanCode far *s; - - for (s = ExtScanCodes,p = ExtScanNames;*s;p++,s++) - if (*s == scan) - return(*p); - - return(ScanNames[scan]); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_WaitForKey() - Waits for a scan code, then clears LastScan and -// returns the scan code -// -/////////////////////////////////////////////////////////////////////////// -ScanCode -IN_WaitForKey() -{ - ScanCode result; - - while (!(result = inpu.LastScan)) - ; - inpu.LastScan = 0; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_WaitForASCII() - Waits for an ASCII char, then clears LastASCII and -// returns the ASCII value -// -/////////////////////////////////////////////////////////////////////////// -char -IN_WaitForASCII() -{ - char result; - - while (!(result = inpu.LastASCII)) - ; - inpu.LastASCII = '\0'; - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_AckBack() - Waits for either an ASCII keypress or a button press -// -/////////////////////////////////////////////////////////////////////////// -void -IN_AckBack() -{ - word i; - - while (!inpu.LastScan) - { - if (inpu.MousePresent) - { - if (INL_GetMouseButtons()) - { - while (INL_GetMouseButtons()) - ; - return; - } - } - - for (i = 0;i < MaxJoys;i++) - { - if (inpu.JoysPresent[i]) - { - if (IN_GetJoyButtonsDB(i)) - { - while (IN_GetJoyButtonsDB(i)) - ; - return; - } - } - } - } - - IN_ClearKey(inpu.LastScan); - inpu.LastScan = sc_None; -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_Ack() - Clears user input & then calls IN_AckBack() -// -/////////////////////////////////////////////////////////////////////////// -void -IN_Ack() -{ - word i; - - if (!inst.IN_Started) - return; - - IN_ClearKey(inpu.LastScan); - inpu.LastScan = sc_None; - - if (inpu.MousePresent) - while (INL_GetMouseButtons()) - ; - for (i = 0;i < MaxJoys;i++) - if (inpu.JoysPresent[i]) - while (IN_GetJoyButtonsDB(i)) - ; - - IN_AckBack(); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_IsUserInput() - Returns true if a key has been pressed or a button -// is down -// -/////////////////////////////////////////////////////////////////////////// -boolean -IN_IsUserInput() -{ - boolean result; - word i; - - result = inpu.LastScan; - - if (inpu.MousePresent) - if (INL_GetMouseButtons()) - result = true; - - for (i = 0;i < MaxJoys;i++) - if (inpu.JoysPresent[i]) - if (INL_GetJoyButtons(i)) - result = true; - - return(result); -} - -/////////////////////////////////////////////////////////////////////////// -// -// IN_UserInput() - Waits for the specified delay time (in ticks) or the -// user pressing a key or a mouse button. If the clear flag is set, it -// then either clears the key or waits for the user to let the mouse -// button up. -// -/////////////////////////////////////////////////////////////////////////// -boolean -IN_UserInput(dword delay,boolean clear) -{ - word TimeCount = *clockw; - word lasttime; - - lasttime = TimeCount; - do - { - if (IN_IsUserInput()) - { - if (clear) - IN_AckBack(); - return(true); - } - } while (TimeCount - lasttime < delay); - return(false); -} - -boolean IN_KeyDown(byte code) -{ - return inpu.Keyboard[code]; -} - -void IN_ClearKey(byte code) -{ - inpu.Keyboard[code] = false; - if(code == inpu.LastScan) - inpu.LastScan = sc_None; - } - -boolean IN_qb(byte kee) -{ -#ifdef __DEBUG_InputMgr__ -// if(dbg_testkeyin > 0) printf("%u\n", inpu.Keyboard[kee]); -#endif - if(inpu.Keyboard[kee]==true) return 1; - else return 0; -} - -//init player! -void IN_initplayer(player_t *player, word pn) -{ - player[pn].x = player[pn].tx*TILEWH; - player[pn].y = player[pn].ty*TILEWH; - player[pn].triggerx = player[pn].tx; - player[pn].triggery = player[pn].ty+1; -/* player[0].info.x = player[0].tx; - player[0].info.xaxis = player[0].tx*TILEWH; - player[0].info.y = player[0].ty; - player[0].info.yaxis = player[0].ty*TILEWH;*/ - player[pn].q=1; - player[pn].d=2; - player[pn].hp=4; - player[pn].speed=4; - player[pn].persist_aniframe=0; - player[pn].spt=(TILEWH/(player[pn].speed)); //speed per tile wwww -} diff --git a/src/lib/_6_in.h b/src/lib/_6_in.h deleted file mode 100755 index eb1650e4..00000000 --- a/src/lib/_6_in.h +++ /dev/null @@ -1,309 +0,0 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -// -// ID Engine -// ID_IN.h - Header file for Input Manager -// v1.0d1w -// By Jason Blochowiak -// Open Watcom port by sparky4 -// - -#ifndef __16_IN__ -#define __16_IN__ - -#include -#include "src/lib/16_head.h" -#include "src/lib/16_timer.h" -#ifdef __WATCOMC__ //borland C BCEXMM.EXE -#include "src/lib/16_dbg.h" -#include "src/lib/16_sprit.h" -//#include "src/lib/bitmap.h" //old format -#endif -#ifdef __DEBUG__ -#define __DEBUG_InputMgr__ -extern boolean dbg_testkeyin,dbg_testcontrolnoisy; -#endif - -//if else for gfxtesting and direction -//player[pn].d == 2 || -//player[pn].d != 2 || -#define DIRECTIONIFELSE (player[pn].info.dir == 2) -//#define NDIRECTIONIFELSE (player[pn].info.dir != 2) - -#define KeyInt 9 // The keyboard ISR number - -// Stuff for the joystick -#define JoyScaleMax 32768 -#define JoyScaleShift 8 -#define MaxJoyValue 5000 - -#define MaxPlayers 4 -#define MaxKbds 2 -#define MaxJoys 2 -#define MaxPads 2 -#define NumCodes 128 - -typedef byte ScanCode; -#define sc_None 0 -#define sc_Bad 0xff -#define sc_Return 0x1c -#define sc_Enter sc_Return -#define sc_Escape 0x01 -#define sc_Space 0x39 -#define sc_BackSpace 0x0e -#define sc_Tab 0x0f -#define sc_Alt 0x38 -#define sc_Control 0x1d -#define sc_CapsLock 0x3a -#define sc_LShift 0x2a -#define sc_RShift 0x36 -#define sc_UpArrow 0x48 -#define sc_DownArrow 0x50 -#define sc_LeftArrow 0x4b -#define sc_RightArrow 0x4d -#define sc_Insert 0x52 -#define sc_Delete 0x53 -#define sc_Home 0x47 -#define sc_End 0x4f -#define sc_PgUp 0x49 -#define sc_PgDn 0x51 -#define sc_F1 0x3b -#define sc_F2 0x3c -#define sc_F3 0x3d -#define sc_F4 0x3e -#define sc_F5 0x3f -#define sc_F6 0x40 -#define sc_F7 0x41 -#define sc_F8 0x42 -#define sc_F9 0x43 -#define sc_F10 0x44 -#define sc_F11 0x57 -#define sc_F12 0x59 - -#define sc_1 0x02 -#define sc_2 0x03 -#define sc_3 0x04 -#define sc_4 0x05 -#define sc_5 0x06 -#define sc_6 0x07 -#define sc_7 0x08 -#define sc_8 0x09 -#define sc_9 0x0a -#define sc_0 0x0b - -#define sc_A 0x1e -#define sc_B 0x30 -#define sc_C 0x2e -#define sc_D 0x20 -#define sc_E 0x12 -#define sc_F 0x21 -#define sc_G 0x22 -#define sc_H 0x23 -#define sc_I 0x17 -#define sc_J 0x24 -#define sc_K 0x25 -#define sc_L 0x26 -#define sc_M 0x32 -#define sc_N 0x31 -#define sc_O 0x18 -#define sc_P 0x19 -#define sc_Q 0x10 -#define sc_R 0x13 -#define sc_S 0x1f -#define sc_T 0x14 -#define sc_U 0x16 -#define sc_V 0x2f -#define sc_W 0x11 -#define sc_X 0x2d -#define sc_Y 0x15 -#define sc_Z 0x2c - -#define key_None 0 -#define key_Return 0x0d -#define key_Enter key_Return -#define key_Escape 0x1b -#define key_Space 0x20 -#define key_BackSpace 0x08 -#define key_Tab 0x09 -#define key_Delete 0x7f - -#define key_LSuper 0x5b -#define key_RSuper 0x5c -#define key_Menu 0x5d - -// Stuff for the mouse -#define MReset 0 -#define MButtons 3 -#define MDelta 11 - -#define MouseInt 0x33 -#ifdef DEMO0 -typedef enum { - demo_Off,demo_Record,demo_Playback,demo_PlayDone - } Demo; -#endif -typedef enum { - //ctrl_None, // MDM (GAMERS EDGE) - added - ctrl_Keyboard, - ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2, - ctrl_Joystick, - ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2, - ctrl_Mouse, - } ControlType; -typedef enum { - motion_Left = -1,motion_Up = -1, - motion_None = 0, - motion_Right = 1,motion_Down = 1 - } Motion; -typedef enum { - dir_North,//dir_NorthEast, - dir_West,//dir_Nortinest, - dir_None, - dir_East,//,dir_SouthEast, - dir_South,//dir_Soutinest, - } Direction; -typedef struct { - boolean near button0,button1,button2,button3; - int near x,y; - Motion near xaxis,yaxis; - Direction near dir; - } CursorInfo; - -typedef struct { - ScanCode near button0,button1, - //upleft, - up, - down, - left, - right - //upright, - //downleft, - //,downright - ; - } KeyboardDef; -typedef struct { - word near joyMinX,joyMinY, - threshMinX,threshMinY, - threshMaxX,threshMaxY, - joyMaxX,joyMaxY, - joyMultXL,joyMultYL, - joyMultXH,joyMultYH; - } JoystickDef; - -typedef struct -{ - int x; //player exact position on the viewable map - int y; //player exact position on the viewable map - int tx; //player tile position on the viewable map - int ty; //player tile position on the viewable map - int triggerx; //player's trigger box tile position on the viewable map - int triggery; //player's trigger box tile position on the viewable map - int sheetsetx; //NOT USED YET! player sprite sheet set on the image x - int sheetsety; //NOT USED YET! player sprite sheet set on the image y - byte d; //direction to render sprite!! wwww - byte q; //loop variable for anumation and locking the playing to compleate the animation cycle to prevent issues with misalignment www - byte near pdir; //previous direction~ - //byte near kd[2]; //array of arrow key pressed - word speed; //player speed! - word spt; //speed per tile -//0000 planar_buf_t huge *data; //supposively the sprite sheet data -// planar_buf_t data; //supposively the sprite sheet data -////0000---- -#ifdef __WATCOMC__ - struct sprite *spri; //supposively the sprite sheet data - memptr gr; -#endif - bitmap_t *data; //supposively the sprite sheet data//old format - sword hp; //hitpoints of the player - int persist_aniframe; /* gonna be increased to 1 before being used, so 0 is ok for default */ - CursorInfo info; - ControlType Controls; -} player_t; - -/* -============================================================================= - - GLOBAL VARIABLES - -============================================================================= -*/ -/*extern struct inconfig -{ - boolean MousePresent; - boolean JoysPresent[MaxJoys]; - boolean Keyboard[NumCodes]; - boolean Paused; - char LastASCII; - ScanCode LastScan; - - KeyboardDef KbdDefs[MaxKbds]; - JoystickDef JoyDefs[MaxJoys]; -} inpu;*/ - -#ifdef DEMO0 - static Demo DemoMode = demo_Off; - static byte /*_seg*/ *DemoBuffer; - static word DemoOffset,DemoSize; -#endif - -// Internal routines -extern void interrupt INL_KeyService(); -extern void Mouse(int x); -//static void INL_GetMouseDelta(int *x,int *y); -//static word INL_GetMouseButtons(void); -extern void IN_GetJoyAbs(word joy,word *xp,word *yp); -//static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive); -//static word INL_GetJoyButtons(word joy); -extern word IN_GetJoyButtonsDB(word joy); -//static void INL_StartKbd(void); -//static void INL_ShutKbd(void); -//static boolean INL_StartMouse(void); -//static void INL_ShutMouse(void); -//static void INL_SetJoyScale(word joy); -extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy); -//static boolean INL_StartJoy(word joy); -//static void INL_ShutJoy(word joy); -extern void IN_Startup(); -extern void IN_Default(boolean gotit,player_t *player,ControlType nt); -extern void IN_Shutdown(); -extern void IN_SetKeyHook(void (*hook)()); -extern void IN_ClearKeysDown(); -//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy); -extern void IN_ReadCursor(CursorInfo *info); -extern void near IN_ReadControl(int pn,player_t *player); -extern void IN_SetControlType(word pn,player_t *player,ControlType type); -#if DEMO0 -extern boolean IN_StartDemoRecord(word bufsize); -extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize); -extern void IN_StopDemo(void); -extern void IN_FreeDemoBuffer(void); -#endif -extern byte *IN_GetScanName(ScanCode scan); -extern ScanCode IN_WaitForKey(); -extern char IN_WaitForASCII(); -extern void IN_AckBack(); -extern void IN_Ack(); -extern boolean IN_IsUserInput(); -extern boolean IN_UserInput(dword delay,boolean clear); -extern boolean IN_KeyDown(byte code); -extern void IN_ClearKey(byte code); -extern boolean IN_qb(byte kee); -void IN_initplayer(player_t *player, word pn); - -#endif diff --git a/src/lib/doslib b/src/lib/doslib index 8037bba4..e3437c72 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit 8037bba4c38f750e1599530d77e41ca1f80a6134 +Subproject commit e3437c7296b618a363f5452ebf90a8c5cf0558fa diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index cb014fd0..06c7fe95 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -26,6 +26,10 @@ void walk(map_view_t *pip, player_t *player, word pn) { +// modexLeave(); +// IN_Shutdown(); +// exit(-5); + #define INC_PER_FRAME if(player[pn].q&1) player[pn].persist_aniframe++; if(player[pn].persist_aniframe>4) player[pn].persist_aniframe = 1; //printf("player[%d].d=%d\n", pn, player[pn].d); switch(player[pn].d) diff --git a/src/scroll.c b/src/scroll.c index c92469cb..114cad0f 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -29,7 +29,7 @@ //#define FADE #define MODEX //this is for mode x initiating -boolean dbg_noplayerinpu=1; +//boolean dbg_noplayerinpu=1; //word far *clock= (word far*) 0x046C; /* 18.2hz clock */ //bitmap_t *p; @@ -42,7 +42,7 @@ float t; sword bakapee; pan_t pan; //debugswitches -boolean panswitch=1; +boolean panswitch=0;//1 //extern boolean pageflipflop=1; unsigned int i; const char *cpus; @@ -65,34 +65,7 @@ void main(int argc, char *argv[]) if(argv[1]) bakapee = atoi(argv[1]); else bakapee = 1; - // 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; - } - - if (_DEBUG_INIT() == 0) { -#ifdef DEBUGSERIAL - printf("WARNING: Failed to initialize DEBUG output\n"); -#endif - } - _DEBUG("Serial debug output started\n"); // NTS: All serial output must end messages with newline, or DOSBox-X will not emit text to log - _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); + Startup16(&gvar); pan.pn=1; @@ -125,7 +98,7 @@ void main(int argc, char *argv[]) if(!dbg_noplayerinpu) { IN_Startup(); - IN_Default(0,&player,ctrl_Joystick); + IN_Default(0,&player,ctrl_Keyboard1); //IN_Default(1,&player,ctrl_Joystick); } @@ -184,7 +157,7 @@ void main(int argc, char *argv[]) //default player position on the viewable map player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx; player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny; - IN_initplayer(&player);//, 0); + IN_initplayer(&player, 0); //IN_initplayer(&player, 1); #ifndef SPRITE @@ -228,9 +201,9 @@ void main(int argc, char *argv[]) //when player[0].tx or player[0].ty == 0 or player[0].tx == 20 or player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map //player movement - IN_ReadControl(/*0,*/&player); + IN_ReadControl(0, &player); if(!panswitch){ - walk(mv, player, 0); + walk(mv, &player, 0); }else{ panpagemanual(mv, player, 0); //printf(" player[0].q: %d", player[0].q); printf(" player[0].d: %d\n", player[0].d); diff --git a/src/vgmtest.c b/src/vgmtest.c index 2760ac0d..6ca69aa1 100755 --- a/src/vgmtest.c +++ b/src/vgmtest.c @@ -64,7 +64,7 @@ main(int argc, char *argv[]) while(!IN_KeyDown(sc_Escape)) //while(!kbhit()) { - IN_ReadControl(/*0,*/&player); + IN_ReadControl(0,&player); UpdateSoundEngine(); } StopMusic(); diff --git a/src/zcroll.c b/src/zcroll.c index 10f87f66..b08fcf7a 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -27,13 +27,13 @@ #include "src/lib/16_dbg.h" #define MODEXZ -boolean dbg_noplayerinpu=1; +//boolean dbg_noplayerinpu=1; //TODO: known issues the array dependent mv stuff and player arrays global_game_variables_t gvar; static map_t map; -player_t *player; -map_view_t *mv; +player_t player[MaxPlayers]; +map_view_t mv[4]; float t; sword bakapee; pan_t pan; @@ -64,10 +64,9 @@ void main(int argc, char *argv[]) pan.pn=0; // OK, this one takes hellova time and needs to be done in farmalloc or MM_... //TODO: USE MM AND CA AND PM WWWWWWWW - player = malloc(sizeof(player_t)); - player->ent = malloc(sizeof(entity_t)); - player->ent->spri = malloc(sizeof(struct sprite)); - player->ent->spri->spritesheet = malloc(sizeof(struct vrs_container)); + player[0].ent = malloc(sizeof(entity_t)); + player[0].ent->spri = malloc(sizeof(struct sprite)); + player[0].ent->spri->spritesheet = malloc(sizeof(struct vrs_container)); // create the map fprintf(stderr, "testing map load~ "); @@ -78,12 +77,12 @@ void main(int argc, char *argv[]) // data printf("loading sprite\n"); - read_vrs(&gvar, "data/spri/chikyuu.vrs", player->ent->spri->spritesheet); printf("sprite loaded\n"); + read_vrs(&gvar, "data/spri/chikyuu.vrs", player[0].ent->spri->spritesheet); printf("sprite loaded\n"); // input! if(!dbg_noplayerinpu) { - IN_Default(0, player,ctrl_Joystick); printf("IN_defaulted\n"); + IN_Default(0, &player,ctrl_Keyboard1); printf("IN_defaulted\n"); } // save the palette @@ -112,29 +111,29 @@ if(dbg_noplayerinpu) { //sprintf(&gvar.pee, "press a key for video setup"); strcpy(global_temp_status_text, "press a key for video setup"); - modexprint(mv->page, 0, 64, 1, 7, 0, global_temp_status_text); + modexprint(mv[0].page, 0, 64, 1, 7, 0, global_temp_status_text); getch(); } modexHiganbanaPageSetup(&gvar.video); - mv->page = &gvar.video.page[0]; - mv->map = ↦ - mv->video = &gvar.video; - mv->pan = &pan; - player->ent->spri->x = player->ent->spri->y = 20; + mv[0].page = &gvar.video.page[0]; + mv[0].map = ↦ + mv[0].video = &gvar.video; + mv[0].pan = &pan; + player[0].ent->spri->x = player[0].ent->spri->y = 20; // set up paging //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen - mapGoTo(mv, 0, 0); + mapGoTo(&mv, 0, 0); #endif //TODO: put player in starting position of spot //default player position on the viewable map - player->tx = mv->tx + mv->page->tilemidposscreenx; - player->ty = mv->ty + mv->page->tilemidposscreeny; - IN_initplayer(player); printf("player inited\n"); + player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx; + player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny; + IN_initplayer(&player, 0); printf("player inited\n"); - i = set_anim_by_id(player->ent->spri, 11); - print_anim_ids(player->ent->spri); + i = set_anim_by_id(player[0].ent->spri, 11); + print_anim_ids(player[0].ent->spri); if (i == -1) { #ifdef FADE @@ -148,31 +147,32 @@ if(dbg_noplayerinpu) #endif exit(-4); } - //animate_spri(&(player->ent->spri)); + //animate_spri(&(player[0].ent->spri)); printf("spri ok\n"); - modexShowPage(mv->page);//!(gvar.video.p) + modexShowPage(mv[0].page);//!(gvar.video.p) shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible. #ifdef FADE modexFadeOn(4, gpal); #endif printf("LOOP\n"); if(!dbg_noplayerinpu) - while(!IN_KeyDown(sc_Escape) && player->hp>0) + while(!IN_KeyDown(sc_Escape) && player[0].hp>0) { shinku(&gvar); //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction - //when player->tx or player->ty == 0 or player->tx == 20 or player->ty == 15 then stop because that is edge of map and you do not want to walk of the map + //when player[0].tx or player[0].ty == 0 or player[0].tx == 20 or player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map //player movement - IN_ReadControl(player); + IN_ReadControl(0, &player); if(!panswitch){ - walk(player->ent, mv); + walk(player[0].ent, mv); + //walk(mv, &player, 0); } //the scripting stuff.... -/* if(((mv->map->data[(player->triggerx-1)+(map.width*(player->triggery-1))] == 0) && IN_KeyDown(0x1C))||(player->tx == 5 && player->ty == 5)) +/* if(((mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))] == 0) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5)) { short i; for(i=800; i>=400; i--) @@ -181,14 +181,14 @@ if(dbg_noplayerinpu) } nosound(); } - if(player->q == (TILEWH/(player->speed))+1 && player->info.dir != 2 && (player->triggerx == 5 && player->triggery == 5)){ player->hp--; } + if(player[0].q == (TILEWH/(player[0].speed))+1 && player[0].info.dir != 2 && (player[0].triggerx == 5 && player[0].triggery == 5)){ player[0].hp--; } */ //debugging binds! - if(IN_KeyDown(2)){ modexShowPage(mv->page); pan.pn=0; } - if(IN_KeyDown(25)){ modexpdump(mv->page); + if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pn=0; } + if(IN_KeyDown(25)){ modexpdump(mv[0].page); IN_UserInput(1,1); } //p #ifdef FADE - if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv->page); IN_UserInput(1,1); } + if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv[0].page); IN_UserInput(1,1); } if(IN_KeyDown(22)){ printf("2paloffset = %d\n", paloffset/3); IN_UserInput(1,1); @@ -209,12 +209,12 @@ if(dbg_noplayerinpu) } if(IN_KeyDown(67)) //f9 { - modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 2); + modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 2); } if(IN_KeyDown(66)) //f8 { - // modexDrawSprite(mv->page, 16, 16, p); - modexDrawSprite(mv->page, 32+48, 16, (player->data)); + // modexDrawSprite(mv[0].page, 16, 16, p); + modexDrawSprite(mv[0].page, 32+48, 16, (player[0].data)); } //TODO fmemtest into page /*if(IN_KeyDown(4+1)) //4 @@ -229,8 +229,8 @@ if(dbg_noplayerinpu) if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); } //if(IN_KeyDown(11)){ modexPalOverscan(15); } #endif - if((player->q==1) && !(player->x%TILEWH==0 && player->y%TILEWH==0)) break; //incase things go out of sync! - player->hp = 0; + if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break; //incase things go out of sync! + player[0].hp = 0; } else @@ -250,18 +250,18 @@ if(dbg_noplayerinpu) Shutdown16(&gvar); printf("\nProject 16 zcroll.exe. This is just a test file!\n"); printf("version %s\n", VERSION); - printf("tx: %d ", mv->tx); - printf("ty: %d\n", mv->ty); + printf("tx: %d ", mv[0].tx); + printf("ty: %d\n", mv[0].ty); printf("\n"); printf("player vars:\n"); - printf(" x: %d", player->x); printf(" y: %d\n", player->y); - //if(player->hp==0) printf("%d wwww\n", player->y+8); - //else printf("\nplayer->y: %d\n", player->y); - printf(" tx: %d", player->tx); printf(" ty: %d\n", player->ty); - printf(" triggx: %d", player->triggerx); printf(" triggy: %d\n", player->triggery); - printf(" hp: %d", (player->hp)); printf(" q: %d", player->q); printf(" player.info.dir: %d", player->info.dir); printf(" player.d: %d ", player->d); - printf(" pdir=%d\n", player->pdir); - printf(" tile data value at player trigger position: %d\n\n", mv->map->data[(player->triggerx-1)+(map.width*(player->triggery-1))]); + printf(" x: %d", player[0].x); printf(" y: %d\n", player[0].y); + //if(player[0].hp==0) printf("%d wwww\n", player[0].y+8); + //else printf("\nplayer[0].y: %d\n", player[0].y); + printf(" tx: %d", player[0].tx); printf(" ty: %d\n", player[0].ty); + printf(" triggx: %d", player[0].triggerx); printf(" triggy: %d\n", player[0].triggery); + printf(" hp: %d", (player[0].hp)); printf(" q: %d", player[0].q); printf(" player.info.dir: %d", player[0].info.dir); printf(" player.d: %d ", player[0].d); + printf(" pdir=%d\n", player[0].pdir); + printf(" tile data value at player trigger position: %d\n\n", mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]); printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height); printf("Screen: %dx", gvar.video.page[0].sw); printf("%d\n", gvar.video.page[0].sh); printf("virtual tile resolution: %dx", gvar.video.page[0].tilesw); printf("%d ", gvar.video.page[0].tilesh); @@ -274,7 +274,7 @@ if(dbg_noplayerinpu) //0000printf("\ngvar.video.tickclk=%f\n", gvar.video.tickclk); //0000printf("gvar.video.clk=%f", gvar.video.clk); printf("\n"); - //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv->map->width, mv->map->height, mv->map->data[0]); + //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv[0].map->width, mv[0].map->height, mv[0].map->data[0]); printf("\n"); switch(detectcpu()) diff --git a/test.exe b/test.exe index fc489c2c..434bf1a8 100755 Binary files a/test.exe and b/test.exe differ