Fixed a bug in the savestate system that caused memcards to eject when they shouldn't have (had uint instead of u64 >_<).

Developers: Changed the way PCSX2_ALIGNED16 macros work, so that they're more friendly to MSVC and Visual Assist X intellisense (more more red squigglies on vars like cpuRegs!)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@618 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-02-27 01:43:43 +00:00
parent dd48940319
commit 5b09d81f36
17 changed files with 112 additions and 56 deletions

View File

@ -83,9 +83,12 @@ typedef unsigned __int64 u64;
typedef unsigned int uint;
// Note: building the 'extern' into PCSX2_ALIGNED16_DECL fixes Visual Assist X's intellisense.
#define PCSX2_ALIGNED(alig,x) __declspec(align(alig)) x
#define PCSX2_ALIGNED_EXTERN(alig,x) __declspec(align(alig)) x
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
#define PCSX2_ALIGNED16_DECL(x) __declspec(align(16)) x
#define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x
#define __naked __declspec(naked)
@ -142,7 +145,11 @@ typedef union _LARGE_INTEGER
#define PCSX2_ALIGNED(alig,x) x __attribute((aligned(alig)))
#define PCSX2_ALIGNED16(x) x __attribute((aligned(16)))
#define PCSX2_ALIGNED16_DECL(x) x
// fixme - is this needed for recent versions of GCC? Or can we just use the macros
// above instead for both definitions (implementations) and declarations (includes)? -- air
#define PCSX2_ALIGNED_EXTERN(alig,x) extern x
#define PCSX2_ALIGNED16_EXTERN(x) extern x
#endif // _MSC_VER

View File

