From 76278b1d3be2ebf4a635cdec253dfe48450075df Mon Sep 17 00:00:00 2001 From: sparky4 Date: Sat, 12 Mar 2016 17:38:43 -0600 Subject: [PATCH] 16_in improvements and added debugging stuff --- dld.bat | 1 + src/inputest.c | 6 ++-- src/lib/16_in.c | 77 ++++++++++++++++++++++++++++------------------- src/lib/16_in.h | 15 ++++++--- src/lib/modex16.h | 1 + src/scroll.c | 6 +++- 6 files changed, 67 insertions(+), 39 deletions(-) create mode 100755 dld.bat diff --git a/dld.bat b/dld.bat new file mode 100755 index 00000000..25d94e8d --- /dev/null +++ b/dld.bat @@ -0,0 +1 @@ +cd src\lib\doslib diff --git a/src/inputest.c b/src/inputest.c index 32947c5c..c0c3792e 100755 --- a/src/inputest.c +++ b/src/inputest.c @@ -29,8 +29,9 @@ main(int argc, char *argv[]) { player_t player[MaxPlayers]; //extern struct inconfig inpu; - testkeyin=1; - testcontrolnoisy=0; + testkeyin=0; + testcontrolnoisy=1; + gfxtest=0; IN_Startup(); IN_Default(0,&player,ctrl_Joystick); //while(!IN_KeyDown(sc_Escape)) @@ -46,4 +47,5 @@ main(int argc, char *argv[]) printf("inputest.exe "); printf("version %s\n", VERSION); printf("testkeyin=%u\n", testkeyin); + printf("testcontrolnoisy=%u\n", testcontrolnoisy); } diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 7519a6c2..062e3bee 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -38,7 +38,7 @@ #include "src/lib/16_in.h" -word testkeyin=1,testcontrolnoisy=0; +byte testkeyin=0,testcontrolnoisy=0,gfxtest=0; /* ============================================================================= @@ -669,6 +669,7 @@ IN_Startup() void IN_Default(boolean gotit,player_t *player,ControlType nt) { + int i; if ( (!gotit) @@ -690,6 +691,8 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) 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; } /////////////////////////////////////////////////////////////////////////// @@ -800,7 +803,7 @@ IN_ReadCursor(CursorInfo *info) // /////////////////////////////////////////////////////////////////////////// void near -IN_ReadControl(int playnum,player_t *player) +IN_ReadControl(int pn,player_t *player) { boolean realdelta; byte dbyte; @@ -837,7 +840,7 @@ register KeyboardDef *def; else { #endif - switch (type = player[playnum].Controls) + switch (type = player[pn].Controls) { case ctrl_Keyboard1: case ctrl_Keyboard2: @@ -851,16 +854,21 @@ register KeyboardDef *def; mx = motion_Left,my = motion_Down; else if (Keyboard[def->downright]) mx = motion_Right,my = motion_Down;*/ - if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ - if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down] && player[playnum].d == 2))// || player[playnum].info.dir == 0) - my = motion_Up; - if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up] && player[playnum].d == 2))// || player[playnum].info.dir == 4) - my = motion_Down; - }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){ - if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right] && player[playnum].d == 2))// || player[playnum].info.dir == 1) - mx = motion_Left; - if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left] && player[playnum].d == 2))// || player[playnum].info.dir == 3) - mx = motion_Right; + if(DIRECTIONIFELSEGFXTEST) + { + if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){// && (inpu.Keyboard[def->up] || inpu.Keyboard[def->down])){ +// if(testcontrolnoisy > 0){ printf("ud "); printf("%u ", inpu.Keyboard[def->up]); printf("%u ", inpu.Keyboard[def->down]);} + if(inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])// || player[pn].info.pdir == 0) + my = motion_Up; + if(inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])// || player[pn].info.pdir == 4) + my = motion_Down; + }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){// && (inpu.Keyboard[def->left] || inpu.Keyboard[def->right])){ +// if(testcontrolnoisy > 0){ printf("lr "); printf("%u ", inpu.Keyboard[def->left]); printf("%u ", inpu.Keyboard[def->right]); } + if(inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])// || player[pn].info.pdir == 1) + mx = motion_Left; + if(inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])// || player[pn].info.pdir == 3) + mx = motion_Right; + } } //input from player if (inpu.Keyboard[def->button0]) @@ -900,22 +908,27 @@ register KeyboardDef *def; dy = my;// * 127; } - player[playnum].info.x = dx; - player[playnum].info.xaxis = mx; - player[playnum].info.y = dy; - player[playnum].info.yaxis = my; - player[playnum].info.button0 = buttons & (1 << 0); - player[playnum].info.button1 = buttons & (1 << 1); - player[playnum].info.button2 = buttons & (1 << 2); - player[playnum].info.button3 = buttons & (1 << 3); -// player[playnum].info.dir = DirTable[((my + 1) * 3) + (mx + 1)]; - conpee=(((my + 1) * 2) + (mx + 1)); - if(conpee) conpee--; - player[playnum].info.dir = DirTable[conpee]; - if(player[playnum].q==1 && (mx!=motion_None || my!=motion_None)) + 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; //if(conpee) conpee--; + player[pn].info.dir = DirTable[conpee]; + if(DIRECTIONIFELSEGFXTEST && player[pn].d != player[pn].info.dir) player[pn].pdir=DirTable[conpee]; + if(player[pn].q==1 && (mx!=motion_None || my!=motion_None)) { - player[playnum].d = player[playnum].info.dir; + player[pn].d = player[pn].info.dir; + //printf("q =%d ", player[pn].q); + //if(testcontrolnoisy > 0) + //if(testcontrolnoisy > 0) + //printf("cpee=%d ", conpee); } + if(testcontrolnoisy > 0) #if DEMO0 if (DemoMode == demo_Record) @@ -944,11 +957,13 @@ register KeyboardDef *def; #endif //#ifdef TESTCONTROLNOISY if(testcontrolnoisy > 0) -if((inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right])&& player[playnum].info.dir!=2) +if((inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->left] || inpu.Keyboard[def->right]) && NDIRECTIONIFELSEGFXTEST) { + printf("q=%d ", player[pn].q); + printf("cpee=%d ", conpee); printf("(mx)=%d ", mx); printf("(my)=%d ", my); - printf("dir=%d\n", player[playnum].info.dir); + printf("pdir=%d d=%d dir=%d\n", player[pn].pdir, player[pn].d, player[pn].info.dir); } //#endif } @@ -960,10 +975,10 @@ if((inpu.Keyboard[def->up] || inpu.Keyboard[def->down] || inpu.Keyboard[def->lef // /////////////////////////////////////////////////////////////////////////// void -IN_SetControlType(word playnum,player_t *player,ControlType type) +IN_SetControlType(word pn,player_t *player,ControlType type) { // DEBUG - check that requested type is present? - player[playnum].Controls = type; + player[pn].Controls = type; } #if DEMO0 diff --git a/src/lib/16_in.h b/src/lib/16_in.h index 44daca6d..e39c400e 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -42,7 +42,11 @@ //#define TESTCONTROLNOISY #endif -extern word testkeyin,testcontrolnoisy; +extern byte testkeyin,testcontrolnoisy,gfxtest; + +//if else for gfxtesting and direction +#define DIRECTIONIFELSEGFXTEST (player[pn].d == 2 && gfxtest) || (player[pn].info.dir == 2 && !gfxtest) +#define NDIRECTIONIFELSEGFXTEST (player[pn].d != 2 && gfxtest) || (player[pn].info.dir != 2 && !gfxtest) #define KeyInt 9 // The keyboard ISR number @@ -220,8 +224,9 @@ typedef struct 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!! wwww - byte q; //loop variable + 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~ word speed; //player speed! //0000 planar_buf_t huge *data; //supposively the sprite sheet data // planar_buf_t data; //supposively the sprite sheet data @@ -285,8 +290,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(int playnum,player_t *player); -extern void IN_SetControlType(word playnum,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); diff --git a/src/lib/modex16.h b/src/lib/modex16.h index 5a2655d6..c45aafbc 100755 --- a/src/lib/modex16.h +++ b/src/lib/modex16.h @@ -36,6 +36,7 @@ #include "src/lib/modex16/256x192.h" #include "src/lib/modex16/192x144_.h" #include "src/lib/modex16/160x120.h" +extern byte gfxtest; static struct pcxHeader { byte id; diff --git a/src/scroll.c b/src/scroll.c index b89d1291..99910f26 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 * * This file is part of Project 16. * @@ -64,6 +64,9 @@ void main(int argc, char *argv[]) if(argv[1]) bakapee = atoi(argv[1]); else bakapee = 1; + testcontrolnoisy=0; + gfxtest=1; + player[0].persist_aniframe=0; player[0].speed=4; //player[0].data = &pp; @@ -422,6 +425,7 @@ void main(int argc, char *argv[]) printf("player[0].tx: %d", player[0].tx); printf(" player[0].ty: %d\n", player[0].ty); printf("player[0].triggx: %d", player[0].triggerx); printf(" player[0].triggy: %d\n", player[0].triggery); printf("player[0].hp: %d", (player[0].hp)); printf(" player[0].q: %d", player[0].q); printf(" player[0].info.dir: %d", player[0].info.dir); printf(" player[0].d: %d\n", player[0].d); + printf("pdir=%d\n", player[0].pdir); printf("tile data value at player trigger position: %d\n", bg->map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]); // printf("palette offset: %d\n", paloffset/3); //++++ printf("Total used: %zu\n", oldfreemem-GetFreeSize()); -- 2.39.5