]> 4ch.mooo.com Git - 16.git/commitdiff
==== old BG rendering is back ====
authorsparky4 <sparky4@cock.li>
Thu, 2 Feb 2017 22:09:27 +0000 (16:09 -0600)
committersparky4 <sparky4@cock.li>
Thu, 2 Feb 2017 22:09:27 +0000 (16:09 -0600)
src/lib/16_enti.c
src/lib/16_sprit.c
src/lib/16_vl.c
src/lib/scroll16.c
src/lib/scroll16.h

index 19df4fd5bc2beb283598b8c4e385b915b723c6a8..310aaab6de36453edb99423296d1cc338dee67ae 100755 (executable)
@@ -46,8 +46,7 @@ void EN_initentity(entity_t *enti, video_t *video)
 //     modexClearRegion(&video->page[0], enti->x, enti->y, 16, 16, 2);\r
 //     modexClearRegion(&video->page[2], 0, 0, video->page[2].sw, video->page[2].sh, 45);\r
 //     modexClearRegion(&video->page[3], 0, 0, video->page[3].sw, video->page[3].sh, 47);\r
-       if(!video->bgps)\r
-       {\r
+       if(!video->bgps){\r
                //video->ofs.pattern_ofs=(uint16_t)video->page[0].data;\r
                //video->ofs.offscreen_ofs=(uint16_t)video->page[3].data;\r
                w = (enti->x + 24) & (~3);\r
@@ -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);\r
                // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally\r
                vga_restore_rm0wm0();\r
-       }else{\r
-               w=h=o=i=o2=0;\r
-               modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32);\r
-       }\r
+       }//else{\r
+               //w=h=o=i=o2=0;\r
+               //modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32);\r
+       //}\r
 }\r
 \r
 //init player!\r
index 1c37d46d81f7b7b569b8499d7d698a44baf192ec..9f699e1963ceea1231b610d990391b01262d2c59 100755 (executable)
@@ -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\r
        if(!video->rss)\r
        {\r
-               if(!video->bgps)\r
-               {\r
-                       if (x >= enti->overdraww) rx = (x - enti->overdraww) & (~3);\r
-                               else rx = -(video->page[0].dx);\r
-                       if (y >= enti->overdrawh) ry = (y - enti->overdrawh);\r
-                               else ry = -(video->page[0].dy);\r
-                       h = enti->spri->sprite_vrl_cont->vrl_header->height + enti->overdrawh + y - ry;\r
-                       w = (x + enti->spri->sprite_vrl_cont->vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up\r
-                       if ((rx+w) > video->page[0].width) w = video->page[0].width-rx;\r
-                       if ((ry+h) > video->page[0].height) h = video->page[0].height-ry;\r
-\r
+               if (x >= enti->overdraww) rx = (x - enti->overdraww) & (~3);\r
+                       else rx = -(video->page[0].dx);\r
+               if (y >= enti->overdrawh) ry = (y - enti->overdrawh);\r
+                       else ry = -(video->page[0].dy);\r
+               h = enti->spri->sprite_vrl_cont->vrl_header->height + enti->overdrawh + y - ry;\r
+               w = (x + enti->spri->sprite_vrl_cont->vrl_header->width + (enti->overdraww*2) + 3 - rx) & (~3) - enti->overdraww;//round up\r
+               if ((rx+w) > video->page[0].width) w = video->page[0].width-rx;\r
+               if ((ry+h) > video->page[0].height) h = video->page[0].height-ry;\r
+\r
+               if(!video->bgps){\r
                        // block copy pattern to where we will draw the sprite\r
                        vga_setup_wm1_block_copy();\r
                        o2 = video->ofs.offscreen_ofs;\r
@@ -177,14 +176,10 @@ void animate_spri(entity_t *enti, video_t *video)
 \r
                        // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally\r
                        vga_restore_rm0wm0();\r
-\r
-                       // replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0)\r
-                       vga_state.vga_draw_stride = w >> 2;\r
-                       vga_state.vga_graphics_ram = omemptr + video->ofs.offscreen_ofs;\r
-               }else{\r
-                       w=h=i=o=o2=0;\r
-                       modexCopyPageRegion(&video->page[2], &video->page[0], enti->x, enti->y, 0, 0, 24, 32);\r
                }\r
+               // replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0)\r
+               vga_state.vga_draw_stride = w >> 2;\r
+               vga_state.vga_graphics_ram = omemptr + video->ofs.offscreen_ofs;\r
        }else{ rx=ry=w=h=0; vga_state.vga_graphics_ram = (VGA_RAM_PTR)video->page[0].data; }\r
        vga_state.vga_draw_stride_limit = (video->page[0].width + 3 - x) >> 2;//round up\r
 \r
@@ -203,11 +198,10 @@ void animate_spri(entity_t *enti, video_t *video)
 #endif\r
        if(!video->rss)\r
        {\r
-               if(!video->bgps)\r
-               {\r
-                       // restore ptr\r
-                       vga_state.vga_graphics_ram = omemptr;\r
+               // restore ptr\r
+               vga_state.vga_graphics_ram = omemptr;\r
 \r
+               if(!video->bgps){\r
                        // block copy to visible RAM from offscreen\r
                        vga_setup_wm1_block_copy();\r
                        o = video->ofs.offscreen_ofs; // source offscreen\r
@@ -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);\r
                        // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally\r
                        vga_restore_rm0wm0();\r
-               }else{\r
-                       //modexCopyPageRegion(&video->page[0], &video->page[2], 0, 0, enti->x, enti->y, 24, 32);\r
                }\r
        }\r
        // restore stride\r
index 5c4855868d8f56529d1b3a0d67b7499b2cf49f4e..56b60684a85fea1818b12799f19218e64f0ef1c0 100755 (executable)
@@ -279,8 +279,14 @@ void modexCalcVmemRemain(video_t *video)
 \r
 void VL_Initofs(video_t *video)\r
 {\r
-       video->ofs.offscreen_ofs =      video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height);\r
-       video->ofs.pattern_ofs =        (uint16_t)video->page[3].data;\r
+       if(!video->bgps)\r
+       {\r
+               video->ofs.offscreen_ofs =      video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height);\r
+               video->ofs.pattern_ofs =        (uint16_t)video->page[2].data;\r
+       }else{\r
+               video->ofs.offscreen_ofs =      0;\r
+               video->ofs.pattern_ofs =        0;//(uint16_t)video->page[0].data;\r
+       }\r
 }\r
 \r
 void modexHiganbanaPageSetup(video_t *video)\r
