void config_read(void)
{
	uint8_t choice=0;
	
	if(read_from_EEPROM(10) != 48)
	{
		while(1)
		{
			choice = uart_getchar();
			putchar('\n');
			putchar('\r');
			
			if(choice=='1')
			{
				while(!(UCSR0A & (1 << RXC0)))adxl345();
				config_menu();
			}
			if(choice=='2')
			{
				while(!(UCSR0A & (1 << RXC0)))
				{
					hmc5843();
					delay_ms(550);//at least 100ms interval between measurements
				}
				config_menu();
			}
			if(choice=='3')
			{
				while(!(UCSR0A & (1 << RXC0)))stgyros();
				config_menu();
			}
			if(choice=='4')
			{
				while(!(UCSR0A & (1 << RXC0)))raw();
				config_menu();
			}
			if(choice=='5')
			{
				self_test();
			}
			if(choice==0x1A) //if ctrl-z
			{
				write_to_EEPROM(10,48);
				auto_raw();
			}
			if(choice==0x3F) //if ?
			{
				help();
				config_menu();
			}
		}
	}else auto_raw();
}
void auto_raw(void)
{
	//while there is not a button pressed
	while(!(UCSR0A & (1 << RXC0)))
	{
		//prints the raw vaues with a '$,' start and ',#' end	
		printf("$,");
		printf("%d,", x_accel());
		printf("%d,", y_accel());
		printf("%d,", z_accel());
		printf("%d,", x_gyro());
		printf("%d,", y_gyro());
		printf("%d,", z_gyro());
		magnetometer();
		printf("%d,", x_mag);
		printf("%d,", y_mag);
		printf("%d,", z_mag);
		printf("#\n\r");
	}

	//if a button is pressed and that button is ctrl-z, reset autorun, display menu
	if(uart_getchar() == 0x1A)
	{
		write_to_EEPROM(10,0);
		config_menu();
	}
	
	auto_raw();
}
Example #3
0
/////===========MAIN=====================/////////////////////
int main(void)
{
	init();
	self_test();
	
	while(1)
	{	
		//check to see if autorun is set, if it is don't print the menu
		if(read_from_EEPROM(1) == 48) config_read();
		else config_menu();
	}
}
Example #4
0
void auto_raw(void)
{
	//while there is not a button pressed
	while(!(UCSR0A & (1 << RXC0)))
	{
		raw();
	}

	//if a button is pressed and that button is ctrl-z, reset autorun, display menu
	if(uart_getchar() == 0x1A)
	{
		write_to_EEPROM(1,0);
		config_menu();
	}
	
	auto_raw();
}
int main(void)
{
	init();
	
	while(1)
	{	
		
		sbi(PORTB, STATUS_LED);
		delay_ms(1000);
		cbi(PORTB, STATUS_LED);
		delay_ms(1000);
		sbi(PORTB, STATUS_LED);
		delay_ms(1000);
		cbi(PORTB, STATUS_LED);
		
		//check to see if autorun is set, if it is don't print the menu
		if(read_from_EEPROM(10) == 48) config_read();
		else config_menu();
	}
}
Example #6
0
void self_test(void)
{
	//MAGNETOMETER
	
	uint8_t xh, xl, yh, yl, zh, zl, hmc_flag = 0;
	x_mag = 0;
	y_mag = 0;
	z_mag = 0;
	
	magnetometer_init();
	
	//must read all six registers plus one to move the pointer back to 0x03
	
	i2cSendStart();
	i2cWaitForComplete();
	i2cSendByte(0x3D);    //write to HMC
	i2cWaitForComplete();
	i2cReceiveByte(TRUE);
	i2cWaitForComplete();
	xh = i2cGetReceivedByte();	//x high byte
	i2cWaitForComplete();
	
	i2cReceiveByte(TRUE);
	i2cWaitForComplete();
	xl = i2cGetReceivedByte();	//x low byte
	i2cWaitForComplete();
	x_mag = xl|(xh << 8);
	
	i2cReceiveByte(TRUE);
	i2cWaitForComplete();
	zh = i2cGetReceivedByte();	
	i2cWaitForComplete();      //z high byte
	
	i2cReceiveByte(TRUE);
	i2cWaitForComplete();
	zl = i2cGetReceivedByte();	//z low byte
	i2cWaitForComplete();
	z_mag = zl|(zh << 8);
	
	i2cReceiveByte(TRUE);
	i2cWaitForComplete();
	yh = i2cGetReceivedByte();	//y high byte
	i2cWaitForComplete();
	
	i2cReceiveByte(TRUE);
	i2cWaitForComplete();
	yl = i2cGetReceivedByte();	//y low byte
	i2cWaitForComplete();
	y_mag = yl|(yh << 8);
	
	i2cSendByte(0x3D);         //must reach 0x09 to go back to 0x03
	i2cWaitForComplete();
	
	i2cSendStop();	
	
	//if it gets to this point and there are values in x,y,z_mag, we can assume part is responding correctly
	if((x_mag == y_mag) && (y_mag == z_mag)) hmc_flag = 0xFF;
	else hmc_flag = 0;
	
	//ACCELEROMETER
	
	uint8_t x, dummy;
	
	//0x32 data registers
	i2cSendStart();
	i2cWaitForComplete();
	i2cSendByte(0xA6);    //write to ADXL
	i2cWaitForComplete();
	i2cSendByte(0x00);    //X0 data register
	i2cWaitForComplete();
	
	i2cSendStop();		 //repeat start
	i2cSendStart();

	i2cWaitForComplete();
	i2cSendByte(0xA7);    //read from ADXL
	i2cWaitForComplete();
	i2cReceiveByte(TRUE);
	i2cWaitForComplete();
	x = i2cGetReceivedByte();
	i2cWaitForComplete();
	i2cReceiveByte(FALSE);
	i2cWaitForComplete();
	dummy = i2cGetReceivedByte();
	i2cWaitForComplete();
	i2cSendStop();	
	
	///////////////////////////////////
	// Gyro////////////////////////////
	///////////////////////////////////
	
	char data;
	
	cbi(TWCR, TWEN);	// Disable TWI
	sbi(TWCR, TWEN);	// Enable TWI
	
	i2cSendStart();
	i2cWaitForComplete();
	i2cSendByte(ITG3200_W);	// write 0xD2
	i2cWaitForComplete();
	i2cSendByte(0x00);	// who am i
	i2cWaitForComplete();
	
	i2cSendStart();
	
	i2cSendByte(ITG3200_R);	// write 0xD3
	i2cWaitForComplete();
	i2cReceiveByte(FALSE);
	i2cWaitForComplete();
	
	data = i2cGetReceivedByte();	// Get MSB result
	i2cWaitForComplete();
	i2cSendStop();
	
	cbi(TWCR, TWEN);	// Disable TWI
	sbi(TWCR, TWEN);	// Enable TWI
	
	int gyro_flag = 0;
	int mag_flag = 0;
	int accel_flag = 0;
	
	if(data == 0x69)
	{
		printf("ITG: GOOD\n\r");
		gyro_flag = 1;
	}else printf("ITG: BAD\n\r");
	
	if(hmc_flag == 0)
	{
		printf("HMC: GOOD\n\r");
		mag_flag = 1;
	}else printf("HMC: BAD\n\r");
	
	if(x == 0xE5)
	{
		printf("ADXL: GOOD\n\r");
		accel_flag = 1;
	}else printf("ADXL: BAD\n\r");
	
	if(gyro_flag ==1 && mag_flag == 1 && accel_flag == 1)
	{
		sbi(PORTB, 5);
		delay_ms(1000);
		cbi(PORTB, 5);
		delay_ms(1000);
		sbi(PORTB, 5);
		delay_ms(1000);
		cbi(PORTB, 5);
		delay_ms(1000);
		sbi(PORTB, 5);
		delay_ms(1000);
		cbi(PORTB, 5);
		delay_ms(1000);
		sbi(PORTB, 5);
		delay_ms(1000);
		cbi(PORTB, 5);
		delay_ms(1000);
		sbi(PORTB, 5);
		delay_ms(1000);
		cbi(PORTB, 5);
		
		gyro_flag = 0;
		mag_flag = 0;
		accel_flag = 0;
		
	}else sbi(PORTB, 5);
	
	//while(!(UCSR0A & (1 << RXC0)));
	config_menu();
} 
Example #7
0
void config_read(void)
{
	uint8_t choice=0;
	
	if(read_from_EEPROM(1) != 48)
	{
		while(1)
		{
			choice = uart_getchar();
			putchar('\n');
			putchar('\r');
			
			if(choice=='1')
			{
				while(!(UCSR0A & (1 << RXC0)))print_adxl345();
				config_menu();
			}
			else if(choice=='2')
			{
				while(!(UCSR0A & (1 << RXC0)))
				{
					print_hmc5883();
					delay_ms(100);//at least 100ms interval between measurements
				}
				config_menu();
			}
			else if(choice=='3')
			{
				while(!(UCSR0A & (1 << RXC0)))print_itg3200();
				config_menu();
			}
			else if(choice=='4')
			{
				while(!(UCSR0A & (1 << RXC0)))raw();
				config_menu();
			}
			else if(choice=='5')
			{
				baud_menu();
				config_menu();
			}
			else if(choice==0x10) //if ctrl-p
			{
				self_test();
			}
			else if(choice==0x1A) //if ctrl-z
			{
				write_to_EEPROM(1,48);
				auto_raw();
			}
			else if(choice==0x3F) //if ?
			{
				help();
				while(!(UCSR0A & (1 << RXC0)));
				config_menu();
			}
			else if(choice==0xFF) config_read();
		}
	}else auto_raw();

}
Example #8
0
void baud_menu(void)
{
	printf("\n\rBaud Rate Select Menu\n\r");
	printf("[1] 4800\n\r");
	printf("[2] 9600\n\r");
	printf("[3] 19200\n\r");
	printf("[4] 38400\n\r");
	printf("[5] 57600\n\r");
	
	uint8_t choicer=0;
	
	while(1)
	{
		choicer = uart_getchar();
		putchar('\n');
		putchar('\r');
		
		if(choicer=='1') //4800
		{
			//outside of default flag: used to notify init not to run default baud value
			write_to_EEPROM(2, 99);
			
			//clear other EEPROM values
			write_to_EEPROM(4, 0);
			write_to_EEPROM(5, 0);
			write_to_EEPROM(6, 0);
			write_to_EEPROM(7, 0);
			
			write_to_EEPROM(3, 4); //baud change flag
			printf("!change baud rate to 4800bps, reset board!");
			delay_ms(50);
			UART_Init(207);
			while(1);
		}
		else if(choicer=='2') //9600
		{
			write_to_EEPROM(2, 99); //outside of default flag
			
			//clear other EEPROM values
			write_to_EEPROM(3, 0);
			write_to_EEPROM(5, 0);
			write_to_EEPROM(6, 0);
			write_to_EEPROM(7, 0);
			
			write_to_EEPROM(4, 9); //baud change flag
			printf("!change baud rate to 9600bps, reset board!");
			delay_ms(50);
			UART_Init(103);
			while(1);
		}
		else if(choicer=='3') //19200
		{
			write_to_EEPROM(2, 99); //outside of default flag
			
			//clear other EEPROM values
			write_to_EEPROM(3, 0);
			write_to_EEPROM(4, 0);
			write_to_EEPROM(6, 0);
			write_to_EEPROM(7, 0);
			
			write_to_EEPROM(5, 19); //baud change flag
			printf("!change baud rate to 19200bps, reset board!");
			delay_ms(50);
			UART_Init(51);
			while(1);
		}
		else if(choicer=='4') //38400
		{
			write_to_EEPROM(2, 99); //outside of default flag
			
			//clear other EEPROM values
			write_to_EEPROM(3, 0);
			write_to_EEPROM(4, 0);
			write_to_EEPROM(5, 0);
			write_to_EEPROM(7, 0);
			
			write_to_EEPROM(6, 38); //baud change flag
			printf("!change baud rate to 38400bps, reset board!");
			delay_ms(50);
			UART_Init(25);
			while(1);
		}
		else if(choicer=='5') //57600
		{
			write_to_EEPROM(2, 99); //outside of default flag
			
			//clear other EEPROM values
			write_to_EEPROM(3, 0);
			write_to_EEPROM(4, 0);
			write_to_EEPROM(5, 0);
			write_to_EEPROM(6, 0);
			
			write_to_EEPROM(7, 57); //baud change flag
			printf("!change baud rate to 57600bps, reset board!");
			delay_ms(50);
			UART_Init(16);
			while(1);
		}
		else if((choicer < 0X31) || (choicer > 0x35))config_menu(); //if choice is not #s 1-5 goto conig menu
	}
	config_menu();
}
Example #9
0
/*! \brief Display system menu
 *
 * This is the system menu that is invoked from within the game.
 * From here you can save, load, configure a couple of options or
 * exit the game altogether.
 * \date 20040229 PH added 'Save anytime' facility when cheat mode is ON
 *
 * \returns 0 if cancelled or nothing happened, 1 otherwise
 */
