aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/fmopl.h4
-rw-r--r--audio/softsynth/opl/dosbox.cpp27
2 files changed, 24 insertions, 7 deletions
diff --git a/audio/fmopl.h b/audio/fmopl.h
index 323cc3d028..ad1794d873 100644
--- a/audio/fmopl.h
+++ b/audio/fmopl.h
@@ -129,7 +129,9 @@ public:
/**
* Function to directly write to a specific OPL register.
- * This writes to *both* chips for a Dual OPL2.
+ * This writes to *both* chips for a Dual OPL2. We allow
+ * writing to secondary OPL registers by using register
+ * values >= 0x100.
*
* @param r hardware register number to write to
* @param v value, which will be written
diff --git a/audio/softsynth/opl/dosbox.cpp b/audio/softsynth/opl/dosbox.cpp
index e039845b8f..a1a736f9de 100644
--- a/audio/softsynth/opl/dosbox.cpp
+++ b/audio/softsynth/opl/dosbox.cpp
@@ -247,7 +247,7 @@ byte OPL::read(int port) {
}
void OPL::writeReg(int r, int v) {
- byte tempReg = 0;
+ int tempReg = 0;
switch (_type) {
case Config::kOpl2:
case Config::kDualOpl2:
@@ -257,12 +257,27 @@ void OPL::writeReg(int r, int v) {
// Backup old setup register
tempReg = _reg.normal;
- // We need to set the register we want to write to via port 0x388
- write(0x388, r);
- // Do the real writing to the register
- write(0x389, v);
+ // We directly allow writing to secondary OPL3 registers by using
+ // register values >= 0x100.
+ if (_type == Config::kOpl3 && r >= 0x100) {
+ // We need to set the register we want to write to via port 0x222,
+ // since we want to write to the secondary register set.
+ write(0x222, r);
+ // Do the real writing to the register
+ write(0x223, v);
+ } else {
+ // We need to set the register we want to write to via port 0x388
+ write(0x388, r);
+ // Do the real writing to the register
+ write(0x389, v);
+ }
+
// Restore the old register
- write(0x388, tempReg);
+ if (_type == Config::kOpl3 && tempReg >= 0x100) {
+ write(0x222, tempReg & ~0x100);
+ } else {
+ write(0x388, tempReg);
+ }
break;
};
}