diff options
Diffstat (limited to 'engines/access')
29 files changed, 226 insertions, 169 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6ad1b22408..7f59ae7ad6 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -41,6 +41,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _events = nullptr; _files = nullptr; _inventory = nullptr; + _midi = nullptr; _player = nullptr; _room = nullptr; _screen = nullptr; @@ -92,6 +93,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _vidX = _vidY = 0; _cheatFl = false; _restartFl = false; + _printEnd = 0; } AccessEngine::~AccessEngine() { @@ -220,12 +222,13 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->clearEvents(); while (!shouldQuit()) { _sound->freeSounds(); - Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundTable.push_back(SoundEntry(sound, 1)); + _sound->loadSoundTable(0, _narateFile + 99, _sndSubFile); _sound->playSound(0); - _scripts->cmdFreeSound(); - _events->pollEvents(); + while(_sound->isSFXPlaying() && !shouldQuit()) + _events->pollEvents(); + + _scripts->cmdFreeSound(); if (_events->isKeyMousePressed()) { _sndSubFile += soundsLeft; @@ -254,9 +257,11 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundTable.push_back(SoundEntry(res, 1)); _sound->playSound(0); - _scripts->cmdFreeSound(); - _events->pollEvents(); + while(_sound->isSFXPlaying() && !shouldQuit()) + _events->pollEvents(); + + _scripts->cmdFreeSound(); if (_events->_leftButton) { _events->debounceLeft(); diff --git a/engines/access/access.h b/engines/access/access.h index a082b969c4..be007e0cb8 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -191,7 +191,6 @@ public: bool _canSaveLoad; Resource *_establish; - int _et; int _printEnd; int _txtPages; int _narateFile; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 933a98aded..4c9df7b8ff 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -61,9 +61,16 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _helpTbl[1] = _help2; _helpTbl[2] = _help3; + _chapter = 0; + _rawInactiveX = _rawInactiveY = 0; + _inactiveYOff = 0; + _hintLevel = 0; + _updateChapter = 0; + _oldTitleChapter = 0; + _iqValue = 0; + _chapterCells.push_back(CellIdent(0, 96, 17)); _inactive._spritesPtr = nullptr; - _inactive._altSpritesPtr = nullptr; _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0; _inactive._position = Common::Point(0, 0); } @@ -261,7 +268,6 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { _screen->_maxChars = 37; _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(estabIndex); - _et = estabIndex; uint16 msgOffset; if (!isCD()) msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2)); @@ -522,8 +528,8 @@ void AmazonEngine::startChapter(int chapter) { _sound->freeSounds(); if (isCD()) { - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1)); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1)); + _sound->loadSoundTable(0, 115, 0); + _sound->loadSoundTable(1, 115, 1); _sound->playSound(0); _sound->playSound(1); @@ -552,7 +558,7 @@ void AmazonEngine::startChapter(int chapter) { // Show chapter screen _files->loadScreen(96, 15); - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0]; _screen->plotImage(_objectsTable[0], _chapter - 1, @@ -583,14 +589,14 @@ void AmazonEngine::startChapter(int chapter) { _screen->clearBuffer(); _files->loadScreen(96, 16); - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); _screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7)); _midi->newMusic(7, 1); _midi->newMusic(34, 0); _screen->forceFadeIn(); - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); _fonts._charSet._lo = 1; _fonts._charSet._hi = 10; @@ -670,7 +676,7 @@ void AmazonEngine::dead(int deathId) { _files->_setPaletteFlag = false; _files->loadScreen(94, 0); _files->_setPaletteFlag = true; - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); if (!isDemo() || deathId != 10) { for (int i = 0; i < 3; ++i) { diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 436a875688..6dffb85e5e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -106,8 +106,8 @@ void CampScene::mWhileDoOpen() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(1, 2); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); // Load animation data _vm->_animation->freeAnimationData(); @@ -317,8 +317,8 @@ void Opening::doTitle() { _vm->_events->hideCursor(); if (!_vm->isDemo()) { - _vm->_sound->queueSound(0, 98, 30); - _vm->_sound->queueSound(1, 98, 8); + _vm->_sound->loadSoundTable(0, 98, 30); + _vm->_sound->loadSoundTable(1, 98, 8); _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 3); @@ -341,19 +341,16 @@ void Opening::doTitle() { _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); delete spriteData; - _vm->_sound->playSound(1); - _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 4); _vm->_sound->playSound(1); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) { - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); int id = COUNTDOWN[_pCount * 2]; int xp = COUNTDOWN[_pCount * 2 + 1]; _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); @@ -385,8 +382,8 @@ void Opening::doTitle() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 5); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); screen.forceFadeIn(); _vm->_midi->newMusic(1, 0); _vm->_events->_vbCount = 700; @@ -493,55 +490,62 @@ void Opening::doTent() { _vm->_screen->setDisplayScan(); _vm->_screen->forceFadeOut(); _vm->_events->hideCursor(); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 39), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 14), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 15), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 16), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 31), 2)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 52), 2)); + _vm->_sound->loadSoundTable(0, 98, 39); + _vm->_sound->loadSoundTable(1, 98, 14); + _vm->_sound->loadSoundTable(2, 98, 15); + _vm->_sound->loadSoundTable(3, 98, 16); + _vm->_sound->loadSoundTable(4, 98, 31, 2); + _vm->_sound->loadSoundTable(5, 98, 52, 2); _vm->_sound->playSound(0); _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(2, 0); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_screen->forceFadeIn(); _vm->_video->setVideo(_vm->_screen, Common::Point(126, 73), FileIdent(2, 1), 10); + int previousFrame = -1; while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) { _vm->_video->playVideo(); - if ((_vm->_video->_videoFrame == 32) || (_vm->_video->_videoFrame == 34)) - _vm->_sound->playSound(4); - else if (_vm->_video->_videoFrame == 36) { - if (step != 2) { - _vm->_sound->playSound(2); - step = 2; - } - } else if (_vm->_video->_videoFrame == 18) { - if (step != 1) { - _vm->_midi->newMusic(73, 1); - _vm->_midi->newMusic(11, 0); - step = 1; - _vm->_sound->playSound(1); + if (previousFrame != _vm->_video->_videoFrame) { + previousFrame = _vm->_video->_videoFrame; + + if ((_vm->_video->_videoFrame == 32) || (_vm->_video->_videoFrame == 34)) + _vm->_sound->playSound(4); + else if (_vm->_video->_videoFrame == 36) { + if (step != 2) { + _vm->_sound->playSound(2); + step = 2; + } + } else if (_vm->_video->_videoFrame == 18) { + if (step != 1) { + _vm->_midi->newMusic(73, 1); + _vm->_midi->newMusic(11, 0); + step = 1; + _vm->_sound->playSound(1); + } } } - _vm->_events->pollEventsAndWait(); } _vm->_sound->playSound(5); _vm->_video->setVideo(_vm->_screen, Common::Point(43, 11), FileIdent(2, 2), 10); + previousFrame = -1; while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) { _vm->_video->playVideo(); - if (_vm->_video->_videoFrame == 26) { - _vm->_sound->playSound(5); - } else if (_vm->_video->_videoFrame == 15) { - if (step !=3) { - _vm->_sound->playSound(3); - step = 3; + if (previousFrame != _vm->_video->_videoFrame) { + previousFrame = _vm->_video->_videoFrame; + if (_vm->_video->_videoFrame == 26) { + _vm->_sound->playSound(5); + } else if (_vm->_video->_videoFrame == 15) { + if (step !=3) { + _vm->_sound->playSound(3); + step = 3; + } } } - _vm->_events->pollEventsAndWait(); } @@ -1035,7 +1039,7 @@ void Guard::setHorizontalCode() { if (_bottomRight.x < screen._orgX1) _gCode2 |= 8; - else if (_bottomRight.y > screen._orgX2) + else if (_bottomRight.x > screen._orgX2) _gCode2 |= 2; } @@ -1276,8 +1280,8 @@ void Cast::doCast(int param1) { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(58, 1); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _xTrack = 0; _yTrack = -6; @@ -1319,7 +1323,7 @@ void Cast::doCast(int param1) { while (!_vm->shouldQuit()) { _vm->_images.clear(); pan(); - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); _vm->_newRects.clear(); _vm->plotList(); _vm->copyBlocks(); @@ -1371,6 +1375,18 @@ River::River(AmazonEngine *vm) : PannedScene(vm) { _deathCount = 0; _oldScrollCol = 0; _maxHits = 0; + _mapPtr = nullptr; + _canoeMoveCount = 0; + _canoeVXPos = 0; + _canoeFrame = 0; + _canoeDir = 0; + _canoeLane = 0; + _canoeYPos = 0; + _hitCount = 0; + _riverIndex = 0; + _topList = _botList = nullptr; + _deathType = 0; + _hitSafe = 0; } void River::setRiverPan() { @@ -1410,7 +1426,7 @@ void River::initRiver() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(95, 4); - _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); screen.restorePalette(); screen.setBufferScan(); @@ -1480,11 +1496,11 @@ void River::initRiver() { _maxHits = 2 - _vm->_riverFlag; _saveRiver = false; - Font &font2 = _vm->_fonts._font2; - font2._fontColors[0] = 0; - font2._fontColors[1] = 33; - font2._fontColors[2] = 34; - font2._fontColors[3] = 35; + // Set font colors for drawing using font2 + Font::_fontColors[0] = 0; + Font::_fontColors[1] = 33; + Font::_fontColors[2] = 34; + Font::_fontColors[3] = 35; } void River::resetPositions() { @@ -1510,8 +1526,6 @@ void River::checkRiverPan() { } bool River::riverJumpTest() { - Screen &screen = *_vm->_screen; - if (_vm->_scrollCol == 120 || _vm->_scrollCol == 60 || _vm->_scrollCol == 0) { int val = *++_mapPtr; if (val == 0xFF) @@ -1744,7 +1758,7 @@ void River::mWhileDownRiver() { screen.savePalette(); if (!_vm->isDemo()) _vm->_files->loadScreen(95, 4); - _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); screen.restorePalette(); screen.setPalette(); screen.setBufferScan(); @@ -1909,7 +1923,6 @@ void River::synchronize(Common::Serializer &s) { if (_vm->_player->_roomNumber == 45) { if (s.isSaving()) { // Set river properties to be saved out - Screen &screen = *_vm->_screen; _rScrollRow = _vm->_scrollRow; _rScrollCol = _vm->_scrollCol; _rScrollX = _vm->_scrollX; diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index a1fb4eef77..0d962483e6 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -242,6 +242,8 @@ public: class InactivePlayer : public ImageEntry { public: SpriteResource *_altSpritesPtr; + + InactivePlayer() { _altSpritesPtr = nullptr; } }; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 633188e4dd..92acb3686d 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -38,7 +38,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { void AmazonScripts::cLoop() { searchForSequence(); _vm->_images.clear(); - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); _vm->_oldRects.clear(); _vm->_scripts->executeScript(); _vm->plotList1(); @@ -51,8 +51,8 @@ void AmazonScripts::mWhile1() { _vm->_events->hideCursor(); _vm->_files->loadScreen(14, 0); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -86,8 +86,8 @@ void AmazonScripts::mWhile1() { _vm->_files->loadScreen(14, 1); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -95,7 +95,7 @@ void AmazonScripts::mWhile1() { _vm->_oldRects.clear(); _sequence = 2200; - _vm->_sound->queueSound(0, 14, 15); + _vm->_sound->loadSoundTable(0, 14, 15); do { cLoop(); @@ -107,8 +107,8 @@ void AmazonScripts::mWhile1() { _vm->_files->loadScreen(14, 2); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -138,8 +138,8 @@ void AmazonScripts::mWhile1() { _vm->_files->loadScreen(14, 3); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -159,8 +159,8 @@ void AmazonScripts::mWhile2() { _vm->_events->hideCursor(); _vm->_files->loadScreen(14, 0); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -190,8 +190,8 @@ void AmazonScripts::mWhile2() { _vm->_files->loadScreen(14, 3); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -240,8 +240,8 @@ void AmazonScripts::loadBackground(int param1, int param2) { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(param1, param2); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_screen->forceFadeIn(); } diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 548e7db02d..14d7c0d4cc 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -310,9 +310,7 @@ Animation *AnimationManager::setAnimation(int animId) { anim->_countdownTicks = anim->_initialTicks; anim->_frameNumber = 0; - anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : - anim->_loopCount; - anim->_field10 = 0; + anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : anim->_loopCount; return anim; } diff --git a/engines/access/animation.h b/engines/access/animation.h index 722f5430ab..72621c4d11 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -106,7 +106,6 @@ public: int _loopCount; int _countdownTicks; int _currentLoopCount; - int _field10; public: Animation(AccessEngine *vm, Common::SeekableReadStream *stream); ~Animation(); diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 38af7add00..5f4372d5af 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -102,7 +102,7 @@ void ImageEntryList::addToList(ImageEntry &ie) { int ASurface::_clipWidth; int ASurface::_clipHeight; -ASurface::ASurface() { +ASurface::ASurface(): Graphics::Surface() { _leftSkip = _rightSkip = 0; _topSkip = _bottomSkip = 0; _lastBoundsX = _lastBoundsY = 0; @@ -110,6 +110,7 @@ ASurface::ASurface() { _orgX1 = _orgY1 = 0; _orgX2 = _orgY2 = 0; _lColor = 0; + _maxChars = 0; } ASurface::~ASurface() { @@ -186,7 +187,7 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } } -void ASurface::transCopyFrom(ASurface *src, const Common::Point &destPos) { +void ASurface::transBlitFrom(ASurface *src, const Common::Point &destPos) { if (getPixels() == nullptr) create(w, h); @@ -201,7 +202,7 @@ void ASurface::transCopyFrom(ASurface *src, const Common::Point &destPos) { } } -void ASurface::transCopyFrom(ASurface *src, const Common::Rect &bounds) { +void ASurface::transBlitFrom(ASurface *src, const Common::Rect &bounds) { const int SCALE_LIMIT = 0x100; int scaleX = SCALE_LIMIT * bounds.width() / src->w; int scaleY = SCALE_LIMIT * bounds.height() / src->h; @@ -247,11 +248,12 @@ void ASurface::transCopyFrom(ASurface *src, const Common::Rect &bounds) { } } -void ASurface::transCopyFrom(ASurface &src) { - copyFrom(src); +void ASurface::transBlitFrom(ASurface &src) { + blitFrom(src); } -void ASurface::copyFrom(Graphics::Surface &src) { +void ASurface::blitFrom(Graphics::Surface &src) { + assert(w >= src.w && h >= src.h); for (int y = 0; y < src.h; ++y) { const byte *srcP = (const byte *)src.getBasePtr(0, y); byte *destP = (byte *)getBasePtr(0, y); @@ -260,7 +262,7 @@ void ASurface::copyFrom(Graphics::Surface &src) { } void ASurface::copyBuffer(Graphics::Surface *src) { - copyFrom(*src); + blitFrom(*src); } void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { @@ -272,14 +274,14 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { - transCopyFrom(frame, bounds); + transBlitFrom(frame, bounds); } void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { ASurface flippedFrame; frame->flipHorizontal(flippedFrame); - transCopyFrom(&flippedFrame, bounds); + transBlitFrom(&flippedFrame, bounds); } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 763e3e629e..4fb47b9c09 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -95,19 +95,19 @@ public: virtual void drawRect(); - virtual void transCopyFrom(ASurface *src, const Common::Point &destPos); + virtual void transBlitFrom(ASurface *src, const Common::Point &destPos); - virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds); + virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds); - virtual void transCopyFrom(ASurface &src); + virtual void transBlitFrom(ASurface &src); - virtual void copyFrom(Graphics::Surface &src); + virtual void blitFrom(Graphics::Surface &src); virtual void copyBuffer(Graphics::Surface *src); virtual void addDirtyRect(const Common::Rect &r) {} - void copyTo(ASurface *dest) { dest->copyFrom(*this); } + void copyTo(ASurface *dest) { dest->blitFrom(*this); } void saveBlock(const Common::Rect &bounds); diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index e37a8142e8..28c211991c 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -27,13 +27,12 @@ namespace Access { BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) { + _startItem = 0; + _startBox = 0; + _charCol = _rowOff = 0; _type = TYPE_2; _bounds = Common::Rect(64, 32, 64 + 130, 32 + 122); _bubbleDisplStr = ""; - _fieldD = 0; - _fieldE = 0; - _fieldF = 0; - _field10 = 0; } void BubbleBox::load(Common::SeekableReadStream *stream) { diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 0130344c7e..0b3f139520 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -49,10 +49,6 @@ public: Common::StringArray _nameIndex; Common::String _bubbleTitle; Common::String _bubbleDisplStr; - int _fieldD; - int _fieldE; - int _fieldF; - int _field10; Common::Array<Common::Rect> _bubbles; public: diff --git a/engines/access/char.cpp b/engines/access/char.cpp index 5bc6707509..b359bcf13a 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -108,8 +108,8 @@ void CharManager::loadChar(int charId) { _vm->_screen->fadeIn(); } - _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); _vm->_screen->setDisplayScan(); if (_charFlag != 2 && _charFlag != 3) { diff --git a/engines/access/char.h b/engines/access/char.h index e89cdae49f..6fb4934978 100644 --- a/engines/access/char.h +++ b/engines/access/char.h @@ -51,11 +51,8 @@ private: void charMenu(); public: Common::Array<CharEntry> _charTable; - int _converseMode; int _charFlag; - // Fields that are included in savegames - int _conversation; public: CharManager(AccessEngine *vm); diff --git a/engines/access/decompress.cpp b/engines/access/decompress.cpp index 62bff87860..c5656afa51 100644 --- a/engines/access/decompress.cpp +++ b/engines/access/decompress.cpp @@ -32,8 +32,9 @@ void LzwDecompressor::decompress(byte *source, byte *dest) { _source = source; - byte litByte; - uint16 copyLength, maxCodeValue, code, nextCode, lastCode, oldCode; + byte litByte = 0; + uint16 oldCode = 0; + uint16 copyLength, maxCodeValue, code, nextCode, lastCode; byte *copyBuf = new byte[8192]; diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 0867b09765..6ffe67acfb 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -140,6 +140,8 @@ void EventsManager::pollEvents(bool skipTimers) { if (checkForNextTimerUpdate() && !skipTimers) nextTimer(); + _vm->_sound->checkSoundQueue(); + _wheelUp = _wheelDown = false; Common::Event event; diff --git a/engines/access/font.cpp b/engines/access/font.cpp index da8f0b6ec5..8af183f193 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -27,6 +27,8 @@ namespace Access { byte Font::_fontColors[4]; Font::Font() { + _bitWidth = 0; + _height = 0; } Font::~Font() { diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 8db62a45fc..df499ba705 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -57,6 +57,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _startAboutItem = 0; _startTravelItem = 0; _iconDisplayFlag = true; + _boxNum = 0; const char *const *names; const int *combineP; diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index 6392206209..4e4a5135a6 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -100,8 +100,8 @@ void MartianEngine::doTitle() { _files->_setPaletteFlag = false; _files->loadScreen(0, 3); - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); + _buffer1.blitFrom(*_screen); _screen->forceFadeIn(); _sound->playSound(1); @@ -115,13 +115,13 @@ void MartianEngine::doTitle() { _files->loadScreen(0, 4); _sound->playSound(1); - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); + _buffer1.blitFrom(*_screen); _sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; for (_pCount = 0; _pCount < 3; ++_pCount) { - _buffer2.copyFrom(_buffer1); + _buffer2.blitFrom(_buffer1); int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); diff --git a/engines/access/player.cpp b/engines/access/player.cpp index d547aedc1d..e47daf532c 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -48,7 +48,6 @@ Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() { _playerSprites1 = nullptr; _manPal1 = nullptr; _frameNumber = 0; - _monData = nullptr; _rawTempL = 0; _rawXTemp = 0; _rawYTempL = 0; @@ -73,6 +72,12 @@ Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() { _playerDirection = NONE; _xFlag = _yFlag = 0; _inactiveYOff = 0; + + _sideWalkMin = _sideWalkMax = 0; + _upWalkMin = _upWalkMax = 0; + _downWalkMin = _downWalkMax = 0; + _diagUpWalkMin = _diagUpWalkMax = 0; + _diagDownWalkMin = _diagDownWalkMax = 0; } Player::~Player() { diff --git a/engines/access/player.h b/engines/access/player.h index 26caec681f..329cc15ed2 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -84,7 +84,6 @@ public: Direction _playerDirection; SpriteResource *_playerSprites; // Fields in original Player structure - byte *_monData; int _walkOffRight[PLAYER_DATA_COUNT]; int _walkOffLeft[PLAYER_DATA_COUNT]; int _walkOffUp[PLAYER_DATA_COUNT]; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f7c2eabd0f..607259ec6f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -370,9 +370,9 @@ void Room::loadPlayField(int fileNum, int subfile) { screen.loadRawPalette(playData->_stream); // Copy off the tile data - _tileSize = (int)header[2] << 8; - _tile = new byte[_tileSize]; - playData->_stream->read(_tile, _tileSize); + int tileSize = (int)header[2] << 8; + _tile = new byte[tileSize]; + playData->_stream->read(_tile, tileSize); // Copy off the playfield data _matrixSize = header[0] * header[1]; diff --git a/engines/access/room.h b/engines/access/room.h index 44279fa6b1..eec273e3f4 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -124,7 +124,6 @@ public: int _playFieldWidth; int _playFieldHeight; byte *_tile; - int _tileSize; int _selectCommand; bool _conFlag; public: diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 35069ba683..970a8f3079 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -56,6 +56,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _bufferBytesWide = _vWindowBytesWide = this->w; _vWindowLinesTall = this->h; + _vWindowWidth = _vWindowHeight = 0; _clipWidth = _vWindowBytesWide - 1; _clipHeight = _vWindowLinesTall - 1; _startCycle = 0; @@ -266,19 +267,19 @@ void Screen::drawRect() { ASurface::drawRect(); } -void Screen::transCopyFrom(ASurface *src, const Common::Point &destPos) { +void Screen::transBlitFrom(ASurface *src, const Common::Point &destPos) { addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h)); - ASurface::transCopyFrom(src, destPos); + ASurface::transBlitFrom(src, destPos); } -void Screen::transCopyFrom(ASurface *src, const Common::Rect &bounds) { +void Screen::transBlitFrom(ASurface *src, const Common::Rect &bounds) { addDirtyRect(bounds); - ASurface::transCopyFrom(src, bounds); + ASurface::transBlitFrom(src, bounds); } -void Screen::copyFrom(Graphics::Surface &src) { +void Screen::blitFrom(Graphics::Surface &src) { addDirtyRect(Common::Rect(0, 0, src.w, src.h)); - ASurface::copyFrom(src); + ASurface::blitFrom(src); } void Screen::copyBuffer(Graphics::Surface *src) { diff --git a/engines/access/screen.h b/engines/access/screen.h index 0fa111c21c..d45a533f9a 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -92,11 +92,11 @@ public: virtual void drawRect(); - virtual void transCopyFrom(ASurface *src, const Common::Point &destPos); + virtual void transBlitFrom(ASurface *src, const Common::Point &destPos); - virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds); + virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds); - virtual void copyFrom(Graphics::Surface &src); + virtual void blitFrom(Graphics::Surface &src); virtual void copyBuffer(Graphics::Surface *src); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2e22d9a2ce..1bd24894d7 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -29,10 +29,12 @@ namespace Access { Scripts::Scripts(AccessEngine *vm) : Manager(vm) { _resource = nullptr; + _specialFunction = -1; _data = nullptr; _sequence = 0; _endFlag = false; _returnCode = 0; + _scriptCommand = 0; _choice = 0; _choiceStart = 0; _charsOrg = Common::Point(0, 0); @@ -73,7 +75,7 @@ void Scripts::charLoop() { _sequence = 2000; searchForSequence(); _vm->_images.clear(); - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); _vm->_newRects.clear(); executeScript(); @@ -792,7 +794,7 @@ void Scripts::cmdFreeSound() { charLoop(); _vm->_events->pollEvents(); - } while (!_vm->shouldQuit() && sound._playingSound); + } while (!_vm->shouldQuit() && sound.isSFXPlaying()); // Free the sounds while (sound._soundTable.size() > 0) { diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index a7d96dac9a..da267bdc4c 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -22,7 +22,6 @@ #include "common/algorithm.h" #include "audio/mixer.h" -#include "audio/audiostream.h" #include "audio/decoders/raw.h" #include "audio/decoders/wave.h" #include "access/access.h" @@ -31,8 +30,6 @@ namespace Access { SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { - _playingSound = false; - _isVoice = false; } SoundManager::~SoundManager() { @@ -44,11 +41,23 @@ void SoundManager::clearSounds() { for (uint i = 0; i < _soundTable.size(); ++i) delete _soundTable[i]._res; + _soundTable.clear(); + + if (_mixer->isSoundHandleActive(_effectsHandle)) + _mixer->stopHandle(_effectsHandle); + + if (_queue.size()) + _queue.remove_at(0); + + while (_queue.size()) { + delete _queue[0]; + _queue.remove_at(0); + } } -void SoundManager::queueSound(int idx, int fileNum, int subfile) { - debugC(1, kDebugSound, "queueSound(%d, %d, %d)", idx, fileNum, subfile); +void SoundManager::loadSoundTable(int idx, int fileNum, int subfile, int priority) { + debugC(1, kDebugSound, "loadSoundTable(%d, %d, %d)", idx, fileNum, subfile); Resource *soundResource; @@ -58,7 +67,7 @@ void SoundManager::queueSound(int idx, int fileNum, int subfile) { delete _soundTable[idx]._res; soundResource = _vm->_files->loadFile(fileNum, subfile); _soundTable[idx]._res = soundResource; - _soundTable[idx]._priority = 1; + _soundTable[idx]._priority = priority; } Resource *SoundManager::loadSound(int fileNum, int subfile) { @@ -77,19 +86,14 @@ void SoundManager::playSound(Resource *res, int priority) { debugC(1, kDebugSound, "playSound"); byte *resourceData = res->data(); - Audio::SoundHandle audioHandle; - Audio::RewindableAudioStream *audioStream = 0; assert(res->_size >= 32); - // HACK: Simulates queueing for the rare sounds played one after the other - while (_mixer->hasActiveChannelOfType(Audio::Mixer::kSFXSoundType)) - ; - if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) { // CD version uses WAVE-files Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(resourceData, res->_size, DisposeAfterUse::NO); - audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES); + Audio::RewindableAudioStream *audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES); + _queue.push_back(audioStream); } else if (READ_BE_UINT32(resourceData) == MKTAG('S', 'T', 'E', 'V')) { // sound files have a fixed header of 32 bytes in total @@ -130,22 +134,34 @@ void SoundManager::playSound(Resource *res, int priority) { return; } - audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0); + Audio::RewindableAudioStream *audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0, DisposeAfterUse::NO); + _queue.push_back(audioStream); } else error("Unknown format"); - audioHandle = Audio::SoundHandle(); - _mixer->playStream(Audio::Mixer::kSFXSoundType, &audioHandle, - audioStream, -1, _mixer->kMaxChannelVolume, 0, - DisposeAfterUse::NO); - - /* - Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); - audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1, - Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES, false); - */ + if (!_mixer->isSoundHandleActive(_effectsHandle)) + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle, + _queue[0], -1, _mixer->kMaxChannelVolume, 0, + DisposeAfterUse::YES); +} + +void SoundManager::checkSoundQueue() { + debugC(5, kDebugSound, "checkSoundQueue"); + + if (_queue.empty() || _mixer->isSoundHandleActive(_effectsHandle)) + return; + + _queue.remove_at(0); + + if (_queue.size()) + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle, + _queue[0], -1, _mixer->kMaxChannelVolume, 0, + DisposeAfterUse::YES); +} + +bool SoundManager::isSFXPlaying() { + return _mixer->isSoundHandleActive(_effectsHandle); } void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) { diff --git a/engines/access/sound.h b/engines/access/sound.h index d0f4584fac..90f6656e26 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -24,6 +24,7 @@ #define ACCESS_SOUND_H #include "common/scummsys.h" +#include "audio/audiostream.h" #include "audio/mixer.h" #include "access/files.h" #include "audio/midiplayer.h" @@ -47,22 +48,23 @@ class SoundManager { private: AccessEngine *_vm; Audio::Mixer *_mixer; - Audio::SoundHandle _soundHandle; + Audio::SoundHandle _effectsHandle; + Common::Array<Audio::RewindableAudioStream *> _queue; void clearSounds(); void playSound(Resource *res, int priority); public: Common::Array<SoundEntry> _soundTable; - bool _playingSound; - bool _isVoice; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); - void queueSound(int idx, int fileNum, int subfile); + void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1); void playSound(int soundIndex); + void checkSoundQueue(); + bool isSFXPlaying(); Resource *loadSound(int fileNum, int subfile); void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds); diff --git a/engines/access/video.cpp b/engines/access/video.cpp index b7d5652e5b..63d0aa5c89 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -27,10 +27,21 @@ namespace Access { VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _vidSurface = nullptr; + _videoData = nullptr; + _startCoord = nullptr; + + _frameCount = 0; + _xCount = 0; + _scanCount = 0; + _frameSize = 0; _videoFrame = 0; _soundFlag = false; _soundFrame = 0; - _videoData = nullptr; + _videoEnd = false; + + _header._frameCount = 0; + _header._width = _header._height = 0; + _header._flags = VIDEOFLAG_NONE; } VideoPlayer::~VideoPlayer() { |