int PBI_MIO_ReadConfig(char *string, char *ptr) { if (strcmp(string, "MIO_ROM") == 0) Util_strlcpy(mio_rom_filename, ptr, sizeof(mio_rom_filename)); else if (strcmp(string, "MIO_SCSI_DISK") == 0) Util_strlcpy(mio_scsi_disk_filename, ptr, sizeof(mio_scsi_disk_filename)); else return FALSE; /* no match */ return TRUE; /* matched something */ }
int COLOURS_PAL_ReadConfig(char *option, char *ptr) { if (strcmp(option, "COLOURS_PAL_SATURATION") == 0) return Util_sscandouble(ptr, &COLOURS_PAL_setup.saturation); else if (strcmp(option, "COLOURS_PAL_CONTRAST") == 0) return Util_sscandouble(ptr, &COLOURS_PAL_setup.contrast); else if (strcmp(option, "COLOURS_PAL_BRIGHTNESS") == 0) return Util_sscandouble(ptr, &COLOURS_PAL_setup.brightness); else if (strcmp(option, "COLOURS_PAL_GAMMA") == 0) return Util_sscandouble(ptr, &COLOURS_PAL_setup.gamma); else if (strcmp(option, "COLOURS_PAL_HUE") == 0) return Util_sscandouble(ptr, &COLOURS_PAL_setup.hue); else if (strcmp(option, "COLOURS_PAL_GTIA_DELAY") == 0) return Util_sscandouble(ptr, &COLOURS_PAL_setup.color_delay); else if (strcmp(option, "COLOURS_PAL_EXTERNAL_PALETTE") == 0) Util_strlcpy(COLOURS_PAL_external.filename, ptr, sizeof(COLOURS_PAL_external.filename)); else if (strcmp(option, "COLOURS_PAL_EXTERNAL_PALETTE_LOADED") == 0) /* Use the "loaded" flag to indicate that the palette must be loaded later. */ return (COLOURS_PAL_external.loaded = Util_sscanbool(ptr)) != -1; else if (strcmp(option, "COLOURS_PAL_ADJUST_EXTERNAL_PALETTE") == 0) return (COLOURS_PAL_external.adjust = Util_sscanbool(ptr)) != -1; else return FALSE; return TRUE; }
int SYSROM_ReadConfig(char *string, char *ptr) { int id = CFG_MatchTextParameter(string, cfg_strings, SYSROM_SIZE); if (id >= 0) { /* For faster start, don't check if CRC matches. */ Util_strlcpy(SYSROM_roms[id].filename, ptr, FILENAME_MAX); ClearUnsetFlag(id); } else if (strcmp(string, "OS_400/800_VERSION") == 0) { if (!MatchROMVersionParameter(ptr, autochoose_order_800_ntsc, &SYSROM_os_versions[Atari800_MACHINE_800])) return FALSE; } else if (strcmp(string, "OS_XL/XE_VERSION") == 0) { if (!MatchROMVersionParameter(ptr, autochoose_order_600xl, &SYSROM_os_versions[Atari800_MACHINE_XLXE])) return FALSE; } else if (strcmp(string, "OS_5200_VERSION") == 0) { if (!MatchROMVersionParameter(ptr, autochoose_order_5200, &SYSROM_os_versions[Atari800_MACHINE_5200])) return FALSE; } else if (strcmp(string, "BASIC_VERSION") == 0) { if (!MatchROMVersionParameter(ptr, autochoose_order_basic, &SYSROM_basic_version)) return FALSE; } else if (strcmp(string, "XEGS_GAME_VERSION") == 0) { if (!MatchROMVersionParameter(ptr, autochoose_order_xegame, &SYSROM_xegame_version)) return FALSE; } /* Parse legacy config parameters. */ else if (strcmp(string, "OS/A_ROM") == 0) { if (SYSROM_SetPath(ptr, 2, SYSROM_A_NTSC, SYSROM_A_PAL) != SYSROM_OK) return FALSE; } else if (strcmp(string, "OS/B_ROM") == 0) { if (SYSROM_SetPath(ptr, 2, SYSROM_B_NTSC, SYSROM_800_CUSTOM) != SYSROM_OK) return FALSE; } else if (strcmp(string, "XL/XE_ROM") == 0) { if (SYSROM_SetPath(ptr, 12, SYSROM_AA00R10, SYSROM_AA01R11, SYSROM_BB00R1, SYSROM_BB01R2, SYSROM_BB02R3, SYSROM_BB02R3V4, SYSROM_CC01R4, SYSROM_BB01R3, SYSROM_BB01R4_OS, SYSROM_BB01R59, SYSROM_BB01R59A, SYSROM_XL_CUSTOM) != SYSROM_OK) return FALSE; } else if (strcmp(string, "5200_ROM") == 0) { if (SYSROM_SetPath(ptr, 3, SYSROM_5200, SYSROM_5200A, SYSROM_5200_CUSTOM) != SYSROM_OK) return FALSE; } else if (strcmp(string, "BASIC_ROM") == 0) { if (SYSROM_SetPath(ptr, 4, SYSROM_BASIC_A, SYSROM_BASIC_B, SYSROM_BASIC_C, SYSROM_BASIC_CUSTOM) != SYSROM_OK) return FALSE; } else return FALSE; return TRUE; }
/* * Provides an opportunity for the specified menu to do something during * a display cycle. * * menu The menu */ void wii_menu_handle_update( TREENODE *menu ) { switch( menu->node_type ) { case NODETYPE_LOAD_ROM: if( !games_read ) { LOCK_RENDER_MUTEX(); if( mount_pending ) { const char* roms = wii_get_roms_dir(); if( strlen( roms ) > 0 ) { char mount[WII_MAX_PATH]; Util_strlcpy( mount, roms, sizeof(mount) ); resetSmbErrorMessage(); // Reset the SMB error message if( !ChangeInterface( mount, FS_RETRY_COUNT ) ) { wii_set_roms_dir( "" ); const char* netMsg = getSmbErrorMessage(); if( netMsg != NULL ) { wii_set_status_message( netMsg ); } else { char msg[256]; snprintf( msg, sizeof(msg), "%s: %s", gettextmsg("Unable to mount"), mount ); wii_set_status_message( msg ); } } } mount_pending = FALSE; } wii_read_game_list( roms_menu ); wii_menu_reset_indexes(); wii_menu_move( roms_menu, 1 ); UNLOCK_RENDER_MUTEX(); } break; default: /* do nothing */ break; } }
/* * Loads the currently selected language */ static void select_language() { TREENODE* lang = language_menu->children[language_index]; if( lang->node_type == NODETYPE_LANG_DEFAULT ) { wii_language[0] = '\0'; // update selected language LoadLanguage( NULL ); } else { // update selected language Util_strlcpy( wii_language, lang->name, sizeof(wii_language) ); char langfile[WII_MAX_PATH] = ""; snprintf( langfile, WII_MAX_PATH, "%s%s.%s", wii_get_lang_dir(), lang->name, WII_LANG_EXT ); LoadLanguage( langfile ); } }
/* * Reads the list of languages into the specified menu * * menu The menu to read the languages into */ static void read_lang_list( TREENODE *menu ) { DIR *langdir = opendir( wii_get_lang_dir() ); if( langdir != NULL) { struct dirent* entry = NULL; char ext[WII_MAX_PATH]; while( ( entry = readdir( langdir ) ) != NULL ) { if( ( strcmp( ".", entry->d_name ) && strcmp( "..", entry->d_name ) ) && ( entry->d_type != DT_DIR ) ) { Util_getextension( entry->d_name, ext ); if( !strcmp( ext, WII_LANG_EXT ) ) { char filepart[WII_MAX_PATH]; Util_strlcpy( filepart, entry->d_name, sizeof(filepart) ); int idx = strlen(filepart) - strlen(WII_LANG_EXT) - 1; if( idx > 0 ) { filepart[ idx ] = '\0'; TREENODE *child = wii_create_tree_node( NODETYPE_LANG, filepart ); wii_add_child( menu, child ); } } } } closedir( langdir ); } else { wii_set_status_message( "Error opening languages directory." ); } // Sort the games list qsort( menu->children, menu->child_count, sizeof(*(menu->children)), wii_menu_name_compare ); }
int COLOURS_EXTERNAL_ReadFilename(COLOURS_EXTERNAL_t *colours, char *filename) { Util_strlcpy(colours->filename, filename, FILENAME_MAX); return COLOURS_EXTERNAL_Read(colours); }
int Atari800_Initialise(int *argc, char *argv[]) { int i, j; const char *rom_filename = NULL; const char *rom2_filename = NULL; const char *run_direct = NULL; #ifndef BASIC const char *state_file = NULL; #endif #ifdef __PLUS /* Atari800Win PLus doesn't use configuration files, it reads configuration from the Registry */ #ifndef _WX_ int bUpdateRegistry = (*argc > 1); #endif int bTapeFile = FALSE; int nCartType = CARTRIDGE_type; /* It is necessary because of the CARTRIDGE_Start (there must not be the registry-read value available at startup) */ CARTRIDGE_type = CARTRIDGE_NONE; #ifndef _WX_ /* Print the time info in the "Log file" window */ Misc_PrintTime(); /* Force screen refreshing */ g_nTestVal = _GetRefreshRate() - 1; g_ulAtariState = ATARI_UNINITIALIZED; #endif /* _WX_ */ #elif defined(MACOSX) #else /* __PLUS */ const char *rtconfig_filename = NULL; int got_config; int help_only = FALSE; if (*argc > 1) { for (i = j = 1; i < *argc; i++) { if (strcmp(argv[i], "-config") == 0) { rtconfig_filename = argv[++i]; } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) { printf("%s\n", Atari800_TITLE); return FALSE; } else if (strcmp(argv[i], "--usage") == 0 || strcmp(argv[i], "--help") == 0) { argv[j++] = "-help"; } else if (strcmp(argv[i], "-verbose") == 0) { verbose = TRUE; } else { argv[j++] = argv[i]; } } *argc = j; } got_config = CFG_LoadConfig(rtconfig_filename); /* try to find ROM images if the configuration file is not found or it does not specify some ROM paths (blank paths count as specified) */ CFG_FindROMImages("", TRUE); /* current directory */ #if defined(unix) || defined(__unix__) || defined(__linux__) CFG_FindROMImages("/usr/share/atari800", TRUE); #endif if (*argc > 0 && argv[0] != NULL) { char atari800_exe_dir[FILENAME_MAX]; char atari800_exe_rom_dir[FILENAME_MAX]; /* the directory of the Atari800 program */ Util_splitpath(argv[0], atari800_exe_dir, NULL); CFG_FindROMImages(atari800_exe_dir, TRUE); /* "rom" and "ROM" subdirectories of this directory */ Util_catpath(atari800_exe_rom_dir, atari800_exe_dir, "rom"); CFG_FindROMImages(atari800_exe_rom_dir, TRUE); /* skip "ROM" on systems that are known to be case-insensitive */ #if !defined(DJGPP) && !defined(WIN32) Util_catpath(atari800_exe_rom_dir, atari800_exe_dir, "ROM"); CFG_FindROMImages(atari800_exe_rom_dir, TRUE); #endif } /* finally if nothing is found, set some defaults to make the configuration file easier to edit */ if (Util_filenamenotset(CFG_osa_filename)) strcpy(CFG_osa_filename, "atariosa.rom"); if (Util_filenamenotset(CFG_osb_filename)) strcpy(CFG_osb_filename, "atariosb.rom"); if (Util_filenamenotset(CFG_xlxe_filename)) strcpy(CFG_xlxe_filename, "atarixl.rom"); if (Util_filenamenotset(CFG_5200_filename)) strcpy(CFG_5200_filename, "5200.rom"); if (Util_filenamenotset(CFG_basic_filename)) strcpy(CFG_basic_filename, "ataribas.rom"); /* if no configuration file read, try to save one with the defaults */ if (!got_config) CFG_WriteConfig(); #endif /* __PLUS */ for (i = j = 1; i < *argc; i++) { if (strcmp(argv[i], "-atari") == 0) { if (Atari800_machine_type != Atari800_MACHINE_OSA) { Atari800_machine_type = Atari800_MACHINE_OSB; MEMORY_ram_size = 48; } } else if (strcmp(argv[i], "-xl") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = 64; } else if (strcmp(argv[i], "-xe") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = 128; } else if (strcmp(argv[i], "-320xe") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = MEMORY_RAM_320_COMPY_SHOP; } else if (strcmp(argv[i], "-rambo") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = MEMORY_RAM_320_RAMBO; } else if (strcmp(argv[i], "-5200") == 0) { Atari800_machine_type = Atari800_MACHINE_5200; MEMORY_ram_size = 16; } else if (strcmp(argv[i], "-nobasic") == 0) Atari800_disable_basic = TRUE; else if (strcmp(argv[i], "-basic") == 0) Atari800_disable_basic = FALSE; else if (strcmp(argv[i], "-nopatch") == 0) ESC_enable_sio_patch = FALSE; else if (strcmp(argv[i], "-nopatchall") == 0) #ifdef D_PATCH ESC_enable_sio_patch = Devices_enable_h_patch = Devices_enable_d_patch = Devices_enable_p_patch = Devices_enable_r_patch = FALSE; #else ESC_enable_sio_patch = Devices_enable_h_patch = Devices_enable_p_patch = Devices_enable_r_patch = FALSE; #endif else if (strcmp(argv[i], "-pal") == 0) Atari800_tv_mode = Atari800_TV_PAL; else if (strcmp(argv[i], "-ntsc") == 0) Atari800_tv_mode = Atari800_TV_NTSC; else if (strcmp(argv[i], "-a") == 0) { Atari800_machine_type = Atari800_MACHINE_OSA; MEMORY_ram_size = 48; } else if (strcmp(argv[i], "-b") == 0) { Atari800_machine_type = Atari800_MACHINE_OSB; MEMORY_ram_size = 48; } else if (strcmp(argv[i], "-emuos") == 0) emuos_mode = 2; else if (strcmp(argv[i], "-c") == 0) { if (MEMORY_ram_size == 48) MEMORY_ram_size = 52; } else { /* parameters that take additional argument follow here */ int i_a = (i + 1 < *argc); /* is argument available? */ int a_m = FALSE; /* error, argument missing! */ if (strcmp(argv[i], "-osa_rom") == 0) { if (i_a) Util_strlcpy(CFG_osa_filename, argv[++i], sizeof(CFG_osa_filename)); else a_m = TRUE; } #if 0 /* TBD what to do with R device */ #ifdef R_IO_DEVICE else if (strcmp(argv[i], "-rdevice") == 0) { Devices_enable_r_patch = TRUE; #ifdef R_SERIAL if (i_a && i + 2 < *argc && *argv[i + 1] != '-') { /* optional serial device name */ struct stat statbuf; if (! stat(argv[i + 1], &statbuf)) { if (S_ISCHR(statbuf.st_mode)) { /* only accept devices as serial device */ Util_strlcpy(RDevice_serial_device, argv[++i], FILENAME_MAX); RDevice_serial_enabled = TRUE; } } } #endif /* R_SERIAL */ } #endif #endif else if (strcmp(argv[i], "-osb_rom") == 0) { if (i_a) Util_strlcpy(CFG_osb_filename, argv[++i], sizeof(CFG_osb_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-xlxe_rom") == 0) { if (i_a) Util_strlcpy(CFG_xlxe_filename, argv[++i], sizeof(CFG_xlxe_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-5200_rom") == 0) { if (i_a) Util_strlcpy(CFG_5200_filename, argv[++i], sizeof(CFG_5200_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-basic_rom") == 0) { if (i_a) Util_strlcpy(CFG_basic_filename, argv[++i], sizeof(CFG_basic_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-cart") == 0) { if (i_a) rom_filename = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-cart2") == 0) { if (i_a) rom2_filename = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-run") == 0) { if (i_a) run_direct = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-mosaic") == 0) { int total_ram = Util_sscandec(argv[++i]); MEMORY_mosaic_enabled = TRUE; MEMORY_mosaic_maxbank = (total_ram - 48)/4 - 1; if (((total_ram - 48) % 4 != 0) || (MEMORY_mosaic_maxbank > 0x3e) || (MEMORY_mosaic_maxbank < 0)) { Log_print("Invalid Mosaic total RAM size"); return FALSE; } if (MEMORY_axlon_enabled) { Log_print("Axlon and Mosaic can not both be enabled, because they are incompatible"); return FALSE; } } else if (strcmp(argv[i], "-axlon") == 0) { int total_ram = Util_sscandec(argv[++i]); int banks = ((total_ram) - 32) / 16; MEMORY_axlon_enabled = TRUE; if (((total_ram - 32) % 16 != 0) || ((banks != 8) && (banks != 16) && (banks != 32) && (banks != 64) && (banks != 128) && (banks != 256))) { Log_print("Invalid Axlon total RAM size"); return FALSE; } if (MEMORY_mosaic_enabled) { Log_print("Axlon and Mosaic can not both be enabled, because they are incompatible"); return FALSE; } MEMORY_axlon_bankmask = banks - 1; } else if (strcmp(argv[i], "-axlon0f") == 0) { MEMORY_axlon_0f_mirror = TRUE; } #ifndef BASIC /* The BASIC version does not support state files, because: 1. It has no ability to save state files, because of lack of UI. 2. It uses a simplified emulation, so the state files would be incompatible with other versions. 3. statesav is not compiled in to make the executable smaller. */ else if (strcmp(argv[i], "-state") == 0) { if (i_a) state_file = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-refresh") == 0) { if (i_a) { Atari800_refresh_rate = Util_sscandec(argv[++i]); if (Atari800_refresh_rate < 1) { Log_print("Invalid refresh rate, using 1"); Atari800_refresh_rate = 1; } } else a_m = TRUE; } #endif /* BASIC */ #ifdef STEREO_SOUND else if (strcmp(argv[i], "-stereo") == 0) { POKEYSND_stereo_enabled = TRUE; } else if (strcmp(argv[i], "-nostereo") == 0) { POKEYSND_stereo_enabled = FALSE; } #endif /* STEREO_SOUND */ else { /* all options known to main module tried but none matched */ if (strcmp(argv[i], "-help") == 0) { #if !defined(__PLUS) && !defined(MACOSX) help_only = TRUE; Log_print("\t-config <file> Specify Alternate Configuration File"); #endif Log_print("\t-atari Emulate Atari 800"); Log_print("\t-xl Emulate Atari 800XL"); Log_print("\t-xe Emulate Atari 130XE"); Log_print("\t-320xe Emulate Atari 320XE (COMPY SHOP)"); Log_print("\t-rambo Emulate Atari 320XE (RAMBO)"); Log_print("\t-5200 Emulate Atari 5200 Games System"); Log_print("\t-nobasic Turn off Atari BASIC ROM"); Log_print("\t-basic Turn on Atari BASIC ROM"); Log_print("\t-pal Enable PAL TV mode"); Log_print("\t-ntsc Enable NTSC TV mode"); Log_print("\t-osa_rom <file> Load OS A ROM from file"); Log_print("\t-osb_rom <file> Load OS B ROM from file"); Log_print("\t-xlxe_rom <file> Load XL/XE ROM from file"); Log_print("\t-5200_rom <file> Load 5200 ROM from file"); Log_print("\t-basic_rom <fil> Load BASIC ROM from file"); Log_print("\t-cart <file> Install cartridge (raw or CART format)"); Log_print("\t-run <file> Run Atari program (COM, EXE, XEX, BAS, LST)"); #ifndef BASIC Log_print("\t-state <file> Load saved-state file"); Log_print("\t-refresh <rate> Specify screen refresh rate"); #endif Log_print("\t-nopatch Don't patch SIO routine in OS"); Log_print("\t-nopatchall Don't patch OS at all, H: device won't work"); Log_print("\t-a Use OS A"); Log_print("\t-b Use OS B"); Log_print("\t-c Enable RAM between 0xc000 and 0xcfff in Atari 800"); Log_print("\t-axlon <n> Use Atari 800 Axlon memory expansion: <n> k total RAM"); Log_print("\t-axlon0f Use Axlon shadow at 0x0fc0-0x0fff"); Log_print("\t-mosaic <n> Use 400/800 Mosaic memory expansion: <n> k total RAM"); #ifdef R_IO_DEVICE Log_print("\t-rdevice [<dev>] Enable R: emulation (using serial device <dev>)"); #endif Log_print("\t-v Show version/release number"); } /* copy this option for platform/module specific evaluation */ argv[j++] = argv[i]; } /* this is the end of the additional argument check */ if (a_m) { printf("Missing argument for '%s'\n", argv[i]); return FALSE; } } }
int COLOURS_PAL_Initialise(int *argc, char *argv[]) { int i; int j; for (i = j = 1; i < *argc; i++) { int i_a = (i + 1 < *argc); /* is argument available? */ int a_m = FALSE; /* error, argument missing! */ if (strcmp(argv[i], "-pal-saturation") == 0) { if (i_a) COLOURS_PAL_setup.saturation = atof(argv[++i]); else a_m = TRUE; } else if (strcmp(argv[i], "-pal-contrast") == 0) { if (i_a) COLOURS_PAL_setup.contrast = atof(argv[++i]); else a_m = TRUE; } else if (strcmp(argv[i], "-pal-brightness") == 0) { if (i_a) COLOURS_PAL_setup.brightness = atof(argv[++i]); else a_m = TRUE; } else if (strcmp(argv[i], "-pal-gamma") == 0) { if (i_a) COLOURS_PAL_setup.gamma = atof(argv[++i]); else a_m = TRUE; } else if (strcmp(argv[i], "-palettep") == 0) { if (i_a) { Util_strlcpy(COLOURS_PAL_external.filename, argv[++i], sizeof(COLOURS_PAL_external.filename)); /* Use the "loaded" flag to indicate that the palette must be loaded later. */ COLOURS_PAL_external.loaded = TRUE; } else a_m = TRUE; } else if (strcmp(argv[i], "-palettep-adjust") == 0) COLOURS_PAL_external.adjust = TRUE; else { if (strcmp(argv[i], "-help") == 0) { Log_print("\t-pal-saturation <num> Set PAL color saturation"); Log_print("\t-pal-contrast <num> Set PAL contrast"); Log_print("\t-pal-brightness <num> Set PAL brightness"); Log_print("\t-pal-gamma <num> Set PAL color gamma factor"); Log_print("\t-palettep <filename> Load PAL external palette"); Log_print("\t-palettep-adjust Apply adjustments to PAL external palette"); } argv[j++] = argv[i]; } if (a_m) { Log_print("Missing argument for '%s'", argv[i]); return FALSE; } } *argc = j; /* Try loading an external palette if needed. */ if (COLOURS_PAL_external.loaded && !COLOURS_EXTERNAL_Read(&COLOURS_PAL_external)) Log_print("Cannot read PAL palette from %s", COLOURS_PAL_external.filename); return TRUE; }
void DatabaseManager::loadEntry( const char* hash ) { char buff[255]; // The buffer to use when reading the file FILE* dbFile; // The database file char dbHash[255]; // A hash found in the file we are reading from int readMode = 0; // The current read mode char* ptr; // Pointer into the current entry value #ifdef WII_NETTRACE net_print_string( NULL, 0, "%s\n", getDbFile() ); net_print_string( NULL, 0, "%s\n", getDbTmpFile() ); net_print_string( NULL, 0, "%s\n", getDbOldFile() ); #endif // Populate the entry with the defaults resetToDefaults(); dbEntry* entry = getEntry(); dbFile = fopen( getDbFile(), "r" ); if( dbFile != 0 ) { while( fgets( buff, sizeof(buff), dbFile ) != 0 ) { if( readMode == 2 ) { // We moved past the current record, exit. break; } if( readMode == 1 ) { // Read from the matching database entry ptr = strchr( buff, '=' ); if( ptr ) { *ptr++ = '\0'; Util_trim( buff ); Util_trim( ptr ); if( !strcmp( buff, "name" ) ) { Util_strlcpy( entry->name, ptr, sizeof(entry->name) ); } else { readEntryValue( entry, buff, ptr ); } } } // Search for the hash if( getHash( buff, dbHash ) && readMode < 2 ) { if( readMode || !strcmp( hash, dbHash ) ) { entry->loaded = 1; readMode++; } } } fclose( dbFile ); } }
int CFG_LoadConfig(const char *alternate_config_filename) { FILE *fp; const char *fname = rtconfig_filename; char string[256]; #ifndef BASIC int was_obsolete_dir = FALSE; #endif #ifdef SUPPORTS_PLATFORM_CONFIGINIT PLATFORM_ConfigInit(); #endif /* if alternate config filename is passed then use it */ if (alternate_config_filename != NULL && *alternate_config_filename > 0) { Util_strlcpy(rtconfig_filename, alternate_config_filename, FILENAME_MAX); } /* else use the default config name under the HOME folder */ else { char *home = getenv("HOME"); if (home != NULL) Util_catpath(rtconfig_filename, home, DEFAULT_CFG_NAME); else strcpy(rtconfig_filename, DEFAULT_CFG_NAME); } fp = fopen(fname, "r"); if (fp == NULL) { Log_print("User config file '%s' not found.", rtconfig_filename); #ifdef SYSTEM_WIDE_CFG_FILE /* try system wide config file */ fname = SYSTEM_WIDE_CFG_FILE; Log_print("Trying system wide config file: %s", fname); fp = fopen(fname, "r"); #endif if (fp == NULL) { Log_print("No configuration file found, will create fresh one from scratch:"); return FALSE; } } if (fgets(string, sizeof(string), fp) != NULL) { Log_print("Using Atari800 config file: %s\nCreated by %s", fname, string); } while (fgets(string, sizeof(string), fp)) { char *ptr; Util_chomp(string); ptr = strchr(string, '='); if (ptr != NULL) { *ptr++ = '\0'; Util_trim(string); Util_trim(ptr); if (SYSROM_ReadConfig(string, ptr)) { } #ifdef BASIC else if (strcmp(string, "ATARI_FILES_DIR") == 0 || strcmp(string, "SAVED_FILES_DIR") == 0 || strcmp(string, "DISK_DIR") == 0 || strcmp(string, "ROM_DIR") == 0 || strcmp(string, "EXE_DIR") == 0 || strcmp(string, "STATE_DIR") == 0) /* do nothing */; #else else if (strcmp(string, "ATARI_FILES_DIR") == 0) { if (UI_n_atari_files_dir >= UI_MAX_DIRECTORIES) Log_print("All ATARI_FILES_DIR slots used!"); else Util_strlcpy(UI_atari_files_dir[UI_n_atari_files_dir++], ptr, FILENAME_MAX); } else if (strcmp(string, "SAVED_FILES_DIR") == 0) { if (UI_n_saved_files_dir >= UI_MAX_DIRECTORIES) Log_print("All SAVED_FILES_DIR slots used!"); else Util_strlcpy(UI_saved_files_dir[UI_n_saved_files_dir++], ptr, FILENAME_MAX); } else if (strcmp(string, "DISK_DIR") == 0 || strcmp(string, "ROM_DIR") == 0 || strcmp(string, "EXE_DIR") == 0 || strcmp(string, "STATE_DIR") == 0) { /* ignore blank and "." values */ if (ptr[0] != '\0' && (ptr[0] != '.' || ptr[1] != '\0')) was_obsolete_dir = TRUE; } #endif else if (strcmp(string, "H1_DIR") == 0) Util_strlcpy(Devices_atari_h_dir[0], ptr, FILENAME_MAX); else if (strcmp(string, "H2_DIR") == 0) Util_strlcpy(Devices_atari_h_dir[1], ptr, FILENAME_MAX); else if (strcmp(string, "H3_DIR") == 0) Util_strlcpy(Devices_atari_h_dir[2], ptr, FILENAME_MAX); else if (strcmp(string, "H4_DIR") == 0) Util_strlcpy(Devices_atari_h_dir[3], ptr, FILENAME_MAX); else if (strcmp(string, "HD_READ_ONLY") == 0) Devices_h_read_only = Util_sscandec(ptr); else if (strcmp(string, "PRINT_COMMAND") == 0) { if (!Devices_SetPrintCommand(ptr)) Log_print("Unsafe PRINT_COMMAND ignored"); } else if (strcmp(string, "SCREEN_REFRESH_RATIO") == 0) Atari800_refresh_rate = Util_sscandec(ptr); else if (strcmp(string, "DISABLE_BASIC") == 0) Atari800_disable_basic = Util_sscanbool(ptr); else if (strcmp(string, "ENABLE_SIO_PATCH") == 0) { ESC_enable_sio_patch = Util_sscanbool(ptr); } else if (strcmp(string, "ENABLE_H_PATCH") == 0) { Devices_enable_h_patch = Util_sscanbool(ptr); } else if (strcmp(string, "ENABLE_P_PATCH") == 0) { Devices_enable_p_patch = Util_sscanbool(ptr); } else if (strcmp(string, "ENABLE_R_PATCH") == 0) { Devices_enable_r_patch = Util_sscanbool(ptr); } else if (strcmp(string, "ENABLE_NEW_POKEY") == 0) { #ifdef SOUND POKEYSND_enable_new_pokey = Util_sscanbool(ptr); #endif /* SOUND */ } else if (strcmp(string, "STEREO_POKEY") == 0) { #ifdef STEREO_SOUND POKEYSND_stereo_enabled = Util_sscanbool(ptr); #ifdef SOUND_THIN_API Sound_desired.channels = POKEYSND_stereo_enabled ? 2 : 1; #endif /* SOUND_THIN_API */ #endif /* STEREO_SOUND */ } else if (strcmp(string, "SPEAKER_SOUND") == 0) { #ifdef CONSOLE_SOUND POKEYSND_console_sound_enabled = Util_sscanbool(ptr); #endif } else if (strcmp(string, "SERIO_SOUND") == 0) { #ifdef SERIO_SOUND POKEYSND_serio_sound_enabled = Util_sscanbool(ptr); #endif } else if (strcmp(string, "MACHINE_TYPE") == 0) { if (strcmp(ptr, "Atari 400/800") == 0 || /* Also recognise legacy values of this parameter */ strcmp(ptr, "Atari OS/A") == 0 || strcmp(ptr, "Atari OS/B") == 0) Atari800_machine_type = Atari800_MACHINE_800; else if (strcmp(ptr, "Atari XL/XE") == 0) Atari800_machine_type = Atari800_MACHINE_XLXE; else if (strcmp(ptr, "Atari 5200") == 0) Atari800_machine_type = Atari800_MACHINE_5200; else Log_print("Invalid machine type: %s", ptr); } else if (strcmp(string, "RAM_SIZE") == 0) { if (strcmp(ptr, "320 (RAMBO)") == 0) MEMORY_ram_size = MEMORY_RAM_320_RAMBO; else if (strcmp(ptr, "320 (COMPY SHOP)") == 0) MEMORY_ram_size = MEMORY_RAM_320_COMPY_SHOP; else { int size = Util_sscandec(ptr); if (MEMORY_SizeValid(size)) MEMORY_ram_size = size; else Log_print("Invalid RAM size: %s", ptr); } } else if (strcmp(string, "DEFAULT_TV_MODE") == 0) { if (strcmp(ptr, "PAL") == 0) Atari800_tv_mode = Atari800_TV_PAL; else if (strcmp(ptr, "NTSC") == 0) Atari800_tv_mode = Atari800_TV_NTSC; else Log_print("Invalid TV Mode: %s", ptr); } else if (strcmp(string, "MOSAIC_RAM_NUM_BANKS") == 0) { int num = Util_sscandec(ptr); if (num >= 0 && num <= 64) MEMORY_mosaic_num_banks = num; else Log_print("Invalid Mosaic RAM number of banks: %s", ptr); } else if (strcmp(string, "AXLON_RAM_NUM_BANKS") == 0) { int num = Util_sscandec(ptr); if (num == 0 || num == 8 || num == 16 || num == 32 || num == 64 || num == 128 || num == 256) MEMORY_axlon_num_banks = num; else Log_print("Invalid Mosaic RAM number of banks: %s", ptr); } else if (strcmp(string, "ENABLE_MAPRAM") == 0) MEMORY_enable_mapram = Util_sscanbool(ptr); else if (strcmp(string, "BUILTIN_BASIC") == 0) Atari800_builtin_basic = Util_sscanbool(ptr); else if (strcmp(string, "KEYBOARD_LEDS") == 0) Atari800_keyboard_leds = Util_sscanbool(ptr); else if (strcmp(string, "F_KEYS") == 0) Atari800_f_keys = Util_sscanbool(ptr); else if (strcmp(string, "BUILTIN_GAME") == 0) Atari800_builtin_game = Util_sscanbool(ptr); else if (strcmp(string, "KEYBOARD_DETACHED") == 0) Atari800_keyboard_detached = Util_sscanbool(ptr); else if (strcmp(string, "1200XL_JUMPER") == 0) Atari800_jumper = Util_sscanbool(ptr); else if (strcmp(string, "CFG_SAVE_ON_EXIT") == 0) { CFG_save_on_exit = Util_sscanbool(ptr); } /* Add module-specific configurations here */ else if (PBI_ReadConfig(string,ptr)) { } else if (CARTRIDGE_ReadConfig(string, ptr)) { } else if (CASSETTE_ReadConfig(string, ptr)) { } else if (RTIME_ReadConfig(string, ptr)) { } #ifdef XEP80_EMULATION else if (XEP80_ReadConfig(string, ptr)) { } #endif #ifdef AF80 else if (AF80_ReadConfig(string,ptr)) { } #endif #if !defined(BASIC) && !defined(CURSES_BASIC) else if (Colours_ReadConfig(string, ptr)) { } else if (ARTIFACT_ReadConfig(string, ptr)) { } else if (Screen_ReadConfig(string, ptr)) { } #endif #ifdef NTSC_FILTER else if (FILTER_NTSC_ReadConfig(string, ptr)) { } #endif #if SUPPORTS_CHANGE_VIDEOMODE else if (VIDEOMODE_ReadConfig(string, ptr)) { } #endif #if defined(SOUND) && defined(SOUND_THIN_API) else if (Sound_ReadConfig(string, ptr)) { } #endif /* defined(SOUND) && defined(SOUND_THIN_API) */ else { #ifdef SUPPORTS_PLATFORM_CONFIGURE if (!PLATFORM_Configure(string, ptr)) { Log_print("Unrecognized variable or bad parameters: '%s=%s'", string, ptr); } #else Log_print("Unrecognized variable: %s", string); #endif } } else { Log_print("Ignored config line: %s", string); } } fclose(fp); #ifndef BASIC if (was_obsolete_dir) { Log_print( "DISK_DIR, ROM_DIR, EXE_DIR and STATE_DIR configuration options\n" "are no longer supported. Please use ATARI_FILES_DIR\n" "and SAVED_FILES_DIR in your Atari800 configuration file."); } #endif return TRUE; }
void StandardDatabaseManager::readEntryValue( dbEntry *ent, const char* name, const char* value ) { if( !ent ) return; DatabaseManager::readEntryValue( ent, name, value ); StandardDbEntry* entry = (StandardDbEntry*)ent; if( !strcmp( name, "profile" ) ) { entry->profile = Util_sscandec( value ); } int x, i; bool btnFound = false; int profileCount = getProfileCount(); for( x = 0; x < profileCount; x++ ) { for( i = 0; !btnFound && i < WII_CONTROLLER_COUNT; i++ ) { for( int j = 0; !btnFound && j < WII_MAP_BUTTON_COUNT; j++ ) { char btnName[64]; // Backward compatibility snprintf( btnName, sizeof(btnName), "btn.%d.%d", i, j ); if( !strcmp( name, btnName ) ) { entry->buttonMap[entry->profile][i][j] = Util_sscandec( value ); btnFound = true; } if( !btnFound ) { snprintf( btnName, sizeof(btnName), "btn.%d.%d.%d", x, i, j ); if( !strcmp( name, btnName ) ) { entry->buttonMap[x][i][j] = Util_sscandec( value ); btnFound = true; } } } } } // Backward compatibility btnFound = false; for( i = 1; !btnFound && i < getMappableButtonCount( entry->profile ); i++ ) { char button[255]; // Backward compatibility snprintf( button, sizeof(button), "btnDesc%d", i ); if( !strcmp( name, button ) ) { Util_strlcpy( entry->buttonDesc[entry->profile][i], value, sizeof(entry->buttonDesc[entry->profile][i]) ); btnFound = true; } } for( x = 0; x < profileCount; x++ ) { for( i = 1; !btnFound && i < getMappableButtonCount( x ); i++ ) { char button[255]; // Backward compatibility snprintf( button, sizeof(button), "btnDesc.%d.%d", x, i ); if( !strcmp( name, button ) ) { Util_strlcpy( entry->buttonDesc[x][i], value, sizeof(entry->buttonDesc[x][i]) ); btnFound = true; } } } }