src/mess/machine/isa_sblaster.c
| r14021 | r14022 | |
| 2 | 2 | |
| 3 | 3 | ISA 8 bit Creative Labs Sound Blaster Sound Card |
| 4 | 4 | |
| 5 | TODO: |
| 6 | - DSP type is unknown at current time, and probably has an internal ROM |
| 7 | that needs decapping; |
| 8 | - joystick port; |
| 9 | - implement jumpers dip-sw; |
| 10 | - state machine + read/write members |
| 11 | |
| 5 | 12 | ***************************************************************************/ |
| 6 | 13 | |
| 7 | 14 | #include "emu.h" |
| r14021 | r14022 | |
| 27 | 34 | |
| 28 | 35 | jumperable? normally 0x220 |
| 29 | 36 | */ |
| 30 | | #define ym3812_StdClock 3579545 |
| 37 | #define ym3812_StdClock XTAL_3_579545MHz |
| 31 | 38 | |
| 39 | static struct { |
| 40 | UINT8 reset_latch; |
| 41 | UINT8 rbuf_status; |
| 42 | UINT8 wbuf_status; |
| 43 | UINT8 in_data; |
| 44 | UINT8 fifo_cmd; |
| 45 | UINT8 cmd; |
| 46 | }m_dsp; |
| 47 | |
| 48 | static UINT8 m_fifo[16],m_fifo_ptr; |
| 49 | |
| 50 | static const int m_cmd_fifo_length[256] = |
| 51 | { |
| 52 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
| 53 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x */ |
| 54 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 1x */ |
| 55 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 2x */ |
| 56 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 3x */ |
| 57 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 4x */ |
| 58 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 5x */ |
| 59 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 6x */ |
| 60 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 7x */ |
| 61 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 8x */ |
| 62 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 9x */ |
| 63 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* Ax */ |
| 64 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* Bx */ |
| 65 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* Cx */ |
| 66 | -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* Dx */ |
| 67 | 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* Ex */ |
| 68 | -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1 /* Fx */ |
| 69 | }; |
| 70 | |
| 32 | 71 | static const ym3812_interface pc_ym3812_interface = |
| 33 | 72 | { |
| 34 | 73 | NULL |
| 35 | 74 | }; |
| 36 | 75 | |
| 37 | | static MACHINE_CONFIG_FRAGMENT( sblaster_config ) |
| 76 | static MACHINE_CONFIG_FRAGMENT( sblaster1_0_config ) |
| 38 | 77 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 39 | 78 | MCFG_SOUND_ADD("ym3812", YM3812, ym3812_StdClock) |
| 40 | 79 | MCFG_SOUND_CONFIG(pc_ym3812_interface) |
| r14021 | r14022 | |
| 45 | 84 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 46 | 85 | MACHINE_CONFIG_END |
| 47 | 86 | |
| 87 | static MACHINE_CONFIG_FRAGMENT( sblaster1_5_config ) |
| 88 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 89 | MCFG_SOUND_ADD("ym3812", YM3812, ym3812_StdClock) |
| 90 | MCFG_SOUND_CONFIG(pc_ym3812_interface) |
| 91 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 92 | /* no CM/S support (empty sockets) */ |
| 93 | |
| 94 | MACHINE_CONFIG_END |
| 95 | |
| 96 | |
| 48 | 97 | static READ8_DEVICE_HANDLER( ym3812_16_r ) |
| 49 | 98 | { |
| 50 | 99 | UINT8 retVal = 0xff; |
| r14021 | r14022 | |
| 78 | 127 | } |
| 79 | 128 | } |
| 80 | 129 | |
| 130 | static READ8_DEVICE_HANDLER( dsp_reset_r ) |
| 131 | { |
| 132 | if(offset) |
| 133 | return 0xff; |
| 134 | logerror("Soundblaster DSP Reset port undocumented read\n"); |
| 135 | return 0xff; |
| 136 | } |
| 137 | |
| 138 | static WRITE8_DEVICE_HANDLER( dsp_reset_w ) |
| 139 | { |
| 140 | if(offset) |
| 141 | return; |
| 142 | |
| 143 | if(data == 0 && m_dsp.reset_latch == 1) |
| 144 | { |
| 145 | // reset routine |
| 146 | m_dsp.rbuf_status |= 0x80; |
| 147 | m_dsp.in_data = 0xaa; // reset OK ID |
| 148 | //m_dsp.fifo_cmd = 0; |
| 149 | } |
| 150 | |
| 151 | m_dsp.reset_latch = data; |
| 152 | |
| 153 | printf("%02x\n",data); |
| 154 | } |
| 155 | |
| 156 | static READ8_DEVICE_HANDLER( dsp_data_r ) |
| 157 | { |
| 158 | if(offset) |
| 159 | return 0xff; |
| 160 | |
| 161 | return m_dsp.in_data; |
| 162 | } |
| 163 | |
| 164 | static WRITE8_DEVICE_HANDLER( dsp_data_w ) |
| 165 | { |
| 166 | if(offset) |
| 167 | return; |
| 168 | logerror("Soundblaster DSP data port undocumented write\n"); |
| 169 | } |
| 170 | |
| 171 | static READ8_DEVICE_HANDLER(dsp_rbuf_status_r) |
| 172 | { |
| 173 | UINT8 res; |
| 174 | |
| 175 | res = 0; |
| 176 | |
| 177 | if(offset) |
| 178 | return 0xff; |
| 179 | |
| 180 | if(m_dsp.rbuf_status & 0x80) |
| 181 | { |
| 182 | m_dsp.rbuf_status &= ~0x80; |
| 183 | res |= 0x80; |
| 184 | } |
| 185 | |
| 186 | return res; |
| 187 | } |
| 188 | |
| 189 | static READ8_DEVICE_HANDLER(dsp_wbuf_status_r) |
| 190 | { |
| 191 | if(offset) |
| 192 | return 0xff; |
| 193 | |
| 194 | return m_dsp.wbuf_status; |
| 195 | } |
| 196 | |
| 197 | static WRITE8_DEVICE_HANDLER(dsp_rbuf_status_w) |
| 198 | { |
| 199 | if(offset) |
| 200 | return; |
| 201 | |
| 202 | logerror("Soundblaster DSP Read Buffer status undocumented write\n"); |
| 203 | } |
| 204 | |
| 205 | static void queue(UINT8 data) |
| 206 | { |
| 207 | if (m_fifo_ptr < 15) |
| 208 | { |
| 209 | m_fifo_ptr++; |
| 210 | |
| 211 | m_fifo[m_fifo_ptr] = data; |
| 212 | } |
| 213 | else |
| 214 | { |
| 215 | // FIFO gets to la-la-land |
| 216 | //logerror("FIFO?\n"); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | static void process_fifo(UINT8 cmd) |
| 221 | { |
| 222 | if (m_cmd_fifo_length[cmd] == -1) |
| 223 | { |
| 224 | logerror("unemulated or undefined fifo command %02x\n",cmd); |
| 225 | } |
| 226 | else if(m_fifo_ptr == m_cmd_fifo_length[cmd]) |
| 227 | { |
| 228 | /* get FIFO params */ |
| 229 | switch(cmd) |
| 230 | { |
| 231 | case 0xd3: // speaker off |
| 232 | m_dsp.rbuf_status |= 0x80; |
| 233 | m_dsp.in_data = 0; |
| 234 | break; |
| 235 | case 0xe0: // get DSP identification |
| 236 | m_dsp.rbuf_status |= 0x80; |
| 237 | m_dsp.in_data = m_fifo[2] ^ 0xff; |
| 238 | break; |
| 239 | case 0xf8: // ??? |
| 240 | m_dsp.rbuf_status |= 0x80; |
| 241 | m_dsp.in_data = 0; |
| 242 | break; |
| 243 | } |
| 244 | |
| 245 | m_fifo_ptr = 0; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | static WRITE8_DEVICE_HANDLER(dsp_cmd_w) |
| 250 | { |
| 251 | if(offset) |
| 252 | return; |
| 253 | |
| 254 | printf("%02x %02x\n",m_dsp.fifo_cmd,m_dsp.cmd); |
| 255 | |
| 256 | queue(data); |
| 257 | |
| 258 | process_fifo(m_fifo[1]); |
| 259 | } |
| 260 | |
| 81 | 261 | //************************************************************************** |
| 82 | 262 | // GLOBAL VARIABLES |
| 83 | 263 | //************************************************************************** |
| 84 | 264 | |
| 85 | | const device_type ISA8_SOUND_BLASTER_1_0 = &device_creator<isa8_sblaster_device>; |
| 265 | const device_type ISA8_SOUND_BLASTER_1_0 = &device_creator<isa8_sblaster1_0_device>; |
| 266 | const device_type ISA8_SOUND_BLASTER_1_5 = &device_creator<isa8_sblaster1_5_device>; |
| 86 | 267 | |
| 87 | 268 | //------------------------------------------------- |
| 88 | 269 | // machine_config_additions - device-specific |
| 89 | 270 | // machine configurations |
| 90 | 271 | //------------------------------------------------- |
| 91 | 272 | |
| 92 | | machine_config_constructor isa8_sblaster_device::device_mconfig_additions() const |
| 273 | machine_config_constructor isa8_sblaster1_0_device::device_mconfig_additions() const |
| 93 | 274 | { |
| 94 | | return MACHINE_CONFIG_NAME( sblaster_config ); |
| 275 | return MACHINE_CONFIG_NAME( sblaster1_0_config ); |
| 95 | 276 | } |
| 96 | 277 | |
| 278 | machine_config_constructor isa8_sblaster1_5_device::device_mconfig_additions() const |
| 279 | { |
| 280 | return MACHINE_CONFIG_NAME( sblaster1_5_config ); |
| 281 | } |
| 282 | |
| 97 | 283 | //************************************************************************** |
| 98 | 284 | // LIVE DEVICE |
| 99 | 285 | //************************************************************************** |
| r14021 | r14022 | |
| 102 | 288 | // isa8_sblaster_device - constructor |
| 103 | 289 | //------------------------------------------------- |
| 104 | 290 | |
| 105 | | isa8_sblaster_device::isa8_sblaster_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 291 | isa8_sblaster1_0_device::isa8_sblaster1_0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 106 | 292 | device_t(mconfig, ISA8_SOUND_BLASTER_1_0, "ISA8_SOUND_BLASTER_1_0", tag, owner, clock), |
| 107 | 293 | device_isa8_card_interface(mconfig, *this) |
| 108 | 294 | { |
| 109 | 295 | } |
| 110 | 296 | |
| 297 | isa8_sblaster1_5_device::isa8_sblaster1_5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 298 | device_t(mconfig, ISA8_SOUND_BLASTER_1_5, "ISA8_SOUND_BLASTER_1_5", tag, owner, clock), |
| 299 | device_isa8_card_interface(mconfig, *this) |
| 300 | { |
| 301 | } |
| 302 | |
| 111 | 303 | //------------------------------------------------- |
| 112 | 304 | // device_start - device-specific startup |
| 113 | 305 | //------------------------------------------------- |
| 114 | 306 | |
| 115 | | void isa8_sblaster_device::device_start() |
| 307 | void isa8_sblaster1_0_device::device_start() |
| 116 | 308 | { |
| 117 | 309 | set_isa_device(); |
| 118 | | m_isa->install_device(subdevice("ym3812"), 0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 119 | 310 | m_isa->install_device(subdevice("saa1099.1"), 0x0220, 0x0221, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) ); |
| 120 | 311 | m_isa->install_device(subdevice("saa1099.2"), 0x0222, 0x0223, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) ); |
| 312 | m_isa->install_device(this, 0x0226, 0x0227, 0, 0, FUNC(dsp_reset_r), FUNC(dsp_reset_w) ); |
| 313 | m_isa->install_device(subdevice("ym3812"), 0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 314 | m_isa->install_device(this, 0x022a, 0x022b, 0, 0, FUNC(dsp_data_r), FUNC(dsp_data_w) ); |
| 315 | m_isa->install_device(this, 0x022c, 0x022d, 0, 0, FUNC(dsp_wbuf_status_r), FUNC(dsp_cmd_w) ); |
| 316 | m_isa->install_device(this, 0x022e, 0x022f, 0, 0, FUNC(dsp_rbuf_status_r), FUNC(dsp_rbuf_status_w) ); |
| 317 | m_isa->install_device(subdevice("ym3812"), 0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 121 | 318 | } |
| 122 | 319 | |
| 320 | void isa8_sblaster1_5_device::device_start() |
| 321 | { |
| 322 | set_isa_device(); |
| 323 | /* 1.5 ditches CM/S support (empty sockets) */ |
| 324 | m_isa->install_device(this, 0x0226, 0x0227, 0, 0, FUNC(dsp_reset_r), FUNC(dsp_reset_w) ); |
| 325 | m_isa->install_device(subdevice("ym3812"), 0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 326 | m_isa->install_device(this, 0x022a, 0x022b, 0, 0, FUNC(dsp_data_r), FUNC(dsp_data_w) ); |
| 327 | m_isa->install_device(this, 0x022c, 0x022d, 0, 0, FUNC(dsp_wbuf_status_r), FUNC(dsp_cmd_w) ); |
| 328 | m_isa->install_device(this, 0x022e, 0x022f, 0, 0, FUNC(dsp_rbuf_status_r), FUNC(dsp_rbuf_status_w) ); |
| 329 | m_isa->install_device(subdevice("ym3812"), 0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 330 | } |
| 331 | |
| 123 | 332 | //------------------------------------------------- |
| 124 | 333 | // device_reset - device-specific reset |
| 125 | 334 | //------------------------------------------------- |
| 126 | 335 | |
| 127 | | void isa8_sblaster_device::device_reset() |
| 336 | void isa8_sblaster1_0_device::device_reset() |
| 128 | 337 | { |
| 338 | // ... |
| 129 | 339 | } |
| 340 | |
| 341 | void isa8_sblaster1_5_device::device_reset() |
| 342 | { |
| 343 | // ... |
| 344 | } |
| 345 | |