mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-10 04:43:26 +00:00
moved code for initialising patterns into own function
added initialisation of return-addresses for patterns and macros svn-id: r43045
This commit is contained in:
parent
0306695459
commit
e6f8bfafc7
@ -334,6 +334,7 @@ void Tfmx::macroRun(ChannelContext &channel) {
|
|||||||
channel.vibLength = macroPtr[1];
|
channel.vibLength = macroPtr[1];
|
||||||
channel.vibCount = macroPtr[1] / 2;
|
channel.vibCount = macroPtr[1] / 2;
|
||||||
channel.vibDelta = macroPtr[3];
|
channel.vibDelta = macroPtr[3];
|
||||||
|
// TODO: Perhaps a bug, vibValue could be left uninitialised
|
||||||
if (!channel.portaDelta) {
|
if (!channel.portaDelta) {
|
||||||
channel.period = channel.refPeriod;
|
channel.period = channel.refPeriod;
|
||||||
channel.vibValue = 0;
|
channel.vibValue = 0;
|
||||||
@ -358,7 +359,7 @@ void Tfmx::macroRun(ChannelContext &channel) {
|
|||||||
channel.envEndVolume = macroPtr[3];
|
channel.envEndVolume = macroPtr[3];
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 0x11: // Add Begin. Parameters: times, Offset(W)
|
case 0x11: // Add Beginn. Parameters: times, Offset(W)
|
||||||
channel.addBeginLength = channel.addBeginCount = macroPtr[1];
|
channel.addBeginLength = channel.addBeginCount = macroPtr[1];
|
||||||
channel.addBeginDelta = (int16)READ_BE_UINT16(¯oPtr[2]);
|
channel.addBeginDelta = (int16)READ_BE_UINT16(¯oPtr[2]);
|
||||||
channel.sampleStart += channel.addBeginDelta;
|
channel.sampleStart += channel.addBeginDelta;
|
||||||
@ -482,8 +483,10 @@ startPatterns:
|
|||||||
// issue all Steps for this tick
|
// issue all Steps for this tick
|
||||||
if (patternRun(pattern)) {
|
if (patternRun(pattern)) {
|
||||||
// we load the next Trackstep Command and then process all Channels again
|
// we load the next Trackstep Command and then process all Channels again
|
||||||
trackRun(true);
|
if (trackRun(true))
|
||||||
goto startPatterns;
|
goto startPatterns;
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@ -493,7 +496,7 @@ startPatterns:
|
|||||||
pattern.command = 0xFF;
|
pattern.command = 0xFF;
|
||||||
ChannelContext &channel = _channelCtx[pattern.expose & (kNumVoices - 1)];
|
ChannelContext &channel = _channelCtx[pattern.expose & (kNumVoices - 1)];
|
||||||
if (!channel.sfxLocked) {
|
if (!channel.sfxLocked) {
|
||||||
clearMacroProgramm(channel);
|
haltMacroProgramm(channel);
|
||||||
Paula::disableChannel(channel.paulaChannel);
|
Paula::disableChannel(channel.paulaChannel);
|
||||||
}
|
}
|
||||||
} // else this pattern-Channel is stopped
|
} // else this pattern-Channel is stopped
|
||||||
@ -587,16 +590,8 @@ bool Tfmx::patternRun(PatternContext &pattern) {
|
|||||||
initFadeCommand((uint8)patternPtr[1], (int8)patternPtr[3]);
|
initFadeCommand((uint8)patternPtr[1], (int8)patternPtr[3]);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 11: { // play pattern. Parameters: patternCmd, channel, expose
|
case 11: // play pattern. Parameters: patternCmd, channel, expose
|
||||||
PatternContext &target = _patternCtx[patternPtr[2] & (kNumChannels - 1)];
|
initPattern(_patternCtx[patternPtr[2] & (kNumChannels - 1)], patternPtr[1], patternPtr[3], _resource->patternOffset[patternPtr[1] & (kMaxPatternOffsets - 1)]);
|
||||||
|
|
||||||
target.command = patternPtr[1];
|
|
||||||
target.offset = _resource->patternOffset[patternPtr[1] & (kMaxPatternOffsets - 1)];
|
|
||||||
target.expose = patternPtr[3];
|
|
||||||
target.step = 0;
|
|
||||||
target.wait = 0;
|
|
||||||
target.loopCount = 0xFF;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 12: // Lock. Parameters: lockFlag, channel, lockTime
|
case 12: // Lock. Parameters: lockFlag, channel, lockTime
|
||||||
@ -631,18 +626,16 @@ bool Tfmx::trackRun(const bool incStep) {
|
|||||||
if (trackData[0] != FROM_BE_16(0xEFFE)) {
|
if (trackData[0] != FROM_BE_16(0xEFFE)) {
|
||||||
// 8 commands for Patterns
|
// 8 commands for Patterns
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
const uint patCmd = READ_BE_UINT16(&trackData[i]);
|
const uint8 *patCmd = (const uint8 *)&trackData[i];
|
||||||
// First byte is pattern number
|
// First byte is pattern number
|
||||||
const uint patNum = (patCmd >> 8);
|
const uint8 patNum = patCmd[0];
|
||||||
// if highest bit is set then keep previous pattern
|
// if highest bit is set then keep previous pattern
|
||||||
if (patNum < 0x80) {
|
if (patNum < 0x80) {
|
||||||
_patternCtx[i].step = 0;
|
initPattern(_patternCtx[i], patNum, patCmd[1], _resource->patternOffset[patNum]);
|
||||||
_patternCtx[i].wait = 0;
|
} else {
|
||||||
_patternCtx[i].loopCount = 0xFF;
|
_patternCtx[i].command = patNum;
|
||||||
_patternCtx[i].offset = _resource->patternOffset[patNum];
|
_patternCtx[i].expose = (int8)patCmd[1];
|
||||||
}
|
}
|
||||||
_patternCtx[i].command = (uint8)patNum;
|
|
||||||
_patternCtx[i].expose = patCmd & 0xFF;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -938,7 +931,7 @@ void Tfmx::stopMacroEffect(int channel) {
|
|||||||
assert(0 <= channel && channel < kNumVoices);
|
assert(0 <= channel && channel < kNumVoices);
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
unlockMacroChannel(_channelCtx[channel]);
|
unlockMacroChannel(_channelCtx[channel]);
|
||||||
clearMacroProgramm(_channelCtx[channel]);
|
haltMacroProgramm(_channelCtx[channel]);
|
||||||
Paula::disableChannel(_channelCtx[channel].paulaChannel);
|
Paula::disableChannel(_channelCtx[channel].paulaChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +231,9 @@ private:
|
|||||||
channel.macroLoopCount = 0xFF;
|
channel.macroLoopCount = 0xFF;
|
||||||
channel.dmaIntCount = 0;
|
channel.dmaIntCount = 0;
|
||||||
channel.deferWait = false;
|
channel.deferWait = false;
|
||||||
|
|
||||||
|
channel.macroReturnOffset = 0;
|
||||||
|
channel.macroReturnStep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearEffects(ChannelContext &channel) {
|
static void clearEffects(ChannelContext &channel) {
|
||||||
@ -240,7 +243,7 @@ private:
|
|||||||
channel.portaDelta = 0;
|
channel.portaDelta = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearMacroProgramm(ChannelContext &channel) {
|
static void haltMacroProgramm(ChannelContext &channel) {
|
||||||
channel.macroRun = false;
|
channel.macroRun = false;
|
||||||
channel.dmaIntCount = 0;
|
channel.dmaIntCount = 0;
|
||||||
}
|
}
|
||||||
@ -252,6 +255,18 @@ private:
|
|||||||
channel.sfxLockTime = -1;
|
channel.sfxLockTime = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void initPattern(PatternContext &pattern, uint8 cmd, int8 expose, uint32 offset) {
|
||||||
|
pattern.command = cmd;
|
||||||
|
pattern.offset = offset;
|
||||||
|
pattern.expose = expose;
|
||||||
|
pattern.step = 0;
|
||||||
|
pattern.wait = 0;
|
||||||
|
pattern.loopCount = 0xFF;
|
||||||
|
|
||||||
|
pattern.savedOffset = 0;
|
||||||
|
pattern.savedStep = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void stopPatternChannels() {
|
void stopPatternChannels() {
|
||||||
for (int i = 0; i < kNumChannels; ++i) {
|
for (int i = 0; i < kNumChannels; ++i) {
|
||||||
_patternCtx[i].command = 0xFF;
|
_patternCtx[i].command = 0xFF;
|
||||||
@ -263,7 +278,7 @@ private:
|
|||||||
for (int i = 0; i < kNumVoices; ++i) {
|
for (int i = 0; i < kNumVoices; ++i) {
|
||||||
clearEffects(_channelCtx[i]);
|
clearEffects(_channelCtx[i]);
|
||||||
unlockMacroChannel(_channelCtx[i]);
|
unlockMacroChannel(_channelCtx[i]);
|
||||||
clearMacroProgramm(_channelCtx[i]);
|
haltMacroProgramm(_channelCtx[i]);
|
||||||
_channelCtx[i].note = 0;
|
_channelCtx[i].note = 0;
|
||||||
_channelCtx[i].volume = 0;
|
_channelCtx[i].volume = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user