int system_menu (void)
{
   int stop = 0, ptr = 0;
   char save_str[10];
   int text_color = FNORMAL;

   strcpy (save_str, _("Save  "));

   if (cansave == 0) {
      text_color = FDARK;
#ifdef KQ_CHEATS
      if (cheat) {
         strcpy (save_str, _("[Save]"));
         text_color = FNORMAL;
      }
#endif /* KQ_CHEATS */
   }

   while (!stop) {
      check_animation ();
      drawmap ();
      menubox (double_buffer, xofs, yofs, 8, 4, BLUE);

      print_font (double_buffer, 16 + xofs, 8 + yofs, save_str, text_color);
      print_font (double_buffer, 16 + xofs, 16 + yofs, _("Load"), FNORMAL);
      print_font (double_buffer, 16 + xofs, 24 + yofs, _("Config"), FNORMAL);
      print_font (double_buffer, 16 + xofs, 32 + yofs, _("Exit"), FNORMAL);

      draw_sprite (double_buffer, menuptr, 0 + xofs, ptr * 8 + 8 + yofs);
      blit2screen (xofs, yofs);
      readcontrols ();


      // TT:
      // When pressed, 'up' or 'down' == 1.  Otherwise, they equal 0.  So:
      //    ptr = ptr - up + down;
      // will correctly modify the pointer, but with less code.
      if (up || down) {
         ptr = ptr + up - down;
         if (ptr < 0)
            ptr = 3;
         else if (ptr > 3)
            ptr = 0;
         play_effect (SND_CLICK, 128);
         unpress ();
      }

      if (balt) {
         unpress ();

         if (ptr == 0) {
            // Pointer is over the SAVE option
#ifdef KQ_CHEATS
            if (cansave == 1 || cheat)
#else
            if (cansave == 1)
#endif /* KQ_CHEATS */
            {
               saveload (1);
               stop = 1;
            } else
               play_effect (SND_BAD, 128);
         }

         if (ptr == 1) {
            if (saveload (0) != 0)
               stop = 1;
         }

         if (ptr == 2)
            config_menu ();

         if (ptr == 3)
            return confirm_quit ();
      }

      if (bctrl) {
         stop = 1;
         unpress ();
      }
   }

   return 0;
}
Example #10
0
int main (void)
{
	char temp;
	short b;

	
    ioinit(); //Setup IO pins and defaults
	USART_Init(10);//set up for 115200
	rprintf_devopen(put_char); /* init rrprintf */
	
	for (b = 0; b < 5; b++)
	{
		PORTB &= (~(1<<STAT));//stat on
		delay_ms(50);
		PORTB |= (1<<STAT);//stat off
		delay_ms(50);
	}
	
	asc = 0;
	auto_run = 0;
	
	//check for existing preset values==============================================================
	temp = EEPROM_read((unsigned int)FREQ_HIGH);
	
	if (temp == 255)//unwritten
	{
		cli();//Disable Interrupts
		
		EEPROM_write((unsigned int) FREQ_LOW, 100);//100Hz
		EEPROM_write((unsigned int) FREQ_HIGH, 0);
		EEPROM_write((unsigned int) SENSE_AR_MODE, 0);//1.5g, auto-run off, binary output
		EEPROM_write((unsigned int) ACT_CHAN, 0x3F);//all channels active
		
		sei();//Enable Interrupts
		
		freq = 100;
		asc = 0;//binary
		auto_run = 0;//auto run off
		//set for 1.5g sensitivity
		PORTB &= (~((1<<GS1) | (1<<GS2)));//GS1 low, GS2 low
	}
	
	//get presets
	else
	{
		b = EEPROM_read((unsigned int)FREQ_HIGH);
		b <<= 8;
		b |= EEPROM_read((unsigned int)FREQ_LOW);
		
		freq = (float)b;
		
		active_channels = EEPROM_read((unsigned int)ACT_CHAN);
		
		temp = EEPROM_read((unsigned int)SENSE_AR_MODE);
		
		if (temp & 0x08) PORTB |= (1<<GS2);//GS2 High
		if (temp & 0x04) PORTB |= (1<<GS1);//GS2 High
		
		if (temp & 0x02) auto_run = 1;
		if (temp & 0x01) asc = 1;
	}
	
	//main loop==================================================================
	while(1)
	{

		if (auto_run == 1)
		{
			while(1)
			{
				//This is the sampling loop. It runs in get_adc() until somebody stops it.
				get_adc();
				
				//If it dumps out of the sampling loop, go to the config menu.
				config_menu();
				
				//Bail out if auto run is off.
				if (auto_run == 0) break;
			}
		}

	
		if (UCSR0A & (1<<RXC0))//if something comes in...
		{
			  
			temp = UDR0;

			if (temp == 35)	//# to run
			{
				asc = 0;
				get_adc();
			
			}
		  
			else if (temp == 37)	//% to set range to 1.5g
			{
				//set for 1.5g sensitivity
				PORTB &= (~((1<<GS1) | (1<<GS2)));//GS1 low, GS2 low
			
			}
			
			else if (temp == 38)	//& to set range to 2g
			{
				PORTB |= (1<<GS1);//GS1 High
				PORTB &= (~(1<<GS2));//GS2 low   
			  
			}
			
			else if (temp == 39)	//' to set range to 4g
			{
				PORTB &= (~(1<<GS1));//GS1 low
				PORTB |= (1<<GS2);//GS2 High
			}
			
			else if (temp == 40)	//( to set range to 6g
			{
				PORTB |= ((1<<GS1) | (1<<GS2));//GS1, GS2 high
				
			}

		  else if (temp == 41) freq = 50;	//) to run at 50Hz
		  
		  else if (temp == 42)	freq = 100;// to run at 100Hz

		  else if (temp == 43)	freq = 150;//+ to run at 150Hz
		  
		  else if (temp == 44)	freq = 200;//, to run at 200Hz
		 
		  else if (temp == 45)	freq = 250;//- to run at 250Hz
		  
		  else if (temp == 32)	//
		  {
			  while(1)
			  {
				  config_menu();

				  if (auto_run == 0) break;

				  get_adc();

				 
			  }
		  }

		  temp = 0;

			  
		}
	}
	
	while(1);
	

}
Example #11
0
/*! \brief Main menu screen
 *
 * This is the main menu... just display the opening and then the menu and
 * then wait for input.  Also handles loading a saved game, and the config menu.
 *
 * \param   c zero if the splash (the bit with the staff and the eight heroes)
 *            should be displayed.
 * \returns 1 if new game, 0 if continuing, 2 if exit
 */
