]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/scroll16.c
==== INITIAL LAYER MAP STUFF DONE, added mapdraw layer ontop of bg, going to implemen...
[16.git] / src / lib / scroll16.c
index 47ee9f7f22674394fc91d8e04800b256fc14797d..469ed1f710051551cdeaceddf20d51a13130ac92 100755 (executable)
@@ -37,7 +37,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                //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->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
+                       !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=2;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -48,7 +48,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        //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->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
+                       else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=1;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -70,7 +70,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                //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->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
+                       !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=2;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -81,7 +81,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        //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->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
+                       else if(player[pn].enti.tx > 1 && !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=1;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -103,7 +103,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                //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->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
+                       !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=2;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -114,7 +114,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        //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->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
+                       else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=1;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -136,7 +136,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                //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->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
+                       !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=2;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -147,7 +147,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        //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->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
+                       else if(player[pn].enti.ty > 1 && !(pip[0].map->layerdata[0].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
                        {\r
                                player[pn].walktype=1;\r
                                if(player[pn].enti.q<=player[pn].enti.spt)\r
@@ -318,8 +318,8 @@ initMap(map_t *map) {
        i=0;\r
        for(y=0; y<map->height; y++) {\r
                for(x=0; x<map->width; x++) {\r
-                       map->MAPDATAPTR[i]=255;\r
-//                     printf("[%d]", map->MAPDATAPTR[i]);\r
+                       map->layerdata[0].data[i]=255;\r
+//                     printf("[%d]", map->layerdata[0].data[i]);\r
                        tile = tile ? 0 : 1;\r
                        i++;\r
                }\r
@@ -344,7 +344,7 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
        if(player[plid].enti.q==4)\r
 #endif\r
 //             if(id==0)\r
-                       mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);\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->MAPTILESPTR->tileWidth, mv[0].page->height);\r
@@ -366,7 +366,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
        if(player[plid].enti.q==4)\r
 #endif\r
 //             if(id==0)\r
-                       mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);\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->MAPTILESPTR->tileWidth, mv[0].page->height);\r
@@ -388,7 +388,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
        if(player[plid].enti.q==4)\r
 #endif\r
 //             if(id==0)\r
-                       mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWROWNUM);\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->MAPTILESPTR->tileHeight);\r
@@ -410,7 +410,7 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
        if(player[plid].enti.q==4)\r
 #endif\r
 //             if(id==0)\r
-                       mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWROWNUM);\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->MAPTILESPTR->tileHeight);\r
@@ -498,8 +498,8 @@ sword chkmap(map_t *map, word q)
                //initiate a null map!\r
                map->width=MAPW;///2;\r
                map->height=MAPH;///2;\r
-//             map->MAPDATAPTR = malloc(((map->width*map->height)+1)*sizeof(byte));\r
-               map->MAPDATAPTR = &x;\r
+//             map->layerdata[0].data = malloc(((map->width*map->height)+1)*sizeof(byte));\r
+               map->layerdata[0].data = &x;\r
                map->MAPTILESPTR = malloc(sizeof(tiles_t));\r
                //fix this to be far~\r
 //             bp = bitmapLoadPcx("data/ed.pcx");\r
@@ -589,59 +589,80 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
                break;\r
        }\r
 }\r
-\r
-void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset)\r
+#define PALMAPDRAWW 13\r
+void near mapDrawRow(map_view_t *mv, nibble id, int tx, int ty, word y, player_t *player, word poopoffset)\r
 {\r
-       int i;\r
+       int i; nibble z;\r
 if(pagedelayrendermap)         if(!y)  y+=TILEWH;      else    y-=TILEWH;\r
        poopoffset%=player[0].enti.speed;\r
 //printf("y: %d\n", poopoffset);\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, 1, 2, 1, global_temp_status_text); }\r
+if(pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv[id].dx); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 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->MAPTILESPTR->tileWidth, tx++) {\r
-               if(i>=0)\r
-                       mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, mv->dx, y);\r
+       i=ty * mv[id].map->width + tx;\r
+       for(    mv[id].dx=poopoffset;   mv[id].dx<(mv[id].page->sw+mv[id].dxThresh)/(poopoffset+1) && tx < mv[id].map->width;   mv[id].dx+=mv[id].map->MAPTILESPTR->tileWidth, tx++) {\r
+               if(i>=0){\r
+                       mapDrawTile(mv[id].map->MAPTILESPTR, mv[id].map->layerdata[0].data[i], mv[id].page, mv[id].dx, y);\r
+                       for(z=1;z<=2;z++){\r
+                               if(mv[id].map->layerdata[z].data[i]){\r
+                                       sprintf(global_temp_status_text2, "%u", mv[id].map->layerdata[z].data[i]); modexprint(mv[id].page, mv[id].dx, (y+((z-1)*4))>>2, 1, 0, PALMAPDRAWW, z+2, global_temp_status_text2);\r
+                                       //mapDrawTile(mv[id].map->MAPTILESPTR, mv[id].map->layerdata[z].data[i], mv[id].page, mv[id].dx, y);\r
+                               }\r
+                       }\r
+               }\r
                i++; /* next! */\r
        }\r
 if(pagedelayrendermap) delay(200);\r
 }\r
 \r
