More work on BBA, changed mask in JIT to the same mask in interpreter. If this is wrong, beat me up, but it fixes BBA for commercial games at least

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3265 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2009-05-21 02:44:49 +00:00
parent e1f43fa5fb
commit cfb94849f9
4 changed files with 37 additions and 15 deletions

View File

@ -68,6 +68,22 @@ bool CEXIETHERNET::activate() {
return true; return true;
} }
bool CEXIETHERNET::CheckRecieved()
{
if(!isActivated())
return false;
char RBuffer[2048]; // Bigger than MTU, but w/e
int Size = recv(fd, RBuffer, 2048, MSG_PEEK);
if(Size == -1)
{
DEBUGPRINT("Recieve check failed with %d\n", errno);
return false;
}
if(Size != 0)
DEBUGPRINT("Have waiting Packet of size %d\n", Size);
return true;
}
bool CEXIETHERNET::startRecv() { bool CEXIETHERNET::startRecv() {
DEBUGPRINT("Start Receive!\n"); DEBUGPRINT("Start Receive!\n");
exit(0); exit(0);
@ -101,6 +117,8 @@ bool CEXIETHERNET::startRecv() {
} }
bool CEXIETHERNET::sendPacket(u8 *etherpckt, int size) bool CEXIETHERNET::sendPacket(u8 *etherpckt, int size)
{ {
if(!isActivated())
activate();
DEBUGPRINT( "Packet: 0x"); DEBUGPRINT( "Packet: 0x");
for(int a = 0; a < size; ++a) for(int a = 0; a < size; ++a)
{ {
@ -110,22 +128,11 @@ bool CEXIETHERNET::sendPacket(u8 *etherpckt, int size)
int numBytesWrit = write(fd, etherpckt, size); int numBytesWrit = write(fd, etherpckt, size);
if(numBytesWrit != size) if(numBytesWrit != size)
{ {
DEBUGPRINT("BBA sendPacket %i only got %i bytes sent!\n", size, numBytesWrit); DEBUGPRINT("BBA sendPacket %i only got %i bytes sent!errno: %d\n", size, numBytesWrit, errno);
return false; return false;
} }
else else
DEBUGPRINT("Sent out the correct number of bytes: %d\n", size); DEBUGPRINT("Sent out the correct number of bytes: %d\n", size);
//fwrite(etherpckt, size, size, raw_socket);
/*DWORD numBytesWrit;
OVERLAPPED overlap;
ZERO_OBJECT(overlap);
//overlap.hEvent = mHRecvEvent;
TGLE(WriteFile(mHAdapter, etherpckt, size, &numBytesWrit, &overlap));
if(numBytesWrit != size)
{
DEGUB("BBA sendPacket %i only got %i bytes sent!\n", size, numBytesWrit);
FAIL(UE_BBA_ERROR);
}*/
recordSendComplete(); recordSendComplete();
//exit(0); //exit(0);
return true; return true;

View File

@ -80,6 +80,7 @@ CEXIETHERNET::CEXIETHERNET() :
void CEXIETHERNET::SetCS(int cs) void CEXIETHERNET::SetCS(int cs)
{ {
DEBUGPRINT("Set CS: %s\n", cs ? "true" : "false");
if (!cs) if (!cs)
{ {
if (mExpectVariableLengthImmWrite) if (mExpectVariableLengthImmWrite)
@ -89,8 +90,7 @@ void CEXIETHERNET::SetCS(int cs)
} }
mExpectSpecialImmRead = false; mExpectSpecialImmRead = false;
mWriteP = mReadP = INVALID_P; mWriteP = mReadP = INVALID_P;
m_uPosition = 0; m_bInterruptSet = false;
Expecting = EXPECT_NONE;
} }
} }
@ -105,6 +105,9 @@ void CEXIETHERNET::Update()
} }
bool CEXIETHERNET::IsInterruptSet() bool CEXIETHERNET::IsInterruptSet()
{ {
//bool Temp = m_bInterruptSet;
//m_bInterruptSet = false;
//return Temp;
return m_bInterruptSet; return m_bInterruptSet;
} }
@ -367,11 +370,22 @@ u32 CEXIETHERNET::ImmRead(u32 _uSize)
exit(0); exit(0);
} }
u32 uResult = 0; u32 uResult = 0;
switch(mReadP)
{
case BBA_NWAYS: // Bit of a hack
mBbaMem[BBA_NWAYS] = (BBA_NWAYS_LS10 | BBA_NWAYS_LPNWAY | BBA_NWAYS_ANCLPT | BBA_NWAYS_10TXF);
break;
default:
break;
}
memcpy(&uResult, mBbaMem + mReadP, _uSize); memcpy(&uResult, mBbaMem + mReadP, _uSize);
// TODO: We do as well? // TODO: We do as well?
uResult = Common::swap32(uResult); //Whinecube : we have a byteswap problem... uResult = Common::swap32(uResult); //Whinecube : we have a byteswap problem...
//DEBUGPRINT("Mem spot is 0x%02x uResult is 0x%x\n", mBbaMem[mReadP], uResult); //DEBUGPRINT("Mem spot is 0x%02x uResult is 0x%x\n", mBbaMem[mReadP], uResult);
#ifndef _WIN32
CheckRecieved();
#endif
DEBUGPRINT( "\t[INFO]Read from BBA address 0x%0*X, %i byte%s: 0x%0*X\n",mReadP >= CB_OFFSET ? 4 : 2, mReadP, _uSize, (_uSize==1?"":"s"),_uSize*2, getbitsw(uResult, 0, _uSize * 8 - 1)); DEBUGPRINT( "\t[INFO]Read from BBA address 0x%0*X, %i byte%s: 0x%0*X\n",mReadP >= CB_OFFSET ? 4 : 2, mReadP, _uSize, (_uSize==1?"":"s"),_uSize*2, getbitsw(uResult, 0, _uSize * 8 - 1));
mReadP = mReadP + _uSize; mReadP = mReadP + _uSize;
return uResult; return uResult;

View File

@ -139,6 +139,7 @@ private:
//TAP interface //TAP interface
bool activate(); bool activate();
bool CheckRecieved();
bool deactivate(); bool deactivate();
bool isActivated(); bool isActivated();
bool resume(); bool resume();

View File

@ -63,7 +63,7 @@ using namespace Gen;
fpr.Flush(FLUSH_ALL); fpr.Flush(FLUSH_ALL);
//Bits SRR1[0, 5-9, 16-23, 25-27, 30-31] are placed into the corresponding bits of the MSR. //Bits SRR1[0, 5-9, 16-23, 25-27, 30-31] are placed into the corresponding bits of the MSR.
//MSR[13] is set to 0. //MSR[13] is set to 0.
const u32 mask = 0x87C0FF73; const u32 mask = 0x87C0FFFF;
// MSR = (MSR & ~mask) | (SRR1 & mask); // MSR = (MSR & ~mask) | (SRR1 & mask);
MOV(32, R(EAX), M(&MSR)); MOV(32, R(EAX), M(&MSR));
MOV(32, R(ECX), M(&SRR1)); MOV(32, R(ECX), M(&SRR1));