Esempio n. 1
0
/* set_config_hex:
 *  Writes a hexadecimal integer to the configuration file.
 */
void set_config_hex(char *section, char *name, int val)
{
   if (val >= 0) {
      char buf[32];
      sprintf(buf, "%X", val);
      set_config_string(section, name, buf);
   }
   else
      set_config_string(section, name, "-1");
}
Esempio n. 2
0
/* set_config_oct:
 *  Writes a hexadecimal integer to the configuration file.
 */
void set_config_oct(char *section, char *name, int size, int val)
{
   if (val >= 0) {
      char buf[16];
      char fmt[8];
      sprintf(fmt, "%%0%do", size);
      sprintf(buf, fmt, val);
      set_config_string(section, name, buf);
   }
   else
      set_config_string(section, name, "-1");
}
Esempio n. 3
0
/*
 * gets some boolean config value.
 * 0 = false, >0 = true, <0 = auto
 * the shortcut can only be used on the commandline
 */
static int get_bool (char *section, char *option, char *shortcut, int def)
{
	char *yesnoauto;
	int res, i;

	res = def;

	if (ignorecfg) goto cmdline;

	/* look into mame.cfg, [section] */
	if (def == 0)
		yesnoauto = get_config_string(section, option, "no");
	else if (def > 0)
		yesnoauto = get_config_string(section, option, "yes");
	else /* def < 0 */
		yesnoauto = get_config_string(section, option, "auto");

	/* if the option doesn't exist in the cfgfile, create it */
	if (get_config_string(section, option, "#") == "#")
		set_config_string(section, option, yesnoauto);

	/* look into mame.cfg, [gamename] */
	yesnoauto = get_config_string((char *)drivers[game]->name, option, yesnoauto);

	/* also take numerical values instead of "yes", "no" and "auto" */
	if      (stricmp(yesnoauto, "no"  ) == 0) res = 0;
	else if (stricmp(yesnoauto, "yes" ) == 0) res = 1;
	else if (stricmp(yesnoauto, "auto") == 0) res = -1;
	else    res = atoi (yesnoauto);

cmdline:
	/* check the commandline */
	for (i = 1; i < mame_argc; i++)
	{
		if (mame_argv[i][0] != '-') continue;
		/* look for "-option" */
		if (stricmp(&mame_argv[i][1], option) == 0)
			res = 1;
		/* look for "-shortcut" */
		if (shortcut && (stricmp(&mame_argv[i][1], shortcut) == 0))
			res = 1;
		/* look for "-nooption" */
		if (strnicmp(&mame_argv[i][1], "no", 2) == 0)
		{
			if (stricmp(&mame_argv[i][3], option) == 0)
				res = 0;
			if (shortcut && (stricmp(&mame_argv[i][3], shortcut) == 0))
				res = 0;
		}
		/* look for "-autooption" */
		if (strnicmp(&mame_argv[i][1], "auto", 4) == 0)
		{
			if (stricmp(&mame_argv[i][5], option) == 0)
				res = -1;
			if (shortcut && (stricmp(&mame_argv[i][5], shortcut) == 0))
				res = -1;
		}
	}
	return res;
}
Esempio n. 4
0
static char *get_string (char *section, char *option, char *shortcut, char *def)
{
	char *res;
	int i;

	res = def;

	if (!ignorecfg)
	{
		/* if the option does not exist, create it */
		if (get_config_string (section, option, "#") == "#" )
			set_config_string (section, option, def);

		/* look into mame.cfg, [section] */
		res = get_config_string(section, option, def);

		/* look into mame.cfg, [gamename] */
		res = get_config_string((char*)drivers[game]->name, option, res);
	}

	/* get it from the commandline */
	for (i = 1; i < mame_argc; i++)
	{
		if (mame_argv[i][0] != '-')
			continue;

		if ((stricmp(&mame_argv[i][1], option) == 0) ||
			(shortcut && (stricmp(&mame_argv[i][1], shortcut)  == 0)))
		{
			i++;
			if (i < mame_argc) res = mame_argv[i];
		}
	}
	return res;
}
Esempio n. 5
0
/* Pops a dialog asking for language. Returns -1 if no object was selected.
 * Else returns zero and writes in string the ID of the selected language.
 */
void select_language(void)
{
   int f = -1;
   const char *lang = "en"; /* default language */
   
   set_palette(desktop_palette);
   clear_bitmap(virtual_screen);
   stretch_virtual_screen();
   _retrieve_available_languages();

   if (!_num_available_languages) {
      //alert("No languages", "to choose from!", "Will use english", "Oh", 0, 'o', 0);
      goto finish;
   }

   while ((f = virtual_do_dialog(_select_lang_dialog, 0)) < 0);
   lang = _available_languages[_select_lang_dialog[0].d1*2];

   finish:
   TRACE("select_language: '%s'\n", lang);
   set_config_string("system", "language", lang);
   reload_config_texts(0);
   text_mode(-1);
   _free_available_languages();

   clear_bitmap(virtual_screen);
   stretch_virtual_screen();
}
Esempio n. 6
0
DataRecovery::DataRecovery(Context* context)
  : m_tempDir(NULL)
  , m_backup(NULL)
  , m_context(context)
{
  // Check if there is already data to recover
  const base::string existent_data_path = get_config_string("DataRecovery", "Path", "");
  if (!existent_data_path.empty() &&
      base::directory_exists(existent_data_path)) {
    // Load the backup data.
    m_tempDir = new base::TempDir();
    m_tempDir->attach(existent_data_path);
    m_backup = new Backup(existent_data_path);
  }
  else {
    // Create a new directory to save the backup information.
    m_tempDir = new base::TempDir(PACKAGE);
    m_backup = new Backup(m_tempDir->path());

    set_config_string("DataRecovery", "Path", m_tempDir->path().c_str());
    flush_config_file();
  }

  m_context->addObserver(this);
}
Esempio n. 7
0
RecentFiles::~RecentFiles()
{
  char buf[512];

  int c = 0;
  for (auto const& filename : m_files) {
    sprintf(buf, "Filename%02d", c);
    set_config_string("RecentFiles", buf, filename.c_str());
    c++;
  }

  c = 0;
  for (auto const& path : m_paths) {
    sprintf(buf, "Path%02d", c);
    set_config_string("RecentPaths", buf, path.c_str());
    c++;
  }
}
Esempio n. 8
0
/* Builds a string corresponding to the options set in 'opt'
 * and writes in the config file
 */
