while(i<count) {\r
if(jsoneq(js, &(t[i]), "layers") == 0) {\r
i++;\r
- map->layerdata = malloc(sizeof(byte*) * t[i].size);\r
+ //map->layerdata = malloc(sizeof(byte*) * t[i].size);\r
inner_end = t[i].end;\r
k = 0;\r
while(t[i].start < inner_end) {\r
#ifdef DEBUG_MAPDATA\r
printf("Layer %d data: [\n", k);\r
#endif\r
- map->layerdata[k] = malloc(sizeof(byte) * t[i+1].size);\r
- map->data = map->layerdata[k];\r
+ map->MAPDATAPTK = malloc(sizeof(byte) * t[i+1].size);\r
+ //for backwards compatibility for rest of code\r
+// map->data = map->MAPDATAPTK;\r
for(j = 0; j < t[i+1].size; j++) {\r
- map->layerdata[k][j] = (byte)atoi(js + t[i+2+j].start);\r
- //for backwards compatibility for rest of code\r
-// map->data[j] = map->layerdata[k][j];//(byte)atoi(js + t[i+2+j].start);//(byte)atoi(js+t->start);\r
+ map->MAPDATAPTK[j] = (byte)atoi(js + t[i+2+j].start);\r
#ifdef DEBUG_MAPDATA\r
- //printf("[%d,%d]%d", k, j, map->layerdata[k][j]);\r
+ //printf("[%d,%d]%d", k, j, map->MAPDATAPTK[j]);\r
fprintf(stdout, "%c", map->data[j]+44);\r
#endif\r
}\r
k = 0;\r
while(t[i].start < inner_end) {\r
if(jsoneq(js, &(t[i]), "image") == 0) {\r
- map->layertile[k] = malloc(sizeof(tiles_t));\r
+ map->MAPTILESPTK = malloc(sizeof(tiles_t));\r
s = remove_ext((char *)js+t[i+1].start, '.', '/');\r
- strcpy(map->layertile[k]->imgname, s);\r
+ strcpy(map->MAPTILESPTK->imgname, s);\r
//And move to vrs, probably\r
// bp = bitmapLoadPcx("data/ed.pcx");\r
-// map->layertile[k]->btdata = &bp;\r
- //map->layertile[k]->btdata = malloc(sizeof(bitmap_t));\r
- map->layertile[k]->rows = 1;\r
- map->layertile[k]->cols = 1;\r
+// map->MAPTILESPTK->btdata = &bp;\r
+ //map->MAPTILESPTK->btdata = malloc(sizeof(bitmap_t));\r
+ map->MAPTILESPTK->rows = 1;\r
+ map->MAPTILESPTK->cols = 1;\r
#ifdef __DEBUG_MAP__\r
dbg_maptext=false;\r
#endif\r
i++;\r
}else if(jsoneq(js, &(t[i]), "tileheight") == 0) {\r
- map->layertile[k]->tileHeight = atoi(js + t[i+1].start);\r
+ map->MAPTILESPTK->tileHeight = atoi(js + t[i+1].start);\r
i++;\r
}else if(jsoneq(js, &(t[i]), "tilewidth") == 0) {\r
- map->layertile[k]->tileWidth = atoi(js + t[i+1].start);\r
+ map->MAPTILESPTK->tileWidth = atoi(js + t[i+1].start);\r
i++;\r
}\r
i++;\r
//right movement\r
case 3:\r
if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&\r
- !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!\r
+ !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!\r
{\r
player[pn].walktype=2;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
//0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
} else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }\r
}\r
- else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))\r
+ else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY))\r
{\r
player[pn].walktype=1;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
//left movement\r
case 1:\r
if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx &&\r
- !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!\r
+ !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection!\r
{\r
player[pn].walktype=2;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
//0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
} else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }\r
}\r
- else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))\r
+ else if(player[pn].enti.tx > 1 && !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY))\r
{\r
player[pn].walktype=1;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
//down movement\r
case 4:\r
if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&\r
- !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!\r
+ !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection!\r
{\r
player[pn].walktype=2;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
//0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
} else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }\r
}\r
- else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))\r
+ else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY))\r
{\r
player[pn].walktype=1;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
//up movement\r
case 0:\r
if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny &&\r
- !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!\r
+ !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection!\r
{\r
player[pn].walktype=2;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
//0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
} else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }\r
}\r
- else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))\r
+ else if(player[pn].enti.ty > 1 && !(pip[0].map->MAPDATAPTR[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY))\r
{\r
player[pn].walktype=1;\r
if(player[pn].enti.q<=player[pn].enti.spt)\r
i=0;\r
for(y=0; y<map->height; y++) {\r
for(x=0; x<map->width; x++) {\r
- map->data[i]=255;\r
-// printf("[%d]", map->data[i]);\r
+ map->MAPDATAPTR[i]=255;\r
+// printf("[%d]", map->MAPDATAPTR[i]);\r
tile = tile ? 0 : 1;\r
i++;\r
}\r
ScrollRight(mv, player, id, plid);\r
\r
/* draw the next column */\r
- x= mv[0].page->sw + mv[0].map->layertile[0]->tileWidth;\r
+ x= mv[0].page->sw + mv[0].map->MAPTILESPTR->tileWidth;\r
#ifndef FULLRCREND\r
if(player[plid].enti.q%4)\r
#else\r
mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);\r
// else\r
// if(mv[0].video->bgps)\r
-// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->layertile[0]->tileWidth, mv[0].page->height);\r
+// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->MAPTILESPTR->tileWidth, mv[0].page->height);\r
//mv[0].video->dorender=1;//ScrollRight\r
}\r
\r
mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);\r
// else\r
// if(mv[0].video->bgps)\r
-// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->layertile[0]->tileWidth, mv[0].page->height);\r
+// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->MAPTILESPTR->tileWidth, mv[0].page->height);\r
//mv[0].video->dorender=1;//ScrollLeft\r
}\r
\r
mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWROWNUM);\r
// else\r
// if(mv[0].video->bgps)\r
-// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->layertile[0]->tileHeight);\r
+// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->MAPTILESPTR->tileHeight);\r
//mv[0].video->dorender=1;//ScrollUp\r
}\r
\r
ScrollDown(mv, player, id, plid);\r
\r
/* draw the next row */\r
- y= mv[0].page->sh + mv[0].map->layertile[0]->tileHeight;\r
+ y= mv[0].page->sh + mv[0].map->MAPTILESPTR->tileHeight;\r
#ifndef FULLRCREND\r
if(player[plid].enti.q%3)\r
#else\r
mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWROWNUM);\r
// else\r
// if(mv[0].video->bgps)\r
-// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->layertile[0]->tileHeight);\r
+// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->MAPTILESPTR->tileHeight);\r
//mv[0].video->dorender=1;//ScrollDown\r
}\r
\r
//initiate a null map!\r
map->width=MAPW;///2;\r
map->height=MAPH;///2;\r
-// map->data = malloc(((map->width*map->height)+1)*sizeof(byte));\r
- map->data = &x;\r
- map->layertile[0] = malloc(sizeof(tiles_t));\r
+// map->MAPDATAPTR = malloc(((map->width*map->height)+1)*sizeof(byte));\r
+ map->MAPDATAPTR = &x;\r
+ map->MAPTILESPTR = malloc(sizeof(tiles_t));\r
//fix this to be far~\r
// bp = bitmapLoadPcx("data/ed.pcx");\r
-// map->layertile[0]->data = &bp;\r
- map->layertile[0]->tileHeight = 16;\r
- map->layertile[0]->tileWidth = 16;\r
- map->layertile[0]->rows = 1;\r
- map->layertile[0]->cols = 1;\r
+// map->MAPTILESPTR->data = &bp;\r
+ map->MAPTILESPTR->tileHeight = 16;\r
+ map->MAPTILESPTR->tileWidth = 16;\r
+ map->MAPTILESPTR->rows = 1;\r
+ map->MAPTILESPTR->cols = 1;\r
#ifdef __DEBUG_MAP__\r
dbg_maptext = true;\r
#endif\r
/* set up the coordinates */\r
mv[0].tx = mv[1].tx = tx;\r
mv[0].ty = mv[1].ty = ty;\r
- mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->layertile[0]->tileWidth;\r
- mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->layertile[0]->tileHeight;\r
+ mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->MAPTILESPTR->tileWidth;\r
+ mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->MAPTILESPTR->tileHeight;\r
\r
/* set up the thresholds */\r
- mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->layertile[0]->tileWidth * 2;\r
- mv[0].dyThresh = mv[1].dyThresh = mv[2].dyThresh = mv[3].dyThresh = mv->map->layertile[0]->tileHeight * 2;\r
+ mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->MAPTILESPTR->tileWidth * 2;\r
+ mv[0].dyThresh = mv[1].dyThresh = mv[2].dyThresh = mv[3].dyThresh = mv->map->MAPTILESPTR->tileHeight * 2;\r
}\r
\r
void ZC_mapredraw(map_view_t *mv, int tx, int ty)\r
\r
py=0;\r
i=mv[0].ty * mv[0].map->width + mv[0].tx;\r
- for(ty=mv[0].ty-1; py < mv[0].page->sh+mv->dyThresh && ty < mv[0].map->height; ty++, py+=mv[0].map->layertile[0]->tileHeight) {\r
+ for(ty=mv[0].ty-1; py < mv[0].page->sh+mv->dyThresh && ty < mv[0].map->height; ty++, py+=mv[0].map->MAPTILESPTR->tileHeight) {\r
mapDrawWRow(&mv[0], tx-1, ty, py);\r
mapDrawWRow(&mv[1], tx-1, ty, py);\r
i+=mv->map->width - tx;\r
if(pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv->dx); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 2, 1, global_temp_status_text); }\r
/* the position within the map array */\r
i=ty * mv->map->width + tx;\r
- for( mv->dx=poopoffset; mv->dx<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; mv->dx+=mv->map->layertile[0]->tileWidth, tx++) {\r
+ for( mv->dx=poopoffset; mv->dx<(mv->page->sw+mv->dxThresh)/(poopoffset+1) && tx < mv->map->width; mv->dx+=mv->map->MAPTILESPTR->tileWidth, tx++) {\r
if(i>=0)\r
- mapDrawTile(mv->map->layertile[0], mv->map->data[i], mv->page, mv->dx, y);\r
+ mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, mv->dx, y);\r
i++; /* next! */\r
}\r
if(pagedelayrendermap) delay(200);\r
i=ty * mv->map->width + tx;\r
/* We'll copy all of the columns in the screen,\r
i + 1 row above and one below */\r
- for( mv->dy=poopoffset; mv->dy<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; mv->dy+=mv->map->layertile[0]->tileHeight, ty++) {\r
+ for( mv->dy=poopoffset; mv->dy<(mv->page->sh+mv->dyThresh)/(poopoffset+1) && ty < mv->map->height; mv->dy+=mv->map->MAPTILESPTR->tileHeight, ty++) {\r
if(i>=0)\r
- mapDrawTile(mv->map->layertile[0], mv->map->data[i], mv->page, x, mv->dy);\r
+ mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, x, mv->dy);\r
i += mv->map->width;\r
}\r
if(pagedelayrendermap) delay(200);\r
\r
/* the position within the map array */\r
i=ty * mv->map->width + tx;\r
- for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->layertile[0]->tileWidth, tx++) {\r
+ for(mv->dx=0; mv->dx<mv->page->sw+mv->dxThresh && tx < mv->map->width; mv->dx+=mv->map->MAPTILESPTR->tileWidth, tx++) {\r
if(i>=0) /* we are in the map, so copy! */\r
- mapDrawTile(mv->map->layertile[0], mv->map->data[i], mv->page, mv->dx, y);\r
+ mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, mv->dx, y);\r
i++; /* next! */\r
}\r
}\r
\r
/* We'll copy all of the columns in the screen,\r
i + 1 row above and one below */\r
- for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->layertile[0]->tileHeight, ty++) {\r
+ for(mv->dy=0; mv->dy<mv->page->sh+mv->dyThresh && ty < mv->map->height; mv->dy+=mv->map->MAPTILESPTR->tileHeight, ty++) {\r
if(i>=0) /* we are in the map, so copy away! */\r
- mapDrawTile(mv->map->layertile[0], mv->map->data[i], mv->page, x, mv->dy);\r
+ mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, x, mv->dy);\r
i += mv->map->width;\r
}\r
}\r
break;\r
}\r
x-=4;\r
- y-=pip[0].map->layertile[0]->tileHeight;\r
+ y-=pip[0].map->MAPTILESPTR->tileHeight;\r
switch (player[pn].enti.d)\r
{\r
case 0:\r