trunk/src/mess/machine/isa_stereo_fx.c
r0 | r17959 | |
| 1 | // ATI Stereo F/X |
| 2 | // |
| 3 | // TODO: UART is connected to MIDI port |
| 4 | |
| 5 | #include "isa_stereo_fx.h" |
| 6 | |
| 7 | const device_type ISA8_STEREO_FX = &device_creator<stereo_fx_device>; |
| 8 | |
| 9 | static const ym3812_interface pc_ym3812_interface = |
| 10 | { |
| 11 | NULL |
| 12 | }; |
| 13 | |
| 14 | READ8_MEMBER( stereo_fx_device::dev_dsp_data_r ) |
| 15 | { |
| 16 | m_data_in = false; |
| 17 | return m_in_byte; |
| 18 | } |
| 19 | |
| 20 | WRITE8_MEMBER( stereo_fx_device::dev_dsp_data_w ) |
| 21 | { |
| 22 | m_data_out = true; |
| 23 | m_out_byte = data; |
| 24 | } |
| 25 | |
| 26 | // port 1 is the left DAC but is written and read bitwise during capture |
| 27 | READ8_MEMBER( stereo_fx_device::p1_r ) |
| 28 | { |
| 29 | return 0x80; |
| 30 | } |
| 31 | |
| 32 | READ8_MEMBER( stereo_fx_device::p3_r ) |
| 33 | { |
| 34 | UINT8 ret = 0; |
| 35 | |
| 36 | ret |= m_data_out << 2; // INT0 |
| 37 | ret |= m_data_in << 3; // INT1 |
| 38 | ret |= m_t0 << 4; // T0 |
| 39 | ret |= m_t1 << 5; // T1 |
| 40 | return ret; |
| 41 | } |
| 42 | |
| 43 | WRITE8_MEMBER( stereo_fx_device::p3_w ) |
| 44 | { |
| 45 | m_t1 = (data & 0x20)&&1; |
| 46 | } |
| 47 | |
| 48 | WRITE8_MEMBER( stereo_fx_device::dev_host_irq_w ) |
| 49 | { |
| 50 | m_isa->irq5_w(1); |
| 51 | } |
| 52 | |
| 53 | WRITE8_MEMBER( stereo_fx_device::raise_drq_w ) |
| 54 | { |
| 55 | m_isa->drq1_w(1); |
| 56 | } |
| 57 | |
| 58 | /* port 0x20 - in ROM (usually) stored in RAM 0x22 |
| 59 | * bit0 - |
| 60 | * bit1 - |
| 61 | * bit2 - |
| 62 | * bit3 - |
| 63 | * bit4 - |
| 64 | * bit5 - |
| 65 | * bit6 - |
| 66 | * bit7 - |
| 67 | */ |
| 68 | WRITE8_MEMBER( stereo_fx_device::port20_w ) |
| 69 | { |
| 70 | m_port20 = data; |
| 71 | } |
| 72 | |
| 73 | /* port 0x00 - in ROM (usually) stored in RAM 0x21 |
| 74 | * bit0 - bits 0-4 related to sample rate |
| 75 | * bit1 - are set to 0x09-0x1e |
| 76 | * bit2 - |
| 77 | * bit3 - |
| 78 | * bit4 - |
| 79 | * bit5 - |
| 80 | * bit6 - |
| 81 | * bit7 - |
| 82 | */ |
| 83 | WRITE8_MEMBER( stereo_fx_device::port00_w ) |
| 84 | { |
| 85 | m_port00 = data; |
| 86 | } |
| 87 | |
| 88 | ROM_START( stereo_fx ) |
| 89 | ROM_REGION( 0x8000, "stereo_fx_cpu", 0 ) |
| 90 | ROM_LOAD("ati_stereo_fx.bin", 0x0000, 0x8000, CRC(1BEBFFA6) SHA1(e66c2619a6c05199554b5702d67877ae3799d415)) |
| 91 | ROM_END |
| 92 | |
| 93 | static ADDRESS_MAP_START(stereo_fx_io, AS_IO, 8, stereo_fx_device) |
| 94 | AM_RANGE(0xFF00, 0xFF00) AM_WRITE(port00_w) |
| 95 | AM_RANGE(0xFF10, 0xFF10) AM_DEVWRITE("dacr", dac_device, write_unsigned8) |
| 96 | AM_RANGE(0xFF20, 0xFF20) AM_WRITE(port20_w) |
| 97 | //AM_RANGE(0xFF30, 0xFF30) AM_WRITE() // used only on reset and undocumented cmd 0xc4 |
| 98 | AM_RANGE(0xFF40, 0xFF40) AM_READWRITE(dev_dsp_data_r, dev_dsp_data_w) |
| 99 | AM_RANGE(0xFF50, 0xFF50) AM_WRITE(raise_drq_w) |
| 100 | AM_RANGE(0xFF60, 0xFF60) AM_WRITE(dev_host_irq_w) |
| 101 | AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READ(p1_r) AM_DEVWRITE("dacl", dac_device, write_unsigned8) |
| 102 | AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_READWRITE(p3_r, p3_w) |
| 103 | ADDRESS_MAP_END |
| 104 | |
| 105 | static ADDRESS_MAP_START(stereo_fx_rom, AS_PROGRAM, 8, stereo_fx_device) |
| 106 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 107 | ADDRESS_MAP_END |
| 108 | |
| 109 | static MACHINE_CONFIG_FRAGMENT( stereo_fx ) |
| 110 | MCFG_CPU_ADD("stereo_fx_cpu", I80C31, XTAL_30MHz) |
| 111 | MCFG_CPU_IO_MAP(stereo_fx_io) |
| 112 | MCFG_CPU_PROGRAM_MAP(stereo_fx_rom) |
| 113 | |
| 114 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 115 | MCFG_SOUND_ADD("ym3812", YM3812, XTAL_3_579545MHz) |
| 116 | MCFG_SOUND_CONFIG(pc_ym3812_interface) |
| 117 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.00) |
| 118 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00) |
| 119 | /* no CM/S support (empty sockets) */ |
| 120 | |
| 121 | MCFG_SOUND_ADD("dacl", DAC, 0) |
| 122 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.00) |
| 123 | MCFG_SOUND_ADD("dacr", DAC, 0) |
| 124 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00) |
| 125 | |
| 126 | MCFG_PC_JOY_ADD("joy") |
| 127 | MACHINE_CONFIG_END |
| 128 | |
| 129 | const rom_entry *stereo_fx_device::device_rom_region() const |
| 130 | { |
| 131 | return ROM_NAME( stereo_fx ); |
| 132 | } |
| 133 | |
| 134 | machine_config_constructor stereo_fx_device::device_mconfig_additions() const |
| 135 | { |
| 136 | return MACHINE_CONFIG_NAME( stereo_fx ); |
| 137 | } |
| 138 | |
| 139 | READ8_MEMBER( stereo_fx_device::dsp_data_r ) |
| 140 | { |
| 141 | m_data_out = false; |
| 142 | return m_out_byte; |
| 143 | } |
| 144 | |
| 145 | WRITE8_MEMBER( stereo_fx_device::dsp_cmd_w ) |
| 146 | { |
| 147 | m_data_in = true; |
| 148 | m_in_byte = data; |
| 149 | } |
| 150 | |
| 151 | UINT8 stereo_fx_device::dack_r(int line) |
| 152 | { |
| 153 | m_data_out = false; |
| 154 | m_isa->drq1_w(0); |
| 155 | return m_out_byte; |
| 156 | } |
| 157 | |
| 158 | void stereo_fx_device::dack_w(int line, UINT8 data) |
| 159 | { |
| 160 | m_data_in = true; |
| 161 | m_isa->drq1_w(0); |
| 162 | m_in_byte = data; |
| 163 | } |
| 164 | |
| 165 | WRITE8_MEMBER( stereo_fx_device::dsp_reset_w ) |
| 166 | { |
| 167 | device_reset(); |
| 168 | m_cpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE); |
| 169 | } |
| 170 | |
| 171 | READ8_MEMBER( stereo_fx_device::dsp_wbuf_status_r ) |
| 172 | { |
| 173 | return m_data_in << 7; |
| 174 | } |
| 175 | |
| 176 | READ8_MEMBER( stereo_fx_device::dsp_rbuf_status_r ) |
| 177 | { |
| 178 | m_isa->irq5_w(0); |
| 179 | return m_data_out << 7; |
| 180 | } |
| 181 | |
| 182 | WRITE8_MEMBER( stereo_fx_device::invalid_w ) |
| 183 | { |
| 184 | logerror("stereo fx: invalid port write\n"); |
| 185 | } |
| 186 | |
| 187 | READ8_MEMBER( stereo_fx_device::invalid_r ) |
| 188 | { |
| 189 | logerror("stereo fx: invalid port write\n"); |
| 190 | return 0xff; |
| 191 | } |
| 192 | |
| 193 | stereo_fx_device::stereo_fx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 194 | device_t(mconfig, ISA8_STEREO_FX, "ATI Stereo F/X Audio Adapter", tag, owner, clock), |
| 195 | device_isa8_card_interface(mconfig, *this), |
| 196 | m_dacl(*this, "dacl"), |
| 197 | m_dacr(*this, "dacr"), |
| 198 | m_joy(*this, "joy"), |
| 199 | m_cpu(*this, "stereo_fx_cpu") |
| 200 | { |
| 201 | m_t1 = 0; |
| 202 | } |
| 203 | |
| 204 | void stereo_fx_device::device_config_complete() |
| 205 | { |
| 206 | m_shortname = "stereo_fx"; |
| 207 | } |
| 208 | |
| 209 | void stereo_fx_device::device_start() |
| 210 | { |
| 211 | set_isa_device(); |
| 212 | m_isa->install_device(0x0200, 0x0207, 0, 0, read8_delegate(FUNC(pc_joy_device::joy_port_r), subdevice<pc_joy_device>("joy")), write8_delegate(FUNC(pc_joy_device::joy_port_w), subdevice<pc_joy_device>("joy"))); |
| 213 | m_isa->install_device(0x0226, 0x0227, 0, 0, read8_delegate(FUNC(stereo_fx_device::invalid_r), this), write8_delegate(FUNC(stereo_fx_device::dsp_reset_w), this)); |
| 214 | m_isa->install_device(0x022a, 0x022b, 0, 0, read8_delegate(FUNC(stereo_fx_device::dsp_data_r), this), write8_delegate(FUNC(stereo_fx_device::invalid_w), this) ); |
| 215 | m_isa->install_device(0x022c, 0x022d, 0, 0, read8_delegate(FUNC(stereo_fx_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(stereo_fx_device::dsp_cmd_w), this) ); |
| 216 | m_isa->install_device(0x022e, 0x022f, 0, 0, read8_delegate(FUNC(stereo_fx_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(stereo_fx_device::invalid_w), this) ); |
| 217 | m_isa->install_device(subdevice("ym3812"), 0x0388, 0x0389, 0, 0, FUNC(ym3812_r), FUNC(ym3812_w) ); |
| 218 | m_isa->install_device(subdevice("ym3812"), 0x0228, 0x0229, 0, 0, FUNC(ym3812_r), FUNC(ym3812_w) ); |
| 219 | m_timer = timer_alloc(); |
| 220 | m_timer->adjust(attotime::from_hz(2000000), 0, attotime::from_hz(2000000)); |
| 221 | m_isa->set_dma_channel(1, this, FALSE); |
| 222 | } |
| 223 | |
| 224 | |
| 225 | void stereo_fx_device::device_reset() |
| 226 | { |
| 227 | m_isa->drq1_w(0); |
| 228 | m_isa->irq5_w(0); |
| 229 | m_data_out = false; |
| 230 | m_data_in = false; |
| 231 | m_port20 = 0; |
| 232 | m_port00 = 0; |
| 233 | m_t0 = CLEAR_LINE; |
| 234 | } |
| 235 | |
| 236 | void stereo_fx_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr) |
| 237 | { |
| 238 | m_t0 = !m_t0; |
| 239 | m_cpu->set_input_line(MCS51_T0_LINE, m_t0); |
| 240 | } |
trunk/src/mess/machine/isa_stereo_fx.h
r0 | r17959 | |
| 1 | #ifndef __STEREO_FX__ |
| 2 | #define __STEREO_FX__ |
| 3 | |
| 4 | #include "emu.h" |
| 5 | #include "machine/isa.h" |
| 6 | #include "sound/dac.h" |
| 7 | #include "machine/pc_joy.h" |
| 8 | #include "cpu/mcs51/mcs51.h" |
| 9 | #include "sound/3812intf.h" |
| 10 | |
| 11 | //********************************************************************* |
| 12 | // TYPE DEFINITIONS |
| 13 | //********************************************************************* |
| 14 | |
| 15 | // ====================> stereo_fx_device |
| 16 | |
| 17 | class stereo_fx_device : public device_t, |
| 18 | public device_isa8_card_interface |
| 19 | { |
| 20 | public: |
| 21 | // construction/destruction |
| 22 | stereo_fx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 23 | |
| 24 | // optional information overrides |
| 25 | virtual const rom_entry *device_rom_region() const; |
| 26 | virtual machine_config_constructor device_mconfig_additions() const; |
| 27 | |
| 28 | required_device<dac_device> m_dacl; |
| 29 | required_device<dac_device> m_dacr; |
| 30 | required_device<pc_joy_device> m_joy; |
| 31 | required_device<cpu_device> m_cpu; |
| 32 | |
| 33 | // mcu ports |
| 34 | DECLARE_READ8_MEMBER( dev_dsp_data_r ); |
| 35 | DECLARE_WRITE8_MEMBER( dev_dsp_data_w ); |
| 36 | DECLARE_READ8_MEMBER( p1_r ); |
| 37 | DECLARE_READ8_MEMBER( p3_r ); |
| 38 | DECLARE_WRITE8_MEMBER( p3_w ); |
| 39 | DECLARE_WRITE8_MEMBER( dev_host_irq_w ); |
| 40 | DECLARE_WRITE8_MEMBER( raise_drq_w ); |
| 41 | DECLARE_WRITE8_MEMBER( port20_w ); |
| 42 | DECLARE_WRITE8_MEMBER( port00_w ); |
| 43 | |
| 44 | // host ports |
| 45 | DECLARE_READ8_MEMBER( dsp_data_r ); |
| 46 | DECLARE_WRITE8_MEMBER( dsp_cmd_w ); |
| 47 | DECLARE_WRITE8_MEMBER( dsp_reset_w ); |
| 48 | DECLARE_READ8_MEMBER( dsp_wbuf_status_r ); |
| 49 | DECLARE_READ8_MEMBER( dsp_rbuf_status_r ); |
| 50 | DECLARE_READ8_MEMBER( invalid_r ); |
| 51 | DECLARE_WRITE8_MEMBER( invalid_w ); |
| 52 | |
| 53 | protected: |
| 54 | // device-level overrides |
| 55 | virtual void device_start(); |
| 56 | virtual void device_reset(); |
| 57 | virtual void device_config_complete(); |
| 58 | |
| 59 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 60 | UINT8 dack_r(int line); |
| 61 | void dack_w(int line, UINT8 data); |
| 62 | private: |
| 63 | // internal state |
| 64 | bool m_data_in; |
| 65 | UINT8 m_in_byte; |
| 66 | bool m_data_out; |
| 67 | UINT8 m_out_byte; |
| 68 | |
| 69 | UINT8 m_port20; |
| 70 | UINT8 m_port00; |
| 71 | emu_timer *m_timer; |
| 72 | UINT8 m_t0; |
| 73 | UINT8 m_t1; |
| 74 | }; |
| 75 | |
| 76 | // device type definition |
| 77 | |
| 78 | extern const device_type ISA8_STEREO_FX; |
| 79 | |
| 80 | #endif |
| 81 | |