Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TIM3_IRQHandler() {
- char key = key_scan();
- char input;
- if (phase == 0) {
- char result = getchar_irq();
- if (my_turn == 'Y') {
- if (key != '\0') {
- putchar_irq('Y');
- pc12out();
- my_turn = 'N';
- }
- }
- if (result == 'Y') {
- my_turn = 'Y';
- }
- }
- //printf("Hello");
- if (phase == 1) {
- phase1(key);
- }
- else if (phase == 2) {
- if (key != '\0') {
- phase2(key);
- }
- }
- else if (phase == 3) {
- if (opponent_ready == 'Y') {
- if (my_turn == 'Y') {
- if (key != '\0')
- phase3_attack(key);
- }
- else if (my_turn == 'N') {
- // printf("hello" );
- /* while(counter < 4) {
- printf("hello2" );
- if((USART1->ISR & USART_ISR_RXNE) == USART_ISR_RXNE) {
- insert_echo_char(USART1->RDR & 0xff);
- counter++;
- }
- } */
- // if (counter == 4) {
- //printf("Hello1");
- //insert_echo_char(USART1->RDR & 0xff);
- input = getchar_irq();
- // putchar_irq(input);
- if ((input) >= 48 && (input) <= 57) {
- //putchar_irq(input);
- if (count < 2) {
- X[count] = input;
- }
- else {
- Y[count-2] = input;
- }
- count++;
- X[2] = '\0';
- Y[2] = '\0';
- //printf("%c",X[0]);
- // printf("%c",X[1]);
- counter = 0;
- if (count >= 4) {
- int X_coordinates = atoi(X);
- int Y_coordinates = atoi(Y);
- printf("%d",X_coordinates);
- printf("%d",Y_coordinates);
- if (ships[X_coordinates][Y_coordinates] == 1) {
- putchar_irq('H');
- ships[X_coordinates][Y_coordinates] = 0;
- opp_hit++;
- }
- else {
- putchar_irq('M');
- }
- count = count % 4;
- if (opp_hit == 17) {
- phase = 4;
- }
- my_turn = 'Y';
- }
- // if RECEIVED coordinates
- // TRANSMIT HIT OR MISS (Did opponent hit or miss)
- // if HIT
- // opp_hit++;
- // UPDATE "your" screen
- }
- }
- //}
- }
- }
- else {
- if (win == 'Y') {
- // DISPLAY WIN
- }
- else {
- // DISPLAY LOSE
- }
- }
- ack_tim3();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement