From: sparky4 Date: Tue, 14 Feb 2017 21:28:21 +0000 (-0600) Subject: hmmm layers in map_t .... X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=commitdiff_plain;h=4293b0d061a726cba49d65a75b53de1f3617ffc5 hmmm layers in map_t .... --- diff --git a/MAPTEST.L16 b/MAPTEST.L16 new file mode 100755 index 00000000..220afd31 --- /dev/null +++ b/MAPTEST.L16 @@ -0,0 +1,32 @@ +map.width= 40 +map.height= 30 +-./0,////////07777777777777777777777-./0 +1234,-,-,,777777777777777777777777771234 +56780-,-,,777777777777777777777777775678 +9:;<,---14777777777777777777777777779:;< +,,0,,,,,44777/77777777777777777777777777 +7777,,,,44777777777777777777777777777777 +7777,,,,77777777777777777777777777777777 +7777,,,,77777777/77777777777777777777777 +777777777,777777/77777777777777777777777 +7777777777777777/77777777777777777777777 +7777777777777777/77777777777777777777777 +777777777777////-./0/////777777777777777 +77777777777/7777123422222///777777777777 +777777777//77777567822222222///777777777 +77777777/77777779:; - - + + diff --git a/src/lib/16_head.c b/src/lib/16_head.c index f48a09c8..7f46743e 100755 --- a/src/lib/16_head.c +++ b/src/lib/16_head.c @@ -34,6 +34,73 @@ filesize(FILE *fp) return(size_of_file); } +//from http://stackoverflow.com/questions/2736753/how-to-remove-extension-from-file-name +// remove_ext: removes the "extension" from a file spec. +// mystr is the string to process. +// dot is the extension separator. +// sep is the path separator (0 means to ignore). +// Returns an allocated string identical to the original but +// with the extension removed. It must be freed when you're +// finished with it. +// If you pass in NULL or the new string can't be allocated, +// it returns NULL. + +char *remove_ext (char* mystr, char dot, char sep) { + char *retstr, *lastdot, *lastsep; + + // Error checks and allocate string. + + if (mystr == NULL) + return NULL; + if ((retstr = malloc (strlen (mystr) + 1)) == NULL) + return NULL; + + // Make a copy and find the relevant characters. + + strcpy (retstr, mystr); + lastdot = strrchr (retstr, dot); + lastsep = (sep == 0) ? NULL : strrchr (retstr, sep); + + // If it has an extension separator. + + if (lastdot != NULL) { + // and it's before the extenstion separator. + + if (lastsep != NULL) { + if (lastsep < lastdot) { + // then remove it. + + *lastdot = '\0'; + } + } else { + // Has extension separator with no path separator. + + *lastdot = '\0'; + } + } + + // Return the modified string. + + return retstr; +} + +//from http://quiz.geeksforgeeks.org/c-program-cyclically-rotate-array-one/ +void rotateR(byte *arr, byte n) +{ + byte x = arr[n-1], i; + for (i = n-1; i > 0; i--) + arr[i] = arr[i-1]; + arr[0] = x; +} + +void rotateL(byte *arr, byte n) +{ + byte x = arr[n+1], i; + for (i = n+1; i > 0; i++) + arr[i] = arr[i+1]; + arr[0] = x; +} + void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free) { byte str[64]; diff --git a/src/lib/16_head.h b/src/lib/16_head.h index aad7a554..134def28 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -198,6 +198,9 @@ typedef union REGPACK regs_t; /* local function */ long int filesize(FILE *fp); +char *remove_ext(char* mystr, char dot, char sep); +void rotateR(byte arr[], byte n); +void rotateL(byte arr[], byte n); void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free); int US_CheckParm(char *parm,char **strings); byte dirchar(byte in); diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c index 9277d4e9..2ff2229d 100755 --- a/src/lib/16_tail.c +++ b/src/lib/16_tail.c @@ -372,73 +372,6 @@ void Quit (global_game_variables_t *gvar, char *error) } //=========================================================================== -//from http://stackoverflow.com/questions/2736753/how-to-remove-extension-from-file-name - -// remove_ext: removes the "extension" from a file spec. -// mystr is the string to process. -// dot is the extension separator. -// sep is the path separator (0 means to ignore). -// Returns an allocated string identical to the original but -// with the extension removed. It must be freed when you're -// finished with it. -// If you pass in NULL or the new string can't be allocated, -// it returns NULL. - -char *remove_ext (char* mystr, char dot, char sep) { - char *retstr, *lastdot, *lastsep; - - // Error checks and allocate string. - - if (mystr == NULL) - return NULL; - if ((retstr = malloc (strlen (mystr) + 1)) == NULL) - return NULL; - - // Make a copy and find the relevant characters. - - strcpy (retstr, mystr); - lastdot = strrchr (retstr, dot); - lastsep = (sep == 0) ? NULL : strrchr (retstr, sep); - - // If it has an extension separator. - - if (lastdot != NULL) { - // and it's before the extenstion separator. - - if (lastsep != NULL) { - if (lastsep < lastdot) { - // then remove it. - - *lastdot = '\0'; - } - } else { - // Has extension separator with no path separator. - - *lastdot = '\0'; - } - } - - // Return the modified string. - - return retstr; -} - -//from http://quiz.geeksforgeeks.org/c-program-cyclically-rotate-array-one/ -void rotateR(byte arr[], byte n) -{ - byte x = arr[n-1], i; - for (i = n-1; i > 0; i--) - arr[i] = arr[i-1]; - arr[0] = x; -} - -void rotateL(byte arr[], byte n) -{ - byte x = arr[n+1], i; - for (i = n+1; i > 0; i++) - arr[i] = arr[i+1]; - arr[0] = x; -} #ifndef __WATCOMC__ char global_temp_status_text[512]; diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h index fc43be38..5dffd51f 100755 --- a/src/lib/16_tail.h +++ b/src/lib/16_tail.h @@ -71,22 +71,19 @@ if(IN_KeyDown(sc_Z)){ DRAWCORNERBOXES } \ if(IN_KeyDown(sc_X)){ TESTBG12 } \ if(IN_KeyDown(sc_C)){ TESTBG34 } \ - if(IN_KeyDown(sc_V)) VL_PatternDraw(&gvar.video, 0, 1, 1); \ - if(IN_KeyDown(sc_PgUp)){ \ + if(IN_KeyDown(sc_V)) VL_PatternDraw(&gvar.video, 0, 1, 1); +/* if(IN_KeyDown(sc_PgDn)){ \ rotateR(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \ - VL_UpdatePaletteWrite(&gvar.video.palette, 0); } \ - if(IN_KeyDown(sc_PgDn)){ \ + VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1,1); } \ + if(IN_KeyDown(sc_PgUp)){ \ rotateL(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \ - VL_UpdatePaletteWrite(&gvar.video.palette, 0); } + VL_UpdatePaletteWrite(&gvar.video.palette, 0); IN_UserInput(1,1); }*/ void DebugMemory_(global_game_variables_t *gvar, boolean q); void Shutdown16(global_game_variables_t *gvar); void Startup16(global_game_variables_t *gvar); void ClearMemory (global_game_variables_t *gvar); void Quit (global_game_variables_t *gvar, char *error); -char *remove_ext(char* mystr, char dot, char sep); -void rotateR(byte arr[], byte n); -void rotateL(byte arr[], byte n); void turboXT(byte bakapee); void nibbletest(); void booleantest(); diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 38fd2260..52435a91 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -80,9 +80,8 @@ typedef struct { //TODO: 16_mm and 16_ca must handle this //TODO: add variables from 16_ca //#define __NEWMAPTILEDATAVARS__ - -#ifdef __NEWMAPTILEDATAVARS__ #define MAPLAYERS 4 +#ifdef __NEWMAPTILEDATAVARS__ #define MAPTILESPTR layertile[0] #define MAPTILESPTK layertile[k] #define MAPDATAPTR layerdata[0] @@ -100,8 +99,8 @@ typedef struct { byte *data; //TODO: 16_mm and 16_ca must handle this tiles_t *tiles; //TODO: 16_mm and 16_ca must handle this #else - byte * far *layerdata; //TODO: 16_mm and 16_ca must handle this - tiles_t far *layertile[MAPLAYERS]; //TODO: 16_mm and 16_ca must handle this + byte * far *layerdata; + tiles_t far *layertile[MAPLAYERS]; #endif int width, height; //this has to be signed! byte name[16]; diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 9cada151..2141dbc3 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -1002,7 +1002,7 @@ void modexpdump(page_t *pee) int palq=(mult)*TILEWH; int palcol=0; int palx, paly; - for(paly=0; palydata->offset=(paloffset/3); modexPalUpdate(map.tiles->data, &paloffset, 0, 0);*/ VL_LoadPalFile(bakapee1p, &gvar.video.palette); + VL_LoadPalFile("data/default.pal", &gvar.video.palette); #ifdef FADE gpal = modexNewPal();