int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Random_Init(1);

  Output_Init();
  ST7735_FillScreen(0x0000);            // set screen to black
  
  ST7735_DrawBitmap(52, 159, PlayerShip0, 18,8); // player ship middle bottom
  ST7735_DrawBitmap(53, 151, Bunker0, 18,5);

  ST7735_DrawBitmap(0, 9, SmallEnemy10pointA, 16,10);
  ST7735_DrawBitmap(20,9, SmallEnemy10pointB, 16,10);
  ST7735_DrawBitmap(40, 9, SmallEnemy20pointA, 16,10);
  ST7735_DrawBitmap(60, 9, SmallEnemy20pointB, 16,10);
  ST7735_DrawBitmap(80, 9, SmallEnemy30pointA, 16,10);
  ST7735_DrawBitmap(100, 9, SmallEnemy30pointB, 16,10);


  Delay100ms(50);              // delay 5 sec at 80 MHz


  ST7735_FillScreen(0x0000);            // set screen to black
  ST7735_SetCursor(1, 1);
  ST7735_OutString("GAME OVER");
  ST7735_SetCursor(1, 2);
  ST7735_OutString("Nice try,");
  ST7735_SetCursor(1, 3);
  ST7735_OutString("Earthling!");
  ST7735_SetCursor(2, 4);
  LCD_OutDec(1234);
  while(1){
  }

}
Exemplo n.º 2
0
int main(void){unsigned short score;
  PLL_Init();  // Set the clocking to run at 80MHz from the PLL.
  LCD_Init();  // Initialize LCD
  LCD_Goto(0,0);
	score =0;
	long v2;
  LCD_SetTextColor(255,0,0); // yellow= red+green, no blue
  printf("score: %d", score);
  LCD_DrawLine(10,16,310,16,BURNTORANGE);
  Timer2_Init(4000000); // 20 times a second
	Timer3_Init(7256);	// 11.025 KHz
	InitEnemy();
	InitBunker();
	InitPlayer();
	InitMissile();
	InitLaser();
	Random_Init(1);
  EnableInterrupts();
	Fireflag=1;
	
while(1){
	if(Semaphore){
		DrawBuffer1();		
		Semaphore = 0;
    }
  }
}
int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Random_Init(1);
  Nokia5110_Init();
  Nokia5110_ClearBuffer();
	Nokia5110_DisplayBuffer();      // draw buffer

  Nokia5110_PrintBMP(32, 47, PlayerShip0, 0); // player ship middle bottom
  Nokia5110_PrintBMP(33, 47 - PLAYERH, Bunker0, 0);

  Nokia5110_PrintBMP(0, ENEMY10H - 1, SmallEnemy10PointA, 0);
  Nokia5110_PrintBMP(16, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(32, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(48, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_PrintBMP(64, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_DisplayBuffer();     // draw buffer

  Delay100ms(50);              // delay 5 sec at 50 MHz


  Nokia5110_Clear();
  Nokia5110_SetCursor(1, 1);
  Nokia5110_OutString("GAME OVER");
  Nokia5110_SetCursor(1, 2);
  Nokia5110_OutString("Nice try,");
  Nokia5110_SetCursor(1, 3);
  Nokia5110_OutString("Earthling!");
  Nokia5110_SetCursor(2, 4);
  Nokia5110_OutUDec(1234);
  while(1){
  }

}
int main(void){
	DisableInterrupts();
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
	Random_Init(1);
  Nokia5110_Init();
	PF1Init();
  //SysTick_Init(2666666); //Initialize SysTick with 30 Hz interrupts
	SysTick_Init(2666666*4); //Increased period by 4 for actual hardware to make the game run at a playable speed
  Nokia5110_ClearBuffer();
	Nokia5110_DisplayBuffer();      // draw buffer
	ADC0_Init();
	Game_Init();
	SwitchLed_Init();
	Sound_Init();
	Timer2_Init(&Sound_Play,7256); //11.025 kHz. 80,000,000/11,025 cycles, which is about 7256
	GameOverFlag = 0;
	EnableInterrupts();
	
  while(1){
		while(Semaphore==0){};
    Semaphore = 0;
		if(GameOverFlag){
			State_GameOver();
		}
		else{
			Draw_GameFrame(); // update the LCD
		}	
		if((GameOverFlag == 0) && (Check_GameOver())){ //just detected game over
			Delay100ms(2);//Delay 200ms
			GameOverFlag = Check_GameOver();
			//SysTick_Init(2666666);//Re-initialize with 30 Hz interrupt
			SysTick_Init(2666666*4); //Increased period by 4 for actual hardware to make the game run at a playable speed
		}
	}
}
Exemplo n.º 5
0
// *************************** Capture image dimensions out of BMP**********
int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Random_Init(69);
  Output_Init();
	ADC0_Init();
	ST7735_InvertDisplay(0);
	ST7735_SetRotation(0);
	AI_Init(0x07);
	Player_Init();
	player.potato=1;
	
	Timer0_Init(Master_Funk,  30);

  ST7735_DrawBitmap(53, 151, Bunker0, 18,5);
//	Delay100ms(1);              // delay 5 sec at 80 MHz

 /* ST7735_FillScreen(0x0000);            // set screen to black
  ST7735_SetCursor(1, 1);
  ST7735_OutString("GAME OVER");
  ST7735_SetCursor(1, 2);
  ST7735_OutString("Nice try,");
  ST7735_SetCursor(1, 3);
  ST7735_OutString("Earthling!");
  ST7735_SetCursor(2, 4);
  LCD_OutDec(1234);	 */
  while(1){							
  } 
}
Exemplo n.º 6
0
Arquivo: EBN.c Projeto: chubylive/ENB
void EBN_Init(){
    Random_Init();
    Init_RS();
    Epoch_Change();
    Epoch_Change();
       messageNum = 0;
}
Exemplo n.º 7
0
int main(void){
	TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
	
	DisableInterrupts();
	
	
	Random_Init(1);
	
  Nokia5110_Init();
  Nokia5110_ClearBuffer();
	Nokia5110_DisplayBuffer();
	
	SysTick_Init();
	// initialize Timer2 after Nokia5110_Init because of
	// error-prone registers operations (old and new registers
	// are not working good together)
	// 80MHz/11,025 cycles, which is about 7256
	Timer2_Init(7256);
	Ports_Init();
	
	InitSprites(NumberOfEnemies);
	RestartGame();
	
	// Countdown, after which all interrupts are enabled!
	// print 3
	Nokia5110_ClearBuffer();
	Nokia5110_PrintBMP(28, 41, _my_Countdown_03, 0);
	Nokia5110_DisplayBuffer();
	Delay100ms(3);
	// print 2
	Nokia5110_ClearBuffer();
	Nokia5110_PrintBMP(28, 41, _my_Countdown_02, 0);
	Nokia5110_DisplayBuffer();
	Delay100ms(3);
	// print 1
	Nokia5110_ClearBuffer();
	Nokia5110_PrintBMP(28, 41, _my_Countdown_01, 0);
	Nokia5110_DisplayBuffer();
	Delay100ms(3);
	// print GO
	Nokia5110_ClearBuffer();
	Nokia5110_PrintBMP(28, 41, _my_Countdown_GO, 0);
	Nokia5110_DisplayBuffer();
	Delay100ms(3);
	
	
	EnableInterrupts();
	
  while(1){
		if (Flag == 1) {
			Nokia5110_DisplayBuffer();
			
			Flag = 0;
		}
	}
	
}
Exemplo n.º 8
0
void Effects_Init(void)
{
	xTaskCreate(Libration_Process,(signed char*)"Libration",64,NULL, tskIDLE_PRIORITY + 1, &xLibrationHandle);
	vTaskSuspend(xLibrationHandle);
	xTaskCreate(Rainbow_Process,(signed char*)"Rainbow",64,NULL, tskIDLE_PRIORITY + 1, &xRainbowHandle);
	//vTaskSuspend(xRainbowHandle);
	xTaskCreate(Blink_Process,(signed char*)"Blink",64,NULL, tskIDLE_PRIORITY + 1, &xBlinkHandle);
	vTaskSuspend(xBlinkHandle);
	Random_Init();

	xTaskCreate(Random_Process,(signed char*)"RAND",64,NULL, tskIDLE_PRIORITY + 1, &xRandomHandle);
	vTaskSuspend(xRandomHandle);
}
Exemplo n.º 9
0
int main(void){
  PLL_Init();                   // set system clock to 80 MHz
  Random_Init(1);
  Nokia5110_Init();
  Nokia5110_ClearBuffer();
	Nokia5110_DisplayBuffer();      // draw buffer
  Init();
  Draw();
  while(1){
    Move();
    Draw();
    Delay100ms(2);
  }
}
int main(void){ int AnyLife = 1; int i;
  TExaS_Init(NoLCD_NoScope);  // set system clock to 80 MHz
  // you cannot use both the Scope and the virtual Nokia (both need UART0)
  Random_Init(1);
  Nokia5110_Init();
  EnableInterrupts(); // virtual Nokia uses UART0 interrupts
  
  Nokia5110_ClearBuffer();
	Nokia5110_DisplayBuffer();      // draw buffer

  Nokia5110_PrintBMP(32, 47, PlayerShip0, 0); // player ship middle bottom
  Nokia5110_PrintBMP(33, 47 - PLAYERH, Bunker0, 0);

  Nokia5110_PrintBMP(0, ENEMY10H - 1, SmallEnemy10PointA, 0);
  Nokia5110_PrintBMP(16, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(32, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(48, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_PrintBMP(64, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_DisplayBuffer();   // draw buffer

  Delay100ms(50);              // delay 5 sec at 80 MHz

  Init();
  Timer2_Init(80000000/30);  // 30 Hz
  while(AnyLife){
    while(Semaphore == 0){};
    Semaphore = 0; // runs at 30 Hz
    AnyLife = 0;
    for(i=0; i<4 ; i++){
      AnyLife |= Enemy[i].life;
    }
    Draw();
  }
  Nokia5110_Clear();
  Nokia5110_SetCursor(1, 1);
  Nokia5110_OutString("GAME OVER");
  Nokia5110_SetCursor(1, 2);
  Nokia5110_OutString("Nice try,");
  Nokia5110_SetCursor(1, 3);
  Nokia5110_OutString("Earthling!");
  Nokia5110_SetCursor(2, 4);
  Nokia5110_OutUDec(1234);
  Nokia5110_SetCursor(0, 0); // renders screen
  while(1){
  }

}
Exemplo n.º 11
0
/*!
 * @brief Initialisation thread. runs once.
 */
void InitThread(void *data)
{
	for (;;)
	{
		OS_SemaphoreWait(InitSemaphore, 0);

		Random_Init();
		//Switches mate
		Switch_Init(S1Callback, (void *) 0, S2Callback, (void *) 0);

		Toggle_Init(ToggleModeFinished);
		Game_Init(GameModeFinished);

		Touch_Init();

//Initialize all the modules
		LEDs_Init();

		I2C_Init(100000, MODULE_CLOCK);
		Accel_Init(&AccelSetup);

		PIT_Init(MODULE_CLOCK, &PitCallback, (void *) 0);
		PIT_Set(500000000, bFALSE);
		PIT_Enable(bTRUE);

		Packet_Init(BAUD_RATE, MODULE_CLOCK);
		Flash_Init();
		CMD_Init();

		//Best to do this one last
		//TODO: disabled for yellow
    RTC_Init((void (*)(void*))OS_SemaphoreSignal, (void *) RtcSemaphore);

		Timer_Init();
		Timer_Set(&PacketTimer);
		Timer_Set(&AccTimer);

		CMD_SpecialGetStartupValues();

		LEDs_On(LED_ORANGE);
	}
}
Exemplo n.º 12
0
int main(void){
	HeartBeat_Init();
	DAC_Init(1024);							// initialize with command: Vout = Vref
	Timer0A_Init(dt[0]);
	LCD_Init();  
    // Initialize RNG
  Random_Init(121213);
    // Initialize touchscreen GPIO
  Touch_Init();
	//lenPush = 1;
  //for(i=0; i<50; i=i+1){
	InitializeBars();
  for(i=0; i<400; i=i+1){
	MovingColorBars();
	}
	for(i=0; i<400; i=i+1){
		DestabilizeBars();
	}
	for(i=0; i<350; i=i+1){
		FinishBars();
	}
	for(i=0; i<1000; i=i+1){
     Random4BPPTestSprite();
  }
	LCD_ColorFill(convertColor(0, 0, 0));
	Buttons_Init();
	play = 0;
	while(1){
			if (instrument == 0){
				Music_Play(Wave[0], 64, strobePtr, 35);		
			}
			if (instrument == 1){
				Music_Play(Trumpet[0], 32, strobePtr, 35);
			}
			if (instrument == 2){
				Music_Play(Flute[0], 32, strobePtr, 35);
			}
	}
}
Exemplo n.º 13
0
/**
 * The main() function of ngIRCd.
 *
 * Here all starts: this function is called by the operating system loader,
 * it is the first portion of code executed of ngIRCd.
 *
 * @param argc The number of arguments passed to ngIRCd on the command line.
 * @param argv An array containing all the arguments passed to ngIRCd.
 * @return Global exit code of ngIRCd, zero on success.
 */
GLOBAL int
main(int argc, const char *argv[])
{
	bool ok, configtest = false;
	bool NGIRCd_NoDaemon = false;
	int i;
	size_t n;

#if defined(DEBUG) && defined(HAVE_MTRACE)
	/* enable GNU libc memory tracing when running in debug mode
	 * and functionality available */
	mtrace();
#endif

	umask(0077);

	NGIRCd_SignalQuit = NGIRCd_SignalRestart = false;
	NGIRCd_Passive = false;
#ifdef DEBUG
	NGIRCd_Debug = false;
#endif
#ifdef SNIFFER
	NGIRCd_Sniffer = false;
#endif
	strlcpy(NGIRCd_ConfFile, SYSCONFDIR, sizeof(NGIRCd_ConfFile));
	strlcat(NGIRCd_ConfFile, CONFIG_FILE, sizeof(NGIRCd_ConfFile));

	Fill_Version();

	/* parse conmmand line */
	for (i = 1; i < argc; i++) {
		ok = false;
		if (argv[i][0] == '-' && argv[i][1] == '-') {
			/* long option */
			if (strcmp(argv[i], "--config") == 0) {
				if (i + 1 < argc) {
					/* Ok, there's an parameter left */
					strlcpy(NGIRCd_ConfFile, argv[i+1],
						sizeof(NGIRCd_ConfFile));
					/* next parameter */
					i++; ok = true;
				}
			}
			if (strcmp(argv[i], "--configtest") == 0) {
				configtest = true;
				ok = true;
			}
#ifdef DEBUG
			if (strcmp(argv[i], "--debug") == 0) {
				NGIRCd_Debug = true;
				ok = true;
			}
#endif
			if (strcmp(argv[i], "--help") == 0) {
				Show_Version();
				puts(""); Show_Help( ); puts( "" );
				exit(1);
			}
			if (strcmp(argv[i], "--nodaemon") == 0) {
				NGIRCd_NoDaemon = true;
				ok = true;
			}
			if (strcmp(argv[i], "--passive") == 0) {
				NGIRCd_Passive = true;
				ok = true;
			}
#ifdef SNIFFER
			if (strcmp(argv[i], "--sniffer") == 0) {
				NGIRCd_Sniffer = true;
				ok = true;
			}
#endif
			if (strcmp(argv[i], "--version") == 0) {
				Show_Version();
				exit(1);
			}
		}
		else if(argv[i][0] == '-' && argv[i][1] != '-') {
			/* short option */
			for (n = 1; n < strlen(argv[i]); n++) {
				ok = false;
#ifdef DEBUG
				if (argv[i][n] == 'd') {
					NGIRCd_Debug = true;
					ok = true;
				}
#endif
				if (argv[i][n] == 'f') {
					if (!argv[i][n+1] && i+1 < argc) {
						/* Ok, next character is a blank */
						strlcpy(NGIRCd_ConfFile, argv[i+1],
							sizeof(NGIRCd_ConfFile));

						/* go to the following parameter */
						i++;
						n = strlen(argv[i]);
						ok = true;
					}
				}

				if (argv[i][n] == 'h') {
					Show_Version();
					puts(""); Show_Help(); puts("");
					exit(1);
				}

				if (argv[i][n] == 'n') {
					NGIRCd_NoDaemon = true;
					ok = true;
				}
				if (argv[i][n] == 'p') {
					NGIRCd_Passive = true;
					ok = true;
				}
#ifdef SNIFFER
				if (argv[i][n] == 's') {
					NGIRCd_Sniffer = true;
					ok = true;
				}
#endif
				if (argv[i][n] == 't') {
					configtest = true;
					ok = true;
				}

				if (argv[i][n] == 'V') {
					Show_Version();
					exit(1);
				}

				if (!ok) {
					printf("%s: invalid option \"-%c\"!\n",
					       PACKAGE_NAME, argv[i][n]);
					printf("Try \"%s --help\" for more information.\n",
					       PACKAGE_NAME);
					exit(1);
				}
			}

		}
		if (!ok) {
			printf("%s: invalid option \"%s\"!\n",
			       PACKAGE_NAME, argv[i]);
			printf("Try \"%s --help\" for more information.\n",
			       PACKAGE_NAME);
			exit(1);
		}
	}

	/* Debug level for "VERSION" command */
	NGIRCd_DebugLevel[0] = '\0';
#ifdef DEBUG
	if (NGIRCd_Debug)
		strcpy(NGIRCd_DebugLevel, "1");
#endif
#ifdef SNIFFER
	if (NGIRCd_Sniffer) {
		NGIRCd_Debug = true;
		strcpy(NGIRCd_DebugLevel, "2");
	}
#endif

	if (configtest) {
		Show_Version(); puts("");
		exit(Conf_Test());
	}

	while (!NGIRCd_SignalQuit) {
		/* Initialize global variables */
		NGIRCd_Start = time(NULL);
		(void)strftime(NGIRCd_StartStr, 64,
			       "%a %b %d %Y at %H:%M:%S (%Z)",
			       localtime(&NGIRCd_Start));

		NGIRCd_SignalRestart = false;
		NGIRCd_SignalQuit = false;

		/* Initialize modules, part I */
		Log_Init(!NGIRCd_NoDaemon);
		Random_Init();
		Conf_Init();
		Log_ReInit();

		/* Initialize the "main program": chroot environment, user and
		 * group ID, ... */
		if (!NGIRCd_Init(NGIRCd_NoDaemon)) {
			Log(LOG_ALERT, "Fatal: Initialization failed");
			exit(1);
		}

		/* Initialize modules, part II: these functions are eventually
		 * called with already dropped privileges ... */
		Channel_Init();
		Client_Init();
		Conn_Init();
		Class_Init();

		if (!io_library_init(CONNECTION_POOL)) {
			Log(LOG_ALERT,
			    "Fatal: Could not initialize IO routines: %s",
			    strerror(errno));
			exit(1);
		}

		if (!Signals_Init()) {
			Log(LOG_ALERT,
			    "Fatal: Could not set up signal handlers: %s",
			    strerror(errno));
			exit(1);
		}

		/* Create protocol and server identification. The syntax
		 * used by ngIRCd in PASS commands and the known "extended
		 * flags" are described in doc/Protocol.txt. */
#ifdef IRCPLUS
		snprintf(NGIRCd_ProtoID, sizeof NGIRCd_ProtoID, "%s%s %s|%s:%s",
			 PROTOVER, PROTOIRCPLUS, PACKAGE_NAME, PACKAGE_VERSION,
			 IRCPLUSFLAGS);
#ifdef ZLIB
		strcat(NGIRCd_ProtoID, "Z");
#endif
		if (Conf_OperCanMode)
			strcat(NGIRCd_ProtoID, "o");
#else /* IRCPLUS */
		snprintf(NGIRCd_ProtoID, sizeof NGIRCd_ProtoID, "%s%s %s|%s",
			 PROTOVER, PROTOIRC, PACKAGE_NAME, PACKAGE_VERSION);
#endif /* IRCPLUS */
		strlcat(NGIRCd_ProtoID, " P", sizeof NGIRCd_ProtoID);
#ifdef ZLIB
		strlcat(NGIRCd_ProtoID, "Z", sizeof NGIRCd_ProtoID);
#endif
		LogDebug("Protocol and server ID is \"%s\".", NGIRCd_ProtoID);

		Channel_InitPredefined();

		if (Conn_InitListeners() < 1) {
			Log(LOG_ALERT,
			    "Server isn't listening on a single port!" );
			Log(LOG_ALERT,
			    "%s exiting due to fatal errors!", PACKAGE_NAME);
			Pidfile_Delete();
			exit(1);
		}

		/* Main Run Loop */
		Conn_Handler();

		Conn_Exit();
		Client_Exit();
		Channel_Exit();
		Class_Exit();
		Log_Exit();
	}
	Pidfile_Delete();

	return 0;
} /* main */
Exemplo n.º 14
0
int main(void) {
    int addScore, position, pauseSel;

    // Initializations
    PLL_Init();  			// Clock set at 80 MHz
    LCD_Init();
    Board_Init();
    Input_Init();
    DAC_Init();
    Random_Init(NVIC_ST_CURRENT_R);
    Timer2_Init(80000000); 	// time interrupt
    Timer1_Init(2000);		// sound interrupt
    EnableInterrupts();
    generateRandomTile();
    drawAllTiles();
    writeScore(0);
    writeHighscore(0);
    writeTime(0);
    displayHighestTile();

    while(1) {

        // draw arrow if ready
        if (arrowReady == 1) {
            // acknowledge flag
            arrowReady = 0;
            // draw arrow
            drawArrow();
        }

        // write time if ready
        if (timeReady == 1) {
            // acknowledge flag
            timeReady = 0;
            // write time
            writeTime(elapsedTime);
        }

        // Play mode and button1 is pushed
        if(Button1 && !pauseMode && !gameOver) {
            // Play sound
            playSound = 1;
            // shift and merge tiles towards arrow
            position = getSliderPosition();
            if (position == 1) {
                shiftLeft();
                addScore = mergeLeft();
                shiftLeft();
            }
            else if (position == 2) {
                shiftUp();
                addScore = mergeUp();
                shiftUp();
            }
            else if (position == 3) {
                shiftRight();
                addScore = mergeRight();
                shiftRight();
            }
            else {
                shiftDown();
                addScore = mergeDown();
                shiftDown();
            }

            eraseBoard();
            drawAllTiles();

            // update score
            score += addScore;
            addScore = 0;
            writeScore(score);
            displayHighestTile();

            // delay before adding new tile
            delay(200);

            // create new tile
            if (countEmptyTiles() != 0) {
                generateRandomTile();
            }
            drawAllTiles();

            // update highest tile image
            displayHighestTile();

            // check if game over
            if (checkGameOver() == 1) {
                gameOver = 1;
            }

            // unset flag
            Button1 = 0;
        }

        // button 2 is pause
        else if (Button2 && !gameOver && !pauseMode) {
            pauseMode = 1;
            pauseSel = 0;

            // disable arrow and timer
            NVIC_ST_CTRL_R = 0;
            TIMER2_CTL_R = 0x00000000;
            LCD_DrawFilledRect(prevX,prevY,20,20,BLACK);

            // draw pause mode screen
            drawPauseMode();

            // acknowledge button
            Button2 = 0;

            // wait until button is pushed
            while (pauseMode) {

                // Button 1 selects current pause selection button
                if (Button1) {

                    // acknowledge button
                    Button1 = 0;
                    Button2 = 0;
                    pauseMode = 0;

                    // if pause selection = "continue" (pauseSel = 0), continue with game
                    if (pauseSel == 0) {

                        // redraw screen
                        eraseBoard();
                        drawAllTiles();

                        // enable gameplay
                        NVIC_ST_CTRL_R = 0x07;
                        TIMER2_CTL_R = 0x00000001;
                    }

                    // if pause selection = "restart" (pauseSel = 0), end game
                    else if (pauseSel == 1) {
                        if (score > highscore) {
                            writeHighscore(score);
                        }
                        score = 0;
                        eraseScore();
                        writeScore(0);
                        clearBoard();
                        eraseBoard();
                        pauseMode = 0;
                        generateRandomTile();
                        drawAllTiles();
                        elapsedTime = 0;
                        eraseTime();
                        writeTime(0);
                        displayHighestTile();
                        NVIC_ST_CTRL_R = 0x07;
                        TIMER2_CTL_R = 0x00000001;
                    }
                }

                // Button 2 changes pause selection
                else if (Button2) {
                    Button2 = 0;
                    if (pauseSel == 0) {
                        pauseSel = 1;
                        LCD_DrawRect(144,112,58,16,BLACK);
                        LCD_DrawRect(222,112,51,16,WHITE);
                    }
                    else if (pauseSel == 1) {
                        pauseSel = 0;
                        LCD_DrawRect(222,112,51,16,BLACK);
                        LCD_DrawRect(144,112,58,16,WHITE);
                    }
                }
            }
        }

        // game over
        if (gameOver == 1) {
            NVIC_ST_CTRL_R = 0;
            TIMER2_CTL_R = 0x00000000;
            LCD_DrawFilledRect(156,38,100,20,BLACK);
            LCD_SetTextColor(255,255,240);
            LCD_Goto(30,5);
            printf("GAME OVER");
            while (Button1 == 0 && Button2 == 0) {}
            Button1 = 0;
            Button2 = 0;
            LCD_DrawFilledRect(prevX,prevY,20,20,BLACK);
            drawGameOver(score, elapsedTime);
            if (score > highscore) {
                writeHighscore(score);
                gameOverHighscore(score);
            }
            // wait til button is pushed
            while (Button1 == 0 && Button2 == 0) {}
            // acknowledge buttons
            Button1 = 0;
            Button2 = 0;
            // start new game
            score = 0;
            eraseScore();
            writeScore(0);
            clearBoard();
            eraseBoard();
            pauseMode = 0;
            generateRandomTile();
            drawAllTiles();
            elapsedTime = 0;
            eraseTime();
            writeTime(0);
            displayHighestTile();
            NVIC_ST_CTRL_R = 0x07;
            TIMER2_CTL_R = 0x00000001;

            // finish game over mode
            gameOver = 0;
        }
    }
}