summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-12-14 08:20:09 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-12-14 08:20:09 +0000
commit98b3cf37e79148efee7d3cb531877082996eb66b (patch)
tree3ea14802b853ef2eadaa9aa1a6cd3f0799f76528 /src/emu/sound
parentaf1273c18d6bdd5c6607554f524306cb5d9df771 (diff)
From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Saturday, December 13, 2008 6:58 AM To: submit@mamedev.org Cc: atariace@hotmail.com Subject: [patch] additional sound core deprecat.h removal Hi mamedev, This patch removes most of the remaining deprecat.h includes in the sound cores. deprecat.h -= 8. ~aa -- From: Atari Ace [mailto:atari_ace@verizon.net] Sent: Saturday, December 13, 2008 10:14 PM To: submit@mamedev.org Cc: atariace@hotmail.com Subject: [patch] final sound core deprecat.h cleanup Hi mamedev, This patch removes the last three deprecat.h includes from the sound cores. ~aa
Diffstat (limited to 'src/emu/sound')
-rw-r--r--src/emu/sound/2413intf.c2
-rw-r--r--src/emu/sound/262intf.c2
-rw-r--r--src/emu/sound/disc_inp.c4
-rw-r--r--src/emu/sound/disc_wav.c4
-rw-r--r--src/emu/sound/discrete.c8
-rw-r--r--src/emu/sound/discrete.h18
-rw-r--r--src/emu/sound/filter.c14
-rw-r--r--src/emu/sound/filter.h4
-rw-r--r--src/emu/sound/fm.c12
-rw-r--r--src/emu/sound/fmopl.c20
-rw-r--r--src/emu/sound/namco52.c4
-rw-r--r--src/emu/sound/pokey.c60
-rw-r--r--src/emu/sound/psx.c9
-rw-r--r--src/emu/sound/sid.c12
-rw-r--r--src/emu/sound/sid.h9
-rw-r--r--src/emu/sound/sid6581.c1
-rw-r--r--src/emu/sound/wave.c3
-rw-r--r--src/emu/sound/ym2151.c11
-rw-r--r--src/emu/sound/ym2413.c16
-rw-r--r--src/emu/sound/ym2413.h2
-rw-r--r--src/emu/sound/ymf262.c16
-rw-r--r--src/emu/sound/ymf262.h2
22 files changed, 113 insertions, 120 deletions
diff --git a/src/emu/sound/2413intf.c b/src/emu/sound/2413intf.c
index 1630b57ff26..09ba3e303b5 100644
--- a/src/emu/sound/2413intf.c
+++ b/src/emu/sound/2413intf.c
@@ -57,7 +57,7 @@ static SND_START( ym2413 )
memset(info, 0, sizeof(*info));
/* emulator create */
- info->chip = ym2413_init(clock, rate, device);
+ info->chip = ym2413_init(device, clock, rate);
if (!info->chip)
return NULL;
diff --git a/src/emu/sound/262intf.c b/src/emu/sound/262intf.c
index ecfe3945d35..3222f9a4d30 100644
--- a/src/emu/sound/262intf.c
+++ b/src/emu/sound/262intf.c
@@ -80,7 +80,7 @@ static SND_START( ymf262 )
info->device = device;
/* stream system initialize */
- info->chip = ymf262_init(clock,rate);
+ info->chip = ymf262_init(device,clock,rate);
if (info->chip == NULL)
return NULL;
diff --git a/src/emu/sound/disc_inp.c b/src/emu/sound/disc_inp.c
index 91126dbc86c..1ea58bf7a18 100644
--- a/src/emu/sound/disc_inp.c
+++ b/src/emu/sound/disc_inp.c
@@ -186,12 +186,12 @@ static DISCRETE_RESET(dss_adjustment)
if (node->custom)
{
- context->port = input_port_by_tag(Machine->portconfig, node->custom);
+ context->port = input_port_by_tag(device->machine->portconfig, node->custom);
if (context->port == NULL)
fatalerror("DISCRETE_ADJUSTMENT_TAG - NODE_%d has invalid tag", node->node-NODE_00);
}
else
- context->port = input_port_by_index(Machine->portconfig, DSS_ADJUSTMENT__PORT);
+ context->port = input_port_by_index(device->machine->portconfig, DSS_ADJUSTMENT__PORT);
context->lastpval = 0x7fffffff;
context->pmin = DSS_ADJUSTMENT__PMIN;
diff --git a/src/emu/sound/disc_wav.c b/src/emu/sound/disc_wav.c
index 0ec93c0e75b..9ac0f488a03 100644
--- a/src/emu/sound/disc_wav.c
+++ b/src/emu/sound/disc_wav.c
@@ -545,7 +545,7 @@ static DISCRETE_STEP(dss_noise)
if(context->phase > (2.0 * M_PI))
{
/* GCC's rand returns a RAND_MAX value of 0x7fff */
- int newval = (mame_rand(Machine) & 0x7fff) - 16384;
+ int newval = (mame_rand(device->machine) & 0x7fff) - 16384;
/* make sure the peak to peak values are the amplitude */
node->output[0] = DSS_NOISE__AMP / 2;
@@ -577,7 +577,7 @@ static DISCRETE_RESET(dss_noise)
struct dss_noise_context *context = node->context;
context->phase=0;
- dss_noise_step(node);
+ DISCRETE_STEP_CALL( dss_noise );
}
diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c
index 6d91a902f49..8339fb1c2c5 100644
--- a/src/emu/sound/discrete.c
+++ b/src/emu/sound/discrete.c
@@ -36,7 +36,6 @@
#include "sndintrf.h"
#include "streams.h"
#include "inptport.h"
-#include "deprecat.h"
#include "wavwrite.h"
#include "discrete.h"
@@ -255,6 +254,7 @@ static SND_START( discrete )
info = auto_malloc(sizeof(*info));
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. */
@@ -406,11 +406,11 @@ static SND_RESET( discrete )
/* if the node has a reset function, call it */
if (node->module.reset)
- (*node->module.reset)(node);
+ (*node->module.reset)(device, node);
/* otherwise, just step it */
else if (node->module.step)
- (*node->module.step)(node);
+ (*node->module.step)(device, node);
}
discrete_current_context = NULL;
@@ -452,7 +452,7 @@ static void discrete_stream_update(void *param, stream_sample_t **inputs, stream
node->run_time -= osd_profiling_ticks();
#endif
if (node->module.step)
- (*node->module.step)(node);
+ (*node->module.step)(info->device, node);
#if (DISCRETE_PROFILING)
node->run_time += osd_profiling_ticks();
#endif
diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h
index 7fe7bfeb70f..88a52b4e34e 100644
--- a/src/emu/sound/discrete.h
+++ b/src/emu/sound/discrete.h
@@ -3280,11 +3280,11 @@
#define DISCRETE_STEP_NAME( _func ) _func ## _step
#define DISCRETE_RESET_NAME( _func ) _func ## _reset
-#define DISCRETE_STEP(_func) void DISCRETE_STEP_NAME(_func) (node_description *node)
-#define DISCRETE_RESET(_func) void DISCRETE_RESET_NAME(_func) (node_description *node)
+#define DISCRETE_STEP(_func) void DISCRETE_STEP_NAME(_func) (const device_config *device, node_description *node)
+#define DISCRETE_RESET(_func) void DISCRETE_RESET_NAME(_func) (const device_config *device, node_description *node)
-#define DISCRETE_STEP_CALL(_func) DISCRETE_STEP_NAME(_func) (node)
-#define DISCRETE_RESET_CALL(_func) DISCRETE_RESET_NAME(_func) (node)
+#define DISCRETE_STEP_CALL(_func) DISCRETE_STEP_NAME(_func) (device, node)
+#define DISCRETE_RESET_CALL(_func) DISCRETE_RESET_NAME(_func) (device, node)
/*************************************
*
@@ -3539,8 +3539,8 @@ struct _discrete_module
const char * name;
int num_output; /* Total number of output nodes, i.e. Master node + 1 */
size_t contextsize;
- void (*reset)(node_description *node); /* Called to reset a node after creation or system reset */
- void (*step)(node_description *node); /* Called to execute one time delta of output update */
+ void (*reset)(const device_config *device, node_description *node); /* Called to reset a node after creation or system reset */
+ void (*step)(const device_config *device, node_description *node); /* Called to execute one time delta of output update */
};
@@ -3583,6 +3583,8 @@ struct _node_description
typedef struct _discrete_info discrete_info;
struct _discrete_info
{
+ const device_config *device;
+
/* emulation info */
int sndindex;
int sample_rate;
@@ -3880,8 +3882,8 @@ struct _discrete_adsr
typedef struct _discrete_custom_info discrete_custom_info;
struct _discrete_custom_info
{
- void (*reset)(node_description *node); /* Called to reset a node after creation or system reset */
- void (*step)(node_description *node); /* Called to execute one time delta of output update */
+ void (*reset)(const device_config *device, node_description *node); /* Called to reset a node after creation or system reset */
+ void (*step)(const device_config *device, node_description *node); /* Called to execute one time delta of output update */
size_t contextsize;
const void *custom; /* Custom function specific initialisation data */
};
diff --git a/src/emu/sound/filter.c b/src/emu/sound/filter.c
index eec1632307a..54cd712030b 100644
--- a/src/emu/sound/filter.c
+++ b/src/emu/sound/filter.c
@@ -1,6 +1,5 @@
-#include "filter.h"
#include "sndintrf.h"
-#include "deprecat.h"
+#include "filter.h"
static filter* filter_alloc(void) {
filter* f = malloc_or_die(sizeof(filter));
@@ -132,18 +131,19 @@ filter* filter_lp_fir_alloc(double freq, int order) {
}
-void filter2_setup(int type, double fc, double d, double gain,
+void filter2_setup(const device_config *device, int type, double fc, double d, double gain,
filter2_context *filter2)
{
+ int sample_rate = device->machine->sample_rate;
double w; /* cutoff freq, in radians/sec */
double w_squared;
double den; /* temp variable */
- double two_over_T = 2*Machine->sample_rate;
+ double two_over_T = 2*sample_rate;
double two_over_T_squared = two_over_T * two_over_T;
/* calculate digital filter coefficents */
/*w = 2.0*M_PI*fc; no pre-warping */
- w = Machine->sample_rate*2.0*tan(M_PI*fc/Machine->sample_rate); /* pre-warping */
+ w = sample_rate*2.0*tan(M_PI*fc/sample_rate); /* pre-warping */
w_squared = w*w;
den = two_over_T_squared + d*w*two_over_T + w_squared;
@@ -202,7 +202,7 @@ void filter2_step(filter2_context *filter2)
/* Setup a filter2 structure based on an op-amp multipole bandpass circuit. */
-void filter_opamp_m_bandpass_setup(double r1, double r2, double r3, double c1, double c2,
+void filter_opamp_m_bandpass_setup(const device_config *device, double r1, double r2, double r3, double c1, double c2,
filter2_context *filter2)
{
double r_in, fc, d, gain;
@@ -228,5 +228,5 @@ void filter_opamp_m_bandpass_setup(double r1, double r2, double r3, double c1, d
d = (c1 + c2) / sqrt(r3 / r_in * c1 * c2);
gain *= -r3 / r_in * c2 / (c1 + c2);
- filter2_setup(FILTER_BANDPASS, fc, d, gain, filter2);
+ filter2_setup(device, FILTER_BANDPASS, fc, d, gain, filter2);
}
diff --git a/src/emu/sound/filter.h b/src/emu/sound/filter.h
index b1a87e2b77d..ccc3a728da6 100644
--- a/src/emu/sound/filter.h
+++ b/src/emu/sound/filter.h
@@ -81,7 +81,7 @@ struct _filter2_context
* d - damp = 1/Q
* gain - overall filter gain. Set to 1 if not needed.
*/
-void filter2_setup(int type, double fc, double d, double gain,
+void filter2_setup(const device_config *device, int type, double fc, double d, double gain,
filter2_context *filter2);
@@ -114,7 +114,7 @@ void filter2_step(filter2_context *filter2);
* gnd vRef >---' |/
*
*/
-void filter_opamp_m_bandpass_setup(double r1, double r2, double r3, double c1, double c2,
+void filter_opamp_m_bandpass_setup(const device_config *device, double r1, double r2, double r3, double c1, double c2,
filter2_context *filter2);
#endif /* __FILTER_H__ */
diff --git a/src/emu/sound/fm.c b/src/emu/sound/fm.c
index 2d1c5e9a6ac..95b60426bcb 100644
--- a/src/emu/sound/fm.c
+++ b/src/emu/sound/fm.c
@@ -118,14 +118,11 @@
#include <math.h>
#ifndef __RAINE__
-#include "deprecat.h"
#include "sndintrf.h" /* use M.A.M.E. */
#else
#include "deftypes.h" /* use RAINE */
#include "support.h" /* use RAINE */
#endif
-
-//#include "ay8910.h"
#include "fm.h"
@@ -643,6 +640,7 @@ typedef struct
typedef struct
{
+ const device_config *device;
void * param; /* this chip parameter */
int clock; /* master clock (Hz) */
int rate; /* sampling rate (Hz) */
@@ -895,7 +893,7 @@ INLINE UINT8 FM_STATUS_FLAG(FM_ST *ST)
{
if( COMPARE_TIMES(ST->busy_expiry_time, UNDEFINED_TIME) != 0 )
{
- if (COMPARE_TIMES(ST->busy_expiry_time, FM_GET_TIME_NOW(Machine)) > 0)
+ if (COMPARE_TIMES(ST->busy_expiry_time, FM_GET_TIME_NOW(ST->device->machine)) > 0)
return ST->status | 0x80; /* with busy */
/* expire */
FM_BUSY_CLEAR(ST);
@@ -905,7 +903,7 @@ INLINE UINT8 FM_STATUS_FLAG(FM_ST *ST)
INLINE void FM_BUSY_SET(FM_ST *ST,int busyclock )
{
TIME_TYPE expiry_period = MULTIPLY_TIME_BY_INT(ATTOTIME_IN_HZ(ST->clock), busyclock * ST->timer_prescaler);
- ST->busy_expiry_time = ADD_TIMES(FM_GET_TIME_NOW(Machine), expiry_period);
+ ST->busy_expiry_time = ADD_TIMES(FM_GET_TIME_NOW(ST->device->machine), expiry_period);
}
#else
#define FM_STATUS_FLAG(ST) ((ST)->status)
@@ -2439,6 +2437,7 @@ void * ym2203_init(void *param, const device_config *device, int clock, int rate
F2203->OPN.ST.param = param;
F2203->OPN.type = TYPE_YM2203;
F2203->OPN.P_CH = F2203->CH;
+ F2203->OPN.ST.device = device;
F2203->OPN.ST.clock = clock;
F2203->OPN.ST.rate = rate;
@@ -3662,6 +3661,7 @@ void * ym2608_init(void *param, const device_config *device, int clock, int rate
F2608->OPN.ST.param = param;
F2608->OPN.type = TYPE_YM2608;
F2608->OPN.P_CH = F2608->CH;
+ F2608->OPN.ST.device = device;
F2608->OPN.ST.clock = clock;
F2608->OPN.ST.rate = rate;
@@ -4349,6 +4349,7 @@ void *ym2610_init(void *param, const device_config *device, int clock, int rate,
F2610->OPN.ST.param = param;
F2610->OPN.type = TYPE_YM2610;
F2610->OPN.P_CH = F2610->CH;
+ F2610->OPN.ST.device = device;
F2610->OPN.ST.clock = clock;
F2610->OPN.ST.rate = rate;
/* Extend handler */
@@ -4813,6 +4814,7 @@ void * ym2612_init(void *param, const device_config *device, int clock, int rate
F2612->OPN.ST.param = param;
F2612->OPN.type = TYPE_YM2612;
F2612->OPN.P_CH = F2612->CH;
+ F2612->OPN.ST.device = device;
F2612->OPN.ST.clock = clock;
F2612->OPN.ST.rate = rate;
/* F2612->OPN.ST.irq = 0; */
diff --git a/src/emu/sound/fmopl.c b/src/emu/sound/fmopl.c
index 73cc7e228a1..675315b1cf6 100644
--- a/src/emu/sound/fmopl.c
+++ b/src/emu/sound/fmopl.c
@@ -68,12 +68,8 @@ Revision History:
*/
#include <math.h>
-
-#include "sndintrf.h" /* use M.A.M.E. */
-#include "deprecat.h" /* use M.A.M.E. */
-
+#include "sndintrf.h"
#include "ymdeltat.h"
-
#include "fmopl.h"
@@ -1726,7 +1722,7 @@ static TIMER_CALLBACK( cymfile_callback )
}
/* lock/unlock for common table */
-static int OPL_LockTable(void)
+static int OPL_LockTable(const device_config *device)
{
num_lock++;
if(num_lock>1) return 0;
@@ -1745,7 +1741,7 @@ static int OPL_LockTable(void)
{
cymfile = fopen("3812_.cym","wb");
if (cymfile)
- timer_pulse ( Machine, ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
+ timer_pulse ( device->machine, ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
else
logerror("Could not create file 3812_.cym\n");
}
@@ -1966,13 +1962,13 @@ static void OPL_save_state(FM_OPL *OPL, const device_config *device)
/* Create one of virtual YM3812/YM3526/Y8950 */
/* 'clock' is chip clock in Hz */
/* 'rate' is sampling rate */
-static FM_OPL *OPLCreate(int type, UINT32 clock, UINT32 rate)
+static FM_OPL *OPLCreate(const device_config *device, UINT32 clock, UINT32 rate, int type)
{
char *ptr;
FM_OPL *OPL;
int state_size;
- if (OPL_LockTable() ==-1) return NULL;
+ if (OPL_LockTable(device) == -1) return NULL;
/* calculate OPL state size */
state_size = sizeof(FM_OPL);
@@ -2162,7 +2158,7 @@ static int OPLTimerOver(FM_OPL *OPL,int c)
void * ym3812_init(const device_config *device, UINT32 clock, UINT32 rate)
{
/* emulator create */
- FM_OPL *YM3812 = OPLCreate(OPL_TYPE_YM3812,clock,rate);
+ FM_OPL *YM3812 = OPLCreate(device,clock,rate,OPL_TYPE_YM3812);
if (YM3812)
{
OPL_save_state(YM3812, device);
@@ -2298,7 +2294,7 @@ void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length)
void *ym3526_init(const device_config *device, UINT32 clock, UINT32 rate)
{
/* emulator create */
- FM_OPL *YM3526 = OPLCreate(OPL_TYPE_YM3526,clock,rate);
+ FM_OPL *YM3526 = OPLCreate(device,clock,rate,OPL_TYPE_YM3526);
if (YM3526)
{
OPL_save_state(YM3526, device);
@@ -2445,7 +2441,7 @@ static void Y8950_deltat_status_reset(void *chip, UINT8 changebits)
void *y8950_init(const device_config *device, UINT32 clock, UINT32 rate)
{
/* emulator create */
- FM_OPL *Y8950 = OPLCreate(OPL_TYPE_Y8950,clock,rate);
+ FM_OPL *Y8950 = OPLCreate(device,clock,rate,OPL_TYPE_Y8950);
if (Y8950)
{
Y8950->deltat->status_set_handler = Y8950_deltat_status_set;
diff --git a/src/emu/sound/namco52.c b/src/emu/sound/namco52.c
index 66db4cedd44..94de6d44da7 100644
--- a/src/emu/sound/namco52.c
+++ b/src/emu/sound/namco52.c
@@ -153,8 +153,8 @@ static SND_START( namco_52xx )
{
chip->n52_step = chip->intf->play_rate / rate;
}
- filter2_setup(FILTER_HIGHPASS, chip->intf->hp_filt_fc, Q_TO_DAMP(chip->intf->hp_filt_q), 1, &chip->n52_hp_filter);
- filter2_setup(FILTER_LOWPASS, chip->intf->lp_filt_fc, Q_TO_DAMP(chip->intf->lp_filt_q), chip->intf->filt_gain, &chip->n52_lp_filter);
+ filter2_setup(device, FILTER_HIGHPASS, chip->intf->hp_filt_fc, Q_TO_DAMP(chip->intf->hp_filt_q), 1, &chip->n52_hp_filter);
+ filter2_setup(device, FILTER_LOWPASS, chip->intf->lp_filt_fc, Q_TO_DAMP(chip->intf->lp_filt_q), chip->intf->filt_gain, &chip->n52_lp_filter);
chip->stream = stream_create(device, 0, 1, rate, chip, namco_52xx_stream_update_one);
diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c
index e7c485e813c..792be15c983 100644
--- a/src/emu/sound/pokey.c
+++ b/src/emu/sound/pokey.c
@@ -50,7 +50,6 @@
*****************************************************************************/
#include "sndintrf.h"
-#include "deprecat.h"
#include "streams.h"
#include "cpuintrf.h"
#include "cpuexec.h"
@@ -169,14 +168,15 @@ struct POKEYregisters
UINT32 samplepos_fract; /* sample position fractional part */
UINT32 samplepos_whole; /* sample position whole part */
UINT32 polyadjust; /* polynome adjustment */
- UINT32 p4; /* poly4 index */
- UINT32 p5; /* poly5 index */
- UINT32 p9; /* poly9 index */
- UINT32 p17; /* poly17 index */
+ UINT32 p4; /* poly4 index */
+ UINT32 p5; /* poly5 index */
+ UINT32 p9; /* poly9 index */
+ UINT32 p17; /* poly17 index */
UINT32 r9; /* rand9 index */
- UINT32 r17; /* rand17 index */
+ UINT32 r17; /* rand17 index */
UINT32 clockmult; /* clock multiplier */
- sound_stream * channel; /* streams channel */
+ const device_config *device;
+ sound_stream * channel; /* streams channel */
emu_timer *timer[3]; /* timers for channel 1,2 and 4 events */
attotime timer_period[3]; /* computed periods for these timers */
int timer_param[3]; /* computed parameters for these timers */
@@ -187,7 +187,7 @@ struct POKEYregisters
read8_space_func serin_r;
write8_space_func serout_w;
void (*interrupt_cb)(running_machine *machine, int mask);
- UINT8 AUDF[4]; /* AUDFx (D200, D202, D204, D206) */
+ UINT8 AUDF[4]; /* AUDFx (D200, D202, D204, D206) */
UINT8 AUDC[4]; /* AUDCx (D201, D203, D205, D207) */
UINT8 POTx[8]; /* POTx (R/D200-D207) */
UINT8 AUDCTL; /* AUDCTL (W/D208) */
@@ -485,8 +485,8 @@ static TIMER_CALLBACK( pokey_pot_trigger );
if( chip->output[CHAN3] ) \
sum += chip->volume[CHAN3]; \
if( chip->output[CHAN4] ) \
- sum += chip->volume[CHAN4]; \
- while( length > 0 ) \
+ sum += chip->volume[CHAN4]; \
+ while( length > 0 ) \
{ \
UINT32 event = chip->samplepos_whole; \
UINT32 channel = SAMPLE; \
@@ -618,6 +618,7 @@ static SND_START( pokey )
if (config)
memcpy(&chip->intf, config, sizeof(pokey_interface));
+ chip->device = device;
chip->clock_period = ATTOTIME_IN_HZ(clock);
chip->index = sndindex;
@@ -818,10 +819,10 @@ static void pokey_potgo(const address_space *space, struct POKEYregisters *p)
static int pokey_register_r(int chip, int offs)
{
- /* temporary hack until this is converted to a device */
- const address_space *space = cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM);
struct POKEYregisters *p = sndti_token(SOUND_POKEY, chip);
- int data = 0, pot;
+ /* temporary hack until this is converted to a device */
+ const address_space *space;
+ int data = 0, pot;
UINT32 adjust = 0;
#ifdef MAME_DEBUG
@@ -832,7 +833,8 @@ static int pokey_register_r(int chip, int offs)
}
#endif
- switch (offs & 15)
+ space = cpu_get_address_space(p->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
+ switch (offs & 15)
{
case POT0_C: case POT1_C: case POT2_C: case POT3_C:
case POT4_C: case POT5_C: case POT6_C: case POT7_C:
@@ -856,7 +858,7 @@ static int pokey_register_r(int chip, int offs)
}
}
else
- logerror("%s: warning - read p[chip] #%d POT%d\n", cpuexec_describe_context(Machine), chip, pot);
+ logerror("%s: warning - read p[chip] #%d POT%d\n", cpuexec_describe_context(p->device->machine), chip, pot);
break;
case ALLPOT_C:
@@ -864,9 +866,9 @@ static int pokey_register_r(int chip, int offs)
* If the 2 least significant bits of SKCTL are 0, the ALLPOTs
* are disabled (SKRESET). Thanks to MikeJ for pointing this out.
****************************************************************/
- if( (p->SKCTL & SK_RESET) == 0)
- {
- data = 0;
+ if( (p->SKCTL & SK_RESET) == 0)
+ {
+ data = 0;
LOG(("POKEY #%d ALLPOT internal $%02x (reset)\n", chip, data));
}
else if( p->allpot_r )
@@ -918,7 +920,7 @@ static int pokey_register_r(int chip, int offs)
LOG_RAND(("POKEY #%d adjust %u rand17[$%05x]: $%02x\n", chip, adjust, p->r17, p->RANDOM));
}
if (adjust > 0)
- timer_adjust_oneshot(p->rtimer, attotime_never, 0);
+ timer_adjust_oneshot(p->rtimer, attotime_never, 0);
data = p->RANDOM ^ 0xff;
break;
@@ -981,9 +983,9 @@ READ8_HANDLER( quad_pokey_r )
static void pokey_register_w(int chip, int offs, int data)
{
- /* temporary hack until this is converted to a device */
- const address_space *space = cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM);
struct POKEYregisters *p = sndti_token(SOUND_POKEY, chip);
+ /* temporary hack until this is converted to a device */
+ const address_space *space = cpu_get_address_space(p->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
int ch_mask = 0, new_val;
#ifdef MAME_DEBUG
@@ -1396,31 +1398,31 @@ WRITE8_HANDLER( quad_pokey_w )
void pokey1_serin_ready(int after)
{
struct POKEYregisters *p = sndti_token(SOUND_POKEY, 0);
- timer_set(Machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
+ timer_set(p->device->machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
}
void pokey2_serin_ready(int after)
{
struct POKEYregisters *p = sndti_token(SOUND_POKEY, 1);
- timer_set(Machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
+ timer_set(p->device->machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
}
void pokey3_serin_ready(int after)
{
struct POKEYregisters *p = sndti_token(SOUND_POKEY, 2);
- timer_set(Machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
+ timer_set(p->device->machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
}
void pokey4_serin_ready(int after)
{
struct POKEYregisters *p = sndti_token(SOUND_POKEY, 3);
- timer_set(Machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
+ timer_set(p->device->machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready);
}
static void pokey_break_w(int chip, int shift)
{
struct POKEYregisters *p = sndti_token(SOUND_POKEY, chip);
- if( shift ) /* shift code ? */
+ if( shift ) /* shift code ? */
p->SKSTAT |= SK_SHIFT;
else
p->SKSTAT &= ~SK_SHIFT;
@@ -1430,8 +1432,8 @@ static void pokey_break_w(int chip, int shift)
/* set break IRQ status and call back the interrupt handler */
p->IRQST |= IRQ_BREAK;
if( p->interrupt_cb )
- (*p->interrupt_cb)(Machine, IRQ_BREAK);
- }
+ (*p->interrupt_cb)(p->device->machine, IRQ_BREAK);
+ }
}
void pokey1_break_w(int shift)
@@ -1474,7 +1476,7 @@ static void pokey_kbcode_w(int chip, int kbcode, int make)
p->SKSTAT |= SK_KBERR;
p->IRQST |= IRQ_KEYBD;
if( p->interrupt_cb )
- (*p->interrupt_cb)(Machine, IRQ_KEYBD);
+ (*p->interrupt_cb)(p->device->machine, IRQ_KEYBD);
}
}
else
diff --git a/src/emu/sound/psx.c b/src/emu/sound/psx.c
index 1e54171aacb..dba896d93f6 100644
--- a/src/emu/sound/psx.c
+++ b/src/emu/sound/psx.c
@@ -10,7 +10,6 @@
#include <stdarg.h>
#include "sndintrf.h"
-#include "deprecat.h"
#include "streams.h"
#include "cpuintrf.h"
#include "cpuexec.h"
@@ -39,6 +38,7 @@ INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level,
struct psxinfo
{
const psx_spu_interface *intf;
+ const device_config *device;
UINT32 *g_p_n_psxram;
UINT16 m_n_mainvolumeleft;
@@ -156,7 +156,7 @@ static void PSXSPU_update(void *param, stream_sample_t **inputs, stream_sample_t
( chip->m_n_irqaddress * 4 ) >= chip->m_p_n_blockaddress[ n_channel ] &&
( chip->m_n_irqaddress * 4 ) <= chip->m_p_n_blockaddress[ n_channel ] + 7 )
{
- chip->intf->irq_set( Machine, 0x0200 );
+ chip->intf->irq_set( chip->device->machine, 0x0200 );
}
n_shift = ( chip->m_p_n_spuram[ chip->m_p_n_blockaddress[ n_channel ] ] >> 0 ) & 0x0f;
@@ -215,8 +215,8 @@ static void PSXSPU_update(void *param, stream_sample_t **inputs, stream_sample_t
static void spu_read( UINT32 n_address, INT32 n_size )
{
- running_machine *machine = Machine;
struct psxinfo *chip = sndti_token(SOUND_PSXSPU, 0);
+ running_machine *machine = chip->device->machine;
verboselog( machine, 1, "spu_read( %08x, %08x )\n", n_address, n_size );
while( n_size > 0 )
@@ -235,8 +235,8 @@ static void spu_read( UINT32 n_address, INT32 n_size )
static void spu_write( UINT32 n_address, INT32 n_size )
{
- running_machine *machine = Machine;
struct psxinfo *chip = sndti_token(SOUND_PSXSPU, 0);
+ running_machine *machine = chip->device->machine;
verboselog( machine, 1, "spu_write( %08x, %08x )\n", n_address, n_size );
while( n_size > 0 )
@@ -262,6 +262,7 @@ static SND_START( psxspu )
memset(chip, 0, sizeof(*chip));
chip->intf = config;
+ chip->device = device;
chip->g_p_n_psxram = *(chip->intf->p_psxram);
chip->m_n_mainvolumeleft = 0;
diff --git a/src/emu/sound/sid.c b/src/emu/sound/sid.c
index f56be4e3c40..452700276cb 100644
--- a/src/emu/sound/sid.c
+++ b/src/emu/sound/sid.c
@@ -16,7 +16,6 @@
#include "sidvoice.h"
#include "sidenvel.h"
#include "sid.h"
-#include "deprecat.h"
static float *filterTable;
static float *bandPassParam;
@@ -31,7 +30,7 @@ static UINT16 mix16mono[256*maxLogicalVoices];
static UINT16 zero16bit=0; /* either signed or unsigned */
//UINT32 splitBufferLen;
-void MixerInit(int threeVoiceAmplify)
+static void MixerInit(int threeVoiceAmplify)
{
long si;
UINT16 ui;
@@ -150,8 +149,9 @@ int sidEmuReset(SID6581 *This)
}
-void filterTableInit(void)
+static void filterTableInit(running_machine *machine)
{
+ int sample_rate = machine->sample_rate;
UINT16 uk;
/* Parameter calculation has not been moved to a separate function */
/* by purpose. */
@@ -173,7 +173,7 @@ void filterTableInit(void)
for ( rk = 0; rk < 0x800; rk++ )
{
filterTable[uk] = (((exp(rk/0x800*log(400.0))/60.0)+0.05)
- *filterRefFreq) / Machine->sample_rate;
+ *filterRefFreq) / sample_rate;
if ( filterTable[uk] < yMin )
filterTable[uk] = yMin;
if ( filterTable[uk] > yMax )
@@ -190,7 +190,7 @@ void filterTableInit(void)
/* Some C++ compilers still have non-local scope! */
for ( rk2 = 0; rk2 < 0x800; rk2++ )
{
- bandPassParam[uk] = (yTmp*filterRefFreq) / Machine->sample_rate;
+ bandPassParam[uk] = (yTmp*filterRefFreq) / sample_rate;
yTmp += yAdd;
uk++;
}
@@ -234,7 +234,7 @@ void sid6581_init (SID6581 *This)
This->filter.Enabled = TRUE;
sidInitMixerEngine();
- filterTableInit();
+ filterTableInit(This->device->machine);
sidInitWaveformTables(This->type);
diff --git a/src/emu/sound/sid.h b/src/emu/sound/sid.h
index df72ccb7159..9e5233edfe5 100644
--- a/src/emu/sound/sid.h
+++ b/src/emu/sound/sid.h
@@ -15,6 +15,7 @@
/* private area */
typedef struct _SID6581
{
+ const device_config *device;
sound_stream *mixer_channel; // mame stream/ mixer channel
int (*ad_read) (int which);
@@ -63,14 +64,6 @@ void sid6581_port_w (SID6581 *This, int offset, int data);
void sid_set_type(SID6581 *This, SIDTYPE type);
-void initMixerEngine(void);
-void filterTableInit(void);
-extern void MixerInit(int threeVoiceAmplify);
-
void sidEmuFillBuffer(SID6581 *This, stream_sample_t *buffer, UINT32 bufferLen );
-#if 0
-void sidFilterTableInit(void);
-#endif
-
#endif /* __SID_H__ */
diff --git a/src/emu/sound/sid6581.c b/src/emu/sound/sid6581.c
index 219c781e022..9b25c2472c9 100644
--- a/src/emu/sound/sid6581.c
+++ b/src/emu/sound/sid6581.c
@@ -37,6 +37,7 @@ static void *sid_start(const device_config *device, int clock, SIDTYPE sidtype)
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;
sid->clock = clock;
diff --git a/src/emu/sound/wave.c b/src/emu/sound/wave.c
index ad88ac4ec8a..674cf8c76d3 100644
--- a/src/emu/sound/wave.c
+++ b/src/emu/sound/wave.c
@@ -10,7 +10,6 @@
#include "driver.h"
#include "streams.h"
-#include "deprecat.h"
#ifdef MESS
#include "messdrv.h"
#include "utils.h"
@@ -41,7 +40,7 @@ static void wave_sound_update(void *param,stream_sample_t **inputs, stream_sampl
{
cassette = cassette_get_image(image);
time_index = cassette_get_position(image);
- duration = ((double) length) / Machine->sample_rate;
+ duration = ((double) length) / image->machine->sample_rate;
cassette_get_samples(cassette, 0, time_index, duration, length, 2, buffer, CASSETTE_WAVEFORM_16BIT);
diff --git a/src/emu/sound/ym2151.c b/src/emu/sound/ym2151.c
index 7c61b1954f8..86e61430353 100644
--- a/src/emu/sound/ym2151.c
+++ b/src/emu/sound/ym2151.c
@@ -7,7 +7,6 @@
#include <math.h>
#include "sndintrf.h"
-#include "deprecat.h"
#include "streams.h"
#include "ym2151.h"
@@ -165,6 +164,7 @@ typedef struct
void (*irqhandler)(running_machine *machine, int irq); /* IRQ function handler */
write8_space_func porthandler; /* port write function handler */
+ const device_config *device;
unsigned int clock; /* chip clock in Hz (passed from 2151intf.c) */
unsigned int sampfreq; /* sampling frequency in Hz (passed from 2151intf.c) */
} YM2151;
@@ -1044,9 +1044,9 @@ INLINE void refresh_EG(YM2151Operator * op)
/* write a register on YM2151 chip number 'n' */
void ym2151_write_reg(void *_chip, int r, int v)
{
- /* temporary hack until this is converted to a device */
- const address_space *space = cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM);
YM2151 *chip = _chip;
+ /* temporary hack until this is converted to a device */
+ const address_space *space = cpu_get_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
YM2151Operator *op = &chip->oper[ (r&0x07)*4+((r&0x18)>>3) ];
/* adjust bus to 8 bits */
@@ -1105,7 +1105,7 @@ void ym2151_write_reg(void *_chip, int r, int v)
{
#ifdef USE_MAME_TIMERS
chip->status &= ~1;
- timer_set(Machine, attotime_zero,chip,0,irqAoff_callback);
+ timer_set(chip->device->machine, attotime_zero,chip,0,irqAoff_callback);
#else
int oldstate = chip->status & 3;
chip->status &= ~1;
@@ -1117,7 +1117,7 @@ void ym2151_write_reg(void *_chip, int r, int v)
{
#ifdef USE_MAME_TIMERS
chip->status &= ~2;
- timer_set(Machine, attotime_zero,chip,0,irqBoff_callback);
+ timer_set(chip->device->machine, attotime_zero,chip,0,irqBoff_callback);
#else
int oldstate = chip->status & 3;
chip->status &= ~2;
@@ -1519,6 +1519,7 @@ void * ym2151_init(const device_config *device, int clock, int rate)
init_tables();
+ PSG->device = device;
PSG->clock = clock;
/*rate = clock/64;*/
PSG->sampfreq = rate ? rate : 44100; /* avoid division by 0 in init_chip_tables() */
diff --git a/src/emu/sound/ym2413.c b/src/emu/sound/ym2413.c
index ba2c662cb98..ed60626f833 100644
--- a/src/emu/sound/ym2413.c
+++ b/src/emu/sound/ym2413.c
@@ -38,9 +38,7 @@ to do:
*/
#include <math.h>
-
-#include "sndintrf.h" /* use M.A.M.E. */
-#include "deprecat.h"
+#include "sndintrf.h"
#include "ym2413.h"
@@ -1918,7 +1916,7 @@ static TIMER_CALLBACK( cymfile_callback )
}
/* lock/unlock for common table */
-static int OPLL_LockTable(void)
+static int OPLL_LockTable(const device_config *device)
{
num_lock++;
if(num_lock>1) return 0;
@@ -1937,7 +1935,7 @@ static int OPLL_LockTable(void)
{
cymfile = fopen("2413_.cym","wb");
if (cymfile)
- timer_pulse ( Machine, ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
+ timer_pulse ( device->machine, ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
else
logerror("Could not create file 2413_.cym\n");
}
@@ -2002,13 +2000,13 @@ static void OPLLResetChip(YM2413 *chip)
/* Create one of virtual YM2413 */
/* 'clock' is chip clock in Hz */
/* 'rate' is sampling rate */
-static YM2413 *OPLLCreate(int clock, int rate, const device_config *device)
+static YM2413 *OPLLCreate(const device_config *device, int clock, int rate)
{
char *ptr;
YM2413 *chip;
int state_size;
- if (OPLL_LockTable() ==-1) return NULL;
+ if (OPLL_LockTable(device) == -1) return NULL;
/* calculate chip state size */
state_size = sizeof(YM2413);
@@ -2078,10 +2076,10 @@ static unsigned char OPLLRead(YM2413 *chip,int a)
-void * ym2413_init(int clock, int rate, const device_config *device)
+void * ym2413_init(const device_config *device, int clock, int rate)
{
/* emulator create */
- return OPLLCreate(clock, rate, device);
+ return OPLLCreate(device, clock, rate);
}
void ym2413_shutdown(void *chip)
diff --git a/src/emu/sound/ym2413.h b/src/emu/sound/ym2413.h
index c983994f585..75df204f25a 100644
--- a/src/emu/sound/ym2413.h
+++ b/src/emu/sound/ym2413.h
@@ -29,7 +29,7 @@ typedef INT8 SAMP;
-void *ym2413_init(int clock, int rate, const device_config *device);
+void *ym2413_init(const device_config *device, int clock, int rate);
void ym2413_shutdown(void *chip);
void ym2413_reset_chip(void *chip);
void ym2413_write(void *chip, int a, int v);
diff --git a/src/emu/sound/ymf262.c b/src/emu/sound/ymf262.c
index eabed321e76..c699cda7eac 100644
--- a/src/emu/sound/ymf262.c
+++ b/src/emu/sound/ymf262.c
@@ -54,9 +54,7 @@ differences between OPL2 and OPL3 shown in datasheets:
*/
#include <math.h>
-
-#include "sndintrf.h" /* use M.A.M.E. */
-#include "deprecat.h"
+#include "sndintrf.h"
#include "ymf262.h"
@@ -2246,7 +2244,7 @@ static TIMER_CALLBACK( cymfile_callback )
}
/* lock/unlock for common table */
-static int OPL3_LockTable(void)
+static int OPL3_LockTable(const device_config *device)
{
num_lock++;
if(num_lock>1) return 0;
@@ -2265,7 +2263,7 @@ static int OPL3_LockTable(void)
{
cymfile = fopen("ymf262_.cym","wb");
if (cymfile)
- timer_pulse ( Machine, ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
+ timer_pulse ( device->machine, ATTOTIME_IN_HZ(110), NULL, 0, cymfile_callback); /*110 Hz pulse timer*/
else
logerror("Could not create ymf262_.cym file\n");
}
@@ -2333,11 +2331,11 @@ static void OPL3ResetChip(OPL3 *chip)
/* Create one of virtual YMF262 */
/* 'clock' is chip clock in Hz */
/* 'rate' is sampling rate */
-static OPL3 *OPL3Create(int type, int clock, int rate)
+static OPL3 *OPL3Create(const device_config *device, int clock, int rate, int type)
{
OPL3 *chip;
- if (OPL3_LockTable() ==-1) return NULL;
+ if (OPL3_LockTable(device) == -1) return NULL;
/* allocate memory block */
chip = (OPL3 *)malloc(sizeof(OPL3));
@@ -2465,9 +2463,9 @@ static int OPL3TimerOver(OPL3 *chip,int c)
-void * ymf262_init(int clock, int rate)
+void * ymf262_init(const device_config *device, int clock, int rate)
{
- return OPL3Create(OPL3_TYPE_YMF262,clock,rate);
+ return OPL3Create(device,clock,rate,OPL3_TYPE_YMF262);
}
void ymf262_shutdown(void *chip)
diff --git a/src/emu/sound/ymf262.h b/src/emu/sound/ymf262.h
index e60a87d7092..83a512f2f94 100644
--- a/src/emu/sound/ymf262.h
+++ b/src/emu/sound/ymf262.h
@@ -32,7 +32,7 @@ typedef void (*OPL3_IRQHANDLER)(void *param,int irq);
typedef void (*OPL3_UPDATEHANDLER)(void *param,int min_interval_us);
-void *ymf262_init(int clock, int rate);
+void *ymf262_init(const device_config *device, int clock, int rate);
void ymf262_shutdown(void *chip);
void ymf262_reset_chip(void *chip);
int ymf262_write(void *chip, int a, int v);