fixed some potential VU micromem clearing problems. i don't know if the fixes effect the current recs (most likely they do), but they definitely effect the new ones i'm working on :/

Devs: when writing to vu micromem
1) remember to vuMicro->clear (preferably with size being a multiple of 8, since micromem holds vu instructions, and the instructions are 8 bytes (64 bits))
2) clear before the write to memory! not after... (if the recs cache old microprograms (like mine will, and i think current ones do), and you clear after the write, then they're caching corrupt data :/)

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@691 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
cottonvibes 2009-02-04 07:52:55 +00:00 committed by Gregory Hainaut
parent 3fcb3a4143
commit cb52374106
6 changed files with 12 additions and 17 deletions

View File

@ -528,9 +528,8 @@ void __fastcall vuMicroWrite8(u32 addr,mem8_t data)
if (vu.Micro[addr]!=data)
{
ClearVuFunc<vunum, dynrec>(addr&(~7), 8); // Clear before writing new data (clearing 8 bytes because an instruction is 8 bytes) (cottonvibes)
vu.Micro[addr]=data;
ClearVuFunc<vunum, dynrec>(addr&(~7),1);
}
}
@ -542,9 +541,8 @@ void __fastcall vuMicroWrite16(u32 addr,mem16_t data)
if (*(u16*)&vu.Micro[addr]!=data)
{
ClearVuFunc<vunum, dynrec>(addr&(~7), 8);
*(u16*)&vu.Micro[addr]=data;
ClearVuFunc<vunum, dynrec>(addr&(~7),1);
}
}
@ -556,9 +554,8 @@ void __fastcall vuMicroWrite32(u32 addr,mem32_t data)
if (*(u32*)&vu.Micro[addr]!=data)
{
ClearVuFunc<vunum, dynrec>(addr&(~7), 8);
*(u32*)&vu.Micro[addr]=data;
ClearVuFunc<vunum, dynrec>(addr&(~7),1);
}
}
@ -570,9 +567,8 @@ void __fastcall vuMicroWrite64(u32 addr,const mem64_t* data)
if (*(u64*)&vu.Micro[addr]!=data[0])
{
ClearVuFunc<vunum, dynrec>(addr&(~7), 8);
*(u64*)&vu.Micro[addr]=data[0];
ClearVuFunc<vunum, dynrec>(addr,1);
}
}
@ -584,10 +580,9 @@ void __fastcall vuMicroWrite128(u32 addr,const mem128_t* data)
if (*(u64*)&vu.Micro[addr]!=data[0] || *(u64*)&vu.Micro[addr+8]!=data[1])
{
ClearVuFunc<vunum, dynrec>(addr&(~7), 16);
*(u64*)&vu.Micro[addr]=data[0];
*(u64*)&vu.Micro[addr+8]=data[1];
ClearVuFunc<vunum, dynrec>(addr,2);
}
}

View File

@ -50,7 +50,7 @@ static void TestClearVUs(u32 madr, u32 size)
{
if( madr >= 0x11000000 ) {
if( madr < 0x11004000 ) {
DbgCon::Notice("scratch pad clearing vu0");
DbgCon::Notice("scratch pad clearing vu0\n");
CpuVU0.Clear(madr&0xfff, size);
}
else if( madr >= 0x11008000 && madr < 0x1100c000 ) {
@ -78,7 +78,7 @@ int _SPR0chain() {
memcpy_fast((u8*)pMem, &PS2MEM_SCRATCH[spr0->sadr & 0x3fff], spr0->qwc << 4);
Cpu->Clear(spr0->madr, spr0->qwc<<2);
// clear VU mem also!
TestClearVUs(spr0->madr, spr0->qwc << 2);
TestClearVUs(spr0->madr, spr0->qwc << 2); // Wtf is going on here? AFAIK, only VIF should affect VU micromem (cottonvibes)
spr0->madr += spr0->qwc << 4;
}

View File

@ -812,8 +812,8 @@ static __forceinline void _vif0mpgTransfer(u32 addr, u32 *data, int size) {
fclose(f);
}*/
if (memcmp(VU0.Micro + addr, data, size << 2)) {
CpuVU0.Clear(addr, size << 2); // Clear before writing! :/ (cottonvibes)
memcpy_fast(VU0.Micro + addr, data, size << 2);
CpuVU0.Clear(addr, size);
}
}
@ -1486,8 +1486,8 @@ static __forceinline void _vif1mpgTransfer(u32 addr, u32 *data, int size) {
}*/
assert( VU1.Micro > 0 );
if (memcmp(VU1.Micro + addr, data, size << 2)) {
CpuVU1.Clear(addr, size << 2); // Clear before writing! :/
memcpy_fast(VU1.Micro + addr, data, size << 2);
CpuVU1.Clear(addr, size);
}
}

View File

@ -33,7 +33,7 @@ namespace VU0micro
void __fastcall recClear(u32 Addr, u32 Size)
{
SuperVUClear(Addr, Size*4, 0);
SuperVUClear(Addr, Size, 0); // Size should be a multiple of 8 bytes!
}
void recShutdown()

View File

@ -41,7 +41,7 @@ namespace VU1micro
void __fastcall recClear( u32 Addr, u32 Size )
{
assert( (Addr&7) == 0 );
SuperVUClear(Addr, Size*4, 1);
SuperVUClear(Addr, Size, 1); // Size should be a multiple of 8 bytes!
}
void recShutdown()

View File

@ -432,7 +432,7 @@ void __fastcall SuperVUClear(u32 startpc, u32 size, int vuindex)
{
vector<VuFunctionHeader::RANGE>::iterator itrange;
list<VuFunctionHeader*>::iterator it = s_listVUHeaders[vuindex].begin();
u32 endpc = startpc+size;
u32 endpc = startpc+(size+(8-(size&7))); // Adding this code to ensure size is always a multiple of 8, it can be simplified to startpc+size if size is always a multiple of 8 (cottonvibes)
while( it != s_listVUHeaders[vuindex].end() ) {
// for every fn, check if it has code in the range