From: sparky4 Date: Mon, 23 Mar 2015 22:16:16 +0000 (-0500) Subject: modified: makefile X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=47de84fccfcf27e3cf83004b74eee1215284c5df;p=16.git modified: makefile modified: scroll.exe modified: src/lib/mapread.c modified: src/lib/mapread.h modified: src/scroll.c --- diff --git a/makefile b/makefile index ebc15e33..61708a58 100644 --- a/makefile +++ b/makefile @@ -3,8 +3,8 @@ SRC=src\ SRCLIB=$(SRC)lib\ all: test.exe pcxtest.exe test2.exe scroll.exe -scroll.exe: scroll.obj modex16.obj dos_kb.obj bitmap.obj - wcl $(FLAGS) scroll.obj modex16.obj dos_kb.obj bitmap.obj 16\lib\x\modex.lib +scroll.exe: scroll.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj + wcl $(FLAGS) scroll.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj 16\lib\x\modex.lib scroll.obj: $(SRC)scroll.c wcl $(FLAGS) -c $(SRC)scroll.c test.exe: test.obj modex16.obj bitmap.obj @@ -29,14 +29,20 @@ modex16.obj: $(SRCLIB)modex16.h $(SRCLIB)modex16.c wcl $(FLAGS) -c $(SRCLIB)modex16.c dos_kb.obj: $(SRCLIB)dos_kb.h $(SRCLIB)dos_kb.c - wcl $(FLAGS) -c $(SRCLIB)dos_kb.c - + wcl $(FLAGS) -c $(SRCLIB)dos_kb.c + bitmap.obj: $(SRCLIB)bitmap.h $(SRCLIB)bitmap.c wcl $(FLAGS) -c $(SRCLIB)bitmap.c planar.obj: $(SRCLIB)planar.h $(SRCLIB)planar.c - wcl $(FLAGS) -c $(SRCLIB)planar.c - + wcl $(FLAGS) -c $(SRCLIB)planar.c + +mapread.obj: $(SRCLIB)mapread.h $(SRCLIB)mapread.c jsmn.obj + wcl $(FLAGS) -c $(SRCLIB)mapread.c + +jsmn.obj: $(SRCLIB)jsmn\jsmn.h $(SRCLIB)jsmn\jsmn.c + wcl $(FLAGS) -c $(SRCLIB)jsmn\jsmn.c + clean: del *.obj # del *.exe diff --git a/scroll.exe b/scroll.exe index 77635411..6442f4df 100644 Binary files a/scroll.exe and b/scroll.exe differ diff --git a/src/lib/mapread.c b/src/lib/mapread.c index 5cd4f1cf..32d06c01 100644 --- a/src/lib/mapread.c +++ b/src/lib/mapread.c @@ -9,13 +9,14 @@ static int jsoneq(const char *json, jsmntok_t *tok, const char *s) { } //this function is quite messy ^^; sorry! it is a quick and dirty fix~ -static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *js_sv,*/ map_t *map, int q) { +static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *js_sv,*/ map_t *map, int q/*, word w*/) { int i, j, k; if (count == 0) { return 0; } /* We may want to do strtol() here to get numeric value */ if (t->type == JSMN_PRIMITIVE) { + //if(w) if(js_sv == "data") { //bgdata[q] = (byte)strtol(js+t->start, (char **)js+t->end, 10); @@ -23,24 +24,29 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char * map->tiles->data->data[q] = (byte)strtol(js+t->start, (char **)js+t->end, 10); printf("%d[%d]", q, map->tiles->data->data[q]); //printf("%d[%d]", q, bgdata[q]); - }else if(js_sv == "height") + } + else + if(js_sv == "height") { map->height = (int)strtol(js+t->start, (char **)js+t->end, 10); - //printf("h:[%d]\n", map->height); + printf("h:[%d]\n", map->height); }else if(js_sv == "width") { map->width = (int)strtol(js+t->start, (char **)js+t->end, 10); - //printf("w:[%d]\n", map->width); + printf("w:[%d]\n", map->width); } return 1; /* We may use strndup() to fetch string value */ } else if (t->type == JSMN_STRING) { //printf("'%.*s'", t->end - t->start, js+t->start); - if (jsoneq(js, t, "data") == 0) + //if(w) + if(jsoneq(js, t, "data") == 0 ) { js_sv="data";//strdup(js+t->start);//, t->end - t->start); //printf("%s\n", js_sv); - }else if (jsoneq(js, t, "height") == 0 && indent==1) + } + else + if (jsoneq(js, t, "height") == 0 && indent==1) { js_sv="height";//strdup(js+t->start);//, t->end - t->start); //printf("%s\n", js_sv); @@ -55,9 +61,9 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char * j = 0; for (i = 0; i < t->size; i++) { //for (k = 0; k < indent; k++) printf("\t"); - j += dump(js, t+1+j, count-j, indent+1, map, i); + j += dump(js, t+1+j, count-j, indent+1, map, i/*, w*/); //printf(": "); - j += dump(js, t+1+j, count-j, indent+1, map, i); + j += dump(js, t+1+j, count-j, indent+1, map, i/*, w*/); //printf("\n"); } return j+1; @@ -68,7 +74,7 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char * //if(bgdata==NULL) bgdata=malloc(sizeof(char)*t->size); //for (k = 0; k < indent-1; k++) printf("\t"); //printf("\t-"); - j += dump(js, t+1+j, count-j, indent+1, map, i); + j += dump(js, t+1+j, count-j, indent+1, map, i/*, w*/); //printf("==\n"); } return j+1; @@ -76,7 +82,7 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char * return 0; } -int loadmap(char *mn, map_t *map) +static int loadmap(char *mn, map_t *map/*, word w*/) { int r; int eof_expected = 0; @@ -118,7 +124,7 @@ int loadmap(char *mn, map_t *map) js = realloc(js, jslen + r + 1); if (js == NULL) { - fprintf(stderr, "realloc(): errno=%d\n", errno); + fprintf(stderr, "realloc(): errno = %d\n", errno); return 3; } strncpy(js + jslen, buf, r); @@ -137,13 +143,17 @@ again: goto again; } } else { - dump(js, tok, p.toknext, 0, map, 0); + dump(js, tok, p.toknext, 0, map, 0/*, w*/); //fprintf(stdout, "[[[[%d]]]]\n", sizeof(tok)); //printf("[\n%d\n]", jslen); eof_expected = 1; } } + free(js); + free(tok); + fclose(fh); + return 0; } diff --git a/src/lib/mapread.h b/src/lib/mapread.h index 26682626..dbb4bfa3 100644 --- a/src/lib/mapread.h +++ b/src/lib/mapread.h @@ -1,13 +1,14 @@ #ifndef _LIBMAPREAD_H_ #define _LIBMAPREAD_H_ #include +#include #include #include -#include "src/lib/jsmn/jsmn.c" +#include "src/lib/jsmn/jsmn.h" #include "src/lib/modex16.h" -char *js_sv; -byte bgdata[4096]; +static char *js_sv; +//byte bgdata[4096]; typedef struct { bitmap_t *data; @@ -25,7 +26,7 @@ typedef struct { } map_t; static int jsoneq(const char *json, jsmntok_t *tok, const char *s); -static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *js_sv,*/ map_t *map, int q); -int loadmap(char *mn, map_t *map); +static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *js_sv,*/ map_t *map, int q/*, word w*/); +static int loadmap(char *mn, map_t *map/*, word w*/); #endif/*_LIBMAPREAD_H_*/ diff --git a/src/scroll.c b/src/scroll.c index f03cda5c..239883f6 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -118,8 +118,9 @@ void main() { }*/ /* create the map */ - loadmap("data/test.map", &map); - map = allocMap(map.width,map.height); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly + loadmap("data/test.map", &map/*, 0*/); + map = allocMap(map.width,map.height); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly + //loadmap(NULL, &map, 1); //if(isEMS()) printf("%d tesuto\n", coretotalEMS()); initMap(&map); mv.map = ↦