diff options
author | Aaron Giles <aaron@aarongiles.com> | 2009-01-14 05:59:32 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2009-01-14 05:59:32 +0000 |
commit | 40d9394d3d509a4e806f78d4610e8f32853922c3 (patch) | |
tree | ad72d3987e327eefcc35504d0c77399711c94233 | |
parent | 491cb6ed7632a32a6b5862c752e796d15907b840 (diff) |
From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Tuesday, January 06, 2009 7:39 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Remove sndindex from SND_START
Hi mamedev,
This is a baby step towards making the sound cores proper devices. It
removes the sndindex parameter from SND_START. Cores should use the
device pointer or tag as appropriate. I also removed a few
address_space hacks taking advantage of the existing fake sound
device.
~aa
29 files changed, 85 insertions, 95 deletions
diff --git a/src/emu/sndintrf.c b/src/emu/sndintrf.c index a9edededa42..a0e86d6092b 100644 --- a/src/emu/sndintrf.c +++ b/src/emu/sndintrf.c @@ -138,7 +138,7 @@ int sndintrf_init_sound(running_machine *machine, int sndnum, const char *tag, s /* start the chip, tagging all its streams */ current_sound_start = &sound[sndnum]; start = (snd_start_func)sndtype_get_info_fct(sndtype, SNDINFO_PTR_START); - info->device->token = (*start)(info->device, clock, config, info->index); + info->device->token = (*start)(info->device, clock, config); current_sound_start = NULL; VPRINTF((" token = %p\n", info->device->token)); diff --git a/src/emu/sndintrf.h b/src/emu/sndintrf.h index 939d5d348cc..07b140a79dc 100644 --- a/src/emu/sndintrf.h +++ b/src/emu/sndintrf.h @@ -46,7 +46,7 @@ enum SNDINFO_PTR_RESET = DEVINFO_FCT_RESET, /* R/O: void (*reset)(const device_config *device) */ SNDINFO_PTR_SET_INFO = DEVINFO_FCT_CLASS_SPECIFIC, /* R/O: void (*set_info)(const device_config *device, UINT32 state, sndinfo *info) */ - SNDINFO_PTR_START, /* R/O: void *(*start)(const device_config *device, int clock, const void *config, int sndindex) */ + SNDINFO_PTR_START, /* R/O: void *(*start)(const device_config *device, int clock, const void *config) */ SNDINFO_FCT_ALIAS, /* R/O: alias to sound type for (type,index) identification */ SNDINFO_FCT_CORE_SPECIFIC = DEVINFO_FCT_DEVICE_SPECIFIC, /* R/W: core-specific values start here */ @@ -78,8 +78,8 @@ enum #define SND_SET_INFO_CALL(name) SND_SET_INFO_NAME(name)(device, state, info) #define SND_START_NAME(name) snd_start_##name -#define SND_START(name) void *SND_START_NAME(name)(const device_config *device, int clock, const void *config, int sndindex) -#define SND_START_CALL(name) SND_START_NAME(name)(device, clock, config, sndindex) +#define SND_START(name) void *SND_START_NAME(name)(const device_config *device, int clock, const void *config) +#define SND_START_CALL(name) SND_START_NAME(name)(device, clock, config) #define SND_STOP_NAME(name) snd_stop_##name #define SND_STOP(name) void SND_STOP_NAME(name)(const device_config *device) @@ -101,7 +101,7 @@ typedef union _sndinfo sndinfo; /* define the various callback functions */ typedef void (*snd_get_info_func)(const device_config *device, UINT32 state, sndinfo *info); typedef void (*snd_set_info_func)(const device_config *device, UINT32 state, sndinfo *info); -typedef void *(*snd_start_func)(const device_config *device, int clock, const void *config, int sndindex); +typedef void *(*snd_start_func)(const device_config *device, int clock, const void *config); typedef void (*snd_stop_func)(const device_config *device); typedef void (*snd_reset_func)(const device_config *device); diff --git a/src/emu/sound/3812intf.c b/src/emu/sound/3812intf.c index 59224ba23fb..0f0793d41ec 100644 --- a/src/emu/sound/3812intf.c +++ b/src/emu/sound/3812intf.c @@ -372,7 +372,6 @@ struct y8950_info void * chip; const y8950_interface *intf; const device_config *device; - int index; }; static void IRQHandler_8950(void *param,int irq) @@ -407,39 +406,31 @@ static void TimerHandler_8950(void *param,int c,attotime period) static unsigned char Y8950PortHandler_r(void *param) { struct y8950_info *info = param; - /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); if (info->intf->portread) - return info->intf->portread(space,info->index); + return info->intf->portread(info->device,0); return 0; } static void Y8950PortHandler_w(void *param,unsigned char data) { struct y8950_info *info = param; - /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); if (info->intf->portwrite) - info->intf->portwrite(space,info->index,data); + info->intf->portwrite(info->device,0,data); } static unsigned char Y8950KeyboardHandler_r(void *param) { struct y8950_info *info = param; - /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); if (info->intf->keyboardread) - return info->intf->keyboardread(space,info->index); + return info->intf->keyboardread(info->device,0); return 0; } static void Y8950KeyboardHandler_w(void *param,unsigned char data) { struct y8950_info *info = param; - /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); if (info->intf->keyboardwrite) - info->intf->keyboardwrite(space,info->index,data); + info->intf->keyboardwrite(info->device,0,data); } static STREAM_UPDATE( y8950_stream_update ) @@ -466,7 +457,6 @@ static SND_START( y8950 ) info->intf = config ? config : &dummy; info->device = device; - info->index = sndindex; /* stream system initialize */ info->chip = y8950_init(device,clock,rate); diff --git a/src/emu/sound/3812intf.h b/src/emu/sound/3812intf.h index 62f06e861a2..bd7c5ac818c 100644 --- a/src/emu/sound/3812intf.h +++ b/src/emu/sound/3812intf.h @@ -17,10 +17,10 @@ struct _y8950_interface { void (*handler)(running_machine *machine, int linestate); - read8_space_func keyboardread; - write8_space_func keyboardwrite; - read8_space_func portread; - write8_space_func portwrite; + read8_device_func keyboardread; + write8_device_func keyboardwrite; + read8_device_func portread; + write8_device_func portwrite; }; diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c index 2a32c8bbd97..2e18bec743f 100644 --- a/src/emu/sound/aica.c +++ b/src/emu/sound/aica.c @@ -513,7 +513,7 @@ static void AICA_StopSlot(struct _SLOT *slot,int keyoff) #define log_base_2(n) (log((float) n)/log((float) 2)) -static void AICA_Init(const device_config *device, struct _AICA *AICA, const aica_interface *intf, int sndindex) +static void AICA_Init(const device_config *device, struct _AICA *AICA, const aica_interface *intf) { int i; @@ -524,14 +524,7 @@ static void AICA_Init(const device_config *device, struct _AICA *AICA, const aic // get AICA RAM { - if (sndindex == 0) - { - AICA->Master=1; - } - else - { - AICA->Master=0; - } + AICA->Master = intf->master; AICA->AICARAM = device->region; if (AICA->AICARAM) @@ -1295,7 +1288,7 @@ static SND_START( aica ) intf = config; // init the emulation - AICA_Init(device, AICA, intf, sndindex); + AICA_Init(device, AICA, intf); // set up the IRQ callbacks { diff --git a/src/emu/sound/aica.h b/src/emu/sound/aica.h index db7bbaccf4b..136ca6d122b 100644 --- a/src/emu/sound/aica.h +++ b/src/emu/sound/aica.h @@ -11,6 +11,7 @@ typedef struct _aica_interface aica_interface; struct _aica_interface { + int master; int roffset; /* offset in the region */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ }; diff --git a/src/emu/sound/cem3394.c b/src/emu/sound/cem3394.c index 38d89b87a46..c1734774ff3 100644 --- a/src/emu/sound/cem3394.c +++ b/src/emu/sound/cem3394.c @@ -108,7 +108,7 @@ typedef struct { sound_stream * stream; /* our stream */ - void (*external)(int, int, short *);/* callback to generate external samples */ + void (*external)(const device_config *, int, short *);/* callback to generate external samples */ double vco_zero_freq; /* frequency of VCO at 0.0V */ double filter_zero_freq; /* frequency of filter at 0.0V */ @@ -131,7 +131,7 @@ typedef struct double inv_sample_rate; int sample_rate; - int index; + const device_config *device; INT16 *mixer_buffer; INT16 *external_buffer; @@ -171,7 +171,7 @@ static STREAM_UPDATE( cem3394_update ) INT16 last_ext = chip->last_ext; /* fetch the external data */ - (*chip->external)(chip->index, samples, chip->external_buffer); + (*chip->external)(chip->device, samples, chip->external_buffer); /* compute the modulation depth, and adjust fstep to the maximum frequency */ /* we lop off 13 bits of depth so that we can multiply by stepadjust, below, */ @@ -322,7 +322,7 @@ static SND_START( cem3394 ) chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(*chip)); - chip->index = sndindex; + chip->device = device; /* copy global parameters */ chip->sample_rate = CEM3394_SAMPLE_RATE; diff --git a/src/emu/sound/cem3394.h b/src/emu/sound/cem3394.h index 8faea098746..bf592394ac7 100644 --- a/src/emu/sound/cem3394.h +++ b/src/emu/sound/cem3394.h @@ -13,7 +13,7 @@ struct _cem3394_interface { double vco_zero_freq; /* frequency at 0V for VCO */ double filter_zero_freq; /* frequency at 0V for filter */ - void (*external)(int, int, short *);/* external input source */ + void (*external)(const device_config *, int, short *);/* external input source */ }; /* inputs */ diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index 31131344bc6..d65a3b88cca 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -255,7 +255,6 @@ static SND_START( discrete ) memset(info, 0, sizeof(*info)); info->device = device; - info->sndindex = sndindex; /* If a clock is specified we will use it, otherwise run at the audio sample rate. */ if (clock) @@ -266,7 +265,7 @@ static SND_START( discrete ) info->neg_sample_time = - info->sample_time; /* create the logfile */ - sprintf(name, "discrete%d.log", info->sndindex); + sprintf(name, "discrete%s.log", device->tag); if (DISCRETE_DEBUGLOG && !info->disclogfile) info->disclogfile = fopen(name, "w"); @@ -714,7 +713,7 @@ static void setup_disc_logs(discrete_info *info) for (log_num = 0; log_num < info->num_csvlogs; log_num++) { - sprintf(name, "discrete%d_%d.csv", info->sndindex, log_num); + sprintf(name, "discrete%s_%d.csv", info->device->tag, log_num); info->disc_csv_file[log_num] = fopen(name, "w"); /* Output some header info */ fprintf(info->disc_csv_file[log_num], "\"MAME Discrete System Node Log\"\n"); @@ -731,7 +730,7 @@ static void setup_disc_logs(discrete_info *info) for (log_num = 0; log_num < info->num_wavelogs; log_num++) { - sprintf(name, "discrete%d_%d.wav", info->sndindex, log_num); + sprintf(name, "discrete%s_%d.wav", info->device->tag, log_num); info->disc_wav_file[log_num] = wav_open(name, info->sample_rate, info->wavelog_node[log_num]->active_inputs/2); } } diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index dd476a260c5..bc254432e7d 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -3186,7 +3186,7 @@ * Use this to monitor nodes while debugging the driver. You should * remove these nodes from the final driver. You can use up to a maximum * DISCRETE_MAX_CSVLOGS. Each file will be called discreteX_Y.csv, - * where X is the sndindex. Y is 0-9, in the order the file is + * where X is the sound tag. Y is 0-9, in the order the file is * created in the driver. * * This can be used to monitor how multiple nodes relate to each other. @@ -3209,7 +3209,7 @@ * Use this to monitor nodes while debugging the driver. You should * remove these nodes from the final driver. You can use up to a maximum * of DISCRETE_MAX_WAVELOGS. Each file will be called discreteX_Y.wav, - * where X is the sndindex. Y is 0-9, in the order the file is + * where X is the sound tag. Y is 0-9, in the order the file is * created in the driver. * * This can be used to monitor how a node's input affects it's output. @@ -3586,7 +3586,6 @@ struct _discrete_info const device_config *device; /* emulation info */ - int sndindex; int sample_rate; double sample_time; double neg_sample_time; diff --git a/src/emu/sound/es5503.c b/src/emu/sound/es5503.c index 571e3769fd7..79d1fb80346 100644 --- a/src/emu/sound/es5503.c +++ b/src/emu/sound/es5503.c @@ -64,7 +64,6 @@ typedef struct UINT8 *docram; - int index; sound_stream * stream; void (*irq_callback)(running_machine *machine, int); // IRQ callback @@ -232,7 +231,6 @@ static SND_START( es5503 ) chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(*chip)); - chip->index = sndindex; intf = config; diff --git a/src/emu/sound/es5506.c b/src/emu/sound/es5506.c index daefc39e724..4cb3e4ef472 100644 --- a/src/emu/sound/es5506.c +++ b/src/emu/sound/es5506.c @@ -821,7 +821,7 @@ static STREAM_UPDATE( es5506_update ) ***********************************************************************************************/ -static void *es5506_start_common(const device_config *device, int sndindex, int clock, const void *config, sound_type sndtype) +static void *es5506_start_common(const device_config *device, int clock, const void *config, sound_type sndtype) { const es5506_interface *intf = config; struct ES5506Chip *chip; @@ -876,7 +876,7 @@ static void *es5506_start_common(const device_config *device, int sndindex, int static SND_START( es5506 ) { - return es5506_start_common(device, sndindex, clock, config, SOUND_ES5506); + return es5506_start_common(device, clock, config, SOUND_ES5506); } @@ -1513,7 +1513,7 @@ static SND_START( es5505 ) es5506intf.irq_callback = intf->irq_callback; es5506intf.read_port = intf->read_port; - return es5506_start_common(device, sndindex, clock, &es5506intf, SOUND_ES5505); + return es5506_start_common(device, clock, &es5506intf, SOUND_ES5505); } diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index c89e3634bb0..74189d7fb2d 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -45,7 +45,6 @@ struct ics2115 { const ics2115_interface *intf; const device_config *device; - int index; UINT8 *rom; INT16 *ulaw; @@ -450,7 +449,6 @@ static SND_START( ics2115 ) chip->device = device; chip->intf = config; - chip->index = sndindex; chip->rom = device->region; chip->timer[0].timer = timer_alloc(device->machine, timer_cb_0, chip); chip->timer[1].timer = timer_alloc(device->machine, timer_cb_1, chip); diff --git a/src/emu/sound/iremga20.c b/src/emu/sound/iremga20.c index f89e2e406fa..a5f5a52b392 100644 --- a/src/emu/sound/iremga20.c +++ b/src/emu/sound/iremga20.c @@ -248,7 +248,7 @@ static SND_START( iremga20 ) chip->stream = stream_create( device, 0, 2, clock/4, chip, IremGA20_update ); - state_save_register_device_item_array(device, sndindex, chip->regs); + state_save_register_device_item_array(device, 0, chip->regs); for (i = 0; i < 4; i++) { state_save_register_device_item(device, i, chip->channel[i].rate); diff --git a/src/emu/sound/msm5205.c b/src/emu/sound/msm5205.c index fd7e04c6ced..80a76116a50 100644 --- a/src/emu/sound/msm5205.c +++ b/src/emu/sound/msm5205.c @@ -33,7 +33,6 @@ struct MSM5205Voice const msm5205_interface *intf; const device_config *device; sound_stream * stream; /* number of stream system */ - INT32 index; INT32 clock; /* clock rate */ emu_timer *timer; /* VCLK callback timer */ INT32 data; /* next adpcm data */ @@ -47,6 +46,8 @@ struct MSM5205Voice }; +static void msm5205_playmode(struct MSM5205Voice *voice,int select); + /* * ADPCM lockup tabe */ @@ -156,7 +157,7 @@ static void msm5205_reset(struct MSM5205Voice *voice) voice->signal = 0; voice->step = 0; /* timer and bitwidth set */ - msm5205_playmode_w(voice->index,voice->intf->select); + msm5205_playmode(voice,voice->intf->select); } @@ -180,7 +181,6 @@ static SND_START( msm5205 ) /* save a global pointer to our interface */ voice->intf = config; voice->device = device; - voice->index = sndindex; voice->clock = clock; /* compute the difference tables */ @@ -259,6 +259,11 @@ void msm5205_data_w (int num, int data) void msm5205_playmode_w(int num,int select) { struct MSM5205Voice *voice = sndti_token(SOUND_MSM5205, num); + msm5205_playmode(voice,select); +} + +static void msm5205_playmode(struct MSM5205Voice *voice,int select) +{ static const int prescaler_table[4] = {96,48,64,0}; int prescaler = prescaler_table[select & 3]; int bitwidth = (select & 4) ? 4 : 3; diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index 5c16e91ee84..7169626debf 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -204,7 +204,6 @@ struct POKEYregisters attotime clock_period; attotime ad_time_fast; attotime ad_time_slow; - int index; UINT8 poly4[0x0f]; UINT8 poly5[0x1f]; @@ -620,7 +619,6 @@ static SND_START( pokey ) memcpy(&chip->intf, config, sizeof(pokey_interface)); chip->device = device; chip->clock_period = ATTOTIME_IN_HZ(clock); - chip->index = sndindex; /* calculate the A/D times * In normal, slow mode (SKCTL bit SK_PADDLE is clear) the conversion @@ -803,7 +801,7 @@ static void pokey_potgo(const address_space *space, struct POKEYregisters *p) { int r = (*p->pot_r[pot])(space, pot); - LOG(("POKEY #%d pot_r(%d) returned $%02x\n", p->index, pot, r)); + LOG(("POKEY %s pot_r(%d) returned $%02x\n", p->device->tag, pot, r)); if( r != -1 ) { if (r > 228) diff --git a/src/emu/sound/s14001a.c b/src/emu/sound/s14001a.c index 8fc3d79de45..015c68a165d 100644 --- a/src/emu/sound/s14001a.c +++ b/src/emu/sound/s14001a.c @@ -236,7 +236,6 @@ and off as it normally does during speech). Once START has gone low-high-low, th typedef struct { - int index; sound_stream * stream; UINT8 WordInput; // value on word input bus @@ -565,7 +564,6 @@ static SND_START( s14001a ) chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(*chip)); - chip->index = sndindex; chip->GlobalSilenceState = 1; chip->OldDelta = 0x02; diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 0222b3597e2..a70dae01e38 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -509,7 +509,7 @@ static void SCSP_StopSlot(struct _SLOT *slot,int keyoff) #define log_base_2(n) (log((double)(n))/log(2.0)) -static void SCSP_Init(const device_config *device, struct _SCSP *SCSP, const scsp_interface *intf, int sndindex) +static void SCSP_Init(const device_config *device, struct _SCSP *SCSP, const scsp_interface *intf) { int i; @@ -521,7 +521,7 @@ static void SCSP_Init(const device_config *device, struct _SCSP *SCSP, const scs SCSP->MidiOutR=SCSP->MidiOutW=0; // get SCSP RAM - if (sndindex == 0) + if (strcmp(device->tag, "scsp") == 0 || strcmp(device->tag, "scsp1") == 0) { SCSP->Master=1; } @@ -1233,7 +1233,7 @@ static SND_START( scsp ) intf = config; // init the emulation - SCSP_Init(device, SCSP, intf, sndindex); + SCSP_Init(device, SCSP, intf); // set up the IRQ callbacks { diff --git a/src/emu/sound/wave.c b/src/emu/sound/wave.c index 2456f4caa3f..92faa5a0d92 100644 --- a/src/emu/sound/wave.c +++ b/src/emu/sound/wave.c @@ -64,7 +64,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)(sndindex | WAVE_TOKEN_MASK); + return (void *) (FPTR)(WAVE_TOKEN_MASK); } diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index 368f4e7b75e..5bc88676a1b 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -107,8 +107,8 @@ typedef struct UINT8 ext_read; const UINT8 *rom; - read8_space_func ext_mem_read; - write8_space_func ext_mem_write; + read8_device_func ext_mem_read; + write8_device_func ext_mem_write; void (*irq_callback)(running_machine *, int); UINT32 clock; @@ -1374,10 +1374,8 @@ static TIMER_CALLBACK( ymf271_timer_b_tick ) static UINT8 ymf271_read_ext_memory(YMF271Chip *chip, UINT32 address) { - /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); if( chip->ext_mem_read ) { - return chip->ext_mem_read(space,address); + return chip->ext_mem_read(chip->device,address); } else { if( address < 0x800000) return chip->rom[address]; @@ -1387,10 +1385,8 @@ static UINT8 ymf271_read_ext_memory(YMF271Chip *chip, UINT32 address) static void ymf271_write_ext_memory(YMF271Chip *chip, UINT32 address, UINT8 data) { - /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); if( chip->ext_mem_write ) { - chip->ext_mem_write(space, address, data); + chip->ext_mem_write(chip->device, address, data); } } @@ -1727,7 +1723,7 @@ static void init_state(YMF271Chip *chip, const device_config *device) state_save_register_device_item(device, 0, chip->ext_read); } -static void ymf271_init(const device_config *device, YMF271Chip *chip, UINT8 *rom, void (*cb)(running_machine *,int), read8_space_func ext_read, write8_space_func ext_write) +static void ymf271_init(const device_config *device, YMF271Chip *chip, UINT8 *rom, void (*cb)(running_machine *,int), read8_device_func ext_read, write8_device_func ext_write) { chip->timA = timer_alloc(device->machine, ymf271_timer_a_tick, chip); chip->timB = timer_alloc(device->machine, ymf271_timer_b_tick, chip); diff --git a/src/emu/sound/ymf271.h b/src/emu/sound/ymf271.h index 617320c1e1a..26273d69875 100644 --- a/src/emu/sound/ymf271.h +++ b/src/emu/sound/ymf271.h @@ -6,8 +6,8 @@ typedef struct _ymf271_interface ymf271_interface; struct _ymf271_interface { - read8_space_func ext_read; /* external memory read */ - write8_space_func ext_write; /* external memory write */ + read8_device_func ext_read; /* external memory read */ + write8_device_func ext_write; /* external memory write */ void (*irq_callback)(running_machine *machine, int state); /* irq callback */ }; diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 47c52ca04ef..28ad89280d3 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -128,7 +128,6 @@ typedef struct INT32 mix_level[8]; sound_stream * stream; - int index; } YMF278BChip; static INT32 *mix; @@ -675,7 +674,6 @@ static SND_START( ymf278b ) chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(*chip)); - chip->index = sndindex; intf = (config != NULL) ? config : &defintrf; diff --git a/src/emu/sound/ymz280b.c b/src/emu/sound/ymz280b.c index 53e69771e71..905032a842f 100644 --- a/src/emu/sound/ymz280b.c +++ b/src/emu/sound/ymz280b.c @@ -91,8 +91,8 @@ struct YMZ280BChip void (*irq_callback)(running_machine *, int); /* IRQ callback */ struct YMZ280BVoice voice[8]; /* the 8 voices */ UINT32 rom_readback_addr; /* where the CPU can read the ROM */ - read8_space_func ext_ram_read; /* external RAM read handler */ - write8_space_func ext_ram_write; /* external RAM write handler */ + read8_device_func ext_ram_read; /* external RAM read handler */ + write8_device_func ext_ram_write; /* external RAM write handler */ #if MAKE_WAVS void * wavresample; /* resampled waveform */ @@ -868,9 +868,7 @@ static void write_to_register(struct YMZ280BChip *chip, int data) case 0x87: /* RAM write */ if (chip->ext_ram_write) { - /* temporary hack until this is converted to a device */ - const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); - chip->ext_ram_write(space, chip->rom_readback_addr, data); + chip->ext_ram_write(chip->device, chip->rom_readback_addr, data); } else logerror("YMZ280B attempted RAM write to %X\n", chip->rom_readback_addr); @@ -1081,7 +1079,7 @@ READ8_HANDLER( ymz280b_data_0_r ) { UINT8 data; struct YMZ280BChip *chip = sndti_token(SOUND_YMZ280B, 0); - data = chip->ext_ram_read(space, chip->rom_readback_addr - 1); + data = chip->ext_ram_read(chip->device, chip->rom_readback_addr - 1); chip->rom_readback_addr++; return data; } @@ -1090,7 +1088,7 @@ READ8_HANDLER( ymz280b_data_1_r ) { UINT8 data; struct YMZ280BChip *chip = sndti_token(SOUND_YMZ280B, 1); - data = chip->ext_ram_read(space, chip->rom_readback_addr - 1); + data = chip->ext_ram_read(chip->device, chip->rom_readback_addr - 1); chip->rom_readback_addr++; return data; } diff --git a/src/emu/sound/ymz280b.h b/src/emu/sound/ymz280b.h index 60f1a45e4dd..050c04eb891 100644 --- a/src/emu/sound/ymz280b.h +++ b/src/emu/sound/ymz280b.h @@ -15,8 +15,8 @@ typedef struct _ymz280b_interface ymz280b_interface; struct _ymz280b_interface { void (*irq_callback)(running_machine *machine, int state); /* irq callback */ - read8_space_func ext_read; /* external RAM read */ - write8_space_func ext_write; /* external RAM write */ + read8_device_func ext_read; /* external RAM read */ + write8_device_func ext_write; /* external RAM write */ }; READ8_HANDLER ( ymz280b_status_0_r ); diff --git a/src/mame/drivers/firebeat.c b/src/mame/drivers/firebeat.c index 7741a1508aa..1c1d4f4055f 100644 --- a/src/mame/drivers/firebeat.c +++ b/src/mame/drivers/firebeat.c @@ -1804,7 +1804,7 @@ ADDRESS_MAP_END /*****************************************************************************/ -static READ8_HANDLER( soundram_r ) +static READ8_DEVICE_HANDLER( soundram_r ) { if (offset >= 0 && offset < 0x200000) { @@ -1817,7 +1817,7 @@ static READ8_HANDLER( soundram_r ) return 0; } -static WRITE8_HANDLER( soundram_w ) +static WRITE8_DEVICE_HANDLER( soundram_w ) { } diff --git a/src/mame/drivers/naomi.c b/src/mame/drivers/naomi.c index 7f1708d5b4b..5a3f7fdf6c5 100644 --- a/src/mame/drivers/naomi.c +++ b/src/mame/drivers/naomi.c @@ -806,6 +806,7 @@ static void aica_irq(running_machine *machine, int irq) static const aica_interface aica_config = { + TRUE, 0, aica_irq }; diff --git a/src/mame/drivers/seibuspi.c b/src/mame/drivers/seibuspi.c index f595fd632f7..8ac1caecb88 100644 --- a/src/mame/drivers/seibuspi.c +++ b/src/mame/drivers/seibuspi.c @@ -1050,7 +1050,7 @@ static ADDRESS_MAP_START( spisound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x8000, 0xffff) AM_ROMBANK(4) ADDRESS_MAP_END -static READ8_HANDLER( flashrom_read ) +static READ8_DEVICE_HANDLER( flashrom_read ) { logerror("Flash Read: %08X\n", offset); if( offset < 0x100000 ) @@ -1064,7 +1064,7 @@ static READ8_HANDLER( flashrom_read ) return 0; } -static WRITE8_HANDLER( flashrom_write ) +static WRITE8_DEVICE_HANDLER( flashrom_write ) { logerror("Flash Write: %08X, %02X\n", offset, data); if( offset < 0x100000 ) diff --git a/src/mame/includes/balsente.h b/src/mame/includes/balsente.h index 6bdb1c81772..3d12354abc5 100644 --- a/src/mame/includes/balsente.h +++ b/src/mame/includes/balsente.h @@ -29,7 +29,7 @@ extern UINT16 *shrike_io; MACHINE_RESET( balsente ); -void balsente_noise_gen(int chip, int count, short *buffer); +void balsente_noise_gen(const device_config *device, int count, short *buffer); WRITE8_HANDLER( balsente_random_reset_w ); READ8_HANDLER( balsente_random_num_r ); diff --git a/src/mame/machine/balsente.c b/src/mame/machine/balsente.c index 0ae2f3e9e29..e699e3cda35 100644 --- a/src/mame/machine/balsente.c +++ b/src/mame/machine/balsente.c @@ -83,6 +83,7 @@ static UINT8 m6850_sound_output; /* noise generator states */ static UINT32 noise_position[6]; +static const device_config *cem_device[6]; /* game-specific states */ static UINT8 nstocker_bits; @@ -182,6 +183,7 @@ MACHINE_RESET( balsente ) /* reset the noise generator */ memset(noise_position, 0, sizeof(noise_position)); + memset(cem_device, 0, sizeof(cem_device)); /* point the banks to bank 0 */ numbanks = (memory_region_length(machine, "main") > 0x40000) ? 16 : 8; @@ -279,11 +281,27 @@ static void poly17_init(void) } -void balsente_noise_gen(int chip, int count, short *buffer) +void balsente_noise_gen(const device_config *device, int count, short *buffer) { + int chip; + UINT32 step, noise_counter; + + /* find the chip we are referring to */ + for (chip = 0; chip < ARRAY_LENGTH(cem_device); chip++) + { + if (device == cem_device[chip]) + break; + else if (cem_device[chip] == NULL) + { + cem_device[chip] = device; + break; + } + } + assert(chip < ARRAY_LENGTH(cem_device)); + /* noise generator runs at 100kHz */ - UINT32 step = (100000 << 14) / CEM3394_SAMPLE_RATE; - UINT32 noise_counter = noise_position[chip]; + step = (100000 << 14) / CEM3394_SAMPLE_RATE; + noise_counter = noise_position[chip]; while (count--) { |