]> 4ch.mooo.com Git - 16.git/commitdiff
cannot work on this much more i gotta do school project and final
authorsparky4 <sparky4@cock.li>
Fri, 17 Feb 2017 15:50:21 +0000 (09:50 -0600)
committersparky4 <sparky4@cock.li>
Fri, 17 Feb 2017 15:50:21 +0000 (09:50 -0600)
MAPTEST.L16 [new file with mode: 0755]
data/test.map
data/test.tmx
src/lib/16_map.c
src/lib/16_map.h
src/lib/16_tdef.h
src/lib/16_vrs.c
src/lib/16_vrs.h
src/maptest.c

diff --git a/MAPTEST.L16 b/MAPTEST.L16
new file mode 100755 (executable)
index 0000000..b9b3513
--- /dev/null
@@ -0,0 +1,13 @@
+objects detected\r
+Object 4's name: (name size is 5)[\r
+'trunk'\r
+]\r
+'{\r
+\r
+                    }'Object 4's name: (name size is 5)[\r
+'stump'\r
+]\r
+'{\r
+\r
+                    }'map.width=       40\r
+map.height=    30\r
index 03307badc87ffb084fb608bc8d803b3d1d725a8f..0b1757c85809ef43dea5eb100a801994bee95a9b 100755 (executable)
@@ -43,7 +43,7 @@
                  "name":"trunk",
                  "properties":
                     {
-
+                     "walkable":"0"
                     },
                  "type":"nonc",
                  "visible":true,
@@ -56,7 +56,7 @@
                  "name":"stump",
                  "properties":
                     {
-
+                     "walkable":"0"
                     },
                  "type":"nonc",
                  "visible":true,
index 5ccdb602e3022b08f1f1dbf0eee11574f11de3b2..fee932f375f27b0b1cfe167d8d59831a1c3b74b2 100755 (executable)
 </data>
  </layer>
  <objectgroup name="ob" width="40" height="30">
-  <object name="trunk" type="nonc" x="128" y="32" width="32" height="16"/>
-  <object name="stump" type="nonc" x="144" y="128" width="16" height="16"/>
+  <object name="trunk" type="nonc" x="128" y="32" width="32" height="16">
+   <properties>
+    <property name="walkable" value="0"/>
+   </properties>
+  </object>
+  <object name="stump" type="nonc" x="144" y="128" width="16" height="16">
+   <properties>
+    <property name="walkable" value="0"/>
+   </properties>
+  </object>
  </objectgroup>
 </map>
