summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Derrick Renaud <derrickr@mamedev.org>2009-09-23 00:30:30 +0000
committer Derrick Renaud <derrickr@mamedev.org>2009-09-23 00:30:30 +0000
commit66db5238525fb54b0b058030915f7ad2a38b6046 (patch)
tree37c76c2fc160408899acbe16e0ae0beb2e97e8f2
parent39bedada9e90469fd98f1cdbe45daace27bd20f0 (diff)
Optimized DISCRETE_74LS624 making dkongjr and mario faster.
-rw-r--r--src/emu/sound/disc_dev.c16
-rw-r--r--src/emu/sound/discrete.h10
2 files changed, 21 insertions, 5 deletions
diff --git a/src/emu/sound/disc_dev.c b/src/emu/sound/disc_dev.c
index a8a3addfd33..69b3f96e193 100644
--- a/src/emu/sound/disc_dev.c
+++ b/src/emu/sound/disc_dev.c
@@ -124,6 +124,9 @@ struct dsd_ls624_context
int state;
double remain; /* remaining time from last step */
int out_type;
+ double k1; /* precalculated cap part of formula */
+ double k2; /* precalculated ring part of formula */
+ double k3; /* another precalculated ring part of formula */
};
@@ -1593,8 +1596,12 @@ static DISCRETE_RESET(dsd_566)
* where calculated using least square approximation.
* This approach gives a bit better results compared to the first approach.
*/
-#define LS624_F(_C, _VI, _VR) pow(10, -0.912029404 * log10(_C) + 0.243264328 * (_VI) \
+/* Original formula before optimization of static values
+ #define LS624_F(_C, _VI, _VR) pow(10, -0.912029404 * log10(_C) + 0.243264328 * (_VI) \
- 0.091695877 * (_VR) -0.014110946 * (_VI) * (_VR) - 3.207072925)
+*/
+#define LS624_F(_VI) pow(10, context->k1 + 0.243264328 * (_VI) \
+ + context->k2 + context->k3 * (_VI))
static DISCRETE_STEP(dsd_ls624)
{
@@ -1610,7 +1617,7 @@ static DISCRETE_STEP(dsd_ls624)
sample_t = node->info->sample_time; /* Change in time */
//dt = LS624_T(DSD_LS624__C, DSD_LS624__VRNG, DSD_LS624__VMOD) / 2.0;
- dt = 1.0f / (2.0f * LS624_F(DSD_LS624__C, DSD_LS624__VMOD, DSD_LS624__VRNG));
+ dt = 1.0f / (2.0f * LS624_F(DSD_LS624__VMOD));
t = context->remain;
en += (double) context->state * t;
while (t + dt <= sample_t)
@@ -1659,6 +1666,11 @@ static DISCRETE_RESET(dsd_ls624)
context->state = 0;
context->out_type = DSD_LS624__OUTTYPE;
+ /* precalculate some parts of the formula for speed */
+ context->k1 = -0.912029404 * log10(DSD_LS624__C);
+ context->k2 = -0.091695877 * (DSD_LS624__VRNG) - 3.207072925;
+ context->k3 = -0.014110946 * (DSD_LS624__VRNG);
+
/* Step the output */
DISCRETE_STEP_CALL(dsd_ls624);
}
diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h
index 23d6668c699..15e584a44ae 100644
--- a/src/emu/sound/discrete.h
+++ b/src/emu/sound/discrete.h
@@ -303,6 +303,7 @@
* DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS)
* DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS)
* DISCRETE_566(NODE,ENAB,VMOD,R,C,OPTIONS)
+ * DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,OUTTYPE)
*
* DISCRETE_CUSTOM1(NODE,IN0,INFO)
* DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO)
@@ -3231,8 +3232,8 @@
* DISCRETE_74LS624(name of node,
* enable node or static value,
* vMod node or static value,
- * vRng node or static value,
- * C node or static value in Farads,
+ * vRng static value,
+ * C static value in Farads,
* Type of output static value)
*
* Type of Output
@@ -3241,6 +3242,9 @@
* DISC_LS624_OUT_COUNT_F Number of Falling edges
* DISC_LS624_OUT_COUNT_R Number of Rising edges
*
+ *
+ * EXAMPLES: see Donkey Kong Jr.
+ *
***********************************************************************
*
* DISCRETE_CUSTOMx - Link to custom code
@@ -4422,7 +4426,7 @@ enum
#define DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS) { NODE, DSD_555_VCO1 , 3, { RESET,VIN,NODE_NC }, { RESET,VIN,-1 }, OPTIONS, "DISCRETE_555_VCO1" },
#define DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS) { NODE, DSD_555_VCO1 , 3, { RESET,VIN,CTRLV }, { RESET,VIN,CTRLV }, OPTIONS, "DISCRETE_555_VCO1_CV" },
#define DISCRETE_566(NODE,ENAB,VMOD,R,C,OPTIONS) { NODE, DSD_566 , 4, { ENAB,VMOD,R,C }, { ENAB,VMOD,R,C }, OPTIONS, "DISCRETE_566" },
-#define DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,OUTTYPE) { NODE, DSD_LS624 , 5, { ENAB,VMOD,VRNG,C,NODE_NC }, { ENAB,VMOD,VRNG,C, OUTTYPE }, NULL, "DISCRETE_74LS624" },
+#define DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,OUTTYPE) { NODE, DSD_LS624 , 5, { ENAB,VMOD,NODE_NC,NODE_NC,NODE_NC }, { ENAB,VMOD,VRNG,C,OUTTYPE }, NULL, "DISCRETE_74LS624" },
/* NOP */
#define DISCRETE_NOP(NODE) { NODE, DSS_NOP , 0, { 0 }, { 0 }, NULL, "DISCRETE_NOP" },