From 5870b7d599d84bac5dd8b9b7a36d5ea336e62b23 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Thu, 22 Dec 2022 21:54:50 +0000 Subject: [PATCH] AUDIO: Reduce the static table sizes in the SID emulator --- audio/softsynth/sid.cpp | 6 +++--- audio/softsynth/sid.h | 21 ++++++++++++--------- audio/softsynth/wave6581.cpp | 8 ++++---- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/audio/softsynth/sid.cpp b/audio/softsynth/sid.cpp index 5ce50cda9d8..85eef474159 100644 --- a/audio/softsynth/sid.cpp +++ b/audio/softsynth/sid.cpp @@ -430,7 +430,7 @@ public: } }; -fc_point Filter::f0_points_6581[] = { +const fc_point Filter::f0_points_6581[] = { // FC f FCHI FCLO // ---------------------------- { 0, 220 }, // 0x00 - repeated end point @@ -798,7 +798,7 @@ void EnvelopeGenerator::reset() { hold_zero = true; } -reg16 EnvelopeGenerator::rate_counter_period[] = { +const data16 EnvelopeGenerator::rate_counter_period[] = { 9, // 2ms*1.0MHz/256 = 7.81 32, // 8ms*1.0MHz/256 = 31.25 63, // 16ms*1.0MHz/256 = 62.50 @@ -818,7 +818,7 @@ reg16 EnvelopeGenerator::rate_counter_period[] = { }; -reg8 EnvelopeGenerator::sustain_level[] = { +const data8 EnvelopeGenerator::sustain_level[] = { 0x00, 0x11, 0x22, diff --git a/audio/softsynth/sid.h b/audio/softsynth/sid.h index 2269ca7b2c9..d834e6c4c07 100644 --- a/audio/softsynth/sid.h +++ b/audio/softsynth/sid.h @@ -49,7 +49,10 @@ typedef unsigned int reg24; typedef int cycle_count; typedef int sound_sample; -typedef sound_sample fc_point[2]; + +typedef unsigned char data8; +typedef unsigned short data16; +typedef unsigned short fc_point[2]; class WaveformGenerator { @@ -116,10 +119,10 @@ protected: reg12 outputNPST(); // Sample data for combinations of waveforms. - static const reg8 wave6581__ST[]; - static const reg8 wave6581_P_T[]; - static const reg8 wave6581_PS_[]; - static const reg8 wave6581_PST[]; + static const data8 wave6581__ST[]; + static const data8 wave6581_P_T[]; + static const data8 wave6581_PS_[]; + static const data8 wave6581_PST[]; friend class Voice; friend class SID; @@ -186,8 +189,8 @@ protected: // FC is an 11 bit register. sound_sample f0_6581[2048]; sound_sample* f0; - static fc_point f0_points_6581[]; - fc_point* f0_points; + static const fc_point f0_points_6581[]; + const fc_point* f0_points; int f0_count; friend class SID; @@ -229,10 +232,10 @@ protected: // Lookup table to convert from attack, decay, or release value to rate // counter period. - static reg16 rate_counter_period[]; + static const data16 rate_counter_period[]; // The 16 selectable sustain levels. - static reg8 sustain_level[]; + static const data8 sustain_level[]; friend class SID; }; diff --git a/audio/softsynth/wave6581.cpp b/audio/softsynth/wave6581.cpp index 1272c6ec3a5..45db3827b71 100644 --- a/audio/softsynth/wave6581.cpp +++ b/audio/softsynth/wave6581.cpp @@ -30,7 +30,7 @@ namespace Resid { -const reg8 WaveformGenerator::wave6581__ST[] = { +const data8 WaveformGenerator::wave6581__ST[] = { /* 0x000: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x008: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x010: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -545,7 +545,7 @@ const reg8 WaveformGenerator::wave6581__ST[] = { /* 0xff8: */ 0x3e, 0x3e, 0x3f, 0x3f, 0x7f, 0x7f, 0x7f, 0x7f, }; -const reg8 WaveformGenerator::wave6581_P_T[] = { +const data8 WaveformGenerator::wave6581_P_T[] = { /* 0x000: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x008: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x010: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1060,7 +1060,7 @@ const reg8 WaveformGenerator::wave6581_P_T[] = { /* 0xff8: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -const reg8 WaveformGenerator::wave6581_PS_[] = { +const data8 WaveformGenerator::wave6581_PS_[] = { /* 0x000: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x008: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x010: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1575,7 +1575,7 @@ const reg8 WaveformGenerator::wave6581_PS_[] = { /* 0xff8: */ 0x7e, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, }; -const reg8 WaveformGenerator::wave6581_PST[] = { +const data8 WaveformGenerator::wave6581_PST[] = { /* 0x000: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x008: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x010: */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,