diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 48 | ||||
-rw-r--r-- | engines/access/access.h | 26 | ||||
-rw-r--r-- | engines/access/amazon/amazon_room.cpp | 5 | ||||
-rw-r--r-- | engines/access/amazon/amazon_room.h | 2 | ||||
-rw-r--r-- | engines/access/asurface.h | 2 | ||||
-rw-r--r-- | engines/access/data.h | 8 | ||||
-rw-r--r-- | engines/access/room.cpp | 127 | ||||
-rw-r--r-- | engines/access/room.h | 35 | ||||
-rw-r--r-- | engines/access/screen.cpp | 9 | ||||
-rw-r--r-- | engines/access/screen.h | 4 | ||||
-rw-r--r-- | engines/access/sound.cpp | 15 | ||||
-rw-r--r-- | engines/access/sound.h | 9 |
12 files changed, 285 insertions, 5 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6b805e4069..98f5529863 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -70,6 +70,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _startup = 0; _currentCharFlag = false; _boxSelect = false; + _charFlag = 0; + _scaleH1 = _scaleH2 = 0; + _scaleN1 = 0; + _scaleT1 = 0; + _scaleMaxY = 0; + _scaleI = 0; + _playFieldHeight = 0; _roomNumber = 0; _rawPlayerXLow = 0; @@ -85,6 +92,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _timerFlag = false; Common::fill(&_flags[0], &_flags[99], 0); Common::fill(&_useItem[0], &_useItem[23], 0); + Common::fill(&_establishTable[0], &_establishTable[100], 0); + _establishFlag = false; + _establishMode = 0; + _establishGroup = 0; _guardLoc = 0; _guardFind = 0; _helpLevel = 0; @@ -192,6 +203,13 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } +void AccessEngine::loadCells(Common::Array<CellIdent> &cells) { + for (uint i = 0; i < cells.size(); ++i) { + _objectsTable[cells[i]._cell] = _files->loadFile( + cells[i]._fileNum, cells[i]._subfile); + } +} + void AccessEngine::clearCellTable() { Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr); } @@ -228,4 +246,34 @@ void AccessEngine::freeManData() { _man = nullptr; } +void AccessEngine::establish(int v) { + _establishMode = 0; + _establishGroup = 0; + doEstablish(v); +} + +void AccessEngine::establishCenter(int v) { + _establishMode = 1; + doEstablish(v); +} + +void AccessEngine::doEstablish(int v) { + _screen->forceFadeOut(); + _screen->clearScreen(); + _screen->setPanel(3); + + if (v != -1) { + _files->loadScreen(95, v); + _buffer2.copyBuffer(_screen); + } + + warning("TODO: doEstablish"); +} + +void AccessEngine::loadPlayField(int fileNum, int subfile) { + // TODO +} + + + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 2e605e49ab..1451e21296 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -80,6 +80,8 @@ private: void setVGA(); void dummyLoop(); + + void doEstablish(int v); protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; @@ -108,13 +110,18 @@ public: SoundManager *_sound; byte *_destIn; - Graphics::Surface _buffer1; - Graphics::Surface _buffer2; + ASurface _buffer1; + ASurface _buffer2; byte *_objectsTable[100]; + int _establishTable[100]; + bool _establishFlag; + int _establishMode; + int _establishGroup; int _numAnimTimers; Common::Array<TimerEntry> _timers; Common::Array<Common::Rect> _newRect; Common::Array<Common::Rect> _oldRect; + Common::Array<ExtraCell> _extraCells; int _pCount; int _selectCommand; bool _normalMouse; @@ -141,6 +148,13 @@ public: int _startTravelBox; bool _currentCharFlag; bool _boxSelect; + int _charFlag; + int _scaleH1, _scaleH2; + int _scaleN1; + int _scaleT1; + int _scaleMaxY; + int _scaleI; + int _playFieldHeight; // Fields that are included in savegames int _roomNumber; @@ -202,6 +216,8 @@ public: void freeAnimationData(); + void loadCells(Common::Array<CellIdent> &cells); + /** * Clear the cell table */ @@ -231,6 +247,12 @@ public: * Free animation data */ void freeManData(); + + void establish(int v); + + void establishCenter(int v); + + void loadPlayField(int fileNum, int subfile); }; } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index ce0683f124..21d9c6097e 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/amazon/amazon_resources.h" #include "access/amazon/amazon_room.h" namespace Access { @@ -32,6 +33,10 @@ AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) { _antOutFlag = false; } +void AmazonRoom::loadRoom(int roomNumber) { + loadRoomData(ROOM_TABLE[roomNumber]); +} + void AmazonRoom::reloadRoom() { loadRoom(_vm->_roomNumber); diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index 6d13a4e52c..006aef54f6 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -40,6 +40,8 @@ private: void roomMenu(); protected: + virtual void loadRoom(int roomNumber); + virtual void reloadRoom(); virtual void reloadRoom1(); diff --git a/engines/access/asurface.h b/engines/access/asurface.h index ecd04b9682..830a493977 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -31,6 +31,8 @@ namespace Access { class ASurface : public Graphics::Surface { public: void clearBuffer(); + + void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } }; } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 7e10e992d9..8b77e7c5b3 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -39,6 +39,14 @@ struct TimerEntry { } }; +class ExtraCell { +public: + int _vidTable; + int _vidTable1; + int _vidSTable; + int _vidSTable1; +}; + } // End of namespace Access #endif /* ACCESS_DATA_H */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f735fdb167..1e9eec79b0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -21,6 +21,7 @@ */ #include "common/scummsys.h" +#include "common/memstream.h" #include "access/access.h" #include "access/resources.h" #include "access/room.h" @@ -131,8 +132,77 @@ void Room::clearRoom() { _vm->freeManData(); } -void Room::loadRoom(int room) { - // TODO +void Room::loadRoomData(const byte *roomData) { + RoomInfo roomInfo(roomData); + + _roomFlag = roomInfo._roomFlag; + + _vm->_establishFlag = false; + if (roomInfo._estIndex != -1) { + _vm->_establishFlag = true; + if (_vm->_establishTable[roomInfo._estIndex] != 1) { + _vm->_establishTable[roomInfo._estIndex] = 1; + _vm->establish(0); + } + } + + _vm->_sound->freeMusic(); + if (roomInfo._musicFile._fileNum != -1) { + _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile._fileNum, + roomInfo._musicFile._subfile); + _vm->_sound->_midiSize = _vm->_files->_filesize; + _vm->_sound->midiPlay(); + _vm->_sound->_musicRepeat = true; + } + + _vm->_scaleH1 = roomInfo._scaleH1; + _vm->_scaleH2 = roomInfo._scaleH2; + _vm->_scaleN1 = roomInfo._scaleN1; + _vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1; + + if (roomInfo._playFieldFile._fileNum != -1) { + _vm->loadPlayField(roomInfo._playFieldFile._fileNum, + roomInfo._playFieldFile._subfile); + setupRoom(); + + _vm->_scaleMaxY = _vm->_playFieldHeight << 4; + } + + // Load cells + _vm->loadCells(roomInfo._cells); + + // Load script data + _vm->_scripts->freeScriptData(); + if (roomInfo._scriptFile._fileNum != -1) + _vm->_scripts->_script = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, + roomInfo._scriptFile._subfile); + + // Load animation data + _vm->freeAnimationData(); + if (roomInfo._animFile._fileNum != -1) + _vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, + roomInfo._animFile._subfile); + + _vm->_scaleI = roomInfo._scaleI; + _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold; + + _vm->_screen->_startColor = roomInfo._startColor; + _vm->_screen->_numColors = roomInfo._numColors; + _vm->_screen->loadPalette(roomInfo._paletteFile._fileNum, + roomInfo._paletteFile._subfile); + + // Load extra cells + _vm->_extraCells.clear(); + for (uint i = 0; i < roomInfo._vidTable.size(); ++i) { + ExtraCell ec; + ec._vidTable = roomInfo._vidTable[i] & 0xffff; + ec._vidTable1 = roomInfo._vidTable[i] >> 16; + + _vm->_extraCells.push_back(ec); + } + + // Load sounds for the scene + _vm->_sound->loadSounds(roomInfo._sounds); } void Room::roomLoop() { @@ -156,4 +226,57 @@ void Room::buildScreen() { // TODO } +/*------------------------------------------------------------------------*/ + +RoomInfo::RoomInfo(const byte *data) { + Common::MemoryReadStream stream(data, 999); + + _roomFlag = stream.readByte() != 0; + _estIndex = (int16)stream.readUint16LE(); + _musicFile._fileNum = (int16)stream.readUint16LE(); + _musicFile._subfile = stream.readUint16LE(); + _scaleH1 = stream.readByte(); + _scaleH2 = stream.readByte(); + _scaleN1 = stream.readByte(); + _playFieldFile._fileNum = (int16)stream.readUint16LE(); + _playFieldFile._subfile = stream.readUint16LE(); + + for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) { + CellIdent ci; + ci._cell = cell; + ci._fileNum = (int16)stream.readUint16LE(); + ci._subfile = stream.readUint16LE(); + + _cells.push_back(ci); + } + + _scriptFile._fileNum = (int16)stream.readUint16LE(); + _scriptFile._subfile = stream.readUint16LE(); + _animFile._fileNum = (int16)stream.readUint16LE(); + _animFile._subfile = stream.readUint16LE(); + _scaleI = stream.readByte(); + _scrollThreshold = stream.readByte(); + _paletteFile._fileNum = (int16)stream.readUint16LE(); + _paletteFile._subfile = stream.readUint16LE(); + _startColor = stream.readUint16LE(); + _numColors = stream.readUint16LE(); + + for (int16 v = (int16)stream.readUint16LE(); v != -1; + v = (int16)stream.readUint16LE()) { + uint16 v2 = stream.readUint16LE(); + + _vidTable.push_back(v | ((uint32)v2 << 16)); + } + + for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1; + fileNum = (int16)stream.readUint16LE()) { + FileIdent fi; + fi._fileNum = fileNum; + fi._subfile = stream.readUint16LE(); + + _sounds.push_back(fi); + } +}; + + } // End of namespace Access diff --git a/engines/access/room.h b/engines/access/room.h index 28506db7d6..1b803667af 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -35,10 +35,13 @@ private: protected: AccessEngine *_vm; + void loadRoomData(const byte *roomData); void setupRoom(); void setWallCodes(); void buildScreen(); + virtual void loadRoom(int roomNumber) = 0; + virtual void reloadRoom() = 0; virtual void reloadRoom1() = 0; @@ -56,8 +59,38 @@ public: * Clear all the data used by the room */ void clearRoom(); +}; + +struct FileIdent { + int _fileNum; + int _subfile; +}; - void loadRoom(int room); +struct CellIdent : FileIdent { + byte _cell; +}; + +class RoomInfo { +public: + bool _roomFlag; + int _estIndex; + FileIdent _musicFile; + int _scaleH1; + int _scaleH2; + int _scaleN1; + FileIdent _playFieldFile; + Common::Array<CellIdent> _cells; + FileIdent _scriptFile; + FileIdent _animFile; + int _scaleI; + int _scrollThreshold; + FileIdent _paletteFile; + int _startColor; + int _numColors; + Common::Array<uint32> _vidTable; + Common::Array<FileIdent> _sounds; +public: + RoomInfo(const byte *data); }; } // End of namespace Access diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 8dcc9f1db9..3823267bc0 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -26,6 +26,7 @@ #include "common/textconsole.h" #include "common/system.h" #include "graphics/palette.h" +#include "access/access.h" #include "access/screen.h" #include "access/resources.h" @@ -42,6 +43,8 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _topSkip = _bottomSkip = 0; _clipWidth = _clipHeight = 0; _scrollFlag = false; + _scrollThreshold = 0; + _startColor = _numColors = 0; } void Screen::setDisplayScan() { @@ -71,6 +74,12 @@ void Screen::loadPalette(Common::SeekableReadStream *stream) { _loadPalFlag = true; } +void Screen::loadPalette(int fileNum, int subfile) { + byte *palette = _vm->_files->loadFile(fileNum, subfile); + Common::copy(palette, palette + (_numColors * 3), &_rawPalette[_startColor * 3]); + delete[] palette; +} + void Screen::setPalette() { g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT); } diff --git a/engines/access/screen.h b/engines/access/screen.h index 1b03d261cf..57d773504f 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -56,6 +56,8 @@ private: public: bool _loadPalFlag; bool _scrollFlag; + int _scrollThreshold; + int _startColor, _numColors; public: Screen(AccessEngine *vm); @@ -89,6 +91,8 @@ public: void loadPalette(Common::SeekableReadStream *stream); + void loadPalette(int fileNum, int subfile); + void setPalette(); /** diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 2f64465f8f..7ac0e4d558 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -34,6 +34,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _soundTable[i]._data = nullptr; _music = nullptr; + _midiSize = 0; + _musicRepeat = false; } SoundManager::~SoundManager() { @@ -66,6 +68,14 @@ void SoundManager::playSound(byte *data, uint32 size) { */ } +void SoundManager::loadSounds(Common::Array<FileIdent> &sounds) { + // TODO +} + +void SoundManager::midiPlay() { + // TODO +} + void SoundManager::midiRepeat() { // TODO } @@ -78,4 +88,9 @@ void SoundManager::freeSounds() { // TODO } +void SoundManager::freeMusic() { + delete[] _music; + _music = nullptr; +} + } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index 37d263eecd..a127051b29 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -49,6 +49,9 @@ public: SoundEntry _soundTable[MAX_SOUNDS]; int _soundPriority[MAX_SOUNDS]; byte *_music; + int _midiSize; + bool _musicRepeat; + public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); @@ -57,11 +60,17 @@ public: void playSound(int soundIndex); + void loadSounds(Common::Array<FileIdent> &sounds); + + void midiPlay(); + void midiRepeat(); void stopSong(); void freeSounds(); + + void freeMusic(); }; } // End of namespace Access |