Пример #1
0
void lcdTest(void)
{
    for(int y=0; y<240; y++) {
        lcdPixel(0, y, COLOR_WHITE);
        lcdPixel(319, y, COLOR_WHITE);
    }
    for(int x=0; x<320; x++) {
        lcdPixel(x, 0, COLOR_WHITE);
        lcdPixel(x, 239, COLOR_WHITE);
    }

    lcdStr(2, 2, "Hello world!", COLOR_GREEN, COLOR_BLUE);
    return;
    writeReg(0x004f, 0); // Set GDDRAM X address counter 
    writeReg(0x004e, 0); // Set GDDRAM Y address counter 
    setRS(0);
    writeLcd(0x22); // RAM data write register
    setRS(1);
    for(int y=0; y<240; y++) {
        for(int x=0; x<320; x++) {
            writeLcd(lcdColor(y, x, 0));
            /*
            if((y & 0x10) ^ (x & 0x10)) {
                writeLcd(lcdColor(0xff, 0, 0));
            } else {
                writeLcd(lcdColor(0, 0xff, 0));
            }
            */
        }
    }
}
Пример #2
0
/*****************************************************************************
 *
 * Description:
 *    Draw cursor in main menu
 *
 * Params:
 *    [in] cursor - Cursor positions
 *
 ****************************************************************************/
static void
drawMenuCursor(void)
{
  tU32 row;

  for(row=0; row<menu.noOfChoices; row++)
  {
    lcdGotoxy(menu.xPos+4,menu.yPos+17+(14*row));
    if(row == cursor)
      lcdColor(menu.bgColor+1,menu.selectedColor);
    else
      lcdColor(menu.bgColor,menu.choicesColor);
    
    lcdPuts(menu.pChoice[row]);
  }
}
Пример #3
0
/*****************************************************************************
 *
 * Description:
 *    Implements a menu
 *    
 ****************************************************************************/
tU8
drawMenu(tMenu newMenu)
{
  tU8 anyKey;
  
  menu = newMenu;
  
  //draw boarder
  lcdRect(menu.xPos, menu.yPos, menu.xLen, menu.yLen, menu.borderColor);
  lcdRect(menu.xPos+1, menu.yPos+16, menu.xLen-2, menu.yLen-17, menu.bgColor);
  
  //write header text
  lcdGotoxy(menu.headerTextXpos,menu.yPos+1);
  lcdColor(menu.borderColor,menu.headerColor);
  lcdPuts(menu.pHeaderText);
  
  //write choices
  cursor = menu.initialChoice;
  drawMenuCursor();
  
  //dummy call just to reset previous key strokes
  checkKey();

  while(1)
  {
    anyKey = checkKey();
    
    if (anyKey != KEY_NOTHING)
    {
      //select specific function
      if (anyKey == KEY_CENTER)
      {
        return cursor;
      }
      
      else if (anyKey == KEY_UP)
      {
        if (cursor > 0)
          cursor--;
        else
          cursor = menu.noOfChoices - 1;
        drawMenuCursor();
      }
      
      else if (anyKey == KEY_DOWN)
      {
        if (cursor < menu.noOfChoices - 1)
          cursor++;
        else
          cursor = 0;
        drawMenuCursor();
      }
    }
    else
      osSleep(1);
  }
}
Пример #4
0
/*****************************************************************************
 *
 * Description:
 *    Draw game background and game board, initialize all variables
 *
 ****************************************************************************/
static void
setupGame (tBool drawBoard)
{
  tS32 i,j;

  //initialize random generator and reset score
  srand(ms);
  score = 0;

#ifdef INCLUDE_EXAMPLE_GAME_BACKGROUND
  //draw background picture
  lcdIcon(0, 0, 130, 130, _brickWall_130x130c[2], _brickWall_130x130c[3], &_brickWall_130x130c[4]);
#endif

  //draw game board
  if (drawBoard == TRUE)
  {
    lcdColor(1, 0xe0);
    lcdGotoxy(16, 116);
    lcdPuts(" Score:   0 ");

    lcdRect(34, 14, 64, 100, 3);
    lcdRect(36, 16, 60, 96, 0);
  }

  //initialise game board
  for (i=0; i<BOARD_WIDTH; i++)
    for (j=0; j<BOARD_HEIGHT; j++)
      board[i][j] = 0;

  currFigure = rand() % NUM_OF_FIGURE;
  currXpos  = 3;
  currYpos  = 0;
  insertFigure(currFigure, currXpos, currYpos);

  lastUpdate = ms;
}
Пример #5
0
/*****************************************************************************
 *
 * Description:
 *    A process entry function 
 *
 ****************************************************************************/