int start_menu (int skip_splash)
{
   int stop = 0, ptr = 0, redraw = 1, a, b;
   DATAFILE *bg;
   BITMAP *staff, *dudes, *tdudes;

#ifdef DEBUGMODE
   if (debugging == 0) {
#endif
      play_music ("oxford.s3m", 0);
      /* Play splash (with the staff and the heroes in circle */
      if (skip_splash == 0) {
         bg = load_datafile_object (PCX_DATAFILE, "KQT_PCX");
         staff = create_bitmap_ex (8, 72, 226);
         dudes = create_bitmap_ex (8, 112, 112);
         tdudes = create_bitmap_ex (8, 112, 112);
         blit ((BITMAP *) bg->dat, staff, 0, 7, 0, 0, 72, 226);
         blit ((BITMAP *) bg->dat, dudes, 80, 0, 0, 0, 112, 112);
         clear_bitmap (double_buffer);
         blit (staff, double_buffer, 0, 0, 124, 22, 72, 226);
         blit2screen (0, 0);

         kq_wait (1000);
         for (a = 0; a < 42; a++) {
            stretch_blit (staff, double_buffer, 0, 0, 72, 226, 124 - (a * 32),
                          22 - (a * 96), 72 + (a * 64), 226 + (a * 192));
            blit2screen (0, 0);
            kq_wait (100);
         }
         for (a = 0; a < 5; a++) {
            color_scale (dudes, tdudes, 53 - a, 53 + a);
            draw_sprite (double_buffer, tdudes, 106, 64);
            blit2screen (0, 0);
            kq_wait (100);
         }
         draw_sprite (double_buffer, dudes, 106, 64);
         blit2screen (0, 0);
         kq_wait (1000);
         destroy_bitmap (staff);
         destroy_bitmap (dudes);
         destroy_bitmap (tdudes);
		 unload_datafile_object(bg);
         /*
            TODO: this fade should actually be to white
            if (_color_depth == 8)
            fade_from (pal, whp, 1);
            else
          */
         do_transition (TRANS_FADE_WHITE, 1);
      }
      clear_to_color (double_buffer, 15);
      blit2screen (0, 0);
      set_palette (pal);
      bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX");
      for (a = 0; a < 16; a++) {
         clear_to_color (double_buffer, 15 - a);
         masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 60 - (a * 4),
                      320, 124);
         blit2screen (0, 0);
         kq_wait (a == 0 ? 500 : 100);
      }
      if (skip_splash == 0)
         kq_wait (500);
#ifdef DEBUGMODE
   } else {
      set_palette (pal);
      bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX");
   }
