From 12c9fb03820c383d5d10fa3c3ba8e2cffad8db98 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Tue, 12 Jun 2007 06:08:47 +0000 Subject: Add support for pausing/resume cutscenes shown on the OmniTV in The Feeble Files. svn-id: r27371 --- engines/sword1/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sword1') diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index d66db9347d..4aad6194e9 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -410,7 +410,7 @@ bool MoviePlayerDXA::load(uint32 id) { snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); if (loadFile(filename)) { // The Broken Sword games always use external audio tracks. - if (_fd.readUint32BE() != MKID_BE('NULL')) + if (_fd->readUint32BE() != MKID_BE('NULL')) return false; _frameWidth = getWidth(); _frameHeight = getHeight(); -- cgit v1.2.3 From fe8a7163cdd39c292e46e9713b26c6e07bf7faf0 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 16 Jun 2007 19:27:05 +0000 Subject: Try to be more robust/paranoid when reading the SAVEGAME.INF file. Apart from being a sensible precaution, it should work around some bugs like #1737801, where the file is obviously corrupted. (Possibly mutilated by some file transfer program.) svn-id: r27484 --- engines/sword1/control.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index e40db20f37..63b86997ce 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -700,6 +700,9 @@ void Control::readSavegameDescriptions(void) { inf = _saveFileMan->openForLoading("SAVEGAME.INF"); _saveScrollPos = _saveFiles = 0; _selectedSavegame = 255; + for (uint8 cnt = 0; cnt < 64; cnt++) { + memset(_saveNames[cnt], 0, sizeof(_saveNames[cnt])); + } if (inf) { uint8 curFileNum = 0; uint8 ch; @@ -707,20 +710,18 @@ void Control::readSavegameDescriptions(void) { uint8 pos = 0; do { ch = inf->readByte(); - if ((ch == 10) || (ch == 255)) - _saveNames[curFileNum][pos] = '\0'; - else - _saveNames[curFileNum][pos] = ch; - pos++; - } while ((ch != 10) && (ch != 255)); - curFileNum++; - } while (ch != 255); + if (pos < sizeof(_saveNames[curFileNum]) - 1) { + if ((ch == 10) || (ch == 255) || (inf->eos())) + _saveNames[curFileNum][pos++] = '\0'; + else if (ch >= 32) + _saveNames[curFileNum][pos++] = ch; + } + } while ((ch != 10) && (ch != 255) && (!inf->eos())); + if (_saveNames[curFileNum][0] != 0) + curFileNum++; + } while ((ch != 255) && (!inf->eos())); _saveFiles = curFileNum; - for (uint8 cnt = _saveFiles; cnt < 64; cnt++) - _saveNames[cnt][0] = '\0'; - } else - for (uint8 cnt = 0; cnt < 64; cnt++) - _saveNames[cnt][0] = '\0'; + } delete inf; } -- cgit v1.2.3 From 2a7c76d4e4e2663edeb38cd37262f196bfc7e14f Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 17 Jun 2007 14:50:49 +0000 Subject: Added support for FLAC encoded music in Broken Sword 1. (The compression tool knows nothing about this, and since they're being rewritten as part of the SoC, I'm not going to do anything about that.) svn-id: r27511 --- engines/sword1/music.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'engines/sword1') diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp index 67a390802b..ebff7f9929 100644 --- a/engines/sword1/music.cpp +++ b/engines/sword1/music.cpp @@ -31,6 +31,7 @@ #include "sword1/music.h" #include "sound/aiff.h" +#include "sound/flac.h" #include "sound/mixer.h" #include "sound/mp3.h" #include "sound/vorbis.h" @@ -201,7 +202,19 @@ int AiffAudioStream::readBuffer(int16 *buffer, const int numSamples) { bool MusicHandle::play(const char *fileBase, bool loop) { char fileName[30]; stop(); - + +#ifdef USE_FLAC + if (!_audioSource) { + sprintf(fileName, "%s.flac", fileBase); + if (_file.open(fileName)) + _audioSource = Audio::makeFlacStream(&_file, false, 0, 0, loop ? 0 : 1); + } + if (!_audioSource) { + sprintf(fileName, "%s.fla", fileBase); + if (_file.open(fileName)) + _audioSource = Audio::makeFlacStream(&_file, false, 0, 0, loop ? 0 : 1); + } +#endif #ifdef USE_VORBIS if (!_audioSource) { sprintf(fileName, "%s.ogg", fileBase); -- cgit v1.2.3 From e42da8f24c92f0828543d75377bf4b8ed1390392 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 22 Jun 2007 09:27:13 +0000 Subject: Use KEYCODE constants. svn-id: r27600 --- engines/sword1/animation.cpp | 2 +- engines/sword1/control.cpp | 2 +- engines/sword1/sword1.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 4aad6194e9..d54968daeb 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -295,7 +295,7 @@ void MoviePlayer::play(void) { handleScreenChanged(); break; case Common::EVENT_KEYDOWN: - if (event.kbd.keycode == 27) { + if (event.kbd.keycode == Common::KEYCODE_ESCAPE) { _snd->stopHandle(_bgSoundHandle); terminated = true; } diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 63b86997ce..62dd0ecb6b 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -1047,7 +1047,7 @@ void Control::delay(uint32 msecs) { case Common::EVENT_KEYDOWN: // Make sure backspace works right (this fixes a small issue on OS X) - if (event.kbd.keycode == 8) + if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) _keyPressed = 8; else _keyPressed = (byte)event.kbd.ascii; diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 97e518421c..05115afc13 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -713,7 +713,7 @@ void SwordEngine::delay(int32 amount) { //copied and mutilated from sky.cpp switch (event.type) { case Common::EVENT_KEYDOWN: // Make sure backspace works right (this fixes a small issue on OS X) - if (event.kbd.keycode == 8) + if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) _keyPressed = 8; else _keyPressed = (uint8)event.kbd.ascii; -- cgit v1.2.3 From 2fa0a5c457e0aea4edffb49aa80a04a59b6e9994 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 21:16:07 +0000 Subject: Cleaning up after myself (I blame it on, err, uhh... the Vogons?) svn-id: r27625 --- engines/sword1/control.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 62dd0ecb6b..108773fc23 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -1047,9 +1047,10 @@ void Control::delay(uint32 msecs) { case Common::EVENT_KEYDOWN: // Make sure backspace works right (this fixes a small issue on OS X) - if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) + if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { +printf("Mac backspace workaround, was %d\n", event.kbd.ascii); _keyPressed = 8; - else + } else _keyPressed = (byte)event.kbd.ascii; // we skip the rest of the delay and return immediately // to handle keyboard input -- cgit v1.2.3 From c9030e4653d8dd3a96724681a6423f1b1b296d4d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 21:34:03 +0000 Subject: Made BS1 track the full KeyState upon KEYDOWN events (this makes it possible to remove to workaround for Mac keyboards) svn-id: r27627 --- engines/sword1/control.cpp | 44 +++++++++++++++++++------------------------- engines/sword1/control.h | 7 ++++--- 2 files changed, 23 insertions(+), 28 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 108773fc23..7479484a06 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -204,7 +204,7 @@ void Control::askForCd(void) { _system->copyRectToScreen(_screenBuf, 640, 0, 0, 640, 480); } delay(300); - if (_keyPressed) { + if (_keyPressed.keycode) { if (!Common::File::exists(fName)) { memset(_screenBuf, 0, 640 * 480); renderText(_lStrings[STR_INCORRECT_CD], 320, 230, TEXT_CENTER); @@ -224,7 +224,8 @@ void Control::askForCd(void) { uint8 Control::runPanel(void) { _mouseDown = false; _restoreBuf = NULL; - _keyPressed = _numButtons = 0; + _keyPressed.keycode = Common::KEYCODE_INVALID; + _numButtons = 0; _screenBuf = (uint8*)malloc(640 * 480); memset(_screenBuf, 0, 640 * 480); _system->copyRectToScreen(_screenBuf, 640, 0, 0, 640, 480); @@ -283,7 +284,7 @@ uint8 Control::runPanel(void) { _cursorVisible = false; _cursorTick = 0; } - if (_keyPressed) + if (_keyPressed.keycode) handleSaveKey(_keyPressed); else if (_cursorVisible != visible) showSavegameNames(); @@ -328,10 +329,9 @@ uint8 Control::getClicks(uint8 mode, uint8 *retVal) { } uint8 flag = 0; - if (_keyPressed == 27) + if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) flag = kButtonCancel; - // 3 is num keypad Enter on Macs. See FR #1273746 - else if (_keyPressed == '\r' || _keyPressed == '\n' || _keyPressed == 3) + else if (_keyPressed.keycode == Common::KEYCODE_RETURN || _keyPressed.keycode == Common::KEYCODE_KP_ENTER) flag = kButtonOk; if (flag) { @@ -622,9 +622,9 @@ bool Control::getConfirm(const uint8 *title) { buttons[0]->draw(); buttons[1]->draw(); delay(1000 / 12); - if (_keyPressed == 27) + if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) retVal = 2; - else if (_keyPressed == '\r' || _keyPressed == '\n') + else if (_keyPressed.keycode == Common::KEYCODE_RETURN || _keyPressed.keycode == Common::KEYCODE_KP_ENTER) retVal = 1; if (_mouseState & BS1L_BUTTON_DOWN) { if (buttons[0]->wasClicked(_mouseX, _mouseY)) @@ -649,7 +649,7 @@ bool Control::getConfirm(const uint8 *title) { return retVal == 1; } -bool Control::keyAccepted(uint8 key) { +bool Control::keyAccepted(uint16 ascii) { // this routine needs changes for Czech keys... No idea how to do that, though. // FIXME: It is not a good idea to put non-ASCII chars into a C source file, // since there is no way to specify which encoding you are using. @@ -658,22 +658,22 @@ bool Control::keyAccepted(uint8 key) { // do not at all specify which encoding keyboard events use, so this // check here is probably not portable anyway... static const char allowedSpecials[] = "éèáàúùäöüÄÖÜß,.:-()?! \"\'"; - if (((key >= 'A') && (key <= 'Z')) || - ((key >= 'a') && (key <= 'z')) || - ((key >= '0') && (key <= '9')) || - strchr(allowedSpecials, key)) + if (((ascii >= 'A') && (ascii <= 'Z')) || + ((ascii >= 'a') && (ascii <= 'z')) || + ((ascii >= '0') && (ascii <= '9')) || + strchr(allowedSpecials, ascii)) return true; else return false; } -void Control::handleSaveKey(uint8 key) { +void Control::handleSaveKey(Common::KeyState kbd) { if (_selectedSavegame < 255) { uint8 len = strlen((char*)_saveNames[_selectedSavegame]); - if ((key == 8) && len) // backspace + if ((kbd.keycode == Common::KEYCODE_BACKSPACE) && len) // backspace _saveNames[_selectedSavegame][len - 1] = '\0'; - else if (keyAccepted(key) && (len < 31)) { - _saveNames[_selectedSavegame][len] = key; + else if (keyAccepted(kbd.ascii) && (len < 31)) { + _saveNames[_selectedSavegame][len] = kbd.ascii; _saveNames[_selectedSavegame][len + 1] = '\0'; } showSavegameNames(); @@ -1037,7 +1037,7 @@ void Control::delay(uint32 msecs) { uint32 now = _system->getMillis(); uint32 endTime = now + msecs; - _keyPressed = 0; //reset + _keyPressed.keycode = Common::KEYCODE_INVALID; //reset _mouseState = 0; do { @@ -1045,13 +1045,7 @@ void Control::delay(uint32 msecs) { while (eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: - - // Make sure backspace works right (this fixes a small issue on OS X) - if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { -printf("Mac backspace workaround, was %d\n", event.kbd.ascii); - _keyPressed = 8; - } else - _keyPressed = (byte)event.kbd.ascii; + _keyPressed = event.kbd; // we skip the rest of the delay and return immediately // to handle keyboard input return; diff --git a/engines/sword1/control.h b/engines/sword1/control.h index 89ea7199b6..1825350170 100644 --- a/engines/sword1/control.h +++ b/engines/sword1/control.h @@ -27,6 +27,7 @@ #define SWORD1_CONTROL_H #include "common/scummsys.h" +#include "common/events.h" #include "sword1/sworddefs.h" class OSystem; @@ -118,8 +119,8 @@ private: void saveNameSelect(uint8 id, bool saving); bool saveToFile(void); bool restoreFromFile(void); - bool keyAccepted(uint8 key); - void handleSaveKey(uint8 key); + bool keyAccepted(uint16 ascii); + void handleSaveKey(Common::KeyState kbd); void renderVolumeBar(uint8 id, uint8 volL, uint8 volR); uint16 getTextWidth(const uint8 *str); @@ -141,7 +142,7 @@ private: Sound *_sound; uint8 *_font, *_redFont; uint8 *_screenBuf; - uint8 _keyPressed; + Common::KeyState _keyPressed; void delay(uint32 msecs); uint16 _mouseX, _mouseY, _mouseState; bool _mouseDown; -- cgit v1.2.3 From 1441f0d044548e32507954e42b6cb5332a5c591d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 22:00:46 +0000 Subject: Converted rest of BS1 to use Common::KeyState (removing two more hacks) svn-id: r27631 --- engines/sword1/sword1.cpp | 14 ++++++-------- engines/sword1/sword1.h | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 05115afc13..8968aefb5a 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -635,7 +635,7 @@ void SwordEngine::checkCd(void) { uint8 SwordEngine::mainLoop(void) { uint8 retCode = 0; - _keyPressed = 0; + _keyPressed.keycode = Common::KEYCODE_INVALID; while ((retCode == 0) && (!_systemVars.engineQuit)) { // do we need the section45-hack from sword.c here? @@ -678,12 +678,14 @@ uint8 SwordEngine::mainLoop(void) { // The control panel is triggered by F5 or ESC. // FIXME: This is a very strange way of detecting F5... - else if (((_keyPressed == 63 || _keyPressed == 27) && (Logic::_scriptVars[MOUSE_STATUS] & 1)) || (_systemVars.controlPanelMode)) { + else if (((_keyPressed.keycode == Common::KEYCODE_F5 || _keyPressed.keycode == Common::KEYCODE_ESCAPE) + && (Logic::_scriptVars[MOUSE_STATUS] & 1)) || (_systemVars.controlPanelMode)) { retCode = _control->runPanel(); if (!retCode) _screen->fullRefresh(); } - _mouseState = _keyPressed = 0; + _mouseState = 0; + _keyPressed.keycode = Common::KEYCODE_INVALID; } while ((Logic::_scriptVars[SCREEN] == Logic::_scriptVars[NEW_SCREEN]) && (retCode == 0) && (!_systemVars.engineQuit)); if ((retCode == 0) && (Logic::_scriptVars[SCREEN] != 53) && _systemVars.wantFade && (!_systemVars.engineQuit)) { @@ -712,11 +714,7 @@ void SwordEngine::delay(int32 amount) { //copied and mutilated from sky.cpp while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: - // Make sure backspace works right (this fixes a small issue on OS X) - if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) - _keyPressed = 8; - else - _keyPressed = (uint8)event.kbd.ascii; + _keyPressed = event.kbd; break; case Common::EVENT_MOUSEMOVE: _mouseX = event.mouse.x; diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h index 1ced01d6ef..7065b5498a 100644 --- a/engines/sword1/sword1.h +++ b/engines/sword1/sword1.h @@ -27,6 +27,7 @@ #define SWORD1_H #include "engines/engine.h" +#include "common/events.h" #include "common/util.h" #include "sword1/sworddefs.h" @@ -92,7 +93,7 @@ private: uint8 mainLoop(void); uint16 _mouseX, _mouseY, _mouseState; - uint8 _keyPressed; + Common::KeyState _keyPressed; ResMan *_resMan; ObjectMan *_objectMan; -- cgit v1.2.3 From d0ee1b3c8ff521707a6f5064ee54638460aaee21 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 22:19:17 +0000 Subject: BS1: Make use of Common::KeySate::reset() svn-id: r27636 --- engines/sword1/control.cpp | 4 ++-- engines/sword1/sword1.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 7479484a06..1ebfaedb2e 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -224,7 +224,7 @@ void Control::askForCd(void) { uint8 Control::runPanel(void) { _mouseDown = false; _restoreBuf = NULL; - _keyPressed.keycode = Common::KEYCODE_INVALID; + _keyPressed.reset(); _numButtons = 0; _screenBuf = (uint8*)malloc(640 * 480); memset(_screenBuf, 0, 640 * 480); @@ -1037,7 +1037,7 @@ void Control::delay(uint32 msecs) { uint32 now = _system->getMillis(); uint32 endTime = now + msecs; - _keyPressed.keycode = Common::KEYCODE_INVALID; //reset + _keyPressed.reset(); _mouseState = 0; do { diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 8968aefb5a..3c8abd0953 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -635,7 +635,7 @@ void SwordEngine::checkCd(void) { uint8 SwordEngine::mainLoop(void) { uint8 retCode = 0; - _keyPressed.keycode = Common::KEYCODE_INVALID; + _keyPressed.reset(); while ((retCode == 0) && (!_systemVars.engineQuit)) { // do we need the section45-hack from sword.c here? @@ -685,7 +685,7 @@ uint8 SwordEngine::mainLoop(void) { _screen->fullRefresh(); } _mouseState = 0; - _keyPressed.keycode = Common::KEYCODE_INVALID; + _keyPressed.reset(); } while ((Logic::_scriptVars[SCREEN] == Logic::_scriptVars[NEW_SCREEN]) && (retCode == 0) && (!_systemVars.engineQuit)); if ((retCode == 0) && (Logic::_scriptVars[SCREEN] != 53) && _systemVars.wantFade && (!_systemVars.engineQuit)) { -- cgit v1.2.3