@@ -306,9 +312,9 @@ void modexHiganbanaPageSetup(video_t *video)
        video->omemptr=                 vga_state.vga_graphics_ram;\r
        video->vga_draw_stride= vga_state.vga_draw_stride;\r
        video->vga_draw_stride_limit=   vga_state.vga_draw_stride_limit;\r
-       //sprite render switch\r
-       video->rss=             0;      //set to new\r
-       video->bgps=    0;      //set to new\r
+       //sprite render switch and bgpreservation switch\r
+       video->rss=             1;\r
+       video->bgps=    1;\r
 \r
        //setup the buffersize\r
        video->page[0].dx=video->page[0].dy=\r
index b35d61598a090820027727880fbfb794f7ecc1ed..c11f49bfd6ba86c482f79303308f2449607e66d0 100755 (executable)
@@ -46,7 +46,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        ANIMATESPRIFUN(pip, player, pn, 2);\r
                                        ScrollRight(pip, player, 3, pn);\r
                                        ScrollRight(pip, player, 2, pn);\r
-                                       mapScrollRight(pip, player, (pip[0].video->p), pn);\r
+                                                                       mapScrollRight(pip, player, (0), pn);\r
+                                       if(pip[0].video->bgps)  mapScrollRight(pip, player, (1), pn);\r
                                        player[pn].enti.q++;\r
                                        //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
                                } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; }\r
@@ -83,7 +84,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        ANIMATESPRIFUN(pip, player, pn, 2);\r
                                        ScrollLeft(pip, player, 3, pn);\r
                                        ScrollLeft(pip, player, 2, pn);\r
-                                       mapScrollLeft(pip, player, (pip[0].video->p), pn);\r
+                                                                       mapScrollLeft(pip, player, (0), pn);\r
+                                       if(pip[0].video->bgps)  mapScrollLeft(pip, player, (1), pn);\r
                                        player[pn].enti.q++;\r
                                        //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
                                } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; }\r