#endif

   reset_world ();

   /* Draw menu and handle menu selection */
   while (!stop) {
      if (redraw) {
         clear_bitmap (double_buffer);
         masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 0, 320, 124);
         menubox (double_buffer, 112, 116, 10, 4, BLUE);
         print_font (double_buffer, 128, 124, _("Continue"), FNORMAL);
         print_font (double_buffer, 128, 132, _("New Game"), FNORMAL);
         print_font (double_buffer, 136, 140, _("Config"), FNORMAL);
         print_font (double_buffer, 144, 148, _("Exit"), FNORMAL);
         draw_sprite (double_buffer, menuptr, 112, ptr * 8 + 124);
         redraw = 0;
      }
      display_credits ();
      blit2screen (0, 0);
      readcontrols ();
      if (bhelp) {
         unpress ();
         show_help ();
         redraw = 1;
      }
      if (up) {
         unpress ();
         if (ptr > 0)
            ptr--;
         else
            ptr = 3;
         play_effect (SND_CLICK, 128);
         redraw = 1;
      }
      if (down) {
         unpress ();
         if (ptr < 3)
            ptr++;
         else
            ptr = 0;
         play_effect (SND_CLICK, 128);
         redraw = 1;
      }
      if (balt) {
         unpress ();
         if (ptr == 0) {        /* User selected "Continue" */
            if (snc[0] == 0 && snc[1] == 0 && snc[2] == 0 && snc[3] == 0
                && snc[4] == 0)
               stop = 2;
            else if (saveload (0) == 1)
               stop = 1;
            redraw = 1;
         } else if (ptr == 1) { /* User selected "New Game" */
            stop = 2;
         } else if (ptr == 2) { /* Config */
            clear (double_buffer);
            config_menu ();
            redraw = 1;

            /* TODO: Save Global Settings Here */
         } else if (ptr == 3) { /* Exit */
            unload_datafile_object (bg);
            klog (_("Then exit you shall!"));
            return 2;
         }
      }
   }
   unload_datafile_object (bg);
   if (stop == 2) {
      /* New game init */
      for (a = 0; a < MAXCHRS; a++)
         memcpy (&party[a], &players[a].plr, sizeof (s_player));
      init_players ();
      memset (progress, 0, SIZE_PROGRESS);
      memset (treasure, 0, SIZE_TREASURE);
      numchrs = 0;
      for (a = 0; a < NUMSHOPS; a++) {
         for (b = 0; b < SHOPITEMS; b++)
            shops[a].items_current[b] = shops[a].items_max[b];
      }
      for (b = 0; b < 2; b++) {
         for (a = 0; a < MAX_INV; a++)
            g_inv[a][b] = 0;
      }
   }
   return stop - 1;
}
Example #12
0
void
new_user(const char *hostname)
{
    int i = 0;
    unsigned int usernum;

    if( check_lockout(hostname) == FALSE )
        logoff(0);
    usersupp = newuser_makesupp();

    more(BBSDIR "/share/newuser/welcome_about", 0);
    cprintf("\1f\1gPress a key..");
    inkey();	
    more(BBSDIR "/share/newuser/welcome_commands", 0);
    cprintf("\1f\1gPress a key..");
    inkey();
    more(BBSDIR "/share/newuser/welcome_rules", 0);
    cprintf("\1f\1gPress a key..");
    inkey();
    more(BBSDIR "/share/newuser/welcome_username", 0);
 
    newuser_getname(usersupp->username);

    /* now we have a name, try to get a number */
    get_new_usernum( usersupp->username, &usernum );
    usersupp->usernum = usernum;

    newuser_getpasswd(usersupp->usernum);
    newuser_registration(usersupp);

    test_ansi_colours(usersupp);
    cprintf("\1f\1g");
    more(BBSDIR "/share/newuser/hideinfo", 0);
    usersupp->hidden_info = H_REALNAME | H_ADDRESS | H_CITY | H_COUNTRY
		    | H_PHONE | H_EMAIL | H_URL | H_BIRTHDAY;
    usersupp->flags |= US_HIDDENHOST;

    cprintf("\n\1f\1gPress a key to continue.. \1a");
    inkey();
    toggle_hidden_info(usersupp);

    config_menu();

    cprintf("\1f\1g\nA personal validation key is being generated and sent to the\n");
    cprintf("following email address: `%s'.\n\n", usersupp->RGemail);
    cprintf("Sending... ");
    fflush(stdout);

    generate_new_key(usersupp->usernum);

    i = send_key(usersupp->usernum );

    switch (i) {

	case 0:
	    more(BBSDIR "/share/newuser/key_done", 0);
	    break;

	case 1:
            more(BBSDIR "/share/newuser/key_invalid_chars", 0);
	    break;

	default:
            more(BBSDIR "/share/newuser/key_unknown_error", 0);
	    break;
    }

    fflush(stdout);
    sleep(1);

    /* final message to the new user */
    cprintf("Press a key to continue.. ");
    inkey();
    more(BBSDIR "/share/newuser/final", 1);

    log_it("newuserlog", "Created user '%s' from host '%s'", usersupp->username, hname);
    writeuser(usersupp, 0);
    mono_sql_u_update_registration( usersupp->usernum,
        usersupp->RGname, usersupp->RGaddr, usersupp->RGzip, usersupp->RGcity,
        usersupp->RGstate, usersupp->RGcountry, usersupp->RGphone );
    mono_sql_u_update_hidden( usersupp->usernum, usersupp->hidden_info );
    mono_sql_u_update_email( usersupp->usernum, usersupp->RGemail );
    mono_sql_u_update_url( usersupp->usernum, usersupp->RGurl );

    cprintf("Press a key to continue.. \1a");
    inkey();
    cprintf("\n");
    return;
}
Example #13
0
/*  startup_screen

    This is the splash-screen which calls the startup functions,
    like loading the plugins, zones, services etc.

    Returncodes:
         0: ok
        -1: error
*/
int startup_screen(struct vrmr_ctx *vctx, struct vrmr_rules *rules,
        struct vrmr_zones *zones, struct vrmr_services *services,
        struct vrmr_interfaces *interfaces, struct vrmr_blocklist *blocklist,
        struct vrmr_regex *reg)
{
    WINDOW *startup_win = NULL, *startup_print_win = NULL;
    PANEL *startup_panel[2];
    int retval = 0, maxy = 0, maxx = 0, y = 0, x = 0, width = 50, heigth = 15,
        result = 0, config_done = 0, cnfresult = 0;
    int print_pan_width = 40;