static void build_settings(int opt, char *section, char *name) {
	char buf[2048];

	usetc(buf, 0);

	if (opt & AGL_ALLEGRO_FORMAT)
		ustrcat(buf, "allegro_format ");
	if (opt & AGL_RED_DEPTH)
		ustrcat(buf, "red_depth ");
	if (opt & AGL_GREEN_DEPTH)
		ustrcat(buf, "green_depth ");
	if (opt & AGL_BLUE_DEPTH)
		ustrcat(buf, "blue_depth ");
	if (opt & AGL_ALPHA_DEPTH)
		ustrcat(buf, "alpha_depth ");
	if (opt & AGL_COLOR_DEPTH)
		ustrcat(buf, "color_depth ");
	if (opt & AGL_ACC_RED_DEPTH)
		ustrcat(buf, "accum_red_depth ");
	if (opt & AGL_ACC_GREEN_DEPTH)
		ustrcat(buf, "accum_green_depth ");
	if (opt & AGL_ACC_BLUE_DEPTH)
		ustrcat(buf, "accum_blue_depth ");
	if (opt & AGL_ACC_ALPHA_DEPTH)
		ustrcat(buf, "accum_alpha_depth ");
	if (opt & AGL_DOUBLEBUFFER)
		ustrcat(buf, "double_buffer ");
	if (opt & AGL_STEREO)
		ustrcat(buf, "stereo_display ");
	if (opt & AGL_AUX_BUFFERS)
		ustrcat(buf, "aux_buffers ");
	if (opt & AGL_Z_DEPTH)
		ustrcat(buf, "z_depth ");
	if (opt & AGL_STENCIL_DEPTH)
		ustrcat(buf, "stencil_depth ");
	if (opt & AGL_WINDOW_X)
		ustrcat(buf, "window_x ");
	if (opt & AGL_WINDOW_Y)
		ustrcat(buf, "window_y ");
	if (opt & AGL_FULLSCREEN)
		ustrcat(buf, "fullscreen ");
	if (opt & AGL_WINDOWED)
		ustrcat(buf, "windowed ");
	if (opt & AGL_VIDEO_MEMORY_POLICY)
		ustrcat(buf, "video_memory_policy ");
	if (opt & AGL_SAMPLE_BUFFERS)
		ustrcat(buf, "sample_buffers ");
	if (opt & AGL_SAMPLES)
		ustrcat(buf, "samples ");
	if (opt & AGL_FLOAT_COLOR)
		ustrcat(buf, "float_color ");
	if (opt & AGL_FLOAT_Z)
		ustrcat(buf, "float_depth ");
		
	set_config_string(section, name, buf);
}
Esempio n. 9
0
/* handle the save command */
int saver()
{
   char buf[FILENAME_LENGTH];

   strcpy(buf, config_file);

   if (file_select_ex("Save Keyboard Config", buf, "CFG", sizeof(buf), 0, 0)) {
      if ((stricmp(config_file, buf) != 0) && (exists(buf))) {
	 if (alert("Overwrite existing file?", NULL, NULL, "Yes", "Cancel", 'y', 27) != 1)
	    return D_REDRAW;
      }

      strlwr(buf);
      strcpy(config_file, buf);

      push_config_state();
      set_config_file(buf);

      set_config_string(NULL, "keyboard_name", keyboard_name);

      set_config_int("key_escape", "accent1", _key_accent1);
      set_config_int("key_escape", "accent2", _key_accent2);
      set_config_int("key_escape", "accent3", _key_accent3);
      set_config_int("key_escape", "accent4", _key_accent4);
      set_config_int("key_escape", "accent1_flag", _key_accent1_flag);
      set_config_int("key_escape", "accent2_flag", _key_accent2_flag);
      set_config_int("key_escape", "accent3_flag", _key_accent3_flag);
      set_config_int("key_escape", "accent4_flag", _key_accent4_flag);

      save_table(_key_ascii_table,               orig_key_ascii_table,               "key_ascii");
      save_table(_key_capslock_table,            orig_key_capslock_table,            "key_capslock");
      save_table(_key_shift_table,               orig_key_shift_table,               "key_shift");
      save_table(_key_control_table,             orig_key_control_table,             "key_control");

      if (split_altgr) {
         save_table(_key_altgr_lower_table,      orig_key_altgr_lower_table,         "key_altgr_lower");
         save_table(_key_altgr_upper_table,      orig_key_altgr_upper_table,         "key_altgr_upper");
      }
      else {
         save_table(_key_altgr_lower_table,      orig_key_altgr_lower_table,         "key_altgr");
      }

      save_table(_key_accent1_lower_table,       orig_key_accent1_lower_table,       "key_accent1_lower");
      save_table(_key_accent1_upper_table,       orig_key_accent1_upper_table,       "key_accent1_upper");
      save_table(_key_accent2_lower_table,       orig_key_accent2_lower_table,       "key_accent2_lower");
      save_table(_key_accent2_upper_table,       orig_key_accent2_upper_table,       "key_accent2_upper");
      save_table(_key_accent3_lower_table,       orig_key_accent3_lower_table,       "key_accent3_lower");
      save_table(_key_accent3_upper_table,       orig_key_accent3_upper_table,       "key_accent3_upper");
      save_table(_key_accent4_lower_table,       orig_key_accent4_lower_table,       "key_accent4_lower");
      save_table(_key_accent4_upper_table,       orig_key_accent4_upper_table,       "key_accent4_upper");

      pop_config_state();
   }

   return D_REDRAW;
}
Esempio n. 10
0
DataRecovery::~DataRecovery()
{
  m_context->removeObserver(this);

  delete m_backup;

  if (m_tempDir) {
    delete m_tempDir;
    set_config_string("DataRecovery", "Path", "");
  }
}
Esempio n. 11
0
RecentFiles::~RecentFiles()
{
  char buf[512];

  int c = 0;
  for (const_iterator it = files_begin(); it != files_end(); ++it) {
    const char* filename = it->c_str();
    sprintf(buf, "Filename%02d", c);
    set_config_string("RecentFiles", buf, filename);
    c++;
  }

  c = 0;
  for (const_iterator it = paths_begin(); it != paths_end(); ++it) {
    const char* path = it->c_str();
    sprintf(buf, "Path%02d", c);
    set_config_string("RecentPaths", buf, path);
    c++;
  }
}
Esempio n. 12
0
/* writes a specific keymapping table to the config file */
void save_table(unsigned short *table, unsigned short *origtable, char *section)
{
   char name[80];
   int i;

   for (i=0; i<KEY_MAX; i++) {
      sprintf(name, "key%d", i);
      if (table[i] != origtable[i])
	 set_config_int(section, name, table[i]);
      else
	 set_config_string(section, name, NULL);
   }
}
void CSerialPortItem::Save()
{
    AnsiString s;
    TframSerialPort *frm;
    frm = (TframSerialPort*)m_PropertyPage;
    frm->Tag = (int)this;
    s = frm->Validate();
    char buf[32];
    sprintf(buf, "port%d", m_PortNo);
    if(set_config_string(&key, "ports", buf, s.c_str(), 500)){
        ReloadContents();
    }
}
Esempio n. 14
0
void save_spacesprite(SpaceSprite *ss, const char *spritename, const char *destination, const char *extension)
{
	STACKTRACE;
	int i;
	char buf[512];

	if (!ss)
		return;

	if (ss->frames()) {
		for (i = 0; i < ss->frames(); i += 1) {
			if (strchr(extension, '.')) {
				sprintf(buf, "tmp/%s%03d%s", spritename, i, extension);
			} else {
				sprintf(buf, "tmp/%s%03d.bmp", spritename, i);
			}

			save_bitmap(buf, ss->get_bitmap(i), NULL);
		}

	}

	sprintf(buf, "tmp/%s.ini", spritename);
	tw_set_config_file(buf);
	set_config_string("Main", "Type", "SpaceSprite");
	set_config_int("SpaceSprite", "Number", (int)ss->frames());
	set_config_int("SpaceSprite", "Width", (int)ss->width());
	set_config_int("SpaceSprite", "Height", (int)ss->height());
	set_config_string("SpaceSprite", "SubType", "Normal");
	set_config_string("SpaceSprite", "Extension", extension);
	chdir("tmp");
	sprintf(buf, "dat ../ships/%s.dat -k -a *", destination);
	//	system(buf);
	sprintf(buf, "move * ..\\ships\\%s", destination);
	system(buf);
	chdir("..");
	return;
}
Esempio n. 15
0
void Init_INI(void)
{
    unsigned long cver, iniver;

    // initialize the system - create the ini file if necessary
    if (!exists(CONFIG_FILE))
    {
	set_config_file(CONFIG_FILE);
	set_config_int("System", "Version_Major", NEWINI_MAJOR);
	set_config_int("System", "Version_Minor", NEWINI_MINOR);
	set_config_string("System", "Info", CONFIG_INFO);
	set_config_string("System", "Author", CONFIG_AUTHOR);
	set_config_string("System", "ROMPath", DEFAULT_PATH);
	Save_INI();
    } else {
	set_config_file(CONFIG_FILE);
	Load_INI();
    }

    ini_version_major = get_config_int("System", 
				    "Version_Major", ini_version_major);
    ini_version_minor = get_config_int("System", 
				    "Version_Minor", ini_version_minor);

    cver = ((NEWINI_MAJOR)<<16) + NEWINI_MINOR;
    iniver = ((ini_version_major)<<16) + ini_version_minor;

    if (cver < iniver)
    {
	printf("ERROR: The \"%s\" file is newer than TURACO.\n"
	     "       There might be problems when running TURACO!\n"
	     "       Winging it!   Press any key to continue...\n",
	     CONFIG_FILE);
	(void)getch();
    }
}
Esempio n. 16
0
// saves the current palette
void SavePalette(int NumCols, int PalIndex, int CurrentPal, int IniFilePalNum)
{
   char * Buffer;
   char NumBuf[10];
   int j;

   // This buffer will hold number like the following:
   // 4 255 255 255  255 255 255
   // Note the 10 allows for the first number, space and a bit of overhead
   // the 13 allows for "255 255 255  ".
   // This is dynamically allocated as we don't know how much space is required
   // until we know the number of colours
   Buffer = malloc(10 + (NumCols * 13));
   if (Buffer == NULL)
   {
      alert("Error", "Failed to save palette!", NULL,  "&Okay", NULL, 'O', 0);
      return;
   }
   sprintf(Buffer, "%d ", NumCols);

   for (j = 0; j < NumCols; j ++)
   {
      int Offset = NumCols * CurrentPal;

      sprintf(NumBuf, "%d ", ColPalettes[PalIndex][j + Offset].r);
      strcat(Buffer, NumBuf);
      sprintf(NumBuf, "%d ", ColPalettes[PalIndex][j + Offset].g);
      strcat(Buffer, NumBuf);
      sprintf(NumBuf, "%d  ", ColPalettes[PalIndex][j + Offset].b);
      strcat(Buffer, NumBuf);
   }

   // now write out the buffer
   sprintf(NumBuf, "Palette%d", IniFilePalNum);

   push_config_state();
   set_config_file(INI_Driver_Path);
   set_config_string("Palette", NumBuf, Buffer);
   pop_config_state();

   free (Buffer);
}
Esempio n. 17
0
void NormalGame::init(Log *_log)
{
	STACKTRACE;
	Game::init(_log);

	team_table_size = 0;

	view->window->locate(0,0,0,0,0,0.9,0,1);

	tw_delete_file(home_ini_full_path("tmp.ini"));
	tw_delete_file(home_ini_full_path("fleets.tmp"));
	tw_set_config_file(home_ini_full_path("tmp.ini"));
	set_config_string (NULL, "Ignorethis", "");
	if (!log->playback) init_players();
	log_file(home_ini_full_path("tmp.ini"));
	if (log->playback) {
		for (int i = 0; true; i += 1) {
			char buffy[64];
			sprintf(buffy, "Player%d", i + 1);
			log_file(home_ini_full_path("tmp.ini"));
			const char *type = get_config_string(buffy, "Type", NULL);
			if (!type) break;
			const char *name = get_config_string(buffy, "Name", buffy);
			int channel = get_config_int(buffy, "Channel", -2);
			int ti = get_config_int(buffy, "Team", 0);
			add_player(create_control(channel, type), ti, name, buffy);
			player_fleet[i]->load(NULL, buffy);
			player_fleet[i]->save("fleets.tmp", buffy);
		}
	}

	prepare();
	init_objects();

	next_choose_new_ships_time = game_time + 200;

	// team and health indicators.
	indteamtoggle = 0;
	indhealthtoggle = 0;

	return;
}
Esempio n. 18
0
void Save_INI(void)
{
    // save out all internal bits to be stored
    //set_config_int("System", "Maped_Stretch", display_stretch);
    if (font == &my_new_font)
	set_config_int("System", "Font", 1);
    else
	set_config_int("System", "Font", 0);


    set_config_int("System", "H_Res", gfx_hres);
    set_config_int("System", "V_Res", gfx_vres);

    set_config_on_off("System", "Driver_Subdirs", drv_subdirs);
    
    set_config_on_off("System", "Troll_Magic", troll_magic);

    //set_config_string("User", "Default_Driver", InitGameName);

    // write out the path for the ROMs
    set_config_string("System", "ROMPath", ROMPath);
}
Esempio n. 19
0
void keyswitch(int keyswitch_lang)
{
	push_config_state();
	set_config_file(F("$(home)/ufo2000.ini"));

	switch (keyswitch_lang) {
		case 0: {
			const char *current_keyboard = get_config_string("system", "keyboard", "us");
			const char *primary_keyboard = get_config_string("system", "primary_keyboard", "us");
			const char *secondary_keyboard = get_config_string("system", "secondary_keyboard", "ru");
			if (strcmp(current_keyboard, primary_keyboard) == 0)
				set_config_string("system", "keyboard", secondary_keyboard);
			else
				set_config_string("system", "keyboard", primary_keyboard);
			break;
		}
		case KEY_E: 
			set_config_string("system", "keyboard", "us"); 
			break;
		case KEY_R: 
			set_config_string("system", "keyboard", "ru"); 
			break;
		case KEY_B: 
			set_config_string("system", "keyboard", "by"); 
			break;
		case KEY_P: 
			set_config_string("system", "keyboard", "pl"); 
			break;
		case KEY_D: 
			set_config_string("system", "keyboard", "de"); 
			break;
		default: 
			pop_config_state(); 
			return;
	}
	
	clear_keybuf();
	remove_keyboard();
	install_keyboard();
	pop_config_state();
}
Esempio n. 20
0
/* set_config_float:
 *  Writes a float to the configuration file.
 */
