coco2: Converted all coco/dragon extension devices to use cts handlers.

This commit is contained in:
Nigel Barnes 2019-05-25 18:15:12 +01:00
parent 2b091f8c65
commit 4cdf369921
17 changed files with 225 additions and 111 deletions

View File

@ -41,6 +41,7 @@ namespace
: device_t(mconfig, COCO_DCMODEM, tag, owner, clock)
, device_cococart_interface(mconfig, *this)
, m_uart(*this, UART_TAG)
, m_eprom(*this, "eprom")
{
}
@ -67,17 +68,20 @@ namespace
// CoCo cartridge level overrides
virtual uint8_t *get_cart_base() override
{
return memregion("eprom")->base();
return m_eprom->base();
}
virtual memory_region* get_cart_memregion() override
{
return memregion("eprom");
return m_eprom;
}
virtual DECLARE_READ8_MEMBER(cts_read) override;
private:
// internal state
required_device<mos6551_device> m_uart;
required_memory_region m_eprom;
};
};
@ -118,4 +122,12 @@ const tiny_rom_entry *coco_dc_modem_device::device_rom_region() const
return ROM_NAME(coco_dcmodem);
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(coco_dc_modem_device::cts_read)
{
return m_eprom->base()[offset & 0x1fff];
}

View File

@ -11,7 +11,7 @@
which mostly uses the same command set with some subtle differences, most
notably the 2797 handles disk side select internally. The Dragon Alpha also
uses the WD2797, however as this is a built in interface and not an external
cartrige, it is dealt with in the main coco.cpp file.
cartridge, it is dealt with in the main coco.cpp file.
The wd's variables are mapped to $FF48-$FF4B on the CoCo and on $FF40-$FF43
on the Dragon. In addition, there is another register
@ -89,6 +89,7 @@ protected:
};
// device-level overrides
virtual DECLARE_READ8_MEMBER(cts_read) override;
virtual DECLARE_READ8_MEMBER(scs_read) override;
virtual DECLARE_WRITE8_MEMBER(scs_write) override;
virtual void device_add_mconfig(machine_config &config) override;
@ -311,6 +312,16 @@ void coco_fdc_device_base::dskreg_w(uint8_t data)
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(coco_fdc_device_base::cts_read)
{
return memregion("eprom")->base()[offset];
}
//-------------------------------------------------
// scs_read
//-------------------------------------------------

View File

@ -102,6 +102,8 @@ namespace
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual READ8_MEMBER(cts_read) override;
virtual WRITE8_MEMBER(cts_write) override;
virtual READ8_MEMBER(scs_read) override;
virtual WRITE8_MEMBER(scs_write) override;
virtual void set_sound_enable(bool sound_enable) override;
@ -355,13 +357,8 @@ void coco_multipak_device::set_select(uint8_t new_select)
cococart_slot_device::line_value old_cart = active_cts_slot().get_line_value(line::CART);
// change value
uint8_t xorval = m_select ^ new_select;
m_select = new_select;
// did the cartridge base change?
if (xorval & 0x03)
cart_base_changed();
// did the CART line change?
line_value new_cart = active_cts_slot().get_line_value(line::CART);
if (new_cart != old_cart)
@ -454,6 +451,26 @@ uint32_t coco_multipak_device::get_cart_size()
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(coco_multipak_device::cts_read)
{
return active_cts_slot().cts_read(space, offset);
}
//-------------------------------------------------
// cts_write
//-------------------------------------------------
WRITE8_MEMBER(coco_multipak_device::cts_write)
{
active_cts_slot().cts_write(space, offset, data);
}
//-------------------------------------------------
// scs_read
//-------------------------------------------------

View File

