trunk/src/mame/audio/cinemat.c
| r31819 | r31820 | |
| 24 | 24 | #include "cpu/z80/z80daisy.h" |
| 25 | 25 | #include "machine/z80ctc.h" |
| 26 | 26 | #include "includes/cinemat.h" |
| 27 | | #include "sound/samples.h" |
| 28 | 27 | |
| 29 | 28 | |
| 30 | 29 | /************************************* |
| r31819 | r31820 | |
| 39 | 38 | #define SOUNDVAL_RISING_EDGE(bit) RISING_EDGE(bit, bits_changed, sound_val) |
| 40 | 39 | #define SOUNDVAL_FALLING_EDGE(bit) FALLING_EDGE(bit, bits_changed, sound_val) |
| 41 | 40 | |
| 42 | | #define SHIFTREG_RISING_EDGE(bit) RISING_EDGE(bit, (state->m_last_shift ^ state->m_current_shift), state->m_current_shift) |
| 43 | | #define SHIFTREG_FALLING_EDGE(bit) FALLING_EDGE(bit, (state->m_last_shift ^ state->m_current_shift), state->m_current_shift) |
| 41 | #define SHIFTREG_RISING_EDGE(bit) RISING_EDGE(bit, (m_last_shift ^ m_current_shift), m_current_shift) |
| 42 | #define SHIFTREG_FALLING_EDGE(bit) FALLING_EDGE(bit, (m_last_shift ^ m_current_shift), m_current_shift) |
| 44 | 43 | |
| 45 | | #define SHIFTREG2_RISING_EDGE(bit) RISING_EDGE(bit, (state->m_last_shift2 ^ state->m_current_shift), state->m_current_shift) |
| 46 | | #define SHIFTREG2_FALLING_EDGE(bit) FALLING_EDGE(bit, (state->m_last_shift2 ^ state->m_current_shift), state->m_current_shift) |
| 44 | #define SHIFTREG2_RISING_EDGE(bit) RISING_EDGE(bit, (m_last_shift2 ^ m_current_shift), m_current_shift) |
| 45 | #define SHIFTREG2_FALLING_EDGE(bit) FALLING_EDGE(bit, (m_last_shift2 ^ m_current_shift), m_current_shift) |
| 47 | 46 | |
| 48 | 47 | |
| 49 | 48 | /************************************* |
| r31819 | r31820 | |
| 61 | 60 | |
| 62 | 61 | /* if something changed, call the sound subroutine */ |
| 63 | 62 | if ((m_sound_control != oldval) && m_sound_handler) |
| 64 | | (*m_sound_handler)(machine(), m_sound_control, m_sound_control ^ oldval); |
| 63 | (this->*m_sound_handler)(m_sound_control, m_sound_control ^ oldval); |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | 66 | |
| r31819 | r31820 | |
| 88 | 87 | } |
| 89 | 88 | |
| 90 | 89 | |
| 91 | | static void generic_init(running_machine &machine, void (*callback)(running_machine &,UINT8, UINT8)) |
| 90 | void cinemat_state::generic_init(sound_func sound_handler) |
| 92 | 91 | { |
| 93 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 94 | | |
| 95 | 92 | /* set the sound handler */ |
| 96 | | state->m_sound_handler = callback; |
| 93 | m_sound_handler = sound_handler; |
| 97 | 94 | |
| 98 | 95 | /* reset sound control */ |
| 99 | | state->m_sound_control = 0x9f; |
| 96 | m_sound_control = 0x9f; |
| 100 | 97 | |
| 101 | 98 | /* reset shift register values */ |
| 102 | | state->m_current_shift = 0xffff; |
| 103 | | state->m_last_shift = 0xffff; |
| 104 | | state->m_last_shift2 = 0xffff; |
| 99 | m_current_shift = 0xffff; |
| 100 | m_last_shift = 0xffff; |
| 101 | m_last_shift2 = 0xffff; |
| 105 | 102 | |
| 106 | 103 | /* reset frame counters */ |
| 107 | | state->m_last_frame = 0; |
| 104 | m_last_frame = 0; |
| 108 | 105 | |
| 109 | 106 | /* reset Star Castle pitch */ |
| 110 | | state->m_current_pitch = 0x10000; |
| 107 | m_current_pitch = 0x10000; |
| 111 | 108 | } |
| 112 | 109 | |
| 113 | 110 | |
| r31819 | r31820 | |
| 138 | 135 | spacewar_sample_names |
| 139 | 136 | }; |
| 140 | 137 | |
| 141 | | static void spacewar_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 138 | void cinemat_state::spacewar_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 142 | 139 | { |
| 143 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 144 | | |
| 145 | 140 | /* Explosion - rising edge */ |
| 146 | 141 | if (SOUNDVAL_RISING_EDGE(0x01)) |
| 147 | | samples->start(0, (machine.rand() & 1) ? 0 : 6); |
| 142 | m_samples->start(0, (machine().rand() & 1) ? 0 : 6); |
| 148 | 143 | |
| 149 | 144 | /* Fire sound - rising edge */ |
| 150 | 145 | if (SOUNDVAL_RISING_EDGE(0x02)) |
| 151 | | samples->start(1, (machine.rand() & 1) ? 1 : 7); |
| 146 | m_samples->start(1, (machine().rand() & 1) ? 1 : 7); |
| 152 | 147 | |
| 153 | 148 | /* Player 1 thrust - 0=on, 1=off */ |
| 154 | 149 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 155 | | samples->start(3, 3, true); |
| 150 | m_samples->start(3, 3, true); |
| 156 | 151 | if (SOUNDVAL_RISING_EDGE(0x04)) |
| 157 | | samples->stop(3); |
| 152 | m_samples->stop(3); |
| 158 | 153 | |
| 159 | 154 | /* Player 2 thrust - 0=on, 1-off */ |
| 160 | 155 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 161 | | samples->start(4, 4, true); |
| 156 | m_samples->start(4, 4, true); |
| 162 | 157 | if (SOUNDVAL_RISING_EDGE(0x08)) |
| 163 | | samples->stop(4); |
| 158 | m_samples->stop(4); |
| 164 | 159 | |
| 165 | 160 | /* Mute - 0=off, 1=on */ |
| 166 | 161 | if (SOUNDVAL_FALLING_EDGE(0x10)) |
| 167 | | samples->start(2, 2, true); /* play idle sound */ |
| 162 | m_samples->start(2, 2, true); /* play idle sound */ |
| 168 | 163 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 169 | 164 | { |
| 170 | 165 | int i; |
| r31819 | r31820 | |
| 172 | 167 | /* turn off all but the idle sound */ |
| 173 | 168 | for (i = 0; i < 5; i++) |
| 174 | 169 | if (i != 2) |
| 175 | | samples->stop(i); |
| 170 | m_samples->stop(i); |
| 176 | 171 | |
| 177 | 172 | /* Pop when board is shut off */ |
| 178 | | samples->start(2, 5); |
| 173 | m_samples->start(2, 5); |
| 179 | 174 | } |
| 180 | 175 | } |
| 181 | 176 | |
| 182 | 177 | SOUND_RESET_MEMBER( cinemat_state, spacewar ) |
| 183 | 178 | { |
| 184 | | generic_init(machine(), spacewar_sound_w); |
| 179 | generic_init(&cinemat_state::spacewar_sound_w); |
| 185 | 180 | } |
| 186 | 181 | |
| 187 | 182 | MACHINE_CONFIG_FRAGMENT( spacewar_sound ) |
| r31819 | r31820 | |
| 216 | 211 | barrier_sample_names |
| 217 | 212 | }; |
| 218 | 213 | |
| 219 | | static void barrier_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 214 | void cinemat_state::barrier_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 220 | 215 | { |
| 221 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 222 | | |
| 223 | 216 | /* Player die - rising edge */ |
| 224 | 217 | if (SOUNDVAL_RISING_EDGE(0x01)) |
| 225 | | samples->start(0, 0); |
| 218 | m_samples->start(0, 0); |
| 226 | 219 | |
| 227 | 220 | /* Player move - falling edge */ |
| 228 | 221 | if (SOUNDVAL_FALLING_EDGE(0x02)) |
| 229 | | samples->start(1, 1); |
| 222 | m_samples->start(1, 1); |
| 230 | 223 | |
| 231 | 224 | /* Enemy move - falling edge */ |
| 232 | 225 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 233 | | samples->start(2, 2); |
| 226 | m_samples->start(2, 2); |
| 234 | 227 | } |
| 235 | 228 | |
| 236 | 229 | SOUND_RESET_MEMBER( cinemat_state, barrier ) |
| 237 | 230 | { |
| 238 | | generic_init(machine(), barrier_sound_w); |
| 231 | generic_init(&cinemat_state::barrier_sound_w); |
| 239 | 232 | } |
| 240 | 233 | |
| 241 | 234 | MACHINE_CONFIG_FRAGMENT( barrier_sound ) |
| r31819 | r31820 | |
| 268 | 261 | speedfrk_sample_names |
| 269 | 262 | }; |
| 270 | 263 | |
| 271 | | static void speedfrk_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 264 | void cinemat_state::speedfrk_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 272 | 265 | { |
| 273 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 274 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 275 | | |
| 276 | 266 | /* on the falling edge of bit 0x08, clock the inverse of bit 0x04 into the top of the shiftreg */ |
| 277 | 267 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 278 | 268 | { |
| 279 | | state->m_current_shift = ((state->m_current_shift >> 1) & 0x7fff) | ((~sound_val << 13) & 1); |
| 269 | m_current_shift = ((m_current_shift >> 1) & 0x7fff) | ((~sound_val << 13) & 1); |
| 280 | 270 | /* high 12 bits control the frequency - counts from value to $FFF, carry triggers */ |
| 281 | 271 | /* another counter */ |
| 282 | 272 | |
| r31819 | r31820 | |
| 285 | 275 | |
| 286 | 276 | /* off-road - 1=on, 0=off */ |
| 287 | 277 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 288 | | samples->start(0, 0, true); |
| 278 | m_samples->start(0, 0, true); |
| 289 | 279 | if (SOUNDVAL_FALLING_EDGE(0x10)) |
| 290 | | samples->stop(0); |
| 280 | m_samples->stop(0); |
| 291 | 281 | |
| 292 | 282 | /* start LED is controlled by bit 0x02 */ |
| 293 | | set_led_status(machine, 0, ~sound_val & 0x02); |
| 283 | set_led_status(machine(), 0, ~sound_val & 0x02); |
| 294 | 284 | } |
| 295 | 285 | |
| 296 | 286 | SOUND_RESET_MEMBER( cinemat_state, speedfrk ) |
| 297 | 287 | { |
| 298 | | generic_init(machine(), speedfrk_sound_w); |
| 288 | generic_init(&cinemat_state::speedfrk_sound_w); |
| 299 | 289 | } |
| 300 | 290 | |
| 301 | 291 | MACHINE_CONFIG_FRAGMENT( speedfrk_sound ) |
| r31819 | r31820 | |
| 333 | 323 | starhawk_sample_names |
| 334 | 324 | }; |
| 335 | 325 | |
| 336 | | static void starhawk_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 326 | void cinemat_state::starhawk_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 337 | 327 | { |
| 338 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 339 | | |
| 340 | 328 | /* explosion - falling edge */ |
| 341 | 329 | if (SOUNDVAL_FALLING_EDGE(0x01)) |
| 342 | | samples->start(0, 0); |
| 330 | m_samples->start(0, 0); |
| 343 | 331 | |
| 344 | 332 | /* right laser - falling edge */ |
| 345 | 333 | if (SOUNDVAL_FALLING_EDGE(0x02)) |
| 346 | | samples->start(1, 1); |
| 334 | m_samples->start(1, 1); |
| 347 | 335 | |
| 348 | 336 | /* left laser - falling edge */ |
| 349 | 337 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 350 | | samples->start(2, 2); |
| 338 | m_samples->start(2, 2); |
| 351 | 339 | |
| 352 | 340 | /* K - 0=on, 1=off */ |
| 353 | 341 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 354 | | samples->start(3, 3, true); |
| 342 | m_samples->start(3, 3, true); |
| 355 | 343 | if (SOUNDVAL_RISING_EDGE(0x08)) |
| 356 | | samples->stop(3); |
| 344 | m_samples->stop(3); |
| 357 | 345 | |
| 358 | 346 | /* master - 0=on, 1=off */ |
| 359 | 347 | if (SOUNDVAL_FALLING_EDGE(0x10)) |
| 360 | | samples->start(4, 4, true); |
| 348 | m_samples->start(4, 4, true); |
| 361 | 349 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 362 | | samples->stop(4); |
| 350 | m_samples->stop(4); |
| 363 | 351 | |
| 364 | 352 | /* K exit - 1=on, 0=off */ |
| 365 | 353 | if (SOUNDVAL_RISING_EDGE(0x80)) |
| 366 | | samples->start(3, 5, true); |
| 354 | m_samples->start(3, 5, true); |
| 367 | 355 | if (SOUNDVAL_FALLING_EDGE(0x80)) |
| 368 | | samples->stop(3); |
| 356 | m_samples->stop(3); |
| 369 | 357 | } |
| 370 | 358 | |
| 371 | 359 | SOUND_RESET_MEMBER( cinemat_state, starhawk ) |
| 372 | 360 | { |
| 373 | | generic_init(machine(), starhawk_sound_w); |
| 361 | generic_init(&cinemat_state::starhawk_sound_w); |
| 374 | 362 | } |
| 375 | 363 | |
| 376 | 364 | MACHINE_CONFIG_FRAGMENT( starhawk_sound ) |
| r31819 | r31820 | |
| 408 | 396 | sundance_sample_names |
| 409 | 397 | }; |
| 410 | 398 | |
| 411 | | static void sundance_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 399 | void cinemat_state::sundance_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 412 | 400 | { |
| 413 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 414 | | |
| 415 | 401 | /* bong - falling edge */ |
| 416 | 402 | if (SOUNDVAL_FALLING_EDGE(0x01)) |
| 417 | | samples->start(0, 0); |
| 403 | m_samples->start(0, 0); |
| 418 | 404 | |
| 419 | 405 | /* whoosh - falling edge */ |
| 420 | 406 | if (SOUNDVAL_FALLING_EDGE(0x02)) |
| 421 | | samples->start(1, 1); |
| 407 | m_samples->start(1, 1); |
| 422 | 408 | |
| 423 | 409 | /* explosion - falling edge */ |
| 424 | 410 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 425 | | samples->start(2, 2); |
| 411 | m_samples->start(2, 2); |
| 426 | 412 | |
| 427 | 413 | /* ping - falling edge */ |
| 428 | 414 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 429 | | samples->start(3, 3); |
| 415 | m_samples->start(3, 3); |
| 430 | 416 | |
| 431 | 417 | /* ping - falling edge */ |
| 432 | 418 | if (SOUNDVAL_FALLING_EDGE(0x10)) |
| 433 | | samples->start(4, 4); |
| 419 | m_samples->start(4, 4); |
| 434 | 420 | |
| 435 | 421 | /* hatch - falling edge */ |
| 436 | 422 | if (SOUNDVAL_FALLING_EDGE(0x80)) |
| 437 | | samples->start(5, 5); |
| 423 | m_samples->start(5, 5); |
| 438 | 424 | } |
| 439 | 425 | |
| 440 | 426 | SOUND_RESET_MEMBER( cinemat_state, sundance ) |
| 441 | 427 | { |
| 442 | | generic_init(machine(), sundance_sound_w); |
| 428 | generic_init(&cinemat_state::sundance_sound_w); |
| 443 | 429 | } |
| 444 | 430 | |
| 445 | 431 | MACHINE_CONFIG_FRAGMENT( sundance_sound ) |
| r31819 | r31820 | |
| 477 | 463 | tailg_sample_names |
| 478 | 464 | }; |
| 479 | 465 | |
| 480 | | static void tailg_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 466 | void cinemat_state::tailg_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 481 | 467 | { |
| 482 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 483 | 468 | /* the falling edge of bit 0x10 clocks bit 0x08 into the mux selected by bits 0x07 */ |
| 484 | 469 | if (SOUNDVAL_FALLING_EDGE(0x10)) |
| 485 | 470 | { |
| 486 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 487 | | |
| 488 | 471 | /* update the shift register (actually just a simple mux) */ |
| 489 | | state->m_current_shift = (state->m_current_shift & ~(1 << (sound_val & 7))) | (((sound_val >> 3) & 1) << (sound_val & 7)); |
| 472 | m_current_shift = (m_current_shift & ~(1 << (sound_val & 7))) | (((sound_val >> 3) & 1) << (sound_val & 7)); |
| 490 | 473 | |
| 491 | 474 | /* explosion - falling edge */ |
| 492 | 475 | if (SHIFTREG_FALLING_EDGE(0x01)) |
| 493 | | samples->start(0, 0); |
| 476 | m_samples->start(0, 0); |
| 494 | 477 | |
| 495 | 478 | /* rumble - 0=on, 1=off */ |
| 496 | 479 | if (SHIFTREG_FALLING_EDGE(0x02)) |
| 497 | | samples->start(1, 1, true); |
| 480 | m_samples->start(1, 1, true); |
| 498 | 481 | if (SHIFTREG_RISING_EDGE(0x02)) |
| 499 | | samples->stop(1); |
| 482 | m_samples->stop(1); |
| 500 | 483 | |
| 501 | 484 | /* laser - 0=on, 1=off */ |
| 502 | 485 | if (SHIFTREG_FALLING_EDGE(0x04)) |
| 503 | | samples->start(2, 2, true); |
| 486 | m_samples->start(2, 2, true); |
| 504 | 487 | if (SHIFTREG_RISING_EDGE(0x04)) |
| 505 | | samples->stop(2); |
| 488 | m_samples->stop(2); |
| 506 | 489 | |
| 507 | 490 | /* shield - 0=on, 1=off */ |
| 508 | 491 | if (SHIFTREG_FALLING_EDGE(0x08)) |
| 509 | | samples->start(3, 3, true); |
| 492 | m_samples->start(3, 3, true); |
| 510 | 493 | if (SHIFTREG_RISING_EDGE(0x08)) |
| 511 | | samples->stop(3); |
| 494 | m_samples->stop(3); |
| 512 | 495 | |
| 513 | 496 | /* bounce - falling edge */ |
| 514 | 497 | if (SHIFTREG_FALLING_EDGE(0x10)) |
| 515 | | samples->start(4, 4); |
| 498 | m_samples->start(4, 4); |
| 516 | 499 | |
| 517 | 500 | /* hyperspace - falling edge */ |
| 518 | 501 | if (SHIFTREG_FALLING_EDGE(0x20)) |
| 519 | | samples->start(5, 5); |
| 502 | m_samples->start(5, 5); |
| 520 | 503 | |
| 521 | 504 | /* LED */ |
| 522 | | set_led_status(machine, 0, state->m_current_shift & 0x40); |
| 505 | set_led_status(machine(), 0, m_current_shift & 0x40); |
| 523 | 506 | |
| 524 | 507 | /* remember the previous value */ |
| 525 | | state->m_last_shift = state->m_current_shift; |
| 508 | m_last_shift = m_current_shift; |
| 526 | 509 | } |
| 527 | 510 | } |
| 528 | 511 | |
| 529 | 512 | SOUND_RESET_MEMBER( cinemat_state, tailg ) |
| 530 | 513 | { |
| 531 | | generic_init(machine(), tailg_sound_w); |
| 514 | generic_init(&cinemat_state::tailg_sound_w); |
| 532 | 515 | } |
| 533 | 516 | |
| 534 | 517 | MACHINE_CONFIG_FRAGMENT( tailg_sound ) |
| r31819 | r31820 | |
| 565 | 548 | warrior_sample_names |
| 566 | 549 | }; |
| 567 | 550 | |
| 568 | | static void warrior_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 551 | void cinemat_state::warrior_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 569 | 552 | { |
| 570 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 571 | | |
| 572 | 553 | /* normal level - 0=on, 1=off */ |
| 573 | 554 | if (SOUNDVAL_FALLING_EDGE(0x01)) |
| 574 | | samples->start(0, 0, true); |
| 555 | m_samples->start(0, 0, true); |
| 575 | 556 | if (SOUNDVAL_RISING_EDGE(0x01)) |
| 576 | | samples->stop(0); |
| 557 | m_samples->stop(0); |
| 577 | 558 | |
| 578 | 559 | /* hi level - 0=on, 1=off */ |
| 579 | 560 | if (SOUNDVAL_FALLING_EDGE(0x02)) |
| 580 | | samples->start(1, 1, true); |
| 561 | m_samples->start(1, 1, true); |
| 581 | 562 | if (SOUNDVAL_RISING_EDGE(0x02)) |
| 582 | | samples->stop(1); |
| 563 | m_samples->stop(1); |
| 583 | 564 | |
| 584 | 565 | /* explosion - falling edge */ |
| 585 | 566 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 586 | | samples->start(2, 2); |
| 567 | m_samples->start(2, 2); |
| 587 | 568 | |
| 588 | 569 | /* fall - falling edge */ |
| 589 | 570 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 590 | | samples->start(3, 3); |
| 571 | m_samples->start(3, 3); |
| 591 | 572 | |
| 592 | 573 | /* appear - falling edge */ |
| 593 | 574 | if (SOUNDVAL_FALLING_EDGE(0x10)) |
| 594 | | samples->start(4, 4); |
| 575 | m_samples->start(4, 4); |
| 595 | 576 | } |
| 596 | 577 | |
| 597 | 578 | SOUND_RESET_MEMBER( cinemat_state, warrior ) |
| 598 | 579 | { |
| 599 | | generic_init(machine(), warrior_sound_w); |
| 580 | generic_init(&cinemat_state::warrior_sound_w); |
| 600 | 581 | } |
| 601 | 582 | |
| 602 | 583 | MACHINE_CONFIG_FRAGMENT( warrior_sound ) |
| r31819 | r31820 | |
| 635 | 616 | armora_sample_names |
| 636 | 617 | }; |
| 637 | 618 | |
| 638 | | static void armora_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 619 | void cinemat_state::armora_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 639 | 620 | { |
| 640 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 641 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 642 | | |
| 643 | 621 | /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ |
| 644 | 622 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 645 | | state->m_current_shift = ((state->m_current_shift >> 1) & 0x7f) | (sound_val & 0x80); |
| 623 | m_current_shift = ((m_current_shift >> 1) & 0x7f) | (sound_val & 0x80); |
| 646 | 624 | |
| 647 | 625 | /* execute on the rising edge of bit 0x01 */ |
| 648 | 626 | if (SOUNDVAL_RISING_EDGE(0x01)) |
| r31819 | r31820 | |
| 651 | 629 | |
| 652 | 630 | /* lo explosion - falling edge */ |
| 653 | 631 | if (SHIFTREG_FALLING_EDGE(0x10)) |
| 654 | | samples->start(0, 0); |
| 632 | m_samples->start(0, 0); |
| 655 | 633 | |
| 656 | 634 | /* jeep fire - falling edge */ |
| 657 | 635 | if (SHIFTREG_FALLING_EDGE(0x20)) |
| 658 | | samples->start(1, 1); |
| 636 | m_samples->start(1, 1); |
| 659 | 637 | |
| 660 | 638 | /* hi explosion - falling edge */ |
| 661 | 639 | if (SHIFTREG_FALLING_EDGE(0x40)) |
| 662 | | samples->start(2, 2); |
| 640 | m_samples->start(2, 2); |
| 663 | 641 | |
| 664 | 642 | /* tank fire - falling edge */ |
| 665 | 643 | if (SHIFTREG_FALLING_EDGE(0x80)) |
| 666 | | samples->start(3, 3); |
| 644 | m_samples->start(3, 3); |
| 667 | 645 | |
| 668 | 646 | /* remember the previous value */ |
| 669 | | state->m_last_shift = state->m_current_shift; |
| 647 | m_last_shift = m_current_shift; |
| 670 | 648 | } |
| 671 | 649 | |
| 672 | 650 | /* tank sound - 0=on, 1=off */ |
| 673 | 651 | /* still not totally correct - should be multiple speeds based on remaining bits in shift reg */ |
| 674 | 652 | if (SOUNDVAL_FALLING_EDGE(0x02)) |
| 675 | | samples->start(4, 4, true); |
| 653 | m_samples->start(4, 4, true); |
| 676 | 654 | if (SOUNDVAL_RISING_EDGE(0x02)) |
| 677 | | samples->stop(4); |
| 655 | m_samples->stop(4); |
| 678 | 656 | |
| 679 | 657 | /* beep sound - 0=on, 1=off */ |
| 680 | 658 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 681 | | samples->start(5, 5, true); |
| 659 | m_samples->start(5, 5, true); |
| 682 | 660 | if (SOUNDVAL_RISING_EDGE(0x04)) |
| 683 | | samples->stop(5); |
| 661 | m_samples->stop(5); |
| 684 | 662 | |
| 685 | 663 | /* chopper sound - 0=on, 1=off */ |
| 686 | 664 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 687 | | samples->start(6, 6, true); |
| 665 | m_samples->start(6, 6, true); |
| 688 | 666 | if (SOUNDVAL_RISING_EDGE(0x08)) |
| 689 | | samples->stop(6); |
| 667 | m_samples->stop(6); |
| 690 | 668 | } |
| 691 | 669 | |
| 692 | 670 | SOUND_RESET_MEMBER( cinemat_state, armora ) |
| 693 | 671 | { |
| 694 | | generic_init(machine(), armora_sound_w); |
| 672 | generic_init(&cinemat_state::armora_sound_w); |
| 695 | 673 | } |
| 696 | 674 | |
| 697 | 675 | MACHINE_CONFIG_FRAGMENT( armora_sound ) |
| r31819 | r31820 | |
| 736 | 714 | ripoff_sample_names |
| 737 | 715 | }; |
| 738 | 716 | |
| 739 | | static void ripoff_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 717 | void cinemat_state::ripoff_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 740 | 718 | { |
| 741 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 742 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 743 | | |
| 744 | 719 | /* on the rising edge of bit 0x02, clock bit 0x01 into the shift register */ |
| 745 | 720 | if (SOUNDVAL_RISING_EDGE(0x02)) |
| 746 | | state->m_current_shift = ((state->m_current_shift >> 1) & 0x7f) | ((sound_val << 7) & 0x80); |
| 721 | m_current_shift = ((m_current_shift >> 1) & 0x7f) | ((sound_val << 7) & 0x80); |
| 747 | 722 | |
| 748 | 723 | /* execute on the rising edge of bit 0x04 */ |
| 749 | 724 | if (SOUNDVAL_RISING_EDGE(0x04)) |
| 750 | 725 | { |
| 751 | 726 | /* background - 0=on, 1=off, selected by bits 0x38 */ |
| 752 | | if ((((state->m_current_shift ^ state->m_last_shift) & 0x38) && !(state->m_current_shift & 0x04)) || SHIFTREG_FALLING_EDGE(0x04)) |
| 753 | | samples->start(5, 5 + ((state->m_current_shift >> 5) & 7), true); |
| 727 | if ((((m_current_shift ^ m_last_shift) & 0x38) && !(m_current_shift & 0x04)) || SHIFTREG_FALLING_EDGE(0x04)) |
| 728 | m_samples->start(5, 5 + ((m_current_shift >> 5) & 7), true); |
| 754 | 729 | if (SHIFTREG_RISING_EDGE(0x04)) |
| 755 | | samples->stop(5); |
| 730 | m_samples->stop(5); |
| 756 | 731 | |
| 757 | 732 | /* beep - falling edge */ |
| 758 | 733 | if (SHIFTREG_FALLING_EDGE(0x02)) |
| 759 | | samples->start(0, 0); |
| 734 | m_samples->start(0, 0); |
| 760 | 735 | |
| 761 | 736 | /* motor - 0=on, 1=off */ |
| 762 | 737 | if (SHIFTREG_FALLING_EDGE(0x01)) |
| 763 | | samples->start(1, 1, true); |
| 738 | m_samples->start(1, 1, true); |
| 764 | 739 | if (SHIFTREG_RISING_EDGE(0x01)) |
| 765 | | samples->stop(1); |
| 740 | m_samples->stop(1); |
| 766 | 741 | |
| 767 | 742 | /* remember the previous value */ |
| 768 | | state->m_last_shift = state->m_current_shift; |
| 743 | m_last_shift = m_current_shift; |
| 769 | 744 | } |
| 770 | 745 | |
| 771 | 746 | /* torpedo - falling edge */ |
| 772 | 747 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 773 | | samples->start(2, 2); |
| 748 | m_samples->start(2, 2); |
| 774 | 749 | |
| 775 | 750 | /* laser - falling edge */ |
| 776 | 751 | if (SOUNDVAL_FALLING_EDGE(0x10)) |
| 777 | | samples->start(3, 3); |
| 752 | m_samples->start(3, 3); |
| 778 | 753 | |
| 779 | 754 | /* explosion - falling edge */ |
| 780 | 755 | if (SOUNDVAL_FALLING_EDGE(0x80)) |
| 781 | | samples->start(4, 4); |
| 756 | m_samples->start(4, 4); |
| 782 | 757 | } |
| 783 | 758 | |
| 784 | 759 | SOUND_RESET_MEMBER( cinemat_state, ripoff ) |
| 785 | 760 | { |
| 786 | | generic_init(machine(), ripoff_sound_w); |
| 761 | generic_init(&cinemat_state::ripoff_sound_w); |
| 787 | 762 | } |
| 788 | 763 | |
| 789 | 764 | MACHINE_CONFIG_FRAGMENT( ripoff_sound ) |
| r31819 | r31820 | |
| 823 | 798 | starcas_sample_names |
| 824 | 799 | }; |
| 825 | 800 | |
| 826 | | static void starcas_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 801 | void cinemat_state::starcas_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 827 | 802 | { |
| 828 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 829 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 830 | 803 | UINT32 target_pitch; |
| 831 | 804 | |
| 832 | 805 | /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ |
| 833 | 806 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 834 | | state->m_current_shift = ((state->m_current_shift >> 1) & 0x7f) | (sound_val & 0x80); |
| 807 | m_current_shift = ((m_current_shift >> 1) & 0x7f) | (sound_val & 0x80); |
| 835 | 808 | |
| 836 | 809 | /* execute on the rising edge of bit 0x01 */ |
| 837 | 810 | if (SOUNDVAL_RISING_EDGE(0x01)) |
| 838 | 811 | { |
| 839 | 812 | /* fireball - falling edge */ |
| 840 | 813 | if (SHIFTREG_FALLING_EDGE(0x80)) |
| 841 | | samples->start(0, 0); |
| 814 | m_samples->start(0, 0); |
| 842 | 815 | |
| 843 | 816 | /* shield hit - falling edge */ |
| 844 | 817 | if (SHIFTREG_FALLING_EDGE(0x40)) |
| 845 | | samples->start(1, 1); |
| 818 | m_samples->start(1, 1); |
| 846 | 819 | |
| 847 | 820 | /* star sound - 0=off, 1=on */ |
| 848 | 821 | if (SHIFTREG_RISING_EDGE(0x20)) |
| 849 | | samples->start(2, 2, true); |
| 822 | m_samples->start(2, 2, true); |
| 850 | 823 | if (SHIFTREG_FALLING_EDGE(0x20)) |
| 851 | | samples->stop(2); |
| 824 | m_samples->stop(2); |
| 852 | 825 | |
| 853 | 826 | /* thrust sound - 1=off, 0=on*/ |
| 854 | 827 | if (SHIFTREG_FALLING_EDGE(0x10)) |
| 855 | | samples->start(3, 3, true); |
| 828 | m_samples->start(3, 3, true); |
| 856 | 829 | if (SHIFTREG_RISING_EDGE(0x10)) |
| 857 | | samples->stop(3); |
| 830 | m_samples->stop(3); |
| 858 | 831 | |
| 859 | 832 | /* drone - 1=off, 0=on */ |
| 860 | 833 | if (SHIFTREG_FALLING_EDGE(0x08)) |
| 861 | | samples->start(4, 4, true); |
| 834 | m_samples->start(4, 4, true); |
| 862 | 835 | if (SHIFTREG_RISING_EDGE(0x08)) |
| 863 | | samples->stop(4); |
| 836 | m_samples->stop(4); |
| 864 | 837 | |
| 865 | 838 | /* latch the drone pitch */ |
| 866 | | target_pitch = (state->m_current_shift & 7) + ((state->m_current_shift & 2) << 2); |
| 839 | target_pitch = (m_current_shift & 7) + ((m_current_shift & 2) << 2); |
| 867 | 840 | target_pitch = 0x5800 + (target_pitch << 12); |
| 868 | 841 | |
| 869 | 842 | /* once per frame slide the pitch toward the target */ |
| 870 | | if (machine.first_screen()->frame_number() > state->m_last_frame) |
| 843 | if (m_screen->frame_number() > m_last_frame) |
| 871 | 844 | { |
| 872 | | if (state->m_current_pitch > target_pitch) |
| 873 | | state->m_current_pitch -= 225; |
| 874 | | if (state->m_current_pitch < target_pitch) |
| 875 | | state->m_current_pitch += 150; |
| 876 | | samples->set_frequency(4, state->m_current_pitch); |
| 877 | | state->m_last_frame = machine.first_screen()->frame_number(); |
| 845 | if (m_current_pitch > target_pitch) |
| 846 | m_current_pitch -= 225; |
| 847 | if (m_current_pitch < target_pitch) |
| 848 | m_current_pitch += 150; |
| 849 | m_samples->set_frequency(4, m_current_pitch); |
| 850 | m_last_frame = m_screen->frame_number(); |
| 878 | 851 | } |
| 879 | 852 | |
| 880 | 853 | /* remember the previous value */ |
| 881 | | state->m_last_shift = state->m_current_shift; |
| 854 | m_last_shift = m_current_shift; |
| 882 | 855 | } |
| 883 | 856 | |
| 884 | 857 | /* loud explosion - falling edge */ |
| 885 | 858 | if (SOUNDVAL_FALLING_EDGE(0x02)) |
| 886 | | samples->start(5, 5); |
| 859 | m_samples->start(5, 5); |
| 887 | 860 | |
| 888 | 861 | /* soft explosion - falling edge */ |
| 889 | 862 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 890 | | samples->start(6, 6); |
| 863 | m_samples->start(6, 6); |
| 891 | 864 | |
| 892 | 865 | /* player fire - falling edge */ |
| 893 | 866 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 894 | | samples->start(7, 7); |
| 867 | m_samples->start(7, 7); |
| 895 | 868 | } |
| 896 | 869 | |
| 897 | 870 | SOUND_RESET_MEMBER( cinemat_state, starcas ) |
| 898 | 871 | { |
| 899 | | generic_init(machine(), starcas_sound_w); |
| 872 | generic_init(&cinemat_state::starcas_sound_w); |
| 900 | 873 | } |
| 901 | 874 | |
| 902 | 875 | MACHINE_CONFIG_FRAGMENT( starcas_sound ) |
| r31819 | r31820 | |
| 936 | 909 | solarq_sample_names |
| 937 | 910 | }; |
| 938 | 911 | |
| 939 | | static void solarq_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 912 | void cinemat_state::solarq_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 940 | 913 | { |
| 941 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 942 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 943 | | |
| 944 | 914 | /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ |
| 945 | 915 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 946 | | state->m_current_shift = ((state->m_current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); |
| 916 | m_current_shift = ((m_current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); |
| 947 | 917 | |
| 948 | 918 | /* execute on the rising edge of bit 0x02 */ |
| 949 | 919 | if (SOUNDVAL_RISING_EDGE(0x02)) |
| 950 | 920 | { |
| 951 | 921 | /* only the upper 8 bits matter */ |
| 952 | | state->m_current_shift >>= 8; |
| 922 | m_current_shift >>= 8; |
| 953 | 923 | |
| 954 | 924 | /* loud explosion - falling edge */ |
| 955 | 925 | if (SHIFTREG_FALLING_EDGE(0x80)) |
| 956 | | samples->start(0, 0); |
| 926 | m_samples->start(0, 0); |
| 957 | 927 | |
| 958 | 928 | /* soft explosion - falling edge */ |
| 959 | 929 | if (SHIFTREG_FALLING_EDGE(0x40)) |
| 960 | | samples->start(1, 1); |
| 930 | m_samples->start(1, 1); |
| 961 | 931 | |
| 962 | 932 | /* thrust - 0=on, 1=off */ |
| 963 | 933 | if (SHIFTREG_FALLING_EDGE(0x20)) |
| 964 | 934 | { |
| 965 | | state->m_target_volume = 1.0; |
| 966 | | if (!samples->playing(2)) |
| 967 | | samples->start(2, 2, true); |
| 935 | m_target_volume = 1.0; |
| 936 | if (!m_samples->playing(2)) |
| 937 | m_samples->start(2, 2, true); |
| 968 | 938 | } |
| 969 | 939 | if (SHIFTREG_RISING_EDGE(0x20)) |
| 970 | | state->m_target_volume = 0; |
| 940 | m_target_volume = 0; |
| 971 | 941 | |
| 972 | 942 | /* ramp the thrust volume */ |
| 973 | | if (samples->playing(2) && machine.first_screen()->frame_number() > state->m_last_frame) |
| 943 | if (m_samples->playing(2) && m_screen->frame_number() > m_last_frame) |
| 974 | 944 | { |
| 975 | | if (state->m_current_volume > state->m_target_volume) |
| 976 | | state->m_current_volume -= 0.078f; |
| 977 | | if (state->m_current_volume < state->m_target_volume) |
| 978 | | state->m_current_volume += 0.078f; |
| 979 | | if (state->m_current_volume > 0) |
| 980 | | samples->set_volume(2, state->m_current_volume); |
| 945 | if (m_current_volume > m_target_volume) |
| 946 | m_current_volume -= 0.078f; |
| 947 | if (m_current_volume < m_target_volume) |
| 948 | m_current_volume += 0.078f; |
| 949 | if (m_current_volume > 0) |
| 950 | m_samples->set_volume(2, m_current_volume); |
| 981 | 951 | else |
| 982 | | samples->stop(2); |
| 983 | | state->m_last_frame = machine.first_screen()->frame_number(); |
| 952 | m_samples->stop(2); |
| 953 | m_last_frame = m_screen->frame_number(); |
| 984 | 954 | } |
| 985 | 955 | |
| 986 | 956 | /* fire - falling edge */ |
| 987 | 957 | if (SHIFTREG_FALLING_EDGE(0x10)) |
| 988 | | samples->start(3, 3); |
| 958 | m_samples->start(3, 3); |
| 989 | 959 | |
| 990 | 960 | /* capture - falling edge */ |
| 991 | 961 | if (SHIFTREG_FALLING_EDGE(0x08)) |
| 992 | | samples->start(4, 4); |
| 962 | m_samples->start(4, 4); |
| 993 | 963 | |
| 994 | 964 | /* nuke - 1=on, 0=off */ |
| 995 | 965 | if (SHIFTREG_RISING_EDGE(0x04)) |
| 996 | | samples->start(5, 5, true); |
| 966 | m_samples->start(5, 5, true); |
| 997 | 967 | if (SHIFTREG_FALLING_EDGE(0x04)) |
| 998 | | samples->stop(5); |
| 968 | m_samples->stop(5); |
| 999 | 969 | |
| 1000 | 970 | /* photon - falling edge */ |
| 1001 | 971 | if (SHIFTREG_FALLING_EDGE(0x02)) |
| 1002 | | samples->start(6, 6); |
| 972 | m_samples->start(6, 6); |
| 1003 | 973 | |
| 1004 | 974 | /* remember the previous value */ |
| 1005 | | state->m_last_shift = state->m_current_shift; |
| 975 | m_last_shift = m_current_shift; |
| 1006 | 976 | } |
| 1007 | 977 | |
| 1008 | 978 | /* clock music data on the rising edge of bit 0x01 */ |
| r31819 | r31820 | |
| 1012 | 982 | |
| 1013 | 983 | /* start/stop the music sample on the high bit */ |
| 1014 | 984 | if (SHIFTREG2_RISING_EDGE(0x8000)) |
| 1015 | | samples->start(7, 7, true); |
| 985 | m_samples->start(7, 7, true); |
| 1016 | 986 | if (SHIFTREG2_FALLING_EDGE(0x8000)) |
| 1017 | | samples->stop(7); |
| 987 | m_samples->stop(7); |
| 1018 | 988 | |
| 1019 | 989 | /* set the frequency */ |
| 1020 | | freq = 56818.181818 / (4096 - (state->m_current_shift & 0xfff)); |
| 1021 | | samples->set_frequency(7, 44100 * freq / 1050); |
| 990 | freq = 56818.181818 / (4096 - (m_current_shift & 0xfff)); |
| 991 | m_samples->set_frequency(7, 44100 * freq / 1050); |
| 1022 | 992 | |
| 1023 | 993 | /* set the volume */ |
| 1024 | | vol = (~state->m_current_shift >> 12) & 7; |
| 1025 | | samples->set_volume(7, vol / 7.0); |
| 994 | vol = (~m_current_shift >> 12) & 7; |
| 995 | m_samples->set_volume(7, vol / 7.0); |
| 1026 | 996 | |
| 1027 | 997 | /* remember the previous value */ |
| 1028 | | state->m_last_shift2 = state->m_current_shift; |
| 998 | m_last_shift2 = m_current_shift; |
| 1029 | 999 | } |
| 1030 | 1000 | } |
| 1031 | 1001 | |
| 1032 | 1002 | SOUND_RESET_MEMBER( cinemat_state, solarq ) |
| 1033 | 1003 | { |
| 1034 | | generic_init(machine(), solarq_sound_w); |
| 1004 | generic_init(&cinemat_state::solarq_sound_w); |
| 1035 | 1005 | } |
| 1036 | 1006 | |
| 1037 | 1007 | MACHINE_CONFIG_FRAGMENT( solarq_sound ) |
| r31819 | r31820 | |
| 1075 | 1045 | boxingb_sample_names |
| 1076 | 1046 | }; |
| 1077 | 1047 | |
| 1078 | | static void boxingb_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 1048 | void cinemat_state::boxingb_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 1079 | 1049 | { |
| 1080 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 1081 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 1082 | | |
| 1083 | 1050 | /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ |
| 1084 | 1051 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 1085 | | state->m_current_shift = ((state->m_current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); |
| 1052 | m_current_shift = ((m_current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); |
| 1086 | 1053 | |
| 1087 | 1054 | /* execute on the rising edge of bit 0x02 */ |
| 1088 | 1055 | if (SOUNDVAL_RISING_EDGE(0x02)) |
| 1089 | 1056 | { |
| 1090 | 1057 | /* only the upper 8 bits matter */ |
| 1091 | | state->m_current_shift >>= 8; |
| 1058 | m_current_shift >>= 8; |
| 1092 | 1059 | |
| 1093 | 1060 | /* soft explosion - falling edge */ |
| 1094 | 1061 | if (SHIFTREG_FALLING_EDGE(0x80)) |
| 1095 | | samples->start(0, 0); |
| 1062 | m_samples->start(0, 0); |
| 1096 | 1063 | |
| 1097 | 1064 | /* loud explosion - falling edge */ |
| 1098 | 1065 | if (SHIFTREG_FALLING_EDGE(0x40)) |
| 1099 | | samples->start(1, 1); |
| 1066 | m_samples->start(1, 1); |
| 1100 | 1067 | |
| 1101 | 1068 | /* chirping birds - 0=on, 1=off */ |
| 1102 | 1069 | if (SHIFTREG_FALLING_EDGE(0x20)) |
| 1103 | | samples->start(2, 2); |
| 1070 | m_samples->start(2, 2); |
| 1104 | 1071 | if (SHIFTREG_RISING_EDGE(0x20)) |
| 1105 | | samples->stop(2); |
| 1072 | m_samples->stop(2); |
| 1106 | 1073 | |
| 1107 | 1074 | /* egg cracking - falling edge */ |
| 1108 | 1075 | if (SHIFTREG_FALLING_EDGE(0x10)) |
| 1109 | | samples->start(3, 3); |
| 1076 | m_samples->start(3, 3); |
| 1110 | 1077 | |
| 1111 | 1078 | /* bug pushing A - rising edge */ |
| 1112 | 1079 | if (SHIFTREG_RISING_EDGE(0x08)) |
| 1113 | | samples->start(4, 4); |
| 1080 | m_samples->start(4, 4); |
| 1114 | 1081 | |
| 1115 | 1082 | /* bug pushing B - rising edge */ |
| 1116 | 1083 | if (SHIFTREG_RISING_EDGE(0x04)) |
| 1117 | | samples->start(5, 5); |
| 1084 | m_samples->start(5, 5); |
| 1118 | 1085 | |
| 1119 | 1086 | /* bug dying - falling edge */ |
| 1120 | 1087 | if (SHIFTREG_FALLING_EDGE(0x02)) |
| 1121 | | samples->start(6, 6); |
| 1088 | m_samples->start(6, 6); |
| 1122 | 1089 | |
| 1123 | 1090 | /* beetle on screen - falling edge */ |
| 1124 | 1091 | if (SHIFTREG_FALLING_EDGE(0x01)) |
| 1125 | | samples->start(7, 7); |
| 1092 | m_samples->start(7, 7); |
| 1126 | 1093 | |
| 1127 | 1094 | /* remember the previous value */ |
| 1128 | | state->m_last_shift = state->m_current_shift; |
| 1095 | m_last_shift = m_current_shift; |
| 1129 | 1096 | } |
| 1130 | 1097 | |
| 1131 | 1098 | /* clock music data on the rising edge of bit 0x01 */ |
| r31819 | r31820 | |
| 1135 | 1102 | |
| 1136 | 1103 | /* start/stop the music sample on the high bit */ |
| 1137 | 1104 | if (SHIFTREG2_RISING_EDGE(0x8000)) |
| 1138 | | samples->start(8, 8, true); |
| 1105 | m_samples->start(8, 8, true); |
| 1139 | 1106 | if (SHIFTREG2_FALLING_EDGE(0x8000)) |
| 1140 | | samples->stop(8); |
| 1107 | m_samples->stop(8); |
| 1141 | 1108 | |
| 1142 | 1109 | /* set the frequency */ |
| 1143 | | freq = 56818.181818 / (4096 - (state->m_current_shift & 0xfff)); |
| 1144 | | samples->set_frequency(8, 44100 * freq / 1050); |
| 1110 | freq = 56818.181818 / (4096 - (m_current_shift & 0xfff)); |
| 1111 | m_samples->set_frequency(8, 44100 * freq / 1050); |
| 1145 | 1112 | |
| 1146 | 1113 | /* set the volume */ |
| 1147 | | vol = (~state->m_current_shift >> 12) & 3; |
| 1148 | | samples->set_volume(8, vol / 3.0); |
| 1114 | vol = (~m_current_shift >> 12) & 3; |
| 1115 | m_samples->set_volume(8, vol / 3.0); |
| 1149 | 1116 | |
| 1150 | 1117 | /* cannon - falling edge */ |
| 1151 | 1118 | if (SHIFTREG2_RISING_EDGE(0x4000)) |
| 1152 | | samples->start(9, 9); |
| 1119 | m_samples->start(9, 9); |
| 1153 | 1120 | |
| 1154 | 1121 | /* remember the previous value */ |
| 1155 | | state->m_last_shift2 = state->m_current_shift; |
| 1122 | m_last_shift2 = m_current_shift; |
| 1156 | 1123 | } |
| 1157 | 1124 | |
| 1158 | 1125 | /* bounce - rising edge */ |
| 1159 | 1126 | if (SOUNDVAL_RISING_EDGE(0x04)) |
| 1160 | | samples->start(10, 10); |
| 1127 | m_samples->start(10, 10); |
| 1161 | 1128 | |
| 1162 | 1129 | /* bell - falling edge */ |
| 1163 | 1130 | if (SOUNDVAL_RISING_EDGE(0x08)) |
| 1164 | | samples->start(11, 11); |
| 1131 | m_samples->start(11, 11); |
| 1165 | 1132 | } |
| 1166 | 1133 | |
| 1167 | 1134 | SOUND_RESET_MEMBER( cinemat_state, boxingb ) |
| 1168 | 1135 | { |
| 1169 | | generic_init(machine(), boxingb_sound_w); |
| 1136 | generic_init(&cinemat_state::boxingb_sound_w); |
| 1170 | 1137 | } |
| 1171 | 1138 | |
| 1172 | 1139 | MACHINE_CONFIG_FRAGMENT( boxingb_sound ) |
| r31819 | r31820 | |
| 1206 | 1173 | wotw_sample_names |
| 1207 | 1174 | }; |
| 1208 | 1175 | |
| 1209 | | static void wotw_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 1176 | void cinemat_state::wotw_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 1210 | 1177 | { |
| 1211 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 1212 | | samples_device *samples = machine.device<samples_device>("samples"); |
| 1213 | 1178 | UINT32 target_pitch; |
| 1214 | 1179 | |
| 1215 | 1180 | /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ |
| 1216 | 1181 | if (SOUNDVAL_RISING_EDGE(0x10)) |
| 1217 | | state->m_current_shift = ((state->m_current_shift >> 1) & 0x7f) | (sound_val & 0x80); |
| 1182 | m_current_shift = ((m_current_shift >> 1) & 0x7f) | (sound_val & 0x80); |
| 1218 | 1183 | |
| 1219 | 1184 | /* execute on the rising edge of bit 0x01 */ |
| 1220 | 1185 | if (SOUNDVAL_RISING_EDGE(0x01)) |
| 1221 | 1186 | { |
| 1222 | 1187 | /* fireball - falling edge */ |
| 1223 | 1188 | if (SHIFTREG_FALLING_EDGE(0x80)) |
| 1224 | | samples->start(0, 0); |
| 1189 | m_samples->start(0, 0); |
| 1225 | 1190 | |
| 1226 | 1191 | /* shield hit - falling edge */ |
| 1227 | 1192 | if (SHIFTREG_FALLING_EDGE(0x40)) |
| 1228 | | samples->start(1, 1); |
| 1193 | m_samples->start(1, 1); |
| 1229 | 1194 | |
| 1230 | 1195 | /* star sound - 0=off, 1=on */ |
| 1231 | 1196 | if (SHIFTREG_RISING_EDGE(0x20)) |
| 1232 | | samples->start(2, 2, true); |
| 1197 | m_samples->start(2, 2, true); |
| 1233 | 1198 | if (SHIFTREG_FALLING_EDGE(0x20)) |
| 1234 | | samples->stop(2); |
| 1199 | m_samples->stop(2); |
| 1235 | 1200 | |
| 1236 | 1201 | /* thrust sound - 1=off, 0=on*/ |
| 1237 | 1202 | if (SHIFTREG_FALLING_EDGE(0x10)) |
| 1238 | | samples->start(3, 3, true); |
| 1203 | m_samples->start(3, 3, true); |
| 1239 | 1204 | if (SHIFTREG_RISING_EDGE(0x10)) |
| 1240 | | samples->stop(3); |
| 1205 | m_samples->stop(3); |
| 1241 | 1206 | |
| 1242 | 1207 | /* drone - 1=off, 0=on */ |
| 1243 | 1208 | if (SHIFTREG_FALLING_EDGE(0x08)) |
| 1244 | | samples->start(4, 4, true); |
| 1209 | m_samples->start(4, 4, true); |
| 1245 | 1210 | if (SHIFTREG_RISING_EDGE(0x08)) |
| 1246 | | samples->stop(4); |
| 1211 | m_samples->stop(4); |
| 1247 | 1212 | |
| 1248 | 1213 | /* latch the drone pitch */ |
| 1249 | | target_pitch = (state->m_current_shift & 7) + ((state->m_current_shift & 2) << 2); |
| 1214 | target_pitch = (m_current_shift & 7) + ((m_current_shift & 2) << 2); |
| 1250 | 1215 | target_pitch = 0x10000 + (target_pitch << 12); |
| 1251 | 1216 | |
| 1252 | 1217 | /* once per frame slide the pitch toward the target */ |
| 1253 | | if (machine.first_screen()->frame_number() > state->m_last_frame) |
| 1218 | if (m_screen->frame_number() > m_last_frame) |
| 1254 | 1219 | { |
| 1255 | | if (state->m_current_pitch > target_pitch) |
| 1256 | | state->m_current_pitch -= 300; |
| 1257 | | if (state->m_current_pitch < target_pitch) |
| 1258 | | state->m_current_pitch += 200; |
| 1259 | | samples->set_frequency(4, state->m_current_pitch); |
| 1260 | | state->m_last_frame = machine.first_screen()->frame_number(); |
| 1220 | if (m_current_pitch > target_pitch) |
| 1221 | m_current_pitch -= 300; |
| 1222 | if (m_current_pitch < target_pitch) |
| 1223 | m_current_pitch += 200; |
| 1224 | m_samples->set_frequency(4, m_current_pitch); |
| 1225 | m_last_frame = m_screen->frame_number(); |
| 1261 | 1226 | } |
| 1262 | 1227 | |
| 1263 | 1228 | /* remember the previous value */ |
| 1264 | | state->m_last_shift = state->m_current_shift; |
| 1229 | m_last_shift = m_current_shift; |
| 1265 | 1230 | } |
| 1266 | 1231 | |
| 1267 | 1232 | /* loud explosion - falling edge */ |
| 1268 | 1233 | if (SOUNDVAL_FALLING_EDGE(0x02)) |
| 1269 | | samples->start(5, 5); |
| 1234 | m_samples->start(5, 5); |
| 1270 | 1235 | |
| 1271 | 1236 | /* soft explosion - falling edge */ |
| 1272 | 1237 | if (SOUNDVAL_FALLING_EDGE(0x04)) |
| 1273 | | samples->start(6, 6); |
| 1238 | m_samples->start(6, 6); |
| 1274 | 1239 | |
| 1275 | 1240 | /* player fire - falling edge */ |
| 1276 | 1241 | if (SOUNDVAL_FALLING_EDGE(0x08)) |
| 1277 | | samples->start(7, 7); |
| 1242 | m_samples->start(7, 7); |
| 1278 | 1243 | } |
| 1279 | 1244 | |
| 1280 | 1245 | SOUND_RESET_MEMBER( cinemat_state, wotw ) |
| 1281 | 1246 | { |
| 1282 | | generic_init(machine(), wotw_sound_w); |
| 1247 | generic_init(&cinemat_state::wotw_sound_w); |
| 1283 | 1248 | } |
| 1284 | 1249 | |
| 1285 | 1250 | MACHINE_CONFIG_FRAGMENT( wotw_sound ) |
| r31819 | r31820 | |
| 1299 | 1264 | * |
| 1300 | 1265 | *************************************/ |
| 1301 | 1266 | |
| 1302 | | static TIMER_CALLBACK( synced_sound_w ) |
| 1267 | TIMER_CALLBACK_MEMBER( cinemat_state::synced_sound_w ) |
| 1303 | 1268 | { |
| 1304 | | cinemat_state *state = machine.driver_data<cinemat_state>(); |
| 1305 | | state->m_sound_fifo[state->m_sound_fifo_in] = param; |
| 1306 | | state->m_sound_fifo_in = (state->m_sound_fifo_in + 1) % 16; |
| 1269 | m_sound_fifo[m_sound_fifo_in] = param; |
| 1270 | m_sound_fifo_in = (m_sound_fifo_in + 1) % 16; |
| 1307 | 1271 | } |
| 1308 | 1272 | |
| 1309 | 1273 | |
| 1310 | | static void demon_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) |
| 1274 | void cinemat_state::demon_sound_w(UINT8 sound_val, UINT8 bits_changed) |
| 1311 | 1275 | { |
| 1312 | 1276 | /* all inputs are inverted */ |
| 1313 | 1277 | sound_val = ~sound_val; |
| 1314 | 1278 | |
| 1315 | 1279 | /* watch for a 0->1 edge on bit 4 ("shift in") to clock in the new data */ |
| 1316 | 1280 | if ((bits_changed & 0x10) && (sound_val & 0x10)) |
| 1317 | | machine.scheduler().synchronize(FUNC(synced_sound_w), sound_val & 0x0f); |
| 1281 | machine().scheduler().synchronize(timer_expired_delegate(FUNC(cinemat_state::synced_sound_w), this), sound_val & 0x0f); |
| 1318 | 1282 | } |
| 1319 | 1283 | |
| 1320 | 1284 | |
| r31819 | r31820 | |
| 1357 | 1321 | SOUND_RESET_MEMBER( cinemat_state, demon ) |
| 1358 | 1322 | { |
| 1359 | 1323 | /* generic init */ |
| 1360 | | generic_init(machine(), demon_sound_w); |
| 1324 | generic_init(&cinemat_state::demon_sound_w); |
| 1361 | 1325 | |
| 1362 | 1326 | /* reset the FIFO */ |
| 1363 | 1327 | m_sound_fifo_in = m_sound_fifo_out = 0; |
| r31819 | r31820 | |
| 1438 | 1402 | WRITE8_MEMBER(cinemat_state::qb3_sound_w) |
| 1439 | 1403 | { |
| 1440 | 1404 | UINT16 rega = m_maincpu->state_int(CCPU_A); |
| 1441 | | demon_sound_w(machine(), 0x00 | (~rega & 0x0f), 0x10); |
| 1405 | demon_sound_w(0x00 | (~rega & 0x0f), 0x10); |
| 1442 | 1406 | } |
| 1443 | 1407 | |
| 1444 | 1408 | |