Exemplo n.º 1
0
/*
********************************************************
splashDisp - displays splash screen waiting for button press
********************************************************
*/
void splashDisp(void) 
{
  pos(2,2);
  pmsglcd("MEYER");
  pos(11,5);
  pmsglcd("SWEEPER");
  
  pos(3,6);
  pmsglcd("Press joystick to start");
}
Exemplo n.º 2
0
/*
********************************************************
splashDisp - displays splash screen waiting for button press
********************************************************
*/
void splashDisp(void) 
{
  lclr();
  pos(3,2);
  pmsglcd("MEYER  SWEEPER");
  //pmsglcd("SWEEPER");
  
  pos(3,5);
  pmsglcd("Press   joystick");
  pos(5,6);
  pmsglcd("to start");
}
Exemplo n.º 3
0
/*
********************************************************
diffDisp - displays splash screen for difficulty selection
********************************************************
*/
void diffDisp(void)
{
  pos(8,2);
  pmsglcd("Easy");

  pos(8,4);
  pmsglcd("Hard");
  pos(9,5);
  pmsglcd("GG");
  
  pos(7,3);           //final cursor position to work with difficulty()
  pmsglcd("Normal");
}
Exemplo n.º 4
0
/*
********************************************************
diffDisp - displays splash screen for difficulty selection
********************************************************
*/
void diffDisp(void)
{
  lclr();
  mensel(8,2,4);
  pmsglcd("Easy");
  
  mensel(8,4,4);
  pmsglcd("Hard");
  
  mensel(9,5,2);
  pmsglcd("GG");
  
  mensel(7,3,6);           //final cursor position to work with difficulty()
  pmsglcd("Normal");
}
Exemplo n.º 5
0
void tdisp()
{
  int digit = 0;
  char d = 0;
  pmsglcd("RT = ", 5, LINE1);
  digit = react / 100;
  print_c(digit + 48, LINE1+0x04);
  digit = (react / 10) % 10;
  print_c(digit + 48, LINE1+0x05);
  digit = react % 10;
  print_c(digit + 48, LINE1+0x06);
  pmsglcd("ms", 2, LINE1+0x07);
  if(react <= 250) {
    GREEN = 1;
  }
}
Exemplo n.º 6
0
/*
********************************************************
minejoy - controls joy interactions during game stage
********************************************************
*/
void minejoy(void){
  
  if(joymove != 0){ 
    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(irow != (NROW - 1)){
        irow++;
      }
    }
    
    pos(icol,irow);                             //x,y
    //mask[y][x]
    if(mask[irow][icol] == 9){                                                  //fog o war
      pmsglcd("#");
    }else if(gameMode == 0 && mask[irow][icol] == 0){                           //blank
      pmsglcd(" ");
    }else if(gameMode == 0 && mask[irow][icol] >= 1 && mask[irow][icol] <= 8){  //num
      dumb = 30 + mask[irow][icol];
      print_c(dumb);
    }else if(gameMode == 1 && mask[irow][icol] == 10){                          //F
      pmsglcd("F");
    }else if(gameMode == 2 && mask[irow][icol] == 11){                          //?
      pmsglcd("?");
    }
  }
  nclick = GameControl(irow,icol,nclick,mine,mask);
}
Exemplo n.º 7
0
/*
********************************************************
gameDisp - displays game screen for PLAY :D
********************************************************
*/
void gameDisp(void)
{
  lclr();
  Create_board(nbomb,mine);
  for(i = 0; i < NROW; i++){          //y var
    for(j = 0; j < NCOL; j++){        //x var
      pos(j,i);
      if(mask[i][j] == 9){
        pmsglcd("#");
      }
    }
  }
  pos(0,0);                           //init cursor in top corner  
}
Exemplo 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);

/*
***********************************************************************
 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 */
}
Exemplo n.º 9
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 */
/*
***********************************************************************
 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 */