Revision: 45758
http://sourceforge.net/p/vice-emu/code/45758
Author: gpz
Date: 2025-09-13 23:30:47 +0000 (Sat, 13 Sep 2025)
Log Message:
-----------
added support for USBSID-Pico, based on patch(es) by LouD
Modified Paths:
--------------
trunk/vice/configure.ac
trunk/vice/doc/vice.texi
trunk/vice/src/Makefile.am
trunk/vice/src/arch/gtk3/widgets/sidenginemodelwidget.c
trunk/vice/src/arch/gtk3/widgets/sidsoundwidget.c
trunk/vice/src/arch/sdl/menu_sid.c
trunk/vice/src/arch/shared/hwsiddrv/Makefile.am
trunk/vice/src/lib/Makefile.am
trunk/vice/src/sid/Makefile.am
trunk/vice/src/sid/parsid.c
trunk/vice/src/sid/sid-cmdline-options.c
trunk/vice/src/sid/sid-cmdline-options.h
trunk/vice/src/sid/sid-resources.c
trunk/vice/src/sid/sid-snapshot.c
trunk/vice/src/sid/sid-snapshot.h
trunk/vice/src/sid/sid.c
trunk/vice/src/sid/sid.h
trunk/vice/src/vicefeatures.c
Added Paths:
-----------
trunk/vice/src/arch/shared/hwsiddrv/us-unixwin-device.c
trunk/vice/src/arch/shared/hwsiddrv/us-unixwin.h
trunk/vice/src/arch/shared/hwsiddrv/usbsid-unixwin-drv.c
trunk/vice/src/lib/libusbsiddrv/
trunk/vice/src/lib/libusbsiddrv/LICENSE
trunk/vice/src/lib/libusbsiddrv/Makefile
trunk/vice/src/lib/libusbsiddrv/Makefile.am
trunk/vice/src/lib/libusbsiddrv/Makefile.in
trunk/vice/src/lib/libusbsiddrv/README.md
trunk/vice/src/lib/libusbsiddrv/USBSID.cpp
trunk/vice/src/lib/libusbsiddrv/USBSID.h
trunk/vice/src/lib/libusbsiddrv/USBSIDInterface.cpp
trunk/vice/src/lib/libusbsiddrv/USBSIDInterface.h
trunk/vice/src/sid/usbsid.c
trunk/vice/src/usbsid.h
Modified: trunk/vice/configure.ac
===================================================================
--- trunk/vice/configure.ac 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/configure.ac 2025-09-13 23:30:47 UTC (rev 45758)
@@ -445,6 +445,7 @@
HAVE_FASTSID_SUPPORT="no "
HAVE_FONTCONFIG_SUPPORT="no "
HAVE_GIF_SUPPORT="no "
+HAVE_USBSID_SUPPORT="no "
HAVE_HARDSID_SUPPORT="no "
HAVE_HWSCALE_SUPPORT="no "
HAVE_IOSID_SUPPORT="no "
@@ -789,6 +790,44 @@
AM_CONDITIONAL(HAVE_CATWEASELMKIII, true)
HAVE_CATWEASELMKIII_SUPPORT="yes"
fi
+
+ dnl check for usbsid required libraries and headers
+ if test x"$enable_usbsid" != "xno" ; then
+ PKG_PROG_PKG_CONFIG
+ WIN32_USBSID_HEADER_PRESENT=yes
+ AC_CHECK_HEADERS(libusb-1.0/libusb.h,,[WIN32_USBSID_HEADER_PRESENT=no],)
+ if test x"$WIN32_USBSID_HEADER_PRESENT" = "xyes"; then
+ AC_CHECK_LIB(usb-1.0, libusb_init,[LIBS="-lusb-1.0 $LIBS"; USBSID_LIB_PRESENT=yes],,)
+ if test x"$PKG_CONFIG" != "x" -a x"$USBSID_LIB_PRESENT" = "xyes"; then
+ PKG_CHECK_MODULES(LIBUSB, [libusb-1.0], HAVE_LIBUSB_SUPPORT="yes")
+ AC_MSG_CHECKING([for pkgconfig libusb-1.0])
+ if test x"$HAVE_LIBUSB_SUPPORT" = "xyes"; then
+ VICE_CFLAGS="$VICE_CFLAGS $LIBUSB_CFLAGS";
+ VICE_CPPFLAGS="$VICE_CPPFLAGS $LIBUSB_CFLAGS";
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ fi
+ fi
+
+ dnl usbsid support
+ AM_CONDITIONAL(HAVE_USBSID, false)
+ AC_MSG_CHECKING([for USBSID-Pico support])
+ if test x"$enable_usbsid" != "xno" ; then
+ if test x"$HAVE_LIBUSB_SUPPORT" = "xyes"; then
+ AC_DEFINE([HAVE_USBSID],,[Support for USBSID])
+ HAVE_USBSID_SUPPORT="yes"
+ AM_CONDITIONAL(HAVE_USBSID, true)
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no (LIBUSB not found)])
+ fi
+ else
+ AC_MSG_RESULT([no (USBSID-Pico disabled)])
+ fi
+
if test x"$enable_hardsid" != "xno"; then
AC_DEFINE(HAVE_HARDSID,,[Support for HardSID.])
HAVE_HARDSID_SUPPORT="yes"
@@ -2761,7 +2800,7 @@
AC_SUBST(SOUND_DRIVERS)
AC_SUBST(SOUND_LIBS)
-dnl Check for ParSID/HardSID/CW support
+dnl Check for ParSID/USBSID/HardSID/CW support
if test x"$is_unix" = "xyes"; then
dnl Check cpu first
@@ -2914,6 +2953,44 @@
fi
fi
+
+ dnl usbsid required libraries and headers
+ if test x"$enable_usbsid" != "xno" ; then
+ PKG_PROG_PKG_CONFIG
+ UNIX_USBSID_HEADER_PRESENT=yes
+ AC_CHECK_HEADERS(libusb-1.0/libusb.h,,[UNIX_USBSID_HEADER_PRESENT=no],)
+ if test x"$UNIX_USBSID_HEADER_PRESENT" = "xyes"; then
+ AC_CHECK_LIB(usb-1.0, libusb_init,[LIBS="-lusb-1.0 $LIBS"; USBSID_LIB_PRESENT=yes],,)
+ if test x"$PKG_CONFIG" != "x" -a x"$USBSID_LIB_PRESENT" = "xyes"; then
+ PKG_CHECK_MODULES(LIBUSB, [libusb-1.0], HAVE_LIBUSB_SUPPORT="yes")
+ AC_MSG_CHECKING([for pkgconfig libusb-1.0])
+ if test x"$HAVE_LIBUSB_SUPPORT" = "xyes"; then
+ VICE_CFLAGS="$VICE_CFLAGS $LIBUSB_CFLAGS";
+ VICE_CPPFLAGS="$VICE_CPPFLAGS $LIBUSB_CFLAGS";
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ fi
+ fi
+
+ dnl usbsid support
+ AM_CONDITIONAL(HAVE_USBSID, false)
+ AC_MSG_CHECKING([for USBSID-Pico support])
+ if test x"$enable_usbsid" != "xno" ; then
+ if test x"$HAVE_LIBUSB_SUPPORT" = "xyes"; then
+ AC_DEFINE([HAVE_USBSID],,[Support for USBSID])
+ HAVE_USBSID_SUPPORT="yes"
+ AM_CONDITIONAL(HAVE_USBSID, true)
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no (LIBUSB not found!!)])
+ fi
+ else
+ AC_MSG_RESULT([no (USBSID-Pico disabled)])
+ fi
+
fi
AC_TYPE_SIGNAL
@@ -3455,6 +3532,7 @@
src/lib/Makefile
src/lib/p64/Makefile
src/lib/linenoise-ng/Makefile
+ src/lib/libusbsiddrv/Makefile
src/lib/libzmbv/Makefile
src/lib/md5/Makefile
src/monitor/Makefile
@@ -3613,6 +3691,7 @@
if test x"$real_arch" = "xUnix" -o x"$real_arch" = "xOSX" -o x"$real_arch" = "xWin32"; then
echo "MIDI support : $HAVE_MIDI_SUPPORT (--enable/disable-midi)"
+ echo "USBSID-Pico support : $HAVE_USBSID_SUPPORT"
fi
if test x"$real_arch" != "xOSX" -a x"$real_arch" != "xBeOS"; then
Modified: trunk/vice/doc/vice.texi
===================================================================
--- trunk/vice/doc/vice.texi 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/doc/vice.texi 2025-09-13 23:30:47 UTC (rev 45758)
@@ -12311,7 +12311,7 @@
@vindex SidEngine
@item SidEngine
Integer specifying what SID engine will be used.
-(0: FastSID, 1: ReSID, 2: Catweasel MKIII, 3: HardSID, 4: ParSID Port 1, 5: ParSID Port 2, 6: ParSID Port 3)
+(0: FastSID, 1: ReSID, 2: Catweasel MKIII, 3: HardSID, 4: ParSID Port 1, 5: ParSID Port 2, 6: ParSID Port 3, 7: USBSID-Pico)
@vindex SidResidSampling
@item SidResidSampling
@@ -12352,6 +12352,37 @@
not downsampled - audio data is written to a file called resid.raw in the current
working directory.
+@vindex SidUSBSIDReadMode
+@item SidUSBSIDReadMode
+Boolean specifying whether to enable USBSID-Pico read mode. When enabled, this
+mode allows for reading from SID registers that provides a means to configure an
+FPGASID that is seated on USBSID-Pico. This mode is not suited for regular audio
+use as it disables cycle exact writing & digiplay.
+Default is (@code{SidUSBSIDReadMode=0}) for off, (@code{SidUSBSIDReadMode=1}) for on.
+
+@vindex SidUSBSIDAudioMode
+@item SidUSBSIDAudioMode
+Boolean to enable USBSID-Pico PCB (v1.3) stereo audio mode. When enabled the audio of SID socket 1
+will be output over the left audio channel and the audio of SID socket 2 over the right channel
+of USBSID-Pico's audio out.
+Default is (@code{SidUSBSIDAudioMode=0}) for Mono, (@code{SidUSBSIDAudioMode=1}) for Stereo.
+
+@vindex SidUSBSIDDiffSize
+@item SidUSBSIDDiffSize
+Integer specifying the minimal difference (must be a number divisable by 8) in bytes to
+use between the head and tail of the drivers ringbuffer, this allows for some audio
+quality tuning on slower systems.
+In most cases the default value of 64 bytes (also the size of a USB packet) is the
+right setting for best audio quality. (@code{SidUSBSIDDiffSize=32-256}).
+
+@vindex SidUSBSIDBufferSize
+@item SidUSBSIDBufferSize
+Integer specifying the size in bytes to use as ringbuffer to store temporary data when sending
+SID writes to USBSID-Pico (must be a number divisable by 8), this allows for some audio quality
+tuning on slower systems.
+In most cases the default value of 8192 bytes is the right setting for best audio quality.
+(@code{SidUSBSIDBufferSize=512-16384}).
+
@end table
@@ -12498,14 +12529,15 @@
Catweasel MKIII: 512/catweaselmkiii/catweasel3/catweasel/cwmkiii/cw3/cw,
HardSID: 768/hardsid/hard/hs,
ParSID Port 1: 1024/parsid/parsid1/par1/lpt1,
-ParSID Port 2: 1280/parsid2/par2/lpt2
-ParSID Port 3: 1536/parsid3/par3/lpt3)
+ParSID Port 2: 1280/parsid2/par2/lpt2,
+ParSID Port 3: 1536/parsid3/par3/lpt3,
+USBSID-Pico: 1792/usbsid/usbs/us)
@findex -sidengine
@item -sidengine <engine>
Specify engine for the emulated SID chip
(@code{SidEngine}).
-(FastSID: 0, ReSID: 1, DTVSID: 2, HardSID: 3, ParSID Port 1: 4, ParSID Port 2: 5, ParSID Port 3: 6)
+(FastSID: 0, ReSID: 1, DTVSID: 2, HardSID: 3, ParSID Port 1: 4, ParSID Port 2: 5, ParSID Port 3: 6, USBSID-Pico: 7)
@findex -sidmodel
@item -sidmodel <model>
@@ -12558,6 +12590,35 @@
not downsampled - audio data is written to a file called resid.raw in the current
working directory.
+@findex -usreadmode
+@item -usreadmode <0 or 1>
+Enable USBSID-Pico read mode. When enabled, this mode allows for reading from SID
+ registers that provides a means to configure an FPGASID that is seated on USBSID-Pico.
+ This mode is not suited for regular audio use as it disables cycle exact writing & digiplay.
+ Default is (@code{SidUSBSIDReadMode=0}) for off, (@code{SidUSBSIDReadMode=1}) for on.
+
+@findex -usaudiomode
+@item -usaudiomode <0 or 1>
+Set USBSID-Pico PCB (v1.3) audio mode to Stereo or Mono. When enabled the audio of SID socket 1
+ will be output over the left audio channel and the audio of SID socket 2 over the right channel
+ of USBSID-Pico's audio out.
+ Default is (@code{SidUSBSIDAudioMode=0}) for Mono, (@code{SidUSBSIDAudioMode=1}) for Stereo.
+
+@findex -usdiffsize
+@item -usdiffsize <number divisable by 8>
+Specifies the minimal difference in bytes to use between the head and tail of the
+ drivers ringbuffer, this allows for some audio quality tuning on slower systems.
+ In most cases the default value of 64 bytes (also the size of a USB packet) is the
+ right setting for best audio quality.
+ (@code{SidUSBSIDDiffSize=32-256}).
+
+@findex -usbuffsize
+@item -usbuffsize <number divisable by 8>
+Specifies the size in bytes to use as ringbuffer to store temporary data when sending
+ SID writes to USBSID-Pico, this allows for some audio quality tuning on slower systems.
+ In most cases the default value of 8192 bytes is the right setting for best audio quality.
+ (@code{SidUSBSIDBufferSize=512-16384}).
+
@end table
@@ -37493,6 +37554,10 @@
@b{Bjoern Odendahl}
Created the new VICE logo and volunteered to create new icons.
+@item
+@b{LouD}
+Added USBSID-Pico hardware SID support.
+
@end itemize
(We hope we have not forgotten anybody; if you think we have,
Modified: trunk/vice/src/Makefile.am
===================================================================
--- trunk/vice/src/Makefile.am 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/src/Makefile.am 2025-09-13 23:30:47 UTC (rev 45758)
@@ -268,6 +268,7 @@
uicmdline.h \
uicolor.h \
uimon.h \
+ usbsid.h \
util.h \
version.h.in \
version.h \
@@ -569,6 +570,9 @@
if !USE_HEADLESSUI
hotkeys_lib = $(top_builddir)/src/arch/shared/hotkeys/libhotkeys.a
endif
+if HAVE_USBSID
+usbsiddrv_lib = $(top_builddir)/src/lib/libusbsiddrv/libusbsiddrv.a
+endif
hwsiddrv_lib = $(top_builddir)/src/arch/shared/hwsiddrv/libhwsiddrv.a
hvsc_lib = $(top_builddir)/src/hvsc/libhvsc.a
iecbus_lib = $(top_builddir)/src/iecbus/libiecbus.a
@@ -630,6 +634,10 @@
driver_libs = $(joyport_lib) $(samplerdrv_lib) $(sounddrv_lib) $(mididrv_lib) $(socketdrv_lib) $(hwsiddrv_lib) $(gfxoutputdrv_lib) $(printerdrv_lib) $(diskimage_lib) $(fsdevice_lib) $(tape_lib) $(fileio_lib) $(serial_lib) $(core_lib)
+if HAVE_USBSID
+driver_libs += $(usbsiddrv_lib)
+endif
+
if SUPPORT_X64
x64_bin = x64
else
@@ -669,6 +677,10 @@
$(vsidstubs_lib) \
$(md5_lib)
+if HAVE_USBSID
+vsid_libs += $(usbsiddrv_lib)
+endif
+
vsid_SOURCES = $(base_sources) $(midi_sources)
vsid_LDADD = $(vsid_libs) $(emu_extlibs) @TFE_LIBS@ @NETPLAY_LIBS@ $(VSID_RES)
@@ -1503,6 +1515,11 @@
$(hvsc_lib):
@echo "making all in hvsc"
@(cd hvsc && $(MAKE))
+if HAVE_USBSID
+$(usbsiddrv_lib):
+ @echo "making all in lib/libusbsiddrv"
+ @(cd lib/libusbsiddrv && $(MAKE))
+endif
$(hwsiddrv_lib):
@echo "making all in arch/shared/hwsiddrv"
@(cd arch/shared/hwsiddrv && $(MAKE))
Modified: trunk/vice/src/arch/gtk3/widgets/sidenginemodelwidget.c
===================================================================
--- trunk/vice/src/arch/gtk3/widgets/sidenginemodelwidget.c 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/src/arch/gtk3/widgets/sidenginemodelwidget.c 2025-09-13 23:30:47 UTC (rev 45758)
@@ -122,7 +122,6 @@
list = sid_get_engine_model_list();
for (i = 0; list[i] != NULL; i++) {
GtkWidget *radio;
-
radio = gtk_radio_button_new_with_label(group, list[i]->name);
gtk_radio_button_join_group(GTK_RADIO_BUTTON(radio),
GTK_RADIO_BUTTON(last));
Modified: trunk/vice/src/arch/gtk3/widgets/sidsoundwidget.c
===================================================================
--- trunk/vice/src/arch/gtk3/widgets/sidsoundwidget.c 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/src/arch/gtk3/widgets/sidsoundwidget.c 2025-09-13 23:30:47 UTC (rev 45758)
@@ -39,6 +39,12 @@
* $VICERES Sid2AddressStart all
* $VICERES Sid3AddressStart all
*
+ * These are related to USBSID
+ * $VICERES SidUSBSIDReadMode all
+ * $VICERES SidUSBSIDAudioMode all
+ * $VICERES SidUSBSIDDiffSize all
+ * $VICERES SidUSBSIDBufferSize all
+ *
* Until PSID files support more than three SIDs, these will be -vsid:
* $VICERES Sid4AddressStart -vsid
* $VICERES Sid5AddressStart -vsid
@@ -133,6 +139,30 @@
};
#endif
+#ifdef HAVE_USBSID
+/** \brief Values for the "SidUSBSIDDiffSize" resource
+ */
+static const vice_gtk3_radiogroup_entry_t us_diffsizes_radio[] = {
+ { "32", 32 },
+ { "64", 64 },
+ { "128", 128 },
+ { "256", 256 },
+ { NULL, -1 }
+};
+
+/** \brief Values for the "SidUSBSIDBufferSize" resource
+ */
+static const vice_gtk3_radiogroup_entry_t us_buffsizes_radio[] = {
+ { "512", 512 },
+ { "1024", 1024 },
+ { "2048", 2048 },
+ { "4092", 4092 },
+ { "8192", 8192 },
+ { "16384", 16384 },
+ { NULL, -1 }
+};
+#endif
+
/** \brief I/O addresses for extra SID's for the C64 */
static int sid_addr_list_c64[] = {
/*N/A*/ 0xd420, 0xd440, 0xd460, 0xd480, 0xd4a0, 0xd4c0, 0xd4e0,
@@ -168,6 +198,15 @@
static GtkWidget *resid_8580_grid;
#endif
+#ifdef HAVE_USBSID
+/** \brief USBSID read mode / audio mode checkbox */
+static GtkWidget *us_switches;
+/** \brief USBSID diffsizes radio buttons */
+static GtkWidget *us_diffsizes;
+/** \brief USBSID buffsizes radio buttons */
+static GtkWidget *us_buffsizes;
+#endif
+
/** \brief Number of extra SIDs widget */
static GtkWidget *num_sids_widget;
@@ -274,6 +313,83 @@
}
#endif
+#ifdef HAVE_USBSID
+/** \brief Create widget to control USBSID switches
+ *
+ * \return GtkGrid
+ */
+static GtkWidget *create_us_switches_widget(void)
+{
+ GtkWidget *grid;
+ GtkWidget *label;
+ GtkWidget *us_readmode;
+ GtkWidget *us_audiomode;
+
+ grid = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(grid), 8);
+
+ label = label_helper("<b>USBSID options</b>");
+ us_readmode = vice_gtk3_resource_check_button_new("SidUSBSIDReadMode",
+ "Enable read mode");
+ us_audiomode = vice_gtk3_resource_check_button_new("SidUSBSIDAudioMode",
+ "Enable stereo mode");
+
+ gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
+ gtk_grid_attach(GTK_GRID(grid), us_readmode, 0, 1, 1, 1);
+ gtk_grid_attach(GTK_GRID(grid), us_audiomode, 0, 2, 1, 1);
+ gtk_widget_show_all(grid);
+ return grid;
+}
+
+/** \brief Create widget to control USBSID buffer diff
+ *
+ * \return GtkGrid
+ */
+static GtkWidget *create_us_diffsizes_widget(void)
+{
+ GtkWidget *grid;
+ GtkWidget *label;
+ GtkWidget *group;
+
+ grid = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(grid), 8);
+
+ label = label_helper("<b>USBSID buffer diff</b>");
+ group = vice_gtk3_resource_radiogroup_new("SidUSBSIDDiffSize",
+ us_diffsizes_radio,
+ GTK_ORIENTATION_VERTICAL);
+
+ gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
+ gtk_grid_attach(GTK_GRID(grid), group, 0, 1, 1, 1);
+ gtk_widget_show_all(grid);
+ return grid;
+}
+
+/** \brief Create widget to control USBSID buffer size
+ *
+ * \return GtkGrid
+ */
+static GtkWidget *create_us_buffsizes_widget(void)
+{
+ GtkWidget *grid;
+ GtkWidget *label;
+ GtkWidget *group;
+
+ grid = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(grid), 8);
+
+ label = label_helper("<b>USBSID buffer size</b>");
+ group = vice_gtk3_resource_radiogroup_new("SidUSBSIDBufferSize",
+ us_buffsizes_radio,
+ GTK_ORIENTATION_VERTICAL);
+
+ gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
+ gtk_grid_attach(GTK_GRID(grid), group, 0, 1, 1, 1);
+ gtk_widget_show_all(grid);
+ return grid;
+}
+#endif
+
/** \brief Create widget to set the number of emulated SID's
*
* \return GtkGrid
@@ -551,6 +667,22 @@
}
#endif
+/* FIXME: HardSID options are missing */
+
+#ifdef HAVE_USBSID
+ us_switches = create_us_switches_widget();
+ us_diffsizes = create_us_diffsizes_widget();
+ us_buffsizes = create_us_buffsizes_widget();
+
+ gtk_grid_attach(GTK_GRID(grid), us_switches, 0, row + 3, 1, 1);
+ gtk_grid_attach(GTK_GRID(grid), us_diffsizes, 1, row + 3, 1, 1);
+ gtk_grid_attach(GTK_GRID(grid), us_buffsizes, 2, row + 3, 1, 1);
+
+ gtk_widget_set_sensitive(us_switches, current_engine == SID_ENGINE_USBSID);
+ gtk_widget_set_sensitive(us_diffsizes, current_engine == SID_ENGINE_USBSID);
+ gtk_widget_set_sensitive(us_buffsizes, current_engine == SID_ENGINE_USBSID);
+#endif
+
if (machine_class != VICE_MACHINE_PLUS4 &&
machine_class != VICE_MACHINE_CBM5x0 &&
machine_class != VICE_MACHINE_CBM6x0) {
Modified: trunk/vice/src/arch/sdl/menu_sid.c
===================================================================
--- trunk/vice/src/arch/sdl/menu_sid.c 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/src/arch/sdl/menu_sid.c 2025-09-13 23:30:47 UTC (rev 45758)
@@ -169,6 +169,94 @@
#endif /* HAVE_RESID */
+#ifdef HAVE_USBSID
+UI_MENU_DEFINE_TOGGLE(SidUSBSIDReadMode)
+UI_MENU_DEFINE_TOGGLE(SidUSBSIDAudioMode)
+UI_MENU_DEFINE_RADIO(SidUSBSIDDiffSize)
+UI_MENU_DEFINE_RADIO(SidUSBSIDBufferSize)
+
+static const ui_menu_entry_t us_diffsize_menu[] = {
+ { .string = "32",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDDiffSize_callback,
+ .data = (ui_callback_data_t)32
+ },
+ { .string = "64",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDDiffSize_callback,
+ .data = (ui_callback_data_t)64
+ },
+ { .string = "128",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDDiffSize_callback,
+ .data = (ui_callback_data_t)128
+ },
+ { .string = "256",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDDiffSize_callback,
+ .data = (ui_callback_data_t)256
+ },
+ SDL_MENU_LIST_END
+};
+
+static const ui_menu_entry_t us_buffsize_menu[] = {
+ { .string = "512",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDBufferSize_callback,
+ .data = (ui_callback_data_t)512
+ },
+ { .string = "1024",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDBufferSize_callback,
+ .data = (ui_callback_data_t)1024
+ },
+ { .string = "2048",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDBufferSize_callback,
+ .data = (ui_callback_data_t)2048
+ },
+ { .string = "4096",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDBufferSize_callback,
+ .data = (ui_callback_data_t)4096
+ },
+ { .string = "8192",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDBufferSize_callback,
+ .data = (ui_callback_data_t)8192
+ },
+ { .string = "16384",
+ .type = MENU_ENTRY_RESOURCE_RADIO,
+ .callback = radio_SidUSBSIDBufferSize_callback,
+ .data = (ui_callback_data_t)16384
+ },
+ SDL_MENU_LIST_END
+};
+
+# define VICE_SDL_USBSID_OPTIONS \
+ { .string = "USBSID enable stereo audio mode", \
+ .type = MENU_ENTRY_RESOURCE_TOGGLE, \
+ .callback = toggle_SidUSBSIDAudioMode_callback \
+ }, \
+ { .string = "USBSID enable read mode", \
+ .type = MENU_ENTRY_RESOURCE_TOGGLE, \
+ .callback = toggle_SidUSBSIDReadMode_callback \
+ }, \
+ { .string = "USBSID buffer size", \
+ .type = MENU_ENTRY_SUBMENU, \
+ .callback = submenu_radio_callback, \
+ .data = (ui_callback_data_t)us_buffsize_menu \
+ }, \
+ { .string = "USBSID diff size", \
+ .type = MENU_ENTRY_SUBMENU, \
+ .callback = submenu_radio_callback, \
+ .data = (ui_callback_data_t)us_diffsize_menu \
+ }, \
+
+
+#endif /* HAVE_USBSID */
+
+
UI_MENU_DEFINE_TOGGLE(SidFilters)
UI_MENU_DEFINE_RADIO(SidStereo)
UI_MENU_DEFINE_RADIO(Sid2AddressStart)
@@ -681,6 +769,9 @@
#ifdef HAVE_RESID
VICE_SDL_RESID_OPTIONS
#endif
+#ifdef HAVE_USBSID
+ VICE_SDL_USBSID_OPTIONS
+#endif
SDL_MENU_LIST_END
};
@@ -736,6 +827,9 @@
#ifdef HAVE_RESID
VICE_SDL_RESID_OPTIONS
#endif
+#ifdef HAVE_USBSID
+ VICE_SDL_USBSID_OPTIONS
+#endif
SDL_MENU_LIST_END
};
@@ -751,6 +845,9 @@
#ifdef HAVE_RESID
VICE_SDL_RESID_OPTIONS
#endif
+#ifdef HAVE_USBSID
+ VICE_SDL_USBSID_OPTIONS
+#endif
SDL_MENU_LIST_END
};
@@ -766,6 +863,9 @@
#ifdef HAVE_RESID
VICE_SDL_RESID_OPTIONS
#endif
+#ifdef HAVE_USBSID
+ VICE_SDL_USBSID_OPTIONS
+#endif
SDL_MENU_LIST_END
};
@@ -789,6 +889,9 @@
#ifdef HAVE_RESID
VICE_SDL_RESID_OPTIONS
#endif
+#ifdef HAVE_USBSID
+ VICE_SDL_USBSID_OPTIONS
+#endif
SDL_MENU_ITEM_SEPARATOR,
SDL_MENU_ITEM_TITLE("SID address"),
{ .string = "$9800",
@@ -833,6 +936,9 @@
#ifdef HAVE_RESID
VICE_SDL_RESID_OPTIONS
#endif
+#ifdef HAVE_USBSID
+ VICE_SDL_USBSID_OPTIONS
+#endif
SDL_MENU_ITEM_SEPARATOR,
SDL_MENU_ITEM_TITLE("SID address"),
{ .string = "$8F00",
@@ -879,6 +985,9 @@
#ifdef HAVE_RESID
VICE_SDL_RESID_OPTIONS
#endif
+#ifdef HAVE_USBSID
+ VICE_SDL_USBSID_OPTIONS
+#endif
SDL_MENU_ITEM_SEPARATOR,
SDL_MENU_ITEM_TITLE("SID address"),
Modified: trunk/vice/src/arch/shared/hwsiddrv/Makefile.am
===================================================================
--- trunk/vice/src/arch/shared/hwsiddrv/Makefile.am 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/src/arch/shared/hwsiddrv/Makefile.am 2025-09-13 23:30:47 UTC (rev 45758)
@@ -16,6 +16,12 @@
AM_LDFLAGS = @VICE_LDFLAGS@
+# TESTING
+if HAVE_USBSID
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/libusbsiddrv
+AM_CXXFLAGS += -I$(top_srcdir)/src/lib/libusbsiddrv
+AM_LDFLAGS += -I$(top_srcdir)/src/lib/libusbsiddrv
+endif
noinst_LIBRARIES = libhwsiddrv.a
@@ -38,6 +44,11 @@
parsid-win32-drv.o \
ps-ieee1284.o
endif HAVE_PARSID
+if HAVE_USBSID
+HWSIDDRIVERS += \
+ usbsid-unixwin-drv.o \
+ us-unixwin-device.o
+endif HAVE_USBSID
endif WINDOWS_COMPILE
if BEOS_COMPILE
@@ -64,6 +75,11 @@
ps-ieee1284.o \
ps-unix-file.o
endif HAVE_PARSID
+if HAVE_USBSID
+HWSIDDRIVERS += \
+ usbsid-unixwin-drv.o \
+ us-unixwin-device.o
+endif HAVE_USBSID
endif UNIX_COMPILE
@@ -80,7 +96,9 @@
parsid-unix-drv.c \
parsid-win32-drv.c \
ps-ieee1284.c \
- ps-unix-file.c
+ ps-unix-file.c \
+ usbsid-unixwin-drv.c \
+ us-unixwin-device.c
EXTRA_DIST = \
cw-unix.h \
@@ -88,7 +106,8 @@
hs-unix.h \
hs-win32.h \
ps-unix.h \
- ps-win32.h
+ ps-win32.h \
+ us-unixwin.h
# Always built:
# (needs to be declared empty to avoid `make` to try to build libhwsiddrv.o
Added: trunk/vice/src/arch/shared/hwsiddrv/us-unixwin-device.c
===================================================================
--- trunk/vice/src/arch/shared/hwsiddrv/us-unixwin-device.c (rev 0)
+++ trunk/vice/src/arch/shared/hwsiddrv/us-unixwin-device.c 2025-09-13 23:30:47 UTC (rev 45758)
@@ -0,0 +1,330 @@
+/*
+ * us-unixwin-device.c
+ *
+ * Written by
+ * LouDnl <vi...@ma...>
+ *
+ * Based on vice code written by
+ * Simon White <sid...@ya...>
+ * Marco van den Heuvel <bla...@ya...>
+ *
+ * This file is part of VICE, modified from the other hardware sid sources.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#include "vice.h"
+
+#if defined(HAVE_USBSID)
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h> /* TIMESPEC */
+#include <time.h> /* TIMESPEC */
+
+#include "alarm.h"
+#include "us-unixwin.h"
+#include "usbsid.h"
+#include "log.h"
+#include "maincpu.h"
+#include "machine.h"
+#include "resources.h"
+#include "sid-resources.h"
+#include "types.h"
+
+#include "USBSIDInterface.h"
+
+static int rc = -1, sids_found = -1, no_sids = -1;
+static int r_audiomode = -1, audiomode = -1;
+static int r_readmode = -1, readmode = -1;
+static int buffsize = -1, diffsize = -1;
+static int r_buffsize = -1, r_diffsize = -1;
+const int d_buffsize = 8192, d_diffsize = 64;
+static uint8_t sid_registers[0x20 * US_MAXSID];
+static int usid_chipno = -1;
+
+static CLOCK usid_main_clk;
+static CLOCK usid_alarm_clk;
+static alarm_t *usid_alarm = NULL;
+static long raster_rate;
+
+static log_t usbsid_log = LOG_DEFAULT;
+
+/* pre declarations */
+static void usbsid_alarm_handler(CLOCK offset, void *data);
+
+USBSIDitf usbsid;
+
+void us_device_reset(bool us_reset)
+{
+ if (sids_found > 0) {
+ raster_rate = getrasterrate_USBSID(usbsid);
+ usid_main_clk = maincpu_clk;
+ usid_alarm_clk = raster_rate;
+ alarm_set(usid_alarm, (usid_main_clk + raster_rate));
+ if (us_reset) {
+ reset_USBSID(usbsid);
+ log_message(usbsid_log, "Reset sent");
+ }
+ no_sids = -1;
+ log_message(usbsid_log, "Clocks reset");
+ }
+ return;
+}
+
+int us_device_open(void)
+{
+ usbsid_log = log_open("USBSID");
+
+ if (!sids_found) {
+ return -1;
+ }
+
+ if (sids_found > 0) {
+ return sids_found;
+ }
+
+ sids_found = 0;
+
+ log_message(usbsid_log, "Detecting boards");
+
+ if (usbsid == NULL) {
+ usbsid = create_USBSID();
+ if (usbsid) {
+ /* Gather settings from resources */
+ resources_get_int("SidUSBSIDReadMode", &r_readmode);
+ resources_get_int("SidUSBSIDAudioMode", &r_audiomode);
+ resources_get_int("SidUSBSIDDiffSize", &r_readmode);
+ resources_get_int("SidUSBSIDBufferSize", &r_diffsize);
+ /* Apply settings to local variables */
+ readmode = r_readmode;
+ audiomode = r_audiomode;
+ diffsize = r_diffsize;
+ buffsize = r_buffsize;
+ /* Update diff and buff size if needed */
+ if (diffsize >= 16) {
+ setdiffsize_USBSID(usbsid, diffsize);
+ }
+ if (buffsize >= 256) {
+ setbuffsize_USBSID(usbsid, buffsize);
+ }
+ }
+
+ if (readmode == 1) {
+ rc = init_USBSID(usbsid, false, false); /* threading and cycles disabled */
+ if (rc >= 0) {
+ log_message(usbsid_log, "Starting in read mode");
+ }
+ } else { /* (readmode == 0 || readmode == -1) */
+ /* NOTICE: Digitunes only play with threaded cycles */
+ rc = init_USBSID(usbsid, true, true); /* threading and cycles enabled */
+ if (rc >= 0) {
+ log_message(usbsid_log, "Starting in normal mode");
+ }
+ }
+ if (rc < 0) {
+ return rc;
+ }
+ }
+
+ log_message(usbsid_log, "Set audio mode to %s", (audiomode == 1 ? "Stereo" : "Mono"));
+ setstereo_USBSID(usbsid, (audiomode == 1 ? audiomode : 0));
+
+ usid_alarm = alarm_new(maincpu_alarm_context, "usbsid", usbsid_alarm_handler, NULL);
+ sids_found = getnumsids_USBSID(usbsid);
+ no_sids = 0;
+ log_message(usbsid_log, "Alarm set, reset sids");
+ us_device_reset(false); /* No reset on init! */
+ log_message(usbsid_log, "Opened");
+
+ return rc;
+}
+
+int us_device_close(void)
+{
+ log_message(usbsid_log, "Start device closing");
+ if (usbsid) {
+ mute_USBSID(usbsid);
+ close_USBSID(usbsid);
+ }
+
+ /* Clean up vars */
+ alarm_destroy(usid_alarm);
+ usid_alarm = 0;
+ sids_found = -1;
+ no_sids = -1;
+ rc = -1;
+ usbsid = NULL;
+ log_message(usbsid_log, "Closed");
+ return 0;
+}
+
+int us_device_read(uint16_t addr, int chipno)
+{ /* NOTICE: Disabled, unneeded */
+ if (chipno < US_MAXSID) {
+ addr = ((addr & 0x1F) + (chipno * 0x20));
+ if (readmode == 1) {
+ sid_registers[addr] = read_USBSID(usbsid, addr);
+ }
+ usid_chipno = chipno;
+ return sid_registers[addr];
+ }
+ usid_chipno = -1;
+ return 0x0;
+}
+
+CLOCK us_delay(void)
+{ /* ISSUE: This should return an unsigned 64 bit integer but that makes vice stall indefinately on negative integers */
+ if (maincpu_clk < usid_main_clk) { /* Sync reset */
+ usid_main_clk = maincpu_clk;
+ return 0;
+ }
+ /* Without substracting 1 cycle this
+ * can cause a clicking noise in cycle exact tunes
+ * create audible skips in digitunes like Sky Buster */
+ CLOCK cycles = maincpu_clk - usid_main_clk - 1;
+ while (cycles > 0xffff) {
+ cycles -= 0xffff;
+ }
+ usid_main_clk = maincpu_clk;
+ return cycles;
+}
+
+void us_device_store(uint16_t addr, uint8_t val, int chipno) /* max chipno = 1 */
+{
+ if (chipno < US_MAXSID) { /* remove 0x20 address limitation */
+ addr = ((addr & 0x1F) + (chipno * 0x20));
+ if (readmode == 0) {
+ CLOCK cycles = us_delay();
+ writeringcycled_USBSID(usbsid, addr, val, (uint16_t)cycles);
+ } else if (readmode == 1) {
+ write_USBSID(usbsid, addr, val);
+ }
+ usid_chipno = chipno;
+ sid_registers[addr] = val;
+ return;
+ }
+ usid_chipno = -1;
+ return;
+}
+
+void us_set_machine_parameter(long cycles_per_sec)
+{
+ setclockrate_USBSID(usbsid, cycles_per_sec, true);
+ raster_rate = getrasterrate_USBSID(usbsid);
+ log_message(usbsid_log, "Clockspeed set to: %ld and rasterrate set to: %ld", cycles_per_sec, raster_rate);
+ return;
+}
+
+unsigned int us_device_available(void)
+{
+ log_message(usbsid_log, "%d SIDs available", sids_found);
+ return sids_found;
+}
+
+void us_set_readmode(int val)
+{
+ resources_get_int("SidUSBSIDReadMode", &r_readmode);
+ if (readmode != val) {
+ log_message(usbsid_log, "Set read mode from %d to %d (resource: %d)", readmode, val, r_readmode);
+ readmode = val;
+ if (val == 0) {
+ enablethread_USBSID(usbsid);
+ }
+ if (val == 1) {
+ disablethread_USBSID(usbsid);
+ }
+ }
+ return;
+}
+
+void us_set_audiomode(int val)
+{ /* Gets set by x64sc from SID settings and by VSID at SID file change */
+ resources_get_int("SidUSBSIDAudioMode", &r_audiomode);
+ log_message(usbsid_log, "Audio mode is '%s' (resource:%d val:%d)", (r_audiomode == 1 ? "Stereo" : "Mono"), r_audiomode, val);
+ audiomode = r_audiomode;
+
+ setstereo_USBSID(usbsid, audiomode);
+}
+
+void us_restart_ringbuffer(void)
+{ /* Restarts the ringbuffer with a new value */
+ if (buffsize != d_buffsize) {
+ log_message(usbsid_log, "Restarting ringbuffer with buffer size:%d & diff size:%d", buffsize, diffsize);
+ restartringbuffer_USBSID(usbsid);
+ }
+}
+
+void us_set_buffsize(int val)
+{ /* Set the ringbuffer size */
+ resources_get_int("SidUSBSIDBufferSize", &r_buffsize);
+ buffsize = r_buffsize;
+ if (r_buffsize != d_buffsize) {
+ log_message(usbsid_log, "Setting ringbuffer size to: %d (val:%d default:%d)", buffsize, val, d_buffsize);
+ setbuffsize_USBSID(usbsid, buffsize);
+ us_restart_ringbuffer();
+ }
+}
+
+void us_set_diffsize(int val)
+{ /* Set the ringbuffer head to tail difference size */
+ resources_get_int("SidUSBSIDDiffSize", &r_diffsize);
+ diffsize = r_diffsize;
+ if (r_diffsize != d_diffsize) {
+ log_message(usbsid_log, "Setting ringbuffer diff size to: %d (val:%d default:%d)", diffsize, val, d_diffsize);
+ setdiffsize_USBSID(usbsid, diffsize);
+ }
+
+}
+
+static void usbsid_alarm_handler(CLOCK offset, void *data)
+{
+ CLOCK cycles = (usid_alarm_clk + offset) - usid_main_clk;
+
+ if (cycles < raster_rate) {
+ usid_alarm_clk = usid_main_clk + raster_rate;
+ } else {
+ setflush_USBSID(usbsid);
+ usid_main_clk = maincpu_clk - offset;
+ usid_alarm_clk = usid_main_clk + raster_rate;
+ }
+ alarm_set(usid_alarm, usid_alarm_clk);
+ return;
+}
+
+/* ---------------------------------------------------------------------*/
+
+void us_device_state_read(int chipno, struct sid_us_snapshot_state_s *sid_state)
+{
+ sid_state->usid_main_clk = usid_main_clk;
+ sid_state->usid_alarm_clk = usid_alarm_clk;
+ sid_state->lastaccess_chipno = usid_chipno;
+}
+
+void us_device_state_write(int chipno, struct sid_us_snapshot_state_s *sid_state)
+{
+ usid_main_clk = sid_state->usid_main_clk;
+ usid_alarm_clk = sid_state->usid_alarm_clk;
+ usid_chipno = sid_state->lastaccess_chipno;
+}
+
+#endif /* HAVE_USBSID */
Added: trunk/vice/src/arch/shared/hwsiddrv/us-unixwin.h
===================================================================
--- trunk/vice/src/arch/shared/hwsiddrv/us-unixwin.h (rev 0)
+++ trunk/vice/src/arch/shared/hwsiddrv/us-unixwin.h 2025-09-13 23:30:47 UTC (rev 45758)
@@ -0,0 +1,68 @@
+/*
+ * us-unixwin.h - Linux USBSID specific prototypes.
+ *
+ * Written by
+ * LouDnl <vi...@ma...>
+ *
+ * Based on hs-unix.h written by
+ * Marco van den Heuvel <bla...@ya...>
+ *
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#ifndef VICE_US_UNIXWIN_H
+#define VICE_US_UNIXWIN_H
+
+#include "sid-snapshot.h"
+#include "types.h"
+
+#define US_MAXSID 4
+
+int us_device_open(void);
+
+int us_device_close(void);
+
+void us_device_reset(bool us_reset);
+
+int us_device_read(uint16_t addr, int chipno);
+
+CLOCK us_delay(void);
+
+void us_device_store(uint16_t addr, uint8_t val, int chipno);
+
+void us_set_machine_parameter(long cycles_per_sec);
+
+unsigned int us_device_available(void);
+
+void us_set_readmode(int val);
+
+void us_set_audiomode(int val);
+
+void us_restart_ringbuffer(void);
+
+void us_set_buffsize(int val);
+
+void us_set_diffsize(int val);
+
+void us_device_state_read(int chipno, struct sid_us_snapshot_state_s *sid_state);
+
+void us_device_state_write(int chipno, struct sid_us_snapshot_state_s *sid_state);
+
+#endif /* VICE_US_UNIXWIN_H */
Added: trunk/vice/src/arch/shared/hwsiddrv/usbsid-unixwin-drv.c
===================================================================
--- trunk/vice/src/arch/shared/hwsiddrv/usbsid-unixwin-drv.c (rev 0)
+++ trunk/vice/src/arch/shared/hwsiddrv/usbsid-unixwin-drv.c 2025-09-13 23:30:47 UTC (rev 45758)
@@ -0,0 +1,151 @@
+/*
+ * usbsid-unixwin-drv.c
+ *
+ * Written by
+ * LouDnl <vi...@ma...>
+ *
+ * Based on hs-unix-linux.c written by
+ * Marco van den Heuvel <bla...@ya...>
+ *
+ * This file is part of VICE, the Versatile Commodore Emulator.
+ * See README for copyright notice.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ *
+ */
+
+#include "vice.h"
+
+#ifdef HAVE_USBSID
+
+#include "usbsid.h"
+#include "us-unixwin.h"
+#include "types.h"
+
+static int use_us_device = 0;
+
+int usbsid_drv_open(void)
+{
+ int rc = 0;
+ if (!(rc = us_device_open())) {
+ use_us_device = 1;
+ return 0;
+ }
+
+ return rc;
+}
+
+int usbsid_drv_close(void)
+{
+
+ if (use_us_device) {
+ use_us_device = 0;
+ us_device_close();
+ }
+
+ return 0;
+}
+
+void usbsid_drv_reset(bool us_reset)
+{
+ if (use_us_device) {
+ us_device_reset(us_reset);
+ }
+}
+
+int usbsid_drv_read(uint16_t addr, int chipno)
+{
+ if (use_us_device) {
+ return us_device_read(addr, chipno);
+ }
+
+ return 0;
+}
+
+void usbsid_drv_store(uint16_t addr, uint8_t val, int chipno)
+{
+ if (use_us_device) {
+ us_device_store(addr, val, chipno);
+ }
+}
+
+void usbsid_drv_set_machine_parameter(long cycles_per_sec)
+{
+ if (use_us_device) {
+ us_set_machine_parameter(cycles_per_sec);
+ }
+}
+
+int usbsid_drv_available(void)
+{
+
+ if (use_us_device) {
+ return us_device_available();
+ }
+
+ return 0;
+}
+
+void usbsid_drv_set_readmode(int val)
+{
+ if (use_us_device) {
+ us_set_readmode(val);
+ }
+}
+
+void usbsid_drv_set_audiomode(int val)
+{
+ if (use_us_device) {
+ us_set_audiomode(val);
+ }
+}
+
+void usbsid_drv_restart_ringbuffer(void)
+{
+ if (use_us_device) {
+ us_restart_ringbuffer();
+ }
+}
+
+void usbsid_drv_set_buffsize(int val)
+{
+ if (use_us_device) {
+ us_set_buffsize(val);
+ }
+}
+
+void usbsid_drv_set_diffsize(int val)
+{
+ if (use_us_device) {
+ us_set_diffsize(val);
+ }
+}
+
+void usbsid_drv_state_read(int chipno, struct sid_us_snapshot_state_s *sid_state)
+{
+ if (use_us_device) {
+ us_device_state_read(chipno, sid_state);
+ }
+}
+
+void usbsid_drv_state_write(int chipno, struct sid_us_snapshot_state_s *sid_state)
+{
+ if (use_us_device) {
+ us_device_state_write(chipno, sid_state);
+ }
+}
+
+#endif /* HAVE_USBSID */
Modified: trunk/vice/src/lib/Makefile.am
===================================================================
--- trunk/vice/src/lib/Makefile.am 2025-09-13 11:58:55 UTC (rev 45757)
+++ trunk/vice/src/lib/Makefile.am 2025-09-13 23:30:47 UTC (rev 45758)
@@ -1,5 +1,9 @@
SUBDIRS = p64 linenoise-ng libzmbv md5
+if HAVE_USBSID
+SUBDIRS += libusbsiddrv
+endif
+
AM_CFLAGS = @VICE_CFLAGS@
AM_CXXFLAGS = @VICE_CXXFLAGS@
@@ -16,3 +20,9 @@
libzmbv:
(cd libzmbv; $(MAKE))
+
+.PHONY: libusbsiddrv
+if HAVE_USBSID
+libusbsiddrv:
+ (cd libusbsiddrv; $(MAKE))
+endif
Added: trunk/vice/src/lib/libusbsiddrv/LICENSE
===================================================================
--- trunk/vice/src/lib/libusbsiddrv/LICENSE (rev 0)
+++ trunk/vice/src/lib/libusbsiddrv/LICENSE 2025-09-13 23:30:47 UTC (rev 45758)
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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.
+
+Also add informati...
[truncated message content] |