src/mess/machine/isa_sblaster.c
| r14032 | r14033 | |
| 37 | 37 | */ |
| 38 | 38 | #define ym3812_StdClock XTAL_3_579545MHz |
| 39 | 39 | |
| 40 | | static struct { |
| 41 | | UINT8 reset_latch; |
| 42 | | UINT8 rbuf_status; |
| 43 | | UINT8 wbuf_status; |
| 44 | | UINT8 fifo[16],fifo_ptr; |
| 45 | | UINT8 fifo_r[16],fifo_r_ptr; |
| 46 | | UINT16 version; |
| 47 | | UINT8 test_reg; |
| 48 | | UINT8 speaker_on; |
| 49 | | }m_dsp; |
| 50 | | |
| 51 | | |
| 52 | 40 | static const int m_cmd_fifo_length[256] = |
| 53 | 41 | { |
| 54 | 42 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
| r14032 | r14033 | |
| 66 | 54 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* Bx */ |
| 67 | 55 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* Cx */ |
| 68 | 56 | -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, /* Dx */ |
| 69 | | 2, 1, -1, -1, 2, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, /* Ex */ |
| 57 | 2, 1, 1, -1, 2, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, /* Ex */ |
| 70 | 58 | -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1 /* Fx */ |
| 71 | 59 | }; |
| 72 | 60 | |
| 61 | static const int protection_magic[4][9] = |
| 62 | { |
| 63 | { 1, -2, -4, 8, -16, 32, 64, -128, -106 }, |
| 64 | { -1, 2, -4, 8, 16, -32, 64, -128, 165 }, |
| 65 | { -1, 2, 4, -8, 16, -32, -64, 128, -151 }, |
| 66 | { 1, -2, 4, -8, -16, 32, -64, 128, 90 } |
| 67 | }; |
| 68 | |
| 73 | 69 | static const ym3812_interface pc_ym3812_interface = |
| 74 | 70 | { |
| 75 | 71 | NULL |
| r14032 | r14033 | |
| 129 | 125 | } |
| 130 | 126 | } |
| 131 | 127 | |
| 132 | | static void queue(UINT8 data) |
| 128 | void sb8_device::queue(UINT8 data) |
| 133 | 129 | { |
| 134 | 130 | if (m_dsp.fifo_ptr < 15) |
| 135 | 131 | { |
| r14032 | r14033 | |
| 144 | 140 | } |
| 145 | 141 | } |
| 146 | 142 | |
| 147 | | static void queue_r(UINT8 data) |
| 143 | void sb8_device::queue_r(UINT8 data) |
| 148 | 144 | { |
| 149 | 145 | m_dsp.rbuf_status |= 0x80; |
| 150 | 146 | |
| r14032 | r14033 | |
| 161 | 157 | } |
| 162 | 158 | } |
| 163 | 159 | |
| 164 | | static UINT8 dequeue_r() |
| 160 | UINT8 sb8_device::dequeue_r() |
| 165 | 161 | { |
| 166 | 162 | UINT8 data = m_dsp.fifo_r[0]; |
| 167 | 163 | |
| r14032 | r14033 | |
| 182 | 178 | } |
| 183 | 179 | |
| 184 | 180 | |
| 185 | | static READ8_DEVICE_HANDLER( dsp_reset_r ) |
| 181 | READ8_MEMBER( sb8_device::dsp_reset_r ) |
| 186 | 182 | { |
| 187 | 183 | if(offset) |
| 188 | 184 | return 0xff; |
| r14032 | r14033 | |
| 190 | 186 | return 0xff; |
| 191 | 187 | } |
| 192 | 188 | |
| 193 | | static WRITE8_DEVICE_HANDLER( dsp_reset_w ) |
| 189 | WRITE8_MEMBER( sb8_device::dsp_reset_w ) |
| 194 | 190 | { |
| 195 | 191 | if(offset) |
| 196 | 192 | return; |
| r14032 | r14033 | |
| 206 | 202 | //printf("%02x\n",data); |
| 207 | 203 | } |
| 208 | 204 | |
| 209 | | static READ8_DEVICE_HANDLER( dsp_data_r ) |
| 205 | READ8_MEMBER( sb8_device::dsp_data_r ) |
| 210 | 206 | { |
| 211 | 207 | if(offset) |
| 212 | 208 | return 0xff; |
| r14032 | r14033 | |
| 214 | 210 | return dequeue_r(); |
| 215 | 211 | } |
| 216 | 212 | |
| 217 | | static WRITE8_DEVICE_HANDLER( dsp_data_w ) |
| 213 | WRITE8_MEMBER( sb8_device::dsp_data_w ) |
| 218 | 214 | { |
| 219 | 215 | if(offset) |
| 220 | 216 | return; |
| 221 | 217 | logerror("Soundblaster DSP data port undocumented write\n"); |
| 222 | 218 | } |
| 223 | 219 | |
| 224 | | static READ8_DEVICE_HANDLER(dsp_rbuf_status_r) |
| 220 | READ8_MEMBER(sb8_device::dsp_rbuf_status_r) |
| 225 | 221 | { |
| 226 | 222 | if(offset) |
| 227 | 223 | return 0xff; |
| r14032 | r14033 | |
| 229 | 225 | return m_dsp.rbuf_status; |
| 230 | 226 | } |
| 231 | 227 | |
| 232 | | static READ8_DEVICE_HANDLER(dsp_wbuf_status_r) |
| 228 | READ8_MEMBER(sb8_device::dsp_wbuf_status_r) |
| 233 | 229 | { |
| 234 | 230 | if(offset) |
| 235 | 231 | return 0xff; |
| r14032 | r14033 | |
| 237 | 233 | return m_dsp.wbuf_status; |
| 238 | 234 | } |
| 239 | 235 | |
| 240 | | static WRITE8_DEVICE_HANDLER(dsp_rbuf_status_w) |
| 236 | WRITE8_MEMBER(sb8_device::dsp_rbuf_status_w) |
| 241 | 237 | { |
| 242 | 238 | if(offset) |
| 243 | 239 | return; |
| r14032 | r14033 | |
| 245 | 241 | logerror("Soundblaster DSP Read Buffer status undocumented write\n"); |
| 246 | 242 | } |
| 247 | 243 | |
| 248 | | static void process_fifo(running_machine &machine, UINT8 cmd) |
| 244 | void sb8_device::process_fifo(UINT8 cmd) |
| 249 | 245 | { |
| 250 | 246 | if (m_cmd_fifo_length[cmd] == -1) |
| 251 | 247 | { |
| r14032 | r14033 | |
| 254 | 250 | else if(m_dsp.fifo_ptr == m_cmd_fifo_length[cmd]) |
| 255 | 251 | { |
| 256 | 252 | /* get FIFO params */ |
| 253 | printf("SB FIFO command: %02x\n", cmd); |
| 257 | 254 | switch(cmd) |
| 258 | 255 | { |
| 259 | 256 | case 0xd1: // speaker on |
| r14032 | r14033 | |
| 274 | 271 | queue_r(m_dsp.version >> 8); |
| 275 | 272 | queue_r(m_dsp.version & 0xff); |
| 276 | 273 | break; |
| 274 | case 0xe2: // DSP protection |
| 275 | for (int i = 0; i < 8; i++) |
| 276 | { |
| 277 | if ((m_dsp.fifo[1] >> i) & 0x01) |
| 278 | { |
| 279 | m_dsp.prot_value += protection_magic[m_dsp.prot_count % 4][i]; |
| 280 | } |
| 281 | |
| 282 | m_dsp.prot_value += protection_magic[m_dsp.prot_count % 4][8]; |
| 283 | m_dsp.prot_count++; |
| 284 | } |
| 285 | |
| 286 | // this wants to return prot_data by DMA. how does ISA DMA work? |
| 287 | m_isa->drq1_w(1); |
| 288 | break; |
| 277 | 289 | case 0xe4: // write test register |
| 278 | 290 | m_dsp.test_reg = m_dsp.fifo[1]; |
| 279 | 291 | break; |
| r14032 | r14033 | |
| 281 | 293 | queue_r(m_dsp.test_reg); |
| 282 | 294 | break; |
| 283 | 295 | case 0xf2: // send PIC irq |
| 284 | | //m_isa->irq5_w(1); |
| 285 | | pic8259_ir5_w(machine.device("pic8259_master"), 1); |
| 296 | m_isa->irq5_w(1); |
| 286 | 297 | break; |
| 287 | 298 | case 0xf8: // ??? |
| 288 | 299 | logerror("SB: Unknown command write 0xf8"); |
| r14032 | r14033 | |
| 294 | 305 | } |
| 295 | 306 | } |
| 296 | 307 | |
| 297 | | static WRITE8_DEVICE_HANDLER(dsp_cmd_w) |
| 308 | WRITE8_MEMBER(sb8_device::dsp_cmd_w) |
| 298 | 309 | { |
| 299 | 310 | if(offset) |
| 300 | 311 | return; |
| 301 | 312 | |
| 302 | 313 | queue(data); |
| 303 | 314 | |
| 304 | | process_fifo(device->machine(),m_dsp.fifo[0]); |
| 315 | process_fifo(m_dsp.fifo[0]); |
| 305 | 316 | } |
| 306 | 317 | |
| 307 | 318 | //************************************************************************** |
| r14032 | r14033 | |
| 317 | 328 | //------------------------------------------------- |
| 318 | 329 | |
| 319 | 330 | machine_config_constructor isa8_sblaster1_0_device::device_mconfig_additions() const |
| 320 | | { |
| 331 | { |
| 321 | 332 | return MACHINE_CONFIG_NAME( sblaster1_0_config ); |
| 322 | 333 | } |
| 323 | 334 | |
| r14032 | r14033 | |
| 330 | 341 | // LIVE DEVICE |
| 331 | 342 | //************************************************************************** |
| 332 | 343 | |
| 344 | sb8_device::sb8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, const char *name) : |
| 345 | device_t(mconfig, type, name, tag, owner, clock), |
| 346 | device_isa8_card_interface(mconfig, *this) |
| 347 | { |
| 348 | } |
| 349 | |
| 350 | |
| 333 | 351 | //------------------------------------------------- |
| 334 | 352 | // isa8_sblaster_device - constructor |
| 335 | 353 | //------------------------------------------------- |
| 336 | 354 | |
| 337 | 355 | isa8_sblaster1_0_device::isa8_sblaster1_0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 338 | | device_t(mconfig, ISA8_SOUND_BLASTER_1_0, "ISA8_SOUND_BLASTER_1_0", tag, owner, clock), |
| 339 | | device_isa8_card_interface(mconfig, *this) |
| 356 | sb8_device(mconfig, ISA8_SOUND_BLASTER_1_0, tag, owner, clock, "Sound Blaster 1.0") |
| 340 | 357 | { |
| 341 | 358 | } |
| 342 | 359 | |
| 343 | 360 | isa8_sblaster1_5_device::isa8_sblaster1_5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 344 | | device_t(mconfig, ISA8_SOUND_BLASTER_1_5, "ISA8_SOUND_BLASTER_1_5", tag, owner, clock), |
| 345 | | device_isa8_card_interface(mconfig, *this) |
| 361 | sb8_device(mconfig, ISA8_SOUND_BLASTER_1_5, tag, owner, clock, "Sound Blaster 1.5") |
| 346 | 362 | { |
| 347 | 363 | } |
| 348 | 364 | |
| r14032 | r14033 | |
| 350 | 366 | // device_start - device-specific startup |
| 351 | 367 | //------------------------------------------------- |
| 352 | 368 | |
| 369 | void sb8_device::device_start() |
| 370 | { |
| 371 | } |
| 372 | |
| 353 | 373 | void isa8_sblaster1_0_device::device_start() |
| 354 | 374 | { |
| 355 | 375 | set_isa_device(); |
| 356 | 376 | m_isa->install_device(subdevice("saa1099.1"), 0x0220, 0x0221, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) ); |
| 357 | 377 | m_isa->install_device(subdevice("saa1099.2"), 0x0222, 0x0223, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) ); |
| 358 | | m_isa->install_device(this, 0x0226, 0x0227, 0, 0, FUNC(dsp_reset_r), FUNC(dsp_reset_w) ); |
| 378 | m_isa->install_device( 0x0226, 0x0227, 0, 0, read8_delegate(FUNC(sb8_device::dsp_reset_r), this), write8_delegate(FUNC(sb8_device::dsp_reset_w), this)); |
| 359 | 379 | m_isa->install_device(subdevice("ym3812"), 0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 360 | | m_isa->install_device(this, 0x022a, 0x022b, 0, 0, FUNC(dsp_data_r), FUNC(dsp_data_w) ); |
| 361 | | m_isa->install_device(this, 0x022c, 0x022d, 0, 0, FUNC(dsp_wbuf_status_r), FUNC(dsp_cmd_w) ); |
| 362 | | m_isa->install_device(this, 0x022e, 0x022f, 0, 0, FUNC(dsp_rbuf_status_r), FUNC(dsp_rbuf_status_w) ); |
| 380 | m_isa->install_device( 0x022a, 0x022b, 0, 0, read8_delegate(FUNC(sb8_device::dsp_data_r), this), write8_delegate(FUNC(sb8_device::dsp_data_w), this) ); |
| 381 | m_isa->install_device( 0x022c, 0x022d, 0, 0, read8_delegate(FUNC(sb8_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_cmd_w), this) ); |
| 382 | m_isa->install_device( 0x022e, 0x022f, 0, 0, read8_delegate(FUNC(sb8_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_rbuf_status_w), this) ); |
| 363 | 383 | m_isa->install_device(subdevice("ym3812"), 0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 364 | 384 | m_dsp.version = 0x0105; |
| 365 | 385 | } |
| r14032 | r14033 | |
| 367 | 387 | void isa8_sblaster1_5_device::device_start() |
| 368 | 388 | { |
| 369 | 389 | set_isa_device(); |
| 370 | | /* 1.5 ditches CM/S support (empty sockets) */ |
| 371 | | m_isa->install_device(this, 0x0226, 0x0227, 0, 0, FUNC(dsp_reset_r), FUNC(dsp_reset_w) ); |
| 390 | /* 1.5 makes CM/S support optional (empty sockets, but they work if the user populates them!) */ |
| 391 | m_isa->install_device( 0x0226, 0x0227, 0, 0, read8_delegate(FUNC(sb8_device::dsp_reset_r), this), write8_delegate(FUNC(sb8_device::dsp_reset_w), this)); |
| 372 | 392 | m_isa->install_device(subdevice("ym3812"), 0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 373 | | m_isa->install_device(this, 0x022a, 0x022b, 0, 0, FUNC(dsp_data_r), FUNC(dsp_data_w) ); |
| 374 | | m_isa->install_device(this, 0x022c, 0x022d, 0, 0, FUNC(dsp_wbuf_status_r), FUNC(dsp_cmd_w) ); |
| 375 | | m_isa->install_device(this, 0x022e, 0x022f, 0, 0, FUNC(dsp_rbuf_status_r), FUNC(dsp_rbuf_status_w) ); |
| 393 | m_isa->install_device( 0x022a, 0x022b, 0, 0, read8_delegate(FUNC(sb8_device::dsp_data_r), this), write8_delegate(FUNC(sb8_device::dsp_data_w), this) ); |
| 394 | m_isa->install_device( 0x022c, 0x022d, 0, 0, read8_delegate(FUNC(sb8_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_cmd_w), this) ); |
| 395 | m_isa->install_device( 0x022e, 0x022f, 0, 0, read8_delegate(FUNC(sb8_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_rbuf_status_w), this) ); |
| 376 | 396 | m_isa->install_device(subdevice("ym3812"), 0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) ); |
| 377 | 397 | m_dsp.version = 0x0200; |
| 378 | 398 | } |
| r14032 | r14033 | |
| 381 | 401 | // device_reset - device-specific reset |
| 382 | 402 | //------------------------------------------------- |
| 383 | 403 | |
| 384 | | void isa8_sblaster1_0_device::device_reset() |
| 404 | void sb8_device::device_reset() |
| 385 | 405 | { |
| 386 | | // ... |
| 406 | m_dsp.prot_value = 0xaa; |
| 407 | m_dsp.prot_count = 0; |
| 387 | 408 | } |
| 388 | 409 | |
| 389 | | void isa8_sblaster1_5_device::device_reset() |
| 390 | | { |
| 391 | | // ... |
| 392 | | } |
| 393 | | |