player_v4a:

Made musictimer work a bit better, merged the 2 tables into 1

svn-id: r41526
This commit is contained in:
Norbert Lange 2009-06-14 19:40:24 +00:00
parent 32d31928ee
commit 1fcd6bff08
5 changed files with 49 additions and 23 deletions

View file

@ -130,7 +130,6 @@
ForceConformanceInForLoopScope="true"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="0"
/>
<Tool

View file

@ -48,12 +48,12 @@ bool Player_V4A::init() {
if (mdatExists && sampleExists) {
Audio::Tfmx *play = new Audio::Tfmx(_mixer->getOutputRate(), true);
if (play->load(fileMdat, fileSample))
if (play->load(fileMdat, fileSample)) {
_tfmxPlay = play;
else
} else
delete play;
}
return true;
return _tfmxPlay != 0;
}
Player_V4A::~Player_V4A() {
@ -98,26 +98,23 @@ void Player_V4A::startSound(int nr) {
debug("%s", buf);
static const uint8 monkeyCommands[52] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 18, 17,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 16, 34, 0, 1, 2, 3, 7, 8, 10, 11, 4, 5, 14, 15, 12,
6, 13, 9, 19 };
static const uint8 monkeyTypes[52] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 };
static const int8 monkeyCommands[52] = {
-1, -2, -3, -4, -5, -6, -7, -8,
-9, -10, -11, -12, -13, -14, 18, 17,
-17, -18, -19, -20, -21, -22, -23, -24,
-25, -26, -27, -28, -29, -30, -31, -32,
-33, 16, -35, 0, 1, 2, 3, 7,
8, 10, 11, 4, 5, 14, 15, 12,
6, 13, 9, 19
};
int val = ptr[9];
if (val < 0 || val >= ARRAYSIZE(monkeyTypes))
if (val < 0 || val >= ARRAYSIZE(monkeyCommands))
debug("Tfmx: illegal Songnumber %i", val);
bool soundFX = monkeyTypes[val] == 1;
int index = monkeyCommands[val];
if (soundFX) {
if (index < 0) {
// SoundFX
debug("Tfmx: Soundpattern %i", index);
debug("Tfmx: Soundpattern %i", -index - 1);
} else {
// Song
@ -127,6 +124,7 @@ void Player_V4A::startSound(int nr) {
_tfmxPlay->doSong(index);
_musicId = nr;
_musicLastTicks = _tfmxPlay->getTicks();
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxPlay, -1, Audio::Mixer::kMaxChannelVolume, 0, false, false);
}
@ -134,9 +132,10 @@ void Player_V4A::startSound(int nr) {
int Player_V4A::getMusicTimer() const {
static int t = 0;
t += 300;
return t;
if (_musicId) {
return (_tfmxPlay->getTicks() - _musicLastTicks) / 25;
} else
return 0;
}
int Player_V4A::getSoundStatus(int nr) const {

View file

@ -54,10 +54,13 @@ public:
private:
ScummEngine *_vm;
Audio::Tfmx *_tfmxPlay;
Audio::Mixer *_mixer;
Audio::SoundHandle _musicHandle;
int _musicLastTicks;
enum {V4A_MAXSFX = 8};
struct SoundSlot {

View file

@ -31,6 +31,8 @@
#include "sound/mods/tfmx.h"
#include "tfmx/tfmxdebug.h"
namespace Audio {
const uint16 Tfmx::noteIntervalls[64] = {
@ -57,6 +59,7 @@ Tfmx::~Tfmx() {
void Tfmx::interrupt() {
//assert(!_end);
++_playerCtx.tickCount;
for (int i = 0; i < kNumVoices; ++i) {
ChannelContext &channel = _channelCtx[i];
@ -187,7 +190,7 @@ static void warnMacroUnimplemented(const byte *macroPtr, int level) {
else
debug("Warning - Macro not completely supported:");
// displayMacroStep(macroPtr);
displayMacroStep(macroPtr);
}
FORCEINLINE bool Tfmx::macroStep(ChannelContext &channel) {
@ -496,6 +499,18 @@ doTrackstep:
}
}
static void warnPatternUnimplemented(const byte *patternPtr, int level) {
if (level > 0)
return;
if (level == 0)
debug("Warning - Pattern not supported:");
else
debug("Warning - Pattern not completely supported:");
displayPatternstep(patternPtr);
}
FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) {
const byte *const patternPtr = (byte *)(_resource.getPatternPtr(pattern.offset) + pattern.step);
++pattern.step;
@ -547,6 +562,7 @@ FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) {
case 14: // Stop custompattern
// TODO ?
warnPatternUnimplemented(patternPtr, 0);
// FT
case 4: // Stop this pattern
pattern.command = 0xFF;
@ -565,10 +581,13 @@ FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) {
return true;
case 8: // Subroutine
warnPatternUnimplemented(patternPtr, 0);
return true;
case 9: // Return from Subroutine
warnPatternUnimplemented(patternPtr, 0);
return true;
case 10: // fade master volume
warnPatternUnimplemented(patternPtr, 0);
return true;
case 11: { // play pattern. Parameters: patternCmd, channel, expose
@ -589,7 +608,10 @@ FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) {
return true;
case 13: // Cue
warnPatternUnimplemented(patternPtr, 1);
debug("Cue/Signal %02X %04X", patternPtr[1], READ_BE_UINT16(&patternPtr[2]));
return true;
case 15: // NOP
return true;
}

View file

@ -49,6 +49,7 @@ public:
void doSong(int songPos);
void doMacro(int macro, int note);
bool load(Common::SeekableReadStream &musicData, Common::SeekableReadStream &sampleData);
int getTicks() {return _playerCtx.tickCount;}
// Note: everythings public so the debug-Routines work.
// private:
@ -200,6 +201,8 @@ public:
int8 fadeTime;
int8 fadeReset;
int8 fadeSlope; */
int tickCount;
} _playerCtx;
void initMacroProgramm(ChannelContext &channel) {