summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/cem3394.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-02-11 19:48:39 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-02-11 19:48:39 +0000
commit5cb6bf00e90dd0e836bcabf7d5a8a2bdbf941767 (patch)
treef0fd5a55acb6b6592a5be0fd9c766aed1a695c88 /src/emu/sound/cem3394.c
parent1420ed893ae8344144582793cdcc1a0eafda4610 (diff)
Ok, this is The Big One.
Please note: regression testing is in progress, but the first round of glaring regressions have already been taken care of. That said, there is likely to be a host of regressions as a result of this change. Also note: There are still a few rough edges in the interfaces. I will try to clean them up systematically once the basic system is working. All sound chips are now proper devices. Merged the sound chip interface into the device interface, removing any differences (such as the whole ALIASing concept). Modified every sound chip in the following ways: * updated to match the device interface * reduced read/write handlers down to the minimal number * added the use of get_safe_token() for ensuring correctness * other minor cleanup Removed the custom sound device. The additional work to just make custom sound cases into full devices is minimal, so I just converted them all over to be actual devices. Vastly simplified the sound interfaces, removing the ghastly sndti_* business and moving everyone over to using tags for sound identity. sndintrf, like cpuintrf, is now just a header file with no implementation. Modified each and every driver that references a sound chip: * all memory maps explicitly reference the targeted device via AM_DEVREAD/AM_DEVWRITE/AM_DEVREADWRITE * 16-bit and 32-bit accesses to 8-bit chips no longer use trampoline functions but instead use the 8-bit AM_DEVREAD/WRITE macros * all references to sound chips are now done via tags * note that these changes are brute force, not optimal; in many cases drivers should grab pointers to devices in MACHINE_START and stash them away
Diffstat (limited to 'src/emu/sound/cem3394.c')
-rw-r--r--src/emu/sound/cem3394.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/emu/sound/cem3394.c b/src/emu/sound/cem3394.c
index aa93e5e58cf..09a3c8a176c 100644
--- a/src/emu/sound/cem3394.c
+++ b/src/emu/sound/cem3394.c
@@ -105,7 +105,8 @@
/* this structure defines the parameters for a channel */
-typedef struct
+typedef struct _cem3394_state cem3394_state;
+struct _cem3394_state
{
sound_stream * stream; /* our stream */
void (*external)(const device_config *, int, short *);/* callback to generate external samples */
@@ -135,13 +136,23 @@ typedef struct
INT16 *mixer_buffer;
INT16 *external_buffer;
-} sound_chip;
+};
+
+
+INLINE cem3394_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_CEM3394);
+ return (cem3394_state *)device->token;
+}
/* generate sound to the mix buffer in mono */
static STREAM_UPDATE( cem3394_update )
{
- sound_chip *chip = param;
+ cem3394_state *chip = param;
int int_volume = (chip->volume * chip->mixer_internal) / 256;
int ext_volume = (chip->volume * chip->mixer_external) / 256;
UINT32 step = chip->step, position, end_position = 0;
@@ -315,10 +326,10 @@ static STREAM_UPDATE( cem3394_update )
}
-static SND_START( cem3394 )
+static DEVICE_START( cem3394 )
{
const cem3394_interface *intf = device->static_config;
- sound_chip *chip = device->token;
+ cem3394_state *chip = get_safe_token(device);
chip->device = device;
@@ -407,9 +418,9 @@ INLINE UINT32 compute_db_volume(double voltage)
}
-void cem3394_set_voltage(int chipnum, int input, double voltage)
+void cem3394_set_voltage(const device_config *device, int input, double voltage)
{
- sound_chip *chip = sndti_token(SOUND_CEM3394, chipnum);
+ cem3394_state *chip = get_safe_token(device);
double temp;
/* don't do anything if no change */
@@ -501,9 +512,9 @@ void cem3394_set_voltage(int chipnum, int input, double voltage)
}
-double cem3394_get_parameter(int chipnum, int input)
+double cem3394_get_parameter(const device_config *device, int input)
{
- sound_chip *chip = sndti_token(SOUND_CEM3394, chipnum);
+ cem3394_state *chip = get_safe_token(device);
double voltage = chip->values[input];
switch (input)
@@ -557,34 +568,24 @@ double cem3394_get_parameter(int chipnum, int input)
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( cem3394 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( cem3394 )
+DEVICE_GET_INFO( cem3394 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(sound_chip); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cem3394_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( cem3394 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( cem3394 ); break;
- case SNDINFO_PTR_STOP: /* nothing */ break;
- case SNDINFO_PTR_RESET: /* nothing */ break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( cem3394 ); break;
+ case DEVINFO_FCT_STOP: /* nothing */ break;
+ case DEVINFO_FCT_RESET: /* nothing */ break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "CEM3394"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Analog Synth"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "CEM3394"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Analog Synth"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}