diff options
author | 2009-02-11 19:48:39 +0000 | |
---|---|---|
committer | 2009-02-11 19:48:39 +0000 | |
commit | 5cb6bf00e90dd0e836bcabf7d5a8a2bdbf941767 (patch) | |
tree | f0fd5a55acb6b6592a5be0fd9c766aed1a695c88 /src/emu/sound/c140.c | |
parent | 1420ed893ae8344144582793cdcc1a0eafda4610 (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/c140.c')
-rw-r--r-- | src/emu/sound/c140.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/emu/sound/c140.c b/src/emu/sound/c140.c index d8867e9846e..68bb3ec66e8 100644 --- a/src/emu/sound/c140.c +++ b/src/emu/sound/c140.c @@ -88,7 +88,8 @@ typedef struct long sample_loop; } VOICE; -struct c140_info +typedef struct _c140_state c140_state; +struct _c140_state { int sample_rate; sound_stream *stream; @@ -106,6 +107,16 @@ struct c140_info VOICE voi[MAX_VOICE]; }; +INLINE c140_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_C140); + return (c140_state *)device->token; +} + + static void init_voice( VOICE *v ) { v->key=0; @@ -119,9 +130,9 @@ static void init_voice( VOICE *v ) v->sample_end=0; v->sample_loop=0; } -READ8_HANDLER( c140_r ) +READ8_DEVICE_HANDLER( c140_r ) { - struct c140_info *info = sndti_token(SOUND_C140, 0); + c140_state *info = get_safe_token(device); offset&=0x1ff; return info->REG[offset]; } @@ -134,7 +145,7 @@ READ8_HANDLER( c140_r ) is done by a small PAL or GAL external to the sound chip, which can be switched per-game or at least per-PCB revision as addressing range needs grow. */ -static long find_sample(struct c140_info *info, long adrs, long bank, int voice) +static long find_sample(c140_state *info, long adrs, long bank, int voice) { long newadr = 0; @@ -184,9 +195,9 @@ static long find_sample(struct c140_info *info, long adrs, long bank, int voice) return (newadr); } -WRITE8_HANDLER( c140_w ) +WRITE8_DEVICE_HANDLER( c140_w ) { - struct c140_info *info = sndti_token(SOUND_C140, 0); + c140_state *info = get_safe_token(device); stream_update(info->stream); offset&=0x1ff; @@ -246,9 +257,9 @@ WRITE8_HANDLER( c140_w ) } } -void c140_set_base(int which, void *base) +void c140_set_base(const device_config *device, void *base) { - struct c140_info *info = sndti_token(SOUND_C140, 0); + c140_state *info = get_safe_token(device); info->pRom = base; } @@ -261,7 +272,7 @@ INLINE int limit(INT32 in) static STREAM_UPDATE( update_stereo ) { - struct c140_info *info = param; + c140_state *info = param; int i,j; INT32 rvol,lvol; @@ -454,12 +465,12 @@ static STREAM_UPDATE( update_stereo ) } } -static SND_START( c140 ) +static DEVICE_START( c140 ) { const c140_interface *intf = device->static_config; - struct c140_info *info = device->token; + c140_state *info = get_safe_token(device); - info->sample_rate=info->baserate=clock; + info->sample_rate=info->baserate=device->clock; info->banking_type = intf->banking_type; @@ -496,34 +507,24 @@ static SND_START( c140 ) * Generic get_info **************************************************************************/ -static SND_SET_INFO( c140 ) -{ - switch (state) - { - /* no parameters to set */ - } -} - - -SND_GET_INFO( c140 ) +DEVICE_GET_INFO( c140 ) { switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ - case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct c140_info); break; + case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(c140_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( c140 ); break; - case SNDINFO_PTR_START: info->start = SND_START_NAME( c140 ); break; - case SNDINFO_PTR_STOP: /* nothing */ break; - case SNDINFO_PTR_RESET: /* nothing */ break; + case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( c140 ); 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, "C140"); break; - case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Namco PCM"); 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, "C140"); break; + case DEVINFO_STR_FAMILY: strcpy(info->s, "Namco PCM"); 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; } } |