void set_config_float(char *section, char *name, float val)
{
   char buf[32];
   sprintf(buf, "%f", val);
   set_config_string(section, name, buf);
}
Esempio n. 21
0
void parse_cmdline (int argc, char **argv, int game_index)
{
	static float f_beam, f_flicker;
	char *resolution;
	char *vesamode;
	char *joyname;
	char tmpres[10];
	int i;
	char *tmpstr;
	char *monitorname;

	mame_argc = argc;
	mame_argv = argv;
	game = game_index;


	/* force third mouse button emulation to "no" otherwise Allegro will default to "yes" */
	set_config_string(0,"emulate_three","no");

	/* read graphic configuration */
	scanlines   = get_bool   ("config", "scanlines",    NULL,  1);
	stretch     = get_bool   ("config", "stretch",		NULL,  1);
	options.use_artwork = get_bool   ("config", "artwork",	NULL,  1);
	options.use_samples = get_bool   ("config", "samples",	NULL,  1);
	video_sync  = get_bool   ("config", "vsync",        NULL,  0);
	wait_vsync  = get_bool   ("config", "waitvsync",    NULL,  0);
	use_triplebuf = get_bool ("config", "triplebuffer",	NULL,  0);
	use_tweaked = get_bool   ("config", "tweak",		NULL,  0);
	vesamode    = get_string ("config", "vesamode",	NULL,	"vesa3");
	use_mmx		= get_bool   ("config", "mmx", 		NULL,	-1);
	use_dirty	= get_bool	 ("config", "dirty",	NULL,	-1);
	options.antialias   = get_bool   ("config", "antialias",    NULL,  1);
	options.translucency = get_bool    ("config", "translucency", NULL, 1);

	vgafreq     = get_int    ("config", "vgafreq",      NULL,  -1);
	always_synced = get_bool ("config", "alwayssynced", NULL, 0);

	tmpstr             = get_string ("config", "depth", NULL, "auto");
	options.color_depth = atoi(tmpstr);
	if (options.color_depth != 8 && options.color_depth != 16) options.color_depth = 0;	/* auto */

	skiplines   = get_int    ("config", "skiplines",    NULL, 0);
	skipcolumns = get_int    ("config", "skipcolumns",  NULL, 0);
	f_beam      = get_float  ("config", "beam",         NULL, 1.0);
	if (f_beam < 1.0) f_beam = 1.0;
	if (f_beam > 16.0) f_beam = 16.0;
	f_flicker   = get_float  ("config", "flicker",      NULL, 0.0);
	if (f_flicker < 0.0) f_flicker = 0.0;
	if (f_flicker > 100.0) f_flicker = 100.0;
	osd_gamma_correction = get_float ("config", "gamma",   NULL, 1.0);
	if (osd_gamma_correction < 0.5) osd_gamma_correction = 0.5;
	if (osd_gamma_correction > 2.0) osd_gamma_correction = 2.0;

	tmpstr             = get_string ("config", "frameskip", "fs", "auto");
	if (!stricmp(tmpstr,"auto"))
	{
		frameskip = 0;
		autoframeskip = 1;
	}
	else
	{
		frameskip = atoi(tmpstr);
		autoframeskip = 0;
	}
	options.norotate  = get_bool ("config", "norotate",  NULL, 0);
	options.ror       = get_bool ("config", "ror",       NULL, 0);
	options.rol       = get_bool ("config", "rol",       NULL, 0);
	options.flipx     = get_bool ("config", "flipx",     NULL, 0);
	options.flipy     = get_bool ("config", "flipy",     NULL, 0);

	/* read sound configuration */
	soundcard           = get_int  ("config", "soundcard",  NULL, -1);
	options.use_emulated_ym3812 = !get_bool ("config", "ym3812opl",  NULL,  0);
	options.samplerate = get_int  ("config", "samplerate", "sr", 22050);
	if (options.samplerate < 5000) options.samplerate = 5000;
	if (options.samplerate > 50000) options.samplerate = 50000;
	usestereo           = get_bool ("config", "stereo",  NULL,  1);
	attenuation         = get_int  ("config", "volume",  NULL,  0);
	if (attenuation < -32) attenuation = -32;
	if (attenuation > 0) attenuation = 0;

	/* read input configuration */
	use_mouse = get_bool   ("config", "mouse",   NULL,  1);
	joyname   = get_string ("config", "joystick", "joy", "none");
	use_hotrod = 0;
	if (get_bool  ("config", "hotrod",   NULL,  0)) use_hotrod = 1;
	if (get_bool  ("config", "hotrodse",   NULL,  0)) use_hotrod = 2;

	/* misc configuration */
	options.cheat      = get_bool ("config", "cheat", NULL, 0);
	options.mame_debug = get_bool ("config", "debug", NULL, 0);
	cheatfile  = get_string ("config", "cheatfile", "cf", "CHEAT.DAT");    /* JCK 980917 */

 	#ifndef MESS
 	history_filename  = get_string ("config", "historyfile", NULL, "HISTORY.DAT");    /* JCK 980917 */
 	#else
 	history_filename  = get_string ("config", "historyfile", NULL, "SYSINFO.DAT");
 	#endif

	mameinfo_filename  = get_string ("config", "mameinfofile", NULL, "MAMEINFO.DAT");    /* JCK 980917 */

	/* get resolution */
	resolution  = get_string ("config", "resolution", NULL, "auto");

	/* set default subdirectories */
	nvdir      = get_string ("directory", "nvram",   NULL, "NVRAM");
	hidir      = get_string ("directory", "hi",      NULL, "HI");
	cfgdir     = get_string ("directory", "cfg",     NULL, "CFG");
	screenshotdir = get_string ("directory", "snap",     NULL, "SNAP");
	memcarddir = get_string ("directory", "memcard", NULL, "MEMCARD");
	stadir     = get_string ("directory", "sta",     NULL, "STA");
	artworkdir = get_string ("directory", "artwork", NULL, "ARTWORK");
 	#ifdef MESS
 		crcdir = get_string ("directory", "crc", NULL, "CRC");
 	#endif

	/* get tweaked modes info */
	tw224x288_h			= get_int ("tweaked", "224x288_h",              NULL, 0x5f);
	tw224x288_v     	= get_int ("tweaked", "224x288_v",              NULL, 0x54);
	tw240x256_h     = get_int ("tweaked", "240x256_h",              NULL, 0x67);
	tw240x256_v     = get_int ("tweaked", "240x256_v",              NULL, 0x23);
	tw256x240_h     = get_int ("tweaked", "256x240_h",              NULL, 0x55);
	tw256x240_v     = get_int ("tweaked", "256x240_v",              NULL, 0x43);
	tw256x256_h     = get_int ("tweaked", "256x256_h",              NULL, 0x6c);
	tw256x256_v     = get_int ("tweaked", "256x256_v",              NULL, 0x23);
	tw256x256_hor_h = get_int ("tweaked", "256x256_hor_h",  NULL, 0x55);
	tw256x256_hor_v = get_int ("tweaked", "256x256_hor_v",  NULL, 0x60);
	tw288x224_h     = get_int ("tweaked", "288x224_h",              NULL, 0x5f);
	tw288x224_v     = get_int ("tweaked", "288x224_v",              NULL, 0x0c);
	tw240x320_h             = get_int ("tweaked", "240x320_h",              NULL, 0x5a);
	tw240x320_v             = get_int ("tweaked", "240x320_v",              NULL, 0x8c);
	tw320x240_h             = get_int ("tweaked", "320x240_h",              NULL, 0x5f);
	tw320x240_v             = get_int ("tweaked", "320x240_v",              NULL, 0x0c);
	tw336x240_h             = get_int ("tweaked", "336x240_h",              NULL, 0x5f);
	tw336x240_v             = get_int ("tweaked", "336x240_v",              NULL, 0x0c);
	tw384x224_h             = get_int ("tweaked", "384x224_h",              NULL, 0x6c);
	tw384x224_v             = get_int ("tweaked", "384x224_v",              NULL, 0x0c);
	tw384x240_h             = get_int ("tweaked", "384x240_h",              NULL, 0x6c);
	tw384x240_v             = get_int ("tweaked", "384x240_v",              NULL, 0x0c);
	tw384x256_h             = get_int ("tweaked", "384x256_h",              NULL, 0x6c);
	tw384x256_v             = get_int ("tweaked", "384x256_v",              NULL, 0x23);

	/* Get 15.75KHz tweak values */
	tw224x288arc_h          = get_int ("tweaked", "224x288arc_h",   NULL, 0x5d);
	tw224x288arc_v          = get_int ("tweaked", "224x288arc_v",   NULL, 0x38);
	tw288x224arc_h          = get_int ("tweaked", "288x224arc_h",   NULL, 0x5d);
	tw288x224arc_v          = get_int ("tweaked", "288x224arc_v",   NULL, 0x09);
	tw256x240arc_h          = get_int ("tweaked", "256x240arc_h",   NULL, 0x5d);
	tw256x240arc_v          = get_int ("tweaked", "256x240arc_v",   NULL, 0x09);
	tw256x256arc_h          = get_int ("tweaked", "256x256arc_h",   NULL, 0x5d);
	tw256x256arc_v          = get_int ("tweaked", "256x256arc_v",   NULL, 0x17);
	tw320x240arc_h          = get_int ("tweaked", "320x240arc_h",   NULL, 0x69);
	tw320x240arc_v          = get_int ("tweaked", "320x240arc_v",   NULL, 0x09);
	tw320x256arc_h          = get_int ("tweaked", "320x256arc_h",   NULL, 0x69);
	tw320x256arc_v          = get_int ("tweaked", "320x256arc_v",   NULL, 0x17);
	tw352x240arc_h          = get_int ("tweaked", "352x240arc_h",   NULL, 0x6a);
	tw352x240arc_v          = get_int ("tweaked", "352x240arc_v",   NULL, 0x09);
	tw352x256arc_h          = get_int ("tweaked", "352x256arc_h",   NULL, 0x6a);
	tw352x256arc_v          = get_int ("tweaked", "352x256arc_v",   NULL, 0x17);
	tw368x224arc_h          = get_int ("tweaked", "368x224arc_h",   NULL, 0x6a);
	tw368x224arc_v          = get_int ("tweaked", "368x224arc_v",   NULL, 0x09);
	tw368x240arc_h          = get_int ("tweaked", "368x240arc_h",   NULL, 0x6a);
	tw368x240arc_v          = get_int ("tweaked", "368x240arc_v",   NULL, 0x09);
	tw368x256arc_h          = get_int ("tweaked", "368x256arc_h",   NULL, 0x6a);
	tw368x256arc_v          = get_int ("tweaked", "368x256arc_v",   NULL, 0x17);
	tw512x224arc_h          = get_int ("tweaked", "512x224arc_h",   NULL, 0xbf);
	tw512x224arc_v          = get_int ("tweaked", "512x224arc_v",   NULL, 0x09);
	tw512x256arc_h          = get_int ("tweaked", "512x256arc_h",   NULL, 0xbf);
	tw512x256arc_v          = get_int ("tweaked", "512x256arc_v",   NULL, 0x17);
	tw512x448arc_h          = get_int ("tweaked", "512x448arc_h",   NULL, 0xbf);
	tw512x448arc_v          = get_int ("tweaked", "512x448arc_v",   NULL, 0x09);
	tw512x512arc_h          = get_int ("tweaked", "512x512arc_h",   NULL, 0xbf);
	tw512x512arc_v          = get_int ("tweaked", "512x512arc_v",   NULL, 0x17);
	tw640x480arc_h          = get_int ("tweaked", "640x480arc_h",   NULL, 0xc1);
	tw640x480arc_v          = get_int ("tweaked", "640x480arc_v",   NULL, 0x09);

	/* this is handled externally cause the audit stuff needs it, too */
	get_rom_sample_path (argc, argv, game_index);

	/* get the monitor type */
	monitorname = get_string ("config", "monitor", NULL, "standard");
	/* get -centerx */
	center_x = get_int ("config", "centerx", NULL,  0);
	/* get -centery */
	center_y = get_int ("config", "centery", NULL,  0);
	/* get -waitinterlace */
	wait_interlace = get_bool ("config", "waitinterlace", NULL,  0);

	/* process some parameters */
	options.beam = (int)(f_beam * 0x00010000);
	if (options.beam < 0x00010000)
		options.beam = 0x00010000;
	if (options.beam > 0x00100000)
		options.beam = 0x00100000;

	options.flicker = (int)(f_flicker * 2.55);
	if (options.flicker < 0)
		options.flicker = 0;
	if (options.flicker > 255)
		options.flicker = 255;

	if (stricmp (vesamode, "vesa1") == 0)
		gfx_mode = GFX_VESA1;
	else if (stricmp (vesamode, "vesa2b") == 0)
		gfx_mode = GFX_VESA2B;
	else if (stricmp (vesamode, "vesa2l") == 0)
		gfx_mode = GFX_VESA2L;
	else if (stricmp (vesamode, "vesa3") == 0)
		gfx_mode = GFX_VESA3;
	else
	{
		if (errorlog)
			fprintf (errorlog, "%s is not a valid entry for vesamode\n",
					vesamode);
		gfx_mode = GFX_VESA3; /* default to VESA2L */
	}

	/* any option that starts with a digit is taken as a resolution option */
	/* this is to handle the old "-wxh" commandline option. */
	for (i = 1; i < argc; i++)
	{
		if (argv[i][0] == '-' && isdigit(argv[i][1]) &&
				(strstr(argv[i],"x") || strstr(argv[i],"X")))
			resolution = &argv[i][1];
	}

	/* break up resolution into gfx_width and gfx_height */
	gfx_height = gfx_width = 0;
	if (stricmp (resolution, "auto") != 0)
	{
		char *tmp;
		strncpy (tmpres, resolution, 10);
		tmp = strtok (tmpres, "xX");
		gfx_width = atoi (tmp);
		tmp = strtok (0, "xX");
		if (tmp)
			gfx_height = atoi (tmp);
	}

	/* convert joystick name into an Allegro-compliant joystick signature */
	joystick = -2; /* default to invalid value */

	for (i = 0; joy_table[i].name != NULL; i++)
	{
		if (stricmp (joy_table[i].name, joyname) == 0)
		{
			joystick = joy_table[i].id;
			if (errorlog)
				fprintf (errorlog, "using joystick %s = %08x\n",
						joyname,joy_table[i].id);
			break;
		}
	}

	if (joystick == -2)
	{
		if (errorlog)
			fprintf (errorlog, "%s is not a valid entry for a joystick\n",
					joyname);
		joystick = JOY_TYPE_NONE;
	}

	/* get monitor type from supplied name */
	monitor_type = MONITOR_TYPE_STANDARD; /* default to PC monitor */

	for (i = 0; monitor_table[i].name != NULL; i++)
	{
		if ((stricmp (monitor_table[i].name, monitorname) == 0))
		{
			monitor_type = monitor_table[i].id;
			break;
		}
	}
}
Esempio n. 22
0
/* set_config_int:
 *  Writes an integer to the configuration file.
 */
