(MESS) amstrad: Added preliminary support for the PlayCity.

This commit is contained in:
mahlemiut 2014-11-01 16:01:45 +13:00
parent 9f236592c7
commit ed94243929
6 changed files with 227 additions and 0 deletions

View File

@ -1294,6 +1294,7 @@ BUSOBJS += $(BUSOBJ)/cpc/cpc_rs232.o
BUSOBJS += $(BUSOBJ)/cpc/mface2.o
BUSOBJS += $(BUSOBJ)/cpc/symbfac2.o
BUSOBJS += $(BUSOBJ)/cpc/amdrum.o
BUSOBJS += $(BUSOBJ)/cpc/playcity.o
endif
#-------------------------------------------------

156
src/emu/bus/cpc/playcity.c Normal file
View File

@ -0,0 +1,156 @@
/*
PlayCity expansion device
Z80 CTC
2x YMZ294 (clocks provided by CTC)
*/
#include "playcity.h"
#include "includes/amstrad.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type CPC_PLAYCITY = &device_creator<cpc_playcity_device>;
// device machine config
static MACHINE_CONFIG_FRAGMENT( cpc_playcity )
MCFG_DEVICE_ADD("ctc", Z80CTC, XTAL_4MHz)
MCFG_Z80CTC_ZC1_CB(WRITELINE(cpc_playcity_device,ctc_zc1_cb))
MCFG_Z80CTC_ZC2_CB(WRITELINE(cpc_playcity_device,ctc_zc2_cb))
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("ymz_1",YMZ294,XTAL_4MHz) // when timer is not set, operates at 4MHz (interally divided by 2, so equivalent to the ST)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
MCFG_SOUND_ADD("ymz_2",YMZ294,XTAL_4MHz)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
// pass-through
MCFG_DEVICE_ADD("exp", CPC_EXPANSION_SLOT, 0)
MCFG_DEVICE_SLOT_INTERFACE(cpc_exp_cards, NULL, false)
MCFG_CPC_EXPANSION_SLOT_OUT_IRQ_CB(DEVWRITELINE("^", cpc_expansion_slot_device, irq_w))
MCFG_CPC_EXPANSION_SLOT_OUT_NMI_CB(DEVWRITELINE("^", cpc_expansion_slot_device, nmi_w))
MCFG_CPC_EXPANSION_SLOT_OUT_ROMDIS_CB(DEVWRITELINE("^", cpc_expansion_slot_device, romdis_w)) // ROMDIS
MACHINE_CONFIG_END
machine_config_constructor cpc_playcity_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( cpc_playcity );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
cpc_playcity_device::cpc_playcity_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, CPC_PLAYCITY, "PlayCity", tag, owner, clock, "cpc_playcity", __FILE__),
device_cpc_expansion_card_interface(mconfig, *this),
m_ctc(*this,"ctc"),
m_ymz1(*this,"ymz_1"),
m_ymz2(*this,"ymz_2")
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void cpc_playcity_device::device_start()
{
device_t* cpu = machine().device("maincpu");
address_space& space = cpu->memory().space(AS_IO);
m_slot = dynamic_cast<cpc_expansion_slot_device *>(owner());
space.install_readwrite_handler(0xf880,0xf883,0,0,read8_delegate(FUNC(cpc_playcity_device::ctc_r),this),write8_delegate(FUNC(cpc_playcity_device::ctc_w),this));
space.install_readwrite_handler(0xf884,0xf884,0,0,read8_delegate(FUNC(cpc_playcity_device::ymz1_data_r),this),write8_delegate(FUNC(cpc_playcity_device::ymz1_data_w),this));
space.install_readwrite_handler(0xf888,0xf888,0,0,read8_delegate(FUNC(cpc_playcity_device::ymz2_data_r),this),write8_delegate(FUNC(cpc_playcity_device::ymz2_data_w),this));
space.install_write_handler(0xf984,0xf984,0,0,write8_delegate(FUNC(cpc_playcity_device::ymz1_address_w),this));
space.install_write_handler(0xf988,0xf988,0,0,write8_delegate(FUNC(cpc_playcity_device::ymz2_address_w),this));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void cpc_playcity_device::device_reset()
{
}
READ8_MEMBER(cpc_playcity_device::ctc_r)
{
return m_ctc->read(space,offset);
}
WRITE8_MEMBER(cpc_playcity_device::ctc_w)
{
m_ctc->write(space,offset,data);
update_ymz_clock();
}
WRITE8_MEMBER(cpc_playcity_device::ymz1_address_w)
{
m_ymz1->address_w(space,offset,data);
}
WRITE8_MEMBER(cpc_playcity_device::ymz2_address_w)
{
m_ymz2->address_w(space,offset,data);
}
WRITE8_MEMBER(cpc_playcity_device::ymz1_data_w)
{
m_ymz1->data_w(space,offset,data);
}
WRITE8_MEMBER(cpc_playcity_device::ymz2_data_w)
{
m_ymz2->data_w(space,offset,data);
}
READ8_MEMBER(cpc_playcity_device::ymz1_data_r)
{
return m_ymz1->data_r(space,offset);
}
READ8_MEMBER(cpc_playcity_device::ymz2_data_r)
{
return m_ymz2->data_r(space,offset);
}
void cpc_playcity_device::update_ymz_clock()
{
// Bit of a hack job here, since there is no way currently to connect the CTC channel output directly to the YMZ clocks.
UINT8 rate = m_ctc->get_channel_constant(0);
UINT64 clk = XTAL_4MHz;
switch(rate)
{
case 0x00: clk = 3980000; break;
case 0x01: clk = 2000000; break;
case 0x02: clk = 3000000; break;
case 0x03: clk = 3330000; break;
case 0x04: clk = 3500000; break;
case 0x05: clk = 3600000; break;
case 0x06: clk = 3670000; break;
case 0x07: clk = 3710000; break;
case 0x08: clk = 3750000; break;
case 0x09: clk = 3780000; break;
case 0x0a: clk = 3800000; break;
case 0x0b: clk = 3820000; break;
case 0x0c: clk = 3830000; break;
case 0x0d: clk = 3850000; break;
case 0x0e: clk = 3860000; break;
case 0x0f: clk = 3870000; break;
}
clk = clk / 2; // YMZ294 has an internal /2 divider (not handled in AY core?)
m_ymz1->ay_set_clock(clk);
m_ymz2->ay_set_clock(clk);
popmessage("YMZ clocks set to %lliHz",clk);
}

View File

@ -0,0 +1,65 @@
/*
PlayCity expansion device
I/O ports:
* F880 - Z80CTC channel 0 (input is system clock (4MHz), output to YMZ294 clock)
* F881 - Z80CTC channel 1 (input from CRTC CURSOR, output to NMI)
* F882 - Z80CTC channel 2 (input is system clock (4MHz), output to channel 3 input)
* F883 - Z80CTC channel 3 (input is channel 2 output, output to IRQ)
* F884 - YMZ294 #1 (right) data
* F888 - YMZ294 #2 (left) data
* F984 - YMZ294 #1 (right) register select
* F988 - YMZ294 #2 (left) register select
*/
#ifndef CPC_PLAYCITY_H_
#define CPC_PLAYCITY_H_
#include "emu.h"
#include "cpcexp.h"
#include "sound/ay8910.h"
#include "machine/z80ctc.h"
class cpc_playcity_device : public device_t,
public device_cpc_expansion_card_interface
{
public:
// construction/destruction
cpc_playcity_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// optional information overrides
virtual machine_config_constructor device_mconfig_additions() const;
DECLARE_READ8_MEMBER(ctc_r);
DECLARE_WRITE8_MEMBER(ctc_w);
DECLARE_WRITE8_MEMBER(ymz1_address_w);
DECLARE_WRITE8_MEMBER(ymz2_address_w);
DECLARE_WRITE8_MEMBER(ymz1_data_w);
DECLARE_WRITE8_MEMBER(ymz2_data_w);
DECLARE_READ8_MEMBER(ymz1_data_r);
DECLARE_READ8_MEMBER(ymz2_data_r);
DECLARE_WRITE_LINE_MEMBER(ctc_zc1_cb) { if(state) {m_slot->nmi_w(1); m_slot->nmi_w(0); } }
DECLARE_WRITE_LINE_MEMBER(ctc_zc2_cb) { m_slot->irq_w(state); }
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
private:
cpc_expansion_slot_device *m_slot;
required_device<z80ctc_device> m_ctc;
required_device<ymz294_device> m_ymz1;
required_device<ymz294_device> m_ymz2;
void update_ymz_clock();
};
// device type definition
extern const device_type CPC_PLAYCITY;
#endif /* CPC_PLAYCITY_H_ */

View File

@ -74,6 +74,8 @@ public:
DECLARE_WRITE_LINE_MEMBER( trg2 );
DECLARE_WRITE_LINE_MEMBER( trg3 );
UINT16 get_channel_constant(UINT8 channel) { return m_channel[channel].m_tconst; }
protected:
// device-level overrides
virtual void device_start();

View File

@ -804,6 +804,7 @@ SLOT_INTERFACE_START(cpc_exp_cards)
SLOT_INTERFACE("amsrs232", CPC_RS232_AMS)
SLOT_INTERFACE("sf2", CPC_SYMBIFACE2)
SLOT_INTERFACE("amdrum", CPC_AMDRUM)
SLOT_INTERFACE("playcity", CPC_PLAYCITY)
SLOT_INTERFACE_END
SLOT_INTERFACE_START(cpcplus_exp_cards)
@ -815,6 +816,7 @@ SLOT_INTERFACE_START(cpcplus_exp_cards)
SLOT_INTERFACE("amsrs232", CPC_RS232_AMS)
SLOT_INTERFACE("sf2", CPC_SYMBIFACE2)
SLOT_INTERFACE("amdrum", CPC_AMDRUM)
SLOT_INTERFACE("playcity", CPC_PLAYCITY)
SLOT_INTERFACE_END
SLOT_INTERFACE_START(amstrad_centronics_devices)

View File

@ -22,6 +22,7 @@
#include "bus/cpc/cpc_rs232.h"
#include "bus/cpc/symbfac2.h"
#include "bus/cpc/amdrum.h"
#include "bus/cpc/playcity.h"
#include "machine/ram.h"
#include "imagedev/cassette.h"
#include "bus/centronics/ctronics.h"