Ejemplo n.º 1
0
/***********************************************************************
Main
***********************************************************************/
void main(void) {
  DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;

//////////////////////////////////////////////////////////////
//;  START OF CODE FOR Spring 2012 MINI-PROJECT
//////////////////////////////////////////////////////////////
  //asm ldx //...

  while(1){
  	
  	
  	
  }
  
  
  

  for(;;) {
   // No need to write any code here
    
    _FEED_COP(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
Ejemplo n.º 2
0
/***********************************************************************
Main
***********************************************************************/
void main(void) {
  DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;
	
	//enables external xirq after vSync IRQ
	vSyncFlag = 0;
	while((vSyncFlag != 1) & (hCnt == 0)) {}	      
  asm andcc #$BF 

//////////////////////////////////////////////////////////////
//;  START OF CODE FOR Spring 2012 MINI-PROJECT
//////////////////////////////////////////////////////////////
  
	// Load/Display Spalsh Screen
	displaySplash();

  for(;;) {
   // write code here (Insert Code down here because we need an infinite loop.)

	// Display Menu Screen
	displayMenu(selection);
	// Check for Menu Selection
	checkMenuInputs(joy0vert);
	// Use case statement to branch to appropriate selection.
	// Don't branch unless the user has triggered the 'select' button.
	if (select == 1)
	{
			select = 0;
			switch (selection)
			{
			// Sub Function
			// Menu:
			case 1:
					//	Select Character
					selectCharacter();
					break;
			case 2:
					//	Select Field
					selectField();
					break;
			case 3:
					//	Start Match
					startMatch();
					break;
			// the default case is '-1' if nothing has been selected
			default:
					break;
			}
	}
    
	 // We don't need the watchdog timer, but I don't think it can hurt to feed it anyway.
	 // The watchdog was disabled in the initialization code.
    _FEED_COP(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
Ejemplo n.º 3
0
void main(void) {
  DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;
  
  turnOffLEDs();
  // reset game on startup
  resetGame();
  
  TC7 = 15000;            //set up TIM TC7 to generate 0.1 ms interrupt rate
  for(;;) {
    displayBoard();
    
    
    if (interuptFlag) {
       tickCounter++;
       ticksSinceLastEvolution++;  	
  
       if (ticksSinceLastEvolution >= TICKS_BETWEEN_EVOLUTIONS) {
         ticksSinceLastEvolution = 0;
         evolveFlag = 1;
       }  
    }
    
    if (evolveFlag) {
      evolveFlag = 0;
      evolve();
    }
    
    if (boardsAreSame == 1) {
      resetGame();
    }
  
    // check to see if the user would like to reset the game (presses right push button)
    if (rghtpb == 1) {
      rghtpb = 0;
      resetGame();
    }
    
  
    _FEED_COP(); /* feeds the watchdog timer */
  } /* loop forever */
  /* make sure that you never leave main */
}
/*     
***********************************************************************
Main
***********************************************************************
*/
void main(void) {
  DisableInterrupts;
  initializations();     
  EnableInterrupts;

  
/* < start of your main loop > */ 
  while(!rghtpb) {}
  rghtpb = 0;
  PTT_PTT4 = 0;
  PTT_PTT5 = 0;  
  PTT_PTT6 = 0;
  PTT_PTT7 = 0;

  recursion(NORTH,NORTH,0,0);
    
    /* loop forever */
  for(;;) {}   
}   /* do not leave main */
Ejemplo n.º 5
0
/*
***********************************************************************
 Main - Setup
***********************************************************************
*/
void main(void) {
  /* put your own code here */
  DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;
  
  //printf("%ld\n",time(0));  //prints time elapsed since 1970 
  
  Initial_board(mine);
  Initial_mask(mask);

/*
***********************************************************************
 Main - Loop
***********************************************************************
*/

  for(;;) {
    PTT_PTT3 = display1_en; //display1_en = 1 means PTT_PTT3 = 0 (en)
    PTT_PTT5 = !display2_en; //display2_en = 1 means PTT_PTT5 = 0 (en)

    //butts();
    
    
    if(diffrun == 0 && gamerun == 0){         //splash screen
      if(setflag == 1){
        send_i(LCDCLR);
        splashDisp();
        setflag = 0;
      }
      if(buttBpb){                            //buttBpb (FLAG), as opposed to buttBatd
        diffrun = 1;
        setflag = 1;
      }    
    }
    
    if(diffrun == 1 && gamerun == 0){         //difficulty screen
      if(setflag == 1){
        send_i(LCDCLR);
        diffDisp();
        setflag = 0;
      }
      difficulty();
      if(buttBpb){
        gamerun = 1;
        diffrun = 0;
        setflag = 1;
      }
    }

    if(diffrun == 0 && gamerun == 1){
      if(setflag == 1){
        send_i(LCDCLR);
        Create_board(nbomb,mine);
        joymove = 99;
        setflag = 0;
      }
      //printf("Mask: \n");
      if(joymove != 0){ 
        for(i = 0; i < NROW; i++){
          for(j = 0; j < NCOL; j++){
            //printf("%2d ",mask[i][j]);
            pos(i,j);
            if(mask[i][j] == 9){
              pmsglcd("?");
            }else if(mask[i][j] == 0){
              pmsglcd(" ");
            }else if(mask[i][j] >= 1 && mask[i][j] <= 8){
              dumb = 30 + mask[i][j];
              print_c(dumb);
            }else if(mask[i][j] == 10){
              pmsglcd("F");
            }
          }
        //printf("\n");
        }
      }
      joymove = joy();
      if(joymove == 2){
        if(irow != 0){
          irow--;
        }
      }
      if(joymove == 4){
        if(icol != 0){
          icol--;
        }
      }
      if(joymove == 6){
        if(icol != (NCOL - 1)){
          icol++;
        }
      }
      if(joymove == 8){
        if(icol != (NROW - 1)){
          irow++;
        }
      }
      
      nclick = GameControl(irow,icol,nclick,mine,mask);    
    }
    
    
    
    
    
    
    if(nclick == -1){
      fail = 1;
      
      for(a = 0; a < NROW; a++){
        for(b = 0; b < NCOL; b++){
          mask[a][b] = mine[a][b];
        }
      }  
    }
    
    
    
    //printf("Number Click: %d\n",nclick);
    
    nflag = FlagControl(frow,fcol,nflag,mask);
    
    if((nflag + nclick) == nbomb){
      win = 1;
    }
    
    //printf("Number Flag: %d\n",nflag);
    //printf("Flag: \n");
    
    for(i = 0; i < NROW; i++){
      for(j = 0; j < NCOL; j++){
        //printf("%2d ",mask[i][j]);
      }
    //printf("\n");
    }

//printf("Mine: \n");
    
    for(i = 0; i < NROW; i++){
      for(j = 0; j < NCOL; j++){
        //printf("%2d ",mine[i][j]);
      }
      //printf("\n");
    }
  
  
/*
//If the left pushbutton
    if(leftpb && !gamerun){
      leftpb = 0;
      gamerun = 1;
      
      send_i(LCDCLR);     //display message
      pmsglcd("Ready, Set...");  
    }      

//If the right pushbutton
    if(rghtpb && gamerun){
      rghtpb = 0;
      gamerun = 0;   
    }
*/    
  
  } /* loop forever */
  /* please make sure that you never leave main */
}
Ejemplo n.º 6
0
void main(void) {
	initializations(); 		  			 		  		
	EnableInterrupts;


  for(;;) {


// Main program loop (state machine)
// Start of main program-driven polling loop

	 	   			 		  			 		  		
//  If the "tenth second" flag is set, then
    if (tenthsec == 1) {
//    - clear the "tenth second" flag
      tenthsec = 0;
//    - if "run/stop" flag is set, then
      if (runstp == 1) {
//       - initiate ATD coversion sequence
         ATDCTL5 = 0x10;
         while((ATDSTAT0 & 0x80) != 0x80) {
         }
//       - apply thresholds to converted values
         out0 = 0;
         out1 = 0;
         if (ATDDR0H > 0x00 && ATDDR0H < THRESH1) {
          out0 = 1;
         }
         if (ATDDR0H > THRESH1 && ATDDR0H < THRESH2) {
          out0 = 2;
         }
         if (ATDDR0H > THRESH2 && ATDDR0H < THRESH3) {
          out0 = 3;
         }
         if (ATDDR0H > THRESH3 && ATDDR0H < THRESH4) {          
          out0 = 4;
         }
         if (ATDDR0H > THRESH4 && ATDDR0H < THRESH5) {
          out0 = 5;
         } else if (ATDDR0H > THRESH5) {
          out0 = 5;
         }
         
         if (ATDDR1H > 0x00 && ATDDR1H < THRESH1) {
          out1 = 1;
         }
         if (ATDDR1H > THRESH1 && ATDDR1H < THRESH2) {
          out1 = 2;
         }
         if (ATDDR1H > THRESH2 && ATDDR1H < THRESH3) {
          out1 = 3;
         }
         if (ATDDR1H > THRESH3 && ATDDR1H < THRESH4) {
          out1 = 4;
         }
         if (ATDDR1H > THRESH4 && ATDDR1H < THRESH5) {
          out1 = 5;
         } else if (ATDDR1H > THRESH5) {
          out1 = 5;
         }        
//       - determine 5-bit bar graph bit settings for each input channel
         for (i = 0; i <= 9; i++) {
          PTT_PTT4 = 0;
          if (i < 5) {
           if(out0 > 0) {
            
            PTT_PTT3 = 1;
            out0--;
           } else {
            PTT_PTT3 = 0;
           }
          }
//       - transmit 10-bit data to external shift register
          else {
           if (out1 > 0) {
            
            PTT_PTT3 = 1;
            out1--;
           } else {
            PTT_PTT3 = 0;
           }
          }
          PTT_PTT4 = 1;
         }
//    - endif
      }
//  Endif
    }
	 	   			 		  			 		  		
//  If the left pushbutton ("stop BGD") flag is set, then:
    if (leftpb == 1) {
//    - clear the left pushbutton flag
      leftpb = 0;
//    - clear the "run/stop" flag (and "freeze" BGD)
      runstp = 0;
//    - turn on left LED/turn off right LED (on docking module)
      PTT_PTT0 = 0;
      PTT_PTT1 = 1;
//  Endif
    }
   			 		  			 		  		

//  If the right pushbutton ("start BGD") flag is set, then
    if (rghtpb == 1) {
//    - clear the right pushbutton flag
      rghtpb = 0;
//    - set the "run/stop" flag (enable BGD updates)
      runstp = 1;
//    - turn off left LED/turn on right LED (on docking module)
      PTT_PTT0 = 1;
      PTT_PTT1 = 0;
//  Endif
    }
	 	
  } /* loop forever */
  
}  /* make sure that you never leave main */
Ejemplo n.º 7
0
void main(void) {
  	DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;



  for(;;) {

    /* write your code here */

//  If the left pushbutton ("start reaction test") flag is set, then:
//    - clear left pushbutton flag
//    - set the "run/stop" flag
//    - display message "Ready, Set..." on the first line of the LCD
//    - turn off the left LED (PT1)
//    - turn on the right LED (PT0)
//  Endif
  if (leftpb ==1 && !runstp){
      goteam = 0;
      react  = 0;
      runstp = 1;
      leftpb = 0;
      RLed   = 1; //Right LED
      LLed   = 0; //Left LED        
      YELLOW = 0;
      GREEN  = 0;
      RED    = 0;
      send_i(LCDCLR);
      lcdwait();
      pmsglcd("Ready, Set...", 13, LINE2);
    }

//  If the "run/stop" flag is set, then:
//    - If the "goteam" flag is NOT set, then:
//       + If "random" = $0000, then:
//         - set the "goteam" flag
//         - clear TCNT register (of TIM)
//         - clear "react" variable (2 bytes)
//         - enable TIM Ch7 interrupts
//         - turn on YELLOW LED
//         - display message "Go Team!" on the second line of the LCD
//      + Endif
//    - Endif
//  Endif
   if(runstp && !goteam && random==0x00){
     goteam = 1;
     react  = 0;
     YELLOW = 1; //Yellow LED
     send_i(LCDCLR);
     lcdwait();
     pmsglcd("Go team!", 8, LINE2);
     TIE    = 0x80;
   }

//  If the right pushbutton ("stop reaction test") flag is set, then:
//    - clear right pushbutton flag
//    - clear the "run/stop" flag
//    - clear the "goteam" flag
//    - turn off yellow LED
//    - disable TIM Ch 7 interrupts
//    - call "tdisp" to display reaction time message
//    - turn off right LED (PT0)
//    - turn on left LED (PT1)
//  Endif
   if (rghtpb == 1) {
     rghtpb = 0;
     if(runstp && goteam){
       runstp  = 0;
       goteam  = 0;
       YELLOW  = 0;
       TIE     = 0x0;
       send_i(LCDCLR);
       lcdwait();
       tdisp();
      
       if(react <= 250){
         GREEN = 1;
         pmsglcd("F**K YEAH!", 10, LINE2);
       }else{
         GREEN =0;
         pmsglcd("Really?", 7, LINE2);
       }
       RLed    = 0; //Right LED
       LLed    = 1; //Left LED      
     }
   }


//  If "react" = 999 (the maximum 3-digit BCD value), then:
//    - clear the "run/stop" flag
//    - turn off yellow LED, turn on red LED
//    - disable TIM Ch 7 interrupts
//    - display message "Time = 999 ms" on the first line of the LCD
//    - display message "Too slow!" on the second line of the LCD 
//    - turn off right LED (PT0)
//    - turn on left LED (PT1)
//  Endif
    if(react >= 999 && runstp){
      runstp = 0;
      react  =0;
      YELLOW = 0; //Yellow LED
      RED    = 1; //Red LED
      TIE    = 0x0;
      send_i(LCDCLR);
      lcdwait();
      pmsglcd("RT = 999ms", 10, LINE1);
      pmsglcd("Too slow!", 9, LINE2);
      RLed   = 0; //Right LED
      LLed   = 1; //Left LED
    }


      _FEED_COP();
    }/* loop forever */
  
}  /* do not leave main */
Ejemplo n.º 8
0
/*
***********************************************************************
 Main - Setup
***********************************************************************
*/
void main(void) {
  /* put your own code here */
  DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;
  
  //printf("%ld\n",time(0));  //prints time elapsed since 1970 
  
  Initial_board(mine);
  Initial_mask(mask);
  send_i(LCDCLR);                   //for redundancy purposes
/*
***********************************************************************
 Main - Loop
***********************************************************************
*/

  for(;;) {                           
    if(diffrun == 0 && gamerun == 0){                 //splash screen
      if(flag1 == 1){
        splashDisp();
        flag1 = 0;
        
      }
      if(buttBpb && prevpb == 0){                            //buttBpb (FLAG), as opposed to buttBatd
        diffrun = 1;
        flag2 = 1;
        buttBpb = 0;                          //resets button B
        
      }    
    }else if(diffrun == 1 && gamerun == 0){           //difficulty screen
      if(flag2 == 1){
        diffDisp();
        flag2 = 0;
      }      
      difficulty();
      if(buttBpb && prevpb == 0){
        gamerun = 1;
        diffrun = 0;
        flag3 = 1;
        buttBpb = 0;                          //resets button B
      }
    }else if(diffrun == 0 && gamerun == 1){
      if(flag3 == 1){
        send_i(LCDCLR);
        gameDisp();                                 //game screen
        flag3 = 0;
      }
      minejoy();                              //joystick/click func in game stage
      
      if(nclick == -1){
        fail = 1;
        
        for(a = 0; a < NROW; a++){
          for(b = 0; b < NCOL; b++){
            mask[a][b] = mine[a][b];
          }
        }  
      }
      
      
      
      //printf("Number Click: %d\n",nclick);
      
      nflag = FlagControl(frow,fcol,nflag,mask);
      
      if((nflag + nclick) == nbomb){
        win = 1;                                  //turn into increment towards win condition or something later
      }
      
      //printf("Number Flag: %d\n",nflag);
      //printf("Flag: \n");
      
      for(i = 0; i < NROW; i++){
        for(j = 0; j < NCOL; j++){
          //printf("%2d ",mask[i][j]);
        }
      //printf("\n");
      }

  //printf("Mine: \n");
      
      for(i = 0; i < NROW; i++){
        for(j = 0; j < NCOL; j++){
          //printf("%2d ",mine[i][j]);
        }
        //printf("\n");
      }
    }
  } /* loop forever */
}
/*
***********************************************************************
 Main
***********************************************************************
*/
void main(void) {
  DisableInterrupts;
 initializations();               
 EnableInterrupts;
 
 //shiftout(0x01);
 

    
      while(flag == 0 && counter_pass < 3)
      {       
  
    chgline(0x80);
    pmsglcd("Enter Password");
      
    if(rghtpb == 0) 
    {
      chgline(0xc0 + counter_pass);

      tempo = atd_convert() ;
  
      print_c(tempo);

     
    }
    
    if(rghtpb == 1) 
    {
     rghtpb = 0;
     temp[counter_pass] = atd_convert() - 48;
     counter_pass++;
     
    }
    if(counter_pass == 3) {
      
    for(i = 0; i < 3; i++) 
    {
        if(our_pass[i] == temp[i]) 
        {
          if(flag2 != 1) 
          {
            flag = 1; 
          } 
        }
        else 
        {
          flag2 = 1;
          flag = 0;
          counter_pass = 0;
          temp[0] = 0;
          temp[1] = 0;
          temp[2] = 0;
          chgline(0xc0);
          send_i(LCDCLR);
        }
    }
    
    
    }
  }
send_i(LCDCLR);   
pmsglcd("Success");
TIE_C7I = 1;
    
    //print_c(tempo);

  for(;;) {

/* write your code here */

    

  }  
  
    
  

    

 /* loop forever */
  
}/* do not leave main */