mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
mos8722: devcb2. (nw)
This commit is contained in:
parent
5a54c5cb7d
commit
647886b12d
@ -13,6 +13,14 @@
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
const device_type MOS8722 = &device_creator<mos8722_device>;
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACROS / CONSTANTS
|
||||
//**************************************************************************
|
||||
@ -20,39 +28,6 @@
|
||||
#define LOG 0
|
||||
|
||||
|
||||
// registers
|
||||
enum
|
||||
{
|
||||
CR = 0,
|
||||
PCRA, LCRA = PCRA,
|
||||
PCRB, LCRB = PCRB,
|
||||
PCRC, LCRC = PCRC,
|
||||
PCRD, LCRD = PCRD,
|
||||
MCR,
|
||||
RCR,
|
||||
P0L,
|
||||
P0H,
|
||||
P1L,
|
||||
P1H,
|
||||
VR
|
||||
};
|
||||
|
||||
|
||||
// configuration register
|
||||
enum
|
||||
{
|
||||
CR_IO_SYSTEM_IO = 0,
|
||||
CR_IO_HI_ROM
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CR_ROM_SYSTEM_ROM = 0,
|
||||
CR_ROM_INT_FUNC_ROM,
|
||||
CR_ROM_EXT_FUNC_ROM,
|
||||
CR_ROM_RAM
|
||||
};
|
||||
|
||||
#define CR_IO BIT(m_reg[CR], 0)
|
||||
#define CR_ROM_LO BIT(m_reg[CR], 1)
|
||||
#define CR_ROM_MID ((m_reg[CR] >> 2) & 0x03)
|
||||
@ -73,14 +48,6 @@ enum
|
||||
static const offs_t RCR_BOTTOM_ADDRESS[4] = { 0x0400, 0x1000, 0x0400, 0x1000 };
|
||||
static const offs_t RCR_TOP_ADDRESS[4] = { 0xf000, 0xf000, 0xe000, 0xc000 };
|
||||
|
||||
enum
|
||||
{
|
||||
RCR_SHARE_1K = 0,
|
||||
RCR_SHARE_4K,
|
||||
RCR_SHARE_8K,
|
||||
RCR_SHARE_16K
|
||||
};
|
||||
|
||||
#define RCR_SHARE (m_reg[RCR] & 0x03)
|
||||
#define RCR_BOTTOM BIT(m_reg[RCR], 2)
|
||||
#define RCR_TOP BIT(m_reg[RCR], 3)
|
||||
@ -96,13 +63,6 @@ enum
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
const device_type MOS8722 = &device_creator<mos8722_device>;
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
@ -111,37 +71,17 @@ const device_type MOS8722 = &device_creator<mos8722_device>;
|
||||
// mos8722_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
mos8722_device::mos8722_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, MOS8722, "MOS8722", tag, owner, clock, "mos8722", __FILE__)
|
||||
mos8722_device::mos8722_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, MOS8722, "MOS8722", tag, owner, clock, "mos8722", __FILE__),
|
||||
m_write_z80en(*this),
|
||||
m_write_fsdir(*this),
|
||||
m_read_game(*this),
|
||||
m_read_exrom(*this),
|
||||
m_read_sense40(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void mos8722_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const mos8722_interface *intf = reinterpret_cast<const mos8722_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<mos8722_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_out_z80en_cb, 0, sizeof(m_out_z80en_cb));
|
||||
memset(&m_out_fsdir_cb, 0, sizeof(m_out_fsdir_cb));
|
||||
memset(&m_in_game_cb, 0, sizeof(m_in_game_cb));
|
||||
memset(&m_in_exrom_cb, 0, sizeof(m_in_exrom_cb));
|
||||
memset(&m_in_sense40_cb, 0, sizeof(m_in_sense40_cb));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
@ -149,11 +89,11 @@ void mos8722_device::device_config_complete()
|
||||
void mos8722_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_out_z80en_func.resolve(m_out_z80en_cb, *this);
|
||||
m_out_fsdir_func.resolve(m_out_fsdir_cb, *this);
|
||||
m_in_game_func.resolve(m_in_game_cb, *this);
|
||||
m_in_exrom_func.resolve(m_in_exrom_cb, *this);
|
||||
m_in_sense40_func.resolve(m_in_sense40_cb, *this);
|
||||
m_write_z80en.resolve_safe();
|
||||
m_write_fsdir.resolve_safe();
|
||||
m_read_game.resolve_safe(1);
|
||||
m_read_exrom.resolve_safe(1);
|
||||
m_read_sense40.resolve_safe(1);
|
||||
}
|
||||
|
||||
|
||||
@ -173,8 +113,8 @@ void mos8722_device::device_reset()
|
||||
m_p0h_latch = 0;
|
||||
m_p1h_latch = 0;
|
||||
|
||||
m_out_z80en_func(MCR_8500);
|
||||
m_out_fsdir_func(MCR_FSDIR);
|
||||
m_write_z80en(MCR_8500);
|
||||
m_write_fsdir(MCR_FSDIR);
|
||||
}
|
||||
|
||||
|
||||
@ -197,9 +137,9 @@ UINT8 mos8722_device::read(offs_t offset, UINT8 data)
|
||||
case MCR:
|
||||
data = m_reg[MCR] | 0x06;
|
||||
|
||||
data &= ((m_in_game_func() << 4) | ~0x10);
|
||||
data &= ((m_in_exrom_func() << 5) | ~0x20);
|
||||
data &= ((m_in_sense40_func() << 7) | ~0x80);
|
||||
data &= ((m_read_game() << 4) | ~0x10);
|
||||
data &= ((m_read_exrom() << 5) | ~0x20);
|
||||
data &= ((m_read_sense40() << 7) | ~0x80);
|
||||
break;
|
||||
|
||||
case VR:
|
||||
@ -261,8 +201,8 @@ WRITE8_MEMBER( mos8722_device::write )
|
||||
|
||||
m_reg[MCR] = data;
|
||||
|
||||
if (_8500 != MCR_8500) m_out_z80en_func(MCR_8500);
|
||||
if (fsdir != MCR_FSDIR) m_out_fsdir_func(MCR_FSDIR);
|
||||
if (_8500 != MCR_8500) m_write_z80en(MCR_8500);
|
||||
if (fsdir != MCR_FSDIR) m_write_fsdir(MCR_FSDIR);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -49,13 +49,20 @@
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_MOS8722_ADD(_tag, _config) \
|
||||
MCFG_DEVICE_ADD(_tag, MOS8722, 0) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
#define MCFG_MOS8722_Z80EN_CALLBACK(_write) \
|
||||
devcb = &mos8722_device::set_z80en_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define MCFG_MOS8722_FSDIR_CALLBACK(_write) \
|
||||
devcb = &mos8722_device::set_fsdir_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
#define MOS8722_INTERFACE(name) \
|
||||
const mos8722_interface (name) =
|
||||
#define MCFG_MOS8722_GAME_CALLBACK(_read) \
|
||||
devcb = &mos8722_device::set_game_rd_callback(*device, DEVCB2_##_read);
|
||||
|
||||
#define MCFG_MOS8722_EXROM_CALLBACK(_read) \
|
||||
devcb = &mos8722_device::set_exrom_rd_callback(*device, DEVCB2_##_read);
|
||||
|
||||
#define MCFG_MOS8722_SENSE40_CALLBACK(_read) \
|
||||
devcb = &mos8722_device::set_sense40_rd_callback(*device, DEVCB2_##_read);
|
||||
|
||||
|
||||
|
||||
@ -63,27 +70,21 @@
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> mos8722_interface
|
||||
|
||||
struct mos8722_interface
|
||||
{
|
||||
devcb_write_line m_out_z80en_cb;
|
||||
devcb_write_line m_out_fsdir_cb;
|
||||
devcb_read_line m_in_game_cb;
|
||||
devcb_read_line m_in_exrom_cb;
|
||||
devcb_read_line m_in_sense40_cb;
|
||||
};
|
||||
|
||||
|
||||
// ======================> mos8722_device
|
||||
|
||||
class mos8722_device : public device_t,
|
||||
public mos8722_interface
|
||||
class mos8722_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
mos8722_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
template<class _Object> static devcb2_base &set_z80en_wr_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_write_z80en.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_fsdir_wr_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_write_fsdir.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_game_rd_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_read_game.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_exrom_rd_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_read_exrom.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_sense40_rd_callback(device_t &device, _Object object) { return downcast<mos8722_device &>(device).m_read_sense40.set_callback(object); }
|
||||
|
||||
|
||||
UINT8 read(offs_t offset, UINT8 data);
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
|
||||
@ -93,16 +94,53 @@ public:
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
private:
|
||||
devcb_resolved_write_line m_out_z80en_func;
|
||||
devcb_resolved_write_line m_out_fsdir_func;
|
||||
devcb_resolved_read_line m_in_game_func;
|
||||
devcb_resolved_read_line m_in_exrom_func;
|
||||
devcb_resolved_read_line m_in_sense40_func;
|
||||
enum
|
||||
{
|
||||
CR = 0,
|
||||
PCRA, LCRA = PCRA,
|
||||
PCRB, LCRB = PCRB,
|
||||
PCRC, LCRC = PCRC,
|
||||
PCRD, LCRD = PCRD,
|
||||
MCR,
|
||||
RCR,
|
||||
P0L,
|
||||
P0H,
|
||||
P1L,
|
||||
P1H,
|
||||
VR
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CR_IO_SYSTEM_IO = 0,
|
||||
CR_IO_HI_ROM
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CR_ROM_SYSTEM_ROM = 0,
|
||||
CR_ROM_INT_FUNC_ROM,
|
||||
CR_ROM_EXT_FUNC_ROM,
|
||||
CR_ROM_RAM
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RCR_SHARE_1K = 0,
|
||||
RCR_SHARE_4K,
|
||||
RCR_SHARE_8K,
|
||||
RCR_SHARE_16K
|
||||
};
|
||||
|
||||
devcb2_write_line m_write_z80en;
|
||||
devcb2_write_line m_write_fsdir;
|
||||
devcb2_read_line m_read_game;
|
||||
devcb2_read_line m_read_exrom;
|
||||
devcb2_read_line m_read_sense40;
|
||||
|
||||
UINT8 m_reg[16];
|
||||
|
||||
|
@ -860,15 +860,6 @@ READ_LINE_MEMBER( c128_state::mmu_sense40_r )
|
||||
return BIT(m_40_80->read(), 0);
|
||||
}
|
||||
|
||||
static MOS8722_INTERFACE( mmu_intf )
|
||||
{
|
||||
DEVCB_DRIVER_LINE_MEMBER(c128_state, mmu_z80en_w),
|
||||
DEVCB_DRIVER_LINE_MEMBER(c128_state, mmu_fsdir_w),
|
||||
DEVCB_DRIVER_LINE_MEMBER(c128_state, mmu_game_r),
|
||||
DEVCB_DRIVER_LINE_MEMBER(c128_state, mmu_exrom_r),
|
||||
DEVCB_DRIVER_LINE_MEMBER(c128_state, mmu_sense40_r)
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// mc6845_interface vdc_intf
|
||||
@ -1478,7 +1469,12 @@ static MACHINE_CONFIG_START( ntsc, c128_state )
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
||||
|
||||
// devices
|
||||
MCFG_MOS8722_ADD(MOS8722_TAG, mmu_intf)
|
||||
MCFG_DEVICE_ADD(MOS8722_TAG, MOS8722, 0)
|
||||
MCFG_MOS8722_Z80EN_CALLBACK(WRITELINE(c128_state, mmu_z80en_w))
|
||||
MCFG_MOS8722_FSDIR_CALLBACK(WRITELINE(c128_state, mmu_fsdir_w))
|
||||
MCFG_MOS8722_GAME_CALLBACK(READLINE(c128_state, mmu_game_r))
|
||||
MCFG_MOS8722_EXROM_CALLBACK(READLINE(c128_state, mmu_exrom_r))
|
||||
MCFG_MOS8722_SENSE40_CALLBACK(READLINE(c128_state, mmu_sense40_r))
|
||||
MCFG_MOS8721_ADD(MOS8721_TAG)
|
||||
MCFG_MOS6526_ADD(MOS6526_1_TAG, VIC6567_CLOCK, 60, WRITELINE(c128_state, cia1_irq_w))
|
||||
MCFG_MOS6526_SERIAL_CALLBACKS(WRITELINE(c128_state, cia1_cnt_w), WRITELINE(c128_state, cia1_sp_w))
|
||||
@ -1611,7 +1607,12 @@ static MACHINE_CONFIG_START( pal, c128_state )
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
||||
|
||||
// devices
|
||||
MCFG_MOS8722_ADD(MOS8722_TAG, mmu_intf)
|
||||
MCFG_DEVICE_ADD(MOS8722_TAG, MOS8722, 0)
|
||||
MCFG_MOS8722_Z80EN_CALLBACK(WRITELINE(c128_state, mmu_z80en_w))
|
||||
MCFG_MOS8722_FSDIR_CALLBACK(WRITELINE(c128_state, mmu_fsdir_w))
|
||||
MCFG_MOS8722_GAME_CALLBACK(READLINE(c128_state, mmu_game_r))
|
||||
MCFG_MOS8722_EXROM_CALLBACK(READLINE(c128_state, mmu_exrom_r))
|
||||
MCFG_MOS8722_SENSE40_CALLBACK(READLINE(c128_state, mmu_sense40_r))
|
||||
MCFG_MOS8721_ADD(MOS8721_TAG)
|
||||
MCFG_MOS6526_ADD(MOS6526_1_TAG, VIC6569_CLOCK, 50, WRITELINE(c128_state, cia1_irq_w))
|
||||
MCFG_MOS6526_SERIAL_CALLBACKS(WRITELINE(c128_state, cia1_cnt_w), WRITELINE(c128_state, cia1_sp_w))
|
||||
|
Loading…
Reference in New Issue
Block a user