void set_config_int(char *section, char *name, int val)
{
   char buf[32];
   sprintf(buf, "%d", val);
   set_config_string(section, name, buf);
}
Esempio n. 23
0
REGISTER_FILE
#include "scp.h"
#include "frame.h"

#include "mmain.h"
#include "mview.h"
#include "mcontrol.h"
#include "other/planet3d.h"
#include "mshppan.h"
#include "mship.h"
#include "mlog.h"
//#include "mnet1.h"
#include "mitems.h"
#include "mfleet.h"

#include "games/gflmelee.h"

#include "other/twconfig.h"

int NormalGame::add_player (Control *c, int team_index, const char *name, const char *fleet_section, const char *fleet_file)
{
	int i = num_players;
	num_players += 1;
	player_control = (Control**) realloc(player_control,   sizeof(Control*)   * num_players);
	player_name    =    (char**) realloc(player_name,      sizeof(char*)      * num_players);
	//	player_panel = (ShipPanel**) realloc(player_panel,     sizeof(ShipPanel*) * num_players);
	player_fleet =     (Fleet**) realloc(player_fleet,     sizeof(Fleet *)    * num_players);
	player_team =    (TeamCode*) realloc(player_team,      sizeof(TeamCode)   * num_players);
	player_control[i] = c;
	add_focus(c, c->channel);
	//	player_panel[i] = NULL;
	player_fleet[i] = new Fleet();
	player_fleet[i]->reset();
	player_name[i] = strdup(name);
	if (team_index >= team_table_size) {
		int i = team_table_size;
		team_table_size = team_index + 1;
		team_table = (TeamCode*) realloc(team_table, sizeof(TeamCode) * team_table_size);
		for (; i < team_table_size; i += 1) {
			if (i) team_table[i] = new_team();
			else team_table[i] = 0;
		}
	}
	if (team_index) player_team[i] = team_table[team_index];
	else player_team[i] = new_team();
	char sect[40];
	sprintf(sect, "Player%d", i+1);
	if (c->channel == channel_none) {
		tw_error("channel_none not allowed here");
		//log_file(fleet_file);
		//::fleet->load(NULL, fleet_section);
	}
	else if (log->get_direction(c->channel) & Log::direction_write) {
		player_fleet[i]->load(fleet_file, fleet_section);
		log_fleet(c->channel, player_fleet[i]);
		c->target_sign_color = ((3+i) % 7) + 1;
	} else {
		log_fleet(c->channel, player_fleet[i]);
	}
	tw_set_config_file(home_ini_full_path("tmp.ini"));
	set_config_string(sect, "Name", name);
	set_config_string(sect, "Type", c->getTypeName());
	set_config_int(sect, "Team", team_index);
	set_config_int(sect, "Channel", c->channel);
	set_config_int(sect, "StartingFleetCost", player_fleet[i]->getCost());
	set_config_int(sect, "StartingFleetSize", player_fleet[i]->getSize());
	player_fleet[i]->save(NULL, sect);
	player_fleet[i]->save("fleets.tmp", sect);
	return i;
}
Esempio n. 24
0
static void init()
{
   char temp_buf[256];

   is_not_genuine_scan_tool = FALSE;
   
   /* initialize some varaibles with default values */
   strcpy(options_file_name, "scantool.cfg");
   strcpy(data_file_name, "scantool.dat");
   strcpy(code_defs_file_name, "codes.dat");
   
   datafile = NULL;
   comport.status = NOT_OPEN;
   display_mode = 0;

   set_uformat(U_ASCII);
   
   /* initialize hardware */
   write_log("\nInitializing Allegro... ");
   allegro_init();
   write_log("OK");
   
   set_window_title(WINDOW_TITLE);
   
   write_log("\nInstalling Timers... ");
   if (install_timer() != 0)
   {
      write_log("Error!");
      fatal_error("Error installing timers");
   }
   write_log("OK");
   write_log("\nInstalling Keyboard... ");
   install_keyboard();
   write_log("OK");
   write_log("\nInstalling Mouse... ");
   install_mouse();
   write_log("OK");

   /* load options from file, the defaults will be automatically substituted if file does not exist */
   write_log("\nLoading Preferences... ");
   set_config_file(options_file_name);
   /* if config file doesn't exist or is of an incorrect version */
   if (strcmp(get_config_string(NULL, "version", ""), SCANTOOL_VERSION_STR) != 0)
   {
      /* update config file */
      remove(options_file_name);
      set_config_file(options_file_name);
      set_config_string(NULL, "version", SCANTOOL_VERSION_STR);
      load_program_options();  // Load defaults
      save_program_options();
   }
   else
      load_program_options();
   write_log("OK");

   display_mode |= FULLSCREEN_MODE_SUPPORTED;
   
   write_log("\nTrying Windowed Graphics Mode... ");
   if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) == 0)
   {
      display_mode |= WINDOWED_MODE_SUPPORTED;
      write_log("OK");
   }
   else
   {
      display_mode &= ~(WINDOWED_MODE_SUPPORTED | WINDOWED_MODE_SET);
      write_log(allegro_error);
   }

   if (!(display_mode & WINDOWED_MODE_SET))
   {
      write_log("\nTrying Full Screen Graphics Mode... ");
      if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0) == 0)
      {
         display_mode |= FULLSCREEN_MODE_SUPPORTED;
         write_log("OK");
      }
      else
      {
         display_mode &= ~FULLSCREEN_MODE_SUPPORTED;
         write_log(allegro_error);
      }
   }
   
   if (!(display_mode & (FULLSCREEN_MODE_SUPPORTED | WINDOWED_MODE_SUPPORTED)))
      fatal_error(allegro_error);
   else if ((display_mode & WINDOWED_MODE_SUPPORTED) && !(display_mode & FULLSCREEN_MODE_SUPPORTED))
   {
      set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
      display_mode &= WINDOWED_MODE_SET;
   }
   
   write_log("\nLoading Data File... ");
   packfile_password(PASSWORD);
   datafile = load_datafile(data_file_name);
   packfile_password(NULL);
   if (datafile == NULL)
   {
      sprintf(temp_buf, "Error loading %s!", data_file_name);
      write_log(temp_buf);
      fatal_error(temp_buf);
   }
   write_log("OK");

   set_pallete(datafile[MAIN_PALETTE].dat);
   font = datafile[ARIAL12_FONT].dat;
   gui_fg_color = C_BLACK;  // set the foreground color
   gui_bg_color = C_WHITE;  // set the background color
   gui_mg_color = C_GRAY;   // set the disabled color
   set_mouse_sprite(NULL); // make mouse use current palette

   write_log("\nInitializing Serial Module... ");
   serial_module_init();
   write_log("OK");

   sprintf(temp_buf, "\nOpening COM%i... ", comport.number + 1);
   write_log(temp_buf);
   /* try opening comport (comport.status will be set) */
   open_comport();
   switch (comport.status)
   {
      case READY:
         write_log("OK");
         break;

      case NOT_OPEN:
         write_log("Error!");
         break;
         
      default:
         write_log("Unknown Status");
         break;
   }
}