src/emu/sound/s14001a.c
| r7181 | r7182 | |
| 1 | 1 | /* |
| 2 | 2 | |
| 3 | | TSI S14001A emulator v1.31c |
| 3 | TSI S14001A emulator v1.32 |
| 4 | 4 | By Jonathan Gevaryahu ("Lord Nightmare") with help from Kevin Horton ("kevtris") |
| 5 | 5 | MAME conversion and integration by R. Belmont |
| 6 | 6 | Clock Frequency control updated by Zsolt Vasvari |
| r7181 | r7182 | |
| 23 | 23 | 1.31a Add chip pinout and other notes - LN (0.128u4) |
| 24 | 24 | 1.31b slight update to notes to clarify input bus stuff, mostly finish the state map in the comments - LN |
| 25 | 25 | 1.31c remove usage of deprecat.h - AtariAce (0.128u5) |
| 26 | 1.32 fix the squealing noise using a define; it isn't accurate to the chip exactly, but there are other issues which need to be fixed too. see TODO. - LN (0.136u2) |
| 26 | 27 | |
| 27 | 28 | TODO: |
| 28 | 29 | * increase accuracy of internal S14001A 'filter' for both driven and undriven cycles (its not terribly inaccurate for undriven cycles, but the dc sliding of driven cycles is not emulated) |
| 29 | 30 | * add option for and attach Frank P.'s emulation of the Analog external filter from the vsu-1000 using the discrete core. (with the direction of independent sound core and analog stuff, this should actually be attached in the main berzerk/frenzy driver and not here) |
| 31 | * fix the local and global silence stuff to not force the dac to a specific level, but cease doing deltas (i.e. force all deltas to 0) after the last sample; this should fix the clipping in p |
| 30 | 32 | */ |
| 31 | 33 | |
| 32 | 34 | /* Chip Pinout: |
| r7181 | r7182 | |
| 229 | 231 | * if mirrored mode is OFF, increment oddphone. if not, don't touch it here. if oddphone was 1 before the increment, increment phoneaddress and set oddphone to 0 |
| 230 | 232 | * |
| 231 | 233 | */ |
| 234 | |
| 235 | #undef ACCURATE_SQUEAL |
| 232 | 236 | |
| 233 | 237 | #include "emu.h" |
| 234 | 238 | #include "streams.h" |
| r7181 | r7182 | |
| 291 | 295 | { 1, 1, 3, 3 }, |
| 292 | 296 | }; |
| 293 | 297 | |
| 298 | #ifdef ACCURATE_SQUEAL |
| 294 | 299 | static INT16 audiofilter(S14001AChip *chip) /* rewrite me to better match the real filter! */ |
| 295 | 300 | { |
| 296 | 301 | UINT8 temp1; |
| r7181 | r7182 | |
| 309 | 314 | chip->filtervals[temp1] = chip->filtervals[(temp1 - 1)]; |
| 310 | 315 | } |
| 311 | 316 | chip->filtervals[0] = inputvalue; |
| 312 | | |
| 313 | 317 | } |
| 318 | #endif |
| 314 | 319 | |
| 315 | 320 | static void PostPhoneme(S14001AChip *chip) /* figure out what the heck to do after playing a phoneme */ |
| 316 | 321 | { |
| r7181 | r7182 | |
| 411 | 416 | chip->oddeven = !(chip->oddeven); // invert the clock |
| 412 | 417 | if (chip->oddeven == 0) // even clock |
| 413 | 418 | { |
| 419 | #ifdef ACCURATE_SQUEAL |
| 414 | 420 | chip->audioout = ALTFLAG; // flag to the renderer that this output should be the average of the last 8 |
| 415 | | // DIGITAL INPUT on the test pins occurs on this cycle used for output |
| 421 | #endif |
| 422 | // DIGITAL INPUT *MIGHT* occur on the test pins occurs on this cycle? |
| 416 | 423 | } |
| 417 | 424 | else // odd clock |
| 418 | 425 | { |
| 419 | 426 | // fix dac output between samples. theoretically this might be unnecessary but it would require some messy logic in state 5 on the first sample load. |
| 427 | // Note: this behavior is NOT accurate, and needs to be fixed. see TODO. |
| 420 | 428 | if (chip->GlobalSilenceState || LOCALSILENCESTATE) |
| 421 | 429 | { |
| 422 | 430 | chip->DACOutput = SILENCE; |
| 423 | 431 | chip->OldDelta = 2; |
| 424 | 432 | } |
| 425 | 433 | chip->audioout = (chip->GlobalSilenceState || LOCALSILENCESTATE) ? SILENCE : chip->DACOutput; // when either silence state is 1, output silence. |
| 426 | | // DIGITAL OUTPUT is driven onto the test pins on this cycle |
| 434 | // DIGITAL OUTPUT *might* be driven onto the test pins on this cycle? |
| 427 | 435 | switch(chip->machineState) // HUUUUUGE switch statement |
| 428 | 436 | { |
| 429 | 437 | case 0: // idle state |
| r7181 | r7182 | |
| 554 | 562 | for (i = 0; i < samples; i++) |
| 555 | 563 | { |
| 556 | 564 | s14001a_clock(chip); |
| 565 | #ifdef ACCURATE_SQUEAL |
| 557 | 566 | if (chip->audioout == ALTFLAG) // input from test pins -> output |
| 558 | 567 | { |
| 559 | 568 | shiftIntoFilter(chip, audiofilter(chip)); // shift over the previous outputs and stick in audioout. |
| r7181 | r7182 | |
| 562 | 571 | else // normal, dac-driven output |
| 563 | 572 | { |
| 564 | 573 | shiftIntoFilter(chip, ((((INT16)chip->audioout)-8)<<9)); // shift over the previous outputs and stick in audioout 4 times. note <<9 instead of <<10, to prevent clipping, and to simulate that the filtered output normally has a somewhat lower amplitude than the driven one. |
| 574 | #endif |
| 565 | 575 | outputs[0][i] = ((((INT16)chip->audioout)-8)<<10)*chip->VSU1000_amp; |
| 576 | #ifdef ACCURATE_SQUEAL |
| 566 | 577 | } |
| 578 | #endif |
| 567 | 579 | } |
| 568 | 580 | } |
| 569 | 581 | |
| r7181 | r7182 | |
| 638 | 650 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 639 | 651 | case DEVINFO_STR_NAME: strcpy(info->s, "S14001A"); break; |
| 640 | 652 | case DEVINFO_STR_FAMILY: strcpy(info->s, "TSI S14001A"); break; |
| 641 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.31"); break; |
| 653 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.32"); break; |
| 642 | 654 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 643 | 655 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Jonathan Gevaryahu"); break; |
| 644 | 656 | } |