@ -41,7 +41,7 @@ IF NOT EXIST "%pcsxoutdir%" (
copy /Y "%~2" "%pcsxoutname%"
copy /Y "%~2" "%pcsxnewname%"
if %ERRORLEVEL% NEQ 0 (
if %ERRORLEVEL% EQU 0 (
echo Target copied to %pcsxnewname%
)

View File

@ -39,7 +39,7 @@ IF NOT EXIST "%pcsxoutdir%" (
)
copy /Y "%~2" "%pcsxoutname%"
if %ERRORLEVEL% NEQ 0 (
if %ERRORLEVEL% EQU 0 (
echo Target copied to %pcsxoutname%
)

View File

@ -32,6 +32,7 @@ int iopsifbusy[2] = { 0, 0 };
static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore, _SPU2writeDMA4Mem spu2WriteFunc, _SPU2readDMA4Mem spu2ReadFunc )
{
const char dmaNum = spuCore ? '7' : '4';
/*if (chcr & 0x400) DevCon::Status("SPU 2 DMA %c linked list chain mode! chcr = %x madr = %x bcr = %x\n", dmaNum, chcr, madr, bcr);
if (chcr & 0x40000000) DevCon::Notice("SPU 2 DMA %c Unusual bit set on 'to' direction chcr = %x madr = %x bcr = %x\n", dmaNum, chcr, madr, bcr);
if ((chcr & 0x1) == 0) DevCon::Status("SPU 2 DMA %c loading from spu2 memory chcr = %x madr = %x bcr = %x\n", dmaNum, chcr, madr, bcr);*/
@ -59,18 +60,18 @@ static void __fastcall psxDmaGeneric(u32 madr, u32 bcr, u32 chcr, u32 spuCore, _
switch (chcr)
{
case 0x01000201: //cpu to spu2 transfer
PSXDMA_LOG("*** DMA %c - mem2spu *** %lx addr = %lx size = %lx\n", dmaNum, chcr, madr, bcr);
PSXDMA_LOG("*** DMA %c - mem2spu *** %x addr = %x size = %x\n", dmaNum, chcr, madr, bcr);
spu2WriteFunc((u16 *)PSXM(madr), size*2);
break;
case 0x01000200: //spu2 to cpu transfer
PSXDMA_LOG("*** DMA %c - spu2mem *** %lx addr = %lx size = %lx\n", dmaNum, chcr, madr, bcr);
PSXDMA_LOG("*** DMA %c - spu2mem *** %x addr = %x size = %x\n", dmaNum, chcr, madr, bcr);
spu2ReadFunc((u16 *)PSXM(madr), size*2);
psxCpu->Clear(spuCore ? HW_DMA7_MADR : HW_DMA4_MADR, size);
break;
default:
Console::Error("*** DMA %c - SPU unknown *** %lx addr = %lx size = %lx\n", params dmaNum, chcr, madr, bcr);
Console::Error("*** DMA %c - SPU unknown *** %x addr = %x size = %x\n", params dmaNum, chcr, madr, bcr);
break;
}
}

View File

@ -118,7 +118,7 @@ struct psxRegisters {
u32 _smflag[32];
};
extern PCSX2_ALIGNED16_DECL(psxRegisters psxRegs);
PCSX2_ALIGNED16_EXTERN(psxRegisters psxRegs);
extern u32 g_psxNextBranchCycle;
extern s32 psxBreak; // used when the IOP execution is broken and control returned to the EE

View File

@ -195,7 +195,9 @@ void cpuException(u32 code, u32 bd)
}
void cpuTlbMiss(u32 addr, u32 bd, u32 excode) {
Console::Error("cpuTlbMiss pc:%x, cycl:%x, addr: %x, status=%x, code=%x", params cpuRegs.pc, cpuRegs.cycle, addr, cpuRegs.CP0.n.Status.val, excode);
Console::Error("cpuTlbMiss pc:%x, cycl:%x, addr: %x, status=%x, code=%x",
params cpuRegs.pc, cpuRegs.cycle, addr, cpuRegs.CP0.n.Status.val, excode);
if (bd) {
Console::Notice("branch delay!!");
}

View File

@ -193,9 +193,9 @@ struct tlbs
void JumpCheckSym(u32 addr, u32 pc);
void JumpCheckSymRet(u32 addr);
extern PCSX2_ALIGNED16_DECL(cpuRegisters cpuRegs);
extern PCSX2_ALIGNED16_DECL(fpuRegisters fpuRegs);
extern PCSX2_ALIGNED16_DECL(tlbs tlb[48]);
PCSX2_ALIGNED16_EXTERN(cpuRegisters cpuRegs);
PCSX2_ALIGNED16_EXTERN(fpuRegisters fpuRegs);
PCSX2_ALIGNED16_EXTERN(tlbs tlb[48]);
extern u32 g_nextBranchCycle;
extern bool eeEventTestIsActive;
@ -271,7 +271,4 @@ extern void cpuTestTIMRInts();
#define EXC_CODE__MASK 0x0000007c
#define EXC_CODE__SHIFT 2
#define EXC_TLB_STORE 1
#define EXC_TLB_LOAD 0
#endif /* __R5900_H__ */

View File

@ -599,7 +599,7 @@ void SaveState::sioFreeze()
for( int i=0; i<2; ++i )
{
uint newCRC = MemoryCard::GetCRC( i );
u64 newCRC = MemoryCard::GetCRC( i );
if( newCRC != m_mcdCRCs[i] )
{
m_PostSavestateCards[i] = 64;

View File

@ -181,7 +181,7 @@ struct _VURegsNum {
};
extern VURegs* g_pVU1;
extern PCSX2_ALIGNED16_DECL(VURegs VU0);
PCSX2_ALIGNED16_EXTERN(VURegs VU0);
#define VU1 (*g_pVU1)

View File

@ -46,10 +46,10 @@ extern "C"
extern u32* _vifCol;
}
extern PCSX2_ALIGNED16_DECL(u32 g_vifRow0[4]);
extern PCSX2_ALIGNED16_DECL(u32 g_vifCol0[4]);
extern PCSX2_ALIGNED16_DECL(u32 g_vifRow1[4]);
extern PCSX2_ALIGNED16_DECL(u32 g_vifCol1[4]);
PCSX2_ALIGNED16_EXTERN(u32 g_vifRow0[4]);
PCSX2_ALIGNED16_EXTERN(u32 g_vifCol0[4]);
PCSX2_ALIGNED16_EXTERN(u32 g_vifRow1[4]);
PCSX2_ALIGNED16_EXTERN(u32 g_vifCol1[4]);
extern vifStruct *_vif;

View File

@ -257,12 +257,17 @@ void __fastcall memRead32(u32 mem, u32 *out) { *out = vtlb_memRead32( mem ); }
// Error / TLB Miss Handlers
//
static const char* _getModeStr( u32 mode )
{
return (mode==0) ? "read" : "write";
}
// Generates a tlbMiss Exception
static __forceinline void vtlb_Miss(u32 addr,u32 mode)
{
Console::Error("vtlb miss : addr 0x%X, mode %d", params addr,mode);
Console::Error( "vtlb miss : addr 0x%X, mode %d [%s]", params addr, mode, _getModeStr(mode) );
verify(false);
if (mode==0)
cpuTlbMissR(addr, cpuRegs.branch);
else
@ -273,7 +278,7 @@ static __forceinline void vtlb_Miss(u32 addr,u32 mode)
// Eventually should generate a BusError exception.
static __forceinline void vtlb_BusError(u32 addr,u32 mode)
{
Console::Error("vtlb bus error : addr 0x%X, mode %d\n",params addr,mode);
Console::Error( "vtlb bus error : addr 0x%X, mode %d\n", params addr, _getModeStr(mode) );
verify(false);
}

View File

@ -56,6 +56,23 @@ 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;
while( (*retval != 0) && (*workingfold != 0) && (tolower(*retval) == tolower(*workingfold)) )
{
retval++;
workingfold++;
}
if( *retval == 0 ) return src;
while( (*retval != 0) && (*retval == '\\') ) retval++;
return retval;
}
void MemcardConfig::Open_Mcd_Proc(HWND hW, int mcd)
{
@ -94,7 +111,11 @@ void MemcardConfig::Open_Mcd_Proc(HWND hW, int mcd)
ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER;
if (GetOpenFileName ((LPOPENFILENAME)&ofn))
Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD_FILE1 : IDC_MCD_FILE2), szFileName);
{
string confusion;
Path::Combine( confusion, g_WorkingFolder, szFileName );
Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD_FILE1 : IDC_MCD_FILE2), _stripPathInfo( confusion.c_str() ) );
}
}
BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@ -102,7 +123,7 @@ BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
switch(uMsg)
{
case WM_INITDIALOG:
{
mcdDlg = hWnd;
SetWindowText(hWnd, _("MemoryCard Config - Pcsx2"));
@ -115,18 +136,29 @@ BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
Static_SetText(GetDlgItem(hWnd, IDC_MCD_ENABLE1), _("Memory Card Slot 1"));
Static_SetText(GetDlgItem(hWnd, IDC_MCD_ENABLE2), _("Memory Card Slot 2"));
if( Config.Mcd[0].Filename[0] == 0 ) strcpy( Config.Mcd[0].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 );
if( Config.Mcd[1].Filename[1] == 0 ) strcpy( Config.Mcd[1].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD2 );
if( Config.Mcd[0].Filename[0] == 0 )
{
string mcdpath;
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 );
mcdpath._Copy_s( Config.Mcd[1].Filename, g_MaxPath, mcdpath.length() );
}
Edit_SetText(GetDlgItem(hWnd,IDC_MCD_FILE1), Config.Mcd[0].Filename);
Edit_SetText(GetDlgItem(hWnd,IDC_MCD_FILE2), Config.Mcd[1].Filename);
if( Config.Mcd[1].Filename[1] == 0 )
{
string mcdpath;
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 );
mcdpath._Copy_s( Config.Mcd[1].Filename, g_MaxPath, mcdpath.length() );
}
Edit_SetText( GetDlgItem(hWnd,IDC_MCD_FILE1), _stripPathInfo( Config.Mcd[0].Filename ) );
Edit_SetText( GetDlgItem(hWnd,IDC_MCD_FILE2), _stripPathInfo( Config.Mcd[1].Filename ) );
SET_CHECK( IDC_MCD_ENABLE1, Config.Mcd[0].Enabled );
SET_CHECK( IDC_MCD_ENABLE2, Config.Mcd[1].Enabled );
SET_CHECK( IDC_NTFS_ENABLE, Config.McdEnableNTFS );
SET_CHECK( IDC_MCD_EJECT_ENABLE, Config.McdEnableEject );
}
break;
case WM_COMMAND:
@ -158,6 +190,16 @@ BOOL CALLBACK MemcardConfig::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
GetWindowText( GetDlgItem( hWnd, IDC_MCD_FILE1 ), Config.Mcd[0].Filename, g_MaxPath );
GetWindowText( GetDlgItem( hWnd, IDC_MCD_FILE2 ), Config.Mcd[1].Filename, g_MaxPath );
// reassign text with the extra unnecessary path info stripped out.
string confusion;
Path::Combine( confusion, g_WorkingFolder, Config.Mcd[0].Filename );
_tcscpy( Config.Mcd[0].Filename, _stripPathInfo( confusion.c_str() ) );
Path::Combine( confusion, g_WorkingFolder, Config.Mcd[1].Filename );
_tcscpy( Config.Mcd[1].Filename, _stripPathInfo( confusion.c_str() ) );
if( g_EmulationInProgress )
{
if( !Config.Mcd[0].Enabled || oldone != Config.Mcd[0].Filename )
@ -204,8 +246,13 @@ void IniFile::MemcardSettings( PcsxConfig& conf )
{
SetCurrentSection( "Memorycards" );
Entry( "Slot1_Path", conf.Mcd[0].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 );
Entry( "Slot2_Path", conf.Mcd[1].Filename, MEMCARDS_DIR "\\" DEFAULT_MEMCARD2 );
string mcdpath;
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD1 );
Entry( "Slot1_Path", conf.Mcd[0].Filename, mcdpath );
Path::Combine( mcdpath, g_WorkingFolder, MEMCARDS_DIR "\\" DEFAULT_MEMCARD2 );
Entry( "Slot2_Path", conf.Mcd[1].Filename, mcdpath );
Entry( "Slot1_Enabled", conf.Mcd[0].Enabled, true );
Entry( "Slot2_Enabled", conf.Mcd[1].Enabled, true );

View File

@ -209,10 +209,10 @@ static bool TestRunMode()
static void _doPluginOverride( const char* name, const char* src, char (&dest)[g_MaxPath] )
{
if( src == NULL ) return;
if( src == NULL || src[0] == 0 ) return;
_tcscpy_s( dest, g_TestRun.pgsdll );
Console::Notice( "* %s plugin override: \n\t%s\n", params name, Config.GS );
_tcscpy_s( dest, src );
Console::Notice( "* %s plugin override: \n\t%s\n", params name, dest);
}
void WinRun()

View File

@ -24,9 +24,6 @@
#include "iR5900.h"
#include "iFPU.h"
extern PCSX2_ALIGNED16_DECL(u32 g_minvals[4]);
extern PCSX2_ALIGNED16_DECL(u32 g_maxvals[4]);
//------------------------------------------------------------------
// Misc...
//------------------------------------------------------------------

View File

@ -134,7 +134,7 @@ extern void recDoBranchImm_Likely( u32* jmpSkip );
}
extern void (*recBSC_co[64])();
extern PCSX2_ALIGNED16_DECL(GPR_reg64 g_cpuConstRegs[32]);
PCSX2_ALIGNED16_EXTERN(GPR_reg64 g_cpuConstRegs[32]);
extern u32 g_cpuHasConstReg, g_cpuFlushedConstReg;
// gets a memory pointer to the constant reg

