mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-29 17:15:40 +00:00
Update network code (Spindizzi)
This commit is contained in:
parent
995cf6adb0
commit
d8572a923a
|
@ -1108,7 +1108,7 @@ UINT16 CModel3::Read16(UINT32 addr)
|
||||||
switch ((addr & 0x3ffff) >> 16)
|
switch ((addr & 0x3ffff) >> 16)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
printf("R16 netbuffer @%x=%x\n", (addr & 0xFFFF), FLIPENDIAN16(*(UINT16 *)&netBuffer[(addr & 0xFFFF)]));
|
//printf("R16 netbuffer @%x=%x\n", (addr & 0xFFFF), FLIPENDIAN16(*(UINT16 *)&netBuffer[(addr & 0xFFFF)]));
|
||||||
result = *(UINT16 *)&netBuffer[(addr & 0xFFFF)];
|
result = *(UINT16 *)&netBuffer[(addr & 0xFFFF)];
|
||||||
return FLIPENDIAN16(result); // result
|
return FLIPENDIAN16(result); // result
|
||||||
default:
|
default:
|
||||||
|
@ -1275,7 +1275,8 @@ UINT32 CModel3::Read32(UINT32 addr)
|
||||||
case 0:
|
case 0:
|
||||||
//printf("R32 netbuffer @%x=%x\n", (addr & 0xFFFF), FLIPENDIAN32(*(UINT32 *)&netBuffer[(addr & 0xFFFF)]));
|
//printf("R32 netbuffer @%x=%x\n", (addr & 0xFFFF), FLIPENDIAN32(*(UINT32 *)&netBuffer[(addr & 0xFFFF)]));
|
||||||
result = *(UINT32 *)&netBuffer[(addr & 0xFFFF)];
|
result = *(UINT32 *)&netBuffer[(addr & 0xFFFF)];
|
||||||
return FLIPENDIAN32(result); // result
|
return _rotl(FLIPENDIAN32(result), 16);
|
||||||
|
//return FLIPENDIAN32(result); // result
|
||||||
|
|
||||||
case 1: // ioreg 32bits access to 16bits range
|
case 1: // ioreg 32bits access to 16bits range
|
||||||
//printf("R32 ioreg @%x=%x\n", (addr & 0x1FF), FLIPENDIAN32(*(UINT32 *)&netBuffer[0x10000 + ((addr & 0x1FF) / 2)]));
|
//printf("R32 ioreg @%x=%x\n", (addr & 0x1FF), FLIPENDIAN32(*(UINT32 *)&netBuffer[0x10000 + ((addr & 0x1FF) / 2)]));
|
||||||
|
@ -1443,7 +1444,7 @@ void CModel3::Write8(UINT32 addr, UINT8 data)
|
||||||
#ifdef NET_BOARD
|
#ifdef NET_BOARD
|
||||||
if (m_game.stepping != "1.0" && (NetBoard.IsAttached() && (m_config["EmulateNet"].ValueAs<bool>())))
|
if (m_game.stepping != "1.0" && (NetBoard.IsAttached() && (m_config["EmulateNet"].ValueAs<bool>())))
|
||||||
{
|
{
|
||||||
printf("CModel 3 : write8 %x<-%x\n", addr, data);
|
//printf("CModel 3 : write8 %x<-%x\n", addr, data);
|
||||||
|
|
||||||
switch ((addr & 0x3ffff) >> 16)
|
switch ((addr & 0x3ffff) >> 16)
|
||||||
{
|
{
|
||||||
|
@ -1788,7 +1789,8 @@ void CModel3::Write32(UINT32 addr, UINT32 data)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
//printf("W32 netbuffer @%x<-%x\n", (addr & 0xFFFF), data);
|
//printf("W32 netbuffer @%x<-%x\n", (addr & 0xFFFF), data);
|
||||||
*(UINT32 *)&netBuffer[(addr & 0xFFFF)] = FLIPENDIAN32(data);
|
//*(UINT32 *)&netBuffer[(addr & 0xFFFF)] = FLIPENDIAN32(data);
|
||||||
|
*(UINT32 *)&netBuffer[(addr & 0xFFFF)] = _rotl(FLIPENDIAN32(data), 16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // ioreg 32bits access to 16bits range
|
case 1: // ioreg 32bits access to 16bits range
|
||||||
|
@ -1820,6 +1822,13 @@ void CModel3::Write32(UINT32 addr, UINT32 data)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((*(UINT16 *)&netBuffer[(0xc00100c0 & 0x3FFFF)] == FLIPENDIAN16(0x0000)) && NetBoard.CodeReady == true) // c0=180/2 // reset net when reboot - not perfect, I think memory must be cleared
|
||||||
|
{
|
||||||
|
printf("Network pause\n");
|
||||||
|
NetBoard.CodeReady = false;
|
||||||
|
NetBoard.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
if ((*(UINT16 *)&netBuffer[(0xc0010088 & 0x3FFFF)] == FLIPENDIAN16(0x0080)) && NetBoard.CodeReady == false) // 88=110/2
|
if ((*(UINT16 *)&netBuffer[(0xc0010088 & 0x3FFFF)] == FLIPENDIAN16(0x0080)) && NetBoard.CodeReady == false) // 88=110/2
|
||||||
{
|
{
|
||||||
printf("Network code copy ending\n");
|
printf("Network code copy ending\n");
|
||||||
|
@ -2030,15 +2039,16 @@ void CModel3::RunFrame(void)
|
||||||
#ifdef NET_BOARD
|
#ifdef NET_BOARD
|
||||||
if (NetBoard.IsAttached() && (m_config["EmulateNet"].ValueAs<bool>()) && ((*(UINT16 *)&netBuffer[(0xc00100C0 & 0x3FFFF)] == 0xFFFF) || (netBuffer[(0xc00100C0 & 0x3FFFF)] == 0xFF) || (*(UINT16 *)&netBuffer[(0xc00100C0 & 0x3FFFF)] == 0x0001)) && (NetBoard.CodeReady == true))
|
if (NetBoard.IsAttached() && (m_config["EmulateNet"].ValueAs<bool>()) && ((*(UINT16 *)&netBuffer[(0xc00100C0 & 0x3FFFF)] == 0xFFFF) || (netBuffer[(0xc00100C0 & 0x3FFFF)] == 0xFF) || (*(UINT16 *)&netBuffer[(0xc00100C0 & 0x3FFFF)] == 0x0001)) && (NetBoard.CodeReady == true))
|
||||||
{
|
{
|
||||||
// ppc irq network needed ? no effect, is it really active ?
|
// ppc irq network needed ? no effect, is it really active/needed ?
|
||||||
RunNetBoardFrame();
|
//RunNetBoardFrame();
|
||||||
IRQ.Assert(0x10);
|
IRQ.Assert(0x10);
|
||||||
ppc_execute(200); // give PowerPC time to acknowledge IRQ
|
ppc_execute(200); // give PowerPC time to acknowledge IRQ
|
||||||
//RunNetBoardFrame();
|
//RunNetBoardFrame();
|
||||||
IRQ.Deassert(0x10);
|
IRQ.Deassert(0x10);
|
||||||
ppc_execute(200); // acknowledge that IRQ was deasserted (TODO: is this really needed?)
|
ppc_execute(200); // acknowledge that IRQ was deasserted (TODO: is this really needed?)
|
||||||
//RunNetBoardFrame();
|
RunNetBoardFrame();
|
||||||
|
// Hum hum, if runnetboardframe is called at 1st place or between ppc irq assert/deassert, spikout freezes just after the gate with net error
|
||||||
|
// if runnetboardframe is called after ppc irq assert/deassert, spikout works
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3185,6 +3195,9 @@ bool CModel3::LoadGame(const Game &game, const ROMSet &rom_set)
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
m_game = game;
|
m_game = game;
|
||||||
|
#ifdef NET_BOARD
|
||||||
|
NetBoard.GetGame(m_game);
|
||||||
|
#endif
|
||||||
return OKAY;
|
return OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,7 @@ UINT8 CNetBoard::Read8(UINT32 a)
|
||||||
case 0x11: // ioreg[c0011]
|
case 0x11: // ioreg[c0011]
|
||||||
DPRINTF("Netboard R8\tioreg[%x]=%x\t\treceive result status\n", a & 0xff, ioreg[a & 0xff]);
|
DPRINTF("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 ///////////////////////////////////////////////////////
|
//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];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -592,16 +593,25 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
|
||||||
switch (d & 0xff)
|
switch (d & 0xff)
|
||||||
{
|
{
|
||||||
case 0x80:
|
case 0x80:
|
||||||
#ifdef NET_DEBUG
|
DPRINTF("\nreceiving : \n");
|
||||||
printf("\nreceiving : \n");
|
|
||||||
#endif
|
|
||||||
//if (recv_offset > 0x1000)
|
//if (recv_offset > 0x1000)
|
||||||
if (recv_size < 0x0019) // must find a better condition
|
if (recv_size < 0x0019) // must find a better condition
|
||||||
{
|
{
|
||||||
auto recv_data = udpReceive.ReadData(5000);
|
//auto recv_data = udpReceive.ReadData(5000);
|
||||||
printf("-> nb recu : %x\n", recv_data.size());
|
//printf("-> nb recu : %x\n", recv_data.size());
|
||||||
memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
|
//memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
|
||||||
|
//DPRINTF("receive enable off=%x size=%x\n", recv_offset, recv_size);
|
||||||
|
UINT16 s = 0;
|
||||||
|
std::vector <uint8_t> recv_data;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
recv_data = udpReceive.ReadData(500);
|
||||||
|
DPRINTF("-> nb recu : %x\n", recv_data.size());
|
||||||
|
s = recv_data.size();
|
||||||
DPRINTF("receive enable off=%x size=%x\n", recv_offset, recv_size);
|
DPRINTF("receive enable off=%x size=%x\n", recv_offset, recv_size);
|
||||||
|
} while (s == 0);
|
||||||
|
memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -617,10 +627,10 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
|
||||||
}
|
}
|
||||||
recv_offset = (recv_offset << 8) | (recv_offset >> 8);
|
recv_offset = (recv_offset << 8) | (recv_offset >> 8);
|
||||||
|
|
||||||
DPRINTF("receive enable off=%x size=%x slot=%x\n", recv_offset, recv_size, slot);
|
//printf("receive enable off=%x size=%x slot=%x\n", recv_offset, recv_size, slot);
|
||||||
|
|
||||||
auto recv_data = udpReceive.ReadData(5000);
|
auto recv_data = udpReceive.ReadData(5000);
|
||||||
printf("-> nb recu : %x\n", recv_data.size());
|
DPRINTF("-> nb recu : %x\n", recv_data.size());
|
||||||
memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
|
memcpy(CommRAM + recv_offset, recv_data.data(), recv_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +692,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
|
||||||
|
|
||||||
case 0x19: // ioreg[c0019]
|
case 0x19: // ioreg[c0019]
|
||||||
ioreg[a & 0xff] = d;
|
ioreg[a & 0xff] = d;
|
||||||
DPRINTF("Netboard W8\tioreg[%x] <- %x\t\ttransmit result status\n");
|
DPRINTF("Netboard W8\tioreg[%x] <- %x\t\ttransmit result status\n", a & 0xff, d);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 1b 1d = send part
|
// 1b 1d = send part
|
||||||
|
@ -711,10 +721,19 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
|
||||||
send_size = (send_size << 4) | ((send_size >> 8) & 0x000f);
|
send_size = (send_size << 4) | ((send_size >> 8) & 0x000f);
|
||||||
send_size = send_size & 0x0fff;
|
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 (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 (slot != 0)
|
//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_size = send_size * slot;
|
||||||
}
|
}
|
||||||
send_offset = (send_offset << 8) | (send_offset >> 8);
|
send_offset = (send_offset << 8) | (send_offset >> 8);
|
||||||
|
@ -888,9 +907,10 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
|
||||||
DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
|
DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x89: // ioreg[c0089] // dayto2pe loops with values 00 01 02 during type 2 frame
|
case 0x89: // ioreg[c0089] // dayto2pe loops with values 00 01 02 during type 2 trame
|
||||||
ioreg[a & 0xff] = d;
|
ioreg[a & 0xff] = d;
|
||||||
//CommRAM[4] = d; /////////////////////////////////// pure hack for spikeout /////////////////////////////////////////////////////////////////////////////////////////////
|
//CommRAM[4] = d; /////////////////////////////////// pure hack for spikeout /////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
if (Gameinfo.name.compare("spikeout") == 0 || Gameinfo.name.compare("spikeofe") == 0) CommRAM[4] = d;
|
||||||
DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
|
DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1061,7 +1081,7 @@ void CNetBoard::Write16(UINT32 a, UINT16 d)
|
||||||
DPRINTF("d = %x \n",d);
|
DPRINTF("d = %x \n",d);
|
||||||
|
|
||||||
M68KSetIRQ(4); // network error if removed
|
M68KSetIRQ(4); // network error if removed
|
||||||
M68KRun(1000); // 1000 is enought
|
M68KRun(1000); // 1000 is enough
|
||||||
M68KSetIRQ(2); // oui sinon pas de trame, pas de cycle sinon crash
|
M68KSetIRQ(2); // oui sinon pas de trame, pas de cycle sinon crash
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1324,7 +1344,6 @@ bool CNetBoard::RunFrame(void)
|
||||||
M68KSetIRQ(5);
|
M68KSetIRQ(5);
|
||||||
M68KRun((4000000 / 60));
|
M68KRun((4000000 / 60));
|
||||||
|
|
||||||
|
|
||||||
M68KGetContext(&M68K);
|
M68KGetContext(&M68K);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1368,5 +1387,8 @@ bool CNetBoard::IsAttached(void)
|
||||||
return m_attached;
|
return m_attached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CNetBoard::GetGame(Game gameinfo)
|
||||||
|
{
|
||||||
|
Gameinfo = gameinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
|
|
||||||
bool Init(UINT8 *netRAMPtr, UINT8 *netBufferPtr);
|
bool Init(UINT8 *netRAMPtr, UINT8 *netBufferPtr);
|
||||||
|
|
||||||
|
void GetGame(Game);
|
||||||
|
|
||||||
CNetBoard(const Util::Config::Node &config);
|
CNetBoard(const Util::Config::Node &config);
|
||||||
~CNetBoard(void);
|
~CNetBoard(void);
|
||||||
|
|
||||||
|
@ -73,6 +75,9 @@ private:
|
||||||
SMUDP::UDPSend udpSend;
|
SMUDP::UDPSend udpSend;
|
||||||
SMUDP::UDPReceive udpReceive;
|
SMUDP::UDPReceive udpReceive;
|
||||||
|
|
||||||
|
//game info
|
||||||
|
Game Gameinfo;
|
||||||
|
|
||||||
// only for some tests
|
// only for some tests
|
||||||
UINT8 *bank;
|
UINT8 *bank;
|
||||||
UINT8 *bank2;
|
UINT8 *bank2;
|
||||||
|
|
Loading…
Reference in a new issue