Ejemplo n.º 1
0
/**
 * genopt_window_save(): Save the settings.
 */
static void genopt_window_save(void)
{
	// Save the current options.
	unsigned char curFPSStyle, curMsgStyle;
	
	// System
	Auto_Fix_CS = (Button_GetCheck(chkMisc_AutoFixChecksum) == BST_CHECKED);
	Auto_Pause = (Button_GetCheck(chkMisc_AutoPause) == BST_CHECKED);
	vdraw_set_fast_blur(Button_GetCheck(chkMisc_FastBlur) == BST_CHECKED);
	Show_LED = (Button_GetCheck(chkMisc_SegaCDLEDs) == BST_CHECKED);
	Video.borderColorEmulation = (Button_GetCheck(chkMisc_BorderColorEmulation) == BST_CHECKED);
	Video.pauseTint = (Button_GetCheck(chkMisc_PauseTint) == BST_CHECKED);
	
	// If Auto Pause is enabled, deactivate emulation.
	// If Auto Pause is disabled, activate emulation.
	Settings.Active = !Auto_Pause;
	
	// FPS counter
	vdraw_set_fps_enabled(Button_GetCheck(chkOSD_Enable[0]) == BST_CHECKED);
	
	curFPSStyle = vdraw_get_fps_style() & ~0x18;
	curFPSStyle |= ((Button_GetCheck(chkOSD_DoubleSized[0]) == BST_CHECKED) ? 0x10 : 0x00);
	curFPSStyle |= ((Button_GetCheck(chkOSD_Transparency[0]) == BST_CHECKED) ? 0x08 : 0x00);
	curFPSStyle &= ~0x06;
	curFPSStyle |= state_optColor[0] << 1;
	vdraw_set_fps_style(curFPSStyle);
	
	// Message
	vdraw_set_msg_enabled(Button_GetCheck(chkOSD_Enable[1]) == BST_CHECKED);
	curMsgStyle = vdraw_get_msg_style() & ~0x18;
	curMsgStyle |= ((Button_GetCheck(chkOSD_DoubleSized[1]) == BST_CHECKED) ? 0x10 : 0x00);
	curMsgStyle |= ((Button_GetCheck(chkOSD_Transparency[1]) == BST_CHECKED) ? 0x08 : 0x00);
	curMsgStyle &= ~0x06;
	curMsgStyle |= state_optColor[1] << 1;
	vdraw_set_msg_style(curMsgStyle);
	
	// Intro effect.
	Intro_Style = ComboBox_GetCurSel(cboIntroEffect);
	if (Intro_Style < 0)
		Intro_Style = 0;
	vdraw_set_intro_effect_color(static_cast<unsigned char>(state_optColor[2]));
}
Ejemplo n.º 2
0
/**
 * parse_args(): Parse command line arguments.
 * @param argc Number of command line arguments.
 * @param argv Array of command line arguments.
 * @return Pointer to startup information struct. (MUST BE free()'d BY CALLER!)
 */
Gens_StartupInfo_t* parse_args(int argc, char *argv[])
{
	int c;
	int error = 0;
	int option_index = 0;
	
	// Create the startup information struct.
	Gens_StartupInfo_t *startup = (Gens_StartupInfo_t*)malloc(sizeof(Gens_StartupInfo_t));
	startup->mode = GSM_IDLE;
	startup->filename[0] = 0x00;
#if defined(GENS_OS_WIN32) && !defined(GENS_WIN32_CONSOLE)
	startup->enable_debug_console = 0;
#endif
	
	while (1)
	{
		c = getopt_long(argc, argv, "", long_options, &option_index);
		if (c == -1)
			break;
		if (c == '?')
		{
			error = 1;
			continue;
		}
		
		if (!strcmp(long_options[option_index].name, opt1arg_str[OPT1_GAME].option))
		{
			// Startup ROM.
			if (optarg && optarg[0] != 0x00)
				parse_startup_rom(optarg, startup);
			continue;
		}
		
		// Test string options.
		TEST_OPTION_STRING(opt1arg_str[OPT1_ROMPATH].option, Rom_Dir);
		TEST_OPTION_STRING(opt1arg_str[OPT1_SAVEPATH].option, State_Dir);
		TEST_OPTION_STRING(opt1arg_str[OPT1_SRAMPATH].option, SRAM_Dir);
		TEST_OPTION_STRING(opt1arg_str[OPT1_BRAMPATH].option, BRAM_Dir);
		TEST_OPTION_STRING(opt1arg_str[OPT1_DUMPWAVPATH].option, PathNames.Dump_WAV_Dir);
		TEST_OPTION_STRING(opt1arg_str[OPT1_DUMPGYMPATH].option, PathNames.Dump_GYM_Dir);
		TEST_OPTION_STRING(opt1arg_str[OPT1_SCREENSHOTPATH].option, PathNames.Screenshot_Dir);
		TEST_OPTION_STRING(opt1arg_str[OPT1_GENESISBIOS].option, BIOS_Filenames.MD_TMSS);
		TEST_OPTION_STRING(opt1arg_str[OPT1_USACDBIOS].option, BIOS_Filenames.SegaCD_US);
		TEST_OPTION_STRING(opt1arg_str[OPT1_EUROPECDBIOS].option, BIOS_Filenames.MegaCD_EU);
		TEST_OPTION_STRING(opt1arg_str[OPT1_JAPANCDBIOS].option, BIOS_Filenames.MegaCD_JP);
		TEST_OPTION_STRING(opt1arg_str[OPT1_32X68KBIOS].option, BIOS_Filenames._32X_MC68000);
		TEST_OPTION_STRING(opt1arg_str[OPT1_32XMSH2BIOS].option, BIOS_Filenames._32X_MSH2);
		TEST_OPTION_STRING(opt1arg_str[OPT1_32XSSH2BIOS].option, BIOS_Filenames._32X_SSH2);
		
		TEST_OPTION_ENABLE(optBarg_str[OPTB_GREYSCALE], Greyscale);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_INVERT], Invert_Color);
		//TEST_OPTION_ENABLE(optBarg_str[OPTB_SCALE], Scale_Colors);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_SPRITELIMIT], Sprite_Over);
		TEST_OPTION_NUMERIC(opt1arg_str[OPT1_FRAMESKIP].option, Frame_Skip);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_Z80], Z80_State);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_YM2612], YM2612_Enable);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_YM2612_IMPROVED], YM2612_Improv);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_DAC], DAC_Enable);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_PSG], PSG_Enable);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_PCM], PCM_Enable);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_PWM], PWM_Enable);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_CDDA], CDDA_Enable);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_PERFECT_SYNC], SegaCD_Accurate);
		TEST_OPTION_NUMERIC(opt1arg_str[OPT1_MSH2_SPEED].option, MSH2_Speed);
		TEST_OPTION_NUMERIC(opt1arg_str[OPT1_SSH2_SPEED].option, SSH2_Speed);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_LED], Show_LED);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_FIXCHKSUM], Auto_Fix_CS);
		TEST_OPTION_ENABLE(optBarg_str[OPTB_AUTOPAUSE], Auto_Pause);
		TEST_OPTION_NUMERIC(opt1arg_str[OPT1_RAMCART_SIZE].option, BRAM_Ex_Size);
		
		// Contrast / Brightness
		TEST_OPTION_NUMERIC_SCALE(opt1arg_str[OPT1_CONTRAST].option, Contrast_Level, 100);
		TEST_OPTION_NUMERIC_SCALE(opt1arg_str[OPT1_BRIGHTNESS].option, Brightness_Level, 100);
		
		// Other options that can't be handled by macros.
		if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_STRETCH].enable))
		{
			vdraw_set_stretch(true);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_STRETCH].disable))
		{
			vdraw_set_stretch(false);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_SOUND].enable))
		{
			audio_set_enabled(true);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_SOUND].disable))
		{
			audio_set_enabled(false);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_STEREO].enable))
		{
			audio_set_stereo(true);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_STEREO].disable))
		{
			audio_set_stereo(false);
		}
