diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 23 | ||||
-rw-r--r-- | engines/access/access.h | 7 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 37 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.h | 2 | ||||
-rw-r--r-- | engines/access/files.cpp | 14 | ||||
-rw-r--r-- | engines/access/files.h | 4 | ||||
-rw-r--r-- | engines/access/screen.cpp | 59 | ||||
-rw-r--r-- | engines/access/screen.h | 8 | ||||
-rw-r--r-- | engines/access/sound.cpp | 29 | ||||
-rw-r--r-- | engines/access/sound.h | 19 |
10 files changed, 177 insertions, 25 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 25d9fcc99e..1470842e1b 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -37,6 +37,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _graphics = nullptr; _screen = nullptr; _sound = nullptr; + + _destIn = nullptr; + _objectsTable = nullptr; } AccessEngine::~AccessEngine() { @@ -46,6 +49,14 @@ AccessEngine::~AccessEngine() { delete _graphics; delete _screen; delete _sound; + + _buffer1.free(); + _buffer2.free(); + delete[] _objectsTable; +} + +void AccessEngine::setVGA() { + initGraphics(320, 200, false); } void AccessEngine::initialize() { @@ -59,13 +70,16 @@ void AccessEngine::initialize() { _files = new FileManager(this); _graphics = new GraphicsManager(this); _screen = new Screen(this); - _sound = new SoundManager(this); + _sound = new SoundManager(this, _mixer); + + _buffer1.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); + _buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); } Common::Error AccessEngine::run() { + setVGA(); initialize(); - setVGA(); _screen->setInitialPalettte(); _events->setCursor(CURSOR_0); _events->showCursor(); @@ -95,9 +109,4 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } -void AccessEngine::setVGA() { - initGraphics(320, 200, false); -} - - } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 3386cd9e11..05ef545e38 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -97,6 +97,13 @@ public: GraphicsManager *_graphics; Screen *_screen; SoundManager *_sound; + + byte *_destIn; + Graphics::Surface _buffer1; + Graphics::Surface _buffer2; + byte *_objectsTable; + int _pCount; + public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 3f8ae73faa..30733087dd 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -30,19 +30,46 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) AccessEngine(syst, gameDesc) { } +AmazonEngine::~AmazonEngine() { +} + + void AmazonEngine::doTitle() { _screen->setDisplayScan(); + _destIn = (byte *)_buffer2.getPixels(); + _screen->forceFadeOut(); _events->hideCursor(); - _sound->_soundTable[0] = _sound->loadSound(98, 30); + _sound->queueSound(0, 98, 30); _sound->_soundPriority[0] = 1; - _sound->_soundTable[1] = _sound->loadSound(98, 8); - _sound->_soundPriority[1] = 2; _screen->_loadPalFlag = false; - byte *scr = _files->loadScreen(0, 3); - _screen->copyBuffer(scr); + _files->loadScreen(0, 3); + + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _screen->forceFadeIn(); + _sound->playSound(1); + + _objectsTable = _files->loadFile(0, 2); + _sound->playSound(1); + + _screen->_loadPalFlag = false; + _files->loadScreen(0, 4); + _sound->playSound(1); + + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _sound->playSound(1); + + const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; + for (int _pCount = 0; _pCount < 3; ++_pCount) { + _buffer2.copyFrom(_buffer1); + int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); + int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); + _screen->plotImage(_objectsTable, id, Common::Point(xp, 71)); + } } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 30ec2c6519..33d7833670 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -35,7 +35,7 @@ protected: public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); - virtual ~AmazonEngine() {} + virtual ~AmazonEngine(); }; } // End of namespace Amazon diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 7b4a23d0e8..37b2578cea 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -72,15 +72,18 @@ void FileManager::openFile(const Common::String &filename) { _filesize = _file.size(); } -byte *FileManager::loadScreen(int fileNum, int subfile) { +void FileManager::loadScreen(int fileNum, int subfile) { setAppended(fileNum); gotoAppended(subfile); _vm->_screen->loadPalette(_stream); - return handleFile(); + // Get the data for the screen, and copy it over + byte *pSrc = handleFile(); + Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels()); + delete[] pSrc; } -byte *FileManager::loadScreen(const Common::String &filename) { +void FileManager::loadScreen(const Common::String &filename) { // Open the file openFile(filename); @@ -91,7 +94,10 @@ byte *FileManager::loadScreen(const Common::String &filename) { delete _stream; _stream = _file.readStream(_file.size() - _file.pos()); - return handleFile(); + // Get the data for the screen, and copy it over + byte *pSrc = handleFile(); + Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels()); + delete[] pSrc; } byte *FileManager::handleFile() { diff --git a/engines/access/files.h b/engines/access/files.h index 9224b29429..848ee0d2ca 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -63,12 +63,12 @@ public: /** * Load a given scren from a container file */ - byte *loadScreen(int fileNum, int subfile); + void loadScreen(int fileNum, int subfile); /** * Load a given screen by name */ - byte *loadScreen(const Common::String &filename); + void loadScreen(const Common::String &filename); /** * Open up a sub-file container file diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 4059cab070..cb0154d56e 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -21,6 +21,8 @@ */ #include "common/algorithm.h" +#include "common/endian.h" +#include "common/rect.h" #include "common/textconsole.h" #include "common/system.h" #include "graphics/palette.h" @@ -33,6 +35,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); _loadPalFlag = false; + _leftSkip = _rightSkip = 0; + _topSkip = _bottomSkip = 0; + _clipWidth = _clipHeight = 0; } void Screen::setDisplayScan() { @@ -114,4 +119,58 @@ void Screen::copyBuffer(const byte *data) { g_system->copyRectToScreen(destP, w, 0, 0, w, h); } +void Screen::plotImage(const byte *pData, int idx, const Common::Point &pt) { + const byte *sizeP = pData + READ_LE_UINT16(pData + idx * 4); + int w = READ_LE_UINT16(sizeP); + int h = READ_LE_UINT16(sizeP + 2); + Common::Rect r(pt.x, pt.y, pt.x + w, pt.y + h); + + if (!clip(r)) { + _lastBounds = r; + //plotf(); + } +} + +bool Screen::clip(Common::Rect &r) { + int skip; + _leftSkip = _rightSkip = 0; + _topSkip = _bottomSkip = 0; + + if (r.left > _clipWidth) { + skip = -r.left; + r.setWidth(r.width() - skip); + _leftSkip = skip; + r.moveTo(0, r.top); + } else if (r.left >= 0) + return true; + + int right = r.right - 1; + if (right < 0) + return true; + else if (right > _clipWidth) { + skip = right - _clipWidth; + r.setWidth(r.width() - skip); + _rightSkip = skip; + } + + if (r.top > _clipHeight) { + skip = -r.top; + r.setHeight(r.height() - skip); + _topSkip = skip; + r.moveTo(r.left, 0); + } else if (r.top >= 0) + return true; + + int bottom = r.bottom - 1; + if (bottom < 0) + return true; + else if (bottom > _clipHeight) { + skip = bottom - _clipHeight; + _bottomSkip = skip; + r.setHeight(r.height() - skip); + } + + return false; +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index d16333c46e..0d68c1bc7e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -40,10 +40,16 @@ private: AccessEngine *_vm; byte _tempPalette[PALETTE_SIZE]; byte _rawPalette[PALETTE_SIZE]; + Common::Rect _lastBounds; + int _leftSkip, _rightSkip; + int _topSkip, _bottomSkip; + int _clipWidth, _clipHeight; void setPalette(); void updatePalette(); + + bool clip(Common::Rect &r); public: bool _loadPalFlag; public: @@ -77,6 +83,8 @@ public: * Copy a buffer to the screen */ void copyBuffer(const byte *data); + + void plotImage(const byte *pData, int idx, const Common::Point &pt); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index baad6352b8..5375485695 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -21,24 +21,47 @@ */ #include "common/algorithm.h" +#include "audio/audiostream.h" #include "access/access.h" #include "access/sound.h" namespace Access { -SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) { - Common::fill(&_soundTable[0], &_soundTable[MAX_SOUNDS], (byte *)nullptr); +SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : + _vm(vm), _mixer(mixer) { Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); + for (int i = 0; i < MAX_SOUNDS; ++i) + _soundTable[i]._data = nullptr; } SoundManager::~SoundManager() { for (int i = 0; i < MAX_SOUNDS; ++i) - delete _soundTable[i]; + delete _soundTable[i]._data; +} + +void SoundManager::queueSound(int idx, int fileNum, int subfile) { + /* + _soundTable[idx]._data = _vm->_files->loadFile(fileNum, subfile); + _soundTable[idx]._size = _vm->_files->_filesize; + */ } byte *SoundManager::loadSound(int fileNum, int subfile) { return _vm->_files->loadFile(fileNum, subfile); } +void SoundManager::playSound(int soundIndex) { + int idx = _soundPriority[soundIndex - 1] - 1; + playSound(_soundTable[idx]._data, _soundTable[idx]._size); +} + +void SoundManager::playSound(byte *data, uint32 size) { + /* + 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); + */ +} } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index 5d173e2e2b..d3d5052c0e 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/mixer.h" #define MAX_SOUNDS 20 @@ -32,16 +33,28 @@ namespace Access { class AccessEngine; class SoundManager { + struct SoundEntry { + byte *_data; + uint32 _size; + }; private: AccessEngine *_vm; + Audio::Mixer *_mixer; + Audio::SoundHandle _soundHandle; + + byte *loadSound(int fileNum, int subfile); + + void playSound(byte *data, uint32 size); public: - byte *_soundTable[MAX_SOUNDS]; + SoundEntry _soundTable[MAX_SOUNDS]; int _soundPriority[MAX_SOUNDS]; public: - SoundManager(AccessEngine *vm); + SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); - byte *loadSound(int fileNum, int subfile); + void queueSound(int idx, int fileNum, int subfile); + + void playSound(int soundIndex); }; } // End of namespace Access |