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