int interruptManager (unsigned int * framePointer0) { init_platform(); // Initialize the GPIO peripherals. int success; // Used for CPU utilization. Uncomment if desired // XTmrCtr_Initialize(instPtr, 0); success = XGpio_Initialize(&gpPB, XPAR_PUSH_BUTTONS_5BITS_DEVICE_ID); // Set the push button peripheral to be inputs. XGpio_SetDataDirection(&gpPB, 1, 0x0000001F); // Enable the global GPIO interrupt for push buttons. XGpio_InterruptGlobalEnable(&gpPB); // Enable all interrupts in the push button peripheral. XGpio_InterruptEnable(&gpPB, 0xFFFFFFFF); // Reset the XAC97 Chip XAC97_HardReset(XPAR_AXI_AC97_0_BASEADDR); XAC97_mSetControl(XPAR_AXI_AC97_0_BASEADDR, AC97_ENABLE_IN_FIFO_INTERRUPT); XAC97_mSetControl(AC97_ExtendedAudioStat, AC97_EXTENDED_AUDIO_CONTROL_VRA); setVolLevel(AC97_VOL_MAX); clearAllSounds(); microblaze_register_handler(interrupt_handler_dispatcher, NULL); XIntc_EnableIntr(XPAR_INTC_0_BASEADDR, (XPAR_FIT_TIMER_0_INTERRUPT_MASK | XPAR_PUSH_BUTTONS_5BITS_IP2INTC_IRPT_MASK | XPAR_AXI_AC97_0_INTERRUPT_MASK)); XIntc_MasterEnable(XPAR_INTC_0_BASEADDR); microblaze_enable_interrupts(); // Uncomment for CPU utilization stats /*XTmrCtr Timer; XTmrCtr *instPtr = &Timer; XTmrCtr_Initialize(instPtr, 0); XTmrCtr_Start(instPtr, 0);*/ while(!isEndOfGame()); // Program never ends. // Uncomment for CPU utilization stats /*XTmrCtr_Stop(instPtr, 0); int val = (int) XTmrCtr_GetValue(instPtr, 0); xil_printf("%d\n\r", val);*/ clearAllSounds(); XAC97_ClearFifos(XPAR_AXI_AC97_0_BASEADDR); drawGameOver(); cleanup_platform(); return 0; }
Move Board::addTokenInColumn(unsigned int column, Token playerColor) { // Search for empty spaces in the column, from bottom to top for(int i = BOARD_Y_SIZE; i>0; i--) { // add the token (red or yellow) if there is space in the column if(board[i][column] == Empty) { board[i][column] = playerColor; //Verify if the player has won if (isEndOfGame(i, column)) return EndOfGame; else return Placed; } } // if it ends up here, it means the column is already full // and the token cannot be placed in the column return Full; }