From 4293b0d061a726cba49d65a75b53de1f3617ffc5 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Tue, 14 Feb 2017 15:28:21 -0600 Subject: [PATCH] hmmm layers in map_t .... --- MAPTEST.L16 | 32 ++++++++++++++++++++++ data/G.PAL | Bin 768 -> 768 bytes data/newtest.map | 8 +++--- data/newtest.tmx | 4 +-- src/lib/16_head.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++ src/lib/16_head.h | 3 +++ src/lib/16_tail.c | 67 ---------------------------------------------- src/lib/16_tail.h | 13 ++++----- src/lib/16_tdef.h | 7 +++-- src/lib/16_vl.c | 2 +- src/maptest.c | 28 +++++++++++++------ src/zcroll.c | 1 + 12 files changed, 138 insertions(+), 94 deletions(-) create mode 100755 MAPTEST.L16 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:;Nx1OMxL+43^`V-PP=Bs}KD5canX6Eh@(OM&U z9LIT{pU)>Vuj_iAXWo}Xgc5zZlL7_rMXOlSy&!c`N!^qNx0vFow^-7>$kdg(Q%_2R zf96r%%B$a5cb0T702a`|067T4h{Cs6(!DUF8^hR)95h_klU8qxf4a>0Z?89h-P{uQr+KBHrm<{7U+{^z^;I_9=cnGu?~+OK;~3 Di(wLF literal 768 QcmZQz7zLvtFmgix00RI30RR91 diff --git a/data/newtest.map b/data/newtest.map index 57f063d4..14b87855 100755 --- a/data/newtest.map +++ b/data/newtest.map @@ -40,12 +40,12 @@ "objects":[ { "height":16, - "name":"", + "name":"trunk", "properties": { }, - "type":"", + "type":"nonc", "visible":true, "width":32, "x":128, @@ -53,12 +53,12 @@ }, { "height":16, - "name":"", + "name":"stump", "properties": { }, - "type":"", + "type":"nonc", "visible":true, "width":16, "x":144, diff --git a/data/newtest.tmx b/data/newtest.tmx index f9f1d08b..1bff6b80 100755 --- a/data/newtest.tmx +++ b/data/newtest.tmx @@ -109,7 +109,7 @@ - - + + 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(); -- 2.39.5