summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/k005289.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/k005289.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/k005289.c')
-rw-r--r--src/emu/sound/k005289.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/emu/sound/k005289.c b/src/emu/sound/k005289.c
index 94499d9e42f..0585dae1dcc 100644
--- a/src/emu/sound/k005289.c
+++ b/src/emu/sound/k005289.c
@@ -40,7 +40,8 @@ typedef struct
const unsigned char *wave;
} k005289_sound_channel;
-struct k005289_info
+typedef struct _k005289_state k005289_state;
+struct _k005289_state
{
k005289_sound_channel channel_list[2];
@@ -60,8 +61,17 @@ struct k005289_info
int k005289_A_latch,k005289_B_latch;
};
+INLINE k005289_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_K005289);
+ return (k005289_state *)device->token;
+}
+
/* build a table to divide by the number of voices */
-static void make_mixer_table(struct k005289_info *info, int voices)
+static void make_mixer_table(k005289_state *info, int voices)
{
int count = voices * 128;
int i;
@@ -87,7 +97,7 @@ static void make_mixer_table(struct k005289_info *info, int voices)
/* generate sound to the mix buffer */
static STREAM_UPDATE( K005289_update )
{
- struct k005289_info *info = param;
+ k005289_state *info = param;
k005289_sound_channel *voice=info->channel_list;
stream_sample_t *buffer = outputs[0];
short *mix;
@@ -148,17 +158,17 @@ static STREAM_UPDATE( K005289_update )
*buffer++ = info->mixer_lookup[*mix++];
}
-static SND_START( k005289 )
+static DEVICE_START( k005289 )
{
k005289_sound_channel *voice;
- struct k005289_info *info = device->token;
+ k005289_state *info = get_safe_token(device);
voice = info->channel_list;
/* get stream channels */
- info->rate = clock/16;
+ info->rate = device->clock/16;
info->stream = stream_create(device, 0, 1, info->rate, info, K005289_update);
- info->mclock = clock;
+ info->mclock = device->clock;
/* allocate a pair of buffers to mix into - 1 second's worth should be more than enough */
info->mixer_buffer = auto_malloc(2 * sizeof(short) * info->rate);
@@ -182,7 +192,7 @@ static SND_START( k005289 )
/********************************************************************************/
-static void k005289_recompute(struct k005289_info *info)
+static void k005289_recompute(k005289_state *info)
{
k005289_sound_channel *voice = info->channel_list;
@@ -196,44 +206,44 @@ static void k005289_recompute(struct k005289_info *info)
voice[1].wave = &info->sound_prom[32 * info->k005289_B_waveform + 0x100];
}
-WRITE8_HANDLER( k005289_control_A_w )
+WRITE8_DEVICE_HANDLER( k005289_control_A_w )
{
- struct k005289_info *info = sndti_token(SOUND_K005289, 0);
+ k005289_state *info = get_safe_token(device);
info->k005289_A_volume=data&0xf;
info->k005289_A_waveform=data>>5;
k005289_recompute(info);
}
-WRITE8_HANDLER( k005289_control_B_w )
+WRITE8_DEVICE_HANDLER( k005289_control_B_w )
{
- struct k005289_info *info = sndti_token(SOUND_K005289, 0);
+ k005289_state *info = get_safe_token(device);
info->k005289_B_volume=data&0xf;
info->k005289_B_waveform=data>>5;
k005289_recompute(info);
}
-WRITE8_HANDLER( k005289_pitch_A_w )
+WRITE8_DEVICE_HANDLER( k005289_pitch_A_w )
{
- struct k005289_info *info = sndti_token(SOUND_K005289, 0);
+ k005289_state *info = get_safe_token(device);
info->k005289_A_latch = 0x1000 - offset;
}
-WRITE8_HANDLER( k005289_pitch_B_w )
+WRITE8_DEVICE_HANDLER( k005289_pitch_B_w )
{
- struct k005289_info *info = sndti_token(SOUND_K005289, 0);
+ k005289_state *info = get_safe_token(device);
info->k005289_B_latch = 0x1000 - offset;
}
-WRITE8_HANDLER( k005289_keylatch_A_w )
+WRITE8_DEVICE_HANDLER( k005289_keylatch_A_w )
{
- struct k005289_info *info = sndti_token(SOUND_K005289, 0);
+ k005289_state *info = get_safe_token(device);
info->k005289_A_frequency = info->k005289_A_latch;
k005289_recompute(info);
}
-WRITE8_HANDLER( k005289_keylatch_B_w )
+WRITE8_DEVICE_HANDLER( k005289_keylatch_B_w )
{
- struct k005289_info *info = sndti_token(SOUND_K005289, 0);
+ k005289_state *info = get_safe_token(device);
info->k005289_B_frequency = info->k005289_B_latch;
k005289_recompute(info);
}
@@ -245,34 +255,24 @@ WRITE8_HANDLER( k005289_keylatch_B_w )
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( k005289 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( k005289 )
+DEVICE_GET_INFO( k005289 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct k005289_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k005289_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( k005289 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( k005289 ); break;
- case SNDINFO_PTR_STOP: /* nothing */ break;
- case SNDINFO_PTR_RESET: /* nothing */ break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( k005289 ); 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, "K005289"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Konami custom"); 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, "K005289"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Konami custom"); 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;
}
}