More work on BBA. Endianess problems are yes. I have no idea what I'm doing

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1556 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2008-12-16 07:24:04 +00:00
parent f2686589e9
commit 5241b51d5f
1 changed files with 41 additions and 22 deletions

View File

@ -29,11 +29,12 @@ unsigned int Expecting;
CEXIETHERNET::CEXIETHERNET() : CEXIETHERNET::CEXIETHERNET() :
m_uPosition(0), m_uPosition(0),
m_uCommand(0), m_uCommand(0),
mWriteBuffer(2000) mWriteBuffer(2048)
{ {
ID = 0x04020200; ID = 0x04020200;
mWriteP = INVALID_P; mWriteP = INVALID_P;
mReadP = INVALID_P; mReadP = INVALID_P;
mReadyToSend = false;
mExpectSpecialImmRead = false; mExpectSpecialImmRead = false;
@ -47,12 +48,13 @@ void CEXIETHERNET::SetCS(int cs)
{ {
m_uPosition = 0; m_uPosition = 0;
Expecting = EXPECT_NONE; Expecting = EXPECT_NONE;
mReadyToSend = true;
} }
} }
bool CEXIETHERNET::IsPresent() bool CEXIETHERNET::IsPresent()
{ {
return false; return true;
} }
void CEXIETHERNET::Update() void CEXIETHERNET::Update()
@ -86,10 +88,11 @@ inline u32 getbitsh(u32 hword, int start, int end) {
inline u32 getbitsw(u32 dword, int start, int end) { inline u32 getbitsw(u32 dword, int start, int end) {
return (dword & makemaskw(start, end)) >> (31 - end); return (dword & makemaskw(start, end)) >> (31 - end);
} }
#define MAKE(type, arg) (*(type *)&(arg))
void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize) void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
{ {
printf("IMM Write, size 0x%x, data 0x%x\n", _uSize, _uData); printf("IMM Write, size 0x%x, data 0x%x mWriteP 0x%x\n", _uSize, _uData, mWriteP);
if(mExpectVariableLengthImmWrite) if(mExpectVariableLengthImmWrite)
{ {
printf("Not doing expecting variable length imm write!\n"); printf("Not doing expecting variable length imm write!\n");
@ -108,33 +111,42 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
{ {
case 0x09: case 0x09:
printf("mWriteP is %x\n", mWriteP); printf("mWriteP is %x\n", mWriteP);
exit(0);
//BBADEGUB("BBA Interrupt reset 0x%02X & ~(0x%02X) => 0x%02X\n", mBbaMem[0x09], MAKE(BYTE, data), mBbaMem[0x09] & ~MAKE(BYTE, data)); //BBADEGUB("BBA Interrupt reset 0x%02X & ~(0x%02X) => 0x%02X\n", mBbaMem[0x09], MAKE(BYTE, data), mBbaMem[0x09] & ~MAKE(BYTE, data));
//MYASSERT(_uSize == 1); //assert(_uSize == 1);
//mBbaMem[0x09] &= ~MAKE(BYTE, data); // TODO: Should we swap our data?
mBbaMem[0x09] &= ~MAKE(u8, _uData);
exit(0);
break; break;
case BBA_NCRA: case BBA_NCRA:
printf("mWriteP is %x\n", mWriteP); // TODO: Should we swap our data?
exit(0); #define RISE(flags) ((_uData & (flags)) && !(mBbaMem[0x00] & (flags)))
/*#define RISE(flags) ((data & (flags)) && !(mBbaMem[0x00] & (flags)))
if(RISE(BBA_NCRA_RESET)) if(RISE(BBA_NCRA_RESET))
{ {
printf("BBA Reset\n"); printf("BBA Reset\n");
exit(0);
} }
if(RISE(BBA_NCRA_SR) && isActivated()) if(RISE(BBA_NCRA_SR) )/*&& isActivated()) */
{ {
BBADEGUB("BBA Start Recieve\n"); printf("BBA Start Recieve\n");
HWGLE(startRecv()); exit(0);
//HWGLE(startRecv());
} }
if(RISE(BBA_NCRA_ST1)) if(RISE(BBA_NCRA_ST1))
{ {
BBADEGUB("BBA Start Transmit\n"); printf("BBA Start Transmit\n");
if(!mReadyToSend) if(!mReadyToSend)
throw hardware_fatal_exception("BBA Transmit without a packet!"); {
HWGLE(sendPacket(mWriteBuffer.p(), mWriteBuffer.size())); printf("Not ready to send!\n");
exit(0);
}
//throw hardware_fatal_exception("BBA Transmit without a packet!");
//HWGLE(sendPacket(mWriteBuffer.p(), mWriteBuffer.size()));
mReadyToSend = false; mReadyToSend = false;
exit(0);
} }
mBbaMem[0x00] = MAKE(BYTE, data);*/ // TODO: Swap here?
_uData = Common::swap32(_uData);
mBbaMem[0x00] = MAKE(u8, _uData);
break; break;
case BBA_NWAYC: case BBA_NWAYC:
printf("mWriteP is %x\n", mWriteP); printf("mWriteP is %x\n", mWriteP);
@ -163,7 +175,8 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
MYASSERT(data == DWORD((WORD)mCbw.p_write() + CB_OFFSET) >> 8);*/ MYASSERT(data == DWORD((WORD)mCbw.p_write() + CB_OFFSET) >> 8);*/
break; break;
default: default:
printf("Default one!\n"); printf("Default one!Size 0x%x _uData: 0x%08x Swapped 0x%08x to 0x%x\n", _uSize, _uData, Common::swap32(_uData),mWriteP);
_uData = Common::swap32(_uData);
memcpy(mBbaMem + mWriteP, &_uData, _uSize); memcpy(mBbaMem + mWriteP, &_uData, _uSize);
mWriteP = mWriteP + _uSize; mWriteP = mWriteP + _uSize;
} }
@ -179,9 +192,9 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
{ // Write to BBA Register { // Write to BBA Register
printf("Write to BBA register!\n"); printf("Write to BBA register!\n");
if(_uSize == 4) if(_uSize == 4)
mWriteP = (u8)getbitsw(_uData, 16, 23); mWriteP = (u8)getbitsw(Common::swap32(_uData), 16, 23);
else //size == 2 else //size == 2
mWriteP = (u8)getbitsw(_uData & ~0x4000, 16, 23); //Dunno about this... mWriteP = (u8)getbitsw(Common::swap32(_uData) & ~0x4000, 16, 23); //Whinecube : Dunno about this...
if(mWriteP == 0x48) if(mWriteP == 0x48)
{ {
mWriteBuffer.clear(); mWriteBuffer.clear();
@ -190,7 +203,9 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
} }
else else
{ {
//BBADEGUB("BBA Write pointer set to 0x%0*X\n", size, mWriteP);
printf("BBA Write pointer set to 0x%0*X\n", _uSize, mWriteP);
//exit(0);
} }
return; return;
} }
@ -242,9 +257,13 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
//mBbaMem[mReadP] = 0x00; //mBbaMem[mReadP] = 0x00;
//if(!sendInProgress()) //if(!sendInProgress())
mBbaMem[mReadP] &= ~(0x06); mBbaMem[mReadP] &= ~(0x06);
printf("mBbaMem[0x%x] &= ~(0x06);! Now %x\n", mReadP, mBbaMem[mReadP]);
//exit(0);
break; break;
case 0x03: case 0x03:
mBbaMem[mReadP] = 0x80; mBbaMem[mReadP] = 0x80;
printf("mBbaMem[0x%x] = 0x80;! Now %x\n", mReadP, mBbaMem[mReadP]);
exit(0);
break; break;
} }
//BBADEGUB("BBA Read pointer set to 0x%0*X\n", size, mReadP); //BBADEGUB("BBA Read pointer set to 0x%0*X\n", size, mReadP);
@ -270,8 +289,8 @@ u32 CEXIETHERNET::ImmRead(u32 _uSize)
} }
u32 uResult = 0; u32 uResult = 0;
memcpy(&uResult, mBbaMem + mReadP, _uSize); memcpy(&uResult, mBbaMem + mReadP, _uSize);
// We do as well? // TODO: We do as well?
//data = swapw(data); //we have a byteswap problem... uResult = Common::swap32(uResult); //Whinecube : we have a byteswap problem...
printf("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)); printf("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;