From 7aa2c7fe5cca8eaa9c68c471cef4595b99021206 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 12:09:27 -0400 Subject: ACCESS: Beginnings of character/converse manager --- engines/access/access.cpp | 9 ++++- engines/access/access.h | 7 +++- engines/access/char.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++ engines/access/char.h | 58 ++++++++++++++++++++++++++++++ engines/access/data.h | 14 ++++++++ engines/access/module.mk | 1 + engines/access/room.cpp | 38 ++++++++++---------- engines/access/room.h | 11 +----- engines/access/scripts.cpp | 19 ++++++++-- engines/access/scripts.h | 2 +- 10 files changed, 213 insertions(+), 35 deletions(-) create mode 100644 engines/access/char.cpp create mode 100644 engines/access/char.h (limited to 'engines') diff --git a/engines/access/access.cpp b/engines/access/access.cpp index ae03dfc7fa..c84ac8b28d 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -34,6 +34,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) { _animation = nullptr; _bubbleBox = nullptr; + _char = nullptr; _debugger = nullptr; _events = nullptr; _files = nullptr; @@ -106,6 +107,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) AccessEngine::~AccessEngine() { delete _animation; delete _bubbleBox; + delete _char; delete _debugger; delete _events; delete _files; @@ -147,6 +149,7 @@ void AccessEngine::initialize() { ASurface::init(); _animation = new AnimationManager(this); _bubbleBox = new BubbleBox(this); + _char = new CharManager(this); _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); @@ -197,7 +200,7 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } -void AccessEngine::loadCells(Common::Array &cells) { +void AccessEngine::loadCells(Common::Array &cells) { for (uint i = 0; i < cells.size(); ++i) { byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile); _objectsTable[cells[i]._cell] = new SpriteResource(this, @@ -371,4 +374,8 @@ void AccessEngine::freeChar() { _animation->freeAnimationData(); } +void AccessEngine::loadChar(int charId) { + +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 2185916c5a..974277280c 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -32,6 +32,7 @@ #include "graphics/surface.h" #include "access/animation.h" #include "access/bubble_box.h" +#include "access/char.h" #include "access/data.h" #include "access/debugger.h" #include "access/events.h" @@ -108,6 +109,7 @@ protected: public: AnimationManager *_animation; BubbleBox *_bubbleBox; + CharManager *_char; Debugger *_debugger; EventsManager *_events; FileManager *_files; @@ -122,6 +124,7 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; + Common::Array _charTable; SpriteResource *_objectsTable[100]; int _establishTable[100]; bool _establishFlag; @@ -204,7 +207,7 @@ public: int getRandomNumber(int maxNumber); - void loadCells(Common::Array &cells); + void loadCells(Common::Array &cells); /** * Free the sprites list @@ -236,6 +239,8 @@ public: void doLoadSave(); void freeChar(); + + void loadChar(int charId); }; } // End of namespace Access diff --git a/engines/access/char.cpp b/engines/access/char.cpp new file mode 100644 index 0000000000..a01643b651 --- /dev/null +++ b/engines/access/char.cpp @@ -0,0 +1,89 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/memstream.h" +#include "access/access.h" +#include "access/char.h" +#include "access/amazon/amazon_resources.h" + +namespace Access { + +CharEntry::CharEntry(const byte *data) { + Common::MemoryReadStream s(data, 999); + + _charFlag = s.readByte(); + _estabFlag = s.readSint16LE(); + _screenFile._fileNum = s.readSint16LE(); + _screenFile._subfile = s.readSint16LE(); + + _paletteFile._fileNum = s.readSint16LE(); + _paletteFile._subfile = s.readUint16LE(); + _startColor = s.readUint16LE(); + _numColors = s.readUint16LE(); + + // Load cells + for (byte cell = s.readByte(); cell != 0xff; cell = s.readByte()) { + CellIdent ci; + ci._cell = cell; + ci._fileNum = s.readSint16LE(); + ci._subfile = s.readUint16LE(); + + _cells.push_back(ci); + } + + _animFile._fileNum = s.readSint16LE(); + _animFile._subfile = s.readUint16LE(); + _scriptFile._fileNum = s.readSint16LE(); + _scriptFile._subfile = s.readUint16LE(); + + for (int16 v = s.readSint16LE(); v != -1; v = s.readSint16LE()) { + ExtraCell ec; + ec._vidTable = v; + ec._vidTable1 = s.readSint16LE(); + ec._vidSTable = s.readSint16LE(); + ec._vidSTable1 = s.readSint16LE(); + + _extraCells.push_back(ec); + } +} + +CharEntry::CharEntry() { + _charFlag = 0; + _estabFlag = 0; + _startColor = _numColors = 0; +} + +/*------------------------------------------------------------------------*/ + +CharManager::CharManager(AccessEngine *vm) : Manager(vm) { + switch (vm->getGameID()) { + case GType_Amazon: + // Setup character list + for (int i = 0; i < 37; ++i) + _charTable.push_back(CharEntry(Amazon::CHARTBL[i])); + break; + default: + error("Unknown game"); + } +} + +} // End of namespace Access diff --git a/engines/access/char.h b/engines/access/char.h new file mode 100644 index 0000000000..8d6c49d47a --- /dev/null +++ b/engines/access/char.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ACCESS_CHAR_H +#define ACCESS_CHAR_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "access/data.h" + +namespace Access { + +class CharEntry { +public: + int _charFlag; + int _estabFlag; + FileIdent _screenFile; + FileIdent _paletteFile; + int _startColor, _numColors; + Common::Array _cells; + FileIdent _animFile; + FileIdent _scriptFile; + Common::Array _extraCells; +public: + CharEntry(const byte *data); + + CharEntry(); +}; + +class CharManager: public Manager { +public: + Common::Array _charTable; +public: + CharManager(AccessEngine *vm); +}; + +} // End of namespace Access + +#endif /* ACCESS_CHAR_H */ diff --git a/engines/access/data.h b/engines/access/data.h index 1601c689bf..c10b2b7f17 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -40,6 +40,20 @@ public: Manager(AccessEngine *vm) : _vm(vm) {} }; +struct FileIdent { + int _fileNum; + int _subfile; + + FileIdent() { + _fileNum = -1; + _subfile = 0; + } +}; + +struct CellIdent : FileIdent { + byte _cell; +}; + struct TimerEntry { int _initTm; int _timer; diff --git a/engines/access/module.mk b/engines/access/module.mk index 46f96693fa..31f0760491 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ asurface.o \ access.o \ bubble_box.o \ + char.o \ data.o \ debugger.o \ decompress.o \ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b5f8554612..d703114090 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -227,13 +227,8 @@ void Room::loadRoomData(const byte *roomData) { // 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); - } + for (uint i = 0; i < roomInfo._extraCells.size(); ++i) + _vm->_extraCells.push_back(roomInfo._extraCells[i]); // Load sounds for the scene _vm->_sound->loadSounds(roomInfo._sounds); @@ -726,34 +721,34 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { _roomFlag = stream.readByte(); if (gameType != GType_MartianMemorandum) - _estIndex = (int16)stream.readUint16LE(); + _estIndex = stream.readSint16LE(); else _estIndex = -1; - _musicFile._fileNum = (int16)stream.readUint16LE(); + _musicFile._fileNum = stream.readSint16LE(); _musicFile._subfile = stream.readUint16LE(); _scaleH1 = stream.readByte(); _scaleH2 = stream.readByte(); _scaleN1 = stream.readByte(); - _playFieldFile._fileNum = (int16)stream.readUint16LE(); + _playFieldFile._fileNum = stream.readSint16LE(); _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._fileNum = stream.readSint16LE(); ci._subfile = stream.readUint16LE(); _cells.push_back(ci); } - _scriptFile._fileNum = (int16)stream.readUint16LE(); + _scriptFile._fileNum = stream.readSint16LE(); _scriptFile._subfile = stream.readUint16LE(); - _animFile._fileNum = (int16)stream.readUint16LE(); + _animFile._fileNum = stream.readSint16LE(); _animFile._subfile = stream.readUint16LE(); _scaleI = stream.readByte(); _scrollThreshold = stream.readByte(); - _paletteFile._fileNum = (int16)stream.readUint16LE(); + _paletteFile._fileNum = stream.readSint16LE(); _paletteFile._subfile = stream.readUint16LE(); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; @@ -762,15 +757,18 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { _numColors = stream.readUint16LE(); } - for (int16 v = (int16)stream.readUint16LE(); v != -1; - v = (int16)stream.readUint16LE()) { - uint16 v2 = stream.readUint16LE(); + for (int16 v = stream.readSint16LE(); v != -1; v = stream.readSint16LE()) { + ExtraCell ec; + ec._vidTable = v; + ec._vidTable1 = stream.readSint16LE(); + ec._vidSTable = stream.readSint16LE(); + ec._vidSTable1 = stream.readSint16LE(); - _vidTable.push_back(v | ((uint32)v2 << 16)); + _extraCells.push_back(ec); } - for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1; - fileNum = (int16)stream.readUint16LE()) { + for (int16 fileNum = stream.readSint16LE(); fileNum != -1; + fileNum = stream.readSint16LE()) { SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); diff --git a/engines/access/room.h b/engines/access/room.h index e1a26a4e4e..40290956cd 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -156,15 +156,6 @@ public: class RoomInfo { public: - struct FileIdent { - int _fileNum; - int _subfile; - }; - - struct CellIdent : FileIdent { - byte _cell; - }; - struct SoundIdent : FileIdent { int _priority; }; @@ -184,7 +175,7 @@ public: FileIdent _paletteFile; int _startColor; int _numColors; - Common::Array _vidTable; + Common::Array _extraCells; Common::Array _sounds; public: RoomInfo(const byte *data, int gameType); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index f6879584f3..f4934d45a3 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -99,7 +99,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, - &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::CMDCONVERSE, + &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, @@ -309,7 +309,22 @@ void Scripts::cmdNewRoom() { cmdRetPos(); } -void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); } +void Scripts::cmdConverse() { + _vm->_conversation = _data->readUint16LE(); + _vm->_room->clearRoom(); + _vm->freeChar(); + _vm->loadChar(_vm->_conversation); + _vm->_events->setCursor(CURSOR_ARROW); + + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 0; + searchForSequence(); + + if (_vm->_screen->_vesaMode) { + _vm->_converseMode = 1; + } +} void Scripts::cmdCheckFrame() { int id = _data->readUint16LE(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 4b224c32bd..ae4c7559e0 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -79,7 +79,7 @@ protected: void cmdCheckInventory(); void cmdSetTex(); void cmdNewRoom(); - void CMDCONVERSE(); + void cmdConverse(); void cmdCheckFrame(); void cmdCheckAnim(); void cmdSnd(); -- cgit v1.2.3