aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorNorbert Lange2009-07-06 18:51:22 +0000
committerNorbert Lange2009-07-06 18:51:22 +0000
commita2e46b76f3d1308b6e65aa9109f44428473dff2b (patch)
tree249003ccee795d83703a6173e9f5f2dcc92b2e15 /sound
parent7c155f87472c550f4bd2494fe31d599dfeb7058c (diff)
downloadscummvm-rg350-a2e46b76f3d1308b6e65aa9109f44428473dff2b.tar.gz
scummvm-rg350-a2e46b76f3d1308b6e65aa9109f44428473dff2b.tar.bz2
scummvm-rg350-a2e46b76f3d1308b6e65aa9109f44428473dff2b.zip
fix identation and replaced the "goto-workaround" with something simpler
svn-id: r42189
Diffstat (limited to 'sound')
-rw-r--r--sound/mods/maxtrax.cpp146
1 files changed, 72 insertions, 74 deletions
diff --git a/sound/mods/maxtrax.cpp b/sound/mods/maxtrax.cpp
index f9cf247eee..2359cc92cc 100644
--- a/sound/mods/maxtrax.cpp
+++ b/sound/mods/maxtrax.cpp
@@ -35,22 +35,22 @@ namespace Audio {
MaxTrax::MaxTrax(int rate, bool stereo)
: Paula(stereo, rate, rate/50), _playerCtx(), _voiceCtx(), _patch(), _channelCtx(), _scores(), _numScores(), _microtonal() {
- _playerCtx.maxScoreNum = 128;
- _playerCtx.vBlankFreq = 50;
- _playerCtx.frameUnit = (uint16)((1000 * (1<<8)) / _playerCtx.vBlankFreq);
- _playerCtx.scoreIndex = -1;
- // glob_CurrentScore = _scoreptr;
- _playerCtx.volume = 0x64;
+ _playerCtx.maxScoreNum = 128;
+ _playerCtx.vBlankFreq = 50;
+ _playerCtx.frameUnit = (uint16)((1000 * (1<<8)) / _playerCtx.vBlankFreq);
+ _playerCtx.scoreIndex = -1;
+ // glob_CurrentScore = _scoreptr;
+ _playerCtx.volume = 0x64;
- _playerCtx.tempoTime = 0;
+ _playerCtx.tempoTime = 0;
- uint32 uinqueId = 0;
- byte flags = 0;
+ uint32 uinqueId = 0;
+ byte flags = 0;
- uint32 colorClock = kPalSystemClock / 2;
+ uint32 colorClock = kPalSystemClock / 2;
- // init extraChannel
- // extraChannel. chan_Number = 16, chan_Flags = chan_VoicesActive = 0
+ // init extraChannel
+ // extraChannel. chan_Number = 16, chan_Flags = chan_VoicesActive = 0
}
MaxTrax::~MaxTrax() {
@@ -200,8 +200,6 @@ void MaxTrax::killVoice(byte num) {
}
int8 MaxTrax::noteOn(ChannelContext &channel, const byte note, uint16 volume, uint16 pri) {
- bool processNote = true;
-
if (channel.microtonal >= 0)
_microtonal[note % 127] = channel.microtonal;
if (!volume)
@@ -226,7 +224,9 @@ int8 MaxTrax::noteOn(ChannelContext &channel, const byte note, uint16 volume, ui
voice.flags |= VoiceContext::kFlagPortamento;
voice.endNote = channel.lastNote = note;
voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
- processNote = false;
+ _playerCtx.addedNote = true;
+ _playerCtx.lastVoice = voiceNum;
+ return voiceNum;
}
} else {
// TODO:
@@ -234,74 +234,72 @@ int8 MaxTrax::noteOn(ChannelContext &channel, const byte note, uint16 volume, ui
// return if no channel found
voiceNum = (channel.flags & ChannelContext::kFlagRightChannel) != 0 ? 0 : 1;
}
- if (processNote) {
- assert(voiceNum >= 0 && voiceNum < ARRAYSIZE(_voiceCtx));
-
- VoiceContext &voice = _voiceCtx[voiceNum];
- voice.flags = 0;
- if (voice.channel) {
- killVoice(voiceNum);
- voice.flags |= VoiceContext::kFlagStolen;
- }
- voice.channel = &channel;
- voice.patch = &patch;
- voice.baseNote = note;
-
- // calc note period
- voice.priority = (byte)pri;
- voice.status = VoiceContext::kStatusStart;
+ assert(voiceNum >= 0 && voiceNum < ARRAYSIZE(_voiceCtx));
- voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
-
- // ifeq HAS_FULLCHANVOL macro
- if (channel.volume < 128)
- voice.noteVolume = (voice.noteVolume * channel.volume) >> 7;
-
- voice.baseVolume = 0;
- voice.lastTicks = 0;
-
- uint16 period = voice.lastPeriod;
- if (!period)
- period = 1000;
+ VoiceContext &voice = _voiceCtx[voiceNum];
+ voice.flags = 0;
+ if (voice.channel) {
+ killVoice(voiceNum);
+ voice.flags |= VoiceContext::kFlagStolen;
+ }
+ voice.channel = &channel;
+ voice.patch = &patch;
+ voice.baseNote = note;
+
+ // calc note period
+ voice.priority = (byte)pri;
+ voice.status = VoiceContext::kStatusStart;
+
+ voice.noteVolume = (_playerCtx.handleVolume) ? volume + 1 : 128;
+
+ // ifeq HAS_FULLCHANVOL macro
+ if (channel.volume < 128)
+ voice.noteVolume = (voice.noteVolume * channel.volume) >> 7;
+
+ voice.baseVolume = 0;
+ voice.lastTicks = 0;
+
+ uint16 period = voice.lastPeriod;
+ if (!period)
+ period = 1000;
+
+ int useOctave = 0;
+ // get samplestart for the given octave
+ const int8 *samplePtr = patch.samplePtr + (patch.sampleTotalLen << useOctave) - patch.sampleTotalLen;
+ if (patch.sampleAttackLen) {
+ Paula::setChannelSampleStart(voiceNum, samplePtr);
+ Paula::setChannelSampleLen(voiceNum, patch.sampleAttackLen << useOctave);
+ Paula::setChannelPeriod(voiceNum, period);
+ Paula::setChannelVolume(voiceNum, 0);
+
+ Paula::enableChannel(voiceNum);
+ // wait for dma-clear
+ }
- int useOctave = 0;
- // get samplestart for the given octave
- const int8 *samplePtr = patch.samplePtr + (patch.sampleTotalLen << useOctave) - patch.sampleTotalLen;
- if (patch.sampleAttackLen) {
- Paula::setChannelSampleStart(voiceNum, samplePtr);
- Paula::setChannelSampleLen(voiceNum, patch.sampleAttackLen << useOctave);
+ if (patch.sampleTotalLen > patch.sampleAttackLen) {
+ Paula::setChannelSampleStart(voiceNum, samplePtr + patch.sampleAttackLen);
+ Paula::setChannelSampleLen(voiceNum, (patch.sampleTotalLen - patch.sampleAttackLen) << useOctave);
+ if (!patch.sampleAttackLen) {
+ // need to enable channel
Paula::setChannelPeriod(voiceNum, period);
Paula::setChannelVolume(voiceNum, 0);
Paula::enableChannel(voiceNum);
- // wait for dma-clear
- }
-
- if (patch.sampleTotalLen > patch.sampleAttackLen) {
- Paula::setChannelSampleStart(voiceNum, samplePtr + patch.sampleAttackLen);
- Paula::setChannelSampleLen(voiceNum, (patch.sampleTotalLen - patch.sampleAttackLen) << useOctave);
- if (!patch.sampleAttackLen) {
- // need to enable channel
- Paula::setChannelPeriod(voiceNum, period);
- Paula::setChannelVolume(voiceNum, 0);
-
- Paula::enableChannel(voiceNum);
- }
- // another pointless wait for DMA-Clear???
}
+ // another pointless wait for DMA-Clear???
+ }
- channel.voicesActive++;
- if (&channel < &_channelCtx[kNumChannels]) {
- const byte flagsSet = ChannelContext::kFlagMono | ChannelContext::kFlagPortamento;
- if ((channel.flags & flagsSet) == flagsSet && channel.lastNote < 0x80 && channel.lastNote != voice.baseNote) {
- voice.portaTicks = 0;
- voice.endNote = voice.baseNote;
- voice.baseNote = channel.lastNote;
- voice.flags |= VoiceContext::kFlagPortamento;
- }
- if ((channel.flags & ChannelContext::kFlagPortamento) != 0)
- channel.lastNote = note;
+ channel.voicesActive++;
+ if (&channel < &_channelCtx[kNumChannels]) {
+ const byte flagsSet = ChannelContext::kFlagMono | ChannelContext::kFlagPortamento;
+ if ((channel.flags & flagsSet) == flagsSet && channel.lastNote < 0x80 && channel.lastNote != voice.baseNote) {
+ voice.portaTicks = 0;
+ voice.endNote = voice.baseNote;
+ voice.baseNote = channel.lastNote;
+ voice.flags |= VoiceContext::kFlagPortamento;
}
+ if ((channel.flags & ChannelContext::kFlagPortamento) != 0)
+ channel.lastNote = note;
}
_playerCtx.addedNote = true;
_playerCtx.lastVoice = voiceNum;