m68705: save EPROM contents using NVRAM mechanism

m68705prg: move stuff that doesn't need to be templated to base class,
de-duplicate machine configuration
This commit is contained in:
Vas Crabb 2017-01-14 11:33:23 +11:00
parent dc7a48c1cf
commit 9cdb6d0d48
3 changed files with 98 additions and 82 deletions

View File

@ -204,6 +204,7 @@ m68705_new_device::m68705_new_device(
char const *shortname,
char const *source)
: m68705_device(mconfig, tag, owner, clock, type, name, addr_width, internal_map, shortname, source)
, device_nvram_interface(mconfig, *this)
, m_user_rom(*this, DEVICE_SELF, u32(1) << addr_width)
, m_port_open_drain{ false, false, false, false }
, m_port_mask{ 0x00, 0x00, 0x00, 0x00 }
@ -445,6 +446,20 @@ void m68705_new_device::execute_set_input(int inputnum, int state)
}
}
void m68705_new_device::nvram_default()
{
}
void m68705_new_device::nvram_read(emu_file &file)
{
file.read(&m_user_rom[0], m_user_rom.bytes());
}
void m68705_new_device::nvram_write(emu_file &file)
{
file.write(&m_user_rom[0], m_user_rom.bytes());
}
/****************************************************************************
* M68705P3x family

View File

@ -81,7 +81,7 @@ protected:
devcb = &m68705_new_device::set_port_cb_w<2>(*device, DEVCB_##obj);
class m68705_new_device : public m68705_device
class m68705_new_device : public m68705_device, public device_nvram_interface
{
public:
// static configuration helpers
@ -140,6 +140,9 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void execute_set_input(int inputnum, int state) override;
virtual void nvram_default() override;
virtual void nvram_read(emu_file &file) override;
virtual void nvram_write(emu_file &file) override;
u8 m_tdr;
u8 m_tcr;

View File

@ -35,14 +35,12 @@
namespace {
template <typename Device>
class m68705prg_state : public driver_device
class m68705prg_state_base : public driver_device
{
public:
m68705prg_state(const machine_config &mconfig, device_type type, const char *tag)
m68705prg_state_base(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_sw(*this, "SW")
, m_mcu(*this, "mcu")
, m_mcu_region(*this, "mcu")
, m_eprom_image(*this, "eprom_image")
, m_mcu_image(*this, "mcu_image")
@ -75,7 +73,7 @@ public:
auto const actual(m_mcu_image->common_get_size("rom"));
if (desired != actual)
{
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Incorrect MCU ROM size");
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Incorrect internal MCU EPROM size");
return image_init_result::FAIL;
}
else
@ -85,6 +83,58 @@ public:
}
}
DECLARE_DRIVER_INIT(m68705prg)
{
m_input_poll_timer = timer_alloc(TIMER_INPUT_POLL);
save_item(NAME(m_addr));
save_item(NAME(m_pb_val));
m_addr = 0x0000;
m_pb_val = 0xff;
}
DECLARE_MACHINE_START(m68705prg)
{
output().set_digit_value(0, s_7seg[(m_addr >> 0) & 0x0f]);
output().set_digit_value(1, s_7seg[(m_addr >> 4) & 0x0f]);
output().set_digit_value(2, s_7seg[(m_addr >> 8) & 0x0f]);
m_input_poll_timer->adjust(attotime::from_hz(120), 0, attotime::from_hz(120));
}
protected:
enum
{
TIMER_INPUT_POLL
};
required_ioport m_sw;
required_region_ptr<u8> m_mcu_region;
required_device<generic_slot_device> m_eprom_image;
required_device<generic_slot_device> m_mcu_image;
emu_timer * m_input_poll_timer;
u16 m_addr;
u8 m_pb_val;
static u8 const s_7seg[16];
};
u8 const m68705prg_state_base::s_7seg[16] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71 };
template <typename Device>
class m68705prg_state : public m68705prg_state_base
{
public:
m68705prg_state(const machine_config &mconfig, device_type type, const char *tag)
: m68705prg_state_base(mconfig, type, tag)
, m_mcu(*this, "mcu")
{
}
DECLARE_WRITE8_MEMBER(pb_w)
{
// PB4: address counter reset (active high)
@ -112,22 +162,6 @@ public:
output().set_digit_value(2, s_7seg[(m_addr >> 8) & 0x0f]);
}
DECLARE_DRIVER_INIT(m68705prg)
{
m_input_poll_timer = timer_alloc(TIMER_INPUT_POLL);
save_item(NAME(m_addr));
save_item(NAME(m_pb_val));
m_addr = 0x0000;
m_pb_val = 0xff;
}
DECLARE_MACHINE_START(m68705prg)
{
m_input_poll_timer->adjust(attotime::from_hz(120), 0, attotime::from_hz(120));
}
DECLARE_MACHINE_RESET(m68705prg)
{
m_sw->field(0x01)->live().value = 0;
@ -143,11 +177,6 @@ public:
}
protected:
enum
{
TIMER_INPUT_POLL
};
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override
{
switch (id)
@ -173,23 +202,9 @@ protected:
m_mcu->set_input_line(INPUT_LINE_RESET, reset ? ASSERT_LINE : CLEAR_LINE);
}
required_ioport m_sw;
required_device<Device> m_mcu;
required_region_ptr<u8> m_mcu_region;
required_device<generic_slot_device> m_eprom_image;
required_device<generic_slot_device> m_mcu_image;
emu_timer * m_input_poll_timer;
u16 m_addr;
u8 m_pb_val;
static u8 const s_7seg[16];
required_device<Device> m_mcu;
};
template <typename Device>
u8 const m68705prg_state<Device>::s_7seg[16] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71 };
typedef m68705prg_state<m68705p3_device> p3prg_state;
typedef m68705prg_state<m68705p5_device> p5prg_state;
typedef m68705prg_state<m68705u3_device> u3prg_state;
@ -202,58 +217,41 @@ INPUT_PORTS_START(m68705prg)
INPUT_PORTS_END
MACHINE_CONFIG_START(m68705p3prg, p3prg_state)
MACHINE_CONFIG_START(m68705prg, m68705prg_state_base)
MCFG_QUANTUM_PERFECT_CPU("mcu")
MCFG_GENERIC_SOCKET_ADD("eprom_image", generic_plain_slot, "eprom")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(m68705prg_state_base, eprom_load)
MCFG_GENERIC_SOCKET_ADD("mcu_image", generic_plain_slot, "mcu")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(m68705prg_state_base, mcu_load)
MCFG_MACHINE_START_OVERRIDE(m68705prg_state_base, m68705prg)
MCFG_DEFAULT_LAYOUT(layout_m68705prg)
MACHINE_CONFIG_END
MACHINE_CONFIG_DERIVED_CLASS(m68705p3prg, m68705prg, p3prg_state)
MCFG_CPU_ADD("mcu", M68705P3, XTAL_1MHz)
MCFG_M68705_PORTB_W_CB(WRITE8(p3prg_state, pb_w))
MCFG_GENERIC_SOCKET_ADD("eprom_image", generic_plain_slot, "eprom")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(p3prg_state, eprom_load)
MCFG_GENERIC_SOCKET_ADD("mcu_image", generic_plain_slot, "mcu")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(p3prg_state, mcu_load)
MCFG_MACHINE_START_OVERRIDE(p3prg_state, m68705prg)
MCFG_MACHINE_RESET_OVERRIDE(p3prg_state, m68705prg)
MCFG_DEFAULT_LAYOUT(layout_m68705prg)
MACHINE_CONFIG_END
MACHINE_CONFIG_START(m68705p5prg, p5prg_state)
MACHINE_CONFIG_DERIVED_CLASS(m68705p5prg, m68705prg, p5prg_state)
MCFG_CPU_ADD("mcu", M68705P5, XTAL_1MHz)
MCFG_M68705_PORTB_W_CB(WRITE8(p5prg_state, pb_w))
MCFG_GENERIC_SOCKET_ADD("eprom_image", generic_plain_slot, "eprom")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(p5prg_state, eprom_load)
MCFG_GENERIC_SOCKET_ADD("mcu_image", generic_plain_slot, "mcu")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(p5prg_state, mcu_load)
MCFG_MACHINE_START_OVERRIDE(p5prg_state, m68705prg)
MCFG_MACHINE_RESET_OVERRIDE(p5prg_state, m68705prg)
MCFG_DEFAULT_LAYOUT(layout_m68705prg)
MACHINE_CONFIG_END
MACHINE_CONFIG_START(m68705u3prg, u3prg_state)
MACHINE_CONFIG_DERIVED_CLASS(m68705u3prg, m68705prg, u3prg_state)
MCFG_CPU_ADD("mcu", M68705U3, XTAL_1MHz)
MCFG_M68705_PORTB_W_CB(WRITE8(u3prg_state, pb_w))
MCFG_GENERIC_SOCKET_ADD("eprom_image", generic_plain_slot, "eprom")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(u3prg_state, eprom_load)
MCFG_GENERIC_SOCKET_ADD("mcu_image", generic_plain_slot, "mcu")
MCFG_GENERIC_EXTENSIONS("bin,rom")
MCFG_GENERIC_LOAD(u3prg_state, mcu_load)
MCFG_MACHINE_START_OVERRIDE(u3prg_state, m68705prg)
MCFG_MACHINE_RESET_OVERRIDE(u3prg_state, m68705prg)
MCFG_DEFAULT_LAYOUT(layout_m68705prg)
MACHINE_CONFIG_END
@ -275,7 +273,7 @@ ROM_END
} // anonymous namespace
// YEAR NAME PARENT COMPAT MACHINE INPUT STATE INIT COMPANY FULLNAME FLAGS
COMP( 1984, 705p3prg, 0, 0, m68705p3prg, m68705prg, p3prg_state, m68705prg, "Motorola", "MC68705P3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW )
COMP( 1984, 705p5prg, 0, 0, m68705p5prg, m68705prg, p5prg_state, m68705prg, "Motorola", "MC68705P5 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW )
COMP( 1984, 705u3prg, 0, 0, m68705u3prg, m68705prg, u3prg_state, m68705prg, "Motorola", "MC68705U3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW )
// YEAR NAME PARENT COMPAT MACHINE INPUT STATE INIT COMPANY FULLNAME FLAGS
COMP( 1984, 705p3prg, 0, 0, m68705p3prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705P3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW )
COMP( 1984, 705p5prg, 0, 0, m68705p5prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705P5 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW )
COMP( 1984, 705u3prg, 0, 0, m68705u3prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705U3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW )