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
This commit is contained in:
arcum42 2009-07-23 23:30:19 +00:00
parent 9f35752ed8
commit 20b95fd187
9 changed files with 81 additions and 41 deletions

View File

@ -136,6 +136,7 @@ struct PcsxConfig
{ {
public: public:
char Bios[g_MaxPath]; char Bios[g_MaxPath];
char GS[g_MaxPath]; char GS[g_MaxPath];
char PAD1[g_MaxPath]; char PAD1[g_MaxPath];
char PAD2[g_MaxPath]; char PAD2[g_MaxPath];
@ -144,9 +145,11 @@ public:
char DEV9[g_MaxPath]; char DEV9[g_MaxPath];
char USB[g_MaxPath]; char USB[g_MaxPath];
char FW[g_MaxPath]; char FW[g_MaxPath];
char PluginsDir[g_MaxPath]; char PluginsDir[g_MaxPath];
char BiosDir[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 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]; char Lang[g_MaxPath];
McdConfig Mcd[2]; McdConfig Mcd[2];

View File

@ -18,7 +18,6 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
// TODO: fix this for linux! (hardcoded as _WIN32 only)
#define ENABLE_TIMESTAMPS #define ENABLE_TIMESTAMPS
#ifdef _WIN32 #ifdef _WIN32
@ -53,9 +52,11 @@ int CheckDiskTypeFS(int baseType)
static struct TocEntry tocEntry; static struct TocEntry tocEntry;
IsoFS_init(); IsoFS_init();
f = IsoFS_open("SYSTEM.CNF;1", 1);
// check if the file exists // check if the file exists
if ((f=IsoFS_open("SYSTEM.CNF;1", 1)) >= 0) if (f >= 0)
{ {
int size = IsoFS_read(f, buffer, 256); int size = IsoFS_read(f, buffer, 256);
IsoFS_close(f); IsoFS_close(f);
@ -91,9 +92,7 @@ int FindDiskType(int mType)
{ {
int dataTracks = 0; int dataTracks = 0;
int audioTracks = 0; int audioTracks = 0;
int iCDType = mType; int iCDType = mType;
cdvdTN tn; cdvdTN tn;
CDVD.getTN(&tn); CDVD.getTN(&tn);
@ -105,6 +104,7 @@ int FindDiskType(int mType)
else if (mType < 0) else if (mType < 0)
{ {
cdvdTD td; cdvdTD td;
CDVD.getTD(0,&td); CDVD.getTD(0,&td);
if (td.lsn > 452849) if (td.lsn > 452849)
{ {
@ -153,6 +153,7 @@ int FindDiskType(int mType)
for(int i = tn.strack; i <= tn.etrack; i++) for(int i = tn.strack; i <= tn.etrack; i++)
{ {
cdvdTD td,td2; cdvdTD td,td2;
CDVD.getTD(i,&td); CDVD.getTD(i,&td);
if (tn.etrack > i) if (tn.etrack > i)
@ -260,20 +261,15 @@ s32 DoCDVDopen(const char* pTitleFilename)
int ret = CDVD.open(pTitleFilename); int ret = CDVD.open(pTitleFilename);
int cdtype = DoCDVDdetectDiskType(); int cdtype = DoCDVDdetectDiskType();
if((Config.Blockdump)&&(cdtype != CDVD_TYPE_NODISC)) if ((Config.Blockdump) && (cdtype != CDVD_TYPE_NODISC))
{ {
char fname_only[g_MaxPath]; char fname_only[g_MaxPath];
if(CDVD.init == ISO.init) if (CDVD.init == ISO.init)
{ {
#ifdef _WIN32 // Base it out of the current directory for now.
char fname[MAX_PATH], ext[g_MaxPath]; string temp = Path::GetWorkingDirectory() + Path::GetFilenameWithoutExt(isoFileName);
_splitpath(isoFileName, NULL, NULL, fname, ext); strcpy(fname_only, temp.c_str());
_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
} }
else else
{ {

View File

@ -34,10 +34,13 @@ int main(int argc, char *argv[])
{ {
char *file = NULL; char *file = NULL;
char elfname[g_MaxPath]; char elfname[g_MaxPath];
string MainDirString;
efile = 0; 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); Console::Notice("MAIN_DIR is %s", params MAIN_DIR);
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
@ -51,12 +54,12 @@ int main(int argc, char *argv[])
sprintf(Config.InisDir, "%s/%s/", MAIN_DIR, DEFAULT_INIS_DIR); sprintf(Config.InisDir, "%s/%s/", MAIN_DIR, DEFAULT_INIS_DIR);
sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir); sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir);
#else #else
mkdir("~/.pcsx2"); Path::CreateDirectory(string("~/.pcsx2"));
chdir("~/.pcsx2"); Path::ChangeDirectory(string("~/.pcsx2"));
mkdir(DEFAULT_INIS_DIR, 0755); Path::CreateDirectory(string(DEFAULT_INIS_DIR));
sprintf(Config.InisDir, "~/.pcsx2/%s/", DEFAULT_INIS_DIR); sprintf(Config.InisDir, "~/.pcsx2/%s/", DEFAULT_INIS_DIR);
sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir); sprintf(cfgfile, "%s/pcsx2.cfg", Config.InisDir);
chdir(MAIN_DIR); Path::ChangeDirectory(string(MAIN_DIR));
#endif #endif
#ifdef PCSX2_DEVBUILD #ifdef PCSX2_DEVBUILD
@ -144,8 +147,6 @@ int main(int argc, char *argv[])
if (!efile) efile = GetPS2ElfName(elfname); if (!efile) efile = GetPS2ElfName(elfname);
loadElfFile(elfname); loadElfFile(elfname);
//ExecuteCpu();
return 0; return 0;
} }
@ -350,6 +351,7 @@ void OnFile_RunBIOS(GtkMenuItem *menuitem, gpointer user_data)
void OnRunIso_Ok(GtkButton* button, gpointer user_data) void OnRunIso_Ok(GtkButton* button, gpointer user_data)
{ {
gchar *File; gchar *File;
string curdir;
CDVD = ISO; CDVD = ISO;
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel)); File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));

View File

@ -20,7 +20,8 @@
void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data) void OnConf_Memcards(GtkMenuItem *menuitem, gpointer user_data)
{ {
char file[g_MaxPath], card[g_MaxPath]; string file;
char card[g_MaxPath];
DIR *dir; DIR *dir;
struct dirent *entry; struct dirent *entry;
struct stat statinfo; 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_enable_mcd2", Config.Mcd[1].Enabled);
set_checked(MemDlg, "check_eject_mcds", Config.McdEnableEject); set_checked(MemDlg, "check_eject_mcds", Config.McdEnableEject);
getcwd(file, ArraySize(file)); /* store current dir */ file = Path::GetCurrentDirectory();/* store current dir */
sprintf(card, "%s/%s", file, MEMCARDS_DIR ); sprintf(card, "%s/%s", file.c_str(), MEMCARDS_DIR );
chdir(card); /* change dirs so that plugins can find their config file*/ Path::ChangeDirectory(string(card));/* change dirs so that plugins can find their config file*/
if ((dir = opendir(card)) == NULL) if ((dir = opendir(card)) == NULL)
{ {
Console::Error("ERROR: Could not open directory %s\n", params card); 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); closedir(dir);
Path::ChangeDirectory(file);
chdir(file);
gtk_widget_show_all(MemDlg); gtk_widget_show_all(MemDlg);
gtk_widget_set_sensitive(MainWindow, FALSE); gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main(); gtk_main();

View File

@ -156,6 +156,7 @@ void SaveConfig()
SetValue("Lang", Config.Lang); SetValue("Lang", Config.Lang);
SetValue("PluginsDir", Config.PluginsDir); SetValue("PluginsDir", Config.PluginsDir);
SetValue("BiosDir", Config.BiosDir); SetValue("BiosDir", Config.BiosDir);
SetValuel("Ps2Out", Config.PsxOut); SetValuel("Ps2Out", Config.PsxOut);
SetValuel("cdvdPrint", Config.cdvdPrint); SetValuel("cdvdPrint", Config.cdvdPrint);

View File

@ -255,11 +255,31 @@ string GetRootDirectory( const string& src )
void CreateDirectory( const string& src ) void CreateDirectory( const string& src )
{ {
#ifdef _WIN32 #ifdef _WIN32
_mkdir( src.c_str() ); _mkdir(src.c_str());
#else #else
mkdir( src.c_str(), 0755); mkdir( src.c_str(), 0755);
#endif #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
}
} }

View File

@ -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_ #ifndef _PCSX2_PATHS_H_
#define _PCSX2_PATHS_H_ #define _PCSX2_PATHS_H_
#define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs. #define g_MaxPath 255 // 255 is safer with antiquated Win32 ASCII APIs.
#ifdef __LINUX__ #ifdef __LINUX__
@ -41,7 +58,8 @@ namespace Path
extern void Split( const std::string& src, std::string& destpath, std::string& destfile ); extern void Split( const std::string& src, std::string& destpath, std::string& destfile );
extern void CreateDirectory( const std::string& src ); extern void CreateDirectory( const std::string& src );
extern std::string GetWorkingDirectory(void);
extern void ChangeDirectory(const std::string& src);
} }
#endif #endif

View File

@ -268,7 +268,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
textdomain(PACKAGE); textdomain(PACKAGE);
#endif #endif
_getcwd( g_WorkingFolder, g_MaxPath ); strcpy(g_WorkingFolder, Path::GetWorkingDirectory().c_str());
int argc; int argc;
TCHAR *const *const argv = _CommandLineToArgv( lpCmdLine, &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); MessageBox( NULL, phelpmsg, "Pcsx2 Help", MB_OK);
case -1: // exit... case -1: // exit...
return 0; return 0;
} }
try try

View File

@ -98,7 +98,7 @@ static void (*SSE_SS[]) (x86SSERegType, x86SSERegType) = {
}; };
// Prints Opcode to MicroProgram Logs // 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); mVUlog(opName);
opCase1 { if (isACC) { mVUlogACC(); } else { mVUlogFd(); } mVUlogFt(); } opCase1 { if (isACC) { mVUlogACC(); } else { mVUlogFd(); } mVUlogFt(); }
opCase2 { if (isACC) { mVUlogACC(); } else { mVUlogFd(); } mVUlogBC(); } opCase2 { if (isACC) { mVUlogACC(); } else { mVUlogFd(); } mVUlogBC(); }
@ -130,7 +130,7 @@ void setupFtReg(microVU* mVU, int& Ft, int opCase) {
} }
// Normal FMAC Opcodes // 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))); } pass1 { setupPass1(mVU, opCase, isACC, ((opType == 3) || (opType == 4))); }
pass2 { pass2 {
int Fs, Ft, ACC; 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 // 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); } pass1 { setupPass1(mVU, opCase, 1, 0); }
pass2 { pass2 {
int Fs, Ft, ACC; int Fs, Ft, ACC;
@ -215,7 +215,7 @@ void mVU_FMACb(microVU* mVU, int recPass, int opCase, int opType, char* opName)
} }
// MADD Opcodes // 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); } pass1 { setupPass1(mVU, opCase, 0, 0); }
pass2 { pass2 {
int Fs, Ft, ACC; int Fs, Ft, ACC;
@ -247,7 +247,7 @@ void mVU_FMACc(microVU* mVU, int recPass, int opCase, char* opName) {
} }
// MSUB Opcodes // 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); } pass1 { setupPass1(mVU, opCase, 0, 0); }
pass2 { pass2 {
int Fs, Ft, Fd; int Fs, Ft, Fd;
@ -335,7 +335,7 @@ mVUop(mVU_OPMSUB) {
} }
// FTOI0/FTIO4/FTIO12/FTIO15 Opcodes // 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_); } pass1 { mVUanalyzeFMAC2(mVU, _Fs_, _Ft_); }
pass2 { pass2 {
if (!_Ft_) return; if (!_Ft_) return;
@ -364,7 +364,7 @@ void mVU_FTOIx(mP, uptr addr, char* opName) {
} }
// ITOF0/ITOF4/ITOF12/ITOF15 Opcodes // 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_); } pass1 { mVUanalyzeFMAC2(mVU, _Fs_, _Ft_); }
pass2 { pass2 {
if (!_Ft_) return; if (!_Ft_) return;