summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/s14001a.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-05-07 23:18:47 +1000
committer Vas Crabb <vas@vastheman.com>2017-05-14 21:44:11 +1000
commit0f0d39ef81562c75e79176dd3bebb1e491ca39d5 (patch)
tree201cee7fdf55ee800f83859a92efd2cfe66cf2b3 /src/devices/sound/s14001a.cpp
parente6c4be2b4d71c7a6c95be0bae111eb416ff0f9e7 (diff)
Move static data out of devices into the device types. This is a significant change, so please pay attention.
The core changes are: * Short name, full name and source file are no longer members of device_t, they are part of the device type * MACHINE_COFIG_START no longer needs a driver class * MACHINE_CONFIG_DERIVED_CLASS is no longer necessary * Specify the state class you want in the GAME/COMP/CONS line * The compiler will work out the base class where the driver init member is declared * There is one static device type object per driver rather than one per machine configuration Use DECLARE_DEVICE_TYPE or DECLARE_DEVICE_TYPE_NS to declare device type. * DECLARE_DEVICE_TYPE forward-declares teh device type and class, and declares extern object finders. * DECLARE_DEVICE_TYPE_NS is for devices classes in namespaces - it doesn't forward-declare the device type. Use DEFINE_DEVICE_TYPE or DEFINE_DEVICE_TYPE_NS to define device types. * These macros declare storage for the static data, and instantiate the device type and device finder templates. The rest of the changes are mostly just moving stuff out of headers that shouldn't be there, renaming stuff for consistency, and scoping stuff down where appropriate. Things I've actually messed with substantially: * More descriptive names for a lot of devices * Untangled the fantasy sound from the driver state, which necessitates breaking up sound/flip writes * Changed DECO BSMT2000 ready callback into a device delegate * Untangled Microprose 3D noise from driver state * Used object finders for CoCo multipak, KC85 D002, and Irem sound subdevices * Started to get TI-99 stuff out of the TI-990 directory and arrange bus devices properly * Started to break out common parts of Samsung ARM SoC devices * Turned some of FM, SID, SCSP DSP, EPIC12 and Voodoo cores into something resmbling C++ * Tried to make Z180 table allocation/setup a bit safer * Converted generic keyboard/terminal to not use WRITE8 - space/offset aren't relevant * Dynamically allocate generic terminal buffer so derived devices (e.g. teleprinter) can specify size * Imporved encapsulation of Z80DART channels * Refactored the SPC7110 bit table generator loop to make it more readable * Added wrappers for SNES PPU operations so members can be made protected * Factored out some boilerplate for YM chips with PSG * toaplan2 gfx * stic/intv resolution * Video System video * Out Run/Y-board sprite alignment * GIC video hookup * Amstrad CPC ROM box members * IQ151 ROM cart region * MSX cart IRQ callback resolution time * SMS passthrough control devices starting subslots I've smoke-tested several drivers, but I've probably missed something. Things I've missed will likely blow up spectacularly with failure to bind errors and the like. Let me know if there's more subtle breakage (could have happened in FM or Voodoo). And can everyone please, please try to keep stuff clean. In particular, please stop polluting the global namespace. Keep things out of headers that don't need to be there, and use things that can be scoped down rather than macros. It feels like an uphill battle trying to get this stuff under control while more of it's added.
Diffstat (limited to 'src/devices/sound/s14001a.cpp')
-rw-r--r--src/devices/sound/s14001a.cpp193
1 files changed, 101 insertions, 92 deletions
diff --git a/src/devices/sound/s14001a.cpp b/src/devices/sound/s14001a.cpp
index 9bc112232f2..68bf81212d8 100644
--- a/src/devices/sound/s14001a.cpp
+++ b/src/devices/sound/s14001a.cpp
@@ -106,11 +106,110 @@ and off as it normally does during speech). Once START has gone low-high-low, th
#include "emu.h"
#include "s14001a.h"
+namespace {
+
+uint8_t Mux8To2(bool bVoicedP2, uint8_t uPPQtrP2, uint8_t uDeltaAdrP2, uint8_t uRomDataP2)
+{
+ // pick two bits of rom data as delta
+
+ if (bVoicedP2 && (uPPQtrP2 & 0x01)) // mirroring
+ uDeltaAdrP2 ^= 0x03; // count backwards
+
+ // emulate 8 to 2 mux to obtain delta from byte (bigendian)
+ switch (uDeltaAdrP2)
+ {
+ case 0x00:
+ return (uRomDataP2 & 0xC0) >> 6;
+ case 0x01:
+ return (uRomDataP2 & 0x30) >> 4;
+ case 0x02:
+ return (uRomDataP2 & 0x0C) >> 2;
+ case 0x03:
+ return (uRomDataP2 & 0x03) >> 0;
+ default:
+ return 0xFF;
+ }
+}
+
+
+void CalculateIncrement(bool bVoicedP2, uint8_t uPPQtrP2, bool bPPQStartP2, uint8_t uDelta, uint8_t uDeltaOldP2, uint8_t &uDeltaOldP1, uint8_t &uIncrementP2, bool &bAddP2)
+{
+ // uPPQtr, pitch period quarter counter; 2 lsb of uLength
+ // bPPStart, start of a pitch period
+ // implemented to mimic silicon (a bit)
+
+ // beginning of a pitch period
+ if ((uPPQtrP2 == 0x00) && bPPQStartP2) // note this is done for voiced and unvoiced
+ uDeltaOldP2 = 0x02;
+
+ static constexpr uint8_t uIncrements[4][4] =
+ {
+ // 00 01 10 11
+ { 3, 3, 1, 1,}, // 00
+ { 1, 1, 0, 0,}, // 01
+ { 0, 0, 1, 1,}, // 10
+ { 1, 1, 3, 3 }, // 11
+ };
+
+ bool const MIRROR = BIT(uPPQtrP2, 0);
+
+ // calculate increment from delta, always done even if silent to update uDeltaOld
+ // in silicon a PLA determined 0,1,3 and add/subtract and passed uDelta to uDeltaOld
+ if (!bVoicedP2 || !MIRROR)
+ {
+ uIncrementP2 = uIncrements[uDelta][uDeltaOldP2];
+ bAddP2 = uDelta >= 0x02;
+ }
+ else
+ {
+ uIncrementP2 = uIncrements[uDeltaOldP2][uDelta];
+ bAddP2 = uDeltaOldP2 < 0x02;
+ }
+ uDeltaOldP1 = uDelta;
+ if (bVoicedP2 && bPPQStartP2 && MIRROR)
+ uIncrementP2 = 0; // no change when first starting mirroring
+}
+
+
+uint8_t CalculateOutput(bool bVoiced, bool bXSilence, uint8_t uPPQtr, bool bPPQStart, uint8_t uLOutput, uint8_t uIncrementP2, bool bAddP2)
+{
+ // implemented to mimic silicon (a bit)
+ // limits output to 0x00 and 0x0f
+
+ bool const SILENCE = BIT(uPPQtr, 1);
+
+ // determine output
+ if (bXSilence || (bVoiced && SILENCE))
+ return 7;
+
+ // beginning of a pitch period
+ if ((uPPQtr == 0x00) && bPPQStart) // note this is done for voiced and nonvoiced
+ uLOutput = 7;
+
+ // adder
+ uint8_t uTmp = uLOutput;
+ if (!bAddP2)
+ uTmp ^= 0x0F; // turns subtraction into addition
+
+ // add 0, 1, 3; limit at 15
+ uTmp += uIncrementP2;
+ if (uTmp > 15)
+ uTmp = 15;
+
+ if (!bAddP2)
+ uTmp ^= 0x0F; // turns addition back to subtraction
+
+ return uTmp;
+}
+
+} // anonymous namespace
+
+
// device definition
-const device_type S14001A = device_creator<s14001a_device>;
+DEFINE_DEVICE_TYPE(S14001A, s14001a_device, "s14001a", "SSi TSI S14001A")
s14001a_device::s14001a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, S14001A, "S14001A", tag, owner, clock, "s14001a", __FILE__),
+ : device_t(mconfig, S14001A, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_SpeechRom(*this, DEVICE_SELF),
m_stream(nullptr),
@@ -471,96 +570,6 @@ bool s14001a_device::Clock()
return true;
}
-uint8_t s14001a_device::Mux8To2(bool bVoicedP2, uint8_t uPPQtrP2, uint8_t uDeltaAdrP2, uint8_t uRomDataP2)
-{
- // pick two bits of rom data as delta
-
- if (bVoicedP2 && uPPQtrP2&0x01) // mirroring
- {
- uDeltaAdrP2 ^= 0x03; // count backwards
- }
- // emulate 8 to 2 mux to obtain delta from byte (bigendian)
- switch (uDeltaAdrP2)
- {
- case 0x00:
- return (uRomDataP2&0xC0)>>6;
- case 0x01:
- return (uRomDataP2&0x30)>>4;
- case 0x02:
- return (uRomDataP2&0x0C)>>2;
- case 0x03:
- return (uRomDataP2&0x03)>>0;
- }
- return 0xFF;
-}
-
-void s14001a_device::CalculateIncrement(bool bVoicedP2, uint8_t uPPQtrP2, bool bPPQStartP2, uint8_t uDelta, uint8_t uDeltaOldP2, uint8_t &uDeltaOldP1, uint8_t &uIncrementP2, bool &bAddP2)
-{
- // uPPQtr, pitch period quarter counter; 2 lsb of uLength
- // bPPStart, start of a pitch period
- // implemented to mimic silicon (a bit)
-
- // beginning of a pitch period
- if (uPPQtrP2 == 0x00 && bPPQStartP2) // note this is done for voiced and unvoiced
- {
- uDeltaOldP2 = 0x02;
- }
- static const uint8_t uIncrements[4][4] =
- {
- // 00 01 10 11
- { 3, 3, 1, 1,}, // 00
- { 1, 1, 0, 0,}, // 01
- { 0, 0, 1, 1,}, // 10
- { 1, 1, 3, 3 }, // 11
- };
-
-#define MIRROR (uPPQtrP2&0x01)
-
- // calculate increment from delta, always done even if silent to update uDeltaOld
- // in silicon a PLA determined 0,1,3 and add/subtract and passed uDelta to uDeltaOld
- if (!bVoicedP2 || !MIRROR)
- {
- uIncrementP2 = uIncrements[uDelta][uDeltaOldP2];
- bAddP2 = uDelta >= 0x02;
- }
- else
- {
- uIncrementP2 = uIncrements[uDeltaOldP2][uDelta];
- bAddP2 = uDeltaOldP2 < 0x02;
- }
- uDeltaOldP1 = uDelta;
- if (bVoicedP2 && bPPQStartP2 && MIRROR) uIncrementP2 = 0; // no change when first starting mirroring
-}
-
-uint8_t s14001a_device::CalculateOutput(bool bVoiced, bool bXSilence, uint8_t uPPQtr, bool bPPQStart, uint8_t uLOutput, uint8_t uIncrementP2, bool bAddP2)
-{
- // implemented to mimic silicon (a bit)
- // limits output to 0x00 and 0x0f
- uint8_t uTmp; // used for subtraction
-
-#define SILENCE (uPPQtr&0x02)
-
- // determine output
- if (bXSilence || (bVoiced && SILENCE)) return 7;
-
- // beginning of a pitch period
- if (uPPQtr == 0x00 && bPPQStart) // note this is done for voiced and nonvoiced
- {
- uLOutput = 7;
- }
-
- // adder
- uTmp = uLOutput;
- if (!bAddP2) uTmp ^= 0x0F; // turns subtraction into addition
-
- // add 0, 1, 3; limit at 15
- uTmp += uIncrementP2;
- if (uTmp > 15) uTmp = 15;
-
- if (!bAddP2) uTmp ^= 0x0F; // turns addition back to subtraction
- return uTmp;
-}
-
void s14001a_device::ClearStatistics()
{
m_uNPitchPeriods = 0;