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); }
void freqency(int enter){ XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, 0x00000006); XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x4, enter); XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, 0x00000007); }
/** * 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; }
//------------------------------------------------------------------------------ void gpio_setAppOutputs(UINT32 val_p) { #ifdef GPIO_OUTPUTS_BASE XGpio_WriteReg(GPIO_OUTPUTS_BASE, XGPIO_DATA_OFFSET, val_p); #else UNUSED_PARAMETER(val_p); #endif }
int main() { while(1){ //Set the LED's to the switch state int LEDState = checkSwitchState() + checkButtonState(); XGpio_WriteReg(XPAR_LEDS_8BIT_BASEADDR,RegOffset, LEDState); } return 0; }
/** * Enable the interrupt output signal. Interrupts enabled through * XGpio_InterruptEnable() will not be passed through until the global enable * bit is set by this function. This function is designed to allow all * interrupts (both channels) to be enabled easily for exiting a critical * section. 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 None. * * @note None. * *****************************************************************************/ void XGpio_InterruptGlobalEnable(XGpio * InstancePtr) { Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertVoid(InstancePtr->InterruptPresent == TRUE); XGpio_WriteReg(InstancePtr->BaseAddress, XGPIO_GIE_OFFSET, XGPIO_GIE_GINTR_ENABLE_MASK); }
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; }
/** * Write to discretes register 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 Data is the value to be written to the discretes register. * * @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. See also XGpio_DiscreteSet() and * XGpio_DiscreteClear(). * *****************************************************************************/ void XGpio_DiscreteWrite(XGpio * InstancePtr, unsigned Channel, u32 Data) { Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertVoid((Channel == 1) || ((Channel == 2) && (InstancePtr->IsDual == TRUE))); XGpio_WriteReg(InstancePtr->BaseAddress, ((Channel - 1) * XGPIO_CHAN_OFFSET) + XGPIO_DATA_OFFSET, Data); }
//------------------------------------------------------------------------------ void gpio_setErrorLed(BOOL fOn_p) { if (fOn_p != FALSE) plkStatusLeds_l |= (1 << GPIO_ERROR_LED_BIT); else plkStatusLeds_l &= ~(1 << GPIO_ERROR_LED_BIT); #ifdef STATUS_LEDS_BASE XGpio_WriteReg(STATUS_LEDS_BASE, XGPIO_DATA_OFFSET, plkStatusLeds_l); #endif }
/** * Set the input/output direction of all discrete signals 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 DirectionMask is a bitmask specifying which discretes are input * and which are output. Bits set to 0 are output and bits set to 1 * are input. * * @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. * *****************************************************************************/ void XGpio_SetDataDirection(XGpio * InstancePtr, unsigned Channel, u32 DirectionMask) { Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertVoid((Channel == 1) || ((Channel == 2) && (InstancePtr->IsDual == TRUE))); XGpio_WriteReg(InstancePtr->BaseAddress, ((Channel - 1) * XGPIO_CHAN_OFFSET) + XGPIO_TRI_OFFSET, DirectionMask); }
void writeInst(lcd screen, XGpio Gpio){ XGpio_Initialize(&Gpio, XPAR_GPIO_0_DEVICE_ID); lcd pinDir; u32 gpioOutput; u32 gpioPinDir; // 0x0 is output, 0xFFF is input... pinDir.rs = 0; pinDir.rw = 0; pinDir.en = 0; pinDir.db = 0xFF; gpioPinDir = outBits(pinDir); // screen arrives with the bits to be written already set. XGpio_SetDataDirection(&Gpio, 1, gpioPinDir); // Start of timing screen.rs = 1; screen.rw = 0; screen.en = 0; gpioOutput = outBits(screen); XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput); delay(1000); screen.en = 1; gpioOutput = outBits(screen); XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput); delay(3000); pinDir.db = 0x00; gpioPinDir = outBits(pinDir); XGpio_SetDataDirection(&Gpio, 1, gpioPinDir); XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput); delay(3000); screen.en = 0; gpioOutput = outBits(screen); XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput); pinDir.db = 0xFF; gpioPinDir = outBits(pinDir); XGpio_SetDataDirection(&Gpio, 1, gpioPinDir); screen.rs = 1; screen.rw = 1; gpioOutput = outBits(screen); XGpio_WriteReg(Gpio.BaseAddress, XGPIO_DATA_OFFSET,gpioOutput); }
/** * 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)); }
/** * 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); }
/** * 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); }
void changeInterrupt(){ int reg = XGpio_ReadReg(XPAR_PIT_0_BASEADDR, 0x0); reg = reg ^2; XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, reg); }
void reloadcounter(){ int reg = XGpio_ReadReg(XPAR_PIT_0_BASEADDR, 0x0); reg = reg ^4; XGpio_WriteReg(XPAR_PIT_0_BASEADDR, 0x0, reg); }
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; }
void init_port(){ XGpio_WriteReg(XPAR_GPIO_0_BASEADDR, 4, 0b0010); }