@ -21,7 +21,7 @@
addressing CPU registers to run the 6809 at 2x speed.
"P" + "ENTER" will play at regular CPU speed. The difference should be
very noticable.
very noticeable.
***************************************************************************/
@ -61,6 +61,7 @@ namespace
coco_orch90_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, COCO_ORCH90, tag, owner, clock)
, device_cococart_interface(mconfig, *this)
, m_eprom(*this, "eprom")
, m_ldac(*this, "ldac")
, m_rdac(*this, "rdac")
{
@ -89,19 +90,22 @@ namespace
// CoCo cartridge level overrides
virtual uint8_t *get_cart_base() override
{
return memregion("eprom")->base();
return m_eprom->base();
}
virtual memory_region* get_cart_memregion() override
{
return memregion("eprom");
return m_eprom;
}
virtual DECLARE_READ8_MEMBER(cts_read) override;
private:
WRITE8_MEMBER(write_left) { m_ldac->write(data); }
WRITE8_MEMBER(write_right) { m_rdac->write(data); }
// internal state
required_memory_region m_eprom;
required_device<dac_byte_interface> m_ldac;
required_device<dac_byte_interface> m_rdac;
};
@ -123,6 +127,15 @@ void coco_orch90_device::device_add_mconfig(machine_config &config)
vref.add_route(0, "rdac", 1.0, DAC_VREF_POS_INPUT); vref.add_route(0, "rdac", -1.0, DAC_VREF_NEG_INPUT);
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(coco_orch90_device::cts_read)
{
return m_eprom->base()[offset & 0x1fff];
}
//**************************************************************************
// DEVICE DECLARATION

View File

