diff options
author | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
commit | 75e8452b6e6a2bf4fb2f588aa00b428a60d873b5 (patch) | |
tree | f29541d55309487a94bd1d38e8b53bb3dde9aec6 /sound/softsynth/fmtowns_pc98 | |
parent | 48ee83b88957dab86bc763e9ef21a70179fa8679 (diff) | |
parent | e9f50882ea5b6beeefa994040be9d3bab6a1f107 (diff) | |
download | scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.gz scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.bz2 scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.zip |
OPENGL: Merged from trunk, from rev 52105 to 53396.
This includes an rather hacky attempt to merge all the recent gp2x backend
changes into the branch. I suppose the gp2x backend and probably all new
backends, i.e. gph, dingux etc., might not compile anymore.
Since I have no way of testing those it would be nice if porters could look
into getting those up to speed in this branch.
svn-id: r53399
Diffstat (limited to 'sound/softsynth/fmtowns_pc98')
-rw-r--r-- | sound/softsynth/fmtowns_pc98/towns_audio.cpp | 44 | ||||
-rw-r--r-- | sound/softsynth/fmtowns_pc98/towns_audio.h | 1 | ||||
-rw-r--r-- | sound/softsynth/fmtowns_pc98/towns_euphony.cpp | 8 | ||||
-rw-r--r-- | sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp | 36 | ||||
-rw-r--r-- | sound/softsynth/fmtowns_pc98/towns_pc98_driver.h | 6 | ||||
-rw-r--r-- | sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp | 52 | ||||
-rw-r--r-- | sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h | 19 |
7 files changed, 133 insertions, 33 deletions
diff --git a/sound/softsynth/fmtowns_pc98/towns_audio.cpp b/sound/softsynth/fmtowns_pc98/towns_audio.cpp index e74991a55f..e6da237881 100644 --- a/sound/softsynth/fmtowns_pc98/towns_audio.cpp +++ b/sound/softsynth/fmtowns_pc98/towns_audio.cpp @@ -103,7 +103,8 @@ 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), - _outputVolumeFlags(0), _outputMuteFlags(0), _ready(false) { + _outputVolumeFlags(0), _outputMuteFlags(0), _pcmChanOut(0), _pcmChanReserved(0), _pcmChanKeyPressed(0), + _pcmChanEffectPlaying(0), _pcmChanKeyPlaying(0), _ready(false) { #define INTCB(x) &TownsAudioInterface::intf_##x static const TownsAudioIntfCallback intfCb[] = { @@ -199,7 +200,7 @@ TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfac INTCB(notImpl), // 72 INTCB(notImpl), - INTCB(notImpl), + INTCB(cdaToggle), INTCB(notImpl), INTCB(notImpl), // 76 @@ -224,6 +225,10 @@ TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfac } TownsAudioInterface::~TownsAudioInterface() { + reset(); + _ready = false; + deinit(); + delete[] _fmSaveReg[0]; delete[] _fmSaveReg[1]; delete[] _fmInstruments; @@ -236,9 +241,6 @@ bool TownsAudioInterface::init() { if (_ready) return true; - if (!_drv) - return false; - if (!TownsPC98_FmSynth::init()) return false; @@ -253,9 +255,9 @@ bool TownsAudioInterface::init() { setVolumeChannelMasks(-1, 0); + _ready = true; callback(0); - _ready = true; return true; } @@ -352,8 +354,9 @@ void TownsAudioInterface::timerCallbackA() { void TownsAudioInterface::timerCallbackB() { Common::StackLock lock(_mutex); - if (_drv && _ready) { - _drv->timerCallback(1); + if (_ready) { + if (_drv) + _drv->timerCallback(1); callback(80); } } @@ -491,7 +494,7 @@ int TownsAudioInterface::intf_enableTimerB(va_list &args) { int TownsAudioInterface::intf_loadSamples(va_list &args) { uint32 dest = va_arg(args, uint32); int size = va_arg(args, int); - uint8 *src = va_arg(args, uint8*); + uint8 *src = va_arg(args, uint8*); if (dest >= 65536 || size == 0 || size > 65536) return 3; @@ -563,7 +566,7 @@ int TownsAudioInterface::intf_loadWaveTable(va_list &args) { TownsAudio_WaveTable *s = &_waveTables[_numWaveTables++]; s->readHeader(data); - + _waveTablesTotalDataSize += s->size; callback(32, _waveTablesTotalDataSize, s->size, data + 32); @@ -658,7 +661,7 @@ int TownsAudioInterface::intf_pcmEffectPlaying(va_list &args) { if (chan < 0x40 || chan > 0x47) return 1; chan -= 0x40; - return (_pcmChanEffectPlaying & _chanFlags[chan]) ? true : false; + return (_pcmChanEffectPlaying & _chanFlags[chan]) ? 1 : 0; } int TownsAudioInterface::intf_fmKeyOn(va_list &args) { @@ -719,11 +722,11 @@ int TownsAudioInterface::intf_setOutputVolume(va_list &args) { static const uint8 flags[] = { 0x0C, 0x30, 0x40, 0x80 }; uint8 chan = (chanType & 0x40) ? 8 : 12; - + chanType &= 3; left = (left & 0x7e) >> 1; right = (right & 0x7e) >> 1; - + if (chan) _outputVolumeFlags |= flags[chanType]; else @@ -758,6 +761,12 @@ int TownsAudioInterface::intf_updateOutputVolume(va_list &args) { return 0; } +int TownsAudioInterface::intf_cdaToggle(va_list &args) { + //int mode = va_arg(args, int); + //_unkMask = mode ? 0x7f : 0x3f; + return 0; +} + int TownsAudioInterface::intf_pcmUpdateEnvelopeGenerator(va_list &args) { for (int i = 0; i < 8; i++) pcmUpdateEnvelopeGenerator(i); @@ -1389,10 +1398,13 @@ 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])); + uint32 maxVol = MAX(_outputLevel[12], _outputLevel[13]); + + int volume = (int)(((float)(maxVol * 255) / 63.0f)); + int balance = maxVol ? (int)( ( ((int)_outputLevel[13] - _outputLevel[12]) * 127) / (float)maxVol) : 0; + g_system->getAudioCDManager()->setVolume(volume); g_system->getAudioCDManager()->setBalance(balance); } diff --git a/sound/softsynth/fmtowns_pc98/towns_audio.h b/sound/softsynth/fmtowns_pc98/towns_audio.h index 950c016b4e..95fb1ded59 100644 --- a/sound/softsynth/fmtowns_pc98/towns_audio.h +++ b/sound/softsynth/fmtowns_pc98/towns_audio.h @@ -95,6 +95,7 @@ private: int intf_setOutputVolume(va_list &args); int intf_resetOutputVolume(va_list &args); int intf_updateOutputVolume(va_list &args); + int intf_cdaToggle(va_list &args); int intf_pcmUpdateEnvelopeGenerator(va_list &args); int intf_notImpl(va_list &args); diff --git a/sound/softsynth/fmtowns_pc98/towns_euphony.cpp b/sound/softsynth/fmtowns_pc98/towns_euphony.cpp index 0c0c203cc9..7b52b4594f 100644 --- a/sound/softsynth/fmtowns_pc98/towns_euphony.cpp +++ b/sound/softsynth/fmtowns_pc98/towns_euphony.cpp @@ -131,7 +131,7 @@ void TownsEuphonyDriver::unloadWaveTable(int id) { void TownsEuphonyDriver::reserveSoundEffectChannels(int num) { _intf->callback(33, num); uint32 volMask = 0; - + if (num > 8) return; @@ -139,7 +139,7 @@ void TownsEuphonyDriver::reserveSoundEffectChannels(int num) { volMask |= v; v >>= 1; } - + _intf->setSoundEffectChanMask(volMask); } @@ -560,10 +560,10 @@ uint8 TownsEuphonyDriver::appendEvent(uint8 evt, uint8 chan) { void TownsEuphonyDriver::sendEvent(uint8 mode, uint8 command) { if (mode == 0) { - warning("TownsEuphonyDriver: Mode 0 not implemented."); + // warning("TownsEuphonyDriver: Mode 0 not implemented"); } else if (mode == 0x10) { - warning("TownsEuphonyDriver: Mode 0x10 not implemented."); + warning("TownsEuphonyDriver: Mode 0x10 not implemented"); } else if (mode == 0xff) { if (command >= 0xf0) { diff --git a/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp b/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp index 82d0bd0438..8047616dbf 100644 --- a/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp +++ b/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp @@ -160,6 +160,7 @@ public: void reset(); }; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL class TownsPC98_MusicChannelPCM : public TownsPC98_MusicChannel { public: TownsPC98_MusicChannelPCM(TownsPC98_AudioDriver *driver, uint8 regOffs, @@ -178,6 +179,7 @@ private: typedef bool (TownsPC98_MusicChannelPCM::*ControlEventFunc)(uint8 para); const ControlEventFunc *controlEvents; }; +#endif TownsPC98_MusicChannel::TownsPC98_MusicChannel(TownsPC98_AudioDriver *driver, uint8 regOffs, uint8 flgs, uint8 num, uint8 key, uint8 prt, uint8 id) : _drv(driver), _regOffset(regOffs), _flags(flgs), _chanNum(num), _keyNum(key), @@ -312,7 +314,7 @@ void TownsPC98_MusicChannel::processEvents() { void TownsPC98_MusicChannel::processFrequency() { if (_flags & CHS_RECALCFREQ) { - _frequency = (((const uint16 *)_drv->_opnFreqTable)[_frqBlockMSB & 0x0f] + _frqLSB) | (((_frqBlockMSB & 0x70) >> 1) << 8); + _frequency = (READ_LE_UINT16(&_drv->_opnFreqTable[(_frqBlockMSB & 0x0f) << 1]) + _frqLSB) | (((_frqBlockMSB & 0x70) >> 1) << 8); _drv->writeReg(_part, _regOffset + 0xa4, (_frequency >> 8)); _drv->writeReg(_part, _regOffset + 0xa0, (_frequency & 0xff)); @@ -709,7 +711,7 @@ void TownsPC98_MusicChannelSSG::processFrequency() { if (_flags & CHS_RECALCFREQ) { _block = _frqBlockMSB >> 4; - _frequency = ((const uint16 *)_drv->_opnFreqTableSSG)[_frqBlockMSB & 0x0f] + _frqLSB; + _frequency = READ_LE_UINT16(&_drv->_opnFreqTableSSG[(_frqBlockMSB & 0x0f) << 1]) + _frqLSB; uint16 f = _frequency >> _block; _drv->writeReg(_part, _regOffset << 1, f & 0xff); @@ -928,6 +930,7 @@ void TownsPC98_SfxChannel::reset() { _drv->_ssgPatches[i + 12] = src[i + 12]; } +#ifndef DISABLE_PC98_RHYTHM_CHANNEL TownsPC98_MusicChannelPCM::TownsPC98_MusicChannelPCM(TownsPC98_AudioDriver *driver, uint8 regOffs, uint8 flgs, uint8 num, uint8 key, uint8 prt, uint8 id) : TownsPC98_MusicChannel(driver, regOffs, flgs, num, key, prt, id), controlEvents(0) { @@ -1016,9 +1019,13 @@ bool TownsPC98_MusicChannelPCM::control_ff_endOfTrack(uint8 para) { return false; } } +#endif // DISABLE_PC98_RHYTHM_CHANNEL TownsPC98_AudioDriver::TownsPC98_AudioDriver(Audio::Mixer *mixer, EmuType type) : TownsPC98_FmSynth(mixer, type), - _channels(0), _ssgChannels(0), _sfxChannels(0), _rhythmChannel(0), + _channels(0), _ssgChannels(0), _sfxChannels(0), +#ifndef DISABLE_PC98_RHYTHM_CHANNEL + _rhythmChannel(0), +#endif _trackPtr(0), _sfxData(0), _sfxOffs(0), _ssgPatches(0), _patches(0), _sfxBuffer(0), _musicBuffer(0), @@ -1027,7 +1034,13 @@ TownsPC98_AudioDriver::TownsPC98_AudioDriver(Audio::Mixer *mixer, EmuType type) _updateChannelsFlag(type == kType26 ? 0x07 : 0x3F), _finishedChannelsFlag(0), _updateSSGFlag(type == kTypeTowns ? 0x00 : 0x07), _finishedSSGFlag(0), - _updateRhythmFlag(type == kType86 ? 0x01 : 0x00), _finishedRhythmFlag(0), + _updateRhythmFlag(type == kType86 ? +#ifndef DISABLE_PC98_RHYTHM_CHANNEL + 0x01 +#else + 0x00 +#endif + : 0x00), _finishedRhythmFlag(0), _updateSfxFlag(0), _finishedSfxFlag(0), _musicTickCounter(0), @@ -1041,6 +1054,8 @@ TownsPC98_AudioDriver::TownsPC98_AudioDriver(Audio::Mixer *mixer, EmuType type) TownsPC98_AudioDriver::~TownsPC98_AudioDriver() { reset(); + _ready = false; + deinit(); if (_channels) { for (int i = 0; i < _numChan; i++) @@ -1059,8 +1074,9 @@ TownsPC98_AudioDriver::~TownsPC98_AudioDriver() { delete _sfxChannels[i]; delete[] _sfxChannels; } - +#ifndef DISABLE_PC98_RHYTHM_CHANNEL delete _rhythmChannel; +#endif delete[] _ssgPatches; } @@ -1104,10 +1120,12 @@ bool TownsPC98_AudioDriver::init() { } } +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_hasPercussion) { _rhythmChannel = new TownsPC98_MusicChannelPCM(this, 0, 0, 0, 0, 0, 1); _rhythmChannel->init(); } +#endif setMusicTempo(84); setSfxTempo(654); @@ -1149,7 +1167,9 @@ void TownsPC98_AudioDriver::loadMusicData(uint8 *data, bool loadPaused) { } if (_hasPercussion) { +#ifndef DISABLE_PC98_RHYTHM_CHANNEL _rhythmChannel->loadData(data + READ_LE_UINT16(src_a)); +#endif src_a += 2; } @@ -1209,8 +1229,10 @@ void TownsPC98_AudioDriver::reset() { memcpy(_ssgPatches, _drvTables + 156, 256); } +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_rhythmChannel) _rhythmChannel->reset(); +#endif } void TownsPC98_AudioDriver::fadeStep() { @@ -1230,10 +1252,12 @@ void TownsPC98_AudioDriver::fadeStep() { if (!_fading) { _fading = 19; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_hasPercussion) { if (_updateRhythmFlag & _rhythmChannel->_idFlag) _rhythmChannel->reset(); } +#endif } else { if (!--_fading) reset(); @@ -1260,9 +1284,11 @@ void TownsPC98_AudioDriver::timerCallbackB() { } } +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_hasPercussion) if (_updateRhythmFlag & _rhythmChannel->_idFlag) _rhythmChannel->processEvents(); +#endif } toggleRegProtection(false); diff --git a/sound/softsynth/fmtowns_pc98/towns_pc98_driver.h b/sound/softsynth/fmtowns_pc98/towns_pc98_driver.h index 18daee1e72..00fcf7c5d5 100644 --- a/sound/softsynth/fmtowns_pc98/towns_pc98_driver.h +++ b/sound/softsynth/fmtowns_pc98/towns_pc98_driver.h @@ -31,13 +31,17 @@ class TownsPC98_MusicChannel; class TownsPC98_MusicChannelSSG; class TownsPC98_SfxChannel; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL class TownsPC98_MusicChannelPCM; +#endif class TownsPC98_AudioDriver : public TownsPC98_FmSynth { friend class TownsPC98_MusicChannel; friend class TownsPC98_MusicChannelSSG; friend class TownsPC98_SfxChannel; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL friend class TownsPC98_MusicChannelPCM; +#endif public: TownsPC98_AudioDriver(Audio::Mixer *mixer, EmuType type); ~TownsPC98_AudioDriver(); @@ -84,7 +88,9 @@ protected: TownsPC98_MusicChannel **_channels; TownsPC98_MusicChannelSSG **_ssgChannels; TownsPC98_SfxChannel **_sfxChannels; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL TownsPC98_MusicChannelPCM *_rhythmChannel; +#endif const uint8 *_opnCarrier; const uint8 *_opnFreqTable; diff --git a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp index 241b9bde50..e779812c42 100644 --- a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp +++ b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp @@ -377,6 +377,7 @@ private: bool _ready; }; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL class TownsPC98_FmSynthPercussionSource { public: TownsPC98_FmSynthPercussionSource(const uint32 timerbase, const uint32 rtt); @@ -442,6 +443,7 @@ private: bool _ready; }; +#endif // DISABLE_PC98_RHYTHM_CHANNEL 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), @@ -627,6 +629,7 @@ void TownsPC98_FmSynthSquareSineSource::updateRegs() { _updateRequest = -1; } +#ifndef DISABLE_PC98_RHYTHM_CHANNEL 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) { @@ -823,11 +826,16 @@ void TownsPC98_FmSynthPercussionSource::advanceInput(RhtChannel *ins) { cur >>= 4; } } +#endif // DISABLE_PC98_RHYTHM_CHANNEL TownsPC98_FmSynth::TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type) : _mixer(mixer), - _chanInternal(0), _ssg(0), _prc(0), - _numChan(type == kType26 ? 3 : 6), _numSSG(type == kTypeTowns ? 0 : 3), _hasPercussion(type == kType86 ? true : false), + _chanInternal(0), _ssg(0), +#ifndef DISABLE_PC98_RHYTHM_CHANNEL + _prc(0), +#endif + _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), _rtt(type == kTypeTowns ? 0x514767 : 0x5B8D80), _baserate(55125.0f / (float)mixer->getOutputRate()), _volMaskA(0), _volMaskB(0), _volumeA(255), _volumeB(255), @@ -835,16 +843,19 @@ TownsPC98_FmSynth::TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type) : memset(&_timers[0], 0, sizeof(ChipTimer)); memset(&_timers[1], 0, sizeof(ChipTimer)); - _timers[0].cb = &TownsPC98_FmSynth::timerCallbackA; - _timers[1].cb = &TownsPC98_FmSynth::timerCallbackB; - _timerbase = (uint32)(_baserate * 1000000.0f); + + _timers[0].cb = _timers[1].cb = &TownsPC98_FmSynth::idleTimerCallback; + _timerbase = (uint32)(_baserate * 1000000.0f); } TownsPC98_FmSynth::~TownsPC98_FmSynth() { - Common::StackLock lock(_mutex); - _mixer->stopHandle(_soundHandle); + if (_ready) + deinit(); + delete _ssg; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL delete _prc; +#endif delete[] _chanInternal; delete[] _oprRates; @@ -876,10 +887,15 @@ bool TownsPC98_FmSynth::init() { _ssg->init(&_ssgTables[0], &_ssgTables[16]); } +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_hasPercussion) { _prc = new TownsPC98_FmSynthPercussionSource(_timerbase, _rtt); _prc->init(_percussionData); } +#endif + + _timers[0].cb = &TownsPC98_FmSynth::timerCallbackA; + _timers[1].cb = &TownsPC98_FmSynth::timerCallbackB; _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); @@ -890,6 +906,7 @@ bool TownsPC98_FmSynth::init() { } void TownsPC98_FmSynth::reset() { + Common::StackLock lock(_mutex); for (int i = 0; i < _numChan; i++) { for (int ii = 0; ii < 4; ii++) _chanInternal[i].opr[ii]->reset(); @@ -905,8 +922,10 @@ void TownsPC98_FmSynth::reset() { if (_ssg) _ssg->reset(); +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_prc) _prc->reset(); +#endif } void TownsPC98_FmSynth::writeReg(uint8 part, uint8 regAddress, uint8 value) { @@ -940,9 +959,11 @@ void TownsPC98_FmSynth::writeReg(uint8 part, uint8 regAddress, uint8 value) { _ssg->writeReg(l, value); break; case 0x10: +#ifndef DISABLE_PC98_RHYTHM_CHANNEL // pcm rhythm channel if (_prc) _prc->writeReg(l, value); +#endif break; case 0x20: if (l == 8) { @@ -1103,7 +1124,7 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) { memset(tmp, 0, sizeof(int32) * numSamples); int32 samplesLeft = numSamples >> 1; - while (samplesLeft) { + while (_ready && samplesLeft) { int32 render = samplesLeft; for (int i = 0; i < 2; i++) { @@ -1134,8 +1155,10 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) { if (_ssg) _ssg->nextTick(tmp, render); +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_prc) _prc->nextTick(tmp, render); +#endif nextTickEx(tmp, render); @@ -1154,6 +1177,13 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) { return numSamples; } +void TownsPC98_FmSynth::deinit() { + _ready = false; + _mixer->stopHandle(_soundHandle); + Common::StackLock lock(_mutex); + _timers[0].cb = _timers[1].cb = &TownsPC98_FmSynth::idleTimerCallback; +} + uint8 TownsPC98_FmSynth::readSSGStatus() { return _ssg->chanEnable(); } @@ -1164,8 +1194,10 @@ void TownsPC98_FmSynth::setVolumeIntern(int volA, int volB) { _volumeB = CLIP<uint16>(volB, 0, Audio::Mixer::kMaxMixerVolume); if (_ssg) _ssg->setVolumeIntern(_volumeA, _volumeB); +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_prc) _prc->setVolumeIntern(_volumeA, _volumeB); +#endif } void TownsPC98_FmSynth::setVolumeChannelMasks(int channelMaskA, int channelMaskB) { @@ -1174,8 +1206,10 @@ void TownsPC98_FmSynth::setVolumeChannelMasks(int channelMaskA, int channelMaskB _volMaskB = channelMaskB; if (_ssg) _ssg->setVolumeChannelMasks(_volMaskA >> _numChan, _volMaskB >> _numChan); +#ifndef DISABLE_PC98_RHYTHM_CHANNEL if (_prc) _prc->setVolumeChannelMasks(_volMaskA >> (_numChan + _numSSG), _volMaskB >> (_numChan + _numSSG)); +#endif } void TownsPC98_FmSynth::generateTables() { @@ -1388,6 +1422,7 @@ const int TownsPC98_FmSynth::_ssgTables[] = { 0x000575, 0x000463, 0x00039D, 0x0002FA, 0x000242, 0x0001B6, 0x00014C, 0x0000FB }; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL const uint8 TownsPC98_FmSynth::_percussionData[] = { 0, 24, 1, 192, 1, 216, 2, 128, 4, 88, 23, 64, 27, 152, 1, 128, 29, 24, 2, 128, 31, 152, 0, 128, 136, 128, 128, 128, 0, 136, 97, 103, 153, 139, 34, 163, 72, 195, 27, 69, 1, 154, 137, 35, 8, 51, 169, 122, 164, 75, 133, 203, 81, 146, 168, 121, 185, 68, 202, 8, 33, 237, 49, 177, 12, 133, 140, 17, 160, 42, 161, 10, 0, 137, 176, 57, 233, 41, 160, 136, 235, 65, 177, 137, 128, 26, 164, 28, 3, 157, 51, 137, 1, 152, 113, 161, 40, 146, 115, 192, 56, 5, 169, 66, 161, 56, 1, 50, 145, 59, 39, 168, 97, 1, 160, 57, 7, 153, 50, 153, 32, 2, 25, 129, 32, 20, 186, 66, 129, 24, 153, 164, 142, 130, 169, 153, 26, 242, 138, 217, 9, 128, 204, 58, 209, 172, 40, 176, 141, @@ -1502,6 +1537,7 @@ const uint8 TownsPC98_FmSynth::_percussionData[] = { 45, 136, 18, 144, 105, 138, 1, 160, 14, 128, 132, 145, 186, 37, 138, 41, 192, 48, 145, 46, 160, 33, 44, 24, 225, 16, 13, 132, 136, 137, 16, 148, 25, 170, 194, 82, 152, 136, 91, 24, 42, 169, 33, 233, 131, 179, 24, 185, 149, 16, 57, 172, 164, 18, 10, 211, 160, 147, 211, 33, 138, 243, 129, 16, 41, 193, 0, 43, 132, 155, 73, 58, 145, 244, 145, 43, 35, 9, 171, 16, 110, 25, 8, 28, 74, 162, 128, 26, 27, 82, 45, 136, 153, 18, 8, 136, 8 }; +#endif // DISABLE_PC98_RHYTHM_CHANNEL TownsPC98_FmSynth::ChanInternal::ChanInternal() { memset(this, 0, sizeof(ChanInternal)); diff --git a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h index 3072503610..ddd249b1b8 100644 --- a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h +++ b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h @@ -30,9 +30,21 @@ #include "sound/mixer.h" #include "common/list.h" +#ifdef __DS__ +/* This disables the rhythm channel when emulating the PC-98 type 86 sound card. + * The only purpose is code size reduction for certain backends. + * At the moment the only games which make use of the rhythm channel are the + * (very rare) PC-98 versions of Legend of Kyrandia 2 and Lands of Lore. Music will + * still be okay, just missing a couple of rhythm instruments. + */ +#define DISABLE_PC98_RHYTHM_CHANNEL +#endif + class TownsPC98_FmSynthOperator; class TownsPC98_FmSynthSquareSineSource; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL class TownsPC98_FmSynthPercussionSource; +#endif enum EnvelopeState { kEnvReady, @@ -71,6 +83,8 @@ public: } protected: + void deinit(); + // Implement this in your inherited class if your driver generates // additional output that has to be inserted into the buffer. virtual void nextTickEx(int32 *buffer, uint32 bufferSize) {} @@ -126,7 +140,9 @@ private: }; TownsPC98_FmSynthSquareSineSource *_ssg; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL TownsPC98_FmSynthPercussionSource *_prc; +#endif ChanInternal *_chanInternal; uint8 *_oprRates; @@ -140,6 +156,7 @@ private: bool _regProtectionFlag; typedef void (TownsPC98_FmSynth::*ChipTimerProc)(); + void idleTimerCallback() {} struct ChipTimer { bool enabled; @@ -165,7 +182,9 @@ private: Audio::Mixer *_mixer; Audio::SoundHandle _soundHandle; +#ifndef DISABLE_PC98_RHYTHM_CHANNEL static const uint8 _percussionData[]; +#endif static const uint32 _adtStat[]; static const uint8 _detSrc[]; static const int _ssgTables[]; |