diff --git a/plugins/Sid/CMakeLists.txt b/plugins/Sid/CMakeLists.txt index c9fce7bb77d..38e839ddeaa 100644 --- a/plugins/Sid/CMakeLists.txt +++ b/plugins/Sid/CMakeLists.txt @@ -1,51 +1,11 @@ INCLUDE(BuildPlugin) -INCLUDE_DIRECTORIES(resid) +include_directories(resid/resid) +add_subdirectory(resid) BUILD_PLUGIN(sid SidInstrument.cpp SidInstrument.h - resid/envelope.h - resid/extfilt.h - resid/filter.h - resid/pot.h - resid/siddefs.h - resid/sid.h - resid/spline.h - resid/voice.h - resid/wave.h - resid/envelope.cc - resid/extfilt.cc - resid/filter.cc - resid/pot.cc - resid/sid.cc - resid/version.cc - resid/voice.cc - resid/wave6581_PS_.cc - resid/wave6581_PST.cc - resid/wave6581_P_T.cc - resid/wave6581__ST.cc - resid/wave8580_PS_.cc - resid/wave8580_PST.cc - resid/wave8580_P_T.cc - resid/wave8580__ST.cc - resid/wave.cc + $ MOCFILES SidInstrument.h EMBEDDED_RESOURCES *.png) - -# Parse VERSION -FILE(READ "resid/CMakeLists.txt" lines) -STRING(REGEX MATCH "set\\(MAJOR_VER [A-Za-z0-9_]*\\)" MAJOR_RAW ${lines}) -STRING(REGEX MATCH "set\\(MINOR_VER [A-Za-z0-9_]*\\)" MINOR_RAW ${lines}) -STRING(REGEX MATCH "set\\(PATCH_VER [A-Za-z0-9_]*\\)" PATCH_RAW ${lines}) -SEPARATE_ARGUMENTS(MAJOR_RAW) -SEPARATE_ARGUMENTS(MINOR_RAW) -SEPARATE_ARGUMENTS(PATCH_RAW) -LIST(GET MAJOR_RAW 1 MAJOR_RAW) -LIST(GET MINOR_RAW 1 MINOR_RAW) -LIST(GET PATCH_RAW 1 PATCH_RAW) -STRING(REPLACE ")" "" MAJOR_VER "${MAJOR_RAW}") -STRING(REPLACE ")" "" MINOR_VER "${MINOR_RAW}") -STRING(REPLACE ")" "" PATCH_VER "${PATCH_RAW}") - -TARGET_COMPILE_DEFINITIONS(sid PRIVATE VERSION="${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}") diff --git a/plugins/Sid/SidInstrument.cpp b/plugins/Sid/SidInstrument.cpp index f663c3b6977..7e4f726f45c 100644 --- a/plugins/Sid/SidInstrument.cpp +++ b/plugins/Sid/SidInstrument.cpp @@ -239,7 +239,7 @@ f_cnt_t SidInstrument::desiredReleaseFrames() const -static int sid_fillbuffer(unsigned char* sidreg, SID *sid, int tdelta, short *ptr, int samples) +static int sid_fillbuffer(unsigned char* sidreg, reSID::SID *sid, int tdelta, short *ptr, int samples) { int tdelta2; int result; @@ -302,9 +302,9 @@ void SidInstrument::playNote( NotePlayHandle * _n, if (!_n->m_pluginData) { - SID *sid = new SID(); - sid->set_sampling_parameters( clockrate, SAMPLE_FAST, samplerate ); - sid->set_chip_model( MOS8580 ); + auto sid = new reSID::SID(); + sid->set_sampling_parameters(clockrate, reSID::SAMPLE_FAST, samplerate); + sid->set_chip_model(reSID::MOS8580); sid->enable_filter( true ); sid->reset(); _n->m_pluginData = sid; @@ -312,7 +312,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - SID *sid = static_cast( _n->m_pluginData ); + auto sid = static_cast(_n->m_pluginData); int delta_t = clockrate * frames / samplerate + 4; // avoid variable length array for msvc compat auto buf = reinterpret_cast(_working_buffer + offset); @@ -325,20 +325,20 @@ void SidInstrument::playNote( NotePlayHandle * _n, if( (ChipModel)m_chipModel.value() == ChipModel::MOS6581 ) { - sid->set_chip_model( MOS6581 ); + sid->set_chip_model(reSID::MOS6581); } else { - sid->set_chip_model( MOS8580 ); + sid->set_chip_model(reSID::MOS8580); } // voices - reg8 data8 = 0; - reg8 data16 = 0; - reg8 base = 0; + reSID::reg8 data8 = 0; + reSID::reg8 data16 = 0; + reSID::reg8 base = 0; float freq = 0.0; float note = 0.0; - for( reg8 i = 0 ; i < 3 ; ++i ) + for (reSID::reg8 i = 0; i < 3; ++i) { base = i*7; // freq ( Fn = Fout / Fclk * 16777216 ) + coarse detuning @@ -438,7 +438,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, void SidInstrument::deleteNotePluginData( NotePlayHandle * _n ) { - delete static_cast( _n->m_pluginData ); + delete static_cast(_n->m_pluginData); } diff --git a/plugins/Sid/resid/CMakeLists.txt b/plugins/Sid/resid/CMakeLists.txt index c46758da870..501cec90178 100644 --- a/plugins/Sid/resid/CMakeLists.txt +++ b/plugins/Sid/resid/CMakeLists.txt @@ -1,14 +1,67 @@ -add_library(resid OBJECT - resid/dac.cc - resid/envelope.cc - resid/extfilt.cc - resid/filter8580new.cc - resid/filter.cc - resid/pot.cc +add_library(resid OBJECT resid/sid.cc resid/voice.cc resid/wave.cc + resid/envelope.cc + resid/filter8580new.cc + resid/dac.cc + resid/extfilt.cc + resid/pot.cc + resid/version.cc ) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resid/siddefs.h.in ${CMAKE_CURRENT_SOURCE_DIR}/resid/siddefs.h @ONLY) -target_include_directories(resid PUBLIC resid) \ No newline at end of file +target_include_directories(resid PUBLIC resid) + +set(RESID_WAVE_DATA + wave6581_PST + wave6581_PS_ + wave6581_P_T + wave6581__ST + wave8580_PST + wave8580_PS_ + wave8580_P_T + wave8580__ST +) + +find_package(Perl) +if(${PERL_FOUND}) + set(RESID_SAMP2SRC_SCRIPT samp2src.pl) + foreach(WAVE_DATA ${RESID_WAVE_DATA}) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_SOURCE_DIR}/resid/${WAVE_DATA}.h + COMMAND + ${PERL_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/resid/${RESID_SAMP2SRC_SCRIPT} + ${CMAKE_CURRENT_SOURCE_DIR}/resid/${WAVE_DATA} + ${CMAKE_CURRENT_SOURCE_DIR}/resid/${WAVE_DATA}.dat + ${CMAKE_CURRENT_SOURCE_DIR}/resid/${WAVE_DATA}.h + VERBATIM + COMMENT "Generating resid wave data" + ) + target_sources(resid PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/resid/${WAVE_DATA}.h) + endforeach() +else() + message(SEND_ERROR "Cannot build resid - Perl not found") +endif() + +# These are the defaults +set(RESID_INLINING 1) +set(RESID_INLINE inline) +set(RESID_BRANCH_HINTS 1) +set(NEW_8580_FILTER 1) + +check_cxx_source_compiles("int main() { bool flag; }" HAVE_BOOL) +check_cxx_source_compiles("int main() { __builtin_expect(0, 0); }" HAVE_BUILTIN_EXPECT) +check_cxx_source_compiles("#include int main() { log1p(1); }" HAVE_LOG1P) + +configure_file(resid/siddefs.h.in resid/siddefs.h @ONLY) +configure_file(resid/siddefs.h.in ${CMAKE_CURRENT_SOURCE_DIR}/resid/siddefs.h @ONLY) + +# used the version from the previous submodule, this might not be accurate +set(SRC_VER 0.16) +set(MAJOR_VER 5) +set(MINOR_VER 0) +set(PATCH_VER 0) + +target_compile_definitions(resid PUBLIC VERSION="${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}") \ No newline at end of file