diff options
author | Norbert Lange | 2009-08-01 16:10:00 +0000 |
---|---|---|
committer | Norbert Lange | 2009-08-01 16:10:00 +0000 |
commit | 27ee1eb33179aa2cae92a9790867bfa5eaa0e471 (patch) | |
tree | 7bcd54e8db2a86bf73df5755ad8ae85d0ca4e456 | |
parent | 1becc072f91994425abc9d9e8a3759fc45f63017 (diff) | |
download | scummvm-rg350-27ee1eb33179aa2cae92a9790867bfa5eaa0e471.tar.gz scummvm-rg350-27ee1eb33179aa2cae92a9790867bfa5eaa0e471.tar.bz2 scummvm-rg350-27ee1eb33179aa2cae92a9790867bfa5eaa0e471.zip |
refactored and commented player_va4 a bit
fix waitcommand in Tfmx
try making tfmxplayer compile again
svn-id: r42976
-rw-r--r-- | dists/msvc9/scummvm-tfmx.vcproj | 11 | ||||
-rw-r--r-- | engines/scumm/player_v4a.cpp | 72 | ||||
-rw-r--r-- | engines/scumm/player_v4a.h | 18 | ||||
-rw-r--r-- | sound/mods/tfmx.cpp | 8 | ||||
-rw-r--r-- | sound/mods/tfmx.h | 1 | ||||
-rw-r--r-- | tfmx/tfmxplayer.cpp | 8 |
6 files changed, 64 insertions, 54 deletions
diff --git a/dists/msvc9/scummvm-tfmx.vcproj b/dists/msvc9/scummvm-tfmx.vcproj index 226a957329..b464fd432a 100644 --- a/dists/msvc9/scummvm-tfmx.vcproj +++ b/dists/msvc9/scummvm-tfmx.vcproj @@ -175,7 +175,7 @@ <Tool Name="VCCLCompilerTool" InlineFunctionExpansion="0" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NOT_TFMX_CMDLINE_TOOL;MXTX_CMDLINE_TOOL" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;TFMX_CMDLINE_TOOL;NMXTX_CMDLINE_TOOL" UsePrecompiledHeader="0" SuppressStartupBanner="false" Detect64BitPortabilityProblems="false" @@ -2018,6 +2018,14 @@ Name="VCCLCompilerTool" /> </FileConfiguration> + <FileConfiguration + Name="Debug_Command|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> </File> <File RelativePath="..\..\tfmx\tfmxdebug.h" @@ -2028,7 +2036,6 @@ > <FileConfiguration Name="Debug|Win32" - ExcludedFromBuild="true" > <Tool Name="VCCLCompilerTool" diff --git a/engines/scumm/player_v4a.cpp b/engines/scumm/player_v4a.cpp index 7c2b17ac3c..649f198f70 100644 --- a/engines/scumm/player_v4a.cpp +++ b/engines/scumm/player_v4a.cpp @@ -33,8 +33,9 @@ namespace Scumm { Player_V4A::Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer) - : _vm(scumm), _mixer(mixer), _musicId(), _sfxSlots(), _tfmxPlay(0), _tfmxSfx(0), _musicHandle(), _sfxHandle() { - init(); + : _vm(scumm), _mixer(mixer), _musicId(), _sfxSlots(), _initState(0), _tfmxMusic(0), _tfmxSfx(0), _musicHandle(), _sfxHandle(), _signal(0) { + assert(scumm); + assert(mixer); } bool Player_V4A::init() { @@ -49,8 +50,8 @@ bool Player_V4A::init() { if (mdatExists && sampleExists) { Audio::Tfmx *play = new Audio::Tfmx(_mixer->getOutputRate(), true); if (play->load(fileMdat, fileSample)) { - play->setSignalPtr(_signal, ARRAYSIZE(_signal)); - _tfmxPlay = play; + play->setSignalPtr(&_signal, 1); + _tfmxMusic = play; } else delete play; @@ -62,13 +63,13 @@ bool Player_V4A::init() { } else delete play; } - return _tfmxPlay != 0; + return _tfmxMusic != 0; } Player_V4A::~Player_V4A() { _mixer->stopHandle(_musicHandle); _mixer->stopHandle(_sfxHandle); - delete _tfmxPlay; + delete _tfmxMusic; delete _tfmxSfx; } @@ -78,9 +79,9 @@ void Player_V4A::setMusicVolume(int vol) { void Player_V4A::stopAllSounds() { debug(5, "player_v4a: stopAllSounds"); - if (_tfmxPlay) { - _tfmxPlay->stopSong(); - _signal[0] = 0; + if (_tfmxMusic) { + _tfmxMusic->stopSong(); + _signal = 0; } _musicId = 0; if (_tfmxSfx) @@ -94,8 +95,8 @@ void Player_V4A::stopSound(int nr) { return; if (nr == _musicId) { _musicId = 0; - _tfmxPlay->stopSong(); - _signal[0] = 0; + _tfmxMusic->stopSong(); + _signal = 0; } else { const int chan = getSfxChan(nr); if (chan != -1) { @@ -106,10 +107,6 @@ void Player_V4A::stopSound(int nr) { } void Player_V4A::startSound(int nr) { - assert(_vm); - const byte *ptr = _vm->getResourceAddress(rtSound, nr); - assert(ptr); - static const int8 monkeyCommands[52] = { -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, 18, 17, @@ -120,67 +117,70 @@ void Player_V4A::startSound(int nr) { 6, 13, 9, 19 }; + const byte *ptr = _vm->getResourceAddress(rtSound, nr); + assert(ptr); + const int val = ptr[9]; if (val < 0 || val >= ARRAYSIZE(monkeyCommands)) { warning("player_v4a: illegal Songnumber %i", val); return; } - if (!_tfmxSfx || !_tfmxPlay) + if (!_initState) + _initState = init() ? 1 : -1; + + if (_initState <= 0) return; int index = monkeyCommands[val]; const byte type = ptr[6]; - if (index < 0) { - // SoundFX + if (index < 0) { // SoundFX index = -index - 1; debug(3, "player_v4a: play %d: custom %i - %02X", nr, index, type); + // start an empty Song so timing is setup if (_tfmxSfx->getSongIndex() < 0) _tfmxSfx->doSong(0x18); + const int chan = _tfmxSfx->doSfx((uint16)index); if (chan >= 0 && chan < ARRAYSIZE(_sfxSlots)) setSfxSlot(chan, nr, type); else warning("player_v4a: custom %i is not of required type", index); + // the Tfmx-player newer "ends" the output by itself, so this should be threadsafe if (!_mixer->isSoundHandleActive(_sfxHandle)) _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, _tfmxSfx, -1, Audio::Mixer::kMaxChannelVolume, 0, false); - } else { - // Song + + } else { // Song debug(3, "player_v4a: play %d: song %i - %02X", nr, index, type); if (ptr[6] != 0x7F) warning("player_v4a: Song has wrong type"); - _tfmxPlay->doSong(index); - _signal[0] = 2; + _tfmxMusic->doSong(index); + _signal = 2; _musicId = nr; + // the Tfmx-player newer "ends" the output by itself, so this should be threadsafe if (!_mixer->isSoundHandleActive(_musicHandle)) - _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxPlay, -1, Audio::Mixer::kMaxChannelVolume, 0, false); + _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxMusic, -1, Audio::Mixer::kMaxChannelVolume, 0, false); } } int Player_V4A::getMusicTimer() const { if (_musicId) { - // TODO: The titlesong is running with ~70 ticks per second and the scale seems to be based on that. - // Other songs dont and I have no clue if this scalevalue is anything close to correct for them. - // The Amiga-Game doesnt counts the ticks of the song, but has an own timer and I hope thespeed is constant through the game - const int magicScale = 357; // ~ 1000 * 25 * (10173 / 709379.0) - return (_mixer->getSoundElapsedTime(_musicHandle)) / magicScale; + // The titlesong (and a few others) is running with ~70 ticks per second and the scale seems to be based on that. + // The Game itself doesnt get the timing from the Tfmx Player however, so we just use the elapsed time + // 357 ~ 1000 * 25 * (1 / 70) + return (_mixer->getSoundElapsedTime(_musicHandle)) / 357; } return 0; } int Player_V4A::getSoundStatus(int nr) const { - bool a = nr == _musicId; - bool b = _tfmxPlay->getSongIndex() >= 0; - int c = _signal[0]; - - debug(5, "player_v4a: getSoundStatus music=%d, active=%d, signal=%d", a, b, c); - if (nr == _musicId) - return _signal[0]; - return 0; + // For music the game queues a variable the Tfmx Player sets through a special command. + // For sfx there seems to be no way to queue them, and the game doesnt try to. + return (nr == _musicId) ? _signal : 0; } } // End of namespace Scumm diff --git a/engines/scumm/player_v4a.h b/engines/scumm/player_v4a.h index 3b454e9349..373e06fe41 100644 --- a/engines/scumm/player_v4a.h +++ b/engines/scumm/player_v4a.h @@ -53,22 +53,24 @@ public: virtual int getSoundStatus(int sound) const; private: - ScummEngine *_vm; + ScummEngine *const _vm; + Audio::Mixer *const _mixer; - Audio::Tfmx *_tfmxPlay; + Audio::Tfmx *_tfmxMusic; Audio::Tfmx *_tfmxSfx; - Audio::Mixer *_mixer; Audio::SoundHandle _musicHandle; Audio::SoundHandle _sfxHandle; int _musicId; - uint16 _signal[4]; - + uint16 _signal; + struct SfxChan { int id; - byte type; +// byte type; } _sfxSlots[4]; + int8 _initState; // < 0: failed, 0: uninitialised, > 0: initialised + int getSfxChan(int id) const { for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i) if (_sfxSlots[i].id == id) @@ -78,13 +80,13 @@ private: void setSfxSlot(int channel, int id, byte type = 0) { _sfxSlots[channel].id = id; - _sfxSlots[channel].type = type; +// _sfxSlots[channel].type = type; } void clearSfxSlots() { for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i){ _sfxSlots[i].id = 0; - _sfxSlots[i].type = 0; +// _sfxSlots[i].type = 0; } } diff --git a/sound/mods/tfmx.cpp b/sound/mods/tfmx.cpp index 55e2481aea..a9adf27a25 100644 --- a/sound/mods/tfmx.cpp +++ b/sound/mods/tfmx.cpp @@ -213,7 +213,7 @@ void Tfmx::effects(ChannelContext &channel) { } void Tfmx::macroRun(ChannelContext &channel) { - bool deferWait = false; + bool deferWait = channel.deferWait; for (;;) { const byte *const macroPtr = (byte *)(_resource.getMacroPtr(channel.macroOffset) + channel.macroStep); ++channel.macroStep; @@ -276,7 +276,7 @@ void Tfmx::macroRun(ChannelContext &channel) { case 0x04: // Wait. Parameters: Ticks to wait(W). // TODO: some unkown Parameter? (macroPtr[1] & 1) channel.macroWait = READ_BE_UINT16(¯oPtr[2]); - return; + break; case 0x10: // Loop Key Up. Parameters: Loopcount, MacroStep(W) if (channel.keyUp) @@ -401,7 +401,7 @@ void Tfmx::macroRun(ChannelContext &channel) { // TODO: MI loads 24 bit, but thats useless? const uint16 temp = /* ((int8)macroPtr[1] << 16) | */ READ_BE_UINT16(¯oPtr[2]); if (macroPtr[1] || (temp & 1)) - warning("Tfmx: Problematic value for sampleloop: %i", (macroPtr[1] << 16) | temp); + warning("Tfmx: Problematic value for sampleloop: %06X", (macroPtr[1] << 16) | temp); channel.sampleStart += temp & 0xFFFE; channel.sampleLen -= (temp / 2) /* & 0x7FFF */; Paula::setChannelSampleStart(channel.paulaChannel, _resource.getSamplePtr(channel.sampleStart)); @@ -871,7 +871,7 @@ void Tfmx::doMacro(int note, int macro, int relVol, int finetune, int channelNo) startPaula(); } -void Tfmx::stopMacroEffect(int channel) { +void Tfmx::stopMacroEffect(int channel) { assert(0 <= channel && channel < kNumVoices); Common::StackLock lock(_mutex); unlockMacroChannel(_channelCtx[channel]); diff --git a/sound/mods/tfmx.h b/sound/mods/tfmx.h index 267c122ce3..f720d727d6 100644 --- a/sound/mods/tfmx.h +++ b/sound/mods/tfmx.h @@ -232,6 +232,7 @@ private: channel.macroSfxRun = 0; channel.macroLoopCount = 0xFF; channel.dmaIntCount = 0; + channel.deferWait = false; } static void clearEffects(ChannelContext &channel) { diff --git a/tfmx/tfmxplayer.cpp b/tfmx/tfmxplayer.cpp index a41b79dc41..adf4b9866c 100644 --- a/tfmx/tfmxplayer.cpp +++ b/tfmx/tfmxplayer.cpp @@ -72,7 +72,7 @@ void modcmdmain(const int argc, const char *const argv[]) { if (i + 1 < argc) { param = atoi(argv[++i]); debug( "play Macro %02X", param); - dumpMacro(*player, param); + //dumpMacro(*player, param); player->doMacro(0x1B, param); hasCmd = true; } @@ -80,7 +80,7 @@ void modcmdmain(const int argc, const char *const argv[]) { if (i + 1 < argc) { param = atoi(argv[++i]); debug( "play Song %02X", param); - dumpTrackstepsBySong(*player, param); + //dumpTrackstepsBySong(*player, param); player->doSong(param); hasCmd = true; } @@ -96,13 +96,13 @@ void modcmdmain(const int argc, const char *const argv[]) { } else if (!strcmp("-flac", argv[i])) { playflag = 2; } else if (!strcmp("-hack-patternstop", argv[i])) - player->_playerCtx.stopWithLastPattern = true; + // player->_playerCtx.stopWithLastPattern = true; ++i; } if (!hasCmd) { player->doSong(4); - dumpTrackstepsBySong(*player, 4); + //dumpTrackstepsBySong(*player, 4); } |