aboutsummaryrefslogtreecommitdiff
path: root/engines/access
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2015-07-22 22:37:40 +0200
committerWillem Jan Palenstijn2015-07-22 22:43:42 +0200
commit6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch)
tree503d50902bad2d800165593039d08d5ccf0c98ab /engines/access
parent5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff)
parent4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff)
downloadscummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz
scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2
scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip
Merge branch 'master' into mm
Conflicts: engines/access/access.cpp engines/access/asurface.h engines/access/bubble_box.cpp engines/access/bubble_box.h engines/access/martian/martian_game.cpp engines/access/player.cpp engines/access/player.h engines/access/resources.cpp engines/access/screen.cpp engines/access/screen.h engines/access/sound.cpp engines/access/sound.h
Diffstat (limited to 'engines/access')
-rw-r--r--engines/access/access.cpp20
-rw-r--r--engines/access/amazon/amazon_game.cpp21
-rw-r--r--engines/access/amazon/amazon_logic.cpp134
-rw-r--r--engines/access/amazon/amazon_logic.h2
-rw-r--r--engines/access/amazon/amazon_scripts.cpp32
-rw-r--r--engines/access/animation.cpp4
-rw-r--r--engines/access/animation.h1
-rw-r--r--engines/access/asurface.cpp20
-rw-r--r--engines/access/asurface.h12
-rw-r--r--engines/access/bubble_box.h1
-rw-r--r--engines/access/char.cpp4
-rw-r--r--engines/access/char.h3
-rw-r--r--engines/access/decompress.cpp49
-rw-r--r--engines/access/decompress.h3
-rw-r--r--engines/access/events.cpp2
-rw-r--r--engines/access/files.cpp4
-rw-r--r--engines/access/files.h2
-rw-r--r--engines/access/font.cpp2
-rw-r--r--engines/access/inventory.cpp1
-rw-r--r--engines/access/player.cpp9
-rw-r--r--engines/access/player.h1
-rw-r--r--engines/access/resources.cpp20
-rw-r--r--engines/access/room.cpp6
-rw-r--r--engines/access/room.h1
-rw-r--r--engines/access/screen.cpp15
-rw-r--r--engines/access/screen.h6
-rw-r--r--engines/access/scripts.cpp6
-rw-r--r--engines/access/sound.cpp152
-rw-r--r--engines/access/sound.h13
-rw-r--r--engines/access/video.cpp13
30 files changed, 349 insertions, 210 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 9749706c96..3fd5c0698c 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;
@@ -91,6 +92,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_vidX = _vidY = 0;
_cheatFl = false;
_restartFl = false;
+ _printEnd = 0;
+ for (int i = 0; i < 100; i++)
+ _objectsTable[i] = nullptr;
+ _clearSummaryFlag = false;
for (int i = 0; i < 60; i++)
TRAVEL[i] = 0;
@@ -252,12 +257,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;
@@ -286,9 +292,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/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index b469cf5597..9c39a9bd49 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);
}
@@ -532,8 +539,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);
@@ -562,7 +569,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,
@@ -593,14 +600,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;
@@ -680,7 +687,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 d24629a467..de53da51cd 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);
@@ -326,40 +326,27 @@ void Opening::doTitle() {
_vm->_buffer2.copyFrom(*_vm->_screen);
_vm->_buffer1.copyFrom(*_vm->_screen);
screen.forceFadeIn();
- _vm->_sound->playSound(1);
- // WORKAROUND: This delay has been added to replace original game delay that
- // came from loading resources, since nowadays it would be too fast to be visible
- // nowadays to be visible.
- _vm->_events->_vbCount = 70;
- while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0)
- _vm->_events->pollEventsAndWait();
- if (_vm->shouldQuit())
- return;
+ _vm->_sound->playSound(1, true);
Resource *spriteData = _vm->_files->loadFile(0, 2);
_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));
_vm->_buffer2.copyTo(_vm->_screen);
- _vm->_sound->playSound(1);
_vm->_events->_vbCount = 70;
while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) {
_vm->_events->pollEventsAndWait();
@@ -371,6 +358,7 @@ void Opening::doTitle() {
return;
_vm->_sound->stopSound();
+ _vm->_sound->checkSoundQueue(); // HACK: Clear sound 1 from the queue
_vm->_sound->playSound(0);
screen.forceFadeOut();
_vm->_events->_vbCount = 100;
@@ -385,11 +373,11 @@ 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;
+ _vm->_events->_vbCount = 950;
while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
_vm->_events->pollEventsAndWait();
}
@@ -493,55 +481,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 +1030,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 +1271,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 +1314,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 +1366,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 +1417,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 +1487,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 +1517,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 +1749,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 +1914,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 19777541e4..8c49424bc5 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -40,7 +40,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();
@@ -53,8 +53,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();
@@ -88,8 +88,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();
@@ -97,7 +97,7 @@ void AmazonScripts::mWhile1() {
_vm->_oldRects.clear();
_sequence = 2200;
- _vm->_sound->queueSound(0, 14, 15);
+ _vm->_sound->loadSoundTable(0, 14, 15);
do {
cLoop();
@@ -109,8 +109,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();
@@ -140,8 +140,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();
@@ -161,8 +161,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();
@@ -192,8 +192,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();
@@ -242,8 +242,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 1029c355da..526690807a 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -108,7 +108,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;
@@ -116,6 +116,7 @@ ASurface::ASurface() {
_orgX1 = _orgY1 = 0;
_orgX2 = _orgY2 = 0;
_lColor = 0;
+ _maxChars = 0;
}
ASurface::~ASurface() {
@@ -192,7 +193,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);
@@ -207,7 +208,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;
@@ -253,11 +254,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);
@@ -266,7 +268,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) {
@@ -278,14 +280,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 0c656a03a9..022e2534c1 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -100,20 +100,20 @@ public:
virtual void drawLine();
virtual void drawBox();
+
+ virtual void transBlitFrom(ASurface *src, const Common::Point &destPos);
- virtual void transCopyFrom(ASurface *src, const Common::Point &destPos);
+ virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds);
- virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds);
+ virtual void transBlitFrom(ASurface &src);
- virtual void transCopyFrom(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.h b/engines/access/bubble_box.h
index 35b7ca2cdb..6bf752d1a3 100644
--- a/engines/access/bubble_box.h
+++ b/engines/access/bubble_box.h
@@ -73,7 +73,6 @@ public:
int _btnX3;
Common::Rect _btnUpPos;
Common::Rect _btnDownPos;
-
Common::Array<Common::Rect> _bubbles;
public:
BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w, int h, int val1, int val2, int val3, int val4, Common::String title);
diff --git a/engines/access/char.cpp b/engines/access/char.cpp
index b3b026b6c9..aca7262952 100644
--- a/engines/access/char.cpp
+++ b/engines/access/char.cpp
@@ -124,8 +124,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 e64e90078c..f2828e9779 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..3de376c193 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];
@@ -45,7 +46,7 @@ void LzwDecompressor::decompress(byte *source, byte *dest) {
maxCodeValue = 512;
copyLength = 0;
- _bitPos = 0;
+ _sourceBitsLeft = 8;
while (1) {
@@ -96,17 +97,39 @@ uint16 LzwDecompressor::getCode() {
const byte bitMasks[9] = {
0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0x0FF
};
- uint16 bits, loCode, hiCode;
- loCode = (READ_LE_UINT16(_source) >> _bitPos) & 0xFF;
- _source++;
- bits = _codeLength - 8;
- hiCode = (READ_LE_UINT16(_source) >> _bitPos) & bitMasks[bits];
- _bitPos += bits;
- if (_bitPos > 8) {
- _source++;
- _bitPos -= 8;
+
+ byte resultBitsLeft = _codeLength;
+ byte resultBitsPos = 0;
+ uint16 result = 0;
+ byte currentByte = *_source;
+ byte currentBits = 0;
+
+ // Get bits of current byte
+ while (resultBitsLeft) {
+ if (resultBitsLeft < _sourceBitsLeft) {
+ // we need less than we have left
+ currentBits = (currentByte >> (8 - _sourceBitsLeft)) & bitMasks[resultBitsLeft];
+ result |= (currentBits << resultBitsPos);
+ _sourceBitsLeft -= resultBitsLeft;
+ resultBitsLeft = 0;
+
+ } else {
+ // we need as much as we have left or more
+ resultBitsLeft -= _sourceBitsLeft;
+ currentBits = currentByte >> (8 - _sourceBitsLeft);
+ result |= (currentBits << resultBitsPos);
+ resultBitsPos += _sourceBitsLeft;
+
+ // Go to next byte
+ _source++;
+
+ _sourceBitsLeft = 8;
+ if (resultBitsLeft) {
+ currentByte = *_source;
+ }
+ }
}
- return (hiCode << 8) | loCode;
+ return result;
}
uint32 decompressDBE(byte *source, byte **dest) {
diff --git a/engines/access/decompress.h b/engines/access/decompress.h
index eea450086b..bea9a1d3f8 100644
--- a/engines/access/decompress.h
+++ b/engines/access/decompress.h
@@ -32,7 +32,8 @@ public:
void decompress(byte *source, byte *dest);
private:
byte *_source;
- byte _codeLength, _bitPos;
+ byte _sourceBitsLeft;
+ byte _codeLength;
uint16 getCode();
};
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/files.cpp b/engines/access/files.cpp
index 42a7914638..4d734a67a9 100644
--- a/engines/access/files.cpp
+++ b/engines/access/files.cpp
@@ -40,6 +40,10 @@ void FileIdent::load(Common::SeekableReadStream &s) {
/*------------------------------------------------------------------------*/
+CellIdent:: CellIdent() {
+ _cell = 0;
+}
+
CellIdent::CellIdent(int cell, int fileNum, int subfile) {
_cell = cell;
_fileNum = fileNum;
diff --git a/engines/access/files.h b/engines/access/files.h
index 8b1aef0363..714ea44c75 100644
--- a/engines/access/files.h
+++ b/engines/access/files.h
@@ -46,7 +46,7 @@ struct FileIdent {
struct CellIdent : FileIdent {
byte _cell;
- CellIdent() {}
+ CellIdent();
CellIdent(int cell, int fileNum, int subfile);
};
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 48add68424..d14f116376 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -64,6 +64,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/player.cpp b/engines/access/player.cpp
index b4af672a7c..ead24025a2 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -49,7 +49,6 @@ Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() {
_playerSprites1 = nullptr;
_manPal1 = nullptr;
_frameNumber = 0;
- _monData = nullptr;
_rawTempL = 0;
_rawXTemp = 0;
_rawYTempL = 0;
@@ -74,6 +73,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;
_walkOffRight = _walkOffLeft = nullptr;
_walkOffUp = _walkOffDown = nullptr;
_walkOffUR = _walkOffDR = nullptr;
@@ -410,7 +415,7 @@ void Player::walkUpLeft() {
tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
_rawYTempL = (byte)tempL;
_rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset] -
- (tempL < 0 ? 1 : 0);;
+ (tempL < 0 ? 1 : 0);
if (_vm->_room->codeWalls()) {
plotCom2();
diff --git a/engines/access/player.h b/engines/access/player.h
index f3df2d027a..3c554556dd 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -79,7 +79,6 @@ public:
SpriteResource *_playerSprites;
// Fields in original Player structure
byte *_manPal1;
- byte *_monData;
int *_walkOffRight;
int *_walkOffLeft;
int *_walkOffUp;
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index b1cc64840b..8699a4a82f 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -46,17 +46,17 @@ const byte INITIAL_PALETTE[18 * 3] = {
0x00, 0x00, 0x00
};
-const char *const LOOK_MESSAGE = "LOOKING THERE REVEALS NOTHING OF INTEREST.";
-const char *const GET_MESSAGE = "YOU CAN'T TAKE THAT.";
-const char *const OPEN_MESSAGE = "THAT DOESN'T OPEN.";
-const char *const MOVE_MESSAGE = "THAT WON'T MOVE.";
-const char *const USE_MESSAGE = "THAT DOESN'T SEEM TO WORK.";
-const char *const GO_MESSAGE = "YOU CAN'T CLIMB THAT.";
-const char *const HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS";
-const char *const TALK_MESSAGE = "THERE SEEMS TO BE NO RESPONSE.";
const char *const GENERAL_MESSAGES[] = {
- LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE,
- GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE
+ "LOOKING THERE REVEALS NOTHING OF INTEREST.", // LOOK_MESSAGE
+ "THAT DOESN'T OPEN.", // OPEN_MESSAGE
+ "THAT WON'T MOVE." // MOVE_MESSAGE
+ "YOU CAN'T TAKE THAT.", // GET_MESSAGE
+ "THAT DOESN'T SEEM TO WORK.", // USE_MESSAGE
+ "YOU CAN'T CLIMB THAT.", // GO_MESSAGE
+ "THERE SEEMS TO BE NO RESPONSE.", // TALK_MESSAGE
+ "THIS OBJECT REQUIRES NO HINTS", // HELP_MESSAGE
+ "THIS OBJECT REQUIRES NO HINTS", // HELP_MESSAGE
+ "THAT DOESN'T SEEM TO WORK.", // USE_MESSAGE
};
const int INVCOORDS[][4] = {
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 6e0a4aa6db..46e8d2c8d8 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -477,9 +477,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 022d940fa0..12e7375428 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -128,7 +128,6 @@ public:
int _playFieldWidth;
int _playFieldHeight;
byte *_tile;
- int _tileSize;
int _selectCommand;
bool _conFlag;
int _rMouse[10][2];
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 5130d8ed5f..9392decead 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;
@@ -198,7 +199,7 @@ void Screen::forceFadeIn() {
for (int idx = 0; idx < PALETTE_SIZE; ++idx, ++srcP, ++destP) {
if (*destP != *srcP) {
repeatFlag = true;
- *destP = MAX((int)*destP + FADE_AMOUNT, (int)*srcP);
+ *destP = MIN((int)*destP + FADE_AMOUNT, (int)*srcP);
}
}
@@ -281,19 +282,19 @@ void Screen::drawBox() {
ASurface::drawBox();
}
-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 97ec59d1d1..52485e5c7c 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -94,11 +94,11 @@ public:
virtual void drawBox();
- 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 db9053039c..b20189049e 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);
@@ -162,7 +164,7 @@ void Scripts::charLoop() {
_sequence = 2000;
searchForSequence();
_vm->_images.clear();
- _vm->_buffer2.copyFrom(_vm->_buffer1);
+ _vm->_buffer2.blitFrom(_vm->_buffer1);
_vm->_newRects.clear();
executeScript();
@@ -993,7 +995,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 9ade99cb72..f2dc0fdf4c 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -21,18 +21,18 @@
*/
#include "common/algorithm.h"
+#include "common/config-manager.h"
#include "audio/mixer.h"
-#include "audio/audiostream.h"
#include "audio/decoders/raw.h"
#include "audio/decoders/wave.h"
+// Miles Audio
+#include "audio/miles.h"
#include "access/access.h"
#include "access/sound.h"
namespace Access {
SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
- _playingSound = false;
- _isVoice = false;
}
SoundManager::~SoundManager() {
@@ -44,11 +44,20 @@ void SoundManager::clearSounds() {
for (uint i = 0; i < _soundTable.size(); ++i)
delete _soundTable[i]._res;
+
_soundTable.clear();
+
+ if (_mixer->isSoundHandleActive(_effectsHandle))
+ _mixer->stopHandle(_effectsHandle);
+
+ 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) {
@@ -66,31 +75,26 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) {
return _vm->_files->loadFile(fileNum, subfile);
}
-void SoundManager::playSound(int soundIndex) {
- debugC(1, kDebugSound, "playSound(%d)", soundIndex);
+void SoundManager::playSound(int soundIndex, bool loop) {
+ debugC(1, kDebugSound, "playSound(%d, %d)", soundIndex, loop);
int priority = _soundTable[soundIndex]._priority;
- playSound(_soundTable[soundIndex]._res, priority);
+ playSound(_soundTable[soundIndex]._res, priority, loop);
}
-void SoundManager::playSound(Resource *res, int priority) {
+void SoundManager::playSound(Resource *res, int priority, bool loop) {
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))
- ;
+ Audio::RewindableAudioStream *audioStream;
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);
-
} else if (READ_BE_UINT32(resourceData) == MKTAG('S', 'T', 'E', 'V')) {
// sound files have a fixed header of 32 bytes in total
// header content:
@@ -130,22 +134,39 @@ void SoundManager::playSound(Resource *res, int priority) {
return;
}
- audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0);
-
+ audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0, DisposeAfterUse::NO);
} else
error("Unknown format");
- audioHandle = Audio::SoundHandle();
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &audioHandle,
- audioStream, -1, _mixer->kMaxChannelVolume, 0,
+ if (loop) {
+ _queue.push_back(new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::NO));
+ } else {
+ _queue.push_back(audioStream);
+ }
+
+ if (!_mixer->isSoundHandleActive(_effectsHandle))
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle,
+ _queue[0], -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);
- */
+void SoundManager::checkSoundQueue() {
+ debugC(5, kDebugSound, "checkSoundQueue");
+
+ if (_queue.empty() || _mixer->isSoundHandleActive(_effectsHandle))
+ return;
+
+ delete _queue[0];
+ _queue.remove_at(0);
+
+ if (_queue.size() && _queue[0])
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle,
+ _queue[0], -1, _mixer->kMaxChannelVolume, 0,
+ DisposeAfterUse::NO);
+}
+
+bool SoundManager::isSFXPlaying() {
+ return _mixer->isSoundHandleActive(_effectsHandle);
}
void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
@@ -162,7 +183,7 @@ void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
void SoundManager::stopSound() {
debugC(3, kDebugSound, "stopSound");
- _mixer->stopHandle(Audio::SoundHandle());
+ _mixer->stopHandle(_effectsHandle);
}
void SoundManager::freeSounds() {
@@ -178,19 +199,59 @@ MusicManager::MusicManager(AccessEngine *vm) : _vm(vm) {
_music = nullptr;
_tempMusic = nullptr;
_isLooping = false;
+ _driver = nullptr;
_byte1F781 = false;
+ MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MT32);
+ MusicType musicType = MidiDriver::getMusicType(dev);
+
+ // Amazon Guardians of Eden uses MIDPAK inside MIDIDRV.AP
+ // AdLib patches are inside MIDIDRV.AP too, 2nd resource file
+ //
+ // Amazon Guardians of Eden (demo) seems to use another type of driver, possibly written by Access themselves
+ // Martian Memorandum uses this other type of driver as well, which means it makes sense to reverse engineer it.
+ //
+ switch (musicType) {
+ case MT_ADLIB: {
+ Resource *midiDrvResource = _vm->_files->loadFile(92, 1);
+ Common::MemoryReadStream *adLibInstrumentStream = new Common::MemoryReadStream(midiDrvResource->data(), midiDrvResource->_size);
+
+ _driver = Audio::MidiDriver_Miles_AdLib_create("", "", adLibInstrumentStream);
+
+ delete midiDrvResource;
+ delete adLibInstrumentStream;
+ break;
+ }
+ case MT_MT32:
+ _driver = Audio::MidiDriver_Miles_MT32_create("");
+ _nativeMT32 = true;
+ break;
+ case MT_GM:
+ if (ConfMan.getBool("native_mt32")) {
+ _driver = Audio::MidiDriver_Miles_MT32_create("");
+ _nativeMT32 = true;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+#if 0
MidiPlayer::createDriver();
MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
+#endif
- int retValue = _driver->open();
- if (retValue == 0) {
- if (_nativeMT32)
- _driver->sendMT32Reset();
- else
- _driver->sendGMReset();
+ if (_driver) {
+ int retValue = _driver->open();
+ if (retValue == 0) {
+ if (_nativeMT32)
+ _driver->sendMT32Reset();
+ else
+ _driver->sendGMReset();
- _driver->setTimerCallback(this, &timerCallback);
+ _driver->setTimerCallback(this, &timerCallback);
+ }
}
}
@@ -200,16 +261,23 @@ MusicManager::~MusicManager() {
}
void MusicManager::send(uint32 b) {
+ // Pass data directly to driver
+ _driver->send(b);
+#if 0
if ((b & 0xF0) == 0xC0 && !_nativeMT32) {
b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8;
}
Audio::MidiPlayer::send(b);
+#endif
}
void MusicManager::midiPlay() {
debugC(1, kDebugSound, "midiPlay");
+ if (!_driver)
+ return;
+
if (_music->_size < 4) {
error("midiPlay() wrong music resource size");
}
@@ -218,12 +286,6 @@ void MusicManager::midiPlay() {
if (READ_BE_UINT32(_music->data()) != MKTAG('F', 'O', 'R', 'M')) {
warning("midiPlay() Unexpected signature");
- Common::DumpFile *outFile = new Common::DumpFile();
- Common::String outName = "music.dump";
- outFile->open(outName);
- outFile->write(_music->data(), _music->_size);
- outFile->finalize();
- outFile->close();
_isPlaying = false;
} else {
_parser = MidiParser::createParser_XMIDI();
@@ -253,6 +315,8 @@ bool MusicManager::checkMidiDone() {
void MusicManager::midiRepeat() {
debugC(1, kDebugSound, "midiRepeat");
+ if (!_driver)
+ return;
if (!_parser)
return;
@@ -265,6 +329,9 @@ void MusicManager::midiRepeat() {
void MusicManager::stopSong() {
debugC(1, kDebugSound, "stopSong");
+ if (!_driver)
+ return;
+
stop();
}
@@ -283,6 +350,9 @@ void MusicManager::loadMusic(FileIdent file) {
void MusicManager::newMusic(int musicId, int mode) {
debugC(1, kDebugSound, "newMusic(%d, %d)", musicId, mode);
+ if (!_driver)
+ return;
+
if (mode == 1) {
stopSong();
freeMusic();
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 6bfdbcda7d..e11a6b9730 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,24 @@ class SoundManager {
private:
AccessEngine *_vm;
Audio::Mixer *_mixer;
- Audio::SoundHandle _soundHandle;
+ Audio::SoundHandle _effectsHandle;
+ Common::Array<Audio::AudioStream *> _queue;
void clearSounds();
- void playSound(Resource *res, int priority);
+ void playSound(Resource *res, int priority, bool loop);
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 playSound(int soundIndex, bool loop = false);
+ 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 70d6ac62e8..5fc5f6762c 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() {