]> 4ch.mooo.com Git - 16.git/blobdiff - src/scroll.c
!! optimized 1 scroll function
[16.git] / src / scroll.c
index 29d7037dc14813b1f0697c73987d0ca23eb4bf17..e0a6efca43634ea1ca9052f6125704d3076dd359 100644 (file)
@@ -30,11 +30,16 @@ typedef struct {
        word d; //direction\r
        bitmap_t data; //supposively the sprite sheet data\r
        int hp; //hitpoints of the player\r
-} actor_t;\r
+} actor_t;
+
+typedef struct
+{
+       map_view_t *mv;
+} map_view_db_t;\r
 \r
 map_t allocMap(int w, int h);\r
 void initMap(map_t *map);\r
-void mapScrollRight(map_view_t *mv, byte offset);\r
+void mapScrollRight(map_view_db_t *mvdb, byte offset, word id);\r
 void mapScrollLeft(map_view_t *mv, byte offest);\r
 void mapScrollUp(map_view_t *mv, byte offset);\r
 void mapScrollDown(map_view_t *mv, byte offset);\r
@@ -72,7 +77,8 @@ void main() {
        page_t screen, screen2, screen3;\r
        map_t map;\r
        map_view_t mv, mv2, mv3;\r
-       map_view_t *bg, *spri, *mask;//, *tmp;\r
+       map_view_t *bg, *spri, *mask;//, *tmp;
+       map_view_db_t pgid[4];
        byte *dpal, *gpal;\r
        byte *ptr;\r
        byte *mappalptr;\r
@@ -201,7 +207,10 @@ void main() {
        /* set up paging */\r
        bg = &mv;\r
        spri = &mv2;\r
-       mask = &mv3;\r
+       mask = &mv3;
+       pgid[0].mv = &mv;
+       pgid[1].mv = &mv2;
+       pgid[2].mv = &mv3;\r
 \r
 //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen\r
        mapGoTo(bg, 0, 0);\r
@@ -256,8 +265,8 @@ void main() {
                                INC_PER_FRAME;\r
                                //animatePlayer(bg, spri, mask, 1, 1, player.x, player.y, persist_aniframe, q, &ptmp);\r
                                animatePlayer(bg, spri, player.d-1, 1, player.x, player.y, persist_aniframe, player.q, &ptmp);\r
-                               mapScrollRight(bg, SPEED);\r
-                               mapScrollRight(spri, SPEED);\r
+                               mapScrollRight(pgid, SPEED, 0);\r
+                               mapScrollRight(pgid, SPEED, 1);\r
                                //mapScrollRight(mask, SPEED);\r
                                modexShowPage(spri->page);\r
                                player.q++;\r
@@ -702,25 +711,27 @@ initMap(map_t *map) {
 \r
 \r
 void\r
-mapScrollRight(map_view_t *mv, byte offset) {\r
+mapScrollRight(map_view_db_t *mvdb, byte offset, word id) {\r
        word x, y;  /* coordinate for drawing */\r
 \r
        /* increment the pixel position and update the page */\r
-       mv->page->dx += offset;\r
+       mvdb[id].mv->page->dx += offset;\r
 \r
        /* check to see if this changes the tile */\r
-       if(mv->page->dx >= mv->dxThresh ) {\r
+       if(mvdb[id].mv->page->dx >= mvdb[id].mv->dxThresh ) {\r
        /* go forward one tile */\r
-       mv->tx++;\r
+       mvdb[id].mv->tx++;\r
        /* Snap the origin forward */\r
-       mv->page->data += 4;\r
-       mv->page->dx = mv->map->tiles->tileWidth;\r
-       //}\r
+       mvdb[id].mv->page->data += 4;\r
+       mvdb[id].mv->page->dx = mvdb[id].mv->map->tiles->tileWidth;\r
 \r
        /* draw the next column */\r
-       x= SCREEN_WIDTH + mv->map->tiles->tileWidth;\r
-               if(mv->page->id==0)\r
-               mapDrawCol(mv, mv->tx + 20 , mv->ty-1, x);\r
+       x= SCREEN_WIDTH + mvdb[id].mv->map->tiles->tileWidth;\r
+               if(mvdb[id].mv->page->id==0)
+                       mapDrawCol(mvdb[id].mv, mvdb[id].mv->tx + 20 , mvdb[id].mv->ty-1, x);
+               else
+                       modexCopyPageRegion(mvdb[id].mv->page, mvdb[0].mv->page, x, 0, x, 0, mvdb[id].mv->map->tiles->tileWidth, mvdb[id].mv->map->tiles->tileHeight*17);
+//              mv[0]\r
        }\r
 }\r
 \r