summaryrefslogtreecommitdiff
path: root/PcsxSrc/Win32
diff options
context:
space:
mode:
Diffstat (limited to 'PcsxSrc/Win32')
-rw-r--r--PcsxSrc/Win32/AboutDlg.c88
-rw-r--r--PcsxSrc/Win32/AboutDlg.h46
-rw-r--r--PcsxSrc/Win32/ConfigurePlugins.c942
-rw-r--r--PcsxSrc/Win32/Win32.h94
-rw-r--r--PcsxSrc/Win32/WndMain.c2086
-rw-r--r--PcsxSrc/Win32/plugin.c402
-rw-r--r--PcsxSrc/Win32/plugin.h56
-rw-r--r--PcsxSrc/Win32/resource.h532
8 files changed, 2123 insertions, 2123 deletions
diff --git a/PcsxSrc/Win32/AboutDlg.c b/PcsxSrc/Win32/AboutDlg.c
index 0a93fae..b476396 100644
--- a/PcsxSrc/Win32/AboutDlg.c
+++ b/PcsxSrc/Win32/AboutDlg.c
@@ -1,44 +1,44 @@
-/* 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 <windows.h>
-#include <windowsx.h>
-#include "resource.h"
-#include "AboutDlg.h"
-
-LRESULT WINAPI AboutDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
- Static_SetText(GetDlgItem(hDlg, IDC_PCSX_ABOUT_TEXT), "P©SX EMU\nVersion " PCSX_VERSION);
- return TRUE;
- }
-
- case WM_COMMAND:
- switch(wParam)
- {
- case IDOK:
- EndDialog(hDlg, TRUE );
- return TRUE;
- }
- break;
- }
- return FALSE;
-}
+/* 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 <windows.h>
+#include <windowsx.h>
+#include "resource.h"
+#include "AboutDlg.h"
+
+LRESULT WINAPI AboutDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ Static_SetText(GetDlgItem(hDlg, IDC_PCSX_ABOUT_TEXT), "P©SX EMU\nVersion " PCSX_VERSION);
+ return TRUE;
+ }
+
+ case WM_COMMAND:
+ switch(wParam)
+ {
+ case IDOK:
+ EndDialog(hDlg, TRUE );
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/PcsxSrc/Win32/AboutDlg.h b/PcsxSrc/Win32/AboutDlg.h
index 4c71245..c85456d 100644
--- a/PcsxSrc/Win32/AboutDlg.h
+++ b/PcsxSrc/Win32/AboutDlg.h
@@ -1,24 +1,24 @@
-/* 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
- */
-
-#ifndef _PCSX_ABOUTDLG_H_
-#define _PCSX_ABOUTDLG_H_
-
-LRESULT WINAPI AboutDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
+/* 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
+ */
+
+#ifndef _PCSX_ABOUTDLG_H_
+#define _PCSX_ABOUTDLG_H_
+
+LRESULT WINAPI AboutDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
#endif \ No newline at end of file
diff --git a/PcsxSrc/Win32/ConfigurePlugins.c b/PcsxSrc/Win32/ConfigurePlugins.c
index 5399dc1..76cb189 100644
--- a/PcsxSrc/Win32/ConfigurePlugins.c
+++ b/PcsxSrc/Win32/ConfigurePlugins.c
@@ -1,471 +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 <windows.h>
-#include <windowsx.h>
-#include <stdio.h>
-#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<iCnt; i++) { \
- lp = (char *)ComboBox_GetItemData(hWC, i); \
- if (lp) free(lp); \
- } \
- ComboBox_ResetContent(hWC);
-
-void CleanUpCombos(HWND hW) {
- int i,iCnt;HWND hWC;char * lp;
-
- CleanCombo(IDC_LISTGPU);
- CleanCombo(IDC_LISTSPU);
- CleanCombo(IDC_LISTCDR);
- CleanCombo(IDC_LISTPAD1);
- CleanCombo(IDC_LISTPAD2);
- CleanCombo(IDC_LISTBIOS);
-}
-
-
-void OnCancel(HWND hW) {
- CleanUpCombos(hW);
- EndDialog(hW,FALSE);
-}
-
-
-char *GetSelDLL(HWND hW,int id) {
- HWND hWC = GetDlgItem(hW,id);
- int iSel;
- iSel = ComboBox_GetCurSel(hWC);
- if (iSel<0) return NULL;
- return (char *)ComboBox_GetItemData(hWC, iSel);
-}
-
-
-void OnOK(HWND hW) {
- char * gpuDLL=GetSelDLL(hW,IDC_LISTGPU);
- char * spuDLL=GetSelDLL(hW,IDC_LISTSPU);
- char * cdrDLL=GetSelDLL(hW,IDC_LISTCDR);
- char * pad1DLL=GetSelDLL(hW,IDC_LISTPAD1);
- char * pad2DLL=GetSelDLL(hW,IDC_LISTPAD2);
- char * biosFILE=GetSelDLL(hW,IDC_LISTBIOS);
-
- if ((gpuDLL==NULL) || (spuDLL ==NULL) ||
- (cdrDLL ==NULL) || (pad1DLL==NULL) ||
- (pad2DLL==NULL) ||(biosFILE==NULL)) {
- MessageBox(hW,"Configuration not OK!","Error",MB_OK|MB_ICONERROR);
- return;
- }
-
- strcpy(Config.Bios, biosFILE);
- strcpy(Config.Gpu, gpuDLL);
- strcpy(Config.Spu, spuDLL);
- strcpy(Config.Cdr, cdrDLL);
- strcpy(Config.Pad1, pad1DLL);
- strcpy(Config.Pad2, pad2DLL);
-
- SaveConfig();
-
- CleanUpCombos(hW);
-
- if (!ConfPlug) {
- NeedReset = 1;
- ReleasePlugins();
- LoadPlugins();
- }
- EndDialog(hW,TRUE);
-}
-
-
-#define ConfPlugin(src, confs, name) \
- void *drv; \
- src conf; \
- char * pDLL = GetSelDLL(hW, confs); \
- char file[256]; \
- if(pDLL==NULL) return; \
- strcpy(file, Config.PluginsDir); \
- strcat(file, pDLL); \
- drv = SysLoadLibrary(file); \
- if (drv == NULL) return; \
- conf = (src) SysLoadSym(drv, name); \
- if (SysLibError() == NULL) conf(); \
- SysCloseLibrary(drv);
-
-void ConfigureGPU(HWND hW) {
- ConfPlugin(GPUconfigure, IDC_LISTGPU, "GPUconfigure");
-}
-
-void ConfigureSPU(HWND hW) {
- ConfPlugin(SPUconfigure, IDC_LISTSPU, "SPUconfigure");
-}
-
-void ConfigureCDR(HWND hW) {
- ConfPlugin(CDRconfigure, IDC_LISTCDR, "CDRconfigure");
-}
-
-void ConfigurePAD1(HWND hW) {
- ConfPlugin(PADconfigure, IDC_LISTPAD1, "PADconfigure");
-}
-
-void ConfigurePAD2(HWND hW) {
- ConfPlugin(PADconfigure, IDC_LISTPAD2, "PADconfigure");
-}
-
-
-void AboutGPU(HWND hW) {
- ConfPlugin(GPUabout, IDC_LISTGPU, "GPUabout");
-}
-
-void AboutSPU(HWND hW) {
- ConfPlugin(SPUabout, IDC_LISTSPU, "SPUabout");
-}
-
-void AboutCDR(HWND hW) {
- ConfPlugin(CDRabout, IDC_LISTCDR, "CDRabout");
-}
-
-void AboutPAD1(HWND hW) {
- ConfPlugin(PADabout, IDC_LISTPAD1, "PADabout");
-}
-
-void AboutPAD2(HWND hW) {
- ConfPlugin(PADabout, IDC_LISTPAD2, "PADabout");
-}
-
-
-#define TestPlugin(src, confs, name) \
- void *drv; \
- src conf; \
- int ret = 0; \
- char * pDLL = GetSelDLL(hW, confs); \
- char file[256]; \
- if (pDLL== NULL) return; \
- strcpy(file, Config.PluginsDir); \
- strcat(file, pDLL); \
- drv = SysLoadLibrary(file); \
- if (drv == NULL) return; \
- conf = (src) SysLoadSym(drv, name); \
- if (SysLibError() == NULL) ret = conf(); \
- SysCloseLibrary(drv); \
- SysMessage("This plugin reports that should %swork correctly",ret == 0 ? "" : "not ");
-
-void TestGPU(HWND hW) {
- TestPlugin(GPUtest, IDC_LISTGPU, "GPUtest");
-}
-
-void TestSPU(HWND hW) {
- TestPlugin(SPUtest, IDC_LISTSPU, "SPUtest");
-}
-
-void TestCDR(HWND hW) {
- TestPlugin(CDRtest, IDC_LISTCDR, "CDRtest");
-}
-
-void TestPAD1(HWND hW) {
- TestPlugin(PADtest, IDC_LISTPAD1, "PADtest");
-}
-
-void TestPAD2(HWND hW) {
- TestPlugin(PADtest, IDC_LISTPAD2, "PADtest");
-}
-
-#include <shlobj.h>
-
-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);
-}
-
+/* 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 <windows.h>
+#include <windowsx.h>
+#include <stdio.h>
+#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<iCnt; i++) { \
+ lp = (char *)ComboBox_GetItemData(hWC, i); \
+ if (lp) free(lp); \
+ } \
+ ComboBox_ResetContent(hWC);
+
+void CleanUpCombos(HWND hW) {
+ int i,iCnt;HWND hWC;char * lp;
+
+ CleanCombo(IDC_LISTGPU);
+ CleanCombo(IDC_LISTSPU);
+ CleanCombo(IDC_LISTCDR);
+ CleanCombo(IDC_LISTPAD1);
+ CleanCombo(IDC_LISTPAD2);
+ CleanCombo(IDC_LISTBIOS);
+}
+
+
+void OnCancel(HWND hW) {
+ CleanUpCombos(hW);
+ EndDialog(hW,FALSE);
+}
+
+
+char *GetSelDLL(HWND hW,int id) {
+ HWND hWC = GetDlgItem(hW,id);
+ int iSel;
+ iSel = ComboBox_GetCurSel(hWC);
+ if (iSel<0) return NULL;
+ return (char *)ComboBox_GetItemData(hWC, iSel);
+}
+
+
+void OnOK(HWND hW) {
+ char * gpuDLL=GetSelDLL(hW,IDC_LISTGPU);
+ char * spuDLL=GetSelDLL(hW,IDC_LISTSPU);
+ char * cdrDLL=GetSelDLL(hW,IDC_LISTCDR);
+ char * pad1DLL=GetSelDLL(hW,IDC_LISTPAD1);
+ char * pad2DLL=GetSelDLL(hW,IDC_LISTPAD2);
+ char * biosFILE=GetSelDLL(hW,IDC_LISTBIOS);
+
+ if ((gpuDLL==NULL) || (spuDLL ==NULL) ||
+ (cdrDLL ==NULL) || (pad1DLL==NULL) ||
+ (pad2DLL==NULL) ||(biosFILE==NULL)) {
+ MessageBox(hW,"Configuration not OK!","Error",MB_OK|MB_ICONERROR);
+ return;
+ }
+
+ strcpy(Config.Bios, biosFILE);
+ strcpy(Config.Gpu, gpuDLL);
+ strcpy(Config.Spu, spuDLL);
+ strcpy(Config.Cdr, cdrDLL);
+ strcpy(Config.Pad1, pad1DLL);
+ strcpy(Config.Pad2, pad2DLL);
+
+ SaveConfig();
+
+ CleanUpCombos(hW);
+
+ if (!ConfPlug) {
+ NeedReset = 1;
+ ReleasePlugins();
+ LoadPlugins();
+ }
+ EndDialog(hW,TRUE);
+}
+
+
+#define ConfPlugin(src, confs, name) \
+ void *drv; \
+ src conf; \
+ char * pDLL = GetSelDLL(hW, confs); \
+ char file[256]; \
+ if(pDLL==NULL) return; \
+ strcpy(file, Config.PluginsDir); \
+ strcat(file, pDLL); \
+ drv = SysLoadLibrary(file); \
+ if (drv == NULL) return; \
+ conf = (src) SysLoadSym(drv, name); \
+ if (SysLibError() == NULL) conf(); \
+ SysCloseLibrary(drv);
+
+void ConfigureGPU(HWND hW) {
+ ConfPlugin(GPUconfigure, IDC_LISTGPU, "GPUconfigure");
+}
+
+void ConfigureSPU(HWND hW) {
+ ConfPlugin(SPUconfigure, IDC_LISTSPU, "SPUconfigure");
+}
+
+void ConfigureCDR(HWND hW) {
+ ConfPlugin(CDRconfigure, IDC_LISTCDR, "CDRconfigure");
+}
+
+void ConfigurePAD1(HWND hW) {
+ ConfPlugin(PADconfigure, IDC_LISTPAD1, "PADconfigure");
+}
+
+void ConfigurePAD2(HWND hW) {
+ ConfPlugin(PADconfigure, IDC_LISTPAD2, "PADconfigure");
+}
+
+
+void AboutGPU(HWND hW) {
+ ConfPlugin(GPUabout, IDC_LISTGPU, "GPUabout");
+}
+
+void AboutSPU(HWND hW) {
+ ConfPlugin(SPUabout, IDC_LISTSPU, "SPUabout");
+}
+
+void AboutCDR(HWND hW) {
+ ConfPlugin(CDRabout, IDC_LISTCDR, "CDRabout");
+}
+
+void AboutPAD1(HWND hW) {
+ ConfPlugin(PADabout, IDC_LISTPAD1, "PADabout");
+}
+
+void AboutPAD2(HWND hW) {
+ ConfPlugin(PADabout, IDC_LISTPAD2, "PADabout");
+}
+
+
+#define TestPlugin(src, confs, name) \
+ void *drv; \
+ src conf; \
+ int ret = 0; \
+ char * pDLL = GetSelDLL(hW, confs); \
+ char file[256]; \
+ if (pDLL== NULL) return; \
+ strcpy(file, Config.PluginsDir); \
+ strcat(file, pDLL); \
+ drv = SysLoadLibrary(file); \
+ if (drv == NULL) return; \
+ conf = (src) SysLoadSym(drv, name); \
+ if (SysLibError() == NULL) ret = conf(); \
+ SysCloseLibrary(drv); \
+ SysMessage("This plugin reports that should %swork correctly",ret == 0 ? "" : "not ");
+
+void TestGPU(HWND hW) {
+ TestPlugin(GPUtest, IDC_LISTGPU, "GPUtest");
+}
+
+void TestSPU(HWND hW) {
+ TestPlugin(SPUtest, IDC_LISTSPU, "SPUtest");
+}
+
+void TestCDR(HWND hW) {
+ TestPlugin(CDRtest, IDC_LISTCDR, "CDRtest");
+}
+
+void TestPAD1(HWND hW) {
+ TestPlugin(PADtest, IDC_LISTPAD1, "PADtest");
+}
+
+void TestPAD2(HWND hW) {
+ TestPlugin(PADtest, IDC_LISTPAD2, "PADtest");
+}
+
+#include <shlobj.h>
+
+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);
+}
+
diff --git a/PcsxSrc/Win32/Win32.h b/PcsxSrc/Win32/Win32.h
index 77954ad..75e35f9 100644
--- a/PcsxSrc/Win32/Win32.h
+++ b/PcsxSrc/Win32/Win32.h
@@ -1,48 +1,48 @@
-/* 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
- */
-
-#ifndef __WIN32_H__
-#define __WIN32_H__
-
-AppData gApp;
-HANDLE hConsole;
-
-long LoadCdBios;
-extern int StatesC;
-extern int AccBreak;
-extern int NeedReset;
-extern int ConfPlug;
-int Running;
-char PcsxDir[256];
-
-LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
-BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
-BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-void ConfigurePlugins(HWND hWnd);
-
-int Open_File_Proc(char *file);
-void Open_Mcd_Proc(HWND hW, int MCDID);
-void CreateMainWindow(int nCmdShow);
-void RunGui();
-void PADhandleKey(int key);
-
-int LoadConfig();
-void SaveConfig();
-
+/* 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
+ */
+
+#ifndef __WIN32_H__
+#define __WIN32_H__
+
+AppData gApp;
+HANDLE hConsole;
+
+long LoadCdBios;
+extern int StatesC;
+extern int AccBreak;
+extern int NeedReset;
+extern int ConfPlug;
+int Running;
+char PcsxDir[256];
+
+LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
+BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+void ConfigurePlugins(HWND hWnd);
+
+int Open_File_Proc(char *file);
+void Open_Mcd_Proc(HWND hW, int MCDID);
+void CreateMainWindow(int nCmdShow);
+void RunGui();
+void PADhandleKey(int key);
+
+int LoadConfig();
+void SaveConfig();
+
#endif /* __WIN32_H__ */ \ No newline at end of file
diff --git a/PcsxSrc/Win32/WndMain.c b/PcsxSrc/Win32/WndMain.c
index eaeab13..dde28da 100644
--- a/PcsxSrc/Win32/WndMain.c
+++ b/PcsxSrc/Win32/WndMain.c
@@ -1,1044 +1,1044 @@
-/* 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 <windows.h>
-#include <windowsx.h>
-#include <commctrl.h>
-#include <time.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "resource.h"
-#include "AboutDlg.h"
-
-#include "PsxCommon.h"
-#include "plugin.h"
-#include "Debug.h"
-#include "Win32.h"
-
-int AccBreak=0;
-int ConfPlug=0;
-int StatesC=0;
-int NeedReset=1;
-int cdOpenCase=0;
-
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
- gApp.hInstance = hInstance;
-
- Running=0;
-
- GetCurrentDirectory(256, PcsxDir);
-
- memset(&Config, 0, sizeof(PcsxConfig));
- if (LoadConfig() == -1) {
- Config.PsxAuto = 1;
- strcpy(Config.PluginsDir, "Plugin\\");
- strcpy(Config.BiosDir, "Bios\\");
- SysMessage("Pcsx needs to be configured");
- ConfPlug=1;
- ConfigurePlugins(gApp.hWnd);
- DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_MCDCONF), gApp.hWnd, (DLGPROC)ConfigureMcdsDlgProc);
- SysMessage("Pcsx now will quit, restart it");
- return 0;
- }
-
- if (SysInit() == -1) return 1;
-
- CreateMainWindow(nCmdShow);
-
- RunGui();
-
- return 0;
-}
-
-void RunGui() {
- MSG msg;
-
- PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
-
- for (;;) {
- if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-}
-
-void OpenConsole() {
- if (hConsole) return;
- AllocConsole();
- SetConsoleTitle("Psx Output");
- hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
-}
-
-void CloseConsole() {
- FreeConsole(); hConsole = NULL;
-}
-
-LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- char File[256];
-
- switch (msg) {
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case ID_FILE_EXIT:
- SysClose();
- PostQuitMessage(0);
- exit(0);
- return TRUE;
-
- case ID_FILE_RUN_CD:
- LoadCdBios = 0;
- SetMenu(hWnd, NULL);
- OpenPlugins(hWnd);
- SysReset();
- NeedReset = 0;
- CheckCdrom();
- if (LoadCdrom() == -1) {
- ClosePlugins();
- AccBreak = 1;
- DestroyWindow(gApp.hWnd);
- CreateMainWindow(SW_SHOWNORMAL);
- SetMenu(gApp.hWnd, gApp.hMenu);
- SetCursor(LoadCursor(gApp.hInstance, IDC_ARROW));
- ShowCursor(TRUE);
- SysMessage("Could not load Cdrom\n");
- return TRUE;
- }
- ShowCursor(FALSE);
- Running = 1;
- psxCpu->Execute();
- return TRUE;
-
- case ID_FILE_RUNCDBIOS:
- LoadCdBios = 1;
- SetMenu(hWnd, NULL);
- OpenPlugins(hWnd);
- ShowCursor(FALSE);
- CheckCdrom();
- SysReset();
- NeedReset = 0;
- Running = 1;
- psxCpu->Execute();
- return TRUE;
-
- case ID_FILE_RUN_EXE:
- if (!Open_File_Proc(File)) return TRUE;
- SetMenu(hWnd, NULL);
- OpenPlugins(hWnd);
- SysReset();
- NeedReset = 0;
- Load(File);
- Running = 1;
- psxCpu->Execute();
- return TRUE;
-
- case ID_EMULATOR_RUN:
- SetMenu(hWnd, NULL);
- OpenPlugins(hWnd);
- ShowCursor(FALSE);
- if (NeedReset) { SysReset(); NeedReset = 0; }
- Running = 1;
- psxCpu->Execute();
- return TRUE;
-
- case ID_EMULATOR_RESET:
- NeedReset = 1;
- return TRUE;
-
- case ID_CONFIGURATION_GRAPHICS:
- GPU_configure();
- return TRUE;
-
- case ID_CONFIGURATION_SOUND:
- SPU_configure();
- return TRUE;
-
- case ID_CONFIGURATION_CONTROLLERS:
- PAD1_configure();
- if (strcmp(Config.Pad1, Config.Pad2)) PAD2_configure();
- return TRUE;
-
- case ID_CONFIGURATION_CDROM:
- CDR_configure();
- return TRUE;
-
- case ID_CONFIGURATION_MEMORYCARDMANAGER:
- DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_MCDCONF), hWnd, (DLGPROC)ConfigureMcdsDlgProc);
- return TRUE;
-
- case ID_CONFIGURATION_CPU:
- DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_CPUCONF), hWnd, (DLGPROC)ConfigureCpuDlgProc);
- return TRUE;
-
- case ID_CONFIGURATION:
- ConfigurePlugins(hWnd);
- return TRUE;
-
- case ID_HELP_HELP:
- ShellExecute(NULL, "open", "Readme.txt", NULL, NULL, SW_SHOWNORMAL);
- return TRUE;
-
- case ID_HELP_ABOUT:
- DialogBox(gApp.hInstance, MAKEINTRESOURCE(ABOUT_DIALOG), hWnd, (DLGPROC)AboutDlgProc);
- return TRUE;
- }
- break;
-
- case WM_SYSKEYDOWN:
- if (wParam != VK_F10)
- return DefWindowProc(hWnd, msg, wParam, lParam);
- case WM_KEYDOWN:
- PADhandleKey(wParam);
- return TRUE;
-
- case WM_DESTROY:
- if (!AccBreak) {
- if (Running) ClosePlugins();
- SysClose();
- PostQuitMessage(0);
- exit(0);
- }
- else AccBreak = 0;
-
- return TRUE;
-
- case WM_CREATE:
- gApp.hMenu = LoadMenu(gApp.hInstance, MAKEINTRESOURCE(IDR_MENU1));
- SetMenu(hWnd, gApp.hMenu);
- break;
-
- case WM_QUIT:
- exit(0);
- break;
-
- default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
-
- return FALSE;
-}
-
-HWND mcdDlg;
-McdBlock Blocks[2][15];
-int IconC[2][15];
-HIMAGELIST Iiml[2];
-HICON eICON;
-
-void CreateListView(int idc) {
- HWND List;
- LV_COLUMN col;
-
- List = GetDlgItem(mcdDlg, idc);
-
- col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- col.fmt = LVCFMT_LEFT;
-
- col.pszText = "Title";
- col.cx = 170;
- col.iSubItem = 0;
-
- ListView_InsertColumn(List, 0, &col);
-
- col.pszText = "Status";
- col.cx = 50;
- col.iSubItem = 1;
-
- ListView_InsertColumn(List, 1, &col);
-
- col.pszText = "Game ID";
- col.cx = 90;
- col.iSubItem = 2;
-
- ListView_InsertColumn(List, 2, &col);
-
- col.pszText = "Game";
- col.cx = 80;
- col.iSubItem = 3;
-
- ListView_InsertColumn(List, 3, &col);
-}
-
-int GetRGB() {
- HDC scrDC, memDC;
- HBITMAP oldBmp = NULL;
- HBITMAP curBmp = NULL;
- COLORREF oldColor;
- COLORREF curColor = RGB(255,255,255);
- int i, R, G, B;
-
- R = G = B = 1;
-
- scrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
- memDC = CreateCompatibleDC(NULL);
- curBmp = CreateCompatibleBitmap(scrDC, 1, 1);
- oldBmp = (HBITMAP)SelectObject(memDC, curBmp);
-
- for (i = 255; i >= 0; --i) {
- oldColor = curColor;
- curColor = SetPixel(memDC, 0, 0, RGB(i, i, i));
-
- if (GetRValue(curColor) < GetRValue(oldColor)) ++R;
- if (GetGValue(curColor) < GetGValue(oldColor)) ++G;
- if (GetBValue(curColor) < GetBValue(oldColor)) ++B;
- }
-
- DeleteObject(oldBmp);
- DeleteObject(curBmp);
- DeleteDC(scrDC);
- DeleteDC(memDC);
-
- return (R * G * B);
-}
-
-HICON GetIcon(short *icon) {
- ICONINFO iInfo;
- HDC hDC;
- char mask[16*16];
- int x, y, c, Depth;
-
- hDC = CreateIC("DISPLAY",NULL,NULL,NULL);
- Depth=GetDeviceCaps(hDC, BITSPIXEL);
- DeleteDC(hDC);
-
- if (Depth == 16) {
- if (GetRGB() == (32 * 32 * 32))
- Depth = 15;
- }
-
- for (y=0; y<16; y++) {
- for (x=0; x<16; x++) {
- c = icon[y*16+x];
- if (Depth == 15)
- c = ((c&0x001f) << 10) | ((c&0x7c00) >> 10) | (c&0x03e0);
- else
- c = (c&0x001f) | ((c&0x7c00) << 1) | ((c&0x03e0) << 1);
-
- icon[y*16+x] = c;
- }
- }
-
- iInfo.fIcon = TRUE;
- memset(mask, 0, 16*16);
- iInfo.hbmMask = CreateBitmap(16, 16, 1, 1, mask);
- iInfo.hbmColor = CreateBitmap(16, 16, 1, 16, icon);
-
- return CreateIconIndirect(&iInfo);
-}
-
-HICON hICON[2][3][15];
-int aIover[2];
-int ani[2];
-
-void LoadMcdItems(int mcd, int idc) {
- HWND List = GetDlgItem(mcdDlg, idc);
- LV_ITEM item;
- HIMAGELIST iml = Iiml[mcd-1];
- int i, j;
- HICON hIcon;
- McdBlock *Info;
-
- aIover[mcd-1]=0;
- ani[mcd-1]=0;
-
- ListView_DeleteAllItems(List);
-
- for (i=0; i<15; i++) {
-
- item.mask = LVIF_TEXT | LVIF_IMAGE;
- item.iItem = i;
- item.iImage = i;
- item.pszText = LPSTR_TEXTCALLBACK;
- item.iSubItem = 0;
-
- IconC[mcd-1][i] = 0;
- Info = &Blocks[mcd-1][i];
-
- if ((Info->Flags & 0xF) == 1 && Info->IconCount != 0) {
- hIcon = GetIcon(Info->Icon);
-
- if (Info->IconCount > 1) {
- for(j = 0; j < 3; j++)
- hICON[mcd-1][j][i]=hIcon;
- }
- } else {
- hIcon = eICON;
- }
-
- ImageList_ReplaceIcon(iml, -1, hIcon);
- ListView_InsertItem(List, &item);
- }
-}
-
-void UpdateMcdItems(int mcd, int idc) {
- HWND List = GetDlgItem(mcdDlg, idc);
- LV_ITEM item;
- HIMAGELIST iml = Iiml[mcd-1];
- int i, j;
- McdBlock *Info;
- HICON hIcon;
-
- aIover[mcd-1]=0;
- ani[mcd-1]=0;
-
- for (i=0; i<15; i++) {
-
- item.mask = LVIF_TEXT | LVIF_IMAGE;
- item.iItem = i;
- item.iImage = i;
- item.pszText = LPSTR_TEXTCALLBACK;
- item.iSubItem = 0;
-
- IconC[mcd-1][i] = 0;
- Info = &Blocks[mcd-1][i];
-
- if ((Info->Flags & 0xF) == 1 && Info->IconCount != 0) {
- hIcon = GetIcon(Info->Icon);
-
- if (Info->IconCount > 1) {
- for(j = 0; j < 3; j++)
- hICON[mcd-1][j][i]=hIcon;
- }
- } else {
- hIcon = eICON;
- }
-
- ImageList_ReplaceIcon(iml, i, hIcon);
- ListView_SetItem(List, &item);
- }
- ListView_Update(List, -1);
-}
-
-void McdListGetDispInfo(int mcd, int idc, LPNMHDR pnmh) {
- LV_DISPINFO *lpdi = (LV_DISPINFO *)pnmh;
- McdBlock *Info;
-
- Info = &Blocks[mcd-1][lpdi->item.iItem];
-
- switch (lpdi->item.iSubItem) {
- case 0:
- switch (Info->Flags & 0xF) {
- case 1:
- lpdi->item.pszText = Info->Title;
- break;
- case 2:
- lpdi->item.pszText = "mid link block";
- break;
- case 3:
- lpdi->item.pszText = "terminiting link block";
- break;
- }
- break;
- case 1:
- if ((Info->Flags & 0xF0) == 0xA0) {
- if ((Info->Flags & 0xF) >= 1 &&
- (Info->Flags & 0xF) <= 3) {
- lpdi->item.pszText = "Deleted";
- } else lpdi->item.pszText = "Free";
- } else if ((Info->Flags & 0xF0) == 0x50)
- lpdi->item.pszText = "Used";
- else { lpdi->item.pszText = "Free"; }
- break;
- case 2:
- if((Info->Flags & 0xF)==1)
- lpdi->item.pszText = Info->ID;
- break;
- case 3:
- if((Info->Flags & 0xF)==1)
- lpdi->item.pszText = Info->Name;
- break;
- }
-}
-
-void McdListNotify(int mcd, int idc, LPNMHDR pnmh) {
- switch (pnmh->code) {
- case LVN_GETDISPINFO: McdListGetDispInfo(mcd, idc, pnmh); break;
- }
-}
-
-void UpdateMcdDlg() {
- int i;
-
- for (i=1; i<16; i++) GetMcdBlockInfo(1, i, &Blocks[0][i-1]);
- for (i=1; i<16; i++) GetMcdBlockInfo(2, i, &Blocks[1][i-1]);
- UpdateMcdItems(1, IDC_LIST1);
- UpdateMcdItems(2, IDC_LIST2);
-}
-
-void LoadMcdDlg() {
- int i;
-
- for (i=1; i<16; i++) GetMcdBlockInfo(1, i, &Blocks[0][i-1]);
- for (i=1; i<16; i++) GetMcdBlockInfo(2, i, &Blocks[1][i-1]);
- LoadMcdItems(1, IDC_LIST1);
- LoadMcdItems(2, IDC_LIST2);
-}
-
-void UpdateMcdIcon(int mcd, int idc) {
- HWND List = GetDlgItem(mcdDlg, idc);
- HIMAGELIST iml = Iiml[mcd-1];
- int i;
- McdBlock *Info;
- int *count;
-
- if(!aIover[mcd-1]) {
- ani[mcd-1]++;
-
- for (i=0; i<15; i++) {
- Info = &Blocks[mcd-1][i];
- count = &IconC[mcd-1][i];
-
- if ((Info->Flags & 0xF) != 1) continue;
- if (Info->IconCount <= 1) continue;
-
- if (*count < Info->IconCount) {
- (*count)++;
- aIover[mcd-1]=0;
-
- if(ani[mcd-1] <= (Info->IconCount-1)) // last frame and below...
- hICON[mcd-1][ani[mcd-1]][i] = GetIcon(&Info->Icon[(*count)*16*16]);
- } else {
- aIover[mcd-1]=1;
- }
- }
-
- } else {
-
- if (ani[mcd-1] > 1) ani[mcd-1] = 0; // 1st frame
- else ani[mcd-1]++; // 2nd, 3rd frame
-
- for(i=0;i<15;i++) {
-// RECT rect, hrect;
-
- Info = &Blocks[mcd-1][i];
-
- if (((Info->Flags & 0xF) == 1) && (Info->IconCount > 1))
- ImageList_ReplaceIcon(iml, i, hICON[mcd-1][ani[mcd-1]][i]);
-
-/* GetWindowRect(List, &hrect);
- ListView_GetItemRect(List, i, &rect, LVIR_ICON);
- rect.left+= hrect.left; rect.right+= hrect.left;
- rect.top+= hrect.top; rect.bottom+= hrect.top;
-
-// rect.left-= 12; rect.right-= 12; // quick fix
-
- InvalidateRect(mcdDlg, &rect, FALSE);*/
- }
- ListView_Update(List, 0);
- }
-}
-
-static int copy = 0, copymcd = 0;
-static int listsel = 0;
-
-BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- char str[256];
- LPBYTE lpAND, lpXOR;
- LPBYTE lpA, lpX;
- int i, j;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- mcdDlg = hW;
-
- lpA=lpAND=(LPBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(16*16));
- lpX=lpXOR=(LPBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(16*16));
-
- for(i=0;i<16;i++)
- {
- for(j=0;j<16;j++)
- {
- *lpA++=0xff;
- *lpX++=0;
- }
- }
- eICON=CreateIcon(gApp.hInstance,16,16,1,1,lpAND,lpXOR);
-
- HeapFree(GetProcessHeap(),0,lpAND);
- HeapFree(GetProcessHeap(),0,lpXOR);
-
- if (!strlen(Config.Mcd1)) strcpy(Config.Mcd1, "memcards\\Mcd001.mcr");
- if (!strlen(Config.Mcd2)) strcpy(Config.Mcd2, "memcards\\Mcd002.mcr");
- Edit_SetText(GetDlgItem(hW,IDC_MCD1), Config.Mcd1);
- Edit_SetText(GetDlgItem(hW,IDC_MCD2), Config.Mcd2);
-
- CreateListView(IDC_LIST1);
- CreateListView(IDC_LIST2);
-
- Iiml[0] = ImageList_Create(16, 16, ILC_COLOR16, 0, 0);
- Iiml[1] = ImageList_Create(16, 16, ILC_COLOR16, 0, 0);
-
- ListView_SetImageList(GetDlgItem(mcdDlg, IDC_LIST1), Iiml[0], LVSIL_SMALL);
- ListView_SetImageList(GetDlgItem(mcdDlg, IDC_LIST2), Iiml[1], LVSIL_SMALL);
-
- Button_Enable(GetDlgItem(hW, IDC_PASTE), FALSE);
-
- LoadMcdDlg();
-
- SetTimer(hW, 1, 250, NULL);
-
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_COPYTO1:
- copy = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST2));
- copymcd = 1;
-
- Button_Enable(GetDlgItem(hW, IDC_PASTE), TRUE);
- return TRUE;
- case IDC_COPYTO2:
- copy = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST1));
- copymcd = 2;
-
- Button_Enable(GetDlgItem(hW, IDC_PASTE), TRUE);
- return TRUE;
- case IDC_PASTE:
- if (MessageBox(hW, "Are you sure you want to paste this selection?", "Confirmation", MB_YESNO) == IDNO) return TRUE;
-
- if (copymcd == 1) {
- Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
- i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST1));
-
- // save dir data + save data
- memcpy(Mcd1Data + (i+1) * 128, Mcd2Data + (copy+1) * 128, 128);
- SaveMcd(str, Mcd1Data, (i+1) * 128, 128);
- memcpy(Mcd1Data + (i+1) * 1024 * 8, Mcd2Data + (copy+1) * 1024 * 8, 1024 * 8);
- SaveMcd(str, Mcd1Data, (i+1) * 1024 * 8, 1024 * 8);
- } else { // 2
- Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
- i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST2));
-
- // save dir data + save data
- memcpy(Mcd2Data + (i+1) * 128, Mcd1Data + (copy+1) * 128, 128);
- SaveMcd(str, Mcd2Data, (i+1) * 128, 128);
- memcpy(Mcd2Data + (i+1) * 1024 * 8, Mcd1Data + (copy+1) * 1024 * 8, 1024 * 8);
- SaveMcd(str, Mcd2Data, (i+1) * 1024 * 8, 1024 * 8);
- }
-
- UpdateMcdDlg();
-
- return TRUE;
- case IDC_DELETE1:
- {
- McdBlock *Info;
- int mcd = 1;
- int i, xor = 0, j;
- unsigned char *data, *ptr;
-
- Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
- i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST1));
- data = Mcd1Data;
-
- i++;
-
- ptr = data + i * 128;
-
- Info = &Blocks[mcd-1][i-1];
-
- if ((Info->Flags & 0xF0) == 0xA0) {
- if ((Info->Flags & 0xF) >= 1 &&
- (Info->Flags & 0xF) <= 3) { // deleted
- *ptr = 0x50 | (Info->Flags & 0xF);
- } else return TRUE;
- } else if ((Info->Flags & 0xF0) == 0x50) { // used
- *ptr = 0xA0 | (Info->Flags & 0xF);
- } else { return TRUE; }
-
- for (j=0; j<127; j++) xor^=*ptr++;
- *ptr = xor;
-
- SaveMcd(str, data, i * 128, 128);
- UpdateMcdDlg();
- }
-
- return TRUE;
- case IDC_DELETE2:
- {
- McdBlock *Info;
- int mcd = 2;
- int i, xor = 0, j;
- unsigned char *data, *ptr;
-
- Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
- i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST2));
- data = Mcd2Data;
-
- i++;
-
- ptr = data + i * 128;
-
- Info = &Blocks[mcd-1][i-1];
-
- if ((Info->Flags & 0xF0) == 0xA0) {
- if ((Info->Flags & 0xF) >= 1 &&
- (Info->Flags & 0xF) <= 3) { // deleted
- *ptr = 0x50 | (Info->Flags & 0xF);
- } else return TRUE;
- } else if ((Info->Flags & 0xF0) == 0x50) { // used
- *ptr = 0xA0 | (Info->Flags & 0xF);
- } else { return TRUE; }
-
- for (j=0; j<127; j++) xor^=*ptr++;
- *ptr = xor;
-
- SaveMcd(str, data, i * 128, 128);
- UpdateMcdDlg();
- }
-
- return TRUE;
-
- case IDC_MCDSEL1:
- Open_Mcd_Proc(hW, 1);
- return TRUE;
- case IDC_MCDSEL2:
- Open_Mcd_Proc(hW, 2);
- return TRUE;
- case IDC_RELOAD1:
- Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
- LoadMcd(1, str);
- UpdateMcdDlg();
- return TRUE;
- case IDC_RELOAD2:
- Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
- LoadMcd(2, str);
- UpdateMcdDlg();
- return TRUE;
- case IDC_FORMAT1:
- if (MessageBox(hW, "Are you sure you want to format this Memory Card?", "Confirmation", MB_YESNO) == IDNO) return TRUE;
- Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
- CreateMcd(str);
- LoadMcd(1, str);
- UpdateMcdDlg();
- return TRUE;
- case IDC_FORMAT2:
- if (MessageBox(hW, "Are you sure you want to format this Memory Card?", "Confirmation", MB_YESNO) == IDNO) return TRUE;
- Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
- CreateMcd(str);
- LoadMcd(2, str);
- UpdateMcdDlg();
- return TRUE;
- case IDCANCEL:
- LoadMcds(Config.Mcd1, Config.Mcd2);
-
- EndDialog(hW,FALSE);
-
- return TRUE;
- case IDOK:
- Edit_GetText(GetDlgItem(hW,IDC_MCD1), Config.Mcd1, 256);
- Edit_GetText(GetDlgItem(hW,IDC_MCD2), Config.Mcd2, 256);
-
- LoadMcds(Config.Mcd1, Config.Mcd2);
- SaveConfig();
-
- EndDialog(hW,TRUE);
-
- return TRUE;
- }
- case WM_NOTIFY:
- switch (wParam) {
- case IDC_LIST1: McdListNotify(1, IDC_LIST1, (LPNMHDR)lParam); break;
- case IDC_LIST2: McdListNotify(2, IDC_LIST2, (LPNMHDR)lParam); break;
- }
- return TRUE;
- case WM_TIMER:
- UpdateMcdIcon(1, IDC_LIST1);
- UpdateMcdIcon(2, IDC_LIST2);
- return TRUE;
- case WM_DESTROY:
- DestroyIcon(eICON);
- //KillTimer(hW, 1);
- return TRUE;
- }
- return FALSE;
-}
-
-BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- long tmp;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- Button_SetCheck(GetDlgItem(hW,IDC_XA), Config.Xa);
- Button_SetCheck(GetDlgItem(hW,IDC_SIO), Config.Sio);
- Button_SetCheck(GetDlgItem(hW,IDC_MDEC), Config.Mdec);
- Button_SetCheck(GetDlgItem(hW,IDC_QKEYS), Config.QKeys);
- Button_SetCheck(GetDlgItem(hW,IDC_CDDA), Config.Cdda);
- Button_SetCheck(GetDlgItem(hW,IDC_PSXAUTO), Config.PsxAuto);
- Button_SetCheck(GetDlgItem(hW,IDC_CPU), Config.Cpu);
- Button_SetCheck(GetDlgItem(hW,IDC_PSXOUT), Config.PsxOut);
- Button_SetCheck(GetDlgItem(hW,IDC_SPUIRQ), Config.SpuIrq);
- Button_SetCheck(GetDlgItem(hW,IDC_CDTIMING),Config.CdTiming);
- ComboBox_AddString(GetDlgItem(hW,IDC_PSXTYPES),"NTSC");
- ComboBox_AddString(GetDlgItem(hW,IDC_PSXTYPES),"PAL");
- ComboBox_SetCurSel(GetDlgItem(hW,IDC_PSXTYPES),Config.PsxType);
-
- case WM_COMMAND: {
- switch (LOWORD(wParam)) {
- case IDCANCEL: EndDialog(hW,FALSE); return TRUE;
- case IDOK:
- tmp = ComboBox_GetCurSel(GetDlgItem(hW,IDC_PSXTYPES));
- if (tmp == 0) Config.PsxType = 0;
- else Config.PsxType = 1;
-
- Config.Xa = Button_GetCheck(GetDlgItem(hW,IDC_XA));
- Config.Sio = Button_GetCheck(GetDlgItem(hW,IDC_SIO));
- Config.Mdec = Button_GetCheck(GetDlgItem(hW,IDC_MDEC));
- Config.QKeys = Button_GetCheck(GetDlgItem(hW,IDC_QKEYS));
- Config.Cdda = Button_GetCheck(GetDlgItem(hW,IDC_CDDA));
- Config.PsxAuto = Button_GetCheck(GetDlgItem(hW,IDC_PSXAUTO));
- tmp = Config.Cpu;
- Config.Cpu = Button_GetCheck(GetDlgItem(hW,IDC_CPU));
- if (tmp != Config.Cpu) {
- psxCpu->Shutdown();
- if (Config.Cpu)
- psxCpu = &psxInt;
- else psxCpu = &psxRec;
- if (psxCpu->Init() == -1) {
- SysClose();
- exit(1);
- }
- psxCpu->Reset();
- }
- Config.PsxOut = Button_GetCheck(GetDlgItem(hW,IDC_PSXOUT));
- Config.SpuIrq = Button_GetCheck(GetDlgItem(hW,IDC_SPUIRQ));
- Config.CdTiming= Button_GetCheck(GetDlgItem(hW,IDC_CDTIMING));
-
- SaveConfig();
-
- EndDialog(hW,TRUE);
-
- if (Config.PsxOut) OpenConsole();
- else CloseConsole();
-
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-#define MAXFILENAME 256
-
-void Open_Mcd_Proc(HWND hW, int mcd) {
- OPENFILENAME ofn;
- char szFileName[MAXFILENAME];
- char szFileTitle[MAXFILENAME];
-
- memset(&szFileName, 0, sizeof(szFileName));
- memset(&szFileTitle, 0, sizeof(szFileTitle));
-
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = hW;
- ofn.lpstrFilter = "Psx Mcd Format (*.mcr;*.mc;*.mem;*.vgs;*.mcd;*.gme;*.ddf)\0*.mcr;*.mcd;*.mem;*.gme;*.mc;*.ddf\0Psx Memory Card (*.mcr;*.mc)\0*.mcr;0*.mc\0CVGS Memory Card (*.mem;*.vgs)\0*.mem;*.vgs\0Bleem Memory Card (*.mcd)\0*.mcd\0DexDrive Memory Card (*.gme)\0*.gme\0DataDeck Memory Card (*.ddf)\0*.ddf\0";;
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = szFileName;
- ofn.nMaxFile = MAXFILENAME;
- ofn.lpstrInitialDir = "memcards";
- ofn.lpstrFileTitle = szFileTitle;
- ofn.nMaxFileTitle = MAXFILENAME;
- ofn.lpstrTitle = NULL;
- ofn.lpstrDefExt = "MCR";
- ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
-
- if (GetOpenFileName ((LPOPENFILENAME)&ofn)) {
- Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD1 : IDC_MCD2), szFileName);
- LoadMcd(mcd, szFileName);
- UpdateMcdDlg();
- }
-}
-
-int Open_File_Proc(char *file) {
- OPENFILENAME ofn;
- char szFileName[MAXFILENAME];
- char szFileTitle[MAXFILENAME];
-
- memset(&szFileName, 0, sizeof(szFileName));
- memset(&szFileTitle, 0, sizeof(szFileTitle));
-
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = gApp.hWnd;
- ofn.lpstrFilter = "Psx Exe Format\0*.*;*.*\0";
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = szFileName;
- ofn.nMaxFile = MAXFILENAME;
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrFileTitle = szFileTitle;
- ofn.nMaxFileTitle = MAXFILENAME;
- ofn.lpstrTitle = NULL;
- ofn.lpstrDefExt = "EXE";
- ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
-
- if (GetOpenFileName ((LPOPENFILENAME)&ofn)) {
- strcpy(file, szFileName);
- return 1;
- } else
- return 0;
-}
-
-void CreateMainWindow(int nCmdShow) {
- char strTitle[20];
- WNDCLASS wc;
- HWND hWnd;
- HDC hdc;
- HPEN hpen;
-
- LoadString(gApp.hInstance, IDS_TITLE, strTitle, 20);
-
- wc.lpszClassName = "P©SX Main";
- wc.lpfnWndProc = MainWndProc;
- wc.style = 0;
- wc.hInstance = gApp.hInstance;
- wc.hIcon = LoadIcon(gApp.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
- wc.hCursor = NULL;
- wc.hbrBackground = (HBRUSH)(COLOR_MENUTEXT);
- wc.lpszMenuName = 0;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
-
- RegisterClass(&wc);
-
- hWnd = CreateWindow("P©SX Main",
- strTitle,
- WS_OVERLAPPED | WS_SYSMENU,
- 20,
- 20,
- 320,
- 240,
- NULL,
- NULL,
- gApp.hInstance,
- NULL);
-
- gApp.hWnd = hWnd;
-
- hdc = GetDC(hWnd);
- hpen = CreatePen(PS_SOLID, 0, 0xffffff);
-
- SelectObject(hdc, hpen);
-
- ShowWindow(hWnd, nCmdShow);
-}
-
-int SysInit() {
- if (Config.PsxOut) OpenConsole();
-
- if (psxInit() == -1) return -1;
-
- #ifdef GTE_DUMP
- gteLog = fopen("gteLog.txt","w");
- #endif
-
-#ifdef EMU_LOG
- emuLog = fopen("emuLog.txt","w");
- setvbuf(emuLog, NULL, _IONBF, 0);
-#endif
-
- LoadPlugins();
- LoadMcds(Config.Mcd1, Config.Mcd2);
-
- return 0;
-}
-
-void SysReset() {
- psxReset();
-}
-
-
-void SysClose() {
- psxShutdown();
- ReleasePlugins();
-
- if (Config.PsxOut) CloseConsole();
-
- if (emuLog != NULL) fclose(emuLog);
- #ifdef GTE_DUMP
- if (gteLog != NULL) fclose(gteLog);
- #endif
-}
-
-void SysPrintf(char *fmt, ...) {
- va_list list;
- char msg[512];
- DWORD tmp;
-
- if (!hConsole) return;
-
- va_start(list,fmt);
- vsprintf(msg,fmt,list);
- va_end(list);
-
- WriteConsole(hConsole, msg, (DWORD)strlen(msg), &tmp, 0);
-#ifdef EMU_LOG
-#ifndef LOG_STDOUT
- fprintf(emuLog, "%s", msg);
-#endif
-#endif
-}
-
-void SysMessage(char *fmt, ...) {
- va_list list;
- char tmp[512];
-
- va_start(list,fmt);
- vsprintf(tmp,fmt,list);
- va_end(list);
- MessageBox(0, tmp, "Pcsx Msg", 0);
-}
-
-static char *err = "Error Loading Symbol";
-static int errval;
-
-void *SysLoadLibrary(char *lib) {
- return LoadLibrary(lib);
-}
-
-void *SysLoadSym(void *lib, char *sym) {
- void *tmp = GetProcAddress((HINSTANCE)lib, sym);
- if (tmp == NULL) errval = 1;
- else errval = 0;
- return tmp;
-}
-
-char *SysLibError() {
- if (errval) { errval = 0; return err; }
- return NULL;
-}
-
-void SysCloseLibrary(void *lib) {
- FreeLibrary((HINSTANCE)lib);
-}
-
-void SysUpdate() {
- MSG msg;
-
- PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
-
- while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-}
-
-void SysRunGui() {
- RunGui();
+/* 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 <windows.h>
+#include <windowsx.h>
+#include <commctrl.h>
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "resource.h"
+#include "AboutDlg.h"
+
+#include "PsxCommon.h"
+#include "plugin.h"
+#include "Debug.h"
+#include "Win32.h"
+
+int AccBreak=0;
+int ConfPlug=0;
+int StatesC=0;
+int NeedReset=1;
+int cdOpenCase=0;
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
+ gApp.hInstance = hInstance;
+
+ Running=0;
+
+ GetCurrentDirectory(256, PcsxDir);
+
+ memset(&Config, 0, sizeof(PcsxConfig));
+ if (LoadConfig() == -1) {
+ Config.PsxAuto = 1;
+ strcpy(Config.PluginsDir, "Plugin\\");
+ strcpy(Config.BiosDir, "Bios\\");
+ SysMessage("Pcsx needs to be configured");
+ ConfPlug=1;
+ ConfigurePlugins(gApp.hWnd);
+ DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_MCDCONF), gApp.hWnd, (DLGPROC)ConfigureMcdsDlgProc);
+ SysMessage("Pcsx now will quit, restart it");
+ return 0;
+ }
+
+ if (SysInit() == -1) return 1;
+
+ CreateMainWindow(nCmdShow);
+
+ RunGui();
+
+ return 0;
+}
+
+void RunGui() {
+ MSG msg;
+
+ PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
+
+ for (;;) {
+ if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+}
+
+void OpenConsole() {
+ if (hConsole) return;
+ AllocConsole();
+ SetConsoleTitle("Psx Output");
+ hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+}
+
+void CloseConsole() {
+ FreeConsole(); hConsole = NULL;
+}
+
+LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+ char File[256];
+
+ switch (msg) {
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case ID_FILE_EXIT:
+ SysClose();
+ PostQuitMessage(0);
+ exit(0);
+ return TRUE;
+
+ case ID_FILE_RUN_CD:
+ LoadCdBios = 0;
+ SetMenu(hWnd, NULL);
+ OpenPlugins(hWnd);
+ SysReset();
+ NeedReset = 0;
+ CheckCdrom();
+ if (LoadCdrom() == -1) {
+ ClosePlugins();
+ AccBreak = 1;
+ DestroyWindow(gApp.hWnd);
+ CreateMainWindow(SW_SHOWNORMAL);
+ SetMenu(gApp.hWnd, gApp.hMenu);
+ SetCursor(LoadCursor(gApp.hInstance, IDC_ARROW));
+ ShowCursor(TRUE);
+ SysMessage("Could not load Cdrom\n");
+ return TRUE;
+ }
+ ShowCursor(FALSE);
+ Running = 1;
+ psxCpu->Execute();
+ return TRUE;
+
+ case ID_FILE_RUNCDBIOS:
+ LoadCdBios = 1;
+ SetMenu(hWnd, NULL);
+ OpenPlugins(hWnd);
+ ShowCursor(FALSE);
+ CheckCdrom();
+ SysReset();
+ NeedReset = 0;
+ Running = 1;
+ psxCpu->Execute();
+ return TRUE;
+
+ case ID_FILE_RUN_EXE:
+ if (!Open_File_Proc(File)) return TRUE;
+ SetMenu(hWnd, NULL);
+ OpenPlugins(hWnd);
+ SysReset();
+ NeedReset = 0;
+ Load(File);
+ Running = 1;
+ psxCpu->Execute();
+ return TRUE;
+
+ case ID_EMULATOR_RUN:
+ SetMenu(hWnd, NULL);
+ OpenPlugins(hWnd);
+ ShowCursor(FALSE);
+ if (NeedReset) { SysReset(); NeedReset = 0; }
+ Running = 1;
+ psxCpu->Execute();
+ return TRUE;
+
+ case ID_EMULATOR_RESET:
+ NeedReset = 1;
+ return TRUE;
+
+ case ID_CONFIGURATION_GRAPHICS:
+ GPU_configure();
+ return TRUE;
+
+ case ID_CONFIGURATION_SOUND:
+ SPU_configure();
+ return TRUE;
+
+ case ID_CONFIGURATION_CONTROLLERS:
+ PAD1_configure();
+ if (strcmp(Config.Pad1, Config.Pad2)) PAD2_configure();
+ return TRUE;
+
+ case ID_CONFIGURATION_CDROM:
+ CDR_configure();
+ return TRUE;
+
+ case ID_CONFIGURATION_MEMORYCARDMANAGER:
+ DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_MCDCONF), hWnd, (DLGPROC)ConfigureMcdsDlgProc);
+ return TRUE;
+
+ case ID_CONFIGURATION_CPU:
+ DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_CPUCONF), hWnd, (DLGPROC)ConfigureCpuDlgProc);
+ return TRUE;
+
+ case ID_CONFIGURATION:
+ ConfigurePlugins(hWnd);
+ return TRUE;
+
+ case ID_HELP_HELP:
+ ShellExecute(NULL, "open", "Readme.txt", NULL, NULL, SW_SHOWNORMAL);
+ return TRUE;
+
+ case ID_HELP_ABOUT:
+ DialogBox(gApp.hInstance, MAKEINTRESOURCE(ABOUT_DIALOG), hWnd, (DLGPROC)AboutDlgProc);
+ return TRUE;
+ }
+ break;
+
+ case WM_SYSKEYDOWN:
+ if (wParam != VK_F10)
+ return DefWindowProc(hWnd, msg, wParam, lParam);
+ case WM_KEYDOWN:
+ PADhandleKey(wParam);
+ return TRUE;
+
+ case WM_DESTROY:
+ if (!AccBreak) {
+ if (Running) ClosePlugins();
+ SysClose();
+ PostQuitMessage(0);
+ exit(0);
+ }
+ else AccBreak = 0;
+
+ return TRUE;
+
+ case WM_CREATE:
+ gApp.hMenu = LoadMenu(gApp.hInstance, MAKEINTRESOURCE(IDR_MENU1));
+ SetMenu(hWnd, gApp.hMenu);
+ break;
+
+ case WM_QUIT:
+ exit(0);
+ break;
+
+ default:
+ return DefWindowProc(hWnd, msg, wParam, lParam);
+ }
+
+ return FALSE;
+}
+
+HWND mcdDlg;
+McdBlock Blocks[2][15];
+int IconC[2][15];
+HIMAGELIST Iiml[2];
+HICON eICON;
+
+void CreateListView(int idc) {
+ HWND List;
+ LV_COLUMN col;
+
+ List = GetDlgItem(mcdDlg, idc);
+
+ col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ col.fmt = LVCFMT_LEFT;
+
+ col.pszText = "Title";
+ col.cx = 170;
+ col.iSubItem = 0;
+
+ ListView_InsertColumn(List, 0, &col);
+
+ col.pszText = "Status";
+ col.cx = 50;
+ col.iSubItem = 1;
+
+ ListView_InsertColumn(List, 1, &col);
+
+ col.pszText = "Game ID";
+ col.cx = 90;
+ col.iSubItem = 2;
+
+ ListView_InsertColumn(List, 2, &col);
+
+ col.pszText = "Game";
+ col.cx = 80;
+ col.iSubItem = 3;
+
+ ListView_InsertColumn(List, 3, &col);
+}
+
+int GetRGB() {
+ HDC scrDC, memDC;
+ HBITMAP oldBmp = NULL;
+ HBITMAP curBmp = NULL;
+ COLORREF oldColor;
+ COLORREF curColor = RGB(255,255,255);
+ int i, R, G, B;
+
+ R = G = B = 1;
+
+ scrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
+ memDC = CreateCompatibleDC(NULL);
+ curBmp = CreateCompatibleBitmap(scrDC, 1, 1);
+ oldBmp = (HBITMAP)SelectObject(memDC, curBmp);
+
+ for (i = 255; i >= 0; --i) {
+ oldColor = curColor;
+ curColor = SetPixel(memDC, 0, 0, RGB(i, i, i));
+
+ if (GetRValue(curColor) < GetRValue(oldColor)) ++R;
+ if (GetGValue(curColor) < GetGValue(oldColor)) ++G;
+ if (GetBValue(curColor) < GetBValue(oldColor)) ++B;
+ }
+
+ DeleteObject(oldBmp);
+ DeleteObject(curBmp);
+ DeleteDC(scrDC);
+ DeleteDC(memDC);
+
+ return (R * G * B);
+}
+
+HICON GetIcon(short *icon) {
+ ICONINFO iInfo;
+ HDC hDC;
+ char mask[16*16];
+ int x, y, c, Depth;
+
+ hDC = CreateIC("DISPLAY",NULL,NULL,NULL);
+ Depth=GetDeviceCaps(hDC, BITSPIXEL);
+ DeleteDC(hDC);
+
+ if (Depth == 16) {
+ if (GetRGB() == (32 * 32 * 32))
+ Depth = 15;
+ }
+
+ for (y=0; y<16; y++) {
+ for (x=0; x<16; x++) {
+ c = icon[y*16+x];
+ if (Depth == 15)
+ c = ((c&0x001f) << 10) | ((c&0x7c00) >> 10) | (c&0x03e0);
+ else
+ c = (c&0x001f) | ((c&0x7c00) << 1) | ((c&0x03e0) << 1);
+
+ icon[y*16+x] = c;
+ }
+ }
+
+ iInfo.fIcon = TRUE;
+ memset(mask, 0, 16*16);
+ iInfo.hbmMask = CreateBitmap(16, 16, 1, 1, mask);
+ iInfo.hbmColor = CreateBitmap(16, 16, 1, 16, icon);
+
+ return CreateIconIndirect(&iInfo);
+}
+
+HICON hICON[2][3][15];
+int aIover[2];
+int ani[2];
+
+void LoadMcdItems(int mcd, int idc) {
+ HWND List = GetDlgItem(mcdDlg, idc);
+ LV_ITEM item;
+ HIMAGELIST iml = Iiml[mcd-1];
+ int i, j;
+ HICON hIcon;
+ McdBlock *Info;
+
+ aIover[mcd-1]=0;
+ ani[mcd-1]=0;
+
+ ListView_DeleteAllItems(List);
+
+ for (i=0; i<15; i++) {
+
+ item.mask = LVIF_TEXT | LVIF_IMAGE;
+ item.iItem = i;
+ item.iImage = i;
+ item.pszText = LPSTR_TEXTCALLBACK;
+ item.iSubItem = 0;
+
+ IconC[mcd-1][i] = 0;
+ Info = &Blocks[mcd-1][i];
+
+ if ((Info->Flags & 0xF) == 1 && Info->IconCount != 0) {
+ hIcon = GetIcon(Info->Icon);
+
+ if (Info->IconCount > 1) {
+ for(j = 0; j < 3; j++)
+ hICON[mcd-1][j][i]=hIcon;
+ }
+ } else {
+ hIcon = eICON;
+ }
+
+ ImageList_ReplaceIcon(iml, -1, hIcon);
+ ListView_InsertItem(List, &item);
+ }
+}
+
+void UpdateMcdItems(int mcd, int idc) {
+ HWND List = GetDlgItem(mcdDlg, idc);
+ LV_ITEM item;
+ HIMAGELIST iml = Iiml[mcd-1];
+ int i, j;
+ McdBlock *Info;
+ HICON hIcon;
+
+ aIover[mcd-1]=0;
+ ani[mcd-1]=0;
+
+ for (i=0; i<15; i++) {
+
+ item.mask = LVIF_TEXT | LVIF_IMAGE;
+ item.iItem = i;
+ item.iImage = i;
+ item.pszText = LPSTR_TEXTCALLBACK;
+ item.iSubItem = 0;
+
+ IconC[mcd-1][i] = 0;
+ Info = &Blocks[mcd-1][i];
+
+ if ((Info->Flags & 0xF) == 1 && Info->IconCount != 0) {
+ hIcon = GetIcon(Info->Icon);
+
+ if (Info->IconCount > 1) {
+ for(j = 0; j < 3; j++)
+ hICON[mcd-1][j][i]=hIcon;
+ }
+ } else {
+ hIcon = eICON;
+ }
+
+ ImageList_ReplaceIcon(iml, i, hIcon);
+ ListView_SetItem(List, &item);
+ }
+ ListView_Update(List, -1);
+}
+
+void McdListGetDispInfo(int mcd, int idc, LPNMHDR pnmh) {
+ LV_DISPINFO *lpdi = (LV_DISPINFO *)pnmh;
+ McdBlock *Info;
+
+ Info = &Blocks[mcd-1][lpdi->item.iItem];
+
+ switch (lpdi->item.iSubItem) {
+ case 0:
+ switch (Info->Flags & 0xF) {
+ case 1:
+ lpdi->item.pszText = Info->Title;
+ break;
+ case 2:
+ lpdi->item.pszText = "mid link block";
+ break;
+ case 3:
+ lpdi->item.pszText = "terminiting link block";
+ break;
+ }
+ break;
+ case 1:
+ if ((Info->Flags & 0xF0) == 0xA0) {
+ if ((Info->Flags & 0xF) >= 1 &&
+ (Info->Flags & 0xF) <= 3) {
+ lpdi->item.pszText = "Deleted";
+ } else lpdi->item.pszText = "Free";
+ } else if ((Info->Flags & 0xF0) == 0x50)
+ lpdi->item.pszText = "Used";
+ else { lpdi->item.pszText = "Free"; }
+ break;
+ case 2:
+ if((Info->Flags & 0xF)==1)
+ lpdi->item.pszText = Info->ID;
+ break;
+ case 3:
+ if((Info->Flags & 0xF)==1)
+ lpdi->item.pszText = Info->Name;
+ break;
+ }
+}
+
+void McdListNotify(int mcd, int idc, LPNMHDR pnmh) {
+ switch (pnmh->code) {
+ case LVN_GETDISPINFO: McdListGetDispInfo(mcd, idc, pnmh); break;
+ }
+}
+
+void UpdateMcdDlg() {
+ int i;
+
+ for (i=1; i<16; i++) GetMcdBlockInfo(1, i, &Blocks[0][i-1]);
+ for (i=1; i<16; i++) GetMcdBlockInfo(2, i, &Blocks[1][i-1]);
+ UpdateMcdItems(1, IDC_LIST1);
+ UpdateMcdItems(2, IDC_LIST2);
+}
+
+void LoadMcdDlg() {
+ int i;
+
+ for (i=1; i<16; i++) GetMcdBlockInfo(1, i, &Blocks[0][i-1]);
+ for (i=1; i<16; i++) GetMcdBlockInfo(2, i, &Blocks[1][i-1]);
+ LoadMcdItems(1, IDC_LIST1);
+ LoadMcdItems(2, IDC_LIST2);
+}
+
+void UpdateMcdIcon(int mcd, int idc) {
+ HWND List = GetDlgItem(mcdDlg, idc);
+ HIMAGELIST iml = Iiml[mcd-1];
+ int i;
+ McdBlock *Info;
+ int *count;
+
+ if(!aIover[mcd-1]) {
+ ani[mcd-1]++;
+
+ for (i=0; i<15; i++) {
+ Info = &Blocks[mcd-1][i];
+ count = &IconC[mcd-1][i];
+
+ if ((Info->Flags & 0xF) != 1) continue;
+ if (Info->IconCount <= 1) continue;
+
+ if (*count < Info->IconCount) {
+ (*count)++;
+ aIover[mcd-1]=0;
+
+ if(ani[mcd-1] <= (Info->IconCount-1)) // last frame and below...
+ hICON[mcd-1][ani[mcd-1]][i] = GetIcon(&Info->Icon[(*count)*16*16]);
+ } else {
+ aIover[mcd-1]=1;
+ }
+ }
+
+ } else {
+
+ if (ani[mcd-1] > 1) ani[mcd-1] = 0; // 1st frame
+ else ani[mcd-1]++; // 2nd, 3rd frame
+
+ for(i=0;i<15;i++) {
+// RECT rect, hrect;
+
+ Info = &Blocks[mcd-1][i];
+
+ if (((Info->Flags & 0xF) == 1) && (Info->IconCount > 1))
+ ImageList_ReplaceIcon(iml, i, hICON[mcd-1][ani[mcd-1]][i]);
+
+/* GetWindowRect(List, &hrect);
+ ListView_GetItemRect(List, i, &rect, LVIR_ICON);
+ rect.left+= hrect.left; rect.right+= hrect.left;
+ rect.top+= hrect.top; rect.bottom+= hrect.top;
+
+// rect.left-= 12; rect.right-= 12; // quick fix
+
+ InvalidateRect(mcdDlg, &rect, FALSE);*/
+ }
+ ListView_Update(List, 0);
+ }
+}
+
+static int copy = 0, copymcd = 0;
+static int listsel = 0;
+
+BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
+ char str[256];
+ LPBYTE lpAND, lpXOR;
+ LPBYTE lpA, lpX;
+ int i, j;
+
+ switch(uMsg) {
+ case WM_INITDIALOG:
+ mcdDlg = hW;
+
+ lpA=lpAND=(LPBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(16*16));
+ lpX=lpXOR=(LPBYTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(16*16));
+
+ for(i=0;i<16;i++)
+ {
+ for(j=0;j<16;j++)
+ {
+ *lpA++=0xff;
+ *lpX++=0;
+ }
+ }
+ eICON=CreateIcon(gApp.hInstance,16,16,1,1,lpAND,lpXOR);
+
+ HeapFree(GetProcessHeap(),0,lpAND);
+ HeapFree(GetProcessHeap(),0,lpXOR);
+
+ if (!strlen(Config.Mcd1)) strcpy(Config.Mcd1, "memcards\\Mcd001.mcr");
+ if (!strlen(Config.Mcd2)) strcpy(Config.Mcd2, "memcards\\Mcd002.mcr");
+ Edit_SetText(GetDlgItem(hW,IDC_MCD1), Config.Mcd1);
+ Edit_SetText(GetDlgItem(hW,IDC_MCD2), Config.Mcd2);
+
+ CreateListView(IDC_LIST1);
+ CreateListView(IDC_LIST2);
+
+ Iiml[0] = ImageList_Create(16, 16, ILC_COLOR16, 0, 0);
+ Iiml[1] = ImageList_Create(16, 16, ILC_COLOR16, 0, 0);
+
+ ListView_SetImageList(GetDlgItem(mcdDlg, IDC_LIST1), Iiml[0], LVSIL_SMALL);
+ ListView_SetImageList(GetDlgItem(mcdDlg, IDC_LIST2), Iiml[1], LVSIL_SMALL);
+
+ Button_Enable(GetDlgItem(hW, IDC_PASTE), FALSE);
+
+ LoadMcdDlg();
+
+ SetTimer(hW, 1, 250, NULL);
+
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_COPYTO1:
+ copy = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST2));
+ copymcd = 1;
+
+ Button_Enable(GetDlgItem(hW, IDC_PASTE), TRUE);
+ return TRUE;
+ case IDC_COPYTO2:
+ copy = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST1));
+ copymcd = 2;
+
+ Button_Enable(GetDlgItem(hW, IDC_PASTE), TRUE);
+ return TRUE;
+ case IDC_PASTE:
+ if (MessageBox(hW, "Are you sure you want to paste this selection?", "Confirmation", MB_YESNO) == IDNO) return TRUE;
+
+ if (copymcd == 1) {
+ Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
+ i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST1));
+
+ // save dir data + save data
+ memcpy(Mcd1Data + (i+1) * 128, Mcd2Data + (copy+1) * 128, 128);
+ SaveMcd(str, Mcd1Data, (i+1) * 128, 128);
+ memcpy(Mcd1Data + (i+1) * 1024 * 8, Mcd2Data + (copy+1) * 1024 * 8, 1024 * 8);
+ SaveMcd(str, Mcd1Data, (i+1) * 1024 * 8, 1024 * 8);
+ } else { // 2
+ Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
+ i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST2));
+
+ // save dir data + save data
+ memcpy(Mcd2Data + (i+1) * 128, Mcd1Data + (copy+1) * 128, 128);
+ SaveMcd(str, Mcd2Data, (i+1) * 128, 128);
+ memcpy(Mcd2Data + (i+1) * 1024 * 8, Mcd1Data + (copy+1) * 1024 * 8, 1024 * 8);
+ SaveMcd(str, Mcd2Data, (i+1) * 1024 * 8, 1024 * 8);
+ }
+
+ UpdateMcdDlg();
+
+ return TRUE;
+ case IDC_DELETE1:
+ {
+ McdBlock *Info;
+ int mcd = 1;
+ int i, xor = 0, j;
+ unsigned char *data, *ptr;
+
+ Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
+ i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST1));
+ data = Mcd1Data;
+
+ i++;
+
+ ptr = data + i * 128;
+
+ Info = &Blocks[mcd-1][i-1];
+
+ if ((Info->Flags & 0xF0) == 0xA0) {
+ if ((Info->Flags & 0xF) >= 1 &&
+ (Info->Flags & 0xF) <= 3) { // deleted
+ *ptr = 0x50 | (Info->Flags & 0xF);
+ } else return TRUE;
+ } else if ((Info->Flags & 0xF0) == 0x50) { // used
+ *ptr = 0xA0 | (Info->Flags & 0xF);
+ } else { return TRUE; }
+
+ for (j=0; j<127; j++) xor^=*ptr++;
+ *ptr = xor;
+
+ SaveMcd(str, data, i * 128, 128);
+ UpdateMcdDlg();
+ }
+
+ return TRUE;
+ case IDC_DELETE2:
+ {
+ McdBlock *Info;
+ int mcd = 2;
+ int i, xor = 0, j;
+ unsigned char *data, *ptr;
+
+ Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
+ i = ListView_GetSelectionMark(GetDlgItem(mcdDlg, IDC_LIST2));
+ data = Mcd2Data;
+
+ i++;
+
+ ptr = data + i * 128;
+
+ Info = &Blocks[mcd-1][i-1];
+
+ if ((Info->Flags & 0xF0) == 0xA0) {
+ if ((Info->Flags & 0xF) >= 1 &&
+ (Info->Flags & 0xF) <= 3) { // deleted
+ *ptr = 0x50 | (Info->Flags & 0xF);
+ } else return TRUE;
+ } else if ((Info->Flags & 0xF0) == 0x50) { // used
+ *ptr = 0xA0 | (Info->Flags & 0xF);
+ } else { return TRUE; }
+
+ for (j=0; j<127; j++) xor^=*ptr++;
+ *ptr = xor;
+
+ SaveMcd(str, data, i * 128, 128);
+ UpdateMcdDlg();
+ }
+
+ return TRUE;
+
+ case IDC_MCDSEL1:
+ Open_Mcd_Proc(hW, 1);
+ return TRUE;
+ case IDC_MCDSEL2:
+ Open_Mcd_Proc(hW, 2);
+ return TRUE;
+ case IDC_RELOAD1:
+ Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
+ LoadMcd(1, str);
+ UpdateMcdDlg();
+ return TRUE;
+ case IDC_RELOAD2:
+ Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
+ LoadMcd(2, str);
+ UpdateMcdDlg();
+ return TRUE;
+ case IDC_FORMAT1:
+ if (MessageBox(hW, "Are you sure you want to format this Memory Card?", "Confirmation", MB_YESNO) == IDNO) return TRUE;
+ Edit_GetText(GetDlgItem(hW,IDC_MCD1), str, 256);
+ CreateMcd(str);
+ LoadMcd(1, str);
+ UpdateMcdDlg();
+ return TRUE;
+ case IDC_FORMAT2:
+ if (MessageBox(hW, "Are you sure you want to format this Memory Card?", "Confirmation", MB_YESNO) == IDNO) return TRUE;
+ Edit_GetText(GetDlgItem(hW,IDC_MCD2), str, 256);
+ CreateMcd(str);
+ LoadMcd(2, str);
+ UpdateMcdDlg();
+ return TRUE;
+ case IDCANCEL:
+ LoadMcds(Config.Mcd1, Config.Mcd2);
+
+ EndDialog(hW,FALSE);
+
+ return TRUE;
+ case IDOK:
+ Edit_GetText(GetDlgItem(hW,IDC_MCD1), Config.Mcd1, 256);
+ Edit_GetText(GetDlgItem(hW,IDC_MCD2), Config.Mcd2, 256);
+
+ LoadMcds(Config.Mcd1, Config.Mcd2);
+ SaveConfig();
+
+ EndDialog(hW,TRUE);
+
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ switch (wParam) {
+ case IDC_LIST1: McdListNotify(1, IDC_LIST1, (LPNMHDR)lParam); break;
+ case IDC_LIST2: McdListNotify(2, IDC_LIST2, (LPNMHDR)lParam); break;
+ }
+ return TRUE;
+ case WM_TIMER:
+ UpdateMcdIcon(1, IDC_LIST1);
+ UpdateMcdIcon(2, IDC_LIST2);
+ return TRUE;
+ case WM_DESTROY:
+ DestroyIcon(eICON);
+ //KillTimer(hW, 1);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
+ long tmp;
+
+ switch(uMsg) {
+ case WM_INITDIALOG:
+ Button_SetCheck(GetDlgItem(hW,IDC_XA), Config.Xa);
+ Button_SetCheck(GetDlgItem(hW,IDC_SIO), Config.Sio);
+ Button_SetCheck(GetDlgItem(hW,IDC_MDEC), Config.Mdec);
+ Button_SetCheck(GetDlgItem(hW,IDC_QKEYS), Config.QKeys);
+ Button_SetCheck(GetDlgItem(hW,IDC_CDDA), Config.Cdda);
+ Button_SetCheck(GetDlgItem(hW,IDC_PSXAUTO), Config.PsxAuto);
+ Button_SetCheck(GetDlgItem(hW,IDC_CPU), Config.Cpu);
+ Button_SetCheck(GetDlgItem(hW,IDC_PSXOUT), Config.PsxOut);
+ Button_SetCheck(GetDlgItem(hW,IDC_SPUIRQ), Config.SpuIrq);
+ Button_SetCheck(GetDlgItem(hW,IDC_CDTIMING),Config.CdTiming);
+ ComboBox_AddString(GetDlgItem(hW,IDC_PSXTYPES),"NTSC");
+ ComboBox_AddString(GetDlgItem(hW,IDC_PSXTYPES),"PAL");
+ ComboBox_SetCurSel(GetDlgItem(hW,IDC_PSXTYPES),Config.PsxType);
+
+ case WM_COMMAND: {
+ switch (LOWORD(wParam)) {
+ case IDCANCEL: EndDialog(hW,FALSE); return TRUE;
+ case IDOK:
+ tmp = ComboBox_GetCurSel(GetDlgItem(hW,IDC_PSXTYPES));
+ if (tmp == 0) Config.PsxType = 0;
+ else Config.PsxType = 1;
+
+ Config.Xa = Button_GetCheck(GetDlgItem(hW,IDC_XA));
+ Config.Sio = Button_GetCheck(GetDlgItem(hW,IDC_SIO));
+ Config.Mdec = Button_GetCheck(GetDlgItem(hW,IDC_MDEC));
+ Config.QKeys = Button_GetCheck(GetDlgItem(hW,IDC_QKEYS));
+ Config.Cdda = Button_GetCheck(GetDlgItem(hW,IDC_CDDA));
+ Config.PsxAuto = Button_GetCheck(GetDlgItem(hW,IDC_PSXAUTO));
+ tmp = Config.Cpu;
+ Config.Cpu = Button_GetCheck(GetDlgItem(hW,IDC_CPU));
+ if (tmp != Config.Cpu) {
+ psxCpu->Shutdown();
+ if (Config.Cpu)
+ psxCpu = &psxInt;
+ else psxCpu = &psxRec;
+ if (psxCpu->Init() == -1) {
+ SysClose();
+ exit(1);
+ }
+ psxCpu->Reset();
+ }
+ Config.PsxOut = Button_GetCheck(GetDlgItem(hW,IDC_PSXOUT));
+ Config.SpuIrq = Button_GetCheck(GetDlgItem(hW,IDC_SPUIRQ));
+ Config.CdTiming= Button_GetCheck(GetDlgItem(hW,IDC_CDTIMING));
+
+ SaveConfig();
+
+ EndDialog(hW,TRUE);
+
+ if (Config.PsxOut) OpenConsole();
+ else CloseConsole();
+
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+#define MAXFILENAME 256
+
+void Open_Mcd_Proc(HWND hW, int mcd) {
+ OPENFILENAME ofn;
+ char szFileName[MAXFILENAME];
+ char szFileTitle[MAXFILENAME];
+
+ memset(&szFileName, 0, sizeof(szFileName));
+ memset(&szFileTitle, 0, sizeof(szFileTitle));
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hW;
+ ofn.lpstrFilter = "Psx Mcd Format (*.mcr;*.mc;*.mem;*.vgs;*.mcd;*.gme;*.ddf)\0*.mcr;*.mcd;*.mem;*.gme;*.mc;*.ddf\0Psx Memory Card (*.mcr;*.mc)\0*.mcr;0*.mc\0CVGS Memory Card (*.mem;*.vgs)\0*.mem;*.vgs\0Bleem Memory Card (*.mcd)\0*.mcd\0DexDrive Memory Card (*.gme)\0*.gme\0DataDeck Memory Card (*.ddf)\0*.ddf\0";;
+ ofn.lpstrCustomFilter = NULL;
+ ofn.nMaxCustFilter = 0;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = szFileName;
+ ofn.nMaxFile = MAXFILENAME;
+ ofn.lpstrInitialDir = "memcards";
+ ofn.lpstrFileTitle = szFileTitle;
+ ofn.nMaxFileTitle = MAXFILENAME;
+ ofn.lpstrTitle = NULL;
+ ofn.lpstrDefExt = "MCR";
+ ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
+
+ if (GetOpenFileName ((LPOPENFILENAME)&ofn)) {
+ Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD1 : IDC_MCD2), szFileName);
+ LoadMcd(mcd, szFileName);
+ UpdateMcdDlg();
+ }
+}
+
+int Open_File_Proc(char *file) {
+ OPENFILENAME ofn;
+ char szFileName[MAXFILENAME];
+ char szFileTitle[MAXFILENAME];
+
+ memset(&szFileName, 0, sizeof(szFileName));
+ memset(&szFileTitle, 0, sizeof(szFileTitle));
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = gApp.hWnd;
+ ofn.lpstrFilter = "Psx Exe Format\0*.*;*.*\0";
+ ofn.lpstrCustomFilter = NULL;
+ ofn.nMaxCustFilter = 0;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = szFileName;
+ ofn.nMaxFile = MAXFILENAME;
+ ofn.lpstrInitialDir = NULL;
+ ofn.lpstrFileTitle = szFileTitle;
+ ofn.nMaxFileTitle = MAXFILENAME;
+ ofn.lpstrTitle = NULL;
+ ofn.lpstrDefExt = "EXE";
+ ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
+
+ if (GetOpenFileName ((LPOPENFILENAME)&ofn)) {
+ strcpy(file, szFileName);
+ return 1;
+ } else
+ return 0;
+}
+
+void CreateMainWindow(int nCmdShow) {
+ char strTitle[20];
+ WNDCLASS wc;
+ HWND hWnd;
+ HDC hdc;
+ HPEN hpen;
+
+ LoadString(gApp.hInstance, IDS_TITLE, strTitle, 20);
+
+ wc.lpszClassName = "P©SX Main";
+ wc.lpfnWndProc = MainWndProc;
+ wc.style = 0;
+ wc.hInstance = gApp.hInstance;
+ wc.hIcon = LoadIcon(gApp.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
+ wc.hCursor = NULL;
+ wc.hbrBackground = (HBRUSH)(COLOR_MENUTEXT);
+ wc.lpszMenuName = 0;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+
+ RegisterClass(&wc);
+
+ hWnd = CreateWindow("P©SX Main",
+ strTitle,
+ WS_OVERLAPPED | WS_SYSMENU,
+ 20,
+ 20,
+ 320,
+ 240,
+ NULL,
+ NULL,
+ gApp.hInstance,
+ NULL);
+
+ gApp.hWnd = hWnd;
+
+ hdc = GetDC(hWnd);
+ hpen = CreatePen(PS_SOLID, 0, 0xffffff);
+
+ SelectObject(hdc, hpen);
+
+ ShowWindow(hWnd, nCmdShow);
+}
+
+int SysInit() {
+ if (Config.PsxOut) OpenConsole();
+
+ if (psxInit() == -1) return -1;
+
+ #ifdef GTE_DUMP
+ gteLog = fopen("gteLog.txt","w");
+ #endif
+
+#ifdef EMU_LOG
+ emuLog = fopen("emuLog.txt","w");
+ setvbuf(emuLog, NULL, _IONBF, 0);
+#endif
+
+ LoadPlugins();
+ LoadMcds(Config.Mcd1, Config.Mcd2);
+
+ return 0;
+}
+
+void SysReset() {
+ psxReset();
+}
+
+
+void SysClose() {
+ psxShutdown();
+ ReleasePlugins();
+
+ if (Config.PsxOut) CloseConsole();
+
+ if (emuLog != NULL) fclose(emuLog);
+ #ifdef GTE_DUMP
+ if (gteLog != NULL) fclose(gteLog);
+ #endif
+}
+
+void SysPrintf(char *fmt, ...) {
+ va_list list;
+ char msg[512];
+ DWORD tmp;
+
+ if (!hConsole) return;
+
+ va_start(list,fmt);
+ vsprintf(msg,fmt,list);
+ va_end(list);
+
+ WriteConsole(hConsole, msg, (DWORD)strlen(msg), &tmp, 0);
+#ifdef EMU_LOG
+#ifndef LOG_STDOUT
+ fprintf(emuLog, "%s", msg);
+#endif
+#endif
+}
+
+void SysMessage(char *fmt, ...) {
+ va_list list;
+ char tmp[512];
+
+ va_start(list,fmt);
+ vsprintf(tmp,fmt,list);
+ va_end(list);
+ MessageBox(0, tmp, "Pcsx Msg", 0);
+}
+
+static char *err = "Error Loading Symbol";
+static int errval;
+
+void *SysLoadLibrary(char *lib) {
+ return LoadLibrary(lib);
+}
+
+void *SysLoadSym(void *lib, char *sym) {
+ void *tmp = GetProcAddress((HINSTANCE)lib, sym);
+ if (tmp == NULL) errval = 1;
+ else errval = 0;
+ return tmp;
+}
+
+char *SysLibError() {
+ if (errval) { errval = 0; return err; }
+ return NULL;
+}
+
+void SysCloseLibrary(void *lib) {
+ FreeLibrary((HINSTANCE)lib);
+}
+
+void SysUpdate() {
+ MSG msg;
+
+ PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
+
+ while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+void SysRunGui() {
+ RunGui();
} \ No newline at end of file
diff --git a/PcsxSrc/Win32/plugin.c b/PcsxSrc/Win32/plugin.c
index 018257e..4b7f265 100644
--- a/PcsxSrc/Win32/plugin.c
+++ b/PcsxSrc/Win32/plugin.c
@@ -1,201 +1,201 @@
-/* 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 <windows.h>
-#include <stdio.h>
-#include "plugins.h"
-#include "resource.h"
-#include <time.h>
-#include <stdio.h>
-#include "R3000A.h"
-#include "Win32.h"
-
-void PADhandleKey(int key) {
- char Text[255];
- int ret;
-
- if (Running == 0) return;
- switch (key) {
- case 0: break;
- case VK_F1:
- sprintf (Text, "sstates/%s.%3.3d", CdromId, StatesC);
- GPU_freeze(2, (GPUFreeze_t *)&StatesC);
- ret = SaveState(Text);
- sprintf (Text, "*PCSX*: %s State %d", !ret ? "Saved" : "Error Saving", StatesC+1);
- GPU_displayText(Text);
- return;
-
- case VK_F2:
- if (StatesC < 4) StatesC++;
- else StatesC = 0;
- GPU_freeze(2, (GPUFreeze_t *)&StatesC);
- return;
-
- case VK_F3:
- sprintf (Text, "sstates/%s.%3.3d", CdromId, StatesC);
- ret = LoadState(Text);
- sprintf (Text, "*PCSX*: %s State %d", !ret ? "Loaded" : "Error Loading", StatesC+1);
- GPU_displayText(Text);
- return;
-
- case VK_F4:
- {
- gzFile f;
- static int ShowPic;
- static unsigned char *pMem;
-
- if (!ShowPic) {
- sprintf (Text, "sstates/%s.%3.3d", CdromId, StatesC);
- f = gzopen(Text, "rb");
- if (f == NULL) return;
-
- gzseek(f, 32, SEEK_SET); // skip header
-
- pMem = (unsigned char *) malloc(128*96*3);
- gzread(f, pMem, 128*96*3);
- gzclose(f);
- GPU_freeze(2, (GPUFreeze_t *)&StatesC);
- GPU_showScreenPic(pMem);
- free(pMem);
- ShowPic = 1;
- }
- else {
- GPU_showScreenPic(NULL);
- ShowPic = 0;
- }
-
- }
- return;
-
- case VK_F5:
- if (Config.QKeys) break;
- Config.Sio ^= 0x1;
- sprintf (Text, "*PCSX*: Sio Irq %sAlways Enabled", Config.Sio ? "" : "Not ");
- GPU_displayText(Text);
- return;
-
- case VK_F6:
- if (Config.QKeys) break;
- Config.Mdec ^= 0x1;
- sprintf (Text, "*PCSX*: Black&White Only Mdecs %sabled", Config.Mdec ? "En" : "Dis");
- GPU_displayText(Text);
- return;
-
- case VK_F7:
- if (Config.QKeys) break;
- Config.Xa ^= 0x1;
- sprintf (Text, "*PCSX*: Xa %sabled", !Config.Xa ? "En" : "Dis");
- GPU_displayText(Text);
- return;
-
- case VK_F8:
- if (Config.QKeys) break;
- GPU_makeSnapshot();
- return;
-
- case VK_F9:
- GPU_displayText("*PCSX*: CdRom Case Opened");
- cdOpenCase = 1;
- return;
-
- case VK_F10:
- GPU_displayText("*PCSX*: CdRom Case Closed");
- cdOpenCase = 0;
- return;
-
- case VK_F11:
- GPU_displayText("*PCSX*: Begin CPU Log");
- Log = 1;
- return;
-
- case VK_F12:
- GPU_displayText("*PCSX*: Ending CPU Log");
- Log = 0;
- return;
-
- case VK_ESCAPE:
- Running = 0;
- ClosePlugins();
- AccBreak = 1;
- DestroyWindow(gApp.hWnd);
- CreateMainWindow(SW_SHOWNORMAL);
- SetMenu(gApp.hWnd, gApp.hMenu);
- SetCursor(LoadCursor(gApp.hInstance, IDC_ARROW));
- ShowCursor(TRUE);
- RunGui();
- return;
- }
-}
-
-void CALLBACK SPUirq(void);
-
-void OpenPlugins(HWND hWnd) {
- int ret;
-
- ret = CDR_open();
- if (ret != 0) { SysMessage ("Error Opening CDR Plugin\n"); exit(1); }
- ShowCursor(FALSE);
- ret = GPU_open(hWnd);
- if (ret != 0) { SysMessage ("Error Opening GPU Plugin\n"); exit(1); }
- ret = SPU_open(hWnd);
- if (ret != 0) { SysMessage ("Error Opening SPU Plugin\n"); exit(1); }
- SPU_registerCallback(SPUirq);
- ret = PAD1_open(hWnd);
- if (ret != 0) { SysMessage ("Error Opening PAD1 Plugin\n"); exit(1); }
- ret = PAD2_open(hWnd);
- if (ret != 0) { SysMessage ("Error Opening PAD2 Plugin\n"); exit(1); }
- SetCurrentDirectory(PcsxDir);
-}
-
-void ClosePlugins() {
- int ret;
-
- ret = CDR_close();
- if (ret != 0) { SysMessage ("Error Closing CDR Plugin\n"); exit(1); }
- ret = GPU_close();
- if (ret != 0) { SysMessage ("Error Closing GPU Plugin\n"); exit(1); }
- ret = SPU_close();
- if (ret != 0) { SysMessage ("Error Closing SPU Plugin\n"); exit(1); }
- ret = PAD1_close();
- if (ret != 0) { SysMessage ("Error Closing PAD1 Plugin\n"); exit(1); }
- ret = PAD2_close();
- if (ret != 0) { SysMessage ("Error Closing PAD2 Plugin\n"); exit(1); }
- ShowCursor(TRUE);
-}
-
-void ResetPlugins() {
- int ret;
-
- CDR_shutdown();
- GPU_shutdown();
- SPU_shutdown();
- PAD1_shutdown();
- PAD2_shutdown();
- ret = CDR_init();
- if (ret != 0) { SysMessage ("CDRinit error : %d\n",ret); exit(1); }
- ret = GPU_init();
- if (ret != 0) { SysMessage ("GPUinit error : %d\n",ret); exit(1); }
- ret = SPU_init();
- if (ret != 0) { SysMessage ("SPUinit error : %d\n",ret); exit(1); }
- ret = PAD1_init(1);
- if (ret != 0) { SysMessage ("PAD1init error : %d\n",ret); exit(1); }
- ret = PAD2_init(2);
- if (ret != 0) { SysMessage ("PAD2init error : %d\n",ret); exit(1); }
-}
-
-
+/* 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 <windows.h>
+#include <stdio.h>
+#include "plugins.h"
+#include "resource.h"
+#include <time.h>
+#include <stdio.h>
+#include "R3000A.h"
+#include "Win32.h"
+
+void PADhandleKey(int key) {
+ char Text[255];
+ int ret;
+
+ if (Running == 0) return;
+ switch (key) {
+ case 0: break;
+ case VK_F1:
+ sprintf (Text, "sstates/%s.%3.3d", CdromId, StatesC);
+ GPU_freeze(2, (GPUFreeze_t *)&StatesC);
+ ret = SaveState(Text);
+ sprintf (Text, "*PCSX*: %s State %d", !ret ? "Saved" : "Error Saving", StatesC+1);
+ GPU_displayText(Text);
+ return;
+
+ case VK_F2:
+ if (StatesC < 4) StatesC++;
+ else StatesC = 0;
+ GPU_freeze(2, (GPUFreeze_t *)&StatesC);
+ return;
+
+ case VK_F3:
+ sprintf (Text, "sstates/%s.%3.3d", CdromId, StatesC);
+ ret = LoadState(Text);
+ sprintf (Text, "*PCSX*: %s State %d", !ret ? "Loaded" : "Error Loading", StatesC+1);
+ GPU_displayText(Text);
+ return;
+
+ case VK_F4:
+ {
+ gzFile f;
+ static int ShowPic;
+ static unsigned char *pMem;
+
+ if (!ShowPic) {
+ sprintf (Text, "sstates/%s.%3.3d", CdromId, StatesC);
+ f = gzopen(Text, "rb");
+ if (f == NULL) return;
+
+ gzseek(f, 32, SEEK_SET); // skip header
+
+ pMem = (unsigned char *) malloc(128*96*3);
+ gzread(f, pMem, 128*96*3);
+ gzclose(f);
+ GPU_freeze(2, (GPUFreeze_t *)&StatesC);
+ GPU_showScreenPic(pMem);
+ free(pMem);
+ ShowPic = 1;
+ }
+ else {
+ GPU_showScreenPic(NULL);
+ ShowPic = 0;
+ }
+
+ }
+ return;
+
+ case VK_F5:
+ if (Config.QKeys) break;
+ Config.Sio ^= 0x1;
+ sprintf (Text, "*PCSX*: Sio Irq %sAlways Enabled", Config.Sio ? "" : "Not ");
+ GPU_displayText(Text);
+ return;
+
+ case VK_F6:
+ if (Config.QKeys) break;
+ Config.Mdec ^= 0x1;
+ sprintf (Text, "*PCSX*: Black&White Only Mdecs %sabled", Config.Mdec ? "En" : "Dis");
+ GPU_displayText(Text);
+ return;
+
+ case VK_F7:
+ if (Config.QKeys) break;
+ Config.Xa ^= 0x1;
+ sprintf (Text, "*PCSX*: Xa %sabled", !Config.Xa ? "En" : "Dis");
+ GPU_displayText(Text);
+ return;
+
+ case VK_F8:
+ if (Config.QKeys) break;
+ GPU_makeSnapshot();
+ return;
+
+ case VK_F9:
+ GPU_displayText("*PCSX*: CdRom Case Opened");
+ cdOpenCase = 1;
+ return;
+
+ case VK_F10:
+ GPU_displayText("*PCSX*: CdRom Case Closed");
+ cdOpenCase = 0;
+ return;
+
+ case VK_F11:
+ GPU_displayText("*PCSX*: Begin CPU Log");
+ Log = 1;
+ return;
+
+ case VK_F12:
+ GPU_displayText("*PCSX*: Ending CPU Log");
+ Log = 0;
+ return;
+
+ case VK_ESCAPE:
+ Running = 0;
+ ClosePlugins();
+ AccBreak = 1;
+ DestroyWindow(gApp.hWnd);
+ CreateMainWindow(SW_SHOWNORMAL);
+ SetMenu(gApp.hWnd, gApp.hMenu);
+ SetCursor(LoadCursor(gApp.hInstance, IDC_ARROW));
+ ShowCursor(TRUE);
+ RunGui();
+ return;
+ }
+}
+
+void CALLBACK SPUirq(void);
+
+void OpenPlugins(HWND hWnd) {
+ int ret;
+
+ ret = CDR_open();
+ if (ret != 0) { SysMessage ("Error Opening CDR Plugin\n"); exit(1); }
+ ShowCursor(FALSE);
+ ret = GPU_open(hWnd);
+ if (ret != 0) { SysMessage ("Error Opening GPU Plugin\n"); exit(1); }
+ ret = SPU_open(hWnd);
+ if (ret != 0) { SysMessage ("Error Opening SPU Plugin\n"); exit(1); }
+ SPU_registerCallback(SPUirq);
+ ret = PAD1_open(hWnd);
+ if (ret != 0) { SysMessage ("Error Opening PAD1 Plugin\n"); exit(1); }
+ ret = PAD2_open(hWnd);
+ if (ret != 0) { SysMessage ("Error Opening PAD2 Plugin\n"); exit(1); }
+ SetCurrentDirectory(PcsxDir);
+}
+
+void ClosePlugins() {
+ int ret;
+
+ ret = CDR_close();
+ if (ret != 0) { SysMessage ("Error Closing CDR Plugin\n"); exit(1); }
+ ret = GPU_close();
+ if (ret != 0) { SysMessage ("Error Closing GPU Plugin\n"); exit(1); }
+ ret = SPU_close();
+ if (ret != 0) { SysMessage ("Error Closing SPU Plugin\n"); exit(1); }
+ ret = PAD1_close();
+ if (ret != 0) { SysMessage ("Error Closing PAD1 Plugin\n"); exit(1); }
+ ret = PAD2_close();
+ if (ret != 0) { SysMessage ("Error Closing PAD2 Plugin\n"); exit(1); }
+ ShowCursor(TRUE);
+}
+
+void ResetPlugins() {
+ int ret;
+
+ CDR_shutdown();
+ GPU_shutdown();
+ SPU_shutdown();
+ PAD1_shutdown();
+ PAD2_shutdown();
+ ret = CDR_init();
+ if (ret != 0) { SysMessage ("CDRinit error : %d\n",ret); exit(1); }
+ ret = GPU_init();
+ if (ret != 0) { SysMessage ("GPUinit error : %d\n",ret); exit(1); }
+ ret = SPU_init();
+ if (ret != 0) { SysMessage ("SPUinit error : %d\n",ret); exit(1); }
+ ret = PAD1_init(1);
+ if (ret != 0) { SysMessage ("PAD1init error : %d\n",ret); exit(1); }
+ ret = PAD2_init(2);
+ if (ret != 0) { SysMessage ("PAD2init error : %d\n",ret); exit(1); }
+}
+
+
diff --git a/PcsxSrc/Win32/plugin.h b/PcsxSrc/Win32/plugin.h
index bec7f7f..22f38b1 100644
--- a/PcsxSrc/Win32/plugin.h
+++ b/PcsxSrc/Win32/plugin.h
@@ -1,29 +1,29 @@
-/* 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
- */
-
-// Windows Specifyc Plugin Functions
-#ifndef __PLUGIN_H__
-#define __PLUGIN_H__
-
-typedef long (CALLBACK* GPUopen)(HWND);
-
-typedef long (CALLBACK* SPUopen)(HWND);
-
-typedef long (CALLBACK* PADopen)(HWND);
-
+/* 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
+ */
+
+// Windows Specifyc Plugin Functions
+#ifndef __PLUGIN_H__
+#define __PLUGIN_H__
+
+typedef long (CALLBACK* GPUopen)(HWND);
+
+typedef long (CALLBACK* SPUopen)(HWND);
+
+typedef long (CALLBACK* PADopen)(HWND);
+
#endif /* __PLUGIN_H__ */ \ No newline at end of file
diff --git a/PcsxSrc/Win32/resource.h b/PcsxSrc/Win32/resource.h
index 464846e..6ed9ee6 100644
--- a/PcsxSrc/Win32/resource.h
+++ b/PcsxSrc/Win32/resource.h
@@ -1,266 +1,266 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by pcsx.rc
-//
-#define IDS_TITLE 1
-#define IDR_MENU1 101
-#define IDI_APP_ICON 102
-#define IDD_MCDCONF 102
-#define DEBUG_DIALOG 103
-#define ABOUT_DIALOG 104
-#define IDD_CPUCONF 105
-#define SPLASH_LOGO 113
-#define IDD_GPREGS 114
-#define IDD_CP0REGS 115
-#define IDD_COP2D 116
-#define IDD_COP2C 117
-#define IDD_CONFIG 120
-#define IDD_MEMVIEW 136
-#define IDC_EDIT2 1001
-#define IDC_MCD2 1004
-#define IDC_ASMCHECK1 1005
-#define IDC_MCD1 1005
-#define IDC_MCDSEL1 1006
-#define IDC_STEP 1007
-#define IDC_MCDSEL2 1007
-#define IDC_XA 1007
-#define IDC_SIO 1008
-#define IDC_SKIP 1009
-#define IDC_MDEC 1009
-#define IDC_RESET 1010
-#define IDC_PSXAUTO 1010
-#define IDC_GO 1011
-#define IDC_PSXTYPES 1011
-#define IDC_BREAK 1012
-#define IDC_DISCPUQKEYS 1012
-#define IDC_QKEYS 1012
-#define IDC_EDIT1 1013
-#define IDC_CDDA 1013
-#define IDC_CLOSE 1014
-#define IDC_PCSX_ABOUT_TEXT 1014
-#define IDC_PSXOUT 1014
-#define IDC_ASM_SCROLL 1015
-#define IDC_CPU 1015
-#define IDC_ASMCHECK2 1016
-#define IDC_SPUIRQ 1016
-#define IDC_ASMCHECK3 1017
-#define IDC_MDEC2 1017
-#define IDC_CDTIMING 1017
-#define IDC_ASMCHECK4 1018
-#define IDC_ASMCHECK5 1019
-#define IDC_RELOAD1 1019
-#define IDC_CP07 1020
-#define IDC_ASMCHECK6 1020
-#define IDC_RELOAD2 1020
-#define IDC_ASMCHECK7 1021
-#define IDC_COPYTO2 1021
-#define IDC_ASMCHECK8 1022
-#define IDC_COPYTO1 1022
-#define IDC_ASMCHECK9 1023
-#define IDC_PASTE 1023
-#define IDC_ASMCHECK10 1024
-#define IDC_DELETE1 1024
-#define IDC_ASMCHECK11 1025
-#define IDC_DELETE2 1025
-#define IDC_ASMCHECK12 1026
-#define IDC_LIST1 1027
-#define IDC_ASMCHECK13 1027
-#define IDC_ASMCHECK14 1028
-#define IDC_LIST2 1028
-#define IDC_ASMCHECK15 1029
-#define IDC_ASMCHECK16 1030
-#define IDC_ASMCHECK17 1031
-#define IDC_ASMCHECK18 1032
-#define IDC_ASMCHECK19 1033
-#define IDC_CP021 1034
-#define IDC_ASMCHECK20 1034
-#define IDC_CP022 1035
-#define IDC_ASMCHECK21 1035
-#define IDC_CP023 1036
-#define IDC_ASMCHECK22 1036
-#define IDC_CP024 1037
-#define IDC_ASMCHECK23 1037
-#define IDC_CP025 1038
-#define IDC_ASMCHECK24 1038
-#define IDC_CP031 1044
-#define IDC_GPR0 1047
-#define IDC_GPR1 1048
-#define IDC_GPR2 1049
-#define IDC_GPR3 1050
-#define IDC_GPR4 1051
-#define IDC_GPR5 1052
-#define IDC_LISTGPU 1052
-#define IDC_GPR6 1053
-#define IDC_LISTSPU 1053
-#define IDC_GPR7 1054
-#define IDC_LISTCDR 1054
-#define IDC_GPR8 1055
-#define IDC_LISTBIOS 1055
-#define IDC_GPR9 1056
-#define IDC_CONFIGGPU 1056
-#define IDC_GPR10 1057
-#define IDC_TESTGPU 1057
-#define IDC_ABOUTGPU 1058
-#define IDC_CONFIGSPU 1059
-#define IDC_TESTSPU 1060
-#define IDC_ABOUTSPU 1061
-#define IDC_CONFIGCDR 1062
-#define IDC_GPR11 1063
-#define IDC_TESTCDR 1063
-#define IDC_ABOUTCDR 1064
-#define IDC_COMBODRIVE 1065
-#define IDC_LISTPAD1 1066
-#define IDC_CONFIGPAD1 1067
-#define IDC_GPR12 1068
-#define IDC_TESTPAD1 1068
-#define IDC_GPR13 1069
-#define IDC_ABOUTPAD1 1069
-#define IDC_GPR14 1070
-#define IDC_LISTPAD2 1070
-#define IDC_GPR15 1071
-#define IDC_CONFIGPAD2 1071
-#define IDC_GPR16 1072
-#define IDC_TESTPAD2 1072
-#define IDC_GPR17 1073
-#define IDC_ABOUTPAD2 1073
-#define IDC_GPR18 1074
-#define IDC_GPR19 1075
-#define IDC_GPR20 1076
-#define IDC_GPR21 1077
-#define IDC_GPR22 1078
-#define IDC_GPR23 1079
-#define IDC_GPR24 1080
-#define IDC_GPR25 1081
-#define IDC_GPR26 1082
-#define IDC_GPR27 1083
-#define IDC_GPR28 1084
-#define IDC_GPR29 1085
-#define IDC_GPR30 1086
-#define IDC_GPR31 1087
-#define IDC_GPR_PC 1089
-#define IDC_GPR_HI 1091
-#define IDC_GPR_LO 1092
-#define IDC_CP00 1093
-#define IDC_CP01 1094
-#define IDC_CP02 1095
-#define IDC_CP03 1096
-#define IDC_CP04 1097
-#define IDC_CP05 1098
-#define IDC_CP06 1099
-#define IDC_CP08 1100
-#define IDC_CP09 1101
-#define IDC_CP010 1102
-#define IDC_CP011 1103
-#define IDC_CP012 1104
-#define IDC_CP013 1105
-#define IDC_CP014 1106
-#define IDC_CP015 1107
-#define IDC_CP016 1108
-#define IDC_CP017 1109
-#define IDC_CP018 1110
-#define IDC_CP019 1111
-#define IDC_CP020 1112
-#define IDC_CP026 1113
-#define IDC_CP027 1114
-#define IDC_CP028 1115
-#define IDC_CP029 1116
-#define IDC_CP030 1117
-#define IDC_COP2D0 1118
-#define IDC_COP2D1 1119
-#define IDC_COP2D2 1120
-#define IDC_COP2D3 1121
-#define IDC_COP2D4 1122
-#define IDC_COP2D5 1123
-#define IDC_COP2D6 1124
-#define IDC_COP2D7 1125
-#define IDC_COP2D8 1126
-#define IDC_COP2D9 1127
-#define IDC_COP2D10 1128
-#define IDC_COP2D11 1129
-#define IDC_COP2D12 1130
-#define IDC_COP2D13 1131
-#define IDC_COP2D14 1132
-#define IDC_COP2D15 1133
-#define IDC_COP2D16 1134
-#define IDC_COP2D17 1135
-#define IDC_COP2D18 1136
-#define IDC_COP2D19 1137
-#define IDC_COP2D20 1138
-#define IDC_COP2D21 1139
-#define IDC_COP2D22 1140
-#define IDC_COP2D23 1141
-#define IDC_COP2D24 1142
-#define IDC_COP2D25 1143
-#define IDC_COP2D26 1144
-#define IDC_COP2D27 1145
-#define IDC_COP2D28 1146
-#define IDC_COP2D29 1147
-#define IDC_COP2D30 1148
-#define IDC_COP2D31 1149
-#define IDC_COP2C0 1152
-#define IDC_COP2C1 1153
-#define IDC_COP2C2 1154
-#define IDC_COP2C3 1155
-#define IDC_COP2C4 1156
-#define IDC_COP2C5 1157
-#define IDC_COP2C6 1158
-#define IDC_COP2C7 1159
-#define IDC_COP2C8 1160
-#define IDC_COP2C9 1161
-#define IDC_COP2C10 1162
-#define IDC_COP2C11 1163
-#define IDC_COP2C12 1164
-#define IDC_COP2C13 1165
-#define IDC_COP2C14 1166
-#define IDC_COP2C15 1167
-#define IDC_COP2C16 1168
-#define IDC_COP2C17 1169
-#define IDC_COP2C18 1170
-#define IDC_COP2C19 1171
-#define IDC_COP2C20 1172
-#define IDC_COP2C21 1173
-#define IDC_COP2C22 1174
-#define IDC_COP2C23 1175
-#define IDC_COP2C24 1176
-#define IDC_COP2C25 1177
-#define IDC_COP2C26 1178
-#define IDC_COP2C27 1179
-#define IDC_COP2C28 1180
-#define IDC_COP2C29 1181
-#define IDC_COP2C30 1182
-#define IDC_COP2C31 1183
-#define IDC_BUTTON1 1254
-#define IDC_BIOSDIR 1254
-#define IDC_FORMAT1 1254
-#define IDC_PLUGINSDIR 1255
-#define IDC_FORMAT2 1255
-#define ID_FILE_EXIT 40001
-#define ID_HELP_ABOUT 40002
-#define ID_FILE_RUN_CD 40003
-#define ID_FILE_RUN_EXE 40004
-#define ID_EMULATOR_PAUSE 40005
-#define ID_EMULATOR_RESET 40006
-#define ID_HELP_HELP 40007
-#define ID_DEBUG_ENABLE_DEBUGGER 40008
-#define ID_CONFIGURATION_GRAPHICS 40009
-#define ID_CONFIGURATION_SOUND 40010
-#define ID_CONFIGURATION_CDROM 40011
-#define ID_CONFIGURATION_MEMORYCARDMANAGER 40012
-#define ID_CONFIGURATION_CPU 40013
-#define ID_EMULATOR_RUN 40014
-#define ID_DEBUGREG 40015
-#define ID_DEBUG_MESSAGES 40015
-#define ID_CONFIGURATION_CONTROLLERS 40017
-#define ID_CONFIGURATION 40018
-#define ID_FILE_RUNCDBIOS 40026
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 108
-#define _APS_NEXT_COMMAND_VALUE 40028
-#define _APS_NEXT_CONTROL_VALUE 1022
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by pcsx.rc
+//
+#define IDS_TITLE 1
+#define IDR_MENU1 101
+#define IDI_APP_ICON 102
+#define IDD_MCDCONF 102
+#define DEBUG_DIALOG 103
+#define ABOUT_DIALOG 104
+#define IDD_CPUCONF 105
+#define SPLASH_LOGO 113
+#define IDD_GPREGS 114
+#define IDD_CP0REGS 115
+#define IDD_COP2D 116
+#define IDD_COP2C 117
+#define IDD_CONFIG 120
+#define IDD_MEMVIEW 136
+#define IDC_EDIT2 1001
+#define IDC_MCD2 1004
+#define IDC_ASMCHECK1 1005
+#define IDC_MCD1 1005
+#define IDC_MCDSEL1 1006
+#define IDC_STEP 1007
+#define IDC_MCDSEL2 1007
+#define IDC_XA 1007
+#define IDC_SIO 1008
+#define IDC_SKIP 1009
+#define IDC_MDEC 1009
+#define IDC_RESET 1010
+#define IDC_PSXAUTO 1010
+#define IDC_GO 1011
+#define IDC_PSXTYPES 1011
+#define IDC_BREAK 1012
+#define IDC_DISCPUQKEYS 1012
+#define IDC_QKEYS 1012
+#define IDC_EDIT1 1013
+#define IDC_CDDA 1013
+#define IDC_CLOSE 1014
+#define IDC_PCSX_ABOUT_TEXT 1014
+#define IDC_PSXOUT 1014
+#define IDC_ASM_SCROLL 1015
+#define IDC_CPU 1015
+#define IDC_ASMCHECK2 1016
+#define IDC_SPUIRQ 1016
+#define IDC_ASMCHECK3 1017
+#define IDC_MDEC2 1017
+#define IDC_CDTIMING 1017
+#define IDC_ASMCHECK4 1018
+#define IDC_ASMCHECK5 1019
+#define IDC_RELOAD1 1019
+#define IDC_CP07 1020
+#define IDC_ASMCHECK6 1020
+#define IDC_RELOAD2 1020
+#define IDC_ASMCHECK7 1021
+#define IDC_COPYTO2 1021
+#define IDC_ASMCHECK8 1022
+#define IDC_COPYTO1 1022
+#define IDC_ASMCHECK9 1023
+#define IDC_PASTE 1023
+#define IDC_ASMCHECK10 1024
+#define IDC_DELETE1 1024
+#define IDC_ASMCHECK11 1025
+#define IDC_DELETE2 1025
+#define IDC_ASMCHECK12 1026
+#define IDC_LIST1 1027
+#define IDC_ASMCHECK13 1027
+#define IDC_ASMCHECK14 1028
+#define IDC_LIST2 1028
+#define IDC_ASMCHECK15 1029
+#define IDC_ASMCHECK16 1030
+#define IDC_ASMCHECK17 1031
+#define IDC_ASMCHECK18 1032
+#define IDC_ASMCHECK19 1033
+#define IDC_CP021 1034
+#define IDC_ASMCHECK20 1034
+#define IDC_CP022 1035
+#define IDC_ASMCHECK21 1035
+#define IDC_CP023 1036
+#define IDC_ASMCHECK22 1036
+#define IDC_CP024 1037
+#define IDC_ASMCHECK23 1037
+#define IDC_CP025 1038
+#define IDC_ASMCHECK24 1038
+#define IDC_CP031 1044
+#define IDC_GPR0 1047
+#define IDC_GPR1 1048
+#define IDC_GPR2 1049
+#define IDC_GPR3 1050
+#define IDC_GPR4 1051
+#define IDC_GPR5 1052
+#define IDC_LISTGPU 1052
+#define IDC_GPR6 1053
+#define IDC_LISTSPU 1053
+#define IDC_GPR7 1054
+#define IDC_LISTCDR 1054
+#define IDC_GPR8 1055
+#define IDC_LISTBIOS 1055
+#define IDC_GPR9 1056
+#define IDC_CONFIGGPU 1056
+#define IDC_GPR10 1057
+#define IDC_TESTGPU 1057
+#define IDC_ABOUTGPU 1058
+#define IDC_CONFIGSPU 1059
+#define IDC_TESTSPU 1060
+#define IDC_ABOUTSPU 1061
+#define IDC_CONFIGCDR 1062
+#define IDC_GPR11 1063
+#define IDC_TESTCDR 1063
+#define IDC_ABOUTCDR 1064
+#define IDC_COMBODRIVE 1065
+#define IDC_LISTPAD1 1066
+#define IDC_CONFIGPAD1 1067
+#define IDC_GPR12 1068
+#define IDC_TESTPAD1 1068
+#define IDC_GPR13 1069
+#define IDC_ABOUTPAD1 1069
+#define IDC_GPR14 1070
+#define IDC_LISTPAD2 1070
+#define IDC_GPR15 1071
+#define IDC_CONFIGPAD2 1071
+#define IDC_GPR16 1072
+#define IDC_TESTPAD2 1072
+#define IDC_GPR17 1073
+#define IDC_ABOUTPAD2 1073
+#define IDC_GPR18 1074
+#define IDC_GPR19 1075
+#define IDC_GPR20 1076
+#define IDC_GPR21 1077
+#define IDC_GPR22 1078
+#define IDC_GPR23 1079
+#define IDC_GPR24 1080
+#define IDC_GPR25 1081
+#define IDC_GPR26 1082
+#define IDC_GPR27 1083
+#define IDC_GPR28 1084
+#define IDC_GPR29 1085
+#define IDC_GPR30 1086
+#define IDC_GPR31 1087
+#define IDC_GPR_PC 1089
+#define IDC_GPR_HI 1091
+#define IDC_GPR_LO 1092
+#define IDC_CP00 1093
+#define IDC_CP01 1094
+#define IDC_CP02 1095
+#define IDC_CP03 1096
+#define IDC_CP04 1097
+#define IDC_CP05 1098
+#define IDC_CP06 1099
+#define IDC_CP08 1100
+#define IDC_CP09 1101
+#define IDC_CP010 1102
+#define IDC_CP011 1103
+#define IDC_CP012 1104
+#define IDC_CP013 1105
+#define IDC_CP014 1106
+#define IDC_CP015 1107
+#define IDC_CP016 1108
+#define IDC_CP017 1109
+#define IDC_CP018 1110
+#define IDC_CP019 1111
+#define IDC_CP020 1112
+#define IDC_CP026 1113
+#define IDC_CP027 1114
+#define IDC_CP028 1115
+#define IDC_CP029 1116
+#define IDC_CP030 1117
+#define IDC_COP2D0 1118
+#define IDC_COP2D1 1119
+#define IDC_COP2D2 1120
+#define IDC_COP2D3 1121
+#define IDC_COP2D4 1122
+#define IDC_COP2D5 1123
+#define IDC_COP2D6 1124
+#define IDC_COP2D7 1125
+#define IDC_COP2D8 1126
+#define IDC_COP2D9 1127
+#define IDC_COP2D10 1128
+#define IDC_COP2D11 1129
+#define IDC_COP2D12 1130
+#define IDC_COP2D13 1131
+#define IDC_COP2D14 1132
+#define IDC_COP2D15 1133
+#define IDC_COP2D16 1134
+#define IDC_COP2D17 1135
+#define IDC_COP2D18 1136
+#define IDC_COP2D19 1137
+#define IDC_COP2D20 1138
+#define IDC_COP2D21 1139
+#define IDC_COP2D22 1140
+#define IDC_COP2D23 1141
+#define IDC_COP2D24 1142
+#define IDC_COP2D25 1143
+#define IDC_COP2D26 1144
+#define IDC_COP2D27 1145
+#define IDC_COP2D28 1146
+#define IDC_COP2D29 1147
+#define IDC_COP2D30 1148
+#define IDC_COP2D31 1149
+#define IDC_COP2C0 1152
+#define IDC_COP2C1 1153
+#define IDC_COP2C2 1154
+#define IDC_COP2C3 1155
+#define IDC_COP2C4 1156
+#define IDC_COP2C5 1157
+#define IDC_COP2C6 1158
+#define IDC_COP2C7 1159
+#define IDC_COP2C8 1160
+#define IDC_COP2C9 1161
+#define IDC_COP2C10 1162
+#define IDC_COP2C11 1163
+#define IDC_COP2C12 1164
+#define IDC_COP2C13 1165
+#define IDC_COP2C14 1166
+#define IDC_COP2C15 1167
+#define IDC_COP2C16 1168
+#define IDC_COP2C17 1169
+#define IDC_COP2C18 1170
+#define IDC_COP2C19 1171
+#define IDC_COP2C20 1172
+#define IDC_COP2C21 1173
+#define IDC_COP2C22 1174
+#define IDC_COP2C23 1175
+#define IDC_COP2C24 1176
+#define IDC_COP2C25 1177
+#define IDC_COP2C26 1178
+#define IDC_COP2C27 1179
+#define IDC_COP2C28 1180
+#define IDC_COP2C29 1181
+#define IDC_COP2C30 1182
+#define IDC_COP2C31 1183
+#define IDC_BUTTON1 1254
+#define IDC_BIOSDIR 1254
+#define IDC_FORMAT1 1254
+#define IDC_PLUGINSDIR 1255
+#define IDC_FORMAT2 1255
+#define ID_FILE_EXIT 40001
+#define ID_HELP_ABOUT 40002
+#define ID_FILE_RUN_CD 40003
+#define ID_FILE_RUN_EXE 40004
+#define ID_EMULATOR_PAUSE 40005
+#define ID_EMULATOR_RESET 40006
+#define ID_HELP_HELP 40007
+#define ID_DEBUG_ENABLE_DEBUGGER 40008
+#define ID_CONFIGURATION_GRAPHICS 40009
+#define ID_CONFIGURATION_SOUND 40010
+#define ID_CONFIGURATION_CDROM 40011
+#define ID_CONFIGURATION_MEMORYCARDMANAGER 40012
+#define ID_CONFIGURATION_CPU 40013
+#define ID_EMULATOR_RUN 40014
+#define ID_DEBUGREG 40015
+#define ID_DEBUG_MESSAGES 40015
+#define ID_CONFIGURATION_CONTROLLERS 40017
+#define ID_CONFIGURATION 40018
+#define ID_FILE_RUNCDBIOS 40026
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 108
+#define _APS_NEXT_COMMAND_VALUE 40028
+#define _APS_NEXT_CONTROL_VALUE 1022
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif