diff options
author | David Corrales | 2007-06-23 18:51:33 +0000 |
---|---|---|
committer | David Corrales | 2007-06-23 18:51:33 +0000 |
commit | cacd7a28fd51d960947de88abbf30c487e66529d (patch) | |
tree | f3baa59853bfb307e452b86b9d93c4737b1fa6ab /engines/scumm | |
parent | 0ac96302fe9c04df79cb01a77d19535b45fe2db0 (diff) | |
parent | 90c2210dae8c91fa8babc6b05564e15c9d445d18 (diff) | |
download | scummvm-rg350-cacd7a28fd51d960947de88abbf30c487e66529d.tar.gz scummvm-rg350-cacd7a28fd51d960947de88abbf30c487e66529d.tar.bz2 scummvm-rg350-cacd7a28fd51d960947de88abbf30c487e66529d.zip |
Merged the FSNode branch with trunk r27031:27680
svn-id: r27681
Diffstat (limited to 'engines/scumm')
27 files changed, 637 insertions, 617 deletions
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 217b257e5e..8624f80fe7 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -49,17 +49,6 @@ enum { #pragma mark --- Miscellaneous --- #pragma mark - -static const char *findDescriptionFromGameID(const char *gameid) { - const PlainGameDescriptor *g = gameDescriptions; - while (g->gameid) { - if (!scumm_stricmp(g->gameid, gameid)) { - return g->description; - } - g++; - } - error("Unknown gameid '%s' encountered in findDescriptionFromGameID", gameid); -} - static int compareMD5Table(const void *a, const void *b) { const char *key = (const char *)a; const MD5Table *elem = (const MD5Table *)b; @@ -673,37 +662,11 @@ static bool testGame(const GameSettings *g, const DescMap &fileMD5Map, const Com using namespace Scumm; GameList Engine_SCUMM_gameIDList() { - const PlainGameDescriptor *g = gameDescriptions; - GameList games; - while (g->gameid) { - games.push_back(GameDescriptor(g->gameid, g->description)); - g++; - } - return games; + return GameList(gameDescriptions); } GameDescriptor Engine_SCUMM_findGameID(const char *gameid) { - // First search the list of supported game IDs. - const PlainGameDescriptor *g = gameDescriptions; - while (g->gameid) { - if (0 == scumm_stricmp(gameid, g->gameid)) - return GameDescriptor(g->gameid, g->description); - g++; - } - - // If we didn't find the gameid in the main list, check if it - // is an obsolete game id. - GameDescriptor gs; - const ObsoleteGameID *o = obsoleteGameIDsTable; - while (o->from) { - if (0 == scumm_stricmp(gameid, o->from)) { - gs["gameid"] = gameid; - gs["description"] = "Obsolete game ID"; - return gs; - } - o++; - } - return gs; + return Common::AdvancedDetector::findGameID(gameid, gameDescriptions, obsoleteGameIDsTable); } @@ -717,8 +680,9 @@ GameList Engine_SCUMM_detectGames(const FSList &fslist) { // In particular, they are detected as ZakTowns, which is bad. for (Common::List<DetectorResult>::iterator x = results.begin(); x != results.end(); ++x) { - GameDescriptor dg(x->game.gameid, findDescriptionFromGameID(x->game.gameid), - x->language, x->game.platform); + const PlainGameDescriptor *g = findPlainGameDescriptor(x->game.gameid, gameDescriptions); + assert(g); + GameDescriptor dg(x->game.gameid, g->description, x->language, x->game.platform); dg.updateDesc(x->extra); // Append additional information, if set, to the description. // Compute and set the preferred target name for this game. @@ -766,7 +730,7 @@ PluginError Engine_SCUMM_create(OSystem *syst, Engine **engine) { // We start by checking whether the specified game ID is obsolete. // If that is the case, we automatically upgrade the target to use // the correct new game ID (and platform, if specified). - for (const ObsoleteGameID *o = obsoleteGameIDsTable; o->from; ++o) { + for (const Common::ADObsoleteGameID *o = obsoleteGameIDsTable; o->from; ++o) { if (!scumm_stricmp(gameid, o->from)) { // Match found, perform upgrade gameid = o->to; diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index c59c790229..246126611e 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -28,6 +28,7 @@ #include "common/stdafx.h" +#include "common/advancedDetector.h" #include "common/rect.h" #include "common/util.h" @@ -49,12 +50,6 @@ namespace Scumm { #pragma mark --- Data types & constants --- #pragma mark - -struct ObsoleteGameID { - const char *from; - const char *to; - Common::Platform platform; -}; - #define UNK Common::kPlatformUnknown #pragma mark - @@ -146,7 +141,7 @@ static const PlainGameDescriptor gameDescriptions[] = { * Conversion table mapping old obsolete game IDs to the * corresponding new game ID and platform combination. */ -static const ObsoleteGameID obsoleteGameIDsTable[] = { +static const Common::ADObsoleteGameID obsoleteGameIDsTable[] = { {"bluesabctimedemo", "bluesabctime", UNK}, {"BluesBirthdayDemo", "BluesBirthday", UNK}, {"comidemo", "comi", UNK}, @@ -571,6 +566,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "freddi3", "F3-Mdemo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "freddi3", "f3-mdemo", kGenHEPC, UNK_LANG, UNK, 0 }, { "freddi3", "FF3-DEMO", kGenHEPC, UNK_LANG, UNK, 0 }, + { "freddi3", "FF3DEMO", kGenHEPC, Common::HB_ISR, UNK, 0 }, { "freddi3", "Freddi 3", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "freddi3", "Freddi Fish 3", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "freddi3", "FreddiFGT", kGenHEPC, Common::DE_DEU, UNK, 0 }, @@ -660,6 +656,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "pajama2", "pj2demo", kGenHEPC, UNK_LANG, UNK, 0 }, { "pajama2", "Pjs2demo", kGenHEPC, UNK_LANG, UNK, 0 }, { "pajama2", "PJ2 Demo", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, + { "pajama2", "PS2DEMO", kGenHEPC, Common::HB_ISR, UNK, 0 }, { "pajama3", "pajama3", kGenHEPC, UNK_LANG, UNK, 0 }, { "pajama3", "FPJ3Demo", kGenHEPC, Common::FR_FRA, UNK, 0 }, diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 15c22c2bed..85a7a4b675 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -27,6 +27,7 @@ #include "common/config-manager.h" #include "common/savefile.h" #include "common/system.h" +#include "common/events.h" #include "graphics/scaler.h" @@ -618,14 +619,6 @@ ConfigDialog::~ConfigDialog() { #endif } -void ConfigDialog::open() { - GUI_OptionsDialog::open(); -} - -void ConfigDialog::close() { - GUI_OptionsDialog::close(); -} - void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kKeysCmd: @@ -749,21 +742,28 @@ void HelpDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { InfoDialog::InfoDialog(ScummEngine *scumm, int res) : ScummDialog("scummDummyDialog"), _vm(scumm) { // dummy x and w - setInfoText(queryResString(res)); + + _message = queryResString(res); + + // Width and height are dummy + _text = new StaticTextWidget(this, 4, 4, 10, 10, _message, kTextAlignCenter); } InfoDialog::InfoDialog(ScummEngine *scumm, const String& message) : ScummDialog("scummDummyDialog"), _vm(scumm) { // dummy x and w - setInfoText(message); -} -void InfoDialog::setInfoText(const String& message) { _message = message; // Width and height are dummy _text = new StaticTextWidget(this, 4, 4, 10, 10, _message, kTextAlignCenter); } +void InfoDialog::setInfoText(const String& message) { + _message = message; + _text->setLabel(_message); + //reflowLayout(); // FIXME: Should we call this here? Depends on the usage patterns, I guess... +} + void InfoDialog::reflowLayout() { const int screenW = g_system->getOverlayWidth(); const int screenH = g_system->getOverlayHeight(); @@ -913,6 +913,48 @@ void ValueDisplayDialog::open() { _timer = getMillis() + kDisplayDelay; } +SubtitleSettingsDialog::SubtitleSettingsDialog(ScummEngine *scumm, int value) + : InfoDialog(scumm, ""), _value(value) { + +} + +void SubtitleSettingsDialog::handleTickle() { + InfoDialog::handleTickle(); + if (getMillis() > _timer) + close(); +} + +void SubtitleSettingsDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { + if (keycode == 't' && modifiers == Common::KBD_CTRL) { + cycleValue(); + + reflowLayout(); + draw(); + } else { + close(); + } +} + +void SubtitleSettingsDialog::open() { + cycleValue(); + InfoDialog::open(); +} + +void SubtitleSettingsDialog::cycleValue() { + static const char* subtitleDesc[] = { + "Speech Only", + "Speech and Subtitles", + "Subtitles Only" + }; + + _value = (_value + 1) % 3; + + setInfoText(subtitleDesc[_value]); + + setResult(_value); + _timer = getMillis() + 1500; +} + Indy3IQPointsDialog::Indy3IQPointsDialog(ScummEngine *scumm, char* text) : InfoDialog(scumm, text) { } diff --git a/engines/scumm/dialogs.h b/engines/scumm/dialogs.h index d3ee9dbc18..b69e989f8a 100644 --- a/engines/scumm/dialogs.h +++ b/engines/scumm/dialogs.h @@ -142,8 +142,6 @@ public: ConfigDialog(); ~ConfigDialog(); - virtual void open(); - virtual void close(); virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); }; @@ -165,6 +163,8 @@ public: // from resources InfoDialog(ScummEngine *scumm, int res); + void setInfoText(const String& message); + virtual void handleMouseDown(int x, int y, int button, int clickCount) { setResult(0); close(); @@ -177,7 +177,6 @@ public: virtual void reflowLayout(); protected: - void setInfoText (const String& message); // Query a string from the resources const String queryResString(int stringno); @@ -235,6 +234,26 @@ protected: uint32 _timer; }; +/** + * A dialog used to display and cycle subtitle settings. + * Automatically closes after a brief time has passed. + */ +class SubtitleSettingsDialog : public InfoDialog { +public: + SubtitleSettingsDialog(ScummEngine *scumm, int value); + + virtual void open(); + virtual void handleTickle(); + virtual void handleMouseDown(int x, int y, int button, int clickCount) { + close(); + } + virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); +protected: + int _value; + uint32 _timer; + + void cycleValue(); +}; //The Indy IQ dialog class Indy3IQPointsDialog : public InfoDialog { diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index dd7a23d0cf..3547986ce3 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -1146,12 +1146,11 @@ void ScummEngine::moveScreen(int dx, int dy, int height) { if ((dx == 0 && dy == 0) || height <= 0) return; - Graphics::Surface screen; - assert(_system->grabRawScreen(&screen)); - - screen.move(dx, dy, height); - _system->copyRectToScreen((byte *)screen.pixels, screen.pitch, 0, 0, screen.w, screen.h); - screen.free(); + Graphics::Surface *screen = _system->lockScreen(); + if (!screen) + return; + screen->move(dx, dy, height); + _system->unlockScreen(); } void ScummEngine_v5::clearFlashlight() { diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index da0855e1a3..3bc2f3e5d7 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -40,7 +40,7 @@ MoviePlayer::MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer) } int MoviePlayer::getImageNum() { - if (!_fd.isOpen()) + if (!_fd) return 0; return _wizResNum; } @@ -48,7 +48,7 @@ int MoviePlayer::getImageNum() { int MoviePlayer::load(const char *filename, int flags, int image) { char videoName[100]; - if (_fd.isOpen()) { + if (_fd) { closeFile(); } @@ -66,7 +66,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) { debug(1, "Playing video %s", videoName); // Skip sound tag - _fd.readUint32BE(); + _fd->readUint32BE(); if (flags & 2) { _vm->_wiz->createWizEmptyImage(image, 0, 0, _width, _height); @@ -85,7 +85,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) { } void MoviePlayer::handleNextFrame() { - if (_fd.isOpen() == false) { + if (_fd == false) { return; } diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index 29226cd939..baee2f3e49 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -1090,7 +1090,7 @@ void ScummEngine_v60he::o60_readFile() { int val; // Fatty Bear uses positive values - if ((_game.platform == Common::kPlatformPC) && (_game.id == GID_FBEAR)) + if (_game.platform == Common::kPlatformPC && _game.id == GID_FBEAR) size = -size; assert(_hInFileTable[slot]); @@ -1120,7 +1120,7 @@ void ScummEngine_v60he::o60_writeFile() { int slot = pop(); // Fatty Bear uses positive values - if ((_game.platform == Common::kPlatformPC) && (_game.id == GID_FBEAR)) + if (_game.platform == Common::kPlatformPC && _game.id == GID_FBEAR) size = -size; assert(_hOutFileTable[slot]); @@ -1138,13 +1138,15 @@ void ScummEngine_v60he::o60_soundOps() { int arg = pop(); switch (subOp) { - case 0xde: - _imuse->setMusicVolume(arg); + case 222: + if (_imuse) { + _imuse->setMusicVolume(arg); + } break; - case 0xdf: - // Used in fbear introduction + case 223: + // WORKAROUND: For error in room script 228 (room 2) of fbear. break; - case 0xe0: + case 224: // Fatty Bear's Birthday surprise uses this when playing the // piano, but only when using one of the digitized instruments. // See also o6_startSound(). diff --git a/engines/scumm/he/script_v70he.cpp b/engines/scumm/he/script_v70he.cpp index 6b1f670e15..1ced349225 100644 --- a/engines/scumm/he/script_v70he.cpp +++ b/engines/scumm/he/script_v70he.cpp @@ -461,6 +461,9 @@ void ScummEngine_v70he::o70_startSound() { case 164: _heSndFlags |= 2; break; + case 222: + // WORKAROUND: For errors in room script 240 (room 4) of maze + break; case 224: _heSndSoundFreq = pop(); break; diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index bee1a56b82..0221657966 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -39,7 +39,7 @@ namespace Scumm { IMuseDigital::Track::Track() - : soundId(-1), used(false), stream(NULL), stream2(NULL) { + : soundId(-1), used(false), stream(NULL), streamSou(NULL) { } void IMuseDigital::timer_handler(void *refCon) { @@ -128,9 +128,9 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { MKARRAY(Track, soundName[0], sleByte, 15, VER(31)), MKLINE(Track, used, sleByte, VER(31)), MKLINE(Track, toBeRemoved, sleByte, VER(31)), - MKLINE(Track, souStream, sleByte, VER(31)), - MKLINE(Track, started, sleByte, VER(31)), - MKLINE(Track, priority, sleInt32, VER(31)), + MKLINE(Track, souStreamUsed, sleByte, VER(31)), + MKLINE(Track, mixerStreamRunning, sleByte, VER(31)), + MKLINE(Track, soundPriority, sleInt32, VER(31)), MKLINE(Track, regionOffset, sleInt32, VER(31)), MK_OBSOLETE(Track, trackOffset, sleInt32, VER(31), VER(31)), MKLINE(Track, dataOffset, sleInt32, VER(31)), @@ -138,12 +138,12 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { MKLINE(Track, curHookId, sleInt32, VER(31)), MKLINE(Track, volGroupId, sleInt32, VER(31)), MKLINE(Track, soundType, sleInt32, VER(31)), - MKLINE(Track, iteration, sleInt32, VER(31)), - MKLINE(Track, mod, sleInt32, VER(31)), - MKLINE(Track, flags, sleInt32, VER(31)), + MKLINE(Track, feedSize, sleInt32, VER(31)), + MKLINE(Track, dataMod12Bit, sleInt32, VER(31)), + MKLINE(Track, mixerFlags, sleInt32, VER(31)), MK_OBSOLETE(Track, mixerVol, sleInt32, VER(31), VER(42)), MK_OBSOLETE(Track, mixerPan, sleInt32, VER(31), VER(42)), - MKLINE(Track, compressed, sleByte, VER(45)), + MKLINE(Track, sndDataExtComp, sleByte, VER(45)), MKEND() }; @@ -152,15 +152,15 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { Track *track = _track[l]; if (!ser->isSaving()) { - track->compressed = false; + track->sndDataExtComp = false; } ser->saveLoadEntries(track, trackEntries); if (!ser->isSaving()) { if (!track->used) continue; track->readyToRemove = false; - if ((track->toBeRemoved) || (track->souStream) || (track->curRegion == -1)) { - track->stream2 = NULL; + if ((track->toBeRemoved) || (track->souStreamUsed) || (track->curRegion == -1)) { + track->streamSou= NULL; track->stream = NULL; track->used = false; continue; @@ -171,43 +171,43 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { track->volGroupId, -1); if (!track->soundHandle) { warning("IMuseDigital::saveOrLoad: Can't open sound so will not be resumed, propably on diffrent CD"); - track->stream2 = NULL; + track->streamSou = NULL; track->stream = NULL; track->used = false; continue; } - if (track->compressed) { + if (track->sndDataExtComp) { track->regionOffset = 0; } - track->compressed = _sound->isCompressed(track->soundHandle); - if (track->compressed) { + track->sndDataExtComp = _sound->isSndDataExtComp(track->soundHandle); + if (track->sndDataExtComp) { track->regionOffset = 0; } track->dataOffset = _sound->getRegionOffset(track->soundHandle, track->curRegion); int bits = _sound->getBits(track->soundHandle); int channels = _sound->getChannels(track->soundHandle); int freq = _sound->getFreq(track->soundHandle); - track->iteration = freq * channels; - track->flags = 0; + track->feedSize = freq * channels; + track->mixerFlags = 0; if (channels == 2) - track->flags = kFlagStereo | kFlagReverseStereo; + track->mixerFlags = kFlagStereo | kFlagReverseStereo; if ((bits == 12) || (bits == 16)) { - track->flags |= kFlag16Bits; - track->iteration *= 2; + track->mixerFlags |= kFlag16Bits; + track->feedSize *= 2; } else if (bits == 8) { - track->flags |= kFlagUnsigned; + track->mixerFlags |= kFlagUnsigned; } else error("IMuseDigital::saveOrLoad(): Can't handle %d bit samples", bits); #ifdef SCUMM_LITTLE_ENDIAN - if (track->compressed) - track->flags |= kFlagLittleEndian; + if (track->sndDataExtComp) + track->mixerFlags |= kFlagLittleEndian; #endif - track->stream2 = NULL; - track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->flags)); + track->streamSou = NULL; + track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags)); const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0; const int vol = track->vol / 1000; @@ -220,7 +220,7 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { if (track->volGroupId == 3) type = Audio::Mixer::kMusicSoundType; - _mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false); + _mixer->playInputStream(type, &track->mixChanHandle, track->stream, -1, vol, pan, false); } } } @@ -275,8 +275,8 @@ void IMuseDigital::callback() { type = Audio::Mixer::kMusicSoundType; if (track->stream) { - byte *data = NULL; - int32 result = 0; + byte *tmpSndBufferPtr = NULL; + int32 curFeedSize = 0; if (track->curRegion == -1) { switchToNextRegion(track); @@ -287,81 +287,81 @@ void IMuseDigital::callback() { int bits = _sound->getBits(track->soundHandle); int channels = _sound->getChannels(track->soundHandle); - int32 mixer_size = track->iteration / _callbackFps; + int32 feedSize = track->feedSize / _callbackFps; if (track->stream->endOfData()) { - mixer_size *= 2; + feedSize *= 2; } if ((bits == 12) || (bits == 16)) { if (channels == 1) - mixer_size &= ~1; + feedSize &= ~1; if (channels == 2) - mixer_size &= ~3; + feedSize &= ~3; } else { if (channels == 2) - mixer_size &= ~1; + feedSize &= ~1; } - if (mixer_size == 0) + if (feedSize == 0) continue; do { if (bits == 12) { - byte *ptr = NULL; + byte *tmpPtr = NULL; - mixer_size += track->mod; - int mixer_size_12 = (mixer_size * 3) / 4; - int length = (mixer_size_12 / 3) * 4; - track->mod = mixer_size - length; + feedSize += track->dataMod12Bit; + int tmpFeedSize12Bits = (feedSize * 3) / 4; + int tmpLength12Bits = (tmpFeedSize12Bits / 3) * 4; + track->dataMod12Bit = feedSize - tmpLength12Bits; - int32 offset = (track->regionOffset * 3) / 4; - int result2 = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &ptr, offset, mixer_size_12); - result = BundleCodecs::decode12BitsSample(ptr, &data, result2); + int32 tmpOffset = (track->regionOffset * 3) / 4; + int tmpFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits); + curFeedSize = BundleCodecs::decode12BitsSample(tmpPtr, &tmpSndBufferPtr, tmpFeedSize); - free(ptr); + free(tmpPtr); } else if (bits == 16) { - result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size); + curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); if (channels == 1) { - result &= ~1; + curFeedSize &= ~1; } if (channels == 2) { - result &= ~3; + curFeedSize &= ~3; } } else if (bits == 8) { - result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size); + curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); if (channels == 2) { - result &= ~1; + curFeedSize &= ~1; } } - if (result > mixer_size) - result = mixer_size; + if (curFeedSize > feedSize) + curFeedSize = feedSize; if (_mixer->isReady()) { - _mixer->setChannelVolume(track->handle, vol); - _mixer->setChannelBalance(track->handle, pan); - track->stream->queueBuffer(data, result); - track->regionOffset += result; + _mixer->setChannelVolume(track->mixChanHandle, vol); + _mixer->setChannelBalance(track->mixChanHandle, pan); + track->stream->queueBuffer(tmpSndBufferPtr, curFeedSize); + track->regionOffset += curFeedSize; } else - delete[] data; + delete[] tmpSndBufferPtr; if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) { switchToNextRegion(track); if (track->toBeRemoved) break; } - mixer_size -= result; - assert(mixer_size >= 0); - } while (mixer_size != 0); - } else if (track->stream2) { + feedSize -= curFeedSize; + assert(feedSize >= 0); + } while (feedSize != 0); + } else if (track->streamSou) { if (_mixer->isReady()) { - if (!track->started) { - track->started = true; - _mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false); + if (!track->mixerStreamRunning) { + track->mixerStreamRunning = true; + _mixer->playInputStream(type, &track->mixChanHandle, track->streamSou, -1, vol, pan, false); } else { - _mixer->setChannelVolume(track->handle, vol); - _mixer->setChannelBalance(track->handle, pan); + _mixer->setChannelVolume(track->mixChanHandle, vol); + _mixer->setChannelBalance(track->mixChanHandle, pan); } } } diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h index 8cfe0f8542..1b088298df 100644 --- a/engines/scumm/imuse_digi/dimuse.h +++ b/engines/scumm/imuse_digi/dimuse.h @@ -67,41 +67,41 @@ enum { class IMuseDigital : public MusicEngine { private: - int _callbackFps; + int _callbackFps; // value how many times callback needs to be called per second struct Track { - int trackId; - - int8 pan; // pan - int32 vol; // volume - int32 volFadeDest; // - int32 volFadeStep; // - int32 volFadeDelay; // - bool volFadeUsed; // - - int32 soundId; - char soundName[15]; - bool used; - bool toBeRemoved; - bool readyToRemove; - bool started; - bool souStream; - bool compressed; - int32 priority; - int32 regionOffset; - int32 dataOffset; - int32 curRegion; - int32 curHookId; - int32 volGroupId; - int32 soundType; - int32 iteration; - int32 mod; - int32 flags; - - ImuseDigiSndMgr::soundStruct *soundHandle; - Audio::SoundHandle handle; - Audio::AppendableAudioStream *stream; - Audio::AudioStream *stream2; + int trackId; // used to identify track by value (0-15) + + int8 pan; // panning value of sound + int32 vol; // volume level (values 0-127 * 1000) + int32 volFadeDest; // volume level which fading target (values 0-127 * 1000) + int32 volFadeStep; // delta of step while changing volume at each imuse callback + int32 volFadeDelay; // time in ms how long fading volume must be + bool volFadeUsed; // flag if fading is in progress + + int32 soundId; // sound id used by scumm script + char soundName[15]; // sound name but also filename of sound in bundle data + bool used; // flag mean that track is used + bool toBeRemoved; // flag mean that track need to be free + bool readyToRemove; // flag mean that track is ready to stop + bool mixerStreamRunning; // flag mean sound mixer's stream is running + bool souStreamUsed; // flag mean that track use stream from sou file + bool sndDataExtComp;// flag mean that sound data is compressed by scummvm tools + int32 soundPriority;// priority level of played sound (0-127) + int32 regionOffset; // offset to sound data relative to begining of current region + int32 dataOffset; // offset to sound data relative to begining of 'DATA' chunk + int32 curRegion; // id of current used region + int32 curHookId; // id of current used hook id + int32 volGroupId; // id of volume group (IMUSE_VOLGRP_VOICE, IMUSE_VOLGRP_SFX, IMUSE_VOLGRP_MUSIC) + int32 soundType; // type of sound data (kSpeechSoundType, kSFXSoundType, kMusicSoundType) + int32 feedSize; // size of sound data needed to be filled at each callback iteration + int32 dataMod12Bit; // value used between all callback to align 12 bit source of data + int32 mixerFlags; // flags for sound mixer's channel (kFlagStereo, kFlag16Bits, kFlagReverseStereo, kFlagUnsigned, kFlagLittleEndian) + + ImuseDigiSndMgr::soundStruct *soundHandle; // sound handle used by iMuse sound manager + Audio::SoundHandle mixChanHandle; // sound mixer's channel handle + Audio::AppendableAudioStream *stream; // sound mixer's audio stream handle for *.la1 and *.bun + Audio::AudioStream *streamSou; // sound mixer's audio stream handle for *.sou Track(); }; @@ -113,16 +113,16 @@ private: Audio::Mixer *_mixer; ImuseDigiSndMgr *_sound; - char *_audioNames; - int32 _numAudioNames; + char *_audioNames; // filenames of sound SFX used in FT + int32 _numAudioNames; // number of above filenames - bool _pause; + bool _pause; // flag mean that iMuse callback should be idle - int32 _attributes[188]; - int32 _nextSeqToPlay; - int32 _curMusicState; - int32 _curMusicSeq; - int32 _curMusicCue; + int32 _attributes[188]; // internal atributes for each music file to store and check later + int32 _nextSeqToPlay; // id of sequence type of music needed played + int32 _curMusicState; // current or previous id of music + int32 _curMusicSeq; // current or previous id of sequence music + int32 _curMusicCue; // current cue for current music. used in FT int32 makeMixerFlags(int32 flags); static void timer_handler(void *refConf); @@ -201,7 +201,7 @@ struct imuseRoomMap { }; struct imuseDigTable { - byte opcode; + byte transitionType; int16 soundId; char name[20]; byte atribPos; @@ -210,7 +210,7 @@ struct imuseDigTable { }; struct imuseComiTable { - byte opcode; + byte transitionType; int16 soundId; char name[20]; byte atribPos; @@ -226,14 +226,14 @@ struct imuseFtNames { struct imuseFtStateTable { char audioName[9]; - byte opcode; + byte transitionType; byte volume; char name[21]; }; struct imuseFtSeqTable { char audioName[9]; - byte opcode; + byte transitionType; byte volume; }; diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp index 6592be8848..03b3e4e74a 100644 --- a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp @@ -36,7 +36,7 @@ BundleDirCache::BundleDirCache() { _budleDirCache[fileId].bundleTable = NULL; _budleDirCache[fileId].fileName[0] = 0; _budleDirCache[fileId].numFiles = 0; - _budleDirCache[fileId].compressedBun = false; + _budleDirCache[fileId].isCompressed = false; _budleDirCache[fileId].indexTable = NULL; } } @@ -60,8 +60,8 @@ BundleDirCache::IndexNode *BundleDirCache::getIndexTable(int slot) { return _budleDirCache[slot].indexTable; } -bool BundleDirCache::isCompressed(int slot) { - return _budleDirCache[slot].compressedBun; +bool BundleDirCache::isSndDataExtComp(int slot) { + return _budleDirCache[slot].isCompressed; } int BundleDirCache::matchFile(const char *filename) { @@ -93,7 +93,7 @@ int BundleDirCache::matchFile(const char *filename) { tag = file.readUint32BE(); if (tag == MKID_BE('LB23')) - _budleDirCache[freeSlot].compressedBun = true; + _budleDirCache[freeSlot].isCompressed = true; offset = file.readUint32BE(); strcpy(_budleDirCache[freeSlot].fileName, filename); @@ -146,10 +146,10 @@ BundleMgr::BundleMgr(BundleDirCache *cache) { _compTable = NULL; _numFiles = 0; _numCompItems = 0; - _curSample = -1; + _curSampleId = -1; _fileBundleId = -1; _file = new ScummFile(); - _compInput = NULL; + _compInputBuff = NULL; } BundleMgr::~BundleMgr() { @@ -187,7 +187,7 @@ bool BundleMgr::open(const char *filename, bool &compressed, bool errorFlag) { int slot = _cache->matchFile(filename); assert(slot != -1); - compressed = _cache->isCompressed(slot); + compressed = _cache->isSndDataExtComp(slot); _numFiles = _cache->getNumFiles(slot); assert(_numFiles); _bundleTable = _cache->getTable(slot); @@ -209,11 +209,11 @@ void BundleMgr::close() { _compTableLoaded = false; _lastBlock = -1; _outputSize = 0; - _curSample = -1; + _curSampleId = -1; free(_compTable); _compTable = NULL; - free(_compInput); - _compInput = NULL; + free(_compInputBuff); + _compInputBuff = NULL; } } @@ -241,19 +241,19 @@ bool BundleMgr::loadCompTable(int32 index) { maxSize = _compTable[i].size; } // CMI hack: one more byte at the end of input buffer - _compInput = (byte *)malloc(maxSize + 1); - assert(_compInput); + _compInputBuff = (byte *)malloc(maxSize + 1); + assert(_compInputBuff); return true; } -int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) { - return decompressSampleByIndex(_curSample, offset, size, comp_final, header_size, header_outside); +int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside) { + return decompressSampleByIndex(_curSampleId, offset, size, compFinal, headerSize, headerOutside); } -int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) { - int32 i, final_size, output_size; - int skip, first_block, last_block; +int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside) { + int32 i, finalSize, outputSize; + int skip, firstBlock, lastBlock; assert(0 <= index && index < _numFiles); @@ -262,10 +262,10 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, return 0; } - if (_curSample == -1) - _curSample = index; + if (_curSampleId == -1) + _curSampleId = index; - assert(_curSample == index); + assert(_curSampleId == index); if (!_compTableLoaded) { _compTableLoaded = loadCompTable(index); @@ -273,54 +273,54 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, return 0; } - first_block = (offset + header_size) / 0x2000; - last_block = (offset + header_size + size - 1) / 0x2000; + firstBlock = (offset + headerSize) / 0x2000; + lastBlock = (offset + headerSize + size - 1) / 0x2000; // Clip last_block by the total number of blocks (= "comp items") - if ((last_block >= _numCompItems) && (_numCompItems > 0)) - last_block = _numCompItems - 1; + if ((lastBlock >= _numCompItems) && (_numCompItems > 0)) + lastBlock = _numCompItems - 1; - int32 blocks_final_size = 0x2000 * (1 + last_block - first_block); - *comp_final = (byte *)malloc(blocks_final_size); - assert(*comp_final); - final_size = 0; + int32 blocksFinalSize = 0x2000 * (1 + lastBlock - firstBlock); + *compFinal = (byte *)malloc(blocksFinalSize); + assert(*compFinal); + finalSize = 0; - skip = (offset + header_size) % 0x2000; + skip = (offset + headerSize) % 0x2000; - for (i = first_block; i <= last_block; i++) { + for (i = firstBlock; i <= lastBlock; i++) { if (_lastBlock != i) { // CMI hack: one more zero byte at the end of input buffer - _compInput[_compTable[i].size] = 0; + _compInputBuff[_compTable[i].size] = 0; _file->seek(_bundleTable[index].offset + _compTable[i].offset, SEEK_SET); - _file->read(_compInput, _compTable[i].size); - _outputSize = BundleCodecs::decompressCodec(_compTable[i].codec, _compInput, _compOutput, _compTable[i].size); + _file->read(_compInputBuff, _compTable[i].size); + _outputSize = BundleCodecs::decompressCodec(_compTable[i].codec, _compInputBuff, _compOutputBuff, _compTable[i].size); if (_outputSize > 0x2000) { error("_outputSize: %d", _outputSize); } _lastBlock = i; } - output_size = _outputSize; + outputSize = _outputSize; - if (header_outside) { - output_size -= skip; + if (headerOutside) { + outputSize -= skip; } else { - if ((header_size != 0) && (skip >= header_size)) - output_size -= skip; + if ((headerSize != 0) && (skip >= headerSize)) + outputSize -= skip; } - if ((output_size + skip) > 0x2000) // workaround - output_size -= (output_size + skip) - 0x2000; + if ((outputSize + skip) > 0x2000) // workaround + outputSize -= (outputSize + skip) - 0x2000; - if (output_size > size) - output_size = size; + if (outputSize > size) + outputSize = size; - assert(final_size + output_size <= blocks_final_size); + assert(finalSize + outputSize <= blocksFinalSize); - memcpy(*comp_final + final_size, _compOutput + skip, output_size); - final_size += output_size; + memcpy(*compFinal + finalSize, _compOutputBuff + skip, outputSize); + finalSize += outputSize; - size -= output_size; + size -= outputSize; assert(size >= 0); if (size == 0) break; @@ -328,7 +328,7 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, skip = 0; } - return final_size; + return finalSize; } int32 BundleMgr::decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside) { diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.h b/engines/scumm/imuse_digi/dimuse_bndmgr.h index ba044a24ed..65360d8ba4 100644 --- a/engines/scumm/imuse_digi/dimuse_bndmgr.h +++ b/engines/scumm/imuse_digi/dimuse_bndmgr.h @@ -51,7 +51,7 @@ private: char fileName[20]; AudioTable *bundleTable; int32 numFiles; - bool compressedBun; + bool isCompressed; IndexNode *indexTable; } _budleDirCache[4]; @@ -63,7 +63,7 @@ public: AudioTable *getTable(int slot); IndexNode *getIndexTable(int slot); int32 getNumFiles(int slot); - bool isCompressed(int slot); + bool isSndDataExtComp(int slot); }; class BundleMgr { @@ -80,14 +80,15 @@ private: BundleDirCache::AudioTable *_bundleTable; BundleDirCache::IndexNode *_indexTable; CompTable *_compTable; + int _numFiles; int _numCompItems; - int _curSample; + int _curSampleId; BaseScummFile *_file; bool _compTableLoaded; int _fileBundleId; - byte _compOutput[0x2000]; - byte *_compInput; + byte _compOutputBuff[0x2000]; + byte *_compInputBuff; int _outputSize; int _lastBlock; @@ -98,19 +99,19 @@ public: BundleMgr(BundleDirCache *_cache); ~BundleMgr(); - bool open(const char *filename, bool &compressed, bool errorFlag=false); + bool open(const char *filename, bool &compressed, bool errorFlag = false); void close(); Common::File *getFile(const char *filename, int32 &offset, int32 &size); - int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside); - int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside); - int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside); + int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **compFinal, bool headerOutside); + int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **compFinal, int header_size, bool headerOutside); + int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside); }; namespace BundleCodecs { uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size); void initializeImcTables(); -int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 input_size); +int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inputSize); } // End of namespace BundleCodecs diff --git a/engines/scumm/imuse_digi/dimuse_codecs.cpp b/engines/scumm/imuse_digi/dimuse_codecs.cpp index 601bfddbe9..17082f5256 100644 --- a/engines/scumm/imuse_digi/dimuse_codecs.cpp +++ b/engines/scumm/imuse_digi/dimuse_codecs.cpp @@ -188,51 +188,51 @@ static int32 compDecode(byte *src, byte *dst) { } #undef NextBit -int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 input_size) { - int32 output_size, channels; +int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inputSize) { + int32 outputSize, channels; int32 offset1, offset2, offset3, length, k, c, s, j, r, t, z; byte *src, *t_table, *p, *ptr; byte t_tmp1, t_tmp2; switch (codec) { case 0: - memcpy(comp_output, comp_input, input_size); - output_size = input_size; + memcpy(compOutput, compInput, inputSize); + outputSize = inputSize; break; case 1: - output_size = compDecode(comp_input, comp_output); + outputSize = compDecode(compInput, compOutput); break; case 2: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 1; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; break; case 3: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 2; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 2; z < outputSize; z++) p[z] += p[z - 1]; - for (z = 1; z < output_size; z++) + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; break; case 4: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 2; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 2; z < outputSize; z++) p[z] += p[z - 1]; - for (z = 1; z < output_size; z++) + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; - t_table = (byte *)malloc(output_size); + t_table = (byte *)malloc(outputSize); assert(t_table); - src = comp_output; - length = (output_size << 3) / 12; + src = compOutput; + length = (outputSize << 3) / 12; k = 0; if (length > 0) { c = -12; @@ -258,23 +258,23 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in } offset1 = ((length - 1) * 3) >> 1; t_table[offset1 + 1] = (t_table[offset1 + 1]) | (src[length - 1] & 0xf0); - memcpy(src, t_table, output_size); + memcpy(src, t_table, outputSize); free(t_table); break; case 5: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 2; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 2; z < outputSize; z++) p[z] += p[z - 1]; - for (z = 1; z < output_size; z++) + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; - t_table = (byte *)malloc(output_size); + t_table = (byte *)malloc(outputSize); assert(t_table); - src = comp_output; - length = (output_size << 3) / 12; + src = compOutput; + length = (outputSize << 3) / 12; k = 1; c = 0; s = 12; @@ -300,29 +300,29 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in j++; } while (k < t); } - memcpy(src, t_table, output_size); + memcpy(src, t_table, outputSize); free(t_table); break; case 6: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 2; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 2; z < outputSize; z++) p[z] += p[z - 1]; - for (z = 1; z < output_size; z++) + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; - t_table = (byte *)malloc(output_size); + t_table = (byte *)malloc(outputSize); assert(t_table); - src = comp_output; - length = (output_size << 3) / 12; + src = compOutput; + length = (outputSize << 3) / 12; k = 0; c = 0; j = 0; s = -12; - t_table[0] = src[output_size - 1]; - t_table[output_size - 1] = src[length - 1]; + t_table[0] = src[outputSize - 1]; + t_table[outputSize - 1] = src[length - 1]; t = length - 1; if (t > 0) { do { @@ -343,26 +343,26 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in j++; } while (k < t); } - memcpy(src, t_table, output_size); + memcpy(src, t_table, outputSize); free(t_table); break; case 10: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 2; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 2; z < outputSize; z++) p[z] += p[z - 1]; - for (z = 1; z < output_size; z++) + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; - t_table = (byte *)malloc(output_size); + t_table = (byte *)malloc(outputSize); assert(t_table); - memcpy(t_table, p, output_size); + memcpy(t_table, p, outputSize); - offset1 = output_size / 3; + offset1 = outputSize / 3; offset2 = offset1 << 1; offset3 = offset2; - src = comp_output; + src = compOutput; while (offset1--) { offset2 -= 2; @@ -371,8 +371,8 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in t_table[offset2 + 1] = src[offset3]; } - src = comp_output; - length = (output_size << 3) / 12; + src = compOutput; + length = (outputSize << 3) / 12; k = 0; if (length > 0) { c = -12; @@ -402,21 +402,21 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in break; case 11: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 2; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 2; z < outputSize; z++) p[z] += p[z - 1]; - for (z = 1; z < output_size; z++) + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; - t_table = (byte *)malloc(output_size); + t_table = (byte *)malloc(outputSize); assert(t_table); - memcpy(t_table, p, output_size); + memcpy(t_table, p, outputSize); - offset1 = output_size / 3; + offset1 = outputSize / 3; offset2 = offset1 << 1; offset3 = offset2; - src = comp_output; + src = compOutput; while (offset1--) { offset2 -= 2; @@ -425,8 +425,8 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in t_table[offset2 + 1] = src[offset3]; } - src = comp_output; - length = (output_size << 3) / 12; + src = compOutput; + length = (outputSize << 3) / 12; k = 1; c = 0; s = 12; @@ -456,21 +456,21 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in break; case 12: - output_size = compDecode(comp_input, comp_output); - p = comp_output; - for (z = 2; z < output_size; z++) + outputSize = compDecode(compInput, compOutput); + p = compOutput; + for (z = 2; z < outputSize; z++) p[z] += p[z - 1]; - for (z = 1; z < output_size; z++) + for (z = 1; z < outputSize; z++) p[z] += p[z - 1]; - t_table = (byte *)malloc(output_size); + t_table = (byte *)malloc(outputSize); assert(t_table); - memcpy(t_table, p, output_size); + memcpy(t_table, p, outputSize); - offset1 = output_size / 3; + offset1 = outputSize / 3; offset2 = offset1 << 1; offset3 = offset2; - src = comp_output; + src = compOutput; while (offset1--) { offset2 -= 2; @@ -479,13 +479,13 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in t_table[offset2 + 1] = src[offset3]; } - src = comp_output; - length = (output_size << 3) / 12; + src = compOutput; + length = (outputSize << 3) / 12; k = 0; c = 0; s = -12; - src[0] = t_table[output_size - 1]; - src[output_size - 1] = t_table[length - 1]; + src[0] = t_table[outputSize - 1]; + src[outputSize - 1] = t_table[length - 1]; t = length - 1; if (t > 0) { do { @@ -536,9 +536,9 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in // We only support mono and stereo assert(channels == 1 || channels == 2); - src = comp_input; - dst = comp_output; - output_size = 0x2000; + src = compInput; + dst = compOutput; + outputSize = 0x2000; outputSamplesLeft = 0x1000; // Every data packet contains 0x2000 bytes of audio data @@ -641,11 +641,11 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in default: error("BundleCodecs::decompressCodec() Unknown codec %d!", (int)codec); - output_size = 0; + outputSize = 0; break; } - return output_size; + return outputSize; } } // End of namespace BundleCodecs diff --git a/engines/scumm/imuse_digi/dimuse_music.cpp b/engines/scumm/imuse_digi/dimuse_music.cpp index ad734c7311..bdfc4bf4fa 100644 --- a/engines/scumm/imuse_digi/dimuse_music.cpp +++ b/engines/scumm/imuse_digi/dimuse_music.cpp @@ -110,7 +110,7 @@ void IMuseDigital::setDigMusicSequence(int seqId) { _nextSeqToPlay = 0; _attributes[DIG_SEQ_OFFSET + num] = 1; } else { - if ((_digSeqMusicTable[_curMusicSeq].opcode == 4) || (_digSeqMusicTable[_curMusicSeq].opcode == 6)) { + if ((_digSeqMusicTable[_curMusicSeq].transitionType == 4) || (_digSeqMusicTable[_curMusicSeq].transitionType == 6)) { _nextSeqToPlay = num; return; } else { @@ -174,7 +174,7 @@ void IMuseDigital::playDigMusic(const char *songName, const imuseDigTable *table fadeOutMusic(120); - switch (table->opcode) { + switch (table->transitionType) { case 0: case 5: case 6: @@ -252,7 +252,7 @@ void IMuseDigital::setComiMusicSequence(int seqId) { playComiMusic(_comiSeqMusicTable[num].name, &_comiSeqMusicTable[num], 0, true); _nextSeqToPlay = 0; } else { - if ((_comiSeqMusicTable[_curMusicSeq].opcode == 4) || (_comiSeqMusicTable[_curMusicSeq].opcode == 6)) { + if ((_comiSeqMusicTable[_curMusicSeq].transitionType == 4) || (_comiSeqMusicTable[_curMusicSeq].transitionType == 6)) { _nextSeqToPlay = num; return; } else { @@ -295,7 +295,7 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab } } - switch (table->opcode) { + switch (table->transitionType) { case 0: fadeOutMusic(120); break; @@ -333,7 +333,7 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab startMusic(table->filename, table->soundId, 0, 127); return; } - if (table->opcode == 12) { + if (table->transitionType == 12) { startMusic(table->filename, table->soundId, table->hookId, 127); } else { startMusic(table->filename, table->soundId, hookId, 127); @@ -355,7 +355,7 @@ void IMuseDigital::setFtMusicState(int stateId) { if (stateId == 0) playFtMusic(NULL, 0, 0); else - playFtMusic(_ftStateMusicTable[stateId].audioName, _ftStateMusicTable[stateId].opcode, _ftStateMusicTable[stateId].volume); + playFtMusic(_ftStateMusicTable[stateId].audioName, _ftStateMusicTable[stateId].transitionType, _ftStateMusicTable[stateId].volume); } _curMusicState = stateId; @@ -374,11 +374,11 @@ void IMuseDigital::setFtMusicSequence(int seqId) { if (_curMusicState == 0) playFtMusic(NULL, 0, 0); else { - playFtMusic(_ftStateMusicTable[_curMusicState].audioName, _ftStateMusicTable[_curMusicState].opcode, _ftStateMusicTable[_curMusicState].volume); + playFtMusic(_ftStateMusicTable[_curMusicState].audioName, _ftStateMusicTable[_curMusicState].transitionType, _ftStateMusicTable[_curMusicState].volume); } } else { int seq = (seqId - 1) * 4; - playFtMusic(_ftSeqMusicTable[seq].audioName, _ftSeqMusicTable[seq].opcode, _ftSeqMusicTable[seq].volume); + playFtMusic(_ftSeqMusicTable[seq].audioName, _ftSeqMusicTable[seq].transitionType, _ftSeqMusicTable[seq].volume); } _curMusicSeq = seqId; @@ -401,7 +401,7 @@ void IMuseDigital::setFtMusicCuePoint(int cueId) { playFtMusic(NULL, 0, 0); else { int seq = ((_curMusicSeq - 1) * 4) + cueId; - playFtMusic(_ftSeqMusicTable[seq].audioName, _ftSeqMusicTable[seq].opcode, _ftSeqMusicTable[seq].volume); + playFtMusic(_ftSeqMusicTable[seq].audioName, _ftSeqMusicTable[seq].transitionType, _ftSeqMusicTable[seq].volume); } _curMusicCue = cueId; diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp index a61fbcfb24..186d04483e 100644 --- a/engines/scumm/imuse_digi/dimuse_script.cpp +++ b/engines/scumm/imuse_digi/dimuse_script.cpp @@ -176,17 +176,17 @@ void IMuseDigital::flushTracks() { // appendable stream. We play it nice and wait till all of it // played. if (track->stream->endOfStream()) { - _mixer->stopHandle(track->handle); + _mixer->stopHandle(track->mixChanHandle); delete track->stream; track->stream = NULL; _sound->closeSound(track->soundHandle); track->soundHandle = NULL; track->used = false; } - } else if (track->stream2) { - _mixer->stopHandle(track->handle); - delete track->stream2; - track->stream2 = NULL; + } else if (track->streamSou) { + _mixer->stopHandle(track->mixChanHandle); + delete track->streamSou; + track->streamSou = NULL; track->used = false; } } @@ -273,7 +273,7 @@ int32 IMuseDigital::getPosInMs(int soundId) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { - int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->iteration / 200); + int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->feedSize / 200); return pos; } } @@ -287,7 +287,7 @@ int IMuseDigital::getSoundStatus(int sound) const { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; if (track->soundId == sound) { - if ((track->stream2 && _mixer->isSoundHandleActive(track->handle)) || + if ((track->streamSou && _mixer->isSoundHandleActive(track->mixChanHandle)) || (track->stream && track->used && !track->readyToRemove)) { return 1; } @@ -393,15 +393,15 @@ void IMuseDigital::stopAllSounds() { // as we are protected by a mutex, and this method is never called // from IMuseDigital::callback either. if (track->stream) { - _mixer->stopHandle(track->handle); + _mixer->stopHandle(track->mixChanHandle); delete track->stream; track->stream = NULL; _sound->closeSound(track->soundHandle); track->soundHandle = NULL; - } else if (track->stream2) { - _mixer->stopHandle(track->handle); - delete track->stream2; - track->stream2 = NULL; + } else if (track->streamSou) { + _mixer->stopHandle(track->mixChanHandle); + delete track->streamSou; + track->streamSou = NULL; } // Mark the track as unused diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 61c5fece2a..ce963eaeea 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -465,7 +465,7 @@ bool ImuseDigiSndMgr::checkForProperHandle(soundStruct *soundHandle) { return false; } -bool ImuseDigiSndMgr::isCompressed(soundStruct *soundHandle) { +bool ImuseDigiSndMgr::isSndDataExtComp(soundStruct *soundHandle) { assert(checkForProperHandle(soundHandle)); return soundHandle->compressed; } diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.h b/engines/scumm/imuse_digi/dimuse_sndmgr.h index 2bdaed446b..5d2f8c88ba 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.h +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.h @@ -120,7 +120,7 @@ public: void closeSound(soundStruct *soundHandle); soundStruct *cloneSound(soundStruct *soundHandle); - bool isCompressed(soundStruct *soundHandle); + bool isSndDataExtComp(soundStruct *soundHandle); int getFreq(soundStruct *soundHandle); int getBits(soundStruct *soundHandle); int getChannels(soundStruct *soundHandle); diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index 6277cfdf01..75dde5e60f 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -52,8 +52,8 @@ int IMuseDigital::allocSlot(int priority) { for (l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; if (track->used && !track->toBeRemoved && - (lowest_priority > track->priority) && !track->stream2) { - lowest_priority = track->priority; + (lowest_priority > track->soundPriority) && !track->streamSou) { + lowest_priority = track->soundPriority; trackId = l; } } @@ -98,15 +98,15 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, track->volFadeDelay = 0; track->volFadeUsed = false; track->soundId = soundId; - track->started = false; + track->mixerStreamRunning = false; track->volGroupId = volGroupId; track->curHookId = hookId; - track->priority = priority; + track->soundPriority = priority; track->curRegion = -1; track->dataOffset = 0; track->regionOffset = 0; - track->mod = 0; - track->flags = 0; + track->dataMod12Bit = 0; + track->mixerFlags = 0; track->toBeRemoved = false; track->readyToRemove = false; track->soundType = soundType; @@ -114,19 +114,19 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int bits = 0, freq = 0, channels = 0; if (input) { - track->iteration = 0; - track->souStream = true; + track->feedSize = 0; + track->souStreamUsed = true; track->soundName[0] = 0; track->soundHandle = NULL; } else { - track->souStream = false; + track->souStreamUsed = false; strcpy(track->soundName, soundName); track->soundHandle = _sound->openSound(soundId, soundName, soundType, volGroupId, -1); if (track->soundHandle == NULL) return; - track->compressed = _sound->isCompressed(track->soundHandle); + track->sndDataExtComp = _sound->isSndDataExtComp(track->soundHandle); bits = _sound->getBits(track->soundHandle); channels = _sound->getChannels(track->soundHandle); @@ -145,28 +145,28 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, assert(channels == 1 || channels == 2); assert(0 < freq && freq <= 65535); - track->iteration = freq * channels; + track->feedSize = freq * channels; if (channels == 2) - track->flags = kFlagStereo | kFlagReverseStereo; + track->mixerFlags = kFlagStereo | kFlagReverseStereo; if ((bits == 12) || (bits == 16)) { - track->flags |= kFlag16Bits; - track->iteration *= 2; + track->mixerFlags |= kFlag16Bits; + track->feedSize *= 2; } else if (bits == 8) { - track->flags |= kFlagUnsigned; + track->mixerFlags |= kFlagUnsigned; } else error("IMuseDigital::startSound(): Can't handle %d bit samples", bits); #ifdef SCUMM_LITTLE_ENDIAN - if (track->compressed) - track->flags |= kFlagLittleEndian; + if (track->sndDataExtComp) + track->mixerFlags |= kFlagLittleEndian; #endif } if (input) { - track->stream2 = input; + track->streamSou = input; track->stream = NULL; - track->started = false; + track->mixerStreamRunning = false; } else { const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0; const int vol = track->vol / 1000; @@ -179,11 +179,10 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, if (track->volGroupId == 3) type = Audio::Mixer::kMusicSoundType; - // setup 1 second stream wrapped buffer - track->stream2 = NULL; - track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->flags)); - _mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false); - track->started = true; + track->streamSou = NULL; + track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags)); + _mixer->playInputStream(type, &track->mixChanHandle, track->stream, -1, vol, pan, false); + track->mixerStreamRunning = true; } track->used = true; @@ -197,7 +196,7 @@ void IMuseDigital::setPriority(int soundId, int priority) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { - track->priority = priority; + track->soundPriority = priority; } } } @@ -358,11 +357,10 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(const Track *track, int f type = Audio::Mixer::kPlainSoundType; break; } - fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), makeMixerFlags(fadeTrack->flags)); - _mixer->playInputStream(type, &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false); + fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), makeMixerFlags(fadeTrack->mixerFlags)); + _mixer->playInputStream(type, &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false); - // Mark the track as, uhh, used & started (surprise, surprise :) - fadeTrack->started = true; + fadeTrack->mixerStreamRunning = true; fadeTrack->used = true; return fadeTrack; diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 50307ebc57..2d7401fe57 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -85,29 +85,32 @@ void ScummEngine::parseEvents() { else if (event.kbd.keycode == 's') _res->resourceStats(); else - _keyPressed = event.kbd.ascii; // Normal key press, pass on to the game. + _keyPressed = event.kbd; // Normal key press, pass on to the game. } else if (event.kbd.flags & Common::KBD_ALT) { - // The result must be 273 for Alt-W - // because that's what MI2 looks for in - // its "instant win" cheat. - _keyPressed = event.kbd.keycode + 154; - } else if (event.kbd.ascii == 315 && (_game.id == GID_CMI && !(_game.features & GF_DEMO))) { - // FIXME: support in-game menu screen. For now, this remaps F1 to F5 in COMI - _keyPressed = 319; - } else if (event.kbd.ascii < 273 || event.kbd.ascii > 276 || _game.version >= 7) { - // don't let game have arrow keys as we currently steal them - // for keyboard cursor control - // this fixes bug with up arrow (273) corresponding to - // "instant win" cheat in MI2 mentioned above - // - // This is not applicable to Full Throttle as it processes keyboard - // cursor control by itself. Also it fixes derby scene - _keyPressed = event.kbd.ascii; // Normal key press, pass on to the game. + // Handle KBD_ALT combos. We know that the result must be 273 for Alt-W + // because that's what MI2 looks for in its "instant win" cheat. + + // FIXME: Handle this specific property of MI2 inside processKeyboard ? + _keyPressed = event.kbd; + _keyPressed.ascii = event.kbd.keycode + 154; + } else { + // Normal key press, pass on to the game. + _keyPressed = event.kbd; } - if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD) { - if (event.kbd.ascii >= 273 && event.kbd.ascii <= 276) { - _keyPressed = event.kbd.ascii - 273 + 54; + if (event.kbd.keycode >= Common::KEYCODE_UP && event.kbd.keycode <= Common::KEYCODE_LEFT) { + if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD) { + _keyPressed = event.kbd; + _keyPressed.ascii = event.kbd.ascii - Common::KEYCODE_UP + 54; + } else if (_game.version < 7) { + // FIXME: Handle this specific property inside processKeyboard ? + + // Don't let game see arrow keys. This fixes bug with up arrow (273) + // corresponding to the "instant win" cheat in MI2 mentioned above. + // + // This is not applicable to V7+ games, which need to see the arrow keys, + // too, else certain things (derby scene, asterorid lander) won't work. + _keyPressed.reset(); } } @@ -115,16 +118,16 @@ void ScummEngine::parseEvents() { // Keyboard is controlled via variable int _keyState = 0; - if (event.kbd.ascii == 276) // Left + if (event.kbd.keycode == Common::KEYCODE_LEFT) // Left _keyState = 1; - if (event.kbd.ascii == 275) // Right + if (event.kbd.keycode == Common::KEYCODE_RIGHT) // Right _keyState |= 2; - if (event.kbd.ascii == 273) // Up + if (event.kbd.keycode == Common::KEYCODE_UP) // Up _keyState |= 4; - if (event.kbd.ascii == 274) // Down + if (event.kbd.keycode == Common::KEYCODE_DOWN) // Down _keyState |= 8; if (event.kbd.flags == Common::KBD_SHIFT) @@ -136,10 +139,23 @@ void ScummEngine::parseEvents() { VAR(VAR_KEY_STATE) = _keyState; } - if (_keyPressed >= 512) - debugC(DEBUG_GENERAL, "_keyPressed > 512 (%d)", _keyPressed); + // FIXME: There is a discrepancy between EVENT_KEYDOWN and EVENT_KEYUP here: + // For EVENT_KEYDOWN, we use _keyPressed.keycode, which has potentially been + // modified, while for EVENT_KEYUP we use the unfiltered event.kbd.keycode. + // This could lead problems (like a key becoming 'stuck'). + + // FIXME #2: We are mixing ascii and keycode values here. We probably should + // be using keycodes, but at least INSANE checks for "Shift-V" by looking for + // the 'V' key being pressed. It would be easy to solve that by also storing the + // the modifier flags. However, since getKeyState() is also called by scripts, + // we have to be very careful with semantic changes. + // Nevertheless, it's bad to rely on "ascii" holdoing keycode values for special + // keys (like the function keys), so this should be fixed. + + if (_keyPressed.ascii >= 512) + debugC(DEBUG_GENERAL, "_keyPressed > 512 (%d)", _keyPressed.ascii); else - _keyDownMap[_keyPressed] = true; + _keyDownMap[_keyPressed.ascii] = true; break; case Common::EVENT_KEYUP: @@ -194,11 +210,11 @@ void ScummEngine::parseEvents() { // checking the gameid. Values are taken from script-14. case Common::EVENT_WHEELDOWN: - _keyPressed = 55; + _keyPressed = Common::KeyState(Common::KEYCODE_7, 55); // '7' break; case Common::EVENT_WHEELUP: - _keyPressed = 54; + _keyPressed = Common::KeyState(Common::KEYCODE_6, 54); // '6' break; case Common::EVENT_QUIT: @@ -218,20 +234,20 @@ void ScummEngine::parseEvents() { void ScummEngine_v90he::clearClickedStatus() { ScummEngine::clearClickedStatus(); if (_game.heversion >= 98) { - _logicHE->processKeyStroke(_keyPressed); + _logicHE->processKeyStroke(_keyPressed.ascii); } } void ScummEngine_v90he::processInput() { if (_game.heversion >= 98) { - _logicHE->processKeyStroke(_keyPressed); + _logicHE->processKeyStroke(_keyPressed.ascii); } ScummEngine::processInput(); } #endif void ScummEngine::clearClickedStatus() { - _keyPressed = 0; + _keyPressed.reset(); _mouseAndKeyboardStat = 0; _leftBtnPressed &= ~msClicked; @@ -240,15 +256,16 @@ void ScummEngine::clearClickedStatus() { void ScummEngine_v0::processInput() { // F1 - F3 - if (_keyPressed >= 315 && _keyPressed <= 317) { - switchActor(_keyPressed - 315); + if (_keyPressed.keycode >= Common::KEYCODE_F1 && _keyPressed.keycode <= Common::KEYCODE_F3) { + switchActor(_keyPressed.keycode - Common::KEYCODE_F1); } ScummEngine::processInput(); } + void ScummEngine::processInput() { - int lastKeyHit = _keyPressed; - _keyPressed = 0; + Common::KeyState lastKeyHit = _keyPressed; + _keyPressed.reset(); // // Clip the mouse coordinates, and compute _virtualMouse.x (and clip it, too) @@ -278,30 +295,30 @@ void ScummEngine::processInput() { _mouseAndKeyboardStat = 0; // Interpret 'return' as left click and 'tab' as right click - if (lastKeyHit && _cursor.state > 0) { - if (lastKeyHit == 9) { + if (lastKeyHit.keycode && _cursor.state > 0) { + if (lastKeyHit.keycode == Common::KEYCODE_TAB) { _mouseAndKeyboardStat = MBS_RIGHT_CLICK; - lastKeyHit = 0; - } else if (lastKeyHit == 13) { + lastKeyHit.reset(); + } else if (lastKeyHit.keycode == Common::KEYCODE_RETURN) { _mouseAndKeyboardStat = MBS_LEFT_CLICK; - lastKeyHit = 0; + lastKeyHit.reset(); } } - if (_leftBtnPressed & msClicked && _rightBtnPressed & msClicked && _game.version >= 4) { + if ((_leftBtnPressed & msClicked) && (_rightBtnPressed & msClicked) && _game.version >= 4) { // Pressing both mouse buttons is treated as if you pressed - // the cutscene exit key (i.e. ESC in most games). That mimicks + // the cutscene exit key (ESC) in V4+ games. That mimicks // the behaviour of the original engine where pressing both // mouse buttons also skips the current cutscene. _mouseAndKeyboardStat = 0; - lastKeyHit = (uint)VAR(VAR_CUTSCENEEXIT_KEY); - } else if (_rightBtnPressed & msClicked && (_game.version <= 3 && _game.id != GID_LOOM)) { + lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); + } else if ((_rightBtnPressed & msClicked) && (_game.version <= 3 && _game.id != GID_LOOM)) { // Pressing right mouse button is treated as if you pressed - // the cutscene exit key (i.e. ESC in most games). That mimicks + // the cutscene exit key (ESC) in V0-V3 games. That mimicks // the behaviour of the original engine where pressing right // mouse button also skips the current cutscene. _mouseAndKeyboardStat = 0; - lastKeyHit = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; + lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); } else if (_leftBtnPressed & msClicked) { _mouseAndKeyboardStat = MBS_LEFT_CLICK; } else if (_rightBtnPressed & msClicked) { @@ -322,33 +339,40 @@ void ScummEngine::processInput() { _rightBtnPressed &= ~msClicked; #ifdef _WIN32_WCE - if (lastKeyHit == KEY_ALL_SKIP) { + if (lastKeyHit.ascii == KEY_ALL_SKIP) { // Skip talk - if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) - lastKeyHit = (uint)VAR(VAR_TALKSTOP_KEY); - else - // Escape - lastKeyHit = 27; + if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) { + lastKeyHit = Common::KeyState(Common::KEYCODE_PERIOD); + } else { + lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); + } } #endif - if (!lastKeyHit) + if (!lastKeyHit.ascii) return; processKeyboard(lastKeyHit); } #ifndef DISABLE_SCUMM_7_8 -void ScummEngine_v8::processKeyboard(int lastKeyHit) { - // Alt-F5 brings up the original save/load dialog +void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { - if (lastKeyHit == 440 && !(_game.features & GF_DEMO)) { - lastKeyHit = 315; + if (!(_game.features & GF_DEMO)) { + // F1 (the trigger for the original save/load dialog) is mapped to F5 + if (lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.flags == 0) { + lastKeyHit = Common::KeyState(Common::KEYCODE_F5, 319); + } + + // Alt-F5 should bring up the original save/load dialog, so map it to F1. + if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { + lastKeyHit = Common::KeyState(Common::KEYCODE_F1, 315); + } } // If a key script was specified (a V8 feature), and it's trigger - // key was pressed, run it. - if (_keyScriptNo && (_keyScriptKey == lastKeyHit)) { + // key was pressed, run it. Usually used to display the built-in menu. + if (_keyScriptNo && (_keyScriptKey == lastKeyHit.ascii)) { runScript(_keyScriptNo, 0, 0, 0); return; } @@ -357,18 +381,18 @@ void ScummEngine_v8::processKeyboard(int lastKeyHit) { ScummEngine_v7::processKeyboard(lastKeyHit); } -void ScummEngine_v7::processKeyboard(int lastKeyHit) { +void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) { + const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0); - // COMI version string is hard coded in the engine, hence we don't - // invoke versionDialog here (it would only show nonsense). - // Dig/FT version strings are partly hard coded, too. - if (_game.version == 7 && lastKeyHit == VAR(VAR_VERSION_KEY)) { + // VAR_VERSION_KEY (usually ctrl-v) is used in COMI, Dig and FT to trigger + // a version dialog, unless VAR_VERSION_KEY is set to 0. However, the COMI + // version string is hard coded in the engine, hence we don't invoke + // versionDialog for it. Dig/FT version strings are partly hard coded, too. + if (_game.id != GID_CMI && 0 != VAR(VAR_VERSION_KEY) && + lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit.flags == Common::KBD_CTRL) { versionDialog(); - return; - } -#ifndef _WIN32_WCE - if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY)) { + } else if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { // Skip cutscene (or active SMUSH video). if (_smushActive) { if (_game.id == GID_FT) @@ -379,62 +403,30 @@ void ScummEngine_v7::processKeyboard(int lastKeyHit) { if (!_smushActive || _smushVideoShouldFinish) abortCutscene(); - _mouseAndKeyboardStat = lastKeyHit; - return; - } -#else - // On WinCE we've also got one special for skipping cutscenes or dialog, whatever is appropriate - // Since _smushActive is not a member of the base case class ScummEngine::, we detect here if we're - // playing a cutscene and skip it; else we forward the keystroke through to ScummEngine::processInput. - if (lastKeyHit == KEY_ALL_SKIP || (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY))) { - int bail = 1; - if (_smushActive) { - if (_game.id == GID_FT) { - _insane->escapeKeyHandler(); - bail = 0; - } else - _smushVideoShouldFinish = true; - } - if ((!_smushActive && vm.cutScenePtr[vm.cutSceneStackPointer]) || _smushVideoShouldFinish) { - abortCutscene(); - bail = 0; - } - if (!bail) { - _mouseAndKeyboardStat = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; - return; - } - - } -#endif + _mouseAndKeyboardStat = Common::ASCII_ESCAPE; - // Fall back to V6 behavior - ScummEngine_v6::processKeyboard(lastKeyHit); + } else { + // Fall back to V6 behavior + ScummEngine_v6::processKeyboard(lastKeyHit); + } } #endif -void ScummEngine_v6::processKeyboard(int lastKeyHit) { - if (lastKeyHit == 20) { - // FIXME: What key is '20' supposed to indicate? I can't trigger - // it with my keyboard, it seems... - char buf[256]; - - _voiceMode++; - if (_voiceMode == 3) - _voiceMode = 0; +void ScummEngine_v6::processKeyboard(Common::KeyState lastKeyHit) { + if (lastKeyHit.keycode == Common::KEYCODE_t && lastKeyHit.flags == Common::KBD_CTRL) { + SubtitleSettingsDialog dialog(this, _voiceMode); + _voiceMode = runDialog(dialog); switch (_voiceMode) { case 0: - sprintf(buf, "Speech Only"); ConfMan.setBool("speech_mute", false); ConfMan.setBool("subtitles", false); break; case 1: - sprintf(buf, "Speech and Subtitles"); ConfMan.setBool("speech_mute", false); ConfMan.setBool("subtitles", true); break; case 2: - sprintf(buf, "Subtitles Only"); ConfMan.setBool("speech_mute", true); ConfMan.setBool("subtitles", true); break; @@ -443,8 +435,6 @@ void ScummEngine_v6::processKeyboard(int lastKeyHit) { if (VAR_VOICE_MODE != 0xFF) VAR(VAR_VOICE_MODE) = _voiceMode; - GUI::TimedMessageDialog dialog(buf, 1500); - runDialog(dialog); return; } @@ -452,56 +442,31 @@ void ScummEngine_v6::processKeyboard(int lastKeyHit) { ScummEngine::processKeyboard(lastKeyHit); } -void ScummEngine_v2::processKeyboard(int lastKeyHit) { - if (lastKeyHit == ' ') { // space - pauseGame(); - } else if (lastKeyHit == 314+5) { // F5 - mainMenuDialog(); - } else if (lastKeyHit == 314+8) { // F8 - confirmRestartDialog(); - } else { - - if ((_game.version == 0 && lastKeyHit == 27) || - (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == 314+VAR(VAR_CUTSCENEEXIT_KEY))) { - abortCutscene(); - } else { - // Fall back to default behavior - ScummEngine::processKeyboard(lastKeyHit); - } +void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { + // Fall back to default behavior + ScummEngine::processKeyboard(lastKeyHit); - // Alt-F5 brings up the original save/load dialog + // Store the input type. So far we can't distinguish + // between 1, 3 and 5. + // 1) Verb 2) Scene 3) Inv. 4) Key + // 5) Sentence Bar - if (lastKeyHit == 440) { - lastKeyHit = 314+5; - } - - // Store the input type. So far we can't distinguish - // between 1, 3 and 5. - // 1) Verb 2) Scene 3) Inv. 4) Key - // 5) Sentence Bar - - if (VAR_KEYPRESS != 0xFF && lastKeyHit) { // Key Input - if (315 <= lastKeyHit && lastKeyHit < 315+12) { - // Convert F-Keys for V1/V2 games (they start at 1 instead of at 315) - VAR(VAR_KEYPRESS) = lastKeyHit - 314; - } else { - VAR(VAR_KEYPRESS) = lastKeyHit; - } + if (VAR_KEYPRESS != 0xFF && _mouseAndKeyboardStat) { // Key Input + if (315 <= _mouseAndKeyboardStat && _mouseAndKeyboardStat <= 323) { + // Convert F-Keys for V1/V2 games (they start at 1) + VAR(VAR_KEYPRESS) = _mouseAndKeyboardStat - 314; + } else { + VAR(VAR_KEYPRESS) = _mouseAndKeyboardStat; } } } -void ScummEngine_v3::processKeyboard(int lastKeyHit) { - if (_game.platform == Common::kPlatformFMTowns && lastKeyHit == 314+8) { // F8 - confirmRestartDialog(); - } else { - // Fall back to default behavior - ScummEngine::processKeyboard(lastKeyHit); - } - - // i brings up an IQ dialog in Indy3 +void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) { + // Fall back to default behavior + ScummEngine::processKeyboard(lastKeyHit); - if (lastKeyHit == 'i' && _game.id == GID_INDY3) { + // 'i' brings up an IQ dialog in Indy3 + if (lastKeyHit.ascii == 'i' && _game.id == GID_INDY3) { // SCUMM var 244 is the episode score // and var 245 is the series score char text[50]; @@ -520,22 +485,31 @@ void ScummEngine_v3::processKeyboard(int lastKeyHit) { } } -void ScummEngine::processKeyboard(int lastKeyHit) { - int saveloadkey; - +void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { + // Enable the following five special keys conditionally: + bool restartKeyEnabled = (VAR_RESTART_KEY == 0xFF || VAR(VAR_RESTART_KEY) != 0); + bool pauseKeyEnabled = (VAR_PAUSE_KEY == 0xFF || VAR(VAR_PAUSE_KEY) != 0); + bool talkstopKeyEnabled = (VAR_TALKSTOP_KEY == 0xFF || VAR(VAR_TALKSTOP_KEY) != 0); + bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0); + bool mainmenuKeyEnabled = (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0); + + // In FM-TOWNS games F8 / restart is always enabled + if (_game.platform == Common::kPlatformFMTowns) + restartKeyEnabled = true; + + // For games which use VAR_MAINMENU_KEY, disable the mainmenu key if + // requested by the scripts. We make an exception for COMI (i.e. + // forcefully always enable it there), as that always disables it. + if (_game.id == GID_CMI) + mainmenuKeyEnabled = true; + +/* + FIXME: We also used to force-enable F5 in Sam&Max and HE >= 72 games -- why? if ((_game.version <= 3) || (_game.id == GID_SAMNMAX) || (_game.id == GID_CMI) || (_game.heversion >= 72)) - saveloadkey = 319; // F5 - else - saveloadkey = VAR(VAR_MAINMENU_KEY); - - // Alt-F5 brings up the original save/load dialog. + mainmenuKeyEnabled = true; +*/ - if (lastKeyHit == 440 && _game.version > 2 && _game.version < 8) { - lastKeyHit = saveloadkey; - saveloadkey = -1; - } - - if (lastKeyHit == saveloadkey) { + if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0)) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0); @@ -544,57 +518,66 @@ void ScummEngine::processKeyboard(int lastKeyHit) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0); - } else if (VAR_RESTART_KEY != 0xFF && lastKeyHit == VAR(VAR_RESTART_KEY)) { + } else if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0)) { confirmRestartDialog(); - } else if (VAR_PAUSE_KEY != 0xFF && lastKeyHit == VAR(VAR_PAUSE_KEY)) { + } else if (pauseKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_SPACE && lastKeyHit.flags == 0)) { pauseGame(); - } else if (VAR_TALKSTOP_KEY != 0xFF && lastKeyHit == VAR(VAR_TALKSTOP_KEY)) { + } else if (talkstopKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_PERIOD && lastKeyHit.flags == 0)) { _talkDelay = 0; if (_sound->_sfxMode & 2) stopTalk(); + } else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit.flags == 0)) { + abortCutscene(); + + // FIXME: Is the following line really necessary? + _mouseAndKeyboardStat = VAR(VAR_CUTSCENEEXIT_KEY); + + } else if (lastKeyHit.ascii == '[' || lastKeyHit.ascii == ']') { // Change music volume + int vol = ConfMan.getInt("music_volume") / 16; + if (lastKeyHit.ascii == ']' && vol < 16) + vol++; + else if (lastKeyHit.ascii == '[' && vol > 0) + vol--; + + // Display the music volume + ValueDisplayDialog dlg("Music volume: ", 0, 16, vol, ']', '['); + vol = runDialog(dlg); + + vol *= 16; + if (vol > Audio::Mixer::kMaxMixerVolume) + vol = Audio::Mixer::kMaxMixerVolume; + + ConfMan.setInt("music_volume", vol); + updateSoundSettings(); + + } else if (lastKeyHit.ascii == '-' || lastKeyHit.ascii == '+') { // Change text speed + if (lastKeyHit.ascii == '+' && _defaultTalkDelay > 0) + _defaultTalkDelay--; + else if (lastKeyHit.ascii == '-' && _defaultTalkDelay < 9) + _defaultTalkDelay++; + + // Display the talk speed + ValueDisplayDialog dlg("Subtitle speed: ", 0, 9, 9 - _defaultTalkDelay, '+', '-'); + _defaultTalkDelay = 9 - runDialog(dlg); + + // Save the new talkspeed value to ConfMan + setTalkspeed(_defaultTalkDelay); + + if (VAR_CHARINC != 0xFF) + VAR(VAR_CHARINC) = _defaultTalkDelay; + + } else if (lastKeyHit.ascii == '~' || lastKeyHit.ascii == '#') { // Debug console + _debugger->attach(); + } else { - if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY)) { - abortCutscene(); - } else if (lastKeyHit == '[' || lastKeyHit == ']') { // Change music volume - int vol = ConfMan.getInt("music_volume") / 16; - if (lastKeyHit == ']' && vol < 16) - vol++; - else if (lastKeyHit == '[' && vol > 0) - vol--; - - // Display the music volume - ValueDisplayDialog dlg("Music volume: ", 0, 16, vol, ']', '['); - vol = runDialog(dlg); - - vol *= 16; - if (vol > Audio::Mixer::kMaxMixerVolume) - vol = Audio::Mixer::kMaxMixerVolume; - - ConfMan.setInt("music_volume", vol); - updateSoundSettings(); - } else if (lastKeyHit == '-' || lastKeyHit == '+') { // Change text speed - if (lastKeyHit == '+' && _defaultTalkDelay > 0) - _defaultTalkDelay--; - else if (lastKeyHit == '-' && _defaultTalkDelay < 9) - _defaultTalkDelay++; - - // Display the talk speed - ValueDisplayDialog dlg("Subtitle speed: ", 0, 9, 9 - _defaultTalkDelay, '+', '-'); - _defaultTalkDelay = 9 - runDialog(dlg); - - // Save the new talkspeed value to ConfMan - setTalkspeed(_defaultTalkDelay); - - if (VAR_CHARINC != 0xFF) - VAR(VAR_CHARINC) = _defaultTalkDelay; - } else if (lastKeyHit == '~' || lastKeyHit == '#') { // Debug console - _debugger->attach(); - } - - _mouseAndKeyboardStat = lastKeyHit; + // FIXME: Possibly convert even more keycode/ascii pairs to their SCUMM counterparts? + if (lastKeyHit.keycode >= Common::KEYCODE_F1 && lastKeyHit.keycode <= Common::KEYCODE_F9) + _mouseAndKeyboardStat = lastKeyHit.keycode - Common::KEYCODE_F1 + 315; + else + _mouseAndKeyboardStat = lastKeyHit.ascii; } } diff --git a/engines/scumm/insane/insane.cpp b/engines/scumm/insane/insane.cpp index f445fe490c..252407913e 100644 --- a/engines/scumm/insane/insane.cpp +++ b/engines/scumm/insane/insane.cpp @@ -580,10 +580,10 @@ int32 Insane::processKeyboard(void) { _enemyState[EN_BEN][1] += tmpy; } - if (_vm->getKeyState(0x0d)) + if (_vm->getKeyState(Common::KEYCODE_RETURN)) retval |= 1; - if (_vm->getKeyState(0x09)) + if (_vm->getKeyState(Common::KEYCODE_TAB)) retval |= 2; return retval; diff --git a/engines/scumm/insane/insane_enemy.cpp b/engines/scumm/insane/insane_enemy.cpp index 36568a635c..3866cf230d 100644 --- a/engines/scumm/insane/insane_enemy.cpp +++ b/engines/scumm/insane/insane_enemy.cpp @@ -230,7 +230,7 @@ int32 Insane::enemy0handler(int32 actor1, int32 actor2, int32 probability) { _actor[actor1].cursorX = -160; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[1].damage = _actor[1].maxdamage + 10; @@ -375,7 +375,7 @@ int32 Insane::enemy1handler(int32 actor1, int32 actor2, int32 probability) { _actor[actor1].cursorX = -160; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[1].damage = _actor[1].maxdamage + 10; @@ -524,7 +524,7 @@ int32 Insane::enemy2handler(int32 actor1, int32 actor2, int32 probability) { _actor[actor1].cursorX = -160; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[1].damage = _actor[1].maxdamage + 10; @@ -681,7 +681,7 @@ int32 Insane::enemy3handler(int32 actor1, int32 actor2, int32 probability) { _actor[actor1].cursorX = -160; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[1].damage = _actor[1].maxdamage + 10; @@ -851,7 +851,7 @@ int32 Insane::enemy4handler(int32 actor1, int32 actor2, int32 probability) { _actor[actor1].cursorX = -160; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[1].damage = _actor[1].maxdamage + 10; @@ -995,7 +995,7 @@ int32 Insane::enemy5handler(int32 actor1, int32 actor2, int32 probability) { _enHdlVar[EN_VULTF2][0]++; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[1].damage = _actor[1].maxdamage + 10; @@ -1123,7 +1123,7 @@ int32 Insane::enemy6handler(int32 actor1, int32 actor2, int32 probability) { retval = 2; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[0].act[2].state = 97; @@ -1213,7 +1213,7 @@ int32 Insane::enemy7handler(int32 actor1, int32 actor2, int32 probability) { _enHdlVar[EN_CAVEFISH][0] = act1damage; // Shift+V cheat to win the battle - if (_vm->getKeyState(0x56) && !_beenCheated && + if (_vm->getKeyState('V') && !_beenCheated && !_actor[0].lost && !_actor[1].lost) { _beenCheated = 1; _actor[1].damage = _actor[1].maxdamage + 10; diff --git a/engines/scumm/intern.h b/engines/scumm/intern.h index 3c16f78a68..008c2995e5 100644 --- a/engines/scumm/intern.h +++ b/engines/scumm/intern.h @@ -241,7 +241,7 @@ protected: virtual void readRoomsOffsets(); virtual void loadCharset(int no); - virtual void processKeyboard(int lastKeyHit); + virtual void processKeyboard(Common::KeyState lastKeyHit); }; /** @@ -305,7 +305,7 @@ protected: virtual void resetScummVars(); virtual void decodeParseString(); - virtual void processKeyboard(int lastKeyHit); + virtual void processKeyboard(Common::KeyState lastKeyHit); virtual void readIndexFile(); void readClassicIndexFile(); // V1 @@ -611,7 +611,7 @@ protected: virtual const char *getOpcodeDesc(byte i); virtual void scummLoop_handleActors(); - virtual void processKeyboard(int lastKeyHit); + virtual void processKeyboard(Common::KeyState lastKeyHit); virtual void setupScummVars(); virtual void decodeParseString(int a, int b); @@ -912,7 +912,7 @@ protected: virtual void scummLoop_handleSound(); virtual void scummLoop_handleDrawing(); - virtual void processKeyboard(int lastKeyHit); + virtual void processKeyboard(Common::KeyState lastKeyHit); virtual void setupScumm(); @@ -994,7 +994,7 @@ protected: virtual int getObjectIdFromOBIM(const byte *obim); - virtual void processKeyboard(int lastKeyHit); + virtual void processKeyboard(Common::KeyState lastKeyHit); void desaturatePalette(int hueScale, int satScale, int lightScale, int startColor, int endColor); diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp index a408616942..7e0d705377 100644 --- a/engines/scumm/script_v6.cpp +++ b/engines/scumm/script_v6.cpp @@ -2803,25 +2803,34 @@ void ScummEngine_v6::o6_kernelGetFunctions() { int ScummEngine::getKeyState(int key) { switch (key) { case 0x147: // Home - return (_keyDownMap[0x107] || _keyDownMap[0x115]) ? 1 : 0; + // FIXME: There seems to be a mistake in the code here ("insert" vs. "home") + return (_keyDownMap[Common::KEYCODE_KP7] || + _keyDownMap[Common::KEYCODE_INSERT]) ? 1 : 0; case 0x148: // Up - return (_keyDownMap[0x108] || _keyDownMap[0x111] || - _keyDownMap[0x38]) ? 1 : 0; + return (_keyDownMap[Common::KEYCODE_KP8] || + _keyDownMap[Common::KEYCODE_UP] || + _keyDownMap[Common::KEYCODE_8]) ? 1 : 0; case 0x149: // PgUp - return (_keyDownMap[0x109] || _keyDownMap[0x118]) ? 1 : 0; + return (_keyDownMap[Common::KEYCODE_KP9] || + _keyDownMap[Common::KEYCODE_PAGEUP]) ? 1 : 0; case 0x14B: // Left - return (_keyDownMap[0x104] || _keyDownMap[0x114] || - _keyDownMap[0x34]) ? 1 : 0; + return (_keyDownMap[Common::KEYCODE_KP4] || + _keyDownMap[Common::KEYCODE_LEFT] || + _keyDownMap[Common::KEYCODE_4]) ? 1 : 0; case 0x14D: // Right - return (_keyDownMap[0x106] || _keyDownMap[0x113] || - _keyDownMap[0x36]) ? 1 : 0; + return (_keyDownMap[Common::KEYCODE_KP6] || + _keyDownMap[Common::KEYCODE_RIGHT] || + _keyDownMap[Common::KEYCODE_6]) ? 1 : 0; case 0x14F: // End - return (_keyDownMap[0x101] || _keyDownMap[0x117]) ? 1 : 0; + return (_keyDownMap[Common::KEYCODE_KP1] || + _keyDownMap[Common::KEYCODE_END]) ? 1 : 0; case 0x150: // Down - return (_keyDownMap[0x102] || _keyDownMap[0x112] || - _keyDownMap[0x32]) ? 1 : 0; + return (_keyDownMap[Common::KEYCODE_KP2] || + _keyDownMap[Common::KEYCODE_DOWN] || + _keyDownMap[Common::KEYCODE_2]) ? 1 : 0; case 0x151: // PgDn - return (_keyDownMap[0x103] || _keyDownMap[0x119]) ? 1 : 0; + return (_keyDownMap[Common::KEYCODE_KP3] || + _keyDownMap[Common::KEYCODE_PAGEDOWN]) ? 1 : 0; default: return (_keyDownMap[key]) ? 1 : 0; } diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 05d18f8a90..840940caa3 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Sun May 13 00:46:42 2007 + This file was generated by the md5table tool on Fri Jun 08 10:51:50 2007 DO NOT EDIT MANUALLY! */ @@ -113,6 +113,7 @@ static const MD5Table md5table[] = { { "2a208ffbcd0e83e86f4356e6f64aa6e1", "loom", "EGA", "EGA", -1, Common::ES_ESP, Common::kPlatformPC }, { "2a41b53cf1a90b6e6f26c10cc6041084", "tentacle", "", "Demo", 2439158, Common::EN_ANY, Common::kPlatformMacintosh }, { "2a446817ffcabfef8716e0c456ecaf81", "puttzoo", "", "Demo", -1, Common::DE_DEU, Common::kPlatformWindows }, + { "2a8658dbd13d84d1bce64a71a35995eb", "pajama2", "HE 99", "Demo", -1, Common::HB_ISR, Common::kPlatformWindows }, { "2c04aacffb8428f30ccf4f734fbe3adc", "activity", "", "", -1, Common::EN_ANY, Common::kPlatformPC }, { "2ccd8891ce4d3f1a334d21bff6a88ca2", "monkey", "CD", "", 9455, Common::EN_ANY, Common::kPlatformMacintosh }, { "2d1e891fe52df707c30185e52c50cd92", "monkey", "CD", "CD", 8955, Common::EN_ANY, Common::kPlatformPC }, @@ -154,6 +155,7 @@ static const MD5Table md5table[] = { { "3a0c35f3c147b98a2bdf8d400cfc4ab5", "indy3", "FM-TOWNS", "", -1, Common::JA_JPN, Common::kPlatformFMTowns }, { "3a5d13675e9a23aedac0bac7730f0ac1", "samnmax", "", "CD", -1, Common::FR_FRA, Common::kPlatformMacintosh }, { "3a5ec90d556d4920976c5578bfbfaf79", "maniac", "NES", "extracted", -1, Common::DE_DEU, Common::kPlatformNES }, + { "3af61c5edf8e15b43dbafd285b2e9777", "puttcircus", "", "Demo", -1, Common::HB_ISR, Common::kPlatformWindows }, { "3b301b7892f883ce42ab4be6a274fea6", "samnmax", "", "Floppy", -1, Common::EN_ANY, Common::kPlatformPC }, { "3b832f4a90740bf22e9b8ed42ca0128c", "freddi4", "HE 99", "", -1, Common::EN_GRB, Common::kPlatformWindows }, { "3cce1913a3bc586b51a75c3892ff18dd", "indy3", "VGA", "VGA", -1, Common::RU_RUS, Common::kPlatformPC }, @@ -475,6 +477,7 @@ static const MD5Table md5table[] = { { "d62d248c3df6ec177405e2cb23d923b2", "indy3", "EGA", "EGA", -1, Common::IT_ITA, Common::kPlatformPC }, { "d6334a5a9b61afe18c368540fdf522ca", "airport", "", "", -1, Common::EN_ANY, Common::kPlatformMacintosh }, { "d6dd0646404768a63e963891a96daadd", "atlantis", "", "Floppy", 12035, Common::EN_ANY, Common::kPlatformMacintosh }, + { "d73c851b942af44deb9b6d5f416a0972", "freddi3", "HE 99", "Demo", -1, Common::HB_ISR, Common::kPlatformWindows }, { "d74122362a77ec24525fdd50297dfd82", "freddi4", "", "", -1, Common::FR_FRA, Common::kPlatformMacintosh }, { "d7ab7cd6105546016e6a0d46fb36b964", "pajama", "HE 100", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "d7b247c26bf1f01f8f7daf142be84de3", "balloon", "HE 99", "Updated", -1, Common::EN_ANY, Common::kPlatformWindows }, diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 8abfd006a5..4b3a365394 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -180,7 +180,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _curPalIndex = 0; _currentRoom = 0; _egoPositioned = false; - _keyPressed = 0; _mouseAndKeyboardStat = 0; _leftBtnPressed = 0; _rightBtnPressed = 0; diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 59c5923e3b..8c8124714d 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -29,6 +29,7 @@ #include "engines/engine.h" #include "common/endian.h" #include "common/file.h" +#include "common/keyboard.h" #include "common/rect.h" #include "common/str.h" #include "graphics/surface.h" @@ -482,7 +483,7 @@ public: protected: void waitForTimer(int msec_delay); virtual void processInput(); - virtual void processKeyboard(int lastKeyHit); + virtual void processKeyboard(Common::KeyState lastKeyHit); virtual void clearClickedStatus(); // Cursor/palette @@ -584,7 +585,7 @@ public: Common::String generateFilename(const int room) const; protected: - int _keyPressed; + Common::KeyState _keyPressed; bool _keyDownMap[512]; // FIXME - 512 is a guess. it's max(kbd.ascii) Common::Point _mouse; diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 4a468d151c..e5720a013f 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -643,7 +643,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle _vm->_imuseDigital->startVoice(kTalkSoundID, input); #endif } else { - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, input, id); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, handle, input, id); } } } |