From 4a80c53a8d5e34cea84cd1f8a0061600a548e354 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sun, 30 Aug 2009 05:42:33 +0000 Subject: [PATCH] [from AtariAce] Hi mamedev, This patch continues deglobalifying the MAME core, this time targeting sound.c. The first two patches adds running_machine to apis in sound.h that lack it (the first patch is generated by the perl script, the second patch fixes some cases it didn't handle well). The last patch then removes the globals in the traditional way. ~aa --- src/emu/debug/debugcpu.c | 4 +- src/emu/mame.c | 4 +- src/emu/mame.h | 2 + src/emu/sound.c | 118 +++++++++++++++++++++--------------- src/emu/sound.h | 8 +-- src/emu/sound/sn76477.c | 2 +- src/emu/ui.c | 6 +- src/mame/audio/8080bw.c | 14 ++--- src/mame/audio/astrof.c | 4 +- src/mame/audio/bzone.c | 4 +- src/mame/audio/cinemat.c | 2 +- src/mame/audio/circus.c | 2 +- src/mame/audio/mw8080bw.c | 22 +++---- src/mame/audio/scramble.c | 2 +- src/mame/audio/segag80r.c | 2 +- src/mame/audio/turbo.c | 4 +- src/mame/drivers/astinvad.c | 4 +- src/mame/drivers/buggychl.c | 2 +- src/mame/drivers/crbaloon.c | 2 +- src/mame/drivers/darius.c | 2 +- src/mame/drivers/galaxian.c | 2 +- src/mame/drivers/m10.c | 6 +- src/mame/drivers/maxaflex.c | 2 +- src/mame/drivers/ninjaw.c | 2 +- src/mame/drivers/segahang.c | 2 +- src/mame/drivers/segaorun.c | 2 +- src/mame/drivers/segaxbd.c | 4 +- src/mame/drivers/segaybd.c | 2 +- src/mame/drivers/system1.c | 2 +- src/mame/drivers/thepit.c | 2 +- src/mame/drivers/tutankhm.c | 2 +- src/mame/drivers/uapce.c | 2 +- src/mame/drivers/warriorb.c | 2 +- src/mame/video/bking.c | 2 +- src/mame/video/dday.c | 2 +- 35 files changed, 133 insertions(+), 113 deletions(-) diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index c2c7435bcb5..1d6c96cafa1 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -669,7 +669,7 @@ void debug_cpu_instruction_hook(const device_config *device, offs_t curpc) debugger_refresh_display(device->machine); /* wait for the debugger; during this time, disable sound output */ - sound_mute(TRUE); + sound_mute(device->machine, TRUE); while (global->execution_state == EXECUTION_STATE_STOPPED) { /* flush any pending updates before waiting again */ @@ -694,7 +694,7 @@ void debug_cpu_instruction_hook(const device_config *device, offs_t curpc) if (mame_is_scheduled_event_pending(device->machine)) global->execution_state = EXECUTION_STATE_RUNNING; } - sound_mute(FALSE); + sound_mute(device->machine, FALSE); /* remember the last visible CPU in the debugger */ global->visiblecpu = device; diff --git a/src/emu/mame.c b/src/emu/mame.c index 1498b73cf39..c22e8a5ae3f 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -335,7 +335,7 @@ int mame_execute(core_options *options) /* load the configuration settings and NVRAM */ settingsloaded = config_load_settings(machine); nvram_load(machine); - sound_mute(FALSE); + sound_mute(machine, FALSE); /* display the startup screens */ ui_display_startup_screens(machine, firstrun, !settingsloaded); @@ -377,7 +377,7 @@ int mame_execute(core_options *options) end_resource_tracking(); /* save the NVRAM and configuration */ - sound_mute(TRUE); + sound_mute(machine, TRUE); nvram_save(machine); config_save_settings(machine); } diff --git a/src/emu/mame.h b/src/emu/mame.h index 375d3a07331..9a2de49849d 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -134,6 +134,7 @@ typedef struct _tilemap_private tilemap_private; typedef struct _streams_private streams_private; typedef struct _devices_private devices_private; typedef struct _romload_private romload_private; +typedef struct _sound_private sound_private; typedef struct _input_port_private input_port_private; typedef struct _ui_input_private ui_input_private; typedef struct _cheat_private cheat_private; @@ -184,6 +185,7 @@ struct _running_machine streams_private * streams_data; /* internal data from streams.c */ devices_private * devices_data; /* internal data from devices.c */ romload_private * romload_data; /* internal data from romload.c */ + sound_private * sound_data; /* internal data from sound.c */ input_port_private * input_port_data; /* internal data from inptport.c */ ui_input_private * ui_input_data; /* internal data from uiinput.c */ cheat_private * cheat_data; /* internal data from cheat.c */ diff --git a/src/emu/sound.c b/src/emu/sound.c index fdf4bbf932f..e11b07d9694 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -80,26 +80,24 @@ struct _speaker_info #endif }; +struct _sound_private +{ + emu_timer *update_timer; + int totalsnd; -/*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ + UINT32 finalmix_leftover; + INT16 *finalmix; + INT32 *leftmix; + INT32 *rightmix; -static emu_timer *sound_update_timer; + int muted; + int attenuation; + int enabled; + int nosound_mode; -static int totalsnd; - -static INT16 *finalmix; -static UINT32 finalmix_leftover; -static INT32 *leftmix, *rightmix; - -static int sound_muted; -static int sound_attenuation; -static int global_sound_enabled; -static int nosound_mode; - -static wav_file *wavfile; + wav_file *wavfile; +}; @@ -191,24 +189,27 @@ INLINE speaker_info *index_to_input(running_machine *machine, int index, int *in void sound_init(running_machine *machine) { + sound_private *global; const char *filename; + machine->sound_data = global = auto_alloc_clear(machine, sound_private); + /* handle -nosound */ - nosound_mode = !options_get_bool(mame_options(), OPTION_SOUND); - if (nosound_mode) + global->nosound_mode = !options_get_bool(mame_options(), OPTION_SOUND); + if (global->nosound_mode) machine->sample_rate = 11025; /* count the speakers */ VPRINTF(("total speakers = %d\n", speaker_output_count(machine->config))); /* allocate memory for mix buffers */ - leftmix = auto_alloc_array(machine, INT32, machine->sample_rate); - rightmix = auto_alloc_array(machine, INT32, machine->sample_rate); - finalmix = auto_alloc_array(machine, INT16, machine->sample_rate); + global->leftmix = auto_alloc_array(machine, INT32, machine->sample_rate); + global->rightmix = auto_alloc_array(machine, INT32, machine->sample_rate); + global->finalmix = auto_alloc_array(machine, INT16, machine->sample_rate); /* allocate a global timer for sound timing */ - sound_update_timer = timer_alloc(machine, sound_update, NULL); - timer_adjust_periodic(sound_update_timer, STREAMS_UPDATE_FREQUENCY, 0, STREAMS_UPDATE_FREQUENCY); + global->update_timer = timer_alloc(machine, sound_update, NULL); + timer_adjust_periodic(global->update_timer, STREAMS_UPDATE_FREQUENCY, 0, STREAMS_UPDATE_FREQUENCY); /* finally, do all the routing */ VPRINTF(("route_sound\n")); @@ -217,12 +218,12 @@ void sound_init(running_machine *machine) /* open the output WAV file if specified */ filename = options_get_string(mame_options(), OPTION_WAVWRITE); if (filename[0] != 0) - wavfile = wav_open(filename, machine->sample_rate, 2); + global->wavfile = wav_open(filename, machine->sample_rate, 2); /* enable sound by default */ - global_sound_enabled = TRUE; - sound_muted = FALSE; - sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME)); + global->enabled = TRUE; + global->muted = FALSE; + sound_set_attenuation(machine, options_get_int(mame_options(), OPTION_VOLUME)); /* register callbacks */ config_register(machine, "mixer", sound_load, sound_save); @@ -238,12 +239,15 @@ void sound_init(running_machine *machine) static void sound_exit(running_machine *machine) { + sound_private *global = machine->sound_data; + /* close any open WAV file */ - if (wavfile != NULL) - wav_close(wavfile); + if (global->wavfile != NULL) + wav_close(global->wavfile); + global->wavfile = NULL; /* reset variables */ - totalsnd = 0; + global->totalsnd = 0; } @@ -541,25 +545,29 @@ static void sound_reset(running_machine *machine) static void sound_pause(running_machine *machine, int pause) { + sound_private *global = machine->sound_data; + if (pause) - sound_muted |= 0x02; + global->muted |= 0x02; else - sound_muted &= ~0x02; - osd_set_mastervolume(sound_muted ? -32 : sound_attenuation); + global->muted &= ~0x02; + osd_set_mastervolume(global->muted ? -32 : global->attenuation); } /*------------------------------------------------- - sound_pause - pause sound output + sound_mute - mute sound output -------------------------------------------------*/ -void sound_mute(int mute) +void sound_mute(running_machine *machine, int mute) { + sound_private *global = machine->sound_data; + if (mute) - sound_muted |= 0x01; + global->muted |= 0x01; else - sound_muted &= ~0x01; - osd_set_mastervolume(sound_muted ? -32 : sound_attenuation); + global->muted &= ~0x01; + osd_set_mastervolume(global->muted ? -32 : global->attenuation); } @@ -567,10 +575,11 @@ void sound_mute(int mute) sound_set_attenuation - set the global volume -------------------------------------------------*/ -void sound_set_attenuation(int attenuation) +void sound_set_attenuation(running_machine *machine, int attenuation) { - sound_attenuation = attenuation; - osd_set_mastervolume(sound_muted ? -32 : sound_attenuation); + sound_private *global = machine->sound_data; + global->attenuation = attenuation; + osd_set_mastervolume(global->muted ? -32 : global->attenuation); } @@ -579,9 +588,10 @@ void sound_set_attenuation(int attenuation) volume -------------------------------------------------*/ -int sound_get_attenuation(void) +int sound_get_attenuation(running_machine *machine) { - return sound_attenuation; + sound_private *global = machine->sound_data; + return global->attenuation; } @@ -590,9 +600,10 @@ int sound_get_attenuation(void) globally -------------------------------------------------*/ -void sound_global_enable(int enable) +void sound_global_enable(running_machine *machine, int enable) { - global_sound_enabled = enable; + sound_private *global = machine->sound_data; + global->enabled = enable; } @@ -684,11 +695,18 @@ static TIMER_CALLBACK( sound_update ) const device_config *curspeak; int samples_this_update = 0; int sample; + sound_private *global = machine->sound_data; + INT16 *finalmix; + INT32 *leftmix, *rightmix; VPRINTF(("sound_update\n")); profiler_mark_start(PROFILER_SOUND); + leftmix = global->leftmix; + rightmix = global->rightmix; + finalmix = global->finalmix; + /* force all the speaker streams to generate the proper number of samples */ for (curspeak = speaker_output_first(machine->config); curspeak != NULL; curspeak = speaker_output_next(curspeak)) { @@ -729,7 +747,7 @@ static TIMER_CALLBACK( sound_update ) #endif /* mix if sound is enabled */ - if (global_sound_enabled && !nosound_mode) + if (global->enabled && !global->nosound_mode) { /* if the speaker is centered, send to both left and right */ if (spk->speaker->x == 0) @@ -755,7 +773,7 @@ static TIMER_CALLBACK( sound_update ) /* now downmix the final result */ finalmix_step = video_get_speed_factor(); finalmix_offset = 0; - for (sample = finalmix_leftover; sample < samples_this_update * 100; sample += finalmix_step) + for (sample = global->finalmix_leftover; sample < samples_this_update * 100; sample += finalmix_step) { int sampindex = sample / 100; INT32 samp; @@ -776,15 +794,15 @@ static TIMER_CALLBACK( sound_update ) samp = 32767; finalmix[finalmix_offset++] = samp; } - finalmix_leftover = sample - samples_this_update * 100; + global->finalmix_leftover = sample - samples_this_update * 100; /* play the result */ if (finalmix_offset > 0) { osd_update_audio_stream(machine, finalmix, finalmix_offset / 2); video_avi_add_sound(machine, finalmix, finalmix_offset / 2); - if (wavfile != NULL) - wav_add_data_16(wavfile, finalmix, finalmix_offset); + if (global->wavfile != NULL) + wav_add_data_16(global->wavfile, finalmix, finalmix_offset); } /* update the streamer */ diff --git a/src/emu/sound.h b/src/emu/sound.h index 299a8e2d644..3228fd31a29 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -156,10 +156,10 @@ DEVICE_GET_INFO( sound ); /* global sound controls */ -void sound_mute(int mute); -void sound_set_attenuation(int attenuation); -int sound_get_attenuation(void); -void sound_global_enable(int enable); +void sound_mute(running_machine *machine, int mute); +void sound_set_attenuation(running_machine *machine, int attenuation); +int sound_get_attenuation(running_machine *machine); +void sound_global_enable(running_machine *machine, int enable); /* user gain controls on speaker inputs for mixing */ int sound_get_user_gain_count(running_machine *machine); diff --git a/src/emu/sound/sn76477.c b/src/emu/sound/sn76477.c index 6f7b0c33910..a92e7b6a1fe 100644 --- a/src/emu/sound/sn76477.c +++ b/src/emu/sound/sn76477.c @@ -1999,7 +1999,7 @@ static STREAM_UPDATE( SN76477_update ) { recursing = 1; - sound_global_enable(1); + sound_global_enable(device->machine, 1); SN76477_test_enable_w(sn, !sn->enable); } diff --git a/src/emu/ui.c b/src/emu/ui.c index 1e5c2803a73..1981264986c 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -1576,10 +1576,10 @@ static slider_state *slider_init(running_machine *machine) static INT32 slider_volume(running_machine *machine, void *arg, astring *string, INT32 newval) { if (newval != SLIDER_NOCHANGE) - sound_set_attenuation(newval); + sound_set_attenuation(machine, newval); if (string != NULL) - astring_printf(string, "%3ddB", sound_get_attenuation()); - return sound_get_attenuation(); + astring_printf(string, "%3ddB", sound_get_attenuation(machine)); + return sound_get_attenuation(machine); } diff --git a/src/mame/audio/8080bw.c b/src/mame/audio/8080bw.c index 80c97fde9b8..7d88b36416c 100644 --- a/src/mame/audio/8080bw.c +++ b/src/mame/audio/8080bw.c @@ -52,7 +52,7 @@ WRITE8_HANDLER( invadpt2_sh_port_1_w ) c8080bw_screen_red_w(data & 0x04); - sound_global_enable(data & 0x20); + sound_global_enable(space->machine, data & 0x20); port_1_last_extra = data; @@ -145,7 +145,7 @@ WRITE8_HANDLER( lrescue_sh_port_1_w ) if (rising_bits & 0x08) sample_start(samples, 1, 0, 0); /* Alien Hit */ if (rising_bits & 0x10) sample_start(samples, 2, 5, 0); /* Bonus Ship (not confirmed) */ - sound_global_enable(data & 0x20); + sound_global_enable(space->machine, data & 0x20); c8080bw_screen_red_w(data & 0x04); @@ -204,7 +204,7 @@ WRITE8_HANDLER( ballbomb_sh_port_1_w ) if (rising_bits & 0x08) sample_start(samples, 1, 7, 0); /* Hit a Bomb */ if (rising_bits & 0x10) sample_start(samples, 3, 8, 0); /* Bonus Base at 1500 points */ - sound_global_enable(data & 0x20); + sound_global_enable(space->machine, data & 0x20); c8080bw_screen_red_w(data & 0x04); @@ -281,7 +281,7 @@ WRITE8_HANDLER( indianbt_sh_port_1_w ) if (rising_bits & 0x04) sample_start(samples, 2, 3, 0); /* Move */ if (rising_bits & 0x08) sample_start(samples, 3, 2, 0); /* Hit */ - sound_global_enable(data & 0x20); + sound_global_enable(space->machine, data & 0x20); c8080bw_screen_red_w(data & 0x01); @@ -881,7 +881,7 @@ WRITE8_HANDLER( schaser_sh_port_2_w ) discrete_sound_w(discrete, SCHASER_MUSIC_BIT, data & 0x01); discrete_sound_w(discrete, SCHASER_SND_EN, data & 0x02); - sound_global_enable(data & 0x02); + sound_global_enable(space->machine, data & 0x02); coin_lockout_global_w(data & 0x04); @@ -1090,7 +1090,7 @@ WRITE8_HANDLER( schasrcv_sh_port_2_w ) speaker_level_w(speaker, (data & 0x01) ? 1 : 0); /* End-of-Level */ - sound_global_enable(data & 0x10); + sound_global_enable(space->machine, data & 0x10); c8080bw_flip_screen_w(space, data & 0x20); } @@ -1112,7 +1112,7 @@ WRITE8_HANDLER( yosakdon_sh_port_1_w ) if (rising_bits & 0x08) sample_start(samples, 1, 2, 0); /* Man dead */ if (rising_bits & 0x10) sample_start(samples, 5, 8, 0); /* Bonus Man? */ - sound_global_enable(data & 0x20); + sound_global_enable(space->machine, data & 0x20); port_1_last_extra = data; } diff --git a/src/mame/audio/astrof.c b/src/mame/audio/astrof.c index 38e4704458b..d19df98d63a 100644 --- a/src/mame/audio/astrof.c +++ b/src/mame/audio/astrof.c @@ -106,7 +106,7 @@ WRITE8_HANDLER( astrof_audio_1_w ) /* D6 - don't know. Probably something to do with the explosion sounds */ /* D7 - sound enable bit */ - sound_global_enable(data & 0x80); + sound_global_enable(space->machine, data & 0x80); port_1_last = data; } @@ -237,7 +237,7 @@ WRITE8_HANDLER( tomahawk_audio_w ) /* D6 - explosion */ /* D7 - sound enable bit */ - sound_global_enable(data & 0x80); + sound_global_enable(space->machine, data & 0x80); } diff --git a/src/mame/audio/bzone.c b/src/mame/audio/bzone.c index 733ed9d5865..4d980c05936 100644 --- a/src/mame/audio/bzone.c +++ b/src/mame/audio/bzone.c @@ -64,7 +64,7 @@ WRITE8_HANDLER( bzone_sounds_w ) stream_update(channel); latch = data; - sound_global_enable(latch & 0x20); + sound_global_enable(space->machine, latch & 0x20); } static STREAM_UPDATE( bzone_sound_update ) @@ -567,7 +567,7 @@ WRITE8_DEVICE_HANDLER( bzone_sounds_w ) discrete_sound_w(device, BZ_INPUT, data); output_set_value("startled", (data >> 6) & 1); - sound_global_enable(data & 0x20); + sound_global_enable(device->machine, data & 0x20); } diff --git a/src/mame/audio/cinemat.c b/src/mame/audio/cinemat.c index 6930cd2c3d1..764302ca714 100644 --- a/src/mame/audio/cinemat.c +++ b/src/mame/audio/cinemat.c @@ -1482,7 +1482,7 @@ static WRITE8_DEVICE_HANDLER( sound_portb_w ) /* bit 2 controls the global mute */ if ((data & 4) != (last_portb_write & 4)) - sound_global_enable(!(data & 4)); + sound_global_enable(device->machine, !(data & 4)); /* remember the last value written */ last_portb_write = data; diff --git a/src/mame/audio/circus.c b/src/mame/audio/circus.c index 1f39f5ff11b..3b621fdf790 100644 --- a/src/mame/audio/circus.c +++ b/src/mame/audio/circus.c @@ -278,5 +278,5 @@ WRITE8_HANDLER( circus_clown_z_w ) } /* Bit 7 enables amplifier (0 = on) */ - sound_global_enable(~data & 0x80); + sound_global_enable(space->machine, ~data & 0x80); } diff --git a/src/mame/audio/mw8080bw.c b/src/mame/audio/mw8080bw.c index 3c2655eefab..cee27e6a97c 100644 --- a/src/mame/audio/mw8080bw.c +++ b/src/mame/audio/mw8080bw.c @@ -1058,7 +1058,7 @@ WRITE8_DEVICE_HANDLER( checkmat_audio_w ) coin_counter_w(0, (data >> 2) & 0x01); - sound_global_enable((data >> 3) & 0x01); + sound_global_enable(device->machine, (data >> 3) & 0x01); discrete_sound_w(device, CHECKMAT_TONE_DATA_45, (data >> 4) & 0x03); discrete_sound_w(device, CHECKMAT_TONE_DATA_67, (data >> 6) & 0x03); @@ -1653,7 +1653,7 @@ WRITE8_HANDLER( gmissile_audio_1_w ) coin_counter_w(0, (data >> 2) & 0x01); - sound_global_enable((data >> 3) & 0x01); + sound_global_enable(space->machine, (data >> 3) & 0x01); /* if (data & 0x10) enable RIGHT MISSILE sound (goes to right speaker) */ if (rising_bits & 0x10) sample_start(samples1, 0, 0, 0); @@ -1749,7 +1749,7 @@ WRITE8_HANDLER( m4_audio_1_w ) coin_counter_w(0, (data >> 2) & 0x01); - sound_global_enable((data >> 3) & 0x01); + sound_global_enable(space->machine, (data >> 3) & 0x01); /* if (data & 0x10) enable LEFT PLAYER SHOT sound (goes to left speaker) */ if (rising_bits & 0x10) sample_start(samples0, 0, 0, 0); @@ -2052,7 +2052,7 @@ WRITE8_DEVICE_HANDLER( clowns_audio_2_w ) discrete_sound_w(device, CLOWNS_POP_TOP_EN, (data >> 2) & 0x01); - sound_global_enable((data >> 3) & 0x01); + sound_global_enable(device->machine, (data >> 3) & 0x01); discrete_sound_w(device, CLOWNS_SPRINGBOARD_HIT_EN, (data >> 4) & 0x01); @@ -2109,7 +2109,7 @@ WRITE8_HANDLER( shuffle_audio_1_w ) /* if (data & 0x02) enable SHUFFLE ROLLOVER sound */ - sound_global_enable((data >> 2) & 0x01); + sound_global_enable(space->machine, (data >> 2) & 0x01); /* set SHUFFLE ROLLING sound((data >> 3) & 0x07) 0, if not rolling, faster rolling = higher number */ @@ -2198,7 +2198,7 @@ WRITE8_HANDLER( dogpatch_audio_w ) coin_counter_w(0, (data >> 2) & 0x01); - sound_global_enable((data >> 3) & 0x01); + sound_global_enable(space->machine, (data >> 3) & 0x01); /* if (data & 0x10) enable LEFT SHOOT sound */ @@ -2742,7 +2742,7 @@ MACHINE_DRIVER_END WRITE8_DEVICE_HANDLER( spcenctr_audio_1_w ) { - sound_global_enable((data >> 0) & 0x01); + sound_global_enable(device->machine, (data >> 0) & 0x01); /* D1 is marked as 'OPTIONAL SWITCH VIDEO FOR COCKTAIL', but it is never set by the software */ @@ -2830,7 +2830,7 @@ WRITE8_HANDLER( phantom2_audio_1_w ) /* if (data & 0x02) enable ENEMY SHOT sound */ - sound_global_enable((data >> 2) & 0x01); + sound_global_enable(space->machine, (data >> 2) & 0x01); coin_counter_w(0, (data >> 3) & 0x01); @@ -2956,7 +2956,7 @@ WRITE8_DEVICE_HANDLER( bowler_audio_1_w ) coin_counter_w(0, (data >> 1) & 0x01); - sound_global_enable((data >> 2) & 0x01); + sound_global_enable(device->machine, (data >> 2) & 0x01); discrete_sound_w(device, BOWLER_FOWL_EN, (data >> 3) & 0x01); @@ -3693,7 +3693,7 @@ WRITE8_DEVICE_HANDLER( invaders_audio_1_w ) discrete_sound_w(device, INVADERS_NODE(INVADERS_INVADER_HIT_EN, 1), data & 0x08); discrete_sound_w(device, INVADERS_NODE(INVADERS_BONUS_MISSLE_BASE_EN, 1), data & 0x10); - sound_global_enable(data & 0x20); + sound_global_enable(device->machine, data & 0x20); /* D6 and D7 are not connected */ } @@ -4075,7 +4075,7 @@ WRITE8_DEVICE_HANDLER( invad2ct_audio_1_w ) discrete_sound_w(device, INVADERS_NODE(INVADERS_INVADER_HIT_EN, 1), data & 0x08); discrete_sound_w(device, INVADERS_NODE(INVADERS_BONUS_MISSLE_BASE_EN, 1), data & 0x10); - sound_global_enable(data & 0x20); + sound_global_enable(device->machine, data & 0x20); /* D6 and D7 are not connected */ } diff --git a/src/mame/audio/scramble.c b/src/mame/audio/scramble.c index cde1a4117ed..60dba3e39e5 100644 --- a/src/mame/audio/scramble.c +++ b/src/mame/audio/scramble.c @@ -84,7 +84,7 @@ WRITE8_DEVICE_HANDLER( scramble_sh_irqtrigger_w ) TTL7474_update(device->machine, 2); /* bit 4 is sound disable */ - sound_global_enable(~data & 0x10); + sound_global_enable(device->machine, ~data & 0x10); } WRITE8_DEVICE_HANDLER( mrkougar_sh_irqtrigger_w ) diff --git a/src/mame/audio/segag80r.c b/src/mame/audio/segag80r.c index 068ccb7a5b8..530f2872dc6 100644 --- a/src/mame/audio/segag80r.c +++ b/src/mame/audio/segag80r.c @@ -274,7 +274,7 @@ WRITE8_HANDLER( astrob_sound_w ) if ((data & 0x10) && sample_playing(samples, 4)) sample_stop(samples, 4); /* MUTE */ - sound_global_enable(!(data & 0x20)); + sound_global_enable(space->machine, !(data & 0x20)); /* REFILL: channel 5 */ if (!(data & 0x40) && !sample_playing(samples, 5)) sample_start(samples, 5, 9, FALSE); diff --git a/src/mame/audio/turbo.c b/src/mame/audio/turbo.c index 8b3c35f7155..aad96af4f99 100644 --- a/src/mame/audio/turbo.c +++ b/src/mame/audio/turbo.c @@ -413,7 +413,7 @@ WRITE8_DEVICE_HANDLER( subroc3d_sound_c_w ) sample_set_volume(samples, 11, (data & 0x40) ? 0 : 1.0); /* /GAME START */ - sound_global_enable(!(data & 0x80)); + sound_global_enable(device->machine, !(data & 0x80)); } @@ -568,7 +568,7 @@ WRITE8_DEVICE_HANDLER( buckrog_sound_b_w ) if ((diff & 0x40) && !(data & 0x40) && sample_playing(samples, 5)) sample_stop(samples, 5); /* GAME ON */ - sound_global_enable(data & 0x80); + sound_global_enable(device->machine, data & 0x80); } diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c index 2be2fe81497..afad784b972 100644 --- a/src/mame/drivers/astinvad.c +++ b/src/mame/drivers/astinvad.c @@ -267,7 +267,7 @@ static WRITE8_DEVICE_HANDLER( astinvad_sound1_w ) if (bits_gone_hi & 0x04) sample_start(samples, 2, SND_BASEHIT, 0); if (bits_gone_hi & 0x08) sample_start(samples, 3, SND_INVADERHIT, 0); - sound_global_enable(data & 0x20); + sound_global_enable(device->machine, data & 0x20); screen_red = data & 0x04; } @@ -313,7 +313,7 @@ static WRITE8_HANDLER( spaceint_sound2_w ) int bits_gone_hi = data & ~sound_state[1]; sound_state[1] = data; - sound_global_enable(data & 0x02); + sound_global_enable(space->machine, data & 0x02); if (bits_gone_hi & 0x04) sample_start(samples, 3, SND_INVADERHIT, 0); diff --git a/src/mame/drivers/buggychl.c b/src/mame/drivers/buggychl.c index c6e95e72173..8131792f262 100644 --- a/src/mame/drivers/buggychl.c +++ b/src/mame/drivers/buggychl.c @@ -127,7 +127,7 @@ static WRITE8_HANDLER( nmi_enable_w ) static WRITE8_HANDLER( sound_enable_w ) { - sound_global_enable(data & 1); + sound_global_enable(space->machine, data & 1); } diff --git a/src/mame/drivers/crbaloon.c b/src/mame/drivers/crbaloon.c index fcd4aa36c0f..ff00fa4b725 100644 --- a/src/mame/drivers/crbaloon.c +++ b/src/mame/drivers/crbaloon.c @@ -167,7 +167,7 @@ static WRITE8_HANDLER( port_sound_w ) crbaloon_set_clear_collision_address((data & 0x01) ? TRUE : FALSE); /* D1 - SOUND STOP */ - sound_global_enable((data & 0x02) ? TRUE : FALSE); + sound_global_enable(space->machine, (data & 0x02) ? TRUE : FALSE); /* D2 - unlabeled - music enable */ crbaloon_audio_set_music_enable(discrete, 0, (data & 0x04) ? TRUE : FALSE); diff --git a/src/mame/drivers/darius.c b/src/mame/drivers/darius.c index f93ef9d427e..2c4e8cafdc2 100644 --- a/src/mame/drivers/darius.c +++ b/src/mame/drivers/darius.c @@ -1203,7 +1203,7 @@ static MACHINE_RESET( darius ) } memory_set_bankptr(machine, 1, RAM); - sound_global_enable( 1 ); /* mixer enabled */ + sound_global_enable( machine, 1 ); /* mixer enabled */ for( i = 0; i < DARIUS_VOL_MAX; i++ ){ darius_vol[i] = 0x00; /* min volume */ diff --git a/src/mame/drivers/galaxian.c b/src/mame/drivers/galaxian.c index ba310faefb0..4fb1b1cdaa6 100644 --- a/src/mame/drivers/galaxian.c +++ b/src/mame/drivers/galaxian.c @@ -373,7 +373,7 @@ static WRITE8_DEVICE_HANDLER( konami_sound_control_w ) cputag_set_input_line(device->machine, "audiocpu", 0, HOLD_LINE); /* bit 4 is sound disable */ - sound_global_enable(~data & 0x10); + sound_global_enable(device->machine, ~data & 0x10); } diff --git a/src/mame/drivers/m10.c b/src/mame/drivers/m10.c index 7bf3d990b0b..5593c8245a9 100644 --- a/src/mame/drivers/m10.c +++ b/src/mame/drivers/m10.c @@ -239,7 +239,7 @@ static WRITE8_HANDLER( m10_ctrl_w ) state->flip = ~data & 0x10; if (!(input_port_read(space->machine, "CAB") & 0x02)) - sound_global_enable(~data & 0x80); + sound_global_enable(space->machine, ~data & 0x80); /* sound command in lower 4 bytes */ switch (data & 0x07) @@ -315,7 +315,7 @@ static WRITE8_HANDLER( m11_ctrl_w ) state->flip = ~data & 0x10; if (!(input_port_read(space->machine, "CAB") & 0x02)) - sound_global_enable(~data & 0x80); + sound_global_enable(space->machine, ~data & 0x80); } /* @@ -344,7 +344,7 @@ static WRITE8_HANDLER( m15_ctrl_w ) if (input_port_read(space->machine, "CAB") & 0x01) state->flip = ~data & 0x04; if (!(input_port_read(space->machine, "CAB") & 0x02)) - sound_global_enable(~data & 0x08); + sound_global_enable(space->machine, ~data & 0x08); } diff --git a/src/mame/drivers/maxaflex.c b/src/mame/drivers/maxaflex.c index 931a0bd2443..015075f233f 100644 --- a/src/mame/drivers/maxaflex.c +++ b/src/mame/drivers/maxaflex.c @@ -82,7 +82,7 @@ static WRITE8_HANDLER( mcu_portB_w ) cputag_set_input_line(space->machine, "mcu", M6805_IRQ_LINE, CLEAR_LINE ); /* AUDMUTE */ - sound_global_enable((data >> 5) & 1); + sound_global_enable(space->machine, (data >> 5) & 1); /* RES600 */ if (diff & 0x10) diff --git a/src/mame/drivers/ninjaw.c b/src/mame/drivers/ninjaw.c index a2e4a4ad32f..ec6e4ba24d8 100644 --- a/src/mame/drivers/ninjaw.c +++ b/src/mame/drivers/ninjaw.c @@ -1006,7 +1006,7 @@ static MACHINE_START( ninjaw ) static MACHINE_RESET( ninjaw ) { /**** mixer control enable ****/ - sound_global_enable( 1 ); /* mixer enabled */ + sound_global_enable( machine, 1 ); /* mixer enabled */ } diff --git a/src/mame/drivers/segahang.c b/src/mame/drivers/segahang.c index 32da3768e22..aefeda41840 100644 --- a/src/mame/drivers/segahang.c +++ b/src/mame/drivers/segahang.c @@ -304,7 +304,7 @@ static WRITE8_DEVICE_HANDLER( tilemap_sound_w ) cputag_set_input_line(device->machine, "soundcpu", INPUT_LINE_NMI, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE); segaic16_tilemap_set_colscroll(device->machine, 0, ~data & 0x04); segaic16_tilemap_set_rowscroll(device->machine, 0, ~data & 0x02); - sound_global_enable(data & 0x01); + sound_global_enable(device->machine, data & 0x01); } diff --git a/src/mame/drivers/segaorun.c b/src/mame/drivers/segaorun.c index 3f4a89ab442..5b10908b578 100644 --- a/src/mame/drivers/segaorun.c +++ b/src/mame/drivers/segaorun.c @@ -412,7 +412,7 @@ static WRITE16_HANDLER( outrun_custom_io_w ) D7: /MUTE D6-D0: unknown */ - sound_global_enable(data & 0x80); + sound_global_enable(space->machine, data & 0x80); } return; diff --git a/src/mame/drivers/segaxbd.c b/src/mame/drivers/segaxbd.c index ea75938a1b6..2832b5dbcdb 100644 --- a/src/mame/drivers/segaxbd.c +++ b/src/mame/drivers/segaxbd.c @@ -567,7 +567,7 @@ static WRITE16_HANDLER( iochip_0_w ) D7: Amplifier mute control (1= sounding, 0= muted) D6-D0: CN D pin A17-A23 (output level 1= high, 0= low) */ - sound_global_enable(data & 0x80); + sound_global_enable(space->machine, data & 0x80); return; } @@ -653,7 +653,7 @@ static WRITE16_HANDLER( aburner2_iochip_0_D_w ) coin_counter_w(0, (data >> 4) & 0x01); output_set_lamp_value(0, (data >> 5) & 0x01); /* lock on lamp */ output_set_lamp_value(1, (data >> 6) & 0x01); /* danger lamp */ - sound_global_enable((data >> 7) & 0x01); + sound_global_enable(space->machine, (data >> 7) & 0x01); } diff --git a/src/mame/drivers/segaybd.c b/src/mame/drivers/segaybd.c index 3a7cba53434..d9f4e83ac89 100644 --- a/src/mame/drivers/segaybd.c +++ b/src/mame/drivers/segaybd.c @@ -332,7 +332,7 @@ static WRITE16_HANDLER( io_chip_w ) case 0x0e/2: /* D7 = /MUTE */ /* D6-D0 = FLT31-25 */ - sound_global_enable(data & 0x80); + sound_global_enable(space->machine, data & 0x80); break; /* CNT register */ diff --git a/src/mame/drivers/system1.c b/src/mame/drivers/system1.c index 26bf458c64b..f0411769f06 100644 --- a/src/mame/drivers/system1.c +++ b/src/mame/drivers/system1.c @@ -464,7 +464,7 @@ static void dakkochn_custom_w(running_machine *machine, UINT8 data, UINT8 prevda static WRITE8_DEVICE_HANDLER( sound_control_w ) { /* bit 0 = MUTE (inverted sense on System 2) */ - sound_global_enable(~(data ^ mute_xor) & 1); + sound_global_enable(device->machine, ~(data ^ mute_xor) & 1); /* bit 6 = feedback from sound board that read occurrred */ diff --git a/src/mame/drivers/thepit.c b/src/mame/drivers/thepit.c index 01218c26d21..dd9729a8251 100644 --- a/src/mame/drivers/thepit.c +++ b/src/mame/drivers/thepit.c @@ -160,7 +160,7 @@ static READ8_HANDLER( thepit_colorram_r ) static WRITE8_HANDLER( thepit_sound_enable_w ) { - sound_global_enable(data); + sound_global_enable(space->machine, data); } diff --git a/src/mame/drivers/tutankhm.c b/src/mame/drivers/tutankhm.c index 27ea9a3653c..d5470362f39 100644 --- a/src/mame/drivers/tutankhm.c +++ b/src/mame/drivers/tutankhm.c @@ -83,7 +83,7 @@ static WRITE8_HANDLER( tutankhm_bankselect_w ) static WRITE8_HANDLER( sound_mute_w ) { - sound_global_enable(~data & 1); + sound_global_enable(space->machine, ~data & 1); } diff --git a/src/mame/drivers/uapce.c b/src/mame/drivers/uapce.c index 519b762c841..19cbb47c685 100644 --- a/src/mame/drivers/uapce.c +++ b/src/mame/drivers/uapce.c @@ -38,7 +38,7 @@ static WRITE8_HANDLER( jamma_if_control_latch_w ) UINT8 diff = data ^ jamma_if_control_latch; jamma_if_control_latch = data; - sound_global_enable( (data >> 7) & 1 ); + sound_global_enable( space->machine, (data >> 7) & 1 ); if ( diff & 0x40 ) { diff --git a/src/mame/drivers/warriorb.c b/src/mame/drivers/warriorb.c index de4044d3328..947a997de54 100644 --- a/src/mame/drivers/warriorb.c +++ b/src/mame/drivers/warriorb.c @@ -710,7 +710,7 @@ static MACHINE_RESET( taito_dualscreen ) banknum = -1; /**** mixer control enable ****/ - sound_global_enable( 1 ); /* mixer enabled */ + sound_global_enable( machine, 1 ); /* mixer enabled */ } diff --git a/src/mame/video/bking.c b/src/mame/video/bking.c index 9e9cc9d659d..8df59df84da 100644 --- a/src/mame/video/bking.c +++ b/src/mame/video/bking.c @@ -186,7 +186,7 @@ WRITE8_HANDLER( bking_cont3_w ) palette_bank = (data >> 1) & 0x03; - sound_global_enable(~data & 0x08); + sound_global_enable(space->machine, ~data & 0x08); } diff --git a/src/mame/video/dday.c b/src/mame/video/dday.c index 8a96be68d2a..ab1b7568f5d 100644 --- a/src/mame/video/dday.c +++ b/src/mame/video/dday.c @@ -299,7 +299,7 @@ WRITE8_HANDLER( dday_control_w ) if (!(data & 0x10) && (control & 0x10)) devtag_reset(space->machine, "ay"); - sound_global_enable(data & 0x10); + sound_global_enable(space->machine, data & 0x10); /* bit 6 is search light enable */ sl_enable = data & 0x40;