void main_set_core_defaults(void) { /* parameters controlling the operation of the core */ #if defined(DYNAREC) ConfigSetDefaultInt(g_CoreConfig, "R4300Emulator", 2, "Use Pure Interpreter if 0, Cached Interpreter if 1, or Dynamic Recompiler if 2 or more"); #else ConfigSetDefaultInt(g_CoreConfig, "R4300Emulator", 1, "Use Pure Interpreter if 0, Cached Interpreter if 1, or Dynamic Recompiler if 2 or more"); #endif ConfigSetDefaultBool(g_CoreConfig, "NoCompiledJump", 0, "Disable compiled jump commands in dynamic recompiler (should be set to False) "); ConfigSetDefaultBool(g_CoreConfig, "DisableExtraMem", 0, "Disable 4MB expansion RAM pack. May be necessary for some games"); ConfigSetDefaultBool(g_CoreConfig, "AutoStateSlotIncrement", 0, "Increment the save state slot after each save operation"); ConfigSetDefaultInt(g_CoreConfig, "CurrentStateSlot", 0, "Save state slot (0-9) to use when saving/loading the emulator state"); ConfigSetDefaultString(g_CoreConfig, "SaveStatePath", "", "Path to directory where save states are saved. If this is blank, the default value of ${UserConfigPath}/save will be used"); ConfigSetDefaultString(g_CoreConfig, "SharedDataPath", "", "Path to a directory to search when looking for shared data files"); }
int main_set_core_defaults(void) { float fConfigParamsVersion; int bSaveConfig = 0, bUpgrade = 0; if (ConfigGetParameter(g_CoreConfig, "Version", M64TYPE_FLOAT, &fConfigParamsVersion, sizeof(float)) != M64ERR_SUCCESS) { DebugMessage(M64MSG_WARNING, "No version number in 'Core' config section. Setting defaults."); ConfigDeleteSection("Core"); ConfigOpenSection("Core", &g_CoreConfig); bSaveConfig = 1; } else if (((int) fConfigParamsVersion) != ((int) CONFIG_PARAM_VERSION)) { DebugMessage(M64MSG_WARNING, "Incompatible version %.2f in 'Core' config section: current is %.2f. Setting defaults.", fConfigParamsVersion, (float) CONFIG_PARAM_VERSION); ConfigDeleteSection("Core"); ConfigOpenSection("Core", &g_CoreConfig); bSaveConfig = 1; } else if ((CONFIG_PARAM_VERSION - fConfigParamsVersion) >= 0.0001f) { float fVersion = (float) CONFIG_PARAM_VERSION; ConfigSetParameter(g_CoreConfig, "Version", M64TYPE_FLOAT, &fVersion); DebugMessage(M64MSG_INFO, "Updating parameter set version in 'Core' config section to %.2f", fVersion); bUpgrade = 1; bSaveConfig = 1; } /* parameters controlling the operation of the core */ ConfigSetDefaultFloat(g_CoreConfig, "Version", (float) CONFIG_PARAM_VERSION, "Mupen64Plus Core config parameter set version number. Please don't change this version number."); ConfigSetDefaultBool(g_CoreConfig, "OnScreenDisplay", 1, "Draw on-screen display if True, otherwise don't draw OSD"); #if defined(DYNAREC) ConfigSetDefaultInt(g_CoreConfig, "R4300Emulator", 2, "Use Pure Interpreter if 0, Cached Interpreter if 1, or Dynamic Recompiler if 2 or more"); #else ConfigSetDefaultInt(g_CoreConfig, "R4300Emulator", 1, "Use Pure Interpreter if 0, Cached Interpreter if 1, or Dynamic Recompiler if 2 or more"); #endif ConfigSetDefaultBool(g_CoreConfig, "NoCompiledJump", 0, "Disable compiled jump commands in dynamic recompiler (should be set to False) "); ConfigSetDefaultBool(g_CoreConfig, "DisableExtraMem", 0, "Disable 4MB expansion RAM pack. May be necessary for some games"); ConfigSetDefaultBool(g_CoreConfig, "EnableDebugger", 0, "Activate the R4300 debugger when ROM execution begins, if core was built with Debugger support"); ConfigSetDefaultInt(g_CoreConfig, "CountPerOp", 0, "Force number of cycles per emulated instruction."); ConfigSetDefaultBool(g_CoreConfig, "DelaySI", 1, "Delay interrupt after DMA SI read/write"); if (bSaveConfig) ConfigSaveSection("Core"); return 1; }
BOOL Config_Open() { if (ConfigOpenSection("Video-General", &video_general_section) != M64ERR_SUCCESS || ConfigOpenSection("Video-Glide64mk2", &video_glide64_section) != M64ERR_SUCCESS) { ERRLOG("Could not open configuration"); return FALSE; } ConfigSetDefaultBool(video_general_section, "Fullscreen", false, "Use fullscreen mode if True, or windowed mode if False"); ConfigSetDefaultBool(video_general_section, "VerticalSync", true, "If true, prevent frame tearing by waiting for vsync before swapping"); ConfigSetDefaultInt(video_general_section, "ScreenWidth", 640, "Width of output window or fullscreen width"); ConfigSetDefaultInt(video_general_section, "ScreenHeight", 480, "Height of output window or fullscreen height"); ConfigSetDefaultInt(video_glide64_section, "wrpAntiAliasing", 0, "Enable full-scene anti-aliasing by setting this to a value greater than 1"); ConfigSetDefaultInt(video_general_section, "Rotate", 0, "Rotate screen contents: 0=0 degree, 1=90 degree, 2 = 180 degree, 3=270 degree"); return TRUE; }
void main_set_core_defaults(void) { /* parameters controlling the operation of the core */ ConfigSetDefaultBool(g_CoreConfig, "OnScreenDisplay", 1, "Draw on-screen display if True, otherwise don't draw OSD"); ConfigSetDefaultInt(g_CoreConfig, "R4300Emulator", 1, "Use Pure Interpreter if 0, Cached Interpreter if 1, or Dynamic Recompiler if 2 or more"); ConfigSetDefaultBool(g_CoreConfig, "NoCompiledJump", 0, "Disable compiled jump commands in dynamic recompiler (should be set to False) "); ConfigSetDefaultBool(g_CoreConfig, "DisableExtraMem", 0, "Disable 4MB expansion RAM pack. May be necessary for some games"); ConfigSetDefaultBool(g_CoreConfig, "AutoStateSlotIncrement", 0, "Increment the save state slot after each save operation"); ConfigSetDefaultBool(g_CoreConfig, "EnableDebugger", 0, "Activate the R4300 debugger when ROM execution begins, if core was built with Debugger support"); ConfigSetDefaultInt(g_CoreConfig, "CurrentStateSlot", 0, "Save state slot (0-9) to use when saving/loading the emulator state"); ConfigSetDefaultString(g_CoreConfig, "ScreenshotPath", "", "Path to directory where screenshots are saved. If this is blank, the default value of ${UserConfigPath}/screenshot will be used"); ConfigSetDefaultString(g_CoreConfig, "SaveStatePath", "", "Path to directory where save states are saved. If this is blank, the default value of ${UserConfigPath}/save will be used"); ConfigSetDefaultString(g_CoreConfig, "SharedDataPath", "", "Path to a directory to search when looking for shared data files"); /* set config parameters for keyboard and joystick commands */ event_set_core_defaults(); }
BOOL Config_Open() { if (ConfigOpenSection("Video-General", &video_general_section) != M64ERR_SUCCESS || ConfigOpenSection("Video-Glide64mk2", &video_glide64_section) != M64ERR_SUCCESS) { ERRLOG("Could not open configuration"); return FALSE; } ConfigSetDefaultBool(video_general_section, "Fullscreen", false, "Use fullscreen mode if True, or windowed mode if False"); ConfigSetDefaultInt(video_general_section, "ScreenWidth", 640, "Width of output window or fullscreen width"); ConfigSetDefaultInt(video_general_section, "ScreenHeight", 480, "Height of output window or fullscreen height"); return TRUE; }
BOOL Config_ReadInt(const char *itemname, const char *desc, int def_value, int create, int isBoolean) { VLOG("Getting value %s", itemname); if (isBoolean) { ConfigSetDefaultBool(video_glide64_section, itemname, def_value, desc); return ConfigGetParamBool(video_glide64_section, itemname); } else { ConfigSetDefaultInt(video_glide64_section, itemname, def_value, desc); return ConfigGetParamInt(video_glide64_section, itemname); } }
m64p_error ConfigInit(const char *ConfigDirOverride, const char *DataDirOverride) { m64p_error rval; const char *configpath = NULL; char *filepath; long filelen, pathlen; FILE *fPtr; char *configtext; config_section *current_section = NULL; char *line, *end, *lastcomment; if (l_ConfigInit) return M64ERR_ALREADY_INIT; l_ConfigInit = 1; /* if a data directory was specified, make a copy of it */ if (DataDirOverride != NULL) { l_DataDirOverride = (char *) malloc(strlen(DataDirOverride) + 1); if (l_DataDirOverride == NULL) return M64ERR_NO_MEMORY; strcpy(l_DataDirOverride, DataDirOverride); } /* if a config directory was specified, make a copy of it */ if (ConfigDirOverride != NULL) { l_ConfigDirOverride = (char *) malloc(strlen(ConfigDirOverride) + 1); if (l_ConfigDirOverride == NULL) return M64ERR_NO_MEMORY; strcpy(l_ConfigDirOverride, ConfigDirOverride); } /* get the full pathname to the config file and try to open it */ configpath = ConfigGetUserConfigPath(); if (configpath == NULL) return M64ERR_FILES; filepath = (char *) malloc(strlen(configpath) + 32); if (filepath == NULL) return M64ERR_NO_MEMORY; strcpy(filepath, configpath); pathlen = strlen(filepath); if (filepath[pathlen - 1] != OSAL_DIR_SEPARATOR) { filepath[pathlen] = OSAL_DIR_SEPARATOR; filepath[pathlen + 1] = 0; } strcat(filepath, MUPEN64PLUS_CFG_NAME); fPtr = fopen(filepath, "rb"); if (fPtr == NULL) { DebugMessage(M64MSG_INFO, "Couldn't open configuration file '%s'. Using defaults.", filepath); free(filepath); l_SaveConfigOnExit = 1; /* auto-save the config file so that the defaults will be saved to disk */ return M64ERR_SUCCESS; } free(filepath); /* read the entire config file */ fseek(fPtr, 0L, SEEK_END); filelen = ftell(fPtr); fseek(fPtr, 0L, SEEK_SET); configtext = (char *) malloc(filelen + 16); if (configtext == NULL) { fclose(fPtr); return M64ERR_NO_MEMORY; } if (fread(configtext, 1, filelen, fPtr) != filelen) { free(configtext); fclose(fPtr); return M64ERR_FILES; } fclose(fPtr); /* parse the file data */ current_section = NULL; line = configtext; end = configtext + filelen; lastcomment = NULL; *end = 0; while (line < end) { char *pivot, *varname, *varvalue; /* get the pointer to the next line, and null-terminate this line */ char *nextline = strchr(line, '\n'); if (nextline == NULL) nextline = end; *nextline++ = 0; /* strip the whitespace and handle comment */ strip_whitespace(line); if (strlen(line) < 1) { line = nextline; continue; } if (line[0] == '#') { line++; strip_whitespace(line); lastcomment = line; line = nextline; continue; } /* handle section definition line */ if (strlen(line) > 2 && line[0] == '[' && line[strlen(line)-1] == ']') { line++; line[strlen(line)-1] = 0; rval = ConfigOpenSection(line, (m64p_handle *) ¤t_section); if (rval != M64ERR_SUCCESS) { free(configtext); return rval; } lastcomment = NULL; line = nextline; continue; } /* handle variable definition */ pivot = strchr(line, '='); if (current_section == NULL || pivot == NULL) { line = nextline; continue; } varname = line; varvalue = pivot + 1; *pivot = 0; strip_whitespace(varname); strip_whitespace(varvalue); if (varvalue[0] == '"' && varvalue[strlen(varvalue)-1] == '"') { varvalue++; varvalue[strlen(varvalue)-1] = 0; ConfigSetDefaultString((m64p_handle) current_section, varname, varvalue, lastcomment); } else if (osal_insensitive_strcmp(varvalue, "false") == 0) { ConfigSetDefaultBool((m64p_handle) current_section, varname, 0, lastcomment); } else if (osal_insensitive_strcmp(varvalue, "true") == 0) { ConfigSetDefaultBool((m64p_handle) current_section, varname, 1, lastcomment); } else if (is_numeric(varvalue)) { int val_int = (int) strtol(varvalue, NULL, 10); float val_float = (float) strtod(varvalue, NULL); if ((val_float - val_int) != 0.0) ConfigSetDefaultFloat((m64p_handle) current_section, varname, val_float, lastcomment); else ConfigSetDefaultInt((m64p_handle) current_section, varname, val_int, lastcomment); } else { /* assume that it's a string */ ConfigSetDefaultString((m64p_handle) current_section, varname, varvalue, lastcomment); } lastcomment = NULL; line = nextline; } /* release memory used for config file text */ free(configtext); /* duplicate the entire config data list, to store a copy of the list which represents the state of the file on disk */ copy_configlist_active_to_saved(); return M64ERR_SUCCESS; }
static bool Config_SetDefault() { if (ConfigOpenSection("Video-General", &g_configVideoGeneral) != M64ERR_SUCCESS) { LOG(LOG_ERROR, "Unable to open Video-General configuration section"); return false; } if (ConfigOpenSection("Video-GLideN64", &g_configVideoGliden64) != M64ERR_SUCCESS) { LOG(LOG_ERROR, "Unable to open GLideN64 configuration section"); return false; } config.resetToDefaults(); // Set default values for "Video-General" section, if they are not set yet. Taken from RiceVideo m64p_error res = ConfigSetDefaultBool(g_configVideoGeneral, "Fullscreen", config.video.fullscreen, "Use fullscreen mode if True, or windowed mode if False "); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGeneral, "ScreenWidth", config.video.windowedWidth, "Width of output window or fullscreen width"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGeneral, "ScreenHeight", config.video.windowedHeight, "Height of output window or fullscreen height"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGeneral, "VerticalSync", config.video.verticalSync, "If true, activate the SDL_GL_SWAP_CONTROL attribute"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "configVersion", CONFIG_VERSION_CURRENT, "Settings version. Don't touch it."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "MultiSampling", config.video.multisampling, "Enable/Disable MultiSampling (0=off, 2,4,8,16=quality)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "AspectRatio", config.frameBufferEmulation.aspect, "Screen aspect ratio (0=stretch, 1=force 4:3, 2=force 16:9, 3=adjust)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "BufferSwapMode", config.frameBufferEmulation.bufferSwapMode, "Swap frame buffers (0=On VI update call, 1=On VI origin change, 2=On buffer update)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "UseNativeResolutionFactor", config.frameBufferEmulation.nativeResFactor, "Frame buffer size is the factor of N64 native resolution."); assert(res == M64ERR_SUCCESS); //#Texture Settings res = ConfigSetDefaultBool(g_configVideoGliden64, "bilinearMode", config.texture.bilinearMode, "Bilinear filtering mode (0=N64 3point, 1=standard)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "MaxAnisotropy", config.texture.maxAnisotropy, "Max level of Anisotropic Filtering, 0 for off"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "CacheSize", config.texture.maxBytes / uMegabyte, "Size of texture cache in megabytes. Good value is VRAM*3/4"); assert(res == M64ERR_SUCCESS); //#Emulation Settings res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableNoise", config.generalEmulation.enableNoise, "Enable color noise emulation."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableLOD", config.generalEmulation.enableLOD, "Enable LOD emulation."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableHWLighting", config.generalEmulation.enableHWLighting, "Enable hardware per-pixel lighting."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableShadersStorage", config.generalEmulation.enableShadersStorage, "Use persistent storage for compiled shaders."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "CorrectTexrectCoords", config.generalEmulation.correctTexrectCoords, "Make texrect coordinates continuous to avoid black lines between them. (0=Off, 1=Auto, 2=Force)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "enableNativeResTexrects", config.generalEmulation.enableNativeResTexrects, "Render 2D texrects in native resolution to fix misalignment between parts of 2D image."); assert(res == M64ERR_SUCCESS); #ifdef ANDROID res = ConfigSetDefaultBool(g_configVideoGliden64, "ForcePolygonOffset", config.generalEmulation.forcePolygonOffset, "If true, use polygon offset values specified below"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultFloat(g_configVideoGliden64, "PolygonOffsetFactor", config.generalEmulation.polygonOffsetFactor, "Specifies a scale factor that is used to create a variable depth offset for each polygon"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultFloat(g_configVideoGliden64, "PolygonOffsetUnits", config.generalEmulation.polygonOffsetUnits, "Is multiplied by an implementation-specific value to create a constant depth offset"); assert(res == M64ERR_SUCCESS); #endif //#Frame Buffer Settings:" res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableFBEmulation", config.frameBufferEmulation.enable, "Enable frame and|or depth buffer emulation."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableCopyAuxiliaryToRDRAM", config.frameBufferEmulation.copyAuxToRDRAM, "Copy auxiliary buffers to RDRAM"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableN64DepthCompare", config.frameBufferEmulation.N64DepthCompare, "Enable N64 depth compare instead of OpenGL standard one. Experimental."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "DisableFBInfo", config.frameBufferEmulation.fbInfoDisabled, "Disable buffers read/write with FBInfo. Use for games, which do not work with FBInfo."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "FBInfoReadColorChunk", config.frameBufferEmulation.fbInfoReadColorChunk, "Read color buffer by 4kb chunks (strict follow to FBRead specification)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "FBInfoReadDepthChunk", config.frameBufferEmulation.fbInfoReadDepthChunk, "Read depth buffer by 4kb chunks (strict follow to FBRead specification)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "EnableCopyColorToRDRAM", config.frameBufferEmulation.copyToRDRAM, "Enable color buffer copy to RDRAM (0=do not copy, 1=copy in sync mode, 2=copy in async mode)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "EnableCopyDepthToRDRAM", config.frameBufferEmulation.copyDepthToRDRAM, "Enable depth buffer copy to RDRAM (0=do not copy, 1=copy from video memory, 2=use software render)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableCopyColorFromRDRAM", config.frameBufferEmulation.copyFromRDRAM, "Enable color buffer copy from RDRAM."); assert(res == M64ERR_SUCCESS); //#Texture filter settings res = ConfigSetDefaultInt(g_configVideoGliden64, "txFilterMode", config.textureFilter.txFilterMode, "Texture filter (0=none, 1=Smooth filtering 1, 2=Smooth filtering 2, 3=Smooth filtering 3, 4=Smooth filtering 4, 5=Sharp filtering 1, 6=Sharp filtering 2)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "txEnhancementMode", config.textureFilter.txEnhancementMode, "Texture Enhancement (0=none, 1=store as is, 2=X2, 3=X2SAI, 4=HQ2X, 5=HQ2XS, 6=LQ2X, 7=LQ2XS, 8=HQ4X, 9=2xBRZ, 10=3xBRZ, 11=4xBRZ, 12=5xBRZ), 13=6xBRZ"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txDeposterize", config.textureFilter.txDeposterize, "Deposterize texture before enhancement."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txFilterIgnoreBG", config.textureFilter.txFilterIgnoreBG, "Don't filter background textures."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "txCacheSize", config.textureFilter.txCacheSize/uMegabyte, "Size of filtered textures cache in megabytes."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txHiresEnable", config.textureFilter.txHiresEnable, "Use high-resolution texture packs if available."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txHiresFullAlphaChannel", config.textureFilter.txHiresFullAlphaChannel, "Allow to use alpha channel of high-res texture fully."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txHresAltCRC", config.textureFilter.txHresAltCRC, "Use alternative method of paletted textures CRC calculation."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txDump", config.textureFilter.txDump, "Enable dump of loaded N64 textures."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txCacheCompression", config.textureFilter.txCacheCompression, "Zip textures cache."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txForce16bpp", config.textureFilter.txForce16bpp, "Force use 16bit texture formats for HD textures."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "txSaveCache", config.textureFilter.txSaveCache, "Save texture cache to hard disk."); assert(res == M64ERR_SUCCESS); // Convert to multibyte char txPath[PLUGIN_PATH_SIZE * 2]; wcstombs(txPath, config.textureFilter.txPath, PLUGIN_PATH_SIZE * 2); res = ConfigSetDefaultString(g_configVideoGliden64, "txPath", txPath, "Path to folder with hi-res texture packs."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultString(g_configVideoGliden64, "fontName", config.font.name.c_str(), "File name of True Type Font for text messages."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "fontSize", config.font.size, "Font size."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultString(g_configVideoGliden64, "fontColor", "B5E61D", "Font color in RGB format."); assert(res == M64ERR_SUCCESS); //#Bloom filter settings res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableBloom", config.bloomFilter.enable, "Enable bloom filter"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "bloomThresholdLevel", config.bloomFilter.thresholdLevel, "Brightness threshold level for bloom. Values [2, 6]"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "bloomBlendMode", config.bloomFilter.blendMode, "Bloom blend mode (0=Strong, 1=Mild, 2=Light)"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "blurAmount", config.bloomFilter.blurAmount, "Blur radius. Values [2, 10]"); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultInt(g_configVideoGliden64, "blurStrength", config.bloomFilter.blurStrength, "Blur strength. Values [10, 100]"); assert(res == M64ERR_SUCCESS); //#Gamma correction settings res = ConfigSetDefaultBool(g_configVideoGliden64, "ForceGammaCorrection", config.gammaCorrection.force, "Force gamma correction."); assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultFloat(g_configVideoGliden64, "GammaCorrectionLevel", config.gammaCorrection.level, "Gamma correction level."); assert(res == M64ERR_SUCCESS); return ConfigSaveSection("Video-GLideN64") == M64ERR_SUCCESS; }
m64p_error ConfigInit(const char *ConfigDirOverride, const char *DataDirOverride) { m64p_error rval; const char *configpath = NULL; char *filepath; long filelen; FILE *fPtr; char *configtext; config_section *current_section = NULL; char *line, *end, *lastcomment; if (l_ConfigInit) return M64ERR_ALREADY_INIT; l_ConfigInit = 1; /* if a data directory was specified, make a copy of it */ if (DataDirOverride != NULL) { l_DataDirOverride = strdup(DataDirOverride); if (l_DataDirOverride == NULL) return M64ERR_NO_MEMORY; /* TODO mupen64plus-ae specific hack */ strcpy(l_DataDirOverride, DataDirOverride); } /* if a config directory was specified, make a copy of it */ if (ConfigDirOverride != NULL) { l_ConfigDirOverride = strdup(ConfigDirOverride); if (l_ConfigDirOverride == NULL) return M64ERR_NO_MEMORY; } /* get the full pathname to the config file and try to open it */ configpath = ConfigGetUserConfigPath(); if (configpath == NULL) return M64ERR_FILES; filepath = combinepath(configpath, MUPEN64PLUS_CFG_NAME); if (filepath == NULL) return M64ERR_NO_MEMORY; fPtr = fopen(filepath, "rb"); if (fPtr == NULL) { DebugMessage(M64MSG_INFO, "Couldn't open configuration file '%s'. Using defaults.", filepath); free(filepath); l_SaveConfigOnExit = 1; /* auto-save the config file so that the defaults will be saved to disk */ return M64ERR_SUCCESS; } free(filepath); /* read the entire config file */ fseek(fPtr, 0L, SEEK_END); filelen = ftell(fPtr); fseek(fPtr, 0L, SEEK_SET); configtext = (char *) malloc(filelen + 1); if (configtext == NULL) { fclose(fPtr); return M64ERR_NO_MEMORY; } if (fread(configtext, 1, filelen, fPtr) != filelen) { free(configtext); fclose(fPtr); return M64ERR_FILES; } fclose(fPtr); /* parse the file data */ current_section = NULL; line = configtext; end = configtext + filelen; lastcomment = NULL; *end = 0; while (line < end) { ini_line l = ini_parse_line(&line); switch (l.type) { case INI_COMMENT: lastcomment = l.value; break; case INI_SECTION: rval = ConfigOpenSection(l.name, (m64p_handle *) ¤t_section); if (rval != M64ERR_SUCCESS) { free(configtext); return rval; } lastcomment = NULL; break; case INI_PROPERTY: if (l.value[0] == '"' && l.value[strlen(l.value)-1] == '"') { l.value++; l.value[strlen(l.value)-1] = 0; ConfigSetDefaultString((m64p_handle) current_section, l.name, l.value, lastcomment); } else if (osal_insensitive_strcmp(l.value, "false") == 0) { ConfigSetDefaultBool((m64p_handle) current_section, l.name, 0, lastcomment); } else if (osal_insensitive_strcmp(l.value, "true") == 0) { ConfigSetDefaultBool((m64p_handle) current_section, l.name, 1, lastcomment); } else if (is_numeric(l.value)) { int val_int = (int) strtol(l.value, NULL, 10); float val_float = (float) strtod(l.value, NULL); if ((val_float - val_int) != 0.0) ConfigSetDefaultFloat((m64p_handle) current_section, l.name, val_float, lastcomment); else ConfigSetDefaultInt((m64p_handle) current_section, l.name, val_int, lastcomment); } else { /* assume that it's a string */ ConfigSetDefaultString((m64p_handle) current_section, l.name, l.value, lastcomment); } lastcomment = NULL; break; default: break; } } /* release memory used for config file text */ free(configtext); /* duplicate the entire config data list, to store a copy of the list which represents the state of the file on disk */ copy_configlist_active_to_saved(); return M64ERR_SUCCESS; }
static void save_controller_config(int iCtrlIdx, const char *pccDeviceName) { m64p_handle pConfig; char SectionName[32], Param[32], ParamString[128]; int j; /* Delete the configuration section for this controller, so we can use SetDefaults and save the help comments also */ sprintf(SectionName, "Input-SDL-Control%i", iCtrlIdx + 1); ConfigDeleteSection(SectionName); /* Open the configuration section for this controller (create a new one) */ if (ConfigOpenSection(SectionName, &pConfig) != M64ERR_SUCCESS) { DebugMessage(M64MSG_ERROR, "Couldn't open config section '%s'", SectionName); return; } /* save the general controller parameters */ ConfigSetDefaultFloat(pConfig, "version", CONFIG_VERSION, "Mupen64Plus SDL Input Plugin config parameter version number. Please don't change this version number."); ConfigSetDefaultBool(pConfig, "plugged", controller[iCtrlIdx].control->Present, "Specifies whether this controller is 'plugged in' to the simulated N64"); ConfigSetDefaultInt(pConfig, "plugin", controller[iCtrlIdx].control->Plugin, "Specifies which type of expansion pak is in the controller: 1=None, 2=Mem pak, 5=Rumble pak"); ConfigSetDefaultBool(pConfig, "mouse", controller[iCtrlIdx].mouse, "If True, then mouse buttons may be used with this controller"); ConfigSetDefaultInt(pConfig, "device", controller[iCtrlIdx].device, "Specifies which joystick is bound to this controller: -2=Keyboard/mouse, -1=Auto config, 0 or more= SDL Joystick number"); ConfigSetDefaultString(pConfig, "name", pccDeviceName, "SDL joystick name (name check disabled if this is empty string)"); sprintf(Param, "%.2f,%.2f", controller[iCtrlIdx].mouse_sens[0], controller[iCtrlIdx].mouse_sens[1]); ConfigSetDefaultString(pConfig, "MouseSensitivity", Param, "Scaling factor for mouse movements. For X, Y axes."); sprintf(Param, "%i,%i", controller[iCtrlIdx].axis_deadzone[0], controller[iCtrlIdx].axis_deadzone[1]); ConfigSetDefaultString(pConfig, "AnalogDeadzone", Param, "The minimum absolute value of the SDL analog joystick axis to move the N64 controller axis value from 0. For X, Y axes."); sprintf(Param, "%i,%i", controller[iCtrlIdx].axis_peak[0], controller[iCtrlIdx].axis_peak[1]); ConfigSetDefaultString(pConfig, "AnalogPeak", Param, "An absolute value of the SDL joystick axis >= AnalogPeak will saturate the N64 controller axis value (at 80). For X, Y axes. For each axis, this must be greater than the corresponding AnalogDeadzone value"); /* save configuration for all the digital buttons */ for (j = 0; j < X_AXIS; j++ ) { const char *Help; int len = 0; ParamString[0] = 0; if (controller[iCtrlIdx].button[j].key > 0) { sprintf(Param, "key(%i) ", controller[iCtrlIdx].button[j].key); strcat(ParamString, Param); } if (controller[iCtrlIdx].button[j].button >= 0) { sprintf(Param, "button(%i) ", controller[iCtrlIdx].button[j].button); strcat(ParamString, Param); } if (controller[iCtrlIdx].button[j].axis >= 0) { if (controller[iCtrlIdx].button[j].axis_deadzone >= 0) sprintf(Param, "axis(%i%c,%i) ", controller[iCtrlIdx].button[j].axis, (controller[iCtrlIdx].button[j].axis_dir == -1) ? '-' : '+', controller[iCtrlIdx].button[j].axis_deadzone); else sprintf(Param, "axis(%i%c) ", controller[iCtrlIdx].button[j].axis, (controller[iCtrlIdx].button[j].axis_dir == -1) ? '-' : '+'); strcat(ParamString, Param); } if (controller[iCtrlIdx].button[j].hat >= 0) { sprintf(Param, "hat(%i %s) ", controller[iCtrlIdx].button[j].hat, HAT_POS_NAME(controller[iCtrlIdx].button[j].hat_pos)); strcat(ParamString, Param); } if (controller[iCtrlIdx].button[j].mouse >= 0) { sprintf(Param, "mouse(%i) ", controller[iCtrlIdx].button[j].mouse); strcat(ParamString, Param); } if (j == 0) Help = "Digital button configuration mappings"; else Help = NULL; /* if last character is a space, chop it off */ len = strlen(ParamString); if (len > 0 && ParamString[len-1] == ' ') ParamString[len-1] = 0; ConfigSetDefaultString(pConfig, button_names[j], ParamString, Help); } /* save configuration for the 2 analog axes */ for (j = 0; j < 2; j++ ) { const char *Help; int len = 0; ParamString[0] = 0; if (controller[iCtrlIdx].axis[j].key_a > 0 && controller[iCtrlIdx].axis[j].key_b > 0) { sprintf(Param, "key(%i,%i) ", controller[iCtrlIdx].axis[j].key_a, controller[iCtrlIdx].axis[j].key_b); strcat(ParamString, Param); } if (controller[iCtrlIdx].axis[j].button_a >= 0 && controller[iCtrlIdx].axis[j].button_b >= 0) { sprintf(Param, "button(%i,%i) ", controller[iCtrlIdx].axis[j].button_a, controller[iCtrlIdx].axis[j].button_b); strcat(ParamString, Param); } if (controller[iCtrlIdx].axis[j].axis_a >= 0 && controller[iCtrlIdx].axis[j].axis_b >= 0) { sprintf(Param, "axis(%i%c,%i%c) ", controller[iCtrlIdx].axis[j].axis_a, (controller[iCtrlIdx].axis[j].axis_dir_a <= 0) ? '-' : '+', controller[iCtrlIdx].axis[j].axis_b, (controller[iCtrlIdx].axis[j].axis_dir_b <= 0) ? '-' : '+' ); strcat(ParamString, Param); } if (controller[iCtrlIdx].axis[j].hat >= 0) { sprintf(Param, "hat(%i %s %s) ", controller[iCtrlIdx].axis[j].hat, HAT_POS_NAME(controller[iCtrlIdx].axis[j].hat_pos_a), HAT_POS_NAME(controller[iCtrlIdx].axis[j].hat_pos_b)); strcat(ParamString, Param); } if (j == 0) Help = "Analog axis configuration mappings"; else Help = NULL; /* if last character is a space, chop it off */ len = strlen(ParamString); if (len > 0 && ParamString[len-1] == ' ') ParamString[len-1] = 0; ConfigSetDefaultString(pConfig, button_names[X_AXIS + j], ParamString, Help); } }