From 1159fe5a6cd0f8eaeee6e8584f5972d42e004073 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Tue, 10 Jan 2017 12:12:11 -0600 Subject: [PATCH] made a new function modexMVSetup() and made scroller use dx and dy on page[0].dx --- src/lib/16_tdef.h | 4 +-- src/lib/16_vl.c | 36 ++++++++++----------- src/lib/scroll16.c | 78 +++++++++++++++++++++++----------------------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 09e86c74..101ad475 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -92,8 +92,8 @@ typedef struct { typedef struct { /*nibble*/word id; /* the Identification number of the page~ For layering~ */ byte far* data; /* the data for the page */ - word dx; /* col we are viewing on the virtual screen */ /* off screen buffer on the left size */ - word dy; /* row we are viewing on the virtual screen */ /* off screen buffer on the top size */ + word dx; /* col we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the left size */ + word dy; /* row we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the top size */ word sw; /* screen width */ /* resolution */ word sh; /* screen heigth */ /* resolution */ word tw; /* screen width in tiles */ diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 652ef89c..0e2bfcf0 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -213,8 +213,8 @@ modexNextPage(page_t *p) { page_t result; result.data = p->data + (p->pagesize); - result.dx = 0; - result.dy = 0; + result.dx = p->dx; // not used anymore we use page[0].dx + result.dy = p->dy; // not used anymore we use page[0].dy result.sw = p->sw; result.sh = p->sh; result.width = p->width; @@ -238,8 +238,8 @@ modexNextPageFlexibleSize(page_t *p, word x, word y) page_t result; result.data = p->data + (p->pagesize); /* compute the offset */ - result.dx = 0; - result.dy = 0; + result.dx = 0; // not used anymore we use page[0].dx + result.dy = 0; // not used anymore we use page[0].dy result.sw = x; result.sh = y; result.width = x; @@ -294,10 +294,10 @@ void modexHiganbanaPageSetup(video_t *video) video->r=1; //setup the buffersize - video->page[0].dy=video->page[0].dx= - video->page[1].dx=video->page[1].dy=TILEWH; // 1 tile size buffer + video->page[0].dy=video->page[0].dx=TILEWH; + /* video->page[1].dx=video->page[1].dy=TILEWH; // 1 tile size buffer video->page[2].dx=video->page[2].dy= - video->page[3].dx=video->page[3].dy=0; // cache pages are buffer wwww + video->page[3].dx=video->page[3].dy=0; */// cache pages are buffer wwww } // @@ -310,8 +310,8 @@ modexShowPage(page_t *page) { /* calculate offset */ offset = (word) page->data; - offset += page->dy * (page->width >> 2 ); - offset += page->dx >> 2; + offset += page[0].dy * (page->width >> 2 ); + offset += page[0].dx >> 2; /* calculate crtcOffset according to virtual width */ crtcOffset = page->width >> 3; @@ -331,7 +331,7 @@ modexShowPage(page_t *page) { /* do PEL panning here */ outp(AC_INDEX, 0x33); - outp(AC_INDEX, (page->dx & 0x03) << 1); + outp(AC_INDEX, (page[0].dx & 0x03) << 1); } // @@ -345,8 +345,8 @@ modexShowPage_(page_t *page) /* calculate offset */ offset = (word) page->data; - offset += page->dy * (page->width >> 2 ); - offset += page->dx >> 2; + offset += page[0].dy * (page->width >> 2 ); + offset += page[0].dx >> 2; /* calculate crtcOffset according to virtual width */ crtcOffset = page->sw >> 3; @@ -366,7 +366,7 @@ modexShowPage_(page_t *page) /* do PEL panning here */ outp(AC_INDEX, 0x33); - outp(AC_INDEX, (page->dx & 0x03) << 1); + outp(AC_INDEX, (page[0].dx & 0x03) << 1); } void @@ -376,8 +376,8 @@ modexShowPageVsync(page_t *page) { /* calculate offset */ offset = (word) page->data; - offset += page->dy * (page->width >> 2 ); - offset += page->dx >> 2; + offset += page[0].dy * (page->width >> 2 ); + offset += page[0].dx >> 2; /* calculate crtcOffset according to virtual width */ crtcOffset = page->width >> 3; @@ -397,13 +397,13 @@ modexShowPageVsync(page_t *page) { /* do PEL panning here */ outp(AC_INDEX, 0x33); - outp(AC_INDEX, (page->dx & 0x03) << 1); + outp(AC_INDEX, (page[0].dx & 0x03) << 1); } void modexPanPage(page_t *page, int dx, int dy) { - page->dx = dx; - page->dy = dy; + page[0].dx = dx; + page[0].dy = dy; } void diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 0901f382..7f4ff16d 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -224,7 +224,7 @@ void panPageManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dx+=4; + pip[pip[0].pan->pn].page[0].dx+=4; modexShowPage(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx++; } @@ -237,7 +237,7 @@ void panPageManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dx-=4; + pip[pip[0].pan->pn].page[0].dx-=4; modexShowPage(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx--; } @@ -250,7 +250,7 @@ void panPageManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dy+=4; + pip[pip[0].pan->pn].page[0].dy+=4; modexShowPage(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty++; } @@ -263,7 +263,7 @@ void panPageManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dy-=4; + pip[pip[0].pan->pn].page[0].dy-=4; modexShowPage(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty--; } @@ -284,7 +284,7 @@ void panVmemManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dx+=4; + pip[pip[0].pan->pn].page[0].dx+=4; modexShowPageVsync(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx++; } @@ -297,7 +297,7 @@ void panVmemManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dx-=4; + pip[pip[0].pan->pn].page[0].dx-=4; modexShowPageVsync(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx--; } @@ -310,7 +310,7 @@ void panVmemManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dy+=4; + pip[pip[0].pan->pn].page[0].dy+=4; modexShowPageVsync(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty++; } @@ -323,7 +323,7 @@ void panVmemManual(map_view_t *pip, player_t *player, word pn) { if(player[pn].q<=player[pn].spt) { - pip[pip[0].pan->pn].page->dy-=4; + pip[pip[0].pan->pn].page[0].dy-=4; modexShowPageVsync(pip[pip[0].pan->pn].page); player[pn].q++; } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty--; } @@ -338,7 +338,7 @@ void panVmemManual(map_view_t *pip, player_t *player, word pn) */ void modexMVSetup(map_view_t *mv, map_t *map, pan_t *pan, global_game_variables_t *gv) { - word i; + byte i; // 1st page mv[0].page = &gv->video.page[0]; mv[0].map = map; @@ -446,24 +446,24 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) word x;//, y; /* coordinate for drawing */ /* increment the pixel position and update the page */ - mv[id].page->dx += player[plid].speed; + mv[id].page[0].dx += player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dx >= mv[id].dxThresh ) + if(mv[id].page[0].dx >= mv[id].dxThresh ) { /* go forward one tile */ mv[id].tx++; /* Snap the origin forward */ mv[id].page->data += 4; - mv[id].page->dx = mv[id].map->tiles->tileWidth; + mv[id].page[0].dx = mv[id].map->tiles->tileWidth; } /* draw the next column */ x= mv[0].page->sw + mv[id].map->tiles->tileWidth; if(player[plid].q%4) if(id==0) - mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page->dx); + mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page[0].dx); else if(!pageflipflop && !pageploop) modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2)); @@ -476,24 +476,24 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) word x;//,y; /* coordinate for drawing */ /* decrement the pixel position and update the page */ - mv[id].page->dx -= player[plid].speed; + mv[id].page[0].dx -= player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dx == 0) + if(mv[id].page[0].dx == 0) { /* go backward one tile */ mv[id].tx--; /* Snap the origin backward */ mv[id].page->data -= 4; - mv[id].page->dx = mv[id].map->tiles->tileWidth; + mv[id].page[0].dx = mv[id].map->tiles->tileWidth; } /* draw the next column */ x= 0; if(player[plid].q%4) if(id==0) - mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page->dx); + mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page[0].dx); else if(!pageflipflop && !pageploop) modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2)); @@ -506,24 +506,24 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) word y;//x, /* coordinate for drawing */ /* decrement the pixel position and update the page */ - mv[id].page->dy -= player[plid].speed; + mv[id].page[0].dy -= player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dy == 0 ) + if(mv[id].page[0].dy == 0 ) { /* go down one tile */ mv[id].ty--; /* Snap the origin downward */ mv[id].page->data -= mv[id].page->pi; - mv[id].page->dy = mv[id].map->tiles->tileHeight; + mv[id].page[0].dy = mv[id].map->tiles->tileHeight; } /* draw the next row */ y= 0; if(player[plid].q%3) if(id==0) - mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page->dy); + mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page[0].dy); else if(!pageflipflop && !pageploop) modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight); @@ -535,24 +535,24 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) word y;//x, /* coordinate for drawing */ /* increment the pixel position and update the page */ - mv[id].page->dy += player[plid].speed; + mv[id].page[0].dy += player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dy >= mv[id].dyThresh ) + if(mv[id].page[0].dy >= mv[id].dyThresh ) { /* go down one tile */ mv[id].ty++; /* Snap the origin downward */ mv[id].page->data += mv[id].page->pi; - mv[id].page->dy = mv[id].map->tiles->tileHeight; + mv[id].page[0].dy = mv[id].map->tiles->tileHeight; } /* draw the next row */ y= mv[0].page->sh + mv[id].map->tiles->tileHeight; if(player[plid].q%3) if(id==0) - mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page->dy); + mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page[0].dy); else if(!pageflipflop && !pageploop) modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight); @@ -564,68 +564,68 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid) { /* increment the pixel position and update the page */ - mv[id].page->dx += player[plid].speed; + mv[id].page[0].dx += player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dx >= mv[0].dxThresh ) + if(mv[id].page[0].dx >= mv[0].dxThresh ) { // vga_setup_wm1_block_copy(); // _fmemmove(mv[id].page->data+4, mv[id].page->data, mv[id].page->pagesize); // vga_restore_rm0wm0(); /* Snap the origin forward */ mv[id].page->data += 4; - mv[id].page->dx = mv[0].map->tiles->tileWidth; + mv[id].page[0].dx = mv[0].map->tiles->tileWidth; } } void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid) { /* decrement the pixel position and update the page */ - mv[id].page->dx -= player[plid].speed; + mv[id].page[0].dx -= player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dx == 0) + if(mv[id].page[0].dx == 0) { // vga_setup_wm1_block_copy(); // _fmemmove(mv[id].page->data-4, mv[id].page->data, mv[id].page->pagesize); // vga_restore_rm0wm0(); /* Snap the origin backward */ mv[id].page->data -= 4; - mv[id].page->dx = mv[0].map->tiles->tileWidth; + mv[id].page[0].dx = mv[0].map->tiles->tileWidth; } } void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid) { /* decrement the pixel position and update the page */ - mv[id].page->dy -= player[plid].speed; + mv[id].page[0].dy -= player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dy == 0) + if(mv[id].page[0].dy == 0) { // vga_setup_wm1_block_copy(); // _fmemmove(mv[id].page->data-mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize); // vga_restore_rm0wm0(); /* Snap the origin backward */ mv[id].page->data -= mv[id].page->pi; - mv[id].page->dy = mv[0].map->tiles->tileWidth; + mv[id].page[0].dy = mv[0].map->tiles->tileWidth; } } void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid) { /* increment the pixel position and update the page */ - mv[id].page->dy += player[plid].speed; + mv[id].page[0].dy += player[plid].speed; /* check to see if this changes the tile */ - if(mv[id].page->dy >= mv[0].dxThresh ) + if(mv[id].page[0].dy >= mv[0].dxThresh ) { // vga_setup_wm1_block_copy(); // _fmemmove(mv[id].page->data+mv[id].page->pi, mv[id].page->data, mv[id].page->pagesize); // vga_restore_rm0wm0(); /* Snap the origin forward */ mv[id].page->data += mv[id].page->pi; - mv[id].page->dy = mv[0].map->tiles->tileWidth; + mv[id].page[0].dy = mv[0].map->tiles->tileWidth; } } @@ -713,8 +713,8 @@ void mapinitmapview(map_view_t *mv, int tx, int ty) /* set up the coordinates */ mv[0].tx = mv[1].tx = tx; mv[0].ty = mv[1].ty = ty; - mv[0].page->dx = mv[1].page->dx = mv[2].page->dx = mv[3].page->dx = mv->map->tiles->tileWidth; - mv[0].page->dy = mv[1].page->dy = mv[2].page->dy = mv[3].page->dy = mv->map->tiles->tileHeight; + mv[0].page[0].dx = mv[1].page[0].dx = mv[2].page[0].dx = mv[3].page[0].dx = mv->map->tiles->tileWidth; + mv[0].page[0].dy = mv[1].page[0].dy = mv[2].page[0].dy = mv[3].page[0].dy = mv->map->tiles->tileHeight; /* set up the thresholds */ mv[0].dxThresh = mv[1].dxThresh = mv[2].dxThresh = mv[3].dxThresh = mv->map->tiles->tileWidth * 2; -- 2.39.5