+/*\r
+void animate_spri(struct sprite *spri, global_game_variables_t *gv)\r
+{\r
+#define VMEMPAGESIZE2 gv->video.page[0].pagesize+gv->video.page[1].pagesize\r
+#define VMEMPAGEDATA2 gv->video.page[2].data\r
+ unsigned int i,o,o2; int j;\r
+ int x,y,rx,ry,w,h;\r
+ int overdraw = 1; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks.\r
+ // if the sprite's edge pixels are clear anyway, you can set this to 0.\r
+ VGA_RAM_PTR omemptr;\r
+\r
+ // Events go here\r
+\r
+\r
+ omemptr = vga_state.vga_graphics_ram; // save original mem ptr\r
+ x=spri->x-4;\r
+ y=spri->y;\r
+\r
+ // Draw sprite\r
+ j = get_vrl_by_id(spri->spritesheet, spri->curr_spri_id, spri->sprite_vrl_cont);\r
+ if(j < 0)\r
+ {\r
+ Quit (gv, "Error retriving required sprite");\r
+ }\r
+\r
+ // render box bounds. y does not need modification, but x and width must be multiple of 4\r
+ if (x >= overdraw) rx = (x - overdraw) & (~3);\r
+ else rx = -(gv->video.page[0].dx);\r
+ if (y >= overdraw) ry = (y - overdraw);\r
+ else ry = -(gv->video.page[0].dy);\r
+ h = spri->sprite_vrl_cont->vrl_header->height + overdraw + y - ry;\r
+ w = (x + spri->sprite_vrl_cont->vrl_header->width + (overdraw*2) + 3 - rx) & (~3);//round up\r
+ if ((rx+w) > gv->video.page[0].width) w = gv->video.page[0].width-rx;\r
+ if ((ry+h) > gv->video.page[0].height) h = gv->video.page[0].height-ry;\r
+\r
+ // block copy pattern to where we will draw the sprite\r
+ vga_setup_wm1_block_copy();\r
+ o2 = VMEMPAGESIZE2;\r
+ o = (0x10000UL - (uint16_t)VMEMPAGEDATA2) + (ry * gv->video.page[0].stridew) + (rx >> 2); // source offscreen\r
+ for (i=0;i < h;i++,o += gv->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
+ 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_limit = (gv->video.page[0].width + 3 - x) >> 2;//round up\r
+ vga_state.vga_draw_stride = w >> 2;\r
+ vga_state.vga_graphics_ram = omemptr + VMEMPAGESIZE2;\r
+\r
+ // then the sprite. note modding ram ptr means we just draw to (x&3,0)\r
+ draw_vrl1_vgax_modex(\r
+ x-rx,\r
+ y-ry,\r
+ spri->sprite_vrl_cont->vrl_header,\r
+ spri->sprite_vrl_cont->line_offsets,\r
+ spri->sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header),\r
+ spri->sprite_vrl_cont->data_size\r
+ );\r
+\r
+ // restore ptr\r
+ vga_state.vga_graphics_ram = omemptr;\r
+\r
+ // block copy to visible RAM from offscreen\r
+ vga_setup_wm1_block_copy();\r
+ o = VMEMPAGESIZE2; // source offscreen\r
+ o2 = (ry * gv->video.page[0].stridew) + (rx >> 2); // dest visible (original stride)\r
+ for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += gv->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
+\r
+ // restore stride\r
+ vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = gv->video.page[0].stridew;\r
+\r
+ // Depending on delay, update indices\r
+ switch(spri->delay){\r
+ // Delay = 0 means that sprite should loop. Nothing to change here\r
+ case 0:\r
+ break;\r
+\r
+ // Delay = 1 means that on next time unit sprite should be changed\r
+ case 1:\r
+ spri->curr_anim_spri++;\r
+\r
+ // If we hit the end of an animation sequence, restart it\r
+ if(!(spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id)){\r
+ spri->curr_anim_spri = 0;\r
+ spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id;\r
+ }\r
+ spri->delay = spri->curr_anim_list[spri->curr_anim_spri].delay;\r
+\r
+ // Delay > 1 means that we should not change sprite yet. Decrease delay\r
+ default:\r
+ spri->delay--;\r
+ break;\r
+ }\r
+}\r
+*/\r