aboutsummaryrefslogtreecommitdiff
path: root/sound/softsynth
diff options
context:
space:
mode:
authorAlejandro Marzini2010-08-16 00:21:07 +0000
committerAlejandro Marzini2010-08-16 00:21:07 +0000
commitb0409d673921163085d2e2fa440911080a7cf884 (patch)
tree81b1bb895db6baed7881ca5cbc7ff3a830286189 /sound/softsynth
parent503578ac1087b91dcb912fd7918454de73538b34 (diff)
parentb49761b6eae3a0aadefef4c4ffee6a7b583cc3ac (diff)
downloadscummvm-rg350-b0409d673921163085d2e2fa440911080a7cf884.tar.gz
scummvm-rg350-b0409d673921163085d2e2fa440911080a7cf884.tar.bz2
scummvm-rg350-b0409d673921163085d2e2fa440911080a7cf884.zip
Merge trunk, from r51777 to r52105
svn-id: r52108
Diffstat (limited to 'sound/softsynth')
-rw-r--r--sound/softsynth/appleiigs.cpp57
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_audio.cpp102
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_audio.h16
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_euphony.cpp20
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_euphony.h12
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp49
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h1
-rw-r--r--sound/softsynth/sid.cpp31
8 files changed, 200 insertions, 88 deletions
diff --git a/sound/softsynth/appleiigs.cpp b/sound/softsynth/appleiigs.cpp
new file mode 100644
index 0000000000..9004d1f0ab
--- /dev/null
+++ b/sound/softsynth/appleiigs.cpp
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* 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.
+*
+* $URL$
+* $Id$
+*
+*/
+
+#include "sound/null.h"
+
+// Plugin interface
+// (This can only create a null driver since apple II gs support seeems not to be implemented
+// and also is not part of the midi driver architecture. But we need the plugin for the options
+// menu in the launcher and for MidiDriver::detectDevice() which is more or less used by all engines.)
+
+class AppleIIGSMusicPlugin : public NullMusicPlugin {
+public:
+ const char *getName() const {
+ return _s("Apple II GS Emulator (NOT IMPLEMENTED)");
+ }
+
+ const char *getId() const {
+ return "appleIIgs";
+ }
+
+ MusicDevices getDevices() const;
+};
+
+MusicDevices AppleIIGSMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_APPLEIIGS));
+ return devices;
+}
+
+//#if PLUGIN_ENABLED_DYNAMIC(APPLEIIGS)
+ //REGISTER_PLUGIN_DYNAMIC(APPLEIIGS, PLUGIN_TYPE_MUSIC, AppleIIGSMusicPlugin);
+//#else
+ REGISTER_PLUGIN_STATIC(APPLEIIGS, PLUGIN_TYPE_MUSIC, AppleIIGSMusicPlugin);
+//#endif
+
diff --git a/sound/softsynth/fmtowns_pc98/towns_audio.cpp b/sound/softsynth/fmtowns_pc98/towns_audio.cpp
index f09c5d8851..e74991a55f 100644
--- a/sound/softsynth/fmtowns_pc98/towns_audio.cpp
+++ b/sound/softsynth/fmtowns_pc98/towns_audio.cpp
@@ -103,7 +103,7 @@ TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfac
_fmInstruments(0), _pcmInstruments(0), _pcmChan(0), _waveTables(0), _waveTablesTotalDataSize(0),
_baserate(55125.0f / (float)mixer->getOutputRate()), _tickLength(0), _timer(0), _drv(driver),
_pcmSfxChanMask(0), _musicVolume(Audio::Mixer::kMaxMixerVolume), _sfxVolume(Audio::Mixer::kMaxMixerVolume),
- _cdaVolFlags(0), _ready(false) {
+ _outputVolumeFlags(0), _outputMuteFlags(0), _ready(false) {
#define INTCB(x) &TownsAudioInterface::intf_##x
static const TownsAudioIntfCallback intfCb[] = {
@@ -191,11 +191,11 @@ TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfac
INTCB(notImpl),
INTCB(notImpl),
INTCB(notImpl),
- INTCB(cdaSetVolume),
+ INTCB(setOutputVolume),
// 68
- INTCB(cdaReset),
- INTCB(notImpl),
+ INTCB(resetOutputVolume),
INTCB(notImpl),
+ INTCB(updateOutputVolume),
INTCB(notImpl),
// 72
INTCB(notImpl),
@@ -217,6 +217,8 @@ TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfac
_intfOpcodes = intfCb;
memset(_fmSaveReg, 0, sizeof(_fmSaveReg));
+ memset(_outputLevel, 0, sizeof(_outputLevel));
+
_timerBase = (uint32)(_baserate * 1000000.0f);
_tickLength = 2 * _timerBase;
}
@@ -285,7 +287,7 @@ void TownsAudioInterface::setSoundEffectVolume(int volume) {
setVolumeIntern(_musicVolume, _sfxVolume);
}
-void TownsAudioInterface::setSoundEffectChanMask(uint32 mask) {
+void TownsAudioInterface::setSoundEffectChanMask(int mask) {
_pcmSfxChanMask = mask >> 6;
mask &= 0x3f;
setVolumeChannelMasks(~mask, mask);
@@ -297,8 +299,8 @@ void TownsAudioInterface::nextTickEx(int32 *buffer, uint32 bufferSize) {
for (uint32 i = 0; i < bufferSize; i++) {
_timer += _tickLength;
- while (_timer > 0x5B8D80) {
- _timer -= 0x5B8D80;
+ while (_timer > 0x514767) {
+ _timer -= 0x514767;
for (int ii = 0; ii < 8; ii++) {
if ((_pcmChanKeyPlaying & _chanFlags[ii]) || (_pcmChanEffectPlaying & _chanFlags[ii])) {
@@ -357,10 +359,9 @@ void TownsAudioInterface::timerCallbackB() {
}
int TownsAudioInterface::intf_reset(va_list &args) {
- Common::StackLock lock(_mutex);
fmReset();
pcmReset();
- cdaReset();
+ callback(68);
return 0;
}
@@ -707,56 +708,59 @@ int TownsAudioInterface::intf_fmReset(va_list &args) {
return 0;
}
-int TownsAudioInterface::intf_cdaReset(va_list &args) {
- cdaReset();
- return 0;
-}
-
-int TownsAudioInterface::intf_pcmUpdateEnvelopeGenerator(va_list &args) {
- for (int i = 0; i < 8; i++)
- pcmUpdateEnvelopeGenerator(i);
- return 0;
-}
-
-int TownsAudioInterface::intf_cdaSetVolume(va_list &args) {
- int mode = va_arg(args, int);
+int TownsAudioInterface::intf_setOutputVolume(va_list &args) {
+ int chanType = va_arg(args, int);
int left = va_arg(args, int);
int right = va_arg(args, int);
- // calculate mixer balance value
- int8 balance = right - left;
-
if (left & 0xff80 || right & 0xff80)
return 3;
static const uint8 flags[] = { 0x0C, 0x30, 0x40, 0x80 };
- //int a = (mode & 0x40) ? 4 : 0;
- int b = mode & 3;
+ uint8 chan = (chanType & 0x40) ? 8 : 12;
+
+ chanType &= 3;
left = (left & 0x7e) >> 1;
right = (right & 0x7e) >> 1;
- if (mode & 0x40)
- _cdaVolFlags |= flags[b];
+ if (chan)
+ _outputVolumeFlags |= flags[chanType];
else
- _cdaVolFlags &= ~flags[b];
+ _outputVolumeFlags &= ~flags[chanType];
- if (mode > 1) {
- // Unknown purpose / TODO
+ if (chanType > 1) {
+ _outputLevel[chan + chanType] = left;
+ } else {
+ if (chanType == 0)
+ chan -= 8;
+ _outputLevel[chan] = left;
+ _outputLevel[chan + 1] = right;
+ }
- } else if (mode == 1) {
- // FM Towns seems to support volumes of 0 - 63 for each channel.
- // We recalculate sane values for out 0 to 255 volume range.
+ updateOutputVolume();
- int vl = (int)(((float)left * 255.0f) / 63.0f);
- int vr = (int)(((float)right * 255.0f) / 63.0f);
- g_system->getAudioCDManager()->setVolume((vl + vr) >> 1);
- g_system->getAudioCDManager()->setBalance(balance);
+ return 0;
+}
- } else {
- // Unknown purpose / TODO
- }
+int TownsAudioInterface::intf_resetOutputVolume(va_list &args) {
+ memset(_outputLevel, 0, sizeof(_outputLevel));
+ _outputMuteFlags = 0;
+ _outputVolumeFlags = 0;
+ updateOutputVolume();
+ return 0;
+}
+int TownsAudioInterface::intf_updateOutputVolume(va_list &args) {
+ int flags = va_arg(args, int);
+ _outputMuteFlags = flags & 3;
+ updateOutputVolume();
+ return 0;
+}
+
+int TownsAudioInterface::intf_pcmUpdateEnvelopeGenerator(va_list &args) {
+ for (int i = 0; i < 8; i++)
+ pcmUpdateEnvelopeGenerator(i);
return 0;
}
@@ -1381,8 +1385,16 @@ void TownsAudioInterface::pcmCalcPhaseStep(TownsAudio_PcmChannel *p, TownsAudio_
p->step = (s * p->stepPitch) >> 14;
}
-void TownsAudioInterface::cdaReset() {
-
+void TownsAudioInterface::updateOutputVolume() {
+ // FM Towns seems to support volumes of 0 - 63 for each channel.
+ // We recalculate sane values for our 0 to 255 volume range and
+ // balance values for our -128 to 127 volume range
+
+ // CD-AUDIO
+ int volume = (int)(((float)MAX(_outputLevel[12], _outputLevel[13]) * 255.0f) / 63.0f);
+ int balance = (int)((float)((_outputLevel[13] - _outputLevel[12]) * 127.0f) / (float)MAX(_outputLevel[12], _outputLevel[13]));
+ g_system->getAudioCDManager()->setVolume(volume);
+ g_system->getAudioCDManager()->setBalance(balance);
}
const uint8 TownsAudioInterface::_chanFlags[] = {
@@ -1456,7 +1468,7 @@ void TownsAudio_PcmChannel::clear() {
stepNote = 0x4000;
stepPitch = 0x4000;
- panLeft = panRight = 0;
+ panLeft = panRight = 7;
envTotalLevel = envAttackRate = envDecayRate = envSustainLevel = envSustainRate = envReleaseRate = 0;
envStep = envCurrentLevel = 0;
diff --git a/sound/softsynth/fmtowns_pc98/towns_audio.h b/sound/softsynth/fmtowns_pc98/towns_audio.h
index 212c00c40f..950c016b4e 100644
--- a/sound/softsynth/fmtowns_pc98/towns_audio.h
+++ b/sound/softsynth/fmtowns_pc98/towns_audio.h
@@ -50,7 +50,7 @@ public:
void setSoundEffectVolume(int volume);
// Defines the channels used as sound effect channels for the purpose of ScummVM GUI volume control.
// The first 6 bits are the 6 fm channels. The next 8 bits are pcm channels.
- void setSoundEffectChanMask(uint32 mask);
+ void setSoundEffectChanMask(int mask);
private:
void nextTickEx(int32 *buffer, uint32 bufferSize);
@@ -92,8 +92,9 @@ private:
int intf_fmSetPitch(va_list &args);
int intf_fmSetLevel(va_list &args);
int intf_fmReset(va_list &args);
- int intf_cdaSetVolume(va_list &args);
- int intf_cdaReset(va_list &args);
+ int intf_setOutputVolume(va_list &args);
+ int intf_resetOutputVolume(va_list &args);
+ int intf_updateOutputVolume(va_list &args);
int intf_pcmUpdateEnvelopeGenerator(va_list &args);
int intf_notImpl(va_list &args);
@@ -148,9 +149,10 @@ private:
void pcmCalcPhaseStep(TownsAudio_PcmChannel *p, TownsAudio_WaveTable *w);
- void cdaReset();
-
- uint8 _cdaVolFlags;
+ void updateOutputVolume();
+ uint8 _outputVolumeFlags;
+ uint8 _outputLevel[16];
+ uint8 _outputMuteFlags;
const float _baserate;
uint32 _timerBase;
@@ -159,7 +161,7 @@ private:
uint16 _musicVolume;
uint16 _sfxVolume;
- uint32 _pcmSfxChanMask;
+ int _pcmSfxChanMask;
TownsAudioInterfacePluginDriver *_drv;
bool _ready;
diff --git a/sound/softsynth/fmtowns_pc98/towns_euphony.cpp b/sound/softsynth/fmtowns_pc98/towns_euphony.cpp
index e23d5bcb36..0c0c203cc9 100644
--- a/sound/softsynth/fmtowns_pc98/towns_euphony.cpp
+++ b/sound/softsynth/fmtowns_pc98/towns_euphony.cpp
@@ -180,6 +180,10 @@ void TownsEuphonyDriver::stopParser() {
}
}
+void TownsEuphonyDriver::continueParsing() {
+ _suspendParsing = false;
+}
+
void TownsEuphonyDriver::playSoundEffect(int chan, int note, int velo, const uint8 *data) {
_intf->callback(37, chan, note, velo, data);
}
@@ -204,7 +208,7 @@ void TownsEuphonyDriver::chanVolume(int chan, int vol) {
_intf->callback(8, chan, vol);
}
-void TownsEuphonyDriver::cdaSetVolume(int mode, int volLeft, int volRight) {
+void TownsEuphonyDriver::setOutputVolume(int mode, int volLeft, int volRight) {
_intf->callback(67, mode, volLeft, volRight);
}
@@ -230,7 +234,7 @@ int TownsEuphonyDriver::chanOrdr(int tableEntry, int val) {
return 0;
}
-int TownsEuphonyDriver::chanLevel(int tableEntry, int val) {
+int TownsEuphonyDriver::chanVolumeShift(int tableEntry, int val) {
if (tableEntry > 31)
return 3;
if (val <= 40)
@@ -238,7 +242,7 @@ int TownsEuphonyDriver::chanLevel(int tableEntry, int val) {
return 0;
}
-int TownsEuphonyDriver::chanTranspose(int tableEntry, int val) {
+int TownsEuphonyDriver::chanNoteShift(int tableEntry, int val) {
if (tableEntry > 31)
return 3;
if (val <= 40)
@@ -660,8 +664,8 @@ bool TownsEuphonyDriver::evtSetupNote() {
uint8 velo = _musicPos[5];
sendEvent(mode, evt);
- sendEvent(mode, prepTranspose(note));
- sendEvent(mode, prepVelo(velo));
+ sendEvent(mode, applyNoteShift(note));
+ sendEvent(mode, applyVolumeShift(velo));
jumpNextLoop();
if (_musicPos[0] == 0xfe || _musicPos[0] == 0xfd)
@@ -700,7 +704,7 @@ bool TownsEuphonyDriver::evtPolyphonicAftertouch() {
uint8 mode = _tMode[_musicPos[1]];
sendEvent(mode, evt);
- sendEvent(mode, prepTranspose(_musicPos[4]));
+ sendEvent(mode, applyNoteShift(_musicPos[4]));
sendEvent(mode, _musicPos[5]);
return false;
@@ -768,7 +772,7 @@ bool TownsEuphonyDriver::evtModeOrdrChange() {
return false;
}
-uint8 TownsEuphonyDriver::prepTranspose(uint8 in) {
+uint8 TownsEuphonyDriver::applyNoteShift(uint8 in) {
int out = _tTranspose[_musicPos[1]];
if (!out)
return in;
@@ -783,7 +787,7 @@ uint8 TownsEuphonyDriver::prepTranspose(uint8 in) {
return out & 0xff;
}
-uint8 TownsEuphonyDriver::prepVelo(uint8 in) {
+uint8 TownsEuphonyDriver::applyVolumeShift(uint8 in) {
int out = _tLevel[_musicPos[1]];
out += (in & 0x7f);
out = CLIP(out, 1, 127);
diff --git a/sound/softsynth/fmtowns_pc98/towns_euphony.h b/sound/softsynth/fmtowns_pc98/towns_euphony.h
index 2026a299c1..fa1f8ba496 100644
--- a/sound/softsynth/fmtowns_pc98/towns_euphony.h
+++ b/sound/softsynth/fmtowns_pc98/towns_euphony.h
@@ -45,6 +45,8 @@ public:
int startMusicTrack(const uint8 *data, int trackSize, int startTick);
void setMusicLoop(bool loop);
void stopParser();
+ bool parserIsPlaying() {return _playing; }
+ void continueParsing();
void playSoundEffect(int chan, int note, int velo, const uint8 *data);
void stopSoundEffect(int chan);
@@ -54,13 +56,13 @@ public:
void chanPitch(int chan, int pitch);
void chanVolume(int chan, int vol);
- void cdaSetVolume(int mode, int volLeft, int volRight);
+ void setOutputVolume(int chanType, int volLeft, int volRight);
int chanEnable(int tableEntry, int val);
int chanMode(int tableEntry, int val);
int chanOrdr(int tableEntry, int val);
- int chanLevel(int tableEntry, int val);
- int chanTranspose(int tableEntry, int val);
+ int chanVolumeShift(int tableEntry, int val);
+ int chanNoteShift(int tableEntry, int val);
int assignChannel(int chan, int tableEntry);
@@ -112,8 +114,8 @@ private:
return false;
}
- uint8 prepTranspose(uint8 in);
- uint8 prepVelo(uint8 in);
+ uint8 applyNoteShift(uint8 in);
+ uint8 applyVolumeShift(uint8 in);
void sendNoteOff();
void sendNoteOn();
diff --git a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
index 507c8e159a..241b9bde50 100644
--- a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
+++ b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
@@ -28,7 +28,7 @@
class TownsPC98_FmSynthOperator {
public:
- TownsPC98_FmSynthOperator(const uint32 timerbase, const uint8 *rateTable,
+ TownsPC98_FmSynthOperator(const uint32 timerbase, const uint32 rtt, const uint8 *rateTable,
const uint8 *shiftTable, const uint8 *attackDecayTable, const uint32 *frqTable,
const uint32 *sineTable, const int32 *tlevelOut, const int32 *detuneTable);
~TownsPC98_FmSynthOperator() {}
@@ -108,6 +108,7 @@ protected:
const uint32 _tickLength;
uint32 _timer;
+ const uint32 _rtt;
int32 _currentLevel;
struct EvpState {
@@ -116,10 +117,10 @@ protected:
} fs_a, fs_d, fs_s, fs_r;
};
-TownsPC98_FmSynthOperator::TownsPC98_FmSynthOperator(const uint32 timerbase, const uint8 *rateTable,
- const uint8 *shiftTable, const uint8 *attackDecayTable, const uint32 *frqTable,
- const uint32 *sineTable, const int32 *tlevelOut, const int32 *detuneTable) :
- _rateTbl(rateTable), _rshiftTbl(shiftTable), _adTbl(attackDecayTable), _fTbl(frqTable),
+TownsPC98_FmSynthOperator::TownsPC98_FmSynthOperator(const uint32 timerbase, const uint32 rtt,
+ const uint8 *rateTable, const uint8 *shiftTable, const uint8 *attackDecayTable,
+ const uint32 *frqTable, const uint32 *sineTable, const int32 *tlevelOut, const int32 *detuneTable) :
+ _rtt(rtt), _rateTbl(rateTable), _rshiftTbl(shiftTable), _adTbl(attackDecayTable), _fTbl(frqTable),
_sinTbl(sineTable), _tLvlTbl(tlevelOut), _detnTbl(detuneTable), _tickLength(timerbase * 2),
_specifiedAttackRate(0), _specifiedDecayRate(0), _specifiedReleaseRate(0), _specifiedSustainRate(0),
_phase(0), _state(kEnvReady), _playing(false), _timer(0), _keyScale1(0),
@@ -190,8 +191,8 @@ void TownsPC98_FmSynthOperator::generateOutput(int32 phasebuf, int32 *feed, int3
return;
_timer += _tickLength;
- while (_timer > 0x5B8D80) {
- _timer -= 0x5B8D80;
+ while (_timer > _rtt) {
+ _timer -= _rtt;
++_tickCount;
int32 levelIncrement = 0;
@@ -308,7 +309,7 @@ bool TownsPC98_FmSynthOperator::scaleRate(uint8 value) {
class TownsPC98_FmSynthSquareSineSource {
public:
- TownsPC98_FmSynthSquareSineSource(const uint32 timerbase);
+ TownsPC98_FmSynthSquareSineSource(const uint32 timerbase, const uint32 rtt);
~TownsPC98_FmSynthSquareSineSource();
void init(const int *rsTable, const int *rseTable);
@@ -351,6 +352,7 @@ private:
const uint32 _tickLength;
uint32 _timer;
+ const uint32 _rtt;
struct Channel {
int tick;
@@ -377,7 +379,7 @@ private:
class TownsPC98_FmSynthPercussionSource {
public:
- TownsPC98_FmSynthPercussionSource(const uint32 timerbase);
+ TownsPC98_FmSynthPercussionSource(const uint32 timerbase, const uint32 rtt);
~TownsPC98_FmSynthPercussionSource() {
delete[] _reg;
}
@@ -429,6 +431,7 @@ private:
const uint32 _tickLength;
uint32 _timer;
+ const uint32 _rtt;
uint8 **_reg;
@@ -440,8 +443,8 @@ private:
bool _ready;
};
-TownsPC98_FmSynthSquareSineSource::TownsPC98_FmSynthSquareSineSource(const uint32 timerbase) : _tlTable(0),
- _tleTable(0), _updateRequest(-1), _tickLength(timerbase * 27), _ready(0), _reg(0), _rand(1), _outN(1),
+TownsPC98_FmSynthSquareSineSource::TownsPC98_FmSynthSquareSineSource(const uint32 timerbase, const uint32 rtt) : _tlTable(0),
+ _rtt(rtt), _tleTable(0), _updateRequest(-1), _tickLength(timerbase * 27), _ready(0), _reg(0), _rand(1), _outN(1),
_nTick(0), _evpUpdateCnt(0), _evpTimer(0x1f), _pReslt(0x1f), _attack(0), _cont(false), _evpUpdate(true),
_timer(0), _noiseGenerator(0), _chanEnable(0),
_volMaskA(0), _volMaskB(0), _volumeA(Audio::Mixer::kMaxMixerVolume), _volumeB(Audio::Mixer::kMaxMixerVolume) {
@@ -558,8 +561,8 @@ void TownsPC98_FmSynthSquareSineSource::nextTick(int32 *buffer, uint32 bufferSiz
for (uint32 i = 0; i < bufferSize; i++) {
_timer += _tickLength;
- while (_timer > 0x5B8D80) {
- _timer -= 0x5B8D80;
+ while (_timer > _rtt) {
+ _timer -= _rtt;
if (++_nTick >= (_noiseGenerator & 0x1f)) {
if ((_rand + 1) & 2)
@@ -597,7 +600,7 @@ void TownsPC98_FmSynthSquareSineSource::nextTick(int32 *buffer, uint32 bufferSiz
int32 finOut = 0;
for (int ii = 0; ii < 3; ii++) {
-int32 finOutTemp = ((_channels[ii].vol >> 4) & 1) ? _tleTable[_channels[ii].out ? _pReslt : 0] : _tlTable[_channels[ii].out ? (_channels[ii].vol & 0x0f) : 0];
+ int32 finOutTemp = ((_channels[ii].vol >> 4) & 1) ? _tleTable[_channels[ii].out ? _pReslt : 0] : _tlTable[_channels[ii].out ? (_channels[ii].vol & 0x0f) : 0];
if ((1 << ii) & _volMaskA)
finOutTemp = (finOutTemp * _volumeA) / Audio::Mixer::kMaxMixerVolume;
@@ -624,8 +627,8 @@ void TownsPC98_FmSynthSquareSineSource::updateRegs() {
_updateRequest = -1;
}
-TownsPC98_FmSynthPercussionSource::TownsPC98_FmSynthPercussionSource(const uint32 timerbase) :
- _tickLength(timerbase * 2), _timer(0), _ready(false), _volMaskA(0), _volMaskB(0), _volumeA(Audio::Mixer::kMaxMixerVolume), _volumeB(Audio::Mixer::kMaxMixerVolume) {
+TownsPC98_FmSynthPercussionSource::TownsPC98_FmSynthPercussionSource(const uint32 timerbase, const uint32 rtt) :
+ _rtt(rtt), _tickLength(timerbase * 2), _timer(0), _ready(false), _volMaskA(0), _volMaskB(0), _volumeA(Audio::Mixer::kMaxMixerVolume), _volumeB(Audio::Mixer::kMaxMixerVolume) {
memset(_rhChan, 0, sizeof(RhtChannel) * 6);
_reg = new uint8 *[40];
@@ -758,8 +761,8 @@ void TownsPC98_FmSynthPercussionSource::nextTick(int32 *buffer, uint32 bufferSiz
for (uint32 i = 0; i < bufferSize; i++) {
_timer += _tickLength;
- while (_timer > 0x5B8D80) {
- _timer -= 0x5B8D80;
+ while (_timer > _rtt) {
+ _timer -= _rtt;
for (int ii = 0; ii < 6; ii++) {
RhtChannel *s = &_rhChan[ii];
@@ -826,7 +829,7 @@ TownsPC98_FmSynth::TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type) :
_chanInternal(0), _ssg(0), _prc(0),
_numChan(type == kType26 ? 3 : 6), _numSSG(type == kTypeTowns ? 0 : 3), _hasPercussion(type == kType86 ? true : false),
_oprRates(0), _oprRateshift(0), _oprAttackDecay(0), _oprFrq(0), _oprSinTbl(0), _oprLevelOut(0), _oprDetune(0),
- _baserate(55125.0f / (float)mixer->getOutputRate()),
+ _rtt(type == kTypeTowns ? 0x514767 : 0x5B8D80), _baserate(55125.0f / (float)mixer->getOutputRate()),
_volMaskA(0), _volMaskB(0), _volumeA(255), _volumeB(255),
_regProtectionFlag(false), _ready(false) {
@@ -834,7 +837,7 @@ TownsPC98_FmSynth::TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type) :
memset(&_timers[1], 0, sizeof(ChipTimer));
_timers[0].cb = &TownsPC98_FmSynth::timerCallbackA;
_timers[1].cb = &TownsPC98_FmSynth::timerCallbackB;
- _timerbase = (uint32)(_baserate * 1000000.0f);
+ _timerbase = (uint32)(_baserate * 1000000.0f);
}
TownsPC98_FmSynth::~TownsPC98_FmSynth() {
@@ -865,16 +868,16 @@ bool TownsPC98_FmSynth::init() {
for (int i = 0; i < _numChan; i++) {
memset(&_chanInternal[i], 0, sizeof(ChanInternal));
for (int j = 0; j < 4; ++j)
- _chanInternal[i].opr[j] = new TownsPC98_FmSynthOperator(_timerbase, _oprRates, _oprRateshift, _oprAttackDecay, _oprFrq, _oprSinTbl, _oprLevelOut, _oprDetune);
+ _chanInternal[i].opr[j] = new TownsPC98_FmSynthOperator(_timerbase, _rtt, _oprRates, _oprRateshift, _oprAttackDecay, _oprFrq, _oprSinTbl, _oprLevelOut, _oprDetune);
}
if (_numSSG) {
- _ssg = new TownsPC98_FmSynthSquareSineSource(_timerbase);
+ _ssg = new TownsPC98_FmSynthSquareSineSource(_timerbase, _rtt);
_ssg->init(&_ssgTables[0], &_ssgTables[16]);
}
if (_hasPercussion) {
- _prc = new TownsPC98_FmSynthPercussionSource(_timerbase);
+ _prc = new TownsPC98_FmSynthPercussionSource(_timerbase, _rtt);
_prc->init(_percussionData);
}
diff --git a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
index 34ee2ce7b8..3072503610 100644
--- a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
+++ b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
@@ -160,6 +160,7 @@ private:
const float _baserate;
uint32 _timerbase;
+ uint32 _rtt;
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
diff --git a/sound/softsynth/sid.cpp b/sound/softsynth/sid.cpp
index e925f4a447..c05ae2e8f5 100644
--- a/sound/softsynth/sid.cpp
+++ b/sound/softsynth/sid.cpp
@@ -31,6 +31,7 @@
#ifndef DISABLE_SID
#include "sid.h"
+#include "sound/null.h"
#include <math.h>
namespace Resid {
@@ -1422,4 +1423,34 @@ int SID::clock(cycle_count& delta_t, short* buf, int n, int interleave) {
}
+// Plugin interface
+// (This can only create a null driver since C64 audio support is not part of the
+// midi driver architecture. But we need the plugin for the options menu in the launcher
+// and for MidiDriver::detectDevice() which is more or less used by all engines.)
+
+class C64MusicPlugin : public NullMusicPlugin {
+public:
+ const char *getName() const {
+ return _s("C64 Audio Emulator");
+ }
+
+ const char *getId() const {
+ return "C64";
+ }
+
+ MusicDevices getDevices() const;
+};
+
+MusicDevices C64MusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_C64));
+ return devices;
+}
+
+//#if PLUGIN_ENABLED_DYNAMIC(C64)
+ //REGISTER_PLUGIN_DYNAMIC(C64, PLUGIN_TYPE_MUSIC, C64MusicPlugin);
+//#else
+ REGISTER_PLUGIN_STATIC(C64, PLUGIN_TYPE_MUSIC, C64MusicPlugin);
+//#endif
+
#endif