diff options
author | 2009-01-18 20:24:42 +0000 | |
---|---|---|
committer | 2009-01-18 20:24:42 +0000 | |
commit | 170b4c27522f3ed0c3af90e0e24e45659f0ea763 (patch) | |
tree | ebf0563c6f0a9f8b48040beec2543e5b5fd086fa /src/emu/sound | |
parent | 6278021cf6a3a3e6af895ff4ea3623175fd4ef71 (diff) |
Sound cores no longer allocate their own tokens. Instead they return a new
integer value indicating the size of token they want, and the core allocates
it for them. This mirrors the standard device behavior.
Diffstat (limited to 'src/emu/sound')
82 files changed, 333 insertions, 512 deletions
diff --git a/src/emu/sound/2151intf.c b/src/emu/sound/2151intf.c index ee8de7d2a11..d43a26b7003 100644 --- a/src/emu/sound/2151intf.c +++ b/src/emu/sound/2151intf.c @@ -39,12 +39,9 @@ static STATE_POSTLOAD( ym2151intf_postload ) static SND_START( ym2151 ) { static const ym2151_interface dummy = { 0 }; - struct ym2151_info *info; + struct ym2151_info *info = device->token; int rate; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = device->static_config ? device->static_config : &dummy; rate = clock/64; @@ -53,16 +50,13 @@ static SND_START( ym2151 ) info->stream = stream_create(device,0,2,rate,info,ym2151_update); info->chip = ym2151_init(device,clock,rate); + assert_always(info->chip != NULL, "Error creating YM2151 chip"); state_save_register_postload(device->machine, ym2151intf_postload, info); - if (info->chip != 0) - { - ym2151_set_irq_handler(info->chip,info->intf->irqhandler); - ym2151_set_port_write_handler(info->chip,info->intf->portwritehandler); - return info; - } - return NULL; + ym2151_set_irq_handler(info->chip,info->intf->irqhandler); + ym2151_set_port_write_handler(info->chip,info->intf->portwritehandler); + return DEVICE_START_OK; } @@ -222,6 +216,7 @@ SND_GET_INFO( ym2151 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2151_info); 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( ym2151 ); break; diff --git a/src/emu/sound/2203intf.c b/src/emu/sound/2203intf.c index 0c98e9ce2a5..1496c157058 100644 --- a/src/emu/sound/2203intf.c +++ b/src/emu/sound/2203intf.c @@ -117,16 +117,13 @@ static SND_START( ym2203 ) NULL }; const ym2203_interface *intf = device->static_config ? device->static_config : &generic_2203; - struct ym2203_info *info; + struct ym2203_info *info = device->token; int rate = clock/72; /* ??? */ - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = intf; info->device = device; - info->psg = ay8910_start_ym(SOUND_YM2203, device, clock, &intf->ay8910_intf); - if (!info->psg) return NULL; + info->psg = ay8910_start_ym(NULL, SOUND_YM2203, device, clock, &intf->ay8910_intf); + assert_always(info->psg != NULL, "Error creating YM2203/AY8910 chip"); /* Timer Handler set */ info->timer[0] = timer_alloc(device->machine, timer_callback_2203_0, info); @@ -137,15 +134,11 @@ static SND_START( ym2203 ) /* Initialize FM emurator */ info->chip = ym2203_init(info,device,clock,rate,timer_handler,IRQHandler,&psgintf); + assert_always(info->chip != NULL, "Error creating YM2203 chip"); state_save_register_postload(device->machine, ym2203_intf_postload, info); - if (info->chip) - return info; - - /* error */ - /* stream close */ - return NULL; + return DEVICE_START_OK; } static SND_STOP( ym2203 ) @@ -341,6 +334,7 @@ SND_GET_INFO( ym2203 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2203_info); 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( ym2203 ); break; diff --git a/src/emu/sound/2413intf.c b/src/emu/sound/2413intf.c index 2830cc5141c..e5670c7d7ff 100644 --- a/src/emu/sound/2413intf.c +++ b/src/emu/sound/2413intf.c @@ -51,22 +51,18 @@ static void _stream_update(void *param, int interval) static SND_START( ym2413 ) { int rate = clock/72; - struct ym2413_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct ym2413_info *info = device->token; /* emulator create */ info->chip = ym2413_init(device, clock, rate); - if (!info->chip) - return NULL; + assert_always(info->chip != NULL, "Error creating YM2413 chip"); /* stream system initialize */ info->stream = stream_create(device,0,2,rate,info,ym2413_stream_update); ym2413_set_update_handler(info->chip, _stream_update, info); - return info; + return DEVICE_START_OK; @@ -169,6 +165,7 @@ SND_GET_INFO( ym2413 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2413_info); 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( ym2413 ); break; diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c index fbe3c64ec3f..94ad83f5ea6 100644 --- a/src/emu/sound/2608intf.c +++ b/src/emu/sound/2608intf.c @@ -134,17 +134,14 @@ static SND_START( ym2608 ) void *pcmbufa; int pcmsizea; - struct ym2608_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct ym2608_info *info = device->token; info->intf = intf; info->device = device; /* FIXME: Force to use simgle output */ - info->psg = ay8910_start_ym(SOUND_YM2608, device, clock, &intf->ay8910_intf); - if (!info->psg) return NULL; + info->psg = ay8910_start_ym(NULL, SOUND_YM2608, device, clock, &intf->ay8910_intf); + assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip"); /* Timer Handler set */ info->timer[0] = timer_alloc(device->machine, timer_callback_2608_0, info); @@ -160,14 +157,10 @@ static SND_START( ym2608 ) info->chip = ym2608_init(info,device,clock,rate, pcmbufa,pcmsizea, timer_handler,IRQHandler,&psgintf); + assert_always(info->chip != NULL, "Error creating YM2608 chip"); state_save_register_postload(device->machine, ym2608_intf_postload, info); - - if (info->chip) - return info; - - /* error */ - return NULL; + return DEVICE_START_OK; } static SND_STOP( ym2608 ) @@ -309,6 +302,7 @@ SND_GET_INFO( ym2608 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2608_info); 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( ym2608 ); break; diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c index cabd80cb83a..bd586245950 100644 --- a/src/emu/sound/2610intf.c +++ b/src/emu/sound/2610intf.c @@ -133,18 +133,15 @@ static SND_START( ym2610 ) int rate = clock/72; void *pcmbufa,*pcmbufb; int pcmsizea,pcmsizeb; - struct ym2610_info *info; + struct ym2610_info *info = device->token; astring *name = astring_alloc(); chip_type = SOUND_YM2610; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = intf; info->device = device; - info->psg = ay8910_start_ym(SOUND_YM2610, device, clock, &generic_ay8910); - if (!info->psg) return NULL; + info->psg = ay8910_start_ym(NULL, SOUND_YM2610, device, clock, &generic_ay8910); + assert_always(info->psg != NULL, "Error creating YM2610/AY8910 chip"); /* Timer Handler set */ info->timer[0] = timer_alloc(device->machine, timer_callback_0, info); @@ -169,14 +166,11 @@ static SND_START( ym2610 ) info->chip = ym2610_init(info,device,clock,rate, pcmbufa,pcmsizea,pcmbufb,pcmsizeb, timer_handler,IRQHandler,&psgintf); + assert_always(info->chip != NULL, "Error creating YM2610 chip"); state_save_register_postload(device->machine, ym2610_intf_postload, info); - if (info->chip) - return info; - - /* error */ - return NULL; + return DEVICE_START_OK; } #endif @@ -200,18 +194,15 @@ static SND_START( ym2610b ) int rate = clock/72; void *pcmbufa,*pcmbufb; int pcmsizea,pcmsizeb; - struct ym2610_info *info; + struct ym2610_info *info = device->token; astring *name = astring_alloc(); chip_type = SOUND_YM2610B; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = intf; info->device = device; - info->psg = ay8910_start_ym(SOUND_YM2610B, device, clock, &generic_ay8910); - if (!info->psg) return NULL; + info->psg = ay8910_start_ym(NULL, SOUND_YM2610B, device, clock, &generic_ay8910); + assert_always(info->psg != NULL, "Error creating YM2610B/AY8910 chip"); /* Timer Handler set */ info->timer[0] =timer_alloc(device->machine, timer_callback_0, info); @@ -236,11 +227,9 @@ static SND_START( ym2610b ) info->chip = ym2610_init(info,device,clock,rate, pcmbufa,pcmsizea,pcmbufb,pcmsizeb, timer_handler,IRQHandler,&psgintf); - if (info->chip) - return info; - - /* error */ - return NULL; + assert_always(info->chip != NULL, "Error creating YM2610B chip"); + + return DEVICE_START_OK; } #endif @@ -495,6 +484,7 @@ SND_GET_INFO( ym2610 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2610_info); 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( ym2610 ); break; @@ -532,6 +522,7 @@ SND_GET_INFO( ym2610b ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2610_info); 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( ym2610b ); break; diff --git a/src/emu/sound/2612intf.c b/src/emu/sound/2612intf.c index cf0608852c3..fbaf4af4361 100644 --- a/src/emu/sound/2612intf.c +++ b/src/emu/sound/2612intf.c @@ -90,12 +90,9 @@ static STATE_POSTLOAD( ym2612_intf_postload ) static SND_START( ym2612 ) { static const ym2612_interface dummy = { 0 }; - struct ym2612_info *info; + struct ym2612_info *info = device->token; int rate = clock/72; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = device->static_config ? device->static_config : &dummy; info->device = device; @@ -109,13 +106,11 @@ static SND_START( ym2612 ) /**** initialize YM2612 ****/ info->chip = ym2612_init(info,device,clock,rate,timer_handler,IRQHandler); + assert_always(info->chip != NULL, "Error creating YM2612 chip"); state_save_register_postload(device->machine, ym2612_intf_postload, info); - - if (info->chip) - return info; - /* error */ - return NULL; + + return DEVICE_START_OK; } @@ -362,6 +357,7 @@ SND_GET_INFO( ym2612 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2612_info); 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( ym2612 ); break; @@ -398,6 +394,7 @@ SND_GET_INFO( ym3438 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2612_info); 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( ym3438 ); break; diff --git a/src/emu/sound/262intf.c b/src/emu/sound/262intf.c index 31601de3681..213ed4d2648 100644 --- a/src/emu/sound/262intf.c +++ b/src/emu/sound/262intf.c @@ -70,19 +70,15 @@ static void _stream_update(void *param, int interval) static SND_START( ymf262 ) { static const ymf262_interface dummy = { 0 }; - struct ymf262_info *info; + struct ymf262_info *info = device->token; int rate = clock/288; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = device->static_config ? device->static_config : &dummy; info->device = device; /* stream system initialize */ info->chip = ymf262_init(device,clock,rate); - if (info->chip == NULL) - return NULL; + assert_always(info->chip != NULL, "Error creating YMF262 chip"); info->stream = stream_create(device,0,4,rate,info,ymf262_stream_update); @@ -94,7 +90,7 @@ static SND_START( ymf262 ) info->timer[0] = timer_alloc(device->machine, timer_callback_262_0, info); info->timer[1] = timer_alloc(device->machine, timer_callback_262_1, info); - return info; + return DEVICE_START_OK; } static SND_STOP( ymf262 ) @@ -173,6 +169,7 @@ SND_GET_INFO( ymf262 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ymf262_info); 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( ymf262 ); break; diff --git a/src/emu/sound/3812intf.c b/src/emu/sound/3812intf.c index 945cd534dd6..8a881a42f8b 100644 --- a/src/emu/sound/3812intf.c +++ b/src/emu/sound/3812intf.c @@ -82,19 +82,15 @@ static void _stream_update_3812(void * param, int interval) static SND_START( ym3812 ) { static const ym3812_interface dummy = { 0 }; - struct ym3812_info *info; + struct ym3812_info *info = device->token; int rate = clock/72; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = device->static_config ? device->static_config : &dummy; info->device = device; /* stream system initialize */ info->chip = ym3812_init(device,clock,rate); - if (!info->chip) - return NULL; + assert_always(info->chip != NULL, "Error creating YM3812 chip"); info->stream = stream_create(device,0,1,rate,info,ym3812_stream_update); @@ -106,7 +102,7 @@ static SND_START( ym3812 ) info->timer[0] = timer_alloc(device->machine, timer_callback_3812_0, info); info->timer[1] = timer_alloc(device->machine, timer_callback_3812_1, info); - return info; + return DEVICE_START_OK; } static SND_STOP( ym3812 ) @@ -174,6 +170,7 @@ SND_GET_INFO( ym3812 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym3812_info); 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( ym3812 ); break; @@ -253,19 +250,15 @@ static void _stream_update_3526(void *param, int interval) static SND_START( ym3526 ) { static const ym3526_interface dummy = { 0 }; - struct ym3526_info *info; + struct ym3526_info *info = device->token; int rate = clock/72; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = device->static_config ? device->static_config : &dummy; info->device = device; /* stream system initialize */ info->chip = ym3526_init(device,clock,rate); - if (!info->chip) - return NULL; + assert_always(info->chip != NULL, "Error creating YM3526 chip"); info->stream = stream_create(device,0,1,rate,info,ym3526_stream_update); /* YM3526 setup */ @@ -276,7 +269,7 @@ static SND_START( ym3526 ) info->timer[0] = timer_alloc(device->machine, timer_callback_3526_0, info); info->timer[1] = timer_alloc(device->machine, timer_callback_3526_1, info); - return info; + return DEVICE_START_OK; } static SND_STOP( ym3526 ) @@ -344,6 +337,7 @@ SND_GET_INFO( ym3526 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym3526_info); 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( ym3526 ); break; @@ -449,19 +443,15 @@ static void _stream_update_8950(void *param, int interval) static SND_START( y8950 ) { static const y8950_interface dummy = { 0 }; - struct y8950_info *info; + struct y8950_info *info = device->token; int rate = clock/72; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = device->static_config ? device->static_config : &dummy; info->device = device; /* stream system initialize */ info->chip = y8950_init(device,clock,rate); - if (!info->chip) - return NULL; + assert_always(info->chip != NULL, "Error creating Y8950 chip"); /* ADPCM ROM data */ y8950_set_delta_t_memory(info->chip, device->region, device->regionbytes); @@ -480,7 +470,7 @@ static SND_START( y8950 ) info->timer[0] = timer_alloc(device->machine, timer_callback_8950_0, info); info->timer[1] = timer_alloc(device->machine, timer_callback_8950_1, info); - return info; + return DEVICE_START_OK; } static SND_STOP( y8950 ) @@ -548,6 +538,7 @@ SND_GET_INFO( y8950 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct y8950_info); 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( y8950 ); break; diff --git a/src/emu/sound/5110intf.c b/src/emu/sound/5110intf.c index 9e02f7d9862..e88f24b5ea9 100644 --- a/src/emu/sound/5110intf.c +++ b/src/emu/sound/5110intf.c @@ -67,28 +67,20 @@ static void speech_rom_set_addr(int addr) static SND_START( tms5110 ) { static const tms5110_interface dummy = { 0 }; - struct tms5110_info *info; + struct tms5110_info *info = device->token; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); info->intf = device->static_config ? device->static_config : &dummy; info->table = device->region; info->chip = tms5110_create(device, TMS5110_IS_5110A); - if (!info->chip) - return NULL; - sndintrf_register_token(info); + assert_always(info->chip != NULL, "Error creating TMS5110 chip"); /* initialize a stream */ info->stream = stream_create(device, 0, 1, clock / 80, info, tms5110_update); if (info->table == NULL) { - if (info->intf->M0_callback==NULL) - { - logerror("\n file: 5110intf.c, SND_START( tms5110 ):\n Missing _mandatory_ 'M0_callback' function pointer in the TMS5110 interface\n This function is used by TMS5110 to call for a single bits\n needed to generate the speech\n Aborting startup...\n"); - return NULL; - } + assert_always(info->intf->M0_callback != NULL, "Missing _mandatory_ 'M0_callback' function pointer in the TMS5110 interface\n This function is used by TMS5110 to call for a single bits\n needed to generate the speech\n Aborting startup...\n"); tms5110_set_M0_callback(info->chip, info->intf->M0_callback ); tms5110_set_load_address(info->chip, info->intf->load_address ); } @@ -102,49 +94,55 @@ static SND_START( tms5110 ) tms5110_reset_chip(info->chip); /* request a sound channel */ - return info; + return DEVICE_START_OK; } static SND_START( tms5100 ) { - struct tms5110_info *info = SND_START_CALL( tms5110 ); + struct tms5110_info *info = device->token; + SND_START_CALL( tms5110 ); tms5110_set_variant(info->chip, TMS5110_IS_5100); - return info; + return DEVICE_START_OK; } static SND_START( tms5110a ) { - struct tms5110_info *info = SND_START_CALL( tms5110 ); + struct tms5110_info *info = device->token; + SND_START_CALL( tms5110 ); tms5110_set_variant(info->chip, TMS5110_IS_5110A); - return info; + return DEVICE_START_OK; } static SND_START( cd2801 ) { - struct tms5110_info *info = SND_START_CALL( tms5110 ); + struct tms5110_info *info = device->token; + SND_START_CALL( tms5110 ); tms5110_set_variant(info->chip, TMS5110_IS_CD2801); - return info; + return DEVICE_START_OK; } static SND_START( tmc0281 ) { - struct tms5110_info *info = SND_START_CALL( tms5110 ); + struct tms5110_info *info = device->token; + SND_START_CALL( tms5110 ); tms5110_set_variant(info->chip, TMS5110_IS_TMC0281); - return info; + return DEVICE_START_OK; } static SND_START( cd2802 ) { - struct tms5110_info *info = SND_START_CALL( tms5110 ); + struct tms5110_info *info = device->token; + SND_START_CALL( tms5110 ); tms5110_set_variant(info->chip, TMS5110_IS_CD2802); - return info; + return DEVICE_START_OK; } static SND_START( m58817 ) { - struct tms5110_info *info = SND_START_CALL( tms5110 ); + struct tms5110_info *info = device->token; + SND_START_CALL( tms5110 ); tms5110_set_variant(info->chip, TMS5110_IS_M58817); - return info; + return DEVICE_START_OK; } @@ -298,6 +296,7 @@ SND_GET_INFO( tms5110 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct tms5110_info); break; case SNDINFO_FCT_ALIAS: info->type = SOUND_TMS5110; break; /* --- the following bits of info are returned as pointers to data or functions --- */ diff --git a/src/emu/sound/5220intf.c b/src/emu/sound/5220intf.c index b2b68aae904..47d51941d0e 100644 --- a/src/emu/sound/5220intf.c +++ b/src/emu/sound/5220intf.c @@ -44,16 +44,12 @@ static STREAM_UPDATE( tms5220_update ); static SND_START( tms5220 ) { static const tms5220_interface dummy = { 0 }; - struct tms5220_info *info; + struct tms5220_info *info = device->token; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); info->intf = device->static_config ? device->static_config : &dummy; info->chip = tms5220_create(device); - if (!info->chip) - return NULL; - sndintrf_register_token(info); + assert_always(info->chip != NULL, "Error creating TMS5220 chip"); /* initialize a info->stream */ info->stream = stream_create(device, 0, 1, clock / 80, info, tms5220_update); @@ -69,16 +65,17 @@ static SND_START( tms5220 ) tms5220_set_read_and_branch(info->chip, info->intf->read_and_branch); /* request a sound channel */ - return info; + return DEVICE_START_OK; } #if (HAS_TMC0285 || HAS_TMS5200) static SND_START( tms5200 ) { - struct tms5220_info *info = SND_START_CALL( tms5220 ); + struct tms5220_info *info = device->token; + SND_START_CALL( tms5220 ); tms5220_set_variant(info->chip, variant_tmc0285); - return info; + return DEVICE_START_OK; } #endif /* (HAS_TMC0285) && (HAS_TMS5200) */ @@ -254,6 +251,7 @@ SND_GET_INFO( tms5220 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct tms5220_info); break; case SNDINFO_FCT_ALIAS: info->type = SOUND_TMS5220; break; /* --- the following bits of info are returned as pointers to data or functions --- */ diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c index c39b1481350..89966aff170 100644 --- a/src/emu/sound/aica.c +++ b/src/emu/sound/aica.c @@ -1280,10 +1280,7 @@ static SND_START( aica ) { const aica_interface *intf; - struct _AICA *AICA; - - AICA = auto_malloc(sizeof(*AICA)); - memset(AICA, 0, sizeof(*AICA)); + struct _AICA *AICA = device->token; intf = device->static_config; @@ -1297,7 +1294,7 @@ static SND_START( aica ) AICA->stream = stream_create(device, 0, 2, 44100, AICA, AICA_Update); } - return AICA; + return DEVICE_START_OK; } #ifdef UNUSED_FUNCTION @@ -1373,6 +1370,7 @@ SND_GET_INFO( aica ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct _AICA); 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( aica ); break; diff --git a/src/emu/sound/astrocde.c b/src/emu/sound/astrocde.c index 932ad479bae..60b7f598153 100644 --- a/src/emu/sound/astrocde.c +++ b/src/emu/sound/astrocde.c @@ -258,13 +258,9 @@ static void astrocade_state_save_register(struct astrocade_info *chip, const dev static SND_START( astrocade ) { - struct astrocade_info *chip; + struct astrocade_info *chip = device->token; int i; - /* allocate the chip memory */ - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - /* generate a bitswap table for the noise */ for (i = 0; i < 256; i++) chip->bitswap[i] = BITSWAP8(i, 0,1,2,3,4,5,6,7); @@ -276,7 +272,7 @@ static SND_START( astrocade ) astrocade_reset(chip); astrocade_state_save_register(chip, device); - return chip; + return DEVICE_START_OK; } @@ -338,6 +334,7 @@ SND_GET_INFO( astrocade ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct astrocade_info); 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( astrocade ); break; diff --git a/src/emu/sound/ay8910.c b/src/emu/sound/ay8910.c index 267f9463d16..b6c485e7551 100644 --- a/src/emu/sound/ay8910.c +++ b/src/emu/sound/ay8910.c @@ -659,12 +659,15 @@ static void ay8910_statesave(ay8910_context *psg, const device_config *device) * *************************************/ -void *ay8910_start_ym(sound_type chip_type, const device_config *device, int clock, const ay8910_interface *intf) +void *ay8910_start_ym(void *infoptr, sound_type chip_type, const device_config *device, int clock, const ay8910_interface *intf) { - ay8910_context *info; + ay8910_context *info = infoptr; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + if (info == NULL) + { + info = auto_malloc(sizeof(*info)); + memset(info, 0, sizeof(*info)); + } info->device = device; info->intf = intf; if ((info->intf->flags & AY8910_SINGLE_OUTPUT) != 0) @@ -819,7 +822,8 @@ static SND_START( ay8910 ) NULL, NULL, NULL, NULL }; const ay8910_interface *intf = (device->static_config ? device->static_config : &generic_ay8910); - return ay8910_start_ym(SOUND_AY8910, device, clock, intf); + ay8910_start_ym(device->token, SOUND_AY8910, device, clock, intf); + return DEVICE_START_OK; } static SND_START( ym2149 ) @@ -831,7 +835,8 @@ static SND_START( ym2149 ) NULL, NULL, NULL, NULL }; const ay8910_interface *intf = (device->static_config ? device->static_config : &generic_ay8910); - return ay8910_start_ym(SOUND_YM2149, device, clock, intf); + ay8910_start_ym(device->token, SOUND_YM2149, device, clock, intf); + return DEVICE_START_OK; } static SND_STOP( ay8910 ) @@ -857,7 +862,8 @@ SND_GET_INFO( ay8910 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ - case SNDINFO_FCT_ALIAS: info->type = SOUND_AY8910; break; + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(ay8910_context); break; + case SNDINFO_FCT_ALIAS: info->type = SOUND_AY8910; 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( ay8910 ); break; diff --git a/src/emu/sound/ay8910.h b/src/emu/sound/ay8910.h index d8ceaccb1c9..73580224c00 100644 --- a/src/emu/sound/ay8910.h +++ b/src/emu/sound/ay8910.h @@ -126,7 +126,7 @@ WRITE16_HANDLER( ay8910_write_port_4_msb_w ); /*********** An interface for SSG of YM2203 ***********/ -void *ay8910_start_ym(sound_type chip_type, const device_config *device, int clock, const ay8910_interface *intf); +void *ay8910_start_ym(void *infoptr, sound_type chip_type, const device_config *device, int clock, const ay8910_interface *intf); void ay8910_stop_ym(void *chip); void ay8910_reset_ym(void *chip); diff --git a/src/emu/sound/beep.c b/src/emu/sound/beep.c index e57f3b49cfe..29a0b1c3f4e 100644 --- a/src/emu/sound/beep.c +++ b/src/emu/sound/beep.c @@ -83,17 +83,14 @@ static STREAM_UPDATE( beep_sound_update ) static SND_START( beep ) { - struct beep_sound *pBeep; - - pBeep = auto_malloc(sizeof(*pBeep)); - memset(pBeep, 0, sizeof(*pBeep)); + struct beep_sound *pBeep = device->token; pBeep->stream = stream_create(device, 0, 1, BEEP_RATE, pBeep, beep_sound_update ); pBeep->enable = 0; pBeep->frequency = 3250; pBeep->incr = 0; pBeep->signal = 0x07fff; - return pBeep; + return DEVICE_START_OK; } @@ -180,6 +177,7 @@ SND_GET_INFO( beep ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct beep_sound); 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( beep ); break; diff --git a/src/emu/sound/bsmt2000.c b/src/emu/sound/bsmt2000.c index 74d3e18428d..325d7d6b596 100644 --- a/src/emu/sound/bsmt2000.c +++ b/src/emu/sound/bsmt2000.c @@ -107,13 +107,9 @@ static void set_regmap(bsmt2000_chip *chip, UINT8 posbase, UINT8 ratebase, UINT8 static SND_START( bsmt2000 ) { - bsmt2000_chip *chip; + bsmt2000_chip *chip = device->token; int voicenum; - /* allocate the chip */ - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - /* create a stream at a nominal sample rate (real one specified later) */ chip->stream = stream_create(device, 0, 2, clock / 1000, chip, bsmt2000_update); chip->clock = clock; @@ -147,7 +143,7 @@ static SND_START( bsmt2000 ) /* reset the chip -- this also configures the default mode */ bsmt2000_reset(chip); - return chip; + return DEVICE_START_OK; } @@ -500,6 +496,7 @@ SND_GET_INFO( bsmt2000 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(bsmt2000_chip); 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( bsmt2000 ); break; diff --git a/src/emu/sound/c140.c b/src/emu/sound/c140.c index d1d615025a0..fcc3a8bb836 100644 --- a/src/emu/sound/c140.c +++ b/src/emu/sound/c140.c @@ -457,10 +457,7 @@ static STREAM_UPDATE( update_stereo ) static SND_START( c140 ) { const c140_interface *intf = device->static_config; - struct c140_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct c140_info *info = device->token; info->sample_rate=info->baserate=clock; @@ -490,7 +487,7 @@ static SND_START( c140 ) /* allocate a pair of buffers to mix into - 1 second's worth should be more than enough */ info->mixer_buffer_left = auto_malloc(2 * sizeof(INT16)*info->sample_rate ); info->mixer_buffer_right = info->mixer_buffer_left + info->sample_rate; - return info; + return DEVICE_START_OK; } @@ -514,6 +511,7 @@ SND_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; /* --- 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; diff --git a/src/emu/sound/c352.c b/src/emu/sound/c352.c index 05ad81b6d3e..dd7d83b684a 100644 --- a/src/emu/sound/c352.c +++ b/src/emu/sound/c352.c @@ -532,10 +532,7 @@ static void c352_init(struct c352_info *info, const device_config *device) static SND_START( c352 ) { - struct c352_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct c352_info *info = device->token; info->c352_rom_samples = device->region; info->c352_rom_length = device->regionbytes; @@ -546,7 +543,7 @@ static SND_START( c352 ) c352_init(info, device); - return info; + return DEVICE_START_OK; } @@ -591,6 +588,7 @@ SND_GET_INFO( c352 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct c352_info); 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( c352 ); break; diff --git a/src/emu/sound/c6280.c b/src/emu/sound/c6280.c index 72ac1adaa4f..af6e2adebc5 100644 --- a/src/emu/sound/c6280.c +++ b/src/emu/sound/c6280.c @@ -310,10 +310,7 @@ static STREAM_UPDATE( c6280_update ) static SND_START( c6280 ) { int rate = clock/16; - c6280_t *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + c6280_t *info = device->token; /* Initialize PSG emulator */ c6280_init(device, info, clock, rate); @@ -321,7 +318,7 @@ static SND_START( c6280 ) /* Create stereo stream */ info->stream = stream_create(device, 0, 2, rate, info, c6280_update); - return info; + return DEVICE_START_OK; } READ8_HANDLER( c6280_r ) { return h6280io_get_buffer((device_config*)space->cpu); } @@ -348,6 +345,7 @@ SND_GET_INFO( c6280 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(c6280_t); 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( c6280 ); break; diff --git a/src/emu/sound/cdda.c b/src/emu/sound/cdda.c index 0bab6475fcb..f9b94b1e99b 100644 --- a/src/emu/sound/cdda.c +++ b/src/emu/sound/cdda.c @@ -46,10 +46,7 @@ static STREAM_UPDATE( cdda_update ) static SND_START( cdda ) { const struct CDDAinterface *intf; - cdda_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + cdda_info *info = device->token; /* allocate an audio cache */ info->audio_cache = auto_malloc( CD_MAX_SECTOR_DATA * MAX_SECTORS ); @@ -67,7 +64,7 @@ static SND_START( cdda ) state_save_register_device_item( device, 0, info->audio_samples ); state_save_register_device_item( device, 0, info->audio_bptr ); - return info; + return DEVICE_START_OK; } @@ -315,6 +312,7 @@ SND_GET_INFO( cdda ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(cdda_info); 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( cdda ); break; diff --git a/src/emu/sound/cdp1869.c b/src/emu/sound/cdp1869.c index 9b9afe6bed5..5425bde8c87 100644 --- a/src/emu/sound/cdp1869.c +++ b/src/emu/sound/cdp1869.c @@ -105,10 +105,7 @@ static STREAM_UPDATE( cdp1869_update ) static SND_START( cdp1869 ) { - struct CDP1869 *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct CDP1869 *info = device->token; info->device = device; info->stream = stream_create(device, 0, 1, device->machine->sample_rate, info, cdp1869_update ); @@ -124,7 +121,7 @@ static SND_START( cdp1869 ) info->wnfreq = 0; info->wnamp = 0; - return info; + return DEVICE_START_OK; } void cdp1869_set_toneamp(int which, int value) @@ -186,6 +183,7 @@ SND_GET_INFO( cdp1869 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct CDP1869); 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( cdp1869 ); break; diff --git a/src/emu/sound/cem3394.c b/src/emu/sound/cem3394.c index 43fcf8eb1b5..169243ea56c 100644 --- a/src/emu/sound/cem3394.c +++ b/src/emu/sound/cem3394.c @@ -318,10 +318,8 @@ static STREAM_UPDATE( cem3394_update ) static SND_START( cem3394 ) { const cem3394_interface *intf = device->static_config; - sound_chip *chip; + sound_chip *chip = device->token; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); chip->device = device; /* copy global parameters */ @@ -351,7 +349,7 @@ static SND_START( cem3394 ) state_save_register_device_item(device, 0, chip->last_ext); state_save_register_device_item(device, 0, chip->pulse_width); - return chip; + return DEVICE_START_OK; } @@ -575,6 +573,7 @@ SND_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; /* --- 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; diff --git a/src/emu/sound/custom.c b/src/emu/sound/custom.c index 036ddfc15d7..74f97357bac 100644 --- a/src/emu/sound/custom.c +++ b/src/emu/sound/custom.c @@ -12,21 +12,17 @@ struct custom_info static SND_START( custom ) { - struct custom_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct custom_info *info = device->token; /* stash a pointer and call the start routine */ info->intf = device->static_config; if (info->intf->start) { info->token = (*info->intf->start)(device, clock, device->static_config); - if (!info->token) - return NULL; + assert_always(info->token != NULL, "Error starting custom sound"); } - return info; + return DEVICE_START_OK; } @@ -72,6 +68,7 @@ SND_GET_INFO( custom ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct custom_info); 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( custom ); break; diff --git a/src/emu/sound/dac.c b/src/emu/sound/dac.c index 39fc9d0a8e4..8fa5d75d244 100644 --- a/src/emu/sound/dac.c +++ b/src/emu/sound/dac.c @@ -101,10 +101,7 @@ static void DAC_build_voltable(struct dac_info *info) static SND_START( dac ) { - struct dac_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct dac_info *info = device->token; DAC_build_voltable(info); @@ -113,7 +110,7 @@ static SND_START( dac ) state_save_register_device_item(device, 0, info->output); - return info; + return DEVICE_START_OK; } @@ -169,6 +166,7 @@ SND_GET_INFO( dac ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct dac_info); 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( dac ); break; diff --git a/src/emu/sound/digitalk.c b/src/emu/sound/digitalk.c index ff44afe290c..306315e4bfc 100644 --- a/src/emu/sound/digitalk.c +++ b/src/emu/sound/digitalk.c @@ -641,8 +641,7 @@ static void digitalker_register_for_save(digitalker *dg) static SND_START(digitalker) { - digitalker *dg = auto_malloc(sizeof(*dg)); - memset(dg, 0, sizeof(*dg)); + digitalker *dg = device->token; dg->device = device; dg->rom = memory_region(device->machine, device->tag); dg->stream = stream_create(device, 0, 1, clock/4, dg, digitalker_update); @@ -654,7 +653,7 @@ static SND_START(digitalker) digitalker_register_for_save(dg); - return dg; + return DEVICE_START_OK; } static SND_SET_INFO(digitalker) @@ -665,6 +664,7 @@ static SND_SET_INFO(digitalker) SND_GET_INFO(digitalker) { switch(state) { + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(digitalker); break; case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME(digitalker); break; case SNDINFO_PTR_START: info->start = SND_START_NAME(digitalker); break; case SNDINFO_PTR_STOP: break; diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index c5dcf091a84..284862daeff 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -248,12 +248,9 @@ node_description *discrete_find_node(void *chip, int node) static SND_START( discrete ) { discrete_sound_block *intf = (discrete_sound_block *)device->static_config; - discrete_info *info; + discrete_info *info = device->token; char name[32]; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->device = device; /* If a clock is specified we will use it, otherwise run at the audio sample rate. */ @@ -318,7 +315,7 @@ static SND_START( discrete ) setup_disc_logs(info); discrete_current_context = NULL; - return info; + return DEVICE_START_OK; } @@ -755,6 +752,7 @@ SND_GET_INFO( discrete ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(discrete_info); 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( discrete ); break; diff --git a/src/emu/sound/dmadac.c b/src/emu/sound/dmadac.c index dd72f1d48d7..c949aa91e7a 100644 --- a/src/emu/sound/dmadac.c +++ b/src/emu/sound/dmadac.c @@ -93,10 +93,7 @@ static STREAM_UPDATE( dmadac_update ) static SND_START( dmadac ) { - struct dmadac_channel_data *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct dmadac_channel_data *info = device->token; /* allocate a clear a buffer */ info->buffer = auto_malloc(sizeof(info->buffer[0]) * BUFFER_SIZE); @@ -116,7 +113,7 @@ static SND_START( dmadac ) state_save_register_device_item(device, 0, info->frequency); state_save_register_device_item_pointer(device, 0, info->buffer, BUFFER_SIZE); - return info; + return DEVICE_START_OK; } @@ -249,6 +246,7 @@ SND_GET_INFO( dmadac ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct dmadac_channel_data); 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( dmadac ); break; diff --git a/src/emu/sound/es5503.c b/src/emu/sound/es5503.c index edf1741fa1a..80d05b207d6 100644 --- a/src/emu/sound/es5503.c +++ b/src/emu/sound/es5503.c @@ -227,10 +227,7 @@ static SND_START( es5503 ) { const es5503_interface *intf; int osc; - ES5503Chip *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + ES5503Chip *chip = device->token; intf = device->static_config; @@ -268,7 +265,7 @@ static SND_START( es5503 ) chip->output_rate = (clock/8)/34; // (input clock / 8) / # of oscs. enabled + 2 chip->stream = stream_create(device, 0, 2, chip->output_rate, chip, es5503_pcm_update); - return chip; + return DEVICE_START_OK; } READ8_HANDLER(es5503_reg_0_r) @@ -521,6 +518,7 @@ SND_GET_INFO( es5503 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(ES5503Chip); 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( es5503 ); break; diff --git a/src/emu/sound/es5506.c b/src/emu/sound/es5506.c index 60fe357ccd1..9bbcd9a74a4 100644 --- a/src/emu/sound/es5506.c +++ b/src/emu/sound/es5506.c @@ -177,7 +177,7 @@ static void update_internal_irq_state(struct ES5506Chip *chip) ***********************************************************************************************/ -static int compute_tables(struct ES5506Chip *chip) +static void compute_tables(struct ES5506Chip *chip) { int i; @@ -211,8 +211,6 @@ static int compute_tables(struct ES5506Chip *chip) chip->volume_lookup[i] = (mantissa << 11) >> (20 - exponent); } - - return 1; } @@ -821,23 +819,19 @@ static STREAM_UPDATE( es5506_update ) ***********************************************************************************************/ -static void *es5506_start_common(const device_config *device, int clock, const void *config, sound_type sndtype) +static device_start_err es5506_start_common(const device_config *device, int clock, const void *config, sound_type sndtype) { const es5506_interface *intf = config; - struct ES5506Chip *chip; + struct ES5506Chip *chip = device->token; int j; UINT32 accum_mask; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - /* debugging */ if (LOG_COMMANDS && !eslog) eslog = fopen("es.log", "w"); /* compute the tables */ - if (!compute_tables(chip)) - return NULL; + compute_tables(chip); /* create the stream */ chip->stream = stream_create(device, 0, 2, clock / (16*32), chip, es5506_update); @@ -870,7 +864,7 @@ static void *es5506_start_common(const device_config *device, int clock, const v chip->scratch = auto_malloc(sizeof(chip->scratch[0]) * 2 * MAX_SAMPLE_CHUNK); /* success */ - return chip; + return DEVICE_START_OK; } @@ -2159,6 +2153,7 @@ SND_GET_INFO( es5505 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ES5506Chip); 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( es5505 ); break; @@ -2194,6 +2189,7 @@ SND_GET_INFO( es5506 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ES5506Chip); 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( es5506 ); break; diff --git a/src/emu/sound/es8712.c b/src/emu/sound/es8712.c index 312ff7e65ef..617af273e00 100644 --- a/src/emu/sound/es8712.c +++ b/src/emu/sound/es8712.c @@ -209,10 +209,7 @@ static void es8712_state_save_register(struct es8712 *chip, const device_config static SND_START( es8712 ) { - struct es8712 *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct es8712 *chip = device->token; compute_tables(); @@ -232,7 +229,7 @@ static SND_START( es8712 ) es8712_state_save_register(chip, device); /* success */ - return chip; + return DEVICE_START_OK; } @@ -450,6 +447,7 @@ SND_GET_INFO( es8712 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct es8712); 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( es8712 ); break; diff --git a/src/emu/sound/flt_rc.c b/src/emu/sound/flt_rc.c index d5a4aa63f0c..bcb8b16a6fa 100644 --- a/src/emu/sound/flt_rc.c +++ b/src/emu/sound/flt_rc.c @@ -82,12 +82,9 @@ static void set_RC_info(struct filter_rc_info *info, int type, double R1, double static SND_START( filter_rc ) { - struct filter_rc_info *info; + struct filter_rc_info *info = device->token; const flt_rc_config *conf = device->static_config; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->device = device; info->stream = stream_create(device, 1, 1, device->machine->sample_rate, info, filter_rc_update); if (conf) @@ -95,7 +92,7 @@ static SND_START( filter_rc ) else set_RC_info(info, FLT_RC_LOWPASS, 1, 1, 1, 0); - return info; + return DEVICE_START_OK; } @@ -130,6 +127,7 @@ SND_GET_INFO( filter_rc ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct filter_rc_info); 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( filter_rc ); break; diff --git a/src/emu/sound/flt_vol.c b/src/emu/sound/flt_vol.c index 111b076f97f..180111760e2 100644 --- a/src/emu/sound/flt_vol.c +++ b/src/emu/sound/flt_vol.c @@ -24,15 +24,12 @@ static STREAM_UPDATE( filter_volume_update ) static SND_START( filter_volume ) { - struct filter_volume_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct filter_volume_info *info = device->token; info->gain = 0x100; info->stream = stream_create(device, 1, 1, device->machine->sample_rate, info, filter_volume_update); - return info; + return DEVICE_START_OK; } @@ -62,6 +59,7 @@ SND_GET_INFO( filter_volume ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct filter_volume_info); 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( filter_volume ); break; diff --git a/src/emu/sound/gaelco.c b/src/emu/sound/gaelco.c index 96d72785689..811b3e2f27f 100644 --- a/src/emu/sound/gaelco.c +++ b/src/emu/sound/gaelco.c @@ -242,14 +242,12 @@ WRITE16_HANDLER( gaelcosnd_w ) CG-1V/GAE1 Init ============================================================================*/ -static void *gaelcosnd_start(sound_type sndtype, const device_config *device, int clock) +static device_start_err gaelcosnd_start(sound_type sndtype, const device_config *device, int clock) { int j, vol; const gaelcosnd_interface *intf = device->static_config; - struct GAELCOSND *info; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct GAELCOSND *info = device->token; chip_type = sndtype; @@ -272,7 +270,7 @@ static void *gaelcosnd_start(sound_type sndtype, const device_config *device, in if (LOG_WAVE) wavraw = wav_open("gae1_snd.wav", 8000, 2); - return info; + return DEVICE_START_OK; } static SND_START( gaelco_gae1 ) @@ -314,6 +312,7 @@ SND_GET_INFO( gaelco_gae1 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct GAELCOSND); 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( gaelco_gae1 ); break; @@ -350,6 +349,7 @@ SND_GET_INFO( gaelco_cg1v ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct GAELCOSND); 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( gaelco_cg1v ); break; diff --git a/src/emu/sound/hc55516.c b/src/emu/sound/hc55516.c index c687f56e598..8b414fa018e 100644 --- a/src/emu/sound/hc55516.c +++ b/src/emu/sound/hc55516.c @@ -52,14 +52,10 @@ static STREAM_UPDATE( hc55516_update ); -static void *start_common(const device_config *device, int clock, +static device_start_err start_common(const device_config *device, int clock, UINT8 _shiftreg_mask, int _active_clock_hi) { - struct hc55516_data *chip; - - /* allocate the chip */ - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct hc55516_data *chip = device->token; /* compute the fixed charge, decay, and leak time constants */ charge = pow(exp(-1), 1.0 / (FILTER_CHARGE_TC * 16000.0)); @@ -85,7 +81,7 @@ static void *start_common(const device_config *device, int clock, state_save_register_device_item(device, 0, chip->integrator); /* success */ - return chip; + return DEVICE_START_OK; } @@ -339,6 +335,7 @@ SND_GET_INFO( hc55516 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct hc55516_data); break; case SNDINFO_FCT_ALIAS: info->type = SOUND_HC55516; break; /* --- the following bits of info are returned as pointers to data or functions --- */ diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index 3a7d8934f30..4d8d0ed668b 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -441,12 +441,9 @@ static UINT16 ics2115_reg_r(struct ics2115 *chip, UINT8 reg) static SND_START( ics2115 ) { - struct ics2115 *chip; + struct ics2115 *chip = device->token; int i; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - chip->device = device; chip->intf = device->static_config; chip->rom = device->region; @@ -467,7 +464,7 @@ static SND_START( ics2115 ) chip->ulaw[i] = v; } - return chip; + return DEVICE_START_OK; } READ8_HANDLER( ics2115_r ) @@ -552,6 +549,7 @@ SND_GET_INFO( ics2115 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ics2115); 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( ics2115 ); break; diff --git a/src/emu/sound/iremga20.c b/src/emu/sound/iremga20.c index 1a1e04078f6..a8c5a2d9450 100644 --- a/src/emu/sound/iremga20.c +++ b/src/emu/sound/iremga20.c @@ -230,12 +230,9 @@ static SND_RESET( iremga20 ) static SND_START( iremga20 ) { - struct IremGA20_chip_def *chip; + struct IremGA20_chip_def *chip = device->token; int i; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - /* Initialize our chip structure */ chip->rom = device->region; chip->rom_size = device->regionbytes; @@ -261,7 +258,7 @@ static SND_START( iremga20 ) state_save_register_device_item(device, i, chip->channel[i].play); } - return chip; + return DEVICE_START_OK; } @@ -285,6 +282,7 @@ SND_GET_INFO( iremga20 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct IremGA20_chip_def); 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( iremga20 ); break; diff --git a/src/emu/sound/k005289.c b/src/emu/sound/k005289.c index e2ef977611e..a6a18b0b0ba 100644 --- a/src/emu/sound/k005289.c +++ b/src/emu/sound/k005289.c @@ -61,7 +61,7 @@ struct k005289_info }; /* build a table to divide by the number of voices */ -static int make_mixer_table(struct k005289_info *info, int voices) +static void make_mixer_table(struct k005289_info *info, int voices) { int count = voices * 128; int i; @@ -81,8 +81,6 @@ static int make_mixer_table(struct k005289_info *info, int voices) info->mixer_lookup[ i] = val; info->mixer_lookup[-i] = -val; } - - return 0; } @@ -153,10 +151,8 @@ static STREAM_UPDATE( K005289_update ) static SND_START( k005289 ) { k005289_sound_channel *voice; - struct k005289_info *info; + struct k005289_info *info = device->token; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); voice = info->channel_list; /* get stream channels */ @@ -168,8 +164,7 @@ static SND_START( k005289 ) info->mixer_buffer = auto_malloc(2 * sizeof(short) * info->rate); /* build the mixer table */ - if (make_mixer_table(info, 2)) - return NULL; + make_mixer_table(info, 2); info->sound_prom = device->region; @@ -183,7 +178,7 @@ static SND_START( k005289 ) voice[1].wave = &info->sound_prom[0x100]; voice[1].counter = 0; - return info; + return DEVICE_START_OK; } @@ -266,6 +261,7 @@ SND_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; /* --- 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; diff --git a/src/emu/sound/k007232.c b/src/emu/sound/k007232.c index 88e3abfc10e..60684513aeb 100644 --- a/src/emu/sound/k007232.c +++ b/src/emu/sound/k007232.c @@ -297,10 +297,7 @@ static SND_START( k007232 ) { static const k007232_interface defintrf = { 0 }; int i; - struct kdacApcm *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct kdacApcm *info = device->token; info->intf = (device->static_config != NULL) ? device->static_config : &defintrf; @@ -330,7 +327,7 @@ static SND_START( k007232 ) KDAC_A_make_fncode(info); - return info; + return DEVICE_START_OK; } /************************************************/ @@ -492,6 +489,7 @@ SND_GET_INFO( k007232 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct kdacApcm); 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( k007232 ); break; diff --git a/src/emu/sound/k051649.c b/src/emu/sound/k051649.c index 4814d4cc403..d3808c5d1bd 100644 --- a/src/emu/sound/k051649.c +++ b/src/emu/sound/k051649.c @@ -55,7 +55,7 @@ struct k051649_info }; /* build a table to divide by the number of voices */ -static int make_mixer_table(struct k051649_info *info, int voices) +static void make_mixer_table(struct k051649_info *info, int voices) { int count = voices * 256; int i; @@ -75,8 +75,6 @@ static int make_mixer_table(struct k051649_info *info, int voices) info->mixer_lookup[ i] = val; info->mixer_lookup[-i] = -val; } - - return 0; } @@ -129,10 +127,7 @@ static STREAM_UPDATE( k051649_update ) static SND_START( k051649 ) { - struct k051649_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct k051649_info *info = device->token; /* get stream channels */ info->rate = clock/16; @@ -143,10 +138,9 @@ static SND_START( k051649 ) info->mixer_buffer = auto_malloc(2 * sizeof(short) * info->rate); /* build the mixer table */ - if (make_mixer_table(info, 5)) - return NULL; + make_mixer_table(info, 5); - return info; + return DEVICE_START_OK; } static SND_RESET( k051649 ) @@ -237,6 +231,7 @@ SND_GET_INFO( k051649 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct k051649_info); 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( k051649 ); break; diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c index 945a1213989..1e047aced77 100644 --- a/src/emu/sound/k053260.c +++ b/src/emu/sound/k053260.c @@ -202,13 +202,10 @@ static STREAM_UPDATE( k053260_update ) { static SND_START( k053260 ) { static const k053260_interface defintrf = { 0 }; - struct k053260_chip_def *ic; + struct k053260_chip_def *ic = device->token; int rate = clock / 32; int i; - ic = auto_malloc(sizeof(*ic)); - memset(ic, 0, sizeof(*ic)); - /* Initialize our chip structure */ ic->device = device; ic->intf = (device->static_config != NULL) ? device->static_config : &defintrf; @@ -237,7 +234,7 @@ static SND_START( k053260 ) if ( ic->intf->irq ) timer_pulse( device->machine, attotime_mul(ATTOTIME_IN_HZ(clock), 32), NULL, 0, ic->intf->irq ); - return ic; + return DEVICE_START_OK; } INLINE void check_bounds( struct k053260_chip_def *ic, int channel ) { @@ -481,6 +478,7 @@ SND_GET_INFO( k053260 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct k053260_chip_def); 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( k053260 ); break; diff --git a/src/emu/sound/k054539.c b/src/emu/sound/k054539.c index eca42424b44..d840fe0aed5 100644 --- a/src/emu/sound/k054539.c +++ b/src/emu/sound/k054539.c @@ -633,10 +633,7 @@ static SND_START( k054539 ) { static const k054539_interface defintrf = { 0 }; int i; - struct k054539_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct k054539_info *info = device->token; for (i = 0; i < 8; i++) info->k054539_gain[i] = 1.0; @@ -669,7 +666,7 @@ static SND_START( k054539 ) k054539_init_chip(device, info, clock); state_save_register_postload(device->machine, reset_zones, info); - return info; + return DEVICE_START_OK; } WRITE8_HANDLER( k054539_0_w ) @@ -713,6 +710,7 @@ SND_GET_INFO( k054539 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct k054539_info); 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( k054539 ); break; diff --git a/src/emu/sound/msm5205.c b/src/emu/sound/msm5205.c index 27fd3562652..14c6a3f193e 100644 --- a/src/emu/sound/msm5205.c +++ b/src/emu/sound/msm5205.c @@ -172,11 +172,7 @@ static SND_RESET( msm5205 ) static SND_START( msm5205 ) { - struct MSM5205Voice *voice; - - voice = auto_malloc(sizeof(*voice)); - memset(voice, 0, sizeof(*voice)); - sndintrf_register_token(voice); + struct MSM5205Voice *voice = device->token; /* save a global pointer to our interface */ voice->intf = device->static_config; @@ -204,7 +200,7 @@ static SND_START( msm5205 ) state_save_register_device_item(device, 0, voice->step); /* success */ - return voice; + return DEVICE_START_OK; } /* @@ -321,6 +317,7 @@ SND_GET_INFO( msm5205 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct MSM5205Voice); 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( msm5205 ); break; diff --git a/src/emu/sound/msm5232.c b/src/emu/sound/msm5232.c index a92f0c24bfe..d1616b5997f 100644 --- a/src/emu/sound/msm5232.c +++ b/src/emu/sound/msm5232.c @@ -782,15 +782,12 @@ static SND_START( msm5232 ) { const msm5232_interface *intf = device->static_config; int rate = clock/CLOCK_RATE_DIVIDER; - MSM5232 *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + MSM5232 *chip = device->token; msm5232_init(chip, intf, clock, rate); chip->stream = stream_create(device,0,11,rate,chip,MSM5232_update_one); - return chip; + return DEVICE_START_OK; } static SND_STOP( msm5232 ) @@ -846,6 +843,7 @@ SND_GET_INFO( msm5232 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(MSM5232); 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( msm5232 ); break; diff --git a/src/emu/sound/multipcm.c b/src/emu/sound/multipcm.c index 55255981199..9cc0cdd8d3c 100644 --- a/src/emu/sound/multipcm.c +++ b/src/emu/sound/multipcm.c @@ -488,11 +488,9 @@ static unsigned char multi_pcm_reg_r(int chip, int offset) static SND_START( multipcm ) { - struct _MultiPCM *ptChip; + struct _MultiPCM *ptChip = device->token; int i; - ptChip=(struct _MultiPCM *)auto_malloc(sizeof(struct _MultiPCM)); - ptChip->ROM=(INT8 *)device->region; ptChip->Rate=(float) clock / MULTIPCM_CLOCKDIV; @@ -636,7 +634,7 @@ static SND_START( multipcm ) LFO_Init(); - return ptChip; + return DEVICE_START_OK; } @@ -707,6 +705,7 @@ SND_GET_INFO( multipcm ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct _MultiPCM); 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( multipcm ); break; diff --git a/src/emu/sound/n63701x.c b/src/emu/sound/n63701x.c index f7935cbdbdc..5c92f467fa7 100644 --- a/src/emu/sound/n63701x.c +++ b/src/emu/sound/n63701x.c @@ -101,16 +101,13 @@ static STREAM_UPDATE( namco_63701x_update ) static SND_START( namco_63701x ) { - struct namco_63701x *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct namco_63701x *chip = device->token; chip->rom = device->region; chip->stream = stream_create(device, 0, 2, clock/1000, chip, namco_63701x_update); - return chip; + return DEVICE_START_OK; } @@ -173,6 +170,7 @@ SND_GET_INFO( namco_63701x ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct namco_63701x); 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( namco_63701x ); break; diff --git a/src/emu/sound/namco.c b/src/emu/sound/namco.c index a4f147432b3..bb4c2c06d0b 100644 --- a/src/emu/sound/namco.c +++ b/src/emu/sound/namco.c @@ -105,7 +105,7 @@ static void update_namco_waveform(struct namco_sound *chip, int offset, UINT8 da /* build the decoded waveform table */ -static int build_decoded_waveform(struct namco_sound *chip, UINT8 *rgnbase) +static void build_decoded_waveform(struct namco_sound *chip, UINT8 *rgnbase) { INT16 *p; int size; @@ -141,8 +141,6 @@ static int build_decoded_waveform(struct namco_sound *chip, UINT8 *rgnbase) for (offset = 0; offset < 256; offset++) update_namco_waveform(chip, offset, namco_wavedata[offset]); } - - return 0; } @@ -358,10 +356,7 @@ static SND_START( namco ) sound_channel *voice; const namco_interface *intf = device->static_config; int clock_multiple; - struct namco_sound *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct namco_sound *chip = device->token; /* extract globals from the interface */ chip->num_voices = intf->voices; @@ -381,8 +376,7 @@ static SND_START( namco ) logerror("Namco: freq fractional bits = %d: internal freq = %d, output freq = %d\n", chip->f_fracbits, chip->namco_clock, chip->sample_rate); /* build the waveform table */ - if (build_decoded_waveform(chip, device->region)) - return NULL; + build_decoded_waveform(chip, device->region); /* get stream channels */ if (intf->stereo) @@ -426,7 +420,7 @@ static SND_START( namco ) state_save_register_device_item(device, voicenum, voice->waveform_select); } - return chip; + return DEVICE_START_OK; } @@ -818,6 +812,7 @@ SND_GET_INFO( namco ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct namco_sound); 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( namco ); break; @@ -852,6 +847,7 @@ SND_GET_INFO( namco_15xx ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct namco_sound); 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( namco_15xx ); break; @@ -886,6 +882,7 @@ SND_GET_INFO( namco_cus30 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct namco_sound); 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( namco_cus30 ); break; diff --git a/src/emu/sound/namco52.c b/src/emu/sound/namco52.c index ea1f23720ff..81a6a972a55 100644 --- a/src/emu/sound/namco52.c +++ b/src/emu/sound/namco52.c @@ -134,12 +134,9 @@ static SND_RESET( namco_52xx ) static SND_START( namco_52xx ) { - struct namco_52xx *chip; + struct namco_52xx *chip = device->token; int rate = clock/32; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - chip->intf = device->static_config; chip->rom = device->region; chip->rom_len = device->regionbytes; @@ -168,7 +165,7 @@ static SND_START( namco_52xx ) state_save_register_device_item(device, 0, chip->n52_length); state_save_register_device_item(device, 0, chip->n52_pos); - return chip; + return DEVICE_START_OK; } @@ -213,6 +210,7 @@ SND_GET_INFO( namco_52xx ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct namco_52xx); 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( namco_52xx ); break; diff --git a/src/emu/sound/nes_apu.c b/src/emu/sound/nes_apu.c index 58af0303bda..0c1c27d0cba 100644 --- a/src/emu/sound/nes_apu.c +++ b/src/emu/sound/nes_apu.c @@ -671,13 +671,10 @@ static STREAM_UPDATE( nes_psg_update_sound ) static SND_START( nesapu ) { const nes_interface *intf = device->static_config; - struct nesapu_info *info; + struct nesapu_info *info = device->token; int rate = clock / 4; int i; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - /* Initialize global variables */ info->samps_per_sync = rate / ATTOSECONDS_TO_HZ(video_screen_get_frame_period(device->machine->primary_screen).attoseconds); info->buffer_size = info->samps_per_sync; @@ -752,7 +749,7 @@ static SND_START( nesapu ) state_save_register_device_item(device, 0, info->APU.buf_pos); #endif - return info; + return DEVICE_START_OK; } @@ -774,6 +771,7 @@ SND_GET_INFO( nesapu ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct nesapu_info); 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( nesapu ); break; diff --git a/src/emu/sound/nile.c b/src/emu/sound/nile.c index 188b9d4bf2b..459b85fe5e9 100644 --- a/src/emu/sound/nile.c +++ b/src/emu/sound/nile.c @@ -218,16 +218,13 @@ static STREAM_UPDATE( nile_update ) static SND_START( nile ) { - struct nile_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct nile_info *info = device->token; info->sound_ram = device->region; info->stream = stream_create(device, 0, 2, 44100, info, nile_update); - return info; + return DEVICE_START_OK; } @@ -250,6 +247,7 @@ SND_GET_INFO( nile ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct nile_info); 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( nile ); break; diff --git a/src/emu/sound/okim6258.c b/src/emu/sound/okim6258.c index 0049bcc9c1f..74f912c3395 100644 --- a/src/emu/sound/okim6258.c +++ b/src/emu/sound/okim6258.c @@ -185,10 +185,7 @@ static void okim6258_state_save_register(struct okim6258 *info, const device_con static SND_START( okim6258 ) { const okim6258_interface *intf = device->static_config; - struct okim6258 *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct okim6258 *info = device->token; compute_tables(); @@ -206,7 +203,7 @@ static SND_START( okim6258 ) okim6258_state_save_register(info, device); - return info; + return DEVICE_START_OK; } @@ -475,6 +472,7 @@ SND_GET_INFO( okim6258 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct okim6258); 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(okim6258); break; diff --git a/src/emu/sound/okim6295.c b/src/emu/sound/okim6295.c index 6e572b3d093..89e8f231c84 100644 --- a/src/emu/sound/okim6295.c +++ b/src/emu/sound/okim6295.c @@ -320,13 +320,10 @@ static void okim6295_state_save_register(struct okim6295 *info, const device_con static SND_START( okim6295 ) { const okim6295_interface *intf = device->static_config; - struct okim6295 *info; + struct okim6295 *info = device->token; int voice; int divisor = intf->pin7 ? 132 : 165; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - compute_tables(); info->command = -1; @@ -351,7 +348,7 @@ static SND_START( okim6295 ) okim6295_state_save_register(info, device); /* success */ - return info; + return DEVICE_START_OK; } @@ -662,6 +659,7 @@ SND_GET_INFO( okim6295 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct okim6295); 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( okim6295 ); break; diff --git a/src/emu/sound/okim6376.c b/src/emu/sound/okim6376.c index c5450043b3d..129ad957d7e 100644 --- a/src/emu/sound/okim6376.c +++ b/src/emu/sound/okim6376.c @@ -289,13 +289,10 @@ static void okim6376_state_save_register(struct okim6376 *info, const device_con static SND_START( okim6376 ) { - struct okim6376 *info; + struct okim6376 *info = device->token; int voice; int divisor = 165; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - compute_tables(); info->command = -1; @@ -316,7 +313,7 @@ static SND_START( okim6376 ) okim6376_state_save_register(info, device); /* success */ - return info; + return DEVICE_START_OK; } @@ -599,6 +596,7 @@ SND_GET_INFO( okim6376 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct okim6376); 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( okim6376 ); break; diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index aeb6b89f788..0f409eab3b4 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -608,13 +608,10 @@ static void register_for_save(struct POKEYregisters *chip, const device_config * static SND_START( pokey ) { - struct POKEYregisters *chip; + struct POKEYregisters *chip = device->token; int sample_rate = clock; int i; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - if (device->static_config) memcpy(&chip->intf, device->static_config, sizeof(pokey_interface)); chip->device = device; @@ -668,7 +665,7 @@ static SND_START( pokey ) register_for_save(chip, device); - return chip; + return DEVICE_START_OK; } static TIMER_CALLBACK( pokey_timer_expire ) @@ -1525,6 +1522,7 @@ SND_GET_INFO( pokey ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct POKEYregisters); 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( pokey ); break; diff --git a/src/emu/sound/psx.c b/src/emu/sound/psx.c index 12d4436d841..800b89b78ff 100644 --- a/src/emu/sound/psx.c +++ b/src/emu/sound/psx.c @@ -252,13 +252,10 @@ static void spu_write( running_machine *machine, UINT32 n_address, INT32 n_size static SND_START( psxspu ) { - struct psxinfo *chip; + struct psxinfo *chip = device->token; int n_effect; int n_channel; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - chip->intf = device->static_config; chip->device = device; chip->g_p_n_psxram = *(chip->intf->p_psxram); @@ -352,7 +349,7 @@ static SND_START( psxspu ) chip->intf->spu_install_write_handler( 4, spu_write ); chip->stream = stream_create( device, 0, 2, 44100, chip, PSXSPU_update ); - return chip; + return DEVICE_START_OK; } @@ -682,6 +679,7 @@ SND_GET_INFO( psxspu ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct psxinfo); 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( psxspu ); break; diff --git a/src/emu/sound/qsound.c b/src/emu/sound/qsound.c index 1b22b009c41..37f70c57029 100644 --- a/src/emu/sound/qsound.c +++ b/src/emu/sound/qsound.c @@ -94,12 +94,9 @@ static void qsound_set_command(struct qsound_info *chip, int data, int value); static SND_START( qsound ) { - struct qsound_info *chip; + struct qsound_info *chip = device->token; int i; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - chip->sample_rom = (QSOUND_SRC_SAMPLE *)device->region; chip->sample_rom_length = device->regionbytes; @@ -149,7 +146,7 @@ static SND_START( qsound ) state_save_register_device_item(device, i, chip->channel[i].offset); } - return chip; + return DEVICE_START_OK; } static SND_STOP( qsound ) @@ -383,6 +380,7 @@ SND_GET_INFO( qsound ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct qsound_info); 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( qsound ); break; diff --git a/src/emu/sound/rf5c400.c b/src/emu/sound/rf5c400.c index b93b1636252..0f022f8f5bf 100644 --- a/src/emu/sound/rf5c400.c +++ b/src/emu/sound/rf5c400.c @@ -340,14 +340,11 @@ static void rf5c400_init_chip(const device_config *device, struct rf5c400_info * static SND_START( rf5c400 ) { - struct rf5c400_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct rf5c400_info *info = device->token; rf5c400_init_chip(device, info, clock); - return info; + return DEVICE_START_OK; } /*****************************************************************************/ @@ -580,6 +577,7 @@ SND_GET_INFO( rf5c400 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct rf5c400_info); 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( rf5c400 ); break; diff --git a/src/emu/sound/rf5c68.c b/src/emu/sound/rf5c68.c index cc136017a83..3db950651dd 100644 --- a/src/emu/sound/rf5c68.c +++ b/src/emu/sound/rf5c68.c @@ -124,12 +124,11 @@ static STREAM_UPDATE( rf5c68_update ) static SND_START( rf5c68 ) { /* allocate memory for the chip */ - struct rf5c68pcm *chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct rf5c68pcm *chip = device->token; /* allocate the stream */ chip->stream = stream_create(device, 0, 2, clock / 384, chip, rf5c68_update); - return chip; + return DEVICE_START_OK; } @@ -240,6 +239,7 @@ SND_GET_INFO( rf5c68 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct rf5c68pcm); 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( rf5c68 ); break; diff --git a/src/emu/sound/s14001a.c b/src/emu/sound/s14001a.c index 015c68a165d..724ba0357ad 100644 --- a/src/emu/sound/s14001a.c +++ b/src/emu/sound/s14001a.c @@ -559,12 +559,9 @@ static STREAM_UPDATE( s14001a_pcm_update ) static SND_START( s14001a ) { - S14001AChip *chip; + S14001AChip *chip = device->token; int i; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - chip->GlobalSilenceState = 1; chip->OldDelta = 0x02; chip->DACOutput = SILENCE; @@ -578,7 +575,7 @@ static SND_START( s14001a ) chip->stream = stream_create(device, 0, 1, clock ? clock : device->machine->sample_rate, chip, s14001a_pcm_update); - return chip; + return DEVICE_START_OK; } static SND_SET_INFO( s14001a ) @@ -632,6 +629,9 @@ SND_GET_INFO( s14001a ) { switch (state) { + /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(S14001AChip); 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( s14001a ); break; case SNDINFO_PTR_START: info->start = SND_START_NAME( s14001a ); break; diff --git a/src/emu/sound/saa1099.c b/src/emu/sound/saa1099.c index 127a64edc3b..584316d4411 100644 --- a/src/emu/sound/saa1099.c +++ b/src/emu/sound/saa1099.c @@ -314,10 +314,7 @@ static STREAM_UPDATE( saa1099_update ) static SND_START( saa1099 ) { - struct SAA1099 *saa; - - saa = auto_malloc(sizeof(*saa)); - memset(saa, 0, sizeof(*saa)); + struct SAA1099 *saa = device->token; /* copy global parameters */ saa->device = device; @@ -326,7 +323,7 @@ static SND_START( saa1099 ) /* for each chip allocate one stream */ saa->stream = stream_create(device, 0, 2, saa->sample_rate, saa, saa1099_update); - return saa; + return DEVICE_START_OK; } static void saa1099_control_port_w( int chip, int reg, int data ) @@ -504,6 +501,7 @@ SND_GET_INFO( saa1099 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct SAA1099); 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( saa1099 ); break; diff --git a/src/emu/sound/samples.c b/src/emu/sound/samples.c index 4fa4e787bba..0d6b153609c 100644 --- a/src/emu/sound/samples.c +++ b/src/emu/sound/samples.c @@ -524,12 +524,9 @@ static SND_START( samples ) { int i; const samples_interface *intf = device->static_config; - struct samples_info *info; + struct samples_info *info = device->token; - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); info->device = device; - sndintrf_register_token(info); /* read audio samples */ if (intf->samplenames) @@ -564,7 +561,7 @@ static SND_START( samples ) if (intf->start) (*intf->start)(device); - return info; + return DEVICE_START_OK; } @@ -587,6 +584,7 @@ SND_GET_INFO( samples ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct samples_info); 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( samples ); break; diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 75972e1c5b4..40ad912287a 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -1225,10 +1225,7 @@ static SND_START( scsp ) { const scsp_interface *intf; - struct _SCSP *SCSP; - - SCSP = auto_malloc(sizeof(*SCSP)); - memset(SCSP, 0, sizeof(*SCSP)); + struct _SCSP *SCSP = device->token; intf = device->static_config; @@ -1242,7 +1239,7 @@ static SND_START( scsp ) SCSP->stream = stream_create(device, 0, 2, 44100, SCSP, SCSP_Update); } - return SCSP; + return DEVICE_START_OK; } @@ -1385,6 +1382,7 @@ SND_GET_INFO( scsp ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct _SCSP); 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( scsp ); break; diff --git a/src/emu/sound/segapcm.c b/src/emu/sound/segapcm.c index 779a4f25f9d..a8a877074e0 100644 --- a/src/emu/sound/segapcm.c +++ b/src/emu/sound/segapcm.c @@ -80,10 +80,7 @@ static SND_START( segapcm ) { const sega_pcm_interface *intf = device->static_config; int mask, rom_mask, len; - struct segapcm *spcm; - - spcm = auto_malloc(sizeof(*spcm)); - memset(spcm, 0, sizeof(*spcm)); + struct segapcm *spcm = device->token; spcm->rom = (const UINT8 *)device->region; spcm->ram = auto_malloc(0x800); @@ -106,7 +103,7 @@ static SND_START( segapcm ) state_save_register_device_item_array(device, 0, spcm->low); state_save_register_device_item_pointer(device, 0, spcm->ram, 0x800); - return spcm; + return DEVICE_START_OK; } @@ -144,6 +141,7 @@ SND_GET_INFO( segapcm ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct segapcm); 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( segapcm ); break; diff --git a/src/emu/sound/sid6581.c b/src/emu/sound/sid6581.c index ec5d534bd27..a09e9b741d7 100644 --- a/src/emu/sound/sid6581.c +++ b/src/emu/sound/sid6581.c @@ -29,14 +29,11 @@ static STREAM_UPDATE( sid_update ) -static void *sid_start(const device_config *device, int clock, SIDTYPE sidtype) +static device_start_err sid_start(const device_config *device, int clock, SIDTYPE sidtype) { - SID6581 *sid; + SID6581 *sid = device->token; const sid6581_interface *iface = (const sid6581_interface*) device->static_config; - sid = (SID6581 *) auto_malloc(sizeof(*sid)); - memset(sid, 0, sizeof(*sid)); - sid->device = device; sid->mixer_channel = stream_create (device, 0, 1, device->machine->sample_rate, (void *) sid, sid_update); sid->PCMfreq = device->machine->sample_rate; @@ -46,7 +43,7 @@ static void *sid_start(const device_config *device, int clock, SIDTYPE sidtype) sid6581_init(sid); sidInitWaveformTables(sidtype); - return sid; + return DEVICE_START_OK; } @@ -113,6 +110,7 @@ SND_GET_INFO( sid6581 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(SID6581); 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( sid6581 ); break; diff --git a/src/emu/sound/sn76477.c b/src/emu/sound/sn76477.c index 33eaaf8e159..50c13c5033b 100644 --- a/src/emu/sound/sn76477.c +++ b/src/emu/sound/sn76477.c @@ -2388,7 +2388,7 @@ static void state_save_register(const device_config *device, struct SN76477 *sn) static SND_START( sn76477 ) { - struct SN76477 *sn; + struct SN76477 *sn = device->token; sn76477_interface *intf; @@ -2399,9 +2399,6 @@ static SND_START( sn76477 ) #endif - sn = auto_malloc(sizeof(*sn)); - memset(sn, 0, sizeof(*sn)); - sn->device = device; sn->channel = stream_create(device, 0, 1, device->machine->sample_rate, sn, SN76477_update); @@ -2417,8 +2414,6 @@ static SND_START( sn76477 ) intialize_noise(sn); - sndintrf_register_token(sn); - /* set up interface values */ _SN76477_enable_w(sn, intf->enable); _SN76477_vco_w(sn, intf->vco); @@ -2457,7 +2452,7 @@ static SND_START( sn76477 ) if (LOG_WAV) open_wav_file(sn); - return sn; + return DEVICE_START_OK; } @@ -2474,6 +2469,7 @@ SND_GET_INFO( sn76477 ) { switch (state) { + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct SN76477); break; case SNDINFO_PTR_START: info->start = SND_START_NAME( sn76477 ); break; case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( sn76477 ); break; case SNDINFO_STR_NAME: strcpy(info->s, "SN76477"); break; diff --git a/src/emu/sound/sn76496.c b/src/emu/sound/sn76496.c index 3a1ed9077bf..bcc71ef2dc6 100644 --- a/src/emu/sound/sn76496.c +++ b/src/emu/sound/sn76496.c @@ -314,15 +314,12 @@ static int SN76496_init(const device_config *device, int clock, struct SN76496 * } -static void *generic_start(const device_config *device, int clock, int feedbackmask, int noisetaps, int noiseinvert) +static device_start_err generic_start(const device_config *device, int clock, int feedbackmask, int noisetaps, int noiseinvert) { - struct SN76496 *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct SN76496 *chip = device->token; if (SN76496_init(device,clock,chip) != 0) - return NULL; + fatalerror("Error creating SN76496 chip"); SN76496_set_gain(chip, 0); chip->FeedbackMask = feedbackmask; @@ -338,8 +335,7 @@ static void *generic_start(const device_config *device, int clock, int feedbackm state_save_register_device_item_array(device, 0, chip->Count); state_save_register_device_item_array(device, 0, chip->Output); - return chip; - + return DEVICE_START_OK; } @@ -392,6 +388,7 @@ SND_GET_INFO( sn76496 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct SN76496); break; case SNDINFO_FCT_ALIAS: info->type = SOUND_SN76496; break; /* --- the following bits of info are returned as pointers to data or functions --- */ diff --git a/src/emu/sound/snkwave.c b/src/emu/sound/snkwave.c index 54ab16e41c8..30276dbed20 100644 --- a/src/emu/sound/snkwave.c +++ b/src/emu/sound/snkwave.c @@ -101,13 +101,10 @@ static STREAM_UPDATE( snkwave_update ) static SND_START( snkwave ) { - struct snkwave_sound *chip; + struct snkwave_sound *chip = device->token; assert(device->static_config == 0); - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); - /* adjust internal clock */ chip->external_clock = clock; @@ -128,7 +125,7 @@ static SND_START( snkwave ) state_save_register_device_item(device, 0, chip->waveform_position); state_save_register_device_item_pointer(device, 0, chip->waveform, WAVEFORM_LENGTH); - return chip; + return DEVICE_START_OK; } @@ -177,6 +174,7 @@ SND_GET_INFO( snkwave ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct snkwave_sound); 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( snkwave ); break; diff --git a/src/emu/sound/sp0250.c b/src/emu/sound/sp0250.c index 71cb6296249..0fae88116fe 100644 --- a/src/emu/sound/sp0250.c +++ b/src/emu/sound/sp0250.c @@ -195,10 +195,8 @@ static STREAM_UPDATE( sp0250_update ) static SND_START( sp0250 ) { const struct sp0250_interface *intf = device->static_config; - struct sp0250 *sp; + struct sp0250 *sp = device->token; - sp = auto_malloc(sizeof(*sp)); - memset(sp, 0, sizeof(*sp)); sp->RNG = 1; sp->drq = (intf != NULL) ? intf->drq_callback : NULL; if (sp->drq != NULL) @@ -209,7 +207,7 @@ static SND_START( sp0250 ) sp->stream = stream_create(device, 0, 1, clock / CLOCK_DIVIDER, sp, sp0250_update); - return sp; + return DEVICE_START_OK; } @@ -255,6 +253,7 @@ SND_GET_INFO( sp0250 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct sp0250); 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( sp0250 ); break; diff --git a/src/emu/sound/sp0256.c b/src/emu/sound/sp0256.c index c26ae3f60c9..cb9bc84bce8 100644 --- a/src/emu/sound/sp0256.c +++ b/src/emu/sound/sp0256.c @@ -1172,10 +1172,8 @@ static STREAM_UPDATE( sp0256_update ) static SND_START( sp0256 ) { const sp0256_interface *intf = device->static_config; - struct sp0256 *sp; + struct sp0256 *sp = device->token; - sp = auto_malloc(sizeof(*sp)); - memset(sp, 0, sizeof(*sp)); sp->device = device; sp->drq = intf->lrq_callback; sp->sby = intf->sby_callback; @@ -1210,7 +1208,7 @@ static SND_START( sp0256 ) sp->rom = device->region; sp0256_bitrevbuff(sp->rom, 0, 0xffff); - return sp; + return DEVICE_START_OK; } static SND_STOP( sp0256 ) @@ -1362,6 +1360,7 @@ SND_GET_INFO( sp0256 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct sp0256); 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( sp0256 ); break; diff --git a/src/emu/sound/speaker.c b/src/emu/sound/speaker.c index cf2c154c83a..3f5855be784 100644 --- a/src/emu/sound/speaker.c +++ b/src/emu/sound/speaker.c @@ -37,13 +37,14 @@ static STREAM_UPDATE( speaker_sound_update ) static SND_START( speaker ) { - struct speaker *sp = auto_malloc(sizeof(*sp)); + struct speaker *sp = device->token; sp->channel = stream_create(device, 0, 1, device->machine->sample_rate, sp, speaker_sound_update); sp->num_levels = 2; sp->levels = default_levels; sp->level = 0; - return sp; + + return DEVICE_START_OK; } @@ -87,6 +88,7 @@ SND_GET_INFO( speaker ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct speaker); 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( speaker ); break; diff --git a/src/emu/sound/st0016.c b/src/emu/sound/st0016.c index 519993ef107..e4de20774c5 100644 --- a/src/emu/sound/st0016.c +++ b/src/emu/sound/st0016.c @@ -127,16 +127,13 @@ static STREAM_UPDATE( st0016_update ) static SND_START( st0016 ) { const st0016_interface *intf = device->static_config; - struct st0016_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct st0016_info *info = device->token; info->sound_ram = intf->p_soundram; info->stream = stream_create(device, 0, 2, 44100, info, st0016_update); - return info; + return DEVICE_START_OK; } @@ -159,6 +156,7 @@ SND_GET_INFO( st0016 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct st0016_info); 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( st0016 ); break; diff --git a/src/emu/sound/tiaintf.c b/src/emu/sound/tiaintf.c index 7278b52bbb0..3cbaea8759e 100644 --- a/src/emu/sound/tiaintf.c +++ b/src/emu/sound/tiaintf.c @@ -19,18 +19,14 @@ static STREAM_UPDATE( tia_update ) static SND_START( tia ) { - struct tia_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct tia_info *info = device->token; info->channel = stream_create(device, 0, 1, clock, info, tia_update); info->chip = tia_sound_init(clock, clock, 16); - if (!info->chip) - return NULL; + assert_always(info->chip != NULL, "Error creating TIA chip"); - return info; + return DEVICE_START_OK; } static SND_STOP( tia ) @@ -67,6 +63,7 @@ SND_GET_INFO( tia ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct tia_info); 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( tia ); break; diff --git a/src/emu/sound/tms3615.c b/src/emu/sound/tms3615.c index 5b923472b42..c1da3f9fb7f 100644 --- a/src/emu/sound/tms3615.c +++ b/src/emu/sound/tms3615.c @@ -79,16 +79,13 @@ void tms3615_enable_w(int chip, int enable) static SND_START( tms3615 ) { - struct TMS3615 *tms; - - tms = auto_malloc(sizeof(*tms)); - memset(tms, 0, sizeof(*tms)); + struct TMS3615 *tms = device->token; tms->channel = stream_create(device, 0, 2, clock/8, tms, tms3615_sound_update); tms->samplerate = clock/8; tms->basefreq = clock; - return tms; + return DEVICE_START_OK; } /************************************************************************** @@ -108,6 +105,7 @@ SND_GET_INFO( tms3615 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct TMS3615); 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( tms3615 ); break; diff --git a/src/emu/sound/tms36xx.c b/src/emu/sound/tms36xx.c index 936c7ee1152..78d46b4bf4a 100644 --- a/src/emu/sound/tms36xx.c +++ b/src/emu/sound/tms36xx.c @@ -488,12 +488,9 @@ void tms3617_enable_w(int chip, int enable) static SND_START( tms36xx ) { int j; - struct TMS36XX *tms; + struct TMS36XX *tms = device->token; int enable; - tms = auto_malloc(sizeof(*tms)); - memset(tms, 0, sizeof(*tms)); - tms->intf = device->static_config; tms->channel = stream_create(device, 0, 1, clock * 64, tms, tms36xx_sound_update); @@ -518,7 +515,7 @@ static SND_START( tms36xx ) tms->decay[3], tms->decay[4], tms->decay[5])); LOG(("TMS36xx speed %d\n", tms->speed)); - return tms; + return DEVICE_START_OK; } @@ -542,6 +539,7 @@ SND_GET_INFO( tms36xx ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct TMS36XX); 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( tms36xx ); break; diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index 7586b2faa92..fd14c537660 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -630,10 +630,7 @@ static SND_START( upd7759 ) { static const upd7759_interface defintrf = { 0 }; const upd7759_interface *intf = (device->static_config != NULL) ? device->static_config : &defintrf; - struct upd7759_chip *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct upd7759_chip *chip = device->token; chip->device = device; @@ -666,7 +663,7 @@ static SND_START( upd7759 ) register_for_save(chip, device); - return chip; + return DEVICE_START_OK; } @@ -792,6 +789,7 @@ SND_GET_INFO( upd7759 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct upd7759_chip); 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( upd7759 ); break; diff --git a/src/emu/sound/vlm5030.c b/src/emu/sound/vlm5030.c index 4e728063ebb..4ffa47d3d83 100644 --- a/src/emu/sound/vlm5030.c +++ b/src/emu/sound/vlm5030.c @@ -641,10 +641,7 @@ static SND_START( vlm5030 ) { const vlm5030_interface defintrf = { 0 }; int emulation_rate; - struct vlm5030_info *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct vlm5030_info *chip = device->token; chip->device = device; chip->intf = (device->static_config != NULL) ? device->static_config : &defintrf; @@ -690,7 +687,7 @@ static SND_START( vlm5030 ) state_save_register_device_item_array(device,0,chip->x); state_save_register_postload(device->machine, vlm5030_restore_state, chip); - return chip; + return DEVICE_START_OK; } @@ -712,6 +709,7 @@ SND_GET_INFO( vlm5030 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct vlm5030_info); 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( vlm5030 ); break; diff --git a/src/emu/sound/votrax.c b/src/emu/sound/votrax.c index f3d4e9862c5..eb0785af77d 100644 --- a/src/emu/sound/votrax.c +++ b/src/emu/sound/votrax.c @@ -103,10 +103,7 @@ static STREAM_UPDATE( votrax_update_sound ) static SND_START( votrax ) { - struct votrax_info *votrax; - - votrax = auto_malloc(sizeof(*votrax)); - memset(votrax, 0, sizeof(*votrax)); + struct votrax_info *votrax = device->token; votrax->device = device; votrax->samples = readsamples(VotraxTable,"votrax"); @@ -118,7 +115,7 @@ static SND_START( votrax ) votrax->sample = NULL; votrax->step = 0; - return votrax; + return DEVICE_START_OK; } @@ -174,6 +171,7 @@ SND_GET_INFO( votrax ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct votrax_info); 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( votrax ); break; diff --git a/src/emu/sound/vrender0.c b/src/emu/sound/vrender0.c index 0376bd315bd..e0c602783b9 100644 --- a/src/emu/sound/vrender0.c +++ b/src/emu/sound/vrender0.c @@ -97,10 +97,7 @@ void vr0_snd_set_areas(UINT32 *texture,UINT32 *frame) static SND_START( vrender0 ) { const vr0_interface *intf; - struct _VR0Chip *VR0; - - VR0 = auto_malloc(sizeof(*VR0)); - memset(VR0, 0, sizeof(*VR0)); + struct _VR0Chip *VR0 = device->token; intf=device->static_config; @@ -109,7 +106,7 @@ static SND_START( vrender0 ) VR0->stream = stream_create(device, 0, 2, 44100, VR0, VR0_Update); - return VR0; + return DEVICE_START_OK; } WRITE32_HANDLER(vr0_snd_write) @@ -256,6 +253,7 @@ SND_GET_INFO( vrender0 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct _VR0Chip); 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( vrender0 ); break; diff --git a/src/emu/sound/wave.c b/src/emu/sound/wave.c index 92faa5a0d92..759751a1ac9 100644 --- a/src/emu/sound/wave.c +++ b/src/emu/sound/wave.c @@ -18,7 +18,6 @@ #include "wave.h" #define ALWAYS_PLAY_SOUND 0 -#define WAVE_TOKEN_MASK 0xFFFF0000 @@ -64,7 +63,7 @@ static SND_START( wave ) image = device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, device->tag ); #endif stream_create(device, 0, 1, device->machine->sample_rate, (void *)image, wave_sound_update); - return (void *) (FPTR)(WAVE_TOKEN_MASK); + return DEVICE_START_OK; } @@ -87,6 +86,7 @@ SND_GET_INFO( wave ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = 1; 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( wave ); break; diff --git a/src/emu/sound/x1_010.c b/src/emu/sound/x1_010.c index 3ac261aef90..86373cc5125 100644 --- a/src/emu/sound/x1_010.c +++ b/src/emu/sound/x1_010.c @@ -195,10 +195,7 @@ static SND_START( x1_010 ) { int i; const x1_010_interface *intf = device->static_config; - struct x1_010_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); + struct x1_010_info *info = device->token; info->region = device->region; info->base_clock = clock; @@ -215,7 +212,7 @@ static SND_START( x1_010 ) /* get stream channels */ info->stream = stream_create(device,0,2,info->rate,info,seta_update); - return info; + return DEVICE_START_OK; } @@ -302,6 +299,7 @@ SND_GET_INFO( x1_010 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct x1_010_info); 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( x1_010 ); break; diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index 043c4fff619..10c8f4335fb 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -1743,10 +1743,8 @@ static SND_START( ymf271 ) static const ymf271_interface defintrf = { 0 }; const ymf271_interface *intf; int i; - YMF271Chip *chip; + YMF271Chip *chip = device->token; - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); chip->device = device; chip->clock = clock; @@ -1770,7 +1768,7 @@ static SND_START( ymf271 ) total_level[i] = (int)(65536.0 / pow(10.0, db / 20.0)); } - return chip; + return DEVICE_START_OK; } READ8_HANDLER( ymf271_0_r ) @@ -1823,6 +1821,7 @@ SND_GET_INFO( ymf271 ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(YMF271Chip); 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( ymf271 ); break; diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 06dca0b966a..00f7a90647f 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -670,10 +670,7 @@ static SND_START( ymf278b ) static const ymf278b_interface defintrf = { 0 }; const ymf278b_interface *intf; int i; - YMF278BChip *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + YMF278BChip *chip = device->token; intf = (device->static_config != NULL) ? device->static_config : &defintrf; @@ -698,7 +695,7 @@ static SND_START( ymf278b ) chip->mix_level[i] = chip->volume[8*i+8]; chip->mix_level[7] = 0; - return chip; + return DEVICE_START_OK; } @@ -804,6 +801,7 @@ SND_GET_INFO( ymf278b ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(YMF278BChip); 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( ymf278b ); break; diff --git a/src/emu/sound/ymz280b.c b/src/emu/sound/ymz280b.c index 8f53b53130d..6232f638cb9 100644 --- a/src/emu/sound/ymz280b.c +++ b/src/emu/sound/ymz280b.c @@ -631,10 +631,7 @@ static SND_START( ymz280b ) { static const ymz280b_interface defintrf = { 0 }; const ymz280b_interface *intf = (device->static_config != NULL) ? device->static_config : &defintrf; - struct YMZ280BChip *chip; - - chip = auto_malloc(sizeof(*chip)); - memset(chip, 0, sizeof(*chip)); + struct YMZ280BChip *chip = device->token; chip->device = device; chip->ext_ram_read = intf->ext_read; @@ -699,7 +696,7 @@ static SND_START( ymz280b ) #endif /* success */ - return chip; + return DEVICE_START_OK; } @@ -1114,6 +1111,7 @@ SND_GET_INFO( ymz280b ) switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ + case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct YMZ280BChip); 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( ymz280b ); break; |