コード例 #1
0
ファイル: pitDrive.c プロジェクト: zaphinath/SpaceInvaders
void changeCounter(){
	int reg = XGpio_ReadReg(XPAR_PIT_0_BASEADDR, 0x0);
	if(reg << 31 == 0)
		XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, reg+1);
	else
		XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, reg-1);
}
コード例 #2
0
ファイル: xgpio_intr.c プロジェクト: 223323/LPRS2_lab3
/**
* Returns the interrupt enable mask. This function will assert if the
* hardware device has not been built with interrupt capabilities.
*
* @param	InstancePtr is the GPIO instance to operate on.
*
* @return	A mask of bits made from XGPIO_IR* bits which are contained in
*		xgpio_l.h.
*
* @return	None.
*
* @note		None.
*
*****************************************************************************/
u32 XGpio_InterruptGetEnabled(XGpio * InstancePtr)
{
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid(InstancePtr->InterruptPresent == TRUE);

	return XGpio_ReadReg(InstancePtr->BaseAddress, XGPIO_IER_OFFSET);
}
コード例 #3
0
/**
* Read state of discretes for the specified GPIO channnel.
*
* @param	InstancePtr is a pointer to an XGpio instance to be worked on.
* @param	Channel contains the channel of the GPIO (1 or 2) to operate on.
*
* @return	Current copy of the discretes register.
*
* @note		The hardware must be built for dual channels if this function
*		is used with any channel other than 1.  If it is not, this
*		function will assert.
*
*****************************************************************************/
u32 XGpio_DiscreteRead(XGpio * InstancePtr, unsigned Channel)
{
    Xil_AssertNonvoid(InstancePtr != NULL);
    Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
    Xil_AssertNonvoid((Channel == 1) ||
                      ((Channel == 2) && (InstancePtr->IsDual == TRUE)));

    return XGpio_ReadReg(InstancePtr->BaseAddress,
                         ((Channel - 1) * XGPIO_CHAN_OFFSET) +
                         XGPIO_DATA_OFFSET);
}
コード例 #4
0
//------------------------------------------------------------------------------
UINT8 gpio_getAppInput(void)
{
    UINT8 key;

#ifdef GPIO_INPUTS_BASE
    key = XGpio_ReadReg(GPIO_INPUTS_BASE, 0);
#else
    key = 0;
#endif

    return key;
}
コード例 #5
0
//------------------------------------------------------------------------------
UINT8 gpio_getNodeid(void)
{
    UINT8 nodeid;

#ifdef NODE_SWITCH_BASE
    nodeid = XGpio_ReadReg(NODE_SWITCH_BASE, 0);
#else
    nodeid = 0;
#endif

    return nodeid;
}
コード例 #6
0
/**
* The purpose of this function is to illustrate how to use the GPIO low level
* driver to turn on and off an LED.
*
* @param	None
*
* @return	Always 0
*
* @note
* The main function is returning an integer to prevent compiler warnings.
*
******************************************************************************/
int main()
{
	u32 Data;
	volatile int Delay;

	/*
	 * Set the direction for all signals to be inputs except the LED output
	 */
	XGpio_WriteReg((GPIO_REG_BASEADDR),
			((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
			XGPIO_TRI_OFFSET, (~LED));


	/* Loop forever blinking the LED */

	while (1) {
		/*
		 * Read the state of the data so that only the LED state can be
		 * modified
		 */
		Data = XGpio_ReadReg(GPIO_REG_BASEADDR,
				((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
				  XGPIO_DATA_OFFSET);


		/* Set the LED to the opposite state such that it blinks */

		if (Data & LED) {

			XGpio_WriteReg((GPIO_REG_BASEADDR),
				((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
				XGPIO_DATA_OFFSET, Data & ~LED);

		} else {

			XGpio_WriteReg((GPIO_REG_BASEADDR),
				((LED_CHANNEL - 1) * XGPIO_CHAN_OFFSET) +
				XGPIO_DATA_OFFSET, Data | LED);
		}

		/* Wait a small amount of time so that the LED is visible */

		for (Delay = 0; Delay < LED_DELAY; Delay++);
	}

	return 0;
}
コード例 #7
0
ファイル: xgpio_intr.c プロジェクト: 223323/LPRS2_lab3
/**
* Disable interrupts. This function allows specific interrupts for each
* channel to be disabled. This function will assert if the hardware device
* has not been built with interrupt capabilities.
*
* @param	InstancePtr is the GPIO instance to operate on.
* @param 	Mask is the mask to disable. Bits set to 1 are disabled. This
*		mask is formed by OR'ing bits from XGPIO_IR* bits which are
*		contained in xgpio_l.h.
*
* @return	None.
*
* @note		None.
*
*****************************************************************************/
void XGpio_InterruptDisable(XGpio * InstancePtr, u32 Mask)
{
	u32 Register;

	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertVoid(InstancePtr->InterruptPresent == TRUE);

	/*
	 * Read the interrupt enable register and only disable the specified
	 * interrupts without enabling or disabling any others.
	 */
	Register = XGpio_ReadReg(InstancePtr->BaseAddress, XGPIO_IER_OFFSET);
	XGpio_WriteReg(InstancePtr->BaseAddress, XGPIO_IER_OFFSET,
			Register & (~Mask));

}
コード例 #8
0
ファイル: task1.c プロジェクト: PaintScratcher/uni_embs
int checkButtonState(){
	int buttonState = XGpio_ReadReg(XPAR_BUTTONS_4BIT_BASEADDR, RegOffset);

	if (buttonState & 0x8){ // Check North
		north = 0x2;
	}
	if (buttonState & 0x4){ // Check East
		east = 1;
	}
	if (buttonState & 0x2){ // Check West
		west = 0x4;
	}
	if (buttonState & 1){
		west = 0;
		east = 0;
		north = 0;
	}
	return north + west + east;
}
コード例 #9
0
u32 read( XGpio Gpio ){
	XGpio_Initialize(&Gpio, XPAR_GPIO_0_DEVICE_ID);
	lcd commands;
	lcd pinDir;
	u32 gpioPinDir; // 0x0 is output, 0xFFF is input...
	u32 gpioOutput;
	commands.rs = 0;
	commands.rw = 0;
	commands.en = 0;
	commands.db = 0x00;

	pinDir.rs = 0;
	pinDir.rw = 0;
	pinDir.en = 0;
	pinDir.db = 0xFF;
	gpioPinDir = outBits(pinDir);
	XGpio_SetDataDirection(&Gpio, 1, gpioPinDir);
	gpioOutput = outBits(commands);
	XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput);
	// commands.rs = 1;
	commands.rw = 1;
	gpioOutput = outBits(commands);
	XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput);
	delay(3000);
	commands.en = 1;
	gpioOutput = outBits(commands);
	XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput);
	delay(3000);
	// READ
	u32 readVal = 0;
	readVal = XGpio_ReadReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET);
	delay(1000);
	commands.en = 0;
	gpioOutput = outBits(commands);
	XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput);
	delay(1000);
	commands.rs = 0;
	commands.rw = 0;
	gpioOutput = outBits(commands);
	XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput);
	return readVal;
}
コード例 #10
0
ファイル: xgpio_intr.c プロジェクト: 223323/LPRS2_lab3
/**
* Clear pending interrupts with the provided mask. This function should be
* called after the software has serviced the interrupts that are pending.
* This function will assert if the hardware device has not been built with
* interrupt capabilities.
*
* @param 	InstancePtr is the GPIO instance to operate on.
* @param 	Mask is the mask to clear pending interrupts for. Bit positions
*		of 1 are cleared. This mask is formed by OR'ing bits from
*		XGPIO_IR* bits which are contained in xgpio_l.h.
*
* @return	None.
*
* @note		None.
*
*****************************************************************************/
void XGpio_InterruptClear(XGpio * InstancePtr, u32 Mask)
{
	u32 Register;

	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertVoid(InstancePtr->InterruptPresent == TRUE);

	/*
	 * Read the interrupt status register and only clear the interrupts
	 * that are specified without affecting any others.  Since the register
	 * is a toggle on write, make sure any bits to be written are already
	 * set.
	 */
	Register = XGpio_ReadReg(InstancePtr->BaseAddress, XGPIO_ISR_OFFSET);
	XGpio_WriteReg(InstancePtr->BaseAddress, XGPIO_ISR_OFFSET,
			Register & Mask);


}
コード例 #11
0
ファイル: xgpio_extra.c プロジェクト: Akaname/Arty
/**
* Set output discrete(s) to logic 1 for the specified GPIO channel.
*
* @param	InstancePtr is a pointer to an XGpio instance to be worked on.
* @param	Channel contains the channel of the GPIO (1 or 2) to operate on.
* @param	Mask is the set of bits that will be set to 1 in the discrete
*		data register. All other bits in the data register are
*		unaffected.
*
* @return	None.
*
* @note
*
* The hardware must be built for dual channels if this function is used
* with any channel other than 1.  If it is not, this function will assert.
*
* This API can only be used if the GPIO_IO ports in the IP are used for
* connecting to the external output ports.
*
*****************************************************************************/
void XGpio_DiscreteSet(XGpio * InstancePtr, unsigned Channel, u32 Mask)
{
	u32 Current;
	unsigned DataOffset;

	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertVoid((Channel == 1) ||
		     ((Channel == 2) && (InstancePtr->IsDual == TRUE)));

	/*
	 * Calculate the offset to the data register of the GPIO once
	 */
	DataOffset = ((Channel - 1) * XGPIO_CHAN_OFFSET) + XGPIO_DATA_OFFSET;

	/*
	 * Read the contents of the data register, merge in Mask and write
	 * back results
	 */
	Current = XGpio_ReadReg(InstancePtr->BaseAddress, DataOffset);
	Current |= Mask;
	XGpio_WriteReg(InstancePtr->BaseAddress, DataOffset, Current);
}
コード例 #12
0
ファイル: pitDrive.c プロジェクト: zaphinath/SpaceInvaders
void changeInterrupt(){

	int reg = XGpio_ReadReg(XPAR_PIT_0_BASEADDR, 0x0);
	reg = reg ^2;
	XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, reg);
}
コード例 #13
0
ファイル: pitDrive.c プロジェクト: zaphinath/SpaceInvaders
void reloadcounter(){
	int reg = XGpio_ReadReg(XPAR_PIT_0_BASEADDR, 0x0);
	reg = reg ^4;
	XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, reg);
}
コード例 #14
0
ファイル: task1.c プロジェクト: PaintScratcher/uni_embs
int checkSwitchState(){
	//Read state of switches
	int switchState = XGpio_ReadReg(XPAR_DIP_SWITCHES_4BIT_BASEADDR, RegOffset);
	//Get the last four bits via a shift
	return switchState << 4;
}
コード例 #15
0
int main(){

	int i, addr, cont, LorR = 1, bullets[MAX_BULLETS] = {-1}, bullDir[MAX_BULLETS] = {1};

	int foreground[1200] = {0}, background[1200] = {0};
	evinLoc oldLoc = {1040, 1041, 1080, 1081, 1120, 1121};
	evinLoc newLoc = {1040, 1041, 1080, 1081, 1120, 1121};
	evinLoc endLoc = {558, 559, 598, 599, 638, 639};

	//sprite map declaration
	int sprMap[2048] = {	//evin TL 0
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cblk1, cblk1, cblk1, cblk1, cwht0, cwht0,
			cwht0, cblk1, cyel1, cyel1, cred1, cred1, cblk1, cwht0,
			cwht0, cblk1, cyel1, cyel1, cred1, cred1, cblk1, cwht0,
			cwht0, cblk1, cyel1, cyel1, cred1, cred1, cblk1, cwht0,
			cwht0, cblk1, cyel1, cyel1, cred1, cred1, cblk1, cwht0,
			cwht0, cblk1, cblk1, cblk1, cblk1, cblk1, cwht0, cwht0,
			//evin TR 1
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cblk1, cblk1, cblk1, cblk1, cblk1, cwht0,
			cwht0, cblk1, cred1, cred1, cred1, cyel1, cyel1, cblk1,
			cwht0, cblk1, cred1, cred1, cred1, cyel1, cyel1, cblk1,
			cwht0, cblk1, cred1, cred1, cred1, cyel1, cyel1, cblk1,
			cwht0, cblk1, cred1, cred1, cred1, cyel1, cyel1, cblk1,
			cwht0, cwht0, cblk1, cblk1, cblk1, cblk1, cblk1, cwht0,
			cwht0, cwht0, cwht0, cblk1, cwht0, cwht0, cwht0, cwht0,
			//evin CL 2
			cwht0, cwht0, cwht0, cwht0, cblk1, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cblk1, cwht0, cwht0, ccyn1,
			cwht0, cwht0, cwht0, cwht0, cblk1, cblk1, cblk1, cblk1,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cblk1, cblk1,
			cwht0, cwht0, cwht0, cwht0, cblk1, cblk1, cblk1, cblk1,
			cgrn1, cgrn1, cgrn1, cblk1, cblk1, cblu1, cblu1, cblu1,
			cgrn1, cwht0, cwht0, cblk1, cblu1, cblu1, cblu1, cblu1,
			cgrn1, cwht0, cwht0, cblk1, cblu1, cblu1, cblu1, cblu1,
			//evin CR 3
			cwht0, cwht0, cwht0, cblk1, cwht0, cwht0, cwht0, cwht0,
			ccyn1, cwht0, cwht0, cblk1, cwht0, cwht0, cwht0, cwht0,
			cblk1, cblk1, cblk1, cblk1, cwht0, cwht0, cwht0, cwht0,
			cblk1, cblk1, cwht0, cwht0, cwht0, cgrn1, cgrn1, cwht0,
			cblk1, cblk1, cblk1, cblk1, cwht0, cwht0, cgrn1, cwht0,
			cblu1, cblu1, cblu1, cblk1, cblk1, cwht0, cgrn1, cwht0,
			cblu1, cblu1, cblu1, cblu1, cblk1, cgrn1, cgrn1, cwht0,
			cblu1, cblu1, cblu1, cblu1, cblk1, cwht0, cwht0, cwht0,
			//evin BL 4
			cgrn1, cgrn1, cwht0, cblk1, cblu1, cblu1, cblu1, cblu1,
			cwht0, cwht0, cwht0, cblk1, cblu1, cblu1, cblu1, cblu1,
			cwht0, cwht0, cwht0, cblk1, cblk1, cblu1, cblu1, cblu1,
			cwht0, cwht0, cwht0, cwht0, cblk1, cblu1, cblu1, cblu1,
			cwht0, cwht0, cwht0, cblk1, cblk1, cblu1, cblu1, cblu1,
			cwht0, cwht0, cblk1, cblk1, cblu1, cblu1, cblu1, cblu1,
			cwht0, cwht0, cblk1, cblk1, cblk1, cblk1, cblk1, cblk1,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//evin BR 5
			cblu1, cblu1, cblu1, cblu1, cblk1, cwht0, cwht0, cwht0,
			cblu1, cblu1, cblu1, cblu1, cblk1, cwht0, cwht0, cwht0,
			cblu1, cblu1, cblu1, cblk1, cblk1, cwht0, cwht0, cwht0,
			cblu1, cblu1, cblu1, cblk1, cwht0, cwht0, cwht0, cwht0,
			cblu1, cblu1, cblu1, cblk1, cblk1, cwht0, cwht0, cwht0,
			cblu1, cblu1, cblu1, cblu1, cblk1, cblk1, cwht0, cwht0,
			cblk1, cblk1, cblk1, cblk1, cblk1, cblk1, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//foreground 6
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//win 7
			cblk0, cyel0, cblk0, cyel0, cblk0, cyel0, cblk0, cblk0,
			cblk0, cblk0, cyel0, cblk0, cyel0, cblk0, cblk0, cblk0,
			cblk0, cblk0, cgrn0, cgrn0, cgrn0, cblk0, cblk0, cblk0,
			cblk0, cblk0, cblk0, cgrn0, cblk0, cblk0, cblk0, cblk0,
			cblk0, cblk0, cgrn0, cgrn0, cgrn0, cblk0, cblk0, cblk0,
			cblk0, cred0, cred0, cblk0, cblk0, cred0, cblk0, cblk0,
			cblk0, cred0, cblk0, cred0, cblk0, cred0, cblk0, cblk0,
			cblk0, cred0, cblk0, cblk0, cred0, cred0, cblk0, cblk0,
			//evin bullet 8
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cblu1, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cblu1, ccyn1, cblu1, cwht0, cwht0, cwht0,
			cwht0, cblu1, cblu1, ccyn1, cblu1, cblu1, cwht0, cwht0,
			cwht0, cblu1, cblu1, ccyn1, cblu1, cblu1, cwht0, cwht0,
			cwht0, cwht0, cblu1, ccyn1, cblu1, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cblu1, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//bullet enemy 9
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cmag1, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cmag1, cred1, cmag1, cwht0, cwht0, cwht0,
			cwht0, cmag1, cmag1, cred1, cmag1, cmag1, cwht0, cwht0,
			cwht0, cmag1, cmag1, cred1, cmag1, cmag1, cwht0, cwht0,
			cwht0, cwht0, cmag1, cred1, cmag1, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cmag1, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//10
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//11
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//12
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//13
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//14
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//15
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//16
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//17
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//18
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//19
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//20
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//21
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//22
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//23
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//green/magenta level 24
			cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0,
			cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0,
			cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0,
			cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0,
			cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0,
			cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0,
			cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0,
			cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0, cmag0, cgrn0,
			//yellow level 25
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0, cyel0,
			//blue level 26
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0, cblu0,
			//cyan level 27
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0, ccyn0,
			//black/white level 28
			cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0, cblk0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//white level 29
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0, cwht0,
			//rock 30
			cred0, cred0, cred0, cred0, cred0, cred0, cred0, cred0,
			cred0, cred0, cred0, cwht0, cwht0, cwht0, cwht0, cred0,
			cred0, cred0, cred0, cwht0, cred0, cred0, cwht0, cred0,
			cred0, cred0, cred0, cwht0, cred0, cred0, cwht0, cred0,
			cred0, cred0, cred0, cwht0, cwht0, cwht0, cwht0, cred0,
			cred0, cred0, cred0, cred0, cred0, cred0, cred0, cred0,
			cred0, cred0, cred0, cred0, cred0, cred0, cred0, cred0,
			cred0, cred0, cred0, cred0, cred0, cred0, cred0, cred0,
			//background 31
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0,
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0,
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0,
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0,
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0,
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0,
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0,
			cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0, cmag0
	};

	for (i = 0; i < 1200; ++i){								//magenta level
		background[i] = 31;
		foreground[i] = 6;
	}

	for (i = 679; i < 1200; i += 40) background[i] = 30;

	for (i = 670; i < 675; ++i) background[i] = 30;
	for (i = 740; i < 745; ++i) background[i] = 30;
	for (i = 840; i < 850; ++i) background[i] = 30;
	for (i = 1017; i < 1028; ++i) background[i] = 30;
	for (i = 1160; i < 1200; ++i) background[i] = 30;

	foreground[oldLoc.tl] = 0;
	foreground[oldLoc.tr] = 1;
	foreground[oldLoc.cl] = 2;
	foreground[oldLoc.cr] = 3;
	foreground[oldLoc.bl] = 4;
	foreground[oldLoc.br] = 5;
	for (;;){

		cont = XGpio_ReadReg(controllerCoreAddr, 0);
		//process move
		if (cont == 254){					//A (jump)
			if (background[newLoc.tl-40] != 30 && background[newLoc.tr-40] != 30 && newLoc.tl > 39 &&
					newLoc.tr > 39){
				newLoc.tl = oldLoc.tl - 40;
				newLoc.tr = oldLoc.tr - 40;
				newLoc.cl = oldLoc.cl - 40;
				newLoc.cr = oldLoc.cr - 40;
				newLoc.bl = oldLoc.bl - 40;
				newLoc.br = oldLoc.br - 40;
				foreground[oldLoc.bl] = 6;
				foreground[oldLoc.br] = 6;
			}
		}
		if (cont == 253){					//B (fire)
			for (i = 0; i < MAX_BULLETS; ++i){
				if (bullets[i] == -1){
					if (LorR == 1){
						bullets[i] = oldLoc.cr + 1;
						bullDir[i] = 1;
					}
					else{
						bullets[i] = oldLoc.cl - 1;
						bullDir[i] = -1;
					}
					break;
				}
			}
		}
		if (cont == 191){					//left
			LorR = -1;
			if (background[newLoc.tl-1] != 30 && background[newLoc.cl-1] != 30 && background[newLoc.bl-1] != 30){
				newLoc.tl = oldLoc.tl - 1;
				newLoc.tr = oldLoc.tr - 1;
				newLoc.cl = oldLoc.cl - 1;
				newLoc.cr = oldLoc.cr - 1;
				newLoc.bl = oldLoc.bl - 1;
				newLoc.br = oldLoc.br - 1;
				foreground[oldLoc.tr] = 6;
				foreground[oldLoc.cr] = 6;
				foreground[oldLoc.br] = 6;
			}
		}
		if (cont == 190){					//left + A
			if (background[newLoc.tl+1] != 30 && background[newLoc.cl+1] != 30 && background[newLoc.bl+1] != 30
					&& newLoc.tl > -1 && newLoc.tr > -1){
				newLoc.tl = oldLoc.tl - 41;
				newLoc.tr = oldLoc.tr - 41;
				newLoc.cl = oldLoc.cl - 41;
				newLoc.cr = oldLoc.cr - 41;
				newLoc.bl = oldLoc.bl - 41;
				newLoc.br = oldLoc.br - 41;
				foreground[oldLoc.tr] = 6;
				foreground[oldLoc.cr] = 6;
				foreground[oldLoc.bl] = 6;
				foreground[oldLoc.br] = 6;
			}
		}
		if (cont == 127){					//right
			LorR = 1;
			if (background[newLoc.tr+1] != 30 && background[newLoc.cr+1] != 30 && background[newLoc.br+1] != 30
					|| ((newLoc.cr+1) % 39 != 39) || (newLoc.cr != 39 || newLoc.cr != 79 || newLoc.cr != 119 || newLoc.cr != 159
					|| newLoc.cr != 199 || newLoc.cr != 239 || newLoc.cr != 279 || newLoc.cr != 319
					|| newLoc.cr != 359 || newLoc.cr != 399 || newLoc.cr != 439 || newLoc.cr != 479
					|| newLoc.cr != 519 || newLoc.cr != 559 || newLoc.cr != 599 || newLoc.cr != 639
					|| newLoc.cr != 679 || newLoc.cr != 719 || newLoc.cr != 759 || newLoc.cr != 799
					|| newLoc.cr != 839 || newLoc.cr != 879 || newLoc.cr != 919 || newLoc.cr != 959
					|| newLoc.cr != 999 || newLoc.cr != 1039 || newLoc.cr != 1079 || newLoc.cr != 1119
					|| newLoc.cr != 1159 || newLoc.cr != 1199)){
				newLoc.tl = oldLoc.tl + 1;
				newLoc.tr = oldLoc.tr + 1;
				newLoc.cl = oldLoc.cl + 1;
				newLoc.cr = oldLoc.cr + 1;
				newLoc.bl = oldLoc.bl + 1;
				newLoc.br = oldLoc.br + 1;
				foreground[oldLoc.tl] = 6;
				foreground[oldLoc.cl] = 6;
				foreground[oldLoc.bl] = 6;
			}
		}
		if (cont == 126){					//right + A
			if (background[newLoc.tr+1] != 30 && background[newLoc.cr+1] != 30 && background[newLoc.br+1] != 30
					&& newLoc.tl > 39 && newLoc.tr > 39){
				newLoc.tl = oldLoc.tl - 39;
				newLoc.tr = oldLoc.tr - 39;
				newLoc.cl = oldLoc.cl - 39;
				newLoc.cr = oldLoc.cr - 39;
				newLoc.bl = oldLoc.bl - 39;
				newLoc.br = oldLoc.br - 39;
				foreground[oldLoc.tl] = 6;
				foreground[oldLoc.cl] = 6;
				foreground[oldLoc.bl] = 6;
				foreground[oldLoc.br] = 6;
			}
		}

		//gravity?
		if (cont != 254 && background[oldLoc.bl+40] != 30 && background[oldLoc.br+40] != 30){
			if(cont == 191){
				newLoc.tl += 39;
				newLoc.tr += 39;
				newLoc.cl += 39;
				newLoc.cr += 39;
				newLoc.bl += 39;
				newLoc.br += 39;
				foreground[oldLoc.tl] = 6;
				foreground[oldLoc.cl] = 6;
				foreground[oldLoc.bl] = 6;
				foreground[oldLoc.tr] = 6;
				foreground[oldLoc.cr] = 6;
				foreground[oldLoc.br] = 6;
			}
			else if (cont == 127){
				newLoc.tl += 41;
				newLoc.tr += 41;
				newLoc.cl += 41;
				newLoc.cr += 41;
				newLoc.bl += 41;
				newLoc.br += 41;
				foreground[oldLoc.tl] = 6;
				foreground[oldLoc.cl] = 6;
				foreground[oldLoc.bl] = 6;
				foreground[oldLoc.tr] = 6;
				foreground[oldLoc.cr] = 6;
				foreground[oldLoc.br] = 6;
			}
			else {
				newLoc.tl += 40;
				newLoc.tr += 40;
				newLoc.cl += 40;
				newLoc.cr += 40;
				newLoc.bl += 40;
				newLoc.br += 40;
				foreground[oldLoc.tl] = 6;
				foreground[oldLoc.tr] = 6;
			}
		}

		//copy over old location to new
		oldLoc = newLoc;

		foreground[oldLoc.tl] = 0;
		foreground[oldLoc.tr] = 1;
		foreground[oldLoc.cl] = 2;
		foreground[oldLoc.cr] = 3;
		foreground[oldLoc.bl] = 4;
		foreground[oldLoc.br] = 5;

		//update any bullets out there
		for (i = 0; i < MAX_BULLETS; ++i){
			if (bullets[i] != -1){
				foreground[bullets[i]] = 6;
				bullets[i] += bullDir[i];
				if (background[bullets[i]] == 30 || (bullets[i] == 0) || (bullets[i] == 39) || (bullets[i] == 79)
						|| (bullets[i] == 119) || (bullets[i] == 159) || (bullets[i] == 199)
						|| (bullets[i] == 239) || (bullets[i] == 279) || (bullets[i] == 319)
						|| (bullets[i] == 359) || (bullets[i] == 399) || (bullets[i] == 439)
						|| (bullets[i] == 479) || (bullets[i] == 519) || (bullets[i] == 559)
						|| (bullets[i] == 599) || (bullets[i] == 639) || (bullets[i] == 679)
						|| (bullets[i] == 719) || (bullets[i] == 759) || (bullets[i] == 799)
						|| (bullets[i] == 839) || (bullets[i] == 879) || (bullets[i] == 919)
						|| (bullets[i] == 959) || (bullets[i] == 999) || (bullets[i] == 1039)
						|| (bullets[i] == 1079) || (bullets[i] == 1119) || (bullets[i] == 1159)
						|| (bullets[i] == 1199)) bullets[i] = -1;
				else foreground[bullets[i]] = 8;
			}
		}

		//start with foreground
		for (addr = 0; addr < 1200; ++addr){
			XGpio_WriteReg(IPcoreAddr, 0, addr + foreground[addr]*fgSprOff + fgOff);
			XGpio_ReadReg(IPcoreAddr, 0);
		}

		//now do background
		for (addr = 0; addr < 1200; ++addr){
			XGpio_WriteReg(IPcoreAddr, 0, addr + background[addr]*bgSprOff + bgOff);
			XGpio_ReadReg(IPcoreAddr, 0);
		}

		//finally sprite
		for (addr = 0; addr < 2048; ++addr){
			XGpio_WriteReg(IPcoreAddr, 0, addr + sprMap[addr]*sprColorOff + sprOff);
			XGpio_ReadReg(IPcoreAddr, 0);
		}

		//proceed to next level if we reach the goal
		if (endLoc.tl == oldLoc.tl && endLoc.tr == oldLoc.tr && endLoc.cl == oldLoc.cl &&
				endLoc.cr == oldLoc.cr && endLoc.bl == oldLoc.bl && endLoc.br == oldLoc.br) break;
	}

	/*for(;;){
		cont = XGpio_ReadReg(controllerCoreAddr, 0);
		//paint background
		if (cont == 254){ //A
			for (i = 0; i < 1200; ++i){
				background[i] = 29;
				foreground[i] = 6;
			}
			foreground[1040] = 0;
			foreground[1041] = 1;
			foreground[1080] = 2;
			foreground[1081] = 3;
			foreground[1120] = 4;
			foreground[1121] = 5;

			for (i = 0; i < 1040; i += 40) background[i] = 30;
			for (i = 39; i < 1040; i += 40) background[i] = 30;
			for (i = 436; i < 1200; i += 40) background[i] = 30;
			for (i = 731; i < 931; i += 40) background[i] = 30;

			for (i = 0; i < 40; ++i) background[i] = 30;
			for (i = 309; i < 311; ++i) background[i] = 30;
			for (i = 455; i < 457; ++i) background[i] = 30;
			for (i = 465; i < 467; ++i) background[i] = 30;
			for (i = 566; i < 568; ++i) background[i] = 30;
			for (i = 721; i < 723; ++i) background[i] = 30;
			for (i = 928; i < 935; ++i) background[i] = 30;
			for (i = 1160; i < 1200; ++i) background[i] = 30;
		}
		else if (cont == 253){ //B
			for (i = 0; i < 1200; ++i){
				background[i] = 28;
				foreground[i] = 6;
			}
			foreground[0] = 0;
			foreground[1] = 1;
			foreground[40] = 2;
			foreground[41] = 3;
			foreground[80] = 4;
			foreground[81] = 5;

			for (i = 899; i < 902; ++i) background[i] = 30;
			for (i = 1026; i < 1029; ++i) background[i] = 30;
			for (i = 1012; i < 1015; ++i) background[i] = 30;
			for (i = 1160; i < 1200; ++i) background[i] = 30;
		}
		else if (cont == 239){ //up
			for (i = 0; i < 1200; ++i){
				background[i] = 27;
				foreground[i] = 6;
			}
			foreground[400] = 0;
			foreground[401] = 1;
			foreground[440] = 2;
			foreground[441] = 3;
			foreground[480] = 4;
			foreground[481] = 5;

			for (i = 520; i < 523; ++i) background[i] = 30;

			for (i = 62; i < 65; ++i) background[i] = 30;
			for (i = 186; i < 189; ++i) background[i] = 30;
			for (i = 312; i < 315; ++i) background[i] = 30;
			for (i = 428; i < 431; ++i) background[i] = 30;
			for (i = 544; i < 547; ++i) background[i] = 30;
			for (i = 660; i < 663; ++i) background[i] = 30;
			for (i = 776; i < 779; ++i) background[i] = 30;
			for (i = 892; i < 895; ++i) background[i] = 30;
			for (i = 1008; i < 1011; ++i) background[i] = 30;
			for (i = 1124; i < 1127; ++i) background[i] = 30;
		}
		else if (cont == 223){ //down
			for (i = 0; i < 1200; ++i){
				background[i] = 26;
				foreground[i] = 6;
			}
			foreground[1040] = 0;
			foreground[1041] = 1;
			foreground[1080] = 2;
			foreground[1081] = 3;
			foreground[1120] = 4;
			foreground[1121] = 5;

			for (i = 0; i < 1000; i += 40) background[i] = 30;
			for (i = 39; i < 1200; i += 40) background[i] = 30;
			for (i = 251; i < 411; i += 40) background[i] = 30;

			for (i = 115; i < 118; ++i) background[i] = 30;
			for (i = 200; i < 206; ++i) background[i] = 30;
			for (i = 214; i < 216; ++i) background[i] = 30;
			for (i = 263; i < 272; ++i) background[i] = 30;
			for (i = 369; i < 371; ++i) background[i] = 30;
			for (i = 520; i < 526; ++i) background[i] = 30;
			for (i = 720; i < 735; ++i) background[i] = 30;
			for (i = 750; i < 760; ++i) background[i] = 30;
			for (i = 940; i < 950; ++i) background[i] = 30;
			for (i = 1160; i < 1200; ++i) background[i] = 30;
		}
		else if (cont == 191){ //left
			for (i = 0; i < 1200; ++i){
				background[i] = 25;
				foreground[i] = 6;
			}
			foreground[440] = 0;
			foreground[441] = 1;
			foreground[480] = 2;
			foreground[481] = 3;
			foreground[520] = 4;
			foreground[521] = 5;

			for (i = 455; i < 575; i += 40) background[i] = 30;
			for (i = 461; i < 601; i += 40) background[i] = 30;

			for (i = 560; i < 576; ++i) background[i] = 30;
			for (i = 581; i < 600; ++i) background[i] = 30;

		}
		else if (cont == 127){ //right
			for (i = 0; i < 1200; ++i){
				background[i] = 24;
				foreground[i] = 6;
			}
			foreground[0] = 0;
			foreground[1] = 1;
			foreground[40] = 2;
			foreground[41] = 3;
			foreground[80] = 4;
			foreground[81] = 5;

			for (i = 19; i < 619; i += 40) background[i] = 30;

			for (i = 67; i < 70; ++i) background[i] = 30;
			for (i = 120; i < 123; ++i) background[i] = 30;
			for (i = 196; i < 199; ++i) background[i] = 30;
			for (i = 290; i < 293; ++i) background[i] = 30;
			for (i = 387; i < 390; ++i) background[i] = 30;
			for (i = 440; i < 443; ++i) background[i] = 30;
			for (i = 556; i < 559; ++i) background[i] = 30;
			for (i = 690; i < 693; ++i) background[i] = 30;
			for (i = 707; i < 710; ++i) background[i] = 30;
			for (i = 898; i < 901; ++i) background[i] = 30;
		}
		else{
			for (i = 0; i < 1200; ++i){
				background[i] = 31;
				foreground[i] = 6;
			}
			foreground[0] = 0;
			foreground[1] = 1;
			foreground[40] = 2;
			foreground[41] = 3;
			foreground[80] = 4;
			foreground[81] = 5;

			for (i = 679; i < 1200; i += 40) background[i] = 30;

			for (i = 670; i < 675; ++i) background[i] = 30;
			for (i = 740; i < 745; ++i) background[i] = 30;
			for (i = 840; i < 850; ++i) background[i] = 30;
			for (i = 1017; i < 1028; ++i) background[i] = 30;
			for (i = 1160; i < 1200; ++i) background[i] = 30;
		}

		//start with foreground
		for (addr = 0; addr < 1200; ++addr){
			XGpio_WriteReg(IPcoreAddr, 0, addr + foreground[addr]*fgSprOff + fgOff);
			XGpio_ReadReg(IPcoreAddr, 0);
		}

		//now do background
		for (addr = 0; addr < 1200; ++addr){
			XGpio_WriteReg(IPcoreAddr, 0, addr + background[addr]*bgSprOff + bgOff);
			XGpio_ReadReg(IPcoreAddr, 0);
		}

		//finally sprite
		for (addr = 0; addr < 2048; ++addr){
			XGpio_WriteReg(IPcoreAddr, 0, addr + sprMap[addr]*sprColorOff + sprOff);
			XGpio_ReadReg(IPcoreAddr, 0);
		}

	}*/

	return 0;
}