]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/scroll16.c
zcroll16 merged with scroll16
[16.git] / src / lib / scroll16.c
index b94e768a77c1a8d4813111caa3e2bdae39c36cf3..d6b1a06a94f4f6e82d9bf543ec8eb62cda5f14be 100755 (executable)
 \r
 void walk(map_view_t *pip, player_t *player, word pn)\r
 {\r
+//                     modexLeave();\r
+//                     IN_Shutdown();\r
+//                     exit(-5);\r
+\r
        #define INC_PER_FRAME if(player[pn].q&1) player[pn].persist_aniframe++; if(player[pn].persist_aniframe>4) player[pn].persist_aniframe = 1;\r
        //printf("player[%d].d=%d\n", pn, player[pn].d);\r
        switch(player[pn].d)\r
@@ -362,7 +366,7 @@ initMap(map_t *map) {
 \r
 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)\r
 {\r
-       word x, y;  /* coordinate for drawing */\r
+       word x;//, y;  /* coordinate for drawing */\r
 \r
        /* increment the pixel position and update the page */\r
        mv[id].page->dx += player[plid].speed;\r
@@ -392,7 +396,7 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
 \r
 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)\r
 {\r
-       word xy;  /* coordinate for drawing */\r
+       word x;//,y;  /* coordinate for drawing */\r
 \r
        /* decrement the pixel position and update the page */\r
        mv[id].page->dx -= player[plid].speed;\r
@@ -422,7 +426,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
 \r
 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)\r
 {\r
-       word x, y;  /* coordinate for drawing */\r
+       word y;//x,  /* coordinate for drawing */\r
 \r
        /* decrement the pixel position and update the page */\r
        mv[id].page->dy -= player[plid].speed;\r
@@ -451,7 +455,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
 \r
 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)\r
 {\r
-       word x, y;  /* coordinate for drawing */\r
+       word y;//x,  /* coordinate for drawing */\r
 \r
        /* increment the pixel position and update the page */\r
        mv[id].page->dy += player[plid].speed;\r
@@ -594,7 +598,7 @@ sword chkmap(map_t *map, word q)
 //TODO: player position here\r
 void mapGoTo(map_view_t *mv, int tx, int ty)\r
 {\r
-       int px, py;\r
+       int py;//px,\r
        unsigned int i;\r
 \r
        /* set up the coordinates */\r
@@ -634,8 +638,7 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y)
 {\r
        word rx;\r
        word ry;\r
-       word textx=0;\r
-       word texty=0;\r
+       //word textx=0, texty=0;\r
        //if(i==0) i=2;\r
        if(i==0)\r
        {\r
@@ -761,8 +764,8 @@ void shinku(global_game_variables_t *gv)
 {\r
        word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen\r
        word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen\r
-       word w = 64, h = 8, col = 7, bgcol = 0, type = 1;\r
-       byte o,o2,i;\r
+       word col = 7, bgcol = 0, type = 1;//w = 64, h = 8,\r
+       //byte o,o2,i;\r
        //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);\r
        /* block copy to visible RAM from offscreen */\r
 //     vga_setup_wm1_block_copy();\r
@@ -774,9 +777,16 @@ void shinku(global_game_variables_t *gv)
 //     vga_restore_rm0wm0();\r
        if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))\r
        {\r
-               sprintf(gv->pee, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));\r
+        // NTS: For some bizarre reason, gv->pee is not initialized, but the pointer is not NULL even\r
+        //      though it should be. Instead it's NULL as a near pointer but contains a non-null\r
+        //      segment value, so testing against NULL doesn't work. It is initialized properly if\r
+        //      you call start_timer() though which uses near malloc. Rather than fight with that,\r
+        //      I decided it would be better to declare a temp buffer statically and sprintf to that.\r
+        //\r
+        //      This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit.\r
+               sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));\r
                //modexClearRegion(&(gv->video.page[shinku_fps_indicator_page]), x, y, w, h, 45);\r
-               modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, gv->pee);\r
+               modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text);\r
                gv->kurokku.tiku=0;\r
                /* block copy to visible RAM from offscreen */\r
 //             vga_setup_wm1_block_copy();\r
@@ -914,3 +924,95 @@ void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scroll
        //printf("x=%d  y=%d    bx=%d           by=%d\n", x, y, bx, by);\r
        pip->video->r=1;\r
 }\r
+\r
+/*\r
+ * from zcroll16.c\r
+*/\r
+\r
+boolean boundary_check(int x, int y, int dx, int dy, int h, int w)\r
+{\r
+       return (dx > 0 && (x + dx) < w) || (dx < 0 && (x + dx) >= 0) || (dy > 0 && (y + dy) < h) || (dy < 0 && (y + dy) >= 0) || (dx == dy && dx == 0);\r
+}\r
+\r
+boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v)\r
+{\r
+       // Assume everything crosses at most 1 tile at once\r
+       return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v);\r
+}\r
+\r
+boolean ZC_walk(entity_t *ent, map_view_t *map_v)\r
+{\r
+       //return 1;\r
+       int dx = 1;\r
+       int dy = 1;\r
+       switch(ent->d)\r
+       {\r
+               case 2:\r
+                       return 0;\r
+               case 1:\r
+                       dx = -dx;\r
+               case 3:\r
+                       dy = 0;\r
+                       break;\r
+               case 0:\r
+                       dy = -dy;\r
+               case 4:\r
+                       dx = 0;\r
+                       break;\r
+       }\r
+       if(coll_check(ent->x, ent->y, dx, dy,  map_v))\r
+       {\r
+               // Allow movement\r
+               // Set speed\r
+               // Start animation\r
+               // Mark next tile as occupied\r
+               // Mark this tile as vacant\r
+               return 1;\r
+       }\r
+       return 0;\r
+}\r
+\r
+void player_walk(player_t *player, map_view_t *map_v){\r
+       int dx=16, dy=16;\r
+       if(ZC_walk(player->ent, map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh))\r
+       {\r
+               mapScroll(map_v, player);\r
+               // (Un)load stuff?\r
+       }\r
+}\r
+\r
+void near mapScroll(map_view_t *mv, player_t *player)\r
+{\r
+       //word x, y;  /* coordinate for drawing */\r
+       int c = 1;\r
+       int delta;\r
+       mv->delta += player->dx | player->dy;\r
+       delta = mv->delta;\r
+       mv->d = (player->dx) ? (player->dx > 0) ? 3 : 1 : (player->dy) ? (player->dy > 0) ? 4 : 0 : 2;\r
+       switch(mv->d){\r
+               case 4:\r
+                       c = -1;\r
+                       delta = -delta;\r
+               case 0:\r
+                       if(!(delta + mv->dxThresh))\r
+                       {\r
+                               mv->delta = 0;\r
+                               mv->ty += c;\r
+                       }\r
+                       break;\r
+               case 3:\r
+                       c = -1;\r
+                       delta = -delta;\r
+               case 1:\r
+                       if(!(delta + mv->dyThresh))\r
+                       {\r
+                               mv->delta = 0;\r
+                               mv->tx += c;\r
+                       }\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+\r
+       mv->video->r=1;\r
+}\r