summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author James Wallace <james-wallace-ghub@users.noreply.github.com>2020-08-05 19:27:04 +0100
committer James Wallace <james-wallace-ghub@users.noreply.github.com>2020-08-05 19:27:04 +0100
commit56d1b54ebf7b9fc189a56accbf1f3378d056d419 (patch)
treeb837314f527a489caea685932378482649c11b60 /src
parent6a498a59ad347d481715ffd2e83505e5fcc23d1b (diff)
Added an implementation of the BACTA Datalogging protocol used in many of the AWP drivers.
The logged data is currently served to the error log. Hooked the BACTA logger up to the MPU4 driver to fix Datapak/Protocol games.
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/mpu4vid.cpp35
-rw-r--r--src/mame/includes/mpu4.h9
-rw-r--r--src/mame/machine/bacta_datalogger.cpp139
-rw-r--r--src/mame/machine/bacta_datalogger.h45
-rw-r--r--src/mame/machine/mpu4.cpp31
5 files changed, 229 insertions, 30 deletions
diff --git a/src/mame/drivers/mpu4vid.cpp b/src/mame/drivers/mpu4vid.cpp
index 6e495c38b96..c53d87c2843 100644
--- a/src/mame/drivers/mpu4vid.cpp
+++ b/src/mame/drivers/mpu4vid.cpp
@@ -172,6 +172,7 @@ TODO:
They appear to hang on the handshake with the MPU4 board
- Layouts needed for the other working games, and DIP switches need checking/altering (no test mode?)
- BWB Vid5 cabinets seem to have the speakers wired the other way according to test (left/right swapped)
+ - BWB sampled sound seems to not play despite hookup.
***********************************************************************************************************/
#include "emu.h"
#include "includes/mpu4.h"
@@ -1909,9 +1910,10 @@ void mpu4vid_state::bwbvidoki_68k_map(address_map &map)
map(0xc00000, 0xc1ffff).rw(FUNC(mpu4vid_state::mpu4_vid_vidram_r), FUNC(mpu4vid_state::mpu4_vid_vidram_w)).share("vid_vidram");
map(0xe00000, 0xe00003).rw(m_acia_1, FUNC(acia6850_device::read), FUNC(acia6850_device::write)).umask16(0x00ff);
map(0xe01000, 0xe0100f).rw(m_ptm, FUNC(ptm6840_device::read), FUNC(ptm6840_device::write)).umask16(0x00ff);
- map(0xe02000, 0xe02007).rw("pia_ic4ss", FUNC(pia6821_device::read), FUNC(pia6821_device::write)).umask16(0xff00); //Seems odd...
+ map(0xe02000, 0xe02007).rw("pia_ic4ss", FUNC(pia6821_device::read), FUNC(pia6821_device::write)).umask16(0xff00);
map(0xe03000, 0xe0300f).r("ptm_ic3ss", FUNC(ptm6840_device::read)).umask16(0xff00); // 6840PTM on sampled sound board
map(0xe03000, 0xe0300f).w(FUNC(mpu4vid_state::ic3ss_vid_w)).umask16(0xff00); // 6840PTM on sampled sound board
+ map(0xe05000, 0xe05001).noprw();
}
/* TODO: Fix up MPU4 map*/
@@ -1972,7 +1974,6 @@ void mpu4vid_state::ic3ss_vid_w(offs_t offset, uint8_t data)
int denom2 = denom1 + 0.5f;//need to round up, this gives same precision as chip
int freq=num*denom2;
-
if (freq)
{
m_msm6376->set_unscaled_clock(freq);
@@ -1996,6 +1997,7 @@ void mpu4vid_state::mpu4_vid(machine_config &config)
mpu4_common(config);
+
/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_raw(VIDEO_MASTER_CLOCK, (63*8)+(17*8), 0, (63*8), (37*8)+17, 0, (37*8));
@@ -2070,12 +2072,16 @@ void mpu4vid_state::vid_oki(machine_config &config)
//m_ptm_ic3ss->o3_callback().set("ptm_ic3ss", FUNC(ptm6840_device::set_g1));
//m_ptm_ic3ss->irq_callback().set(FUNC(mpu4_state::cpu1_ptm_irq));
- pia6821_device &pia_ic4ss(PIA6821(config, "pia_ic4ss", 0));
- pia_ic4ss.readpb_handler().set(FUNC(mpu4vid_state::pia_gb_portb_r));
- pia_ic4ss.writepa_handler().set(FUNC(mpu4vid_state::pia_gb_porta_w));
- pia_ic4ss.writepb_handler().set(FUNC(mpu4vid_state::pia_gb_portb_w));
- pia_ic4ss.ca2_handler().set(FUNC(mpu4vid_state::pia_gb_ca2_w));
- pia_ic4ss.cb2_handler().set(FUNC(mpu4vid_state::pia_gb_cb2_w));
+ PIA6821(config, m_pia_ic4ss, 0);
+ m_pia_ic4ss->readpb_handler().set(FUNC(mpu4vid_state::pia_gb_portb_r));
+ m_pia_ic4ss->writepa_handler().set(FUNC(mpu4vid_state::pia_gb_porta_w));
+ m_pia_ic4ss->writepb_handler().set(FUNC(mpu4vid_state::pia_gb_portb_w));
+ m_pia_ic4ss->ca2_handler().set(FUNC(mpu4vid_state::pia_gb_ca2_w));
+ m_pia_ic4ss->cb2_handler().set(FUNC(mpu4vid_state::pia_gb_cb2_w));
+
+ okim6376_device &msm6376(OKIM6376(config, "msm6376", 128000)); //Adjusted by IC3 on sound board
+ msm6376.add_route(0, "lspeaker", 0.5);
+ msm6376.add_route(1, "rspeaker", 0.5);
}
void mpu4vid_state::mating(machine_config &config)
@@ -2083,12 +2089,9 @@ void mpu4vid_state::mating(machine_config &config)
crmaze(config);
vid_oki(config);
m_videocpu->set_addrmap(AS_PROGRAM, &mpu4vid_state::mpu4oki_68k_map);
+}
- okim6376_device &msm6376(OKIM6376(config, "msm6376", 128000)); //Adjusted by IC3 on sound board
- msm6376.add_route(0, "lspeaker", 0.5);
- msm6376.add_route(1, "rspeaker", 0.5);
-}
void mpu4vid_state::bwbvid(machine_config &config)
{
@@ -2098,13 +2101,9 @@ void mpu4vid_state::bwbvid(machine_config &config)
void mpu4vid_state::bwbvid_oki(machine_config &config)
{
- bwbvid(config);
- vid_oki(config);
+ mpu4_vid(config);
m_videocpu->set_addrmap(AS_PROGRAM, &mpu4vid_state::bwbvidoki_68k_map);
-
- okim6376_device &msm6376(OKIM6376(config, "msm6376", 128000)); //?
- msm6376.add_route(0, "lspeaker", 0.5);
- msm6376.add_route(1, "rspeaker", 0.5);
+ vid_oki(config);
}
/*
diff --git a/src/mame/includes/mpu4.h b/src/mame/includes/mpu4.h
index 69694712bfe..92be9cf5cc3 100644
--- a/src/mame/includes/mpu4.h
+++ b/src/mame/includes/mpu4.h
@@ -14,6 +14,9 @@
#include "machine/steppers.h"
#include "machine/roc10937.h"
#include "machine/meters.h"
+
+#include "machine/bacta_datalogger.h"
+
#include "emupal.h"
@@ -113,6 +116,7 @@ public:
, m_pia6(*this, "pia_ic6")
, m_pia7(*this, "pia_ic7")
, m_pia8(*this, "pia_ic8")
+ , m_pia_ic4ss(*this, "pia_ic4ss")
, m_port_mux(*this, {"ORANGE1", "ORANGE2", "BLACK1", "BLACK2", "ORANGE1", "ORANGE2", "DIL1", "DIL2"})
, m_aux1_port(*this, "AUX1")
, m_aux2_port(*this, "AUX2")
@@ -123,6 +127,7 @@ public:
, m_meters(*this, "meters")
, m_ym2413(*this, "ym2413")
, m_ay8913(*this, "ay8913")
+ , m_dataport(*this, "dataport")
, m_lamps(*this, "lamp%u", 0U)
, m_mpu4leds(*this, "mpu4led%u", 0U)
, m_digits(*this, "digit%u", 0U)
@@ -311,6 +316,8 @@ protected:
DECLARE_WRITE_LINE_MEMBER(pia_gb_ca2_w);
DECLARE_WRITE_LINE_MEMBER(pia_gb_cb2_w);
+ DECLARE_WRITE_LINE_MEMBER(dataport_rxd);
+
required_device<cpu_device> m_maincpu;
optional_device<rocvfd_device> m_vfd;
optional_device<ptm6840_device> m_6840ptm;
@@ -321,6 +328,7 @@ protected:
optional_device<pia6821_device> m_pia6;
optional_device<pia6821_device> m_pia7;
optional_device<pia6821_device> m_pia8;
+ optional_device<pia6821_device> m_pia_ic4ss;
required_ioport_array<8> m_port_mux;
required_ioport m_aux1_port;
required_ioport m_aux2_port;
@@ -331,6 +339,7 @@ protected:
required_device<meters_device> m_meters;
optional_device<ym2413_device> m_ym2413;
optional_device<ay8913_device> m_ay8913;
+ optional_device<bacta_datalogger_device> m_dataport;
// not all systems have this many lamps/LEDs/digits but the driver is too much of a mess to split up now
diff --git a/src/mame/machine/bacta_datalogger.cpp b/src/mame/machine/bacta_datalogger.cpp
new file mode 100644
index 00000000000..6caddd70bf2
--- /dev/null
+++ b/src/mame/machine/bacta_datalogger.cpp
@@ -0,0 +1,139 @@
+// license:BSD-3-Clause
+// copyright-holders:James Wallace
+#include "emu.h"
+#include "bacta_datalogger.h"
+
+#define LOG_DATA 1
+/***********************************************************************************************************
+ BACTA Datalogger emulation
+ The British Amusement and Catering Trade Association created a standard for the tracking of statistics
+ and other features on British AWPs across hardware manufacturers.
+ The specification is very simple, a 1200 baud null modem via RS232, with the logger sending an ACK
+ command (0x06) on receipt of a valid character.
+ As this is RS232, the logger itself can be of any design provided the acknowledgment is made where demanded
+ (by, for example, Protocol game ROMS).
+ In this emulation, the simplest functioning device is simulated here, derived from the rs232 null_modem.
+ We only handle the feedback for acknowledgment, not any other feature.
+************************************************************************************************************/
+
+// device type definition
+DEFINE_DEVICE_TYPE(BACTA_DATALOGGER, bacta_datalogger_device, "bacta_datalogger", "BACTA Datalogger")
+
+//-------------------------------------------------
+// bacta_datalogger_device - constructor
+//-------------------------------------------------
+
+bacta_datalogger_device::bacta_datalogger_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : bacta_datalogger_device(mconfig, BACTA_DATALOGGER, tag, owner, clock)
+{
+}
+
+bacta_datalogger_device::bacta_datalogger_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, BACTA_DATALOGGER, tag, owner, clock),
+ device_serial_interface(mconfig, *this),
+ m_rxd_handler(*this),
+ m_output_char(0),
+ m_timer_poll(nullptr)
+{
+}
+
+void bacta_datalogger_device::device_start()
+{
+ m_rxd_handler.resolve_safe();
+
+ m_timer_poll = timer_alloc(TIMER_POLL);
+}
+
+
+WRITE_LINE_MEMBER(bacta_datalogger_device::update_serial)
+{
+ int startbits = 1;
+ int databits = 8;
+ parity_t parity = device_serial_interface::PARITY_ODD;
+ stop_bits_t stopbits = device_serial_interface::STOP_BITS_1; // 1 stop bit
+
+ set_data_frame(startbits, databits, parity, stopbits);
+
+ set_tra_rate(1200);
+
+ set_rcv_rate(1200);
+
+ output_rxd(1);
+}
+
+void bacta_datalogger_device::device_reset()
+{
+ update_serial(0);
+ queue();
+}
+
+void bacta_datalogger_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ switch (id)
+ {
+ case TIMER_POLL:
+ queue();
+ break;
+
+ default:
+ break;
+ }
+}
+
+void bacta_datalogger_device::queue()
+{
+ if (m_output_char != 0)
+ {
+ if (is_transmit_register_empty())
+ {
+ transmit_register_setup(m_output_char);
+ m_timer_poll->adjust(attotime::never);
+ return;
+
+ m_timer_poll->adjust(attotime::from_hz(1200));
+ }
+ }
+}
+
+void bacta_datalogger_device::tra_callback()
+{
+ output_rxd(transmit_register_get_data_bit());
+}
+
+void bacta_datalogger_device::tra_complete()
+{
+ queue();
+}
+
+void bacta_datalogger_device::rcv_complete()
+{
+ u8 data;
+
+ receive_register_extract();
+
+ data = get_received_char();
+ if (!is_receive_parity_error())
+ {
+ if (data == 0x00)//clean up logging
+ {
+ if (LOG_DATA)
+ {
+ logerror("Received: %02x () \n",data);
+ }
+
+ }
+ else
+ {
+ if (LOG_DATA)
+ {
+ logerror("Received: %02x (%c) \n",data, data);
+ }
+ }
+ m_output_char = 0x06;//ACK
+ }
+ else
+ {
+ m_output_char = 0x15;//NAK
+ }
+ queue();
+} \ No newline at end of file
diff --git a/src/mame/machine/bacta_datalogger.h b/src/mame/machine/bacta_datalogger.h
new file mode 100644
index 00000000000..63a069ff751
--- /dev/null
+++ b/src/mame/machine/bacta_datalogger.h
@@ -0,0 +1,45 @@
+// license:BSD-3-Clause
+// copyright-holders:James Wallace
+#ifndef MAME_BACTA_DATALOGGER_H
+#define MAME_BACTA_DATALOGGER_H
+
+#include "diserial.h"
+
+class bacta_datalogger_device : public device_t,
+ public device_serial_interface
+{
+public:
+ bacta_datalogger_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
+
+ virtual WRITE_LINE_MEMBER( write_txd ) { device_serial_interface::rx_w(state); }
+ auto rxd_handler() { return m_rxd_handler.bind(); }
+
+ DECLARE_WRITE_LINE_MEMBER( output_rxd ) { m_rxd_handler(state); }
+
+ DECLARE_WRITE_LINE_MEMBER(update_serial);
+
+protected:
+ bacta_datalogger_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+ virtual void tra_callback() override;
+ virtual void tra_complete() override;
+ virtual void rcv_complete() override;
+
+private:
+ static constexpr int TIMER_POLL = 1;
+
+ void queue();
+
+ devcb_write_line m_rxd_handler;
+
+ uint8_t m_output_char;
+ emu_timer *m_timer_poll;
+};
+
+DECLARE_DEVICE_TYPE(BACTA_DATALOGGER, bacta_datalogger_device)
+
+#endif // MAME_BACTA_DATALOGGER_H
diff --git a/src/mame/machine/mpu4.cpp b/src/mame/machine/mpu4.cpp
index c6de7de46a4..7a763d0d0dd 100644
--- a/src/mame/machine/mpu4.cpp
+++ b/src/mame/machine/mpu4.cpp
@@ -159,7 +159,7 @@ IRQ line connected to CPU
| | |
| | | PA0-PA7, INPUT AUX1 connector
| | |
- | | | CA2 OUTPUT, serial port Transmit line
+ | | | CA2 OUTPUT, serial port Transmit line (Tx)
| | | CA1 not connected
| | | IRQA connected to IRQ of CPU
| | |
@@ -705,6 +705,13 @@ void mpu4_state::device_timer(emu_timer &timer, device_timer_id id, int param, v
}
+WRITE_LINE_MEMBER(mpu4_state::dataport_rxd)
+{
+ m_serial_data = state;
+ m_pia4->cb1_w(state);
+ LOG_IC3(("Dataport RX %x\n",state));
+}
+
/* IC4, 7 seg leds, 50Hz timer reel sensors, current sensors */
void mpu4_state::pia_ic4_porta_w(uint8_t data)
{
@@ -743,16 +750,13 @@ void mpu4_state::pia_ic4_portb_w(uint8_t data)
uint8_t mpu4_state::pia_ic4_portb_r()
{
- /// TODO: this shouldn't be clocked from a read callback
if ( m_serial_data )
{
m_ic4_input_b |= 0x80;
- m_pia4->cb1_w(1);
}
else
{
m_ic4_input_b &= ~0x80;
- m_pia4->cb1_w(0);
}
if (!m_reel_mux)
@@ -1072,7 +1076,7 @@ uint8_t mpu4_state::pia_ic5_portb_r()
WRITE_LINE_MEMBER(mpu4_state::pia_ic5_ca2_w)
{
LOG(("%s: IC5 PIA Write CA2 (Serial Tx) %2x\n",machine().describe_context(),state));
- m_serial_data = state;
+ m_dataport->write_txd(state);
}
@@ -1361,6 +1365,7 @@ void mpu4_state::pia_gb_portb_w(uint8_t data)
}
{
+ LOG_SS(("%s: GAMEBOARD: Volume Set to %2x\n", machine().describe_context(),data));
float percent = (32-m_global_volume)/32.0;
m_msm6376->set_output_gain(0, percent);
m_msm6376->set_output_gain(1, percent);
@@ -1392,7 +1397,6 @@ uint8_t mpu4_state::pia_gb_portb_r()
WRITE_LINE_MEMBER(mpu4_state::pia_gb_ca2_w)
{
LOG_SS(("%s: GAMEBOARD: OKI RESET data = %02X\n", machine().describe_context(), state));
-
// reset line
}
@@ -3058,6 +3062,9 @@ void mpu4_state::mpu4_common(machine_config &config)
m_pia8->irqb_handler().set(FUNC(mpu4_state::cpu0_irq));
METERS(config, m_meters, 0).set_number(8);
+
+ BACTA_DATALOGGER(config, m_dataport, 0);
+ m_dataport->rxd_handler().set(FUNC(mpu4_state::dataport_rxd));
}
void mpu4_state::mpu4_common2(machine_config &config)
@@ -3069,12 +3076,12 @@ void mpu4_state::mpu4_common2(machine_config &config)
//m_ptm_ic3ss->o3_callback().set("ptm_ic3ss", FUNC(ptm6840_device::set_g1));
//m_ptm_ic3ss->irq_callback().set(FUNC(mpu4_state::cpu1_ptm_irq));
- pia6821_device &pia_ic4ss(PIA6821(config, "pia_ic4ss", 0));
- pia_ic4ss.readpb_handler().set(FUNC(mpu4_state::pia_gb_portb_r));
- pia_ic4ss.writepa_handler().set(FUNC(mpu4_state::pia_gb_porta_w));
- pia_ic4ss.writepb_handler().set(FUNC(mpu4_state::pia_gb_portb_w));
- pia_ic4ss.ca2_handler().set(FUNC(mpu4_state::pia_gb_ca2_w));
- pia_ic4ss.cb2_handler().set(FUNC(mpu4_state::pia_gb_cb2_w));
+ PIA6821(config, m_pia_ic4ss, 0);
+ m_pia_ic4ss->readpb_handler().set(FUNC(mpu4_state::pia_gb_portb_r));
+ m_pia_ic4ss->writepa_handler().set(FUNC(mpu4_state::pia_gb_porta_w));
+ m_pia_ic4ss->writepb_handler().set(FUNC(mpu4_state::pia_gb_portb_w));
+ m_pia_ic4ss->ca2_handler().set(FUNC(mpu4_state::pia_gb_ca2_w));
+ m_pia_ic4ss->cb2_handler().set(FUNC(mpu4_state::pia_gb_cb2_w));
}
/* machine driver for MOD 2 board */