    // get screensize and set windowlocation
    getmaxyx(stdscr, maxy, maxx);
    y = (maxy - heigth) / 2;
    x = (maxx - width) / 2;

    // create the windows and panels
    startup_win = create_newwin(heigth, width, y, x, "Vuurmuur_conf",
            vccnf.color_win_init | A_BOLD);
    startup_print_win = newwin(1, print_pan_width, y + heigth - 3, x + 5);
    wbkgd(startup_print_win, vccnf.color_win_init | A_BOLD);
    startup_panel[0] = new_panel(startup_win);
    startup_panel[1] = new_panel(startup_print_win);
    update_panels();
    doupdate();

    // print the logo: it looks a bit weird here because of escape sequences
    // also print version
    mvwprintw(startup_win, 3, 4, "  \\\\   //           |\\\\ //|            ");
    mvwprintw(startup_win, 4, 4, "   \\\\ // | | | | |] ||\\//|| | | | | |] ");
    mvwprintw(startup_win, 5, 4,
            "    \\//  \\/| \\/| |\\ ||   || \\/| \\/| |\\ ");
    mvwprintw(startup_win, 6, 4, "                                Config ");
    mvwprintw(startup_win, 7, 4, "  ------------------------------------ ");
    mvwprintw(startup_win, 9, 3, "%s ", VUURMUUR_COPYRIGHT);
    mvwprintw(startup_win, 10, 3, gettext("Version: %s"), VUURMUURCONF_VERSION);
    mvwprintw(startup_win, 12, 4, "[");
    mvwprintw(startup_win, 12, 4 + print_pan_width + 1, "]");