View File

@ -86,15 +86,15 @@
//------------------------------------------------------------------
int vucycle;
PCSX2_ALIGNED16(float s_fones[8]) = {1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f};
PCSX2_ALIGNED16(u32 s_mask[4]) = {0x007fffff, 0x007fffff, 0x007fffff, 0x007fffff};
PCSX2_ALIGNED16(u32 s_expmask[4]) = {0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000};
PCSX2_ALIGNED16(u32 g_minvals[4]) = {0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff};
PCSX2_ALIGNED16(u32 g_maxvals[4]) = {0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff};
PCSX2_ALIGNED16(u32 const_clip[8]) = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
0x80000000, 0x80000000, 0x80000000, 0x80000000};
PCSX2_ALIGNED(64, u32 g_ones[4]) = {0x00000001, 0x00000001, 0x00000001, 0x00000001};
PCSX2_ALIGNED16(u32 g_minvals_XYZW[16][4]) =
PCSX2_ALIGNED16(const float s_fones[8]) = {1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f};
PCSX2_ALIGNED16(const u32 s_mask[4]) = {0x007fffff, 0x007fffff, 0x007fffff, 0x007fffff};
PCSX2_ALIGNED16(const u32 s_expmask[4]) = {0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000};
PCSX2_ALIGNED16(const u32 g_minvals[4]) = {0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff};
PCSX2_ALIGNED16(const u32 g_maxvals[4]) = {0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff};
PCSX2_ALIGNED16(const u32 const_clip[8]) = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
0x80000000, 0x80000000, 0x80000000, 0x80000000};
PCSX2_ALIGNED(64, const u32 g_ones[4]) = {0x00000001, 0x00000001, 0x00000001, 0x00000001};
PCSX2_ALIGNED16(const u32 g_minvals_XYZW[16][4]) =
{
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, //0000
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xff7fffff }, //0001
@ -113,7 +113,7 @@ PCSX2_ALIGNED16(u32 g_minvals_XYZW[16][4]) =
{ 0xff7fffff, 0xff7fffff, 0xff7fffff, 0xffffffff }, //1110
{ 0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff }, //1111
};
PCSX2_ALIGNED16(u32 g_maxvals_XYZW[16][4])=
PCSX2_ALIGNED16(const u32 g_maxvals_XYZW[16][4])=
{
{ 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff }, //0000
{ 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7f7fffff }, //0001

View File

@ -74,12 +74,12 @@ extern vFloat vFloats1_useEAX[16];
extern vFloat vFloats2[16];
extern vFloat vFloats4[16];
extern vFloat vFloats4_useEAX[16];
extern PCSX2_ALIGNED16(float s_fones[8]);
extern PCSX2_ALIGNED16(u32 s_mask[4]);
extern PCSX2_ALIGNED16(u32 s_expmask[4]);
extern PCSX2_ALIGNED16(u32 g_minvals[4]);
extern PCSX2_ALIGNED16(u32 g_maxvals[4]);
extern PCSX2_ALIGNED16(u32 const_clip[8]);
PCSX2_ALIGNED16_EXTERN(const float s_fones[8]);
PCSX2_ALIGNED16_EXTERN(const u32 s_mask[4]);
PCSX2_ALIGNED16_EXTERN(const u32 s_expmask[4]);
PCSX2_ALIGNED16_EXTERN(const u32 g_minvals[4]);
PCSX2_ALIGNED16_EXTERN(const u32 g_maxvals[4]);
PCSX2_ALIGNED16_EXTERN(const u32 const_clip[8]);
u32 GetVIAddr(VURegs * VU, int reg, int read, int info);
int _vuGetTempXMMreg(int info);