Am 09.01.2017 um 17:02 schrieb Max Kellermann: > There is still no patch description (= commit message).
decoder/sidplay: add kernal and basic rom image support for libsidplayfp > Did you ensure that your code compiles with the old libsidplay? It > looks suspicious. According to my modest knowledge of libsidplay there is no support for loading ROM files. Thank you Max for the valuable advice and hints. Hopefully, the new code is less problematic. Dropped support for "chargen" ROM dumps because no SID tune seems to require this. diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index 56dad02..58b43dd 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -40,6 +40,7 @@ #include <sidplayfp/builders/resid.h> #include <sidplayfp/builders/residfp.h> #include <sidplayfp/SidDatabase.h> +#include <fs/io/FileReader.cxx> #else #include <sidplay/sidplay2.h> #include <sidplay/builders/resid.h> @@ -61,6 +62,35 @@ static unsigned default_songlength; static bool filter_setting; +#ifdef HAVE_SIDPLAYFP +static const unsigned romSize = 8192; +static std::unique_ptr<uint8_t[]> kernal(new uint8_t[romSize]); +static std::unique_ptr<uint8_t[]> basic(new uint8_t[romSize]); + +static void loadRom(std::unique_ptr<uint8_t[]> &dump, const Path romPath) + +{ + try { + FileReader romDump(romPath); + if (romDump.GetSize() != romSize) { + FormatInfo(sidplay_domain, + "Corrupted rom dump %s - %u bytes expected", + romPath.c_str(), romSize); + } else { + romDump.Read(dump.get(), romSize); + FormatInfo(sidplay_domain, "LOAD \"%s\",8,1", + romPath.c_str()); + } + } + catch (...) { + /* We break for nobody. Most tunes play without roms */ + FormatWarning(sidplay_domain, + "Could not load rom dump '%s' ", romPath.c_str()); + } +} + +#endif + static SidDatabase * sidplay_load_songlength_db(const Path path) { @@ -96,6 +126,15 @@ sidplay_init(const ConfigBlock &block) filter_setting = block.GetBlockValue("filter", true); +#ifdef HAVE_SIDPLAYFP + /* read kernal rom dump file */ + const auto kernal_path = block.GetPath("kernal"); + if (!kernal_path.IsNull()) loadRom(kernal, kernal_path); + + /* read basic rom dump file */ + const auto basic_path = block.GetPath("basic"); + if (!basic_path.IsNull()) loadRom(basic, basic_path); +#endif return true; } @@ -103,6 +142,8 @@ static void sidplay_finish() { delete songlength_database; + kernal.reset(); + basic.reset(); } struct SidplayContainerPath { @@ -198,6 +239,10 @@ sidplay_file_decode(DecoderClient &client, Path path_fs) #ifdef HAVE_SIDPLAYFP sidplayfp player; + + player.setRoms((const uint8_t*)kernal.get(), + (const uint8_t*)basic.get(), nullptr); + #else sidplay2 player; #endif diff --git a/doc/user.xml b/doc/user.xml index 8f4c9e7..dd1512b 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -2555,6 +2555,31 @@ run</programlisting> Turns the SID filter emulation on or off. </entry> </row> + + <row> + <entry> + <varname>kernal</varname> + <parameter>PATH</parameter> + </entry> + <entry> + Only libsidplayfp. Some SID tunes require rom images + to play. C64 rom dumps are included in Frodo or VICE + emulation software tarballs. Absolute path to kernal + rom image file. + </entry> + </row> + + <row> + <entry> + <varname>basic</varname> + <parameter>PATH</parameter> + </entry> + <entry> + Only libsidplayfp. Absolute path to basic rom image + file. + </entry> + </row> + </tbody> </tgroup> </informaltable> _______________________________________________ mpd-devel mailing list mpd-devel@musicpd.org http://mailman.blarg.de/listinfo/mpd-devel