#include <io.h>
#include <system.h>
#include <stdio.h>

#define IOWR_SRAM_DATA(base, offset, data) \
  IOWR_16DIRECT(base, (offset) * 2, data)

// 60* 80 player 13 2
// 60 * 80 boss 15 0
// 30 * 14 bullet14 1


int main()
{

    int xPlayerCoordinate;
    int yPlayerCoordinate;
    int xBossCoordinate;
    int yBossCoordinate;
    int xBulletCoordinate;
    int yBulletCoordinate;
    int xSpeed;
    int ySpeed;
    int xLowBound;
    int xHighBound;
    int yLowBound;
    int yHighBound;
    int counter=10000;
    int time;
    printf("software works \n");

    //IOWR_VGA_SPEED(VGA_BASE, 0x0040);

    xPlayerCoordinate = 40;
    yPlayerCoordinate = 50;
    xBossCoordinate = 600;
    yBossCoordinate = 200;
    xSpeed = 2;
    ySpeed = -2;
    xLowBound = 0;
    xHighBound = 640;
    yLowBound = 0;
    yHighBound = 480;


    for(;;){
    	counter--;

    	if (counter ==0)
    	{
    		counter=10000;

        if(yPlayerCoordinate - yLowBound <= 50){
            ySpeed = - ySpeed;
        }
        if(yHighBound - yPlayerCoordinate <= 50){
            ySpeed = - ySpeed;
        }

        if(yBulletCoordinate == 640){
        	xBulletCoordinate = 80;
        	yBulletCoordinate = yPlayerCoordinate;
        }
        xBulletCoordinate = xBulletCoordinate + xSpeed;
        yPlayerCoordinate = yPlayerCoordinate + ySpeed;

        IOWR_SRAM_DATA(VGA_BASE, 2, xPlayerCoordinate);
        IOWR_SRAM_DATA(VGA_BASE, 13, yPlayerCoordinate);
    	}
    }


    return 0;
}
