--- /dev/null
+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
"name":"trunk",
"properties":
{
-
+ "walkable":"0"
},
"type":"nonc",
"visible":true,
"name":"stump",
"properties":
{
-
+ "walkable":"0"
},
"type":"nonc",
"visible":true,
</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>
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
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
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
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
\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
#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
//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
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
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
#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
#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
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