/*************************************************************************** * \brief ISR for ENC_A * \return void ***************************************************************************/ __declspec (interrupt) void EncAISR (void) { unsigned char mask; if (DIORead(ENC_A)) { if (DIORead(ENC_B)) { stateRegister.move = SI_MOVE_LEFT; } else { stateRegister.move = SI_MOVE_RIGHT; } } else { if (DIORead(ENC_B)) { stateRegister.move = SI_MOVE_RIGHT; } else { stateRegister.move = SI_MOVE_LEFT; } } CISR &= ~(1 << ENC_A); // clear interrupt flag }
/*************************************************************************** * \brief ISR for button USW3 * \return void ***************************************************************************/ __declspec (interrupt) void Usw3ISR (void) { if (DIORead(USW3)) { stateRegister.restart ^= TRUE; } CISR &= ~(1 << USW3); // clear interrupt flag }
/*************************************************************************** * \brief ISR for button USW0 * \return void ***************************************************************************/ __declspec (interrupt) void Usw0ISR (void) { if (DIORead(USW0) == 1) { stateRegister.shoot ^= 0x02; } CISR &= ~(1 << USW0); // clear interrupt flag }
int main (void) { Wall wall; Heli heli; Landscape landscape; hardwareInit(); initLandscape(&landscape, 70); heli_init(&heli); wall_init(&wall, 10, getYRoof(&landscape, 159), getYBottom(&landscape, 159) ); while(1) { //DelayMs(100); heli_clear(&heli); if(DIORead(USW0)) { DPRINT("up\n"); heli_update(&heli, 0.1, 100); // - means up } else { DPRINT("down\n"); heli_update(&heli, -0.1, 100); // + means down } landscapeFlow(&landscape, 70); wall_clear(&wall); wall_update(&wall, 100); if(heli_check_collision(&heli, wall.x, wall.y1, wall.x, wall.y2)) { heli_init(&heli); wall_init(&wall, 10, getYRoof(&landscape, 159), getYBottom(&landscape, 159) ); } if(touch(&landscape, heli.x, heli.y+heliRadius)) { heli_init(&heli); wall_init(&wall, 10, getYRoof(&landscape, 159), getYBottom(&landscape, 159) ); } if(touch(&landscape, heli.x, heli.y-heliRadius)) { heli_init(&heli); wall_init(&wall, 10, getYRoof(&landscape, 159), getYBottom(&landscape, 159) ); } wall_draw(&wall); heli_draw(&heli); } }