summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Dirk Best <mail@dirk-best.de>2019-08-30 14:01:24 +0200
committer Dirk Best <mail@dirk-best.de>2019-08-30 14:04:13 +0200
commit5c4048ad73cdbe6a24a42bc1e6ed2cd6e45a2a94 (patch)
treec9b6cf5c8886cc853bbf36878aae9f4d7eba24ef
parentcb8c1590926cb0bd3db7a1a1ae25291475140853 (diff)
Emulate the Sega Billboard and hook it up to the STV driver
[biggestsonicfan, Dirk Best] It's not shown by default. To view it, choose the layout view 'Billboard'.
-rw-r--r--scripts/target/mame/arcade.lua2
-rw-r--r--src/mame/drivers/stv.cpp8
-rw-r--r--src/mame/includes/stv.h5
-rw-r--r--src/mame/machine/segabill.cpp186
-rw-r--r--src/mame/machine/segabill.h58
5 files changed, 258 insertions, 1 deletions
diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua
index 21aa1c663e3..e6cc86c4296 100644
--- a/scripts/target/mame/arcade.lua
+++ b/scripts/target/mame/arcade.lua
@@ -3511,6 +3511,8 @@ files {
MAME_DIR .. "src/mame/machine/mc8123.h",
MAME_DIR .. "src/mame/machine/segaic16.cpp",
MAME_DIR .. "src/mame/machine/segaic16.h",
+ MAME_DIR .. "src/mame/machine/segabill.cpp",
+ MAME_DIR .. "src/mame/machine/segabill.h",
MAME_DIR .. "src/mame/audio/segasnd.cpp",
MAME_DIR .. "src/mame/audio/segasnd.h",
MAME_DIR .. "src/mame/video/segaic16.cpp",
diff --git a/src/mame/drivers/stv.cpp b/src/mame/drivers/stv.cpp
index 7b291026a68..62e8616496c 100644
--- a/src/mame/drivers/stv.cpp
+++ b/src/mame/drivers/stv.cpp
@@ -51,6 +51,7 @@
#include "coreutil.h"
+#include "segabill.lh"
#define FIRST_SPEEDUP_SLOT (2) // in case we remove/alter the BIOS speedups later
@@ -147,6 +148,9 @@ WRITE8_MEMBER(stv_state::stv_ioga_w)
machine().bookkeeping().coin_lockout_w(0,~data & 0x04);
machine().bookkeeping().coin_lockout_w(1,~data & 0x08);
break;
+ case 0x09:
+ m_billboard->write(data);
+ break;
case 0x0d:
// then bit 7==0 - reset counters, currently this is unhandled, instead counters reset after each read (PORT_RESET used)
m_ioga_portg = data;
@@ -1182,6 +1186,10 @@ void stv_state::stv(machine_config &config)
m_scsp->main_irq_cb().set(m_scu, FUNC(sega_scu_device::sound_req_w));
m_scsp->add_route(0, "lspeaker", 1.0);
m_scsp->add_route(1, "rspeaker", 1.0);
+
+ SEGA_BILLBOARD(config, m_billboard, 0);
+
+ config.set_default_layout(layout_segabill);
}
void stv_state::stv_5881(machine_config &config)
diff --git a/src/mame/includes/stv.h b/src/mame/includes/stv.h
index 39d420939d4..1cdb78bef00 100644
--- a/src/mame/includes/stv.h
+++ b/src/mame/includes/stv.h
@@ -9,6 +9,7 @@
#include "audio/rax.h"
#include "machine/eepromser.h"
#include "machine/ticket.h"
+#include "machine/segabill.h"
class stv_state : public saturn_state
{
@@ -24,7 +25,8 @@ public:
m_eeprom(*this, "eeprom"),
m_cryptdevice(*this, "315_5881"),
m_5838crypt(*this, "315_5838"),
- m_hopper(*this, "hopper")
+ m_hopper(*this, "hopper"),
+ m_billboard(*this, "billboard")
{
}
@@ -153,6 +155,7 @@ private:
optional_device<sega_315_5881_crypt_device> m_cryptdevice;
optional_device<sega_315_5838_comp_device> m_5838crypt;
optional_device<ticket_dispenser_device> m_hopper;
+ required_device<sega_billboard_device> m_billboard;
uint16_t crypt_read_callback(uint32_t addr);
DECLARE_READ8_MEMBER(pdr1_input_r);
diff --git a/src/mame/machine/segabill.cpp b/src/mame/machine/segabill.cpp
new file mode 100644
index 00000000000..19d87c149a7
--- /dev/null
+++ b/src/mame/machine/segabill.cpp
@@ -0,0 +1,186 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Sega Billboard
+
+***************************************************************************/
+
+#include "emu.h"
+#include "segabill.h"
+#include "cpu/z80/z80.h"
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(SEGA_BILLBOARD, sega_billboard_device, "segabill", "Sega Billboard")
+
+//-------------------------------------------------
+// mem_map - z80 memory map
+//-------------------------------------------------
+
+void sega_billboard_device::mem_map(address_map &map)
+{
+ map(0x0000, 0x7fff).rom();
+ map(0xe000, 0xffff).ram();
+}
+
+//-------------------------------------------------
+// io_map - z80 io map
+//-------------------------------------------------
+
+void sega_billboard_device::io_map(address_map &map)
+{
+ map.global_mask(0xff);
+ map(0x20, 0x2f).rw("io", FUNC(sega_315_5338a_device::read), FUNC(sega_315_5338a_device::write));
+}
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+static INPUT_PORTS_START( billboard )
+ PORT_START("dsw")
+ PORT_DIPNAME(0x01, 0x01, "Test Winner LED P1")
+ PORT_DIPSETTING( 0x01, DEF_STR( Off ))
+ PORT_DIPSETTING( 0x00, DEF_STR( On ))
+ PORT_DIPLOCATION("DSW:1")
+ PORT_DIPNAME(0x02, 0x02, "Test Winner LED P2")
+ PORT_DIPSETTING( 0x02, DEF_STR( Off ))
+ PORT_DIPSETTING( 0x00, DEF_STR( On ))
+ PORT_DIPLOCATION("DSW:2")
+ PORT_DIPNAME(0x04, 0x04, "Test 7-Segment P1")
+ PORT_DIPSETTING( 0x04, DEF_STR( Off ))
+ PORT_DIPSETTING( 0x00, DEF_STR( On ))
+ PORT_DIPLOCATION("DSW:3")
+ PORT_DIPNAME(0x08, 0x08, "Test 7-Segment P2")
+ PORT_DIPSETTING( 0x08, DEF_STR( Off ))
+ PORT_DIPSETTING( 0x00, DEF_STR( On ))
+ PORT_DIPLOCATION("DSW:4")
+ PORT_DIPUNKNOWN_DIPLOC(0x10, 0x10, "DSW:5")
+ PORT_DIPUNKNOWN_DIPLOC(0x20, 0x20, "DSW:6")
+ PORT_DIPNAME(0x40, 0x00, "Demo")
+ PORT_DIPSETTING( 0x00, DEF_STR( Off ))
+ PORT_DIPSETTING( 0x40, DEF_STR( On ))
+ PORT_DIPLOCATION("DSW:7")
+ PORT_DIPNAME(0x80, 0x00, "Testmode")
+ PORT_DIPSETTING( 0x00, DEF_STR( Off ))
+ PORT_DIPSETTING( 0x80, DEF_STR( On ))
+ PORT_DIPLOCATION("DSW:8")
+INPUT_PORTS_END
+
+ioport_constructor sega_billboard_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(billboard);
+}
+
+//-------------------------------------------------
+// rom_region - device-specific ROM region
+//-------------------------------------------------
+
+ROM_START( billboard )
+ ROM_REGION(0x10000, "billcpu", 0)
+ ROM_LOAD("epr-18022.ic2", 0x00000, 0x10000, CRC(0ca70f80) SHA1(edf5ade72d9fa2f4d5f83f9f89e6cecfadd77f56))
+ROM_END
+
+const tiny_rom_entry *sega_billboard_device::device_rom_region() const
+{
+ return ROM_NAME(billboard);
+}
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+void sega_billboard_device::device_add_mconfig(machine_config &config)
+{
+ Z80(config, m_billcpu, 32_MHz_XTAL / 8); // divisor guessed
+ m_billcpu->set_addrmap(AS_PROGRAM, &sega_billboard_device::mem_map);
+ m_billcpu->set_addrmap(AS_IO, &sega_billboard_device::io_map);
+ m_billcpu->set_periodic_int(FUNC(sega_billboard_device::irq0_line_hold), attotime::from_hz(32_MHz_XTAL/65536)); // timing?
+
+ sega_315_5338a_device &io(SEGA_315_5338A(config, "io", 32_MHz_XTAL));
+ io.in_pa_callback().set_ioport("dsw");
+ io.in_pb_callback().set(FUNC(sega_billboard_device::cmd_r));
+ io.out_pc_callback().set(FUNC(sega_billboard_device::digit_w<1>));
+ io.out_pd_callback().set(FUNC(sega_billboard_device::digit_w<0>));
+ io.out_pe_callback().set(FUNC(sega_billboard_device::digit_w<3>));
+ io.out_pf_callback().set(FUNC(sega_billboard_device::digit_w<2>));
+ io.out_pg_callback().set(FUNC(sega_billboard_device::led_w));
+}
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// sega_billboard_device - constructor
+//-------------------------------------------------
+
+sega_billboard_device::sega_billboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, SEGA_BILLBOARD, tag, owner, clock),
+ m_billcpu(*this, "billcpu"),
+ m_io(*this, "io"),
+ m_digits(*this, "digit%u", 0U),
+ m_leds(*this, "led_winner%u", 0U),
+ m_cmd(0xff)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void sega_billboard_device::device_start()
+{
+ // resolve output finders
+ m_digits.resolve();
+ m_leds.resolve();
+
+ // register for save states
+ save_item(NAME(m_cmd));
+}
+
+//-------------------------------------------------
+// device_start - device-specific reset
+//-------------------------------------------------
+
+void sega_billboard_device::device_reset()
+{
+ m_cmd = 0xff;
+}
+
+
+//**************************************************************************
+// INTERFACE
+//**************************************************************************
+
+void sega_billboard_device::irq0_line_hold(device_t &device)
+{
+ m_billcpu->set_input_line(INPUT_LINE_IRQ0, HOLD_LINE);
+}
+
+void sega_billboard_device::write(uint8_t data)
+{
+ m_cmd = data;
+}
+
+uint8_t sega_billboard_device::cmd_r()
+{
+ return m_cmd;
+}
+
+template<int N>
+void sega_billboard_device::digit_w(uint8_t data)
+{
+ m_digits[N] = ~data & 0xff;
+}
+
+void sega_billboard_device::led_w(uint8_t data)
+{
+ m_leds[0] = BIT(~data, 0);
+ m_leds[1] = BIT(~data, 1);
+}
diff --git a/src/mame/machine/segabill.h b/src/mame/machine/segabill.h
new file mode 100644
index 00000000000..03b6b3adb9b
--- /dev/null
+++ b/src/mame/machine/segabill.h
@@ -0,0 +1,58 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Sega Billboard
+
+***************************************************************************/
+
+#ifndef MAME_MACHINE_SEGABILL_H
+#define MAME_MACHINE_SEGABILL_H
+
+#pragma once
+
+#include "machine/315_5338a.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+class sega_billboard_device : public device_t
+{
+public:
+ // construction/destruction
+ sega_billboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ void mem_map(address_map &map);
+ void io_map(address_map &map);
+
+ void write(uint8_t data);
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual const tiny_rom_entry *device_rom_region() const override;
+ virtual ioport_constructor device_input_ports() const override;
+ virtual void device_add_mconfig(machine_config &config) override;
+
+private:
+ required_device<cpu_device> m_billcpu;
+ required_device<sega_315_5338a_device> m_io;
+ output_finder<4> m_digits;
+ output_finder<2> m_leds;
+
+ void irq0_line_hold(device_t &device);
+
+ uint8_t cmd_r();
+ template<int N> void digit_w(uint8_t data);
+ void led_w(uint8_t data);
+
+ uint8_t m_cmd;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(SEGA_BILLBOARD, sega_billboard_device)
+
+#endif // MAME_MACHINE_SEGABILL_H