@ -58,7 +58,7 @@ DEFINE_DEVICE_TYPE(COCO_PAK, coco_pak_device, "cocopak", "CoCo Program PAK")
coco_pak_device::coco_pak_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
, device_cococart_interface(mconfig, *this)
, m_cart(nullptr), m_autostart(*this, CART_AUTOSTART_TAG)
, m_cart(nullptr), m_eprom(*this, CARTSLOT_TAG), m_autostart(*this, CART_AUTOSTART_TAG)
{
}
@ -127,7 +127,7 @@ void coco_pak_device::device_reset()
uint8_t* coco_pak_device::get_cart_base()
{
return memregion(CARTSLOT_TAG)->base();
return m_eprom->base();
}
/*-------------------------------------------------
@ -136,7 +136,19 @@ uint8_t* coco_pak_device::get_cart_base()
memory_region* coco_pak_device::get_cart_memregion()
{
return memregion(CARTSLOT_TAG);
return m_eprom;
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(coco_pak_device::cts_read)
{
if (offset < m_eprom->bytes())
return m_eprom->base()[offset];
else
return 0x00;
}
@ -198,7 +210,6 @@ void coco_pak_banked_device::device_reset()
coco_pak_device::device_reset();
m_pos = 0;
cart_base_changed();
}
//-------------------------------------------------
@ -207,10 +218,7 @@ void coco_pak_banked_device::device_reset()
uint8_t *coco_pak_banked_device::get_cart_base()
{
uint8_t *rom = memregion(CARTSLOT_TAG)->base();
uint32_t rom_length = memregion(CARTSLOT_TAG)->bytes();
return &rom[(m_pos * 0x4000) % rom_length];
return m_eprom->base() + (m_pos * 0x4000) % m_eprom->bytes();
}
//-------------------------------------------------
@ -222,6 +230,15 @@ uint32_t coco_pak_banked_device::get_cart_size()
return 0x4000;
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(coco_pak_banked_device::cts_read)
{
return m_eprom->base()[(m_pos * 0x4000) % m_eprom->bytes() | offset];
}
//-------------------------------------------------
// scs_write
//-------------------------------------------------

View File

@ -35,10 +35,11 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual DECLARE_READ8_MEMBER(cts_read) override;
// internal state
device_image_interface *m_cart;
required_memory_region m_eprom;
optional_ioport m_autostart;
};
@ -60,6 +61,7 @@ protected:
virtual void device_reset() override;
virtual uint8_t *get_cart_base() override;
virtual uint32_t get_cart_size() override;
virtual DECLARE_READ8_MEMBER(cts_read) override;
virtual DECLARE_WRITE8_MEMBER(scs_write) override;
private:

View File

@ -39,6 +39,7 @@ namespace
coco_rs232_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, COCO_RS232, tag, owner, clock)
, device_cococart_interface(mconfig, *this)
, m_eprom(*this, "eprom")
, m_uart(*this, UART_TAG)
{
}
@ -65,16 +66,19 @@ namespace
// CoCo cartridge level overrides
virtual uint8_t *get_cart_base() override
{
return memregion("eprom")->base();
return m_eprom->base();
}
virtual memory_region* get_cart_memregion() override
{
return memregion("eprom");
return m_eprom;
}
virtual DECLARE_READ8_MEMBER(cts_read) override;
private:
// internal state
required_memory_region m_eprom;
required_device<mos6551_device> m_uart;
};
};
@ -112,6 +116,15 @@ const tiny_rom_entry *coco_rs232_device::device_rom_region() const
return ROM_NAME(coco_rs232_device);
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(coco_rs232_device::cts_read)
{
return m_eprom->base()[offset & 0x0fff];
}
//**************************************************************************
// DEVICE DECLARATION
//**************************************************************************

View File

@ -129,17 +129,18 @@ namespace
optional_ioport m_autostart;
virtual DECLARE_READ8_MEMBER(cts_read) override;
virtual DECLARE_READ8_MEMBER(scs_read) override;
virtual DECLARE_WRITE8_MEMBER(scs_write) override;
private:
// internal state
required_memory_region m_eprom;
required_memory_region m_eprom_banked;
required_device<acia6850_device> m_uart;
required_device<pia6821_device> m_pia;
required_device<mc14411_device> m_brg;
required_ioport m_serial_baud;
void set_bank();
};
};
@ -241,6 +242,8 @@ coco_t4426_device::coco_t4426_device(const machine_config &mconfig, device_type
, m_cart(nullptr)
, m_select(0)
, m_autostart(*this, CART_AUTOSTART_TAG)
, m_eprom(*this, CARTSLOT_TAG)
, m_eprom_banked(*this, CARTBANK_TAG)
, m_uart(*this, UART_TAG)
, m_pia(*this, PIA_TAG)
, m_brg(*this, BRG_TAG)
@ -293,7 +296,7 @@ void coco_t4426_device::device_reset()
LOG("%s()\n", FUNCNAME );
auto cart_line = line_value::Q;
set_line_value(line::CART, cart_line);
set_bank();
m_select = 0x00;
// Set up the BRG divider statically to X1
m_brg->rsa_w( ASSERT_LINE );
@ -398,26 +401,39 @@ WRITE8_MEMBER( coco_t4426_device::pia_A_w )
{
LOGPIA("%s(%02x)\n", FUNCNAME, data);
m_select = data;
set_bank();
}
void coco_t4426_device::set_bank()
{
uint8_t *cartbase = memregion(CARTSLOT_TAG)->base();
uint8_t *bankbase = memregion(CARTBANK_TAG)->base();
/*-------------------------------------------------
cts_read
-------------------------------------------------*/
READ8_MEMBER(coco_t4426_device::cts_read)
{
uint8_t result = 0x00;
switch (offset & 0x2000)
{
case 0x0000:
switch (m_select)
{
case 0:
case ROM0:memcpy(cartbase, bankbase + 0x0000, 0x2000); break;
case ROM1:memcpy(cartbase, bankbase + 0x2000, 0x2000); break;
case ROM2:memcpy(cartbase, bankbase + 0x4000, 0x2000); break;
case ROM3:memcpy(cartbase, bankbase + 0x6000, 0x2000); break;
case ROM4:memcpy(cartbase, bankbase + 0x8000, 0x2000); break;
case ROM5:memcpy(cartbase, bankbase + 0xa000, 0x2000); break;
case ROM6:memcpy(cartbase, bankbase + 0xc000, 0x2000); break;
case ROM7:memcpy(cartbase, bankbase + 0xe000, 0x2000); break;
case ROM0:result = m_eprom_banked->base()[0x0000 | offset]; break;
case ROM1:result = m_eprom_banked->base()[0x2000 | offset]; break;
case ROM2:result = m_eprom_banked->base()[0x4000 | offset]; break;
case ROM3:result = m_eprom_banked->base()[0x6000 | offset]; break;
case ROM4:result = m_eprom_banked->base()[0x8000 | offset]; break;
case ROM5:result = m_eprom_banked->base()[0xa000 | offset]; break;
case ROM6:result = m_eprom_banked->base()[0xc000 | offset]; break;
case ROM7:result = m_eprom_banked->base()[0xe000 | offset]; break;
}
break;
case 0x2000:
result = m_eprom->base()[offset];
break;
}
return result;
}
/*-------------------------------------------------

View File

@ -532,12 +532,6 @@ void device_cococart_interface::interface_pre_start()
READ8_MEMBER(device_cococart_interface::cts_read)
{
memory_region *cart_mem = get_cart_memregion();
offs_t cart_length = cart_mem->bytes();
if (cart_mem)
return cart_mem->base()[offset & (cart_length - 1)];
else
return 0x00;
}

View File

@ -99,6 +99,7 @@ namespace
dragon_fdc_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
virtual DECLARE_READ8_MEMBER(cts_read) override;
virtual DECLARE_READ8_MEMBER(scs_read) override;
virtual DECLARE_WRITE8_MEMBER(scs_write) override;
virtual void device_add_mconfig(machine_config &config) override;
@ -120,6 +121,7 @@ namespace
premier_fdc_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
virtual DECLARE_READ8_MEMBER(cts_read) override;
virtual DECLARE_READ8_MEMBER(scs_read) override;
virtual DECLARE_WRITE8_MEMBER(scs_write) override;
virtual void device_add_mconfig(machine_config &config) override;
@ -287,6 +289,22 @@ void premier_fdc_device_base::dskreg_w(uint8_t data)
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(dragon_fdc_device_base::cts_read)
{
return memregion("eprom")->base()[offset];
}
READ8_MEMBER(premier_fdc_device_base::cts_read)
{
return memregion("eprom")->base()[offset];
}
//-------------------------------------------------
// scs_read
//-------------------------------------------------

View File

@ -43,6 +43,7 @@ DEFINE_DEVICE_TYPE(DRAGON_JCBSND, dragon_jcbsnd_device, "dragon_jcbsnd", "Dragon
dragon_jcbsnd_device::dragon_jcbsnd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, DRAGON_JCBSND, tag, owner, clock)
, device_cococart_interface(mconfig, *this )
, m_eprom(*this, "eprom")
, m_ay8910(*this, "ay8910")
{
}
@ -65,7 +66,7 @@ void dragon_jcbsnd_device::device_start()
uint8_t* dragon_jcbsnd_device::get_cart_base()
{
return memregion("eprom")->base();
return m_eprom->base();
}
//-------------------------------------------------
@ -74,7 +75,7 @@ uint8_t* dragon_jcbsnd_device::get_cart_base()
memory_region* dragon_jcbsnd_device::get_cart_memregion()
{
return memregion("eprom");
return m_eprom;
}
//-------------------------------------------------
@ -96,3 +97,12 @@ const tiny_rom_entry *dragon_jcbsnd_device::device_rom_region() const
{
return ROM_NAME( dragon_jcbsnd );
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
READ8_MEMBER(dragon_jcbsnd_device::cts_read)
{
return m_eprom->base()[offset & 0x1fff];
}

View File

@ -31,9 +31,12 @@ protected:
virtual uint8_t* get_cart_base() override;
virtual memory_region* get_cart_memregion() override;
virtual DECLARE_READ8_MEMBER(cts_read) override;
// internal state
device_image_interface *m_cart;
private:
required_memory_region m_eprom;
required_device<ay8910_device> m_ay8910;
};

View File

@ -161,7 +161,7 @@ protected:
// miscellaneous
virtual void update_keyboard_input(uint8_t value, uint8_t z);
virtual void cart_w(bool state);
virtual void update_cart_base(uint8_t *cart_base) = 0;
virtual void update_cart_base(uint8_t *cart_base) { };
protected:
// timer constants

View File

@ -61,7 +61,6 @@ public:
void coco(machine_config &config);
protected:
virtual void device_start() override;
virtual void update_cart_base(uint8_t *cart_base) override;
// PIA1
virtual void pia1_pb_changed(uint8_t data) override;

View File

@ -68,7 +68,7 @@ DEFINE_DEVICE_TYPE(SAM6883, sam6883_device, "sam6883", "MC6883 SAM")
//**************************************************************************
//-------------------------------------------------
// ctor
// constructor
//-------------------------------------------------
sam6883_device::sam6883_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
@ -85,6 +85,7 @@ sam6883_device::sam6883_device(const machine_config &mconfig, const char *tag, d
, m_space_FF40(*this)
, m_space_FF60(*this)
, m_space_FFE0(*this)
, m_space_FFF2(*this)
{
}
@ -157,7 +158,7 @@ void sam6883_device::configure_bank(int bank, uint8_t *memory, uint32_t memory_s
switch(bank)
{
case 3:
m_space_C000.point(m_banks[3], m_banks[3].m_memory_offset);
m_space_C000.point(m_banks[3], 0x0000);
break;
case 4:
m_space_FF00.point(m_banks[4], 0x0000);
@ -173,6 +174,7 @@ void sam6883_device::configure_bank(int bank, uint8_t *memory, uint32_t memory_s
break;
case 2:
m_space_FFE0.point(m_banks[2], 0x1FE0);
m_space_FFF2.point(m_banks[2], 0x1FF2);
break;
}
}
@ -264,8 +266,9 @@ void sam6883_device::update_memory(void)
break;
case SAM_STATE_M1:
// 64k mode (dynamic)
case SAM_STATE_M1|SAM_STATE_M0:
// 64k mode
// 64k mode (static)
if (m_sam_state & SAM_STATE_TY)
{
// full 64k RAM
@ -293,8 +296,8 @@ void sam6883_device::update_memory(void)
m_space_C000.point(m_banks[3], m_banks[3].m_memory_offset);
}
// update $FFE0-$FFFF
m_space_FFE0.point(m_banks[2], m_banks[2].m_memory_offset + 0x1FE0);
// update $FFF2-$FFFF
m_space_FFF2.point(m_banks[2], m_banks[2].m_memory_offset + 0x1FF2);
}
@ -442,7 +445,7 @@ WRITE_LINE_MEMBER( sam6883_device::hs_w )
//-------------------------------------------------
// sam_space::ctor
// sam_space::constructor
//-------------------------------------------------
template<uint16_t _addrstart, uint16_t _addrend>
@ -506,9 +509,6 @@ void sam6883_device::sam_space<_addrstart, _addrend>::point_specific_bank(const
if (length != ~0)
length -= std::min(offset, length);
// do we even have a bank? and if so, have legit changes occured?
if (!memory_bank || !memory_bank->matches_exactly(addrstart, addrend) || (length != m_length))
{
// name the bank
auto tag = string_format("bank%04X_%c", addrstart, is_write ? 'w' : 'r');
@ -537,7 +537,6 @@ void sam6883_device::sam_space<_addrstart, _addrend>::point_specific_bank(const
// and get it
memory_bank = cpu_space().device().owner()->membank(tag.c_str());
}
// point the bank
if (memory_bank != nullptr)
@ -551,7 +550,7 @@ void sam6883_device::sam_space<_addrstart, _addrend>::point_specific_bank(const
else
{
// this bank uses handlers - first thing's first, assert that we are not doing
// any weird stuff with offfsets and lengths - that isn't supported in this path
// any weird stuff with offsets and lengths - that isn't supported in this path
assert((offset == 0) && (length == (uint32_t)~0));
if (is_write)

View File

@ -175,7 +175,8 @@ private:
sam_space<0xFF20, 0xFF3F> m_space_FF20;
sam_space<0xFF40, 0xFF5F> m_space_FF40;
sam_space<0xFF60, 0xFFBF> m_space_FF60;
sam_space<0xFFE0, 0xFFFF> m_space_FFE0;
sam_space<0xFFE0, 0xFFF1> m_space_FFE0;
sam_space<0xFFF2, 0xFFFF> m_space_FFF2;
uint16_t m_counter_mask;
// SAM state

View File

@ -105,14 +105,3 @@ void coco12_state::pia1_pb_changed(uint8_t data)
m_vdg->gm2_w(data & 0x40);
m_vdg->ag_w(data & 0x80);
}
//-------------------------------------------------
// update_cart_base
//-------------------------------------------------
void coco12_state::update_cart_base(uint8_t *cart_base)
{
m_sam->configure_bank(3, cart_base, 0x4000, true); // $C000-$FEFF
}