Skip to content

Commit

Permalink
SudoMakers RetroWave OPL3 Express.
Browse files Browse the repository at this point in the history
* We do not set baud-rate, not needed for RetroWave OPL3 Express atleast
* We use register-reset instead of PIN reset, avoids clicking sound
* OS X El Capitan (10.11.6) and possible other MacOS versions have a bug in USB driver, so on __APPLE__ we always enforce work-around
* Setup dialog via setup:/adplugconfig.dev
* Linux, with detection
* mingw, with detection
* MacOS, with detection
* BSD, no detection due to no API to read out mapping between /dev/cuaU* /dev/dtyU*, does not appear in `lsusb -v`
* Haiku, no detection, due to no API to read out mapping between /dev/ports, does not appear in `listusb -v` or in `listdev -d`

Not implemented due to lack of hardware:
* Raspberry PI + SPI (RetroWave OPL3 HAT)
  • Loading branch information
mywave82 committed Jul 30, 2023
1 parent 47e39dc commit b9b5a9f
Show file tree
Hide file tree
Showing 16 changed files with 2,306 additions and 199 deletions.
18 changes: 13 additions & 5 deletions boot/pmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,17 @@ static int init_modules(int argc, char *argv[])
cfSetProfileInt ("fscolors", "VGM", 13, 10);
}

if (epoch < 20230607)
if (epoch < 20230630)
{
fprintf(stderr, "ocp.ini update (0.2.106), added [adplug] retrowave support\n");
cfSetProfileComment ("adplug", "emulator", "; Possible values are ken, nuked, satoh, woody and retrowave.");
cfSetProfileString ("adplug", "retrowave", "auto");
cfSetProfileComment ("adplug", "retrowave", "; Device to use, e.g. /dev/ttyACM0 /dev/cuaU0 /dev/dtyU0 /dev/cu.usbmodem0000001 COM1");
}

if (epoch < 20230630)
{
cfSetProfileInt("version", "epoch", 20230607, 10);
cfSetProfileInt("version", "epoch", 20230630, 10);
cfStoreConfig();
if (isatty(2))
{
Expand All @@ -1009,13 +1017,13 @@ static int init_modules(int argc, char *argv[])
sleep(5);
}
}
if (cfGetProfileInt("version", "epoch", 0, 10) != 20230607)
if (cfGetProfileInt("version", "epoch", 0, 10) != 20230630)
{
if (isatty(2))
{
fprintf(stderr,"\n\033[1m\033[31mWARNING, ocp.ini [version] epoch != 20230607\033[0m\n\n");
fprintf(stderr,"\n\033[1m\033[31mWARNING, ocp.ini [version] epoch != 20230630\033[0m\n\n");
} else {
fprintf(stderr,"\nWARNING, ocp.ini [version] epoch != 20230607\n\n");
fprintf(stderr,"\nWARNING, ocp.ini [version] epoch != 20230630\n\n");
}
sleep(5);
}
Expand Down
2 changes: 2 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@

#undef HAVE_FCNTL_H

#undef HAVE_GRP_H

#undef HAVE_NDIR_H

#undef HAVE_SYS_NDIR_H
Expand Down
7 changes: 7 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -8609,6 +8609,13 @@ then :

fi

ac_fn_c_check_header_compile "$LINENO" "grp.h" "ac_cv_header_grp_h" "$ac_includes_default"
if test "x$ac_cv_header_grp_h" = xyes
then :
printf "%s\n" "#define HAVE_GRP_H 1" >>confdefs.h

fi

