aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorFlorian Kagerer2010-10-03 16:28:31 +0000
committerFlorian Kagerer2010-10-03 16:28:31 +0000
commit718fe1d18f2550a6e5247782229843fdd5d2ef7f (patch)
treeeca7f9ad98dc0bf2d3c0fb8aa7588bc3b6209588 /sound
parent7f2dfd0f82b0ef8e96ca22338922d601ad2516e1 (diff)
downloadscummvm-rg350-718fe1d18f2550a6e5247782229843fdd5d2ef7f.tar.gz
scummvm-rg350-718fe1d18f2550a6e5247782229843fdd5d2ef7f.tar.bz2
scummvm-rg350-718fe1d18f2550a6e5247782229843fdd5d2ef7f.zip
PC-98 AUDIO: some code size reduction for the NDS port
svn-id: r52994
Diffstat (limited to 'sound')
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp30
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_pc98_driver.h6
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp28
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h6
4 files changed, 65 insertions, 5 deletions
diff --git a/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp b/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
index 72054f71c6..21e8f9b2e5 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 __DS__
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),
@@ -928,6 +930,7 @@ void TownsPC98_SfxChannel::reset() {
_drv->_ssgPatches[i + 12] = src[i + 12];
}
+#ifndef __DS__
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 // ifndef __DS__
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 __DS__
+ _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 __DS__
+ 0x01
+#else
+ 0x00
+#endif
+ : 0x00), _finishedRhythmFlag(0),
_updateSfxFlag(0), _finishedSfxFlag(0),
_musicTickCounter(0),
@@ -1062,8 +1075,9 @@ TownsPC98_AudioDriver::~TownsPC98_AudioDriver() {
delete _sfxChannels[i];
delete[] _sfxChannels;
}
-
+#ifndef __DS__
delete _rhythmChannel;
+#endif
delete[] _ssgPatches;
}
@@ -1107,10 +1121,12 @@ bool TownsPC98_AudioDriver::init() {
}
}
+#ifndef __DS__
if (_hasPercussion) {
_rhythmChannel = new TownsPC98_MusicChannelPCM(this, 0, 0, 0, 0, 0, 1);
_rhythmChannel->init();
}
+#endif
setMusicTempo(84);
setSfxTempo(654);
@@ -1152,7 +1168,9 @@ void TownsPC98_AudioDriver::loadMusicData(uint8 *data, bool loadPaused) {
}
if (_hasPercussion) {
+#ifndef __DS__
_rhythmChannel->loadData(data + READ_LE_UINT16(src_a));
+#endif
src_a += 2;
}
@@ -1212,8 +1230,10 @@ void TownsPC98_AudioDriver::reset() {
memcpy(_ssgPatches, _drvTables + 156, 256);
}
+#ifndef __DS__
if (_rhythmChannel)
_rhythmChannel->reset();
+#endif
}
void TownsPC98_AudioDriver::fadeStep() {
@@ -1233,10 +1253,12 @@ void TownsPC98_AudioDriver::fadeStep() {
if (!_fading) {
_fading = 19;
+#ifndef __DS__
if (_hasPercussion) {
if (_updateRhythmFlag & _rhythmChannel->_idFlag)
_rhythmChannel->reset();
}
+#endif
} else {
if (!--_fading)
reset();
@@ -1263,9 +1285,11 @@ void TownsPC98_AudioDriver::timerCallbackB() {
}
}
+#ifndef __DS__
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..162156b2b5 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 __DS__
class TownsPC98_MusicChannelPCM;
+#endif
class TownsPC98_AudioDriver : public TownsPC98_FmSynth {
friend class TownsPC98_MusicChannel;
friend class TownsPC98_MusicChannelSSG;
friend class TownsPC98_SfxChannel;
+#ifndef __DS__
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 __DS__
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 b51f695087..7b94a46426 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 __DS__
class TownsPC98_FmSynthPercussionSource {
public:
TownsPC98_FmSynthPercussionSource(const uint32 timerbase, const uint32 rtt);
@@ -442,6 +443,7 @@ private:
bool _ready;
};
+#endif
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 __DS__
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 // ifndef __DS__
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 __DS__
+ _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),
@@ -846,7 +854,9 @@ TownsPC98_FmSynth::~TownsPC98_FmSynth() {
deinit();
delete _ssg;
+#ifndef __DS__
delete _prc;
+#endif
delete[] _chanInternal;
delete[] _oprRates;
@@ -878,10 +888,12 @@ bool TownsPC98_FmSynth::init() {
_ssg->init(&_ssgTables[0], &_ssgTables[16]);
}
+#ifndef __DS__
if (_hasPercussion) {
_prc = new TownsPC98_FmSynthPercussionSource(_timerbase, _rtt);
_prc->init(_percussionData);
}
+#endif
_timers[0].cb = &TownsPC98_FmSynth::timerCallbackA;
_timers[1].cb = &TownsPC98_FmSynth::timerCallbackB;
@@ -910,8 +922,10 @@ void TownsPC98_FmSynth::reset() {
if (_ssg)
_ssg->reset();
+#ifndef __DS__
if (_prc)
_prc->reset();
+#endif
}
void TownsPC98_FmSynth::writeReg(uint8 part, uint8 regAddress, uint8 value) {
@@ -945,9 +959,11 @@ void TownsPC98_FmSynth::writeReg(uint8 part, uint8 regAddress, uint8 value) {
_ssg->writeReg(l, value);
break;
case 0x10:
+#ifndef __DS__
// pcm rhythm channel
if (_prc)
_prc->writeReg(l, value);
+#endif
break;
case 0x20:
if (l == 8) {
@@ -1139,8 +1155,10 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) {
if (_ssg)
_ssg->nextTick(tmp, render);
+#ifndef __DS__
if (_prc)
_prc->nextTick(tmp, render);
+#endif
nextTickEx(tmp, render);
@@ -1176,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 __DS__
if (_prc)
_prc->setVolumeIntern(_volumeA, _volumeB);
+#endif
}
void TownsPC98_FmSynth::setVolumeChannelMasks(int channelMaskA, int channelMaskB) {
@@ -1186,8 +1206,10 @@ void TownsPC98_FmSynth::setVolumeChannelMasks(int channelMaskA, int channelMaskB
_volMaskB = channelMaskB;
if (_ssg)
_ssg->setVolumeChannelMasks(_volMaskA >> _numChan, _volMaskB >> _numChan);
+#ifndef __DS__
if (_prc)
_prc->setVolumeChannelMasks(_volMaskA >> (_numChan + _numSSG), _volMaskB >> (_numChan + _numSSG));
+#endif
}
void TownsPC98_FmSynth::generateTables() {
@@ -1400,6 +1422,7 @@ const int TownsPC98_FmSynth::_ssgTables[] = {
0x000575, 0x000463, 0x00039D, 0x0002FA, 0x000242, 0x0001B6, 0x00014C, 0x0000FB
};
+#ifndef __DS__
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,
@@ -1514,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
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 4a618338ed..a6fd39646a 100644
--- a/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
+++ b/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
@@ -32,7 +32,9 @@
class TownsPC98_FmSynthOperator;
class TownsPC98_FmSynthSquareSineSource;
+#ifndef __DS__
class TownsPC98_FmSynthPercussionSource;
+#endif
enum EnvelopeState {
kEnvReady,
@@ -128,7 +130,9 @@ private:
};
TownsPC98_FmSynthSquareSineSource *_ssg;
+#ifndef __DS__
TownsPC98_FmSynthPercussionSource *_prc;
+#endif
ChanInternal *_chanInternal;
uint8 *_oprRates;
@@ -168,7 +172,9 @@ private:
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
+#ifndef __DS__
static const uint8 _percussionData[];
+#endif
static const uint32 _adtStat[];
static const uint8 _detSrc[];
static const int _ssgTables[];