OSDN Git Service

modified: makefile
authorsparky4 <sparky4@cock.li>
Mon, 23 Mar 2015 22:16:16 +0000 (17:16 -0500)
committersparky4 <sparky4@cock.li>
Mon, 23 Mar 2015 22:16:16 +0000 (17:16 -0500)
modified:   scroll.exe
modified:   src/lib/mapread.c
modified:   src/lib/mapread.h
modified:   src/scroll.c

makefile
scroll.exe
src/lib/mapread.c
src/lib/mapread.h
src/scroll.c

index ebc15e3..61708a5 100644 (file)
--- a/makefile
+++ b/makefile
@@ -3,8 +3,8 @@ SRC=src\
 SRCLIB=$(SRC)lib\\r
 all: test.exe pcxtest.exe test2.exe scroll.exe\r
 \r
-scroll.exe: scroll.obj modex16.obj dos_kb.obj bitmap.obj\r
-       wcl $(FLAGS) scroll.obj modex16.obj dos_kb.obj bitmap.obj 16\lib\x\modex.lib\r
+scroll.exe: scroll.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj\r
+       wcl $(FLAGS) scroll.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj 16\lib\x\modex.lib\r
 scroll.obj: $(SRC)scroll.c\r
        wcl $(FLAGS) -c $(SRC)scroll.c\r
 test.exe: test.obj modex16.obj bitmap.obj\r
@@ -29,14 +29,20 @@ modex16.obj: $(SRCLIB)modex16.h $(SRCLIB)modex16.c
        wcl $(FLAGS) -c $(SRCLIB)modex16.c\r
 \r
 dos_kb.obj: $(SRCLIB)dos_kb.h $(SRCLIB)dos_kb.c\r
-       wcl $(FLAGS) -c $(SRCLIB)dos_kb.c\r
-\r
+       wcl $(FLAGS) -c $(SRCLIB)dos_kb.c
+
 bitmap.obj: $(SRCLIB)bitmap.h $(SRCLIB)bitmap.c\r
        wcl $(FLAGS) -c $(SRCLIB)bitmap.c\r
 \r
 planar.obj: $(SRCLIB)planar.h $(SRCLIB)planar.c\r
-       wcl $(FLAGS) -c $(SRCLIB)planar.c\r
-       \r
+       wcl $(FLAGS) -c $(SRCLIB)planar.c
+       
+mapread.obj: $(SRCLIB)mapread.h $(SRCLIB)mapread.c jsmn.obj\r
+       wcl $(FLAGS) -c $(SRCLIB)mapread.c\r
+
+jsmn.obj: $(SRCLIB)jsmn\jsmn.h $(SRCLIB)jsmn\jsmn.c\r
+       wcl $(FLAGS) -c $(SRCLIB)jsmn\jsmn.c
+\r
 clean: \r
        del *.obj\r
 #      del *.exe\r
index 7763541..6442f4d 100644 (file)
Binary files a/scroll.exe and b/scroll.exe differ
index 5cd4f1c..32d06c0 100644 (file)
@@ -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;
 }
 
index 2668262..dbb4bfa 100644 (file)
@@ -1,13 +1,14 @@
 #ifndef _LIBMAPREAD_H_
 #define _LIBMAPREAD_H_
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <errno.h>
-#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 {\r
        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_*/
index f03cda5..239883f 100644 (file)
@@ -118,8 +118,9 @@ void main() {
        }*/\r
 \r
        /* create the map */
-       loadmap("data/test.map", &map);\r
-       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\r
+       loadmap("data/test.map", &map/*, 0*/);\r
+       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);\r
        //if(isEMS()) printf("%d tesuto\n", coretotalEMS());\r
        initMap(&map);\r
        mv.map = &map;\r