#ifdef GENS_OS_WIN32
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_SWBLIT].enable))
		{
			vdraw_set_sw_render(true);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_SWBLIT].disable))
		{
			vdraw_set_sw_render(false);
		}
#endif /* GENS_OS_WIN32 */
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_FASTBLUR].enable))
		{
			vdraw_set_fast_blur(true);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_FASTBLUR].disable))
		{
			vdraw_set_fast_blur(false);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_FPS].enable))
		{
			vdraw_set_fps_enabled(true);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_FPS].disable))
		{
			vdraw_set_fps_enabled(false);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_MSG].enable))
		{
			vdraw_set_msg_enabled(true);
		}
		else if (!strcmp(long_options[option_index].name, optBarg_str[OPTB_MSG].disable))
		{
			vdraw_set_fps_enabled(false);
		}
		else if (!strcmp(long_options[option_index].name, opt0arg_str[OPT0_FS].option))
		{
			vdraw_set_fullscreen(true);
		}
		else if (!strcmp(long_options[option_index].name, opt0arg_str[OPT0_WINDOW].option))
		{
			vdraw_set_fullscreen(false);
		}
		else if (!strcmp(long_options[option_index].name, opt1arg_str[OPT1_SOUNDRATE].option))
		{
			int rate = atoi(optarg);
			
			if (rate == 11025 || rate == 22050 || rate == 44100)
			{
				audio_set_sound_rate(rate);
			}
			else
			{
				fprintf(stderr, "Invalid sound rate: %d\n", rate);
				exit(1);
			}
		}
		else if (!strcmp(long_options[option_index].name, opt0arg_str[OPT0_QUICKEXIT].option))
		{
			Quick_Exit = 1;
		}
#ifdef GENS_CDROM
		else if (!strcmp(long_options[option_index].name, opt0arg_str[OPT0_BOOT_CD].option))
		{
			// Boot SegaCD on startup.
			startup->mode = GSM_BOOT_CD;
		}
#endif
#if defined(GENS_OS_WIN32) && !defined(GENS_WIN32_CONSOLE)
		else if (!strcmp(long_options[option_index].name, opt0arg_str[OPT0_DEBUG_CONSOLE].option))
		{
			// Enable Debug console.
			startup->enable_debug_console = 1;
		}
#endif
#if defined(GENS_OS_WIN32)
		else if (!strcmp(long_options[option_index].name, opt0arg_str[OPT0_ANSI].option))
		{
			// ANSI mode. This is checked by libgsft_w32u,
			// so we don't have to do anything here.
		}
#endif
		else if (!strcmp(long_options[option_index].name, opt0arg_str[OPT0_HELP].option))
		{
			_usage(argv[0]);
		}
		else 
		{
			_usage(argv[0]);
		}
	}
	
	// Make sure contrast and brightness are in range.
	if (Contrast_Level < 0)
		Contrast_Level = 0;
	else if (Contrast_Level > 200)
		Contrast_Level = 200;
		
	if (Brightness_Level < 0)
		Brightness_Level = 0;
	else if (Brightness_Level > 200)
		Brightness_Level = 200;
	
	if (optind < argc - 1 || error)
	{
		fputs("Arguments not understood.\n", stderr);
		_usage(argv[0]);
	}
	else if (optind == (argc - 1))
	{
		// Startup ROM.
		if (argv[optind] && argv[optind][0] != 0x00)
			parse_startup_rom(argv[optind], startup);
	}
	
	// Return the startup information.
	return startup;
}