void
displayStartupSequence(void)
{
  tU32 step = 0;
  tU8 anyKey = KEY_NOTHING;

  for(step=0; step<=48; step++)
  {
    anyKey = checkKey();
    if (anyKey != KEY_NOTHING)
      break;

    switch(step)
    {
      case 0: lcdColor(0xfd,0x00); lcdClrscr(); break;
      case 1: lcdIcon(0, 0, 130, 90, _fun_0_130x90c[2], _fun_0_130x90c[3], &_fun_0_130x90c[4]); break;

      case 2: lcdGotoxy(8,100); lcdPutchar('H'); break;
      case 3: lcdPutchar('A'); break;
      case 4: lcdPutchar('V'); break;
      case 5: lcdPutchar('E'); lcdIcon(0, 0, 130, 90, _fun_1_130x90c[2], _fun_1_130x90c[3], &_fun_1_130x90c[4]); break;

      case 6: lcdGotoxy(8+(8*4),100); lcdPutchar(' '); break;
      case 7: lcdPutchar('S'); break;
      case 8: lcdPutchar('O'); break;
      case 9: lcdPutchar('M'); lcdIcon(0, 0, 130, 90, _fun_0_130x90c[2], _fun_0_130x90c[3], &_fun_0_130x90c[4]); break;

      case 10: lcdGotoxy(8+(8*8),100); lcdPutchar('E'); break;
      case 11: lcdPutchar(' '); break;
      case 12: lcdPutchar('F'); break;
      case 13: lcdPutchar('U'); lcdIcon(0, 0, 130, 90, _fun_1_130x90c[2], _fun_1_130x90c[3], &_fun_1_130x90c[4]); break;
      
      case 14: lcdGotoxy(8+(8*12),100); lcdPutchar('N'); break;
      case 15: lcdPutchar('!'); break;
      case 17:
      case 25:
      case 33:
      case 41: lcdIcon(0, 0, 130, 90, _fun_0_130x90c[2], _fun_0_130x90c[3], &_fun_0_130x90c[4]); break;

      case 21:
      case 29:
      case 37:
      case 45: lcdIcon(0, 0, 130, 90, _fun_1_130x90c[2], _fun_1_130x90c[3], &_fun_1_130x90c[4]); break;

      default: break;
    }
    osSleep(15);
  }
  
  if (anyKey == KEY_NOTHING)
  for(step=0; step<=257; step++)
  {
    anyKey = checkKey();
    if (anyKey != KEY_NOTHING)
      break;

    switch(step)
    {
      case 0: lcdColor(0xff,0x00); lcdClrscr(); break;
      case 1: lcdIcon(16, 0, 97, 60, _ea_97x60c[2], _ea_97x60c[3], &_ea_97x60c[4]); break;
      case 2: lcdGotoxy(16,66); lcdPutchar('D'); break;
      case 3: lcdPutchar('e'); break;
      case 4: lcdPutchar('s'); break;
      case 5: lcdPutchar('i'); break;
      case 6: lcdPutchar('g'); break;
      case 7: lcdPutchar('n'); break;
      case 8: lcdPutchar('e'); break;
      case 9: lcdPutchar('d'); break;
      case 10: lcdPutchar(' '); break;
      case 11: lcdPutchar('a'); break;
      case 12: lcdPutchar('n'); break;
      case 13: lcdPutchar('d'); break;
      case 14: lcdGotoxy(20,80); lcdPutchar('p'); break;
      case 15: lcdPutchar('r'); break;
      case 16: lcdPutchar('o'); break;
      case 17: lcdPutchar('d'); break;
      case 18: lcdPutchar('u'); break;
      case 19: lcdPutchar('c'); break;
      case 20: lcdPutchar('e'); break;
      case 21: lcdPutchar('d'); break;
      case 22: lcdPutchar(' '); break;
      case 23: lcdPutchar('b'); break;
      case 24: lcdPutchar('y'); break;
      case 25: lcdGotoxy(0,96); lcdPutchar('E'); break;
      case 26: lcdPutchar('m'); break;
      case 27: lcdPutchar('b'); break;
      case 28: lcdPutchar('e'); break;
      case 29: lcdPutchar('d'); break;
      case 30: lcdPutchar('d'); break;
      case 31: lcdPutchar('e'); break;
      case 32: lcdPutchar('d'); break;
      case 33: lcdPutchar(' '); break;
      case 34: lcdPutchar('A'); break;
      case 35: lcdPutchar('r'); break;
      case 36: lcdPutchar('t'); break;
      case 37: lcdPutchar('i'); break;
      case 38: lcdPutchar('s'); break;
      case 39: lcdPutchar('t'); break;
      case 40: lcdPutchar('s'); break;
      case 41: lcdGotoxy(32,112); lcdPutchar('('); break;
      case 42: lcdPutchar('C'); break;
      case 43: lcdPutchar(')'); break;
      case 44: lcdPutchar(' '); break;
      case 45: lcdPutchar('2'); break;
      case 46: lcdPutchar('0'); break;
      case 47: lcdPutchar('0'); break;
      case 48: lcdPutchar('6'); break;

      case 60: lcdClrscr(); lcdIcon(0, 0, 128, 39, _future_128x39c[2], _future_128x39c[3], &_future_128x39c[4]); break;
      case 61: lcdGotoxy(8,44); lcdPutchar('i'); break;
      case 62: lcdPutchar('n'); break;
      case 63: lcdPutchar(' '); break;
      case 64: lcdPutchar('c'); break;
      case 65: lcdPutchar('o'); break;
      case 66: lcdPutchar('o'); break;
      case 67: lcdPutchar('p'); break;
      case 68: lcdPutchar('e'); break;
      case 69: lcdPutchar('r'); break;
      case 70: lcdPutchar('a'); break;
      case 71: lcdPutchar('t'); break;
      case 72: lcdPutchar('i'); break;
      case 73: lcdPutchar('o'); break;
      case 74: lcdPutchar('n'); break;
      case 75: lcdGotoxy(20,60); lcdPutchar('w'); break;
      case 76: lcdPutchar('i'); break;
      case 77: lcdPutchar('t'); break;
      case 78: lcdPutchar('h'); break;
      case 79: lcdPutchar(' '); break;
      case 80: lcdPutchar('F'); break;
      case 81: lcdPutchar('u'); break;
      case 82: lcdPutchar('t'); break;
      case 83: lcdPutchar('u'); break;
      case 84: lcdPutchar('r'); break;
      case 85: lcdPutchar('e'); break;
      case 86: lcdGotoxy(4,76); lcdPutchar('E'); break;
      case 87: lcdPutchar('l'); break;
      case 88: lcdPutchar('e'); break;
      case 89: lcdPutchar('c'); break;
      case 90: lcdPutchar('t'); break;
      case 91: lcdPutchar('r'); break;
      case 92: lcdPutchar('o'); break;
      case 93: lcdPutchar('n'); break;
      case 94: lcdPutchar('i'); break;
      case 95: lcdPutchar('c'); break;
      case 96: lcdPutchar('s'); break;
      case 97: lcdPutchar(' '); break;
      case 98: lcdPutchar('a'); break;
      case 99: lcdPutchar('n'); break;
      case 100: lcdPutchar('d'); break;
      case 105: lcdIcon(3, 98, 122, 25, _philips_122x25c[2], _philips_122x25c[3], &_philips_122x25c[4]); break;
      
      case 120: lcdClrscr(); lcdIcon(22, 3, 85, 40, _segger_85x40c[2], _segger_85x40c[3], &_segger_85x40c[4]); break;
      case 121: lcdGotoxy(12,48); lcdPutchar('E'); break;
      case 122: lcdPutchar('m'); break;
      case 123: lcdPutchar('b'); break;
      case 124: lcdPutchar('e'); break;
      case 125: lcdPutchar('d'); break;
      case 126: lcdPutchar('d'); break;
      case 127: lcdPutchar('e'); break;
      case 128: lcdPutchar('d'); break;
      case 129: lcdPutchar(' '); break;
      case 130: lcdPutchar('J'); break;
      case 131: lcdPutchar('T'); break;
      case 132: lcdPutchar('A'); break;
      case 133: lcdPutchar('G'); break;
      case 134: lcdGotoxy(40,64); lcdPutchar('J'); break;
      case 135: lcdPutchar('-'); break;
      case 136: lcdPutchar('l'); break;
      case 137: lcdPutchar('i'); break;
      case 138: lcdPutchar('n'); break;
      case 139: lcdPutchar('k'); break;
      case 140: lcdGotoxy(20,80); lcdPutchar('t'); break;
      case 141: lcdPutchar('e'); break;
      case 142: lcdPutchar('c'); break;
      case 143: lcdPutchar('h'); break;
      case 144: lcdPutchar('n'); break;
      case 145: lcdPutchar('o'); break;
      case 146: lcdPutchar('l'); break;
      case 147: lcdPutchar('o'); break;
      case 148: lcdPutchar('g'); break;
      case 149: lcdPutchar('y'); break;
      case 150: lcdGotoxy(16,94); lcdPutchar('l'); break;
      case 151: lcdPutchar('i'); break;
      case 152: lcdPutchar('c'); break;
      case 153: lcdPutchar('e'); break;
      case 154: lcdPutchar('n'); break;
      case 155: lcdPutchar('s'); break;
      case 156: lcdPutchar('e'); break;
      case 157: lcdPutchar('d'); break;
      case 158: lcdPutchar(' '); break;
      case 159: lcdPutchar('b'); break;
      case 160: lcdPutchar('y'); break;
      case 161: lcdGotoxy(8,110); lcdPutchar('w'); break;
      case 162: lcdPutchar('w'); break;
      case 163: lcdPutchar('w'); break;
      case 164: lcdPutchar('.'); break;
      case 165: lcdPutchar('s'); break;
      case 166: lcdPutchar('e'); break;
      case 167: lcdPutchar('g'); break;
      case 168: lcdPutchar('g'); break;
      case 169: lcdPutchar('e'); break;
      case 170: lcdPutchar('r'); break;
      case 171: lcdPutchar('.'); break;
      case 172: lcdPutchar('c'); break;
      case 173: lcdPutchar('o'); break;
      case 174: lcdPutchar('m'); break;

      case 190: lcdColor(0xff,0x00); lcdClrscr(); break;
      case 191: lcdIcon(16, 0, 97, 60, _ea_97x60c[2], _ea_97x60c[3], &_ea_97x60c[4]); break;
      case 192: lcdGotoxy(0,66); lcdPutchar('P'); break;
      case 193: lcdPutchar('r'); break;
      case 194: lcdPutchar('o'); break;
      case 195: lcdPutchar('g'); break;
      case 196: lcdPutchar('r'); break;
      case 197: lcdPutchar('a'); break;
      case 198: lcdPutchar('m'); break;
      case 199: lcdPutchar(' '); break;
      case 200: lcdPutchar('v'); break;
      case 201: lcdPutchar('e'); break;
      case 202: lcdPutchar('r'); break;
      case 203: lcdPutchar(':'); break;
      case 204: lcdPutchar('1'); break;
      case 205: lcdPutchar('.'); break;
      case 206: lcdPutchar('8'); break;
      case 207: lcdGotoxy(20,80); lcdPutchar('C'); break;
      case 208: lcdPutchar('h'); break;
      case 209: lcdPutchar('e'); break;
      case 210: lcdPutchar('c'); break;
      case 211: lcdPutchar('k'); break;
      case 212: lcdPutchar(' '); break;
      case 213: lcdPutchar('f'); break;
      case 214: lcdPutchar('o'); break;
      case 215: lcdPutchar('r'); break;
      case 216: lcdGotoxy(8,96); lcdPutchar('u'); break;
      case 217: lcdPutchar('p'); break;
      case 218: lcdPutchar('d'); break;
      case 219: lcdPutchar('a'); break;
      case 220: lcdPutchar('t'); break;
      case 221: lcdPutchar('e'); break;
      case 222: lcdPutchar('s'); break;
      case 223: lcdPutchar(' '); break;
      case 224: lcdPutchar('a'); break;
      case 225: lcdPutchar('t'); break;
      case 226: lcdPutchar(' '); break;
      case 227: lcdPutchar('t'); break;
      case 228: lcdPutchar('h'); break;
      case 229: lcdPutchar('e'); break;
      case 230: lcdGotoxy(8,112); lcdPutchar('s'); break;
      case 231: lcdPutchar('u'); break;
      case 232: lcdPutchar('p'); break;
      case 233: lcdPutchar('p'); break;
      case 234: lcdPutchar('o'); break;
      case 235: lcdPutchar('r'); break;
      case 236: lcdPutchar('t'); break;
      case 237: lcdPutchar(' '); break;
      case 238: lcdPutchar('p'); break;
      case 239: lcdPutchar('a'); break;
      case 240: lcdPutchar('g'); break;
      case 241: lcdPutchar('e'); break;
      case 242: lcdPutchar('.'); break;

      default: break;
    }
    osSleep(10);
  }

  lcdColor(0x00,0x00);
  lcdClrscr();
}
Пример #6
0
/*****************************************************************************
 *
 * Description:
 *    Implements example game
 *    
 ****************************************************************************/
