From a2e46b76f3d1308b6e65aa9109f44428473dff2b Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Mon, 6 Jul 2009 18:51:22 +0000 Subject: fix identation and replaced the "goto-workaround" with something simpler svn-id: r42189 --- sound/mods/maxtrax.cpp | 146 ++++++++++++++++++++++++------------------------- 1 file changed, 72 insertions(+), 74 deletions(-) (limited to 'sound') 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; -- cgit v1.2.3