index 931afe435553116819dcd7682dc26ba1cfaf992f..2616778109b6b2559e5ff25271e6c7cd049cf225 100755 (executable)
@@ -46,23 +46,20 @@ void extract_map(const char *js, jsmntok_t *t, size_t count, map_t *map) {
                        inner_end = t[i].end;\r
                        k = 0;\r
                        while(t[i].start < inner_end) {\r
-#ifdef DEBUG_DUMPVARS\r
-                               printf("t[%d].start=%d, %d\n", i, t[i].start, inner_end);\r
-#endif\r
+//#define DEBUG_DUMPVARS\r
+//#ifdef DEBUG_DUMPVARS\r
+//                             printf("t[%d].start=%d, %d\n", i, t[i].start, inner_end);\r
+//#endif\r
                                if(!objlay){\r
                                if(jsoneq(js, &(t[i]), "data") == 0) {\r
 #ifdef DEBUG_MAPDATA\r
                                        printf("Layer %d data: (size is %d)[\n", k, t[i+1].size);\r
 #endif\r
                                        map->layerdata[k].data = malloc(sizeof(byte) * t[i+1].size);//TODO: USE MM_ CA_ AND PM_\r
-//                                     map->data = (map->layerdata[k].data); //for backwards compatibility for rest of code\r
                                        for(j = 0; j < t[i+1].size; j++) {\r
-                                               //map->layerdata[k][j] = (byte)atoi(js + t[i+2+j].start);\r
                                                map->layerdata[k].data[j] = (byte)atoi(js + t[i+2+j].start);\r
 #ifdef DEBUG_MAPDATA\r
-                                               //printf("[%d,%d]%d", k, j, map->MAPDATAPTK[j]);\r
-                                               printf("%c",  map->MAPDATAPTK[j]+44);\r
-                                               //fprintf(stdout, "%c", map->data[j]+44);\r
+                                               printf("%c",  map->layerdata[k].data[j]+44);\r
 #endif\r
                                        }\r
                                        i += j + 2;\r
@@ -70,13 +67,13 @@ void extract_map(const char *js, jsmntok_t *t, size_t count, map_t *map) {
                                        puts("\n]");\r
 #endif\r
                                }else if(jsoneq(js, &(t[i]), "name") == 0) {\r
-#ifdef DEBUG_MAPDATA\r
+#ifdef DEBUG_MAPVARS\r
                                        printf("Layer %d's name: (size is %d)[\n", k, MAPLNAMESIZE);\r
 #endif\r
-                                       map->layerdata[k].layername = malloc(sizeof(byte) * MAPLNAMESIZE);//TODO: USE MM_ CA_ AND PM_\r
-                                       strncpy(map->layerdata[k].layername, js+t[i+1].start, MAPLNAMESIZE);\r
-                                       if(map->layerdata[k].layername[MAPLNAMESIZE]!=0) map->layerdata[k].layername[MAPLNAMESIZE]='\0';\r
-                                       if(strstr(map->layerdata[k].layername, "ob")) objlay=1;\r
+                                       //map->layerdata[k].layername = malloc(sizeof(byte) * MAPLNAMESIZE);//TODO: USE MM_ CA_ AND PM_\r
+                                       strncpy(&(map->layerdata[k].layername), js+t[i+1].start, MAPLNAMESIZE);\r
+                                       if((map->layerdata[k].layername[MAPLNAMESIZE])!=0) map->layerdata[k].layername[MAPLNAMESIZE]='\0';\r
+                                       if(strstr(&map->layerdata[k].layername, "ob")) objlay=1;\r
 #ifdef DEBUG_MAPDATA\r
                                        printf("%s", map->layerdata[k].layername);\r
                                        printf("\n]\n");\r
@@ -84,24 +81,33 @@ void extract_map(const char *js, jsmntok_t *t, size_t count, map_t *map) {
                                        k++;\r
                                }\r
                                }else{ //objlay\r
-                               if(jsoneq(js, &(t[i]), "objects") == 0) {\r
-#ifdef DEBUG_MAPDATA\r
-                                       printf("objects detected\n");\r
+                                       if(jsoneq(js, &(t[i]), "objects") == 0) {\r
+#ifdef DEBUG_OBVARS\r
+                                               printf("objects detected\n");\r
 #endif\r
-//                                     map->layerdata[k].layername = mAlloc(sizeof(byte) * MAPLNAMESIZE);//TODO: USE MM_ CA_ AND PM_\r
-//                                     strncpy(map->layerdata[k].layername, js+t[i+1].start, MAPLNAMESIZE);//TODO: USE MM_ CA_ AND PM_\r
-//                                     if(map->layerdata[k].layername[MAPLNAMESIZE]!=0) map->layerdata[k].layername[MAPLNAMESIZE]='\0';\r
-                               }else if(jsoneq(js, &(t[i]), "name") == 0) {\r
-#ifdef DEBUG_MAPDATA\r
-                                       printf("Object %d's name: (size is %d)[\n", k, MAPLNAMESIZE);\r
-                                       printf("'%.*s'", t[i+1].end - t[i+1].start, js+t[i+1].start);\r
-                                       printf("\n]\n");\r
+#ifdef DEBUG_OBVARS\r
+\r
 #endif\r
+//                                             map->layerdata[k].layername = mAlloc(sizeof(byte) * MAPLNAMESIZE);//TODO: USE MM_ CA_ AND PM_\r
+//                                             strncpy(map->layerdata[k].layername, js+t[i+1].start, MAPLNAMESIZE);//TODO: USE MM_ CA_ AND PM_\r
+//                                             if(map->layerdata[k].layername[MAPLNAMESIZE]!=0) map->layerdata[k].layername[MAPLNAMESIZE]='\0';\r
+                                       }else if(jsoneq(js, &(t[i]), "name") == 0) {\r
+#ifdef DEBUG_OBVARS\r
+                                               printf("Object %d's name: ", k);//, MAPLNAMESIZE\r
+                                               printf("'%.*s'\n", t[i+1].end - t[i+1].start, js+t[i+1].start);\r
+#endif\r
+                                       }else if(jsoneq(js, &(t[i]), "properties") == 0) {\r
+#ifdef DEBUG_OBVARS\r
+                                               printf("        properties: %.*s\n", t[i+1].end - t[i+1].start, js+t[i+1].start);\r
+#endif\r
+                                       }else if(jsoneq(js, &(t[i]), "walkable") == 0) {\r
+                                                       printf("                walkable: %d\n", atoi(js + t[i+1].start));\r
                                        }\r
-                               }\r
-                               i++;\r
-                       }\r
-               }\r
+\r
+                               }//end objlay\r
+                               i++;//next token\r
+                       }//tokens\r
+               }//layers\r
 \r
 \r
                if(jsoneq(js, &(t[i]), "tilesets") == 0) {\r
@@ -124,13 +130,13 @@ void extract_map(const char *js, jsmntok_t *t, size_t count, map_t *map) {
                                        i++;\r
                                }else if(jsoneq(js, &(t[i]), "tileheight") == 0) {\r
                                        map->tiles->tileHeight = atoi(js + t[i+1].start);\r
-#ifdef DEBUG_MAPVAR\r
+#ifdef DEBUG_MAPVARS\r
                                        printf("Tile Height: %d\n", map->tiles->tileHeight);\r
 #endif\r
                                        i++;\r
                                }else if(jsoneq(js, &(t[i]), "tilewidth") == 0) {\r
                                        map->tiles->tileWidth = atoi(js + t[i+1].start);\r
-#ifdef DEBUG_MAPVAR\r
+#ifdef DEBUG_MAPVARS\r
                                        printf("Tile Width: %d\n", map->tiles->tileWidth);\r
 #endif\r
                                        i++;\r
@@ -142,14 +148,14 @@ void extract_map(const char *js, jsmntok_t *t, size_t count, map_t *map) {
 \r
                if (jsoneq(js, &(t[i]), "height") == 0 && indent<=1) {\r
                        map->height = atoi(js + t[i+1].start);\r
-#ifdef DEBUG_MAPVAR\r
+#ifdef DEBUG_MAPVARS\r
                        printf("Height: %d\n", map->height);\r
 #endif\r
                        i++;\r
                }\r
                else if(jsoneq(js, &(t[i]), "width") == 0 && indent<=1) {\r
                        map->width = atoi(js + t[i+1].start);\r
-#ifdef DEBUG_MAPVAR\r
+#ifdef DEBUG_MAPVARS\r
                        printf("Width: %d\n", map->width);\r
 #endif\r
                        i++;\r
index e8290486aa45f6832bdf4132b23420a666f73045..8ea0ec19856647053641223294302dc68aa90bed 100755 (executable)
@@ -34,8 +34,8 @@
 #include "src/lib/16_pm.h"\r
 \r
 //#define DEBUG_MAPDATA\r
-//#define DEBUG_MAPVAR\r
-//#define DEBUG_DUMPVARS\r
+//#define DEBUG_MAPVARS\r
+#define DEBUG_OBVARS\r
 //#define DEBUG_JS\r
 \r
 //typedefs moved to 16_tdef.h\r
index ec92baaa11bc12cf945e62cf6d14b2d758b11b8f..9df1eee955c4eab926d400bec6617e2e4355e198 100755 (executable)
@@ -104,7 +104,7 @@ typedef struct {
 //TODO: 16_mm and 16_ca must handle this\r
 //TODO: add variables from 16_ca\r
 typedef struct {\r
-       byte    *layername;\r
+       byte    layername[8];\r
        byte    *data;                  //TODO: 16_mm and 16_ca must handle this\r
 } mapl_t;      //map layer array type def\r
 \r
index f77c7e3c5427467d7d631880120e77d9d42ac534..efb62ba8fc4fd122a99683c7836ff00691c62b26 100755 (executable)
@@ -78,64 +78,6 @@ void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_varia
        enti->spri.sprite_vrl_cont = malloc(sizeof(struct vrl_container));\r
 }\r
 \r
-// Read .vrs file into far memory\r
-int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container *vrs_cont){\r
-       int fd;\r
-       dword size;\r
-       byte far *buffer;\r
-       vrl1_vgax_offset_t **vrl_line_offsets;\r
-       uint32_t far *vrl_headers_offsets;\r
-       uint16_t far *vrl_id_iter;\r
-       uint32_t vrl_size;\r
-       int num_of_vrl=0, i;\r
-       struct vrl1_vgax_header far *curr_vrl;\r
-       int success=1;\r
-\r
-       // Open filename, get size of file,\r
-       // populate the vrs_container if all tests pass\r
-       fd = open(filename, O_RDONLY|O_BINARY);\r
-       // Insert sanity cheks later\r
-       size = lseek(fd, 0, SEEK_END);\r
-       buffer = malloc(size);\r
-       lseek(fd, 0, SEEK_SET);\r
-       read(fd, buffer, size);\r
-       close(fd);\r
-       if(!success)\r
-       {\r
-               Quit (gvar, "Unable to load file");\r
-       }\r
-       vrs_cont->data_size = size - sizeof(struct vrs_header);\r
-       vrs_cont->buffer = buffer;\r
-\r
-       // Calculate vrl offsets\r
-\r
-       // Count sprites\r
-       vrl_id_iter = (uint16_t far *)(buffer + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST]);\r
-       while(vrl_id_iter[num_of_vrl]){\r
-               num_of_vrl++;\r
-       }\r
-       // Allocate memory for vrl line offsets table\r
-       vrl_line_offsets = malloc(sizeof(vrl1_vgax_offset_t *)*num_of_vrl);\r
-\r
-       vrl_headers_offsets = (uint32_t far *)(buffer + vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_VRS_LIST]);\r
-       // Calculate line offsets for each vrl\r
-       for(i = 0; i < num_of_vrl; i++){\r
-               curr_vrl = (struct vrl1_vgax_header far *)(buffer + vrl_headers_offsets[i]);\r
-\r
-               // Calc. vrl size as (next_offset - curr_offset)\r
-               if (i != num_of_vrl - 1){\r
-                       vrl_size = vrl_headers_offsets[i+1] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
-               }\r
-               // If it's the last vrl, size is (next_vrs_struct_offset - curr_offset)\r
-               else{\r
-                       vrl_size = vrs_cont->vrs_hdr->offset_table[VRS_HEADER_OFFSET_SPRITE_ID_LIST] - vrl_headers_offsets[i] - sizeof(struct vrl1_vgax_header);\r
-               }\r
-               vrl_line_offsets[i] = vrl1_vgax_genlineoffsets(curr_vrl, (byte *)curr_vrl + sizeof(struct vrl1_vgax_header), vrl_size);\r
-       }\r
-       vrs_cont->vrl_line_offsets = vrl_line_offsets;\r
-       return 0;\r
-}\r
-\r
 // Seek and return a specified .vrl blob from .vrs blob in far memory\r
 int get_vrl_by_id(struct vrs_container far *vrs_cont, uint16_t id, struct vrl_container *vrl_cont){\r
        uint16_t far *ids;\r
index 068f569fa9fbf89b7f8d48690313e91f71ee6020..9a089f471f645c540160885a06eda40fbdae85a2 100755 (executable)
@@ -64,7 +64,6 @@ struct vrl_container{
 void VRS_ReadVRS(char *filename, entity_t *enti, global_game_variables_t *gvar);\r
 void VRS_LoadVRS(char *filename, entity_t *enti, global_game_variables_t *gvar);\r
 void VRS_OpenVRS(char *filename, entity_t *enti, boolean rlsw, global_game_variables_t *gvar);\r
-//int read_vrs(global_game_variables_t *gvar, char *filename, struct vrs_container *vrs_cont);\r
 \r
 /* Seek and return a specified .vrl blob from .vrs blob in memory\r
 * In:\r
index a605a8efef4551a2c1da94daabe2120c9dc1a939..11097deb6911bb1f1cd6be7a199a7a455f47a97a 100755 (executable)
@@ -22,7 +22,7 @@
 #include "src/lib/16_map.h"\r
 \r
 #define DUMP\r
-#define DUMP_MAP\r
+//#define DUMP_MAP\r
 \r
 void\r
 main(int argc, char *argv[])\r
@@ -37,23 +37,20 @@ main(int argc, char *argv[])
 #endif\r
        char *fmt = "Memory available = %u\n";\r
        char *fmt0 = "Largest Contiguous Block of Memory available = %u\n";\r
-       byte *datboi = "oh shit waddup!\n";\r
+       //byte *datboi = "oh shit waddup!\n";\r
 \r
        MM_Startup(&gvar);\r
        PM_Startup(&gvar);\r
        //printf("pmstarted ok\n");\r
-       //PM_CheckMainMem(&gvar);\r
+       PM_CheckMainMem(&gvar);\r
        PM_UnlockMainMem(&gvar);\r
        CA_Startup(&gvar);\r
 \r
        fprintf(stderr, fmt, _memavl());\r
        fprintf(stderr, fmt0, _memmax());\r
        fprintf(stderr, "Size of map var = %u\n", _msize(&(gvar.ca.camap.mapsegs)));\r
-       //fprintf(stderr, "program always crashes for some reason....\n");\r
        //getch();\r
 \r
-       //loadmap("data/test.map", &map);\r
-       //newloadmap("data/test.map", &map);\r
        CA_loadmap("data/test.map", &map, &gvar);\r
 #ifdef DUMP\r
        fprintf(stdout, "map.width=     %d\n", map.width);\r
@@ -86,9 +83,7 @@ main(int argc, char *argv[])
        fprintf(stdout, "&map.height==%Fp\n", map.height);\r
        fprintf(stdout, "&map.data==%Fp\n", map.data);*/\r
 #endif\r
-       fprintf(stderr, "here comes dat boi!\n");\r
-       getch();\r
-       fprintf(stderr, "%s", datboi);\r
+       //fprintf(stderr, "here comes dat boi!\n"); getch(); fprintf(stderr, "%s", datboi);\r
        MM_FreePtr(&(gvar.ca.camap.mapsegs), &gvar);\r
        PM_Shutdown(&gvar);\r
        CA_Shutdown(&gvar);\r