void Config_LoadConfig() { FILE *f; char line[4096]; // default configuration Config_SetDefault(); // read configuration char filename[PATH_MAX]; snprintf(filename, PATH_MAX, "%s/gles2n64.conf", GetPluginDir()); f = fopen(filename, "r"); if (!f) { LOG(LOG_MINIMAL, "[gles2N64]: Couldn't open config file '%s' for reading: %s\n", filename, strerror( errno ) ); LOG(LOG_MINIMAL, "[gles2N64]: Attempting to write new Config \n"); Config_WriteConfig(filename); } else { LOG(LOG_MINIMAL, "[gles2n64]: Loading Config from %s \n", filename); while (!feof( f )) { char *val; fgets( line, 4096, f ); if (line[0] == '#' || line[0] == '\n') continue; val = strchr( line, '=' ); if (!val) continue; *val++ = '\0'; Config_SetOption(line,val); } if (config.version < CONFIG_VERSION) { LOG(LOG_WARNING, "[gles2N64]: Wrong config version, rewriting config with defaults\n"); Config_SetDefault(); Config_WriteConfig(filename); } fclose(f); } }
BOOL LoadGFXDll(char * RspDll) { if(hGfxDll != NULL) CloseGfxPlugin(); PLUGIN_INFO PluginInfo; char DllName[300]; GetPluginDir(DllName); strcat(DllName,GfxDLL); hGfxDll = LoadLibrary(DllName); if (hGfxDll == NULL) return FALSE; GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( hGfxDll, "GetDllInfo" ); if (GetDllInfo == NULL) return FALSE; GetDllInfo(&PluginInfo); //if (!ValidPluginVersion(&PluginInfo) || PluginInfo.MemoryBswaped == FALSE) { return FALSE; } _GFXCloseDLL = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "CloseDLL" ); _ChangeWindow = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ChangeWindow" ); _GFXDllAbout = (void (__cdecl *)(HWND))GetProcAddress( hGfxDll, "DllAbout" ); _GFXDllConfig = (void (__cdecl *)(HWND))GetProcAddress( hGfxDll, "DllConfig" ); _DrawScreen = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "DrawScreen" ); _InitiateGFX = (BOOL (__cdecl *)(GFX_INFO))GetProcAddress( hGfxDll, "InitiateGFX" ); _MoveScreen = (void (__cdecl *)(int, int))GetProcAddress( hGfxDll, "MoveScreen" ); _ProcessDList = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ProcessDList" ); _GfxRomClosed = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "RomClosed" ); _GfxRomOpen = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "RomOpen" ); _UpdateScreen = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "UpdateScreen" ); _ViStatusChanged = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ViStatusChanged" ); _ViWidthChanged = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ViWidthChanged" ); _ProcessRDPList = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ProcessRDPList" ); _CaptureScreen = (void (__cdecl *)(char *))GetProcAddress( hGfxDll, "CaptureScreen" ); _ShowCFB = (void (__cdecl *)(void))GetProcAddress( hGfxDll, "ShowCFB" ); #ifdef CFB_READ FrameBufferRead = (void (__cdecl *)(DWORD))GetProcAddress( hGfxDll, "FBRead" ); FrameBufferWrite = (void (__cdecl *)(DWORD, DWORD))GetProcAddress( hGfxDll, "FBWrite" ); #endif return TRUE; }
static void okButton_clicked( GtkWidget *widget, void *data ) { const char *text; int i, i1, i2; FILE *f; gtk_widget_hide( configWindow ); // apply configuration /* text = gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(resolutionCombo[0])->entry) ); if (sscanf( text, "%d x %d", &i1, &i2 ) != 2) { i1 = 640; i2 = 480; } OGL.fullscreenWidth = i1; OGL.fullscreenHeight = i2; text = gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(bitdepthCombo[0])->entry) ); if (sscanf( text, "%d Bit", &i1 ) != 1) i1 = 0; OGL.fullscreenBits = i1; text = gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(resolutionCombo[1])->entry) ); if (sscanf( text, "%d x %d", &i1, &i2 ) != 2) { i1 = 640; i2 = 480; } OGL.windowedWidth = i1; OGL.windowedHeight = i2; text = gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(bitdepthCombo[1])->entry) ); if (sscanf( text, "%d Bit", &i1 ) != 1) i1 = 0; OGL.windowedBits = i1;*/ text = gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(resolutionCombo)->entry) ); if (sscanf( text, "%d x %d", &i1, &i2 ) != 2) { i1 = 640; i2 = 480; } OGL.fullscreenWidth = OGL.windowedWidth = i1; OGL.fullscreenHeight = OGL.windowedHeight = i2; OGL.forceBilinear = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(forceBilinearCheck) ); OGL.enable2xSaI = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enable2xSAICheck) ); OGL.enableAnisotropicFiltering = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableAnisotropicFilteringCheck)); OGL.fog = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableFogCheck) ); OGL.frameBufferTextures = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enableHardwareFBCheck) ); OGL.usePolygonStipple = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(enablePolygonStippleCheck) ); const char *depth = gtk_entry_get_text( GTK_ENTRY(GTK_COMBO(textureDepthCombo)->entry) ); OGL.textureBitDepth = 1; for (i = 0; textureBitDepth[i] != 0; i++) { if (!strcmp( depth, textureBitDepth[i] )) OGL.textureBitDepth = i; } cache.maxBytes = atoi( gtk_entry_get_text( GTK_ENTRY(textureCacheEntry) ) ) * 1048576; // write configuration if (pluginDir == 0) pluginDir = GetPluginDir(); char filename[PATH_MAX]; snprintf( filename, PATH_MAX, "%s/glN64.conf", pluginDir ); f = fopen( filename, "w" ); if (!f) { fprintf( stderr, "[glN64]: (EE) Couldn't save config file '%s': %s\n", filename, strerror( errno ) ); return; } /* fprintf( f, "fullscreen width=%d\n", OGL.fullscreenWidth ); fprintf( f, "fullscreen height=%d\n", OGL.fullscreenHeight ); fprintf( f, "fullscreen depth=%d\n", OGL.fullscreenBits );*/ fprintf( f, "width=%d\n", OGL.windowedWidth ); fprintf( f, "height=%d\n", OGL.windowedHeight ); // fprintf( f, "windowed depth=%d\n", OGL.windowedBits );*/ /* fprintf( f, "width=%d\n", OGL.width ); fprintf( f, "height=%d\n", OGL.height );*/ fprintf( f, "force bilinear=%d\n", OGL.forceBilinear ); fprintf( f, "enable anisotropic=%d\n", OGL.enableAnisotropicFiltering ); fprintf( f, "enable 2xSAI=%d\n", OGL.enable2xSaI ); fprintf( f, "enable fog=%d\n", OGL.fog ); fprintf( f, "enable HardwareFB=%d\n", OGL.frameBufferTextures ); fprintf( f, "enable dithered alpha=%d\n", OGL.usePolygonStipple ); fprintf( f, "texture depth=%d\n", OGL.textureBitDepth ); fprintf( f, "cache size=%d\n", cache.maxBytes / 1048576 ); fclose( f ); }
void Config_LoadConfig() { static int loaded = 0; FILE *f; char line[2000]; if (loaded) return; loaded = 1; if (pluginDir == 0) pluginDir = GetPluginDir(); // default configuration OGL.fullscreenWidth = 640; OGL.fullscreenHeight = 480; // OGL.fullscreenBits = 0; OGL.windowedWidth = 640; OGL.windowedHeight = 480; // OGL.windowedBits = 0; OGL.forceBilinear = 0; OGL.enable2xSaI = 0; OGL.enableAnisotropicFiltering = 0; OGL.fog = 1; OGL.textureBitDepth = 1; // normal (16 & 32 bits) OGL.frameBufferTextures = 0; OGL.usePolygonStipple = 0; cache.maxBytes = 32 * 1048576; // read configuration char filename[PATH_MAX]; snprintf( filename, PATH_MAX, "%s/glN64.conf", pluginDir ); f = fopen( filename, "r" ); if (!f) { fprintf( stderr, "[glN64]: (WW) Couldn't open config file '%s' for reading: %s\n", filename, strerror( errno ) ); return; } while (!feof( f )) { char *val; fgets( line, 2000, f ); val = strchr( line, '=' ); if (!val) continue; *val++ = '\0'; /* if (!strcasecmp( line, "fullscreen width" )) { OGL.fullscreenWidth = atoi( val ); } else if (!strcasecmp( line, "fullscreen height" )) { OGL.fullscreenHeight = atoi( val ); } else if (!strcasecmp( line, "fullscreen depth" )) { OGL.fullscreenBits = atoi( val ); } else if (!strcasecmp( line, "windowed width" )) { OGL.windowedWidth = atoi( val ); } else if (!strcasecmp( line, "windowed height" )) { OGL.windowedHeight = atoi( val ); } else if (!strcasecmp( line, "windowed depth" )) { OGL.windowedBits = atoi( val ); }*/ if (!strcasecmp( line, "width" )) { int w = atoi( val ); OGL.fullscreenWidth = OGL.windowedWidth = (w == 0) ? (640) : (w); } else if (!strcasecmp( line, "height" )) { int h = atoi( val ); OGL.fullscreenHeight = OGL.windowedHeight = (h == 0) ? (480) : (h); } else if (!strcasecmp( line, "force bilinear" )) { OGL.forceBilinear = atoi( val ); } else if (!strcasecmp( line, "enable 2xSAI" )) { OGL.enable2xSaI = atoi( val ); } else if (!strcasecmp( line, "enable anisotropic")) { OGL.enableAnisotropicFiltering = atoi( val ); } else if (!strcasecmp( line, "enable fog" )) { OGL.fog = atoi( val ); } else if (!strcasecmp( line, "cache size" )) { cache.maxBytes = atoi( val ) * 1048576; } else if (!strcasecmp( line, "enable HardwareFB" )) { OGL.frameBufferTextures = atoi( val ); } else if (!strcasecmp( line, "enable dithered alpha" )) { OGL.usePolygonStipple = atoi( val ); } else if (!strcasecmp( line, "texture depth" )) { OGL.textureBitDepth = atoi( val ); } else { printf( "Unknown config option: %s\n", line ); } } fclose( f ); }
BOOL CALLBACK PluginSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { char Plugin[300]; HMODULE hLib; DWORD count, index; switch (uMsg) { case WM_INITDIALOG: SetupPluginScreen(hDlg); break; case WM_COMMAND: switch (LOWORD(wParam)) { #ifndef EXTERNAL_RELEASE case RSP_LIST: if (HIWORD(wParam) == CBN_SELCHANGE) { index = SendMessage(GetDlgItem(hDlg,RSP_LIST),CB_GETCURSEL,0,0); if (index == CB_ERR) { break; } // *** Add in Build 53 index = SendMessage(GetDlgItem(hDlg,RSP_LIST),CB_GETITEMDATA,(WPARAM)index,0); GetPluginDir(Plugin); strcat(Plugin,PluginNames[index]); hLib = LoadLibrary(Plugin); if (hLib == NULL) { DisplayError("%s %s",GS(MSG_FAIL_LOAD_PLUGIN),Plugin); } RSPDllAbout = (void (__cdecl *)(HWND))GetProcAddress( hLib, "DllAbout" ); EnableWindow(GetDlgItem(hDlg,RSP_ABOUT),RSPDllAbout != NULL ? TRUE:FALSE); } break; #endif case GFX_LIST: if (HIWORD(wParam) == CBN_SELCHANGE) { index = SendMessage(GetDlgItem(hDlg,GFX_LIST),CB_GETCURSEL,0,0); if (index == CB_ERR) { break; } // *** Add in Build 53 index = SendMessage(GetDlgItem(hDlg,GFX_LIST),CB_GETITEMDATA,(WPARAM)index,0); GetPluginDir(Plugin); strcat(Plugin,PluginNames[index]); hLib = LoadLibrary(Plugin); if (hLib == NULL) { DisplayError("%s %s",GS(MSG_FAIL_LOAD_PLUGIN),Plugin); } _GFXDllAbout = (void (__cdecl *)(HWND))GetProcAddress( (HMODULE)hLib, "DllAbout" ); EnableWindow(GetDlgItem(hDlg,GFX_ABOUT), _GFXDllAbout != NULL ? TRUE:FALSE); } break; case AUDIO_LIST: if (HIWORD(wParam) == CBN_SELCHANGE) { index = SendMessage(GetDlgItem(hDlg,AUDIO_LIST),CB_GETCURSEL,0,0); if (index == CB_ERR) { break; } // *** Add in Build 53 index = SendMessage(GetDlgItem(hDlg,AUDIO_LIST),CB_GETITEMDATA,(WPARAM)index,0); GetPluginDir(Plugin); strcat(Plugin,PluginNames[index]); hLib = LoadLibrary(Plugin); if (hLib == NULL) { DisplayError("%s %s",GS(MSG_FAIL_LOAD_PLUGIN),Plugin); } _AiDllAbout = (void (__cdecl *)(HWND))GetProcAddress( (HMODULE)hLib, "DllAbout" ); EnableWindow(GetDlgItem(hDlg,GFX_ABOUT), _AiDllAbout != NULL ? TRUE:FALSE); } break; case CONT_LIST: if (HIWORD(wParam) == CBN_SELCHANGE) { index = SendMessage(GetDlgItem(hDlg,CONT_LIST),CB_GETCURSEL,0,0); if (index == CB_ERR) { break; } // *** Add in Build 53 index = SendMessage(GetDlgItem(hDlg,CONT_LIST),CB_GETITEMDATA,(WPARAM)index,0); GetPluginDir(Plugin); strcat(Plugin,PluginNames[index]); hLib = LoadLibrary(Plugin); if (hLib == NULL) { DisplayError("%s %s",GS(MSG_FAIL_LOAD_PLUGIN),Plugin); } _ContDllAbout = (void (__cdecl *)(HWND))GetProcAddress( (HMODULE)hLib, "DllAbout" ); EnableWindow(GetDlgItem(hDlg,CONT_ABOUT), _ContDllAbout != NULL ? TRUE:FALSE); } break; #ifndef EXTERNAL_RELEASE case RSP_ABOUT: RSPDllAbout(hDlg); break; #endif case GFX_ABOUT: GFXDllAbout(hDlg); break; case CONT_ABOUT: ContDllAbout(hDlg); break; case AUDIO_ABOUT: AiDllAbout(hDlg); break; } break; case WM_NOTIFY: if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { long lResult; HKEY hKeyResults = 0; DWORD Disposition = 0; char String[200]; if (PluginsChanged(hDlg) == FALSE) { break; } if (CPURunning) { int Response; ShowWindow(hDlg,SW_HIDE); Response = MessageBox(hMainWindow,GS(MSG_PLUGIN_CHANGE),GS(MSG_PLUGIN_CHANGE_TITLE),MB_YESNO|MB_ICONQUESTION); if (Response != IDYES) { break; } } sprintf(String,"Software\\N64 Emulation\\%s\\Dll",AppName); lResult = RegCreateKeyEx( HKEY_CURRENT_USER, String,0,"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition); if (lResult == ERROR_SUCCESS) { DWORD index; #ifndef EXTERNAL_RELEASE index = SendMessage(GetDlgItem(hDlg,RSP_LIST),CB_GETCURSEL,0,0); index = SendMessage(GetDlgItem(hDlg,RSP_LIST),CB_GETITEMDATA,(WPARAM)index,0); sprintf(String,"%s",PluginNames[index]); RegSetValueEx(hKeyResults,"RSP Dll",0,REG_SZ,(CONST BYTE *)String, strlen(String)); #endif index = SendMessage(GetDlgItem(hDlg,GFX_LIST),CB_GETCURSEL,0,0); index = SendMessage(GetDlgItem(hDlg,GFX_LIST),CB_GETITEMDATA,(WPARAM)index,0); sprintf(String,"%s",PluginNames[index]); RegSetValueEx(hKeyResults,"Graphics Dll",0,REG_SZ,(CONST BYTE *)String, strlen(String)); index = SendMessage(GetDlgItem(hDlg,AUDIO_LIST),CB_GETCURSEL,0,0); index = SendMessage(GetDlgItem(hDlg,AUDIO_LIST),CB_GETITEMDATA,(WPARAM)index,0); sprintf(String,"%s",PluginNames[index]); RegSetValueEx(hKeyResults,"Audio Dll",0,REG_SZ,(CONST BYTE *)String, strlen(String)); index = SendMessage(GetDlgItem(hDlg,CONT_LIST),CB_GETCURSEL,0,0); index = SendMessage(GetDlgItem(hDlg,CONT_LIST),CB_GETITEMDATA,(WPARAM)index,0); sprintf(String,"%s",PluginNames[index]); RegSetValueEx(hKeyResults,"Controller Dll",0,REG_SZ,(CONST BYTE *)String, strlen(String)); } RegCloseKey(hKeyResults); if (CPURunning) { CloseCpu(); SetupPlugins(hMainWindow); StartEmulation(); } else { if (!RomBrowser) { SetupPlugins(hMainWindow); } if (RomBrowser) { SetupPlugins(hHiddenWin); } } } if (((NMHDR FAR *) lParam)->code == PSN_RESET) { for (count = 0; count < PluginCount; count ++ ) { free(PluginNames[count]); } } break; default: return FALSE; } return TRUE; }
BOOL CALLBACK DirSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { HKEY hKeyResults = 0; char String[256]; char Directory[255]; long lResult; sprintf(String,"Software\\N64 Emulation\\%s",AppName); lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0, KEY_ALL_ACCESS,&hKeyResults); if (lResult == ERROR_SUCCESS) { DWORD Type, Value, Bytes = 4; lResult = RegQueryValueEx(hKeyResults,"Use Default Plugin Dir",0,&Type,(LPBYTE)(&Value),&Bytes); if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; } SendMessage(GetDlgItem(hDlg,Value?IDC_PLUGIN_DEFAULT:IDC_PLUGIN_OTHER),BM_SETCHECK, BST_CHECKED,0); lResult = RegQueryValueEx(hKeyResults,"Use Default Rom Dir",0,&Type,(LPBYTE)(&Value),&Bytes); if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = FALSE; } SendMessage(GetDlgItem(hDlg,Value?IDC_ROM_DEFAULT:IDC_ROM_OTHER),BM_SETCHECK, BST_CHECKED,0); lResult = RegQueryValueEx(hKeyResults,"Use Default Auto Save Dir",0,&Type,(LPBYTE)(&Value),&Bytes); if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; } SendMessage(GetDlgItem(hDlg,Value?IDC_AUTO_DEFAULT:IDC_AUTO_OTHER),BM_SETCHECK, BST_CHECKED,0); lResult = RegQueryValueEx(hKeyResults,"Use Default Instant Save Dir",0,&Type,(LPBYTE)(&Value),&Bytes); if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; } SendMessage(GetDlgItem(hDlg,Value?IDC_INSTANT_DEFAULT:IDC_INSTANT_OTHER),BM_SETCHECK, BST_CHECKED,0); lResult = RegQueryValueEx(hKeyResults,"Use Default Snap Shot Dir",0,&Type,(LPBYTE)(&Value),&Bytes); if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; } SendMessage(GetDlgItem(hDlg,Value?IDC_SNAP_DEFAULT:IDC_SNAP_OTHER),BM_SETCHECK, BST_CHECKED,0); Bytes = sizeof(Directory); lResult = RegQueryValueEx(hKeyResults,"Plugin Directory",0,&Type,(LPBYTE)Directory,&Bytes); if (lResult != ERROR_SUCCESS) { GetPluginDir(Directory ); } SetDlgItemText(hDlg,IDC_PLUGIN_DIR,Directory); Bytes = sizeof(Directory); lResult = RegQueryValueEx(hKeyResults,"Instant Save Directory",0,&Type,(LPBYTE)Directory,&Bytes); if (lResult != ERROR_SUCCESS) { GetInstantSaveDir(Directory); } SetDlgItemText(hDlg,IDC_INSTANT_DIR,Directory); Bytes = sizeof(Directory); lResult = RegQueryValueEx(hKeyResults,"Auto Save Directory",0,&Type,(LPBYTE)Directory,&Bytes); if (lResult != ERROR_SUCCESS) { GetAutoSaveDir(Directory); } SetDlgItemText(hDlg,IDC_AUTO_DIR,Directory); Bytes = sizeof(Directory); lResult = RegQueryValueEx(hKeyResults,"Snap Shot Directory",0,&Type,(LPBYTE)Directory,&Bytes); if (lResult != ERROR_SUCCESS) { GetSnapShotDir(Directory); } SetDlgItemText(hDlg,IDC_SNAP_DIR,Directory); } else { SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_DEFAULT),BM_SETCHECK, BST_CHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_ROM_DEFAULT),BM_SETCHECK, BST_CHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_AUTO_DEFAULT),BM_SETCHECK, BST_CHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_INSTANT_DEFAULT),BM_SETCHECK, BST_CHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_SNAP_DEFAULT),BM_SETCHECK, BST_CHECKED,0); GetPluginDir(Directory ); SetDlgItemText(hDlg,IDC_PLUGIN_DIR,Directory); GetInstantSaveDir(Directory); SetDlgItemText(hDlg,IDC_INSTANT_DIR,Directory); GetAutoSaveDir(Directory); SetDlgItemText(hDlg,IDC_AUTO_DIR,Directory); GetSnapShotDir(Directory); SetDlgItemText(hDlg,IDC_SNAP_DIR,Directory); } GetRomDirectory( Directory ); SetDlgItemText(hDlg,IDC_ROM_DIR,Directory); SetDlgItemText(hDlg,IDC_DIR_FRAME1,GS(DIR_PLUGIN)); SetDlgItemText(hDlg,IDC_DIR_FRAME2,GS(DIR_ROM)); SetDlgItemText(hDlg,IDC_DIR_FRAME3,GS(DIR_AUTO_SAVE)); SetDlgItemText(hDlg,IDC_DIR_FRAME4,GS(DIR_INSTANT_SAVE)); SetDlgItemText(hDlg,IDC_DIR_FRAME5,GS(DIR_SCREEN_SHOT)); SetDlgItemText(hDlg,IDC_ROM_DEFAULT,GS(DIR_ROM_DEFAULT)); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SELECT_PLUGIN_DIR: case IDC_SELECT_ROM_DIR: case IDC_SELECT_INSTANT_DIR: case IDC_SELECT_AUTO_DIR: case IDC_SELECT_SNAP_DIR: { char Buffer[MAX_PATH], Directory[255], Title[255]; LPITEMIDLIST pidl; BROWSEINFO bi; switch (LOWORD(wParam)) { case IDC_SELECT_PLUGIN_DIR: strcpy(Title,GS(DIR_SELECT_PLUGIN)); GetPluginDir(Directory); break; case IDC_SELECT_ROM_DIR: GetRomDirectory(Directory); strcpy(Title,GS(DIR_SELECT_ROM)); break; case IDC_SELECT_AUTO_DIR: GetAutoSaveDir(Directory); strcpy(Title,GS(DIR_SELECT_AUTO)); break; case IDC_SELECT_INSTANT_DIR: GetInstantSaveDir(Directory); strcpy(Title,GS(DIR_SELECT_INSTANT)); break; case IDC_SELECT_SNAP_DIR: GetSnapShotDir(Directory); strcpy(Title,GS(DIR_SELECT_SCREEN)); break; } bi.hwndOwner = hDlg; bi.pidlRoot = NULL; bi.pszDisplayName = Buffer; bi.lpszTitle = Title; bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = (BFFCALLBACK)SelectDirCallBack; bi.lParam = (DWORD)Directory; if ((pidl = SHBrowseForFolder(&bi)) != NULL) { if (SHGetPathFromIDList(pidl, Directory)) { int len = strlen(Directory); if (Directory[len - 1] != '\\') { strcat(Directory,"\\"); } switch (LOWORD(wParam)) { case IDC_SELECT_PLUGIN_DIR: SetDlgItemText(hDlg,IDC_PLUGIN_DIR,Directory); SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_OTHER),BM_SETCHECK, BST_CHECKED,0); break; case IDC_SELECT_ROM_DIR: SetDlgItemText(hDlg,IDC_ROM_DIR,Directory); SendMessage(GetDlgItem(hDlg,IDC_ROM_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_ROM_OTHER),BM_SETCHECK, BST_CHECKED,0); break; case IDC_SELECT_INSTANT_DIR: SetDlgItemText(hDlg,IDC_INSTANT_DIR,Directory); SendMessage(GetDlgItem(hDlg,IDC_INSTANT_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_INSTANT_OTHER),BM_SETCHECK, BST_CHECKED,0); break; case IDC_SELECT_AUTO_DIR: SetDlgItemText(hDlg,IDC_AUTO_DIR,Directory); SendMessage(GetDlgItem(hDlg,IDC_AUTO_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_AUTO_OTHER),BM_SETCHECK, BST_CHECKED,0); break; case IDC_SELECT_SNAP_DIR: SetDlgItemText(hDlg,IDC_SNAP_DIR,Directory); SendMessage(GetDlgItem(hDlg,IDC_SNAP_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); SendMessage(GetDlgItem(hDlg,IDC_SNAP_OTHER),BM_SETCHECK, BST_CHECKED,0); break; } } } } break; } break; case WM_NOTIFY: if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { long lResult; HKEY hKeyResults = 0; DWORD Disposition = 0; char String[200]; sprintf(String,"Software\\N64 Emulation\\%s",AppName); lResult = RegCreateKeyEx( HKEY_CURRENT_USER, String,0,"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition); if (lResult == ERROR_SUCCESS) { DWORD Value; Value = SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_DEFAULT),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE; RegSetValueEx(hKeyResults,"Use Default Plugin Dir",0,REG_DWORD,(BYTE *)&Value,sizeof(DWORD)); if (Value == FALSE) { GetDlgItemText(hDlg,IDC_PLUGIN_DIR,String,sizeof(String)); RegSetValueEx(hKeyResults,"Plugin Directory",0,REG_SZ,(CONST BYTE *)String,strlen(String)); } Value = SendMessage(GetDlgItem(hDlg,IDC_ROM_DEFAULT),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE; RegSetValueEx(hKeyResults,"Use Default Rom Dir",0,REG_DWORD,(BYTE *)&Value,sizeof(DWORD)); if (Value == FALSE) { GetDlgItemText(hDlg,IDC_ROM_DIR,String,sizeof(String)); RegSetValueEx(hKeyResults,"Rom Directory",0,REG_SZ,(CONST BYTE *)String,strlen(String)); } Value = SendMessage(GetDlgItem(hDlg,IDC_AUTO_DEFAULT),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE; RegSetValueEx(hKeyResults,"Use Default Auto Save Dir",0,REG_DWORD,(BYTE *)&Value,sizeof(DWORD)); if (Value == FALSE) { GetDlgItemText(hDlg,IDC_AUTO_DIR,String,sizeof(String)); RegSetValueEx(hKeyResults,"Auto Save Directory",0,REG_SZ,(CONST BYTE *)String,strlen(String)); } Value = SendMessage(GetDlgItem(hDlg,IDC_INSTANT_DEFAULT),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE; RegSetValueEx(hKeyResults,"Use Default Instant Save Dir",0,REG_DWORD,(BYTE *)&Value,sizeof(DWORD)); if (Value == FALSE) { GetDlgItemText(hDlg,IDC_INSTANT_DIR,String,sizeof(String)); RegSetValueEx(hKeyResults,"Instant Save Directory",0,REG_SZ,(CONST BYTE *)String,strlen(String)); } Value = SendMessage(GetDlgItem(hDlg,IDC_SNAP_DEFAULT),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE; RegSetValueEx(hKeyResults,"Use Default Snap Shot Dir",0,REG_DWORD,(BYTE *)&Value,sizeof(DWORD)); if (Value == FALSE) { GetDlgItemText(hDlg,IDC_SNAP_DIR,String,sizeof(String)); RegSetValueEx(hKeyResults,"Snap Shot Directory",0,REG_SZ,(CONST BYTE *)String,strlen(String)); } } RegCloseKey(hKeyResults); } break; default: return FALSE; } return TRUE; }
void Config_LoadRomConfig(unsigned char* header) { char line[4096]; char filename[PATH_MAX]; // get the name of the ROM for (int i=0; i<20; i++) config.romName[i] = header[0x20+i]; config.romName[20] = '\0'; while (config.romName[strlen(config.romName)-1] == ' ') { config.romName[strlen(config.romName)-1] = '\0'; } switch(header[0x3e]) { case 0x44: //Germany ('D') config.romPAL = true; break; case 0x45: //USA ('E') config.romPAL = false; break; case 0x4A: //= Japan ('J') config.romPAL = false; break; case 0x50: //= Europe ('P') config.romPAL = true; break; case 0x55: //= Australia ('U') config.romPAL = true; break; default: config.romPAL = false; break; } LOG(LOG_MINIMAL, "Rom is %s\n", config.romPAL ? "PAL" : "NTSC"); snprintf(filename, PATH_MAX, "%s/gles2n64rom.conf", GetPluginDir()); FILE *f = fopen(filename,"r"); if (!f) { LOG(LOG_MINIMAL, "Could not find %s Rom settings file, using global.\n", filename); return; } else { LOG(LOG_MINIMAL, "[gles2N64]: Searching %s Database for \"%s\" ROM\n", filename, config.romName); bool isRom = false; while (!feof(f)) { fgets(line, 4096, f); if (line[0] == '\n') continue; if (strncmp(line,"rom name=", 9) == 0) { char* v = strchr(line, '\n'); if (v) *v='\0'; isRom = (strcasecmp(config.romName, line+9) == 0); } else { if (isRom) { char* val = strchr(line, '='); if (!val) continue; *val++ = '\0'; Config_SetOption(line,val); } } } } }