    /* initialize the vuurmuur conf config */
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_LOAD_VUURMUUR_CONF_SETTINGS);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    while (!config_done) {
        result = init_vcconfig(&vctx->conf, vccnf.configfile_location, &vccnf);
        if (result == VRMR_CNF_E_UNKNOWN_ERR || result == VRMR_CNF_E_PARAMETER)
            return (-1);
        else if (result == VRMR_CNF_E_FILE_PERMISSION) {
            return (-1);
        }
        /* missing file? use defaults */
        else if (result == VRMR_CNF_E_FILE_MISSING) {
            vcconfig_use_defaults(&vccnf);

            werase(startup_print_win);
            wprintw(startup_print_win, "%s... %s",
                    STR_LOAD_VUURMUUR_CONF_SETTINGS, STR_COK);
            update_panels();
            doupdate();
            config_done = 1;
        } else if (result == VRMR_CNF_E_MISSING_VAR ||
                   result == VRMR_CNF_E_ILLEGAL_VAR ||
                   result == VRMR_CNF_W_MISSING_VAR ||
                   result == VRMR_CNF_W_ILLEGAL_VAR) {
            if (confirm(gettext("Problem with the Vuurmuur_conf settings"),
                        gettext("Do you want to edit the settings now?"),
                        vccnf.color_win_note, vccnf.color_win_note_rev | A_BOLD,
                        1)) {
                /* this prompt the user with the config menu */
                cnfresult = edit_vcconfig();
                if (cnfresult < 0)
                    return (-1);
            } else {
                /* if the user doesn't want to solve the problem we exit if we
                   had an error in case of a warning, we continue
                */
                if (result == VRMR_CNF_E_MISSING_VAR ||
                        result == VRMR_CNF_E_FILE_MISSING)
                    return (-1);
                else {
                    // TODO: print warning to warn the user that the config is
                    // not yet ok?
                    config_done = 1;
                }
            }
        } else if (result == VRMR_CNF_OK) {
            werase(startup_print_win);
            wprintw(startup_print_win, "%s... %s",
                    STR_LOAD_VUURMUUR_CONF_SETTINGS, STR_COK);
            update_panels();
            doupdate();
            config_done = 1;
        } else {
            vrmr_error(-1, VR_ERR,
                    "unknown return code from init_vcconfig. This can't be "
                    "good");
            return (-1);
        }

        if (config_done == 0) {
            werase(startup_print_win);
            wprintw(startup_print_win, "%s...",
                    STR_LOAD_VUURMUUR_CONF_SETTINGS);
            update_panels();
            doupdate();
        }
    }

    /* initialize the config */
    config_done = 0;
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_LOAD_VUURMUUR_CONFIG);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    while (!config_done) {
        result = vrmr_init_config(&vctx->conf);
        if (result == VRMR_CNF_E_UNKNOWN_ERR || result == VRMR_CNF_E_PARAMETER)
            return (-1);
        else if (result == VRMR_CNF_E_FILE_PERMISSION) {
            return (-1);
        } else if (result == VRMR_CNF_E_FILE_MISSING ||
                   result == VRMR_CNF_E_MISSING_VAR ||
                   result == VRMR_CNF_E_ILLEGAL_VAR ||
                   result == VRMR_CNF_W_MISSING_VAR ||
                   result == VRMR_CNF_W_ILLEGAL_VAR) {
            if (confirm(gettext("Problem with the Vuurmuur config"),
                        gettext("Do you want to edit the config now?"),
                        vccnf.color_win_note, vccnf.color_win_note_rev | A_BOLD,
                        1)) {
                /* this prompt the user with the config menu */
                cnfresult = config_menu(&vctx->conf);
                if (cnfresult < 0)
                    return (-1);
            } else {
                /* if the user doesn't want to solve the problem we exit if we
                   had an error in case of a warning, we continue
                */
                if (result == VRMR_CNF_E_MISSING_VAR ||
                        result == VRMR_CNF_E_FILE_MISSING)
                    return (-1);
                else {
                    // TODO: print warning to warn the user that the config is
                    // not yet ok?
                    config_done = 1;
                }
            }
        } else if (result == VRMR_CNF_OK) {
            werase(startup_print_win);
            wprintw(startup_print_win, "%s... %s", STR_LOAD_VUURMUUR_CONFIG,
                    STR_COK);
            update_panels();
            doupdate();
            config_done = 1;
        } else {
            vrmr_error(-1, VR_INTERR,
                    "unknown return code from vrmr_init_config. This can't be "
                    "good");
            return (-1);
        }

        if (config_done == 0) {
            werase(startup_print_win);
            wprintw(startup_print_win, "%s...", STR_LOAD_VUURMUUR_CONFIG);
            update_panels();
            doupdate();
        }
    }

    /* config done, so now we can use logprinting */
    if (vrmr_debug_level >= LOW)
        vrprint.info = vuumuurconf_print_info;
    else
        vrprint.info = vrmr_logprint_info;

    vrprint.debug = vrmr_logprint_debug;
    vrprint.audit = vrmr_logprint_audit;

    /* print that we started */
    vrmr_audit("started: effective user %s (%ld), real user %s (%ld).",
            vctx->user_data.username, (long)vctx->user_data.user,
            vctx->user_data.realusername, (long)vctx->user_data.realuser);

    /* now load the backends */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_LOAD_PLUGINS);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    result = vrmr_backends_load(&vctx->conf, vctx);
    if (result < 0) {
        vrmr_error(-1, VR_ERR, gettext("loading the plugins failed."));
        return (-1);
    }
    werase(startup_print_win);
    wprintw(startup_print_win, "%s... %s", STR_LOAD_PLUGINS, STR_COK);
    update_panels();
    doupdate();

    /* init services */
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_INIT_SERVICES);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    result = vrmr_init_services(vctx, services, reg);
    if (result < 0) {
        vrmr_error(-1, VR_ERR, gettext("intializing the services failed."));
        return (-1);
    }
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s... %s", STR_INIT_SERVICES, STR_COK);
    update_panels();
    doupdate();

    /* init interfaces */
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_INIT_INTERFACES);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    result = vrmr_init_interfaces(vctx, interfaces);
    if (result < 0) {
        vrmr_error(-1, VR_ERR, gettext("intializing the interfaces failed."));
        return (-1);
    }
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s... %s", STR_INIT_INTERFACES, STR_COK);
    update_panels();
    doupdate();

    /* init zones */
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_INIT_ZONES);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    result = vrmr_init_zonedata(vctx, zones, interfaces, reg);
    if (result < 0) {
        vrmr_error(-1, VR_ERR, gettext("intializing the zones failed."));
        return (-1);
    }
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s... %s", STR_INIT_ZONES, STR_COK);
    update_panels();
    doupdate();

    /* init rules */
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_INIT_RULES);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    result = vrmr_rules_init_list(vctx, &vctx->conf, rules, reg);
    if (result < 0) {
        /* TRANSLATORS: max 40 characters */
        werase(startup_print_win);
        wprintw(startup_print_win, "%s... %s", STR_INIT_RULES, STR_CFAILED);
        update_panels();
        doupdate();
    } else {
        /* TRANSLATORS: max 40 characters */
        werase(startup_print_win);
        wprintw(startup_print_win, "%s... %s", STR_INIT_RULES, STR_COK);
        update_panels();
        doupdate();
    }

    /* load the blockfile */
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s...", STR_INIT_BLOCKLIST);
    update_panels();
    doupdate();
    if (vrmr_debug_level > LOW)
        sleep(1);
    result = vrmr_blocklist_init_list(vctx, &vctx->conf, zones, blocklist,
            /*load_ips*/ FALSE, /*no_refcnt*/ FALSE);
    if (result < 0) {
        /* TRANSLATORS: max 40 characters */
        werase(startup_print_win);
        wprintw(startup_print_win, "%s... %s", STR_INIT_BLOCKLIST, STR_CFAILED);
        update_panels();
        doupdate();
    } else {
        /* TRANSLATORS: max 40 characters */
        werase(startup_print_win);
        wprintw(startup_print_win, "%s... %s", STR_INIT_BLOCKLIST, STR_COK);
        update_panels();
        doupdate();
    }

    /*
        try to connect to vuurmuur trough shm
    */
    vuurmuur_shmtable = NULL;
    werase(startup_print_win);
    wprintw(startup_print_win, "%s Vuurmuur...", STR_CONNECTING_TO);
    update_panels();
    doupdate();
    vuurmuur_pid = get_vuurmuur_pid("/var/run/vuurmuur.pid", &vuurmuur_shmid);
    if (vuurmuur_shmid > 0) {
        /* attach to shared memory */
        vuurmuur_shmp = shmat(vuurmuur_shmid, 0, 0);
        if (vuurmuur_shmp == (char *)(-1)) {
            vrmr_error(-1, VR_ERR,
                    gettext("attaching to shared memory failed: %s"),
                    strerror(errno));
        } else {
            vuurmuur_shmtable = (struct vrmr_shm_table *)vuurmuur_shmp;
            vuurmuur_semid = vuurmuur_shmtable->sem_id;

            /* now try to connect to the shared memory */
            if (vrmr_lock(vuurmuur_semid)) {
                vuurmuur_shmtable->configtool.connected = 1;
                (void)snprintf(vuurmuur_shmtable->configtool.name,
                        sizeof(vuurmuur_shmtable->configtool.name),
                        "Vuurmuur_conf %s (user: %s)", version_string,
                        vctx->user_data.realusername);
                (void)strlcpy(vuurmuur_shmtable->configtool.username,
                        vctx->user_data.realusername,
                        sizeof(vuurmuur_shmtable->configtool.username));
                vrmr_unlock(vuurmuur_semid);

                werase(startup_print_win);
                wprintw(startup_print_win, "%s Vuurmuur... %s",
                        STR_CONNECTING_TO, STR_COK);
                update_panels();
                doupdate();
            } else {
                werase(startup_print_win);
                wprintw(startup_print_win, "%s Vuurmuur... %s",
                        STR_CONNECTING_TO, STR_CFAILED);
                update_panels();
                doupdate();
                vuurmuur_shmp = NULL;
            }
        }
    } else {
        /* TRANSLATORS: max 40 characters */
        werase(startup_print_win);
        wprintw(startup_print_win, "%s Vuurmuur... %s", STR_CONNECTING_TO,
                STR_CFAILED);
        update_panels();
        doupdate();
        vuurmuur_shmp = NULL;
    }

    /*
        try to connect to vuurmuur trough shm
    */
    vuurmuurlog_shmtable = NULL;
    /* TRANSLATORS: max 40 characters */
    werase(startup_print_win);
    wprintw(startup_print_win, "%s Vuurmuur_log...", STR_CONNECTING_TO);
    update_panels();
    doupdate();
    vuurmuurlog_pid =
            get_vuurmuur_pid("/var/run/vuurmuur_log.pid", &vuurmuurlog_shmid);
    if (vuurmuurlog_shmid > 0) {
        /* attach to shared memory */
        vuurmuurlog_shmp = shmat(vuurmuurlog_shmid, 0, 0);
        if (vuurmuurlog_shmp == (char *)(-1)) {
            vrmr_error(-1, VR_ERR, "attaching to shared memory failed: %s",
                    strerror(errno));
        } else {
            vuurmuurlog_shmtable = (struct vrmr_shm_table *)vuurmuurlog_shmp;
            vuurmuurlog_semid = vuurmuurlog_shmtable->sem_id;

            vrmr_debug(LOW, "vuurmuur_log: sem_id: %d.", vuurmuurlog_semid);

            /* now try to connect to the shared memory */
            if (vrmr_lock(vuurmuurlog_semid)) {
                vuurmuurlog_shmtable->configtool.connected = 1;
                (void)snprintf(vuurmuurlog_shmtable->configtool.name,
                        sizeof(vuurmuurlog_shmtable->configtool.name),
                        "Vuurmuur_conf %s (user: %s)", version_string,
                        vctx->user_data.realusername);
                (void)strlcpy(vuurmuurlog_shmtable->configtool.username,
                        vctx->user_data.realusername,
                        sizeof(vuurmuurlog_shmtable->configtool.username));
                vrmr_unlock(vuurmuurlog_semid);

                werase(startup_print_win);
                wprintw(startup_print_win, "%s Vuurmuur_log... %s",
                        STR_CONNECTING_TO, STR_COK);
                update_panels();
                doupdate();
            } else {
                werase(startup_print_win);
                wprintw(startup_print_win, "%s Vuurmuur_log... %s",
                        STR_CONNECTING_TO, STR_CFAILED);
                update_panels();
                doupdate();
                vuurmuurlog_shmp = NULL;
            }
        }
    } else {
        werase(startup_print_win);
        wprintw(startup_print_win, "%s Vuurmuur_log... %s", STR_CONNECTING_TO,
                STR_CFAILED);
        update_panels();
        doupdate();
        vuurmuurlog_shmp = NULL;
    }

    /* cleanup */
    del_panel(startup_panel[0]);
    del_panel(startup_panel[1]);

    destroy_win(startup_print_win);
    destroy_win(startup_win);

    update_panels();
    doupdate();

    return (retval);
}
Example #14
0
REGISTER_FILE

