diff options
author | Johannes Schickel | 2012-10-01 01:50:23 +0200 |
---|---|---|
committer | Johannes Schickel | 2012-10-01 01:50:23 +0200 |
commit | 1c024519d538c34431362678c925ea99958ddb6b (patch) | |
tree | dc5f27b8b38ec2e4023163bb6684954bc58e2a39 /audio/softsynth/opl/dosbox.cpp | |
parent | 04baadcf7a205b3da7b830463f2189b4e018330f (diff) | |
download | scummvm-rg350-1c024519d538c34431362678c925ea99958ddb6b.tar.gz scummvm-rg350-1c024519d538c34431362678c925ea99958ddb6b.tar.bz2 scummvm-rg350-1c024519d538c34431362678c925ea99958ddb6b.zip |
AUDIO: Add easy way to write to OPL3's secondary register set.
Diffstat (limited to 'audio/softsynth/opl/dosbox.cpp')
-rw-r--r-- | audio/softsynth/opl/dosbox.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
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; }; } |