DISCRETE_RC_CIRCUIT_1 - promoted skyraid custom charge to it's own module so it could be used with the same circuit in Battlezone.

Battlezone - updated to use new module.  Adjusted sound levels.  Adjusted engine frequency.  Remember there is a slider to adjust the frequency.

Donkey Kong Jr. - set noise clock to a fixed measured frequency.  (Speed optimization)
This commit is contained in:
Derrick Renaud 2009-10-21 04:34:00 +00:00
parent ba138e24f5
commit c79245f95c
7 changed files with 254 additions and 188 deletions

View File

@ -12,6 +12,7 @@
* DST_FILTER1 - Generic 1st order filter
* DST_FILTER2 - Generic 2nd order filter
* DST_OP_AMP_FILT - Op Amp filter circuits
* DST_RC_CIRCUIT_1 - RC charge/discharge circuit
* DST_RCDISC - Simple discharging RC
* DST_RCDISC2 - Simple charge R1/C, discharge R0/C
* DST_RCDISC3 - Simple charge R1/c, discharge R0*R1/(R0+R1)/C
@ -66,6 +67,16 @@ struct dst_op_amp_filt_context
double b0,b1,b2; /* digital filter coefficients, numerator */
};
struct dst_rc_circuit_1_context
{
double v_cap;
double v_charge_1_2;
double v_drop;
double exp_1;
double exp_1_2;
double exp_2;
};
struct dst_rcdisc_context
{
int state;
@ -372,7 +383,7 @@ static DISCRETE_STEP(dst_op_amp_filt)
i = context->iFixed;
switch (context->type)
{
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1M:
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1_A:
i += (DST_OP_AMP_FILT__INP1 - DST_OP_AMP_FILT__INP2) / info->r1;
if (info->r2 != 0)
i += (context->vP - DST_OP_AMP_FILT__INP2) / info->r2;
@ -395,7 +406,7 @@ static DISCRETE_STEP(dst_op_amp_filt)
node->output[0] = context->vC1 * context->gain + info->vRef;
break;
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1M:
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1_A:
context->vC1 += (v - context->vC1) * context->exponentC1;
node->output[0] = context->vC1 * context->gain + DST_OP_AMP_FILT__INP2;
break;
@ -497,7 +508,7 @@ static DISCRETE_RESET(dst_op_amp_filt)
switch (context->type)
{
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1:
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1M:
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1_A:
context->exponentC1 = RC_CHARGE_EXP(info->rF * info->c1);
context->exponentC2 = 0;
break;
@ -554,6 +565,70 @@ static DISCRETE_RESET(dst_op_amp_filt)
}
/************************************************************************
*
* DST_RC_CIRCUIT_1 - RC charge/discharge circuit
*
************************************************************************/
#define DST_RC_CIRCUIT_1__IN1 DISCRETE_INPUT(0)
#define DST_RC_CIRCUIT_1__IN2 DISCRETE_INPUT(1)
#define DST_RC_CIRCUIT_1__R DISCRETE_INPUT(2)
#define DST_RC_CIRCUIT_1__C DISCRETE_INPUT(3)
#define CD4066_R_ON 270
static DISCRETE_STEP( dst_rc_circuit_1 )
{
struct dst_rc_circuit_1_context *context = (struct dst_rc_circuit_1_context *)node->context;
if (DST_RC_CIRCUIT_1__IN1 == 0)
if (DST_RC_CIRCUIT_1__IN2 == 0)
/* cap is floating and does not change charge */
/* output is pulled to ground */
node->output[0] = 0;
else
{
/* cap is discharged */
context->v_cap -= context->v_cap * context->exp_2;
node->output[0] = context->v_cap * context->v_drop;
}
else
if (DST_RC_CIRCUIT_1__IN2 == 0)
{
/* cap is charged */
context->v_cap += (5.0 - context->v_cap) * context->exp_1;
/* output is pulled to ground */
node->output[0] = 0;
}
else
{
/* cap is charged slightly less */
context->v_cap += (context->v_charge_1_2 - context->v_cap) * context->exp_1_2;
node->output[0] = context->v_cap * context->v_drop;
}
}
static DISCRETE_RESET( dst_rc_circuit_1 )
{
struct dst_rc_circuit_1_context *context = (struct dst_rc_circuit_1_context *)node->context;
/* the charging voltage across the cap based on in2*/
context->v_drop = RES_VOLTAGE_DIVIDER(CD4066_R_ON, CD4066_R_ON + DST_RC_CIRCUIT_1__R);
context->v_charge_1_2 = 5.0 * context->v_drop;
context->v_cap = 0;
/* precalculate charging exponents */
/* discharge cap - in1 = 0, in2 = 1*/
context->exp_2 = RC_CHARGE_EXP((CD4066_R_ON + DST_RC_CIRCUIT_1__R) * DST_RC_CIRCUIT_1__C);
/* charge cap - in1 = 1, in2 = 0 */
context->exp_1 = RC_CHARGE_EXP(CD4066_R_ON * DST_RC_CIRCUIT_1__C);
/* charge cap - in1 = 1, in2 = 1 */
context->exp_1_2 = RC_CHARGE_EXP(RES_2_PARALLEL(CD4066_R_ON, CD4066_R_ON + DST_RC_CIRCUIT_1__R) * DST_RC_CIRCUIT_1__C);
/* starts at 0 until cap starts charging */
node->output[0] = 0;
}
/************************************************************************
*
* DST_RCDISC - Usage of node_description values for RC discharge

View File

@ -286,6 +286,7 @@ static const discrete_module module_list[] =
{ DST_SALLEN_KEY ,"DST_SALLEN_KEY" , 1 ,sizeof(struct dss_filter2_context) ,dst_sallen_key_reset ,dst_sallen_key_step ,NULL ,NULL },
{ DST_CRFILTER ,"DST_CRFILTER" , 1 ,sizeof(struct dst_rcfilter_context) ,dst_crfilter_reset ,dst_crfilter_step ,NULL ,NULL },
{ DST_OP_AMP_FILT ,"DST_OP_AMP_FILT" , 1 ,sizeof(struct dst_op_amp_filt_context) ,dst_op_amp_filt_reset ,dst_op_amp_filt_step ,NULL ,NULL },
{ DST_RC_CIRCUIT_1,"DST_RC_CIRCUIT_1", 1 ,sizeof(struct dst_rc_circuit_1_context),dst_rc_circuit_1_reset,dst_rc_circuit_1_step,NULL ,NULL },
{ DST_RCDISC ,"DST_RCDISC" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc_reset ,dst_rcdisc_step ,NULL ,NULL },
{ DST_RCDISC2 ,"DST_RCDISC2" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc2_reset ,dst_rcdisc2_step ,NULL ,NULL },
{ DST_RCDISC3 ,"DST_RCDISC3" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc3_reset ,dst_rcdisc3_step ,NULL ,NULL },

View File

@ -289,6 +289,7 @@
* DISCRETE_CRFILTER(NODE,IN0,RVAL,CVAL)
* DISCRETE_CRFILTER_VREF(NODE,IN0,RVAL,CVAL,VREF)
* DISCRETE_OP_AMP_FILTER(NODE,ENAB,INP0,INP1,TYPE,INFO)
* DISCRETE_RC_CIRCUIT_1(NODE,INP0,INP1,RVAL,CVAL)
* DISCRETE_RCDISC(NODE,ENAB,IN0,RVAL,CVAL)
* DISCRETE_RCDISC2(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)
* DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL, DJV)
@ -2310,8 +2311,8 @@
* vRef >-----------------------' |/
*
* --------------------------------------------------
*
* DISC_OP_AMP_FILTER_IS_LOW_PASS_1M
*
* DISC_OP_AMP_FILTER_IS_LOW_PASS_1_A
* First Order Low Pass Filter
*
* c1
@ -2485,8 +2486,44 @@
* http://en.wikipedia.org/wiki/Sallen_Key_filter
***********************************************************************
*
* DISCRETE_RC_CIRCUIT_1 - RC charge/discharge circuit
*
* Declaration syntax
*
* DISCRETE_RC_CIRCUIT_1(name of node,
* In0 (Logic) node,
* In1 (Logic) node,
* R static value,
* C static value)
*
* 5V
* v
* |
* .-------.
* | 4066 |
* In0 >---|c |
* '-------'
* |
* +------------.
* | |
* .-------. --- C
* | 4066 | ---
* In1 >---|c | |
* '-------' gnd
* |
* +----> Node Output
* |
* Z
* Z R
* Z
* |
* gnd
*
* EXAMPLES: see Sky Raider, Battlezone
*
************************************************************************
*
* DISCRETE_RCDISC - Simple single pole RC discharge network
* DISCRETE_RCFILTER_VREF - Same but refrenced to vRef not 0V
*
* .------------.
* | |
@ -2507,12 +2544,6 @@
* resistor value in OHMS,
* capacitor value in FARADS)
*
* DISCRETE_RCFILTER_VREF(name of node,
* input node (or value)
* resistor value in OHMS
* capacitor value in FARADS,
* vRef node or static value)
*
* Example config line
*
* DISCRETE_RCDISC(NODE_11,10,100,CAP_U(1))
@ -3580,7 +3611,7 @@ enum
#define DISC_OP_AMP_FILTER_IS_BAND_PASS_1M 0x30
#define DISC_OP_AMP_FILTER_IS_HIGH_PASS_0 0x40
#define DISC_OP_AMP_FILTER_IS_BAND_PASS_0 0x50
#define DISC_OP_AMP_FILTER_IS_LOW_PASS_1M 0x60
#define DISC_OP_AMP_FILTER_IS_LOW_PASS_1_A 0x60
#define DISC_OP_AMP_FILTER_TYPE_MASK (0xf0 | DISC_OP_AMP_IS_NORTON) // Used only internally.
@ -4279,7 +4310,6 @@ enum
DST_OP_AMP_1SHT, /* Op Amp One Shot */
DST_TVCA_OP_AMP, /* Triggered Op Amp Voltage controlled amplifier circuits */
DST_VCA, /* IC Voltage controlled amplifiers */
// DST_DELAY, /* Phase shift/Delay line */
/* from disc_flt.c */
/* generic modules */
@ -4289,6 +4319,7 @@ enum
DST_SALLEN_KEY, /* Sallen key filters */
DST_CRFILTER, /* RC Bypass Filter (High Pass) */
DST_OP_AMP_FILT, /* Op Amp filters */
DST_RC_CIRCUIT_1,
DST_RCDISC, /* Simple RC discharge */
DST_RCDISC2, /* Switched 2 Input RC discharge */
DST_RCDISC3, /* Charge/discharge with diode */
@ -4468,6 +4499,7 @@ enum
#define DISCRETE_CRFILTER(NODE,INP0,RVAL,CVAL) { NODE, DST_CRFILTER , 4, { INP0,RVAL,CVAL }, { INP0,RVAL,CVAL }, NULL, "DISCRETE_CRFILTER" },
#define DISCRETE_CRFILTER_VREF(NODE,INP0,RVAL,CVAL,VREF) { NODE, DST_CRFILTER , 5, { INP0,RVAL,CVAL,VREF }, { INP0,RVAL,CVAL,VREF }, NULL, "DISCRETE_CRFILTER_VREF" },
#define DISCRETE_OP_AMP_FILTER(NODE,ENAB,INP0,INP1,TYPE,INFO) { NODE, DST_OP_AMP_FILT , 4, { ENAB,INP0,INP1,NODE_NC }, { ENAB,INP0,INP1,TYPE }, INFO, "DISCRETE_OP_AMP_FILTER" },
#define DISCRETE_RC_CIRCUIT_1(NODE,INP0,INP1,RVAL,CVAL) { NODE, DST_RC_CIRCUIT_1, 4, { INP0,INP1,NODE_NC,NODE_NC }, { INP0,INP1,RVAL,CVAL }, NULL, "DISCRETE_RC_CIRCUIT_1" },
#define DISCRETE_RCDISC(NODE,ENAB,INP0,RVAL,CVAL) { NODE, DST_RCDISC , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCDISC" },
#define DISCRETE_RCDISC2(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL) { NODE, DST_RCDISC2 , 6, { SWITCH,INP0,NODE_NC,INP1,NODE_NC,NODE_NC }, { SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL }, NULL, "DISCRETE_RCDISC2" },
#define DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL,DJV) { NODE, DST_RCDISC3 , 6, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL0,RVAL1,CVAL,DJV }, NULL, "DISCRETE_RCDISC3" },

View File

@ -25,7 +25,7 @@ D0 explosion enable gates a noise generator
#include "sound/discrete.h"
#include "sound/pokey.h"
#define BZ_NOISE_CLOCK 12000 /* FIXME */
#define BZ_NOISE_CLOCK 12000
/*************************************
*
@ -43,7 +43,7 @@ D0 explosion enable gates a noise generator
#define BZ_INP_STARTLED NODE_10_06
#define BZ_INP_MOTEN NODE_10_07
#define TTL_OUT 5
#define TTL_OUT 3.4
#define BZ_R5 RES_K(1)
#define BZ_R6 RES_K(4.7)
@ -83,6 +83,7 @@ D0 explosion enable gates a noise generator
#define BZ_C13 CAP_U(10)
#define BZ_C14 CAP_U(10)
#define BZ_C20 CAP_U(0.1)
#define BZ_C21 CAP_U(0.0047)
#define BZ_C22 CAP_U(0.0047)
#define BZ_C29 CAP_U(0.47)
@ -168,15 +169,97 @@ static const discrete_mixer_desc bzone_eng_mixer_desc =
static const discrete_mixer_desc bzone_final_mixer_desc =
{
DISC_MIXER_IS_RESISTOR,
{BZ_R28, BZ_R25, BZ_R26, BZ_R27},
{BZ_R25, BZ_R28, BZ_R26 + BZ_R20 / 4, BZ_R27},
{0, 0, 0, 0},
{0, 0, 0, 0},
0, BZ_R29,
0,
0, /* no out cap */
BZ_C20, /* The speakers are driven by a +/- signal, just using the cap is good enough */
0, 1
};
/************************************************************************
*
* Custom Battlezone filter
*
* .------. r2 c
* | O|-----+--ZZZZ--+-------||---------.
* | 4066 | | | |
* IN0 >--|c I|-. Z r1 | r5 |
* '------' | Z +------ZZZZ--------+
* | Z | |
* gnd | | |\ |
* gnd | | \ |
* '-----------|- \ |
* r3 | >--+----> Netlist Node
* IN1 >----ZZZZ----------------+-----------|+ /
* | | /
* Z r4 |/
* Z
* Z
* | VP = B+
* gnd
*
************************************************************************/
#define BZONE_CUSTOM_FILTER__IN0 DISCRETE_INPUT(0)
#define BZONE_CUSTOM_FILTER__IN1 DISCRETE_INPUT(1)
#define BZONE_CUSTOM_FILTER__R1 DISCRETE_INPUT(2)
#define BZONE_CUSTOM_FILTER__R2 DISCRETE_INPUT(3)
#define BZONE_CUSTOM_FILTER__R3 DISCRETE_INPUT(4)
#define BZONE_CUSTOM_FILTER__R4 DISCRETE_INPUT(5)
#define BZONE_CUSTOM_FILTER__R5 DISCRETE_INPUT(6)
#define BZONE_CUSTOM_FILTER__C DISCRETE_INPUT(7)
#define BZONE_CUSTOM_FILTER__VP DISCRETE_INPUT(8)
struct bzone_custom_filter_context
{
double v_in1_gain;
double v_p;
double exponent;
double gain[2];
};
#define CD4066_R_ON 270
static DISCRETE_STEP(bzone_custom_filter)
{
struct bzone_custom_filter_context *context = (struct bzone_custom_filter_context *)node->context;
int in0 = (BZONE_CUSTOM_FILTER__IN0 == 0) ? 0 : 1;
double v;
if (BZONE_CUSTOM_FILTER__IN1 > 0)
v = 0;
v = BZONE_CUSTOM_FILTER__IN1 * context->v_in1_gain * context->gain[in0];
if (v > context->v_p) v = context->v_p;
if (v < 0) v = 0;
node->output[0] += (v - node->output[0]) * context->exponent;
}
static DISCRETE_RESET(bzone_custom_filter)
{
struct bzone_custom_filter_context *context = (struct bzone_custom_filter_context *)node->context;
context->gain[0] = BZONE_CUSTOM_FILTER__R1 + BZONE_CUSTOM_FILTER__R2;
context->gain[0] = BZONE_CUSTOM_FILTER__R5 / context->gain[0] + 1;
context->gain[1] = RES_2_PARALLEL(CD4066_R_ON, BZONE_CUSTOM_FILTER__R1) + BZONE_CUSTOM_FILTER__R2;
context->gain[1] = BZONE_CUSTOM_FILTER__R5 / context->gain[1] + 1;
context->v_in1_gain = RES_VOLTAGE_DIVIDER(BZONE_CUSTOM_FILTER__R3, BZONE_CUSTOM_FILTER__R4);
context->v_p = BZONE_CUSTOM_FILTER__VP - OP_AMP_VP_RAIL_OFFSET;
context->exponent = RC_CHARGE_EXP(BZONE_CUSTOM_FILTER__R5 * BZONE_CUSTOM_FILTER__C);;
node->output[0] = 0;
}
static const discrete_custom_info bzone_custom_filter =
{
DISCRETE_CUSTOM_MODULE( bzone_custom_filter, struct bzone_custom_filter_context),
NULL
};
/*************************************
*
* Discrete Sound Blocks
@ -186,13 +269,14 @@ static const discrete_mixer_desc bzone_final_mixer_desc =
static DISCRETE_SOUND_START(bzone)
/************************************************/
/* Input register mapping for galaxian */
/* Input register mapping for Battlezone */
/************************************************/
DISCRETE_INPUT_DATA(BZ_INPUT)
/* decode the bits */
DISCRETE_BITS_DECODE(NODE_10, BZ_INPUT, 0, 7, 5.7)// TTL_OUT) /* QA-QD 74393 */
DISCRETE_ADJUSTMENT_TAG(NODE_11, 0, RES_K(250), DISC_LINADJ, "R11")
DISCRETE_BITS_DECODE(NODE_10, BZ_INPUT, 0, 7, 1) /* QA-QD 74393 */
/* the pot is 250K, but we will use a smaller range to get a better adjustment range */
DISCRETE_ADJUSTMENT_TAG(NODE_11, RES_K(75), RES_K(10), DISC_LINADJ, "R11")
/************************************************/
@ -215,41 +299,38 @@ static DISCRETE_SOUND_START(bzone)
/* Explosion */
/************************************************/
/* FIXME: +0.7 for diode */
DISCRETE_RCDISC5(NODE_40, NODE_34, BZ_INP_EXPLO, BZ_R17 + BZ_R16, BZ_C14)
DISCRETE_MULTIPLY(NODE_41, BZ_R16 / (BZ_R17 + BZ_R16), NODE_40)
/* one of two filter configurations active */
DISCRETE_LOGIC_INVERT(NODE_42, BZ_INP_EXPLOLS)
DISCRETE_OP_AMP_FILTER(NODE_43, BZ_INP_EXPLOLS, 0, NODE_41,
DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_explo_1)
DISCRETE_OP_AMP_FILTER(NODE_44, NODE_42, 0, NODE_41,
DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_explo_0)
DISCRETE_ADDER2(NODE_45, 1, NODE_43, NODE_44)
DISCRETE_RC_CIRCUIT_1(NODE_40,
BZ_INP_EXPLO, NODE_34, /* INP0, INP1 */
BZ_R17 + BZ_R16, BZ_C14)
DISCRETE_CUSTOM9(NODE_45, /* IC K5, pin 1 */
BZ_INP_EXPLOLS, NODE_40, /* IN0, IN1 */
BZ_R19, BZ_R18, BZ_R17, BZ_R16, BZ_R33,
BZ_C22,
22, /* B+ of op-amp */
&bzone_custom_filter)
/************************************************/
/* Shell */
/************************************************/
/* FIXME: +0.7 for diode */
DISCRETE_RCDISC5(NODE_50, NODE_31, BZ_INP_SHELL, BZ_R14 + BZ_R15, BZ_C9)
DISCRETE_MULTIPLY(NODE_51, BZ_R15 / (BZ_R14 + BZ_R15), NODE_50)
/* one of two filter configurations active */
DISCRETE_LOGIC_INVERT(NODE_52, BZ_INP_SHELLLS)
DISCRETE_OP_AMP_FILTER(NODE_53, BZ_INP_SHELLLS, 0, NODE_51,
DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_shell_1)
DISCRETE_OP_AMP_FILTER(NODE_54, NODE_52, 0, NODE_51,
DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_shell_0)
DISCRETE_ADDER2(NODE_55, 1, NODE_53, NODE_54)
DISCRETE_RC_CIRCUIT_1(NODE_50,
BZ_INP_SHELL, NODE_31, /* INP0, INP1 */
BZ_R14 + BZ_R15, BZ_C9)
DISCRETE_MULTIPLY(NODE_51, RES_VOLTAGE_DIVIDER(BZ_R14, BZ_R15), NODE_50)
DISCRETE_CUSTOM9(NODE_55, /* IC K5, pin 1 */
BZ_INP_EXPLOLS, NODE_50, /* IN0, IN1 */
BZ_R12, BZ_R13, BZ_R14, BZ_R15, BZ_R32,
BZ_C21,
22, /* B+ of op-amp */
&bzone_custom_filter)
/************************************************/
/* Engine */
/************************************************/
DISCRETE_TRANSFORM2(NODE_60, BZ_INP_ENGREV, 0.0, "01=")
// FIXME: from R5 .. R7
DISCRETE_MULTIPLEX2(NODE_61, NODE_60, 2.5, 4.2)
DISCRETE_SWITCH(NODE_61,
1, BZ_INP_ENGREV, /* ENAB, SWITCH */
5.0 * RES_VOLTAGE_DIVIDER(BZ_R7, BZ_R6), /* INP0 */
5.0 * RES_VOLTAGE_DIVIDER(BZ_R7, RES_2_PARALLEL(CD4066_R_ON + BZ_R5, BZ_R6))) /* INP1 */
DISCRETE_RCDISC3(NODE_62, 1, NODE_61, BZ_R8, BZ_R9, BZ_C13, -0.5)
/* R11 taken from adjuster port */
@ -270,12 +351,10 @@ static DISCRETE_SOUND_START(bzone)
/* FINAL MIX */
/************************************************/
/* not sure about pokey output levels - below is just a estimate */
DISCRETE_INPUTX_STREAM(NODE_85, 0, 5.0/32767.0 * 4, 0)
DISCRETE_MIXER4(NODE_280, 1, NODE_45, NODE_55, NODE_75, NODE_85, &bzone_final_mixer_desc)
DISCRETE_OUTPUT(NODE_280, 32767.0/1.75)
//DISCRETE_WAVELOG2(NODE_30, 32767.0/5.0, NODE_31, 32767.0/5.0)
/* not sure about pokey output levels - below is just a estimate to get a 5V signal */
DISCRETE_INPUTX_STREAM(NODE_85, 0, 5.0 / 11000, 0)
DISCRETE_MIXER4(NODE_280, 1, NODE_55, NODE_45, NODE_75, NODE_85, &bzone_final_mixer_desc)
DISCRETE_OUTPUT(NODE_280, 50000)
DISCRETE_SOUND_END

View File

@ -857,7 +857,7 @@ static const discrete_mixer_desc dkongjr_s1_mixer_desc =
static const discrete_lfsr_desc dkongjr_lfsr =
{
DISC_CLK_BY_COUNT,
DISC_CLK_IS_FREQ,
16, /* Bit Length */
0, /* Reset Value */
2, /* Use Bit 2 (QC of first LS164) as F0 input 0 */
@ -981,27 +981,13 @@ DISCRETE_TASK_END()
/************************************************/
DISCRETE_TASK_START(1)
#if (USE_LS629)
DISCRETE_74LS629(NODE_20, /* IC 7P, pin 10 */
1, /* ENAB */
0, DK_SUP_V, /* VMOD, VRNG */
JR_C20, 0, /* C, R_FREQ_IN */
DISC_LS624_OUT_COUNT_F)
#else
/* this should be just replaced with a measured fixed frequency */
DISCRETE_74LS624(NODE_20, 0, 0.98*DK_SUP_V, JR_C20, DISC_LS624_OUT_COUNT_F)
#endif
//DISCRETE_74LS629(NODE_30, /* IC 7P, pin 10 */
// 1, /* ENAB */
// 0, DK_SUP_V, /* VMOD, VRNG */
// JR_C20, 0, /* C, R_FREQ_IN */
// DISC_LS624_OUT_LOGIC)
// /* this should be just replaced with a measured fixed frequency */
//DISCRETE_74LS624(NODE_31, 0, 0.98*DK_SUP_V, JR_C20, DISC_LS624_OUT_LOGIC)
//DISCRETE_WAVELOG2(NODE_30, 1000, NODE_31, 1000)
//
DISCRETE_LFSR_NOISE(NODE_21, 1, 1, NODE_20, 1.0, 0, 0.5, &dkongjr_lfsr)
/* the noise source clock is a 74LS629 IC 7P, pin 10.
* using JR_C20 as the timing cap, with Freq Control tied to 0V
* and Range tied to 5V. This creates a fixed frequency of 710Hz.
* So for speed, I breadboarded and measured the frequency.
* Oct 2009, D.R.
*/
DISCRETE_LFSR_NOISE(NODE_21, 1, 1, 710, 1.0, 0, 0.5, &dkongjr_lfsr)
DISCRETE_LS123_INV(NODE_25, DS_SOUND2_INV, JR_R17, JR_C27)
DISCRETE_RCDISC_MODULATED(NODE_26, NODE_25, NODE_21, 120, JR_R24, RES_K(0.001), JR_R18, JR_C29, DK_SUP_V)
/* The following circuit does not match 100%, however works.

View File

@ -101,115 +101,6 @@ static const discrete_mixer_desc skyraid_mixer =
};
/************************************************************************
*
* Custom skyraid explosion charge
*
* input[0] - In1 (Logic)
* input[1] - In2 (Logic)
* input[2] - R
* input[3] - C
*
* 5V
* v
* |
* .-------.
* | 4066 |
* In1 >---|c |
* '-------'
* |
* +------------.
* | |
* .-------. --- C
* | 4066 | ---
* In2 >---|c | |
* '-------' gnd
* |
* +----> Node Output
* |
* Z
* Z R
* Z
* |
* gnd
*
************************************************************************/
#define SKYRAID_EXPLOSION_CUSTOM_IN1 DISCRETE_INPUT(0)
#define SKYRAID_EXPLOSION_CUSTOM_IN2 DISCRETE_INPUT(1)
#define SKYRAID_EXPLOSION_CUSTOM_R DISCRETE_INPUT(2)
#define SKYRAID_EXPLOSION_CUSTOM_C DISCRETE_INPUT(3)
#define SKYRAID_4066_R_ON 270
struct skyraid_explosion_custom_charge_context
{
double v_cap;
double v_charge_1_2;
double v_drop;
double exp_1;
double exp_1_2;
double exp_2;
};
static DISCRETE_STEP( skyraid_explosion_custom_charge )
{
struct skyraid_explosion_custom_charge_context *context = (struct skyraid_explosion_custom_charge_context *)node->context;
if (SKYRAID_EXPLOSION_CUSTOM_IN1 == 0)
if (SKYRAID_EXPLOSION_CUSTOM_IN2 == 0)
/* cap is floating and does not change charge */
/* output is pulled to ground */
node->output[0] = 0;
else
{
/* cap is discharged */
context->v_cap -= context->v_cap * context->exp_2;
node->output[0] = context->v_cap * context->v_drop;
}
else
if (SKYRAID_EXPLOSION_CUSTOM_IN2 == 0)
{
/* cap is charged */
context->v_cap += (5.0 - context->v_cap) * context->exp_1;
/* output is pulled to ground */
node->output[0] = 0;
}
else
{
/* cap is charged slightly less */
context->v_cap += (context->v_charge_1_2 - context->v_cap) * context->exp_1_2;
node->output[0] = context->v_cap * context->v_drop;
}
}
static DISCRETE_RESET( skyraid_explosion_custom_charge )
{
struct skyraid_explosion_custom_charge_context *context = (struct skyraid_explosion_custom_charge_context *)node->context;
/* the charging voltage across the cap based on in2*/
context->v_drop = RES_VOLTAGE_DIVIDER(SKYRAID_4066_R_ON, SKYRAID_4066_R_ON + SKYRAID_EXPLOSION_CUSTOM_R);
context->v_charge_1_2 = 5.0 * context->v_drop;
context->v_cap = 0;
/* precalculate charging exponents */
/* discharge cap - in1 = 0, in2 = 1*/
context->exp_2 = RC_CHARGE_EXP((SKYRAID_4066_R_ON + SKYRAID_EXPLOSION_CUSTOM_R) * SKYRAID_EXPLOSION_CUSTOM_C);
/* charge cap - in1 = 1, in2 = 0 */
context->exp_1 = RC_CHARGE_EXP(SKYRAID_4066_R_ON * SKYRAID_EXPLOSION_CUSTOM_C);
/* charge cap - in1 = 1, in2 = 1 */
context->exp_1_2 = RC_CHARGE_EXP(RES_2_PARALLEL(SKYRAID_4066_R_ON, SKYRAID_4066_R_ON + SKYRAID_EXPLOSION_CUSTOM_R) * SKYRAID_EXPLOSION_CUSTOM_C);
/* starts at 0 until cap starts charging */
node->output[0] = 0;
}
static const discrete_custom_info skyraid_explosion_custom_charge =
{
DISCRETE_CUSTOM_MODULE(skyraid_explosion_custom_charge, struct skyraid_explosion_custom_charge_context),
NULL
};
/************************************************************************
*
* Custom skyraid missle charge
@ -325,13 +216,15 @@ DISCRETE_SOUND_START( skyraid )
1, /* ENAB */
SKYRAID_ATTRACT_EN, /* RESET */
1.49 / ((SKYRAID_R20 + 2 * SKYRAID_R19) * SKYRAID_C51), /* CLK - 555 astable source */
1, 0, 0.5, &skyraid_lfsr) /* AMPL,FEED,BIAS,LFSRTB */
1, 0, 0.5, &skyraid_lfsr) /* AMPL, FEED, BIAS */
DISCRETE_LOGIC_NOR(NODE_20, SKYRAID_EXPLOSION_EN, SKYRAID_NOISE)
DISCRETE_CUSTOM4(NODE_21, SKYRAID_EXPLOSION_EN, NODE_20, RES_2_PARALLEL(SKYRAID_R84, SKYRAID_R85 + SKYRAID_R86), SKYRAID_C68, &skyraid_explosion_custom_charge)
DISCRETE_RC_CIRCUIT_1(NODE_21,
SKYRAID_EXPLOSION_EN, NODE_20, /* INP0, INP1 */
RES_2_PARALLEL(SKYRAID_R84, SKYRAID_R85 + SKYRAID_R86), SKYRAID_C68)
DISCRETE_OP_AMP_FILTER(NODE_22,
1, /* ENAB */
NODE_21, 0, /* INP0,INP1 */
NODE_21, 0, /* INP0, INP1 */
DISC_OP_AMP_FILTER_IS_BAND_PASS_1M, &skyraid_explosion_filter) /* TYPE,INFO */
/* IC E10, pin 14 gain and clipping */
DISCRETE_GAIN(NODE_23, NODE_22, SKYRAID_R119 / SKYRAID_R121 + 1)

View File

@ -405,7 +405,7 @@ ADDRESS_MAP_END
#define BZONEADJ \
PORT_START("R11") \
PORT_ADJUSTER( 50, "Engine Frequency" )
PORT_ADJUSTER( 40, "R11 - Engine Frequency" )
static INPUT_PORTS_START( bzone )
BZONEIN0