From: Robert Lowe Date: Thu, 4 Sep 2014 02:25:07 +0000 (-0400) Subject: separated out row and column rendering into functions X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=f3b8d7ac9f01e8077da6d731eebe7e2446bf0ab1;p=16.git separated out row and column rendering into functions --- diff --git a/16/modex16/scroll.c b/16/modex16/scroll.c index 1a637919..4b9ca122 100644 --- a/16/modex16/scroll.c +++ b/16/modex16/scroll.c @@ -39,6 +39,8 @@ void mapScrollUp(map_view_t *mv, byte offset); void mapScrollDown(map_view_t *mv, byte offset); void mapGoTo(map_view_t *mv, byte tx, byte ty); void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y); +void mapDrawRow(map_view_t *mv, int tx, int ty, word y); +void mapDrawCol(map_view_t *mv, int tx, int ty, word x); void main() { int show1=1; @@ -62,17 +64,9 @@ void main() { mv.page = &screen; mapGoTo(&mv, 0, 0); - /* scroll all the way to the right */ - /*for(x=0; x<((80)*16-SCREEN_WIDTH); x++) { - mapScrollRight(&mv, 1); - modexShowPage(mv.page); - } - for(x=0; x<((80+0.50625)*16-SCREEN_WIDTH); x++) { - mapScrollLeft(&mv, 1); - modexShowPage(mv.page); - }*/ - + /* scroll all the way to the right */ + for(x=0; x<((20)*16-SCREEN_WIDTH); x++) { mapScrollRight(&mv, 1); modexShowPage(mv.page); @@ -80,7 +74,7 @@ void main() { for(x=0; x<((40/*+0.50625*/)*16-SCREEN_WIDTH); x++) { mapScrollLeft(&mv, 1); modexShowPage(mv.page); - } + } /* spin for a time */ for(x=0; x<500; x++) { @@ -173,7 +167,7 @@ mapScrollRight(map_view_t *mv, byte offset) { void -mapScrollLeft(map_view_t *mv, byte offset) { +mapScrollLeft(map_view_t *mv, byte offset) { word x, y; /* coordinate for drawing */ unsigned int i; @@ -195,8 +189,8 @@ mapScrollLeft(map_view_t *mv, byte offset) { for(y=0; ymap->tiles, mv->map->data[i], mv->page, (int)mv->page->dx + x, (int)mv->page->dy+y); i += mv->map->width; - } -} + } + } } @@ -244,3 +238,40 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) { ry = (i / t->cols) * t->tileHeight; modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, t->data); } + + +void +mapDrawRow(map_view_t *mv, int tx, int ty, word y) { + word x; + int i; + + /* the position within the map array */ + i=ty * mv->map->width + tx; + for(x=0; xmap->width; x+=mv->map->tiles->tileWidth, tx++) { + if(i>=0) { + /* we are in the map, so copy! */ + mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i++; /* next! */ + } +} + + +void +mapDrawCol(map_view_t *mv, int tx, int ty, word x) { + int y; + int i; + + /* location in the map array */ + i=ty * mv->map->width + tx; + + /* We'll copy all of the columns in the screen, + i + 1 row above and one below */ + for(y=0; ymap->height; y+=mv->map->tiles->tileHeight, ty++) { + if(i>=0) { + /* we are in the map, so copy away! */ + mapDrawTile(mv->map->tiles, mv->map->data[i], mv->page, x, y); + } + i += mv->map->width; + } +} diff --git a/16/modex16/scroll.exe b/16/modex16/scroll.exe index 90af5276..8e82eda4 100644 Binary files a/16/modex16/scroll.exe and b/16/modex16/scroll.exe differ