Corrected alignment issues with netboard RAM; send/receive parameters no longer need to be manipulated to work correctly. Fixes bugs including Scud Race linked car orientation.

This commit is contained in:
Matthew Daniels 2021-03-22 01:08:45 +00:00
parent 4b9221ecd6
commit 98d4f1c6f6
2 changed files with 52 additions and 118 deletions

View file

@ -1008,7 +1008,7 @@ UINT8 CModel3::Read8(UINT32 addr)
{
case 0:
//printf("R8 netbuffer @%x=%x\n", (addr & 0xFFFF), netBuffer[(addr & 0xFFFF)]);
return netBuffer[(addr & 0xFFFF)];
return netBuffer[(addr & 0xFFFF) ^ 2];
case 1: // ioreg 32bits access in 16bits environment
if (addr > 0xc00101ff)
@ -1148,7 +1148,7 @@ UINT16 CModel3::Read16(UINT32 addr)
{
case 0:
//printf("R16 netbuffer @%x=%x\n", (addr & 0xFFFF), FLIPENDIAN16(*(UINT16 *)&netBuffer[(addr & 0xFFFF)]));
result = *(UINT16 *)&netBuffer[(addr & 0xFFFF)];
result = *(UINT16 *)&netBuffer[(addr & 0xFFFF) ^ 2];
return FLIPENDIAN16(result); // result
default:
printf("CMODEL3 : unknown R16 : %x (C0)\n", addr);
@ -1490,7 +1490,7 @@ void CModel3::Write8(UINT32 addr, UINT8 data)
{
case 0:
//printf("W8 netbuffer @%x<-%x\n", (addr & 0xFFFF), data);
*(UINT8 *)&netBuffer[(addr & 0xFFFF)] = data;
*(UINT8 *)&netBuffer[(addr & 0xFFFF) ^ 2] = data;
break;
case 1: // ioreg 32bits access to 16bits range
@ -1625,7 +1625,7 @@ void CModel3::Write16(UINT32 addr, UINT16 data)
{
case 0:
//printf("W16 netbuffer @%x<-%x\n", (addr & 0xFFFF), data);
*(UINT16 *)&netBuffer[(addr & 0xFFFF)] = FLIPENDIAN16(data);
*(UINT16 *)&netBuffer[(addr & 0xFFFF) ^ 2] = FLIPENDIAN16(data);
break;
default:

View file

@ -171,7 +171,7 @@ UINT8 CNetBoard::Read8(UINT32 a)
DebugLog("OUT OF RANGE RAM[%x]\n", a);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Info", "Out of Range", NULL);
}
return RAM[a];
return RAM[a ^ 1];
case 0x4:
//DebugLog("Netboard R8\tctrlrw[%x]=%x\n", a&0xff, ctrlrw[a&0xff]);
@ -203,7 +203,7 @@ UINT8 CNetBoard::Read8(UINT32 a)
DebugLog("OUT OF RANGE CommRAM[%x]\n", a);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Info", "Out of Range", NULL);
}
return CommRAM[a & 0xffff];
return CommRAM[(a & 0xffff) ^ 1];
case 0xc: // dirt devils
//DebugLog("Netboard R8\tioreg[%x]=%x\t\t", a&0xff, ioreg[a&0xff]);
@ -219,38 +219,38 @@ UINT8 CNetBoard::Read8(UINT32 a)
DebugLog("Netboard R8\tioreg[%x]=%x\t\treceive result status\n", a & 0xff, ioreg[a & 0xff]);
//return 0x5; /////////////////////////////////// pure hack for spikofe - must have the pure hack spikeout enable too ///////////////////////////////////////////////////////
if (Gameinfo.name.compare("spikeofe") == 0) return 0x5;
return ioreg[a&0xff];
return ioreg[(a&0xff) ^ 1];
break;
case 0x19: // ioreg[c0019]
DebugLog("Netboard R8\tioreg[%x]=%x\t\ttransmit result status\n", a & 0xff, ioreg[a & 0xff]);
return ioreg[a&0xff];
return ioreg[(a&0xff) ^ 1];
break;
case 0x81: // ioreg[c0081]
DebugLog("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
return ioreg[a&0xff];
return ioreg[(a&0xff) ^ 1];
break;
case 0x83: // ioreg[c0083]
DebugLog("Netboard R8\tioreg[%x]=%x\t\tirq status\n", a & 0xff, ioreg[a & 0xff]);
return ioreg[a&0xff];
return ioreg[(a&0xff) ^ 1];
break;
case 0x89: // ioreg[c0089]
DebugLog("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
return ioreg[a&0xff];
return ioreg[(a&0xff) ^ 1];
break;
case 0x8a: // ioreg[c008a]
DebugLog("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
return ioreg[a & 0xff];
return ioreg[(a&0xff) ^ 1];
break;
default:
DebugLog("unknown c00(%x)\n", a & 0xff);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Info", "Unknown R8 IOREG", NULL);
return ioreg[a&0xff];
return ioreg[(a&0xff) ^ 1];
break;
}
@ -425,7 +425,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
DebugLog("OUT OF RANGE RAM[%x]\n", a);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Info", "Out of Range", NULL);
}
RAM[a] = d;
RAM[a ^ 1] = d;
break;
case 0x4:
@ -478,7 +478,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
DebugLog("OUT OF RANGE CommRAM[%x]\n", a);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Info", "Out of Range", NULL);
}
CommRAM[a & 0xffff] = d;
CommRAM[(a & 0xffff) ^ 1] = d;
break;
case 0xc: // dirt devils
@ -492,24 +492,24 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
switch (a & 0xff)
{
case 0x01: // ioreg[c0001]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
#ifdef NET_DEBUG
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break;
case 0x03: // ioreg[c0003]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x05: // ioreg[c0005]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
/*case 0x15: // 0x00 0x01 0x80 // ioreg[c0015]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
if ((d & 0xFF) != 0x80)
@ -534,7 +534,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
break;
case 0x17: // 0x00 0x8c // ioreg[c0017]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
//M68KSetIRQ(6); // si irq6 ici, reset master a la fin de la synchro
DebugLog("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
if ((d & 0xFF) == 0x8C)
@ -581,50 +581,20 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
// slave follow with 15 17 then (set id node) 1b 1d
case 0x15: // 0x00 0x01 0x80 // ioreg[c0015]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
switch (d & 0xff)
{
case 0x80:
DebugLog("\nreceiving : \n");
//if (recv_offset > 0x1000)
if (recv_size < 0x0019) // must find a better condition
{
//auto recv_data = udpReceive.ReadData(5000);
//DebugLog("-> nb recu : %x\n", recv_data.size());
//memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
//DebugLog("receive enable off=%x size=%x\n", recv_offset, recv_size);
DebugLog("receive enable off=%x size=%x\n", recv_offset, recv_size);
auto &recv_data = netr->Receive();
memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
}
else
{
DebugLog("receive enable original value off=%x size=%x\n", recv_offset, recv_size);
slot = (recv_size >> 12) & 0x0f;
recv_size = recv_size & 0x0fff;
recv_size = (recv_size << 4) | ((recv_size >> 8) & 0x000f);
recv_size = recv_size & 0x0fff;
if (slot != 0)
{
recv_size = recv_size * slot;
}
recv_offset = (recv_offset << 8) | (recv_offset >> 8);
//DebugLog("receive enable off=%x size=%x slot=%x\n", recv_offset, recv_size, slot);
//auto recv_data = udpReceive.ReadData(5000);
auto &recv_data = netr->Receive();
DebugLog("-> nb recu : %x\n", recv_data.size());
memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
}
#ifdef NET_DEBUG
DebugLog("receiving : ");
if (recv_size > 50) // too long to print so...
{
for (int i = 0; i < 100; i++)
@ -659,7 +629,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
break;
case 0x17: // 0x00 0x8c // ioreg[c0017]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
switch (d & 0xff)
@ -681,7 +651,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x19: // ioreg[c0019]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\t\ttransmit result status\n", a & 0xff, d);
break;
@ -689,51 +659,15 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
// 1b is where real send must be because master always initiate dial with 1b (sure)
case 0x1b: // 0x80 // ioreg[c001b]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\t\t\n", a & 0xff, d);
switch (d & 0xff)
{
case 0x80:
//if (send_offset > 0x1000)
if (send_size < 0x0011) // must find a better condition
{
//udpSend.SendAsync(addr_out.data(), port_out, send_size, (const char*)CommRAM + send_offset, 1000);
nets->Send((const char*)CommRAM + send_offset, send_size);
DebugLog("send enable off=%x size=%x\n", send_offset, send_size);
}
else
{
DebugLog("send enable original value off=%x size=%x\n", send_offset, send_size);
slot = (send_size >> 12) & 0x0f;
send_size = send_size & 0x0fff;
send_size = (send_size << 4) | ((send_size >> 8) & 0x000f);
send_size = send_size & 0x0fff;
//if (slot == 0) slot = (recv_size >> 12) & 0x0f; // cheat hack for harley,skichamp, and dirt in the same time
//if (Gameinfo.name.compare("dirtdvls")!=0) slot = (recv_size >> 12) & 0x0f;
//if (Gameinfo.name.find("dirtdvls") == std::string::npos) slot = (recv_size >> 12) & 0x0f;
//if (slot != 0)
//if ((slot != 0) && (((recv_size >> 12) & 0x0f) == 0)) // if dirt, warning may be lemans,von2 too (test name game ?)
//if (Gameinfo.name.compare("dirtdvls") == 0) // dirtdvls up to 4 players
if (Gameinfo.name.find("dirtdvls") != std::string::npos) // dirtdvls up to 4 players
{
send_size = send_size * slot * (CommRAM[0x0002] - 1); // dirtdvls CommRAM[0x0002] = number of machine
}
else
{
if (slot == 0) slot = (recv_size >> 12) & 0x0f; // for harley,skichamp
send_size = send_size * slot;
}
send_offset = (send_offset << 8) | (send_offset >> 8);
//udpSend.SendAsync(addr_out.data(), port_out, send_size, (const char*)CommRAM + send_offset, 1000);
nets->Send((const char*)CommRAM + send_offset, send_size);
DebugLog("send enable off=%x size=%x slot=%x\n", send_offset, send_size, slot);
}
#ifdef NET_DEBUG
DebugLog("transmitting : ");
if (send_size > 50) //too big for print, so...
@ -765,7 +699,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
break;
case 0x1d: // 0x8c // ioreg[c001d]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
switch (d & 0xff)
@ -786,12 +720,12 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x29: // ioreg[c0029]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x2f: // 0x00 or 0x00->0x40->0x00 or 0x82// ioreg[c002f]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
/*if ((d & 0xff) == 0x00)
@ -812,7 +746,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
break;
case 0x41: // ioreg[c0041]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
recv_offset = (recv_offset >> 8) | (d << 8 );
//DebugLog("recv off = %x\n",recv_offset);
@ -820,105 +754,105 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
break;
case 0x43: // ioreg[c0043]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
recv_size = (recv_size >> 8) | (d << 8);
DebugLog("recv size = %x\n", d);
break;
case 0x45: // ioreg[c0045]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
send_offset = (send_offset >> 8) | (d << 8);
//DebugLog("send off = %x\n", send_offset);
DebugLog("send off = %x\n", d);
break;
case 0x47: // ioreg[c0047]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
send_size = (send_size >> 8) | (d << 8);
//DebugLog("send size = %x\n", send_size);
DebugLog("send size = %x\n", d);
break;
case 0x51: //0x04 0x18 // ioreg[c0051]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x55: // ioreg[c0055]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x57: // 0x04->0x09 // ioreg[c0057]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x59: // ioreg[c0059]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x5b: // ioreg[c005b]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x5d: // ioreg[c005d]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x5f: // ioreg[c005f]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x81: // ioreg[c0081]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x83: // 0x35 once and after 0x00 always // ioreg[c0083] // just apres le ioreg[83]=0 on a ppc R32 ioreg[114] et R32 ioreg[110] et apres ack irq5
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x85: // ioreg[c0085]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x87: // ioreg[c0087]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x88: // ioreg[c0088]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x89: // ioreg[c0089] // dayto2pe loops with values 00 01 02 during type 2 trame
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
//CommRAM[4] = d; /////////////////////////////////// pure hack for spikeout /////////////////////////////////////////////////////////////////////////////////////////////
if (Gameinfo.name.compare("spikeout") == 0 || Gameinfo.name.compare("spikeofe") == 0) CommRAM[4] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x8a: // ioreg[c008a]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
case 0x8b: // ioreg[c008b]
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
break;
default:
DebugLog("unknown c00(%x)\n", a & 0xff);
ioreg[a & 0xff] = d;
ioreg[(a & 0xff) ^ 1] = d;
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Info", "Unknown W8 IOREG", NULL);
break;