]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_sprit.c
it is semi working the bg preservation wwww
[16.git] / src / lib / 16_sprit.c
index d9ecad991bfedaf07b7f626ca8099e89718a98ac..66797e3da75bae4fc8a21a1aa25d7a59bbaca1df 100755 (executable)
@@ -99,16 +99,13 @@ void print_anim_ids(struct sprite *spri)
 void animate_spri(entity_t *enti, video_t *video)\r
 {\r
 #define INC_PER_FRAME if(enti->q&1) enti->persist_aniframe++; if(enti->persist_aniframe>4) enti->persist_aniframe = 1;\r
-       const unsigned int offscreen_ofs =      video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height);\r
-       const unsigned int pattern_ofs =        0x10000UL - (uint16_t)video->page[2].data;//(vga_state.vga_stride * vga_state.vga_height);\r
-       unsigned int copy_ofs =                 offscreen_ofs;\r
-       unsigned int display_ofs =              0x0000;\r
        unsigned int i,o,o2; int j;\r
        int x,y,rx,ry,w,h;\r
 \r
        VGA_RAM_PTR omemptr = (VGA_RAM_PTR)video->page[0].data;// save original mem ptr\r
        x=enti->spri->x;\r
        y=enti->spri->y;\r
+       VL_Initofs(video);\r
 \r
        // Depending on delay, update indices\r
 //#define FRAME1 modexDrawSpriteRegion(pip[(pip->video->p)].page, x, y, 48, player[pn].enti.dire, 24, 32,      PLAYERBMPDATAPTR);\r
@@ -116,11 +113,11 @@ void animate_spri(entity_t *enti, video_t *video)
 //#define FRAME3 modexDrawSpriteRegion(pip[(pip->video->p)].page, x, y, 0, player[pn].enti.dire, 24, 32,       PLAYERBMPDATAPTR);\r
 //#define FRAME4 modexDrawSpriteRegion(pip[(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32,      PLAYERBMPDATAPTR); stand\r
 \r
-       /* copy active display (0) to offscreen buffer (0x4000) */\r
-       vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = vga_state.vga_stride;\r
+       // copy active display (0) to offscreen buffer (0x4000)\r
+       /*vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = vga_state.vga_stride;\r
        vga_setup_wm1_block_copy();\r
        vga_wm1_mem_block_copy(copy_ofs,        display_ofs,    vga_state.vga_stride * vga_state.vga_height);\r
-       vga_restore_rm0wm0();\r
+       vga_restore_rm0wm0();*/\r
 \r
        switch(enti->spri->delay)\r
        {\r
@@ -171,8 +168,8 @@ void animate_spri(entity_t *enti, video_t *video)
 \r
        // block copy pattern to where we will draw the sprite\r
        vga_setup_wm1_block_copy();\r
-       o2 = offscreen_ofs;\r
-       o = pattern_ofs + (ry * video->page[0].stridew) + (rx >> 2); // source offscreen                0x10000UL -\r
+       o2 = video->ofs.offscreen_ofs;\r
+       o = video->ofs.pattern_ofs + (ry * video->page[0].stridew) + (rx >> 2); // source offscreen\r
        for (i=0;i < h;i++,o += video->page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2);\r
 \r
        // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally\r
@@ -180,7 +177,7 @@ void animate_spri(entity_t *enti, video_t *video)
 \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 + offscreen_ofs;\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,7 +200,7 @@ void animate_spri(entity_t *enti, video_t *video)
 \r
        // block copy to visible RAM from offscreen\r
        vga_setup_wm1_block_copy();\r
-       o = offscreen_ofs; // source offscreen\r
+       o = video->ofs.offscreen_ofs; // source offscreen\r
        o2 = (ry * video->page[0].stridew) + (rx >> 2); // dest visible (original stride)\r
        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