From 20b95fd1877a95e21ad7ec057e97fb7d00904a2d Mon Sep 17 00:00:00 2001 From: arcum42 Date: Thu, 23 Jul 2009 23:30:19 +0000 Subject: [PATCH 01/22] Added a few new calls to PathUtils, and used them to get rid of some platform specific code in the new Iso code. I also modified some other code to use the new calls, and fixed a few microVU compiler warnings. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1559 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Config.h | 3 +++ pcsx2/CDVD/CDVDaccess.cpp | 26 +++++++++++--------------- pcsx2/Linux/LnxMain.cpp | 16 +++++++++------- pcsx2/Linux/McdDlgs.cpp | 14 +++++++------- pcsx2/Linux/Pref.cpp | 1 + pcsx2/PathUtils.cpp | 22 +++++++++++++++++++++- pcsx2/Paths.h | 22 ++++++++++++++++++++-- pcsx2/windows/WinMain.cpp | 4 ++-- pcsx2/x86/microVU_Upper.inl | 14 +++++++------- 9 files changed, 81 insertions(+), 41 deletions(-) diff --git a/common/include/Pcsx2Config.h b/common/include/Pcsx2Config.h index dcbd04703a..4623f14110 100644 --- a/common/include/Pcsx2Config.h +++ b/common/include/Pcsx2Config.h @@ -136,6 +136,7 @@ struct PcsxConfig { public: char Bios[g_MaxPath]; + char GS[g_MaxPath]; char PAD1[g_MaxPath]; char PAD2[g_MaxPath]; @@ -144,9 +145,11 @@ public: char DEV9[g_MaxPath]; char USB[g_MaxPath]; char FW[g_MaxPath]; + char PluginsDir[g_MaxPath]; char BiosDir[g_MaxPath]; char InisDir[g_MaxPath]; // This is intended for the program to populate, and the plugins to read. Obviously can't be saved in the config file. :) + char Lang[g_MaxPath]; McdConfig Mcd[2]; diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index da1242ab6a..5054c8dae2 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -18,7 +18,6 @@ #include "PrecompiledHeader.h" -// TODO: fix this for linux! (hardcoded as _WIN32 only) #define ENABLE_TIMESTAMPS #ifdef _WIN32 @@ -53,9 +52,11 @@ int CheckDiskTypeFS(int baseType) static struct TocEntry tocEntry; IsoFS_init(); - + + f = IsoFS_open("SYSTEM.CNF;1", 1); + // check if the file exists - if ((f=IsoFS_open("SYSTEM.CNF;1", 1)) >= 0) + if (f >= 0) { int size = IsoFS_read(f, buffer, 256); IsoFS_close(f); @@ -91,9 +92,7 @@ int FindDiskType(int mType) { int dataTracks = 0; int audioTracks = 0; - int iCDType = mType; - cdvdTN tn; CDVD.getTN(&tn); @@ -105,6 +104,7 @@ int FindDiskType(int mType) else if (mType < 0) { cdvdTD td; + CDVD.getTD(0,&td); if (td.lsn > 452849) { @@ -153,6 +153,7 @@ int FindDiskType(int mType) for(int i = tn.strack; i <= tn.etrack; i++) { cdvdTD td,td2; + CDVD.getTD(i,&td); if (tn.etrack > i) @@ -260,20 +261,15 @@ s32 DoCDVDopen(const char* pTitleFilename) int ret = CDVD.open(pTitleFilename); int cdtype = DoCDVDdetectDiskType(); - if((Config.Blockdump)&&(cdtype != CDVD_TYPE_NODISC)) + if ((Config.Blockdump) && (cdtype != CDVD_TYPE_NODISC)) { char fname_only[g_MaxPath]; - if(CDVD.init == ISO.init) + if (CDVD.init == ISO.init) { -#ifdef _WIN32 - char fname[MAX_PATH], ext[g_MaxPath]; - _splitpath(isoFileName, NULL, NULL, fname, ext); - _makepath(fname_only, NULL, NULL, fname, NULL); -#else - getcwd(fname_only, ArraySize(fname_only)); // Base it out of the current directory for now. - strcat(fname_only, Path::GetFilenameWithoutExt(isoFileName).c_str()); -#endif + // Base it out of the current directory for now. + string temp = Path::GetWorkingDirectory() + Path::GetFilenameWithoutExt(isoFileName); + strcpy(fname_only, temp.c_str()); } else { diff --git a/pcsx2/Linux/LnxMain.cpp b/pcsx2/Linux/LnxMain.cpp index b8ccf75b62..86125d5995 100644 --- a/pcsx2/Linux/LnxMain.cpp +++ b/pcsx2/Linux/LnxMain.cpp @@ -34,10 +34,13 @@ int main(int argc, char *argv[]) { char *file = NULL; char elfname[g_MaxPath]; + string MainDirString; efile = 0; - getcwd(MAIN_DIR, ArraySize(MAIN_DIR)); /* store main dir */ + /* store main dir */ + MainDirString = Path::GetWorkingDirectory(); + strcpy(MAIN_DIR, MainDirString.c_str()); Console::Notice("MAIN_DIR is %s", params MAIN_DIR); #ifdef ENABLE_NLS setlocale(LC_ALL, ""); @@ -51,12 +54,12 @@ int main(int argc, char *argv[]) sprintf(Config.InisDir, "%s/%s/", MAIN_DIR, DEFAULT_INIS_DIR); sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir); #else - mkdir("~/.pcsx2"); - chdir("~/.pcsx2"); - mkdir(DEFAULT_INIS_DIR, 0755); + Path::CreateDirectory(string("~/.pcsx2")); + Path::ChangeDirectory(string("~/.pcsx2")); + Path::CreateDirectory(string(DEFAULT_INIS_DIR)); sprintf(Config.InisDir, "~/.pcsx2/%s/", DEFAULT_INIS_DIR); sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir); - chdir(MAIN_DIR); + Path::ChangeDirectory(string(MAIN_DIR)); #endif #ifdef PCSX2_DEVBUILD @@ -144,8 +147,6 @@ int main(int argc, char *argv[]) if (!efile) efile = GetPS2ElfName(elfname); loadElfFile(elfname); - //ExecuteCpu(); - return 0; } @@ -350,6 +351,7 @@ void OnFile_RunBIOS(GtkMenuItem *menuitem, gpointer user_data) void OnRunIso_Ok(GtkButton* button, gpointer user_data) { gchar *File; + string curdir; CDVD = ISO; File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel)); diff --git a/pcsx2/Linux/McdDlgs.cpp b/pcsx2/Linux/McdDlgs.cpp index 576e2ed52a..39454e1afc 100644 --- a/pcsx2/Linux/McdDlgs.cpp +++ b/pcsx2/Linux/McdDlgs.cpp @@ -20,7 +20,8 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) { - char file[g_MaxPath], card[g_MaxPath]; + string file; + char card[g_MaxPath]; DIR *dir; struct dirent *entry; struct stat statinfo; @@ -37,10 +38,10 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) set_checked(MemDlg, "check_enable_mcd2", Config.Mcd[1].Enabled); set_checked(MemDlg, "check_eject_mcds", Config.McdEnableEject); - getcwd(file, ArraySize(file)); /* store current dir */ - sprintf(card, "%s/%s", file, MEMCARDS_DIR ); - chdir(card); /* change dirs so that plugins can find their config file*/ - + file = Path::GetCurrentDirectory();/* store current dir */ + sprintf(card, "%s/%s", file.c_str(), MEMCARDS_DIR ); + Path::ChangeDirectory(string(card));/* change dirs so that plugins can find their config file*/ + if ((dir = opendir(card)) == NULL) { Console::Error("ERROR: Could not open directory %s\n", params card); @@ -72,8 +73,7 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) } closedir(dir); - - chdir(file); + Path::ChangeDirectory(file); gtk_widget_show_all(MemDlg); gtk_widget_set_sensitive(MainWindow, FALSE); gtk_main(); diff --git a/pcsx2/Linux/Pref.cpp b/pcsx2/Linux/Pref.cpp index 1f5d814a4c..77ebfb3db0 100644 --- a/pcsx2/Linux/Pref.cpp +++ b/pcsx2/Linux/Pref.cpp @@ -156,6 +156,7 @@ void SaveConfig() SetValue("Lang", Config.Lang); SetValue("PluginsDir", Config.PluginsDir); SetValue("BiosDir", Config.BiosDir); + SetValuel("Ps2Out", Config.PsxOut); SetValuel("cdvdPrint", Config.cdvdPrint); diff --git a/pcsx2/PathUtils.cpp b/pcsx2/PathUtils.cpp index 3cca885154..e308e3ae0d 100644 --- a/pcsx2/PathUtils.cpp +++ b/pcsx2/PathUtils.cpp @@ -255,11 +255,31 @@ string GetRootDirectory( const string& src ) void CreateDirectory( const string& src ) { #ifdef _WIN32 - _mkdir( src.c_str() ); + _mkdir(src.c_str()); #else mkdir( src.c_str(), 0755); #endif } +string GetWorkingDirectory(void) +{ + char curdir[g_MaxPath]; +#ifdef _WIN32 + _getcwd(curdir, ArraySize(curdir)); +#else + getcwd(curdir, ArraySize(curdir)); +#endif + return string(curdir); +} + +void ChangeDirectory(const string& src) +{ +#ifdef _WIN32 + _chdir(src.c_str() ); +#else + chdir(src.c_str()); +#endif +} + } diff --git a/pcsx2/Paths.h b/pcsx2/Paths.h index d3bf1bb6cb..348d74d755 100644 --- a/pcsx2/Paths.h +++ b/pcsx2/Paths.h @@ -1,7 +1,24 @@ +/* Pcsx2 - Pc Ps2 Emulator + * Copyright (C) 2002-2009 Pcsx2 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #ifndef _PCSX2_PATHS_H_ #define _PCSX2_PATHS_H_ - #define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs. #ifdef __LINUX__ @@ -41,7 +58,8 @@ namespace Path extern void Split( const std::string& src, std::string& destpath, std::string& destfile ); extern void CreateDirectory( const std::string& src ); - + extern std::string GetWorkingDirectory(void); + extern void ChangeDirectory(const std::string& src); } #endif diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index 0f11713321..66fda867ae 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -268,7 +268,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine textdomain(PACKAGE); #endif - _getcwd( g_WorkingFolder, g_MaxPath ); + strcpy(g_WorkingFolder, Path::GetWorkingDirectory().c_str()); int argc; TCHAR *const *const argv = _CommandLineToArgv( lpCmdLine, &argc ); @@ -286,7 +286,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine MessageBox( NULL, phelpmsg, "Pcsx2 Help", MB_OK); case -1: // exit... - return 0; + return 0; } try diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index 1f46c8d7a4..ce73408362 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -98,7 +98,7 @@ static void (*SSE_SS[]) (x86SSERegType, x86SSERegType) = { }; // Prints Opcode to MicroProgram Logs -void mVU_printOP(microVU* mVU, int opCase, char* opName, bool isACC) { +void mVU_printOP(microVU* mVU, int opCase, const char* opName, bool isACC) { mVUlog(opName); opCase1 { if (isACC) { mVUlogACC(); } else { mVUlogFd(); } mVUlogFt(); } opCase2 { if (isACC) { mVUlogACC(); } else { mVUlogFd(); } mVUlogBC(); } @@ -130,7 +130,7 @@ void setupFtReg(microVU* mVU, int& Ft, int opCase) { } // Normal FMAC Opcodes -void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, char* opName) { +void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, const char* opName) { pass1 { setupPass1(mVU, opCase, isACC, ((opType == 3) || (opType == 4))); } pass2 { int Fs, Ft, ACC; @@ -171,7 +171,7 @@ void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, ch } // MADDA/MSUBA Opcodes -void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, char* opName) { +void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* opName) { pass1 { setupPass1(mVU, opCase, 1, 0); } pass2 { int Fs, Ft, ACC; @@ -215,7 +215,7 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, char* opName) } // MADD Opcodes -void mVU_FMACc(microVU* mVU, int recPass, int opCase, char* opName) { +void mVU_FMACc(microVU* mVU, int recPass, int opCase, const char* opName) { pass1 { setupPass1(mVU, opCase, 0, 0); } pass2 { int Fs, Ft, ACC; @@ -247,7 +247,7 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, char* opName) { } // MSUB Opcodes -void mVU_FMACd(microVU* mVU, int recPass, int opCase, char* opName) { +void mVU_FMACd(microVU* mVU, int recPass, int opCase, const char* opName) { pass1 { setupPass1(mVU, opCase, 0, 0); } pass2 { int Fs, Ft, Fd; @@ -335,7 +335,7 @@ mVUop(mVU_OPMSUB) { } // FTOI0/FTIO4/FTIO12/FTIO15 Opcodes -void mVU_FTOIx(mP, uptr addr, char* opName) { +void mVU_FTOIx(mP, uptr addr, const char* opName) { pass1 { mVUanalyzeFMAC2(mVU, _Fs_, _Ft_); } pass2 { if (!_Ft_) return; @@ -364,7 +364,7 @@ void mVU_FTOIx(mP, uptr addr, char* opName) { } // ITOF0/ITOF4/ITOF12/ITOF15 Opcodes -void mVU_ITOFx(mP, uptr addr, char* opName) { +void mVU_ITOFx(mP, uptr addr, const char* opName) { pass1 { mVUanalyzeFMAC2(mVU, _Fs_, _Ft_); } pass2 { if (!_Ft_) return; From a9999cbffadaef984599e0305a2c20c59985f40a Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 24 Jul 2009 00:53:40 +0000 Subject: [PATCH 02/22] Reworked a few things in PcsxConfig, to make things a little more organized, and make path changes later easier. (May have broken Linux temporarily. If so, I'll fix it in a bit.) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1560 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Config.h | 61 ++++++++++++++++++++++++---------- pcsx2/CDVD/CDVD.cpp | 4 +-- pcsx2/Linux/ConfigDlg.cpp | 8 ++--- pcsx2/Linux/ConfigDlg.h | 16 ++++----- pcsx2/Linux/LnxMain.cpp | 27 +++++++-------- pcsx2/Linux/Pref.cpp | 40 +++++++++++----------- pcsx2/Memory.cpp | 6 ++-- pcsx2/Misc.cpp | 2 +- pcsx2/Paths.h | 6 ++-- pcsx2/Plugins.cpp | 16 ++++----- pcsx2/windows/ConfigDlg.cpp | 50 ++++++++++++++-------------- pcsx2/windows/HacksDlg.cpp | 2 +- pcsx2/windows/McdConfigDlg.cpp | 16 ++++----- pcsx2/windows/Win32.h | 2 +- pcsx2/windows/WinMain.cpp | 17 +++++----- pcsx2/windows/ini.cpp | 40 +++++++++++----------- 16 files changed, 168 insertions(+), 145 deletions(-) diff --git a/common/include/Pcsx2Config.h b/common/include/Pcsx2Config.h index 4623f14110..15f6fbe709 100644 --- a/common/include/Pcsx2Config.h +++ b/common/include/Pcsx2Config.h @@ -132,11 +132,8 @@ struct McdConfig bool Enabled; }; -struct PcsxConfig +struct PluginNames { -public: - char Bios[g_MaxPath]; - char GS[g_MaxPath]; char PAD1[g_MaxPath]; char PAD2[g_MaxPath]; @@ -145,10 +142,46 @@ public: char DEV9[g_MaxPath]; char USB[g_MaxPath]; char FW[g_MaxPath]; +}; - char PluginsDir[g_MaxPath]; - char BiosDir[g_MaxPath]; - char InisDir[g_MaxPath]; // This is intended for the program to populate, and the plugins to read. Obviously can't be saved in the config file. :) +// This is intended to be where all the main paths for Pcsx2 are. +// This may end up being moved to Paths.h. It may also be converted to strings. +struct FilePaths +{ + char Working[g_MaxPath]; + char Plugins[g_MaxPath]; + char Bios[g_MaxPath]; + + // These are mainly placeholders for later. + char Isos[g_MaxPath]; + char Dumps[g_MaxPath]; + + // This is intended for the program to populate, and the plugins to read. + // Obviously can't be saved in the config file. :) + char Inis[g_MaxPath]; +}; + +struct Hacks_t +{ + int EECycleRate; + bool IOPCycleDouble; + //bool WaitCycleExt; + bool INTCSTATSlow; + bool IdleLoopFF; + int VUCycleSteal; + bool vuFlagHack; + bool vuMinMax; + bool ESCExits; // this is a hack!? +}; + +struct PcsxConfig +{ +public: + // The Bios name isn't really a plugin name, so doesn't go with the Plugins. + char Bios[g_MaxPath]; + + PluginNames Plugins; + FilePaths Paths; char Lang[g_MaxPath]; @@ -169,17 +202,9 @@ public: int Mdec; int Patch; int CustomFps; - struct Hacks_t { - int EECycleRate; - bool IOPCycleDouble; - //bool WaitCycleExt; - bool INTCSTATSlow; - bool IdleLoopFF; - int VUCycleSteal; - bool vuFlagHack; - bool vuMinMax; - bool ESCExits; // this is a hack!? - } Hacks; + + Hacks_t Hacks; + int GameFixes; int CustomFrameSkip; int CustomConsecutiveFrames; diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 00d6ded5c4..9825cae210 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -77,7 +77,7 @@ FILE *_cdvdOpenMechaVer() { FILE* fd; // get the name of the bios file - string Bios( Path::Combine( Config.BiosDir, Config.Bios ) ); + string Bios( Path::Combine( Config.Paths.Bios, Config.Bios ) ); // use the bios filename to get the name of the mecha ver file // [TODO] : Upgrade this to use std::string! @@ -125,7 +125,7 @@ FILE *_cdvdOpenNVM() { FILE* fd; // get the name of the bios file - string Bios( Path::Combine( Config.BiosDir, Config.Bios ) ); + string Bios( Path::Combine( Config.Paths.Bios, Config.Bios ) ); // use the bios filename to get the name of the nvm file // [TODO] : Upgrade this to use std::string! diff --git a/pcsx2/Linux/ConfigDlg.cpp b/pcsx2/Linux/ConfigDlg.cpp index dd0f3f924d..120eeea56a 100644 --- a/pcsx2/Linux/ConfigDlg.cpp +++ b/pcsx2/Linux/ConfigDlg.cpp @@ -239,7 +239,7 @@ void OnConfConf_BiosPath(GtkButton *button, gpointer user_data) char reply[g_MaxPath]; GetDirectory(ConfDlg, "Choose the Bios Directory:", reply); - strcpy(Config.BiosDir, reply); + strcpy(Config.Paths.Bios, reply); UpdateConfDlg(); } @@ -391,10 +391,10 @@ void FindPlugins() } closedir(dir); - dir = opendir(Config.BiosDir); + dir = opendir(Config.Paths.Bios); if (dir == NULL) { - Msgbox::Alert("Could not open '%s' directory", params Config.BiosDir); + Msgbox::Alert("Could not open '%s' directory", params Config.Paths.Bios); return; } @@ -403,7 +403,7 @@ void FindPlugins() struct stat buf; char description[50]; //2002-09-28 (Florin) - sprintf(plugin, "%s%s", Config.BiosDir, ent->d_name); + sprintf(plugin, "%s%s", Config.Paths.Bios, ent->d_name); if (stat(plugin, &buf) == -1) continue; if (buf.st_size > (1024*4096)) continue; //2002-09-28 (Florin) if (!IsBIOS(ent->d_name, description)) continue;//2002-09-28 (Florin) diff --git a/pcsx2/Linux/ConfigDlg.h b/pcsx2/Linux/ConfigDlg.h index 081e2c0a3f..09e5d1a42d 100644 --- a/pcsx2/Linux/ConfigDlg.h +++ b/pcsx2/Linux/ConfigDlg.h @@ -83,14 +83,14 @@ __forceinline const char *PluginName(int type) { switch (type) { - case GS: return Config.GS; - case PAD1: return Config.PAD1; - case PAD2: return Config.PAD2; - case SPU2: return Config.SPU2; - case CDVD: return Config.CDVD; - case DEV9: return Config.DEV9; - case USB: return Config.USB; - case FW: return Config.FW; + case GS: return Config.Plugins.GS; + case PAD1: return Config.Plugins.PAD1; + case PAD2: return Config.Plugins.PAD2; + case SPU2: return Config.Plugins.SPU2; + case CDVD: return Config.Plugins.CDVD; + case DEV9: return Config.Plugins.DEV9; + case USB: return Config.Plugins.USB; + case FW: return Config.Plugins.FW; case BIOS: return Config.Bios; } return NULL; diff --git a/pcsx2/Linux/LnxMain.cpp b/pcsx2/Linux/LnxMain.cpp index 86125d5995..f8e0faf723 100644 --- a/pcsx2/Linux/LnxMain.cpp +++ b/pcsx2/Linux/LnxMain.cpp @@ -28,38 +28,35 @@ const char* g_pRunGSState = NULL; int efile = 0; char elfname[g_MaxPath]; -char MAIN_DIR[g_MaxPath]; int main(int argc, char *argv[]) { char *file = NULL; char elfname[g_MaxPath]; - string MainDirString; efile = 0; /* store main dir */ - MainDirString = Path::GetWorkingDirectory(); - strcpy(MAIN_DIR, MainDirString.c_str()); - Console::Notice("MAIN_DIR is %s", params MAIN_DIR); + strcpy(Config.Paths.Working, Path::GetWorkingDirectory().c_str()); + Console::Notice("Config.Paths.Working is %s", params Config.Paths.Working); #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, "Langs"); textdomain(PACKAGE); #endif - // Note: Config.InisDir won't do anything till we set up windows and the plugins to use it. + // Note: Config.Paths.Inis won't do anything till we set up windows and the plugins to use it. #ifndef LOCAL_PLUGIN_INIS mkdir(DEFAULT_INIS_DIR, 0755); - sprintf(Config.InisDir, "%s/%s/", MAIN_DIR, DEFAULT_INIS_DIR); - sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir); + sprintf(Config.Paths.Inis, "%s/%s/", Config.Paths.Working, DEFAULT_INIS_DIR); + sprintf(cfgfile, "%s/pcsx2.cfg", Config.Paths.Inis); #else Path::CreateDirectory(string("~/.pcsx2")); Path::ChangeDirectory(string("~/.pcsx2")); Path::CreateDirectory(string(DEFAULT_INIS_DIR)); - sprintf(Config.InisDir, "~/.pcsx2/%s/", DEFAULT_INIS_DIR); - sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir); - Path::ChangeDirectory(string(MAIN_DIR)); + sprintf(Config.Paths.Inis, "~/.pcsx2/%s/", DEFAULT_INIS_DIR); + sprintf(cfgfile, "%s/pcsx2.cfg", Config.Paths.Inis); + Path::ChangeDirectory(string(Config.Paths.Working)); #endif #ifdef PCSX2_DEVBUILD @@ -84,10 +81,10 @@ int main(int argc, char *argv[]) { memset(&Config, 0, sizeof(Config)); - sprintf(Config.BiosDir, "%s/%s/", MAIN_DIR, DEFAULT_BIOS_DIR); - sprintf(Config.PluginsDir, "%s/%s/", MAIN_DIR, DEFAULT_PLUGINS_DIR); - sprintf(Config.Mcd[0].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD1); - sprintf(Config.Mcd[1].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD2); + sprintf(Config.Paths.Bios, "%s/%s/", Config.Paths.Working, DEFAULT_BIOS_DIR); + sprintf(Config.Paths.Plugins, "%s/%s/", Config.Paths.Working, DEFAULT_PLUGINS_DIR); + sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD1); + sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD2); Config.Mcd[0].Enabled = 1; Config.Mcd[1].Enabled = 1; Config.McdEnableEject = 1; diff --git a/pcsx2/Linux/Pref.cpp b/pcsx2/Linux/Pref.cpp index 77ebfb3db0..916af5829d 100644 --- a/pcsx2/Linux/Pref.cpp +++ b/pcsx2/Linux/Pref.cpp @@ -73,8 +73,8 @@ int LoadConfig() GetValue("Lang", Config.Lang); GetValuel("Ps2Out", Config.PsxOut); GetValuel("cdvdPrint", Config.cdvdPrint); - GetValue("PluginsDir", Config.PluginsDir); - GetValue("BiosDir", Config.BiosDir); + GetValue("PluginsDir", Config.Paths.Plugins); + GetValue("BiosDir", Config.Paths.Bios); GetValuel("EnabledCard1", Config.Mcd[0].Enabled); GetValue("Mcd1", Config.Mcd[0].Filename); @@ -86,14 +86,14 @@ int LoadConfig() GetValuel("McdEnableEject", Config.McdEnableEject); - GetValue("GS", Config.GS); - GetValue("SPU2", Config.SPU2); - GetValue("CDVD", Config.CDVD); - GetValue("PAD1", Config.PAD1); - GetValue("PAD2", Config.PAD2); - GetValue("DEV9", Config.DEV9); - GetValue("USB", Config.USB); - GetValue("FW", Config.FW); + GetValue("GS", Config.Plugins.GS); + GetValue("SPU2", Config.Plugins.SPU2); + GetValue("CDVD", Config.Plugins.CDVD); + GetValue("PAD1", Config.Plugins.PAD1); + GetValue("PAD2", Config.Plugins.PAD2); + GetValue("DEV9", Config.Plugins.DEV9); + GetValue("USB", Config.Plugins.USB); + GetValue("FW", Config.Plugins.FW); GetValuel("Patch", Config.Patch); #ifdef PCSX2_DEVBUILD @@ -154,8 +154,8 @@ void SaveConfig() SetValue("Bios", Config.Bios); SetValue("Lang", Config.Lang); - SetValue("PluginsDir", Config.PluginsDir); - SetValue("BiosDir", Config.BiosDir); + SetValue("PluginsDir", Config.Paths.Plugins); + SetValue("BiosDir", Config.Paths.Bios); SetValuel("Ps2Out", Config.PsxOut); SetValuel("cdvdPrint", Config.cdvdPrint); @@ -167,14 +167,14 @@ void SaveConfig() SetValue("Mcd2", Config.Mcd[1].Filename); SetValuel("McdEnableEject", Config.McdEnableEject); - SetValue("GS", Config.GS); - SetValue("SPU2", Config.SPU2); - SetValue("CDVD", Config.CDVD); - SetValue("PAD1", Config.PAD1); - SetValue("PAD2", Config.PAD2); - SetValue("DEV9", Config.DEV9); - SetValue("USB", Config.USB); - SetValue("FW", Config.FW); + SetValue("GS", Config.Plugins.GS); + SetValue("SPU2", Config.Plugins.SPU2); + SetValue("CDVD", Config.Plugins.CDVD); + SetValue("PAD1", Config.Plugins.PAD1); + SetValue("PAD2", Config.Plugins.PAD2); + SetValue("DEV9", Config.Plugins.DEV9); + SetValue("USB", Config.Plugins.USB); + SetValue("FW", Config.Plugins.FW); SetValuel("Options", Config.Options); diff --git a/pcsx2/Memory.cpp b/pcsx2/Memory.cpp index 8a7f22fc9d..9cdc11a4e0 100644 --- a/pcsx2/Memory.cpp +++ b/pcsx2/Memory.cpp @@ -90,7 +90,7 @@ void loadBiosRom( const char *ext, u8 *dest, long maxSize ) string Bios1; long filesize; - string Bios( Path::Combine( Config.BiosDir, Config.Bios ) ); + string Bios( Path::Combine( Config.Paths.Bios, Config.Bios ) ); // Try first a basic extension concatenation (normally results in something like name.bin.rom1) ssprintf(Bios1, "%hs.%s", &Bios, ext); @@ -101,7 +101,7 @@ void loadBiosRom( const char *ext, u8 *dest, long maxSize ) if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 ) { // Try for the old-style method (rom1.bin) - Bios1 = Path::Combine( Config.BiosDir, ext ) + ".bin"; + Bios1 = Path::Combine( Config.Paths.Bios, ext ) + ".bin"; if( (filesize=Path::getFileSize( Bios1 ) ) <= 0 ) { Console::Notice( "Bios Warning > %s not found.", params ext ); @@ -802,7 +802,7 @@ void memReset() vtlb_VMapUnmap(0x20000000,0x60000000); FILE *fp; - string Bios( Path::Combine( Config.BiosDir, Config.Bios ) ); + string Bios( Path::Combine( Config.Paths.Bios, Config.Bios ) ); long filesize; if( ( filesize = Path::getFileSize( Bios ) ) <= 0 ) diff --git a/pcsx2/Misc.cpp b/pcsx2/Misc.cpp index dab17662ac..3077150e82 100644 --- a/pcsx2/Misc.cpp +++ b/pcsx2/Misc.cpp @@ -220,7 +220,7 @@ int IsBIOS(const char *filename, char *description) unsigned int fileOffset=0, found=FALSE; struct romdir rd; - string Bios( Path::Combine( Config.BiosDir, filename ) ); + string Bios( Path::Combine( Config.Paths.Bios, filename ) ); int biosFileSize = Path::getFileSize( Bios ); if( biosFileSize <= 0) return FALSE; diff --git a/pcsx2/Paths.h b/pcsx2/Paths.h index 348d74d755..b8ae430236 100644 --- a/pcsx2/Paths.h +++ b/pcsx2/Paths.h @@ -21,9 +21,9 @@ #define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs. -#ifdef __LINUX__ -extern char MAIN_DIR[g_MaxPath]; -#endif +//#ifdef __LINUX__ +//extern char MAIN_DIR[g_MaxPath]; +//#endif #define DEFAULT_INIS_DIR "inis" #define DEFAULT_BIOS_DIR "bios" diff --git a/pcsx2/Plugins.cpp b/pcsx2/Plugins.cpp index 9734d535c7..edc4682081 100644 --- a/pcsx2/Plugins.cpp +++ b/pcsx2/Plugins.cpp @@ -721,14 +721,14 @@ int LoadPlugins() { if (plugins_loaded) return 0; - if (LoadGSplugin( Path::Combine( Config.PluginsDir, Config.GS )) == -1) return -1; - if (LoadPAD1plugin( Path::Combine( Config.PluginsDir, Config.PAD1 )) == -1) return -1; - if (LoadPAD2plugin( Path::Combine( Config.PluginsDir, Config.PAD2 )) == -1) return -1; - if (LoadSPU2plugin( Path::Combine( Config.PluginsDir, Config.SPU2 )) == -1) return -1; - if (LoadCDVDplugin( Path::Combine( Config.PluginsDir, Config.CDVD )) == -1) return -1; - if (LoadDEV9plugin( Path::Combine( Config.PluginsDir, Config.DEV9 )) == -1) return -1; - if (LoadUSBplugin( Path::Combine( Config.PluginsDir, Config.USB )) == -1) return -1; - if (LoadFWplugin( Path::Combine( Config.PluginsDir, Config.FW )) == -1) return -1; + if (LoadGSplugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.GS )) == -1) return -1; + if (LoadPAD1plugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.PAD1 )) == -1) return -1; + if (LoadPAD2plugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.PAD2 )) == -1) return -1; + if (LoadSPU2plugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.SPU2 )) == -1) return -1; + if (LoadCDVDplugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.CDVD )) == -1) return -1; + if (LoadDEV9plugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.DEV9 )) == -1) return -1; + if (LoadUSBplugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.USB )) == -1) return -1; + if (LoadFWplugin( Path::Combine( Config.Paths.Plugins, Config.Plugins.FW )) == -1) return -1; plugins_loaded = true; diff --git a/pcsx2/windows/ConfigDlg.cpp b/pcsx2/windows/ConfigDlg.cpp index 82592ed3aa..05fe13c98f 100644 --- a/pcsx2/windows/ConfigDlg.cpp +++ b/pcsx2/windows/ConfigDlg.cpp @@ -46,7 +46,7 @@ struct ComboInitializer , PS2E_GetLibName( NULL ) , PS2E_GetLibVersion2( NULL ) { - Find = FindFirstFile( Path::Combine( Config.PluginsDir, "*.dll" ).c_str(), &FindData); + Find = FindFirstFile( Path::Combine( Config.Paths.Plugins, "*.dll" ).c_str(), &FindData); } ~ComboInitializer() @@ -62,7 +62,7 @@ struct ComboInitializer bool LoadNextLibrary() { - string tmpStr( Path::Combine( Config.PluginsDir, FindData.cFileName ) ); + string tmpStr( Path::Combine( Config.Paths.Plugins, FindData.cFileName ) ); Lib = HostSys::LoadLibrary( tmpStr.c_str() ); if (Lib == NULL) { @@ -129,7 +129,7 @@ BOOL OnConfigureDialog(HWND hW) { if( !tool.LoadNextLibrary() ) continue; if( tool.CheckVersion( "GS", PS2E_LT_GS, PS2E_GS_VERSION ) ) - tool.AddPlugin(hWC_GS, winConfig.GS); + tool.AddPlugin(hWC_GS, winConfig.Plugins.GS); if (tool.type & PS2E_LT_PAD) { @@ -141,27 +141,27 @@ BOOL OnConfigureDialog(HWND hW) { if( tool.CheckVersion( "PAD", PS2E_LT_PAD, PS2E_PAD_VERSION ) ) { if (query() & 0x1) - tool.AddPlugin(hWC_PAD1, winConfig.PAD1); + tool.AddPlugin(hWC_PAD1, winConfig.Plugins.PAD1); if (query() & 0x2) - tool.AddPlugin(hWC_PAD2, winConfig.PAD2); + tool.AddPlugin(hWC_PAD2, winConfig.Plugins.PAD2); } } } if( tool.CheckVersion( "SPU2", PS2E_LT_SPU2, PS2E_SPU2_VERSION ) ) - tool.AddPlugin(hWC_SPU2, winConfig.SPU2); + tool.AddPlugin(hWC_SPU2, winConfig.Plugins.SPU2); if( tool.CheckVersion( "CDVD", PS2E_LT_CDVD, PS2E_CDVD_VERSION ) ) - tool.AddPlugin(hWC_CDVD, winConfig.CDVD); + tool.AddPlugin(hWC_CDVD, winConfig.Plugins.CDVD); if( tool.CheckVersion( "DEV9", PS2E_LT_DEV9, PS2E_DEV9_VERSION ) ) - tool.AddPlugin(hWC_DEV9, winConfig.DEV9); + tool.AddPlugin(hWC_DEV9, winConfig.Plugins.DEV9); if( tool.CheckVersion( "USB", PS2E_LT_USB, PS2E_USB_VERSION ) ) - tool.AddPlugin(hWC_USB, winConfig.USB); + tool.AddPlugin(hWC_USB, winConfig.Plugins.USB); if( tool.CheckVersion( "FW", PS2E_LT_FW, PS2E_FW_VERSION ) ) - tool.AddPlugin(hWC_FW, winConfig.FW); + tool.AddPlugin(hWC_FW, winConfig.Plugins.FW); } while( tool.FindNext() ); @@ -177,7 +177,7 @@ BOOL OnConfigureDialog(HWND hW) { HANDLE Find; WIN32_FIND_DATA FindData; - Find = FindFirstFile( Path::Combine( Config.BiosDir, "*" ).c_str(), &FindData); + Find = FindFirstFile( Path::Combine( Config.Paths.Bios, "*" ).c_str(), &FindData); do { @@ -268,21 +268,21 @@ char *GetComboSel(HWND hW, int id) { void OnOK(HWND hW) { CheckComboSel(winConfig.Bios, IDC_LISTBIOS); - CheckComboSel(winConfig.GS, IDC_LISTGS); - CheckComboSel(winConfig.PAD1, IDC_LISTPAD1); - CheckComboSel(winConfig.PAD2, IDC_LISTPAD2); - CheckComboSel(winConfig.SPU2, IDC_LISTSPU2); - CheckComboSel(winConfig.CDVD, IDC_LISTCDVD); - CheckComboSel(winConfig.DEV9, IDC_LISTDEV9); - CheckComboSel(winConfig.USB, IDC_LISTUSB); - CheckComboSel(winConfig.FW, IDC_LISTFW); + CheckComboSel(winConfig.Plugins.GS, IDC_LISTGS); + CheckComboSel(winConfig.Plugins.PAD1, IDC_LISTPAD1); + CheckComboSel(winConfig.Plugins.PAD2, IDC_LISTPAD2); + CheckComboSel(winConfig.Plugins.SPU2, IDC_LISTSPU2); + CheckComboSel(winConfig.Plugins.CDVD, IDC_LISTCDVD); + CheckComboSel(winConfig.Plugins.DEV9, IDC_LISTDEV9); + CheckComboSel(winConfig.Plugins.USB, IDC_LISTUSB); + CheckComboSel(winConfig.Plugins.FW, IDC_LISTFW); CleanUpCombos(hW); EndDialog(hW, TRUE); // Apply winConfig settings: - #define ApplyPluginPath( name ) strcpy( Config.name, winConfig.name ) - ApplyPluginPath( Bios ); + #define ApplyPluginPath( name ) strcpy( Config.Plugins.name, winConfig.Plugins.name ) + strcpy( Config.Bios, winConfig.Bios ); ApplyPluginPath( GS ); ApplyPluginPath( PAD1 ); ApplyPluginPath( PAD2 ); @@ -306,7 +306,7 @@ static void ConfPlugin( HWND hW, int confs, const char* name ) if(pDLL==NULL) return; - drv = SysLoadLibrary( Path::Combine( Config.PluginsDir, pDLL ).c_str() ); + drv = SysLoadLibrary( Path::Combine( Config.Paths.Plugins, pDLL ).c_str() ); if (drv == NULL) return; conf = (void (*)()) SysLoadSym(drv, name); @@ -385,7 +385,7 @@ static void TestPlugin( HWND hW, int confs, const char* name ) if (pDLL== NULL) return; - drv = SysLoadLibrary( Path::Combine( Config.PluginsDir, pDLL ).c_str() ); + drv = SysLoadLibrary( Path::Combine( Config.Paths.Plugins, pDLL ).c_str() ); if (drv == NULL) return; conf = (int (*)()) SysLoadSym(drv, name); @@ -456,7 +456,7 @@ void SetPluginsDir(HWND hW) { char Path[g_MaxPath]; if (SelectPath(hW, _("Select Plugins Directory"), Path) == -1) return; - strcpy(Config.PluginsDir, Path); + strcpy(Config.Paths.Plugins, Path); CleanUpCombos(hW); OnConfigureDialog(hW); } @@ -465,7 +465,7 @@ void SetBiosDir(HWND hW) { char Path[g_MaxPath]; if (SelectPath(hW, _("Select Bios Directory"), Path) == -1) return; - strcpy(Config.BiosDir, Path); + strcpy(Config.Paths.Bios, Path); CleanUpCombos(hW); OnConfigureDialog(hW); } diff --git a/pcsx2/windows/HacksDlg.cpp b/pcsx2/windows/HacksDlg.cpp index 55ad85e67a..07f67d48e8 100644 --- a/pcsx2/windows/HacksDlg.cpp +++ b/pcsx2/windows/HacksDlg.cpp @@ -76,7 +76,7 @@ BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { case IDOK: { - PcsxConfig::Hacks_t newhacks; + Hacks_t newhacks; newhacks.EECycleRate = 0; for( int i=1; i<3; i++ ) diff --git a/pcsx2/windows/McdConfigDlg.cpp b/pcsx2/windows/McdConfigDlg.cpp index c78c1075aa..826bd78c38 100644 --- a/pcsx2/windows/McdConfigDlg.cpp +++ b/pcsx2/windows/McdConfigDlg.cpp @@ -59,7 +59,7 @@ void DlgItem_GetText( HWND hwnd, int dlgId, string& dest ) static const char* _stripPathInfo( const char* src ) { const char* retval = src; - const char* workingfold = g_WorkingFolder; + const char* workingfold = Config.Paths.Working; while( (*retval != 0) && (*workingfold != 0) && (tolower(*retval) == tolower(*workingfold)) ) { @@ -115,7 +115,7 @@ void MemcardConfig::Open_Mcd_Proc(HWND hW, int mcd) if (GetOpenFileName ((LPOPENFILENAME)&ofn)) { Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD_FILE1 : IDC_MCD_FILE2), - _stripPathInfo( Path::Combine( g_WorkingFolder, szFileName ).c_str() ) ); + _stripPathInfo( Path::Combine( Config.Paths.Working, szFileName ).c_str() ) ); } } @@ -146,13 +146,13 @@ BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA if( Config.Mcd[0].Filename[0] == 0 ) { strcpy_s( Config.Mcd[0].Filename, - Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[0] ).c_str() ); + Path::Combine( Config.Paths.Working, m_Default_MemcardsDir[0] ).c_str() ); } if( Config.Mcd[1].Filename[1] == 0 ) { strcpy_s( Config.Mcd[1].Filename, - Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[1] ).c_str() ); + Path::Combine( Config.Paths.Working, m_Default_MemcardsDir[1] ).c_str() ); } Edit_SetText( GetDlgItem(hWnd,IDC_MCD_FILE1), _stripPathInfo( Config.Mcd[0].Filename ) ); @@ -197,8 +197,8 @@ BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA // reassign text with the extra unnecessary path info stripped out. - _tcscpy( Config.Mcd[0].Filename, _stripPathInfo( Path::Combine( g_WorkingFolder, Config.Mcd[0].Filename ).c_str() ) ); - _tcscpy( Config.Mcd[1].Filename, _stripPathInfo( Path::Combine( g_WorkingFolder, Config.Mcd[1].Filename ).c_str() ) ); + _tcscpy( Config.Mcd[0].Filename, _stripPathInfo( Path::Combine( Config.Paths.Working, Config.Mcd[0].Filename ).c_str() ) ); + _tcscpy( Config.Mcd[1].Filename, _stripPathInfo( Path::Combine( Config.Paths.Working, Config.Mcd[1].Filename ).c_str() ) ); if( g_EmulationInProgress ) { @@ -247,10 +247,10 @@ void IniFile::MemcardSettings( PcsxConfig& conf ) SetCurrentSection( "Memorycards" ); Entry( "Slot1_Path", conf.Mcd[0].Filename, - Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[0] ) ); + Path::Combine( Config.Paths.Working, m_Default_MemcardsDir[0] ) ); Entry( "Slot2_Path", conf.Mcd[1].Filename, - Path::Combine( g_WorkingFolder, m_Default_MemcardsDir[1] ) ); + Path::Combine( Config.Paths.Working, m_Default_MemcardsDir[1] ) ); Entry( "Slot1_Enabled", conf.Mcd[0].Enabled, true ); Entry( "Slot2_Enabled", conf.Mcd[1].Enabled, true ); diff --git a/pcsx2/windows/Win32.h b/pcsx2/windows/Win32.h index 252475101e..a0c4f8f652 100644 --- a/pcsx2/windows/Win32.h +++ b/pcsx2/windows/Win32.h @@ -43,7 +43,7 @@ int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps); // --->> Ini Configuration [ini.c] -extern char g_WorkingFolder[g_MaxPath]; +//extern char g_WorkingFolder[g_MaxPath]; extern const char* g_CustomConfigFile; bool LoadConfig(); diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index 66fda867ae..6dfe9e492d 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -197,12 +197,12 @@ void WinRun() memcpy( &winConfig, &Config, sizeof( PcsxConfig ) ); - _doPluginOverride( "GS", g_Startup.gsdll, Config.GS ); - _doPluginOverride( "CDVD", g_Startup.cdvddll, Config.CDVD ); - _doPluginOverride( "SPU2", g_Startup.spudll, Config.SPU2 ); - _doPluginOverride( "PAD1", g_Startup.pad1dll, Config.PAD1 ); - _doPluginOverride( "PAD2", g_Startup.pad2dll, Config.PAD2 ); - _doPluginOverride( "DEV9", g_Startup.dev9dll, Config.DEV9 ); + _doPluginOverride( "GS", g_Startup.gsdll, Config.Plugins.GS ); + _doPluginOverride( "CDVD", g_Startup.cdvddll, Config.Plugins.CDVD ); + _doPluginOverride( "SPU2", g_Startup.spudll, Config.Plugins.SPU2 ); + _doPluginOverride( "PAD1", g_Startup.pad1dll, Config.Plugins.PAD1 ); + _doPluginOverride( "PAD2", g_Startup.pad2dll, Config.Plugins.PAD2 ); + _doPluginOverride( "DEV9", g_Startup.dev9dll, Config.Plugins.DEV9 ); if( Config.Profiler ) @@ -268,7 +268,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine textdomain(PACKAGE); #endif - strcpy(g_WorkingFolder, Path::GetWorkingDirectory().c_str()); + //strcpy(g_WorkingFolder, Path::GetWorkingDirectory().c_str()); + strcpy(Config.Paths.Working, Path::GetWorkingDirectory().c_str()); int argc; TCHAR *const *const argv = _CommandLineToArgv( lpCmdLine, &argc ); @@ -739,7 +740,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case ID_CONFIG_CONTROLLERS: if (PAD1configure) PAD1configure(); if (PAD2configure) { - if (strcmp(Config.PAD1, Config.PAD2))PAD2configure(); + if (strcmp(Config.Plugins.PAD1, Config.Plugins.PAD2))PAD2configure(); } break; diff --git a/pcsx2/windows/ini.cpp b/pcsx2/windows/ini.cpp index e31086c5fd..2092ef6d8c 100644 --- a/pcsx2/windows/ini.cpp +++ b/pcsx2/windows/ini.cpp @@ -24,7 +24,7 @@ static const u32 IniVersion = 102; const char* g_CustomConfigFile; -char g_WorkingFolder[g_MaxPath]; // Working folder at application startup +//char g_WorkingFolder[g_MaxPath]; // Working folder at application startup // Returns TRUE if the user has invoked the -cfg command line option. static bool hasCustomConfig() @@ -38,7 +38,7 @@ static string GetConfigFilename() // Load a user-specified configuration, or use the ini relative to the application's working directory. // (Our current working directory can change, so we use the one we detected at startup) - return Path::Combine( g_WorkingFolder, hasCustomConfig() ? g_CustomConfigFile : (DEFAULT_INIS_DIR "\\pcsx2.ini") ); + return Path::Combine( Config.Paths.Working, hasCustomConfig() ? g_CustomConfigFile : (DEFAULT_INIS_DIR "\\pcsx2.ini") ); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -188,9 +188,9 @@ void IniFile::DoConfig( PcsxConfig& Conf ) Entry( "Bios", Conf.Bios ); Entry( "Language", Conf.Lang ); string plug = DEFAULT_PLUGINS_DIR; - Entry( "PluginsDir", Conf.PluginsDir, plug ); + Entry( "PluginsDir", Conf.Paths.Plugins, plug ); string bios = DEFAULT_BIOS_DIR; - Entry( "BiosDir", Conf.BiosDir, bios ); + Entry( "BiosDir", Conf.Paths.Bios, bios ); Entry( "CloseGsOnEscape", Conf.closeGSonEsc, true ); SetCurrentSection( "Console" ); @@ -208,14 +208,14 @@ void IniFile::DoConfig( PcsxConfig& Conf ) SetCurrentSection( "Plugins" ); - Entry( "GS", Conf.GS ); - Entry( "SPU2", Conf.SPU2 ); - Entry( "CDVD", Conf.CDVD ); - Entry( "PAD1", Conf.PAD1 ); - Entry( "PAD2", Conf.PAD2 ); - Entry( "DEV9", Conf.DEV9 ); - Entry( "USB", Conf.USB ); - Entry( "FW", Conf.FW ); + Entry( "GS", Conf.Plugins.GS ); + Entry( "SPU2", Conf.Plugins.SPU2 ); + Entry( "CDVD", Conf.Plugins.CDVD ); + Entry( "PAD1", Conf.Plugins.PAD1 ); + Entry( "PAD2", Conf.Plugins.PAD2 ); + Entry( "DEV9", Conf.Plugins.DEV9 ); + Entry( "USB", Conf.Plugins.USB ); + Entry( "FW", Conf.Plugins.FW ); //cpu SetCurrentSection( "Cpu" ); @@ -317,14 +317,14 @@ void SaveConfig() { PcsxConfig tmpConf = Config; - strcpy( tmpConf.GS, winConfig.GS ); - strcpy( tmpConf.SPU2, winConfig.SPU2 ); - strcpy( tmpConf.CDVD, winConfig.CDVD ); - strcpy( tmpConf.PAD1, winConfig.PAD1 ); - strcpy( tmpConf.PAD2, winConfig.PAD2 ); - strcpy( tmpConf.DEV9, winConfig.DEV9 ); - strcpy( tmpConf.USB, winConfig.USB ); - strcpy( tmpConf.FW, winConfig.FW ); + strcpy( tmpConf.Plugins.GS, winConfig.Plugins.GS ); + strcpy( tmpConf.Plugins.SPU2, winConfig.Plugins.SPU2 ); + strcpy( tmpConf.Plugins.CDVD, winConfig.Plugins.CDVD ); + strcpy( tmpConf.Plugins.PAD1, winConfig.Plugins.PAD1 ); + strcpy( tmpConf.Plugins.PAD2, winConfig.Plugins.PAD2 ); + strcpy( tmpConf.Plugins.DEV9, winConfig.Plugins.DEV9 ); + strcpy( tmpConf.Plugins.USB, winConfig.Plugins.USB ); + strcpy( tmpConf.Plugins.FW, winConfig.Plugins.FW ); IniFileSaver().DoConfig( tmpConf ); } From 90c2f8ebc6f48860b9b49d23c0cbb635fae28f4d Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 24 Jul 2009 01:11:41 +0000 Subject: [PATCH 03/22] Fixed up Linux after my previous changes. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1561 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Linux/ConfigDlg.cpp | 10 +++++----- pcsx2/Linux/HacksDlg.cpp | 2 +- pcsx2/Linux/LnxMain.cpp | 4 ++-- pcsx2/Linux/McdDlgs.cpp | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pcsx2/Linux/ConfigDlg.cpp b/pcsx2/Linux/ConfigDlg.cpp index 120eeea56a..66773fb5c2 100644 --- a/pcsx2/Linux/ConfigDlg.cpp +++ b/pcsx2/Linux/ConfigDlg.cpp @@ -58,7 +58,7 @@ static void ConfPlugin(plugin_types type, plugin_callback call, bool pullcombo = if (pullcombo) GetComboText(confs->Combo, confs->plist, plugin); if (plugin == NULL) return; - drv = SysLoadLibrary( Path::Combine( Config.PluginsDir, plugin ).c_str() ); + drv = SysLoadLibrary( Path::Combine( Config.Paths.Plugins, plugin ).c_str() ); if (drv == NULL) return; if (call != PLUGIN_TEST) @@ -229,7 +229,7 @@ void OnConfConf_PluginsPath(GtkButton *button, gpointer user_data) char reply[g_MaxPath]; GetDirectory(ConfDlg, "Choose the Plugin Directory:", reply); - strcpy(Config.PluginsDir, reply); + strcpy(Config.Paths.Plugins, reply); UpdateConfDlg(); } @@ -282,10 +282,10 @@ void FindPlugins() confs->PluginNameList = NULL; } - dir = opendir(Config.PluginsDir); + dir = opendir(Config.Paths.Plugins); if (dir == NULL) { - Msgbox::Alert("Could not open '%s' directory", params Config.PluginsDir); + Msgbox::Alert("Could not open '%s' directory", params Config.Paths.Plugins); return; } while ((ent = readdir(dir)) != NULL) @@ -293,7 +293,7 @@ void FindPlugins() u32 version; u32 type; - sprintf(plugin, "%s%s", Config.PluginsDir, ent->d_name); + sprintf(plugin, "%s%s", Config.Paths.Plugins, ent->d_name); if (strstr(plugin, ".so") == NULL) continue; Handle = SysLoadLibrary(plugin); diff --git a/pcsx2/Linux/HacksDlg.cpp b/pcsx2/Linux/HacksDlg.cpp index 88e36ebdcd..98b6b2cdc1 100644 --- a/pcsx2/Linux/HacksDlg.cpp +++ b/pcsx2/Linux/HacksDlg.cpp @@ -100,7 +100,7 @@ void on_Speed_Hacks(GtkMenuItem *menuitem, gpointer user_data) void on_Speed_Hack_OK(GtkButton *button, gpointer user_data) { - PcsxConfig::Hacks_t newhacks; + Hacks_t newhacks; newhacks.EECycleRate = 0; newhacks.IOPCycleDouble = is_checked(SpeedHacksDlg, "check_iop_cycle_rate"); diff --git a/pcsx2/Linux/LnxMain.cpp b/pcsx2/Linux/LnxMain.cpp index f8e0faf723..1c1a9d9605 100644 --- a/pcsx2/Linux/LnxMain.cpp +++ b/pcsx2/Linux/LnxMain.cpp @@ -432,12 +432,12 @@ void pcsx2_exit() // with this the problem with plugins that are linked with the pthread // library is solved - dir = opendir(Config.PluginsDir); + dir = opendir(Config.Paths.Plugins); if (dir != NULL) { while ((ent = readdir(dir)) != NULL) { - sprintf(plugin, "%s%s", Config.PluginsDir, ent->d_name); + sprintf(plugin, "%s%s", Config.Paths.Plugins, ent->d_name); if (strstr(plugin, ".so") == NULL) continue; Handle = SysLoadLibrary(plugin); diff --git a/pcsx2/Linux/McdDlgs.cpp b/pcsx2/Linux/McdDlgs.cpp index 39454e1afc..0968c0d013 100644 --- a/pcsx2/Linux/McdDlgs.cpp +++ b/pcsx2/Linux/McdDlgs.cpp @@ -38,7 +38,7 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) set_checked(MemDlg, "check_enable_mcd2", Config.Mcd[1].Enabled); set_checked(MemDlg, "check_eject_mcds", Config.McdEnableEject); - file = Path::GetCurrentDirectory();/* store current dir */ + file = Path::GetWorkingDirectory();/* store current dir */ sprintf(card, "%s/%s", file.c_str(), MEMCARDS_DIR ); Path::ChangeDirectory(string(card));/* change dirs so that plugins can find their config file*/ @@ -56,7 +56,7 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) { char path[g_MaxPath]; - sprintf(path, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, entry->d_name); + sprintf(path, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, entry->d_name); for (j = 0; j < 2; j++) { @@ -83,17 +83,17 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) void OnMemcards_Ok(GtkButton *button, gpointer user_data) { if (gtk_combo_box_get_active(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo"))) != -1) - sprintf(Config.Mcd[0].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, + sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo")))); else - sprintf(Config.Mcd[0].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD1); + sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD1); if (gtk_combo_box_get_active(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo"))) != -1) - sprintf(Config.Mcd[1].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, + sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo")))); else - sprintf(Config.Mcd[1].Filename, "%s/%s/%s", MAIN_DIR, MEMCARDS_DIR, DEFAULT_MEMCARD2); + sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD2); Config.Mcd[0].Enabled = is_checked(MemDlg, "check_enable_mcd1"); Config.Mcd[1].Enabled = is_checked(MemDlg, "check_enable_mcd2"); From 56a98ca922c1b36b2c2b8f521a7abf7c38fca43d Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 24 Jul 2009 03:08:14 +0000 Subject: [PATCH 04/22] Converted a few of the file paths to strings, and moved the generic file manipulation functions in IsoFileFormats to their own file. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1562 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Config.h | 8 +- pcsx2/CDVD/IsoFileFormats.cpp | 130 +----------------- pcsx2/CDVD/IsoFileFormats.h | 27 +--- pcsx2/CDVD/IsoFileTools.cpp | 148 +++++++++++++++++++++ pcsx2/CDVD/IsoFileTools.h | 50 +++++++ pcsx2/CDVD/Makefile.am | 2 +- pcsx2/Linux/LnxMain.cpp | 28 ++-- pcsx2/Linux/McdDlgs.cpp | 10 +- pcsx2/windows/McdConfigDlg.cpp | 2 +- pcsx2/windows/VCprojects/pcsx2_2008.vcproj | 8 ++ pcsx2/windows/WinMain.cpp | 2 +- 11 files changed, 234 insertions(+), 181 deletions(-) create mode 100644 pcsx2/CDVD/IsoFileTools.cpp create mode 100644 pcsx2/CDVD/IsoFileTools.h diff --git a/common/include/Pcsx2Config.h b/common/include/Pcsx2Config.h index 15f6fbe709..17b6bfe6f1 100644 --- a/common/include/Pcsx2Config.h +++ b/common/include/Pcsx2Config.h @@ -148,17 +148,17 @@ struct PluginNames // This may end up being moved to Paths.h. It may also be converted to strings. struct FilePaths { - char Working[g_MaxPath]; + string Working; char Plugins[g_MaxPath]; char Bios[g_MaxPath]; // These are mainly placeholders for later. - char Isos[g_MaxPath]; - char Dumps[g_MaxPath]; + string Isos; + string Dumps; // This is intended for the program to populate, and the plugins to read. // Obviously can't be saved in the config file. :) - char Inis[g_MaxPath]; + string Inis; }; struct Hacks_t diff --git a/pcsx2/CDVD/IsoFileFormats.cpp b/pcsx2/CDVD/IsoFileFormats.cpp index 2eef41014e..25b9f3f248 100644 --- a/pcsx2/CDVD/IsoFileFormats.cpp +++ b/pcsx2/CDVD/IsoFileFormats.cpp @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - + #include "PrecompiledHeader.h" #include "IopCommon.h" #include "IsoFStools.h" @@ -26,134 +26,6 @@ #include #include -#ifdef _WIN32 -#include - -void *_openfile(const char *filename, int flags) -{ - HANDLE handle; - -// Console::WriteLn("_openfile %s, %d", params filename, flags & O_RDONLY); - if (flags & O_WRONLY) - { - int _flags = CREATE_NEW; - if (flags & O_CREAT) _flags = CREATE_ALWAYS; - handle = CreateFile(filename, GENERIC_WRITE, 0, NULL, _flags, 0, NULL); - } - else - { - handle = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); - } - - return handle == INVALID_HANDLE_VALUE ? NULL : handle; -} - -u64 _tellfile(void *handle) -{ - u64 ofs; - PLONG _ofs = (LONG*) & ofs; - _ofs[1] = 0; - _ofs[0] = SetFilePointer(handle, 0, &_ofs[1], FILE_CURRENT); - return ofs; -} - -int _seekfile(void *handle, u64 offset, int whence) -{ - u64 ofs = (u64)offset; - PLONG _ofs = (LONG*) & ofs; -// Console::WriteLn("_seekfile %p, %d_%d", params handle, _ofs[1], _ofs[0]); - if (whence == SEEK_SET) - { - SetFilePointer(handle, _ofs[0], &_ofs[1], FILE_BEGIN); - } - else - { - SetFilePointer(handle, _ofs[0], &_ofs[1], FILE_END); - } - return 0; -} - -int _readfile(void *handle, void *dst, int size) -{ - DWORD ret; - -// Console::WriteLn("_readfile %p %d", params handle, size); - ReadFile(handle, dst, size, &ret, NULL); -// Console::WriteLn("_readfile ret %d; %d", params ret, GetLastError()); - return ret; -} - -int _writefile(void *handle, void *src, int size) -{ - DWORD ret; - -// Console::WriteLn("_writefile %p, %d", params handle, size); -// _seekfile(handle, _tellfile(handle)); - WriteFile(handle, src, size, &ret, NULL); -// Console::WriteLn("_writefile ret %d", params ret); - return ret; -} - -void _closefile(void *handle) -{ - CloseHandle(handle); -} - -#else - -void *_openfile(const char *filename, int flags) -{ -// Console::WriteLn("_openfile %s %x", params filename, flags); - - if (flags & O_WRONLY) - return fopen64(filename, "wb"); - else - return fopen64(filename, "rb"); -} - -u64 _tellfile(void *handle) -{ - s64 cursize = ftell(handle); - - if (cursize == -1) - { - // try 64bit - cursize = ftello64(handle); - if (cursize < -1) - { - // zero top 32 bits - cursize &= 0xffffffff; - } - } - return cursize; -} - -int _seekfile(void *handle, u64 offset, int whence) -{ - int seekerr = fseeko64(handle, offset, whence); - - if (seekerr == -1) Console::Error("Failed to seek."); - - return seekerr; -} - -int _readfile(void *handle, void *dst, int size) -{ - return fread(dst, 1, size, handle); -} - -int _writefile(void *handle, void *src, int size) -{ - return fwrite(src, 1, size, handle); -} - -void _closefile(void *handle) -{ - fclose(handle); -} - -#endif - int detect(isoFile *iso) { u8 buf[2448]; diff --git a/pcsx2/CDVD/IsoFileFormats.h b/pcsx2/CDVD/IsoFileFormats.h index c7f33ca4ce..f7e6f95af2 100644 --- a/pcsx2/CDVD/IsoFileFormats.h +++ b/pcsx2/CDVD/IsoFileFormats.h @@ -19,26 +19,8 @@ #ifndef __LIBISO_H__ #define __LIBISO_H__ -#ifndef __USE_LARGEFILE64 -#define __USE_LARGEFILE64 -#endif - -#ifndef _LARGEFILE64_SOURCE -#define _LARGEFILE_SOURCE -#endif - -#ifndef _LARGEFILE64_SOURCE -#define _LARGEFILE64_SOURCE -#endif - -#define __USE_FILE_OFFSET64 -#define _FILE_OFFSET_BITS 64 - -#ifdef _MSC_VER -#pragma warning(disable:4018) -#endif - #include "CDVD.h" +#include "IsoFileTools.h" enum isoType { @@ -99,11 +81,4 @@ int isoReadBlock(isoFile *iso, u8 *dst, int lsn); int isoWriteBlock(isoFile *iso, u8 *src, int lsn); void isoClose(isoFile *iso); -void *_openfile(const char *filename, int flags); -u64 _tellfile(void *handle); -int _seekfile(void *handle, u64 offset, int whence); -int _readfile(void *handle, void *dst, int size); -int _writefile(void *handle, void *src, int size); -void _closefile(void *handle); - #endif /* __LIBISO_H__ */ diff --git a/pcsx2/CDVD/IsoFileTools.cpp b/pcsx2/CDVD/IsoFileTools.cpp new file mode 100644 index 0000000000..0fb7ea10e6 --- /dev/null +++ b/pcsx2/CDVD/IsoFileTools.cpp @@ -0,0 +1,148 @@ +/* Pcsx2 - Pc Ps2 Emulator + * Copyright (C) 2002-2009 Pcsx2 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "PrecompiledHeader.h" +#include "IsoFileTools.h" + + #ifdef _WIN32 +#include + +void *_openfile(const char *filename, int flags) +{ + HANDLE handle; + +// Console::WriteLn("_openfile %s, %d", params filename, flags & O_RDONLY); + if (flags & O_WRONLY) + { + int _flags = CREATE_NEW; + if (flags & O_CREAT) _flags = CREATE_ALWAYS; + handle = CreateFile(filename, GENERIC_WRITE, 0, NULL, _flags, 0, NULL); + } + else + { + handle = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); + } + + return handle == INVALID_HANDLE_VALUE ? NULL : handle; +} + +u64 _tellfile(void *handle) +{ + u64 ofs; + PLONG _ofs = (LONG*) & ofs; + _ofs[1] = 0; + _ofs[0] = SetFilePointer(handle, 0, &_ofs[1], FILE_CURRENT); + return ofs; +} + +int _seekfile(void *handle, u64 offset, int whence) +{ + u64 ofs = (u64)offset; + PLONG _ofs = (LONG*) & ofs; +// Console::WriteLn("_seekfile %p, %d_%d", params handle, _ofs[1], _ofs[0]); + if (whence == SEEK_SET) + { + SetFilePointer(handle, _ofs[0], &_ofs[1], FILE_BEGIN); + } + else + { + SetFilePointer(handle, _ofs[0], &_ofs[1], FILE_END); + } + return 0; +} + +int _readfile(void *handle, void *dst, int size) +{ + DWORD ret; + +// Console::WriteLn("_readfile %p %d", params handle, size); + ReadFile(handle, dst, size, &ret, NULL); +// Console::WriteLn("_readfile ret %d; %d", params ret, GetLastError()); + return ret; +} + +int _writefile(void *handle, void *src, int size) +{ + DWORD ret; + +// Console::WriteLn("_writefile %p, %d", params handle, size); +// _seekfile(handle, _tellfile(handle)); + WriteFile(handle, src, size, &ret, NULL); +// Console::WriteLn("_writefile ret %d", params ret); + return ret; +} + +void _closefile(void *handle) +{ + CloseHandle(handle); +} + +#else + +void *_openfile(const char *filename, int flags) +{ +// Console::WriteLn("_openfile %s %x", params filename, flags); + + if (flags & O_WRONLY) + return fopen64(filename, "wb"); + else + return fopen64(filename, "rb"); +} + +u64 _tellfile(void *handle) +{ + s64 cursize = ftell(handle); + + if (cursize == -1) + { + // try 64bit + cursize = ftello64(handle); + if (cursize < -1) + { + // zero top 32 bits + cursize &= 0xffffffff; + } + } + return cursize; +} + +int _seekfile(void *handle, u64 offset, int whence) +{ + int seekerr = fseeko64(handle, offset, whence); + + if (seekerr == -1) Console::Error("Failed to seek."); + + return seekerr; +} + +int _readfile(void *handle, void *dst, int size) +{ + return fread(dst, 1, size, handle); +} + +int _writefile(void *handle, void *src, int size) +{ + return fwrite(src, 1, size, handle); +} + +void _closefile(void *handle) +{ + fclose(handle); +} + +#endif diff --git a/pcsx2/CDVD/IsoFileTools.h b/pcsx2/CDVD/IsoFileTools.h new file mode 100644 index 0000000000..0692c4ccaa --- /dev/null +++ b/pcsx2/CDVD/IsoFileTools.h @@ -0,0 +1,50 @@ +/* Pcsx2 - Pc Ps2 Emulator + * Copyright (C) 2002-2009 Pcsx2 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + #ifndef __ISO_FILE_TOOLS_H__ +#define __ISO_FILE_TOOLS_H__ + +#ifndef _LARGEFILE_SOURCE +#define _LARGEFILE_SOURCE +#endif + +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE +#endif + +#define __USE_FILE_OFFSET64 +#define _FILE_OFFSET_BITS 64 + +#ifdef _MSC_VER +#pragma warning(disable:4018) +#endif + +#include "IopCommon.h" + +#include +#include +#include + +void *_openfile(const char *filename, int flags); +u64 _tellfile(void *handle); +int _seekfile(void *handle, u64 offset, int whence); +int _readfile(void *handle, void *dst, int size); +int _writefile(void *handle, void *src, int size); +void _closefile(void *handle); + +#endif \ No newline at end of file diff --git a/pcsx2/CDVD/Makefile.am b/pcsx2/CDVD/Makefile.am index 16f646a2e0..9497da4d1a 100644 --- a/pcsx2/CDVD/Makefile.am +++ b/pcsx2/CDVD/Makefile.am @@ -15,6 +15,6 @@ libps2_cdvd_a_SOURCES = \ CDVD.cpp IsoFStools.cpp IsoFSdrv.cpp CdRom.cpp \ CDVD.h CDVD_internal.h IsoFStools.h IsoFSdrv.h IsoFScdvd.h CdRom.h \ CDVDisoReader.cpp CDVDisoReader.h CDVDaccess.cpp CDVDaccess.h \ -IsoFileFormats.cpp IsoFileFormats.h +IsoFileFormats.cpp IsoFileFormats.h IsoFileTools.cpp IsoFileTools.h #SUBDIRS = diff --git a/pcsx2/Linux/LnxMain.cpp b/pcsx2/Linux/LnxMain.cpp index 1c1a9d9605..219864c43f 100644 --- a/pcsx2/Linux/LnxMain.cpp +++ b/pcsx2/Linux/LnxMain.cpp @@ -37,8 +37,8 @@ int main(int argc, char *argv[]) efile = 0; /* store main dir */ - strcpy(Config.Paths.Working, Path::GetWorkingDirectory().c_str()); - Console::Notice("Config.Paths.Working is %s", params Config.Paths.Working); + Config.Paths.Working = Path::GetWorkingDirectory(); + Console::Notice("Config.Paths.Working is %s", params Config.Paths.Working.c_str()); #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, "Langs"); @@ -48,15 +48,15 @@ int main(int argc, char *argv[]) // Note: Config.Paths.Inis won't do anything till we set up windows and the plugins to use it. #ifndef LOCAL_PLUGIN_INIS mkdir(DEFAULT_INIS_DIR, 0755); - sprintf(Config.Paths.Inis, "%s/%s/", Config.Paths.Working, DEFAULT_INIS_DIR); - sprintf(cfgfile, "%s/pcsx2.cfg", Config.Paths.Inis); + Config.Paths.Inis = Config.Paths.Working + "/" + string(DEFAULT_INIS_DIR) + "/"; + sprintf(cfgfile, "%s/pcsx2.cfg", Config.Paths.Inis.c_str()); #else - Path::CreateDirectory(string("~/.pcsx2")); - Path::ChangeDirectory(string("~/.pcsx2")); - Path::CreateDirectory(string(DEFAULT_INIS_DIR)); - sprintf(Config.Paths.Inis, "~/.pcsx2/%s/", DEFAULT_INIS_DIR); - sprintf(cfgfile, "%s/pcsx2.cfg", Config.Paths.Inis); - Path::ChangeDirectory(string(Config.Paths.Working)); + Path::CreateDirectory("~/.pcsx2"); + Path::ChangeDirectory("~/.pcsx2"); + Path::CreateDirectory(DEFAULT_INIS_DIR); + Config.Paths.Inis = "~/.pcsx2/" + DEFAULT_INIS_DIR + "/"; + sprintf(cfgfile, "%s/pcsx2.cfg", Config.Paths.Inis.c_str()); + Path::ChangeDirectory(Config.Paths.Working); #endif #ifdef PCSX2_DEVBUILD @@ -81,10 +81,10 @@ int main(int argc, char *argv[]) { memset(&Config, 0, sizeof(Config)); - sprintf(Config.Paths.Bios, "%s/%s/", Config.Paths.Working, DEFAULT_BIOS_DIR); - sprintf(Config.Paths.Plugins, "%s/%s/", Config.Paths.Working, DEFAULT_PLUGINS_DIR); - sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD1); - sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD2); + sprintf(Config.Paths.Bios, "%s/%s/", Config.Paths.Working.c_str(), DEFAULT_BIOS_DIR); + sprintf(Config.Paths.Plugins, "%s/%s/", Config.Paths.Working.c_str(), DEFAULT_PLUGINS_DIR); + sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working.c_str(), MEMCARDS_DIR, DEFAULT_MEMCARD1); + sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working.c_str(), MEMCARDS_DIR, DEFAULT_MEMCARD2); Config.Mcd[0].Enabled = 1; Config.Mcd[1].Enabled = 1; Config.McdEnableEject = 1; diff --git a/pcsx2/Linux/McdDlgs.cpp b/pcsx2/Linux/McdDlgs.cpp index 0968c0d013..370ca99200 100644 --- a/pcsx2/Linux/McdDlgs.cpp +++ b/pcsx2/Linux/McdDlgs.cpp @@ -56,7 +56,7 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) { char path[g_MaxPath]; - sprintf(path, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, entry->d_name); + sprintf(path, "%s/%s/%s", Config.Paths.Working.c_str(), MEMCARDS_DIR, entry->d_name); for (j = 0; j < 2; j++) { @@ -83,17 +83,17 @@ void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) void OnMemcards_Ok(GtkButton *button, gpointer user_data) { if (gtk_combo_box_get_active(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo"))) != -1) - sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, + sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working.c_str(), MEMCARDS_DIR, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard1combo")))); else - sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD1); + sprintf(Config.Mcd[0].Filename, "%s/%s/%s", Config.Paths.Working.c_str(), MEMCARDS_DIR, DEFAULT_MEMCARD1); if (gtk_combo_box_get_active(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo"))) != -1) - sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, + sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working.c_str(), MEMCARDS_DIR, gtk_combo_box_get_active_text(GTK_COMBO_BOX(lookup_widget(MemDlg, "memcard2combo")))); else - sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working, MEMCARDS_DIR, DEFAULT_MEMCARD2); + sprintf(Config.Mcd[1].Filename, "%s/%s/%s", Config.Paths.Working.c_str(), MEMCARDS_DIR, DEFAULT_MEMCARD2); Config.Mcd[0].Enabled = is_checked(MemDlg, "check_enable_mcd1"); Config.Mcd[1].Enabled = is_checked(MemDlg, "check_enable_mcd2"); diff --git a/pcsx2/windows/McdConfigDlg.cpp b/pcsx2/windows/McdConfigDlg.cpp index 826bd78c38..b7adce2dee 100644 --- a/pcsx2/windows/McdConfigDlg.cpp +++ b/pcsx2/windows/McdConfigDlg.cpp @@ -59,7 +59,7 @@ void DlgItem_GetText( HWND hwnd, int dlgId, string& dest ) static const char* _stripPathInfo( const char* src ) { const char* retval = src; - const char* workingfold = Config.Paths.Working; + const char* workingfold = Config.Paths.Working.c_str(); while( (*retval != 0) && (*workingfold != 0) && (tolower(*retval) == tolower(*workingfold)) ) { diff --git a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj index c45cbc9c00..6594926e75 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj @@ -2487,6 +2487,14 @@ RelativePath="..\..\CDVD\IsoFileFormats.h" > + + + + diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index 6dfe9e492d..a1ab0e8b93 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -269,7 +269,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine #endif //strcpy(g_WorkingFolder, Path::GetWorkingDirectory().c_str()); - strcpy(Config.Paths.Working, Path::GetWorkingDirectory().c_str()); + Config.Paths.Working = Path::GetWorkingDirectory(); int argc; TCHAR *const *const argv = _CommandLineToArgv( lpCmdLine, &argc ); From 5abbb0c2425eacfcf0b25783bec91e90174f2b86 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 24 Jul 2009 05:33:02 +0000 Subject: [PATCH 05/22] Unbreak FF X-2 with the new iso code. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1563 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD/CDVD.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 9825cae210..b6708bdc19 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -590,7 +590,7 @@ int cdvdReadSector() { { // dual layer ptp disc layerNum = 1; - lsn = lsn-layer1Start + 0x30000; + lsn = lsn - layer1Start + 0x30000; } else if((dualType == 2) && (lsn >= layer1Start)) { @@ -599,7 +599,8 @@ int cdvdReadSector() { lsn = ~(layer1Start+0x30000 - 1); } else - { // Assumed the other dualType is 0. + { + // Assumed the other dualType is 0. // single layer disc // or on first layer of dual layer disc layerNum = 0; @@ -624,8 +625,25 @@ int cdvdReadSector() { mdest[11] = 0; // normal 2048 bytes of sector data - memcpy_fast( &mdest[12], cdr.pTransfer, 2048); - + if (cdr.pTransfer == NULL) + { + // Unlike CDVDiso, the internal IsoReadTrack function will pass an error if lsn is more + // then the number of blocks in the iso. If this happens, cdr.pTransfer will be NULL. + // + // Passing null to memcpy is a bad thing, and will result in, for example, the start of + // Final Fantasy X-2 crashing. So we won't. + + DevCon::WriteLn("Bad Transfer!"); + for (int i = 12; i > 2060; i++) + { + mdest[i] = 0; + } + } + else + { + memcpy_fast( &mdest[12], cdr.pTransfer, 2048); + } + // 4 bytes of edc (not calculated at present) mdest[2060] = 0; mdest[2061] = 0; @@ -725,7 +743,10 @@ __forceinline void cdvdReadInterrupt() cdr.pTransfer = cdr.Transfer; } else + { + DevCon::WriteLn("Error reading track."); cdr.pTransfer = NULL; + } if (cdr.RErr == -1) { From 319782cf39348522b2614c83c5600e6e9f2773e2 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Fri, 24 Jul 2009 09:24:09 +0000 Subject: [PATCH 06/22] GSdx: just updating vs2010 project files git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1564 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDevice.cpp | 4 ++-- plugins/GSdx/GSDevice10.cpp | 2 +- plugins/GSdx/GSDevice11.cpp | 2 +- plugins/GSdx/GSDevice7.cpp | 4 ++-- plugins/GSdx/GSTextureCache.cpp | 2 +- plugins/GSdx/GSTextureCacheSW.cpp | 2 +- plugins/GSdx/GSdx_vs2008.vcproj | 6 ------ plugins/GSdx/GSdx_vs2010.vcxproj | 20 ++++++++++---------- plugins/GSdx/vsprops/common.props | 5 +++-- plugins/GSdx/vsprops/common.vsprops | 1 + plugins/GSdx/vsprops/sse2.props | 8 ++++++++ plugins/GSdx/vsprops/sse4.props | 8 ++++++++ plugins/GSdx/vsprops/ssse3.props | 8 ++++++++ 13 files changed, 46 insertions(+), 26 deletions(-) diff --git a/plugins/GSdx/GSDevice.cpp b/plugins/GSdx/GSDevice.cpp index 648b44216b..d023f45649 100644 --- a/plugins/GSdx/GSDevice.cpp +++ b/plugins/GSdx/GSDevice.cpp @@ -79,8 +79,8 @@ void GSDevice::Present(const GSVector4i& r, int shader, bool limit) { GSVector4i cr = m_wnd->GetClientRect(); - int w = std::max(cr.width(), 1); - int h = std::max(cr.height(), 1); + int w = std::max(cr.width(), 1); + int h = std::max(cr.height(), 1); if(!m_backbuffer || m_backbuffer->m_size.x != w || m_backbuffer->m_size.y != h) { diff --git a/plugins/GSdx/GSDevice10.cpp b/plugins/GSdx/GSDevice10.cpp index a8d832631b..8f5d709387 100644 --- a/plugins/GSdx/GSDevice10.cpp +++ b/plugins/GSdx/GSDevice10.cpp @@ -420,7 +420,7 @@ void GSDevice10::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) { D3D10_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; - m_dev->CopySubresourceRegion(*(GSTexture10*)dt, 0, 0, 0, 0, *(GSTexture10*)st, 0, &box); + m_dev->CopySubresourceRegion(*(GSTexture10*)dt, 0, r.left, r.top, 0, *(GSTexture10*)st, 0, &box); } void GSDevice10::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear) diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index aa6547dd45..4ab7429375 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -417,7 +417,7 @@ void GSDevice11::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) { D3D11_BOX box = {r.left, r.top, 0, r.right, r.bottom, 1}; - m_ctx->CopySubresourceRegion(*(GSTexture11*)dt, 0, 0, 0, 0, *(GSTexture11*)st, 0, &box); + m_ctx->CopySubresourceRegion(*(GSTexture11*)dt, 0, r.left, r.top, 0, *(GSTexture11*)st, 0, &box); } void GSDevice11::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear) diff --git a/plugins/GSdx/GSDevice7.cpp b/plugins/GSdx/GSDevice7.cpp index 1f769ec92d..aa3c42abdd 100644 --- a/plugins/GSdx/GSDevice7.cpp +++ b/plugins/GSdx/GSDevice7.cpp @@ -142,8 +142,8 @@ void GSDevice7::Present(const GSVector4i& r, int shader, bool limit) GSVector4i cr = m_wnd->GetClientRect(); - int w = std::max(cr.width(), 1); - int h = std::max(cr.height(), 1); + int w = std::max(cr.width(), 1); + int h = std::max(cr.height(), 1); if(!m_backbuffer || m_backbuffer->m_size.x != w || m_backbuffer->m_size.y != h) { diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index a2d88f39a7..9c70530e9c 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -951,7 +951,7 @@ void GSTextureCache::Target::Update() if(GSTexture* t = m_renderer->m_dev->CreateTexture(w, h)) { - const GSOffset* o = m_renderer->m_mem.GetOffset(m_TEX0.TBP0, m_TEX0.TBW, m_TEX0.PSM); // TODO: m_renderer->m_context->bo.tex; + const GSOffset* o = m_renderer->m_mem.GetOffset(m_TEX0.TBP0, m_TEX0.TBW, m_TEX0.PSM); GIFRegTEXA TEXA; diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index 7c548f6672..df8bfb7762 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -260,7 +260,7 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX return false; } - m_tw = std::max(psm.pal > 0 ? 5 : 3, TEX0.TW); // makes one row 32 bytes at least, matches the smallest block size that is allocated above for m_buff + m_tw = std::max(TEX0.TW, psm.pal > 0 ? 5 : 3); // makes one row 32 bytes at least, matches the smallest block size that is allocated above for m_buff } GSLocalMemory& mem = m_state->m_mem; diff --git a/plugins/GSdx/GSdx_vs2008.vcproj b/plugins/GSdx/GSdx_vs2008.vcproj index b6ae9a9c48..1273ff6d0a 100644 --- a/plugins/GSdx/GSdx_vs2008.vcproj +++ b/plugins/GSdx/GSdx_vs2008.vcproj @@ -56,7 +56,6 @@ /> @@ -183,7 +182,6 @@ /> @@ -310,7 +308,6 @@ /> @@ -436,7 +433,6 @@ /> @@ -561,7 +557,6 @@ /> @@ -688,7 +683,6 @@ /> diff --git a/plugins/GSdx/GSdx_vs2010.vcxproj b/plugins/GSdx/GSdx_vs2010.vcxproj index a926859248..d6fe2960c1 100644 --- a/plugins/GSdx/GSdx_vs2010.vcxproj +++ b/plugins/GSdx/GSdx_vs2010.vcxproj @@ -251,9 +251,9 @@ + - @@ -261,9 +261,9 @@ + - @@ -271,47 +271,47 @@ + - + - + - + - + - + - + - + - diff --git a/plugins/GSdx/vsprops/common.props b/plugins/GSdx/vsprops/common.props index 0edc67dee6..f2b3e7153f 100644 --- a/plugins/GSdx/vsprops/common.props +++ b/plugins/GSdx/vsprops/common.props @@ -3,6 +3,7 @@ <_PropertySheetDisplayName>common $(SolutionDir)\bin\$(PcsxSubsection)\ $(PlatformName)\$(Configuration)\ + $(ProjectName)-$(SSEtype) @@ -15,9 +16,9 @@ 4995;4324;%(DisableSpecificWarnings) - JITProfiling.lib;d3d11_beta.lib;d3dx11.lib;d3d10.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;ddraw.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;cg.lib;cgGL.lib;glut32.lib;glew32.lib;%(AdditionalDependencies) + JITProfiling.lib;d3d11_beta.lib;d3dx11.lib;d3d10.lib;d3d10_1.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;ddraw.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;cg.lib;cgGL.lib;glut32.lib;glew32.lib;%(AdditionalDependencies) ./vtune;%(AdditionalLibraryDirectories) - d3d9.dll;d3dx9_41.dll;d3d10.dll;d3dx10_41.dll;d3d11.dll;d3d11_beta.dll;d3dx11_41.dll;%(DelayLoadDLLs) + d3d9.dll;d3dx9_41.dll;d3d10.dll;d3d10_1.dll;d3dx10_41.dll;d3d11.dll;d3d11_beta.dll;d3dx11_41.dll;%(DelayLoadDLLs) true Windows false diff --git a/plugins/GSdx/vsprops/common.vsprops b/plugins/GSdx/vsprops/common.vsprops index 100fa0e3aa..e88afb9883 100644 --- a/plugins/GSdx/vsprops/common.vsprops +++ b/plugins/GSdx/vsprops/common.vsprops @@ -19,6 +19,7 @@ + + SSE2 + <_PropertySheetDisplayName>sse2 @@ -8,4 +11,9 @@ _M_SSE=0x200;%(PreprocessorDefinitions) + + + $(SSEtype) + + \ No newline at end of file diff --git a/plugins/GSdx/vsprops/sse4.props b/plugins/GSdx/vsprops/sse4.props index 273b626cee..6f6036ae28 100644 --- a/plugins/GSdx/vsprops/sse4.props +++ b/plugins/GSdx/vsprops/sse4.props @@ -1,4 +1,7 @@  + + SSE4 + <_PropertySheetDisplayName>sse4 @@ -8,4 +11,9 @@ StreamingSIMDExtensions2 + + + $(SSEtype) + + \ No newline at end of file diff --git a/plugins/GSdx/vsprops/ssse3.props b/plugins/GSdx/vsprops/ssse3.props index 0d1131f6a8..622cdf6ddf 100644 --- a/plugins/GSdx/vsprops/ssse3.props +++ b/plugins/GSdx/vsprops/ssse3.props @@ -1,4 +1,7 @@  + + SSSE3 + <_PropertySheetDisplayName>sse3 @@ -8,4 +11,9 @@ _M_SSE=0x301;%(PreprocessorDefinitions) + + + $(SSEtype) + + \ No newline at end of file From 4eaa5265dfdbfa0b295abe4676d674d01fd39b3a Mon Sep 17 00:00:00 2001 From: gabest11 Date: Fri, 24 Jul 2009 12:54:54 +0000 Subject: [PATCH 07/22] Added vs2010 project files for xpad and CDVDolio, too. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1565 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/CDVDolio/cdvd_vs2010.vcxproj | 582 ++++++++++++++++++ plugins/CDVDolio/cdvd_vs2010.vcxproj.filters | 64 ++ plugins/CDVDolio/cdvd_vs2010.vcxproj.user | 6 + plugins/CDVDolio/vsprops/ProjectRootDir.props | 25 + plugins/CDVDolio/vsprops/common.props | 27 + plugins/CDVDolio/vsprops/debug.props | 15 + plugins/CDVDolio/vsprops/release.props | 24 + plugins/CDVDolio/vsprops/release.vsprops | 2 +- plugins/CDVDolio/vsprops/ssse3.props | 11 + plugins/xpad/vsprops/ProjectRootDir.props | 25 + plugins/xpad/vsprops/common.props | 27 + plugins/xpad/vsprops/debug.props | 15 + plugins/xpad/vsprops/release.props | 24 + plugins/xpad/vsprops/release.vsprops | 2 +- plugins/xpad/vsprops/sse2.props | 11 + plugins/xpad/vsprops/sse4.props | 11 + plugins/xpad/vsprops/ssse3.props | 11 + plugins/xpad/xpad_vs2010.vcxproj | 577 +++++++++++++++++ plugins/xpad/xpad_vs2010.vcxproj.filters | 52 ++ plugins/xpad/xpad_vs2010.vcxproj.user | 6 + 20 files changed, 1515 insertions(+), 2 deletions(-) create mode 100644 plugins/CDVDolio/cdvd_vs2010.vcxproj create mode 100644 plugins/CDVDolio/cdvd_vs2010.vcxproj.filters create mode 100644 plugins/CDVDolio/cdvd_vs2010.vcxproj.user create mode 100644 plugins/CDVDolio/vsprops/ProjectRootDir.props create mode 100644 plugins/CDVDolio/vsprops/common.props create mode 100644 plugins/CDVDolio/vsprops/debug.props create mode 100644 plugins/CDVDolio/vsprops/release.props create mode 100644 plugins/CDVDolio/vsprops/ssse3.props create mode 100644 plugins/xpad/vsprops/ProjectRootDir.props create mode 100644 plugins/xpad/vsprops/common.props create mode 100644 plugins/xpad/vsprops/debug.props create mode 100644 plugins/xpad/vsprops/release.props create mode 100644 plugins/xpad/vsprops/sse2.props create mode 100644 plugins/xpad/vsprops/sse4.props create mode 100644 plugins/xpad/vsprops/ssse3.props create mode 100644 plugins/xpad/xpad_vs2010.vcxproj create mode 100644 plugins/xpad/xpad_vs2010.vcxproj.filters create mode 100644 plugins/xpad/xpad_vs2010.vcxproj.user diff --git a/plugins/CDVDolio/cdvd_vs2010.vcxproj b/plugins/CDVDolio/cdvd_vs2010.vcxproj new file mode 100644 index 0000000000..3a541044c0 --- /dev/null +++ b/plugins/CDVDolio/cdvd_vs2010.vcxproj @@ -0,0 +1,582 @@ + + + + Debug SSE2 + Win32 + + + Debug SSE2 + Win32 + + + Debug SSE2 + x64 + + + Debug SSE2 + x64 + + + Debug SSE4 + Win32 + + + Debug SSE4 + Win32 + + + Debug SSE4 + x64 + + + Debug SSE4 + x64 + + + Debug SSSE3 + Win32 + + + Debug SSSE3 + Win32 + + + Debug SSSE3 + x64 + + + Debug SSSE3 + x64 + + + Debug + Win32 + + + Debug + Win32 + + + Debug + x64 + + + Debug + x64 + + + Release SSE2 + Win32 + + + Release SSE2 + Win32 + + + Release SSE2 + x64 + + + Release SSE2 + x64 + + + Release SSE4 + Win32 + + + Release SSE4 + Win32 + + + Release SSE4 + x64 + + + Release SSE4 + x64 + + + Release SSSE3 + Win32 + + + Release SSSE3 + Win32 + + + Release SSSE3 + x64 + + + Release SSSE3 + x64 + + + Release + Win32 + + + Release + Win32 + + + Release + x64 + + + Release + x64 + + + + CDVDolio + {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB} + cdvd + Win32Proj + + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + + + DynamicLibrary + Static + MultiByte + true + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + Static + MultiByte + false + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + true + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + true + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + Static + MultiByte + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + Static + MultiByte + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.20506.1 + $(Configuration)\ + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + + + MachineX64 + + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + + + MachineX64 + + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + MachineX64 + + + + + Use + + + .\cdvd.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + MachineX64 + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/CDVDolio/cdvd_vs2010.vcxproj.filters b/plugins/CDVDolio/cdvd_vs2010.vcxproj.filters new file mode 100644 index 0000000000..a34d6414dc --- /dev/null +++ b/plugins/CDVDolio/cdvd_vs2010.vcxproj.filters @@ -0,0 +1,64 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + + + + Source Files + + + Resource Files + + + + + Header Files + + + Header Files + + + Resource Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/plugins/CDVDolio/cdvd_vs2010.vcxproj.user b/plugins/CDVDolio/cdvd_vs2010.vcxproj.user new file mode 100644 index 0000000000..91498d016d --- /dev/null +++ b/plugins/CDVDolio/cdvd_vs2010.vcxproj.user @@ -0,0 +1,6 @@ + + + + cdvd.rc + + \ No newline at end of file diff --git a/plugins/CDVDolio/vsprops/ProjectRootDir.props b/plugins/CDVDolio/vsprops/ProjectRootDir.props new file mode 100644 index 0000000000..fd31a6334d --- /dev/null +++ b/plugins/CDVDolio/vsprops/ProjectRootDir.props @@ -0,0 +1,25 @@ + + + $(ProjectDir). + $(ProjectRootDir)\..\.. + $(SvnRootDir)\common + plugins + + + <_PropertySheetDisplayName>ProjectRootDir + + + + $(ProjectRootDir) + + + $(SvnRootDir) + + + $(SvnCommonDir) + + + $(PcsxSubsection) + + + \ No newline at end of file diff --git a/plugins/CDVDolio/vsprops/common.props b/plugins/CDVDolio/vsprops/common.props new file mode 100644 index 0000000000..153b18395e --- /dev/null +++ b/plugins/CDVDolio/vsprops/common.props @@ -0,0 +1,27 @@ + + + <_PropertySheetDisplayName>common + ..\..\bin\plugins\ + $(PlatformName)\$(Configuration)\ + $(ProjectName) + .dll + + + + true + WIN32;_WINDOWS;_WIN32_WINNT=0x500;%(PreprocessorDefinitions) + Fast + false + Level4 + ProgramDatabase + 4995;4324;%(DisableSpecificWarnings) + + + d3d10.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;ddraw.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;%(AdditionalDependencies) + d3d9.dll;d3dx9_40.dll;d3d10.dll;d3dx10_40.dll;%(DelayLoadDLLs) + true + Windows + false + + + \ No newline at end of file diff --git a/plugins/CDVDolio/vsprops/debug.props b/plugins/CDVDolio/vsprops/debug.props new file mode 100644 index 0000000000..b42c70d73c --- /dev/null +++ b/plugins/CDVDolio/vsprops/debug.props @@ -0,0 +1,15 @@ + + + <_PropertySheetDisplayName>debug + true + + + + Disabled + _DEBUG;%(PreprocessorDefinitions) + true + StackFrameRuntimeCheck + MultiThreadedDebugDLL + + + \ No newline at end of file diff --git a/plugins/CDVDolio/vsprops/release.props b/plugins/CDVDolio/vsprops/release.props new file mode 100644 index 0000000000..8c3093865c --- /dev/null +++ b/plugins/CDVDolio/vsprops/release.props @@ -0,0 +1,24 @@ + + + <_PropertySheetDisplayName>release + false + + + + MaxSpeed + AnySuitable + true + Speed + true + true + NDEBUG;_SECURE_SCL=0;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + + + true + true + + + \ No newline at end of file diff --git a/plugins/CDVDolio/vsprops/release.vsprops b/plugins/CDVDolio/vsprops/release.vsprops index 4d61fbc89f..c9fd3740b2 100644 --- a/plugins/CDVDolio/vsprops/release.vsprops +++ b/plugins/CDVDolio/vsprops/release.vsprops @@ -12,7 +12,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="true" WholeProgramOptimization="true" - PreprocessorDefinitions="NDEBUG" + PreprocessorDefinitions="NDEBUG;_SECURE_SCL=0" StringPooling="true" RuntimeLibrary="2" BufferSecurityCheck="false" diff --git a/plugins/CDVDolio/vsprops/ssse3.props b/plugins/CDVDolio/vsprops/ssse3.props new file mode 100644 index 0000000000..0d1131f6a8 --- /dev/null +++ b/plugins/CDVDolio/vsprops/ssse3.props @@ -0,0 +1,11 @@ + + + <_PropertySheetDisplayName>sse3 + + + + StreamingSIMDExtensions2 + _M_SSE=0x301;%(PreprocessorDefinitions) + + + \ No newline at end of file diff --git a/plugins/xpad/vsprops/ProjectRootDir.props b/plugins/xpad/vsprops/ProjectRootDir.props new file mode 100644 index 0000000000..fd31a6334d --- /dev/null +++ b/plugins/xpad/vsprops/ProjectRootDir.props @@ -0,0 +1,25 @@ + + + $(ProjectDir). + $(ProjectRootDir)\..\.. + $(SvnRootDir)\common + plugins + + + <_PropertySheetDisplayName>ProjectRootDir + + + + $(ProjectRootDir) + + + $(SvnRootDir) + + + $(SvnCommonDir) + + + $(PcsxSubsection) + + + \ No newline at end of file diff --git a/plugins/xpad/vsprops/common.props b/plugins/xpad/vsprops/common.props new file mode 100644 index 0000000000..153b18395e --- /dev/null +++ b/plugins/xpad/vsprops/common.props @@ -0,0 +1,27 @@ + + + <_PropertySheetDisplayName>common + ..\..\bin\plugins\ + $(PlatformName)\$(Configuration)\ + $(ProjectName) + .dll + + + + true + WIN32;_WINDOWS;_WIN32_WINNT=0x500;%(PreprocessorDefinitions) + Fast + false + Level4 + ProgramDatabase + 4995;4324;%(DisableSpecificWarnings) + + + d3d10.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;ddraw.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;%(AdditionalDependencies) + d3d9.dll;d3dx9_40.dll;d3d10.dll;d3dx10_40.dll;%(DelayLoadDLLs) + true + Windows + false + + + \ No newline at end of file diff --git a/plugins/xpad/vsprops/debug.props b/plugins/xpad/vsprops/debug.props new file mode 100644 index 0000000000..b42c70d73c --- /dev/null +++ b/plugins/xpad/vsprops/debug.props @@ -0,0 +1,15 @@ + + + <_PropertySheetDisplayName>debug + true + + + + Disabled + _DEBUG;%(PreprocessorDefinitions) + true + StackFrameRuntimeCheck + MultiThreadedDebugDLL + + + \ No newline at end of file diff --git a/plugins/xpad/vsprops/release.props b/plugins/xpad/vsprops/release.props new file mode 100644 index 0000000000..8c3093865c --- /dev/null +++ b/plugins/xpad/vsprops/release.props @@ -0,0 +1,24 @@ + + + <_PropertySheetDisplayName>release + false + + + + MaxSpeed + AnySuitable + true + Speed + true + true + NDEBUG;_SECURE_SCL=0;%(PreprocessorDefinitions) + true + MultiThreadedDLL + false + + + true + true + + + \ No newline at end of file diff --git a/plugins/xpad/vsprops/release.vsprops b/plugins/xpad/vsprops/release.vsprops index 4d61fbc89f..c9fd3740b2 100644 --- a/plugins/xpad/vsprops/release.vsprops +++ b/plugins/xpad/vsprops/release.vsprops @@ -12,7 +12,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="true" WholeProgramOptimization="true" - PreprocessorDefinitions="NDEBUG" + PreprocessorDefinitions="NDEBUG;_SECURE_SCL=0" StringPooling="true" RuntimeLibrary="2" BufferSecurityCheck="false" diff --git a/plugins/xpad/vsprops/sse2.props b/plugins/xpad/vsprops/sse2.props new file mode 100644 index 0000000000..593107b5a9 --- /dev/null +++ b/plugins/xpad/vsprops/sse2.props @@ -0,0 +1,11 @@ + + + <_PropertySheetDisplayName>sse2 + + + + StreamingSIMDExtensions2 + _M_SSE=0x200;%(PreprocessorDefinitions) + + + \ No newline at end of file diff --git a/plugins/xpad/vsprops/sse4.props b/plugins/xpad/vsprops/sse4.props new file mode 100644 index 0000000000..273b626cee --- /dev/null +++ b/plugins/xpad/vsprops/sse4.props @@ -0,0 +1,11 @@ + + + <_PropertySheetDisplayName>sse4 + + + + _M_SSE=0x401;%(PreprocessorDefinitions) + StreamingSIMDExtensions2 + + + \ No newline at end of file diff --git a/plugins/xpad/vsprops/ssse3.props b/plugins/xpad/vsprops/ssse3.props new file mode 100644 index 0000000000..0d1131f6a8 --- /dev/null +++ b/plugins/xpad/vsprops/ssse3.props @@ -0,0 +1,11 @@ + + + <_PropertySheetDisplayName>sse3 + + + + StreamingSIMDExtensions2 + _M_SSE=0x301;%(PreprocessorDefinitions) + + + \ No newline at end of file diff --git a/plugins/xpad/xpad_vs2010.vcxproj b/plugins/xpad/xpad_vs2010.vcxproj new file mode 100644 index 0000000000..de11c7554b --- /dev/null +++ b/plugins/xpad/xpad_vs2010.vcxproj @@ -0,0 +1,577 @@ + + + + Debug SSE2 + Win32 + + + Debug SSE2 + Win32 + + + Debug SSE2 + x64 + + + Debug SSE2 + x64 + + + Debug SSE4 + Win32 + + + Debug SSE4 + Win32 + + + Debug SSE4 + x64 + + + Debug SSE4 + x64 + + + Debug SSSE3 + Win32 + + + Debug SSSE3 + Win32 + + + Debug SSSE3 + x64 + + + Debug SSSE3 + x64 + + + Debug + Win32 + + + Debug + Win32 + + + Debug + x64 + + + Debug + x64 + + + Release SSE2 + Win32 + + + Release SSE2 + Win32 + + + Release SSE2 + x64 + + + Release SSE2 + x64 + + + Release SSE4 + Win32 + + + Release SSE4 + Win32 + + + Release SSE4 + x64 + + + Release SSE4 + x64 + + + Release SSSE3 + Win32 + + + Release SSSE3 + Win32 + + + Release SSSE3 + x64 + + + Release SSSE3 + x64 + + + Release + Win32 + + + Release + Win32 + + + Release + x64 + + + Release + x64 + + + + xpad + {6F3C4136-5801-4EBC-AC6E-37DF6FAB150A} + xpad + Win32Proj + + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + + + DynamicLibrary + Static + MultiByte + true + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + Static + MultiByte + false + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + true + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + true + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + Static + MultiByte + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + Static + MultiByte + + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + Static + MultiByte + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.20506.1 + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + + + MachineX64 + + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + + + MachineX64 + + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + Use + + + + + MachineX64 + + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + MachineX64 + + + + + Use + + + .\xpad.def + %(DelayLoadDLLs) + + + MachineX86 + + + + + X64 + + + Use + + + + + MachineX64 + + + + + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/xpad/xpad_vs2010.vcxproj.filters b/plugins/xpad/xpad_vs2010.vcxproj.filters new file mode 100644 index 0000000000..57613c73b4 --- /dev/null +++ b/plugins/xpad/xpad_vs2010.vcxproj.filters @@ -0,0 +1,52 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + Source Files + + + + + Resource Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + + Source Files + + + \ No newline at end of file diff --git a/plugins/xpad/xpad_vs2010.vcxproj.user b/plugins/xpad/xpad_vs2010.vcxproj.user new file mode 100644 index 0000000000..f6df7c591b --- /dev/null +++ b/plugins/xpad/xpad_vs2010.vcxproj.user @@ -0,0 +1,6 @@ + + + + xpad.rc + + \ No newline at end of file From 93d6d5a2acd32052ee4ad39dadaf80e3de5c6333 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 25 Jul 2009 01:40:34 +0000 Subject: [PATCH 08/22] Fixed some bleedthrough on the colors on the console, took care of a typo I made earier, and did assorted cleanup. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1566 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD/CDVD.cpp | 19 ++++------ pcsx2/CDVD/CDVD.h | 37 +++++++++++++++++++ pcsx2/CDVD/CDVDaccess.cpp | 4 +-- pcsx2/CDVD/CDVDisoReader.cpp | 68 +++-------------------------------- pcsx2/CDVD/CDVDisoReader.h | 13 ------- pcsx2/CDVD/CdRom.cpp | 29 ++++----------- pcsx2/CDVD/IsoFSdrv.cpp | 19 +++++----- pcsx2/CDVD/IsoFStools.cpp | 59 +++++++++--------------------- pcsx2/CDVD/IsoFStools.h | 4 +++ pcsx2/CDVD/IsoFileFormats.cpp | 9 ++--- pcsx2/CDVD/IsoFileTools.cpp | 18 ++++------ pcsx2/Console.cpp | 2 ++ 12 files changed, 99 insertions(+), 182 deletions(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index b6708bdc19..3273973c4b 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -294,11 +294,8 @@ s32 cdvdReadConfig(u8* config) } s32 cdvdWriteConfig(const u8* config) { - // make sure its in write mode - if(cdvd.CReadWrite != 1) - return 1; - // check if block index is in bounds - else if(cdvd.CBlockIndex >= cdvd.CNumBlocks) + // make sure its in write mode && the block index is in bounds + if ((cdvd.CReadWrite != 1) || (cdvd.CBlockIndex >= cdvd.CNumBlocks)) return 1; else if( ((cdvd.COffset == 0) && (cdvd.CBlockIndex >= 4))|| @@ -543,14 +540,12 @@ void cdvdNewDiskCB() void mechaDecryptBytes( u32 madr, int size ) { - int i; - int shiftAmount = (cdvd.decSet>>4) & 7; int doXor = (cdvd.decSet) & 1; int doShift = (cdvd.decSet) & 2; u8* curval = iopPhysMem( madr ); - for( i=0; i> shiftAmount) | (*curval << (8-shiftAmount) ); @@ -600,9 +595,8 @@ int cdvdReadSector() { } else { - // Assumed the other dualType is 0. - // single layer disc - // or on first layer of dual layer disc + // Assuming the other dualType is 0, + // single layer disc, or on first layer of dual layer disc. layerNum = 0; lsn += 0x30000; } @@ -634,7 +628,7 @@ int cdvdReadSector() { // Final Fantasy X-2 crashing. So we won't. DevCon::WriteLn("Bad Transfer!"); - for (int i = 12; i > 2060; i++) + for (int i = 12; i <= 2060; i++) { mdest[i] = 0; } @@ -789,7 +783,6 @@ __forceinline void cdvdReadInterrupt() cdvd.Ready = CDVD_READY2; // All done! :D - return; } diff --git a/pcsx2/CDVD/CDVD.h b/pcsx2/CDVD/CDVD.h index 81e9a50774..1649bcab5d 100644 --- a/pcsx2/CDVD/CDVD.h +++ b/pcsx2/CDVD/CDVD.h @@ -27,6 +27,43 @@ extern char isoFileName[]; #define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ #define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ +static __forceinline s32 msf_to_lsn(u8 *Time) +{ + u32 lsn; + + lsn = Time[2]; + lsn +=(Time[1] - 2) * 75; + lsn += Time[0] * 75 * 60; + return lsn; +} + +static __forceinline s32 msf_to_lba(u8 m, u8 s, u8 f) +{ + u32 lsn; + lsn = f; + lsn += (s - 2) * 75; + lsn += m * 75 * 60; + return lsn; +} + +static __forceinline void lsn_to_msf(u8 *Time, s32 lsn) +{ + lsn += 150; + Time[2] = lsn / 4500; // minuten + lsn = lsn - Time[2] * 4500; // minuten rest + Time[1] = lsn / 75; // sekunden + Time[0] = lsn - Time[1] * 75; // sekunden rest +} + + +static __forceinline void lba_to_msf(s32 lba, u8* m, u8* s, u8* f) +{ + lba += 150; + *m = lba / (60 * 75); + *s = (lba / 75) % 60; + *f = lba % 75; +} + struct cdvdRTC { u8 status; u8 second; diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index 5054c8dae2..c966628f2b 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -305,9 +305,7 @@ s32 DoCDVDopen(const char* pTitleFilename) cdvdTD td; CDVD.getTD(0, &td); - int blockofs = 0; - int blocksize = 0; - int blocks = td.lsn; + int blockofs = 0, blocksize = 0, blocks = td.lsn; switch(cdtype) { diff --git a/pcsx2/CDVD/CDVDisoReader.cpp b/pcsx2/CDVD/CDVDisoReader.cpp index 4b8f9b21b2..c7f70c4e53 100644 --- a/pcsx2/CDVD/CDVDisoReader.cpp +++ b/pcsx2/CDVD/CDVDisoReader.cpp @@ -30,79 +30,21 @@ #include "CDVDisoReader.h" char isoFileName[g_MaxPath]; - u8 *pbuffer; -int cdtype; - -static int psize; - -isoFile *iso; - -FILE *cdvdLog = NULL; - +static int psize, cdtype; u8 cdbuffer[2352] = {0}; - -s32 msf_to_lba(u8 m, u8 s, u8 f) -{ - u32 lsn; - lsn = f; - lsn += (s - 2) * 75; - lsn += m * 75 * 60; - return lsn; -} - -void lba_to_msf(s32 lba, u8* m, u8* s, u8* f) -{ - lba += 150; - *m = lba / (60 * 75); - *s = (lba / 75) % 60; - *f = lba % 75; -} - -//#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ -//#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ - - -/*#ifdef PCSX2_DEBUG -void __Log(char *fmt, ...) -{ - va_list list; - - if (cdvdLog == NULL) return; - - va_start(list, fmt); - vfprintf(cdvdLog, fmt, list); - va_end(list); -} -#else -#define __Log 0&& -#endif*/ +isoFile *iso; s32 CALLBACK ISOinit() { -/*#ifdef PCSX2_DEBUG - cdvdLog = fopen("logs/cdvdLog.txt", "w"); - if (cdvdLog == NULL) - { - cdvdLog = fopen("cdvdLog.txt", "w"); - if (cdvdLog == NULL) - { - Console::Error("Can't create cdvdLog.txt"); - return -1; - } - } - setvbuf(cdvdLog, NULL, _IONBF, 0);*/ - CDVD_LOG("CDVDinit\n"); -/*#endif*/ + CDVD_LOG("ISOinit\n"); return 0; } void CALLBACK ISOshutdown() { -/*#ifdef CDVD_LOG - if (cdvdLog != NULL) fclose(cdvdLog); -#endif*/ + CDVD_LOG("ISOshutdown\n"); } s32 CALLBACK ISOopen(const char* pTitle) @@ -246,7 +188,7 @@ s32 CALLBACK ISOgetTOC(void* toc) u8 type = ISOgetDiskType(); u8* tocBuff = (u8*)toc; - //__Log("CDVDgetTOC\n"); + //CDVD_LOG("CDVDgetTOC\n"); if (type == CDVD_TYPE_DVDV || type == CDVD_TYPE_PS2DVD) { diff --git a/pcsx2/CDVD/CDVDisoReader.h b/pcsx2/CDVD/CDVDisoReader.h index cb0448d72a..8e988acee9 100644 --- a/pcsx2/CDVD/CDVDisoReader.h +++ b/pcsx2/CDVD/CDVDisoReader.h @@ -29,19 +29,6 @@ #include "IsoFStools.h" #include "IsoFileFormats.h" -//#define CDVD_LOG __Log - -//#ifndef MAX_PATH -//#define MAX_PATH 255 -//#endif - -//extern FILE *cdvdLog; - -//void __Log(char *fmt, ...); - -//#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ -//#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ - extern char isoFileName[g_MaxPath]; extern isoFile *iso; diff --git a/pcsx2/CDVD/CdRom.cpp b/pcsx2/CDVD/CdRom.cpp index 726d4ae97b..ed9aa41f7f 100644 --- a/pcsx2/CDVD/CdRom.cpp +++ b/pcsx2/CDVD/CdRom.cpp @@ -118,30 +118,13 @@ static __forceinline void SetResultSize(u8 size) { cdr.ResultReady = 1; } -static __forceinline s32 MSFtoLSN(u8 *Time) { - u32 lsn; - - lsn = Time[2]; - lsn+=(Time[1] - 2) * 75; - lsn+= Time[0] * 75 * 60; - return lsn; -} - -static __forceinline void LSNtoMSF(u8 *Time, s32 lsn) { - lsn += 150; - Time[2] = lsn / 4500; // minuten - lsn = lsn - Time[2] * 4500; // minuten rest - Time[1] = lsn / 75; // sekunden - Time[0] = lsn - Time[1] * 75; // sekunden rest -} - static void ReadTrack() { cdr.Prev[0] = itob(cdr.SetSector[0]); cdr.Prev[1] = itob(cdr.SetSector[1]); cdr.Prev[2] = itob(cdr.SetSector[2]); CDR_LOG("KEY *** %x:%x:%x", cdr.Prev[0], cdr.Prev[1], cdr.Prev[2]); - cdr.RErr = DoCDVDreadTrack(MSFtoLSN(cdr.SetSector), CDVD_MODE_2340); + cdr.RErr = DoCDVDreadTrack(msf_to_lsn(cdr.SetSector), CDVD_MODE_2340); } // cdr.Stat: @@ -351,7 +334,7 @@ void cdrInterrupt() { cdr.Stat = DiskError; cdr.Result[0]|= 0x01; } else { - LSNtoMSF(cdr.ResultTD, trackInfo.lsn); + lsn_to_msf(cdr.ResultTD, trackInfo.lsn); cdr.Stat = Acknowledge; cdr.Result[0] = cdr.StatP; cdr.Result[1] = itob(cdr.ResultTD[0]); @@ -397,11 +380,14 @@ void cdrInterrupt() { SetResultSize(4); *(int*)cdr.Result = *(int*)Test20; break; + case 0x22: SetResultSize(8); *(int*)cdr.Result = *(int*)Test22; break; - case 0x23: case 0x24: + + case 0x23: + case 0x24: SetResultSize(8); *(int*)cdr.Result = *(int*)Test23; break; @@ -456,8 +442,7 @@ void cdrInterrupt() { break; case READ_ACK: - if (!cdr.Reading) - return; + if (!cdr.Reading) return; SetResultSize(1); cdr.StatP|= 0x2; diff --git a/pcsx2/CDVD/IsoFSdrv.cpp b/pcsx2/CDVD/IsoFSdrv.cpp index ce014f892b..19d8bc9dec 100644 --- a/pcsx2/CDVD/IsoFSdrv.cpp +++ b/pcsx2/CDVD/IsoFSdrv.cpp @@ -27,7 +27,7 @@ #include "IsoFSdrv.h" struct fdtable{ -//int fd; +// int fd; int fileSize; int LBA; int filePos; @@ -68,8 +68,7 @@ int IsoFS_open(const char *name, int mode){ static struct TocEntry tocEntry; // check if the file exists - if (IsoFS_findFile(name, &tocEntry) != TRUE) - return -1; + if (IsoFS_findFile(name, &tocEntry) != TRUE) return -1; if(mode != 1) return -2; //SCE_RDONLY @@ -117,11 +116,12 @@ int IsoFS_lseek(int fd, int offset, int whence){ return -1; } - if (fd_table[fd].filePos < 0) - fd_table[fd].filePos = 0; + if (fd_table[fd].filePos < 0) fd_table[fd].filePos = 0; - if (fd_table[fd].filePos > fd_table[fd].fileSize) + if (fd_table[fd].filePos > fd_table[fd].fileSize) + { fd_table[fd].filePos = fd_table[fd].fileSize; + } return fd_table[fd].filePos; } @@ -152,8 +152,10 @@ int IsoFS_read( int fd, char *buffer, int size ) } if ((fd_table[fd].filePos + size) > fd_table[fd].fileSize) + { size = fd_table[fd].fileSize - fd_table[fd].filePos; - + } + // Now work out where we want to start reading from asector = ssector = fd_table[fd].LBA + (fd_table[fd].filePos >> 11); off_sector = (fd_table[fd].filePos & 0x7FF); @@ -179,7 +181,7 @@ int IsoFS_read( int fd, char *buffer, int size ) } memcpy_fast(buffer, lb + off_sector, ssize); } - if (asize) if (IsoFS_readSectors(asector, asize >> 11, buffer+ssize) != TRUE) + if (asize && (IsoFS_readSectors(asector, asize >> 11, buffer+ssize) != TRUE)) { ISOFS_LOG("[IsoFSdrv:read] Couldn't Read from file for some reason"); return 0; @@ -228,6 +230,7 @@ int IsoFS_close( int fd) ISOFS_LOG("[IsoFSdrv:close] ERROR: File does not appear to be open!"); return -1; } + ISOFS_LOG("[IsoFSdrv:close] internal fd %d", fd); fd_used[fd] = 0; files_open--; diff --git a/pcsx2/CDVD/IsoFStools.cpp b/pcsx2/CDVD/IsoFStools.cpp index 4ef2d6cac8..8282379782 100644 --- a/pcsx2/CDVD/IsoFStools.cpp +++ b/pcsx2/CDVD/IsoFStools.cpp @@ -113,10 +113,10 @@ void TocEntryCopy(TocEntry* tocEntry, const dirTocEntry* internalTocEntry){ filenamelen = internalTocEntry->filenameLength/2; - if (!(tocEntry->fileProperties & 0x02)){ +// if (!(tocEntry->fileProperties & 0x02)){ // strip the ;1 from the filename // filenamelen -= 2;//(Florin) nah, do not strip ;1 - } +// } for (i=0; i < filenamelen; i++) tocEntry->filename[i] = internalTocEntry->filename[(i<<1)+1]; @@ -126,10 +126,10 @@ void TocEntryCopy(TocEntry* tocEntry, const dirTocEntry* internalTocEntry){ else{ filenamelen = internalTocEntry->filenameLength; - if (!(tocEntry->fileProperties & 0x02)){ +// if (!(tocEntry->fileProperties & 0x02)){ // strip the ;1 from the filename // filenamelen -= 2;//(Florin) nah, do not strip ;1 - } +// } // use normal string copy strncpy(tocEntry->filename,internalTocEntry->filename,128); @@ -140,10 +140,7 @@ void TocEntryCopy(TocEntry* tocEntry, const dirTocEntry* internalTocEntry){ // Check if a TOC Entry matches our extension list int TocEntryCompare(char* filename, char* extensions){ static char ext_list[129]; - - char* token; - - char* ext_point; + char* token, ext_point; strncpy(ext_list,extensions,128); ext_list[128]=0; @@ -167,15 +164,9 @@ int TocEntryCompare(char* filename, char* extensions){ } -#define CD_SECS 60 /* seconds per minute */ -#define CD_FRAMES 75 /* frames per second */ -#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ - int IsoFS_readSectors(u32 lsn, u32 sectors, void *buf) { - u32 i; - - for (i=0; i 128) - req_entries = 128; + if (req_entries > 128) req_entries = 128; for (toc_entry_num=0; toc_entry_num < req_entries;) { diff --git a/pcsx2/CDVD/IsoFStools.h b/pcsx2/CDVD/IsoFStools.h index 6c146e4abc..93e38000bc 100644 --- a/pcsx2/CDVD/IsoFStools.h +++ b/pcsx2/CDVD/IsoFStools.h @@ -28,6 +28,10 @@ int IsoFS_initDirectoryList(char* pathname, char* extensions, unsigned int inc_dirs); int IsoFS_getDirectories(TocEntry tocEntry[], int req_entries); +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ + #if defined(_MSC_VER) #pragma pack(1) #pragma warning(disable:4996) //ignore the stricmp deprecated warning diff --git a/pcsx2/CDVD/IsoFileFormats.cpp b/pcsx2/CDVD/IsoFileFormats.cpp index 25b9f3f248..22d4fdbeb1 100644 --- a/pcsx2/CDVD/IsoFileFormats.cpp +++ b/pcsx2/CDVD/IsoFileFormats.cpp @@ -205,10 +205,7 @@ isoFile *isoCreate(const char *filename, int flags) sprintf(Zfile, "%s.table", iso->filename); iso->htable = _openfile(Zfile, O_WRONLY); - if (iso->htable == NULL) - { - return NULL; - } + if (iso->htable == NULL) return NULL; } iso->handle = _openfile(iso->filename, O_WRONLY | O_CREAT); @@ -361,7 +358,7 @@ int isoReadBlock(isoFile *iso, u8 *dst, int lsn) else ret = _isoReadBlock(iso, dst, lsn); - if (ret == -1) return ret; + if (ret == -1) return -1; if (iso->type == ISOTYPE_CD) { @@ -411,7 +408,7 @@ int isoWriteBlock(isoFile *iso, u8 *src, int lsn) else ret = _isoWriteBlock(iso, src, lsn); - if (ret == -1) return ret; + if (ret == -1) return -1; return 0; } diff --git a/pcsx2/CDVD/IsoFileTools.cpp b/pcsx2/CDVD/IsoFileTools.cpp index 0fb7ea10e6..455eac513f 100644 --- a/pcsx2/CDVD/IsoFileTools.cpp +++ b/pcsx2/CDVD/IsoFileTools.cpp @@ -54,15 +54,11 @@ int _seekfile(void *handle, u64 offset, int whence) { u64 ofs = (u64)offset; PLONG _ofs = (LONG*) & ofs; + // Console::WriteLn("_seekfile %p, %d_%d", params handle, _ofs[1], _ofs[0]); - if (whence == SEEK_SET) - { - SetFilePointer(handle, _ofs[0], &_ofs[1], FILE_BEGIN); - } - else - { - SetFilePointer(handle, _ofs[0], &_ofs[1], FILE_END); - } + + SetFilePointer(handle, _ofs[0], &_ofs[1], (whence == SEEK_SET) ? FILE_BEGIN : FILE_END); + return 0; } @@ -70,9 +66,8 @@ int _readfile(void *handle, void *dst, int size) { DWORD ret; -// Console::WriteLn("_readfile %p %d", params handle, size); ReadFile(handle, dst, size, &ret, NULL); -// Console::WriteLn("_readfile ret %d; %d", params ret, GetLastError()); +// Console::WriteLn("_readfile(%p, %d) = %d; %d", params handle, size, ret, GetLastError()); return ret; } @@ -80,10 +75,9 @@ int _writefile(void *handle, void *src, int size) { DWORD ret; -// Console::WriteLn("_writefile %p, %d", params handle, size); // _seekfile(handle, _tellfile(handle)); WriteFile(handle, src, size, &ret, NULL); -// Console::WriteLn("_writefile ret %d", params ret); +// Console::WriteLn("_readfile(%p, %d) = %d", params handle, size, ret); return ret; } diff --git a/pcsx2/Console.cpp b/pcsx2/Console.cpp index abed30a619..a4eaa64c47 100644 --- a/pcsx2/Console.cpp +++ b/pcsx2/Console.cpp @@ -60,11 +60,13 @@ namespace Console bool Write( Colors color, const char* fmt, VARG_PARAM dummy, ... ) { varg_assert(); + SetColor( color ); va_list list; va_start(list,dummy); Write( vfmt_string( fmt, list ).c_str() ); va_end(list); + ClearColor(); return false; } From 829efedfb5e1ec14bcdfe740bdd040f5a5f1936f Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Sat, 25 Jul 2009 01:56:27 +0000 Subject: [PATCH 09/22] microVU: - Re-implemented logical min/max code - Re-implemented tri-ace gamefix - Fixed some bugs... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1567 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_Alloc.inl | 3 +- pcsx2/x86/microVU_Misc.inl | 132 ++++++++++++++++++++++-------------- pcsx2/x86/microVU_Upper.inl | 60 ++++++++-------- 3 files changed, 114 insertions(+), 81 deletions(-) diff --git a/pcsx2/x86/microVU_Alloc.inl b/pcsx2/x86/microVU_Alloc.inl index 56fbdeea2c..00a1a0cf65 100644 --- a/pcsx2/x86/microVU_Alloc.inl +++ b/pcsx2/x86/microVU_Alloc.inl @@ -118,8 +118,7 @@ microVUt(void) mVUallocVIb(mV, int GPRreg, int _reg_) { //------------------------------------------------------------------ #define getIreg(reg, modXYZW) { \ - MOV32MtoR(gprT1, (uptr)&mVU->regs->VI[REG_I].UL); \ - SSE2_MOVD_R_to_XMM(reg, gprT1); \ + SSE_MOVSS_M32_to_XMM(reg, (uptr)&mVU->regs->VI[REG_I].UL); \ if (CHECK_VU_EXTRA_OVERFLOW) mVUclamp2(reg, xmmT2, 8); \ if (!((_XYZW_SS && modXYZW) || (_X_Y_Z_W == 8))) { mVUunpack_xyzw(reg, reg, 0); } \ } diff --git a/pcsx2/x86/microVU_Misc.inl b/pcsx2/x86/microVU_Misc.inl index 44cd2e6557..42a7e5b077 100644 --- a/pcsx2/x86/microVU_Misc.inl +++ b/pcsx2/x86/microVU_Misc.inl @@ -317,67 +317,60 @@ microVUt(void) mVUrestoreRegs(microVU* mVU) { static const u32 PCSX2_ALIGNED16(MIN_MAX_MASK1[4]) = {0xffffffff, 0x80000000, 0xffffffff, 0x80000000}; static const u32 PCSX2_ALIGNED16(MIN_MAX_MASK2[4]) = {0x00000000, 0x40000000, 0x00000000, 0x40000000}; -// Warning: Modifies xmmT1 and xmmT2 -void MIN_MAX_(x86SSERegType to, x86SSERegType from, bool min) { +// Warning: Modifies t1 and t2 +void MIN_MAX_PS(microVU* mVU, int to, int from, int t1, int t2, bool min) { + bool t1b = 0, t2b = 0; + if (t1 < 0) { t1 = mVU->regAlloc->allocReg(); t1b = 1; } + if (t2 < 0) { t2 = mVU->regAlloc->allocReg(); t2b = 1; } // ZW - SSE2_PSHUFD_XMM_to_XMM(xmmT1, to, 0xfa); - SSE2_PAND_M128_to_XMM (xmmT1, (uptr)MIN_MAX_MASK1); - SSE2_POR_M128_to_XMM (xmmT1, (uptr)MIN_MAX_MASK2); - SSE2_PSHUFD_XMM_to_XMM(xmmT2, from, 0xfa); - SSE2_PAND_M128_to_XMM (xmmT2, (uptr)MIN_MAX_MASK1); - SSE2_POR_M128_to_XMM (xmmT2, (uptr)MIN_MAX_MASK2); - if (min) SSE2_MINPD_XMM_to_XMM(xmmT1, xmmT2); - else SSE2_MAXPD_XMM_to_XMM(xmmT1, xmmT2); + SSE2_PSHUFD_XMM_to_XMM(t1, to, 0xfa); + SSE2_PAND_M128_to_XMM (t1, (uptr)MIN_MAX_MASK1); + SSE2_POR_M128_to_XMM (t1, (uptr)MIN_MAX_MASK2); + SSE2_PSHUFD_XMM_to_XMM(t2, from, 0xfa); + SSE2_PAND_M128_to_XMM (t2, (uptr)MIN_MAX_MASK1); + SSE2_POR_M128_to_XMM (t2, (uptr)MIN_MAX_MASK2); + if (min) SSE2_MINPD_XMM_to_XMM(t1, t2); + else SSE2_MAXPD_XMM_to_XMM(t1, t2); // XY - SSE2_PSHUFD_XMM_to_XMM(xmmT2, from, 0x50); - SSE2_PAND_M128_to_XMM (xmmT2, (uptr)MIN_MAX_MASK1); - SSE2_POR_M128_to_XMM (xmmT2, (uptr)MIN_MAX_MASK2); + SSE2_PSHUFD_XMM_to_XMM(t2, from, 0x50); + SSE2_PAND_M128_to_XMM (t2, (uptr)MIN_MAX_MASK1); + SSE2_POR_M128_to_XMM (t2, (uptr)MIN_MAX_MASK2); SSE2_PSHUFD_XMM_to_XMM(to, to, 0x50); - SSE2_PAND_M128_to_XMM (to, (uptr)MIN_MAX_MASK1); - SSE2_POR_M128_to_XMM (to, (uptr)MIN_MAX_MASK2); - if (min) SSE2_MINPD_XMM_to_XMM(to, xmmT2); - else SSE2_MAXPD_XMM_to_XMM(to, xmmT2); + SSE2_PAND_M128_to_XMM (to, (uptr)MIN_MAX_MASK1); + SSE2_POR_M128_to_XMM (to, (uptr)MIN_MAX_MASK2); + if (min) SSE2_MINPD_XMM_to_XMM(to, t2); + else SSE2_MAXPD_XMM_to_XMM(to, t2); - SSE_SHUFPS_XMM_to_XMM(to, xmmT1, 0x88); + SSE_SHUFPS_XMM_to_XMM(to, t1, 0x88); + if (t1b) mVU->regAlloc->clearNeeded(t1); + if (t2b) mVU->regAlloc->clearNeeded(t2); } -// Warning: Modifies from and to's upper 3 vectors -void MIN_MAX_SS(x86SSERegType to, x86SSERegType from, bool min) { +// Warning: Modifies from's upper 3 vectors, and t1 +void MIN_MAX_SS(mV, int to, int from, int t1, bool min) { + bool t1b = 0; + if (t1 < 0) { t1 = mVU->regAlloc->allocReg(); t1b = 1; } SSE_SHUFPS_XMM_to_XMM (to, from, 0); SSE2_PAND_M128_to_XMM (to, (uptr)MIN_MAX_MASK1); SSE2_POR_M128_to_XMM (to, (uptr)MIN_MAX_MASK2); - SSE2_PSHUFD_XMM_to_XMM(from, to, 0xee); - if (min) SSE2_MINPD_XMM_to_XMM(to, from); - else SSE2_MAXPD_XMM_to_XMM(to, from); -} - -void SSE_MAX2PS_XMM_to_XMM(x86SSERegType to, x86SSERegType from) { - if (CHECK_VU_MINMAXHACK) { SSE_MAXPS_XMM_to_XMM(to, from); } - else { MIN_MAX_(to, from, 0); } -} -void SSE_MIN2PS_XMM_to_XMM(x86SSERegType to, x86SSERegType from) { - if (CHECK_VU_MINMAXHACK) { SSE_MINPS_XMM_to_XMM(to, from); } - else { MIN_MAX_(to, from, 1); } -} -void SSE_MAX2SS_XMM_to_XMM(x86SSERegType to, x86SSERegType from) { - if (CHECK_VU_MINMAXHACK) { SSE_MAXSS_XMM_to_XMM(to, from); } - else { MIN_MAX_SS(to, from, 0); } -} -void SSE_MIN2SS_XMM_to_XMM(x86SSERegType to, x86SSERegType from) { - if (CHECK_VU_MINMAXHACK) { SSE_MINSS_XMM_to_XMM(to, from); } - else { MIN_MAX_SS(to, from, 1); } + SSE2_PSHUFD_XMM_to_XMM(t1, to, 0xee); + if (min) SSE2_MINPD_XMM_to_XMM(to, t1); + else SSE2_MAXPD_XMM_to_XMM(to, t1); + if (t1b) mVU->regAlloc->clearNeeded(t1); } // Warning: Modifies all vectors in 'to' and 'from', and Modifies xmmT1 and xmmT2 -void SSE_ADD2SS_XMM_to_XMM(x86SSERegType to, x86SSERegType from) { - - if (!CHECK_VUADDSUBHACK) { SSE_ADDSS_XMM_to_XMM(to, from); return; } - u8 *localptr[8]; +void ADD_SS(microVU* mVU, int to, int from, int t1, int t2) { - SSE_MOVAPS_XMM_to_XMM(xmmT1, to); - SSE_MOVAPS_XMM_to_XMM(xmmT2, from); + u8 *localptr[8]; + bool t1b = 0, t2b = 0; + if (t1 < 0) { t1 = mVU->regAlloc->allocReg(); t1b = 1; } + if (t2 < 0) { t2 = mVU->regAlloc->allocReg(); t2b = 1; } + + SSE_MOVAPS_XMM_to_XMM(t1, to); + SSE_MOVAPS_XMM_to_XMM(t2, from); SSE2_MOVD_XMM_to_R(gprT2, to); SHR32ItoR(gprT2, 23); SSE2_MOVD_XMM_to_R(gprT1, from); @@ -435,15 +428,54 @@ void SSE_ADD2SS_XMM_to_XMM(x86SSERegType to, x86SSERegType from) { x86SetJ8(localptr[6]); x86SetJ8(localptr[7]); - SSE_ANDPS_XMM_to_XMM(to, xmmT1); //to contains mask - SSE_ANDPS_XMM_to_XMM(from, xmmT2); //from contains mask + SSE_ANDPS_XMM_to_XMM(to, t1); // to contains mask + SSE_ANDPS_XMM_to_XMM(from, t2); // from contains mask SSE_ADDSS_XMM_to_XMM(to, from); + if (t1b) mVU->regAlloc->clearNeeded(t1); + if (t2b) mVU->regAlloc->clearNeeded(t2); } -// Note: Wrapper function, Tri-Ace Games just need the SS implementation -void SSE_ADD2PS_XMM_to_XMM(x86SSERegType to, x86SSERegType from) { +void SSE_MAXPS(mV, int to, int from, int t1, int t2) { + if (CHECK_VU_MINMAXHACK) { SSE_MAXPS_XMM_to_XMM(to, from); } + else { MIN_MAX_PS(mVU, to, from, t1, t2, 0); } +} +void SSE_MINPS(mV, int to, int from, int t1, int t2) { + if (CHECK_VU_MINMAXHACK) { SSE_MINPS_XMM_to_XMM(to, from); } + else { MIN_MAX_PS(mVU, to, from, t1, t2, 1); } +} +void SSE_MAXSS(mV, int to, int from, int t1, int t2) { + if (CHECK_VU_MINMAXHACK) { SSE_MAXSS_XMM_to_XMM(to, from); } + else { MIN_MAX_SS(mVU, to, from, t1, 0); } +} +void SSE_MINSS(mV, int to, int from, int t1, int t2) { + if (CHECK_VU_MINMAXHACK) { SSE_MINSS_XMM_to_XMM(to, from); } + else { MIN_MAX_SS(mVU, to, from, t1, 1); } +} +void SSE_ADD2SS(mV, int to, int from, int t1, int t2) { + if (!CHECK_VUADDSUBHACK) { SSE_ADDSS_XMM_to_XMM(to, from); } + else { ADD_SS(mVU, to, from, t1, t2); } +} +void SSE_ADD2PS(mV, int to, int from, int t1, int t2) { SSE_ADDPS_XMM_to_XMM(to, from); } +void SSE_ADDPS(mV, int to, int from, int t1, int t2) { + SSE_ADDPS_XMM_to_XMM(to, from); +} +void SSE_ADDSS(mV, int to, int from, int t1, int t2) { + SSE_ADDSS_XMM_to_XMM(to, from); +} +void SSE_SUBPS(mV, int to, int from, int t1, int t2) { + SSE_SUBPS_XMM_to_XMM(to, from); +} +void SSE_SUBSS(mV, int to, int from, int t1, int t2) { + SSE_SUBSS_XMM_to_XMM(to, from); +} +void SSE_MULPS(mV, int to, int from, int t1, int t2) { + SSE_MULPS_XMM_to_XMM(to, from); +} +void SSE_MULSS(mV, int to, int from, int t1, int t2) { + SSE_MULSS_XMM_to_XMM(to, from); +} //------------------------------------------------------------------ // Micro VU - Custom Quick Search diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index ce73408362..4d93e77f1a 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -81,20 +81,22 @@ microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { // Helper Macros and Functions //------------------------------------------------------------------ -static void (*SSE_PS[]) (x86SSERegType, x86SSERegType) = { - SSE_ADDPS_XMM_to_XMM, // 0 - SSE_SUBPS_XMM_to_XMM, // 1 - SSE_MULPS_XMM_to_XMM, // 2 - SSE_MAXPS_XMM_to_XMM, // 3 - SSE_MINPS_XMM_to_XMM // 4 +static void (*SSE_PS[]) (microVU*, int, int, int, int) = { + SSE_ADDPS, // 0 + SSE_SUBPS, // 1 + SSE_MULPS, // 2 + SSE_MAXPS, // 3 + SSE_MINPS, // 4 + SSE_ADD2PS // 5 }; -static void (*SSE_SS[]) (x86SSERegType, x86SSERegType) = { - SSE_ADDSS_XMM_to_XMM, // 0 - SSE_SUBSS_XMM_to_XMM, // 1 - SSE_MULSS_XMM_to_XMM, // 2 - SSE_MAXSS_XMM_to_XMM, // 3 - SSE_MINSS_XMM_to_XMM // 4 +static void (*SSE_SS[]) (microVU*, int, int, int, int) = { + SSE_ADDSS, // 0 + SSE_SUBSS, // 1 + SSE_MULSS, // 2 + SSE_MAXSS, // 3 + SSE_MINSS, // 4 + SSE_ADD2SS // 5 }; // Prints Opcode to MicroProgram Logs @@ -147,8 +149,8 @@ void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, co opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } - if (_XYZW_SS) SSE_SS[opType](Fs, Ft); - else SSE_PS[opType](Fs, Ft); + if (_XYZW_SS) SSE_SS[opType](mVU, Fs, Ft, -1, -1); + else SSE_PS[opType](mVU, Fs, Ft, -1, -1); opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } @@ -185,22 +187,22 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* op opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } - if (_XYZW_SS) SSE_SS[2](Fs, Ft); - else SSE_PS[2](Fs, Ft); + if (_XYZW_SS) SSE_SS[2](mVU, Fs, Ft, -1, -1); + else SSE_PS[2](mVU, Fs, Ft, -1, -1); opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } if (_XYZW_SS || _X_Y_Z_W == 0xf) { - if (_XYZW_SS) SSE_SS[opType](ACC, Fs); - else SSE_PS[opType](ACC, Fs); + if (_XYZW_SS) SSE_SS[opType](mVU, ACC, Fs, -1, -1); + else SSE_PS[opType](mVU, ACC, Fs, -1, -1); mVUupdateFlags(mVU, ACC, Fs); if (_XYZW_SS && _X_Y_Z_W != 8) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } else { int tempACC = mVU->regAlloc->allocReg(); SSE_MOVAPS_XMM_to_XMM(tempACC, ACC); - SSE_PS[opType](tempACC, Fs); + SSE_PS[opType](mVU, tempACC, Fs, -1, -1); mVUmergeRegs(ACC, tempACC, _X_Y_Z_W); mVU->regAlloc->clearNeeded(tempACC); } @@ -229,8 +231,8 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, const char* opName) { opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } - if (_XYZW_SS) { SSE_SS[2](Fs, Ft); SSE_SS[0](Fs, ACC); } - else { SSE_PS[2](Fs, Ft); SSE_PS[0](Fs, ACC); } + if (_XYZW_SS) { SSE_SS[2](mVU, Fs, Ft, -1, -1); SSE_SS[0](mVU, Fs, ACC, -1, -1); } + else { SSE_PS[2](mVU, Fs, Ft, -1, -1); SSE_PS[0](mVU, Fs, ACC, -1, -1); } mVUupdateFlags(mVU, Fs, -1); @@ -260,8 +262,8 @@ void mVU_FMACd(microVU* mVU, int recPass, int opCase, const char* opName) { opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } - if (_XYZW_SS) { SSE_SS[2](Fs, Ft); SSE_SS[1](Fd, Fs); } - else { SSE_PS[2](Fs, Ft); SSE_PS[1](Fd, Fs); } + if (_XYZW_SS) { SSE_SS[2](mVU, Fs, Ft, -1, -1); SSE_SS[1](mVU, Fd, Fs, -1, -1); } + else { SSE_PS[2](mVU, Fs, Ft, -1, -1); SSE_PS[1](mVU, Fd, Fs, -1, -1); } mVUupdateFlags(mVU, Fd, Fs); @@ -315,8 +317,8 @@ mVUop(mVU_OPMSUB) { pass1 { mVUanalyzeFMAC1(mVU, _Fd_, _Fs_, _Ft_); } pass2 { mVU->regAlloc->reset(); // Reset for Testing - int Ft = mVU->regAlloc->allocReg(_Ft_); - int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + int Ft = mVU->regAlloc->allocReg(_Ft_, 0, 0xf); + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); int ACC = mVU->regAlloc->allocReg(32, _Fd_, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(Fs, Fs, 0xC9); // WXZY @@ -325,7 +327,7 @@ mVUop(mVU_OPMSUB) { SSE_SUBPS_XMM_to_XMM(ACC, Fs); mVUupdateFlags(mVU, ACC, Fs); - mVU->regAlloc->clearNeeded(32); + mVU->regAlloc->clearNeeded(ACC); mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(Ft); mVU->regAlloc->flushAll(); // Flush All for Testing @@ -386,8 +388,8 @@ mVUop(mVU_CLIP) { pass1 { mVUanalyzeFMAC4(mVU, _Fs_, _Ft_); } pass2 { mVU->regAlloc->reset(); // Reset for Testing - int Fs = mVU->regAlloc->allocReg(_Fs_); - int Ft = mVU->regAlloc->allocReg(_Ft_, 0, 1); + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); + int Ft = mVU->regAlloc->allocReg(_Ft_, 0, 0x1); int t1 = mVU->regAlloc->allocReg(); mVUunpack_xyzw(Ft, Ft, 0); @@ -429,7 +431,7 @@ mVUop(mVU_CLIP) { //------------------------------------------------------------------ mVUop(mVU_ADD) { mVU_FMACa(mVU, recPass, 1, 0, 0, "ADD"); } -mVUop(mVU_ADDi) { mVU_FMACa(mVU, recPass, 3, 0, 0, "ADDi"); } +mVUop(mVU_ADDi) { mVU_FMACa(mVU, recPass, 3, 5, 0, "ADDi"); } mVUop(mVU_ADDq) { mVU_FMACa(mVU, recPass, 4, 0, 0, "ADDq"); } mVUop(mVU_ADDx) { mVU_FMACa(mVU, recPass, 2, 0, 0, "ADDx"); } mVUop(mVU_ADDy) { mVU_FMACa(mVU, recPass, 2, 0, 0, "ADDy"); } From aedf28726cb7979afe55606416f909166f88ff96 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Sat, 25 Jul 2009 02:38:09 +0000 Subject: [PATCH 10/22] microVU: Setting VU clamp mode to "normal" should fix sps/problems in alot of games now. I'll list what I think should be fixed: Dawn of Mana SPS <- Should be fixed, untested ToTa Characters <- Should be fixed, untested FFXII SPS in Barheim Passage <- Should be fixed, untested KH1 floor bug <- Fixed for me, but theres still other sps on characters caused by something else Most-likely SPS in some other games is fixed as well... If anyone can confirm the games I listed are fixed, please leave a comment :D git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1568 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_Lower.inl | 4 ++-- pcsx2/x86/microVU_Misc.inl | 34 ++++++++++++++++++---------------- pcsx2/x86/microVU_Upper.inl | 3 +++ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/pcsx2/x86/microVU_Lower.inl b/pcsx2/x86/microVU_Lower.inl index 7bd2cdd09f..4ca15ed320 100644 --- a/pcsx2/x86/microVU_Lower.inl +++ b/pcsx2/x86/microVU_Lower.inl @@ -68,7 +68,7 @@ mVUop(mVU_DIV) { x86SetJ8(cjmp); MOV32ItoM((uptr)&mVU->divFlag, 0); // Clear I/D flags SSE_DIVSS_XMM_to_XMM(xmmFs, xmmFt); - if (CHECK_VU_OVERFLOW) mVUclamp1(xmmFs, xmmFt, 8); + mVUclamp1(xmmFs, xmmFt, 8); x86SetJ8(djmp); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); @@ -124,7 +124,7 @@ mVUop(mVU_RSQRT) { djmp = JMP8(0); x86SetJ8(ajmp); SSE_DIVSS_XMM_to_XMM(xmmFs, xmmFt); - if (CHECK_VU_OVERFLOW) mVUclamp1(xmmFs, xmmFt, 8); + mVUclamp1(xmmFs, xmmFt, 8); x86SetJ8(djmp); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); diff --git a/pcsx2/x86/microVU_Misc.inl b/pcsx2/x86/microVU_Misc.inl index 42a7e5b077..73c762d45b 100644 --- a/pcsx2/x86/microVU_Misc.inl +++ b/pcsx2/x86/microVU_Misc.inl @@ -24,15 +24,17 @@ // Used for Result Clamping void mVUclamp1(int reg, int regT1, int xyzw) { - switch (xyzw) { - case 1: case 2: case 4: case 8: - SSE_MINSS_M32_to_XMM(reg, (uptr)mVU_maxvals); - SSE_MAXSS_M32_to_XMM(reg, (uptr)mVU_minvals); - break; - default: - SSE_MINPS_M128_to_XMM(reg, (uptr)mVU_maxvals); - SSE_MAXPS_M128_to_XMM(reg, (uptr)mVU_minvals); - break; + if (CHECK_VU_OVERFLOW) { + switch (xyzw) { + case 1: case 2: case 4: case 8: + SSE_MINSS_M32_to_XMM(reg, (uptr)mVU_maxvals); + SSE_MAXSS_M32_to_XMM(reg, (uptr)mVU_minvals); + break; + default: + SSE_MINPS_M128_to_XMM(reg, (uptr)mVU_maxvals); + SSE_MAXPS_M128_to_XMM(reg, (uptr)mVU_minvals); + break; + } } } @@ -41,18 +43,18 @@ void mVUclamp2(int reg, int regT1, int xyzw) { if (CHECK_VU_SIGN_OVERFLOW) { switch (xyzw) { case 1: case 2: case 4: case 8: - SSE_MOVSS_XMM_to_XMM(regT1, reg); + SSE_MOVSS_XMM_to_XMM (regT1, reg); SSE_ANDPS_M128_to_XMM(regT1, (uptr)mVU_signbit); - SSE_MINSS_M32_to_XMM(reg, (uptr)mVU_maxvals); - SSE_MAXSS_M32_to_XMM(reg, (uptr)mVU_minvals); - SSE_ORPS_XMM_to_XMM(reg, regT1); + SSE_MINSS_M32_to_XMM (reg, (uptr)mVU_maxvals); + SSE_MAXSS_M32_to_XMM (reg, (uptr)mVU_minvals); + SSE_ORPS_XMM_to_XMM (reg, regT1); break; default: SSE_MOVAPS_XMM_to_XMM(regT1, reg); SSE_ANDPS_M128_to_XMM(regT1, (uptr)mVU_signbit); - SSE_MINPS_M128_to_XMM(reg, (uptr)mVU_maxvals); - SSE_MAXPS_M128_to_XMM(reg, (uptr)mVU_minvals); - SSE_ORPS_XMM_to_XMM(reg, regT1); + SSE_MINPS_M128_to_XMM(reg, (uptr)mVU_maxvals); + SSE_MAXPS_M128_to_XMM(reg, (uptr)mVU_minvals); + SSE_ORPS_XMM_to_XMM (reg, regT1); break; } } diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index 4d93e77f1a..bc7e56cf86 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -148,6 +148,7 @@ void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, co opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } + opCase2 { if (opType == 2) { mVUclamp1(Fs, -1, _X_Y_Z_W); } } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) SSE_SS[opType](mVU, Fs, Ft, -1, -1); else SSE_PS[opType](mVU, Fs, Ft, -1, -1); @@ -186,6 +187,7 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* op if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } + opCase2 { if (opType == 2) { mVUclamp1(Fs, -1, _X_Y_Z_W); } } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) SSE_SS[2](mVU, Fs, Ft, -1, -1); else SSE_PS[2](mVU, Fs, Ft, -1, -1); @@ -230,6 +232,7 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, const char* opName) { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } + opCase2 { mVUclamp1(Fs, -1, _X_Y_Z_W); } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) { SSE_SS[2](mVU, Fs, Ft, -1, -1); SSE_SS[0](mVU, Fs, ACC, -1, -1); } else { SSE_PS[2](mVU, Fs, Ft, -1, -1); SSE_PS[0](mVU, Fs, ACC, -1, -1); } From e768150a4b13991ef72a866afc354f4a140f03c7 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 25 Jul 2009 03:22:40 +0000 Subject: [PATCH 11/22] Quick fix for r1566. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1569 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD/IsoFStools.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcsx2/CDVD/IsoFStools.cpp b/pcsx2/CDVD/IsoFStools.cpp index 8282379782..fee2370e96 100644 --- a/pcsx2/CDVD/IsoFStools.cpp +++ b/pcsx2/CDVD/IsoFStools.cpp @@ -140,7 +140,8 @@ void TocEntryCopy(TocEntry* tocEntry, const dirTocEntry* internalTocEntry){ // Check if a TOC Entry matches our extension list int TocEntryCompare(char* filename, char* extensions){ static char ext_list[129]; - char* token, ext_point; + char* token; + char* ext_point; strncpy(ext_list,extensions,128); ext_list[128]=0; From c595eab03695ed34fa3633d80a293a260b9c61d5 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Sun, 26 Jul 2009 05:54:30 +0000 Subject: [PATCH 12/22] microVU: more regAlloc work... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1570 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_Alloc.inl | 34 +-- pcsx2/x86/microVU_Compile.inl | 56 ++-- pcsx2/x86/microVU_Execute.inl | 4 - pcsx2/x86/microVU_Flags.inl | 6 +- pcsx2/x86/microVU_IR.h | 3 +- pcsx2/x86/microVU_Lower.inl | 535 ++++++++++++++++++++-------------- pcsx2/x86/microVU_Misc.h | 14 +- pcsx2/x86/microVU_Misc.inl | 2 +- 8 files changed, 357 insertions(+), 297 deletions(-) diff --git a/pcsx2/x86/microVU_Alloc.inl b/pcsx2/x86/microVU_Alloc.inl index 00a1a0cf65..d929e00126 100644 --- a/pcsx2/x86/microVU_Alloc.inl +++ b/pcsx2/x86/microVU_Alloc.inl @@ -119,7 +119,7 @@ microVUt(void) mVUallocVIb(mV, int GPRreg, int _reg_) { #define getIreg(reg, modXYZW) { \ SSE_MOVSS_M32_to_XMM(reg, (uptr)&mVU->regs->VI[REG_I].UL); \ - if (CHECK_VU_EXTRA_OVERFLOW) mVUclamp2(reg, xmmT2, 8); \ + if (CHECK_VU_EXTRA_OVERFLOW) mVUclamp2(reg, -1, 8); \ if (!((_XYZW_SS && modXYZW) || (_X_Y_Z_W == 8))) { mVUunpack_xyzw(reg, reg, 0); } \ } @@ -137,38 +137,6 @@ microVUt(void) mVUallocVIb(mV, int GPRreg, int _reg_) { // Lower Instruction Allocator Helpers //------------------------------------------------------------------ -#define getReg(reg, _reg_) { \ - mVUloadReg(reg, (uptr)&mVU->regs->VF[_reg_].UL[0], _X_Y_Z_W); \ - if (CHECK_VU_EXTRA_OVERFLOW) mVUclamp2(reg, xmmT2, _X_Y_Z_W); \ -} - -#define getZero(reg) { \ - if (_W) { mVUloadReg(reg, (uptr)&mVU->regs->VF[0].UL[0], _X_Y_Z_W); } \ - else { SSE_XORPS_XMM_to_XMM(reg, reg); } \ -} - -#define getReg6(reg, _reg_) { \ - if (!_reg_) { getZero(reg); } \ - else { getReg(reg, _reg_); } \ -} - -#define getReg5(reg, _reg_, _fxf_) { \ - if (!_reg_) { \ - if (_fxf_ < 3) { SSE_XORPS_XMM_to_XMM(reg, reg); } \ - else { mVUloadReg(reg, (uptr)&mVU->regs->VF[_reg_].UL[0], 1); } \ - } \ - else { \ - mVUloadReg(reg, (uptr)&mVU->regs->VF[_reg_].UL[0], (1 << (3 - _fxf_))); \ - if (CHECK_VU_EXTRA_OVERFLOW) mVUclamp2(reg, xmmT2, (1 << (3 - _fxf_))); \ - } \ -} - -// Doesn't Clamp -#define getReg7(reg, _reg_) { \ - if (!_reg_) { getZero(reg); } \ - else { mVUloadReg(reg, (uptr)&mVU->regs->VF[_reg_].UL[0], _X_Y_Z_W); } \ -} - // VF to GPR #define getReg8(GPRreg, _reg_, _fxf_) { \ if (!_reg_ && (_fxf_ < 3)) { XOR32RtoR(GPRreg, GPRreg); } \ diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index 46b43b95f9..ed62120809 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -31,30 +31,6 @@ } \ } -#define doBackupVF1() { \ - if (mVUinfo.backupVF && !mVUlow.noWriteVF) { \ - DevCon::Status("microVU%d: Backing Up VF Reg [%04x]", params getIndex, xPC); \ - SSE_MOVAPS_M128_to_XMM(xmmT1, (uptr)&mVU->regs->VF[mVUlow.VF_write.reg].UL[0]); \ - SSE_MOVAPS_XMM_to_M128((uptr)mVU->xmmVFb, xmmT1); \ - } \ -} - -#define doBackupVF2() { \ - if (mVUinfo.backupVF && !mVUlow.noWriteVF) { \ - SSE_MOVAPS_M128_to_XMM(xmmT1, (uptr)mVU->xmmVFb); \ - SSE_MOVAPS_M128_to_XMM(xmmT2, (uptr)&mVU->regs->VF[mVUlow.VF_write.reg].UL[0]); \ - SSE_MOVAPS_XMM_to_M128((uptr)&mVU->regs->VF[mVUlow.VF_write.reg].UL[0], xmmT1); \ - SSE_MOVAPS_XMM_to_M128((uptr)mVU->xmmVFb, xmmT2); \ - } \ -} - -#define doBackupVF3() { \ - if (mVUinfo.backupVF && !mVUlow.noWriteVF) { \ - SSE_MOVAPS_M128_to_XMM(xmmT1, (uptr)mVU->xmmVFb); \ - SSE_MOVAPS_XMM_to_M128((uptr)&mVU->regs->VF[mVUlow.VF_write.reg].UL[0], xmmT1); \ - } \ -} - #define startLoop() { \ mVUdebug1(); \ memset(&mVUinfo, 0, sizeof(mVUinfo)); \ @@ -68,7 +44,6 @@ #define incQ() { mVU->q = (mVU->q+1) & 1; } #define doUpperOp() { mVUopU(mVU, 1); mVUdivSet(mVU); } #define doLowerOp() { incPC(-1); mVUopL(mVU, 1); incPC(1); } -#define doSwapOp() { doBackupVF1(); mVUopL(mVU, 1); doBackupVF2(); incPC(1); doUpperOp(); doBackupVF3(); } #define doIbit() { if (mVUup.iBit) { incPC(-1); MOV32ItoM((uptr)&mVU->regs->VI[REG_I].UL, curI); incPC(1); } } #define blockCreate(addr) { if (!mVUblocks[addr]) mVUblocks[addr] = new microBlockManager(); } @@ -76,6 +51,29 @@ // Helper Functions //------------------------------------------------------------------ +microVUt(void) doSwapOp(mV) { + if (mVUinfo.backupVF && !mVUlow.noWriteVF) { + DevCon::Status("microVU%d: Backing Up VF Reg [%04x]", params getIndex, xPC); + int t1 = mVU->regAlloc->allocReg(mVUlow.VF_write.reg); + int t2 = mVU->regAlloc->allocReg(); + SSE_MOVAPS_XMM_to_XMM(t2, t1); + mVU->regAlloc->clearNeeded(t1); + mVUopL(mVU, 1); + t1 = mVU->regAlloc->allocReg(mVUlow.VF_write.reg, mVUlow.VF_write.reg, 0xf, 0); + SSE_XORPS_XMM_to_XMM(t2, t1); + SSE_XORPS_XMM_to_XMM(t1, t2); + SSE_XORPS_XMM_to_XMM(t2, t1); + mVU->regAlloc->clearNeeded(t1); + incPC(1); + doUpperOp(); + t1 = mVU->regAlloc->allocReg(-1, mVUlow.VF_write.reg, 0xf); + SSE_MOVAPS_XMM_to_XMM(t1, t2); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->clearNeeded(t2); + } + else { mVUopL(mVU, 1); incPC(1); doUpperOp(); } +} + // Used by mVUsetupRange microVUt(void) mVUcheckIsSame(mV) { @@ -169,14 +167,14 @@ microVUt(void) mVUoptimizePipeState(mV) { microVUt(void) mVUsetupBranch(mV, int* xStatus, int* xMac, int* xClip, int xCycles) { mVUprint("mVUsetupBranch"); + // Flush Allocated Regs + mVU->regAlloc->flushAll(); + // Shuffle Flag Instances mVUsetupFlags(mVU, xStatus, xMac, xClip, xCycles); // Shuffle P/Q regs since every block starts at instance #0 if (mVU->p || mVU->q) { SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, shufflePQ); } - - // Flush Allocated Regs - mVU->regAlloc->flushAll(); } microVUt(void) mVUincCycles(mV, int x) { @@ -435,7 +433,7 @@ microVUr(void*) mVUcompile(microVU* mVU, u32 startPC, uptr pState) { if (mVUup.mBit) { OR32ItoM((uptr)&mVU->regs->flags, VUFLAG_MFLAGSET); } if (mVUlow.isNOP) { incPC(1); doUpperOp(); doIbit(); } else if (!mVUinfo.swapOps) { incPC(1); doUpperOp(); doLowerOp(); } - else { doSwapOp(); } + else { doSwapOp(mVU); } if (mVUinfo.doXGKICK) { mVU_XGKICK_DELAY(mVU, 1); } if (!mVUinfo.isBdelay) { incPC(1); } diff --git a/pcsx2/x86/microVU_Execute.inl b/pcsx2/x86/microVU_Execute.inl index bfb2586174..673d9ce10c 100644 --- a/pcsx2/x86/microVU_Execute.inl +++ b/pcsx2/x86/microVU_Execute.inl @@ -68,7 +68,6 @@ void mVUdispatcherA(mV) { SSE_SHUFPS_XMM_to_XMM (xmmT1, xmmT1, 0); SSE_MOVAPS_XMM_to_M128((uptr)mVU->clipFlag, xmmT1); - //SSE_MOVAPS_M128_to_XMM(xmmACC, (uptr)&mVU->regs->ACC.UL[0]); SSE_MOVAPS_M128_to_XMM(xmmT1, (uptr)&mVU->regs->VI[REG_P].UL); SSE_MOVAPS_M128_to_XMM(xmmPQ, (uptr)&mVU->regs->VI[REG_Q].UL); SSE_SHUFPS_XMM_to_XMM(xmmPQ, xmmT1, 0); // wzyx = PPQQ @@ -84,9 +83,6 @@ void mVUdispatcherB(mV) { // Load EE's MXCSR state SSE_LDMXCSR((uptr)&g_sseMXCSR); - // Save Regs (Other Regs Saved in mVUcompile) - //SSE_MOVAPS_XMM_to_M128((uptr)&mVU->regs->ACC.UL[0], xmmACC); - // __fastcall = The first two DWORD or smaller arguments are passed in ECX and EDX registers; all other arguments are passed right to left. if (!isVU1) { CALLFunc((uptr)mVUcleanUpVU0); } else { CALLFunc((uptr)mVUcleanUpVU1); } diff --git a/pcsx2/x86/microVU_Flags.inl b/pcsx2/x86/microVU_Flags.inl index 203f0a14f4..8ad213e870 100644 --- a/pcsx2/x86/microVU_Flags.inl +++ b/pcsx2/x86/microVU_Flags.inl @@ -215,9 +215,9 @@ microVUt(void) mVUsetupFlags(mV, int* xStatus, int* xMac, int* xClip, int cycles if (__Clip) { int bClip[4]; sortFlag(xClip, bClip, cycles); - SSE_MOVAPS_M128_to_XMM(xmmT1, (uptr)mVU->clipFlag); - SSE_SHUFPS_XMM_to_XMM (xmmT1, xmmT1, shuffleClip); - SSE_MOVAPS_XMM_to_M128((uptr)mVU->clipFlag, xmmT1); + SSE_MOVAPS_M128_to_XMM(xmmT2, (uptr)mVU->clipFlag); + SSE_SHUFPS_XMM_to_XMM (xmmT2, xmmT2, shuffleClip); + SSE_MOVAPS_XMM_to_M128((uptr)mVU->clipFlag, xmmT2); } } diff --git a/pcsx2/x86/microVU_IR.h b/pcsx2/x86/microVU_IR.h index 7e0ba4e85e..fde98f75c6 100644 --- a/pcsx2/x86/microVU_IR.h +++ b/pcsx2/x86/microVU_IR.h @@ -211,9 +211,10 @@ public: } counter = 0; } - void flushAll() { + void flushAll(bool clearState = 1) { for (int i = 0; i < xmmTotal; i++) { writeBackReg(i); + if (clearState) clearReg(i); } } void clearReg(int reg) { diff --git a/pcsx2/x86/microVU_Lower.inl b/pcsx2/x86/microVU_Lower.inl index 4ca15ed320..e74d92f004 100644 --- a/pcsx2/x86/microVU_Lower.inl +++ b/pcsx2/x86/microVU_Lower.inl @@ -46,13 +46,15 @@ mVUop(mVU_DIV) { pass1 { mVUanalyzeFDIV(mVU, _Fs_, _Fsf_, _Ft_, _Ftf_, 7); } pass2 { u8 *ajmp, *bjmp, *cjmp, *djmp; - getReg5(xmmFs, _Fs_, _Fsf_); - getReg5(xmmFt, _Ft_, _Ftf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + int Ft = mVU->regAlloc->allocReg(_Ft_, 0, (1 << (3 - _Ftf_))); + int t1 = mVU->regAlloc->allocReg(); - testZero(xmmFt, xmmT1, gprT1); // Test if Ft is zero + testZero(Ft, t1, gprT1); // Test if Ft is zero cjmp = JZ8(0); // Skip if not zero - testZero(xmmFs, xmmT1, gprT1); // Test if Fs is zero + testZero(Fs, t1, gprT1); // Test if Fs is zero ajmp = JZ8(0); MOV32ItoM((uptr)&mVU->divFlag, divI); // Set invalid flag (0/0) bjmp = JMP8(0); @@ -60,20 +62,25 @@ mVUop(mVU_DIV) { MOV32ItoM((uptr)&mVU->divFlag, divD); // Zero divide (only when not 0/0) x86SetJ8(bjmp); - SSE_XORPS_XMM_to_XMM (xmmFs, xmmFt); - SSE_ANDPS_M128_to_XMM(xmmFs, (uptr)mVU_signbit); - SSE_ORPS_M128_to_XMM (xmmFs, (uptr)mVU_maxvals); // If division by zero, then xmmFs = +/- fmax + SSE_XORPS_XMM_to_XMM (Fs, Ft); + SSE_ANDPS_M128_to_XMM(Fs, (uptr)mVU_signbit); + SSE_ORPS_M128_to_XMM (Fs, (uptr)mVU_maxvals); // If division by zero, then xmmFs = +/- fmax djmp = JMP8(0); x86SetJ8(cjmp); MOV32ItoM((uptr)&mVU->divFlag, 0); // Clear I/D flags - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmFt); - mVUclamp1(xmmFs, xmmFt, 8); + SSE_DIVSS_XMM_to_XMM(Fs, Ft); + mVUclamp1(Fs, t1, 8); x86SetJ8(djmp); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + SSE_MOVSS_XMM_to_XMM(xmmPQ, Fs); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); + + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("DIV Q, vf%02d%s, vf%02d%s", _Fs_, _Fsf_String, _Ft_, _Ftf_String); } } @@ -82,16 +89,20 @@ mVUop(mVU_SQRT) { pass1 { mVUanalyzeFDIV(mVU, 0, 0, _Ft_, _Ftf_, 7); } pass2 { u8 *ajmp; - getReg5(xmmFt, _Ft_, _Ftf_); + mVU->regAlloc->reset(); // Reset for Testing + int Ft = mVU->regAlloc->allocReg(_Ft_, 0, (1 << (3 - _Ftf_))); MOV32ItoM((uptr)&mVU->divFlag, 0); // Clear I/D flags - testNeg(xmmFt, gprT1, ajmp); // Check for negative sqrt + testNeg(Ft, gprT1, ajmp); // Check for negative sqrt - if (CHECK_VU_OVERFLOW) SSE_MINSS_M32_to_XMM(xmmFt, (uptr)mVU_maxvals); // Clamp infinities (only need to do positive clamp since xmmFt is positive) - SSE_SQRTSS_XMM_to_XMM(xmmFt, xmmFt); + if (CHECK_VU_OVERFLOW) SSE_MINSS_M32_to_XMM(Ft, (uptr)mVU_maxvals); // Clamp infinities (only need to do positive clamp since xmmFt is positive) + SSE_SQRTSS_XMM_to_XMM(Ft, Ft); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFt); + SSE_MOVSS_XMM_to_XMM(xmmPQ, Ft); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); + + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQRT Q, vf%02d%s", _Ft_, _Ftf_String); } } @@ -100,17 +111,19 @@ mVUop(mVU_RSQRT) { pass1 { mVUanalyzeFDIV(mVU, _Fs_, _Fsf_, _Ft_, _Ftf_, 13); } pass2 { u8 *ajmp, *bjmp, *cjmp, *djmp; - getReg5(xmmFs, _Fs_, _Fsf_); - getReg5(xmmFt, _Ft_, _Ftf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + int Ft = mVU->regAlloc->allocReg(_Ft_, 0, (1 << (3 - _Ftf_))); + int t1 = mVU->regAlloc->allocReg(); MOV32ItoM((uptr)&mVU->divFlag, 0); // Clear I/D flags - testNeg(xmmFt, gprT1, ajmp); // Check for negative sqrt + testNeg(Ft, gprT1, ajmp); // Check for negative sqrt - SSE_SQRTSS_XMM_to_XMM(xmmFt, xmmFt); - testZero(xmmFt, xmmT1, gprT1); // Test if Ft is zero + SSE_SQRTSS_XMM_to_XMM(Ft, Ft); + testZero(Ft, t1, gprT1); // Test if Ft is zero ajmp = JZ8(0); // Skip if not zero - testZero(xmmFs, xmmT1, gprT1); // Test if Fs is zero + testZero(Fs, t1, gprT1); // Test if Fs is zero bjmp = JZ8(0); // Skip if none are MOV32ItoM((uptr)&mVU->divFlag, divI); // Set invalid flag (0/0) cjmp = JMP8(0); @@ -118,18 +131,23 @@ mVUop(mVU_RSQRT) { MOV32ItoM((uptr)&mVU->divFlag, divD); // Zero divide flag (only when not 0/0) x86SetJ8(cjmp); - SSE_ANDPS_M128_to_XMM(xmmFs, (uptr)mVU_signbit); - SSE_ORPS_M128_to_XMM (xmmFs, (uptr)mVU_maxvals); // xmmFs = +/-Max + SSE_ANDPS_M128_to_XMM(Fs, (uptr)mVU_signbit); + SSE_ORPS_M128_to_XMM (Fs, (uptr)mVU_maxvals); // xmmFs = +/-Max djmp = JMP8(0); x86SetJ8(ajmp); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmFt); - mVUclamp1(xmmFs, xmmFt, 8); + SSE_DIVSS_XMM_to_XMM(Fs, Ft); + mVUclamp1(Fs, t1, 8); x86SetJ8(djmp); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + SSE_MOVSS_XMM_to_XMM(xmmPQ, Fs); if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); + + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("RSQRT Q, vf%02d%s, vf%02d%s", _Fs_, _Fsf_String, _Ft_, _Ftf_String); } } @@ -138,21 +156,19 @@ mVUop(mVU_RSQRT) { // EATAN/EEXP/ELENG/ERCPR/ERLENG/ERSADD/ERSQRT/ESADD/ESIN/ESQRT/ESUM //------------------------------------------------------------------ -#define EATANhelper(addr) { \ - SSE_MULSS_XMM_to_XMM(xmmT1, xmmFs); \ - SSE_MULSS_XMM_to_XMM(xmmT1, xmmFs); \ - SSE_MOVAPS_XMM_to_XMM(xmmFt, xmmT1); \ - SSE_MULSS_M32_to_XMM(xmmFt, (uptr)addr); \ - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmFt); \ +#define EATANhelper(addr) { \ + SSE_MULSS_XMM_to_XMM (t2, Fs); \ + SSE_MULSS_XMM_to_XMM (t2, Fs); \ + SSE_MOVAPS_XMM_to_XMM(t1, t2); \ + SSE_MULSS_M32_to_XMM (t1, (uptr)addr); \ + SSE_ADDSS_XMM_to_XMM (PQ, t1); \ } -microVUt(void) mVU_EATAN_(mV) { - - // ToDo: Can Be Optimized Further? (takes approximately (~115 cycles + mem access time) on a c2d) - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); - SSE_MULSS_M32_to_XMM(xmmPQ, (uptr)mVU_T1); - SSE_MOVAPS_XMM_to_XMM(xmmT1, xmmFs); - +// ToDo: Can Be Optimized Further? (takes approximately (~115 cycles + mem access time) on a c2d) +microVUt(void) mVU_EATAN_(mV, int PQ, int Fs, int t1, int t2) { + SSE_MOVSS_XMM_to_XMM (PQ, Fs); + SSE_MULSS_M32_to_XMM (PQ, (uptr)mVU_T1); + SSE_MOVAPS_XMM_to_XMM(t2, Fs); EATANhelper(mVU_T2); EATANhelper(mVU_T3); EATANhelper(mVU_T4); @@ -160,23 +176,26 @@ microVUt(void) mVU_EATAN_(mV) { EATANhelper(mVU_T6); EATANhelper(mVU_T7); EATANhelper(mVU_T8); - - SSE_ADDSS_M32_to_XMM(xmmPQ, (uptr)mVU_Pi4); - SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); + SSE_ADDSS_M32_to_XMM (PQ, (uptr)mVU_Pi4); + SSE2_PSHUFD_XMM_to_XMM(PQ, PQ, mVUinfo.writeP ? 0x27 : 0xC6); } mVUop(mVU_EATAN) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 54); } pass2 { - getReg5(xmmFs, _Fs_, _Fsf_); + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + int t1 = mVU->regAlloc->allocReg(); + int t2 = mVU->regAlloc->allocReg(); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); - SSE_SUBSS_M32_to_XMM(xmmFs, (uptr)mVU_one); - SSE_ADDSS_M32_to_XMM(xmmPQ, (uptr)mVU_one); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmPQ); - - mVU_EATAN_(mVU); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); + SSE_SUBSS_M32_to_XMM (Fs, (uptr)mVU_one); + SSE_ADDSS_M32_to_XMM (xmmPQ, (uptr)mVU_one); + SSE_DIVSS_XMM_to_XMM (Fs, xmmPQ); + mVU_EATAN_(mVU, xmmPQ, Fs, t1, t2); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->clearNeeded(t2); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EATAN P"); } } @@ -184,16 +203,21 @@ mVUop(mVU_EATAN) { mVUop(mVU_EATANxy) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 54); } pass2 { - getReg6(xmmFt, _Fs_); - SSE2_PSHUFD_XMM_to_XMM(xmmFs, xmmFt, 0x01); + mVU->regAlloc->reset(); // Reset for Testing + int t1 = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); + int Fs = mVU->regAlloc->allocReg(); + int t2 = mVU->regAlloc->allocReg(); + SSE2_PSHUFD_XMM_to_XMM(Fs, t1, 0x01); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); - SSE_SUBSS_XMM_to_XMM(xmmFs, xmmFt); // y-x, not y-1? >< - SSE_ADDSS_XMM_to_XMM(xmmFt, xmmPQ); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmFt); - - mVU_EATAN_(mVU); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); + SSE_SUBSS_XMM_to_XMM (Fs, t1); // y-x, not y-1? >< + SSE_ADDSS_XMM_to_XMM (t1, xmmPQ); + SSE_DIVSS_XMM_to_XMM (Fs, t1); + mVU_EATAN_(mVU, xmmPQ, Fs, t1, t2); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->clearNeeded(t2); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EATANxy P"); } } @@ -201,83 +225,95 @@ mVUop(mVU_EATANxy) { mVUop(mVU_EATANxz) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 54); } pass2 { - getReg6(xmmFt, _Fs_); - SSE2_PSHUFD_XMM_to_XMM(xmmFs, xmmFt, 0x02); + mVU->regAlloc->reset(); // Reset for Testing + int t1 = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); + int Fs = mVU->regAlloc->allocReg(); + int t2 = mVU->regAlloc->allocReg(); + SSE2_PSHUFD_XMM_to_XMM(Fs, t1, 0x02); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); - SSE_SUBSS_XMM_to_XMM(xmmFs, xmmFt); - SSE_ADDSS_XMM_to_XMM(xmmFt, xmmPQ); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmFt); - - mVU_EATAN_(mVU); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); + SSE_SUBSS_XMM_to_XMM (Fs, t1); + SSE_ADDSS_XMM_to_XMM (t1, xmmPQ); + SSE_DIVSS_XMM_to_XMM (Fs, t1); + mVU_EATAN_(mVU, xmmPQ, Fs, t1, t2); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->clearNeeded(t2); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EATANxz P"); } } -#define eexpHelper(addr) { \ - SSE_MULSS_XMM_to_XMM(xmmT1, xmmFs); \ - SSE_MOVAPS_XMM_to_XMM(xmmFt, xmmT1); \ - SSE_MULSS_M32_to_XMM(xmmFt, (uptr)addr); \ - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmFt); \ +#define eexpHelper(addr) { \ + SSE_MULSS_XMM_to_XMM (t2, Fs); \ + SSE_MOVAPS_XMM_to_XMM(t1, t2); \ + SSE_MULSS_M32_to_XMM (t1, (uptr)addr); \ + SSE_ADDSS_XMM_to_XMM (xmmPQ, t1); \ } mVUop(mVU_EEXP) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 44); } pass2 { - getReg5(xmmFs, _Fs_, _Fsf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + int t1 = mVU->regAlloc->allocReg(); + int t2 = mVU->regAlloc->allocReg(); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); - SSE_MULSS_M32_to_XMM(xmmPQ, (uptr)mVU_E1); - SSE_ADDSS_M32_to_XMM(xmmPQ, (uptr)mVU_one); - - SSE_MOVAPS_XMM_to_XMM(xmmFt, xmmFs); - SSE_MULSS_XMM_to_XMM(xmmFt, xmmFs); - SSE_MOVAPS_XMM_to_XMM(xmmT1, xmmFt); - SSE_MULSS_M32_to_XMM(xmmFt, (uptr)mVU_E2); - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmFt); - + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); + SSE_MULSS_M32_to_XMM (xmmPQ, (uptr)mVU_E1); + SSE_ADDSS_M32_to_XMM (xmmPQ, (uptr)mVU_one); + SSE_MOVAPS_XMM_to_XMM (t1, Fs); + SSE_MULSS_XMM_to_XMM (t1, Fs); + SSE_MOVAPS_XMM_to_XMM (t2, t1); + SSE_MULSS_M32_to_XMM (t1, (uptr)mVU_E2); + SSE_ADDSS_XMM_to_XMM (xmmPQ, t1); eexpHelper(mVU_E3); eexpHelper(mVU_E4); eexpHelper(mVU_E5); - - SSE_MULSS_XMM_to_XMM(xmmT1, xmmFs); - SSE_MULSS_M32_to_XMM(xmmT1, (uptr)mVU_E6); - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmT1); - SSE_MULSS_XMM_to_XMM(xmmPQ, xmmPQ); - SSE_MULSS_XMM_to_XMM(xmmPQ, xmmPQ); - SSE_MOVSS_M32_to_XMM(xmmT1, (uptr)mVU_one); - SSE_DIVSS_XMM_to_XMM(xmmT1, xmmPQ); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmT1); + SSE_MULSS_XMM_to_XMM (t2, Fs); + SSE_MULSS_M32_to_XMM (t2, (uptr)mVU_E6); + SSE_ADDSS_XMM_to_XMM (xmmPQ, t2); + SSE_MULSS_XMM_to_XMM (xmmPQ, xmmPQ); + SSE_MULSS_XMM_to_XMM (xmmPQ, xmmPQ); + SSE_MOVSS_M32_to_XMM (t2, (uptr)mVU_one); + SSE_DIVSS_XMM_to_XMM (t2, xmmPQ); + SSE_MOVSS_XMM_to_XMM (xmmPQ, t2); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->clearNeeded(t2); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EEXP P"); } } -microVUt(void) mVU_sumXYZ() { - // xmmPQ.x = x ^ 2 + y ^ 2 + z ^ 2 +// sumXYZ(): PQ.x = x ^ 2 + y ^ 2 + z ^ 2 +microVUt(void) mVU_sumXYZ(int PQ, int Fs) { if( cpucaps.hasStreamingSIMD4Extensions ) { - SSE4_DPPS_XMM_to_XMM(xmmFs, xmmFs, 0x71); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + SSE4_DPPS_XMM_to_XMM(Fs, Fs, 0x71); + SSE_MOVSS_XMM_to_XMM(PQ, Fs); } else { - SSE_MULPS_XMM_to_XMM(xmmFs, xmmFs); // wzyx ^ 2 - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); // x ^ 2 - SSE2_PSHUFD_XMM_to_XMM(xmmFs, xmmFs, 0xe1); // wzyx -> wzxy - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmFs); // x ^ 2 + y ^ 2 - SSE2_PSHUFD_XMM_to_XMM(xmmFs, xmmFs, 0xD2); // wzxy -> wxyz - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmFs); // x ^ 2 + y ^ 2 + z ^ 2 + SSE_MULPS_XMM_to_XMM (Fs, Fs); // wzyx ^ 2 + SSE_MOVSS_XMM_to_XMM (PQ, Fs); // x ^ 2 + SSE2_PSHUFD_XMM_to_XMM(Fs, Fs, 0xe1); // wzyx -> wzxy + SSE_ADDSS_XMM_to_XMM (PQ, Fs); // x ^ 2 + y ^ 2 + SSE2_PSHUFD_XMM_to_XMM(Fs, Fs, 0xD2); // wzxy -> wxyz + SSE_ADDSS_XMM_to_XMM (PQ, Fs); // x ^ 2 + y ^ 2 + z ^ 2 } } mVUop(mVU_ELENG) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 18); } pass2 { - getReg6(xmmFs, _Fs_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - mVU_sumXYZ(); - SSE_SQRTSS_XMM_to_XMM(xmmPQ, xmmPQ); + mVU_sumXYZ(xmmPQ, Fs); + SSE_SQRTSS_XMM_to_XMM (xmmPQ, xmmPQ); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ELENG P"); } } @@ -285,13 +321,16 @@ mVUop(mVU_ELENG) { mVUop(mVU_ERCPR) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 12); } pass2 { - getReg5(xmmFs, _Fs_, _Fsf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); - SSE_MOVSS_M32_to_XMM(xmmFs, (uptr)mVU_one); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmPQ); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); + SSE_MOVSS_M32_to_XMM (Fs, (uptr)mVU_one); + SSE_DIVSS_XMM_to_XMM (Fs, xmmPQ); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERCPR P"); } } @@ -299,14 +338,17 @@ mVUop(mVU_ERCPR) { mVUop(mVU_ERLENG) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 24); } pass2 { - getReg6(xmmFs, _Fs_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - mVU_sumXYZ(); - SSE_SQRTSS_XMM_to_XMM(xmmPQ, xmmPQ); - SSE_MOVSS_M32_to_XMM(xmmFs, (uptr)mVU_one); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmPQ); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + mVU_sumXYZ(xmmPQ, Fs); + SSE_SQRTSS_XMM_to_XMM (xmmPQ, xmmPQ); + SSE_MOVSS_M32_to_XMM (Fs, (uptr)mVU_one); + SSE_DIVSS_XMM_to_XMM (Fs, xmmPQ); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERLENG P"); } } @@ -314,14 +356,16 @@ mVUop(mVU_ERLENG) { mVUop(mVU_ERSADD) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 18); } pass2 { - getReg6(xmmFs, _Fs_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - mVU_sumXYZ(); - //SSE_RCPSS_XMM_to_XMM(xmmPQ, xmmPQ); // Lower Precision is bad? - SSE_MOVSS_M32_to_XMM(xmmFs, (uptr)mVU_one); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmPQ); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + mVU_sumXYZ(xmmPQ, Fs); + SSE_MOVSS_M32_to_XMM (Fs, (uptr)mVU_one); + SSE_DIVSS_XMM_to_XMM (Fs, xmmPQ); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERSADD P"); } } @@ -329,13 +373,16 @@ mVUop(mVU_ERSADD) { mVUop(mVU_ERSQRT) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 18); } pass2 { - getReg5(xmmFs, _Fs_, _Fsf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - SSE_SQRTSS_XMM_to_XMM(xmmPQ, xmmFs); - SSE_MOVSS_M32_to_XMM(xmmFs, (uptr)mVU_one); - SSE_DIVSS_XMM_to_XMM(xmmFs, xmmPQ); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + SSE_SQRTSS_XMM_to_XMM (xmmPQ, Fs); + SSE_MOVSS_M32_to_XMM (Fs, (uptr)mVU_one); + SSE_DIVSS_XMM_to_XMM (Fs, xmmPQ); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERSQRT P"); } } @@ -343,43 +390,50 @@ mVUop(mVU_ERSQRT) { mVUop(mVU_ESADD) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 11); } pass2 { - getReg6(xmmFs, _Fs_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - mVU_sumXYZ(); + mVU_sumXYZ(xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESADD P"); } } -#define esinHelper(addr) { \ - SSE_MULSS_XMM_to_XMM(xmmT1, xmmFt); \ - SSE_MOVAPS_XMM_to_XMM(xmmFs, xmmT1); \ - SSE_MULSS_M32_to_XMM(xmmFs, (uptr)addr); \ - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmFs); \ +#define esinHelper(addr) { \ + SSE_MULSS_XMM_to_XMM (t2, t1); \ + SSE_MOVAPS_XMM_to_XMM(Fs, t2); \ + SSE_MULSS_M32_to_XMM (Fs, (uptr)addr); \ + SSE_ADDSS_XMM_to_XMM (xmmPQ, Fs); \ } mVUop(mVU_ESIN) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 29); } pass2 { - getReg5(xmmFs, _Fs_, _Fsf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + int t1 = mVU->regAlloc->allocReg(); + int t2 = mVU->regAlloc->allocReg(); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); - //SSE_MULSS_M32_to_XMM(xmmPQ, (uptr)mVU_one); // Multiplying by 1 is redundant? - SSE_MOVAPS_XMM_to_XMM(xmmFt, xmmFs); - SSE_MULSS_XMM_to_XMM(xmmFs, xmmFt); - SSE_MOVAPS_XMM_to_XMM(xmmT1, xmmFs); - SSE_MULSS_XMM_to_XMM(xmmFs, xmmFt); - SSE_MOVAPS_XMM_to_XMM(xmmFt, xmmFs); - SSE_MULSS_M32_to_XMM(xmmFs, (uptr)mVU_S2); - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmFs); - + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); + SSE_MOVAPS_XMM_to_XMM (t1, Fs); + SSE_MULSS_XMM_to_XMM (Fs, t1); + SSE_MOVAPS_XMM_to_XMM (t2, Fs); + SSE_MULSS_XMM_to_XMM (Fs, t1); + SSE_MOVAPS_XMM_to_XMM (t1, Fs); + SSE_MULSS_M32_to_XMM (Fs, (uptr)mVU_S2); + SSE_ADDSS_XMM_to_XMM (xmmPQ, Fs); esinHelper(mVU_S3); esinHelper(mVU_S4); - - SSE_MULSS_XMM_to_XMM(xmmT1, xmmFt); - SSE_MULSS_M32_to_XMM(xmmT1, (uptr)mVU_S5); - SSE_ADDSS_XMM_to_XMM(xmmPQ, xmmT1); + SSE_MULSS_XMM_to_XMM (t2, t1); + SSE_MULSS_M32_to_XMM (t2, (uptr)mVU_S5); + SSE_ADDSS_XMM_to_XMM (xmmPQ, t2); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->clearNeeded(t2); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESIN P"); } } @@ -387,10 +441,13 @@ mVUop(mVU_ESIN) { mVUop(mVU_ESQRT) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 12); } pass2 { - getReg5(xmmFs, _Fs_, _Fsf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - SSE_SQRTSS_XMM_to_XMM(xmmPQ, xmmFs); + SSE_SQRTSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESQRT P"); } } @@ -398,14 +455,19 @@ mVUop(mVU_ESQRT) { mVUop(mVU_ESUM) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 12); } pass2 { - getReg6(xmmFs, _Fs_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + int t1 = mVU->regAlloc->allocReg(); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance - SSE2_PSHUFD_XMM_to_XMM(xmmFt, xmmFs, 0x1b); - SSE_ADDPS_XMM_to_XMM(xmmFs, xmmFt); - SSE2_PSHUFD_XMM_to_XMM(xmmFt, xmmFs, 0x01); - SSE_ADDSS_XMM_to_XMM(xmmFs, xmmFt); - SSE_MOVSS_XMM_to_XMM(xmmPQ, xmmFs); + SSE2_PSHUFD_XMM_to_XMM(t1, Fs, 0x1b); + SSE_ADDPS_XMM_to_XMM (Fs, t1); + SSE2_PSHUFD_XMM_to_XMM(t1, Fs, 0x01); + SSE_ADDSS_XMM_to_XMM (Fs, t1); + SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->clearNeeded(t1); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESUM P"); } } @@ -691,11 +753,14 @@ mVUop(mVU_ISUBIU) { mVUop(mVU_MFIR) { pass1 { if (!_Ft_) { mVUlow.isNOP = 1; } analyzeVIreg1(_Is_, mVUlow.VI_read[0]); analyzeReg2(_Ft_, mVUlow.VF_write, 1); } pass2 { + mVU->regAlloc->reset(); // Reset for Testing + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); mVUallocVIa(mVU, gprT1, _Is_); MOVSX32R16toR(gprT1, gprT1); - SSE2_MOVD_R_to_XMM(xmmT1, gprT1); - if (!_XYZW_SS) { mVUunpack_xyzw(xmmT1, xmmT1, 0); } - mVUsaveReg(xmmT1, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); + SSE2_MOVD_R_to_XMM(Ft, gprT1); + if (!_XYZW_SS) { mVUunpack_xyzw(Ft, Ft, 0); } + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MFIR.%s vf%02d, vi%02d", _XYZW_String, _Ft_, _Fs_); } } @@ -703,8 +768,11 @@ mVUop(mVU_MFIR) { mVUop(mVU_MFP) { pass1 { mVUanalyzeMFP(mVU, _Ft_); } pass2 { - getPreg(xmmFt); - mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); + mVU->regAlloc->reset(); // Reset for Testing + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); + getPreg(Ft); + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MFP.%s vf%02d, P", _XYZW_String, _Ft_); } } @@ -712,8 +780,10 @@ mVUop(mVU_MFP) { mVUop(mVU_MOVE) { pass1 { mVUanalyzeMOVE(mVU, _Fs_, _Ft_); } pass2 { - mVUloadReg(xmmT1, (uptr)&mVU->regs->VF[_Fs_].UL[0], _X_Y_Z_W); - mVUsaveReg(xmmT1, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MOVE.%s vf%02d, vf%02d", _XYZW_String, _Ft_, _Fs_); } } @@ -721,9 +791,14 @@ mVUop(mVU_MOVE) { mVUop(mVU_MR32) { pass1 { mVUanalyzeMR32(mVU, _Fs_, _Ft_); } pass2 { - mVUloadReg(xmmT1, (uptr)&mVU->regs->VF[_Fs_].UL[0], (_X_Y_Z_W == 8) ? 4 : 15); - if (_X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(xmmT1, xmmT1, 0x39); } - mVUsaveReg(xmmT1, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 0); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); + if (_XYZW_SS) mVUunpack_xyzw(Ft, Fs, (_X ? 1 : (_Y ? 2 : (_Z ? 3 : 0)))); + else SSE2_PSHUFD_XMM_to_XMM(Ft, Fs, 0x39); + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MR32.%s vf%02d, vf%02d", _XYZW_String, _Ft_, _Fs_); } } @@ -731,8 +806,12 @@ mVUop(mVU_MR32) { mVUop(mVU_MTIR) { pass1 { if (!_It_) { mVUlow.isNOP = 1; } analyzeReg5(_Fs_, _Fsf_, mVUlow.VF_read[0]); analyzeVIreg2(_It_, mVUlow.VI_write, 1); } pass2 { - MOVZX32M16toR(gprT1, (uptr)&mVU->regs->VF[_Fs_].UL[_Fsf_]); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + SSE2_MOVD_XMM_to_R(gprT1, Fs); mVUallocVIb(mVU, gprT1, _It_); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MTIR vi%02d, vf%02d%s", _Ft_, _Fs_, _Fsf_String); } } @@ -818,7 +897,7 @@ mVUop(mVU_ISWR) { else { mVUallocVIa(mVU, gprT1, _Is_); mVUallocVIa(mVU, gprT2, _It_); - mVUaddrFix(mVU, gprT1); + mVUaddrFix (mVU, gprT1); if (_X) MOV32RtoRm(gprT1, gprT2, (uptr)mVU->regs->Mem); if (_Y) MOV32RtoRm(gprT1, gprT2, (uptr)mVU->regs->Mem+4); if (_Z) MOV32RtoRm(gprT1, gprT2, (uptr)mVU->regs->Mem+8); @@ -835,17 +914,17 @@ mVUop(mVU_ISWR) { mVUop(mVU_LQ) { pass1 { mVUanalyzeLQ(mVU, _Ft_, _Is_, 0); } pass2 { - if (!_Is_) { - mVUloadReg(xmmFt, (uptr)mVU->regs->Mem + getVUmem(_Imm11_), _X_Y_Z_W); - mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); - } - else { + mVU->regAlloc->reset(); // Reset for Testing + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); + if (_Is_) { mVUallocVIa(mVU, gprT1, _Is_); ADD32ItoR(gprT1, _Imm11_); mVUaddrFix(mVU, gprT1); - mVUloadReg2(xmmFt, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); - mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); + mVUloadReg2(Ft, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); } + else mVUloadReg(Ft, (uptr)mVU->regs->Mem + getVUmem(_Imm11_), _X_Y_Z_W); + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("LQ.%s vf%02d, vi%02d + %d", _XYZW_String, _Ft_, _Fs_, _Imm11_); } } @@ -853,20 +932,24 @@ mVUop(mVU_LQ) { mVUop(mVU_LQD) { pass1 { mVUanalyzeLQ(mVU, _Ft_, _Is_, 1); } pass2 { - if (!_Is_ && !mVUlow.noWriteVF) { - mVUloadReg(xmmFt, (uptr)mVU->regs->Mem, _X_Y_Z_W); - mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); - } - else { + mVU->regAlloc->reset(); // Reset for Testing + if (_Is_) { mVUallocVIa(mVU, gprT1, _Is_); SUB16ItoR(gprT1, 1); mVUallocVIb(mVU, gprT1, _Is_); if (!mVUlow.noWriteVF) { + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); mVUaddrFix(mVU, gprT1); - mVUloadReg2(xmmFt, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); - mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); + mVUloadReg2(Ft, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); + mVU->regAlloc->clearNeeded(Ft); } } + else if (!mVUlow.noWriteVF) { + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); + mVUloadReg(Ft, (uptr)mVU->regs->Mem, _X_Y_Z_W); + mVU->regAlloc->clearNeeded(Ft); + } + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("LQD.%s vf%02d, --vi%02d", _XYZW_String, _Ft_, _Is_); } } @@ -874,21 +957,25 @@ mVUop(mVU_LQD) { mVUop(mVU_LQI) { pass1 { mVUanalyzeLQ(mVU, _Ft_, _Is_, 1); } pass2 { - if (!_Is_ && !mVUlow.noWriteVF) { - mVUloadReg(xmmFt, (uptr)mVU->regs->Mem, _X_Y_Z_W); - mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); - } - else { + mVU->regAlloc->reset(); // Reset for Testing + if (_Is_) { mVUallocVIa(mVU, (!mVUlow.noWriteVF) ? gprT1 : gprT2, _Is_); if (!mVUlow.noWriteVF) { + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); MOV32RtoR(gprT2, gprT1); mVUaddrFix(mVU, gprT1); - mVUloadReg2(xmmFt, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); - mVUsaveReg(xmmFt, (uptr)&mVU->regs->VF[_Ft_].UL[0], _X_Y_Z_W, 1); + mVUloadReg2(Ft, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); + mVU->regAlloc->clearNeeded(Ft); } ADD16ItoR(gprT2, 1); mVUallocVIb(mVU, gprT2, _Is_); } + else if (!mVUlow.noWriteVF) { + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); + mVUloadReg(Ft, (uptr)mVU->regs->Mem, _X_Y_Z_W); + mVU->regAlloc->clearNeeded(Ft); + } + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("LQI.%s vf%02d, vi%02d++", _XYZW_String, _Ft_, _Fs_); } } @@ -900,17 +987,17 @@ mVUop(mVU_LQI) { mVUop(mVU_SQ) { pass1 { mVUanalyzeSQ(mVU, _Fs_, _It_, 0); } pass2 { - if (!_It_) { - getReg7(xmmFs, _Fs_); - mVUsaveReg(xmmFs, (uptr)mVU->regs->Mem + getVUmem(_Imm11_), _X_Y_Z_W, 1); - } - else { + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + if (_It_) { mVUallocVIa(mVU, gprT1, _It_); ADD32ItoR(gprT1, _Imm11_); mVUaddrFix(mVU, gprT1); - getReg7(xmmFs, _Fs_); - mVUsaveReg2(xmmFs, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); + mVUsaveReg2(Fs, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); } + else mVUsaveReg(Fs, (uptr)mVU->regs->Mem + getVUmem(_Imm11_), _X_Y_Z_W, 1); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQ.%s vf%02d, vi%02d + %d", _XYZW_String, _Fs_, _Ft_, _Imm11_); } } @@ -918,18 +1005,18 @@ mVUop(mVU_SQ) { mVUop(mVU_SQD) { pass1 { mVUanalyzeSQ(mVU, _Fs_, _It_, 1); } pass2 { - if (!_It_) { - getReg7(xmmFs, _Fs_); - mVUsaveReg(xmmFs, (uptr)mVU->regs->Mem, _X_Y_Z_W, 1); - } - else { + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + if (_It_) { mVUallocVIa(mVU, gprT1, _It_); SUB16ItoR(gprT1, 1); mVUallocVIb(mVU, gprT1, _It_); mVUaddrFix(mVU, gprT1); - getReg7(xmmFs, _Fs_); - mVUsaveReg2(xmmFs, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); + mVUsaveReg2(Fs, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); } + else mVUsaveReg(Fs, (uptr)mVU->regs->Mem, _X_Y_Z_W, 1); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQD.%s vf%02d, --vi%02d", _XYZW_String, _Fs_, _Ft_); } } @@ -937,19 +1024,19 @@ mVUop(mVU_SQD) { mVUop(mVU_SQI) { pass1 { mVUanalyzeSQ(mVU, _Fs_, _It_, 1); } pass2 { - if (!_It_) { - getReg7(xmmFs, _Fs_); - mVUsaveReg(xmmFs, (uptr)mVU->regs->Mem, _X_Y_Z_W, 1); - } - else { + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + if (_It_) { mVUallocVIa(mVU, gprT1, _It_); MOV32RtoR(gprT2, gprT1); mVUaddrFix(mVU, gprT1); - getReg7(xmmFs, _Fs_); - mVUsaveReg2(xmmFs, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); + mVUsaveReg2(Fs, gprT1, (uptr)mVU->regs->Mem, _X_Y_Z_W); ADD16ItoR(gprT2, 1); - mVUallocVIb(mVU, gprT2, _It_); + mVUallocVIb(mVU, gprT2, _It_); } + else mVUsaveReg(Fs, (uptr)mVU->regs->Mem, _X_Y_Z_W, 1); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQI.%s vf%02d, vi%02d++", _XYZW_String, _Fs_, _Ft_); } } @@ -962,10 +1049,14 @@ mVUop(mVU_RINIT) { pass1 { mVUanalyzeR1(mVU, _Fs_, _Fsf_); } pass2 { if (_Fs_ || (_Fsf_ == 3)) { - getReg8(gprT1, _Fs_, _Fsf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + SSE2_MOVD_XMM_to_R(gprT1, Fs); AND32ItoR(gprT1, 0x007fffff); OR32ItoR (gprT1, 0x3f800000); MOV32RtoM(Rmem, gprT1); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } else MOV32ItoM(Rmem, 0x3f800000); } @@ -974,10 +1065,12 @@ mVUop(mVU_RINIT) { microVUt(void) mVU_RGET_(mV, int Rreg) { if (!mVUlow.noWriteVF) { - if (_X) MOV32RtoM((uptr)&mVU->regs->VF[_Ft_].UL[0], Rreg); - if (_Y) MOV32RtoM((uptr)&mVU->regs->VF[_Ft_].UL[1], Rreg); - if (_Z) MOV32RtoM((uptr)&mVU->regs->VF[_Ft_].UL[2], Rreg); - if (_W) MOV32RtoM((uptr)&mVU->regs->VF[_Ft_].UL[3], Rreg); + mVU->regAlloc->reset(); // Reset for Testing + int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); + SSE2_MOVD_R_to_XMM(Ft, Rreg); + if (!_XYZW_SS) mVUunpack_xyzw(Ft, Ft, 0); + mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->flushAll(); // Flush All for Testing } } @@ -1016,9 +1109,13 @@ mVUop(mVU_RXOR) { pass1 { mVUanalyzeR1(mVU, _Fs_, _Fsf_); } pass2 { if (_Fs_ || (_Fsf_ == 3)) { - getReg8(gprT1, _Fs_, _Fsf_); + mVU->regAlloc->reset(); // Reset for Testing + int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); + SSE2_MOVD_XMM_to_R(gprT1, Fs); AND32ItoR(gprT1, 0x7fffff); XOR32RtoM(Rmem, gprT1); + mVU->regAlloc->clearNeeded(Fs); + mVU->regAlloc->flushAll(); // Flush All for Testing } } pass3 { mVUlog("RXOR R, vf%02d%s", _Fs_, _Fsf_String); } diff --git a/pcsx2/x86/microVU_Misc.h b/pcsx2/x86/microVU_Misc.h index 4ca4f8843f..c5cb1e7857 100644 --- a/pcsx2/x86/microVU_Misc.h +++ b/pcsx2/x86/microVU_Misc.h @@ -115,13 +115,13 @@ declareAllVariables #define offsetSS ((_X) ? (0) : ((_Y) ? (4) : ((_Z) ? 8: 12))) #define offsetReg ((_X) ? (0) : ((_Y) ? (1) : ((_Z) ? 2: 3))) -#define xmmT1 0 // Temp Reg -#define xmmFs 1 // Holds the Value of Fs (writes back result Fd) -#define xmmFt 2 // Holds the Value of Ft -#define xmmT2 3 // Temp Reg? -#define xmmT3 4 // Temp Reg? -#define xmmT4 5 // Temp Reg? -#define xmmACC 6 // Holds ACC +#define xmmT1 0 // Used for regAlloc +#define xmmT2 1 // Used for regAlloc +#define xmmT3 2 // Used for regAlloc +#define xmmT4 3 // Used for regAlloc +#define xmmT5 4 // Used for regAlloc +#define xmmT6 5 // Used for regAlloc +#define xmmT7 6 // Used for regAlloc #define xmmPQ 7 // Holds the Value and Backup Values of P and Q regs #define gprT1 0 // Temp Reg diff --git a/pcsx2/x86/microVU_Misc.inl b/pcsx2/x86/microVU_Misc.inl index 73c762d45b..31203d624a 100644 --- a/pcsx2/x86/microVU_Misc.inl +++ b/pcsx2/x86/microVU_Misc.inl @@ -40,7 +40,7 @@ void mVUclamp1(int reg, int regT1, int xyzw) { // Used for Operand Clamping void mVUclamp2(int reg, int regT1, int xyzw) { - if (CHECK_VU_SIGN_OVERFLOW) { + if (CHECK_VU_SIGN_OVERFLOW && (regT1 >= 0)) { switch (xyzw) { case 1: case 2: case 4: case 8: SSE_MOVSS_XMM_to_XMM (regT1, reg); From cc3130660a58f4ab87a4949d09e5ee0f01328ce8 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Sun, 26 Jul 2009 15:30:25 +0000 Subject: [PATCH 13/22] GSdx: - Automatic texture filtering should be ok now, occasionally point filtering was used. Tested it on the ps2 and figured with no mip levels LoD and minification settings are just ignored altogether. - Also run a few tests on the gather instruction with the reference rasterizer and found a fatal flaw with it. It returns the four samples for bilinear sampling (in a funny order, which isn't documented of course, x = bl, y = br, z = tr, w = tl), but there is no way to guess which four were selected exactly. Due to some hidden rounding error it might grab different texels than I would when calculating the position of the upper-left texel, of which the fractional part is be used for the interpolation. When the texel positions do not match it leaves annoying discontinuity errors. Oh well... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1571 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GS.h | 6 +- plugins/GSdx/GSClut.h | 2 +- plugins/GSdx/GSDevice10.cpp | 6 +- plugins/GSdx/GSDevice11.cpp | 4 +- plugins/GSdx/GSDevice9.cpp | 49 ++------------ plugins/GSdx/GSRenderer.cpp | 7 +- plugins/GSdx/GSRendererDX.h | 5 +- plugins/GSdx/GSRendererHW.h | 2 +- plugins/GSdx/GSTextureFX.h | 3 +- plugins/GSdx/GSTextureFX10.cpp | 28 ++++---- plugins/GSdx/GSTextureFX11.cpp | 28 ++++---- plugins/GSdx/GSTextureFX9.cpp | 24 ++++--- plugins/GSdx/GSUtil.cpp | 2 +- plugins/GSdx/GSdx_vs2010.vcxproj | 2 + plugins/GSdx/GSdx_vs2010.vcxproj.filters | 6 ++ plugins/GSdx/res/tfx.fx | 82 +++++++++--------------- 16 files changed, 103 insertions(+), 153 deletions(-) diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 352e38da44..ef73ea85f5 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -769,9 +769,9 @@ REG64_(GIFReg, TEST) uint32 _PAD1:13; uint32 _PAD2:32; REG_END2 - __forceinline bool DoFirstPass() {return !ATE || ATST != 0;} // not all pixels fail automatically - __forceinline bool DoSecondPass() {return ATE && ATST != 1 && AFAIL != 0;} // pixels may fail, write fb/z - __forceinline bool NoSecondPass() {return ATE && ATST != 1 && AFAIL == 0;} // pixels may fail, no output + __forceinline bool DoFirstPass() {return !ATE || ATST != ATST_NEVER;} // not all pixels fail automatically + __forceinline bool DoSecondPass() {return ATE && ATST != ATST_ALWAYS && AFAIL != AFAIL_KEEP;} // pixels may fail, write fb/z + __forceinline bool NoSecondPass() {return ATE && ATST != ATST_ALWAYS && AFAIL == AFAIL_KEEP;} // pixels may fail, no output REG_END2 REG64_(GIFReg, TEX0) diff --git a/plugins/GSdx/GSClut.h b/plugins/GSdx/GSClut.h index 6303b81221..e4301ac6fd 100644 --- a/plugins/GSdx/GSClut.h +++ b/plugins/GSdx/GSClut.h @@ -71,7 +71,7 @@ __declspec(align(16)) class GSClut : public GSAlignedClass<16> template void WriteCLUT16_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT); template void WriteCLUT16S_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT); - void WriteCLUT_NULL(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT) {} + void WriteCLUT_NULL(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT) {ASSERT(0);} // xenosaga 3 static void WriteCLUT_T32_I8_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut); static void WriteCLUT_T32_I4_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut); diff --git a/plugins/GSdx/GSDevice10.cpp b/plugins/GSdx/GSDevice10.cpp index 8f5d709387..29e584d8a1 100644 --- a/plugins/GSdx/GSDevice10.cpp +++ b/plugins/GSdx/GSDevice10.cpp @@ -86,8 +86,8 @@ bool GSDevice10::Create(GSWnd* wnd, bool vsync) scd.SampleDesc.Quality = 0; scd.Windowed = TRUE; - uint32 flags = 0; - flags = D3D10_CREATE_DEVICE_SINGLETHREADED; //disables thread safety, should be fine (speedup) + uint32 flags = D3D10_CREATE_DEVICE_SINGLETHREADED; //disables thread safety, should be fine (speedup) + #ifdef DEBUG flags |= D3D10_CREATE_DEVICE_DEBUG; #endif @@ -113,8 +113,6 @@ bool GSDevice10::Create(GSWnd* wnd, bool vsync) } } - // hr = D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, flags, D3D10_SDK_VERSION, &scd, &m_swapchain, &m_dev); - if(FAILED(hr)) return false; // convert diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index 4ab7429375..679b5016ec 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -86,8 +86,8 @@ bool GSDevice11::Create(GSWnd* wnd, bool vsync) scd.SampleDesc.Quality = 0; scd.Windowed = TRUE; - uint32 flags = 0; - flags = D3D11_CREATE_DEVICE_SINGLETHREADED; //disables thread safety, should be fine (speedup) + uint32 flags = D3D11_CREATE_DEVICE_SINGLETHREADED; //disables thread safety, should be fine (speedup) + #ifdef DEBUG flags |= D3D11_CREATE_DEVICE_DEBUG; #endif diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 0889fb51e1..5971220633 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -969,29 +969,6 @@ void GSDevice9::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4 } } -// FIXME: D3DXCompileShaderFromResource of d3dx9 v37 (march 2008) calls GetFullPathName on id for some reason and then crashes - -static HRESULT LoadShader(uint32 id, LPCSTR& data, uint32& size) -{ - CComPtr shader, error; - - HRSRC hRes = FindResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), RT_RCDATA); - - if(!hRes) return E_FAIL; - - size = SizeofResource(theApp.GetModuleHandle(), hRes); - - if(size == 0) return E_FAIL; - - HGLOBAL hResData = LoadResource(theApp.GetModuleHandle(), hRes); - - if(!hResData) return E_FAIL; - - data = (LPCSTR)LockResource(hResData); - - return S_OK; -} - HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il) { vector m; @@ -1002,16 +979,7 @@ HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO CComPtr shader, error; - // FIXME: hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), &m[0], NULL, entry.c_str(), target, 0, &shader, &error, NULL); - - LPCSTR data; - uint32 size; - - hr = LoadShader(id, data, size); - - if(FAILED(hr)) return E_FAIL; - - hr = D3DXCompileShader(data, size, &m[0], NULL, entry.c_str(), m_shader.vs.c_str(), 0, &shader, &error, NULL); + hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), &m[0], NULL, entry.c_str(), m_shader.vs.c_str(), 0, &shader, &error, NULL); if(SUCCEEDED(hr)) { @@ -1047,6 +1015,10 @@ HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO { flags |= D3DXSHADER_AVOID_FLOW_CONTROL; } + else + { + flags |= D3DXSHADER_SKIPVALIDATION; + } vector m; @@ -1056,16 +1028,7 @@ HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO CComPtr shader, error; - // FIXME: hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), &m[0], NULL, entry.c_str(), target, flags, &shader, &error, NULL); - - LPCSTR data; - uint32 size; - - hr = LoadShader(id, data, size); - - if(FAILED(hr)) return E_FAIL; - - hr = D3DXCompileShader(data, size, &m[0], NULL, entry.c_str(), m_shader.ps.c_str(), 0, &shader, &error, NULL); + hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), &m[0], NULL, entry.c_str(), m_shader.ps.c_str(), flags, &shader, &error, NULL); if(SUCCEEDED(hr)) { diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index f1030ee321..a191366f9c 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -709,7 +709,10 @@ bool GSRenderer::IsLinear() bool mmin = TEX1.IsMinLinear(); bool mmag = TEX1.IsMagLinear(); - if(mmag == mmin) return mmag; + if(mmag == mmin || TEX1.MXL == 0) // MXL == 0 => MMIN ignored, tested it on ps2 + { + return mmag; + } if(!TEX1.LCM && !PRIM->FST) // if FST => assume Q = 1.0f (should not, but Q is very often bogus, 0 or DEN) { @@ -761,7 +764,7 @@ bool GSRenderer::IsOpaque() amin = amax = 0x80; } } - else if(context->ALPHA.C == 1) + else if(context->ALPHA.C == 2) { amin = amax = context->ALPHA.FIX; } diff --git a/plugins/GSdx/GSRendererDX.h b/plugins/GSdx/GSRendererDX.h index 887e202f22..7ff1187eca 100644 --- a/plugins/GSdx/GSRendererDX.h +++ b/plugins/GSdx/GSRendererDX.h @@ -199,7 +199,6 @@ public: if(context->TEST.ATE) { - ps_sel.ate = 1; ps_sel.atst = context->TEST.ATST; switch(ps_sel.atst) @@ -215,6 +214,10 @@ public: break; } } + else + { + ps_sel.atst = ATST_ALWAYS; + } if(tex) { diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index 9e8459c500..41cc49b4db 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -624,7 +624,7 @@ protected: { if(TryAlphaTest(fm, zm)) { - context->TEST.ATE = 0; + context->TEST.ATST = ATST_ALWAYS; } } diff --git a/plugins/GSdx/GSTextureFX.h b/plugins/GSdx/GSTextureFX.h index 8e97f8d0a6..eaaf562e9a 100644 --- a/plugins/GSdx/GSTextureFX.h +++ b/plugins/GSdx/GSTextureFX.h @@ -174,7 +174,6 @@ public: uint32 aem:1; uint32 tfx:3; uint32 tcc:1; - uint32 ate:1; uint32 atst:3; uint32 fog:1; uint32 clr1:1; @@ -187,7 +186,7 @@ public: uint32 key; }; - operator uint32() {return key & 0x7fffff;} + operator uint32() {return key & 0x3fffff;} PSSelector() : key(0) {} }; diff --git a/plugins/GSdx/GSTextureFX10.cpp b/plugins/GSdx/GSTextureFX10.cpp index b221f9e069..b822ee691a 100644 --- a/plugins/GSdx/GSTextureFX10.cpp +++ b/plugins/GSdx/GSTextureFX10.cpp @@ -197,7 +197,7 @@ void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample if(i == m_ps.end()) { - string str[14]; + string str[13]; str[0] = format("%d", sel.fst); str[1] = format("%d", sel.wms); @@ -206,13 +206,12 @@ void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample str[4] = format("%d", sel.aem); str[5] = format("%d", sel.tfx); str[6] = format("%d", sel.tcc); - str[7] = format("%d", sel.ate); - str[8] = format("%d", sel.atst); - str[9] = format("%d", sel.fog); - str[10] = format("%d", sel.clr1); - str[11] = format("%d", sel.fba); - str[12] = format("%d", sel.aout); - str[13] = format("%d", sel.ltf); + str[7] = format("%d", sel.atst); + str[8] = format("%d", sel.fog); + str[9] = format("%d", sel.clr1); + str[10] = format("%d", sel.fba); + str[11] = format("%d", sel.aout); + str[12] = format("%d", sel.ltf); D3D10_SHADER_MACRO macro[] = { @@ -223,13 +222,12 @@ void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample {"PS_AEM", str[4].c_str()}, {"PS_TFX", str[5].c_str()}, {"PS_TCC", str[6].c_str()}, - {"PS_ATE", str[7].c_str()}, - {"PS_ATST", str[8].c_str()}, - {"PS_FOG", str[9].c_str()}, - {"PS_CLR1", str[10].c_str()}, - {"PS_FBA", str[11].c_str()}, - {"PS_AOUT", str[12].c_str()}, - {"PS_LTF", str[13].c_str()}, + {"PS_ATST", str[7].c_str()}, + {"PS_FOG", str[8].c_str()}, + {"PS_CLR1", str[9].c_str()}, + {"PS_FBA", str[10].c_str()}, + {"PS_AOUT", str[11].c_str()}, + {"PS_LTF", str[12].c_str()}, {NULL, NULL}, }; diff --git a/plugins/GSdx/GSTextureFX11.cpp b/plugins/GSdx/GSTextureFX11.cpp index 8ad8cf6cf6..95e815c198 100644 --- a/plugins/GSdx/GSTextureFX11.cpp +++ b/plugins/GSdx/GSTextureFX11.cpp @@ -199,7 +199,7 @@ void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample if(i == m_ps.end()) { - string str[14]; + string str[13]; str[0] = format("%d", sel.fst); str[1] = format("%d", sel.wms); @@ -208,13 +208,12 @@ void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample str[4] = format("%d", sel.aem); str[5] = format("%d", sel.tfx); str[6] = format("%d", sel.tcc); - str[7] = format("%d", sel.ate); - str[8] = format("%d", sel.atst); - str[9] = format("%d", sel.fog); - str[10] = format("%d", sel.clr1); - str[11] = format("%d", sel.fba); - str[12] = format("%d", sel.aout); - str[13] = format("%d", sel.ltf); + str[7] = format("%d", sel.atst); + str[8] = format("%d", sel.fog); + str[9] = format("%d", sel.clr1); + str[10] = format("%d", sel.fba); + str[11] = format("%d", sel.aout); + str[12] = format("%d", sel.ltf); D3D11_SHADER_MACRO macro[] = { @@ -225,13 +224,12 @@ void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample {"PS_AEM", str[4].c_str()}, {"PS_TFX", str[5].c_str()}, {"PS_TCC", str[6].c_str()}, - {"PS_ATE", str[7].c_str()}, - {"PS_ATST", str[8].c_str()}, - {"PS_FOG", str[9].c_str()}, - {"PS_CLR1", str[10].c_str()}, - {"PS_FBA", str[11].c_str()}, - {"PS_AOUT", str[12].c_str()}, - {"PS_LTF", str[13].c_str()}, + {"PS_ATST", str[7].c_str()}, + {"PS_FOG", str[8].c_str()}, + {"PS_CLR1", str[9].c_str()}, + {"PS_FBA", str[10].c_str()}, + {"PS_AOUT", str[11].c_str()}, + {"PS_LTF", str[12].c_str()}, {NULL, NULL}, }; diff --git a/plugins/GSdx/GSTextureFX9.cpp b/plugins/GSdx/GSTextureFX9.cpp index 87c6849a56..83a01d2565 100644 --- a/plugins/GSdx/GSTextureFX9.cpp +++ b/plugins/GSdx/GSTextureFX9.cpp @@ -177,7 +177,7 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler if(i == m_ps.end()) { - string str[13]; + string str[12]; str[0] = format("%d", sel.fst); str[1] = format("%d", sel.wms); @@ -186,12 +186,11 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler str[4] = format("%d", sel.aem); str[5] = format("%d", sel.tfx); str[6] = format("%d", sel.tcc); - str[7] = format("%d", sel.ate); - str[8] = format("%d", sel.atst); - str[9] = format("%d", sel.fog); - str[10] = format("%d", sel.clr1); - str[11] = format("%d", sel.rt); - str[12] = format("%d", sel.ltf); + str[7] = format("%d", sel.atst); + str[8] = format("%d", sel.fog); + str[9] = format("%d", sel.clr1); + str[10] = format("%d", sel.rt); + str[11] = format("%d", sel.ltf); D3DXMACRO macro[] = { @@ -202,12 +201,11 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler {"PS_AEM", str[4].c_str()}, {"PS_TFX", str[5].c_str()}, {"PS_TCC", str[6].c_str()}, - {"PS_ATE", str[7].c_str()}, - {"PS_ATST", str[8].c_str()}, - {"PS_FOG", str[9].c_str()}, - {"PS_CLR1", str[10].c_str()}, - {"PS_RT", str[11].c_str()}, - {"PS_LTF", str[12].c_str()}, + {"PS_ATST", str[7].c_str()}, + {"PS_FOG", str[8].c_str()}, + {"PS_CLR1", str[9].c_str()}, + {"PS_RT", str[10].c_str()}, + {"PS_LTF", str[11].c_str()}, {NULL, NULL}, }; diff --git a/plugins/GSdx/GSUtil.cpp b/plugins/GSdx/GSUtil.cpp index 4e9236228a..b5b91643a5 100644 --- a/plugins/GSdx/GSUtil.cpp +++ b/plugins/GSdx/GSUtil.cpp @@ -148,7 +148,7 @@ bool GSUtil::CheckSSE() bool GSUtil::IsDirect3D10Available() { - if(HMODULE hModule = LoadLibrary(_T("d3d10.dll"))) + if(HMODULE hModule = LoadLibrary(_T("d3d10_1.dll"))) { FreeLibrary(hModule); diff --git a/plugins/GSdx/GSdx_vs2010.vcxproj b/plugins/GSdx/GSdx_vs2010.vcxproj index d6fe2960c1..e10b7f43a0 100644 --- a/plugins/GSdx/GSdx_vs2010.vcxproj +++ b/plugins/GSdx/GSdx_vs2010.vcxproj @@ -1319,6 +1319,7 @@ + @@ -1444,6 +1445,7 @@ + diff --git a/plugins/GSdx/GSdx_vs2010.vcxproj.filters b/plugins/GSdx/GSdx_vs2010.vcxproj.filters index 4ca7e0481a..c78db539e9 100644 --- a/plugins/GSdx/GSdx_vs2010.vcxproj.filters +++ b/plugins/GSdx/GSdx_vs2010.vcxproj.filters @@ -198,6 +198,9 @@ Source Files + + Source Files + Source Files @@ -518,6 +521,9 @@ Header Files + + Header Files + Header Files diff --git a/plugins/GSdx/res/tfx.fx b/plugins/GSdx/res/tfx.fx index 630fda80c8..803e853bb9 100644 --- a/plugins/GSdx/res/tfx.fx +++ b/plugins/GSdx/res/tfx.fx @@ -27,8 +27,7 @@ #define PS_AEM 0 #define PS_TFX 0 #define PS_TCC 1 -#define PS_ATE 0 -#define PS_ATST 4 +#define PS_ATST 1 #define PS_FOG 0 #define PS_CLR1 0 #define PS_FBA 0 @@ -100,15 +99,6 @@ float4 sample_p(float u) return Palette.Sample(PaletteSampler, u); } -#if SHADER_MODEL >= 0x401 - -float4 gather_c(float2 uv) -{ - return Texture.Gather(TextureSampler, uv, int2(0, 0)); -} - -#endif - #elif SHADER_MODEL <= 0x300 #ifndef VS_BPPZ @@ -126,7 +116,6 @@ float4 gather_c(float2 uv) #define PS_AEM 0 #define PS_TFX 0 #define PS_TCC 0 -#define PS_ATE 0 #define PS_ATST 4 #define PS_FOG 0 #define PS_CLR1 0 @@ -304,23 +293,15 @@ float4x4 sample_4c(float4 uv) return c; } -float4 sample_4a(float4 uv, float2 st) +float4 sample_4a(float4 uv) { float4 c; -/* - #if SHADER_MODEL >= 0x401 && PS_FMT == FMT_8 && PS_LTF && PS_WMS < 2 && PS_WMT < 2 - - c = gather_c(st); // the order of samples returned might not be the same as ours - - #else -*/ + c.x = sample_c(uv.xy).a; c.y = sample_c(uv.zy).a; c.z = sample_c(uv.xw).a; c.w = sample_c(uv.zw).a; -/* - #endif -*/ + #if SHADER_MODEL <= 0x300 if(PS_RT) c *= 128.0f / 255; #endif @@ -379,19 +360,19 @@ float4 sample(float2 st, float q) if(PS_FMT == FMT_8H) { - c = sample_4p(sample_4a(uv, st.xy)); + c = sample_4p(sample_4a(uv)); } else if(PS_FMT == FMT_4HL) { - c = sample_4p(fmod(sample_4a(uv, st.xy), 1.0f / 16)); + c = sample_4p(fmod(sample_4a(uv), 1.0f / 16)); } else if(PS_FMT == FMT_4HH) { - c = sample_4p(fmod(sample_4a(uv, st.xy) * 16, 1.0f / 16)); + c = sample_4p(fmod(sample_4a(uv) * 16, 1.0f / 16)); } else if(PS_FMT == FMT_8) { - c = sample_4p(sample_4a(uv, st.xy)); + c = sample_4p(sample_4a(uv)); } else { @@ -476,30 +457,31 @@ float4 tfx(float4 t, float4 c) void atst(float4 c) { - if(PS_ATE) + float a = trunc(c.a * 255); + + if(PS_ATST == 0) // never { - float a = trunc(c.a * 255); - - if(PS_ATST == 0) - { - discard; - } - else if(PS_ATST == 2 || PS_ATST == 3) // l, le - { - clip(AREF - a); - } - else if(PS_ATST == 4) // e - { - clip(0.5f - abs(a - AREF)); - } - else if(PS_ATST == 5 || PS_ATST == 6) // ge, g - { - clip(a - AREF); - } - else if(PS_ATST == 7) // ne - { - clip(abs(a - AREF) - 0.5f); - } + discard; + } + else if(PS_ATST == 1) // always + { + // nothing to do + } + else if(PS_ATST == 2 || PS_ATST == 3) // l, le + { + clip(AREF - a); + } + else if(PS_ATST == 4) // e + { + clip(0.5f - abs(a - AREF)); + } + else if(PS_ATST == 5 || PS_ATST == 6) // ge, g + { + clip(a - AREF); + } + else if(PS_ATST == 7) // ne + { + clip(abs(a - AREF) - 0.5f); } } From 37675b6c495a747aba6ad6890447c05da8c559a8 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Mon, 27 Jul 2009 00:27:33 +0000 Subject: [PATCH 14/22] microVU: - Finished implementing regAlloc. Sadly the speedgain wasn't great (0%~2% in the games I tried). I think the speedup should be bigger with a CPU that supports SSE4.1, but I don't have one to test :p git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1573 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU.h | 1 - pcsx2/x86/microVU_Compile.inl | 5 ++- pcsx2/x86/microVU_IR.h | 20 ++++++------ pcsx2/x86/microVU_Lower.inl | 59 ----------------------------------- pcsx2/x86/microVU_Misc.h | 3 ++ pcsx2/x86/microVU_Upper.inl | 50 +++++++++-------------------- 6 files changed, 32 insertions(+), 106 deletions(-) diff --git a/pcsx2/x86/microVU.h b/pcsx2/x86/microVU.h index 90ab25ee21..605d8a9e59 100644 --- a/pcsx2/x86/microVU.h +++ b/pcsx2/x86/microVU.h @@ -136,7 +136,6 @@ struct microVU { PCSX2_ALIGNED16(u32 macFlag[4]); // 4 instances of mac flag (used in execution) PCSX2_ALIGNED16(u32 clipFlag[4]); // 4 instances of clip flag (used in execution) PCSX2_ALIGNED16(u32 xmmPQb[4]); // Backup for xmmPQ - PCSX2_ALIGNED16(u32 xmmVFb[4]); // Backup for VF regs u32 index; // VU Index (VU0 or VU1) u32 vuMemSize; // VU Main Memory Size (in bytes) diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index ed62120809..3c57ced0cd 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -259,6 +259,7 @@ microVUt(void) mVUendProgram(mV, int isEbit, int* xStatus, int* xMac, int* xClip int fClip = (isEbit) ? findFlagInst(xClip, 0x7fffffff) : cI; int qInst = 0; int pInst = 0; + mVU->regAlloc->flushAll(); if (isEbit) { mVUprint("mVUcompile ebit"); @@ -370,6 +371,7 @@ microVUr(void*) mVUcompile(microVU* mVU, u32 startPC, uptr pState) { mVUsetupRange(mVU, startPC, 1); // Reset regAlloc + mVU->regAlloc->flushAll(); mVU->regAlloc->reset(); // First Pass @@ -435,7 +437,8 @@ microVUr(void*) mVUcompile(microVU* mVU, u32 startPC, uptr pState) { else if (!mVUinfo.swapOps) { incPC(1); doUpperOp(); doLowerOp(); } else { doSwapOp(mVU); } if (mVUinfo.doXGKICK) { mVU_XGKICK_DELAY(mVU, 1); } - + if (!doRegAlloc) { mVU->regAlloc->flushAll(); } + if (!mVUinfo.isBdelay) { incPC(1); } else { microBlock* bBlock = NULL; diff --git a/pcsx2/x86/microVU_IR.h b/pcsx2/x86/microVU_IR.h index fde98f75c6..73041293f8 100644 --- a/pcsx2/x86/microVU_IR.h +++ b/pcsx2/x86/microVU_IR.h @@ -181,7 +181,6 @@ private: int findFreeRegRec(int startIdx) { for (int i = startIdx; i < xmmTotal; i++) { if (!xmmReg[i].isNeeded) { - if ((i+1) >= xmmTotal) return i; int x = findFreeRegRec(i+1); if (x == -1) return i; return ((xmmReg[i].count < xmmReg[x].count) ? i : x); @@ -223,14 +222,17 @@ public: xmmReg[reg].xyzw = 0; xmmReg[reg].isNeeded = 0; } - void writeBackReg(int reg) { + void writeBackReg(int reg, bool invalidateRegs = 1) { if ((xmmReg[reg].reg > 0) && xmmReg[reg].xyzw) { // Reg was modified and not Temp or vf0 if (xmmReg[reg].reg == 32) mVUsaveReg(reg, (uptr)&vuRegs->ACC.UL[0], xmmReg[reg].xyzw, 1); else mVUsaveReg(reg, (uptr)&vuRegs->VF[xmmReg[reg].reg].UL[0], xmmReg[reg].xyzw, 1); - for (int i = 0; i < xmmTotal; i++) { - if (i == reg) continue; - if (xmmReg[i].reg == xmmReg[reg].reg) { - clearReg(i); // Invalidate any Cached Regs of same vf Reg + if (invalidateRegs) { + for (int i = 0; i < xmmTotal; i++) { + if ((i == reg) || xmmReg[i].isNeeded) continue; + if (xmmReg[i].reg == xmmReg[reg].reg) { + if (xmmReg[i].xyzw && xmmReg[i].xyzw < 0xf) DevCon::Error("microVU Error: writeBackReg() [%d]", params xmmReg[i].reg); + clearReg(i); // Invalidate any Cached Regs of same vf Reg + } } } if (xmmReg[reg].xyzw == 0xf) { // Make Cached Reg if All Vectors were Modified @@ -271,8 +273,8 @@ public: counter++; if (vfLoadReg >= 0) { // Search For Cached Regs for (int i = 0; i < xmmTotal; i++) { - if ((xmmReg[i].reg == vfLoadReg) && (!xmmReg[i].xyzw // Reg Was Not Modified - || (/*!xmmReg[i].isNeeded &&*/ xmmReg[i].reg && (xmmReg[i].xyzw==0xf)))) { // Reg Had All Vectors Modified and != VF0 + if ((xmmReg[i].reg == vfLoadReg) && (!xmmReg[i].xyzw // Reg Was Not Modified + || (xmmReg[i].reg && (xmmReg[i].xyzw==0xf)))) { // Reg Had All Vectors Modified and != VF0 int z = i; if (vfWriteReg >= 0) { // Reg will be modified if (cloneWrite) { // Clone Reg so as not to use the same Cached Reg @@ -287,7 +289,7 @@ public: } else { // Don't clone reg, but shuffle to adjust for SS ops if ((vfLoadReg != vfWriteReg) || (xyzw != 0xf)) { writeBackReg(z); } - else if (xyzw == 4) SSE2_PSHUFD_XMM_to_XMM(z, i, 1); + if (xyzw == 4) SSE2_PSHUFD_XMM_to_XMM(z, i, 1); else if (xyzw == 2) SSE2_PSHUFD_XMM_to_XMM(z, i, 2); else if (xyzw == 1) SSE2_PSHUFD_XMM_to_XMM(z, i, 3); } diff --git a/pcsx2/x86/microVU_Lower.inl b/pcsx2/x86/microVU_Lower.inl index e74d92f004..fb017f23e8 100644 --- a/pcsx2/x86/microVU_Lower.inl +++ b/pcsx2/x86/microVU_Lower.inl @@ -46,7 +46,6 @@ mVUop(mVU_DIV) { pass1 { mVUanalyzeFDIV(mVU, _Fs_, _Fsf_, _Ft_, _Ftf_, 7); } pass2 { u8 *ajmp, *bjmp, *cjmp, *djmp; - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); int Ft = mVU->regAlloc->allocReg(_Ft_, 0, (1 << (3 - _Ftf_))); int t1 = mVU->regAlloc->allocReg(); @@ -80,7 +79,6 @@ mVUop(mVU_DIV) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(Ft); mVU->regAlloc->clearNeeded(t1); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("DIV Q, vf%02d%s, vf%02d%s", _Fs_, _Fsf_String, _Ft_, _Ftf_String); } } @@ -89,7 +87,6 @@ mVUop(mVU_SQRT) { pass1 { mVUanalyzeFDIV(mVU, 0, 0, _Ft_, _Ftf_, 7); } pass2 { u8 *ajmp; - mVU->regAlloc->reset(); // Reset for Testing int Ft = mVU->regAlloc->allocReg(_Ft_, 0, (1 << (3 - _Ftf_))); MOV32ItoM((uptr)&mVU->divFlag, 0); // Clear I/D flags @@ -102,7 +99,6 @@ mVUop(mVU_SQRT) { if (mVUinfo.writeQ) SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, 0xe1); mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQRT Q, vf%02d%s", _Ft_, _Ftf_String); } } @@ -111,7 +107,6 @@ mVUop(mVU_RSQRT) { pass1 { mVUanalyzeFDIV(mVU, _Fs_, _Fsf_, _Ft_, _Ftf_, 13); } pass2 { u8 *ajmp, *bjmp, *cjmp, *djmp; - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); int Ft = mVU->regAlloc->allocReg(_Ft_, 0, (1 << (3 - _Ftf_))); int t1 = mVU->regAlloc->allocReg(); @@ -147,7 +142,6 @@ mVUop(mVU_RSQRT) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(Ft); mVU->regAlloc->clearNeeded(t1); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("RSQRT Q, vf%02d%s, vf%02d%s", _Fs_, _Fsf_String, _Ft_, _Ftf_String); } } @@ -195,7 +189,6 @@ mVUop(mVU_EATAN) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(t1); mVU->regAlloc->clearNeeded(t2); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EATAN P"); } } @@ -203,7 +196,6 @@ mVUop(mVU_EATAN) { mVUop(mVU_EATANxy) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 54); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int t1 = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); int Fs = mVU->regAlloc->allocReg(); int t2 = mVU->regAlloc->allocReg(); @@ -217,7 +209,6 @@ mVUop(mVU_EATANxy) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(t1); mVU->regAlloc->clearNeeded(t2); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EATANxy P"); } } @@ -225,7 +216,6 @@ mVUop(mVU_EATANxy) { mVUop(mVU_EATANxz) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 54); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int t1 = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); int Fs = mVU->regAlloc->allocReg(); int t2 = mVU->regAlloc->allocReg(); @@ -239,7 +229,6 @@ mVUop(mVU_EATANxz) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(t1); mVU->regAlloc->clearNeeded(t2); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EATANxz P"); } } @@ -254,7 +243,6 @@ mVUop(mVU_EATANxz) { mVUop(mVU_EEXP) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 44); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); int t1 = mVU->regAlloc->allocReg(); int t2 = mVU->regAlloc->allocReg(); @@ -282,7 +270,6 @@ mVUop(mVU_EEXP) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(t1); mVU->regAlloc->clearNeeded(t2); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("EEXP P"); } } @@ -306,14 +293,12 @@ microVUt(void) mVU_sumXYZ(int PQ, int Fs) { mVUop(mVU_ELENG) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 18); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance mVU_sumXYZ(xmmPQ, Fs); SSE_SQRTSS_XMM_to_XMM (xmmPQ, xmmPQ); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ELENG P"); } } @@ -321,7 +306,6 @@ mVUop(mVU_ELENG) { mVUop(mVU_ERCPR) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 12); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); @@ -330,7 +314,6 @@ mVUop(mVU_ERCPR) { SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERCPR P"); } } @@ -338,7 +321,6 @@ mVUop(mVU_ERCPR) { mVUop(mVU_ERLENG) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 24); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance mVU_sumXYZ(xmmPQ, Fs); @@ -348,7 +330,6 @@ mVUop(mVU_ERLENG) { SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERLENG P"); } } @@ -356,7 +337,6 @@ mVUop(mVU_ERLENG) { mVUop(mVU_ERSADD) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 18); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance mVU_sumXYZ(xmmPQ, Fs); @@ -365,7 +345,6 @@ mVUop(mVU_ERSADD) { SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERSADD P"); } } @@ -373,7 +352,6 @@ mVUop(mVU_ERSADD) { mVUop(mVU_ERSQRT) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 18); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance SSE_SQRTSS_XMM_to_XMM (xmmPQ, Fs); @@ -382,7 +360,6 @@ mVUop(mVU_ERSQRT) { SSE_MOVSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ERSQRT P"); } } @@ -390,13 +367,11 @@ mVUop(mVU_ERSQRT) { mVUop(mVU_ESADD) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 11); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance mVU_sumXYZ(xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESADD P"); } } @@ -411,7 +386,6 @@ mVUop(mVU_ESADD) { mVUop(mVU_ESIN) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 29); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); int t1 = mVU->regAlloc->allocReg(); int t2 = mVU->regAlloc->allocReg(); @@ -433,7 +407,6 @@ mVUop(mVU_ESIN) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(t1); mVU->regAlloc->clearNeeded(t2); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESIN P"); } } @@ -441,13 +414,11 @@ mVUop(mVU_ESIN) { mVUop(mVU_ESQRT) { pass1 { mVUanalyzeEFU1(mVU, _Fs_, _Fsf_, 12); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance SSE_SQRTSS_XMM_to_XMM (xmmPQ, Fs); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESQRT P"); } } @@ -455,7 +426,6 @@ mVUop(mVU_ESQRT) { mVUop(mVU_ESUM) { pass1 { mVUanalyzeEFU2(mVU, _Fs_, 12); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); int t1 = mVU->regAlloc->allocReg(); SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip xmmPQ to get Valid P instance @@ -467,7 +437,6 @@ mVUop(mVU_ESUM) { SSE2_PSHUFD_XMM_to_XMM(xmmPQ, xmmPQ, mVUinfo.writeP ? 0x27 : 0xC6); // Flip back mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(t1); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ESUM P"); } } @@ -753,14 +722,12 @@ mVUop(mVU_ISUBIU) { mVUop(mVU_MFIR) { pass1 { if (!_Ft_) { mVUlow.isNOP = 1; } analyzeVIreg1(_Is_, mVUlow.VI_read[0]); analyzeReg2(_Ft_, mVUlow.VF_write, 1); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); mVUallocVIa(mVU, gprT1, _Is_); MOVSX32R16toR(gprT1, gprT1); SSE2_MOVD_R_to_XMM(Ft, gprT1); if (!_XYZW_SS) { mVUunpack_xyzw(Ft, Ft, 0); } mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MFIR.%s vf%02d, vi%02d", _XYZW_String, _Ft_, _Fs_); } } @@ -768,11 +735,9 @@ mVUop(mVU_MFIR) { mVUop(mVU_MFP) { pass1 { mVUanalyzeMFP(mVU, _Ft_); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); getPreg(Ft); mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MFP.%s vf%02d, P", _XYZW_String, _Ft_); } } @@ -780,10 +745,8 @@ mVUop(mVU_MFP) { mVUop(mVU_MOVE) { pass1 { mVUanalyzeMOVE(mVU, _Fs_, _Ft_); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MOVE.%s vf%02d, vf%02d", _XYZW_String, _Ft_, _Fs_); } } @@ -791,14 +754,12 @@ mVUop(mVU_MOVE) { mVUop(mVU_MR32) { pass1 { mVUanalyzeMR32(mVU, _Fs_, _Ft_); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); if (_XYZW_SS) mVUunpack_xyzw(Ft, Fs, (_X ? 1 : (_Y ? 2 : (_Z ? 3 : 0)))); else SSE2_PSHUFD_XMM_to_XMM(Ft, Fs, 0x39); mVU->regAlloc->clearNeeded(Ft); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MR32.%s vf%02d, vf%02d", _XYZW_String, _Ft_, _Fs_); } } @@ -806,12 +767,10 @@ mVUop(mVU_MR32) { mVUop(mVU_MTIR) { pass1 { if (!_It_) { mVUlow.isNOP = 1; } analyzeReg5(_Fs_, _Fsf_, mVUlow.VF_read[0]); analyzeVIreg2(_It_, mVUlow.VI_write, 1); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_MOVD_XMM_to_R(gprT1, Fs); mVUallocVIb(mVU, gprT1, _It_); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("MTIR vi%02d, vf%02d%s", _Ft_, _Fs_, _Fsf_String); } } @@ -914,7 +873,6 @@ mVUop(mVU_ISWR) { mVUop(mVU_LQ) { pass1 { mVUanalyzeLQ(mVU, _Ft_, _Is_, 0); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); if (_Is_) { mVUallocVIa(mVU, gprT1, _Is_); @@ -924,7 +882,6 @@ mVUop(mVU_LQ) { } else mVUloadReg(Ft, (uptr)mVU->regs->Mem + getVUmem(_Imm11_), _X_Y_Z_W); mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("LQ.%s vf%02d, vi%02d + %d", _XYZW_String, _Ft_, _Fs_, _Imm11_); } } @@ -932,7 +889,6 @@ mVUop(mVU_LQ) { mVUop(mVU_LQD) { pass1 { mVUanalyzeLQ(mVU, _Ft_, _Is_, 1); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing if (_Is_) { mVUallocVIa(mVU, gprT1, _Is_); SUB16ItoR(gprT1, 1); @@ -949,7 +905,6 @@ mVUop(mVU_LQD) { mVUloadReg(Ft, (uptr)mVU->regs->Mem, _X_Y_Z_W); mVU->regAlloc->clearNeeded(Ft); } - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("LQD.%s vf%02d, --vi%02d", _XYZW_String, _Ft_, _Is_); } } @@ -957,7 +912,6 @@ mVUop(mVU_LQD) { mVUop(mVU_LQI) { pass1 { mVUanalyzeLQ(mVU, _Ft_, _Is_, 1); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing if (_Is_) { mVUallocVIa(mVU, (!mVUlow.noWriteVF) ? gprT1 : gprT2, _Is_); if (!mVUlow.noWriteVF) { @@ -975,7 +929,6 @@ mVUop(mVU_LQI) { mVUloadReg(Ft, (uptr)mVU->regs->Mem, _X_Y_Z_W); mVU->regAlloc->clearNeeded(Ft); } - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("LQI.%s vf%02d, vi%02d++", _XYZW_String, _Ft_, _Fs_); } } @@ -987,7 +940,6 @@ mVUop(mVU_LQI) { mVUop(mVU_SQ) { pass1 { mVUanalyzeSQ(mVU, _Fs_, _It_, 0); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); if (_It_) { mVUallocVIa(mVU, gprT1, _It_); @@ -997,7 +949,6 @@ mVUop(mVU_SQ) { } else mVUsaveReg(Fs, (uptr)mVU->regs->Mem + getVUmem(_Imm11_), _X_Y_Z_W, 1); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQ.%s vf%02d, vi%02d + %d", _XYZW_String, _Fs_, _Ft_, _Imm11_); } } @@ -1005,7 +956,6 @@ mVUop(mVU_SQ) { mVUop(mVU_SQD) { pass1 { mVUanalyzeSQ(mVU, _Fs_, _It_, 1); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); if (_It_) { mVUallocVIa(mVU, gprT1, _It_); @@ -1016,7 +966,6 @@ mVUop(mVU_SQD) { } else mVUsaveReg(Fs, (uptr)mVU->regs->Mem, _X_Y_Z_W, 1); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQD.%s vf%02d, --vi%02d", _XYZW_String, _Fs_, _Ft_); } } @@ -1024,7 +973,6 @@ mVUop(mVU_SQD) { mVUop(mVU_SQI) { pass1 { mVUanalyzeSQ(mVU, _Fs_, _It_, 1); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); if (_It_) { mVUallocVIa(mVU, gprT1, _It_); @@ -1036,7 +984,6 @@ mVUop(mVU_SQI) { } else mVUsaveReg(Fs, (uptr)mVU->regs->Mem, _X_Y_Z_W, 1); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("SQI.%s vf%02d, vi%02d++", _XYZW_String, _Fs_, _Ft_); } } @@ -1049,14 +996,12 @@ mVUop(mVU_RINIT) { pass1 { mVUanalyzeR1(mVU, _Fs_, _Fsf_); } pass2 { if (_Fs_ || (_Fsf_ == 3)) { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_MOVD_XMM_to_R(gprT1, Fs); AND32ItoR(gprT1, 0x007fffff); OR32ItoR (gprT1, 0x3f800000); MOV32RtoM(Rmem, gprT1); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } else MOV32ItoM(Rmem, 0x3f800000); } @@ -1065,12 +1010,10 @@ mVUop(mVU_RINIT) { microVUt(void) mVU_RGET_(mV, int Rreg) { if (!mVUlow.noWriteVF) { - mVU->regAlloc->reset(); // Reset for Testing int Ft = mVU->regAlloc->allocReg(-1, _Ft_, _X_Y_Z_W); SSE2_MOVD_R_to_XMM(Ft, Rreg); if (!_XYZW_SS) mVUunpack_xyzw(Ft, Ft, 0); mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } } @@ -1109,13 +1052,11 @@ mVUop(mVU_RXOR) { pass1 { mVUanalyzeR1(mVU, _Fs_, _Fsf_); } pass2 { if (_Fs_ || (_Fsf_ == 3)) { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, (1 << (3 - _Fsf_))); SSE2_MOVD_XMM_to_R(gprT1, Fs); AND32ItoR(gprT1, 0x7fffff); XOR32RtoM(Rmem, gprT1); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } } pass3 { mVUlog("RXOR R, vf%02d%s", _Fs_, _Fsf_String); } diff --git a/pcsx2/x86/microVU_Misc.h b/pcsx2/x86/microVU_Misc.h index c5cb1e7857..04f2373f5b 100644 --- a/pcsx2/x86/microVU_Misc.h +++ b/pcsx2/x86/microVU_Misc.h @@ -267,6 +267,9 @@ typedef u32 (__fastcall *mVUCall)(void*, void*); #define mVUdumpProg 0&& #endif +// Reg Alloc +#define doRegAlloc 1 // Set to 0 to flush every 64bit Instruction (Turns off regAlloc) + // Speed Hacks #define CHECK_VU_CONSTHACK 0 // Only use for GoW (will be slower on other games) #define CHECK_VU_FLAGHACK (u32)Config.Hacks.vuFlagHack // (Can cause Infinite loops, SPS, etc...) diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index bc7e56cf86..8b8ed08c78 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -28,7 +28,7 @@ // Note: If modXYZW is true, then it adjusts XYZW for Single Scalar operations microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { - int sReg, mReg = gprT1, xyzw = _X_Y_Z_W; + int sReg, mReg = gprT1, xyzw = _X_Y_Z_W, regT1b = 0; static const u16 flipMask[16] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}; //SysPrintf("Status = %d; Mac = %d\n", sFLAG.doFlag, mFLAG.doFlag); @@ -42,7 +42,7 @@ microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { mVUallocSFLAGa(sReg, sFLAG.lastWrite); // Get Prev Status Flag if (sFLAG.doNonSticky) AND32ItoR(sReg, 0xfffc00ff); // Clear O,U,S,Z flags } - if (regT1 < 0) { regT1 = mVU->regAlloc->allocReg(); } + if (regT1 < 0) { regT1 = mVU->regAlloc->allocReg(); regT1b = 1; } //-------------------------Check for Signed flags------------------------------ @@ -75,6 +75,7 @@ microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { OR32RtoR (sReg, mReg); } } + if (regT1b) mVU->regAlloc->clearNeeded(regT1); } //------------------------------------------------------------------ @@ -136,12 +137,11 @@ void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, co pass1 { setupPass1(mVU, opCase, isACC, ((opType == 3) || (opType == 4))); } pass2 { int Fs, Ft, ACC; - mVU->regAlloc->reset(); // Reset for Testing setupFtReg(mVU, Ft, opCase); if (isACC) { - ACC = mVU->regAlloc->allocReg((_X_Y_Z_W == 0xf) ? -1 : 32, 32, 0xf, 0); Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + ACC = mVU->regAlloc->allocReg((_X_Y_Z_W == 0xf) ? -1 : 32, 32, 0xf, 0); if (_XYZW_SS && _X_Y_Z_W != 8) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } else { Fs = mVU->regAlloc->allocReg(_Fs_, _Fd_, _X_Y_Z_W); } @@ -164,11 +164,9 @@ void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, co mVU->regAlloc->clearNeeded(ACC); } else mVUupdateFlags(mVU, Fs, (((opCase==2)&&(!_XYZW_SS)) ? Ft : -1)); - - //if (isACC) SSE_MOVAPS_XMM_to_XMM(xmmACC, ACC); // For Testing + mVU->regAlloc->clearNeeded(Fs); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVU_printOP(mVU, opCase, opName, isACC); } } @@ -178,11 +176,10 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* op pass1 { setupPass1(mVU, opCase, 1, 0); } pass2 { int Fs, Ft, ACC; - mVU->regAlloc->reset(); // Reset for Testing setupFtReg(mVU, Ft, opCase); - ACC = mVU->regAlloc->allocReg(32, 32, 0xf, 0); Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + ACC = mVU->regAlloc->allocReg(32, 32, 0xf, 0); if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } @@ -209,11 +206,9 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* op mVU->regAlloc->clearNeeded(tempACC); } - //SSE_MOVAPS_XMM_to_XMM(xmmACC, ACC); // For Testing mVU->regAlloc->clearNeeded(ACC); mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVU_printOP(mVU, opCase, opName, 1); } } @@ -223,7 +218,6 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, const char* opName) { pass1 { setupPass1(mVU, opCase, 0, 0); } pass2 { int Fs, Ft, ACC; - mVU->regAlloc->reset(); // Reset for Testing setupFtReg(mVU, Ft, opCase); ACC = mVU->regAlloc->allocReg(32); @@ -243,10 +237,9 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, const char* opName) { opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } - mVU->regAlloc->clearNeeded(ACC); mVU->regAlloc->clearNeeded(Fs); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing + mVU->regAlloc->clearNeeded(ACC); } pass3 { mVU_printOP(mVU, opCase, opName, 0); } } @@ -256,11 +249,10 @@ void mVU_FMACd(microVU* mVU, int recPass, int opCase, const char* opName) { pass1 { setupPass1(mVU, opCase, 0, 0); } pass2 { int Fs, Ft, Fd; - mVU->regAlloc->reset(); // Reset for Testing setupFtReg(mVU, Ft, opCase); - Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); - Fd = mVU->regAlloc->allocReg(32, _Fd_, _X_Y_Z_W); + Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); + Fd = mVU->regAlloc->allocReg(32, _Fd_, _X_Y_Z_W); opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } @@ -276,7 +268,6 @@ void mVU_FMACd(microVU* mVU, int recPass, int opCase, const char* opName) { mVU->regAlloc->clearNeeded(Fd); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVU_printOP(mVU, opCase, opName, 0); } } @@ -286,11 +277,9 @@ mVUop(mVU_ABS) { pass1 { mVUanalyzeFMAC2(mVU, _Fs_, _Ft_); } pass2 { if (!_Ft_) return; - mVU->regAlloc->reset(); // Reset for Testing - int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W, ((_Fs_ == _Ft_) && (_X_Y_Z_W == 0xf))); + int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W, !((_Fs_ == _Ft_) && (_X_Y_Z_W == 0xf))); SSE_ANDPS_M128_to_XMM(Fs, (uptr)mVU_absclip); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("ABS"); mVUlogFtFs(); } } @@ -299,9 +288,8 @@ mVUop(mVU_ABS) { mVUop(mVU_OPMULA) { pass1 { mVUanalyzeFMAC1(mVU, 0, _Fs_, _Ft_); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing - int Fs = mVU->regAlloc->allocReg(_Fs_, 32, _X_Y_Z_W); int Ft = mVU->regAlloc->allocReg(_Ft_, 0, _X_Y_Z_W); + int Fs = mVU->regAlloc->allocReg(_Fs_, 32, _X_Y_Z_W); SSE2_PSHUFD_XMM_to_XMM(Fs, Fs, 0xC9); // WXZY SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, 0xD2); // WYXZ @@ -310,7 +298,6 @@ mVUop(mVU_OPMULA) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("OPMULA"); mVUlogACC(); mVUlogFt(); } } @@ -319,7 +306,6 @@ mVUop(mVU_OPMULA) { mVUop(mVU_OPMSUB) { pass1 { mVUanalyzeFMAC1(mVU, _Fd_, _Fs_, _Ft_); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Ft = mVU->regAlloc->allocReg(_Ft_, 0, 0xf); int Fs = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); int ACC = mVU->regAlloc->allocReg(32, _Fd_, _X_Y_Z_W); @@ -332,9 +318,7 @@ mVUop(mVU_OPMSUB) { mVU->regAlloc->clearNeeded(ACC); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->clearNeeded(Ft); - mVU->regAlloc->flushAll(); // Flush All for Testing - + mVU->regAlloc->clearNeeded(Ft); } pass3 { mVUlog("OPMSUB"); mVUlogFd(); mVUlogFt(); } } @@ -344,8 +328,7 @@ void mVU_FTOIx(mP, uptr addr, const char* opName) { pass1 { mVUanalyzeFMAC2(mVU, _Fs_, _Ft_); } pass2 { if (!_Ft_) return; - mVU->regAlloc->reset(); // Reset for Testing - int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W, ((_Fs_ == _Ft_) && (_X_Y_Z_W == 0xf))); + int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W, !((_Fs_ == _Ft_) && (_X_Y_Z_W == 0xf))); int t1 = mVU->regAlloc->allocReg(); int t2 = mVU->regAlloc->allocReg(); @@ -363,7 +346,6 @@ void mVU_FTOIx(mP, uptr addr, const char* opName) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(t1); mVU->regAlloc->clearNeeded(t2); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog(opName); mVUlogFtFs(); } } @@ -373,15 +355,13 @@ void mVU_ITOFx(mP, uptr addr, const char* opName) { pass1 { mVUanalyzeFMAC2(mVU, _Fs_, _Ft_); } pass2 { if (!_Ft_) return; - mVU->regAlloc->reset(); // Reset for Testing - int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W, ((_Fs_ == _Ft_) && (_X_Y_Z_W == 0xf))); + int Fs = mVU->regAlloc->allocReg(_Fs_, _Ft_, _X_Y_Z_W, !((_Fs_ == _Ft_) && (_X_Y_Z_W == 0xf))); SSE2_CVTDQ2PS_XMM_to_XMM(Fs, Fs); if (addr) { SSE_MULPS_M128_to_XMM(Fs, addr); } //mVUclamp2(Fs, xmmT1, 15); // Clamp (not sure if this is needed) mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog(opName); mVUlogFtFs(); } } @@ -390,7 +370,6 @@ void mVU_ITOFx(mP, uptr addr, const char* opName) { mVUop(mVU_CLIP) { pass1 { mVUanalyzeFMAC4(mVU, _Fs_, _Ft_); } pass2 { - mVU->regAlloc->reset(); // Reset for Testing int Fs = mVU->regAlloc->allocReg(_Fs_, 0, 0xf); int Ft = mVU->regAlloc->allocReg(_Ft_, 0, 0x1); int t1 = mVU->regAlloc->allocReg(); @@ -424,7 +403,6 @@ mVUop(mVU_CLIP) { mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(Ft); mVU->regAlloc->clearNeeded(t1); - mVU->regAlloc->flushAll(); // Flush All for Testing } pass3 { mVUlog("CLIP"); mVUlogCLIP(); } } From f058728f09f402242f8d76584f195ae633465340 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Mon, 27 Jul 2009 02:55:25 +0000 Subject: [PATCH 15/22] microVU: tweaking/testing some stuff... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1574 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_IR.h | 10 +++--- pcsx2/x86/microVU_Upper.inl | 64 ++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/pcsx2/x86/microVU_IR.h b/pcsx2/x86/microVU_IR.h index 73041293f8..1ce311dda5 100644 --- a/pcsx2/x86/microVU_IR.h +++ b/pcsx2/x86/microVU_IR.h @@ -150,11 +150,11 @@ struct microIR { microOp info[pSize/2]; // Info for Instructions in current block microConstInfo constReg[16]; // Simple Const Propagation Info for VI regs within blocks u8 branch; - u32 cycles; // Cycles for current block - u32 count; // Number of VU 64bit instructions ran (starts at 0 for each block) - u32 curPC; // Current PC - u32 startPC; // Start PC for Cur Block - u32 sFlagHack; // Optimize out all Status flag updates if microProgram doesn't use Status flags + u32 cycles; // Cycles for current block + u32 count; // Number of VU 64bit instructions ran (starts at 0 for each block) + u32 curPC; // Current PC + u32 startPC; // Start PC for Cur Block + u32 sFlagHack; // Optimize out all Status flag updates if microProgram doesn't use Status flags }; //------------------------------------------------------------------ diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index 8b8ed08c78..634c26fc96 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -27,16 +27,18 @@ #define SHIFT_XYZW(gprReg) { if (_XYZW_SS && modXYZW && !_W) { SHL32ItoR(gprReg, ADD_XYZW); } } // Note: If modXYZW is true, then it adjusts XYZW for Single Scalar operations -microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { - int sReg, mReg = gprT1, xyzw = _X_Y_Z_W, regT1b = 0; +microVUt(void) mVUupdateFlags(mV, int reg, int regT1 = -1, int regT2 = -1, bool modXYZW = 1) { + int sReg, mReg = gprT1, xyzw = _X_Y_Z_W, regT1b = 0, regT2b = 0; static const u16 flipMask[16] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}; //SysPrintf("Status = %d; Mac = %d\n", sFLAG.doFlag, mFLAG.doFlag); if (mVUsFlagHack) { sFLAG.doFlag = 0; } if (!sFLAG.doFlag && !mFLAG.doFlag) { return; } if (!(!mFLAG.doFlag || (_XYZW_SS && modXYZW))) { - SSE2_PSHUFD_XMM_to_XMM(reg, reg, 0x1B); // Flip wzyx to xyzw + if (regT2 < 0) { regT2 = mVU->regAlloc->allocReg(); regT2b = 1; } + SSE2_PSHUFD_XMM_to_XMM(regT2, reg, 0x1B); // Flip wzyx to xyzw } + else regT2 = reg; if (sFLAG.doFlag) { getFlagReg(sReg, sFLAG.write); // Set sReg to valid GPR by Cur Flag Instance mVUallocSFLAGa(sReg, sFLAG.lastWrite); // Get Prev Status Flag @@ -48,10 +50,10 @@ microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { // The following code makes sure the Signed Bit isn't set with Negative Zero SSE_XORPS_XMM_to_XMM (regT1, regT1); // Clear regT2 - SSE_CMPEQPS_XMM_to_XMM (regT1, reg); // Set all F's if each vector is zero + SSE_CMPEQPS_XMM_to_XMM (regT1, regT2); // Set all F's if each vector is zero SSE_MOVMSKPS_XMM_to_R32(gprT2, regT1); // Used for Zero Flag Calculation - SSE_ANDNPS_XMM_to_XMM (regT1, reg); // Used for Sign Flag Calculation - SSE_MOVMSKPS_XMM_to_R32(mReg, regT1); // Move the Sign Bits of the t1reg + SSE_ANDNPS_XMM_to_XMM (regT1, regT2); // Used for Sign Flag Calculation + SSE_MOVMSKPS_XMM_to_R32(mReg, regT1); // Move the Sign Bits of the t1reg AND32ItoR(mReg, AND_XYZW); // Grab "Is Signed" bits from the previous calculation SHL32ItoR(mReg, 4 + ADD_XYZW); @@ -64,9 +66,6 @@ microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { //-------------------------Write back flags------------------------------ - if (!(!mFLAG.doFlag || (_XYZW_SS && modXYZW))) { - SSE2_PSHUFD_XMM_to_XMM(reg, reg, 0x1B); // Flip wzyx to xyzw - } if (mFLAG.doFlag) mVUallocMFLAGb(mVU, mReg, mFLAG.write); // Set Mac Flag if (sFLAG.doFlag) { OR32RtoR (sReg, mReg); @@ -76,6 +75,7 @@ microVUt(void) mVUupdateFlags(mV, int reg, int regT1, bool modXYZW = 1) { } } if (regT1b) mVU->regAlloc->clearNeeded(regT1); + if (regT2b) mVU->regAlloc->clearNeeded(regT2); } //------------------------------------------------------------------ @@ -122,11 +122,10 @@ void setupPass1(microVU* mVU, int opCase, bool isACC, bool noFlagUpdate) { void setupFtReg(microVU* mVU, int& Ft, int opCase) { opCase1 { Ft = mVU->regAlloc->allocReg(_Ft_); } opCase2 { - if (!_XYZW_SS) { - Ft = mVU->regAlloc->allocReg(_Ft_, 0, 0xf); - mVUunpack_xyzw(Ft, Ft, _bc_); - } - else Ft = mVU->regAlloc->allocReg(_Ft_); + int tempFt = mVU->regAlloc->allocReg(_Ft_); + Ft = mVU->regAlloc->allocReg(); + mVUunpack_xyzw(Ft, tempFt, _bc_); + mVU->regAlloc->clearNeeded(tempFt); } opCase3 { Ft = mVU->regAlloc->allocReg(); getIreg(Ft, 1); } opCase4 { Ft = mVU->regAlloc->allocReg(); getQreg(Ft); } @@ -147,23 +146,21 @@ void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, co else { Fs = mVU->regAlloc->allocReg(_Fs_, _Fd_, _X_Y_Z_W); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } opCase2 { if (opType == 2) { mVUclamp1(Fs, -1, _X_Y_Z_W); } } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) SSE_SS[opType](mVU, Fs, Ft, -1, -1); else SSE_PS[opType](mVU, Fs, Ft, -1, -1); opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } if (isACC) { if (_XYZW_SS) SSE_MOVSS_XMM_to_XMM(ACC, Fs); else mVUmergeRegs(ACC, Fs, _X_Y_Z_W); - mVUupdateFlags(mVU, ACC, Fs); + mVUupdateFlags(mVU, ACC, Fs, ((opCase==2) ? Ft : -1)); if (_XYZW_SS && _X_Y_Z_W != 8) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); mVU->regAlloc->clearNeeded(ACC); } - else mVUupdateFlags(mVU, Fs, (((opCase==2)&&(!_XYZW_SS)) ? Ft : -1)); + else mVUupdateFlags(mVU, Fs, ((opCase==2) ? Ft : -1)); mVU->regAlloc->clearNeeded(Fs); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); @@ -183,19 +180,17 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* op if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } opCase2 { if (opType == 2) { mVUclamp1(Fs, -1, _X_Y_Z_W); } } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) SSE_SS[2](mVU, Fs, Ft, -1, -1); else SSE_PS[2](mVU, Fs, Ft, -1, -1); opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } if (_XYZW_SS || _X_Y_Z_W == 0xf) { if (_XYZW_SS) SSE_SS[opType](mVU, ACC, Fs, -1, -1); else SSE_PS[opType](mVU, ACC, Fs, -1, -1); - mVUupdateFlags(mVU, ACC, Fs); + mVUupdateFlags(mVU, ACC, Fs, ((opCase==2) ? Ft : -1)); if (_XYZW_SS && _X_Y_Z_W != 8) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } else { @@ -225,17 +220,15 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, const char* opName) { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } opCase2 { mVUclamp1(Fs, -1, _X_Y_Z_W); } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) { SSE_SS[2](mVU, Fs, Ft, -1, -1); SSE_SS[0](mVU, Fs, ACC, -1, -1); } else { SSE_PS[2](mVU, Fs, Ft, -1, -1); SSE_PS[0](mVU, Fs, ACC, -1, -1); } - mVUupdateFlags(mVU, Fs, -1); - if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } + + mVUupdateFlags(mVU, Fs, ((opCase==2) ? Ft : -1)); mVU->regAlloc->clearNeeded(Fs); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); @@ -255,15 +248,13 @@ void mVU_FMACd(microVU* mVU, int recPass, int opCase, const char* opName) { Fd = mVU->regAlloc->allocReg(32, _Fd_, _X_Y_Z_W); opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } - + if (_XYZW_SS) { SSE_SS[2](mVU, Fs, Ft, -1, -1); SSE_SS[1](mVU, Fd, Fs, -1, -1); } else { SSE_PS[2](mVU, Fs, Ft, -1, -1); SSE_PS[1](mVU, Fd, Fs, -1, -1); } - mVUupdateFlags(mVU, Fd, Fs); - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (_XYZW_SS && (!_bc_x)) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS((1 << (3 - _bc_)))); } } + + mVUupdateFlags(mVU, Fd, Fs, ((opCase==2) ? Ft : -1)); mVU->regAlloc->clearNeeded(Fd); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); @@ -294,10 +285,9 @@ mVUop(mVU_OPMULA) { SSE2_PSHUFD_XMM_to_XMM(Fs, Fs, 0xC9); // WXZY SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, 0xD2); // WYXZ SSE_MULPS_XMM_to_XMM(Fs, Ft); - mVUupdateFlags(mVU, Fs, Ft); - - mVU->regAlloc->clearNeeded(Fs); mVU->regAlloc->clearNeeded(Ft); + mVUupdateFlags(mVU, Fs); + mVU->regAlloc->clearNeeded(Fs); } pass3 { mVUlog("OPMULA"); mVUlogACC(); mVUlogFt(); } } @@ -314,11 +304,11 @@ mVUop(mVU_OPMSUB) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, 0xD2); // WYXZ SSE_MULPS_XMM_to_XMM(Fs, Ft); SSE_SUBPS_XMM_to_XMM(ACC, Fs); - mVUupdateFlags(mVU, ACC, Fs); - - mVU->regAlloc->clearNeeded(ACC); mVU->regAlloc->clearNeeded(Fs); - mVU->regAlloc->clearNeeded(Ft); + mVU->regAlloc->clearNeeded(Ft); + mVUupdateFlags(mVU, ACC); + mVU->regAlloc->clearNeeded(ACC); + } pass3 { mVUlog("OPMSUB"); mVUlogFd(); mVUlogFt(); } } From d19077663998800ababe0c5e55e28e31aec0696c Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Mon, 27 Jul 2009 04:27:08 +0000 Subject: [PATCH 16/22] microVU: fixed a bug in my clamping code from r1568. Fixes TOTA invisible characters when clamp-mode set to 'normal' git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1575 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_Upper.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index 634c26fc96..e5b2011d45 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -180,7 +180,7 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* op if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (opType == 2) { mVUclamp1(Fs, -1, _X_Y_Z_W); } } // Clamp Needed for alot of games (TOTA, DoM, etc...) + opCase2 { mVUclamp1(Fs, -1, _X_Y_Z_W); } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) SSE_SS[2](mVU, Fs, Ft, -1, -1); else SSE_PS[2](mVU, Fs, Ft, -1, -1); From 2cbb853535c37498f62950113297a5b3f9a81fb0 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Mon, 27 Jul 2009 23:51:52 +0000 Subject: [PATCH 17/22] Working on a brand new plugin interface, based on passing APIs via structure instead of individually binding each function (which is generally cumbersome and limited in a number of ways). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1576 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/PluginCallbacks.h | 416 ++++++++++++++++++++++++++++++- 1 file changed, 409 insertions(+), 7 deletions(-) diff --git a/common/include/PluginCallbacks.h b/common/include/PluginCallbacks.h index e7334820ee..01dda949ac 100644 --- a/common/include/PluginCallbacks.h +++ b/common/include/PluginCallbacks.h @@ -20,14 +20,413 @@ #ifndef __PLUGINCALLBACKS_H__ #define __PLUGINCALLBACKS_H__ -extern "C" +#include "x86caps.h" // fixme: x86caps.h needs to be implemented from the pcsx2 emitter cpucaps structs + +#ifndef __cplusplus +extern "C" { +#endif + +////////////////////////////////////////////////////////////////////////////////////////// +// HWND is our only operating system dependent type. For it to be defined as accurately +// as possible, this header file needs to be included after whatever window/GUI platform +// headers you need (wxWidgets, Windows.h, GTK, etc). +// +// We could be lazy with this typedef, because window handles are always a (void*) on all +// platforms that matter to us (windows, gtk, OSX). But Windows has some type strictness +// on its HWND define that could be useful, and well it's probably good practice to use +// platform available defines when they exist. +// +#if defined( _WX_DEFS_H_ ) + + typedef WXWidget PS2E_HWND; + +#elif defined( _WINDEF_ ) + + // For Windows let's use HWND, since it has some type strictness applied to it. + typedef HWND PS2E_HWND; + +#else + // Unsupported platform... use void* as a best guess. Should work fine for almost + // any GUI platform, and certainly works for any currently supported one. + typedef void* PS2E_HWND; +#endif + +////////////////////////////////////////////////////////////////////////////////////////// +// Plugin Type / Version Enumerations +// +enum PS2E_ComponentTypes { -// General -typedef u32 (CALLBACK* _PS2EgetLibType)(void); -typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type); -typedef char*(CALLBACK* _PS2EgetLibName)(void); -typedef void (CALLBACK* _PS2EpassConfig)(PcsxConfig *Config); -typedef void (CALLBACK* _PS2EpassIniPath)(const char *path); + PS2E_TYPE_GS=0, + PS2E_TYPE_PAD, + PS2E_TYPE_SPU2, + PS2E_TYPE_CDVD, + PS2E_TYPE_DEV9, + PS2E_TYPE_USB, + PS2E_TYPE_FW, + PS2E_TYPE_SIO, + +}; + +enum PluginLibVersion +{ + PS2E_VER_GS = 0x1000, + PS2E_VER_PAD = 0x1000, + PS2E_VER_SPU2 = 0x1000, + PS2E_VER_CDVD = 0x1000, + PS2E_VER_DEV9 = 0x1000, + PS2E_VER_USB = 0x1000, + PS2E_VER_FW = 0x1000, + PS2E_VER_SIO = 0x1000 +}; + +enum OSDIconTypes +{ + OSD_Icon_None = 0, + OSD_Icon_Error, + OSD_Icon_Notice, // An exclamation point maybe? + + // [TODO] -- dunno. What else? + + // Emulators implementing their own custom non-standard icon extensions should do so + // somewhere after OSD_Icon_ReserveEnd. All values below this are + OSD_Icon_ReserveEnd = 0x1000 +}; + +///////////////////////////////////////////////////////////////////////////////////////// +// PS2E_VersionInfo +// +// This structure is populated by the plugin via the PS2E_PluginLibAPI::GetVersion() +// callback. Specify -1 for any Version or Revision to disable/ignore it. The emulator +// will not factor that info into the display name of the plugin. +// +typedef struct PS2E_VersionInfo +{ + // Low/Mid/High versions combine to form a number in the format of: 2.3.1 + // ... where 2 is the high version, 3 mid, and 1 low. + s16 VersionLow; + s16 VersionMid; + s16 VersionHigh; + + // Revision typically refers a revision control system (such as SVN). When displayed + // by the emulator it will have an 'r' prefixed before it. + s32 Revision; + +} PS2E_VersionInfo; + +////////////////////////////////////////////////////////////////////////////////////////// +// PS2E_MachineInfo +// +// This struct is populated by the emulator when the application is started, and is passed +// to plugins via PS2E_PluginLibAPI::Init(). Plugins may optionally use this information +// to determine compatibility or to select which special CPU-oriented builds and/or functions +// to bind to callbacks. +// +// Fields marked as Optional can either be NULL or -1, denoting the field is unused/ignored. +// +typedef struct _PS2E_MachineInfo +{ + const x86CPU_INFO* x86caps; + + // brief name of the emulator (ex: "PCSX2") [required] + // Depending on the design of the emulator, this string may optionally include version + // information, however that is not recommended since it can inhibit backward support. + const char* EmuName; + + s16 EmuVersionLow; // [optional] + s16 EmuVersionMid; // [optional] + s16 EmuVersionHigh; // [optional] + s32 EmuRevision; // emulator's revision number. [optional] + +} PS2E_MachineInfo; + +////////////////////////////////////////////////////////////////////////////////////////// +// PS2E_SessionInfo +// +// This struct is populated by the emulator prior to starting emulation, and is passed to +// each plugin via a call to PS2E_PluginLibAPI::EmuStart(). +// +typedef struct _PS2E_SessionInfo +{ + PS2E_HWND window; + + u32* CycleEE; // current EE cycle count + u32* CycleIOP; // current IOP cycle count + +} PS2E_SessionInfo; + +///////////////////////////////////////////////////////////////////////////////////////// +// PS2E_EmulatorAPI +// +// These functions are provided to the PS2 plugins by the emulator. Plugins may call these +// functions to perform operations or retrieve data. +// +typedef struct _PS2E_EmulatorAPI +{ + // TODO : Create the ConsoleLogger class. + // Provides a set of basic console functions for writing text to the emulator's + // console. Some emulators may not support a console, in which case these functions + // will be NOPs. For plain and simple to-disk logging, plugins should create and use + // their own logging facilities. + ConsoleLogger* Console; + + // OSD_WriteLn + // This function allows the plugin to post messages to the emulator's On-Screen Display. + // The OSD message will be displayed with the specified icon (optional) for the duration + // of a few seconds, or until other messages have scrolled it out of view. + // Implementation of the OSD is emulator specific, and there is no guarantee that the + // OSD will be honored at all. If the emulator does not support OSD then this function + // call is treated as a NOP. + // + // Typically a plugin author should only use the OSD for infrequent notices that are + // potentially useful to users playing games (particuarly at fullscreen). Troubleshooting + // and debug information is best dumped to console or to disk log. + // + // Parameters: + // icon - an icon identifier, typically from the PS2E_OSDIconTypes enumeration. Specific + // versions of emulators may provide their own icon extensions. The emulator will + // silently ignore unrecognized icon identifiers, thus retaining cross-compat. + // + // msg - string message displayed to the user. + void (CALLBACK* OSD_WriteLn)( int icon, const char* msg ); + +} PS2E_EmulatorAPI; + +///////////////////////////////////////////////////////////////////////////////////////// +// PS2E_LibraryAPI +// +// The LibraryAPI is an overall library-scope set of functions that perform basic Init, +// Shutdown, and global configuration operations. +// +// These are functions provided to the PS2 emulator from the plugin. The emulator will +// call these functions and expect the plugin to perform defined tasks. +// +// Threading: +// - get* callbacks in this struct are not bound to any particular thread. Implementations +// should not assume any specific thread affinity. +// +// - set* callbacks in this struct are bound to the GUI thread of the emulator, and will +// always be invoked from that thread. +// +typedef struct _PS2E_LibraryAPI +{ + // GetInformation + // This function returns name and version information for the requested PS2 plugin + // type. If the plugin does not support the requested type, it should return NULL. + // The returned pointer, if non-NULL, must be valid for the lifetime of the plugin + // (ie, must be either a static value [recommended] or a heap-allocated value). + // + // This function may be called multiple times by the emulator, so it should accommodate + // for such if it performs heap allocations or other initialization procedures. + // + // See PS2E_VersionInfo for more details. + // + // Parameters: + // type - indicates the ps2 plugin type that should be versioned. If the plugin + // does not support the requested bit, the function should return NULL. + // + const PS2E_VersionInfo* (CALLBACK* GetVersion)( u32 type ); + + // GetName + // Returns an ASCII-Z (zero-terminated) string name of the plugin. The name should + // *not* include version or build information. That info is returned separately + // via GetVersion. The return value cannot be NULL. + // + // The pointer should reference a static/global scope char array, or an allocated + // heap pointer (not recommended). + // + // This function may be called multiple times by the emulator, so it should accommodate + // for such if it performs heap allocations or other initialization procedures. + const char* (CALLBACK* GetName)(void); + + // SetSettingsFolder + // Callback is passed an ASCII-Z string representing the folder where the emulator's + // settings files are stored (may either be under the user's documents folder, or a + // location relative to the CWD of the emu application). + // + // Typically this callback is only issued once per plugin session. Settings folder + // location may be change dynamically, however it is considered the responsibility + // of the emu to save the emulation state, shutdown plugins, and restart everything + // anew from the new settings in such an event. + void (CALLBACK* SetSettingsFolder)( const char* folder ); + + // SetSnapshotsFolder + // This callback may be issued at any time. + void (CALLBACK* SetSnapshotsFolder)( const char* folder ); + + // SetLogFolder + // This callback may be issued at any time. It is the responsibility of the plugin + // to do the necessary actions to close existing disk logging facilities and re-open + // new facilities. + void (CALLBACK* SetLogFolder)( const char* folder ); + +} PS2E_LibraryAPI; + +////////////////////////////////////////////////////////////////////////////////////////// +// PS2E_ComponentAPI +// +// The PluginTypeAPI is provided for every PS2 plugin type (see PS2E_PluginTypes enumeration). +// For typical dlls which only provide one plugin type of functionality, the plugin only +// needs one instance of this struct. For multi-type plugins, for example a plugin that +// supports both DEV9 and FW together, an interface must be provided for each plugin type +// supported. +// +// These are functions provided to the PS2 emulator from the plugin. The emulator will +// call these functions and expect the plugin to perform defined tasks. +// +typedef struct _PS2E_ComponentAPI +{ + // Init + // Init is called *once* for the duration of a loaded PS2 component, and is the partner + // to Shutdown, which is also called once prior to the component being unloaded. + // This function is roughly equivalent to DllMain on Windows platforms, in that it is + // called in connection with the DLL being loaded into memory, except that it is specific + // to the scope of a specific plugin component (allowing the user to selectively bind + // parts of a multi-component plugin, and leave other components unused). + // + // Parameters: + // xinfo - Machine info and capabilities, usable for cpu detection. This pointer is + // valid for the duration of the plugin's tenure in memory. + // + // Returns: + // A pointer to a static structure that contains the API for this plugin, or NULL if + // the plugin failed initialization or is unsupported by the machine. + // + // Exceptions (C++ only): + // [TODO] + u32 (CALLBACK* Init)( const PS2E_MachineInfo* xinfo ); + + // Shutdown + // This function is called *once* for the duration of a loaded plugin type, and is the + // partner to PS2E_Init, which is also called once after a plugin is loaded into memory. + // This function is roughly equivalent to DllMain on Windows platforms, in that it is + // called in connection with the DLL being loaded into memory. + // + // If PS2E_Init returns NULL, this method will not be called (which might seem obvious + // but bears saying anyway). + void (CALLBACK* Shutdown)(); + + // EmuStart + // This function is called by the emulator when an emulation session is started. The + // plugin should take this opportunity to bind itself to the given window handle, open + // necessary audio/video/input devices, etc. + // + // Parameters: + // session - provides relevant emulation session information. Provided pointer is + // valid until after the subsequent call to EmuClose() + // + // Threading: EmuStart is called from the GUI thread. All other emulation threads are + // guaranteed to be suspended or closed at the time of this call (no locks required). + // + void (CALLBACK* EmuStart)( const PS2E_SessionInfo *session ); + + // EmuClose + // This function is called by the emulator prior to stopping emulation. The window + // handle specified in EmuStart is guaranteed to be valid at the time EmuClose is called, + // and the plugin should unload/unbind all window dependencies at this time. + // + // This function differs from the PS2E_LibraryAPI::EmuClose() function in that it is + // called for each component this plugin is bound to. In most typical cases the LibraryAPI + // version is better and easier, but in the eventprovided to allow plugins to adhere to a specific plugin initialization + // pattern, if needed. However in most typical cases, the parameter can be + // ignored and the library can simply initialize itself once for all types and + // ignore subsequent calls. + // + // Threading: EmuClose is called from the GUI thread. All other emulation threads are + // guaranteed to be suspended or closed at the time of this call (no locks required). + // + void (CALLBACK* EmuClose)(); + + // CalcFreezeSize + // This function should calculate and return the amount of memory needed for the plugin + // to freeze its complete emulation state. The value can be larger than the required + // amount of space, but cannot be smaller. + // + // The emulation state when this function is called is guaranteed to be the same as + // the following call to Freeze. + // + // Thread Safety: + // May be called from any thread (GUI, Emu, GS, Unknown, etc). + // All Emulation threads are halted at a PS2 logical vsync-end event. + // No locking is necessary. + u32 (CALLBACK* CalcFreezeSize)(); + + // Freeze + // This function should make a complete copy of the plugin's emulation state into the + // provided dest->Data pointer. The plugin is allowed to reduce the dest->Size value + // but is not allowed to make it larger. The plugin will only receive calls to Freeze + // and Thaw while a plugin is in an EmuStart() state. + // + // Parameters: + // dest - a pointer to the Data/Size destination buffer (never NULL). + // + // Thread Safety: + // May be called from any thread (GUI, Emu, GS, Unknown, etc). + // All Emulation threads are halted at a PS2 logical vsync-end event. + // No locking is necessary. + void (CALLBACK* Freeze)( PS2E_FreezeData* dest ); + + // Thaw + // Plugin should restore a complete emulation state from the given FreezeData. The + // plugin will only receive calls to Freeze and Thaw while a plugin is in an EmuStart() + // state. + // + // Thread Safety: + // May be called from any thread (GUI, Emu, GS, Unknown, etc). + // All Emulation threads are halted at a PS2 logical vsync-end event. + // No locking is necessary. + void (CALLBACK* Thaw)( const PS2E_FreezeData* src ); + + // Configure + // The plugin should open a modal dialog box with plugin-specific settings and prop- + // erties. This function can be NULL, in which case the user's Configure option for + // this plugin is grayed out. + // + // All emulation is suspended and the plugin's state is saved to memory prior to this + // function being called. Configure is only called outside the context of EmuStart() + // (after a call to EmuClose()). + // + // Plugin authors should ensure to re-read and re-apply all settings on EmuStart(), + // which will ensure that any user changes will be applied immediately. For changes + // that can be applied without emulation suspension, see/use the GUI extensions for + // menu and toolbar shortcuts. + // + // Thread Safety: + // Always called from the GUI thread, with emulation in a halted state (no locks + // needed). + void (CALLBACK* Configure)(); + +} PS2E_ComponentAPI; + +typedef struct _PS2E_FreezeData +{ + u32 Size; // size of the data being frozen or thawed. This value is allowed to be changed by Freeze(). + void* Data; // pointer to the data target (freeze) or source (thaw) + +} PS2E_FreezeData; + +// PS2E_InitAPI +// Init is called *once* for the duration of a loaded plugin type, and is the partner +// to Shutdown, which is also called once prior to the plugin being unloaded. +// This function is roughly equivalent to DllMain on Windows platforms, in that it is +// called in connection with the DLL being loaded into memory. +// +// Parameters: +// xinfo - Machine info and capabilities, usable for cpu detection. This pointer is +// valid for the duration of the plugin's tenure in memory. +// +// Returns: +// A pointer to a static structure that contains the API for this plugin, or NULL if +// the plugin failed initialization or is unsupported by the machine. +typedef const PS2E_PluginLibAPI* (CALLBACK* _PS2E_InitAPI)( const PS2E_MachineInfo* xinfo ); + + +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// +// Begin old legacy API here (present for reference purposes only, until all plugin API +// specifics have been accounted for) +////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////// + // GS // NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs @@ -428,6 +827,9 @@ extern _FWconfigure FWconfigure; extern _FWfreeze FWfreeze; extern _FWtest FWtest; extern _FWabout FWabout; + +#ifndef __cplusplus } +#endif #endif // __PLUGINCALLBACKS_H__ From 3935927a99714161ad7cdb306fe7eea94aaeb170 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 28 Jul 2009 01:25:51 +0000 Subject: [PATCH 18/22] Cleaned up some loose ends I left behind in my initial rough draft of PluginCallbacks.h, and added some eol-style:native properties to /common/include files that lacked them. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1577 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/PluginCallbacks.h | 214 ++++++++++++++++++------------- 1 file changed, 123 insertions(+), 91 deletions(-) diff --git a/common/include/PluginCallbacks.h b/common/include/PluginCallbacks.h index 01dda949ac..c68f3d63c1 100644 --- a/common/include/PluginCallbacks.h +++ b/common/include/PluginCallbacks.h @@ -21,7 +21,7 @@ #define __PLUGINCALLBACKS_H__ #include "x86caps.h" // fixme: x86caps.h needs to be implemented from the pcsx2 emitter cpucaps structs - + #ifndef __cplusplus extern "C" { #endif @@ -64,8 +64,8 @@ enum PS2E_ComponentTypes PS2E_TYPE_USB, PS2E_TYPE_FW, PS2E_TYPE_SIO, - -}; + +}; enum PluginLibVersion { @@ -191,84 +191,28 @@ typedef struct _PS2E_EmulatorAPI } PS2E_EmulatorAPI; -///////////////////////////////////////////////////////////////////////////////////////// -// PS2E_LibraryAPI + +////////////////////////////////////////////////////////////////////////////////////////// +// PS2E_FreezeData // -// The LibraryAPI is an overall library-scope set of functions that perform basic Init, -// Shutdown, and global configuration operations. +// Structure used to pass savestate info between emulator and plugin. // -// These are functions provided to the PS2 emulator from the plugin. The emulator will -// call these functions and expect the plugin to perform defined tasks. -// -// Threading: -// - get* callbacks in this struct are not bound to any particular thread. Implementations -// should not assume any specific thread affinity. -// -// - set* callbacks in this struct are bound to the GUI thread of the emulator, and will -// always be invoked from that thread. -// -typedef struct _PS2E_LibraryAPI +typedef struct _PS2E_FreezeData { - // GetInformation - // This function returns name and version information for the requested PS2 plugin - // type. If the plugin does not support the requested type, it should return NULL. - // The returned pointer, if non-NULL, must be valid for the lifetime of the plugin - // (ie, must be either a static value [recommended] or a heap-allocated value). - // - // This function may be called multiple times by the emulator, so it should accommodate - // for such if it performs heap allocations or other initialization procedures. - // - // See PS2E_VersionInfo for more details. - // - // Parameters: - // type - indicates the ps2 plugin type that should be versioned. If the plugin - // does not support the requested bit, the function should return NULL. - // - const PS2E_VersionInfo* (CALLBACK* GetVersion)( u32 type ); + u32 Size; // size of the data being frozen or thawed. This value is allowed to be changed by Freeze(). + void* Data; // pointer to the data target (freeze) or source (thaw) - // GetName - // Returns an ASCII-Z (zero-terminated) string name of the plugin. The name should - // *not* include version or build information. That info is returned separately - // via GetVersion. The return value cannot be NULL. - // - // The pointer should reference a static/global scope char array, or an allocated - // heap pointer (not recommended). - // - // This function may be called multiple times by the emulator, so it should accommodate - // for such if it performs heap allocations or other initialization procedures. - const char* (CALLBACK* GetName)(void); +} PS2E_FreezeData; - // SetSettingsFolder - // Callback is passed an ASCII-Z string representing the folder where the emulator's - // settings files are stored (may either be under the user's documents folder, or a - // location relative to the CWD of the emu application). - // - // Typically this callback is only issued once per plugin session. Settings folder - // location may be change dynamically, however it is considered the responsibility - // of the emu to save the emulation state, shutdown plugins, and restart everything - // anew from the new settings in such an event. - void (CALLBACK* SetSettingsFolder)( const char* folder ); - - // SetSnapshotsFolder - // This callback may be issued at any time. - void (CALLBACK* SetSnapshotsFolder)( const char* folder ); - - // SetLogFolder - // This callback may be issued at any time. It is the responsibility of the plugin - // to do the necessary actions to close existing disk logging facilities and re-open - // new facilities. - void (CALLBACK* SetLogFolder)( const char* folder ); - -} PS2E_LibraryAPI; ////////////////////////////////////////////////////////////////////////////////////////// // PS2E_ComponentAPI // -// The PluginTypeAPI is provided for every PS2 plugin type (see PS2E_PluginTypes enumeration). -// For typical dlls which only provide one plugin type of functionality, the plugin only -// needs one instance of this struct. For multi-type plugins, for example a plugin that -// supports both DEV9 and FW together, an interface must be provided for each plugin type -// supported. +// The PluginTypeAPI is provided for every PS2 component plugin (see PS2E_ComponentTypes +// enumeration). For typical dlls which only provide one plugin type of functionality, +// the plugin only needs one instance of this struct. For multi-type plugins, for example +// a plugin that supports both DEV9 and FW together, an interface must be provided for +// each component supported. // // These are functions provided to the PS2 emulator from the plugin. The emulator will // call these functions and expect the plugin to perform defined tasks. @@ -296,7 +240,7 @@ typedef struct _PS2E_ComponentAPI u32 (CALLBACK* Init)( const PS2E_MachineInfo* xinfo ); // Shutdown - // This function is called *once* for the duration of a loaded plugin type, and is the + // This function is called *once* for the duration of a loaded component, and is the // partner to PS2E_Init, which is also called once after a plugin is loaded into memory. // This function is roughly equivalent to DllMain on Windows platforms, in that it is // called in connection with the DLL being loaded into memory. @@ -324,13 +268,6 @@ typedef struct _PS2E_ComponentAPI // handle specified in EmuStart is guaranteed to be valid at the time EmuClose is called, // and the plugin should unload/unbind all window dependencies at this time. // - // This function differs from the PS2E_LibraryAPI::EmuClose() function in that it is - // called for each component this plugin is bound to. In most typical cases the LibraryAPI - // version is better and easier, but in the eventprovided to allow plugins to adhere to a specific plugin initialization - // pattern, if needed. However in most typical cases, the parameter can be - // ignored and the library can simply initialize itself once for all types and - // ignore subsequent calls. - // // Threading: EmuClose is called from the GUI thread. All other emulation threads are // guaranteed to be suspended or closed at the time of this call (no locks required). // @@ -397,18 +334,108 @@ typedef struct _PS2E_ComponentAPI } PS2E_ComponentAPI; -typedef struct _PS2E_FreezeData -{ - u32 Size; // size of the data being frozen or thawed. This value is allowed to be changed by Freeze(). - void* Data; // pointer to the data target (freeze) or source (thaw) -} PS2E_FreezeData; +///////////////////////////////////////////////////////////////////////////////////////// +// PS2E_LibraryAPI +// +// The LibraryAPI is an overall library-scope set of functions that perform basic Init, +// Shutdown, and global configuration operations. +// +// These are functions provided to the PS2 emulator from the plugin. The emulator will +// call these functions and expect the plugin to perform defined tasks. +// +// Threading: +// - get* callbacks in this struct are not bound to any particular thread. Implementations +// should not assume any specific thread affinity. +// +// - set* callbacks in this struct are bound to the GUI thread of the emulator, and will +// always be invoked from that thread. +// +typedef struct _PS2E_LibraryAPI +{ + // GetName + // Returns an ASCII-Z (zero-terminated) string name of the plugin. The name should + // *not* include version or build information. That info is returned separately + // via GetVersion. The return value cannot be NULL. + // + // The pointer should reference a static/global scope char array, or an allocated + // heap pointer (not recommended). + // + // This function may be called multiple times by the emulator, so it should accommodate + // for such if it performs heap allocations or other initialization procedures. + const char* (CALLBACK* GetName)(void); + + // GetVersion + // This function returns name and version information for the requested PS2 component. + // If the plugin does not support the requested component, it should return NULL. + // The returned pointer, if non-NULL, must be either a static value [recommended] or a + // heap-allocated value, and valid for the lifetime of the plugin. + // + // This function may be called multiple times by the emulator, so it should accommodate + // for such if it performs heap allocations or other initialization procedures. + // + // Typically a plugin will return the same version for all supported components. The + // component parameter is mostly provided to allow this function to serve a dual purpose + // of both component versioning and as a component enumerator. + // + // See PS2E_VersionInfo for more details. + // + // Parameters: + // component - indicates the ps2 component plugin to be versioned. If the plugin + // does not support the requested component, the function should return NULL. + // + const PS2E_VersionInfo* (CALLBACK* GetVersion)( u32 component ); + + // GetComponentAPI + // The emulator calls this function to fetch the API for the requested component. + // The plugin is expected to perform an "availability test" and return NULL if the + // plugin does not support the host machine's hardware or software installations. + // + // This function is only called for components which the plugin returned a non-NULL + // version information struct for in GetVersion(). IT may be called more than once + // per supported component, however, since it serves the dual purpose of both an API + // fetch and an availability test. + // + // Parameters: + // component - indicates the ps2 component API to return. + // + // Exceptions: + // C++ Plugins may alternately use exception handling to return more detailed + // information on why the plugin failed it's availability test. [TODO] + // + const PS2E_ComponentAPI* (CALLBACK* GetComponentAPI)( u32 component ); + + // SetSettingsFolder + // Callback is passed an ASCII-Z string representing the folder where the emulator's + // settings files are stored (may either be under the user's documents folder, or a + // location relative to the CWD of the emu application). + // + // Typically this callback is only issued once per plugin session. Settings folder + // location may be change dynamically, however it is considered the responsibility + // of the emu to save the emulation state, shutdown plugins, and restart everything + // anew from the new settings in such an event. + void (CALLBACK* SetSettingsFolder)( const char* folder ); + + // SetSnapshotsFolder + // This callback may be issued at any time. + void (CALLBACK* SetSnapshotsFolder)( const char* folder ); + + // SetLogFolder + // This callback may be issued at any time. It is the responsibility of the plugin + // to do the necessary actions to close existing disk logging facilities and re-open + // new facilities. + void (CALLBACK* SetLogFolder)( const char* folder ); + +} PS2E_LibraryAPI; // PS2E_InitAPI -// Init is called *once* for the duration of a loaded plugin type, and is the partner -// to Shutdown, which is also called once prior to the plugin being unloaded. -// This function is roughly equivalent to DllMain on Windows platforms, in that it is -// called in connection with the DLL being loaded into memory. +// Called by the emulator when the plugin is loaded into memory. The emulator uses the +// presence of this function to detect PS2E-v2 plugin API, and will direct all subsequent +// calls through the returned LibraryAPI. The function is allowed to return NULL if the +// emulator's version information or machine capabilities are insufficient for the +// plugin's needs. +// +// This function is called *once* for the duration of a loaded plugin. // // Parameters: // xinfo - Machine info and capabilities, usable for cpu detection. This pointer is @@ -416,8 +443,13 @@ typedef struct _PS2E_FreezeData // // Returns: // A pointer to a static structure that contains the API for this plugin, or NULL if -// the plugin failed initialization or is unsupported by the machine. -typedef const PS2E_PluginLibAPI* (CALLBACK* _PS2E_InitAPI)( const PS2E_MachineInfo* xinfo ); +// the plugin explicitly does not support the emulator version. +// +// Exceptions: +// C++ Plugins can use exceptions instead of NULL to return additional information on +// why the plugin failed to init the API. [TODO] +// +typedef const PS2E_LibraryAPI* (CALLBACK* _PS2E_InitAPI)( const PS2E_MachineInfo* xinfo ); ////////////////////////////////////////////////////////////////////////////////////////// From 2bcf704ff3c1df0f952b74b9b1c3153affa6f9f5 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Tue, 28 Jul 2009 01:36:37 +0000 Subject: [PATCH 19/22] microVU: Improved microProgram management/searching. Instead of just having live/dead programs, we now have young/old/dead programs. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1578 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU.cpp | 34 +++++++++++++++++++++++----------- pcsx2/x86/microVU.h | 3 ++- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/pcsx2/x86/microVU.cpp b/pcsx2/x86/microVU.cpp index 8b5611a0b7..a4630a3e1e 100644 --- a/pcsx2/x86/microVU.cpp +++ b/pcsx2/x86/microVU.cpp @@ -134,6 +134,7 @@ microVUf(void) mVUclearProg(int progIndex) { microVU* mVU = mVUx; mVUprogI.used = 0; mVUprogI.isDead = 1; + mVUprogI.isOld = 1; mVUprogI.frame = mVU->prog.curFrame; for (int j = 0; j <= mVUprogI.ranges.max; j++) { mVUprogI.ranges.range[j][0] = -1; // Set range to @@ -173,8 +174,9 @@ microVUf(int) mVUfindLeastUsedProg() { if (mVU->prog.prog[i].isDead) { mVU->prog.total++; mVUcacheProg(i); // Cache Micro Program - mVU->prog.prog[i].isDead = 0; - mVU->prog.prog[i].used = 1; + mVU->prog.prog[i].isDead = 0; + mVU->prog.prog[i].isOld = 0; + mVU->prog.prog[i].used = 1; mVUsortProg(mVU, i); Console::Notice("microVU%d: Cached MicroPrograms = [%03d] [%03d]", params vuIndex, i+1, mVU->prog.total+1); return i; @@ -189,14 +191,15 @@ microVUf(int) mVUfindLeastUsedProg() { } mVU->prog.total -= ((mVU->prog.max+1)/4)-1; mVUcacheProg(pIdx); // Cache Micro Program - mVU->prog.prog[pIdx].isDead = 0; - mVU->prog.prog[pIdx].used = 1; + mVU->prog.prog[pIdx].isDead = 0; + mVU->prog.prog[pIdx].isOld = 0; + mVU->prog.prog[pIdx].used = 1; mVUsortProg(mVU, pIdx); Console::Notice("microVU%d: Cached MicroPrograms = [%03d] [%03d]", params vuIndex, pIdx+1, mVU->prog.total+1); return pIdx; } -// Finds and Kills Programs if they haven't been used in a while. +// Finds and Ages/Kills Programs if they haven't been used in a while. microVUt(void) mVUvsyncUpdate(mV) { for (int i = 0; i <= mVU->prog.max; i++) { if (mVU->prog.prog[i].isDead) continue; @@ -204,12 +207,16 @@ microVUt(void) mVUvsyncUpdate(mV) { mVU->prog.prog[i].used = 0; mVU->prog.prog[i].frame = mVU->prog.curFrame; } - if((mVU->prog.curFrame - mVU->prog.prog[i].frame) >= (60 * 7)) { + if((mVU->prog.curFrame - mVU->prog.prog[i].frame) >= (360 * 10)) { mVU->prog.total--; if (!mVU->index) mVUclearProg<0>(i); else mVUclearProg<1>(i); DevCon::Status("microVU%d: Killing Dead Program [%03d]", params mVU->index, i+1); } + else if (!mVU->prog.prog[i].isOld && ((mVU->prog.curFrame - mVU->prog.prog[i].frame) >= (30 * 1))) { + mVU->prog.prog[i].isOld = 1; + //DevCon::Status("microVU%d: Aging Old Program [%03d]", params mVU->index, i+1); + } } mVU->prog.curFrame++; } @@ -227,15 +234,16 @@ microVUf(bool) mVUcmpPartial(int progIndex) { } // Compare Cached microProgram to mVU->regs->Micro -microVUf(bool) mVUcmpProg(int progIndex, const bool cmpWholeProg) { +microVUf(bool) mVUcmpProg(int progIndex, const bool checkOld, const bool cmpWholeProg) { microVU* mVU = mVUx; - if (!mVUprogI.isDead) { + if (!mVUprogI.isDead && (checkOld == mVUprogI.isOld)) { if ((cmpWholeProg && !memcmp_mmx((u8*)mVUprogI.data, mVU->regs->Micro, mVU->microMemSize)) || (!cmpWholeProg && mVUcmpPartial(progIndex))) { mVU->prog.cur = progIndex; mVU->prog.cleared = 0; mVU->prog.isSame = cmpWholeProg ? 1 : -1; - mVU->prog.prog[progIndex].used = 1; + mVU->prog.prog[progIndex].used = 1; + mVU->prog.prog[progIndex].isOld = 0; return 1; } } @@ -247,8 +255,12 @@ microVUf(int) mVUsearchProg() { microVU* mVU = mVUx; if (mVU->prog.cleared) { // If cleared, we need to search for new program for (int i = mVU->prog.max; i >= 0; i--) { - if (mVUcmpProg(mVU->prog.progList[i], 0)) - return 1; + if (mVUcmpProg(mVU->prog.progList[i], 0, 0)) + return 1; // Check Young Programs + } + for (int i = mVU->prog.max; i >= 0; i--) { + if (mVUcmpProg(mVU->prog.progList[i], 1, 0)) + return 1; // Check Old Programs } mVU->prog.cur = mVUfindLeastUsedProg(); // If cleared and program not found, make a new program instance mVU->prog.cleared = 0; diff --git a/pcsx2/x86/microVU.h b/pcsx2/x86/microVU.h index 605d8a9e59..be067f2800 100644 --- a/pcsx2/x86/microVU.h +++ b/pcsx2/x86/microVU.h @@ -110,7 +110,8 @@ struct microProgram { microRange ranges; // The ranges of the microProgram that have already been recompiled u32 frame; // Frame # the program was last used on u32 used; // Program was used this frame? - bool isDead; // Program is dead? + bool isDead; // Program is Dead? + bool isOld; // Program is Old? (Program hasn't been used in a while) }; #define mMaxProg ((mVU->index)?400:8) // The amount of Micro Programs Recs will 'remember' (For n = 1, 2, 4, 8, 16, etc...) From 16fb25c1edccaaf3807a8b002c2dc06bf3fa75d4 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 28 Jul 2009 07:34:49 +0000 Subject: [PATCH 20/22] NewPluginApi: Some tweaks as per Gabest suggestion; probably a tired disaster in need much review. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1579 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/PluginCallbacks.h | 167 ++++++++++++++++++++++++------- 1 file changed, 130 insertions(+), 37 deletions(-) diff --git a/common/include/PluginCallbacks.h b/common/include/PluginCallbacks.h index c68f3d63c1..69c35acc40 100644 --- a/common/include/PluginCallbacks.h +++ b/common/include/PluginCallbacks.h @@ -22,10 +22,6 @@ #include "x86caps.h" // fixme: x86caps.h needs to be implemented from the pcsx2 emitter cpucaps structs -#ifndef __cplusplus -extern "C" { -#endif - ////////////////////////////////////////////////////////////////////////////////////////// // HWND is our only operating system dependent type. For it to be defined as accurately // as possible, this header file needs to be included after whatever window/GUI platform @@ -38,17 +34,54 @@ extern "C" { // #if defined( _WX_DEFS_H_ ) - typedef WXWidget PS2E_HWND; +typedef WXWidget PS2E_HWND; #elif defined( _WINDEF_ ) - // For Windows let's use HWND, since it has some type strictness applied to it. - typedef HWND PS2E_HWND; +// For Windows let's use HWND, since it has some type strictness applied to it. +typedef HWND PS2E_HWND; #else - // Unsupported platform... use void* as a best guess. Should work fine for almost - // any GUI platform, and certainly works for any currently supported one. - typedef void* PS2E_HWND; +// Unsupported platform... use void* as a best guess. Should work fine for almost +// any GUI platform, and certainly works for any currently supported one. +typedef void* PS2E_HWND; +#endif + + +////////////////////////////////////////////////////////////////////////////////////////// +// PS2E_THISPTR - (ps2 component scope 'this' object pointer type) +// +// This macro provides C++ plugin authors with a reasonably friendly way to automatically +// typecast the session objects for your plugin to your internal type. Just #define +// PS2E_THISPTR to your internal structure type prior to loading this header file, and all +// APIs will assume your struct type in their signature. Since all pointer types are inter- +// changeable, plugin APIs will retain full compatibility as long as PS2E_THISPTR is a +// pointer type. +// +#ifndef PS2E_THISPTR +# define PS2E_THISPTR void* +#else + // Ensure the user's defined PS2E_THISPTR retains the correct signature for our + // plugin API. + C_ASSERT( sizeof(PS2E_THISPTR) == sizeof(void*) ); +#endif + +// PS2E_LIB_THISPTR - (library scope version of PS2E_THISPTR) +#ifndef PS2E_LIB_THISPTR +# define PS2E_LIB_THISPTR void* +#else + // Ensure the user's defined PS2E_THISPTR retains the correct signature for our + // plugin API. + C_ASSERT( sizeof(PS2E_LIB_THISPTR) == sizeof(void*) ); +#endif + +// Use fastcall by default, since under most circumstances the object-model approach of the +// API will benefit considerably from it. +#define PS2E_CALLBACK __fastcall + + +#ifndef __cplusplus +extern "C" { #endif ////////////////////////////////////////////////////////////////////////////////////////// @@ -110,7 +143,7 @@ typedef struct PS2E_VersionInfo // Revision typically refers a revision control system (such as SVN). When displayed // by the emulator it will have an 'r' prefixed before it. s32 Revision; - + } PS2E_VersionInfo; ////////////////////////////////////////////////////////////////////////////////////////// @@ -178,8 +211,8 @@ typedef struct _PS2E_EmulatorAPI // call is treated as a NOP. // // Typically a plugin author should only use the OSD for infrequent notices that are - // potentially useful to users playing games (particuarly at fullscreen). Troubleshooting - // and debug information is best dumped to console or to disk log. + // potentially useful to users playing games (particularly at fullscreen). Trouble- + // shooting and debug information is best dumped to console or to disk log. // // Parameters: // icon - an icon identifier, typically from the PS2E_OSDIconTypes enumeration. Specific @@ -187,7 +220,7 @@ typedef struct _PS2E_EmulatorAPI // silently ignore unrecognized icon identifiers, thus retaining cross-compat. // // msg - string message displayed to the user. - void (CALLBACK* OSD_WriteLn)( int icon, const char* msg ); + void (PS2E_CALLBACK* OSD_WriteLn)( int icon, const char* msg ); } PS2E_EmulatorAPI; @@ -217,6 +250,8 @@ typedef struct _PS2E_FreezeData // These are functions provided to the PS2 emulator from the plugin. The emulator will // call these functions and expect the plugin to perform defined tasks. // +// Plugins are expected to use +// typedef struct _PS2E_ComponentAPI { // Init @@ -229,7 +264,8 @@ typedef struct _PS2E_ComponentAPI // // Parameters: // xinfo - Machine info and capabilities, usable for cpu detection. This pointer is - // valid for the duration of the plugin's tenure in memory. + // valid for the duration of the plugin's tenure in memory, and is the same as the + // xinfo pointer passed to PS2E_InitAPI() // // Returns: // A pointer to a static structure that contains the API for this plugin, or NULL if @@ -237,7 +273,7 @@ typedef struct _PS2E_ComponentAPI // // Exceptions (C++ only): // [TODO] - u32 (CALLBACK* Init)( const PS2E_MachineInfo* xinfo ); + u32 (PS2E_CALLBACK* Init)( PS2E_THISPTR thisptr, const PS2E_MachineInfo* xinfo ); // Shutdown // This function is called *once* for the duration of a loaded component, and is the @@ -247,7 +283,7 @@ typedef struct _PS2E_ComponentAPI // // If PS2E_Init returns NULL, this method will not be called (which might seem obvious // but bears saying anyway). - void (CALLBACK* Shutdown)(); + void (PS2E_CALLBACK* Shutdown)( PS2E_THISPTR thisptr ); // EmuStart // This function is called by the emulator when an emulation session is started. The @@ -261,7 +297,7 @@ typedef struct _PS2E_ComponentAPI // Threading: EmuStart is called from the GUI thread. All other emulation threads are // guaranteed to be suspended or closed at the time of this call (no locks required). // - void (CALLBACK* EmuStart)( const PS2E_SessionInfo *session ); + void (PS2E_CALLBACK* EmuStart)( PS2E_THISPTR thisptr, const PS2E_SessionInfo *session ); // EmuClose // This function is called by the emulator prior to stopping emulation. The window @@ -271,7 +307,7 @@ typedef struct _PS2E_ComponentAPI // Threading: EmuClose is called from the GUI thread. All other emulation threads are // guaranteed to be suspended or closed at the time of this call (no locks required). // - void (CALLBACK* EmuClose)(); + void (PS2E_CALLBACK* EmuClose)( PS2E_THISPTR thisptr ); // CalcFreezeSize // This function should calculate and return the amount of memory needed for the plugin @@ -285,7 +321,7 @@ typedef struct _PS2E_ComponentAPI // May be called from any thread (GUI, Emu, GS, Unknown, etc). // All Emulation threads are halted at a PS2 logical vsync-end event. // No locking is necessary. - u32 (CALLBACK* CalcFreezeSize)(); + u32 (PS2E_CALLBACK* CalcFreezeSize)( PS2E_THISPTR thisptr ); // Freeze // This function should make a complete copy of the plugin's emulation state into the @@ -300,7 +336,7 @@ typedef struct _PS2E_ComponentAPI // May be called from any thread (GUI, Emu, GS, Unknown, etc). // All Emulation threads are halted at a PS2 logical vsync-end event. // No locking is necessary. - void (CALLBACK* Freeze)( PS2E_FreezeData* dest ); + void (PS2E_CALLBACK* Freeze)( PS2E_THISPTR thisptr, PS2E_FreezeData* dest ); // Thaw // Plugin should restore a complete emulation state from the given FreezeData. The @@ -311,7 +347,7 @@ typedef struct _PS2E_ComponentAPI // May be called from any thread (GUI, Emu, GS, Unknown, etc). // All Emulation threads are halted at a PS2 logical vsync-end event. // No locking is necessary. - void (CALLBACK* Thaw)( const PS2E_FreezeData* src ); + void (PS2E_CALLBACK* Thaw)( PS2E_THISPTR thisptr, const PS2E_FreezeData* src ); // Configure // The plugin should open a modal dialog box with plugin-specific settings and prop- @@ -330,7 +366,10 @@ typedef struct _PS2E_ComponentAPI // Thread Safety: // Always called from the GUI thread, with emulation in a halted state (no locks // needed). - void (CALLBACK* Configure)(); + void (PS2E_CALLBACK* Configure)( PS2E_THISPTR thisptr ); + + // Reserved area at the end of the structure, for future API expansion. + void* reserved[16]; } PS2E_ComponentAPI; @@ -363,7 +402,7 @@ typedef struct _PS2E_LibraryAPI // // This function may be called multiple times by the emulator, so it should accommodate // for such if it performs heap allocations or other initialization procedures. - const char* (CALLBACK* GetName)(void); + const char* (PS2E_CALLBACK* GetName)( PS2E_LIB_THISPTR thisptr ); // GetVersion // This function returns name and version information for the requested PS2 component. @@ -384,7 +423,7 @@ typedef struct _PS2E_LibraryAPI // component - indicates the ps2 component plugin to be versioned. If the plugin // does not support the requested component, the function should return NULL. // - const PS2E_VersionInfo* (CALLBACK* GetVersion)( u32 component ); + const PS2E_VersionInfo* (PS2E_CALLBACK* GetVersion)( PS2E_LIB_THISPTR thisptr, u32 component ); // GetComponentAPI // The emulator calls this function to fetch the API for the requested component. @@ -398,36 +437,87 @@ typedef struct _PS2E_LibraryAPI // // Parameters: // component - indicates the ps2 component API to return. + // dest - structure to fill with API functions // // Exceptions: // C++ Plugins may alternately use exception handling to return more detailed // information on why the plugin failed it's availability test. [TODO] // - const PS2E_ComponentAPI* (CALLBACK* GetComponentAPI)( u32 component ); + PS2E_THISPTR (PS2E_CALLBACK* GetComponentAPI)( PS2E_LIB_THISPTR thisptr, u32 component, PS2E_ComponentAPI* dest ); // SetSettingsFolder // Callback is passed an ASCII-Z string representing the folder where the emulator's // settings files are stored (may either be under the user's documents folder, or a // location relative to the CWD of the emu application). // - // Typically this callback is only issued once per plugin session. Settings folder - // location may be change dynamically, however it is considered the responsibility - // of the emu to save the emulation state, shutdown plugins, and restart everything - // anew from the new settings in such an event. - void (CALLBACK* SetSettingsFolder)( const char* folder ); - - // SetSnapshotsFolder - // This callback may be issued at any time. - void (CALLBACK* SetSnapshotsFolder)( const char* folder ); + // Typically this callback is only issued once per plugin session, aand prior to the + // opening of any PS2 components. It is the responsibility of the emu to save the + // emulation state, shutdown plugins, and restart everything anew from the new settings + // in such an event as a dynamic change of the settings folder. + void (PS2E_CALLBACK* SetSettingsFolder)( PS2E_LIB_THISPTR thisptr, const char* folder ); // SetLogFolder // This callback may be issued at any time. It is the responsibility of the plugin // to do the necessary actions to close existing disk logging facilities and re-open // new facilities. - void (CALLBACK* SetLogFolder)( const char* folder ); + // + // Thread Safety: + // This function is always called from the GUI thread. All emulation threads are + // suspended during the call, so no locking is required. + // + void (PS2E_CALLBACK* SetLogFolder)( PS2E_LIB_THISPTR thisptr, const char* folder ); + // Reserved area at the end of the structure, for future API expansion. + void* reserved[12]; + } PS2E_LibraryAPI; +////////////////////////////////////////////////////////////////////////////////////////// +// PS2E_Image +// +// Simple RGBA image data container, for passing surface textures to the GS plugin, and +// for receiving snapshots from the GS plugin. +// +// fixme - this might be more ideal as BGRA or ABGR fomat on Windows platforms? +// +typedef struct _PS2E_Image +{ + u32 width + u32 height; + u8* data; // RGBA data. top to bottom. + +} PS2E_Image; + +////////////////////////////////////////////////////////////////////////////////////////// +// PS2E_ComponentAPI_GS +// +// Thread Safety: +// All GS callbacks are issued from the GS thread only, and are never issued concurrently. +// No locks are needed, and DirectX-based GS plugins can safely disable DX multithreading +// support for speedup (unless the plugin utilizes multiple threads of its own +// internally). +// +typedef struct _PS2E_ComponentAPI_GS +{ + // SetSnapshotsFolder + // Callback is passed an ASCII-Z string representing the folder where the emulator's + // snapshots are to be saved (typically located under user documents, but may be CWD + // or any user-specified location). + // + // Thread Safety: + // This function is only called from the GUI thread, however other threads are not + // suspended. + // + void (PS2E_CALLBACK* SetSnapshotsFolder)( PS2E_THISPTR thisptr, const char* folder ); + + // TakeSnapshot + // The GS plugin is to save the current frame into the given target image. This + // function is always called immediately after a GSvsync(), ensuring that the current + // framebuffer is safely intact for capture. + void (PS2E_CALLBACK* TakeSnapshot)( PS2E_THISPTR thisptr, PS2E_Image* dest ); + +} PS2E_ComponentAPI_GS; + // PS2E_InitAPI // Called by the emulator when the plugin is loaded into memory. The emulator uses the // presence of this function to detect PS2E-v2 plugin API, and will direct all subsequent @@ -449,7 +539,10 @@ typedef struct _PS2E_LibraryAPI // C++ Plugins can use exceptions instead of NULL to return additional information on // why the plugin failed to init the API. [TODO] // -typedef const PS2E_LibraryAPI* (CALLBACK* _PS2E_InitAPI)( const PS2E_MachineInfo* xinfo ); +typedef const PS2E_LibraryAPI* (PS2E_CALLBACK* _PS2E_InitAPI)( const PS2E_MachineInfo* xinfo ); + +// fixme! [air dies of sleep deprivation] +typedef PS2E_LIB_THISPTR* (PS2E_CALLBACK* _PS2E_GetInstance)( const PS2E_MachineInfo* xinfo ); ////////////////////////////////////////////////////////////////////////////////////////// From e514d340b6f3a01c4e03f7062be67a14fd82bc40 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Wed, 29 Jul 2009 01:14:56 +0000 Subject: [PATCH 21/22] microVU: tweaked some regAlloc stuff; i think it should be faster. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1580 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU_Misc.h | 4 ++-- pcsx2/x86/microVU_Upper.inl | 41 +++++++++++++++---------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/pcsx2/x86/microVU_Misc.h b/pcsx2/x86/microVU_Misc.h index 04f2373f5b..ec61a5757a 100644 --- a/pcsx2/x86/microVU_Misc.h +++ b/pcsx2/x86/microVU_Misc.h @@ -80,9 +80,9 @@ declareAllVariables #define _Z ((mVU->code>>22) & 0x1) #define _W ((mVU->code>>21) & 0x1) -#define _XYZW_SS (_X+_Y+_Z+_W==1) #define _X_Y_Z_W (((mVU->code >> 21 ) & 0xF )) -#define _xyzw_ACC ((_XYZW_SS && !_X) ? 15 : _X_Y_Z_W) +#define _XYZW_SS (_X+_Y+_Z+_W==1) +#define _XYZW_SS2 (_XYZW_SS && (_X_Y_Z_W != 8)) #define _bc_ (mVU->code & 0x3) #define _bc_x ((mVU->code & 0x3) == 0) diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index e5b2011d45..a4801f65c9 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -120,7 +120,10 @@ void setupPass1(microVU* mVU, int opCase, bool isACC, bool noFlagUpdate) { // Sets Up Ft Reg for Normal, BC, I, and Q Cases void setupFtReg(microVU* mVU, int& Ft, int opCase) { - opCase1 { Ft = mVU->regAlloc->allocReg(_Ft_); } + opCase1 { + if (_XYZW_SS2) Ft = mVU->regAlloc->allocReg(_Ft_, 0, _X_Y_Z_W); + else Ft = mVU->regAlloc->allocReg(_Ft_); + } opCase2 { int tempFt = mVU->regAlloc->allocReg(_Ft_); Ft = mVU->regAlloc->allocReg(); @@ -141,26 +144,23 @@ void mVU_FMACa(microVU* mVU, int recPass, int opCase, int opType, bool isACC, co if (isACC) { Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); ACC = mVU->regAlloc->allocReg((_X_Y_Z_W == 0xf) ? -1 : 32, 32, 0xf, 0); - if (_XYZW_SS && _X_Y_Z_W != 8) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); + if (_XYZW_SS2) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } else { Fs = mVU->regAlloc->allocReg(_Fs_, _Fd_, _X_Y_Z_W); } - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - opCase2 { if (opType == 2) { mVUclamp1(Fs, -1, _X_Y_Z_W); } } // Clamp Needed for alot of games (TOTA, DoM, etc...) + opCase2 { if (opType == 2) { mVUclamp1(Fs, -1, _X_Y_Z_W); } } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) SSE_SS[opType](mVU, Fs, Ft, -1, -1); else SSE_PS[opType](mVU, Fs, Ft, -1, -1); - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - if (isACC) { if (_XYZW_SS) SSE_MOVSS_XMM_to_XMM(ACC, Fs); else mVUmergeRegs(ACC, Fs, _X_Y_Z_W); - mVUupdateFlags(mVU, ACC, Fs, ((opCase==2) ? Ft : -1)); - if (_XYZW_SS && _X_Y_Z_W != 8) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); + mVUupdateFlags(mVU, ACC, Fs, ((opCase==2) ? Ft : (((opCase==1) && _XYZW_SS2) ? Ft : -1))); + if (_XYZW_SS2) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); mVU->regAlloc->clearNeeded(ACC); } - else mVUupdateFlags(mVU, Fs, ((opCase==2) ? Ft : -1)); + else mVUupdateFlags(mVU, Fs, ((opCase==2) ? Ft : -1), (((opCase==1) && _XYZW_SS2) ? Ft : -1)); mVU->regAlloc->clearNeeded(Fs); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); @@ -178,19 +178,16 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, const char* op Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); ACC = mVU->regAlloc->allocReg(32, 32, 0xf, 0); - if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } + if (_XYZW_SS2) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase2 { mVUclamp1(Fs, -1, _X_Y_Z_W); } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) SSE_SS[2](mVU, Fs, Ft, -1, -1); else SSE_PS[2](mVU, Fs, Ft, -1, -1); - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - if (_XYZW_SS || _X_Y_Z_W == 0xf) { if (_XYZW_SS) SSE_SS[opType](mVU, ACC, Fs, -1, -1); else SSE_PS[opType](mVU, ACC, Fs, -1, -1); - mVUupdateFlags(mVU, ACC, Fs, ((opCase==2) ? Ft : -1)); + mVUupdateFlags(mVU, ACC, Fs, ((opCase==2) ? Ft : (((opCase==1) && _XYZW_SS2) ? Ft : -1))); if (_XYZW_SS && _X_Y_Z_W != 8) SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } else { @@ -218,17 +215,15 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, const char* opName) { ACC = mVU->regAlloc->allocReg(32); Fs = mVU->regAlloc->allocReg(_Fs_, _Fd_, _X_Y_Z_W); - if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } + if (_XYZW_SS2) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } opCase2 { mVUclamp1(Fs, -1, _X_Y_Z_W); } // Clamp Needed for alot of games (TOTA, DoM, etc...) if (_XYZW_SS) { SSE_SS[2](mVU, Fs, Ft, -1, -1); SSE_SS[0](mVU, Fs, ACC, -1, -1); } else { SSE_PS[2](mVU, Fs, Ft, -1, -1); SSE_PS[0](mVU, Fs, ACC, -1, -1); } - if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } + if (_XYZW_SS2) { SSE2_PSHUFD_XMM_to_XMM(ACC, ACC, shuffleSS(_X_Y_Z_W)); } - mVUupdateFlags(mVU, Fs, ((opCase==2) ? Ft : -1)); + mVUupdateFlags(mVU, Fs, ((opCase==2) ? Ft : -1), (((opCase==1) && _XYZW_SS2) ? Ft : -1)); mVU->regAlloc->clearNeeded(Fs); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); @@ -247,14 +242,10 @@ void mVU_FMACd(microVU* mVU, int recPass, int opCase, const char* opName) { Fs = mVU->regAlloc->allocReg(_Fs_, 0, _X_Y_Z_W); Fd = mVU->regAlloc->allocReg(32, _Fd_, _X_Y_Z_W); - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - if (_XYZW_SS) { SSE_SS[2](mVU, Fs, Ft, -1, -1); SSE_SS[1](mVU, Fd, Fs, -1, -1); } else { SSE_PS[2](mVU, Fs, Ft, -1, -1); SSE_PS[1](mVU, Fd, Fs, -1, -1); } - - opCase1 { if (_XYZW_SS && _X_Y_Z_W != 8) { SSE2_PSHUFD_XMM_to_XMM(Ft, Ft, shuffleSS(_X_Y_Z_W)); } } - - mVUupdateFlags(mVU, Fd, Fs, ((opCase==2) ? Ft : -1)); + + mVUupdateFlags(mVU, Fd, Fs, ((opCase==2) ? Ft : (((opCase==1) && _XYZW_SS2) ? Ft : -1))); mVU->regAlloc->clearNeeded(Fd); // Always Clear Written Reg First mVU->regAlloc->clearNeeded(Ft); From b93f5bf91ab98a312b7735b341e4e87a847a54ba Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 29 Jul 2009 13:54:49 +0000 Subject: [PATCH 22/22] More new plugin api work. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1581 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/PluginCallbacks.h | 212 ++++++++++++++++--------------- 1 file changed, 112 insertions(+), 100 deletions(-) diff --git a/common/include/PluginCallbacks.h b/common/include/PluginCallbacks.h index 69c35acc40..efc0bcbc5f 100644 --- a/common/include/PluginCallbacks.h +++ b/common/include/PluginCallbacks.h @@ -59,7 +59,7 @@ typedef void* PS2E_HWND; // pointer type. // #ifndef PS2E_THISPTR -# define PS2E_THISPTR void* +# define PS2E_THISPTR struct _PS2E_ComponentAPI* #else // Ensure the user's defined PS2E_THISPTR retains the correct signature for our // plugin API. @@ -185,6 +185,13 @@ typedef struct _PS2E_SessionInfo u32* CycleEE; // current EE cycle count u32* CycleIOP; // current IOP cycle count + u32 ElfCRC; // CRC of the ELF header for this app/game + + // Sony's assigned serial number, valid only for CD/CDVD games (ASCII-Z string). + // Ex: SLUS-2932 (if the running app is not a sony-registered game, the serial + // will be a zero length string). + const char Serial[16]; + } PS2E_SessionInfo; ///////////////////////////////////////////////////////////////////////////////////////// @@ -250,41 +257,8 @@ typedef struct _PS2E_FreezeData // These are functions provided to the PS2 emulator from the plugin. The emulator will // call these functions and expect the plugin to perform defined tasks. // -// Plugins are expected to use -// typedef struct _PS2E_ComponentAPI { - // Init - // Init is called *once* for the duration of a loaded PS2 component, and is the partner - // to Shutdown, which is also called once prior to the component being unloaded. - // This function is roughly equivalent to DllMain on Windows platforms, in that it is - // called in connection with the DLL being loaded into memory, except that it is specific - // to the scope of a specific plugin component (allowing the user to selectively bind - // parts of a multi-component plugin, and leave other components unused). - // - // Parameters: - // xinfo - Machine info and capabilities, usable for cpu detection. This pointer is - // valid for the duration of the plugin's tenure in memory, and is the same as the - // xinfo pointer passed to PS2E_InitAPI() - // - // Returns: - // A pointer to a static structure that contains the API for this plugin, or NULL if - // the plugin failed initialization or is unsupported by the machine. - // - // Exceptions (C++ only): - // [TODO] - u32 (PS2E_CALLBACK* Init)( PS2E_THISPTR thisptr, const PS2E_MachineInfo* xinfo ); - - // Shutdown - // This function is called *once* for the duration of a loaded component, and is the - // partner to PS2E_Init, which is also called once after a plugin is loaded into memory. - // This function is roughly equivalent to DllMain on Windows platforms, in that it is - // called in connection with the DLL being loaded into memory. - // - // If PS2E_Init returns NULL, this method will not be called (which might seem obvious - // but bears saying anyway). - void (PS2E_CALLBACK* Shutdown)( PS2E_THISPTR thisptr ); - // EmuStart // This function is called by the emulator when an emulation session is started. The // plugin should take this opportunity to bind itself to the given window handle, open @@ -395,14 +369,15 @@ typedef struct _PS2E_LibraryAPI // GetName // Returns an ASCII-Z (zero-terminated) string name of the plugin. The name should // *not* include version or build information. That info is returned separately - // via GetVersion. The return value cannot be NULL. + // via GetVersion. The return value cannot be NULL (if it is NULL, the emulator + // will assume the DLL is invalid and ignore it). // // The pointer should reference a static/global scope char array, or an allocated // heap pointer (not recommended). // // This function may be called multiple times by the emulator, so it should accommodate // for such if it performs heap allocations or other initialization procedures. - const char* (PS2E_CALLBACK* GetName)( PS2E_LIB_THISPTR thisptr ); + const char* (PS2E_CALLBACK* GetName)(); // GetVersion // This function returns name and version information for the requested PS2 component. @@ -423,27 +398,55 @@ typedef struct _PS2E_LibraryAPI // component - indicates the ps2 component plugin to be versioned. If the plugin // does not support the requested component, the function should return NULL. // - const PS2E_VersionInfo* (PS2E_CALLBACK* GetVersion)( PS2E_LIB_THISPTR thisptr, u32 component ); + const PS2E_VersionInfo* (PS2E_CALLBACK* GetVersion)( u32 component ); - // GetComponentAPI - // The emulator calls this function to fetch the API for the requested component. - // The plugin is expected to perform an "availability test" and return NULL if the - // plugin does not support the host machine's hardware or software installations. + // Test + // Called by the plugin enumerator to check the hardware availability of the specified + // component. The function should return 1 if the plugin appears to be supported, or + // 0 if the test failed. // - // This function is only called for components which the plugin returned a non-NULL - // version information struct for in GetVersion(). IT may be called more than once - // per supported component, however, since it serves the dual purpose of both an API - // fetch and an availability test. - // - // Parameters: - // component - indicates the ps2 component API to return. - // dest - structure to fill with API functions + // While a plugin is welcome to use its own CPU capabilities information, it is recommended + // that you use the emulator provided CPU capabilities structure instead. The emulator may + // have provisions in its interface to allow for the forced disabling of extended CPU cap- + // abilities, for testing purposes. // // Exceptions: // C++ Plugins may alternately use exception handling to return more detailed // information on why the plugin failed it's availability test. [TODO] // - PS2E_THISPTR (PS2E_CALLBACK* GetComponentAPI)( PS2E_LIB_THISPTR thisptr, u32 component, PS2E_ComponentAPI* dest ); + s32 (PS2E_CALLBACK* Test)( u32 component, const PS2E_MachineInfo* xinfo ); + + // NewComponentInstance + // The emulator calls this function to fetch the API for the requested component. + // The plugin is expected to perform an "availability test" (the same test as performed + // by Test()) and return NULL if the plugin does not support the host machine's hardware + // or software installations. + // + // This function is only called for components which the plugin returned a non-NULL + // version information struct for in GetVersion(). + // + // Plugin Allocation Strategy: + // The Component API has been designed with function invocation efficiency in mind. + // To allocate your plugin's component instance you should create a structure that + // contains PS2E_ComponentAPI_* as the first member (where * refers to the PS2 + // component type), and plugin-specific instance data is stored as any number of + // subsequent members in the struct. + // + // Parameters: + // component - indicates the ps2 component API to return. + // dest - structure to fill with plugin function implementations. Dest should + // be manually typecast by the plugin to match the requested component. + // + // Exceptions: + // C++ Plugins may alternately use exception handling to return more detailed + // information on why the plugin failed it's availability test. [TODO] + // + PS2E_THISPTR (PS2E_CALLBACK* NewComponentInstance)( u32 component ); + + // DeleteComponentInstance + // Called by the emulator when the plugin component is to be shutdown. The component API + // instance pointer can be safely deleted here. + void (PS2E_CALLBACK* DeleteComponentInstance)( PS2E_THISPTR instance ); // SetSettingsFolder // Callback is passed an ASCII-Z string representing the folder where the emulator's @@ -454,7 +457,8 @@ typedef struct _PS2E_LibraryAPI // opening of any PS2 components. It is the responsibility of the emu to save the // emulation state, shutdown plugins, and restart everything anew from the new settings // in such an event as a dynamic change of the settings folder. - void (PS2E_CALLBACK* SetSettingsFolder)( PS2E_LIB_THISPTR thisptr, const char* folder ); + // + void (PS2E_CALLBACK* SetSettingsFolder)( const char* folder ); // SetLogFolder // This callback may be issued at any time. It is the responsibility of the plugin @@ -465,9 +469,11 @@ typedef struct _PS2E_LibraryAPI // This function is always called from the GUI thread. All emulation threads are // suspended during the call, so no locking is required. // - void (PS2E_CALLBACK* SetLogFolder)( PS2E_LIB_THISPTR thisptr, const char* folder ); + void (PS2E_CALLBACK* SetLogFolder)( const char* folder ); - // Reserved area at the end of the structure, for future API expansion. + // Reserved area at the end of the structure, for future API expansion. This area + // should always be zeroed out, so that future versions of emulators that may have + // defined functions here will recognize the functions as not supported. void* reserved[12]; } PS2E_LibraryAPI; @@ -478,7 +484,7 @@ typedef struct _PS2E_LibraryAPI // Simple RGBA image data container, for passing surface textures to the GS plugin, and // for receiving snapshots from the GS plugin. // -// fixme - this might be more ideal as BGRA or ABGR fomat on Windows platforms? +// fixme - this might be more ideal as BGRA or ABGR format on Windows platforms? // typedef struct _PS2E_Image { @@ -487,18 +493,21 @@ typedef struct _PS2E_Image u8* data; // RGBA data. top to bottom. } PS2E_Image; - + ////////////////////////////////////////////////////////////////////////////////////////// // PS2E_ComponentAPI_GS // // Thread Safety: -// All GS callbacks are issued from the GS thread only, and are never issued concurrently. -// No locks are needed, and DirectX-based GS plugins can safely disable DX multithreading -// support for speedup (unless the plugin utilizes multiple threads of its own -// internally). +// All GS callbacks are issued from the GS thread only, and are always called synchronously +// with all other component API functions. No locks are needed, and DirectX-based GS +// plugins can safely disable DX multithreading support for speedup (unless the plugin +// utilizes multiple threads of its own internally). // typedef struct _PS2E_ComponentAPI_GS { + // Base Component API (inherited structure) + struct _PS2E_ComponentAPI Base; + // SetSnapshotsFolder // Callback is passed an ASCII-Z string representing the folder where the emulator's // snapshots are to be saved (typically located under user documents, but may be CWD @@ -515,7 +524,51 @@ typedef struct _PS2E_ComponentAPI_GS // function is always called immediately after a GSvsync(), ensuring that the current // framebuffer is safely intact for capture. void (PS2E_CALLBACK* TakeSnapshot)( PS2E_THISPTR thisptr, PS2E_Image* dest ); + + // OSD_SetTexture + // Uploads a new OSD texture to the GS. Display of the OSD should be performed at + // the next soonest possible vsync. + void (PS2E_CALLBACK* OSD_SetTexture)( PS2E_THISPTR thisptr, PS2E_Image* src ); + + // OSD_SetAlpha + // + // Parameters: + // alphOverall - Specifies the 'full' opacity of the OSD. The alphaFade setting + // effectively slides from alphaOverall to 0.0. + // + // alphaFade - Specifies the fadeout status of the OSD. This value can be loosely + // interpreted by the GS plugin. The only requirement is that the GS plugin + // honor the fade value of 0.0 (OSD is not displayed). + void (PS2E_CALLBACK* OSD_SetAlpha)( PS2E_THISPTR thisptr, float alphaOverall, float alphaFade ); + + void (PS2E_CALLBACK* OSD_SetPosition)( PS2E_THISPTR thisptr, int xpos, int ypos ); + + void (PS2E_CALLBACK* GSvsync)(int field); + // + // + void (PS2E_CALLBACK* GSreadFIFO)(u128 *pMem, int qwc); + + // GStransferTag + // Sends a set of GIFtags. Note that SIGNAL, FINISH, and LABEL tags are handled + // internally by the emulator in a thread-safe manner -- the GS plugin can safely + // ignore the tags (and there is no guarantee the emulator will even bother to + // pass the tags onto the GS). + void (PS2E_CALLBACK* GStransferTags)(u128 *pMem, int tagcnt); + + // GStransferPackedTag + // Sends a set of packed GIFtags. Note that SIGNAL, FINISH, and LABEL tags are handled + // internally by the emulator in a thread-safe manner -- the GS plugin can safely + // ignore the tags (and there is no guarantee the emulator will even bother to + // pass the tags onto the GS). + void (PS2E_CALLBACK* GStransferPackedTags)(u128 *pMem, int tagcnt); + + // GStransferImage + // Uploads GIFtag image data. + void (PS2E_CALLBACK* GStransferImage)(u128 *pMem, u32 len_qwc); + + void* reserved[8]; + } PS2E_ComponentAPI_GS; // PS2E_InitAPI @@ -541,9 +594,6 @@ typedef struct _PS2E_ComponentAPI_GS // typedef const PS2E_LibraryAPI* (PS2E_CALLBACK* _PS2E_InitAPI)( const PS2E_MachineInfo* xinfo ); -// fixme! [air dies of sleep deprivation] -typedef PS2E_LIB_THISPTR* (PS2E_CALLBACK* _PS2E_GetInstance)( const PS2E_MachineInfo* xinfo ); - ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// @@ -553,44 +603,6 @@ typedef PS2E_LIB_THISPTR* (PS2E_CALLBACK* _PS2E_GetInstance)( const PS2E_Machine ////////////////////////////////////////////////////////////////////////////////////////// -// GS -// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs -// If you want to use them, need to save and restore current ones -typedef s32 (CALLBACK* _GSinit)(char *configpath); -typedef s32 (CALLBACK* _GSopen)(void *pDisplay, char *Title, bool multithread); -typedef void (CALLBACK* _GSclose)(); -typedef void (CALLBACK* _GSshutdown)(); -typedef void (CALLBACK* _GSvsync)(int field); -typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem, u32 addr); -typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size); -typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size); -typedef void (CALLBACK* _GSgetLastTag)(u64* ptag); // returns the last tag processed (64 bits) -typedef void (CALLBACK* _GSgifSoftReset)(u32 mask); -typedef void (CALLBACK* _GSreadFIFO)(u64 *pMem); -typedef void (CALLBACK* _GSreadFIFO2)(u64 *pMem, int qwc); - -typedef void (CALLBACK* _GSkeyEvent)(keyEvent* ev); -typedef void (CALLBACK* _GSchangeSaveState)(s32 state, const char* filename); -typedef void (CALLBACK* _GSirqCallback)(void (*callback)()); -typedef void (CALLBACK* _GSprintf)(s32 timeout, char *fmt, ...); -typedef void (CALLBACK* _GSsetBaseMem)(void*); -typedef void (CALLBACK* _GSsetGameCRC)(s32 crc, s32 gameoptions); - -typedef void (CALLBACK* _GSsetFrameSkip)(int frameskip); -typedef bool (CALLBACK* _GSsetupRecording)(bool start); -typedef void (CALLBACK* _GSreset)(); -typedef void (CALLBACK* _GSwriteCSR)(u32 value); -typedef void (CALLBACK* _GSgetDriverInfo)(GSdriverInfo *info); -#ifdef _WINDOWS_ -typedef s32 (CALLBACK* _GSsetWindowInfo)(winInfo *info); -#endif -typedef void (CALLBACK* _GSmakeSnapshot)(const char *path); -typedef void (CALLBACK* _GSmakeSnapshot2)(const char *path, int*, int); -typedef s32 (CALLBACK* _GSfreeze)(u8 mode, freezeData *data); -typedef void (CALLBACK* _GSconfigure)(); -typedef s32 (CALLBACK* _GStest)(); -typedef void (CALLBACK* _GSabout)(); - // PAD typedef s32 (CALLBACK* _PADinit)(char *configpath, u32 flags); typedef s32 (CALLBACK* _PADopen)(void *pDisplay);