void
playExample(void)
{
  gameStatus = GAME_NOT_STARTED;

  setupGame(FALSE);
  lcdGotoxy(5,40);
  lcdColor(0,0xe0);
  lcdPuts("Press to start");

  while(gameStatus != GAME_END)
  {
    tU8 anyKey;

    anyKey = checkKey();
    switch(gameStatus)
    {
      case GAME_NOT_STARTED:
        if (anyKey != KEY_NOTHING)
        {
          gameStatus = GAME_RUNNING;
          setupGame(TRUE);
        }
        break;
        
      case GAME_RUNNING:
        if (anyKey != KEY_NOTHING)
        {
          if (anyKey == KEY_UP)
          {
            if(isValid(currXpos, currYpos, shift[currFigure]))
              currFigure = shift[currFigure];
          }
          else if (anyKey == KEY_DOWN)
          {
            if(isValid(currXpos, currYpos+1, currFigure))
              currYpos++;
          }
          else if (anyKey == KEY_RIGHT)
          {
            if(isValid(currXpos+1, currYpos, currFigure))
              currXpos++;
          }
          else if (anyKey == KEY_LEFT)
          {
            if(isValid(currXpos-1, currYpos, currFigure))
              currXpos--;
          }
          else if (anyKey == KEY_CENTER)
            gameStatus = GAME_OVER;

          advanceGame();
          osSleep(1);
        }
        else
        {
          advanceGame();
          osSleep(1);
        }
        break;
        
      case GAME_OVER:
      {
        tMenu menu;
        
        menu.xPos = 10;
        menu.yPos = 40;
        menu.xLen = 6+(12*8);
        menu.yLen = 4*14;
        menu.noOfChoices = 2;
        menu.initialChoice = 0;
        menu.pHeaderText = "Game over!";
        menu.headerTextXpos = 20;
        menu.pChoice[0] = "Restart game";
        menu.pChoice[1] = "End game";
        menu.bgColor       = 0;
        menu.borderColor   = 0x6d;
        menu.headerColor   = 0;
        menu.choicesColor  = 0xfd;
        menu.selectedColor = 0xe0;
        
        switch(drawMenu(menu))
        {
          case 0: gameStatus = GAME_RUNNING; setupGame(TRUE); break;  //Restart game
          case 1: gameStatus = GAME_END; break;                       //End game
          default: break;
        }
      }
        break;
        
      default:
        gameStatus = GAME_END;
        break;
    }
  }
}