diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 10 | ||||
-rw-r--r-- | engines/access/files.cpp | 71 | ||||
-rw-r--r-- | engines/access/files.h | 35 | ||||
-rw-r--r-- | engines/access/screen.cpp | 17 | ||||
-rw-r--r-- | engines/access/screen.h | 12 | ||||
-rw-r--r-- | engines/access/sound.cpp | 17 | ||||
-rw-r--r-- | engines/access/sound.h | 10 |
7 files changed, 136 insertions, 36 deletions
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 53ddde9f68..3f8ae73faa 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -35,8 +35,14 @@ void AmazonEngine::doTitle() { _screen->forceFadeOut(); _events->hideCursor(); - _sound->loadSound(98, 30); - + _sound->_soundTable[0] = _sound->loadSound(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); } } // End of namespace Amazon diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 7da7574df2..549429b154 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -44,41 +44,72 @@ FileManager::~FileManager() { _file.close(); } -void FileManager::loadFile(int fileNum, int subfile) { +byte *FileManager::loadFile(int fileNum, int subfile) { setAppended(fileNum); gotoAppended(subfile); - handleFile(); + return handleFile(); } -void FileManager::loadFile(const Common::String &filename) { +byte *FileManager::loadFile(const Common::String &filename) { + // Open the file + openFile(filename); + + // Get a stream for the entire file + delete _stream; + _stream = _file.readStream(_file.size()); + + return handleFile(); +} + +void FileManager::openFile(const Common::String &filename) { // Open up the file _fileNumber = -1; _file.close(); if (_file.open(filename)) error("Could not open file - %s", filename.c_str()); +} - // Get a stream for the entire file +byte *FileManager::loadScreen(int fileNum, int subfile) { + setAppended(fileNum); + gotoAppended(subfile); + _vm->_screen->loadPalette(_stream); + + return handleFile(); +} + +byte *FileManager::loadScreen(const Common::String &filename) { + // Open the file + openFile(filename); + + // Get the palette + _vm->_screen->loadPalette(_stream); + + // Get a stream for the remainder of the file delete _stream; _stream = _file.readStream(_file.size()); - handleFile(); + return handleFile(); } -void FileManager::handleFile() { +byte *FileManager::handleFile() { char header[3]; _stream->read(&header[0], 3); - if (!strncmp(header, "BDE", 3)) + if (!strncmp(header, "DBE", 3)) // Decompress the resource - decompressFile(); - else - // Not compressed, so move back to start of data - _stream->seek(0); + return decompressFile(); + + // Not compressed, so pass out all of the file + _stream->seek(0); + byte *data = new byte[_stream->size()]; + _stream->read(data, _stream->size()); + + return data; } -void FileManager::decompressFile() { - // TODO +byte *FileManager::decompressFile() { + error("TODO: decompression"); } void FileManager::setAppended(int fileNum) { @@ -90,17 +121,17 @@ void FileManager::setAppended(int fileNum) { error("Could not open file %s", _filenames[fileNum]); // Read in the file index - _fileIndex.resize(50); - for (int i = 0; i < 50; ++i) { - _fileIndex[i]._offset = _file.readUint32LE(); - _fileIndex[i]._nextOffset = _file.readUint32LE(); - } + int count = _file.readUint16LE(); + assert(count <= 100); + _fileIndex.resize(count); + for (int i = 0; i < count; ++i) + _fileIndex[i] = _file.readUint32LE(); } } void FileManager::gotoAppended(int subfile) { - uint32 offset = _fileIndex[subfile]._offset; - uint32 size = _fileIndex[subfile]._nextOffset - offset; + uint32 offset = _fileIndex[subfile]; + uint32 size = _fileIndex[subfile + 1] - offset; _file.seek(offset); delete _stream; diff --git a/engines/access/files.h b/engines/access/files.h index fcd24808a3..42b439ce45 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -24,47 +24,60 @@ #define ACCESS_FILES_H #include "common/scummsys.h" +#include "common/array.h" #include "common/file.h" namespace Access { class AccessEngine; -struct FileEntry { - uint32 _offset; - uint32 _nextOffset; -}; - class FileManager { private: AccessEngine *_vm; const char * const *_filenames; - void handleFile(); + void openFile(const Common::String &filename); + + byte *handleFile(); - void decompressFile(); + byte *decompressFile(); public: int _fileNumber; Common::File _file; Common::SeekableReadStream *_stream; - Common::Array<FileEntry> _fileIndex; + Common::Array<uint32> _fileIndex; uint32 _entryOffset; uint32 _nextOffset; public: FileManager(AccessEngine *vm); ~FileManager(); - void loadFile(int fileNum, int subfile); + /** + * Load a given subfile from a container file + */ + byte *loadFile(int fileNum, int subfile); + + /** + * Load a given file by name + */ + byte *loadFile(const Common::String &filename); - void loadFile(const Common::String &filename); + /** + * Load a given scren from a container file + */ + byte *loadScreen(int fileNum, int subfile); + + /** + * Load a given screen by name + */ + byte *loadScreen(const Common::String &filename); /** * Open up a sub-file container file */ void setAppended(int fileNum); - /** * Open up a sub-file resource within an alrady opened container file. */ diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 3f8dc4ecda..4059cab070 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -32,6 +32,7 @@ namespace Access { Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + _loadPalFlag = false; } void Screen::setDisplayScan() { @@ -49,6 +50,16 @@ void Screen::setInitialPalettte() { g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18); } +void Screen::loadPalette(Common::SeekableReadStream *stream) { + stream->read(&_rawPalette[0], PALETTE_SIZE); + setPalette(); + _loadPalFlag = true; +} + +void Screen::setPalette() { + g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT); +} + void Screen::updatePalette() { g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT); updateScreen(); @@ -97,4 +108,10 @@ void Screen::forceFadeIn() { } while (repeatFlag); } +void Screen::copyBuffer(const byte *data) { + byte *destP = (byte *)getPixels(); + Common::copy(data, data + (h * w), destP); + g_system->copyRectToScreen(destP, w, 0, 0, w, h); +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index f8e0dab1b1..d16333c46e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "common/stream.h" #include "graphics/surface.h" namespace Access { @@ -40,8 +41,12 @@ private: byte _tempPalette[PALETTE_SIZE]; byte _rawPalette[PALETTE_SIZE]; + void setPalette(); + void updatePalette(); public: + bool _loadPalFlag; +public: Screen(AccessEngine *vm); void setDisplayScan(); @@ -65,6 +70,13 @@ public: * Set the initial palette */ void setInitialPalettte(); + + void loadPalette(Common::SeekableReadStream *stream); + + /** + * Copy a buffer to the screen + */ + void copyBuffer(const byte *data); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index d04d915cc9..baad6352b8 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -20,10 +20,25 @@ * */ +#include "common/algorithm.h" +#include "access/access.h" #include "access/sound.h" namespace Access { -SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {} +SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) { + Common::fill(&_soundTable[0], &_soundTable[MAX_SOUNDS], (byte *)nullptr); + Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); +} + +SoundManager::~SoundManager() { + for (int i = 0; i < MAX_SOUNDS; ++i) + delete _soundTable[i]; +} + +byte *SoundManager::loadSound(int fileNum, int subfile) { + return _vm->_files->loadFile(fileNum, subfile); +} + } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index e35e64795d..5d173e2e2b 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -23,6 +23,10 @@ #ifndef ACCESS_SOUND_H #define ACCESS_SOUND_H +#include "common/scummsys.h" + +#define MAX_SOUNDS 20 + namespace Access { class AccessEngine; @@ -31,11 +35,13 @@ class SoundManager { private: AccessEngine *_vm; public: - int _soundPriority; + byte *_soundTable[MAX_SOUNDS]; + int _soundPriority[MAX_SOUNDS]; public: SoundManager(AccessEngine *vm); + ~SoundManager(); - void loadSound(int fileNum, int subfile) {} + byte *loadSound(int fileNum, int subfile); }; } // End of namespace Access |