/*remember to load: gyro_or2.c, startfuncs.c, gofuncs.c, go_dist_wheel_old3.c, clockorcounterclock.c*/

void main() {
	int facing_dir, myX, myY, oppX, oppY, ss;
	/*float losingdir; */ /*tells us to go 1.0 for counter clockwise, -1.0 for clockwise*/
	lsb_ms_per_deg=256.0;
	lsb_ms_per_deg *= scale_factor;
	start_press();
	calibrate_IR();
      calibrate_gyro();
	/*RF code*/
	
	rf_team=21;
	rf_enable();
	start_machine();

	get_bot_num();
						
  	start_process(update_angle()); 
  	/*Don't set theta, just read it!*/
/*  	start_process(display_angle()); */

	facing_dir = orient();  /*get my facing direction*/

      ss=my_start_side();			/*which side (white 1 or black:0, am I on?) */
	/*losingdir=losing_vote_dir(); */  /*tells us to go: 1.0 for counter clockwise, -1.0 for clockwise*/

	if (ss==1) {  /*starting on white side*/
		if (facing_dir==0 && rf_vote_winner==0) {  /*red is winning*/
			face_west_clockwise();
		}

		else if (facing_dir==1 && rf_vote_winner==0) { /*red is winning*/
			face_in_clockwise();
		}
		else if (facing_dir==2 && rf_vote_winner==0) { /*red is winning*/
			face_east_clockwise();
		}
		else if (facing_dir==3 && rf_vote_winner==0) { /*red is winning*/
			face_out_clockwise();
		}
		else if (facing_dir==0 && rf_vote_winner==1) {  /*green is winning*/
			face_west_counterclockwise();
		}

		else if (facing_dir==1 && rf_vote_winner==1) { /*green is winning*/
			face_in_counterclockwise();
		}
		else if (facing_dir==2 && rf_vote_winner==1) { /*green is winning*/
			face_east_counterclockwise();
		}
		else if (facing_dir==3 && rf_vote_winner==1) { /*green is winning*/
			face_out_counterclockwise();
		}


		

	}
	else if (ss==0) {  /*starting on black side*/
		if (facing_dir==0 && rf_vote_winner==0) {  /*red is winning*/
			face_west_counterclockwise();
		}

		else if (facing_dir==1 && rf_vote_winner==0) { /*red is winning*/
			face_in_counterclockwise();
		}
		else if (facing_dir==2 && rf_vote_winner==0) { /*red is winning*/
			face_east_counterclockwise();
		}
		else if (facing_dir==3 && rf_vote_winner==0) { /*red is winning*/
			face_out_counterclockwise();
		}
		else if (facing_dir==0 && rf_vote_winner==1) {  /*green is winning*/
			face_west_clockwise();
		}

		else if (facing_dir==1 && rf_vote_winner==1) { /*green is winning*/
			face_in_clockwise();
		}
		else if (facing_dir==2 && rf_vote_winner==1) { /*green is winning*/
			face_east_clockwise();
		}
		else if (facing_dir==3 && rf_vote_winner==1) { /*green is winning*/
			face_out_clockwise();
		}

      }

	
      
}

	