@@ -120,7 +122,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        ANIMATESPRIFUN(pip, player, pn, 2);\r
                                        ScrollDown(pip, player, 3, pn);\r
                                        ScrollDown(pip, player, 2, pn);\r
-                                       mapScrollDown(pip, player, (pip[0].video->p), pn);\r
+                                                                       mapScrollDown(pip, player, (0), pn);\r
+                                       if(pip[0].video->bgps)  mapScrollDown(pip, player, (1), pn);\r
                                        player[pn].enti.q++;\r
                                        //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
                                } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; }\r
@@ -157,7 +160,8 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn)
                                        ANIMATESPRIFUN(pip, player, pn, 2);\r
                                        ScrollUp(pip, player, 3, pn);\r
                                        ScrollUp(pip, player, 2, pn);\r
-                                       mapScrollUp(pip, player, (pip[0].video->p), pn);\r
+                                                                       mapScrollUp(pip, player, (0), pn);\r
+                                       if(pip[0].video->bgps)  mapScrollUp(pip, player, (1), pn);\r
                                        player[pn].enti.q++;\r
                                        //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2;\r
                                } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; }\r
@@ -351,17 +355,17 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid)
        ScrollRight(mv, player, id, plid);\r
 \r
        /* draw the next column */\r
-       x= mv[0].page->sw + mv[id].map->tiles->tileWidth;\r
+       x= mv[0].page->sw + mv[0].map->tiles->tileWidth;\r
 #ifndef FULLRCREND\r
        if(player[plid].enti.q%4)\r
 #else\r
        if(player[plid].enti.q==4)\r
 #endif\r
-               if(id==0)\r
-                       mapDrawCol(&mv[0], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);\r
-               else\r
-                       if(mv[0].video->bgps)\r
-                               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));\r
+//             if(id==0)\r
+                       mapDrawCol(&mv[id], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM);\r
+//             else\r
+//                     if(mv[0].video->bgps)\r
+//                             modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);\r
        mv[0].video->r=1;\r
 }\r
 \r
@@ -379,11 +383,11 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid)
 #else\r
        if(player[plid].enti.q==4)\r
 #endif\r
-               if(id==0)\r
-                       mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);\r
-               else\r
-                       if(mv[0].video->bgps)\r
-                               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));\r
+//             if(id==0)\r
+                       mapDrawCol(&mv[id], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM);\r
+//             else\r
+//                     if(mv[0].video->bgps)\r
+//                             modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[0].map->tiles->tileWidth, mv[0].page->height);\r
        mv[0].video->r=1;\r
 }\r
 \r
@@ -401,11 +405,11 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid)
 #else\r
        if(player[plid].enti.q==4)\r
 #endif\r
-               if(id==0)\r
-                       mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWCOLNUM);\r
-               else\r
-                       if(mv[0].video->bgps)\r
-                               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);\r
+//             if(id==0)\r
+                       mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWCOLNUM);\r
+//             else\r
+//                     if(mv[0].video->bgps)\r
+//                             modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);\r
        mv[0].video->r=1;\r
 }\r
 \r
@@ -417,17 +421,17 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid)
        ScrollDown(mv, player, id, plid);\r
 \r
        /* draw the next row */\r
-       y= mv[0].page->sh + mv[id].map->tiles->tileHeight;\r
+       y= mv[0].page->sh + mv[0].map->tiles->tileHeight;\r
 #ifndef FULLRCREND\r
        if(player[plid].enti.q%3)\r
 #else\r
        if(player[plid].enti.q==4)\r
 #endif\r
-               if(id==0)\r
-                       mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWCOLNUM);\r
-               else\r
-                       if(mv[0].video->bgps)\r
-                               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);\r
+//             if(id==0)\r
+                       mapDrawRow(&mv[id], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWCOLNUM);\r
+//             else\r
+//                     if(mv[0].video->bgps)\r
+//                             modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[0].page->width, mv[0].map->tiles->tileHeight);\r
        mv[0].video->r=1;\r
 }\r
 \r
@@ -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;\r
        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) {\r
                mapDrawWRow(&mv[0], tx-1, ty, py);\r
-       i+=mv->map->width - tx;\r
+               i+=mv->map->width - tx;\r
        }\r
-       if(mv[0].video->bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);\r
-//     modexCopyPageRegion(mv[3].page, mv[0].page, 0/**/, 0/**/, 0, 0, 24, 32);\r
+       py=0;\r
+       i=mv[1].ty * mv[1].map->width + mv[1].tx;\r
+       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) {\r
+               mapDrawWRow(&mv[1], tx-1, ty, py);\r
+               i+=mv->map->width - tx;\r
+       }\r
+       //if(mv[0].video->bgps) modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height);\r
 }\r
 \r
 void ZC_mapinitMV(map_view_t *mv, int tx, int ty)\r
@@ -703,16 +712,12 @@ void shinku(global_game_variables_t *gv)
        //render!!\r
        if(gv->video.r )\r
        {//r=1\r
-               if(gv->video.bgps )\r
-               {//bgps=1\r
-                       /*modexCopyPageRegion(&(gv->video.page[\r
-                       ]), &(gv->video.page[(\r
-                       ]), 0, 0, 0, 0, gv->video.page[\r
-                       ].width, gv->video.page[\r
-                       ].height);*/\r
+               /*if(video->bgp s)\r
+               {\r
+                       modexCopyPageRegion(&(gv->video.page[ ]), &(gv->video.page[ ]), 0, 0, 0, 0, gv->video.page[ ].width, gv->video.page[ ].height);\r
                }else{\r
                        //modexCopyPageRegion(&video->page[0], &video->page[1], enti->x, enti->y, 0, 0, 24, 32);\r
-               }\r
+               }*/\r
                VL_ShowPage(&(gv->video.page[gv->video.sp]), gv->kurokku.fpscap, 0);\r
                gv->video.r =!gv->video.r ;\r
                //0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;\r
@@ -799,7 +804,7 @@ void animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitc
                break;\r
        }\r
 \r
-       if(pip[0].video->bgps) modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 36);\r
+//     if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36);\r
 //     else{\r
 //             //copy old bg to page0\r
 //             //modexCopyPageRegion(pip[3].page, pip[0].page, bx, by, 0, 0,   20, 36);\r
@@ -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;\r
        player[pn].enti.spri->y = y;\r
 \r
+       if(pip[0].video->bgps)\r
+               modexCopyPageRegion(pip[0].page, pip[1].page, x-4, y-4, x-4, y-4, 28, 40);\r
        //draw sprite\r
        ZC_drawframe(pip, &player[pn].enti, x, y);\r
 //0000if(player[pn].enti.q<2) delay(200);\r
index 976a0d0d5de12c3841a934c9628dc1496050c97c..bed922b1d09d5a0644b1675fd5ea7c6af9707012 100755 (executable)
@@ -56,8 +56,8 @@
 \r
 //row and colum drawing routines\r
 #define FULLRCREND\r
-#define DRAWCOLNUM mv->page[0].dx\r
-#define DRAWROLNUM mv->page[0].dy\r
+#define DRAWCOLNUM mv->page[id].dx\r
+#define DRAWROLNUM mv->page[id].dy\r
 //#define DRAWCOLNUM player[plid].enti.q\r
 //#define DRAWROLNUM player[plid].enti.q\r
 \r
@@ -77,8 +77,8 @@
 //printf("&global_temp_status_text = %Fp\n", &global_temp_status_text);\r
 //printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx);   printf("%d\n", gvar.video.page[0].tilemidposscreeny);\r
 //printf("     aniframe=%u", player[0].enti.persist_aniframe);\r
-#define SCROLLEXITMESG         printf("txy: %dx%d\n", mv[0].tx, mv[0].ty);\\r
-       printf("\n");\\r
+#define SCROLLEXITMESG         printf("[0]txy: %dx%d   ", mv[0].tx, mv[0].ty); printf("[1]txy: %dx%d", mv[1].tx, mv[1].ty);\\r
+       printf("\n\n");\\r
        printf("player vars:\n");\\r
        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))]);\\r
        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);\\r
@@ -87,6 +87,7 @@ printf("\n\n");\
        VL_PrintmodexmemInfo(&gvar.video);\\r
 \\r
        printf("gvar.video.r=%u ", gvar.video.r);\\r
+       printf("gvar.video.bgps=%u ", gvar.video.bgps);\\r
 printf("\n\n");\r
 \r
 extern boolean pagenorendermap, pagedelayrendermap;\r