trunk/src/emu/bus/cpc/playcity.c
r0 | r241609 | |
| 1 | /* |
| 2 | PlayCity expansion device |
| 3 | |
| 4 | Z80 CTC |
| 5 | 2x YMZ294 (clocks provided by CTC) |
| 6 | */ |
| 7 | |
| 8 | #include "playcity.h" |
| 9 | #include "includes/amstrad.h" |
| 10 | |
| 11 | //************************************************************************** |
| 12 | // DEVICE DEFINITIONS |
| 13 | //************************************************************************** |
| 14 | |
| 15 | const device_type CPC_PLAYCITY = &device_creator<cpc_playcity_device>; |
| 16 | |
| 17 | // device machine config |
| 18 | static MACHINE_CONFIG_FRAGMENT( cpc_playcity ) |
| 19 | MCFG_DEVICE_ADD("ctc", Z80CTC, XTAL_4MHz) |
| 20 | MCFG_Z80CTC_ZC1_CB(WRITELINE(cpc_playcity_device,ctc_zc1_cb)) |
| 21 | MCFG_Z80CTC_ZC2_CB(WRITELINE(cpc_playcity_device,ctc_zc2_cb)) |
| 22 | |
| 23 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 24 | 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) |
| 25 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) |
| 26 | MCFG_SOUND_ADD("ymz_2",YMZ294,XTAL_4MHz) |
| 27 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) |
| 28 | |
| 29 | // pass-through |
| 30 | MCFG_DEVICE_ADD("exp", CPC_EXPANSION_SLOT, 0) |
| 31 | MCFG_DEVICE_SLOT_INTERFACE(cpc_exp_cards, NULL, false) |
| 32 | MCFG_CPC_EXPANSION_SLOT_OUT_IRQ_CB(DEVWRITELINE("^", cpc_expansion_slot_device, irq_w)) |
| 33 | MCFG_CPC_EXPANSION_SLOT_OUT_NMI_CB(DEVWRITELINE("^", cpc_expansion_slot_device, nmi_w)) |
| 34 | MCFG_CPC_EXPANSION_SLOT_OUT_ROMDIS_CB(DEVWRITELINE("^", cpc_expansion_slot_device, romdis_w)) // ROMDIS |
| 35 | |
| 36 | MACHINE_CONFIG_END |
| 37 | |
| 38 | |
| 39 | machine_config_constructor cpc_playcity_device::device_mconfig_additions() const |
| 40 | { |
| 41 | return MACHINE_CONFIG_NAME( cpc_playcity ); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | //************************************************************************** |
| 46 | // LIVE DEVICE |
| 47 | //************************************************************************** |
| 48 | |
| 49 | cpc_playcity_device::cpc_playcity_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 50 | device_t(mconfig, CPC_PLAYCITY, "PlayCity", tag, owner, clock, "cpc_playcity", __FILE__), |
| 51 | device_cpc_expansion_card_interface(mconfig, *this), |
| 52 | m_ctc(*this,"ctc"), |
| 53 | m_ymz1(*this,"ymz_1"), |
| 54 | m_ymz2(*this,"ymz_2") |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | //------------------------------------------------- |
| 59 | // device_start - device-specific startup |
| 60 | //------------------------------------------------- |
| 61 | |
| 62 | void cpc_playcity_device::device_start() |
| 63 | { |
| 64 | device_t* cpu = machine().device("maincpu"); |
| 65 | address_space& space = cpu->memory().space(AS_IO); |
| 66 | m_slot = dynamic_cast<cpc_expansion_slot_device *>(owner()); |
| 67 | |
| 68 | 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)); |
| 69 | 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)); |
| 70 | 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)); |
| 71 | space.install_write_handler(0xf984,0xf984,0,0,write8_delegate(FUNC(cpc_playcity_device::ymz1_address_w),this)); |
| 72 | space.install_write_handler(0xf988,0xf988,0,0,write8_delegate(FUNC(cpc_playcity_device::ymz2_address_w),this)); |
| 73 | } |
| 74 | |
| 75 | //------------------------------------------------- |
| 76 | // device_reset - device-specific reset |
| 77 | //------------------------------------------------- |
| 78 | |
| 79 | void cpc_playcity_device::device_reset() |
| 80 | { |
| 81 | } |
| 82 | |
| 83 | |
| 84 | READ8_MEMBER(cpc_playcity_device::ctc_r) |
| 85 | { |
| 86 | return m_ctc->read(space,offset); |
| 87 | } |
| 88 | |
| 89 | WRITE8_MEMBER(cpc_playcity_device::ctc_w) |
| 90 | { |
| 91 | m_ctc->write(space,offset,data); |
| 92 | update_ymz_clock(); |
| 93 | } |
| 94 | |
| 95 | WRITE8_MEMBER(cpc_playcity_device::ymz1_address_w) |
| 96 | { |
| 97 | m_ymz1->address_w(space,offset,data); |
| 98 | } |
| 99 | |
| 100 | WRITE8_MEMBER(cpc_playcity_device::ymz2_address_w) |
| 101 | { |
| 102 | m_ymz2->address_w(space,offset,data); |
| 103 | } |
| 104 | |
| 105 | WRITE8_MEMBER(cpc_playcity_device::ymz1_data_w) |
| 106 | { |
| 107 | m_ymz1->data_w(space,offset,data); |
| 108 | } |
| 109 | |
| 110 | WRITE8_MEMBER(cpc_playcity_device::ymz2_data_w) |
| 111 | { |
| 112 | m_ymz2->data_w(space,offset,data); |
| 113 | } |
| 114 | |
| 115 | READ8_MEMBER(cpc_playcity_device::ymz1_data_r) |
| 116 | { |
| 117 | return m_ymz1->data_r(space,offset); |
| 118 | } |
| 119 | |
| 120 | READ8_MEMBER(cpc_playcity_device::ymz2_data_r) |
| 121 | { |
| 122 | return m_ymz2->data_r(space,offset); |
| 123 | } |
| 124 | |
| 125 | void cpc_playcity_device::update_ymz_clock() |
| 126 | { |
| 127 | // Bit of a hack job here, since there is no way currently to connect the CTC channel output directly to the YMZ clocks. |
| 128 | UINT8 rate = m_ctc->get_channel_constant(0); |
| 129 | UINT64 clk = XTAL_4MHz; |
| 130 | |
| 131 | switch(rate) |
| 132 | { |
| 133 | case 0x00: clk = 3980000; break; |
| 134 | case 0x01: clk = 2000000; break; |
| 135 | case 0x02: clk = 3000000; break; |
| 136 | case 0x03: clk = 3330000; break; |
| 137 | case 0x04: clk = 3500000; break; |
| 138 | case 0x05: clk = 3600000; break; |
| 139 | case 0x06: clk = 3670000; break; |
| 140 | case 0x07: clk = 3710000; break; |
| 141 | case 0x08: clk = 3750000; break; |
| 142 | case 0x09: clk = 3780000; break; |
| 143 | case 0x0a: clk = 3800000; break; |
| 144 | case 0x0b: clk = 3820000; break; |
| 145 | case 0x0c: clk = 3830000; break; |
| 146 | case 0x0d: clk = 3850000; break; |
| 147 | case 0x0e: clk = 3860000; break; |
| 148 | case 0x0f: clk = 3870000; break; |
| 149 | } |
| 150 | |
| 151 | clk = clk / 2; // YMZ294 has an internal /2 divider (not handled in AY core?) |
| 152 | m_ymz1->ay_set_clock(clk); |
| 153 | m_ymz2->ay_set_clock(clk); |
| 154 | popmessage("YMZ clocks set to %lliHz",clk); |
| 155 | } |
| 156 | |
trunk/src/emu/bus/cpc/playcity.h
r0 | r241609 | |
| 1 | /* |
| 2 | PlayCity expansion device |
| 3 | |
| 4 | I/O ports: |
| 5 | * F880 - Z80CTC channel 0 (input is system clock (4MHz), output to YMZ294 clock) |
| 6 | * F881 - Z80CTC channel 1 (input from CRTC CURSOR, output to NMI) |
| 7 | * F882 - Z80CTC channel 2 (input is system clock (4MHz), output to channel 3 input) |
| 8 | * F883 - Z80CTC channel 3 (input is channel 2 output, output to IRQ) |
| 9 | * F884 - YMZ294 #1 (right) data |
| 10 | * F888 - YMZ294 #2 (left) data |
| 11 | * F984 - YMZ294 #1 (right) register select |
| 12 | * F988 - YMZ294 #2 (left) register select |
| 13 | */ |
| 14 | |
| 15 | #ifndef CPC_PLAYCITY_H_ |
| 16 | #define CPC_PLAYCITY_H_ |
| 17 | |
| 18 | |
| 19 | #include "emu.h" |
| 20 | #include "cpcexp.h" |
| 21 | #include "sound/ay8910.h" |
| 22 | #include "machine/z80ctc.h" |
| 23 | |
| 24 | class cpc_playcity_device : public device_t, |
| 25 | public device_cpc_expansion_card_interface |
| 26 | { |
| 27 | public: |
| 28 | // construction/destruction |
| 29 | cpc_playcity_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 30 | |
| 31 | // optional information overrides |
| 32 | virtual machine_config_constructor device_mconfig_additions() const; |
| 33 | |
| 34 | DECLARE_READ8_MEMBER(ctc_r); |
| 35 | DECLARE_WRITE8_MEMBER(ctc_w); |
| 36 | DECLARE_WRITE8_MEMBER(ymz1_address_w); |
| 37 | DECLARE_WRITE8_MEMBER(ymz2_address_w); |
| 38 | DECLARE_WRITE8_MEMBER(ymz1_data_w); |
| 39 | DECLARE_WRITE8_MEMBER(ymz2_data_w); |
| 40 | DECLARE_READ8_MEMBER(ymz1_data_r); |
| 41 | DECLARE_READ8_MEMBER(ymz2_data_r); |
| 42 | DECLARE_WRITE_LINE_MEMBER(ctc_zc1_cb) { if(state) {m_slot->nmi_w(1); m_slot->nmi_w(0); } } |
| 43 | DECLARE_WRITE_LINE_MEMBER(ctc_zc2_cb) { m_slot->irq_w(state); } |
| 44 | |
| 45 | protected: |
| 46 | // device-level overrides |
| 47 | virtual void device_start(); |
| 48 | virtual void device_reset(); |
| 49 | |
| 50 | private: |
| 51 | cpc_expansion_slot_device *m_slot; |
| 52 | |
| 53 | required_device<z80ctc_device> m_ctc; |
| 54 | required_device<ymz294_device> m_ymz1; |
| 55 | required_device<ymz294_device> m_ymz2; |
| 56 | |
| 57 | void update_ymz_clock(); |
| 58 | }; |
| 59 | |
| 60 | // device type definition |
| 61 | extern const device_type CPC_PLAYCITY; |
| 62 | |
| 63 | |
| 64 | #endif /* CPC_PLAYCITY_H_ */ |
| 65 | |