#include <io.h>
#include <system.h>
#include <stdio.h>
#include "vga_update.h"
//------------------------------------------------
extern int x, y;

int vga_cnt = 0;
//------------------------------------------------
void sprite_refresh()
{
    IOWR_END_IRQ();
    sprite_clear_all();
    int half_second;
    half_second = vga_cnt / 30;
    if(vga_cnt < 659) vga_cnt++;
    else vga_cnt = 0;
    //IOWR_SET_SPRITE(x, 250, 2+half_second, 2, 1, 1);
    //IOWR_SET_SPRITE(x, 200, 22-half_second, 3, 0, 1);
    //IOWR_SET_SPRITE(250, 250, 11, 0, 0, 1);
    IOWR_SET_SPRITE(x+150,  0, 1, 1, 1, 1);
    IOWR_SET_SPRITE(x+300,  0, 2, 2, 1, 1);
    //IOWR_SET_SPRITE(x+450,  0, 3, 3, 1, 1);
    IOWR_SET_SPRITE(x+0,    100, 4, 4, 1, 1);
    IOWR_SET_SPRITE(x+150,  100, 5, 5, 1, 1);
    IOWR_SET_SPRITE(x+300,  100, 6, 6, 1, 1);
    IOWR_SET_SPRITE(x+450,  100, 14, 7, 0, 1);
    IOWR_SET_SPRITE(x+0,    200, 8, 8, 0, 1);
    IOWR_SET_SPRITE(x+150,  200, 9, 9, 0, 1);
    IOWR_SET_SPRITE(x+300,  200, 10, 10, 0, 1);
    IOWR_SET_SPRITE(x+450,  200, 11, 11, 0, 1);
    IOWR_SET_SPRITE(x+0,    300, 12, 12, 0, 1);
    IOWR_SET_SPRITE(x+150,  300, 13, 13, 0, 1);
    IOWR_SET_SPRITE(x+300,  300, 14, 14, 0, 1);
    IOWR_SET_SPRITE(x+450,  300, 15, 15, 0, 1);
}
void sprite_clear_all()
{
    int i;
    for(i = 0; i<16; i++) IOWR_SET_SPRITE( 1023, 1023, 0, i, 0, 0 );
}
