[Scummvm-cvs-logs] SF.net SVN: scummvm:[41692] scummvm/branches/gsoc2009-mods/sound/mods
nolange at users.sourceforge.net
nolange at users.sourceforge.net
Fri Jun 19 23:42:15 CEST 2009
Revision: 41692
http://scummvm.svn.sourceforge.net/scummvm/?rev=41692&view=rev
Author: nolange
Date: 2009-06-19 21:42:14 +0000 (Fri, 19 Jun 2009)
Log Message:
-----------
moved common initialisation routines into their own functions. doMacro and doSong are now nore readable
Modified Paths:
--------------
scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h
Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp 2009-06-19 21:32:57 UTC (rev 41691)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp 2009-06-19 21:42:14 UTC (rev 41692)
@@ -43,16 +43,23 @@
214, 202, 191, 180, 170, 160, 151, 143, 135, 127, 120, 113,
214, 202, 191, 180 };
-
-
Tfmx::Tfmx(int rate, bool stereo)
: Paula(stereo, rate), _resource() {
_playerCtx.enabled = false;
- _playerCtx.song = -1;
_playerCtx.stopWithLastPattern = false;
for (int i = 0; i < kNumVoices; ++i)
_channelCtx[i].paulaChannel = (byte)i;
+
+ _playerCtx.song = -1;
+ _playerCtx.volume = 0x40;
+ _playerCtx.patternCount = 0;
+ _playerCtx.patternSkip = 6;
+ stopPatternChannels();
+ stopMacroChannels();
+
+ setTimerBaseValue(kPalCiaClock);
+ setInterruptFreqUnscaled(kPalDefaultCiaVal);
}
Tfmx::~Tfmx() {
@@ -63,7 +70,6 @@
++_playerCtx.tickCount;
for (int i = 0; i < kNumVoices; ++i) {
ChannelContext &channel = _channelCtx[i];
-
if (channel.dmaIntCount) {
// wait for DMA Interupts to happen
int doneDma = getChannelDmaCount(channel.paulaChannel);
@@ -80,9 +86,10 @@
channel.customMacroPrio = 0;
}
+ // externally queued macros
if (channel.customMacro) {
const byte *const noteCmd = (const byte *)&channel.customMacro;
- const int channelNo = (&channel - _channelCtx);
+ const uint8 channelNo = (uint8)(&channel - _channelCtx);
channel.sfxLocked = false;
noteCommand(noteCmd[0], noteCmd[1], (noteCmd[2] & 0xF0) | channelNo, noteCmd[3]);
@@ -120,12 +127,6 @@
void Tfmx::effects(ChannelContext &channel) {
// addBegin
- // TODO: macroNote pending?
- if (0) {
- channel.sfxLocked = false;
- // TODO: macronote
- }
-
// vibrato
if (channel.vibLength) {
channel.vibValue += channel.vibDelta;
@@ -498,7 +499,11 @@
} else if (pattCmd == 0xFE) { // Stop voice in pattern.expose
_patternCtx[i].command = 0xFF;
- stopChannel(_channelCtx[_patternCtx[i].expose % kNumVoices]);
+ ChannelContext channel = _channelCtx[_patternCtx[i].expose % kNumVoices];
+ if (!channel.sfxLocked) {
+ clearMacroProgramm(channel);
+ Paula::disableChannel(channel.paulaChannel);
+ }
} // else this pattern-Channel is stopped
}
if (_playerCtx.stopWithLastPattern && !runningPatterns) {
@@ -872,40 +877,26 @@
}
-void Tfmx::doMacro(int macro, int note) {
+void Tfmx::doMacro(int note, int macro, int relVol, int finetune, int channelNo) {
assert(0 <= macro && macro < kMaxMacroOffsets);
assert(0 <= note && note < 0xC0);
Common::StackLock lock(_mutex);
- _playerCtx.song = -1;
- _playerCtx.volume = 0x40;
+ channelNo %= kNumVoices;
+ ChannelContext &channel = _channelCtx[channelNo];
+ unlockMacroChannel(channel);
- const int channel = 0;
- _channelCtx[channel].sfxLocked = false;
- _channelCtx[channel].note = 0;
-
- for (int i = 0; i < kNumVoices; ++i) {
- _channelCtx[i].sfxLocked = false;
- _channelCtx[i].sfxLockTime = -1;
- clearEffects(_channelCtx[i]);
- _channelCtx[i].vibValue = 0;
- stopChannel(_channelCtx[i]);
- _channelCtx[i].volume = 0;
- }
-
- noteCommand((uint8)note, (uint8)macro, (uint8)channel, 0);
-
- setTimerBaseValue(kPalCiaClock);
- setInterruptFreqUnscaled(kPalDefaultCiaVal);
+ noteCommand((uint8)note, (uint8)macro, (uint8)(relVol << 4) | channelNo, finetune);
startPaula();
}
void Tfmx::doSong(int songPos) {
assert(0 <= songPos && songPos < kNumSubsongs);
Common::StackLock lock(_mutex);
+ // bool stopCurSong = false;
+ int prevSong = _playerCtx.song;
_playerCtx.song = (int8)songPos;
- _playerCtx.volume = 0x40;
_trackCtx.loopCount = -1;
_trackCtx.startInd = _trackCtx.posInd = _subsong[songPos].songstart;
@@ -913,7 +904,6 @@
const uint16 tempo = _subsong[songPos].tempo;
uint16 ciaIntervall;
-
if (tempo >= 0x10) {
ciaIntervall = (uint16)(kCiaBaseInterval / tempo);
_playerCtx.patternSkip = 0;
@@ -921,27 +911,12 @@
ciaIntervall = kPalDefaultCiaVal;
_playerCtx.patternSkip = tempo;
}
-
- _playerCtx.patternCount = 0;
-
- for (int i = 0; i < kNumChannels; ++i) {
- _patternCtx[i].command = 0xFF;
- _patternCtx[i].expose = 0;
- }
-
- for (int i = 0; i < kNumVoices; ++i) {
- _channelCtx[i].sfxLocked = false;
- _channelCtx[i].sfxLockTime = -1;
- clearEffects(_channelCtx[i]);
- _channelCtx[i].vibValue = 0;
- stopChannel(_channelCtx[i]);
- _channelCtx[i].volume = 0;
- _channelCtx[i].customMacro = 0;
- }
-
setTimerBaseValue(kPalCiaClock);
setInterruptFreqUnscaled(ciaIntervall);
+ stopPatternChannels();
+ stopMacroChannels();
+ _playerCtx.patternCount = 0;
while (trackStep())
;
startPaula();
Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h 2009-06-19 21:32:57 UTC (rev 41691)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h 2009-06-19 21:42:14 UTC (rev 41692)
@@ -48,7 +48,7 @@
void interrupt();
void doSong(int songPos);
void doSfx(int sfxIndex);
- void doMacro(int macro, int note);
+ void doMacro(int note, int macro, int relVol = 0, int finetune = 0, int channelNo = 0);
bool load(Common::SeekableReadStream &musicData, Common::SeekableReadStream &sampleData);
int getTicks() {return _playerCtx.tickCount;}
int getSongIndex() {return _playerCtx.song;}
@@ -232,20 +232,38 @@
void clearEffects(ChannelContext &channel) {
channel.envSkip = 0;
-
channel.vibLength = 0;
-
channel.portaDelta = 0;
}
- void stopChannel(ChannelContext &channel) {
- if (!channel.sfxLocked) {
- channel.macroRun = false;
- channel.dmaIntCount = 0;
- Paula::disableChannel(channel.paulaChannel);
- }
+ void clearMacroProgramm(ChannelContext &channel) {
+ channel.macroRun = false;
+ channel.dmaIntCount = 0;
}
+ void unlockMacroChannel(ChannelContext &channel) {
+ channel.customMacro = 0;
+ channel.customMacroPrio = false;
+ channel.sfxLocked = false;
+ channel.sfxLockTime = -1;
+ }
+
+ void stopPatternChannels() {
+ for (int i = 0; i < kNumChannels; ++i) {
+ _patternCtx[i].command = 0xFF;
+ _patternCtx[i].expose = 0;
+ }
+ }
+
+ void stopMacroChannels() {
+ for (int i = 0; i < kNumVoices; ++i) {
+ clearEffects(_channelCtx[i]);
+ unlockMacroChannel(_channelCtx[i]);
+ clearMacroProgramm(_channelCtx[i]);
+ _channelCtx[i].note = 0;
+ }
+ }
+
void setNoteMacro(ChannelContext &channel, uint note, int fineTune) {
const uint16 noteInt = noteIntervalls[note & 0x3F];
const uint16 finetune = (uint16)(fineTune + channel.fineTune + (1 << 8));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list