From 60c1003845035ad4cd0e9ea50862bad7626faf0e Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 21 Sep 2002 18:47:46 +0000 Subject: Added the Pcsx source. --- PcsxSrc/Win32/ConfigurePlugins.c | 471 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 471 insertions(+) create mode 100644 PcsxSrc/Win32/ConfigurePlugins.c (limited to 'PcsxSrc/Win32/ConfigurePlugins.c') diff --git a/PcsxSrc/Win32/ConfigurePlugins.c b/PcsxSrc/Win32/ConfigurePlugins.c new file mode 100644 index 0000000..5399dc1 --- /dev/null +++ b/PcsxSrc/Win32/ConfigurePlugins.c @@ -0,0 +1,471 @@ +/* Pcsx - Pc Psx Emulator + * Copyright (C) 1999-2002 Pcsx Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include "PsxCommon.h" +#include "plugin.h" +#include "resource.h" +#include "Win32.h" + +#define QueryKeyV(s, name, var) \ + size = s; \ + if (RegQueryValueEx(myKey, name, 0, &type, (LPBYTE) var, &size) != 0) { if (err) { RegCloseKey(myKey); return -1; } } + +#define SetKeyV(name, var, s, t) \ + RegSetValueEx(myKey, name, 0, t, (LPBYTE) var, s); + +int LoadConfig() { + HKEY myKey; + DWORD type,size; + PcsxConfig *Conf = &Config; + int err; + + if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Pcsx",0,KEY_ALL_ACCESS,&myKey)!=ERROR_SUCCESS) return -1; + + err = 1; + QueryKeyV(256, "Bios", Conf->Bios); + QueryKeyV(256, "Gpu", Conf->Gpu); + QueryKeyV(256, "Spu", Conf->Spu); + QueryKeyV(256, "Cdr", Conf->Cdr); + QueryKeyV(256, "Pad1", Conf->Pad1); + QueryKeyV(256, "Pad2", Conf->Pad2); + QueryKeyV(256, "Mcd1", Conf->Mcd1); + QueryKeyV(256, "Mcd2", Conf->Mcd2); + QueryKeyV(256, "PluginsDir", Conf->PluginsDir); + QueryKeyV(256, "BiosDir", Conf->BiosDir); + err = 0; + QueryKeyV(sizeof(Conf->Xa), "Xa", &Conf->Xa); + QueryKeyV(sizeof(Conf->Sio), "Sio", &Conf->Sio); + QueryKeyV(sizeof(Conf->Mdec), "Mdec", &Conf->Mdec); + QueryKeyV(sizeof(Conf->PsxAuto), "PsxAuto", &Conf->PsxAuto); + QueryKeyV(sizeof(Conf->PsxType), "PsxType", &Conf->PsxType); + QueryKeyV(sizeof(Conf->QKeys), "QKeys", &Conf->QKeys); + QueryKeyV(sizeof(Conf->Cdda), "Cdda", &Conf->Cdda); + QueryKeyV(sizeof(Conf->Cpu), "Cpu", &Conf->Cpu); + QueryKeyV(sizeof(Conf->PsxOut), "PsxOut", &Conf->PsxOut); + QueryKeyV(sizeof(Conf->SpuIrq), "SpuIrq", &Conf->SpuIrq); + QueryKeyV(sizeof(Conf->CdTiming),"CdTiming",&Conf->CdTiming); + + RegCloseKey(myKey); + + return 0; +} + +///////////////////////////////////////////////////////// + +void SaveConfig() { + HKEY myKey; + DWORD myDisp; + PcsxConfig *Conf = &Config; + + RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Pcsx",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&myKey,&myDisp); + + SetKeyV("Bios", Conf->Bios, strlen(Conf->Bios), REG_SZ); + SetKeyV("Gpu", Conf->Gpu, strlen(Conf->Gpu), REG_SZ); + SetKeyV("Spu", Conf->Spu, strlen(Conf->Spu), REG_SZ); + SetKeyV("Cdr", Conf->Cdr, strlen(Conf->Cdr), REG_SZ); + SetKeyV("Pad1", Conf->Pad1, strlen(Conf->Pad1), REG_SZ); + SetKeyV("Pad2", Conf->Pad2, strlen(Conf->Pad2), REG_SZ); + SetKeyV("Mcd1", Conf->Mcd1, strlen(Conf->Mcd1), REG_SZ); + SetKeyV("Mcd2", Conf->Mcd2, strlen(Conf->Mcd2), REG_SZ); + SetKeyV("PluginsDir", Conf->PluginsDir, strlen(Conf->PluginsDir), REG_SZ); + SetKeyV("BiosDir", Conf->BiosDir, strlen(Conf->BiosDir), REG_SZ); + SetKeyV("Xa", &Conf->Xa, sizeof(Conf->Xa), REG_DWORD); + SetKeyV("Sio", &Conf->Sio, sizeof(Conf->Sio), REG_DWORD); + SetKeyV("Mdec", &Conf->Mdec, sizeof(Conf->Mdec), REG_DWORD); + SetKeyV("PsxAuto", &Conf->PsxAuto, sizeof(Conf->PsxAuto), REG_DWORD); + SetKeyV("PsxType", &Conf->PsxType, sizeof(Conf->PsxType), REG_DWORD); + SetKeyV("QKeys", &Conf->QKeys, sizeof(Conf->QKeys), REG_DWORD); + SetKeyV("Cdda", &Conf->Cdda, sizeof(Conf->Cdda), REG_DWORD); + SetKeyV("Cpu", &Conf->Cpu, sizeof(Conf->Cpu), REG_DWORD); + SetKeyV("PsxOut", &Conf->PsxOut, sizeof(Conf->PsxOut), REG_DWORD); + SetKeyV("SpuIrq", &Conf->SpuIrq, sizeof(Conf->SpuIrq), REG_DWORD); + SetKeyV("CdTiming",&Conf->CdTiming,sizeof(Conf->SpuIrq), REG_DWORD); + + RegCloseKey(myKey); +} + +///////////////////////////////////////////////////////// + +#define ComboAddPlugin(hw, str) { \ + lp = (char *)malloc(strlen(FindData.cFileName)+8); \ + sprintf(lp, "%s", FindData.cFileName); \ + i = ComboBox_AddString(hw, tmpStr); \ + ComboBox_SetItemData(hw, i, lp); \ + if (stricmp(str, lp)==0) \ + ComboBox_SetCurSel(hw, i); \ +} + +BOOL OnConfigurePluginsDialog(HWND hW) { + WIN32_FIND_DATA FindData; + HANDLE Find; + HANDLE Lib; + PSEgetLibType PSE_GetLibType; + PSEgetLibName PSE_GetLibName; + PSEgetLibVersion PSE_GetLibVersion; + HWND hWC_GPU=GetDlgItem(hW,IDC_LISTGPU); + HWND hWC_SPU=GetDlgItem(hW,IDC_LISTSPU); + HWND hWC_CDR=GetDlgItem(hW,IDC_LISTCDR); + HWND hWC_PAD1=GetDlgItem(hW,IDC_LISTPAD1); + HWND hWC_PAD2=GetDlgItem(hW,IDC_LISTPAD2); + HWND hWC_BIOS=GetDlgItem(hW,IDC_LISTBIOS); + char tmpStr[256]; + char *lp; + int i; + + strcpy(tmpStr, Config.PluginsDir); + strcat(tmpStr, "*.dll"); + Find = FindFirstFile(tmpStr, &FindData); + + do { + if (Find==INVALID_HANDLE_VALUE) break; + sprintf(tmpStr,"%s%s", Config.PluginsDir, FindData.cFileName); + Lib = LoadLibrary(tmpStr); + if (Lib!=NULL) { + PSE_GetLibType = (PSEgetLibType) GetProcAddress((HMODULE)Lib,"PSEgetLibType"); + PSE_GetLibName = (PSEgetLibName) GetProcAddress((HMODULE)Lib,"PSEgetLibName"); + PSE_GetLibVersion = (PSEgetLibVersion) GetProcAddress((HMODULE)Lib,"PSEgetLibVersion"); + + if (PSE_GetLibType != NULL && PSE_GetLibName != NULL && PSE_GetLibVersion != NULL) { + unsigned long version = PSE_GetLibVersion(); + long type; + + sprintf(tmpStr, "%s %d.%d", PSE_GetLibName(), (version>>8)&0xff, version&0xff); + type = PSE_GetLibType(); + if (type & PSE_LT_CDR) { + ComboAddPlugin(hWC_CDR, Config.Cdr); + } + + if (type & PSE_LT_SPU) { + ComboAddPlugin(hWC_SPU, Config.Spu); + } + + if (type & PSE_LT_GPU) { + ComboAddPlugin(hWC_GPU, Config.Gpu); + } + + if (type & PSE_LT_PAD) { + PADquery query; + + query = (PADquery)GetProcAddress((HMODULE)Lib, "PADquery"); + if (query() & 0x1) + ComboAddPlugin(hWC_PAD1, Config.Pad1); + if (query() & 0x2) + ComboAddPlugin(hWC_PAD2, Config.Pad2); + } + } + } + } while (FindNextFile(Find,&FindData)); + + if (Find!=INVALID_HANDLE_VALUE) FindClose(Find); + +// BIOS + + lp=(char *)malloc(strlen("HLE") + 1); + sprintf(lp, "HLE"); + i=ComboBox_AddString(hWC_BIOS, "Internal HLE Bios"); + ComboBox_SetItemData(hWC_BIOS, i, lp); + if (stricmp(Config.Bios, lp)==0) + ComboBox_SetCurSel(hWC_BIOS, i); + + strcpy(tmpStr, Config.BiosDir); + strcat(tmpStr, "*"); + Find=FindFirstFile(tmpStr, &FindData); + + do { + if (Find==INVALID_HANDLE_VALUE) break; + if (!strcmp(FindData.cFileName, ".")) continue; + if (!strcmp(FindData.cFileName, "..")) continue; + if (FindData.nFileSizeLow != 1024 * 512) continue; + lp = (char *)malloc(strlen(FindData.cFileName)+8); + sprintf(lp, "%s", (char *)FindData.cFileName); + i = ComboBox_AddString(hWC_BIOS, FindData.cFileName); + ComboBox_SetItemData(hWC_BIOS, i, lp); + if (stricmp(Config.Bios, FindData.cFileName)==0) + ComboBox_SetCurSel(hWC_BIOS, i); + } while (FindNextFile(Find,&FindData)); + + if (Find!=INVALID_HANDLE_VALUE) FindClose(Find); + + if (ComboBox_GetCurSel(hWC_CDR ) == -1) + ComboBox_SetCurSel(hWC_CDR, 0); + if (ComboBox_GetCurSel(hWC_GPU ) == -1) + ComboBox_SetCurSel(hWC_GPU, 0); + if (ComboBox_GetCurSel(hWC_SPU ) == -1) + ComboBox_SetCurSel(hWC_SPU, 0); + if (ComboBox_GetCurSel(hWC_PAD1) == -1) + ComboBox_SetCurSel(hWC_PAD1, 0); + if (ComboBox_GetCurSel(hWC_PAD2) == -1) + ComboBox_SetCurSel(hWC_PAD2, 0); + if (ComboBox_GetCurSel(hWC_BIOS) == -1) + ComboBox_SetCurSel(hWC_BIOS, 0); + + return TRUE; +} + +#define CleanCombo(item) \ + hWC = GetDlgItem(hW, item); \ + iCnt = ComboBox_GetCount(hWC); \ + for (i=0; i + +int SelectPath(HWND hW, char *Title, char *Path) { + LPITEMIDLIST pidl; + BROWSEINFO bi; + char Buffer[256]; + + bi.hwndOwner = hW; + bi.pidlRoot = NULL; + bi.pszDisplayName = Buffer; + bi.lpszTitle = Title; + bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; + bi.lpfn = NULL; + bi.lParam = 0; + if ((pidl = SHBrowseForFolder(&bi)) != NULL) { + if (SHGetPathFromIDList(pidl, Path)) { + int len = strlen(Path); + + if (Path[len - 1] != '\\') { strcat(Path,"\\"); } + return 0; + } + } + return -1; +} + +void SetPluginsDir(HWND hW) { + char Path[256]; + + if (SelectPath(hW, "Select Plugins Directory", Path) == -1) return; + strcpy(Config.PluginsDir, Path); + CleanUpCombos(hW); + OnConfigurePluginsDialog(hW); +} + +void SetBiosDir(HWND hW) { + char Path[256]; + + if (SelectPath(hW, "Select Bios Directory", Path) == -1) return; + strcpy(Config.BiosDir, Path); + CleanUpCombos(hW); + OnConfigurePluginsDialog(hW); +} + +BOOL CALLBACK ConfigurePluginsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { + switch(uMsg) { + case WM_INITDIALOG: + return OnConfigurePluginsDialog(hW); + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDC_CONFIGGPU: ConfigureGPU(hW); return TRUE; + case IDC_CONFIGSPU: ConfigureSPU(hW); return TRUE; + case IDC_CONFIGCDR: ConfigureCDR(hW); return TRUE; + case IDC_CONFIGPAD1: ConfigurePAD1(hW); return TRUE; + case IDC_CONFIGPAD2: ConfigurePAD2(hW); return TRUE; + + case IDC_TESTGPU: TestGPU(hW); return TRUE; + case IDC_TESTSPU: TestSPU(hW); return TRUE; + case IDC_TESTCDR: TestCDR(hW); return TRUE; + case IDC_TESTPAD1: TestPAD1(hW); return TRUE; + case IDC_TESTPAD2: TestPAD2(hW); return TRUE; + + case IDC_ABOUTGPU: AboutGPU(hW); return TRUE; + case IDC_ABOUTSPU: AboutSPU(hW); return TRUE; + case IDC_ABOUTCDR: AboutCDR(hW); return TRUE; + case IDC_ABOUTPAD1: AboutPAD1(hW); return TRUE; + case IDC_ABOUTPAD2: AboutPAD2(hW); return TRUE; + + case IDC_PLUGINSDIR: SetPluginsDir(hW); return TRUE; + case IDC_BIOSDIR: SetBiosDir(hW); return TRUE; + + case IDCANCEL: OnCancel(hW); return TRUE; + case IDOK: OnOK(hW); return TRUE; + } + } + return FALSE; +} + + +void ConfigurePlugins(HWND hWnd) { + DialogBox(gApp.hInstance, + MAKEINTRESOURCE(IDD_CONFIG), + hWnd, + (DLGPROC)ConfigurePluginsDlgProc); +} + -- cgit v1.2.3