Index: configure.ac
===================================================================
--- configure.ac.orig
+++ configure.ac
@@ -539,6 +539,11 @@ AC_ARG_ENABLE( sid,
 
 if test "x$enable_sid" = "xyes"; then
         AM_PATH_SIDPLAY(have_sidplay=yes, have_sidplay=no)
+        PKG_CHECK_MODULES(SIDPLAYFP, [libsidplayfp], [xs_have_sidplayfp=yes], [])
+        if test "x$xs_have_sidplayfp" = "xyes"; then
+            have_sidplay=yes
+            AC_DEFINE([HAVE_SIDPLAYFP], [], [Description])
+        fi
 else
         AC_MSG_RESULT([*** SID plugin disabled per user request ***])
         have_sidplay=no
@@ -1100,6 +1105,7 @@ echo "  Free Lossless Audio Codec (flacn
 echo "  Commodore 64 audio (SID):               $have_sidplay $xs_have_sidplay2_api"
 echo "    -> libSIDPlay1 support:               $xs_have_sidplay1"
 echo "    -> libSIDPlay2 support:               $xs_have_sidplay2"
+echo "    -> libSIDPlayFP support:              $xs_have_sidplayfp"
 echo "    -> distortion patched libSIDPlay2:    $xs_have_distortion"
 echo "  Game music (spc, nsf & gbs):            $enable_console"
 echo "  PlayStation (psf/psf2) audio:           $enable_psf"
Index: src/sid/xs_sidplayfp.cc
===================================================================
--- /dev/null
+++ src/sid/xs_sidplayfp.cc
@@ -0,0 +1,442 @@
+/*
+   XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
+
+   libSIDPlay FP support
+
+   Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
+   (C) Copyright 1999-2009 Tecnic Software productions (TNSP)
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation, Inc.,
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+#include "xmms-sid.h"
+
+#ifdef HAVE_SIDPLAYFP
+
+#include <stdio.h>
+#include "xs_sidplayfp.h"
+#include "xs_config.h"
+
+
+#include <sidplayfp/sidplay2.h>
+#include <sidplayfp/SidTune.h>
+#include <sidplayfp/sidbuilder.h>
+
+class xs_sidplayfp_t {
+public:
+    sidplay2 *currEng;
+    sidbuilder *currBuilder;
+    sid2_config_t currConfig;
+    SidTune *currTune;
+    guint8 *buf;
+    size_t bufSize;
+
+    xs_sidplayfp_t(void);
+    virtual ~xs_sidplayfp_t(void) { ; }
+};
+
+
+#ifdef HAVE_RESID_BUILDER
+#  include <sidplayfp/builders/resid.h>
+#endif
+#ifdef HAVE_HARDSID_BUILDER
+#  include <sidplayfp/builders/hardsid.h>
+#endif
+
+
+xs_sidplayfp_t::xs_sidplayfp_t(void)
+:currEng(NULL)
+{
+    buf = NULL;
+    bufSize = 0;
+    currTune = NULL;
+    currBuilder = NULL;
+}
+
+
+/* We need to 'export' all this pseudo-C++ crap */
+extern "C" {
+
+
+/* Return song information
+ */
+#define TFUNCTION   xs_sidplayfp_getinfo
+#define TFUNCTION2  xs_sidplayfp_updateinfo
+#define TTUNEINFO   SidTuneInfo
+#define TTUNE       SidTune
+#define TENGINE     xs_sidplayfp_t
+#include "xs_sidplay.h"
+
+
+/* Check if we can play the given file
+ */
+gboolean xs_sidplayfp_probe(xs_file_t *f)
+{
+    gchar tmpBuf[5];
+
+    if (f == NULL) return FALSE;
+
+    if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4)
+        return FALSE;
+
+    if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4))
+        return TRUE;
+    else
+        return FALSE;
+}
+
+
+/* Initialize SIDPlayFP
+ */
+gboolean xs_sidplayfp_init(xs_status_t * status)
+{
+    gint tmpFreq, i;
+    xs_sidplayfp_t *engine;
+    sid_filter_t tmpFilter;
+    xs_sid_filter_t *f;
+    assert(status != NULL);
+
+    /* Allocate internal structures */
+    engine = new xs_sidplayfp_t();
+    status->sidEngine = engine;
+    if (!engine) return FALSE;
+
+    /* Initialize the engine */
+    engine->currEng = new sidplay2;
+    if (!engine->currEng) {
+        xs_error("[SIDPlayFP] Could not initialize emulation engine.\n");
+        return FALSE;
+    }
+
+    /* Get current configuration */
+    engine->currConfig = engine->currEng->config();
+
+    /* Configure channels and stuff */
+    switch (status->audioChannels) {
+
+    case XS_CHN_AUTOPAN:
+        engine->currConfig.playback = sid2_stereo;
+        break;
+
+    case XS_CHN_STEREO:
+        engine->currConfig.playback = sid2_stereo;
+        break;
+
+    case XS_CHN_MONO:
+    default:
+        engine->currConfig.playback = sid2_mono;
+        status->audioChannels = XS_CHN_MONO;
+        break;
+    }
+
+
+    /* Memory mode settings */
+    switch (xs_cfg.memoryMode) {
+    case XS_MPU_BANK_SWITCHING:
+        engine->currConfig.environment = sid2_envBS;
+        break;
+
+    case XS_MPU_TRANSPARENT_ROM:
+        engine->currConfig.environment = sid2_envTP;
+        break;
+
+    case XS_MPU_PLAYSID_ENVIRONMENT:
+        engine->currConfig.environment = sid2_envPS;
+        break;
+
+    case XS_MPU_REAL:
+    default:
+        engine->currConfig.environment = sid2_envR;
+        xs_cfg.memoryMode = XS_MPU_REAL;
+        break;
+    }
+
+
+    /* Audio parameters sanity checking and setup */
+    tmpFreq = status->audioFrequency;
+
+    if (status->oversampleEnable)
+        tmpFreq = (tmpFreq * status->oversampleFactor);
+
+    engine->currConfig.frequency = tmpFreq;
+
+    /* Convert filter */
+    f = &(xs_cfg.sid2Filter);
+    XSDEBUG("using filter '%s', %d points\n", f->name, f->npoints);
+    if (f->npoints > XS_SIDPLAY2_NFPOINTS) {
+        xs_error("[SIDPlayFP] Invalid number of filter curve points (%d > %d)\n",
+            f->npoints, XS_SIDPLAY2_NFPOINTS);
+        f->npoints = XS_SIDPLAY2_NFPOINTS;
+    }
+
+    tmpFilter.points = f->npoints;
+    for (i = 0; i < f->npoints; i++) {
+        tmpFilter.cutoff[i][0] = f->points[i].x;
+        tmpFilter.cutoff[i][1] = f->points[i].y;
+    }
+
+    /* Initialize builder object */
+    XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->currEng->info()).maxsids);
+#ifdef HAVE_RESID_BUILDER
+    if (xs_cfg.sid2Builder == XS_BLD_RESID) {
+        ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder");
+        engine->currBuilder = (sidbuilder *) rs;
+        if (rs) {
+            /* Builder object created, initialize it */
+            rs->create((engine->currEng->info()).maxsids);
+            if (!*rs) {
+                xs_error("reSID->create() failed.\n");
+                return FALSE;
+            }
+
+            rs->filter(xs_cfg.emulateFilters);
+            if (!*rs) {
+                xs_error("reSID->filter(%d) failed.\n", xs_cfg.emulateFilters);
+                return FALSE;
+            }
+
+            // FIXME FIX ME: support other configurable parameters ...
+            // ... WHEN/IF resid-builder+libsidplay2 gets fixed
+            rs->sampling(tmpFreq);
+            if (!*rs) {
+                xs_error("reSID->sampling(%d) failed.\n", tmpFreq);
+                return FALSE;
+            }
+            if (tmpFilter.points > 0)
+                rs->filter((sid_filter_t *) &tmpFilter);
+            else
+                rs->filter((sid_filter_t *) NULL);
+
+            if (!*rs) {
+                xs_error("reSID->filter(NULL) failed.\n");
+                return FALSE;
+            }
+        }
+    }
+#endif
+#ifdef HAVE_HARDSID_BUILDER
+    if (xs_cfg.sid2Builder == XS_BLD_HARDSID) {
+        HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder");
+        engine->currBuilder = (sidbuilder *) hs;
+        if (hs) {
+            /* Builder object created, initialize it */
+            hs->create((engine->currEng->info()).maxsids);
+            if (!*hs) {
+                xs_error("hardSID->create() failed.\n");
+                return FALSE;
+            }
+
+            hs->filter(xs_cfg.emulateFilters);
+            if (!*hs) {
+                xs_error("hardSID->filter(%d) failed.\n", xs_cfg.emulateFilters);
+                return FALSE;
+            }
+        }
+    }
+#endif
+
+    if (!engine->currBuilder) {
+        xs_error("[SIDPlayFP] Could not initialize SIDBuilder object.\n");
+        return FALSE;
+    }
+
+    engine->currConfig.sidEmulation = engine->currBuilder;
+    XSDEBUG("%s\n", engine->currBuilder->credits());
+
+    /* Clockspeed settings */
+    switch (xs_cfg.clockSpeed) {
+    case XS_CLOCK_NTSC:
+        engine->currConfig.clockDefault = SID2_CLOCK_NTSC;
+        break;
+
+    default:
+        xs_error("[SIDPlayFP] Invalid clockSpeed=%d, falling back to PAL.\n",
+            xs_cfg.clockSpeed);
+
+    case XS_CLOCK_PAL:
+        engine->currConfig.clockDefault = SID2_CLOCK_PAL;
+        xs_cfg.clockSpeed = XS_CLOCK_PAL;
+        break;
+    }
+
+
+    /* Configure rest of the emulation */
+    if (xs_cfg.forceSpeed) {
+        engine->currConfig.clockForced = true;
+        engine->currConfig.clockSpeed = engine->currConfig.clockDefault;
+    } else {
+        engine->currConfig.clockForced = false;
+        engine->currConfig.clockSpeed = SID2_CLOCK_CORRECT;
+    }
+
+
+    if (xs_cfg.mos8580)
+        engine->currConfig.sidDefault = SID2_MOS8580;
+    else
+        engine->currConfig.sidDefault = SID2_MOS6581;
+
+    if (xs_cfg.forceModel)
+        engine->currConfig.sidModel = engine->currConfig.sidDefault;
+    else
+        engine->currConfig.sidModel = SID2_MODEL_CORRECT;
+
+
+    /* XXX: Should this be configurable? libSIDPlay1 does not support it, though */
+    engine->currConfig.sidSamples = TRUE;
+
+
+    /* Now set the emulator configuration */
+    if (engine->currEng->config(engine->currConfig) < 0) {
+        xs_error("[SIDPlayFP] Emulator engine configuration failed!\n");
+        return FALSE;
+    }
+
+    /* Create the sidtune */
+    engine->currTune = new SidTune(0);
+    if (!engine->currTune) {
+        xs_error("[SIDPlayFP] Could not initialize SIDTune object.\n");
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+
+/* Close SIDPlayFP engine
+ */
+void xs_sidplayfp_close(xs_status_t * status)
+{
+    xs_sidplayfp_t *engine;
+    assert(status != NULL);
+
+    engine = (xs_sidplayfp_t *) status->sidEngine;
+
+    /* Free internals */
+    if (engine->currBuilder) {
+        delete engine->currBuilder;
+        engine->currBuilder = NULL;
+    }
+
+    if (engine->currEng) {
+        delete engine->currEng;
+        engine->currEng = NULL;
+    }
+
+    if (engine->currTune) {
+        delete engine->currTune;
+        engine->currTune = NULL;
+    }
+
+    xs_sidplayfp_delete(status);
+
+    delete engine;
+    status->sidEngine = NULL;
+}
+
+
+/* Initialize current song and sub-tune
+ */
+gboolean xs_sidplayfp_initsong(xs_status_t * status)
+{
+    xs_sidplayfp_t *engine;
+    assert(status != NULL);
+
+    engine = (xs_sidplayfp_t *) status->sidEngine;
+    if (engine == NULL) return FALSE;
+
+    if (!engine->currTune->selectSong(status->currSong)) {
+        xs_error("[SIDPlayFP] currTune->selectSong() failed\n");
+        return FALSE;
+    }
+
+    if (engine->currEng->load(engine->currTune) < 0) {
+        xs_error("[SIDPlayFP] currEng->load() failed\n");
+        return FALSE;
+    }
+
+    status->isInitialized = TRUE;
+
+    return TRUE;
+}
+
+
+/* Emulate and render audio data to given buffer
+ */
+guint xs_sidplayfp_fillbuffer(xs_status_t * status, gchar * audioBuffer, guint audioBufSize)
+{
+    xs_sidplayfp_t *engine;
+    assert(status != NULL);
+
+    engine = (xs_sidplayfp_t *) status->sidEngine;
+    if (!engine) return 0;
+
+    return engine->currEng->play((short *)audioBuffer, audioBufSize);
+}
+
+
+/* Load a given SID-tune file
+ */
+gboolean xs_sidplayfp_load(xs_status_t * status, const gchar * pcFilename)
+{
+    xs_sidplayfp_t *engine;
+    assert(status != NULL);
+    status->isInitialized = FALSE;
+
+    engine = (xs_sidplayfp_t *) status->sidEngine;
+    if (!engine) return FALSE;
+
+    /* Try to get the tune */
+    if (!pcFilename) return FALSE;
+
+    if (xs_fload_buffer(pcFilename, &(engine->buf), &(engine->bufSize)) != 0)
+        return FALSE;
+
+    if (!engine->currTune->read(engine->buf, engine->bufSize))
+        return FALSE;
+
+    return TRUE;
+}
+
+
+/* Delete INTERNAL information
+ */
+void xs_sidplayfp_delete(xs_status_t * status)
+{
+    xs_sidplayfp_t *engine;
+    assert(status != NULL);
+
+    engine = (xs_sidplayfp_t *) status->sidEngine;
+    if (engine == NULL) return;
+
+    g_free(engine->buf);
+    engine->buf = NULL;
+    engine->bufSize = 0;
+}
+
+
+/* Hardware backend flushing
+ */
+void xs_sidplayfp_flush(xs_status_t * status)
+{
+    assert(status != NULL);
+
+#ifdef HAVE_HARDSID_BUILDER
+    if (xs_cfg.sid2Builder == XS_BLD_HARDSID)
+        ((HardSIDBuilder *) status->currBuilder)->flush();
+#endif
+}
+
+
+}    /* extern "C" */
+#endif    /* HAVE_SIDPLAYFP */
Index: src/sid/xs_sidplayfp.h
===================================================================
--- /dev/null
+++ src/sid/xs_sidplayfp.h
@@ -0,0 +1,26 @@
+#ifndef XS_SIDPLAYFP_H
+#define XS_SIDPLAYFP_H
+
+#include "xs_player.h"
+#include "xs_support.h"
+#include "xs_slsup.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+gboolean    xs_sidplayfp_probe(xs_file_t *);
+void        xs_sidplayfp_close(xs_status_t *);
+gboolean    xs_sidplayfp_init(xs_status_t *);
+gboolean    xs_sidplayfp_initsong(xs_status_t *);
+guint        xs_sidplayfp_fillbuffer(xs_status_t *, gchar *, guint);
+gboolean    xs_sidplayfp_load(xs_status_t *, const gchar *);
+void        xs_sidplayfp_delete(xs_status_t *);
+xs_tuneinfo_t*    xs_sidplayfp_getinfo(const gchar *);
+gboolean    xs_sidplayfp_updateinfo(xs_status_t *);
+void        xs_sidplayfp_flush(xs_status_t *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* XS_SIDPLAY2_H */
Index: src/sid/Makefile
===================================================================
--- src/sid/Makefile.orig
+++ src/sid/Makefile
@@ -9,6 +9,7 @@ SRCS = xs_init.c	\
        xs_filter.c	\
        xs_sidplay1.cc	\
        xs_sidplay2.cc	\
+       xs_sidplayfp.cc	\
        xs_slsup.c	\
        xs_player.c	\
        xmms-sid.c
@@ -20,5 +21,5 @@ plugindir := ${plugindir}/${INPUT_PLUGIN
 
 CFLAGS += ${PLUGIN_CFLAGS}
 CXXFLAGS += ${PLUGIN_CFLAGS}
-CPPFLAGS += ${PLUGIN_CPPFLAGS} -D_REENTRANT -I../.. -DAUDACIOUS_PLUGIN ${SIDPLAY1_CFLAGS} ${SIDPLAY2_CFLAGS} ${BUILDERS_CFLAGS} ${GLIB_CFLAGS}
-LIBS += -lm ${BUILDERS_LDFLAGS} ${SIDPLAY1_LIBS} ${SIDPLAY2_LIBS} ${BUILDERS_LIBS} ${GLIB_LIBS} -lstdc++
+CPPFLAGS += ${PLUGIN_CPPFLAGS} -D_REENTRANT -I../.. -DAUDACIOUS_PLUGIN ${SIDPLAY1_CFLAGS} ${SIDPLAY2_CFLAGS} ${SIDPLAYFP_CFLAGS} ${BUILDERS_CFLAGS} ${GLIB_CFLAGS}
+LIBS += -lm ${BUILDERS_LDFLAGS} ${SIDPLAY1_LIBS} ${SIDPLAY2_LIBS} -Wl,--no-as-needed ${SIDPLAYFP_LIBS} -Wl,--as-needed ${BUILDERS_LIBS} ${GLIB_LIBS} -lstdc++
Index: src/sid/xs_config.c
===================================================================
--- src/sid/xs_config.c.orig
+++ src/sid/xs_config.c
@@ -53,6 +53,10 @@ void xs_init_configuration(void)
     xs_cfg.sid1Filter.fm = XS_SIDPLAY1_FM;
     xs_cfg.sid1Filter.ft = XS_SIDPLAY1_FT;
 
+#ifdef HAVE_SIDPLAYFP
+    xs_cfg.playerEngine = XS_ENG_SIDPLAYFP;
+    xs_cfg.memoryMode = XS_MPU_REAL;
+#else
 #ifdef HAVE_SIDPLAY2
     xs_cfg.playerEngine = XS_ENG_SIDPLAY2;
     xs_cfg.memoryMode = XS_MPU_REAL;
@@ -64,6 +68,7 @@ void xs_init_configuration(void)
 #error This should not happen! No emulator engines configured in!
 #endif
 #endif
+#endif
 
     xs_cfg.clockSpeed = XS_CLOCK_PAL;
     xs_cfg.forceSpeed = FALSE;
Index: src/sid/xs_config.h
===================================================================
--- src/sid/xs_config.h.orig
+++ src/sid/xs_config.h
@@ -12,7 +12,8 @@ extern "C" {
  */
 enum XS_EMUENGINE {
     XS_ENG_SIDPLAY1 = 1,
-    XS_ENG_SIDPLAY2
+    XS_ENG_SIDPLAY2,
+    XS_ENG_SIDPLAYFP
 };
 
 
Index: src/sid/xs_player.c
===================================================================
--- src/sid/xs_player.c.orig
+++ src/sid/xs_player.c
@@ -6,6 +6,9 @@
 #ifdef HAVE_SIDPLAY2
 #include "xs_sidplay2.h"
 #endif
+#ifdef HAVE_SIDPLAYFP
+#include "xs_sidplayfp.h"
+#endif
 
 
 /* List of emulator engines
@@ -31,6 +34,16 @@ static const xs_engine_t xs_enginelist[]
      xs_sidplay2_flush
     },
 #endif
+#ifdef HAVE_SIDPLAYFP
+    {XS_ENG_SIDPLAYFP,
+     xs_sidplayfp_probe,
+     xs_sidplayfp_init, xs_sidplayfp_close,
+     xs_sidplayfp_initsong, xs_sidplayfp_fillbuffer,
+     xs_sidplayfp_load, xs_sidplayfp_delete,
+     xs_sidplayfp_getinfo, xs_sidplayfp_updateinfo,
+     xs_sidplayfp_flush
+    },
+#endif
 };
 
 static const gint xs_nenginelist = (sizeof(xs_enginelist) / sizeof(xs_enginelist[0]));
Index: src/sid/xs_sidplay.h
===================================================================
--- src/sid/xs_sidplay.h.orig
+++ src/sid/xs_sidplay.h
@@ -65,7 +65,7 @@ xs_tuneinfo_t *TFUNCTION(const gchar *si
         myInfo.songs, myInfo.startSong,
         myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2],
         myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr,
-        myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel);
+        myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel1);
     
     /* NOTICE! libSIDPlay[12] headers specifically state that sidModel,
      * songSpeed and clockSpeed are "undefined" before song initialization,
@@ -110,7 +110,7 @@ gboolean TFUNCTION2(xs_status_t *myStatu
      * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ...
      */
     i = myStatus->tuneInfo;
-    i->sidModel = myInfo.sidModel;
+    i->sidModel = myInfo.sidModel1;
 
     if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) {
         gint tmpSpeed = -1;
Index: extra.mk.in
===================================================================
--- extra.mk.in.orig
+++ extra.mk.in
@@ -91,6 +91,8 @@ SIDPLAY1_CFLAGS ?= @SIDPLAY1_CFLAGS@
 SIDPLAY1_LIBS ?= @SIDPLAY1_LIBS@
 SIDPLAY2_CFLAGS ?= @SIDPLAY2_CFLAGS@
 SIDPLAY2_LIBS ?= @SIDPLAY2_LIBS@
+SIDPLAYFP_CFLAGS ?= @SIDPLAYFP_CFLAGS@
+SIDPLAYFP_LIBS ?= @SIDPLAYFP_LIBS@
 SNDFILE_CFLAGS ?= @SNDFILE_CFLAGS@
 SNDFILE_LIBS ?= @SNDFILE_LIBS@
 SNDIO_LIBS ?= @SNDIO_LIBS@