ac_fn_c_check_header_compile "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default"
if test "x$ac_cv_header_getopt_h" = xyes
then :
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ AC_SUBST(HAVE_SYS_STAT_H)
AC_SUBST(HAVE_SYS_TYPES_H)
AC_CHECK_HEADER([dirent.h], [AC_DEFINE(HAVE_DIRENT_H, 1)], [])
AC_CHECK_HEADER([fcntl.h], [AC_DEFINE(HAVE_FCNTL_H, 1)], [])
AC_CHECK_HEADER([grp.h], [AC_DEFINE(HAVE_GRP_H, 1)], [])
AC_CHECK_HEADER([getopt.h], [AC_DEFINE(HAVE_GETOPT_H, 1)] HAVE_GETOPT_H=1, [])
AC_CHECK_HEADER([ndir.h], [AC_DEFINE(HAVE_NDIR_H, 1)], [])
AC_CHECK_HEADER([sys/io], HAVE_SYS_IO_H=1, [])
Expand Down
6 changes: 4 additions & 2 deletions ocp.ini.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[version]
epoch=20230607
epoch=20230630

[general]
;link=
Expand Down Expand Up @@ -140,11 +140,13 @@
chargen=CHARGEN.ROM

[adplug]
emulator=nuked ; Possible values are ken, nuked, satoh and woody.
emulator=nuked ; Possible values are ken, nuked, satoh woody and retrowave.
; Ken is a dual OPL2 emulator based on Ken Silverman OPL2 emulator
; Nuked is a bit-perfect OPL3 emulator made by Nuke.YKT based on die shots.
; Satoh is a dual OPL2 emulator based on code by Tatsuyuki Satoh by the MAME Team.
; Woody is an OPL3 emulator by the DOSBox Team. It is a further development of Ken Silverman OPL2 emulator.
; RetroWave OPL3 [Express] is an external USB device with real OPL3 hardware made by SudoMaker.
retrowave=auto ; Device to use, e.g. /dev/ttyACM0 /dev/cuaU0 /dev/dtyU0 /dev/cu.usbmodem0000001 COM1

[devpALSA]
card=default
Expand Down
24 changes: 20 additions & 4 deletions playopl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ uninstall:
rm -f "$(DESTDIR)$(LIBDIROCP)/autoload/95-playopl$(LIB_SUFFIX)"
rm -f "$(DESTDIR)$(DATADIROCP)/data/adplug.db"

oplconfig.o: oplconfig.c \
oplconfig.o: oplconfig.cpp \
../config.h \
../types.h \
../boot/plinkman.h \
Expand All @@ -68,9 +68,12 @@ oplconfig.o: oplconfig.c \
../filesel/filesystem-setup.h \
../filesel/pfilesel.h \
../playopl/oplconfig.h \
../playopl/oplplay.h \
../playopl/oplRetroWave.h \
../stuff/err.h \
../stuff/piperun.h \
../stuff/poutput.h
$(CC) $(CFLAGS) $< -o $@ -c
$(ADPLUG_CXX) $(ADPLUG_CXXFLAGS) $< -o $@ -c

oplKen.o: oplKen.cpp \
../config.h \
Expand All @@ -88,6 +91,16 @@ oplNuked.o: oplNuked.cpp \
ocpemu.h
$(ADPLUG_CXX) $(ADPLUG_CXXFLAGS) $< -o $@ -c

oplRetroWave.o: \
oplRetroWave.cpp \
oplRetroWave-serialization.cpp \
oplRetroWave-helperthread.cpp \
oplRetroWave.h \
../config.h \
../types.h \
../cpiface/cpiface.h
$(ADPLUG_CXX) $(ADPLUG_CXXFLAGS) $< -o $@ -c

oplSatoh.o: oplSatoh.cpp \
oplSatoh.h \
adplug-git/src/opl.h \
Expand Down Expand Up @@ -117,7 +130,7 @@ opltype.o: opltype.cpp \
opltype.h
$(ADPLUG_CXX) $(ADPLUG_CXXFLAGS) opltype.cpp -o $@ -c

playopl_so=oplconfig.o oplchan.o oplpplay.o oplplay.o oplptrak.o ocpemu.o oplKen.o oplNuked.o oplSatoh.o oplWoody.o opltype.o $(LIBBINIO_TARGETS) $(LIBADPLUG_TARGETS)
playopl_so=oplconfig.o oplchan.o oplpplay.o oplplay.o oplptrak.o ocpemu.o oplKen.o oplNuked.o oplRetroWave.o oplSatoh.o oplWoody.o opltype.o $(LIBBINIO_TARGETS) $(LIBADPLUG_TARGETS)
playopl$(LIB_SUFFIX): $(playopl_so)
$(ADPLUG_CXX) $(ADPLUG_CXXFLAGS) $(SHARED_FLAGS) $(LDFLAGS) -o $@ $^ $(ADPLUG_LIBS) $(MATH_LIBS)

Expand Down Expand Up @@ -163,10 +176,12 @@ oplplay.o: oplplay.cpp \
../filesel/dirdb.h \
../filesel/filesystem.h \
../stuff/imsrtns.h \
oplconfig.h \
oplplay.h \
ocpemu.h \
oplKen.h \
oplNuked.h \
oplRetroWave.h \
oplSatoh.h \
oplWoody.h \
oplptrak.h
Expand All @@ -183,7 +198,8 @@ oplptrak.o: oplptrak.cpp \
ocpemu.o: ocpemu.cpp \
../config.h \
../types.h \
ocpemu.h
ocpemu.h \
oplRetroWave.h
$(ADPLUG_CXX) $(ADPLUG_CXXFLAGS) ocpemu.cpp -o $@ -c

adplugdb_adplugdb.o: \
Expand Down
9 changes: 7 additions & 2 deletions playopl/ocpemu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "config.h"
#include "types.h"
#include "ocpemu.h"
#include "oplRetroWave.h"
#include <stdint.h>
#include <string.h>

Expand Down Expand Up @@ -125,7 +126,7 @@ static const int8_t channel_to_operator_four_operator[18][4]
};
#endif

Cocpemu::Cocpemu(Copl *realopl, int rate) : realopl(realopl)
Cocpemu::Cocpemu(Copl *realopl, int rate, int isRetroWave) : realopl(realopl), isRetroWave(isRetroWave)
{ /* these rates does not take KSR (Envelope Scaling) into the processing, but works well enough for channel statuses */
steprate[ 0] = 0; // fixed for-ever
steprate[ 1] = (((uint_fast32_t)65536) * 64000) / (rate * 1132) + 1;
Expand Down Expand Up @@ -230,7 +231,7 @@ void Cocpemu::update_op (const int ch, const int o, unsigned int samples)

}

void Cocpemu::update(short *buf, int samples)
void Cocpemu::update(short *buf, int samples, uint32_t ratescale)
{
int ch, o;
for (ch=0; ch < 18; ch++)
Expand All @@ -241,6 +242,10 @@ void Cocpemu::update(short *buf, int samples)
}
}

if (isRetroWave)
{
((oplRetroWave *)realopl)->ratescale = ratescale;
}
realopl->update(buf, samples);
}

Expand Down
10 changes: 8 additions & 2 deletions playopl/ocpemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define H_ADPLUG_OCPOPL

#include "adplug-git/src/opl.h"
#include <stdio.h>
#include <stdint.h>

struct op_status
Expand Down Expand Up @@ -96,11 +97,16 @@ struct oplStatus
class Cocpemu : public Copl
{
Copl *realopl;
int isRetroWave;
public:
Cocpemu(Copl *realopl, int rate); // rate = sample rate
Cocpemu(Copl *realopl, int rate, int isRetroWave); // rate = sample rate
virtual ~Cocpemu();

void update(short *buf, int samples); // fill buffer
void update(short *buf, int samples)
{
fprintf (stderr, "Warning, OCP should use update with 3 parameters\n");
}
virtual void update(short *buf, int samples, uint32_t ratescale); // fill buffer
void setchip(int n);

// template methods
Expand Down
Loading

0 comments on commit b9b5a9f

Please sign in to comment.