From: sparky4 Date: Thu, 2 Feb 2017 22:09:27 +0000 (-0600) Subject: ==== old BG rendering is back ==== X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=ba81930a4ab38c4a0d74a3f20b96fda1cdc3338e;p=16.git ==== old BG rendering is back ==== --- diff --git a/src/lib/16_enti.c b/src/lib/16_enti.c index 19df4fd5..310aaab6 100755 --- a/src/lib/16_enti.c +++ b/src/lib/16_enti.c @@ -46,8 +46,7 @@ void EN_initentity(entity_t *enti, video_t *video) // modexClearRegion(&video->page[0], enti->x, enti->y, 16, 16, 2); // modexClearRegion(&video->page[2], 0, 0, video->page[2].sw, video->page[2].sh, 45); // modexClearRegion(&video->page[3], 0, 0, video->page[3].sw, video->page[3].sh, 47); - if(!video->bgps) - { + if(!video->bgps){ //video->ofs.pattern_ofs=(uint16_t)video->page[0].data; //video->ofs.offscreen_ofs=(uint16_t)video->page[3].data; w = (enti->x + 24) & (~3); @@ -60,10 +59,10 @@ void EN_initentity(entity_t *enti, video_t *video) for (i=0;i < h;i++,o += video->page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2); // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally vga_restore_rm0wm0(); - }else{ - w=h=o=i=o2=0; - modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32); - } + }//else{ + //w=h=o=i=o2=0; + //modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32); + //} } //init player! diff --git a/src/lib/16_sprit.c b/src/lib/16_sprit.c index 1c37d46d..9f699e19 100755 --- a/src/lib/16_sprit.c +++ b/src/lib/16_sprit.c @@ -158,17 +158,16 @@ void animate_spri(entity_t *enti, video_t *video) // render box bounds. y does not need modification, but x and width must be multiple of 4 if(!video->rss) { - if(!video->bgps) - { - if (x >= enti->overdraww) rx = (x - enti->overdraww) & (~3); - else rx = -(video->page[0].dx); - if (y >= enti->overdrawh) ry = (y - enti->overdrawh); - else ry = -(video->page[0].dy); - h = enti->spri->sprite_vrl_cont->vrl_header->height + enti->overdrawh + y - ry; - w = (x + enti->spri->sprite_vrl_cont->vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up - if ((rx+w) > video->page[0].width) w = video->page[0].width-rx; - if ((ry+h) > video->page[0].height) h = video->page[0].height-ry; - + if (x >= enti->overdraww) rx = (x - enti->overdraww) & (~3); + else rx = -(video->page[0].dx); + if (y >= enti->overdrawh) ry = (y - enti->overdrawh); + else ry = -(video->page[0].dy); + h = enti->spri->sprite_vrl_cont->vrl_header->height + enti->overdrawh + y - ry; + w = (x + enti->spri->sprite_vrl_cont->vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up + if ((rx+w) > video->page[0].width) w = video->page[0].width-rx; + if ((ry+h) > video->page[0].height) h = video->page[0].height-ry; + + if(!video->bgps){ // block copy pattern to where we will draw the sprite vga_setup_wm1_block_copy(); o2 = video->ofs.offscreen_ofs; @@ -177,14 +176,10 @@ void animate_spri(entity_t *enti, video_t *video) // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally vga_restore_rm0wm0(); - - // replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) - vga_state.vga_draw_stride = w >> 2; - vga_state.vga_graphics_ram = omemptr + video->ofs.offscreen_ofs; - }else{ - w=h=i=o=o2=0; - modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32); } + // replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) + vga_state.vga_draw_stride = w >> 2; + vga_state.vga_graphics_ram = omemptr + video->ofs.offscreen_ofs; }else{ rx=ry=w=h=0; vga_state.vga_graphics_ram = (VGA_RAM_PTR)video->page[0].data; } vga_state.vga_draw_stride_limit = (video->page[0].width + 3 - x) >> 2;//round up @@ -203,11 +198,10 @@ void animate_spri(entity_t *enti, video_t *video) #endif if(!video->rss) { - if(!video->bgps) - { - // restore ptr - vga_state.vga_graphics_ram = omemptr; + // restore ptr + vga_state.vga_graphics_ram = omemptr; + if(!video->bgps){ // block copy to visible RAM from offscreen vga_setup_wm1_block_copy(); o = video->ofs.offscreen_ofs; // source offscreen @@ -215,8 +209,6 @@ void animate_spri(entity_t *enti, video_t *video) for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += video->page[0].stridew) vga_wm1_mem_block_copy(o2,o,w >> 2); // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally vga_restore_rm0wm0(); - }else{ - //modexCopyPageRegion(&video->page[0], &video->page[2], 0, 0, enti->x, enti->y, 24, 32); } } // restore stride diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 5c485586..56b60684 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -279,8 +279,14 @@ void modexCalcVmemRemain(video_t *video) void VL_Initofs(video_t *video) { - video->ofs.offscreen_ofs = video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height); - video->ofs.pattern_ofs = (uint16_t)video->page[3].data; + if(!video->bgps) + { + video->ofs.offscreen_ofs = video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height); + video->ofs.pattern_ofs = (uint16_t)video->page[2].data; + }else{ + video->ofs.offscreen_ofs = 0; + video->ofs.pattern_ofs = 0;//(uint16_t)video->page[0].data; + } } void modexHiganbanaPageSetup(video_t *video) @@ -306,9 +312,9 @@ void modexHiganbanaPageSetup(video_t *video) video->omemptr= vga_state.vga_graphics_ram; video->vga_draw_stride= vga_state.vga_draw_stride; video->vga_draw_stride_limit= vga_state.vga_draw_stride_limit; - //sprite render switch - video->rss= 0; //set to new - video->bgps= 0; //set to new + //sprite render switch and bgpreservation switch + video->rss= 1; + video->bgps= 1; //setup the buffersize video->page[0].dx=video->page[0].dy= diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index b35d6159..c11f49bf 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -46,7 +46,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 2); ScrollRight(pip, player, 3, pn); ScrollRight(pip, player, 2, pn); - mapScrollRight(pip, player, (pip[0].video->p), pn); + mapScrollRight(pip, player, (0), pn); + if(pip[0].video->bgps) mapScrollRight(pip, player, (1), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } @@ -83,7 +84,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 2); ScrollLeft(pip, player, 3, pn); ScrollLeft(pip, player, 2, pn); - mapScrollLeft(pip, player, (pip[0].video->p), pn); + mapScrollLeft(pip, player, (0), pn); + if(pip[0].video->bgps) mapScrollLeft(pip, player, (1), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } @@ -120,7 +122,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 2); ScrollDown(pip, player, 3, pn); ScrollDown(pip, player, 2, pn); - mapScrollDown(pip, player, (pip[0].video->p), pn); + mapScrollDown(pip, player, (0), pn); + if(pip[0].video->bgps) mapScrollDown(pip, player, (1), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } @@ -157,7 +160,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) ANIMATESPRIFUN(pip, player, pn, 2); ScrollUp(pip, player, 3, pn); ScrollUp(pip, player, 2, pn); - mapScrollUp(pip, player, (pip[0].video->p), pn); + mapScrollUp(pip, player, (0), pn); + if(pip[0].video->bgps) mapScrollUp(pip, player, (1), pn); player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } @@ -351,17 +355,17 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) ScrollRight(mv, player, id, plid); /* draw the next column */ - x= mv[0].page->sw + mv[id].map->tiles->tileWidth; + x= mv[0].page->sw + mv[0].map->tiles->tileWidth; #ifndef FULLRCREND if(player[plid].enti.q%4) #else if(player[plid].enti.q==4) #endif - if(id==0) - mapDrawCol(&mv[0], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM); - else - if(mv[0].video->bgps) - modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->ti.th+2)); +// if(id==0) + mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM); +// else +// if(mv[0].video->bgps) +// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height); mv[0].video->r=1; } @@ -379,11 +383,11 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) #else if(player[plid].enti.q==4) #endif - if(id==0) - mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM); - else - if(mv[0].video->bgps) - modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->ti.th+2)); +// if(id==0) + mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM); +// else +// if(mv[0].video->bgps) +// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height); mv[0].video->r=1; } @@ -401,11 +405,11 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) #else if(player[plid].enti.q==4) #endif - if(id==0) - mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWCOLNUM); - else - if(mv[0].video->bgps) - modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->ti.tw+2), mv[id].map->tiles->tileHeight); +// if(id==0) + mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWCOLNUM); +// else +// if(mv[0].video->bgps) +// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight); mv[0].video->r=1; } @@ -417,17 +421,17 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) ScrollDown(mv, player, id, plid); /* draw the next row */ - y= mv[0].page->sh + mv[id].map->tiles->tileHeight; + y= mv[0].page->sh + mv[0].map->tiles->tileHeight; #ifndef FULLRCREND if(player[plid].enti.q%3) #else if(player[plid].enti.q==4) #endif - if(id==0) - mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWCOLNUM); - else - if(mv[0].video->bgps) - modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->ti.tw+2), mv[id].map->tiles->tileHeight); +// if(id==0) + mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWCOLNUM); +// else +// if(mv[0].video->bgps) +// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight); mv[0].video->r=1; } @@ -506,10 +510,15 @@ void mapGoTo(map_view_t *mv, int tx, int ty) i=mv[0].ty * mv[0].map->width + mv[0].tx; for(ty=mv[0].ty-1; py < mv[0].page->sh+mv->dyThresh && ty < mv[0].map->height; ty++, py+=mv[0].map->tiles->tileHeight) { mapDrawWRow(&mv[0], tx-1, ty, py); - i+=mv->map->width - tx; + i+=mv->map->width - tx; } - if(mv[0].video->bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); -// modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32); + py=0; + i=mv[1].ty * mv[1].map->width + mv[1].tx; + for(ty=mv[1].ty-1; py < mv[1].page->sh+mv->dyThresh && ty < mv[1].map->height; ty++, py+=mv[1].map->tiles->tileHeight) { + mapDrawWRow(&mv[1], tx-1, ty, py); + i+=mv->map->width - tx; + } + //if(mv[0].video->bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); } void ZC_mapinitMV(map_view_t *mv, int tx, int ty) @@ -703,16 +712,12 @@ void shinku(global_game_variables_t *gv) //render!! if(gv->video.r ) {//r=1 - if(gv->video.bgps ) - {//bgps=1 - /*modexCopyPageRegion(&(gv->video.page[ - ]), &(gv->video.page[( - ]), 0, 0, 0, 0, gv->video.page[ - ].width, gv->video.page[ - ].height);*/ + /*if(video->bgp s) + { + modexCopyPageRegion(&(gv->video.page[ ]), &(gv->video.page[ ]), 0, 0, 0, 0, gv->video.page[ ].width, gv->video.page[ ].height); }else{ //modexCopyPageRegion(&video->page[0], &video->page[1], enti->x, enti->y, 0, 0, 24, 32); - } + }*/ VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0); gv->video.r =!gv->video.r ; //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2; @@ -799,7 +804,7 @@ void animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitc break; } - if(pip[0].video->bgps) modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 36); +// if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36); // else{ // //copy old bg to page0 // //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0, 20, 36); @@ -895,6 +900,8 @@ void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scr player[pn].enti.spri->x = x; player[pn].enti.spri->y = y; + if(pip[0].video->bgps) + modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40); //draw sprite ZC_drawframe(pip, &player[pn].enti, x, y); //0000if(player[pn].enti.q<2) delay(200); diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index 976a0d0d..bed922b1 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -56,8 +56,8 @@ //row and colum drawing routines #define FULLRCREND -#define DRAWCOLNUM mv->page[0].dx -#define DRAWROLNUM mv->page[0].dy +#define DRAWCOLNUM mv->page[id].dx +#define DRAWROLNUM mv->page[id].dy //#define DRAWCOLNUM player[plid].enti.q //#define DRAWROLNUM player[plid].enti.q @@ -77,8 +77,8 @@ //printf("&global_temp_status_text = %Fp\n", &global_temp_status_text); //printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx); printf("%d\n", gvar.video.page[0].tilemidposscreeny); //printf(" aniframe=%u", player[0].enti.persist_aniframe); -#define SCROLLEXITMESG printf("txy: %dx%d\n", mv[0].tx, mv[0].ty);\ - printf("\n");\ +#define SCROLLEXITMESG printf("[0]txy: %dx%d ", mv[0].tx, mv[0].ty); printf("[1]txy: %dx%d", mv[1].tx, mv[1].ty);\ + printf("\n\n");\ printf("player vars:\n");\ printf(" xy: %dx%d", player[0].enti.x, player[0].enti.y); printf(" txy: %dx%d", player[0].enti.tx, player[0].enti.ty); printf(" triggxy: %dx%d", player[0].enti.triggerx, player[0].enti.triggery); printf(" value: %d\n", mv[0].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\ printf(" hp: %d", (player[0].enti.hp)); printf(" q: %d", player[0].enti.q); printf(" info.dir: %d", player[0].info.dir); printf(" d: %d ", player[0].enti.d);\ @@ -87,6 +87,7 @@ printf("\n\n");\ VL_PrintmodexmemInfo(&gvar.video);\ \ printf("gvar.video.r=%u ", gvar.video.r);\ + printf("gvar.video.bgps=%u ", gvar.video.bgps);\ printf("\n\n"); extern boolean pagenorendermap, pagedelayrendermap;