summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/disc_dev.c
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 /src/emu/sound/disc_dev.c
parent39bedada9e90469fd98f1cdbe45daace27bd20f0 (diff)
Optimized DISCRETE_74LS624 making dkongjr and mario faster.
Diffstat (limited to 'src/emu/sound/disc_dev.c')
-rw-r--r--src/emu/sound/disc_dev.c16
1 files changed, 14 insertions, 2 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);
}