mirror of
https://github.com/holub/mame
synced 2025-05-22 21:58:57 +03:00
S32COMM: Multi32 uses EPR-15033
Multi32 uses EPR-15033 on both Stadium Cross and OutRunners.
This commit is contained in:
parent
715dac74a4
commit
769627c26b
@ -5286,6 +5286,8 @@ void segas32_state::init_orunners(void)
|
||||
segas32_common_init(read16_delegate(FUNC(segas32_state::analog_custom_io_r),this), write16_delegate(FUNC(segas32_state::orunners_custom_io_w),this));
|
||||
m_sw1_output = &segas32_state::orunners_sw1_output;
|
||||
m_sw2_output = &segas32_state::orunners_sw2_output;
|
||||
|
||||
m_s32comm->set_linktype(15033); // EPR-15033
|
||||
}
|
||||
|
||||
|
||||
@ -5314,6 +5316,8 @@ void segas32_state::init_scross(void)
|
||||
|
||||
m_sw1_output = &segas32_state::scross_sw1_output;
|
||||
m_sw2_output = &segas32_state::scross_sw2_output;
|
||||
|
||||
m_s32comm->set_linktype(15033); // EPR-15033
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,14 +177,14 @@ void s32comm_device::set_linktype(UINT16 linktype)
|
||||
// Rad Rally
|
||||
printf("S32COMM: set mode 'EPR-14084 - Rad Rally'\n");
|
||||
break;
|
||||
case 15033:
|
||||
// Stadium Cross / OutRunners
|
||||
printf("S32COMM: set mode 'EPR-15033 - Stadium Cross / OutRunners'\n");
|
||||
break;
|
||||
case 15612:
|
||||
// F1 Super Lap
|
||||
printf("S32COMM: set mode 'EPR-15612 - F1 Super Lap'\n");
|
||||
break;
|
||||
case 3:
|
||||
// OutRunners
|
||||
printf("S32COMM: set mode 'EPR-????? - OutRunners'\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,14 +196,14 @@ void s32comm_device::comm_tick()
|
||||
// Rad Rally
|
||||
comm_tick_14084();
|
||||
break;
|
||||
case 15033:
|
||||
// Stadium Cross / OutRunners
|
||||
comm_tick_15033();
|
||||
break;
|
||||
case 15612:
|
||||
// F1 Super Lap
|
||||
comm_tick_15612();
|
||||
break;
|
||||
case 3:
|
||||
// OutRunners
|
||||
comm_tick3();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,248 +449,7 @@ void s32comm_device::comm_tick_14084()
|
||||
}
|
||||
}
|
||||
|
||||
void s32comm_device::comm_tick_15612()
|
||||
{
|
||||
if (m_linkenable == 0x01)
|
||||
{
|
||||
int frameStart = 0x0010;
|
||||
int frameOffset = 0x0000;
|
||||
int frameSize = 0x00E0;
|
||||
int dataSize = frameSize + 1;
|
||||
int togo = 0;
|
||||
int recv = 0;
|
||||
int idx = 0;
|
||||
|
||||
bool isMaster = (m_shared[1] == 0x01);
|
||||
bool isSlave = (m_shared[1] == 0x02);
|
||||
bool isRelay = (m_shared[1] == 0x00);
|
||||
|
||||
// if link not yet established...
|
||||
if (m_linkalive == 0x00)
|
||||
{
|
||||
// waiting...
|
||||
m_shared[0] = 0x05;
|
||||
|
||||
// check rx socket
|
||||
if (!m_line_rx.is_open())
|
||||
{
|
||||
printf("S32COMM: listen on %s\n", m_localhost);
|
||||
m_line_rx.open(m_localhost);
|
||||
}
|
||||
|
||||
// check tx socket
|
||||
if (!m_line_tx.is_open())
|
||||
{
|
||||
printf("S32COMM: connect to %s\n", m_remotehost);
|
||||
m_line_tx.open(m_remotehost);
|
||||
}
|
||||
|
||||
// if both sockets are there check ring
|
||||
if ((m_line_rx.is_open()) && (m_line_tx.is_open()))
|
||||
{
|
||||
// try to read one messages
|
||||
recv = m_line_rx.read(m_buffer, dataSize);
|
||||
while (recv != 0)
|
||||
{
|
||||
// check if complete message
|
||||
if (recv == dataSize)
|
||||
{
|
||||
// check if message id
|
||||
idx = m_buffer[0];
|
||||
|
||||
// 0xFF - link id
|
||||
if (idx == 0xFF)
|
||||
{
|
||||
if (isMaster)
|
||||
{
|
||||
// master gets first id and starts next state
|
||||
m_linkid = 0x01;
|
||||
m_linkcount = m_buffer[1];
|
||||
m_linktimer = 0x01;
|
||||
}
|
||||
else if (isSlave || isRelay)
|
||||
{
|
||||
// slave gets own id
|
||||
if (isSlave)
|
||||
{
|
||||
m_buffer[1]++;
|
||||
m_linkid = m_buffer[1];
|
||||
}
|
||||
|
||||
// slave and relay forward message
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
}
|
||||
|
||||
// 0xFE - link size
|
||||
else if (idx == 0xFE)
|
||||
{
|
||||
if (isSlave || isRelay)
|
||||
{
|
||||
m_linkcount = m_buffer[1];
|
||||
|
||||
// slave and relay forward message
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
|
||||
// consider it done
|
||||
printf("S32COMM: link established - id %02x of %02x\n", m_linkid, m_linkcount);
|
||||
m_linkalive = 0x01;
|
||||
|
||||
// write to shared mem
|
||||
m_shared[0] = 0x01;
|
||||
m_shared[2] = m_linkid;
|
||||
m_shared[3] = m_linkcount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// got only part of a message - read the rest (and drop it)
|
||||
// TODO: combine parts and push to "ring buffer"
|
||||
togo = dataSize - recv;
|
||||
while (togo > 0){
|
||||
recv = m_line_rx.read(m_buffer, togo);
|
||||
togo -= recv;
|
||||
}
|
||||
printf("S32COMM: droped a message...\n");
|
||||
}
|
||||
|
||||
if (m_linkalive == 0x00)
|
||||
recv = m_line_rx.read(m_buffer, dataSize);
|
||||
else
|
||||
recv = 0;
|
||||
}
|
||||
|
||||
// if we are master and link is not yet established
|
||||
if (isMaster && (m_linkalive == 0x00))
|
||||
{
|
||||
// send first packet
|
||||
if (m_linktimer == 0x00)
|
||||
{
|
||||
m_buffer[0] = 0xFF;
|
||||
m_buffer[1] = 0x01;
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
|
||||
// send second packet
|
||||
else if (m_linktimer == 0x01)
|
||||
{
|
||||
m_buffer[0] = 0xFE;
|
||||
m_buffer[1] = m_linkcount;
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
|
||||
// consider it done
|
||||
printf("S32COMM: link established - id %02x of %02x\n", m_linkid, m_linkcount);
|
||||
m_linkalive = 0x01;
|
||||
|
||||
// write to shared mem
|
||||
m_shared[0] = 0x01;
|
||||
m_shared[2] = m_linkid;
|
||||
m_shared[3] = m_linkcount;
|
||||
}
|
||||
|
||||
else if (m_linktimer > 0x02)
|
||||
{
|
||||
// decrease delay timer
|
||||
m_linktimer--;
|
||||
if (m_linktimer == 0x02)
|
||||
m_linktimer = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update "ring buffer" if link established
|
||||
if (m_linkalive == 0x01)
|
||||
{
|
||||
int togo = 0;
|
||||
// try to read one messages
|
||||
int recv = m_line_rx.read(m_buffer, dataSize);
|
||||
while (recv != 0)
|
||||
{
|
||||
// check if complete message
|
||||
if (recv == dataSize)
|
||||
{
|
||||
// check if valid id
|
||||
int idx = m_buffer[0];
|
||||
if (idx > 0 && idx <= m_linkcount) {
|
||||
// if not our own message
|
||||
if (idx != m_linkid)
|
||||
{
|
||||
// save message to "ring buffer"
|
||||
frameOffset = frameStart + (idx * frameSize);
|
||||
for (int j = 0x00 ; j < frameSize ; j++)
|
||||
{
|
||||
m_shared[frameOffset + j] = m_buffer[1 + j];
|
||||
}
|
||||
|
||||
// forward message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
} else {
|
||||
if (!isMaster && idx == 0xF0){
|
||||
// 0xF0 - master addional bytes
|
||||
for (int j = 0x05 ; j < 0x10 ; j++)
|
||||
{
|
||||
m_shared[j] = m_buffer[1 + j];
|
||||
}
|
||||
|
||||
// forward message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// got only part of a message - read the rest (and drop it)
|
||||
// TODO: combine parts and push to "ring buffer"
|
||||
togo = dataSize - recv;
|
||||
while (togo > 0){
|
||||
recv = m_line_rx.read(m_buffer, togo);
|
||||
togo -= recv;
|
||||
}
|
||||
printf("S32COMM: droped a message...\n");
|
||||
}
|
||||
recv = m_line_rx.read(m_buffer, dataSize);
|
||||
}
|
||||
|
||||
// update "ring buffer" if link established
|
||||
// live relay does not send data
|
||||
if (m_linkid != 0x00 && m_shared[4] != 0x00)
|
||||
{
|
||||
m_buffer[0] = m_linkid;
|
||||
frameOffset = frameStart + (m_linkid * frameSize);
|
||||
for (int j = 0x00 ; j < frameSize ; j++)
|
||||
{
|
||||
// push message to "ring buffer"
|
||||
m_shared[frameOffset + j] = m_shared[frameStart + j];
|
||||
m_buffer[1 + j] = m_shared[frameStart + j];
|
||||
}
|
||||
// push message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
|
||||
// master sends some additional status bytes
|
||||
if (isMaster){
|
||||
m_buffer[0] = 0xF0;
|
||||
for (int j = 0x00 ; j < frameSize ; j++)
|
||||
{
|
||||
m_buffer[1 + j] = 0x00;
|
||||
}
|
||||
for (int j = 0x05 ; j < 0x10 ; j++)
|
||||
{
|
||||
m_buffer[1 + j] = m_shared[j];
|
||||
}
|
||||
// push message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
}
|
||||
// clear 04
|
||||
m_shared[4] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void s32comm_device::comm_tick3()
|
||||
void s32comm_device::comm_tick_15033()
|
||||
{
|
||||
if (m_linkenable == 0x01)
|
||||
{
|
||||
@ -941,4 +700,245 @@ void s32comm_device::comm_tick3()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void s32comm_device::comm_tick_15612()
|
||||
{
|
||||
if (m_linkenable == 0x01)
|
||||
{
|
||||
int frameStart = 0x0010;
|
||||
int frameOffset = 0x0000;
|
||||
int frameSize = 0x00E0;
|
||||
int dataSize = frameSize + 1;
|
||||
int togo = 0;
|
||||
int recv = 0;
|
||||
int idx = 0;
|
||||
|
||||
bool isMaster = (m_shared[1] == 0x01);
|
||||
bool isSlave = (m_shared[1] == 0x02);
|
||||
bool isRelay = (m_shared[1] == 0x00);
|
||||
|
||||
// if link not yet established...
|
||||
if (m_linkalive == 0x00)
|
||||
{
|
||||
// waiting...
|
||||
m_shared[0] = 0x05;
|
||||
|
||||
// check rx socket
|
||||
if (!m_line_rx.is_open())
|
||||
{
|
||||
printf("S32COMM: listen on %s\n", m_localhost);
|
||||
m_line_rx.open(m_localhost);
|
||||
}
|
||||
|
||||
// check tx socket
|
||||
if (!m_line_tx.is_open())
|
||||
{
|
||||
printf("S32COMM: connect to %s\n", m_remotehost);
|
||||
m_line_tx.open(m_remotehost);
|
||||
}
|
||||
|
||||
// if both sockets are there check ring
|
||||
if ((m_line_rx.is_open()) && (m_line_tx.is_open()))
|
||||
{
|
||||
// try to read one messages
|
||||
recv = m_line_rx.read(m_buffer, dataSize);
|
||||
while (recv != 0)
|
||||
{
|
||||
// check if complete message
|
||||
if (recv == dataSize)
|
||||
{
|
||||
// check if message id
|
||||
idx = m_buffer[0];
|
||||
|
||||
// 0xFF - link id
|
||||
if (idx == 0xFF)
|
||||
{
|
||||
if (isMaster)
|
||||
{
|
||||
// master gets first id and starts next state
|
||||
m_linkid = 0x01;
|
||||
m_linkcount = m_buffer[1];
|
||||
m_linktimer = 0x01;
|
||||
}
|
||||
else if (isSlave || isRelay)
|
||||
{
|
||||
// slave gets own id
|
||||
if (isSlave)
|
||||
{
|
||||
m_buffer[1]++;
|
||||
m_linkid = m_buffer[1];
|
||||
}
|
||||
|
||||
// slave and relay forward message
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
}
|
||||
|
||||
// 0xFE - link size
|
||||
else if (idx == 0xFE)
|
||||
{
|
||||
if (isSlave || isRelay)
|
||||
{
|
||||
m_linkcount = m_buffer[1];
|
||||
|
||||
// slave and relay forward message
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
|
||||
// consider it done
|
||||
printf("S32COMM: link established - id %02x of %02x\n", m_linkid, m_linkcount);
|
||||
m_linkalive = 0x01;
|
||||
|
||||
// write to shared mem
|
||||
m_shared[0] = 0x01;
|
||||
m_shared[2] = m_linkid;
|
||||
m_shared[3] = m_linkcount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// got only part of a message - read the rest (and drop it)
|
||||
// TODO: combine parts and push to "ring buffer"
|
||||
togo = dataSize - recv;
|
||||
while (togo > 0){
|
||||
recv = m_line_rx.read(m_buffer, togo);
|
||||
togo -= recv;
|
||||
}
|
||||
printf("S32COMM: droped a message...\n");
|
||||
}
|
||||
|
||||
if (m_linkalive == 0x00)
|
||||
recv = m_line_rx.read(m_buffer, dataSize);
|
||||
else
|
||||
recv = 0;
|
||||
}
|
||||
|
||||
// if we are master and link is not yet established
|
||||
if (isMaster && (m_linkalive == 0x00))
|
||||
{
|
||||
// send first packet
|
||||
if (m_linktimer == 0x00)
|
||||
{
|
||||
m_buffer[0] = 0xFF;
|
||||
m_buffer[1] = 0x01;
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
|
||||
// send second packet
|
||||
else if (m_linktimer == 0x01)
|
||||
{
|
||||
m_buffer[0] = 0xFE;
|
||||
m_buffer[1] = m_linkcount;
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
|
||||
// consider it done
|
||||
printf("S32COMM: link established - id %02x of %02x\n", m_linkid, m_linkcount);
|
||||
m_linkalive = 0x01;
|
||||
|
||||
// write to shared mem
|
||||
m_shared[0] = 0x01;
|
||||
m_shared[2] = m_linkid;
|
||||
m_shared[3] = m_linkcount;
|
||||
}
|
||||
|
||||
else if (m_linktimer > 0x02)
|
||||
{
|
||||
// decrease delay timer
|
||||
m_linktimer--;
|
||||
if (m_linktimer == 0x02)
|
||||
m_linktimer = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update "ring buffer" if link established
|
||||
if (m_linkalive == 0x01)
|
||||
{
|
||||
int togo = 0;
|
||||
// try to read one messages
|
||||
int recv = m_line_rx.read(m_buffer, dataSize);
|
||||
while (recv != 0)
|
||||
{
|
||||
// check if complete message
|
||||
if (recv == dataSize)
|
||||
{
|
||||
// check if valid id
|
||||
int idx = m_buffer[0];
|
||||
if (idx > 0 && idx <= m_linkcount) {
|
||||
// if not our own message
|
||||
if (idx != m_linkid)
|
||||
{
|
||||
// save message to "ring buffer"
|
||||
frameOffset = frameStart + (idx * frameSize);
|
||||
for (int j = 0x00 ; j < frameSize ; j++)
|
||||
{
|
||||
m_shared[frameOffset + j] = m_buffer[1 + j];
|
||||
}
|
||||
|
||||
// forward message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
} else {
|
||||
if (!isMaster && idx == 0xF0){
|
||||
// 0xF0 - master addional bytes
|
||||
for (int j = 0x05 ; j < 0x10 ; j++)
|
||||
{
|
||||
m_shared[j] = m_buffer[1 + j];
|
||||
}
|
||||
|
||||
// forward message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// got only part of a message - read the rest (and drop it)
|
||||
// TODO: combine parts and push to "ring buffer"
|
||||
togo = dataSize - recv;
|
||||
while (togo > 0){
|
||||
recv = m_line_rx.read(m_buffer, togo);
|
||||
togo -= recv;
|
||||
}
|
||||
printf("S32COMM: droped a message...\n");
|
||||
}
|
||||
recv = m_line_rx.read(m_buffer, dataSize);
|
||||
}
|
||||
|
||||
// update "ring buffer" if link established
|
||||
// live relay does not send data
|
||||
if (m_linkid != 0x00 && m_shared[4] != 0x00)
|
||||
{
|
||||
m_buffer[0] = m_linkid;
|
||||
frameOffset = frameStart + (m_linkid * frameSize);
|
||||
for (int j = 0x00 ; j < frameSize ; j++)
|
||||
{
|
||||
// push message to "ring buffer"
|
||||
m_shared[frameOffset + j] = m_shared[frameStart + j];
|
||||
m_buffer[1 + j] = m_shared[frameStart + j];
|
||||
}
|
||||
// push message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
|
||||
// master sends some additional status bytes
|
||||
if (isMaster){
|
||||
m_buffer[0] = 0xF0;
|
||||
for (int j = 0x00 ; j < frameSize ; j++)
|
||||
{
|
||||
m_buffer[1 + j] = 0x00;
|
||||
}
|
||||
for (int j = 0x05 ; j < 0x10 ; j++)
|
||||
{
|
||||
m_buffer[1 + j] = m_shared[j];
|
||||
}
|
||||
// push message to other nodes
|
||||
m_line_tx.write(m_buffer, dataSize);
|
||||
}
|
||||
}
|
||||
// clear 04
|
||||
m_shared[4] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -80,8 +80,8 @@ private:
|
||||
void comm_tick();
|
||||
|
||||
void comm_tick_14084();
|
||||
void comm_tick_15033();
|
||||
void comm_tick_15612();
|
||||
void comm_tick3();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user