-void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset)\r
+void near mapDrawCol(map_view_t *mv, nibble id, int tx, int ty, word x, player_t *player, word poopoffset)\r
 {\r
-       int i;\r
+       int i; nibble z;\r
 if(pagedelayrendermap)         if(!x)  x+=TILEWH;              else    x-=TILEWH;\r
        poopoffset%=player[0].enti.speed;\r
 //printf("x: %d\n", poopoffset);\r
-if(pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv->dy); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 1, 2, 1, global_temp_status_text); }\r
+if(pagedelayrendermap){ sprintf(global_temp_status_text, "%-3u", mv[id].dy); modexprint(mv[0].page, player[0].enti.x, player[0].enti.y-28-(poopoffset*8) , 1, 1, 2, 1, global_temp_status_text); }\r
        /* location in the map array */\r
-       i=ty * mv->map->width + tx;\r
+       i=ty * mv[id].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->MAPTILESPTR->tileHeight, ty++) {\r
-               if(i>=0)\r
-                       mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, x, mv->dy);\r
-               i += mv->map->width;\r
+       for(    mv[id].dy=poopoffset;   mv[id].dy<(mv[id].page->sh+mv[id].dyThresh)/(poopoffset+1) && ty < mv[id].map->height;  mv[id].dy+=mv[id].map->MAPTILESPTR->tileHeight, ty++) {\r
+               if(i>=0){\r
+                       mapDrawTile(mv[id].map->MAPTILESPTR, mv[id].map->layerdata[0].data[i], mv[id].page, x, mv[id].dy);\r
+                       for(z=1;z<=2;z++){\r
+                               if(mv[id].map->layerdata[z].data[i]){\r
+                                       sprintf(global_temp_status_text2, "%u", mv[id].map->layerdata[z].data[i]); modexprint(mv[id].page, (x+((z-1)*4))>>2, mv[id].dy, 1, 0, PALMAPDRAWW, z+2, global_temp_status_text2);\r
+                                       //mapDrawTile(mv[id].map->MAPTILESPTR, mv[id].map->layerdata[z].data[i], mv[id].page, x, mv[id].dy);\r
+                               }\r
+                       }\r
+               }\r
+               i += mv[id].map->width;\r
        }\r
 if(pagedelayrendermap) delay(200);\r
 }\r
 \r
 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y)\r
 {\r
-       int i;\r
+       int i; nibble z;\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->MAPTILESPTR->tileWidth, tx++) {\r
-               if(i>=0)        /* we are in the map, so copy! */\r
-                       mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, mv->dx, y);\r
+               if(i>=0){       /* we are in the map, so copy! */\r
+                       mapDrawTile(mv->map->MAPTILESPTR, mv->map->layerdata[0].data[i], mv->page, mv->dx, y);\r
+                       for(z=1;z<=2;z++){\r
+                               if(mv->map->layerdata[z].data[i]){\r
+                                       sprintf(global_temp_status_text2, "%u", mv->map->layerdata[z].data[i]); modexprint(mv->page, mv->dx, y, 1, 0, PALMAPDRAWW, z+2, global_temp_status_text2);\r
+                                       //mapDrawTile(mv->map->MAPTILESPTR, mv->map->layerdata[z].data[i], mv->page, mv->dx, y);\r
+                               }\r
+                       }\r
+               }\r
                i++; /* next! */\r
        }\r
 }\r
 \r
 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)\r
 {\r
-       int i;\r
+       int i; nibble z;\r
 \r
        /* location in the map array */\r
        i=ty * mv->map->width + tx;\r
@@ -649,8 +670,15 @@ void mapDrawWCol(map_view_t *mv, int tx, int ty, word x)
        /* 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->MAPTILESPTR->tileHeight, ty++) {\r
-               if(i>=0)        /* we are in the map, so copy away! */\r
-                       mapDrawTile(mv->map->MAPTILESPTR, mv->map->MAPDATAPTR[i], mv->page, x, mv->dy);\r
+               if(i>=0){       /* we are in the map, so copy away! */\r
+                       mapDrawTile(mv->map->MAPTILESPTR, mv->map->layerdata[0].data[i], mv->page, x, mv->dy);\r
+                       for(z=1;z<=2;z++){\r
+                               if(mv->map->layerdata[z].data[i]){\r
+                                       sprintf(global_temp_status_text2, "%u", mv->map->layerdata[z].data[i]); modexprint(mv->page, x, mv->dy, 1, 0, PALMAPDRAWW, z+2, global_temp_status_text2);\r
+                                       //mapDrawTile(mv->map->MAPTILESPTR, mv->map->layerdata[z].data[i], mv->page, x, mv->dy);\r
+                               }\r
+                       }\r
+               }\r
                i += mv->map->width;\r
        }\r
 }\r