#include "moptions.h"
#include "scp.h"
#include "gui.h"

#include "util/aastr.h"
#include "util/helper.h"
#include "other/twconfig.h"
#include "other/dialogs.h"

/*

-	master menu
		client.ini
-			video mode
				exit (exit menu)
				apply (use settings)
				make default (use settings and save)
				screen resolution
				bits per pixel
				fullscreen
				gamma correction?
				custom color filter settings?
-			audio mode
				done (use settings, save, and exit menu)
				cancel (exit menu)
				sound disable
				sound volume
				sound channels?
				music disable
				music volume
				music channels?
				game specific settings?
-			other
-				keyboard configuration
				star depth
				star density
				antialiasing mode
				raw backup images
				alpha blending?
				mouse sensitivity?
-		server.ini
			tic rate
			friendly fire
			shot relativity
			map width
			map height
-		turbo
-		f4turbo

*/

void options_menu (Game *game)
{
	int a;
	while (true) {
		a = tw_popup_dialog(NULL, options_dialog, 0);
		switch (a) {
			default:
			case DIALOG_OPTIONS_DONE:
			{
				return;
			}
			break;
			case DIALOG_OPTIONS_VIDEO:
			{
				video_menu(game);
			}
			break;
			case DIALOG_OPTIONS_AUDIO:
			{
				audio_menu(game);
			}
			break;
			case DIALOG_OPTIONS_CONFIG:
			{
				config_menu(game);
			}
			break;
			case DIALOG_OPTIONS_PHYSICS:
			{
				physics_menu(game);
			}
			break;
			case DIALOG_OPTIONS_DEFAULT:
			{
			}
			break;
		}
	}
	return;
}
Example #15
0
configure() {

void config_menu();

char abt = ' ', new_name[NAMESIZE];
int h,i, good;

pause_override = TRUE;

config_menu();

while( abt != 'X' && (carrDet() || ra.onConsole)){
  mPrintf("Selection: ");
  
  abt = (char) toupper(iChar());
  
  switch(abt) {
   case 'A' :
      if (!ra.expert) tutorial("wide.blb");
      ra.termWidth   = getNumber(" Terminal Width",         15, 132);
      --ra.termWidth;
      break;
   case 'B':   
      if (!ra.expert) tutorial("lineht.blb");
      ra.logBuf.pause_at = (ra.logBuf.pause_at & 0x80) |
        ((char) getNumber ("Screen Height in Lines (11-45): ", 11, 45) & 0x7f);
      break;
   case 'C':   
      if (!ra.expert) tutorial("lf.blb");
      sprintf(format, "\n Linefeed Added: %s\n ", 
              (ra.termLF ^= LFMASK) ? " Yes" : " No ");
      mPrintf(format);        
      break;
   case 'D':
      if (!ra.expert) tutorial("tab.blb");
      sprintf(format, "\n Tabs Sent: %s\n ", 
              (ra.termTab ^= TABMASK) ? " Yes" : " No");
      mPrintf(format);        
      break;
   case 'E':   
      if (!ra.expert) tutorial("lasto.blb");
      sprintf(format, "\n Show Last Old Message with New: %s \n  ", 
              (ra.lasto ^= LOMASK) ? " Yes " : " No");
      mPrintf(format);        
      break;
   case 'F':
      if (!ra.expert) tutorial("hlp.blb");
      sprintf(format, "\n Expert Mode On: %s\n ", 
              (ra.expert ^= EXPERT) ? " Yes " : " No");
      mPrintf(format);        
      break;
   case 'G':
      if (!ra.expert) tutorial("more.blb");
      sprintf(format, "\n Screen Pause is On: %s\n ", 
              (ra.termMore ^= MORE) ? " Yes" : " No");
      mPrintf(format);        
      if (ra.termMore) {
         if (getYesNo (" Pause Between Messages ") ) 
            ra.logBuf.pause_at |= 0x80;
         else
            ra.logBuf.pause_at &= 0x7f;
      }
      else ra.logBuf.pause_at &= 0x7f;         
      break;
   case 'H':
      if (!ra.expert) tutorial("pace.blb");
      sprintf(format, "\n Controlled Typeout is %s\n ",
             (ra.nopace ^= NOPACE) ? "Off" : "On");
      mPrintf(format);
      if (ra.nopace) ra.logBuf.lbnulls |= NOPACE;
      else ra.logBuf.lbnulls &=  ~NOPACE;
      break;
             
   case 'X': break;
   
   default: {
      if( !ra.loggedIn) return; 
      config_menu(); 
      break;
    }  
  }
}
storeLog();

pause_override = FALSE;

return TRUE;
}
Example #16
0
void m_flip_display(void)
{
	bool skip_flip = false;

	if (prompt_for_close_on_next_flip) {
		prompt_for_close_on_next_flip = false;
		prepareForScreenGrab2();
		bool hidden = is_cursor_hidden();
		show_mouse_cursor();
		int r = triple_prompt("", "Really quit game or return to menu?", "", "Menu", "Quit", "Cancel", 2, true);
		if (hidden) {
			hide_mouse_cursor();
		}
		if (r == 0) {
			break_main_loop = true;
		}
		else if (r == 1) {
			do_close_exit_game();
		}
		skip_flip = true;
	}
	else if (show_item_info_on_flip >= 0) {
		int tmp = show_item_info_on_flip;
		show_item_info_on_flip = -1;
		prepareForScreenGrab2();
		showItemInfo(tmp, true);
		skip_flip = true;
	}
	else if (show_player_info_on_flip) {
		show_player_info_on_flip = false;
		prepareForScreenGrab2();
		if (player_to_show_on_flip) {
			showPlayerInfo_ptr(player_to_show_on_flip);
			player_to_show_on_flip = NULL;
		}
		else {
			showPlayerInfo_number(player_number_to_show_on_flip);
		}
		skip_flip = true;
	}
	else if (close_pressed_for_configure) {
		close_pressed_for_configure = false;
		int _dx, _dy, _dw, _dh;
		get_screen_offset_size(&_dx, &_dy, &_dw, &_dh);
		ALLEGRO_STATE state;
		al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_NEW_BITMAP_PARAMETERS);
		al_set_new_bitmap_format(al_get_bitmap_format(tmpbuffer->bitmap));
		al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
		ALLEGRO_BITMAP *tmp = al_create_bitmap(
			al_get_bitmap_width(tmpbuffer->bitmap),
			al_get_bitmap_height(tmpbuffer->bitmap)
		);
		al_set_target_bitmap(tmp);
		al_clear_to_color(black);
		al_draw_bitmap(tmpbuffer->bitmap, 0, 0, 0);
		al_restore_state(&state);
		config_menu();
		int __dx, __dy, __dw, __dh;
		get_screen_offset_size(&__dx, &__dy, &__dw, &__dh);
		al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP);
		al_set_target_bitmap(tmpbuffer->bitmap);
		al_clear_to_color(black);
		al_draw_scaled_bitmap(
			tmp,
			_dx, _dy, _dw, _dh,
			__dx, __dy, __dw, __dh,
			0
		);
		al_restore_state(&state);
		al_destroy_bitmap(tmp);
	}

	if (!skip_flip) {
		al_flip_display();
	}

	int xxx, yyy, www, hhh;
	al_get_clipping_rectangle(&xxx, &yyy, &www, &hhh);
	al_set_clipping_rectangle(
		0, 0,
		al_get_display_width(display),
		al_get_display_height(display)
	);
	m_clear(black);
	al_set_clipping_rectangle(xxx, yyy, www, hhh);

	fps_frames++;
	double elapsed = al_get_time() - fps_counter;
	if (fps_on && elapsed > 2) {
		fps = (int)(round((float)fps_frames/elapsed));
		fps_counter = al_get_time();
		fps_frames = 0;
	}
}