mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
Added support for machine config fragments that are applied when the cart is loaded, converted NCR 53C7xx to devcb2 as an example [smf]
This commit is contained in:
parent
9ab5eeb6fb
commit
abcd39913b
@ -44,6 +44,11 @@ device_card_options *device_slot_interface::static_alloc_card_options(device_t &
|
||||
return options;
|
||||
}
|
||||
|
||||
void device_slot_interface::static_set_card_machine_config(device_t &device, const char *card, const machine_config_constructor machine_config)
|
||||
{
|
||||
static_alloc_card_options(device, card)->m_machine_config = machine_config;
|
||||
}
|
||||
|
||||
void device_slot_interface::static_set_card_device_input_defaults(device_t &device, const char *card, const input_device_default *input_device_defaults)
|
||||
{
|
||||
static_alloc_card_options(device, card)->m_input_device_defaults = input_device_defaults;
|
||||
@ -59,6 +64,14 @@ void device_slot_interface::static_set_card_clock(device_t &device, const char *
|
||||
static_alloc_card_options(device, card)->m_clock = clock;
|
||||
}
|
||||
|
||||
const machine_config_constructor device_slot_interface::card_machine_config(const char *card) const
|
||||
{
|
||||
device_card_options *options = m_card_options.find(card);
|
||||
if (options != NULL)
|
||||
return options->m_machine_config;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const input_device_default *device_slot_interface::card_input_device_defaults(const char *card) const
|
||||
{
|
||||
device_card_options *options = m_card_options.find(card);
|
||||
|
@ -23,6 +23,9 @@ struct slot_interface
|
||||
#define MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_card, _fixed) \
|
||||
device_slot_interface::static_set_slot_info(*device, SLOT_INTERFACE_NAME(_slot_intf), _def_card, _fixed);
|
||||
|
||||
#define MCFG_DEVICE_CARD_MACHINE_CONFIG(card, _machine_config_name) \
|
||||
device_slot_interface::static_set_card_machine_config(*device, card, MACHINE_CONFIG_NAME(_machine_config_name));
|
||||
|
||||
#define MCFG_DEVICE_CARD_DEVICE_INPUT_DEFAULTS(card, _dev_inp_def) \
|
||||
device_slot_interface::static_set_card_device_input_defaults(*device, card, DEVICE_INPUT_DEFAULTS_NAME(_dev_inp_def));
|
||||
|
||||
@ -53,6 +56,7 @@ class device_card_options
|
||||
friend class simple_list<device_card_options>;
|
||||
|
||||
private:
|
||||
machine_config_constructor m_machine_config;
|
||||
const input_device_default *m_input_device_defaults;
|
||||
const void *m_config;
|
||||
UINT32 m_clock;
|
||||
@ -70,12 +74,14 @@ public:
|
||||
|
||||
static void static_set_slot_info(device_t &device, const slot_interface *slots_info, const char *default_card,bool fixed);
|
||||
static device_card_options *static_alloc_card_options(device_t &device, const char *card);
|
||||
static void static_set_card_machine_config(device_t &device, const char *card, const machine_config_constructor machine_config);
|
||||
static void static_set_card_device_input_defaults(device_t &device, const char *card, const input_device_default *default_input);
|
||||
static void static_set_card_config(device_t &device, const char *card, const void *config);
|
||||
static void static_set_card_clock(device_t &device, const char *card, UINT32 default_clock);
|
||||
const slot_interface* get_slot_interfaces() const { return m_slot_interfaces; };
|
||||
const char * get_default_card() const { return m_default_card; };
|
||||
virtual const char * get_default_card_software(const machine_config &config, emu_options &options) { return NULL; };
|
||||
const machine_config_constructor card_machine_config(const char *card) const;
|
||||
const input_device_default *card_input_device_defaults(const char *card) const;
|
||||
const void *card_config(const char *card) const;
|
||||
const UINT32 card_clock(const char *card) const;
|
||||
|
@ -59,7 +59,10 @@ const device_type NCR53C7XX = &device_creator<ncr53c7xx_device>;
|
||||
ncr53c7xx_device::ncr53c7xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: nscsi_device(mconfig, NCR53C7XX, "53C7xx SCSI", tag, owner, clock, "ncr537xx", __FILE__),
|
||||
device_execute_interface(mconfig, *this),
|
||||
m_icount(0)
|
||||
m_icount(0),
|
||||
m_irq_handler(*this),
|
||||
m_host_write(*this),
|
||||
m_host_read(*this)
|
||||
{
|
||||
}
|
||||
|
||||
@ -74,7 +77,9 @@ void ncr53c7xx_device::device_start()
|
||||
m_icountptr = &m_icount;
|
||||
|
||||
// resolve line callbacks
|
||||
m_out_irq_func.resolve(m_out_irq_cb, *this);
|
||||
m_irq_handler.resolve_safe();
|
||||
m_host_read.resolve_safe(0);
|
||||
m_host_write.resolve_safe();
|
||||
|
||||
m_tm = timer_alloc(0);
|
||||
|
||||
@ -164,31 +169,7 @@ void ncr53c7xx_device::device_reset()
|
||||
set_scripts_state(SCRIPTS_IDLE);
|
||||
set_scsi_state(IDLE);
|
||||
|
||||
m_out_irq_func(CLEAR_LINE);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void ncr53c7xx_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const NCR53C7XXinterface *intf = reinterpret_cast<const NCR53C7XXinterface *>(static_config());
|
||||
|
||||
if (intf != NULL)
|
||||
{
|
||||
*static_cast<NCR53C7XXinterface *>(this) = *intf;
|
||||
}
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
|
||||
}
|
||||
m_irq_handler(CLEAR_LINE);
|
||||
}
|
||||
|
||||
|
||||
@ -670,8 +651,7 @@ void ncr53c7xx_device::update_irqs()
|
||||
else
|
||||
m_istat &= ~ISTAT_DIP;
|
||||
|
||||
if (!m_out_irq_func.isnull())
|
||||
m_out_irq_func(m_istat ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_irq_handler(m_istat ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -718,7 +698,7 @@ void ncr53c7xx_device::send_byte()
|
||||
|
||||
set_scsi_state( (m_scsi_state & STATE_MASK) | (SEND_WAIT_SETTLE << SUB_SHIFT) );
|
||||
|
||||
UINT32 data = host_r(machine(), false, m_dnad & ~3);
|
||||
UINT32 data = m_host_read(m_dnad & ~3, 0xffffffff);
|
||||
data = data >> ((m_dnad & 3) * 8) & 0xff;
|
||||
|
||||
++m_dnad;
|
||||
@ -1078,7 +1058,7 @@ void ncr53c7xx_device::step(bool timeout)
|
||||
|
||||
UINT32 shift = (8 * (m_dnad & 3));
|
||||
UINT32 mem_mask = 0xff << shift;
|
||||
host_w(machine(), false, m_dnad & ~3, data << shift, mem_mask);
|
||||
m_host_write(m_dnad & ~3, data << shift, mem_mask);
|
||||
|
||||
++m_dnad;
|
||||
--m_dbc;
|
||||
@ -1156,7 +1136,7 @@ void ncr53c7xx_device::execute_run()
|
||||
m_finished = false;
|
||||
|
||||
// Fetch the instruction
|
||||
UINT32 inst = host_r(machine(), false, m_dsp);
|
||||
UINT32 inst = m_host_read(m_dsp, 0xffffffff);
|
||||
|
||||
m_dcmd = inst >> 24;
|
||||
m_dbc = inst & 0xffffff;
|
||||
@ -1239,7 +1219,7 @@ void ncr53c7xx_device::scripts_decode_bm(void)
|
||||
}
|
||||
}
|
||||
|
||||
m_dnad = host_r(machine(), false, m_dsp + 4);
|
||||
m_dnad = m_host_read(m_dsp + 4, 0xffffffff);
|
||||
m_dsp += 8;
|
||||
}
|
||||
|
||||
@ -1317,7 +1297,7 @@ void ncr53c7xx_device::scripts_decode_io(void)
|
||||
}
|
||||
|
||||
// Set some additional registers
|
||||
m_dnad = m_dsps = host_r(machine(), false, m_dsp + 4);
|
||||
m_dnad = m_dsps = m_host_read(m_dsp + 4, 0xffffffff);
|
||||
m_dsp += 8;
|
||||
}
|
||||
|
||||
@ -1352,7 +1332,7 @@ void ncr53c7xx_device::scripts_decode_tc(void)
|
||||
break;
|
||||
}
|
||||
|
||||
m_dnad = m_dsps = host_r(machine(), false, m_dsp + 4);
|
||||
m_dnad = m_dsps = m_host_read(m_dsp + 4, 0xffffffff);
|
||||
m_dsp += 8;
|
||||
}
|
||||
|
||||
@ -1411,7 +1391,7 @@ void ncr53c7xx_device::bm_i_wmov()
|
||||
|
||||
// Indirect addressing
|
||||
if (m_dcmd & (1 << 5))
|
||||
m_dnad = host_r(machine(), false, m_dnad);
|
||||
m_dnad = m_host_read(m_dnad, 0xffffffff);
|
||||
|
||||
// Compare the phase bits
|
||||
if ((scsi_bus->ctrl_r() & 7) == (m_dcmd & 7))
|
||||
|
@ -56,33 +56,35 @@
|
||||
#define DSTAT_ABRT 0x10
|
||||
#define DSTAT_DFE 0x80
|
||||
|
||||
#define MCFG_NCR53C7XX_IRQ_HANDLER(_devcb) \
|
||||
devcb = &ncr53c7xx_device::set_irq_handler(*device, DEVCB2_##_devcb);
|
||||
|
||||
struct NCR53C7XXinterface
|
||||
{
|
||||
devcb_write_line m_out_irq_cb;
|
||||
UINT32 (*host_r)(running_machine &machine, bool io, offs_t addr);
|
||||
void (*host_w)(running_machine &machine, bool io, offs_t addr, UINT32 data, UINT32 mem_mask);
|
||||
};
|
||||
#define MCFG_NCR53C7XX_HOST_WRITE(_devcb) \
|
||||
devcb = &ncr53c7xx_device::set_host_write(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_NCR53C7XX_HOST_READ(_devcb) \
|
||||
devcb = &ncr53c7xx_device::set_host_read(*device, DEVCB2_##_devcb);
|
||||
|
||||
class ncr53c7xx_device : public nscsi_device,
|
||||
public device_execute_interface,
|
||||
public NCR53C7XXinterface
|
||||
public device_execute_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
ncr53c7xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// static configuration helpers
|
||||
template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<ncr53c7xx_device &>(device).m_irq_handler.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_host_write(device_t &device, _Object object) { return downcast<ncr53c7xx_device &>(device).m_host_write.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_host_read(device_t &device, _Object object) { return downcast<ncr53c7xx_device &>(device).m_host_read.set_callback(object); }
|
||||
|
||||
// our API
|
||||
DECLARE_READ32_MEMBER(read);
|
||||
DECLARE_WRITE32_MEMBER(write);
|
||||
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_config_complete();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
virtual void execute_run();
|
||||
|
||||
@ -215,8 +217,9 @@ private:
|
||||
void (ncr53c7xx_device::*m_scripts_op)();
|
||||
|
||||
// callbacks
|
||||
devcb_resolved_write_line m_out_irq_func;
|
||||
devcb_resolved_write_line m_out_drq_func;
|
||||
devcb2_write_line m_irq_handler;
|
||||
devcb2_write32 m_host_write;
|
||||
devcb2_read32 m_host_read;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
|
@ -94,6 +94,10 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
|
||||
device_t *new_dev = device_add(&owner, intf[i].name, intf[i].devtype, slot->card_clock(selval));
|
||||
found = true;
|
||||
|
||||
machine_config_constructor additions = slot->card_machine_config(selval);
|
||||
if (additions != NULL)
|
||||
(*additions)(const_cast<machine_config &>(*this), new_dev);
|
||||
|
||||
const input_device_default *input_device_defaults = slot->card_input_device_defaults(selval);
|
||||
if (input_device_defaults)
|
||||
{
|
||||
|
@ -113,6 +113,8 @@ public:
|
||||
DECLARE_WRITE32_MEMBER(dsp_486_int_w);
|
||||
DECLARE_READ32_MEMBER(dsp_speedup_r);
|
||||
DECLARE_WRITE32_MEMBER(dsp_speedup_w);
|
||||
DECLARE_READ32_MEMBER(ncr53c700_read);
|
||||
DECLARE_WRITE32_MEMBER(ncr53c700_write);
|
||||
DECLARE_WRITE_LINE_MEMBER(scsi_irq);
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(tms_timer1);
|
||||
@ -831,24 +833,22 @@ INPUT_PORTS_END
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static UINT32 ncr53c700_r(running_machine &machine, bool io, offs_t addr)
|
||||
READ32_MEMBER(rastersp_state::ncr53c700_read)
|
||||
{
|
||||
rastersp_state *state = machine.driver_data<rastersp_state>();
|
||||
return state->m_maincpu->space(io ? AS_IO : AS_PROGRAM).read_dword(addr);
|
||||
return m_maincpu->space(AS_PROGRAM).read_dword(offset, mem_mask);
|
||||
}
|
||||
|
||||
static void ncr53c700_w(running_machine &machine, bool io, offs_t addr, UINT32 data, UINT32 mem_mask)
|
||||
WRITE32_MEMBER(rastersp_state::ncr53c700_write)
|
||||
{
|
||||
rastersp_state *state = machine.driver_data<rastersp_state>();
|
||||
state->m_maincpu->space(io ? AS_IO : AS_PROGRAM).write_dword(addr, data, mem_mask);
|
||||
m_maincpu->space(AS_PROGRAM).write_dword(offset, data, mem_mask);
|
||||
}
|
||||
|
||||
static const struct NCR53C7XXinterface ncr53c700_intf =
|
||||
{
|
||||
DEVCB_DRIVER_LINE_MEMBER(rastersp_state, scsi_irq),
|
||||
&ncr53c700_r,
|
||||
&ncr53c700_w,
|
||||
};
|
||||
static MACHINE_CONFIG_FRAGMENT( ncr53c700 )
|
||||
MCFG_DEVICE_MODIFY(DEVICE_SELF)
|
||||
MCFG_NCR53C7XX_IRQ_HANDLER(DEVWRITELINE(":", rastersp_state, scsi_irq))
|
||||
MCFG_NCR53C7XX_HOST_READ(DEVREAD32(":", rastersp_state, ncr53c700_read))
|
||||
MCFG_NCR53C7XX_HOST_WRITE(DEVWRITE32(":", rastersp_state, ncr53c700_write))
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
static SLOT_INTERFACE_START( rastersp_scsi_devices )
|
||||
SLOT_INTERFACE("harddisk", NSCSI_HARDDISK)
|
||||
@ -895,8 +895,8 @@ static MACHINE_CONFIG_START( rastersp, rastersp_state )
|
||||
MCFG_NSCSI_BUS_ADD("scsibus")
|
||||
MCFG_NSCSI_ADD("scsibus:0", rastersp_scsi_devices, "harddisk", true)
|
||||
MCFG_NSCSI_ADD("scsibus:7", rastersp_scsi_devices, "ncr53c700", true)
|
||||
MCFG_DEVICE_CARD_CONFIG("ncr53c700", &ncr53c700_intf)
|
||||
MCFG_DEVICE_CARD_CLOCK("ncr53c700", 66000000)
|
||||
MCFG_DEVICE_CARD_MACHINE_CONFIG("ncr53c700", ncr53c700)
|
||||
|
||||
/* Video */
|
||||
MCFG_SCREEN_ADD("screen", RASTER)
|
||||
|
Loading…
Reference in New Issue
Block a user