use a few macros to make debugging less painful

This commit is contained in:
Ian Curtis 2018-01-06 01:18:14 +00:00
parent 314279ed25
commit 19e6aab1fa
2 changed files with 91 additions and 211 deletions

View file

@ -80,6 +80,16 @@
#include "UDPSend.h" #include "UDPSend.h"
#include "UDPReceive.h" #include "UDPReceive.h"
// few macros to make debugging a bit less painful
// if NET_DEBUG is defined, printf works normally, otherwise it's compiled to nothing (ie removed)
#if defined(NET_DEBUG)
#include <stdio.h>
#define DPRINTF printf
#else
#define DPRINTF(a, ...)
#endif
using namespace SMUDP; using namespace SMUDP;
static int(*Runnet68kCB)(int cycles); static int(*Runnet68kCB)(int cycles);
@ -149,9 +159,7 @@ UINT8 CNetBoard::Read8(UINT32 a)
switch (a & 0xff) switch (a & 0xff)
{ {
case 0x0: case 0x0:
#ifdef NET_DEBUG DPRINTF("Netboard R8\tctrlrw[%x]=%x\tcommbank = %x\n", a & 0xff, ctrlrw[a & 0xff], commbank);
printf("Netboard R8\tctrlrw[%x]=%x\tcommbank = %x\n", a & 0xff, ctrlrw[a & 0xff], commbank);
#endif
return ctrlrw[a&0xff];//commbank; return ctrlrw[a&0xff];//commbank;
break; break;
@ -187,44 +195,32 @@ UINT8 CNetBoard::Read8(UINT32 a)
switch (a & 0xff) switch (a & 0xff)
{ {
case 0x11: // ioreg[c0011] case 0x11: // ioreg[c0011]
#ifdef NET_DEBUG DPRINTF("Netboard R8\tioreg[%x]=%x\t\treceive result status\n", a & 0xff, ioreg[a & 0xff]);
printf("Netboard R8\tioreg[%x]=%x\t\treceive result status\n", a & 0xff, ioreg[a & 0xff]);
#endif
return ioreg[a&0xff]; return ioreg[a&0xff];
break; break;
case 0x19: // ioreg[c0019] case 0x19: // ioreg[c0019]
#ifdef NET_DEBUG DPRINTF("Netboard R8\tioreg[%x]=%x\t\ttransmit result status\n", a & 0xff, ioreg[a & 0xff]);
printf("Netboard R8\tioreg[%x]=%x\t\ttransmit result status\n", a & 0xff, ioreg[a & 0xff]);
#endif
return ioreg[a&0xff]; return ioreg[a&0xff];
break; break;
case 0x81: // ioreg[c0081] case 0x81: // ioreg[c0081]
#ifdef NET_DEBUG DPRINTF("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
printf("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
#endif
return ioreg[a&0xff]; return ioreg[a&0xff];
break; break;
case 0x83: // ioreg[c0083] case 0x83: // ioreg[c0083]
#ifdef NET_DEBUG DPRINTF("Netboard R8\tioreg[%x]=%x\t\tirq status\n", a & 0xff, ioreg[a & 0xff]);
printf("Netboard R8\tioreg[%x]=%x\t\tirq status\n", a & 0xff, ioreg[a & 0xff]);
#endif
return ioreg[a&0xff]; return ioreg[a&0xff];
break; break;
case 0x89: // ioreg[c0089] case 0x89: // ioreg[c0089]
#ifdef NET_DEBUG DPRINTF("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
printf("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
#endif
return ioreg[a&0xff]; return ioreg[a&0xff];
break; break;
case 0x8a: // ioreg[c008a] case 0x8a: // ioreg[c008a]
#ifdef NET_DEBUG DPRINTF("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
printf("Netboard R8\tioreg[%x]=%x\t\n", a & 0xff, ioreg[a & 0xff]);
#endif
return ioreg[a & 0xff]; return ioreg[a & 0xff];
break; break;
@ -315,16 +311,12 @@ UINT16 CNetBoard::Read16(UINT32 a)
{ {
case 0x88: // ioreg[c0088] case 0x88: // ioreg[c0088]
result = *(UINT16 *)&ioreg[a & 0xff]; result = *(UINT16 *)&ioreg[a & 0xff];
#ifdef NET_DEBUG DPRINTF("Netboard R16\tioreg[%x] = %x\n", a & 0xff, *(UINT16 *)&ioreg[a & 0xff]);
printf("Netboard R16\tioreg[%x] = %x\n", a & 0xff, *(UINT16 *)&ioreg[a & 0xff]);
#endif
return result; return result;
case 0x8a: // ioreg[c008a] case 0x8a: // ioreg[c008a]
result = *(UINT16 *)&ioreg[a & 0xff]; result = *(UINT16 *)&ioreg[a & 0xff];
#ifdef NET_DEBUG DPRINTF("Netboard R16\tioreg[%x] = %x\n", a & 0xff, *(UINT16 *)&ioreg[a & 0xff]);
printf("Netboard R16\tioreg[%x] = %x\n", a & 0xff, *(UINT16 *)&ioreg[a & 0xff]);
#endif
return result; return result;
default: default:
@ -441,9 +433,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
{ {
case 0x40: case 0x40:
ctrlrw[a & 0xff] = d; ctrlrw[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tctrlrw[%x] <- %x\tIRQ 5 ack\n", a & 0xff, d);
printf("Netboard W8\tctrlrw[%x] <- %x\tIRQ 5 ack\n", a & 0xff, d);
#endif
NetIRQAck(5); NetIRQAck(5);
//NetIRQAck(0); //NetIRQAck(0);
M68KSetIRQ(4); // dirtdvls needs ???????????????????????????????????????????????????????????????????????????????????????????????????? M68KSetIRQ(4); // dirtdvls needs ????????????????????????????????????????????????????????????????????????????????????????????????????
@ -453,9 +443,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0xa0: case 0xa0:
ctrlrw[a & 0xff] = d; ctrlrw[a & 0xff] = d;
ioreg[0] = ioreg[0] | 0x01; // Do I force this myself or is it automatic, need investigation, bad init way actually ? ioreg[0] = ioreg[0] | 0x01; // Do I force this myself or is it automatic, need investigation, bad init way actually ?
#ifdef NET_DEBUG DPRINTF("Netboard W8\tctrlrw[%x] <- %x\tIRQ 2 ack\n", a & 0xff, d);
printf("Netboard W8\tctrlrw[%x] <- %x\tIRQ 2 ack\n", a & 0xff, d);
#endif
NetIRQAck(2); NetIRQAck(2);
//NetIRQAck(0); //NetIRQAck(0);
//M68KRun(10000); //M68KRun(10000);
@ -463,9 +451,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x80: case 0x80:
ctrlrw[a & 0xff] = d; ctrlrw[a & 0xff] = d;
#ifdef NET_DEBUG //DPRINTF("Netboard W8\tctrlrw[%x] <- %x\tleds <- %x\n", a & 0xff, d,d);
//printf("Netboard W8\tctrlrw[%x] <- %x\tleds <- %x\n", a & 0xff, d,d);
#endif
break; break;
default: default:
@ -510,16 +496,12 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x03: // ioreg[c0003] case 0x03: // ioreg[c0003]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x05: // ioreg[c0005] case 0x05: // ioreg[c0005]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
/*case 0x15: // 0x00 0x01 0x80 // ioreg[c0015] /*case 0x15: // 0x00 0x01 0x80 // ioreg[c0015]
@ -596,9 +578,8 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x15: // 0x00 0x01 0x80 // ioreg[c0015] case 0x15: // 0x00 0x01 0x80 // ioreg[c0015]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
#endif
switch (d & 0xff) switch (d & 0xff)
{ {
case 0x80: case 0x80:
@ -611,15 +592,12 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
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());
#ifdef NET_DEBUG DPRINTF("receive enable off=%x size=%x\n", recv_offset, recv_size);
printf("receive enable off=%x size=%x\n", recv_offset, recv_size);
#endif
} }
else else
{ {
#ifdef NET_DEBUG DPRINTF("receive enable original value off=%x size=%x\n", recv_offset, recv_size);
printf("receive enable original value off=%x size=%x\n", recv_offset, recv_size);
#endif
slot = (recv_size >> 12) & 0x0f; slot = (recv_size >> 12) & 0x0f;
recv_size = recv_size & 0x0fff; recv_size = recv_size & 0x0fff;
recv_size = (recv_size << 4) | ((recv_size >> 8) & 0x000f); recv_size = (recv_size << 4) | ((recv_size >> 8) & 0x000f);
@ -629,9 +607,8 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
recv_size = recv_size * slot; recv_size = recv_size * slot;
} }
recv_offset = (recv_offset << 8) | (recv_offset >> 8); recv_offset = (recv_offset << 8) | (recv_offset >> 8);
#ifdef NET_DEBUG
printf("receive enable off=%x size=%x slot=%x\n", recv_offset, recv_size, slot); DPRINTF("receive enable off=%x size=%x slot=%x\n", recv_offset, recv_size, slot);
#endif
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());
@ -658,15 +635,11 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
break; break;
case 0x00: case 0x00:
#ifdef NET_DEBUG DPRINTF("??? receive disable\n");
printf("??? receive disable\n");
#endif
break; break;
case 0x01: case 0x01:
#ifdef NET_DEBUG DPRINTF("Irq 6 ack\n");
printf("Irq 6 ack\n");
#endif
NetIRQAck(6); NetIRQAck(6);
break; break;
@ -678,22 +651,17 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x17: // 0x00 0x8c // ioreg[c0017] case 0x17: // 0x00 0x8c // ioreg[c0017]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\t\t", a & 0xff, d);
#endif
switch (d & 0xff) switch (d & 0xff)
{ {
case 0x8c: case 0x8c:
#ifdef NET_DEBUG DPRINTF("data receive enable\n");
printf("data receive enable\n");
#endif
M68KSetIRQ(6); M68KSetIRQ(6);
M68KRun(6000); // 6000 enough M68KRun(6000); // 6000 enough
break; break;
case 0x00: case 0x00:
#ifdef NET_DEBUG DPRINTF("??? data receive disable\n");
printf("??? data receive disable\n");
#endif
break; break;
default: default:
printf("17 : other value %x\n",d & 0xff); printf("17 : other value %x\n",d & 0xff);
@ -705,9 +673,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x19: // ioreg[c0019] case 0x19: // ioreg[c0019]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\t\ttransmit result status\n");
printf("Netboard W8\tioreg[%x] <- %x\t\ttransmit result status\n");
#endif
break; break;
// 1b 1d = send part // 1b 1d = send part
@ -715,9 +681,8 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x1b: // 0x80 // ioreg[c001b] case 0x1b: // 0x80 // ioreg[c001b]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\t\t\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\t\t\n", a & 0xff, d);
#endif
switch (d & 0xff) switch (d & 0xff)
{ {
case 0x80: case 0x80:
@ -725,15 +690,13 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
if (send_size < 0x0011) // must find a better condition if (send_size < 0x0011) // must find a better condition
{ {
udpSend.SendAsync(addr_out.data(), port_out, send_size, (const char*)CommRAM + send_offset, 1000); udpSend.SendAsync(addr_out.data(), port_out, send_size, (const char*)CommRAM + send_offset, 1000);
#ifdef NET_DEBUG
printf("send enable off=%x size=%x\n", send_offset, send_size); DPRINTF("send enable off=%x size=%x\n", send_offset, send_size);
#endif
} }
else else
{ {
#ifdef NET_DEBUG DPRINTF("send enable original value off=%x size=%x\n", send_offset, send_size);
printf("send enable original value off=%x size=%x\n", send_offset, send_size);
#endif
slot = (send_size >> 12) & 0x0f; slot = (send_size >> 12) & 0x0f;
send_size = send_size & 0x0fff; send_size = send_size & 0x0fff;
send_size = (send_size << 4) | ((send_size >> 8) & 0x000f); send_size = (send_size << 4) | ((send_size >> 8) & 0x000f);
@ -748,10 +711,8 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
send_offset = (send_offset << 8) | (send_offset >> 8); send_offset = (send_offset << 8) | (send_offset >> 8);
udpSend.SendAsync(addr_out.data(), port_out, send_size, (const char*)CommRAM + send_offset, 1000); udpSend.SendAsync(addr_out.data(), port_out, send_size, (const char*)CommRAM + send_offset, 1000);
#ifdef NET_DEBUG
printf("send enable off=%x size=%x slot=%x\n", send_offset, send_size, slot);
#endif
DPRINTF("send enable off=%x size=%x slot=%x\n", send_offset, send_size, slot);
} }
#ifdef NET_DEBUG #ifdef NET_DEBUG
printf("transmitting : "); printf("transmitting : ");
@ -774,9 +735,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
break; break;
case 0x00: case 0x00:
#ifdef NET_DEBUG DPRINTF("??? transmit disable\n");
printf("??? transmit disable\n");
#endif
break; break;
default: default:
@ -787,9 +746,8 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x1d: // 0x8c // ioreg[c001d] case 0x1d: // 0x8c // ioreg[c001d]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
switch (d & 0xff) switch (d & 0xff)
{ {
case 0x8c: case 0x8c:
@ -809,16 +767,13 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x29: // ioreg[c0029] case 0x29: // ioreg[c0029]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x2f: // 0x00 or 0x00->0x40->0x00 or 0x82// ioreg[c002f] case 0x2f: // 0x00 or 0x00->0x40->0x00 or 0x82// ioreg[c002f]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
/*if ((d & 0xff) == 0x00) /*if ((d & 0xff) == 0x00)
{ {
M68KSetIRQ(2); M68KSetIRQ(2);
@ -827,15 +782,11 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
if ((d & 0xff) == 0x40) if ((d & 0xff) == 0x40)
{ {
#ifdef NET_DEBUG DPRINTF("********************************* trigger something ????\n");
printf("********************************* trigger something ????\n");
#endif
} }
if ((d & 0xff) == 0x82) if ((d & 0xff) == 0x82)
{ {
#ifdef NET_DEBUG DPRINTF("********************************* trigger something number 2 ????\n");
printf("********************************* trigger something number 2 ????\n");
#endif
} }
break; break;
@ -843,146 +794,104 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x41: // ioreg[c0041] case 0x41: // ioreg[c0041]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
recv_offset = (recv_offset >> 8) | (d << 8 ); recv_offset = (recv_offset >> 8) | (d << 8 );
#ifdef NET_DEBUG
//printf("recv off = %x\n",recv_offset); //printf("recv off = %x\n",recv_offset);
printf("recv off = %x\n", d); DPRINTF("recv off = %x\n", d);
//printf("\n");
#endif
break; break;
case 0x43: // ioreg[c0043] case 0x43: // ioreg[c0043]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
recv_size = (recv_size >> 8) | (d << 8); recv_size = (recv_size >> 8) | (d << 8);
#ifdef NET_DEBUG DPRINTF("recv size = %x\n", d);
//printf("recv size = %x\n", recv_size);
printf("recv size = %x\n", d);
//printf("\n");
#endif
break; break;
case 0x45: // ioreg[c0045] case 0x45: // ioreg[c0045]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
send_offset = (send_offset >> 8) | (d << 8); send_offset = (send_offset >> 8) | (d << 8);
#ifdef NET_DEBUG
//printf("send off = %x\n", send_offset); //printf("send off = %x\n", send_offset);
printf("send off = %x\n", d); DPRINTF("send off = %x\n", d);
//printf("\n");
#endif
break; break;
case 0x47: // ioreg[c0047] case 0x47: // ioreg[c0047]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
send_size = (send_size >> 8) | (d << 8); send_size = (send_size >> 8) | (d << 8);
#ifdef NET_DEBUG
//printf("send size = %x\n", send_size); //printf("send size = %x\n", send_size);
printf("send size = %x\n", d); DPRINTF("send size = %x\n", d);
//printf("\n");
#endif
break; break;
case 0x51: //0x04 0x18 // ioreg[c0051] case 0x51: //0x04 0x18 // ioreg[c0051]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x55: // ioreg[c0055] case 0x55: // ioreg[c0055]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x57: // 0x04->0x09 // ioreg[c0057] case 0x57: // 0x04->0x09 // ioreg[c0057]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x59: // ioreg[c0059] case 0x59: // ioreg[c0059]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x5b: // ioreg[c005b] case 0x5b: // ioreg[c005b]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x5d: // ioreg[c005d] case 0x5d: // ioreg[c005d]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x5f: // ioreg[c005f] case 0x5f: // ioreg[c005f]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x81: // ioreg[c0081] case 0x81: // ioreg[c0081]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; 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 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] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x85: // ioreg[c0085] case 0x85: // ioreg[c0085]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x87: // ioreg[c0087] case 0x87: // ioreg[c0087]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x88: // ioreg[c0088] case 0x88: // ioreg[c0088]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
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 frame
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x8a: // ioreg[c008a] case 0x8a: // ioreg[c008a]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
case 0x8b: // ioreg[c008b] case 0x8b: // ioreg[c008b]
ioreg[a & 0xff] = d; ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
printf("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d);
#endif
break; break;
default: default:
@ -1034,9 +943,8 @@ void CNetBoard::Write16(UINT32 a, UINT16 d)
case 0x00: case 0x00:
*(UINT16 *)&ctrlrw[a & 0xff] = d; *(UINT16 *)&ctrlrw[a & 0xff] = d;
commbank = d; commbank = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tctrlrw[%x] <- %x\t\tCommBank <- %x\n", a & 0xff, d,commbank & 1);
printf("Netboard W16\tctrlrw[%x] <- %x\t\tCommBank <- %x\n", a & 0xff, d,commbank & 1);
#endif
// sans swap ca avance, avec ca bloque pour scud // sans swap ca avance, avec ca bloque pour scud
//CommRAM = Buffer + ((commbank & 1) ? 0x10000 : 0); //swap //CommRAM = Buffer + ((commbank & 1) ? 0x10000 : 0); //swap
//CommRAM = ((commbank & 1) ? bank : Buffer); // with bank swap harley doesn't pass to print id, no incidence in dirtdevils //CommRAM = ((commbank & 1) ? bank : Buffer); // with bank swap harley doesn't pass to print id, no incidence in dirtdevils
@ -1054,9 +962,8 @@ void CNetBoard::Write16(UINT32 a, UINT16 d)
break; break;
case 0x40: case 0x40:
*(UINT16 *)&ctrlrw[a & 0xff] = d; *(UINT16 *)&ctrlrw[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tctrlrw[%x] <- %x\t\tIRQ 5 ack\n", a & 0xff, d);
printf("Netboard W16\tctrlrw[%x] <- %x\t\tIRQ 5 ack\n", a & 0xff, d);
#endif
NetIRQAck(5); NetIRQAck(5);
M68KSetIRQ(4); // ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????? M68KSetIRQ(4); // ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????
//M68KRun(10000); //M68KRun(10000);
@ -1064,29 +971,22 @@ void CNetBoard::Write16(UINT32 a, UINT16 d)
case 0xa0: case 0xa0:
*(UINT16 *)&ctrlrw[a & 0xff] = d; *(UINT16 *)&ctrlrw[a & 0xff] = d;
*(UINT8 *)&ioreg[0] = *(UINT8 *)&ioreg[0] | 0x01; // Do I force this myself or is it automatic, need investigation, bad init way actually ? *(UINT8 *)&ioreg[0] = *(UINT8 *)&ioreg[0] | 0x01; // Do I force this myself or is it automatic, need investigation, bad init way actually ?
#ifdef NET_DEBUG DPRINTF("Netboard W16\tctrlrw[%x] <-%x\t\tIRQ 2 ack\n", a & 0xff, d);
printf("Netboard W16\tctrlrw[%x] <-%x\t\tIRQ 2 ack\n", a & 0xff, d);
#endif
NetIRQAck(2); NetIRQAck(2);
//NetIRQAck(0); //NetIRQAck(0);
break; break;
case 0x80: case 0x80:
*(UINT16 *)&ctrlrw[a & 0xff] = d; *(UINT16 *)&ctrlrw[a & 0xff] = d;
#ifdef NET_DEBUG //DPRINTF("Netboard W16\tctrlrw[%x] <-%x\tleds <- %x\n",a & 0xff, d,d);
//printf("Netboard W16\tctrlrw[%x] <-%x\tleds <- %x\n",a & 0xff, d,d);
#endif
break; break;
case 0xc0: case 0xc0:
*(UINT16 *)&ctrlrw[a & 0xff] = d; *(UINT16 *)&ctrlrw[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tctrlrw[%x] <-%x\tNode ID <- %x\n", a & 0xff, d, d);
printf("Netboard W16\tctrlrw[%x] <-%x\tNode ID <- %x\n", a & 0xff, d, d);
#endif
break; break;
case 0xe0: case 0xe0:
*(UINT16 *)&ctrlrw[a & 0xff] = d; *(UINT16 *)&ctrlrw[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tctrlrw[%x] <-%x\t\treceive complete <- %x\n", a & 0xff, d, d);
printf("Netboard W16\tctrlrw[%x] <-%x\t\treceive complete <- %x\n", a & 0xff, d, d);
#endif
break; break;
default: default:
*(UINT16 *)&ctrlrw[a & 0xff] = d; *(UINT16 *)&ctrlrw[a & 0xff] = d;
@ -1125,40 +1025,31 @@ void CNetBoard::Write16(UINT32 a, UINT16 d)
if (d == 0) if (d == 0)
{ {
*(UINT16 *)&ioreg[a & 0xff] = d; *(UINT16 *)&ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tioreg[%x] <- %x\t\t", a & 0xff, d);
printf("Netboard W16\tioreg[%x] <- %x\t\t", a & 0xff, d);
#endif
} }
if (d == 1) if (d == 1)
{ {
*(UINT16 *)&ioreg[a & 0xff] = d; *(UINT16 *)&ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tioreg[%x] <- %x\t\t", a & 0xff, d);
printf("Netboard W16\tioreg[%x] <- %x\t\t", a & 0xff, d);
#endif
} }
if (d == 2) if (d == 2)
{ {
*(UINT16 *)&ioreg[a & 0xff] = d; *(UINT16 *)&ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tioreg[%x] <- %x\t\t", a & 0xff, d);
printf("Netboard W16\tioreg[%x] <- %x\t\t", a & 0xff, d);
#endif
} }
if (d > 2) if (d > 2)
{ {
#ifdef NET_DEBUG DPRINTF("d=%x\n", d);
printf("d=%x\n", d);
#endif
*(UINT16 *)&ioreg[a & 0xff] = d; *(UINT16 *)&ioreg[a & 0xff] = d;
//MessageBox(NULL, "d > 1", NULL, MB_OK); //MessageBox(NULL, "d > 1", NULL, MB_OK);
//MessageBeep(MB_ICONWARNING); //MessageBeep(MB_ICONWARNING);
} }
#ifdef NET_DEBUG DPRINTF("d = %x \n",d);
printf("d = %x \n",d);
#endif
M68KSetIRQ(4); // network error if removed M68KSetIRQ(4); // network error if removed
M68KRun(1000); // 1000 is enought M68KRun(1000); // 1000 is enought
M68KSetIRQ(2); // oui sinon pas de trame, pas de cycle sinon crash M68KSetIRQ(2); // oui sinon pas de trame, pas de cycle sinon crash
@ -1166,10 +1057,8 @@ void CNetBoard::Write16(UINT32 a, UINT16 d)
case 0x8a: // ioreg[c008a] case 0x8a: // ioreg[c008a]
*(UINT16 *)&ioreg[a & 0xff] = d; *(UINT16 *)&ioreg[a & 0xff] = d;
#ifdef NET_DEBUG DPRINTF("Netboard W16\tioreg[%x] <- %x\t", a & 0xff, d);
printf("Netboard W16\tioreg[%x] <- %x\t", a & 0xff, d); DPRINTF("d = %x\n",d);
printf("d = %x\n",d);
#endif
break; break;
default: default:

View file

@ -6,13 +6,10 @@
#include "OSD/Thread.h" #include "OSD/Thread.h"
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
#include <thread> #include <thread>
#include "UDPSend.h" #include "UDPSend.h"
#include "UDPReceive.h" #include "UDPReceive.h"
//using namespace SMUDP;
//#define NET_BUF_SIZE 32800 // 16384 not enough //#define NET_BUF_SIZE 32800 // 16384 not enough
class CNetBoard : public IBus class CNetBoard : public IBus
@ -27,13 +24,10 @@ public:
void Write16(UINT32 addr, UINT16 data); void Write16(UINT32 addr, UINT16 data);
void Write32(UINT32 addr, UINT32 data); void Write32(UINT32 addr, UINT32 data);
void SaveState(CBlockFile *SaveState); void SaveState(CBlockFile *SaveState);
void LoadState(CBlockFile *SaveState); void LoadState(CBlockFile *SaveState);
bool RunFrame(void); bool RunFrame(void);
void Reset(void); void Reset(void);
// Returns a reference to the 68K CPU context // Returns a reference to the 68K CPU context
@ -43,7 +37,6 @@ public:
bool Init(UINT8 *netRAMPtr, UINT8 *netBufferPtr); bool Init(UINT8 *netRAMPtr, UINT8 *netBufferPtr);
CNetBoard(const Util::Config::Node &config); CNetBoard(const Util::Config::Node &config);
~CNetBoard(void); ~CNetBoard(void);
@ -84,12 +77,10 @@ private:
// only for some tests // only for some tests
UINT8 *bank; UINT8 *bank;
UINT8 *bank2; UINT8 *bank2;
UINT8 test_irq; UINT8 test_irq;
std::thread interrupt5; std::thread interrupt5;
bool int5; bool int5;
}; };
void Net_SetCB(int(*Run68k)(int cycles), void(*Int68k)(int irq)); void Net_SetCB(int(*Run68k)(int cycles), void(*Int68k)(int irq));