diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/kyra_lok.cpp | 9 | ||||
-rw-r--r-- | engines/kyra/kyra_lok.h | 3 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 7 | ||||
-rw-r--r-- | engines/kyra/module.mk | 1 | ||||
-rw-r--r-- | engines/kyra/seqplayer.cpp | 5 | ||||
-rw-r--r-- | engines/kyra/sequences_lok.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/sound.cpp | 7 | ||||
-rw-r--r-- | engines/kyra/sound.h | 3 | ||||
-rw-r--r-- | engines/kyra/sound_amiga.cpp | 234 | ||||
-rw-r--r-- | engines/kyra/sound_intern.h | 30 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 180 | ||||
-rw-r--r-- | engines/scumm/module.mk | 1 | ||||
-rw-r--r-- | engines/scumm/music.h | 6 | ||||
-rw-r--r-- | engines/scumm/palette.cpp | 318 | ||||
-rw-r--r-- | engines/scumm/player_v4a.cpp | 193 | ||||
-rw-r--r-- | engines/scumm/player_v4a.h | 98 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 25 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 10 | ||||
-rw-r--r-- | engines/scumm/sound.cpp | 20 |
19 files changed, 893 insertions, 259 deletions
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index 36f134d9e4..fc19b2fb65 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -183,8 +183,13 @@ Common::Error KyraEngine_LoK::init() { _sound->setSoundList(&_soundData[kMusicIntro]); - _trackMap = _dosTrackMap; - _trackMapSize = _dosTrackMapSize; + if (_flags.platform == Common::kPlatformAmiga) { + _trackMap = _amigaTrackMap; + _trackMapSize = _amigaTrackMapSize; + } else { + _trackMap = _dosTrackMap; + _trackMapSize = _dosTrackMapSize; + } if (!_sound->init()) error("Couldn't init sound"); diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h index e7cc92c5e1..5d20cb0652 100644 --- a/engines/kyra/kyra_lok.h +++ b/engines/kyra/kyra_lok.h @@ -507,6 +507,9 @@ protected: static const int8 _dosTrackMap[]; static const int _dosTrackMapSize; + static const int8 _amigaTrackMap[]; + static const int _amigaTrackMapSize; + // TODO: get rid of all variables having pointers to the static resources if possible // i.e. let them directly use the _staticres functions void initStaticResource(); diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index d79d9a8f32..9ee6935384 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -50,7 +50,10 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) _emc = 0; _debugger = 0; - _gameSpeed = 60; + if (_flags.platform == Common::kPlatformAmiga) + _gameSpeed = 50; + else + _gameSpeed = 60; _tickLength = (uint8)(1000.0 / _gameSpeed); _trackMap = 0; @@ -114,6 +117,8 @@ Common::Error KyraEngine_v1::init() { _sound = new SoundPC98(this, _mixer); else _sound = new SoundTownsPC98_v2(this, _mixer); + } else if (_flags.platform == Common::kPlatformAmiga) { + _sound = new SoundAmiga(this, _mixer); } else if (midiDriver == MD_ADLIB) { _sound = new SoundAdlibPC(this, _mixer); } else { diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index 7b0c0dfb68..b484fa345f 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -50,6 +50,7 @@ MODULE_OBJS := \ sequences_hof.o \ sequences_mr.o \ sound_adlib.o \ + sound_amiga.o \ sound_digital.o \ sound_midi.o \ sound_pcspk.o \ diff --git a/engines/kyra/seqplayer.cpp b/engines/kyra/seqplayer.cpp index 38d1b90e7a..4086d06c00 100644 --- a/engines/kyra/seqplayer.cpp +++ b/engines/kyra/seqplayer.cpp @@ -414,8 +414,6 @@ void SeqPlayer::s1_fillRect() { void SeqPlayer::s1_playEffect() { uint8 track = *_seqData++; - if (_vm->gameFlags().platform == Common::kPlatformAmiga) - return; _vm->delay(3 * _vm->tickLength()); _sound->playSoundEffect(track); } @@ -423,9 +421,6 @@ void SeqPlayer::s1_playEffect() { void SeqPlayer::s1_playTrack() { uint8 msg = *_seqData++; - if (_vm->gameFlags().platform == Common::kPlatformAmiga) - return; - if (msg == 1) { _sound->beginFadeOut(); } else { diff --git a/engines/kyra/sequences_lok.cpp b/engines/kyra/sequences_lok.cpp index 8425bf9b0c..5b41c3cef8 100644 --- a/engines/kyra/sequences_lok.cpp +++ b/engines/kyra/sequences_lok.cpp @@ -110,7 +110,7 @@ void KyraEngine_LoK::seq_intro() { _seq->setCopyViewOffs(true); _screen->setFont(Screen::FID_8_FNT); - if (_flags.platform != Common::kPlatformFMTowns && _flags.platform != Common::kPlatformPC98) + if (_flags.platform != Common::kPlatformFMTowns && _flags.platform != Common::kPlatformPC98 && _flags.platform != Common::kPlatformAmiga) snd_playTheme(0, 2); _text->setTalkCoords(144); diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 4d42b1efb7..83584ab454 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -215,6 +215,13 @@ void KyraEngine_v1::snd_playWanderScoreViaMap(int command, int restart) { _sound->playTrack(command); } } + } else if (_flags.platform == Common::kPlatformAmiga) { + if (_curMusicTheme != 1) + snd_playTheme(1, -1); + + assert(command < _trackMapSize); + if (_trackMap[_lastMusicCommand] != _trackMap[command]) + _sound->playTrack(_trackMap[command]); } _lastMusicCommand = command; diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 263cd586f7..2f24a264f1 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -55,7 +55,8 @@ public: kMidiGM, kTowns, kPC98, - kPCSpkr + kPCSpkr, + kAmiga }; virtual kType getMusicType() const = 0; diff --git a/engines/kyra/sound_amiga.cpp b/engines/kyra/sound_amiga.cpp new file mode 100644 index 0000000000..17e27ccc32 --- /dev/null +++ b/engines/kyra/sound_amiga.cpp @@ -0,0 +1,234 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/system.h" +#include "common/mutex.h" +#include "kyra/resource.h" +#include "kyra/sound_intern.h" + +#include "sound/mixer.h" +#include "sound/mods/maxtrax.h" +#include "sound/audiostream.h" + +namespace { + +FORCEINLINE uint8 sfxTableGetNote(const byte* address) { + return (uint8)address[0]; +} +FORCEINLINE uint8 sfxTableGetPatch(const byte* address) { + return (uint8)address[1]; +} +FORCEINLINE uint16 sfxTableGetDuration(const byte* address) { + return READ_BE_UINT16(&address[4]); +} +FORCEINLINE int8 sfxTableGetVolume(const byte* address) { + return (int8)address[6]; +} +FORCEINLINE int8 sfxTableGetPan(const byte* address) { + return (int8)address[7]; +} + +} // end of namespace + +namespace Kyra { + +SoundAmiga::SoundAmiga(KyraEngine_v1 *vm, Audio::Mixer *mixer) + : Sound(vm, mixer), + _driver(0), + _musicHandle(), + _fileLoaded(kFileNone), + _tableSfxIntro(), + _tableSfxGame() { +} + +SoundAmiga::~SoundAmiga() { + _mixer->stopHandle(_musicHandle); + delete _driver; +} + +extern const byte LoKAmigaSfxIntro[]; +extern const byte LoKAmigaSfxGame[]; + +bool SoundAmiga::init() { + _driver = new Audio::MaxTrax(_mixer->getOutputRate(), true); + _tableSfxIntro = LoKAmigaSfxIntro; + _tableSfxGame = LoKAmigaSfxGame; + + return _driver != 0 && _tableSfxIntro && _tableSfxGame; +} + +void SoundAmiga::loadSoundFile(uint file) { + static const char *const tableFilenames[3][2] = { + { "introscr.mx", "introinst.mx" }, + { "kyramusic.mx", 0 }, + { "finalescr.mx", "introinst.mx" } + }; + assert(file < ARRAYSIZE(tableFilenames)); + if (_fileLoaded == (FileType)file) + return; + const char* scoreName = tableFilenames[file][0]; + const char* sampleName = tableFilenames[file][1]; + bool loaded = false; + + Common::SeekableReadStream *scoreIn = _vm->resource()->createReadStream(scoreName); + if (sampleName) { + Common::SeekableReadStream *sampleIn = _vm->resource()->createReadStream(sampleName); + if (scoreIn && sampleIn) { + _fileLoaded = kFileNone; + loaded = _driver->load(*scoreIn, true, false); + loaded = loaded && _driver->load(*sampleIn, false, true); + } else + warning("SoundAmiga: missing atleast one of those music files: %s, %s", scoreName, sampleName); + delete sampleIn; + } else { + if (scoreIn) { + _fileLoaded = kFileNone; + loaded = _driver->load(*scoreIn); + } else + warning("SoundAmiga: missing music file: %s", scoreName); + } + delete scoreIn; + + if (loaded) + _fileLoaded = (FileType)file; +} + +void SoundAmiga::playTrack(uint8 track) { + static const byte tempoIntro[6] = { 0x46, 0x55, 0x3C, 0x41, 0x78, 0x50 }; + static const byte tempoIngame[23] = { + 0x64, 0x64, 0x64, 0x64, 0x64, 0x73, 0x4B, 0x64, + 0x64, 0x64, 0x55, 0x9C, 0x6E, 0x91, 0x78, 0x84, + 0x32, 0x64, 0x64, 0x6E, 0x3C, 0xD8, 0xAF + }; + static const byte loopIngame[23] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 + }; + + int score = -1; + bool loop = false; + byte volume = 0x40; + byte tempo = 0; + + + switch (_fileLoaded) { + case kFileFinal: + // score 0 gets started immediately after loading the music-files with different tempo. + // we need to define a track-value for the fake call of this function + if (track == 10) { + score = 0; + loop = true; + tempo = 0x78; + break; + } + // if this is not the hardcoded start of the song then + // Fallthrough + case kFileIntro: + if (track >= 2 && track < ARRAYSIZE(tempoIntro) + 2) { + score = track - 2; + tempo = tempoIntro[score]; + } + break; + + case kFileGame: + if (track >= 11 && track < ARRAYSIZE(tempoIngame) + 11) { + score = track - 11; + loop = loopIngame[score] != 0; + tempo = tempoIngame[score]; + } + break; + + default: + return; + } + + if (score >= 0) { + if (_driver->playSong(score, loop)) { + _driver->setVolume(volume); + _driver->setTempo(tempo << 4); + if (!_mixer->isSoundHandleActive(_musicHandle)) + _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_musicHandle, _driver, -1, Audio::Mixer::kMaxChannelVolume, 0, false); + } + } else if (track == 0) + _driver->stopMusic(); + else if (track == 1) + beginFadeOut(); +} + +void SoundAmiga::haltTrack() { + _driver->stopMusic(); +} + +void SoundAmiga::beginFadeOut() { + for (int i = 0x3F; i >= 0; --i) { + _driver->setVolume((byte)i); + _vm->delay(_vm->tickLength()); + } + + _driver->stopMusic(); + _vm->delay(_vm->tickLength()); + _driver->setVolume(0x40); +} + +void SoundAmiga::playSoundEffect(uint8 track) { + debug("play sfx %d", track); + const byte* tableEntry = 0; + bool pan = false; + + switch (_fileLoaded) { + case kFileFinal: + case kFileIntro: + assert(track < 40); + + tableEntry = &_tableSfxIntro[track * 8]; + pan = (sfxTableGetPan(tableEntry) != 0); + break; + + case kFileGame: + // 0x61 <= track && track <= 0x63 && variable(0x1BFE2) which might indicate song playing in game and finale + if (0x61 <= track && track <= 0x63) + playTrack(track - 0x4F); + + assert(track < 120); + // variable(0x1BFE4) && tableEffectsGame[track].note, which gets set for ingame and unset for finale + // (and some function reverses its state) + if (sfxTableGetNote(&_tableSfxGame[track * 8])) { + tableEntry = &_tableSfxGame[track * 8]; + pan = (sfxTableGetPan(tableEntry) != 0) && (sfxTableGetPan(tableEntry) != 2); + } + break; + default: + ; + } + + if (tableEntry) { + const bool success = _driver->playNote(sfxTableGetNote(tableEntry), sfxTableGetPatch(tableEntry), sfxTableGetDuration(tableEntry), sfxTableGetVolume(tableEntry), pan); + if (success && !_mixer->isSoundHandleActive(_musicHandle)) + _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_musicHandle, _driver, -1, Audio::Mixer::kMaxChannelVolume, 0, false); + } +} + +} // end of namespace Kyra diff --git a/engines/kyra/sound_intern.h b/engines/kyra/sound_intern.h index 975672b76a..b85b8a2e30 100644 --- a/engines/kyra/sound_intern.h +++ b/engines/kyra/sound_intern.h @@ -37,6 +37,7 @@ namespace Audio { class PCSpeaker; +class MaxTrax; } // end of namespace Audio namespace Kyra { @@ -284,7 +285,34 @@ private: static const uint8 _noteTable2[]; }; +class SoundAmiga : public Sound { +public: + SoundAmiga(KyraEngine_v1 *vm, Audio::Mixer *mixer); + ~SoundAmiga(); + + virtual kType getMusicType() const { return kAmiga; } //FIXME + + bool init(); + + void process() {} + void loadSoundFile(uint file); + void loadSoundFile(Common::String) {} + + void playTrack(uint8 track); + void haltTrack(); + void beginFadeOut(); + + int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx) { return -1; } + void playSoundEffect(uint8); + +protected: + Audio::MaxTrax *_driver; + Audio::SoundHandle _musicHandle; + enum FileType { kFileNone = -1, kFileIntro = 0, kFileGame = 1, kFileFinal = 2 } _fileLoaded; + const byte *_tableSfxIntro; + const byte *_tableSfxGame; +}; + } // end of namespace Kyra #endif - diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index e33d24bf59..83f4b22b6d 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2353,6 +2353,18 @@ const int8 KyraEngine_LoK::_dosTrackMap[] = { const int KyraEngine_LoK::_dosTrackMapSize = ARRAYSIZE(KyraEngine_LoK::_dosTrackMap); +const int8 KyraEngine_LoK::_amigaTrackMap[] = { + 0, 1, 32, 26, 31, 30, 33, 33, + 32, 17, 27, 32, 25, 29, 25, 24, + 23, 26, 26, 30, 28, 21, 21, 15, + 3, 15, 23, 25, 33, 21, 30, 22, + 15, 3, 33, 11, 12, 13, 14, 22, + 22, 22, 3, 3, 3, 23, 3, 3, + 23, 3, 3, 3, 3, 3, 3, 33 +}; + +const int KyraEngine_LoK::_amigaTrackMapSize = ARRAYSIZE(KyraEngine_LoK::_amigaTrackMap); + // kyra engine v2 static data const int GUI_v2::_sliderBarsPosition[] = { @@ -3364,4 +3376,172 @@ const int LoLEngine::_outroMonsterScaleTableY[] = { #endif // ENABLE_LOL +// TODO: fileoffset = 0x32D5C, len = 40 * 8 +extern const byte LoKAmigaSfxIntro[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x6E, 0x00, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x6E, 0x00, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x6E, 0x00, + 0x3C, 0x13, 0x00, 0x00, 0x1B, 0x91, 0x6E, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x16, 0x00, 0x00, 0x26, 0x77, 0x6E, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x17, 0x00, 0x00, 0x11, 0x98, 0x6E, 0x00, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x6E, 0x00, + 0x3C, 0x18, 0x00, 0x00, 0x22, 0xD1, 0x6E, 0x00, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x6E, 0x00, + 0x45, 0x03, 0x00, 0x00, 0x02, 0x24, 0x6E, 0x00, + 0x3C, 0x16, 0x00, 0x00, 0x26, 0x77, 0x6E, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +// TODO: fileoffset = 0x2C55E, len = 120 * 8 +extern const byte LoKAmigaSfxGame[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x13, 0x00, 0x00, 0x01, 0x56, 0x78, 0x02, + 0x3C, 0x14, 0x00, 0x00, 0x27, 0x2C, 0x78, 0x02, + 0x3C, 0x15, 0x00, 0x00, 0x1B, 0x91, 0x78, 0x02, + 0x3C, 0x16, 0x00, 0x00, 0x1E, 0x97, 0x78, 0x02, + 0x3C, 0x17, 0x00, 0x00, 0x12, 0x2B, 0x78, 0x02, + 0x3C, 0x16, 0x00, 0x00, 0x1E, 0x97, 0x78, 0x02, + 0x45, 0x03, 0x00, 0x00, 0x02, 0x24, 0x78, 0x02, + 0x3C, 0x16, 0x00, 0x00, 0x1E, 0x97, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x2C, 0x04, 0x00, 0x00, 0x09, 0x10, 0x78, 0x02, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x3C, 0x1A, 0x00, 0x00, 0x3A, 0xEB, 0x78, 0x02, + 0x25, 0x1B, 0x00, 0x00, 0x13, 0x8B, 0x78, 0x02, + 0x18, 0x03, 0x00, 0x00, 0x0F, 0x52, 0x78, 0x02, + 0x3E, 0x1C, 0x00, 0x00, 0x06, 0x22, 0x78, 0x02, + 0x3B, 0x1C, 0x00, 0x00, 0x07, 0x54, 0x78, 0x02, + 0x16, 0x03, 0x00, 0x00, 0x20, 0x6F, 0x78, 0x02, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x3C, 0x1D, 0x00, 0x00, 0x09, 0xEA, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x14, 0x00, 0x00, 0x27, 0x2C, 0x78, 0x02, + 0x3C, 0x1E, 0x00, 0x00, 0x03, 0x6E, 0x78, 0x02, + 0x3C, 0x17, 0x00, 0x00, 0x12, 0x2B, 0x78, 0x02, + 0x4E, 0x0B, 0x00, 0x00, 0x09, 0x91, 0x78, 0x02, + 0x47, 0x1B, 0x00, 0x00, 0x02, 0xBC, 0x78, 0x02, + 0x4C, 0x1B, 0x00, 0x00, 0x02, 0x11, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x13, 0x00, 0x00, 0x01, 0x56, 0x78, 0x02, + 0x3C, 0x13, 0x00, 0x00, 0x01, 0x56, 0x78, 0x02, + 0x3C, 0x1F, 0x00, 0x00, 0x0E, 0x9E, 0x78, 0x02, + 0x3C, 0x20, 0x00, 0x00, 0x01, 0x0C, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x3C, 0x21, 0x00, 0x00, 0x0F, 0x7C, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2A, 0x0B, 0x00, 0x00, 0x4C, 0x47, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x1B, 0x00, 0x00, 0x05, 0x28, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2C, 0x04, 0x00, 0x00, 0x09, 0x10, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x22, 0x00, 0x00, 0x0A, 0xEE, 0x78, 0x02, + 0x3C, 0x16, 0x00, 0x00, 0x1E, 0x97, 0x78, 0x02, + 0x3C, 0x15, 0x00, 0x00, 0x1B, 0x91, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x14, 0x00, 0x00, 0x27, 0x2C, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x22, 0x00, 0x00, 0x0A, 0xEE, 0x78, 0x02, + 0x3C, 0x14, 0x00, 0x00, 0x27, 0x2C, 0x78, 0x02, + 0x32, 0x23, 0x00, 0x00, 0x14, 0x19, 0x9C, 0x02, + 0x3C, 0x19, 0x00, 0x00, 0x17, 0x1C, 0x78, 0x02, + 0x3C, 0x14, 0x00, 0x00, 0x27, 0x2C, 0x78, 0x02, + 0x3E, 0x1C, 0x00, 0x00, 0x06, 0x22, 0x78, 0x02, + 0x43, 0x13, 0x00, 0x00, 0x02, 0x01, 0x78, 0x02, + 0x3C, 0x24, 0x00, 0x00, 0x12, 0x43, 0x5A, 0x02, + 0x3E, 0x20, 0x00, 0x00, 0x00, 0xEE, 0x78, 0x02, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x29, 0x04, 0x00, 0x00, 0x19, 0xEA, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x20, 0x00, 0x00, 0x01, 0x0C, 0x78, 0x02, + 0x3C, 0x25, 0x00, 0x00, 0x30, 0xB6, 0x78, 0x02, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x16, 0x00, 0x00, 0x1E, 0x97, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x1A, 0x00, 0x00, 0x3A, 0xEB, 0x78, 0x02, + 0x1B, 0x04, 0x00, 0x00, 0x39, 0xF3, 0x78, 0x02, + 0x30, 0x23, 0x00, 0x00, 0x16, 0x99, 0x50, 0x02, + 0x3C, 0x15, 0x00, 0x00, 0x1B, 0x91, 0x78, 0x02, + 0x29, 0x06, 0x00, 0x00, 0x19, 0xEA, 0x50, 0x02, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x1A, 0x00, 0x00, 0x3A, 0xEB, 0x78, 0x02, + 0x3C, 0x19, 0x00, 0x00, 0x25, 0x2C, 0x78, 0x02, + 0x3C, 0x26, 0x00, 0x00, 0x07, 0x13, 0x78, 0x02, + 0x3C, 0x26, 0x00, 0x00, 0x07, 0x13, 0x78, 0x02, + 0x3C, 0x14, 0x00, 0x00, 0x27, 0x2C, 0x78, 0x02, + 0x30, 0x23, 0x00, 0x00, 0x16, 0x99, 0x50, 0x02, + 0x30, 0x23, 0x00, 0x00, 0x16, 0x99, 0x50, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3C, 0x13, 0x00, 0x00, 0x01, 0x56, 0x78, 0x02, +}; + } // End of namespace Kyra diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk index 58d8db91fc..51fbecdb0d 100644 --- a/engines/scumm/module.mk +++ b/engines/scumm/module.mk @@ -40,6 +40,7 @@ MODULE_OBJS := \ player_v2a.o \ player_v2cms.o \ player_v3a.o \ + player_v4a.o \ resource_v2.o \ resource_v3.o \ resource_v4.o \ diff --git a/engines/scumm/music.h b/engines/scumm/music.h index c6555318a9..2fd7c50bce 100644 --- a/engines/scumm/music.h +++ b/engines/scumm/music.h @@ -81,12 +81,6 @@ public: * @return the music timer */ virtual int getMusicTimer() const { return 0; } - - /** - * Terminate the music engine. Called just before the music engine - * is deleted. - */ - virtual void terminate() {} }; } // End of namespace Scumm diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index c356e7a06c..1b531f6bab 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -34,230 +34,155 @@ namespace Scumm { void ScummEngine::resetPalette() { + static const byte tableC64Palette[] = { + 0x00, 0x00, 0x00, 0xFD, 0xFE, 0xFC, 0xBE, 0x1A, 0x24, 0x30, 0xE6, 0xC6, + 0xB4, 0x1A, 0xE2, 0x1F, 0xD2, 0x1E, 0x21, 0x1B, 0xAE, 0xDF, 0xF6, 0x0A, + 0xB8, 0x41, 0x04, 0x6A, 0x33, 0x04, 0xFE, 0x4A, 0x57, 0x42, 0x45, 0x40, + 0x70, 0x74, 0x6F, 0x59, 0xFE, 0x59, 0x5F, 0x53, 0xFE, 0xA4, 0xA7, 0xA2, + + // Use 17 color table for v1 games to allow correct color for inventory and + // sentence line. Original games used some kind of dynamic color table + // remapping between rooms. + 0xFF, 0x55, 0xFF + }; + + static const byte tableNESPalette[] = { + /* 0x1D */ + 0x00, 0x00, 0x00, 0x00, 0x24, 0x92, 0x00, 0x00, 0xDB, 0x6D, 0x49, 0xDB, + 0x92, 0x00, 0x6D, 0xB6, 0x00, 0x6D, 0xB6, 0x24, 0x00, 0x92, 0x49, 0x00, + 0x6D, 0x49, 0x00, 0x24, 0x49, 0x00, 0x00, 0x6D, 0x24, 0x00, 0x92, 0x00, + 0x00, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0xB6, 0xB6, 0xB6, 0x00, 0x6D, 0xDB, 0x00, 0x49, 0xFF, 0x92, 0x00, 0xFF, + 0xB6, 0x00, 0xFF, 0xFF, 0x00, 0x92, 0xFF, 0x00, 0x00, 0xDB, 0x6D, 0x00, + 0x92, 0x6D, 0x00, 0x24, 0x92, 0x00, 0x00, 0x92, 0x00, 0x00, 0xB6, 0x6D, + /* 0x00 */ + 0x00, 0x92, 0x92, 0x6D, 0x6D, 0x6D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0xFF, 0xFF, 0xFF, 0x6D, 0xB6, 0xFF, 0x92, 0x92, 0xFF, 0xDB, 0x6D, 0xFF, + 0xFF, 0x00, 0xFF, 0xFF, 0x6D, 0xFF, 0xFF, 0x92, 0x00, 0xFF, 0xB6, 0x00, + 0xDB, 0xDB, 0x00, 0x6D, 0xDB, 0x00, 0x00, 0xFF, 0x00, 0x49, 0xFF, 0xDB, + 0x00, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0xFF, 0xFF, 0xFF, 0xB6, 0xDB, 0xFF, 0xDB, 0xB6, 0xFF, 0xFF, 0xB6, 0xFF, + 0xFF, 0x92, 0xFF, 0xFF, 0xB6, 0xB6, 0xFF, 0xDB, 0x92, 0xFF, 0xFF, 0x49, + 0xFF, 0xFF, 0x6D, 0xB6, 0xFF, 0x49, 0x92, 0xFF, 0x6D, 0x49, 0xFF, 0xDB, + 0x92, 0xDB, 0xFF, 0x92, 0x92, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + static const byte tableAmigaPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0x00, 0xBB, 0x00, 0x00, 0xBB, 0xBB, + 0xBB, 0x00, 0x00, 0xBB, 0x00, 0xBB, 0xBB, 0x77, 0x00, 0xBB, 0xBB, 0xBB, + 0x77, 0x77, 0x77, 0x77, 0x77, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + 0xFF, 0x88, 0x88, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF + }; + + static const byte tableAmigaMIPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x88, 0x22, 0x00, 0x66, 0x77, + 0xBB, 0x66, 0x66, 0xAA, 0x22, 0xAA, 0x88, 0x55, 0x22, 0x77, 0x77, 0x77, + 0x33, 0x33, 0x33, 0x22, 0x55, 0xDD, 0x22, 0xDD, 0x44, 0x00, 0xCC, 0xFF, + 0xFF, 0x99, 0x99, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0x77, 0xFF, 0xFF, 0xFF + }; + + static const byte tableEGAPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0x00, 0xAA, 0xAA, + 0xAA, 0x00, 0x00, 0xAA, 0x00, 0xAA, 0xAA, 0x55, 0x00, 0xAA, 0xAA, 0xAA, + 0x55, 0x55, 0x55, 0x55, 0x55, 0xFF, 0x55, 0xFF, 0x55, 0x55, 0xFF, 0xFF, + 0xFF, 0x55, 0x55, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0x55, 0xFF, 0xFF, 0xFF + }; + + static const byte tableV1Palette[] = { + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xAA, 0x00, 0x00, 0x00, 0xAA, 0xAA, + 0xAA, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0x00, 0x00, 0xAA, 0xFF, 0xFF, 0x55, + 0xFF, 0x55, 0x55, 0xAA, 0x55, 0x00, 0xFF, 0x55, 0x55, 0x55, 0x55, 0x55, + 0xAA, 0xAA, 0xAA, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, + + 0xFF, 0x55, 0xFF + }; + + static const byte tableCGAPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8, 0x00, 0xA8, 0xA8, 0xA8, 0xA8 + }; + + static const byte tableHercAPalette[] = { + 0x00, 0x00, 0x00, 0xAE, 0x69, 0x38 + }; + + static const byte tableHercGPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00 + }; + if (_game.version <= 1) { if (_game.platform == Common::kPlatformApple2GS) { // TODO: unique palette? - setC64Palette(); + setPaletteFromTable(tableC64Palette, sizeof(tableC64Palette) / 3); } else if (_game.platform == Common::kPlatformC64) { - setC64Palette(); + setPaletteFromTable(tableC64Palette, sizeof(tableC64Palette) / 3); } else if (_game.platform == Common::kPlatformNES) { - setNESPalette(); + setPaletteFromTable(tableNESPalette, sizeof(tableNESPalette) / 3); } else { - setV1Palette(); + setPaletteFromTable(tableV1Palette, sizeof(tableV1Palette) / 3); + if (_game.id == GID_ZAK) + setPalColor(15, 170, 170, 170); } } else if (_game.features & GF_16COLOR) { + bool setupCursor = false; + switch (_renderMode) { case Common::kRenderEGA: - setEGAPalette(); + setPaletteFromTable(tableEGAPalette, sizeof(tableEGAPalette) / 3); break; case Common::kRenderAmiga: - setAmigaPalette(); + setPaletteFromTable(tableAmigaPalette, sizeof(tableAmigaPalette) / 3); break; case Common::kRenderCGA: - setCGAPalette(); + setPaletteFromTable(tableCGAPalette, sizeof(tableCGAPalette) / 3); + setupCursor = true; break; case Common::kRenderHercA: + setPaletteFromTable(tableHercAPalette, sizeof(tableHercAPalette) / 3); + setupCursor = true; + break; + case Common::kRenderHercG: - setHercPalette(); + setPaletteFromTable(tableHercGPalette, sizeof(tableHercGPalette) / 3); + setupCursor = true; break; default: if ((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST)) - setAmigaPalette(); + setPaletteFromTable(tableAmigaPalette, sizeof(tableAmigaPalette) / 3); else - setEGAPalette(); + setPaletteFromTable(tableEGAPalette, sizeof(tableEGAPalette) / 3); + } + if (setupCursor) { + // Setup cursor palette + setPalColor( 7, 170, 170, 170); + setPalColor( 8, 85, 85, 85); + setPalColor(15, 255, 255, 255); } - } else - setDirtyColors(0, 255); -} - -void ScummEngine::setC64Palette() { - setPalColor( 0, 0x00, 0x00, 0x00); - setPalColor( 1, 0xFD, 0xFE, 0xFC); - setPalColor( 2, 0xBE, 0x1A, 0x24); - setPalColor( 3, 0x30, 0xE6, 0xC6); - setPalColor( 4, 0xB4, 0x1A, 0xE2); - setPalColor( 5, 0x1F, 0xD2, 0x1E); - setPalColor( 6, 0x21, 0x1B, 0xAE); - setPalColor( 7, 0xDF, 0xF6, 0x0A); - setPalColor( 8, 0xB8, 0x41, 0x04); - setPalColor( 9, 0x6A, 0x33, 0x04); - setPalColor(10, 0xFE, 0x4A, 0x57); - setPalColor(11, 0x42, 0x45, 0x40); - setPalColor(12, 0x70, 0x74, 0x6F); - setPalColor(13, 0x59, 0xFE, 0x59); - setPalColor(14, 0x5F, 0x53, 0xFE); - setPalColor(15, 0xA4, 0xA7, 0xA2); - - // Use 17 color table for v1 games to allow correct color for inventory and - // sentence line. Original games used some kind of dynamic color table - // remapping between rooms. - setPalColor(16, 255, 85, 255); -} - -void ScummEngine::setNESPalette() { - setPalColor(0x00,0x00,0x00,0x00); // 0x1D - setPalColor(0x01,0x00,0x24,0x92); - setPalColor(0x02,0x00,0x00,0xDB); - setPalColor(0x03,0x6D,0x49,0xDB); - setPalColor(0x04,0x92,0x00,0x6D); - setPalColor(0x05,0xB6,0x00,0x6D); - setPalColor(0x06,0xB6,0x24,0x00); - setPalColor(0x07,0x92,0x49,0x00); - setPalColor(0x08,0x6D,0x49,0x00); - setPalColor(0x09,0x24,0x49,0x00); - setPalColor(0x0A,0x00,0x6D,0x24); - setPalColor(0x0B,0x00,0x92,0x00); - setPalColor(0x0C,0x00,0x49,0x49); - setPalColor(0x0D,0x00,0x00,0x00); - setPalColor(0x0E,0x00,0x00,0x00); - setPalColor(0x0F,0x00,0x00,0x00); - - setPalColor(0x10,0xB6,0xB6,0xB6); - setPalColor(0x11,0x00,0x6D,0xDB); - setPalColor(0x12,0x00,0x49,0xFF); - setPalColor(0x13,0x92,0x00,0xFF); - setPalColor(0x14,0xB6,0x00,0xFF); - setPalColor(0x15,0xFF,0x00,0x92); - setPalColor(0x16,0xFF,0x00,0x00); - setPalColor(0x17,0xDB,0x6D,0x00); - setPalColor(0x18,0x92,0x6D,0x00); - setPalColor(0x19,0x24,0x92,0x00); - setPalColor(0x1A,0x00,0x92,0x00); - setPalColor(0x1B,0x00,0xB6,0x6D); - setPalColor(0x1C,0x00,0x92,0x92); - setPalColor(0x1D,0x6D,0x6D,0x6D); // 0x00 - setPalColor(0x1E,0x00,0x00,0x00); - setPalColor(0x1F,0x00,0x00,0x00); - - setPalColor(0x20,0xFF,0xFF,0xFF); - setPalColor(0x21,0x6D,0xB6,0xFF); - setPalColor(0x22,0x92,0x92,0xFF); - setPalColor(0x23,0xDB,0x6D,0xFF); - setPalColor(0x24,0xFF,0x00,0xFF); - setPalColor(0x25,0xFF,0x6D,0xFF); - setPalColor(0x26,0xFF,0x92,0x00); - setPalColor(0x27,0xFF,0xB6,0x00); - setPalColor(0x28,0xDB,0xDB,0x00); - setPalColor(0x29,0x6D,0xDB,0x00); - setPalColor(0x2A,0x00,0xFF,0x00); - setPalColor(0x2B,0x49,0xFF,0xDB); - setPalColor(0x2C,0x00,0xFF,0xFF); - setPalColor(0x2D,0x49,0x49,0x49); - setPalColor(0x2E,0x00,0x00,0x00); - setPalColor(0x2F,0x00,0x00,0x00); - - setPalColor(0x30,0xFF,0xFF,0xFF); - setPalColor(0x31,0xB6,0xDB,0xFF); - setPalColor(0x32,0xDB,0xB6,0xFF); - setPalColor(0x33,0xFF,0xB6,0xFF); - setPalColor(0x34,0xFF,0x92,0xFF); - setPalColor(0x35,0xFF,0xB6,0xB6); - setPalColor(0x36,0xFF,0xDB,0x92); - setPalColor(0x37,0xFF,0xFF,0x49); - setPalColor(0x38,0xFF,0xFF,0x6D); - setPalColor(0x39,0xB6,0xFF,0x49); - setPalColor(0x3A,0x92,0xFF,0x6D); - setPalColor(0x3B,0x49,0xFF,0xDB); - setPalColor(0x3C,0x92,0xDB,0xFF); - setPalColor(0x3D,0x92,0x92,0x92); - setPalColor(0x3E,0x00,0x00,0x00); - setPalColor(0x3F,0x00,0x00,0x00); -} - -void ScummEngine::setAmigaPalette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 0, 0, 187); - setPalColor( 2, 0, 187, 0); - setPalColor( 3, 0, 187, 187); - setPalColor( 4, 187, 0, 0); - setPalColor( 5, 187, 0, 187); - setPalColor( 6, 187, 119, 0); - setPalColor( 7, 187, 187, 187); - setPalColor( 8, 119, 119, 119); - setPalColor( 9, 119, 119, 255); - setPalColor(10, 0, 255, 0); - setPalColor(11, 0, 255, 255); - setPalColor(12, 255, 136, 136); - setPalColor(13, 255, 0, 255); - setPalColor(14, 255, 255, 0); - setPalColor(15, 255, 255, 255); -} - -void ScummEngine::setHercPalette() { - setPalColor( 0, 0, 0, 0); - - if (_renderMode == Common::kRenderHercA) - setPalColor( 1, 0xAE, 0x69, 0x38); - else - setPalColor( 1, 0x00, 0xFF, 0x00); - - // Setup cursor palette - setPalColor( 7, 170, 170, 170); - setPalColor( 8, 85, 85, 85); - setPalColor(15, 255, 255, 255); -} - -void ScummEngine::setCGAPalette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 0, 168, 168); - setPalColor( 2, 168, 0, 168); - setPalColor( 3, 168, 168, 168); - - // Setup cursor palette - setPalColor( 7, 170, 170, 170); - setPalColor( 8, 85, 85, 85); - setPalColor(15, 255, 255, 255); -} -void ScummEngine::setEGAPalette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 0, 0, 170); - setPalColor( 2, 0, 170, 0); - setPalColor( 3, 0, 170, 170); - setPalColor( 4, 170, 0, 0); - setPalColor( 5, 170, 0, 170); - setPalColor( 6, 170, 85, 0); - setPalColor( 7, 170, 170, 170); - setPalColor( 8, 85, 85, 85); - setPalColor( 9, 85, 85, 255); - setPalColor(10, 85, 255, 85); - setPalColor(11, 85, 255, 255); - setPalColor(12, 255, 85, 85); - setPalColor(13, 255, 85, 255); - setPalColor(14, 255, 255, 85); - setPalColor(15, 255, 255, 255); + } else { + if ((_game.platform == Common::kPlatformAmiga) && _game.version == 4) { + // if rendermode is set to EGA we use the full palette from the resources + // else we initialise and then lock down the first 16 colors. + if (_renderMode != Common::kRenderEGA) + setPaletteFromTable(tableAmigaMIPalette, sizeof(tableAmigaMIPalette) / 3); + } + setDirtyColors(0, 255); + } } -void ScummEngine::setV1Palette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 255, 255, 255); - setPalColor( 2, 170, 0, 0); - setPalColor( 3, 0, 170, 170); - setPalColor( 4, 170, 0, 170); - setPalColor( 5, 0, 170, 0); - setPalColor( 6, 0, 0, 170); - setPalColor( 7, 255, 255, 85); - setPalColor( 8, 255, 85, 85); - setPalColor( 9, 170, 85, 0); - setPalColor(10, 255, 85, 85); - setPalColor(11, 85, 85, 85); - setPalColor(12, 170, 170, 170); - setPalColor(13, 85, 255, 85); - setPalColor(14, 85, 85, 255); - - if (_game.id == GID_ZAK) - setPalColor(15, 170, 170, 170); - else - setPalColor(15, 85, 85, 85); - - setPalColor(16, 255, 85, 255); +void ScummEngine::setPaletteFromTable(const byte *ptr, int numcolor, int index) { + for ( ; numcolor > 0; --numcolor, ++index, ptr += 3) + setPalColor( index, ptr[0], ptr[1], ptr[2]); } void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) { + int firstIndex = 0; int i; byte *dest, r, g, b; @@ -276,8 +201,13 @@ void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) { assertRange(0, numcolor, 256, "setPaletteFromPtr: numcolor"); dest = _currentPalette; + if ((_game.platform == Common::kPlatformAmiga) && _game.version == 4 && _renderMode != Common::kRenderEGA) { + firstIndex = 16; + dest += 3 * 16; + ptr += 3 * 16; + } - for (i = 0; i < numcolor; i++) { + for (i = firstIndex; i < numcolor; i++) { r = *ptr++; g = *ptr++; b = *ptr++; @@ -302,7 +232,7 @@ void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) { memcpy(_darkenPalette, _currentPalette, 768); } - setDirtyColors(0, numcolor - 1); + setDirtyColors(firstIndex, numcolor - 1); } void ScummEngine::setDirtyColors(int min, int max) { diff --git a/engines/scumm/player_v4a.cpp b/engines/scumm/player_v4a.cpp new file mode 100644 index 0000000000..f441b3b364 --- /dev/null +++ b/engines/scumm/player_v4a.cpp @@ -0,0 +1,193 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "engines/engine.h" +#include "scumm/player_v4a.h" +#include "scumm/scumm.h" + +#include "common/file.h" + +namespace Scumm { + +Player_V4A::Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer) + : _vm(scumm), + _mixer(mixer), + _tfmxMusic(_mixer->getOutputRate(), true), + _tfmxSfx(_mixer->getOutputRate(), true), + _musicHandle(), + _sfxHandle(), + _musicId(), + _sfxSlots(), + _initState(0), + _signal(0) { + + assert(scumm); + assert(mixer); + assert(_vm->_game.id == GID_MONKEY_VGA); + _tfmxMusic.setSignalPtr(&_signal, 1); +} + +bool Player_V4A::init() { + if (_vm->_game.id != GID_MONKEY_VGA) + error("player_v4a - unknown game"); + + Common::File fileMdat, fileSample; + + if (fileMdat.open("music.dat") && fileSample.open("sample.dat")) { + // explicitly request that no instance delets the resources automatically + if (_tfmxMusic.load(fileMdat, fileSample, false)) { + _tfmxSfx.setModuleData(_tfmxMusic); + return true; + } + } else + warning("player_v4a: couldnt load one of the music resources: music.dat, sample.dat"); + + return false; +} + +Player_V4A::~Player_V4A() { + _mixer->stopHandle(_musicHandle); + _mixer->stopHandle(_sfxHandle); + _tfmxMusic.freeResources(); +} + +void Player_V4A::setMusicVolume(int vol) { + debug(5, "player_v4a: setMusicVolume %i", vol); +} + +void Player_V4A::stopAllSounds() { + debug(5, "player_v4a: stopAllSounds"); + if (_initState > 0) { + _tfmxMusic.stopSong(); + _signal = 0; + _musicId = 0; + + _tfmxSfx.stopSong(); + clearSfxSlots(); + } else + _mixer->stopHandle(_musicHandle); +} + +void Player_V4A::stopSound(int nr) { + debug(5, "player_v4a: stopSound %d", nr); + if (nr == 0) + return; + if (nr == _musicId) { + _musicId = 0; + if (_initState > 0) + _tfmxMusic.stopSong(); + else + _mixer->stopHandle(_musicHandle); + _signal = 0; + } else { + const int chan = getSfxChan(nr); + if (chan != -1) { + setSfxSlot(chan, 0); + _tfmxSfx.stopMacroEffect(chan); + } + } +} + +void Player_V4A::startSound(int nr) { + 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 + }; + + 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 (!_initState) + _initState = init() ? 1 : -1; + + if (_initState < 0) + return; + + int index = monkeyCommands[val]; + const byte type = ptr[6]; + 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 never "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 + debug(3, "player_v4a: play %d: song %i - %02X", nr, index, type); + if (ptr[6] != 0x7F) + warning("player_v4a: Song has wrong type"); + + _tfmxMusic.doSong(index); + _signal = 2; + + // the Tfmx-player never "ends" the output by itself, so this should be threadsafe + if (!_mixer->isSoundHandleActive(_musicHandle)) + _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, &_tfmxMusic, -1, Audio::Mixer::kMaxChannelVolume, 0, false); + _musicId = nr; + } +} + +int Player_V4A::getMusicTimer() const { + // A workaround if the modplayer couldnt load the datafiles - just return a number big enough to pass all tests + if (_initState < 0) + return 2000; + if (_musicId) { + // 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 { + // 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 new file mode 100644 index 0000000000..5f5fae6b56 --- /dev/null +++ b/engines/scumm/player_v4a.h @@ -0,0 +1,98 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef SCUMM_PLAYER_V4A_H +#define SCUMM_PLAYER_V4A_H + +#include "common/scummsys.h" +#include "scumm/music.h" +#include "sound/mixer.h" +#include "sound/mods/tfmx.h" + +class Mixer; + +namespace Scumm { + +class ScummEngine; + +/** + * Scumm V4 Amiga sound/music driver. + */ +class Player_V4A : public MusicEngine { +public: + Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer); + virtual ~Player_V4A(); + + virtual void setMusicVolume(int vol); + virtual void startSound(int sound); + virtual void stopSound(int sound); + virtual void stopAllSounds(); + virtual int getMusicTimer() const; + virtual int getSoundStatus(int sound) const; + +private: + ScummEngine *const _vm; + Audio::Mixer *const _mixer; + + Audio::Tfmx _tfmxMusic; + Audio::Tfmx _tfmxSfx; + Audio::SoundHandle _musicHandle; + Audio::SoundHandle _sfxHandle; + + int _musicId; + uint16 _signal; + + struct SfxChan { + int id; +// 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) + return i; + return -1; + } + + void setSfxSlot(int channel, int id, byte type = 0) { + _sfxSlots[channel].id = id; +// _sfxSlots[channel].type = type; + } + + void clearSfxSlots() { + for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i){ + _sfxSlots[i].id = 0; +// _sfxSlots[i].type = 0; + } + } + + bool init(); +}; + +} // End of namespace Scumm + +#endif diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 8c5731d539..9d6673d308 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -56,6 +56,7 @@ #include "scumm/player_v2.h" #include "scumm/player_v2a.h" #include "scumm/player_v3a.h" +#include "scumm/player_v4a.h" #include "scumm/he/resource_he.h" #include "scumm/scumm_v0.h" #include "scumm/scumm_v8.h" @@ -281,7 +282,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _useTalkAnims = false; _defaultTalkDelay = 0; _musicType = MDT_NONE; - _tempMusic = 0; _saveSound = 0; memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags)); memset(_scaleSlots, 0, sizeof(_scaleSlots)); @@ -496,7 +496,9 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) case Common::kRenderCGA: case Common::kRenderEGA: case Common::kRenderAmiga: - if ((_game.version >= 4 && !(_game.features & GF_16COLOR)) || (_game.features & GF_OLD256)) + if ((_game.version >= 4 && !(_game.features & GF_16COLOR) + && !(_game.platform == Common::kPlatformAmiga && _renderMode == Common::kRenderEGA)) + || (_game.features & GF_OLD256)) _renderMode = Common::kRenderDefault; break; @@ -547,10 +549,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) ScummEngine::~ScummEngine() { Common::clearAllDebugChannels(); - if (_musicEngine) { - _musicEngine->terminate(); - delete _musicEngine; - } + delete _musicEngine; _mixer->stopAll(); @@ -1281,7 +1280,6 @@ void ScummEngine::setupCostumeRenderer() { void ScummEngine::resetScumm() { int i; - _tempMusic = 0; debug(9, "resetScumm"); if (_game.version == 0) { @@ -1685,7 +1683,7 @@ void ScummEngine::setupMusic(int midi) { } else if (_game.platform == Common::kPlatformPCEngine && _game.version == 3) { // TODO: Add support for music format } else if (_game.platform == Common::kPlatformAmiga && _game.version <= 4) { - // TODO: Add support for music format + _musicEngine = new Player_V4A(this, _mixer); } else if (_game.id == GID_MANIAC && _game.version == 1) { _musicEngine = new Player_V1(this, _mixer, midiDriver != MD_PCSPK); } else if (_game.version <= 2) { @@ -1896,17 +1894,6 @@ void ScummEngine::scummLoop(int delta) { if (_musicEngine) { // The music engine generates the timer data for us. VAR(VAR_MUSIC_TIMER) = _musicEngine->getMusicTimer(); - } else { - // Used for Money Island 1 (Amiga) - // TODO: The music delay (given in milliseconds) might have to be tuned a little - // to get it correct for all games. Without the ability to watch/listen to the - // original games, I can't do that myself. - const int MUSIC_DELAY = 350; - _tempMusic += delta * 1000 / 60; // Convert delta to milliseconds - if (_tempMusic >= MUSIC_DELAY) { - _tempMusic -= MUSIC_DELAY; - VAR(VAR_MUSIC_TIMER) += 1; - } } } diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index bfb188f1c7..f0f2521225 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1028,14 +1028,7 @@ protected: const byte *getPalettePtr(int palindex, int room); - void setC64Palette(); - void setNESPalette(); - void setAmigaPalette(); - void setHercPalette(); - void setCGAPalette(); - void setEGAPalette(); - void setV1Palette(); - + void setPaletteFromTable(const byte *ptr, int numcolor, int firstIndex = 0); void resetPalette(); void setCurrentPalette(int pal); @@ -1144,7 +1137,6 @@ protected: bool _haveActorSpeechMsg; bool _useTalkAnims; uint16 _defaultTalkDelay; - int _tempMusic; int _saveSound; bool _native_mt32; bool _enable_gs; diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 528cceb0cc..07e2ce8bca 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -436,26 +436,6 @@ void Sound::playSound(int soundID) { if (_vm->_game.id == GID_MONKEY_VGA || _vm->_game.id == GID_MONKEY_EGA || (_vm->_game.id == GID_MONKEY && _vm->_game.platform == Common::kPlatformMacintosh)) { - // Sound is currently not supported at all in the amiga versions of these games - if (_vm->_game.platform == Common::kPlatformAmiga) { - int track = -1; - if (soundID == 50) - track = 17; - else if (ptr[6] == 0x7F && ptr[7] == 0x00 && ptr[8] == 0x80) { - static const char tracks[16] = {13,14,10,3,4,9,16,5,1,8,2,15,6,7,11,12}; - if (ptr[9] == 0x0E) - track = 18; - else - track = tracks[ptr[9] - 0x23]; - } - if (track != -1) { - playCDTrack(track,((track < 5) || (track > 16)) ? 1 : -1,0,0); - stopCDTimer(); - _currentCDSound = soundID; - } - return; - } - // Works around the fact that in some places in MonkeyEGA/VGA, // the music is never explicitly stopped. // Rather it seems that starting a new music is supposed to |