summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/model2.cpp16
-rw-r--r--src/mame/includes/model2.h3
-rw-r--r--src/mame/machine/m2comm.cpp130
-rw-r--r--src/mame/machine/m2comm.h3
4 files changed, 60 insertions, 92 deletions
diff --git a/src/mame/drivers/model2.cpp b/src/mame/drivers/model2.cpp
index b09e9b7c57b..efe7c7e1c98 100644
--- a/src/mame/drivers/model2.cpp
+++ b/src/mame/drivers/model2.cpp
@@ -1516,7 +1516,9 @@ static ADDRESS_MAP_START( model2_base_mem, AS_PROGRAM, 32, model2_state )
AM_RANGE(0x01800000, 0x01803fff) AM_READWRITE16(model2_palette_r,model2_palette_w,0xffffffff)
AM_RANGE(0x01810000, 0x0181bfff) AM_RAM AM_SHARE("colorxlat")
AM_RANGE(0x0181c000, 0x0181c003) AM_WRITE(model2_3d_zclip_w)
- AM_RANGE(0x01a10000, 0x01a1ffff) AM_READWRITE(network_r, network_w)
+ AM_RANGE(0x01a10000, 0x01a13fff) AM_DEVREADWRITE8("m2comm", m2comm_device, share_r, share_w, 0xffffffff)
+ AM_RANGE(0x01a14000, 0x01a14003) AM_DEVREADWRITE8("m2comm", m2comm_device, cn_r, cn_w, 0x000000ff)
+ AM_RANGE(0x01a14000, 0x01a14003) AM_DEVREADWRITE8("m2comm", m2comm_device, fg_r, fg_w, 0x00ff0000)
AM_RANGE(0x01d00000, 0x01d03fff) AM_RAM AM_SHARE("backup1") // Backup sram
AM_RANGE(0x02000000, 0x03ffffff) AM_ROM AM_REGION("user1", 0)
@@ -2238,6 +2240,8 @@ TIMER_DEVICE_CALLBACK_MEMBER(model2_state::model2_interrupt)
if(m_intena & 1<<0)
m_maincpu->set_input_line(I960_IRQ0, ASSERT_LINE);
model2_check_irq_state();
+ if (m_m2comm != nullptr)
+ m_m2comm->check_vint_irq();
}
else if(scanline == 0)
{
@@ -2259,6 +2263,8 @@ TIMER_DEVICE_CALLBACK_MEMBER(model2_state::model2c_interrupt)
if(m_intena & 1<<0)
m_maincpu->set_input_line(I960_IRQ0, ASSERT_LINE);
model2_check_irq_state();
+ if (m_m2comm != nullptr)
+ m_m2comm->check_vint_irq();
}
else if(scanline == 0) // 384
{
@@ -2427,6 +2433,8 @@ static MACHINE_CONFIG_START( model2o, model2_state )
MCFG_VIDEO_START_OVERRIDE(model2_state,model2)
MCFG_SEGAM1AUDIO_ADD("m1audio")
+
+ MCFG_M2COMM_ADD("m2comm")
MACHINE_CONFIG_END
/* 2A-CRX */
@@ -2478,6 +2486,8 @@ static MACHINE_CONFIG_START( model2a, model2_state )
MCFG_SCSP_IRQ_CB(WRITE8(model2_state,scsp_irq))
MCFG_SOUND_ROUTE(0, "lspeaker", 2.0)
MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
+
+ MCFG_M2COMM_ADD("m2comm")
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( manxttdx, model2a ) /* Includes a Model 1 Sound board for additional sounds - Deluxe version only */
@@ -2593,6 +2603,8 @@ static MACHINE_CONFIG_START( model2b, model2_state )
MCFG_SCSP_IRQ_CB(WRITE8(model2_state,scsp_irq))
MCFG_SOUND_ROUTE(0, "lspeaker", 2.0)
MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
+
+ MCFG_M2COMM_ADD("m2comm")
MACHINE_CONFIG_END
@@ -2656,6 +2668,8 @@ static MACHINE_CONFIG_START( model2c, model2_state )
MCFG_SCSP_IRQ_CB(WRITE8(model2_state, scsp_irq))
MCFG_SOUND_ROUTE(0, "lspeaker", 2.0)
MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
+
+ MCFG_M2COMM_ADD("m2comm")
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( stcc, model2c )
diff --git a/src/mame/includes/model2.h b/src/mame/includes/model2.h
index eee82ff360a..0a747d0cc3d 100644
--- a/src/mame/includes/model2.h
+++ b/src/mame/includes/model2.h
@@ -8,6 +8,7 @@
#include "sound/scsp.h"
#include "machine/315-5881_crypt.h"
#include "machine/315-5838_317-0229_comp.h"
+#include "machine/m2comm.h"
class model2_renderer;
struct raster_state;
@@ -30,6 +31,7 @@ public:
m_maincpu(*this,"maincpu"),
m_dsbz80(*this, DSBZ80_TAG),
m_m1audio(*this, "m1audio"),
+ m_m2comm(*this, "m2comm"),
m_audiocpu(*this, "audiocpu"),
m_tgp(*this, "tgp"),
m_dsp(*this, "dsp"),
@@ -58,6 +60,7 @@ public:
required_device<i960_cpu_device> m_maincpu;
optional_device<dsbz80_device> m_dsbz80; // Z80-based MPEG Digital Sound Board
optional_device<segam1audio_device> m_m1audio; // Model 1 standard sound board
+ optional_device<m2comm_device> m_m2comm; // Model 2 communication board
optional_device<cpu_device> m_audiocpu;
optional_device<cpu_device> m_tgp;
optional_device<cpu_device> m_dsp;
diff --git a/src/mame/machine/m2comm.cpp b/src/mame/machine/m2comm.cpp
index 4c45669076c..f5c7036f2f4 100644
--- a/src/mame/machine/m2comm.cpp
+++ b/src/mame/machine/m2comm.cpp
@@ -79,6 +79,7 @@ Sega PC BD MODEL2 A-CRX COMMUNICATION 837-11525
EEPROM:
16726.7 Sega Rally Championship
+ 18643.7 ManxTT
18643A.7 ManxTT
@@ -163,6 +164,8 @@ Sega PC BD MODEL2 C-CRX COMMUNICATION 837-12839
18643A.7 Sega Touring Car Championship
*/
+#include "emu.h"
+#include "emuopts.h"
#include "machine/m2comm.h"
//#define __M2COMM_VERBOSE__
@@ -228,7 +231,6 @@ void m2comm_device::device_start()
void m2comm_device::device_reset()
{
- set_linktype(16726);
m_zfg = 0;
m_cn = 0;
m_fg = 0;
@@ -295,8 +297,9 @@ WRITE8_MEMBER(m2comm_device::cn_w)
m_linkid = 0x00;
m_linkalive = 0x00;
m_linkcount = 0x00;
- m_linktimer = 0x04; //0x00E8; // 58 fps * 4s
+ m_linktimer = 0x00E8; // 58 fps * 4s
+ comm_init();
comm_tick();
}
#endif
@@ -321,46 +324,38 @@ void m2comm_device::check_vint_irq()
}
#ifdef __M2COMM_SIMULATION__
-void m2comm_device::set_linktype(UINT16 linktype)
+void m2comm_device::comm_init()
{
- m_linktype = linktype;
-
- switch (m_linktype)
- {
- case 16726:
- // Daytona USA / Sega Rally Championship
- printf("M2COMM: set mode 'EPR-16726 - Daytona USA'\n");
- break;
- }
+ // TODO - check EPR-16726 on Daytona USA and Sega Rally Championship
+ // EPR-18643(A) - these are accessed by VirtuaON and Sega Touring Car Championship
+
+ // frameSize - 0xe00
+ m_shared[0x12] = 0x00;
+ m_shared[0x13] = 0x0e;
+
+ // frameOffset - 0x1c0
+ m_shared[0x14] = 0xc0;
+ m_shared[0x15] = 0x01;
}
void m2comm_device::comm_tick()
{
- switch (m_linktype)
- {
- case 16726:
- // Daytona USA / Sega Rally Championship
- comm_tick_16726();
- break;
- }
-}
-
-void m2comm_device::comm_tick_16726()
-{
if (m_linkenable == 0x01)
{
m_zfg ^= 1;
-
- int frameStart = 0x2000;
- int frameOffset = 0x0000;
- int frameSize = 0x01c0;
+
+ int frameSize = m_shared[0x13] << 8 | m_shared[0x12];
+ int frameOffset = m_shared[0x15] << 8 | m_shared[0x14];
+
int dataSize = frameSize + 1;
int togo = 0;
int recv = 0;
int idx = 0;
- bool isMaster = (m_fg == 0x01);
- bool isSlave = (m_fg == 0x00);
+ // EPR-16726 uses m_fg for Master/Slave
+ // EPR-18643(A) seems to check m_shared[1], with a fallback to m_fg
+ bool isMaster = (m_fg == 0x01 || m_shared[1] == 0x01);
+ bool isSlave = !isMaster && (m_fg == 0x00);
// if link not yet established...
if (m_linkalive == 0x00)
@@ -409,8 +404,8 @@ void m2comm_device::comm_tick_16726()
}
else if (isSlave)
{
+ // increase linkcount
m_buffer[1]++;
- m_linkid = m_buffer[1];
// forward message
m_line_tx.write(m_buffer, dataSize);
@@ -422,7 +417,10 @@ void m2comm_device::comm_tick_16726()
{
if (isSlave)
{
+ // fetch linkcount and linkid, then decrease linkid
m_linkcount = m_buffer[1];
+ m_linkid = m_buffer[2];
+ m_buffer[2]--;
// forward message
m_line_tx.write(m_buffer, dataSize);
@@ -431,6 +429,7 @@ void m2comm_device::comm_tick_16726()
// consider it done
printf("M2COMM: link established - id %02x of %02x\n", m_linkid, m_linkcount);
m_linkalive = 0x01;
+ m_linktimer = 0x01;
// write to shared mem
m_shared[0] = 0x01;
@@ -464,6 +463,7 @@ void m2comm_device::comm_tick_16726()
{
m_buffer[0] = 0xff;
m_buffer[1] = 0x01;
+ m_buffer[2] = 0x00;
m_line_tx.write(m_buffer, dataSize);
}
@@ -472,11 +472,13 @@ void m2comm_device::comm_tick_16726()
{
m_buffer[0] = 0xfe;
m_buffer[1] = m_linkcount;
+ m_buffer[2] = m_linkcount;
m_line_tx.write(m_buffer, dataSize);
// consider it done
printf("M2COMM: link established - id %02x of %02x\n", m_linkid, m_linkcount);
m_linkalive = 0x01;
+ m_linktimer = 0x00;
// write to shared mem
m_shared[0] = 0x01;
@@ -503,52 +505,16 @@ void m2comm_device::comm_tick_16726()
int recv = m_line_rx.read(m_buffer, dataSize);
while (recv != 0)
{
+ m_linktimer = 0x00;
// check if complete message
if (recv == dataSize)
{
// check if valid id
int idx = m_buffer[0];
- if (idx > 0 && idx <= m_linkcount) {
- int slotFrom = m_linkid - idx;
- int slotDest = slotFrom + m_linkcount;
- while (slotDest < 9) {
- slotDest += m_linkcount;
- }
- while (slotDest - m_linkcount > 0) {
- slotFrom = slotDest - m_linkcount;
- if (slotDest < 9) {
- int frameOffset1 = frameStart + slotFrom * frameSize;
- int frameOffset2 = frameStart + slotDest * frameSize;
- for (int j = 0x00 ; j < frameSize ; j++)
- {
- m_shared[frameOffset2 + j] = m_shared[frameOffset1 + j];
- }
- }
- slotDest -= m_linkcount;
- }
- if (slotDest > 0) {
- // save message to "ring buffer"
- frameOffset = frameStart + (slotDest * frameSize);
- for (int j = 0x00 ; j < frameSize ; j++)
- {
- m_shared[frameOffset + j] = m_buffer[1 + j];
- }
- }
- if (idx != m_linkid)
+ if (idx >= 0 && idx <= m_linkcount) {
+ for (int j = 0x00 ; j < frameSize ; 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);
+ m_shared[0x2000 + frameOffset + j] = m_buffer[1 + j];
}
}
}
@@ -566,32 +532,18 @@ void m2comm_device::comm_tick_16726()
recv = m_line_rx.read(m_buffer, dataSize);
}
- // push message to other nodes
- m_buffer[0] = m_linkid;
- for (int j = 0x00 ; j < frameSize ; j++)
+ if (m_linktimer == 0x00)
{
- m_buffer[1 + j] = m_shared[frameStart + j];
- }
- m_line_tx.write(m_buffer, dataSize);
-
- // master sends some additional status bytes
- if (isMaster){
- m_buffer[0] = 0xF0;
+ // push message to other nodes
+ m_buffer[0] = m_linkid;
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];
+ m_buffer[1 + j] = m_shared[0x2000 + j];
}
- // push message to other nodes
m_line_tx.write(m_buffer, dataSize);
+ m_linktimer = 0x01;
}
}
-
- // clear 03
- //TODO:m_shared[3] = 0x00;
}
}
#endif
diff --git a/src/mame/machine/m2comm.h b/src/mame/machine/m2comm.h
index 8566f2cdd33..020ac38fbb2 100644
--- a/src/mame/machine/m2comm.h
+++ b/src/mame/machine/m2comm.h
@@ -77,9 +77,8 @@ private:
UINT16 m_linktype;
+ void comm_init();
void comm_tick();
-
- void comm_tick_16726();
#endif
};