From 7d605ce57316c86a247cf978e6b123b23045659c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Aug 2014 22:17:30 -0400 Subject: ACCESS: Implement outer room handler --- engines/access/room.cpp | 130 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 engines/access/room.cpp (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp new file mode 100644 index 0000000000..25d3584ede --- /dev/null +++ b/engines/access/room.cpp @@ -0,0 +1,130 @@ +/* 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/scummsys.h" +#include "access/access.h" +#include "access/room.h" + +namespace Access { + +Room::Room(AccessEngine *vm) : _vm(vm) { + _function = 0; +} + +void Room::doRoom() { + bool reloadFlag = false; + + while (!_vm->shouldQuit()) { + if (!reloadFlag) { + _vm->_numImages = 0; + _vm->_newRect.clear(); + _vm->_oldRect.clear(); + _vm->_nextImage = 0; + _vm->_numAnimTimers = 0; + } + + reloadFlag = false; + _vm->_startup = 0; + _function = 0; + + while (!_vm->shouldQuit()) { + _vm->_numImages = 0; + if (_vm->_startup != -1 && --_vm->_startup != 0) { + --_vm->_startup; + _vm->_events->showCursor(); + _vm->_screen->fadeIn(); + } + + _vm->_events->pollEvents(); + _vm->_nextImage = 0; + _vm->_player->walk(); + _vm->_sound->midiRepeat(); + _vm->_screen->checkScroll(); + doCommands(); + + // DOROOMFLASHBACK jump point + if (_function == 1) { + clearRoom(); + break; + } else if (_function == 2) { + clearRoom(); + return; + } else if (_function == 3) { + reloadRoom1(); + reloadFlag = true; + break; + } else if (_function == 4) { + break; + } + + if (_vm->_screen->_scrollFlag) { + _vm->_screen->copyBF1BF2(); + _vm->_newRect.clear(); + _function = 0; + roomLoop(); + + if (_function == 1) { + clearRoom(); + break; + } else { + _vm->_screen->plotList(); + _vm->_screen->copyRects(); + + _vm->_screen->copyBF2Vid(); + } + } else { + _vm->_screen->copyBF1BF2(); + _vm->_newRect.clear(); + _function = 0; + roomLoop(); + + if (_function == 1) { + clearRoom(); + break; + } else { + _vm->_screen->plotList(); + _vm->_screen->copyBlocks(); + } + } + } + } +} + +void Room::clearRoom() { + // TODO +} + +void Room::reloadRoom1() { + // TODO +} + +void Room::roomLoop() { + // TODO +} + + +void Room::doCommands() { + +} + + +} // End of namespace Access -- cgit v1.2.3 From 8e43a6c5280e2b695753d4a0b6810811f1bd393f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Aug 2014 23:23:49 -0400 Subject: ACCESS: Add scripts classes and Amazon room setup --- engines/access/room.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 25d3584ede..c3a3a9f8e2 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -28,6 +28,7 @@ namespace Access { Room::Room(AccessEngine *vm) : _vm(vm) { _function = 0; + _roomFlag = 0; } void Room::doRoom() { @@ -40,6 +41,8 @@ void Room::doRoom() { _vm->_oldRect.clear(); _vm->_nextImage = 0; _vm->_numAnimTimers = 0; + + reloadRoom(); } reloadFlag = false; @@ -113,18 +116,63 @@ void Room::clearRoom() { // TODO } +void Room::reloadRoom() { + loadRoom(_vm->_roomNumber); + + if (_roomFlag != 1) { + _vm->_currentMan = _roomFlag; + _vm->_currentManOld = _roomFlag; + _vm->_manScaleOff = 0; + + switch (_vm->_currentMan) { + case 0: + _vm->_man1 = _vm->_files->loadFile("MAN.LZ"); + break; + + case 2: + _vm->_man1 = _vm->_files->loadFile("JMAN.LZ"); + break; + + case 3: + _vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ"); + _vm->_manScaleOff = 1; + break; + + default: + break; + } + } + + reloadRoom1(); +} + void Room::reloadRoom1() { // TODO } +void Room::loadRoom(int room) { + // TODO +} + void Room::roomLoop() { // TODO } void Room::doCommands() { + // TODO +} + +void Room::setupRoom() { + // TODO +} +void Room::setWallCodes() { + // TODO } +void Room::buildScreen() { + // TODO +} } // End of namespace Access -- cgit v1.2.3 From c4d6dc376382de9b2d91d93ac9061f600b6a8696 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Aug 2014 08:28:20 -0400 Subject: ACCESS: Added room clearing --- engines/access/room.cpp | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c3a3a9f8e2..0515b50ab2 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -113,41 +113,21 @@ void Room::doRoom() { } void Room::clearRoom() { - // TODO -} - -void Room::reloadRoom() { - loadRoom(_vm->_roomNumber); - - if (_roomFlag != 1) { - _vm->_currentMan = _roomFlag; - _vm->_currentManOld = _roomFlag; - _vm->_manScaleOff = 0; - - switch (_vm->_currentMan) { - case 0: - _vm->_man1 = _vm->_files->loadFile("MAN.LZ"); - break; - - case 2: - _vm->_man1 = _vm->_files->loadFile("JMAN.LZ"); - break; - - case 3: - _vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ"); - _vm->_manScaleOff = 1; - break; - - default: - break; - } + if (_vm->_sound->_music) { + _vm->_sound->stopSong(); + delete[] _vm->_sound->_music; + _vm->_sound->_music = nullptr; } - reloadRoom1(); -} + _vm->_sound->freeSounds(); + _vm->_numAnimTimers = 0; -void Room::reloadRoom1() { - // TODO + _vm->freeAnimationData(); + _vm->_scripts->freeScriptData(); + _vm->freeCells(); + _vm->freePlayField(); + _vm->freeInactiveData(); + _vm->freeManData(); } void Room::loadRoom(int room) { -- cgit v1.2.3 From 3bd0f0f3394e87ee3e18c1bfda80a99ccc31c61c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Aug 2014 08:55:56 -0400 Subject: ACCESS: Split resources into a seperate file just for Amazon resources --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0515b50ab2..f735fdb167 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/resources.h" #include "access/room.h" namespace Access { -- cgit v1.2.3 From 031cc32c847bf7387859e273069f8efd3b6d4ed0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Aug 2014 22:43:40 -0400 Subject: ACCESS: Implemented room data loading --- engines/access/room.cpp | 127 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') 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 -- cgit v1.2.3 From bea93f3441154197a8f599912a1102ac11688d7f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 09:23:31 -0400 Subject: ACCESS: Implemented setupRoom method --- engines/access/room.cpp | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 1e9eec79b0..9ead04b2ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -206,7 +206,9 @@ void Room::loadRoomData(const byte *roomData) { } void Room::roomLoop() { - // TODO + _vm->_scripts->_sequence = 2000; + _vm->_scripts->searchForSeq(); + _vm->_scripts->executeCommand(); } @@ -215,7 +217,44 @@ void Room::doCommands() { } void Room::setupRoom() { - // TODO + _vm->_screen->setScaleTable(_vm->_scale); + _vm->_screen->setBufferScan(); + + if (_roomFlag != 2) + setIconPalette(); + + if (_vm->_screen->_vWindowSize.x == _vm->_playFieldSize.x) { + _vm->_screen->_scrollX = 0; + _vm->_screen->_scrollCol = 0; + } else { + _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - + (_vm->_player->_rawPlayer.x >> 4); + int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - + (_vm->_screen->_vWindowSize.x / 2), 0); + _vm->_screen->_scrollCol = xp; + + xp = xp + _vm->_screen->_vWindowSize.x - _vm->_playFieldSize.x; + if (xp >= 0) { + _vm->_screen->_scrollCol = xp + 1; + } + } + + if (_vm->_screen->_vWindowSize.y == _vm->_playFieldSize.y) { + _vm->_screen->_scrollY = 0; + _vm->_screen->_scrollRow = 0; + } + else { + _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - + (_vm->_player->_rawPlayer.y >> 4); + int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - + (_vm->_screen->_vWindowSize.y / 2), 0); + _vm->_screen->_scrollRow = yp; + + yp = yp + _vm->_screen->_vWindowSize.y - _vm->_playFieldSize.y; + if (yp >= 0) { + _vm->_screen->_scrollRow = yp + 1; + } + } } void Room::setWallCodes() { -- cgit v1.2.3 From 0183007d0b4f3b951ef2c704894655e894ce4a71 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 20:31:42 -0400 Subject: ACCESS: Fixes for loading room data --- engines/access/room.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9ead04b2ac..afa42c82f0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -186,10 +186,13 @@ void Room::loadRoomData(const byte *roomData) { _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); + // Handle loading scene palette data + if (roomInfo._paletteFile._fileNum != -1) { + _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(); @@ -270,7 +273,7 @@ void Room::buildScreen() { RoomInfo::RoomInfo(const byte *data) { Common::MemoryReadStream stream(data, 999); - _roomFlag = stream.readByte() != 0; + _roomFlag = stream.readByte(); _estIndex = (int16)stream.readUint16LE(); _musicFile._fileNum = (int16)stream.readUint16LE(); _musicFile._subfile = stream.readUint16LE(); @@ -297,8 +300,12 @@ RoomInfo::RoomInfo(const byte *data) { _scrollThreshold = stream.readByte(); _paletteFile._fileNum = (int16)stream.readUint16LE(); _paletteFile._subfile = stream.readUint16LE(); - _startColor = stream.readUint16LE(); - _numColors = stream.readUint16LE(); + if (_paletteFile._fileNum == -1) { + _startColor = _numColors = 0; + } else { + _startColor = stream.readUint16LE(); + _numColors = stream.readUint16LE(); + } for (int16 v = (int16)stream.readUint16LE(); v != -1; v = (int16)stream.readUint16LE()) { @@ -309,9 +316,10 @@ RoomInfo::RoomInfo(const byte *data) { for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1; fileNum = (int16)stream.readUint16LE()) { - FileIdent fi; + SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); + fi._priority = stream.readUint16LE(); _sounds.push_back(fi); } -- cgit v1.2.3 From 0c38730f3fd4965fbf1b854f76ff936dddf9f931 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 21:54:22 -0400 Subject: ACCESS: Implement buildScreen --- engines/access/room.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index afa42c82f0..7a07f58bcb 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -26,9 +26,12 @@ #include "access/resources.h" #include "access/room.h" +#define TILE_WIDTH 16 +#define TILE_HEIGHT 16 + namespace Access { -Room::Room(AccessEngine *vm) : _vm(vm) { +Room::Room(AccessEngine *vm) : Manager(vm) { _function = 0; _roomFlag = 0; } @@ -261,11 +264,40 @@ void Room::setupRoom() { } void Room::setWallCodes() { - // TODO + _jetFrame.clear(); + _jetFrame.resize(_plotter._walls.size()); + + _vm->_player->_rawXTemp = _vm->_player->_rawPlayer.x; + _vm->_player->_rawYTemp = _vm->_player->_rawPlayer.y; } void Room::buildScreen() { - // TODO + int scrollCol = _vm->_screen->_scrollCol; + int cnt = _vm->_screen->_vWindowSize.x + 1; + int offset = 0; + + for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) { + buildColumn(_vm->_screen->_scrollCol, offset); + ++_vm->_screen->_scrollCol; + } + + _vm->_screen->_scrollCol = scrollCol; + _vm->_screen->copyBF1BF2(); +} + +void Room::buildColumn(int playX, int screenX) { + const byte *pSrc = _vm->_playField + _vm->_screen->_scrollRow * + _vm->_playFieldSize.x + playX; + byte *pDest = (byte *)_vm->_buffer1.getPixels(); + + for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) { + byte *pTile = _vm->_tile + (*pSrc << 8); + + for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { + Common::copy(pTile, pTile + TILE_WIDTH, pDest); + pDest += _vm->_screen->_vWindowSize.x; + } + } } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From 6715bb0864212edaf88076dce88e5df1138333da Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 21:59:45 -0400 Subject: ACCESS: Move playField and tile data to Room class --- engines/access/room.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 7a07f58bcb..136d6027e6 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -34,6 +34,23 @@ namespace Access { Room::Room(AccessEngine *vm) : Manager(vm) { _function = 0; _roomFlag = 0; + _playField = nullptr; + _tile = nullptr; +} + +Room::~Room() { + delete[] _playField; + delete[] _tile; +} + +void Room::freePlayField() { + delete[] _playField; + _playField = nullptr; +} + +void Room::freeTileData() { + delete[] _tile; + _tile = nullptr; } void Room::doRoom() { @@ -130,7 +147,7 @@ void Room::clearRoom() { _vm->freeAnimationData(); _vm->_scripts->freeScriptData(); _vm->freeCells(); - _vm->freePlayField(); + freePlayField(); _vm->freeInactiveData(); _vm->freeManData(); } @@ -229,7 +246,7 @@ void Room::setupRoom() { if (_roomFlag != 2) setIconPalette(); - if (_vm->_screen->_vWindowSize.x == _vm->_playFieldSize.x) { + if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { @@ -239,13 +256,13 @@ void Room::setupRoom() { (_vm->_screen->_vWindowSize.x / 2), 0); _vm->_screen->_scrollCol = xp; - xp = xp + _vm->_screen->_vWindowSize.x - _vm->_playFieldSize.x; + xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x; if (xp >= 0) { _vm->_screen->_scrollCol = xp + 1; } } - if (_vm->_screen->_vWindowSize.y == _vm->_playFieldSize.y) { + if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) { _vm->_screen->_scrollY = 0; _vm->_screen->_scrollRow = 0; } @@ -256,7 +273,7 @@ void Room::setupRoom() { (_vm->_screen->_vWindowSize.y / 2), 0); _vm->_screen->_scrollRow = yp; - yp = yp + _vm->_screen->_vWindowSize.y - _vm->_playFieldSize.y; + yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y; if (yp >= 0) { _vm->_screen->_scrollRow = yp + 1; } @@ -286,12 +303,12 @@ void Room::buildScreen() { } void Room::buildColumn(int playX, int screenX) { - const byte *pSrc = _vm->_playField + _vm->_screen->_scrollRow * - _vm->_playFieldSize.x + playX; + const byte *pSrc = _playField + _vm->_screen->_scrollRow * + _playFieldSize.x + playX; byte *pDest = (byte *)_vm->_buffer1.getPixels(); for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) { - byte *pTile = _vm->_tile + (*pSrc << 8); + byte *pTile = _tile + (*pSrc << 8); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); -- cgit v1.2.3 From 52721cf2cb666affa7ae7ab952987d51c35fe0e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 22:04:01 -0400 Subject: ACCESS: General cleanup of Room class --- engines/access/room.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 136d6027e6..de9a41c2d3 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -234,11 +234,6 @@ void Room::roomLoop() { _vm->_scripts->executeCommand(); } - -void Room::doCommands() { - // TODO -} - void Room::setupRoom() { _vm->_screen->setScaleTable(_vm->_scale); _vm->_screen->setBufferScan(); @@ -374,5 +369,4 @@ RoomInfo::RoomInfo(const byte *data) { } }; - } // End of namespace Access -- cgit v1.2.3 From 745aa3daf9934846e183d5c5034d1ec8801fa5bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 22:53:02 -0400 Subject: ACCESS: Implemented skeleton script command method list --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index de9a41c2d3..e3e3700b51 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -230,7 +230,7 @@ void Room::loadRoomData(const byte *roomData) { void Room::roomLoop() { _vm->_scripts->_sequence = 2000; - _vm->_scripts->searchForSeq(); + _vm->_scripts->searchForSequence(); _vm->_scripts->executeCommand(); } -- cgit v1.2.3 From 80c8fbe024230aaba63d93f9a2ff1c1bf25ae922 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Aug 2014 09:19:38 -0400 Subject: ACCESS: Simplify command list array to use a virtual method --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e3e3700b51..80ab3329ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -231,7 +231,7 @@ void Room::loadRoomData(const byte *roomData) { void Room::roomLoop() { _vm->_scripts->_sequence = 2000; _vm->_scripts->searchForSequence(); - _vm->_scripts->executeCommand(); + _vm->_scripts->executeScript(); } void Room::setupRoom() { -- cgit v1.2.3 From 1171400ccb65025a77f04dae3a224a3aec5920a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 15:54:35 -0400 Subject: ACCESS: Beginnings of animation manager --- engines/access/room.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 80ab3329ac..fb70e35ee0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -144,7 +144,7 @@ void Room::clearRoom() { _vm->_sound->freeSounds(); _vm->_numAnimTimers = 0; - _vm->freeAnimationData(); + _vm->_animation->freeAnimationData(); _vm->_scripts->freeScriptData(); _vm->freeCells(); freePlayField(); @@ -198,9 +198,9 @@ void Room::loadRoomData(const byte *roomData) { roomInfo._scriptFile._subfile); // Load animation data - _vm->freeAnimationData(); + _vm->_animation->freeAnimationData(); if (roomInfo._animFile._fileNum != -1) - _vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, + _vm->_animation->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, roomInfo._animFile._subfile); _vm->_scaleI = roomInfo._scaleI; @@ -312,6 +312,10 @@ void Room::buildColumn(int playX, int screenX) { } } +void Room::init4Quads() { + error("TODO: init4Quads"); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { -- cgit v1.2.3 From 00633b94be93bd80fc8d1244f59647002f12fbe1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 16:31:23 -0400 Subject: ACCESS: Convert Scripts class to use a MemoryReadStream --- engines/access/room.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index fb70e35ee0..e0acf1c32a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -193,9 +193,11 @@ void Room::loadRoomData(const byte *roomData) { // Load script data _vm->_scripts->freeScriptData(); - if (roomInfo._scriptFile._fileNum != -1) - _vm->_scripts->_script = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, - roomInfo._scriptFile._subfile); + if (roomInfo._scriptFile._fileNum != -1) { + const byte *data = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, + roomInfo._scriptFile._subfile); + _vm->_scripts->setScript(data, _vm->_files->_filesize); + } // Load animation data _vm->_animation->freeAnimationData(); -- cgit v1.2.3 From b2596cab0edc0a4709fba872ca0c20a782caabe4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 18:36:34 -0400 Subject: ACCESS: Implement loadPlayField --- engines/access/room.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 11 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e0acf1c32a..6f449268c6 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -35,7 +35,13 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _function = 0; _roomFlag = 0; _playField = nullptr; + _playFieldWidth = _playFieldHeight = 0; + _matrixSize = 0; _tile = nullptr; + _vWindowWidth = _vWindowHeight = 0; + _vWindowBytesWide = 0; + _bufferBytesWide = 0; + _vWindowLinesTall = 0; } Room::~Room() { @@ -181,7 +187,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1; if (roomInfo._playFieldFile._fileNum != -1) { - _vm->loadPlayField(roomInfo._playFieldFile._fileNum, + loadPlayField(roomInfo._playFieldFile._fileNum, roomInfo._playFieldFile._subfile); setupRoom(); @@ -243,23 +249,23 @@ void Room::setupRoom() { if (_roomFlag != 2) setIconPalette(); - if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) { + if (_vWindowWidth == _playFieldWidth) { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - (_vm->_player->_rawPlayer.x >> 4); int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - - (_vm->_screen->_vWindowSize.x / 2), 0); + (_vWindowWidth / 2), 0); _vm->_screen->_scrollCol = xp; - xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x; + xp = xp + _vWindowWidth - _playFieldWidth; if (xp >= 0) { _vm->_screen->_scrollCol = xp + 1; } } - if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) { + if (_vWindowHeight == _playFieldHeight) { _vm->_screen->_scrollY = 0; _vm->_screen->_scrollRow = 0; } @@ -267,10 +273,10 @@ void Room::setupRoom() { _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y >> 4); int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - - (_vm->_screen->_vWindowSize.y / 2), 0); + (_vWindowHeight / 2), 0); _vm->_screen->_scrollRow = yp; - yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y; + yp = yp + _vWindowHeight - _playFieldHeight; if (yp >= 0) { _vm->_screen->_scrollRow = yp + 1; } @@ -287,7 +293,7 @@ void Room::setWallCodes() { void Room::buildScreen() { int scrollCol = _vm->_screen->_scrollCol; - int cnt = _vm->_screen->_vWindowSize.x + 1; + int cnt = _vWindowWidth + 1; int offset = 0; for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) { @@ -301,15 +307,15 @@ void Room::buildScreen() { void Room::buildColumn(int playX, int screenX) { const byte *pSrc = _playField + _vm->_screen->_scrollRow * - _playFieldSize.x + playX; + _playFieldWidth + playX; byte *pDest = (byte *)_vm->_buffer1.getPixels(); - for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) { + for (int y = 0; y <= _vWindowHeight; ++y) { byte *pTile = _tile + (*pSrc << 8); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); - pDest += _vm->_screen->_vWindowSize.x; + pDest += _vWindowWidth; } } } @@ -318,6 +324,70 @@ void Room::init4Quads() { error("TODO: init4Quads"); } +void Room::loadPlayField(int fileNum, int subfile) { + byte *playData = _vm->_files->loadFile(fileNum, subfile); + Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); + + // Copy the new palette + _vm->_screen->loadRawPalette(&stream); + + // Copy off the tile data + _tileSize = playData[2] << 8; + _tile = new byte[_tileSize]; + stream.read(_tile, _tileSize); + + // Copy off the playfield data + _matrixSize = playData[0] * playData[1]; + _playField = new byte[_matrixSize]; + stream.read(_playField, _matrixSize); + + // Load the plotter data + int numWalls = READ_LE_UINT16(playData + 6); + int numBlocks = playData[8]; + _plotter.load(&stream, numWalls, numBlocks); + + _vWindowWidth = playData[3]; + _vWindowBytesWide = _vWindowWidth << 4; + _bufferBytesWide = _vWindowBytesWide + 16; + _vWindowHeight = playData[4]; + _vWindowLinesTall = _vWindowHeight << 4; + + _vm->_screen->setBufferScan(); + delete[] playData; +} + +/*------------------------------------------------------------------------*/ + +Plotter::Plotter() { + _delta = _blockIn = 0; +} + +void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockCount) { + // Load the wall count + _walls.resize(wallCount); + + for (int i = 0; i < wallCount; ++i) + _walls[i].left = stream->readSint16LE(); + for (int i = 0; i < wallCount; ++i) + _walls[i].top = stream->readSint16LE(); + for (int i = 0; i < wallCount; ++i) + _walls[i].right = stream->readSint16LE(); + for (int i = 0; i < wallCount; ++i) + _walls[i].bottom = stream->readSint16LE(); + + // Load the block list + _blocks.resize(blockCount); + + for (int i = 0; i < blockCount; ++i) + _blocks[i].left = stream->readSint16LE(); + for (int i = 0; i < blockCount; ++i) + _blocks[i].top = stream->readSint16LE(); + for (int i = 0; i < blockCount; ++i) + _blocks[i].right = stream->readSint16LE(); + for (int i = 0; i < blockCount; ++i) + _blocks[i].bottom = stream->readSint16LE(); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { -- cgit v1.2.3 From e833ae66e2a90e539ad004983acbdae2e4ee94f3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 19:19:32 -0400 Subject: ACCESS: Fix loop in buildScreen --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 6f449268c6..371b714467 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -296,7 +296,7 @@ void Room::buildScreen() { int cnt = _vWindowWidth + 1; int offset = 0; - for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) { + for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { buildColumn(_vm->_screen->_scrollCol, offset); ++_vm->_screen->_scrollCol; } -- cgit v1.2.3 From 69ecc15c028208f6b0f28d6df4d86d1a8ba7e26a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 22:25:30 -0400 Subject: ACCESS: Add decoding of animation resources --- engines/access/room.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 371b714467..98e9d5ed6f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -207,9 +207,11 @@ void Room::loadRoomData(const byte *roomData) { // Load animation data _vm->_animation->freeAnimationData(); - if (roomInfo._animFile._fileNum != -1) - _vm->_animation->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, - roomInfo._animFile._subfile); + if (roomInfo._animFile._fileNum != -1) { + byte *data = _vm->_files->loadFile(roomInfo._animFile._fileNum, + roomInfo._animFile._subfile); + _vm->_animation->loadAnimations(data, _vm->_files->_filesize); + } _vm->_scaleI = roomInfo._scaleI; _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold; -- cgit v1.2.3 From eee84b8760dd38079fe97f263a6fa9361ad5696f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Aug 2014 23:12:53 -0400 Subject: ACCESS: Implemented plotList --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 98e9d5ed6f..b39e99815b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -117,7 +117,7 @@ void Room::doRoom() { clearRoom(); break; } else { - _vm->_screen->plotList(); + _vm->plotList(); _vm->_screen->copyRects(); _vm->_screen->copyBF2Vid(); @@ -132,7 +132,7 @@ void Room::doRoom() { clearRoom(); break; } else { - _vm->_screen->plotList(); + _vm->plotList(); _vm->_screen->copyBlocks(); } } -- cgit v1.2.3 From c0cb03cea276832b2d178155786c0418eccfd21d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 08:38:12 -0400 Subject: ACCESS: Implemented copyBlocks --- engines/access/room.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b39e99815b..ab3592a247 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -65,8 +65,8 @@ void Room::doRoom() { while (!_vm->shouldQuit()) { if (!reloadFlag) { _vm->_numImages = 0; - _vm->_newRect.clear(); - _vm->_oldRect.clear(); + _vm->_newRects.clear(); + _vm->_oldRects.clear(); _vm->_nextImage = 0; _vm->_numAnimTimers = 0; @@ -109,7 +109,7 @@ void Room::doRoom() { if (_vm->_screen->_scrollFlag) { _vm->_screen->copyBF1BF2(); - _vm->_newRect.clear(); + _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -124,7 +124,7 @@ void Room::doRoom() { } } else { _vm->_screen->copyBF1BF2(); - _vm->_newRect.clear(); + _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -133,7 +133,7 @@ void Room::doRoom() { break; } else { _vm->plotList(); - _vm->_screen->copyBlocks(); + _vm->copyBlocks(); } } } -- cgit v1.2.3 From 94eda108eb36594329c20ecbc525d9934083e535 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 09:01:29 -0400 Subject: ACCESS: Fix incorrect decrementing of _startup --- engines/access/room.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index ab3592a247..4996527b74 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -80,12 +80,13 @@ void Room::doRoom() { while (!_vm->shouldQuit()) { _vm->_numImages = 0; if (_vm->_startup != -1 && --_vm->_startup != 0) { - --_vm->_startup; _vm->_events->showCursor(); _vm->_screen->fadeIn(); } + // Handle any events _vm->_events->pollEvents(); + _vm->_nextImage = 0; _vm->_player->walk(); _vm->_sound->midiRepeat(); -- cgit v1.2.3 From 9107cc103fa8ca65e12d0213c7b915ec990fb6cf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 09:16:14 -0400 Subject: ACCESS: Added a temporary frame delay and screen update --- engines/access/room.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 4996527b74..d3f0f8ff06 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -84,6 +84,10 @@ void Room::doRoom() { _vm->_screen->fadeIn(); } + // TODO: Game loop doesn't seem to have any delay. For now, + // introduce a slight delay here + _vm->_events->delay(50); + // Handle any events _vm->_events->pollEvents(); -- cgit v1.2.3 From 483bc1eb03b54db70d3136f3265fca1989b5b417 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 21:40:14 -0400 Subject: ACCESS: Implemented setBufferScan and copyRects --- engines/access/room.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index d3f0f8ff06..22ced20f08 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -123,8 +123,7 @@ void Room::doRoom() { break; } else { _vm->plotList(); - _vm->_screen->copyRects(); - + _vm->copyRects(); _vm->_screen->copyBF2Vid(); } } else { -- cgit v1.2.3 From 89772d55a5c97b3c58bdf685e2419e78335ba02d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 23:34:23 -0400 Subject: ACCESS: Implemented window size fields setup and copyBF2Vid --- engines/access/room.cpp | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 22ced20f08..c258e076d8 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -38,10 +38,6 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _playFieldWidth = _playFieldHeight = 0; _matrixSize = 0; _tile = nullptr; - _vWindowWidth = _vWindowHeight = 0; - _vWindowBytesWide = 0; - _bufferBytesWide = 0; - _vWindowLinesTall = 0; } Room::~Room() { @@ -113,7 +109,7 @@ void Room::doRoom() { } if (_vm->_screen->_scrollFlag) { - _vm->_screen->copyBF1BF2(); + _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -124,10 +120,10 @@ void Room::doRoom() { } else { _vm->plotList(); _vm->copyRects(); - _vm->_screen->copyBF2Vid(); + _vm->copyBF2Vid(); } } else { - _vm->_screen->copyBF1BF2(); + _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -255,34 +251,33 @@ void Room::setupRoom() { if (_roomFlag != 2) setIconPalette(); - if (_vWindowWidth == _playFieldWidth) { + if (_vm->_screen->_vWindowWidth == _playFieldWidth) { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - (_vm->_player->_rawPlayer.x >> 4); int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - - (_vWindowWidth / 2), 0); + (_vm->_screen->_vWindowWidth / 2), 0); _vm->_screen->_scrollCol = xp; - xp = xp + _vWindowWidth - _playFieldWidth; + xp = xp + _vm->_screen->_vWindowWidth - _playFieldWidth; if (xp >= 0) { _vm->_screen->_scrollCol = xp + 1; } } - if (_vWindowHeight == _playFieldHeight) { + if (_vm->_screen->_vWindowHeight == _playFieldHeight) { _vm->_screen->_scrollY = 0; _vm->_screen->_scrollRow = 0; - } - else { + } else { _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y >> 4); int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - - (_vWindowHeight / 2), 0); + (_vm->_screen->_vWindowHeight / 2), 0); _vm->_screen->_scrollRow = yp; - yp = yp + _vWindowHeight - _playFieldHeight; + yp = yp + _vm->_screen->_vWindowHeight - _playFieldHeight; if (yp >= 0) { _vm->_screen->_scrollRow = yp + 1; } @@ -299,7 +294,7 @@ void Room::setWallCodes() { void Room::buildScreen() { int scrollCol = _vm->_screen->_scrollCol; - int cnt = _vWindowWidth + 1; + int cnt = _vm->_screen->_vWindowWidth + 1; int offset = 0; for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { @@ -308,7 +303,7 @@ void Room::buildScreen() { } _vm->_screen->_scrollCol = scrollCol; - _vm->_screen->copyBF1BF2(); + _vm->copyBF1BF2(); } void Room::buildColumn(int playX, int screenX) { @@ -316,12 +311,12 @@ void Room::buildColumn(int playX, int screenX) { _playFieldWidth + playX; byte *pDest = (byte *)_vm->_buffer1.getPixels(); - for (int y = 0; y <= _vWindowHeight; ++y) { + for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) { byte *pTile = _tile + (*pSrc << 8); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); - pDest += _vWindowWidth; + pDest += _vm->_screen->_vWindowWidth; } } } @@ -333,9 +328,10 @@ void Room::init4Quads() { void Room::loadPlayField(int fileNum, int subfile) { byte *playData = _vm->_files->loadFile(fileNum, subfile); Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); + Screen &screen = *_vm->_screen; // Copy the new palette - _vm->_screen->loadRawPalette(&stream); + screen.loadRawPalette(&stream); // Copy off the tile data _tileSize = playData[2] << 8; @@ -352,11 +348,11 @@ void Room::loadPlayField(int fileNum, int subfile) { int numBlocks = playData[8]; _plotter.load(&stream, numWalls, numBlocks); - _vWindowWidth = playData[3]; - _vWindowBytesWide = _vWindowWidth << 4; - _bufferBytesWide = _vWindowBytesWide + 16; - _vWindowHeight = playData[4]; - _vWindowLinesTall = _vWindowHeight << 4; + screen._vWindowWidth = playData[3]; + screen._vWindowBytesWide = screen._vWindowWidth << 4; + screen._bufferBytesWide = screen._vWindowBytesWide + 16; + screen._vWindowHeight = playData[4]; + screen._vWindowLinesTall = screen._vWindowHeight << 4; _vm->_screen->setBufferScan(); delete[] playData; -- cgit v1.2.3 From 146f6b5df40d2800432866389f549838921203d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 20:56:06 -0400 Subject: ACCESS: Fix rendering of scene background --- engines/access/room.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c258e076d8..cd39109e63 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -26,9 +26,6 @@ #include "access/resources.h" #include "access/room.h" -#define TILE_WIDTH 16 -#define TILE_HEIGHT 16 - namespace Access { Room::Room(AccessEngine *vm) : Manager(vm) { @@ -309,15 +306,18 @@ void Room::buildScreen() { void Room::buildColumn(int playX, int screenX) { const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; - byte *pDest = (byte *)_vm->_buffer1.getPixels(); for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) { byte *pTile = _tile + (*pSrc << 8); + byte *pDest = (byte *)_vm->_buffer1.getBasePtr(screenX, y * TILE_HEIGHT); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); - pDest += _vm->_screen->_vWindowWidth; + pTile += TILE_WIDTH; + pDest += _vm->_buffer1.pitch; } + + pSrc += _playFieldWidth; } } @@ -348,6 +348,8 @@ void Room::loadPlayField(int fileNum, int subfile) { int numBlocks = playData[8]; _plotter.load(&stream, numWalls, numBlocks); + _playFieldWidth = playData[0]; + _playFieldHeight = playData[1]; screen._vWindowWidth = playData[3]; screen._vWindowBytesWide = screen._vWindowWidth << 4; screen._bufferBytesWide = screen._vWindowBytesWide + 16; -- cgit v1.2.3 From ed645e435a641cc3be95bfe946d2c08d2ab3836b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 21:07:27 -0400 Subject: ACCESS: Fix clearing pending images list each frame --- engines/access/room.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index cd39109e63..3e9e9e65aa 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -57,10 +57,9 @@ void Room::doRoom() { while (!_vm->shouldQuit()) { if (!reloadFlag) { - _vm->_numImages = 0; + _vm->_images.clear(); _vm->_newRects.clear(); _vm->_oldRects.clear(); - _vm->_nextImage = 0; _vm->_numAnimTimers = 0; reloadRoom(); @@ -71,7 +70,7 @@ void Room::doRoom() { _function = 0; while (!_vm->shouldQuit()) { - _vm->_numImages = 0; + _vm->_images.clear(); if (_vm->_startup != -1 && --_vm->_startup != 0) { _vm->_events->showCursor(); _vm->_screen->fadeIn(); @@ -84,7 +83,6 @@ void Room::doRoom() { // Handle any events _vm->_events->pollEvents(); - _vm->_nextImage = 0; _vm->_player->walk(); _vm->_sound->midiRepeat(); _vm->_screen->checkScroll(); -- cgit v1.2.3 From 79e743ba82b14dce808f3dcda6e173fa6f138137 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 22:54:04 -0400 Subject: ACCESS: Fix more gcc compiler warnings --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3e9e9e65aa..66231e60e1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -445,6 +445,6 @@ RoomInfo::RoomInfo(const byte *data) { _sounds.push_back(fi); } -}; +} } // End of namespace Access -- cgit v1.2.3 From 9547efad776899d1ff49a22e1baa5893080e5830 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Aug 2014 22:02:47 -0400 Subject: ACCESS: Implemented player plotting methods --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 66231e60e1..80bcc0082b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -150,7 +150,7 @@ void Room::clearRoom() { _vm->freeCells(); freePlayField(); _vm->freeInactiveData(); - _vm->freeManData(); + _vm->_player->freeSprites(); } void Room::loadRoomData(const byte *roomData) { -- cgit v1.2.3 From 4a3ce2d27dabc2abe6e562089df4f37859e410f9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Aug 2014 09:27:05 -0400 Subject: ACCESS: Implementing checkScroll --- engines/access/room.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 80bcc0082b..1eeedb7c29 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -85,7 +85,7 @@ void Room::doRoom() { _vm->_player->walk(); _vm->_sound->midiRepeat(); - _vm->_screen->checkScroll(); + _vm->_player->checkScroll(); doCommands(); // DOROOMFLASHBACK jump point @@ -103,7 +103,7 @@ void Room::doRoom() { break; } - if (_vm->_screen->_scrollFlag) { + if (_vm->_player->_scrollFlag) { _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; @@ -209,7 +209,7 @@ void Room::loadRoomData(const byte *roomData) { } _vm->_scaleI = roomInfo._scaleI; - _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold; + _vm->_player->_scrollThreshold = roomInfo._scrollThreshold; // Handle loading scene palette data if (roomInfo._paletteFile._fileNum != -1) { @@ -319,6 +319,10 @@ void Room::buildColumn(int playX, int screenX) { } } +void Room::buildRow(int playY, int screenY) { + error("TODO: buildRow"); +} + void Room::init4Quads() { error("TODO: init4Quads"); } -- cgit v1.2.3 From 86484802589f547348ca9ff7fc771801c5b7123e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Aug 2014 12:24:26 +0200 Subject: ACCESS: Add a second parameter to doEstablish() --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 1eeedb7c29..f42c8b092c 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -163,7 +163,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_establishFlag = true; if (_vm->_establishTable[roomInfo._estIndex] != 1) { _vm->_establishTable[roomInfo._estIndex] = 1; - _vm->establish(0); + _vm->establish(0, roomInfo._estIndex); } } -- cgit v1.2.3 From b3ab8a42a6bf77d99b6b349793f1fa7393359d24 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 09:35:38 -0400 Subject: ACCESS: Implementing doCommand --- engines/access/room.cpp | 141 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 138 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f42c8b092c..773a42b9d4 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -35,6 +35,8 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _playFieldWidth = _playFieldHeight = 0; _matrixSize = 0; _tile = nullptr; + _selectCommand = 0; + _conFlag = false; } Room::~Room() { @@ -394,6 +396,138 @@ void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockC _blocks[i].bottom = stream->readSint16LE(); } +void Room::doCommands() { + int commandId = 0; + Common::KeyState keyState; + + if (_vm->_startup != -1) + return; + + if (_vm->_inventory->_invChangeFlag) + _vm->_inventory->refreshInventory(); + + if (_vm->_screen->_screenChangeFlag) { + _vm->_screen->_screenChangeFlag = false; + _vm->_events->_cursorExitFlag = true; + executeCommand(4); + } else if (_vm->_events->_leftButton) { + if (_vm->_events->_mouseRow >= 22) { + // Mouse in user interface area + for (commandId = 0; commandId < 10; ++commandId) { + if (_vm->_events->_mousePos.x >= RMOUSE[commandId][0] && + _vm->_events->_mousePos.x < RMOUSE[commandId][1]) + break; + } + if (commandId < 10) + handleCommand(commandId); + + } else { + // Mouse click in main game area + mainAreaClick(); + } + } else if (_vm->_events->getKey(keyState)) { + if (keyState.ascii >= ';' && keyState.ascii <= 'D') { + handleCommand((int)keyState.ascii - ';'); + } + } +} + +void Room::handleCommand(int commandId) { + if (commandId == 1) + --commandId; + + if (commandId == 9) + _vm->doLoadSave(); + else if (commandId == _selectCommand) { + _vm->_events->debounceLeft(); + commandOff(); + } else { + _vm->_events->debounceLeft(); + executeCommand(commandId); + } +} + +void Room::executeCommand(int commandId) { + _selectCommand = commandId; + + switch (commandId) { + case 0: + _vm->_events->_normalMouse = 4; + _vm->_events->_mouseMode = 0; + break; + case 2: + _vm->_events->_normalMouse = 5; + _vm->_events->_mouseMode = 0; + break; + case 3: + _vm->_events->_normalMouse = 6; + _vm->_events->_mouseMode = 0; + break; + case 4: + _vm->_events->_normalMouse = 1; + _vm->_events->setCursor(CURSOR_0); + if (_vm->_inventory->newDisplayInv() == 2) { + commandOff(); + return; + } else { + warning("TODO: al = _useItem"); + } + break; + case 5: + _vm->_events->_normalMouse = 7; + _vm->_events->_mouseMode = 0; + break; + case 6: + _vm->_events->_normalMouse = 8; + _vm->_events->_mouseMode = 0; + break; + case 7: + _vm->_events->_normalMouse = 1; + _vm->_scripts->_sequence = 5000; + _vm->_scripts->searchForSequence(); + roomMenu(); + _selectCommand = -1; + _vm->_events->_normalMouse = 1; + _vm->_events->_mouseMode = 0; + + _conFlag = true; + while (_conFlag && !_vm->shouldQuit()) { + _conFlag = false; + _vm->_scripts->executeScript(); + } + _vm->_boxSelect = true; + break; + case 8: + _vm->_events->_normalMouse = 9; + _vm->_events->_mouseMode = 0; + break; + default: + break; + } + + roomMenu(); + _vm->_screen->saveScreen(); + _vm->_screen->setDisplayScan(); + + byte *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); + delete[] iconData; + + // Draw the button as selected + _vm->_screen->plotImage(spr, _selectCommand + 2, + Common::Point(RMOUSE[_selectCommand][0], 176)); + + _vm->_screen->restoreScreen(); + _vm->_boxSelect = true; +} + +void Room::commandOff() { + _selectCommand = -1; + _vm->_events->_normalMouse = 1; + _vm->_events->_mouseMode = 4; + roomMenu(); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -428,20 +562,21 @@ RoomInfo::RoomInfo(const byte *data) { _paletteFile._subfile = stream.readUint16LE(); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; - } else { + } + else { _startColor = stream.readUint16LE(); _numColors = stream.readUint16LE(); } for (int16 v = (int16)stream.readUint16LE(); v != -1; - v = (int16)stream.readUint16LE()) { + 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()) { + fileNum = (int16)stream.readUint16LE()) { SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); -- cgit v1.2.3 From dc5500e2464d3457d9dee70993ecd4340963946e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 10:33:03 -0400 Subject: ACCESS: Cleanup of timer flags and some inventory logic --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 773a42b9d4..cf8da17f05 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -37,6 +37,7 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _tile = nullptr; _selectCommand = 0; _conFlag = false; + _selectCommand = -1; } Room::~Room() { -- cgit v1.2.3 From 5ff004b2d839a4e3a06112916efe0412a5112903 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 11:58:59 -0400 Subject: ACCESS: Fix initialisation of player positioning and scaling values --- engines/access/room.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index cf8da17f05..ccd19b0ed9 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -182,14 +182,14 @@ void Room::loadRoomData(const byte *roomData) { _vm->_scaleH1 = roomInfo._scaleH1; _vm->_scaleH2 = roomInfo._scaleH2; _vm->_scaleN1 = roomInfo._scaleN1; - _vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1; + _vm->_scaleT1 = ((_vm->_scaleH1 - _vm->_scaleH2) << 8) / _vm->_scaleN1; if (roomInfo._playFieldFile._fileNum != -1) { loadPlayField(roomInfo._playFieldFile._fileNum, roomInfo._playFieldFile._subfile); setupRoom(); - _vm->_scaleMaxY = _vm->_playFieldHeight << 4; + _vm->_scaleMaxY = _playFieldHeight << 4; } // Load cells @@ -211,7 +211,8 @@ void Room::loadRoomData(const byte *roomData) { _vm->_animation->loadAnimations(data, _vm->_files->_filesize); } - _vm->_scaleI = roomInfo._scaleI; + _vm->_scale = _vm->_scaleI = roomInfo._scaleI; + _vm->_screen->setScaleTable(_vm->_scale); _vm->_player->_scrollThreshold = roomInfo._scrollThreshold; // Handle loading scene palette data -- cgit v1.2.3 From bca9f14719dda5185c443cae6c16b6a374f50ab2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 16:04:09 -0400 Subject: ACCESS: Fix display of mouse cursor --- engines/access/room.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index ccd19b0ed9..dd6f21877c 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -131,6 +131,12 @@ void Room::doRoom() { break; } else { _vm->plotList(); + + if (_vm->_events->_mousePos.y < 177) { + _vm->_events->setCursor(_vm->_events->_normalMouse); + } else { + _vm->_events->setCursor(CURSOR_ARROW); + } _vm->copyBlocks(); } } @@ -454,20 +460,20 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - _vm->_events->_normalMouse = 4; + _vm->_events->_normalMouse = CURSOR_EYE; _vm->_events->_mouseMode = 0; break; case 2: - _vm->_events->_normalMouse = 5; + _vm->_events->_normalMouse = CURSOR_HAND; _vm->_events->_mouseMode = 0; break; case 3: - _vm->_events->_normalMouse = 6; + _vm->_events->_normalMouse = CURSOR_GET; _vm->_events->_mouseMode = 0; break; case 4: - _vm->_events->_normalMouse = 1; - _vm->_events->setCursor(CURSOR_0); + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; + _vm->_events->setCursor(CURSOR_ARROW); if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; @@ -476,20 +482,20 @@ void Room::executeCommand(int commandId) { } break; case 5: - _vm->_events->_normalMouse = 7; + _vm->_events->_normalMouse = CURSOR_CLIMB; _vm->_events->_mouseMode = 0; break; case 6: - _vm->_events->_normalMouse = 8; + _vm->_events->_normalMouse = CURSOR_TALK; _vm->_events->_mouseMode = 0; break; case 7: - _vm->_events->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_scripts->_sequence = 5000; _vm->_scripts->searchForSequence(); roomMenu(); _selectCommand = -1; - _vm->_events->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->_mouseMode = 0; _conFlag = true; @@ -500,7 +506,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; break; case 8: - _vm->_events->_normalMouse = 9; + _vm->_events->_normalMouse = CURSOR_HELP; _vm->_events->_mouseMode = 0; break; default: @@ -525,7 +531,7 @@ void Room::executeCommand(int commandId) { void Room::commandOff() { _selectCommand = -1; - _vm->_events->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->_mouseMode = 4; roomMenu(); } -- cgit v1.2.3 From 0b7078397417a3f54d33cebcd602034c8d0d1a1e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 16:15:48 -0400 Subject: ACCESS: Fix selecting buttons from the bottom of the screen --- engines/access/room.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index dd6f21877c..796a441a25 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -460,15 +460,15 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - _vm->_events->_normalMouse = CURSOR_EYE; + _vm->_events->_normalMouse = CURSOR_LOOK; _vm->_events->_mouseMode = 0; break; case 2: - _vm->_events->_normalMouse = CURSOR_HAND; + _vm->_events->_normalMouse = CURSOR_USE; _vm->_events->_mouseMode = 0; break; case 3: - _vm->_events->_normalMouse = CURSOR_GET; + _vm->_events->_normalMouse = CURSOR_TAKE; _vm->_events->_mouseMode = 0; break; case 4: @@ -513,10 +513,12 @@ void Room::executeCommand(int commandId) { break; } + // Draw the default toolbar menu at the bottom of the screen roomMenu(); _vm->_screen->saveScreen(); _vm->_screen->setDisplayScan(); + // Get the toolbar icons resource byte *iconData = _vm->_files->loadFile("ICONS.LZ"); SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); delete[] iconData; -- cgit v1.2.3 From a42e52fb5baa2d9ed9e2d726cfdf0365acd15472 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 17:24:22 -0400 Subject: ACCESS: Implemented code for clicking in room area --- engines/access/room.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 796a441a25..4da207b290 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -538,6 +538,52 @@ void Room::commandOff() { roomMenu(); } +int Room::checkBoxes() { + return checkBoxes1(_vm->_player->_rawPlayer); +} + +int Room::checkBoxes1(const Common::Point &pt) { + return checkBoxes2(pt, 0, _plotter._blocks.size()); +} + +int Room::checkBoxes2(const Common::Point &pt, int start, int count) { + for (; count > 0; --count, ++start) { + if (_plotter._blocks[start].contains(pt)) { + _plotter._blockIn = start; + return start; + } + } + + return -1; +} + +void Room::checkBoxes3() { + for (int start = 0; start < _plotter._blocks.size(); ++start) { + if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) { + _plotter._blockIn = start; + if (!(validateBox(start) & 0x80)) { + _vm->_events->debounceLeft(); + _vm->_boxSelect = start; + + _conFlag = true; + while (_conFlag && !_vm->shouldQuit()) { + _conFlag = false; + _vm->_scripts->executeScript(); + } + + _vm->_boxSelect = -1; + return; + } + } + } +} + +int Room::validateBox(int boxId) { + _vm->_scripts->_sequence = boxId; + _vm->_scripts->searchForSequence(); + return _vm->_scripts->executeScript(); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { -- cgit v1.2.3 From 8d6c8ed452bc60a963774ea7a26ff92472752d63 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 20:26:17 -0400 Subject: ACCESS: Beginnings of code for text bubble drawing --- engines/access/room.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 4da207b290..9969f336fd 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -584,6 +584,34 @@ int Room::validateBox(int boxId) { return _vm->_scripts->executeScript(); } +void Room::placeBubble() { + _bubbleBox._maxChars = 27; + placeBubble1(); +} + +void Room::placeBubble1() { + _bubbleBox.clearBubbles(); + _vm->_font._charSet._lo = 1; + _vm->_font._charSet._hi = 8; + _vm->_font._charFor._lo = 29; + _vm->_font._charFor._hi = 32; + + calcBubble(); + + Common::Rect r = _bubbleBox._bubbles[0]; + r.translate(-2, 0); + _vm->_screen->saveBlock(r); + printBubble(); +} + +void Room::calcBubble() { + error("TODO: calcBubble"); +} + +void Room::printBubble() { + error("TODO: printBubble"); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -642,4 +670,30 @@ RoomInfo::RoomInfo(const byte *data) { } } +/*------------------------------------------------------------------------*/ + +BubbleBox::BubbleBox() { + _field0 = 2; + _bounds = Common::Rect(64, 32, 130, 122); + _bubblePtr = -1; + _maxChars = 0; +} + +void BubbleBox::load(Common::SeekableReadStream *stream) { + _bubbleTit.clear(); + + byte v; + do { + v = stream->readByte(); + _bubbleTit.push_back(v); + } while (v != 0); + + _bubblePtr = 0; +} + +void BubbleBox::clearBubbles() { + _bubbles.clear(); +} + + } // End of namespace Access -- cgit v1.2.3 From f784b4efba7518806195f96d0177ccdc6e2dbaf8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 22:18:53 -0400 Subject: ACCESS: Added data for font2 and font6x6 --- engines/access/room.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9969f336fd..74a30d8f2a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -591,10 +591,10 @@ void Room::placeBubble() { void Room::placeBubble1() { _bubbleBox.clearBubbles(); - _vm->_font._charSet._lo = 1; - _vm->_font._charSet._hi = 8; - _vm->_font._charFor._lo = 29; - _vm->_font._charFor._hi = 32; + _vm->_fonts._charSet._lo = 1; + _vm->_fonts._charSet._hi = 8; + _vm->_fonts._charFor._lo = 29; + _vm->_fonts._charFor._hi = 32; calcBubble(); @@ -605,10 +605,25 @@ void Room::placeBubble1() { } void Room::calcBubble() { - error("TODO: calcBubble"); + Common::Point printOrg = _vm->_fonts._printOrg; + Common::Point printStart = _vm->_fonts._printStart; + + Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); + + if (_bubbleBox._field0 == 4) { + _vm->_fonts._printMaxX = 110; + } else { + + } + + + + _vm->_fonts._printOrg = printOrg; + _vm->_fonts._printStart = printStart; } void Room::printBubble() { + //drawBubble(_bubbleBox._bubbles.size() - 1); error("TODO: printBubble"); } -- cgit v1.2.3 From ff01ee6807ccd6e5a71ddc945196d68b87f3aa65 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 23:18:53 -0400 Subject: ACCESS: Added code for bubble box size calculations --- engines/access/room.cpp | 73 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 14 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 74a30d8f2a..b46363b32d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -558,7 +558,7 @@ int Room::checkBoxes2(const Common::Point &pt, int start, int count) { } void Room::checkBoxes3() { - for (int start = 0; start < _plotter._blocks.size(); ++start) { + for (uint start = 0; start < _plotter._blocks.size(); ++start) { if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) { _plotter._blockIn = start; if (!(validateBox(start) & 0x80)) { @@ -571,7 +571,7 @@ void Room::checkBoxes3() { _vm->_scripts->executeScript(); } - _vm->_boxSelect = -1; + _vm->_boxSelect = true; return; } } @@ -605,19 +605,57 @@ void Room::placeBubble1() { } void Room::calcBubble() { + // Save points Common::Point printOrg = _vm->_fonts._printOrg; Common::Point printStart = _vm->_fonts._printStart; - Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); - - if (_bubbleBox._field0 == 4) { + // Figure out maximum width allowed + if (_bubbleBox._type == 4) { _vm->_fonts._printMaxX = 110; } else { - + _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleBox._bubblePtr); } + // Start of with a rect with the given starting x and y + Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); + + // Loop through getting lines + Common::String msg(_bubbleBox._bubblePtr); + Common::String line; + int width = 0; + bool lastLine; + do { + lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width); + width = MIN(width, _vm->_fonts._printMaxX); + + _vm->_fonts._printOrg.y += 6; + _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; + } while (!lastLine); + + if (_bubbleBox._type == 4) + ++_vm->_fonts._printOrg.y += 6; + // Determine the width for the area + width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5; + if (width >= 24) + width += 20 - ((width - 24) % 20); + bounds.setWidth(width); + // Determine the height for area + int y = _vm->_fonts._printOrg.y + 6; + if (_bubbleBox._type == 4) + y += 6; + int height = y - bounds.top; + bounds.setHeight(height); + + height -= (_bubbleBox._type == 4) ? 30 : 24; + if (height >= 0) + bounds.setHeight(bounds.height() + 13 - (height % 13)); + + // Add the new bounds to the bubbles list + _bubbleBox._bubbles.push_back(bounds); + + // Restore points _vm->_fonts._printOrg = printOrg; _vm->_fonts._printStart = printStart; } @@ -627,6 +665,15 @@ void Room::printBubble() { error("TODO: printBubble"); } +void Room::drawBubble(int index) { + _bubbleBox._bounds = _bubbleBox._bubbles[index]; + doBox(); +} + +void Room::doBox() { + error("TODO: doBox"); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -688,22 +735,20 @@ RoomInfo::RoomInfo(const byte *data) { /*------------------------------------------------------------------------*/ BubbleBox::BubbleBox() { - _field0 = 2; + _type = 2; _bounds = Common::Rect(64, 32, 130, 122); - _bubblePtr = -1; + _bubblePtr = nullptr; _maxChars = 0; } void BubbleBox::load(Common::SeekableReadStream *stream) { - _bubbleTit.clear(); + _bubbleTitle.clear(); byte v; - do { - v = stream->readByte(); - _bubbleTit.push_back(v); - } while (v != 0); + while ((v = stream->readByte()) != 0) + _bubbleTitle += (char)v; - _bubblePtr = 0; + _bubblePtr = _bubbleTitle.c_str(); } void BubbleBox::clearBubbles() { -- cgit v1.2.3 From 404c7cd5d33e81c7724cb78dfce5701b26b4659b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 11:14:30 -0400 Subject: ACCESS: Split the bubble box code from Room into it's own file --- engines/access/room.cpp | 114 ------------------------------------------------ 1 file changed, 114 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b46363b32d..0405e7c4ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -584,96 +584,6 @@ int Room::validateBox(int boxId) { return _vm->_scripts->executeScript(); } -void Room::placeBubble() { - _bubbleBox._maxChars = 27; - placeBubble1(); -} - -void Room::placeBubble1() { - _bubbleBox.clearBubbles(); - _vm->_fonts._charSet._lo = 1; - _vm->_fonts._charSet._hi = 8; - _vm->_fonts._charFor._lo = 29; - _vm->_fonts._charFor._hi = 32; - - calcBubble(); - - Common::Rect r = _bubbleBox._bubbles[0]; - r.translate(-2, 0); - _vm->_screen->saveBlock(r); - printBubble(); -} - -void Room::calcBubble() { - // Save points - Common::Point printOrg = _vm->_fonts._printOrg; - Common::Point printStart = _vm->_fonts._printStart; - - // Figure out maximum width allowed - if (_bubbleBox._type == 4) { - _vm->_fonts._printMaxX = 110; - } else { - _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleBox._bubblePtr); - } - - // Start of with a rect with the given starting x and y - Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); - - // Loop through getting lines - Common::String msg(_bubbleBox._bubblePtr); - Common::String line; - int width = 0; - bool lastLine; - do { - lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width); - width = MIN(width, _vm->_fonts._printMaxX); - - _vm->_fonts._printOrg.y += 6; - _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; - } while (!lastLine); - - if (_bubbleBox._type == 4) - ++_vm->_fonts._printOrg.y += 6; - - // Determine the width for the area - width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5; - if (width >= 24) - width += 20 - ((width - 24) % 20); - bounds.setWidth(width); - - // Determine the height for area - int y = _vm->_fonts._printOrg.y + 6; - if (_bubbleBox._type == 4) - y += 6; - int height = y - bounds.top; - bounds.setHeight(height); - - height -= (_bubbleBox._type == 4) ? 30 : 24; - if (height >= 0) - bounds.setHeight(bounds.height() + 13 - (height % 13)); - - // Add the new bounds to the bubbles list - _bubbleBox._bubbles.push_back(bounds); - - // Restore points - _vm->_fonts._printOrg = printOrg; - _vm->_fonts._printStart = printStart; -} - -void Room::printBubble() { - //drawBubble(_bubbleBox._bubbles.size() - 1); - error("TODO: printBubble"); -} - -void Room::drawBubble(int index) { - _bubbleBox._bounds = _bubbleBox._bubbles[index]; - doBox(); -} - -void Room::doBox() { - error("TODO: doBox"); -} - /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -732,28 +642,4 @@ RoomInfo::RoomInfo(const byte *data) { } } -/*------------------------------------------------------------------------*/ - -BubbleBox::BubbleBox() { - _type = 2; - _bounds = Common::Rect(64, 32, 130, 122); - _bubblePtr = nullptr; - _maxChars = 0; -} - -void BubbleBox::load(Common::SeekableReadStream *stream) { - _bubbleTitle.clear(); - - byte v; - while ((v = stream->readByte()) != 0) - _bubbleTitle += (char)v; - - _bubblePtr = _bubbleTitle.c_str(); -} - -void BubbleBox::clearBubbles() { - _bubbles.clear(); -} - - } // End of namespace Access -- cgit v1.2.3 From 17315a4dd71d4f9151724166bb5ddd7fdc0074f7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Aug 2014 00:29:01 -0400 Subject: ACCESS: Implemented wall checks for pathfinding --- engines/access/room.cpp | 135 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0405e7c4ac..9c2bd01650 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -584,6 +584,141 @@ int Room::validateBox(int boxId) { return _vm->_scripts->executeScript(); } +void Room::swapOrg() { + SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); + SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); +} + +int Room::calcLR(int yp) { + const Screen &screen = *_vm->_screen; + + int yv = (yp - screen._orgY1) * (screen._orgX2 - screen._orgX1); + int yd = screen._orgY2 - screen._orgY1; + + int rem = (yv % yd) << 1; + yv /= yd; + if (rem >= yd) + ++yv; + + return yv + screen._orgX1; +} + +int Room::calcUD(int xp) { + const Screen &screen = *_vm->_screen; + + int xv = (xp - screen._orgX1) * (screen._orgY2 - screen._orgY1); + int xd = screen._orgX2 - screen._orgX1; + + int rem = (xv % xd) << 1; + xv /= xd; + if (rem >= xd) + ++xv; + + return xv + screen._orgY1; +} + +bool Room::codeWalls() { + Screen &screen = *_vm->_screen; + Player &player = *_vm->_player; + + if (_plotter._walls.size() == 0) + return false; + + for (uint i = 0; i < _plotter._walls.size(); ++i) { + Common::Rect &r = _plotter._walls[i]; + JetFrame &jf = _jetFrame[i]; + + jf._wallCode = 0; + jf._wallCode1 = 0; + screen._orgX1 = r.left; + screen._orgY1 = r.top; + screen._orgX2 = r.right; + screen._orgY2 = r.bottom; + + if (screen._orgY2 != screen._orgY1) { + if (screen._orgY2 < screen._orgY1) + swapOrg(); + + if ((player._rawYTemp >= screen._orgY1) && + (player._rawYTemp <= screen._orgY2)) { + jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1; + jf._wallCode1 |= (calcLR(player._rawYTemp) - player._playerOffset.x) < 0 ? 2 : 1; + } + } + + if (screen._orgX2 != screen._orgX1) { + if (screen._orgX2 < screen._orgX1) + swapOrg(); + + if ((player._rawXTemp >= screen._orgX1) && + (player._rawXTemp <= screen._orgX2)) { + int y = screen._orgY2; + if (y == screen._orgY1) + y = calcUD(player._rawXTemp); + + jf._wallCode |= (player._rawYTemp - y) < 0 ? 4 : 8; + } + + int x = player._rawXTemp + player._playerOffset.x; + if ((x >= screen._orgX1) && (x <= screen._orgX2)) { + int y = screen._orgY2; + if (screen._orgY2 != screen._orgY1) + y = calcUD(player._rawXTemp + player._playerOffset.x); + + jf._wallCode1 |= (player._rawYTemp - y) < 0 ? 4 : 8; + } + } + } + + for (uint i = 0; i < _jetFrame.size(); ++i) { + JetFrame &jf = _jetFrame[i]; + if (checkCode(jf._wallCode, jf._wallCodeOld) || + checkCode(jf._wallCode1, jf._wallCode1Old)) + return true; + } + + // Copy the current wall calculations to the old properties + for (uint i = 0; i < _jetFrame.size(); ++i) { + JetFrame &jf = _jetFrame[i]; + jf._wallCodeOld = jf._wallCode; + jf._wallCode1Old = jf._wallCode1; + } + + return false; +} + +bool Room::checkCode(int v1, int v2) { + Player &p = *_vm->_player; + + if (!v1) { + p._collideFlag = true; + return true; + } if (!v2 || (v1 == v2)) { + } else if (v1 & 1) { + if (v2 & 2) { + p._collideFlag = true; + return true; + } + } else if (v1 & 2) { + if (v2 & 1) { + p._collideFlag = true; + return true; + } + } else if (v1 & 4) { + if (v2 & 8) { + p._collideFlag = true; + return true; + } + } else if (v1 & 8) { + if (v2 & 4) { + p._collideFlag = true; + return true; + } + } + + return false; +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { -- cgit v1.2.3 From 080a030116862ee21e0ebcec019fdc3f8e073650 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Aug 2014 07:32:17 -0400 Subject: ACCESS: Some initial pathfinding bugfixes --- engines/access/room.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9c2bd01650..5e3a4d743d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -653,7 +653,7 @@ bool Room::codeWalls() { if ((player._rawXTemp >= screen._orgX1) && (player._rawXTemp <= screen._orgX2)) { int y = screen._orgY2; - if (y == screen._orgY1) + if (y != screen._orgY1) y = calcUD(player._rawXTemp); jf._wallCode |= (player._rawYTemp - y) < 0 ? 4 : 8; @@ -691,8 +691,6 @@ bool Room::checkCode(int v1, int v2) { Player &p = *_vm->_player; if (!v1) { - p._collideFlag = true; - return true; } if (!v2 || (v1 == v2)) { } else if (v1 & 1) { if (v2 & 2) { -- cgit v1.2.3 From b4f74b9b5e3b5eebcd695f8c07dd2d78e6a53a61 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Aug 2014 01:46:46 +0200 Subject: ACCESS: Use a variable delay of up to 20ms instead of a fix 50ms --- engines/access/room.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 5e3a4d743d..e40c6b7096 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -79,10 +79,6 @@ void Room::doRoom() { _vm->_screen->fadeIn(); } - // TODO: Game loop doesn't seem to have any delay. For now, - // introduce a slight delay here - _vm->_events->delay(50); - // Handle any events _vm->_events->pollEvents(); -- cgit v1.2.3 From 5870b18e175b8beee29654978d711d94ad92ddf5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 Aug 2014 20:02:17 -0400 Subject: ACCESS: Fix for collision detection --- engines/access/room.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e40c6b7096..e7008c5ab7 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -593,7 +593,7 @@ int Room::calcLR(int yp) { int rem = (yv % yd) << 1; yv /= yd; - if (rem >= yd) + if (rem >= yd || rem < 0) ++yv; return yv + screen._orgX1; @@ -607,7 +607,7 @@ int Room::calcUD(int xp) { int rem = (xv % xd) << 1; xv /= xd; - if (rem >= xd) + if (rem >= xd || rem < 0) ++xv; return xv + screen._orgY1; @@ -638,7 +638,8 @@ bool Room::codeWalls() { if ((player._rawYTemp >= screen._orgY1) && (player._rawYTemp <= screen._orgY2)) { jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1; - jf._wallCode1 |= (calcLR(player._rawYTemp) - player._playerOffset.x) < 0 ? 2 : 1; + jf._wallCode1 |= (calcLR(player._rawYTemp) - + (player._rawXTemp + player._playerOffset.x)) < 0 ? 2 : 1; } } -- cgit v1.2.3 From 4e5eb04e47c96f98cdc6519ae79b908efc9888e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 Aug 2014 20:22:35 -0400 Subject: ACCESS: Fix freeing player sprites when the scene changes --- engines/access/room.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e7008c5ab7..f45ffe7afb 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -88,17 +88,17 @@ void Room::doRoom() { doCommands(); // DOROOMFLASHBACK jump point - if (_function == 1) { + if (_function == FN_CLEAR1) { clearRoom(); break; - } else if (_function == 2) { + } else if (_function == FN_CLEAR2) { clearRoom(); return; - } else if (_function == 3) { + } else if (_function == FN_RELOAD) { reloadRoom1(); reloadFlag = true; break; - } else if (_function == 4) { + } else if (_function == FN_BREAK) { break; } @@ -108,7 +108,7 @@ void Room::doRoom() { _function = 0; roomLoop(); - if (_function == 1) { + if (_function == FN_CLEAR1) { clearRoom(); break; } else { @@ -122,7 +122,7 @@ void Room::doRoom() { _function = 0; roomLoop(); - if (_function == 1) { + if (_function == FN_CLEAR1) { clearRoom(); break; } else { -- cgit v1.2.3 From 966515a7d0f0e9bccc8ad2a761020372d4bae19f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 21 Aug 2014 07:44:41 -0400 Subject: ACCESS: Fix room data loading for MM --- engines/access/room.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f45ffe7afb..0e6cba052d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -159,7 +159,7 @@ void Room::clearRoom() { } void Room::loadRoomData(const byte *roomData) { - RoomInfo roomInfo(roomData); + RoomInfo roomInfo(roomData, _vm->getGameID()); _roomFlag = roomInfo._roomFlag; @@ -716,11 +716,16 @@ bool Room::checkCode(int v1, int v2) { /*------------------------------------------------------------------------*/ -RoomInfo::RoomInfo(const byte *data) { +RoomInfo::RoomInfo(const byte *data, int gameType) { Common::MemoryReadStream stream(data, 999); _roomFlag = stream.readByte(); - _estIndex = (int16)stream.readUint16LE(); + + if (gameType != GType_MartianMemorandum) + _estIndex = (int16)stream.readUint16LE(); + else + _estIndex = -1; + _musicFile._fileNum = (int16)stream.readUint16LE(); _musicFile._subfile = stream.readUint16LE(); _scaleH1 = stream.readByte(); @@ -748,8 +753,7 @@ RoomInfo::RoomInfo(const byte *data) { _paletteFile._subfile = stream.readUint16LE(); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; - } - else { + } else { _startColor = stream.readUint16LE(); _numColors = stream.readUint16LE(); } -- cgit v1.2.3 From 8d1d1f6739b3b9f456d618a8740d754ddac2eb41 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 21 Aug 2014 21:03:44 -0400 Subject: ACCESS: Fix displaying background in scrolling rooms --- engines/access/room.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0e6cba052d..83fcce1a15 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -256,15 +256,13 @@ void Room::setupRoom() { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { - _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - - (_vm->_player->_rawPlayer.x >> 4); - int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - - (_vm->_screen->_vWindowWidth / 2), 0); - _vm->_screen->_scrollCol = xp; - - xp = xp + _vm->_screen->_vWindowWidth - _playFieldWidth; - if (xp >= 0) { - _vm->_screen->_scrollCol = xp + 1; + int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH; + _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; + _vm->_screen->_scrollCol = MAX(xv - (_vm->_screen->_vWindowWidth / 2), 0); + + int sx = _vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth - _playFieldWidth; + if (sx >= 0) { + _vm->_screen->_scrollCol -= sx + 1; } } -- cgit v1.2.3 From b4d2484633e80ac2a1caccfedb51980cd7926c11 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Aug 2014 22:55:17 -0400 Subject: ACCESS: Fixes for drawing scrolling scenes --- engines/access/room.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 83fcce1a15..225cd80548 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -296,6 +296,10 @@ void Room::buildScreen() { int cnt = _vm->_screen->_vWindowWidth + 1; int offset = 0; + // Clear current background buffer + _vm->_buffer1.clearBuffer(); + + // Loop through drawing each column of tiles forming the background for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { buildColumn(_vm->_screen->_scrollCol, offset); ++_vm->_screen->_scrollCol; -- cgit v1.2.3 From 6343ff72c462219afb2f11fea69539725794efd6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 10:21:50 -0400 Subject: ACCESS: Fix cursor positioning in scrolled screens, and background restores --- engines/access/room.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 225cd80548..b5f8554612 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -556,8 +556,10 @@ int Room::checkBoxes2(const Common::Point &pt, int start, int count) { } void Room::checkBoxes3() { + Common::Point pt = _vm->_events->calcRawMouse(); + for (uint start = 0; start < _plotter._blocks.size(); ++start) { - if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) { + if (_plotter._blocks[start].contains(pt)) { _plotter._blockIn = start; if (!(validateBox(start) & 0x80)) { _vm->_events->debounceLeft(); -- cgit v1.2.3 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/room.cpp | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'engines/access/room.cpp') 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(); -- cgit v1.2.3 From 31c8a524a35c19291bbd7bed3d117791a90c7401 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 13:13:56 -0400 Subject: ACCESS: More implementation of CharManager --- engines/access/room.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index d703114090..3ff4d66337 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -241,39 +241,40 @@ void Room::roomLoop() { } void Room::setupRoom() { - _vm->_screen->setScaleTable(_vm->_scale); - _vm->_screen->setBufferScan(); + Screen &screen = *_vm->_screen; + screen.setScaleTable(_vm->_scale); + screen.setBufferScan(); if (_roomFlag != 2) - setIconPalette(); + screen.setIconPalette(); - if (_vm->_screen->_vWindowWidth == _playFieldWidth) { - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollCol = 0; + if (screen._vWindowWidth == _playFieldWidth) { + screen._scrollX = 0; + screen._scrollCol = 0; } else { int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH; - _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; - _vm->_screen->_scrollCol = MAX(xv - (_vm->_screen->_vWindowWidth / 2), 0); + screen._scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; + screen._scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); - int sx = _vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth - _playFieldWidth; + int sx = screen._scrollCol + screen._vWindowWidth - _playFieldWidth; if (sx >= 0) { - _vm->_screen->_scrollCol -= sx + 1; + screen._scrollCol -= sx + 1; } } - if (_vm->_screen->_vWindowHeight == _playFieldHeight) { - _vm->_screen->_scrollY = 0; - _vm->_screen->_scrollRow = 0; + if (screen._vWindowHeight == _playFieldHeight) { + screen._scrollY = 0; + screen._scrollRow = 0; } else { - _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - + screen._scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y >> 4); int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - - (_vm->_screen->_vWindowHeight / 2), 0); - _vm->_screen->_scrollRow = yp; + (screen._vWindowHeight / 2), 0); + screen._scrollRow = yp; - yp = yp + _vm->_screen->_vWindowHeight - _playFieldHeight; + yp = yp + screen._vWindowHeight - _playFieldHeight; if (yp >= 0) { - _vm->_screen->_scrollRow = yp + 1; + screen._scrollRow = yp + 1; } } } -- cgit v1.2.3 From 1e2d79eb598a0ed73a59cc540cddbaddf0bc90dd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 14:13:26 -0400 Subject: ACCESS: Implement more opcodes, stubbed beginning of video player --- engines/access/room.cpp | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3ff4d66337..90ef3470db 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -174,8 +174,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_sound->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { - _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile._fileNum, - roomInfo._musicFile._subfile); + _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile); _vm->_sound->_midiSize = _vm->_files->_filesize; _vm->_sound->midiPlay(); _vm->_sound->_musicRepeat = true; @@ -200,16 +199,14 @@ void Room::loadRoomData(const byte *roomData) { // Load script data _vm->_scripts->freeScriptData(); if (roomInfo._scriptFile._fileNum != -1) { - const byte *data = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, - roomInfo._scriptFile._subfile); + const byte *data = _vm->_files->loadFile(roomInfo._scriptFile); _vm->_scripts->setScript(data, _vm->_files->_filesize); } // Load animation data _vm->_animation->freeAnimationData(); if (roomInfo._animFile._fileNum != -1) { - byte *data = _vm->_files->loadFile(roomInfo._animFile._fileNum, - roomInfo._animFile._subfile); + byte *data = _vm->_files->loadFile(roomInfo._animFile); _vm->_animation->loadAnimations(data, _vm->_files->_filesize); } @@ -726,31 +723,25 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { else _estIndex = -1; - _musicFile._fileNum = stream.readSint16LE(); - _musicFile._subfile = stream.readUint16LE(); + _musicFile.load(stream); _scaleH1 = stream.readByte(); _scaleH2 = stream.readByte(); _scaleN1 = stream.readByte(); - _playFieldFile._fileNum = stream.readSint16LE(); - _playFieldFile._subfile = stream.readUint16LE(); + _playFieldFile.load(stream); for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) { CellIdent ci; ci._cell = cell; - ci._fileNum = stream.readSint16LE(); - ci._subfile = stream.readUint16LE(); + ci.load(stream); _cells.push_back(ci); } - _scriptFile._fileNum = stream.readSint16LE(); - _scriptFile._subfile = stream.readUint16LE(); - _animFile._fileNum = stream.readSint16LE(); - _animFile._subfile = stream.readUint16LE(); + _scriptFile.load(stream); + _animFile.load(stream); _scaleI = stream.readByte(); _scrollThreshold = stream.readByte(); - _paletteFile._fileNum = stream.readSint16LE(); - _paletteFile._subfile = stream.readUint16LE(); + _paletteFile.load(stream); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; } else { @@ -760,10 +751,9 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { 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(); + ec._vid._fileNum = v; + ec._vid._subfile = stream.readSint16LE(); + ec._vidSound.load(stream); _extraCells.push_back(ec); } -- cgit v1.2.3 From ee62d6c1cfce009331050fb9bf8bfecbb8f51472 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 23:21:17 -0400 Subject: ACCESS: In progress inventory display screen --- engines/access/room.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 90ef3470db..a4be02d263 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -451,34 +451,28 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - _vm->_events->_normalMouse = CURSOR_LOOK; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_LOOK); break; case 2: - _vm->_events->_normalMouse = CURSOR_USE; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_USE); break; case 3: - _vm->_events->_normalMouse = CURSOR_TAKE; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_TAKE); break; case 4: - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->setCursor(CURSOR_ARROW); if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; } else { - warning("TODO: al = _useItem"); + // TODO: al = _useItem? } break; case 5: - _vm->_events->_normalMouse = CURSOR_CLIMB; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_CLIMB); break; case 6: - _vm->_events->_normalMouse = CURSOR_TALK; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_TALK); break; case 7: _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; @@ -486,8 +480,7 @@ void Room::executeCommand(int commandId) { _vm->_scripts->searchForSequence(); roomMenu(); _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_CROSSHAIRS); _conFlag = true; while (_conFlag && !_vm->shouldQuit()) { @@ -497,8 +490,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; break; case 8: - _vm->_events->_normalMouse = CURSOR_HELP; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_HELP); break; default: break; @@ -524,8 +516,7 @@ void Room::executeCommand(int commandId) { void Room::commandOff() { _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; - _vm->_events->_mouseMode = 4; + _vm->_events->setCursor(CURSOR_CROSSHAIRS); roomMenu(); } -- cgit v1.2.3 From 3e14e7b9663130d1a730aaf6821c766b505ebdba Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 17:31:41 -0400 Subject: ACCESS: Fix selection of inventory items --- engines/access/room.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a4be02d263..b00b1cf83b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -447,20 +447,24 @@ void Room::handleCommand(int commandId) { } void Room::executeCommand(int commandId) { + EventsManager &events = *_vm->_events; _selectCommand = commandId; switch (commandId) { case 0: - _vm->_events->setCursor(CURSOR_LOOK); + events._normalMouse = CURSOR_LOOK; + events.setCursor(CURSOR_LOOK); break; case 2: - _vm->_events->setCursor(CURSOR_USE); + events._normalMouse = CURSOR_USE; + events.setCursor(CURSOR_USE); break; case 3: - _vm->_events->setCursor(CURSOR_TAKE); + events._normalMouse = CURSOR_TAKE; + events.setCursor(CURSOR_TAKE); break; case 4: - _vm->_events->setCursor(CURSOR_ARROW); + events.setCursor(CURSOR_ARROW); if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; @@ -469,18 +473,20 @@ void Room::executeCommand(int commandId) { } break; case 5: - _vm->_events->setCursor(CURSOR_CLIMB); + events._normalMouse = CURSOR_CLIMB; + events.setCursor(CURSOR_CLIMB); break; case 6: - _vm->_events->setCursor(CURSOR_TALK); + events._normalMouse = CURSOR_TALK; + events.setCursor(CURSOR_TALK); break; case 7: - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; + events._normalMouse = CURSOR_CROSSHAIRS; + events.setCursor(CURSOR_CROSSHAIRS); _vm->_scripts->_sequence = 5000; _vm->_scripts->searchForSequence(); roomMenu(); _selectCommand = -1; - _vm->_events->setCursor(CURSOR_CROSSHAIRS); _conFlag = true; while (_conFlag && !_vm->shouldQuit()) { @@ -490,7 +496,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; break; case 8: - _vm->_events->setCursor(CURSOR_HELP); + events.setCursor(CURSOR_HELP); break; default: break; -- cgit v1.2.3 From f993c8dd46c240daa7022f359542e743d9c7a888 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 22:42:24 -0400 Subject: ACCESS: Improved right scrolling --- engines/access/room.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b00b1cf83b..29d9eef624 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -468,8 +468,6 @@ void Room::executeCommand(int commandId) { if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; - } else { - // TODO: al = _useItem? } break; case 5: -- cgit v1.2.3 From 1568b4a433f8efc0b4e670d8e9714885aa8831c0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Aug 2014 23:55:17 +0200 Subject: ACCESS: Move Establish functions to Amazon engine, start implementing init4Quads --- engines/access/room.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 29d9eef624..10146ff6c3 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -324,10 +324,6 @@ void Room::buildRow(int playY, int screenY) { error("TODO: buildRow"); } -void Room::init4Quads() { - error("TODO: init4Quads"); -} - void Room::loadPlayField(int fileNum, int subfile) { byte *playData = _vm->_files->loadFile(fileNum, subfile); Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); -- cgit v1.2.3 From c0a7852662be724077921bcf9b9bb0bf2da2dfff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:13:43 -0400 Subject: ACCESS: Refactor the file manager to return resource structures --- engines/access/room.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 10146ff6c3..0c60f7b818 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -175,7 +175,6 @@ void Room::loadRoomData(const byte *roomData) { _vm->_sound->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile); - _vm->_sound->_midiSize = _vm->_files->_filesize; _vm->_sound->midiPlay(); _vm->_sound->_musicRepeat = true; } @@ -199,15 +198,15 @@ void Room::loadRoomData(const byte *roomData) { // Load script data _vm->_scripts->freeScriptData(); if (roomInfo._scriptFile._fileNum != -1) { - const byte *data = _vm->_files->loadFile(roomInfo._scriptFile); - _vm->_scripts->setScript(data, _vm->_files->_filesize); + Resource *newScript = _vm->_files->loadFile(roomInfo._scriptFile); + _vm->_scripts->setScript(newScript); } // Load animation data _vm->_animation->freeAnimationData(); if (roomInfo._animFile._fileNum != -1) { - byte *data = _vm->_files->loadFile(roomInfo._animFile); - _vm->_animation->loadAnimations(data, _vm->_files->_filesize); + Resource *anim = _vm->_files->loadFile(roomInfo._animFile); + _vm->_animation->loadAnimations(anim); } _vm->_scale = _vm->_scaleI = roomInfo._scaleI; @@ -325,38 +324,39 @@ void Room::buildRow(int playY, int screenY) { } void Room::loadPlayField(int fileNum, int subfile) { - byte *playData = _vm->_files->loadFile(fileNum, subfile); - Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); + Resource *playData = _vm->_files->loadFile(fileNum, subfile); + byte header[16]; + playData->_stream->read(&header[0], 16); Screen &screen = *_vm->_screen; // Copy the new palette - screen.loadRawPalette(&stream); + screen.loadRawPalette(playData->_stream); // Copy off the tile data - _tileSize = playData[2] << 8; + _tileSize = (int)header[2] << 8; _tile = new byte[_tileSize]; - stream.read(_tile, _tileSize); + playData->_stream->read(_tile, _tileSize); // Copy off the playfield data - _matrixSize = playData[0] * playData[1]; + _matrixSize = header[0] * header[1]; _playField = new byte[_matrixSize]; - stream.read(_playField, _matrixSize); + playData->_stream->read(_playField, _matrixSize); // Load the plotter data int numWalls = READ_LE_UINT16(playData + 6); - int numBlocks = playData[8]; - _plotter.load(&stream, numWalls, numBlocks); + int numBlocks = header[8]; + _plotter.load(playData->_stream, numWalls, numBlocks); - _playFieldWidth = playData[0]; - _playFieldHeight = playData[1]; - screen._vWindowWidth = playData[3]; + _playFieldWidth = header[0]; + _playFieldHeight = header[1]; + screen._vWindowWidth = header[3]; screen._vWindowBytesWide = screen._vWindowWidth << 4; screen._bufferBytesWide = screen._vWindowBytesWide + 16; - screen._vWindowHeight = playData[4]; + screen._vWindowHeight = header[4]; screen._vWindowLinesTall = screen._vWindowHeight << 4; _vm->_screen->setBufferScan(); - delete[] playData; + delete playData; } /*------------------------------------------------------------------------*/ @@ -502,9 +502,9 @@ void Room::executeCommand(int commandId) { _vm->_screen->setDisplayScan(); // Get the toolbar icons resource - byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); - delete[] iconData; + Resource *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData); + delete iconData; // Draw the button as selected _vm->_screen->plotImage(spr, _selectCommand + 2, -- cgit v1.2.3 From 35923890ccb26d958d33c6c472a1b16659718392 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:22:33 -0400 Subject: ACCESS: Fix incorrect use of delete[] on Resources --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0c60f7b818..0de6497422 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -143,7 +143,7 @@ void Room::doRoom() { void Room::clearRoom() { if (_vm->_sound->_music) { _vm->_sound->stopSong(); - delete[] _vm->_sound->_music; + delete _vm->_sound->_music; _vm->_sound->_music = nullptr; } -- cgit v1.2.3 From 3bbec487a53243464030fe1946f833971d6e14c0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:34:50 -0400 Subject: ACCESS: Fixes for memory leaks --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0de6497422..a33bc76e66 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -207,6 +207,7 @@ void Room::loadRoomData(const byte *roomData) { if (roomInfo._animFile._fileNum != -1) { Resource *anim = _vm->_files->loadFile(roomInfo._animFile); _vm->_animation->loadAnimations(anim); + delete anim; } _vm->_scale = _vm->_scaleI = roomInfo._scaleI; -- cgit v1.2.3 From 5abe5b89932adfcc705beb7529d323aa15a85bbd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:39:37 -0400 Subject: ACCESS: Fix loading of room playfield data --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a33bc76e66..b9a07ea2ed 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -344,7 +344,7 @@ void Room::loadPlayField(int fileNum, int subfile) { playData->_stream->read(_playField, _matrixSize); // Load the plotter data - int numWalls = READ_LE_UINT16(playData + 6); + int numWalls = READ_LE_UINT16(&header[6]); int numBlocks = header[8]; _plotter.load(playData->_stream, numWalls, numBlocks); -- cgit v1.2.3 From 83528083228ea45ec3105b7dbcb720a1ac0dba55 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 08:45:42 -0400 Subject: ACCESS: Added code for reading/writing savegame headers and list saves --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b9a07ea2ed..c9e150f8ea 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -433,7 +433,7 @@ void Room::handleCommand(int commandId) { --commandId; if (commandId == 9) - _vm->doLoadSave(); + _vm->openMainMenuDialog(); else if (commandId == _selectCommand) { _vm->_events->debounceLeft(); commandOff(); -- cgit v1.2.3 From f12fa2de07694d93a7035875f56f36ed4849275d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 09:57:51 -0400 Subject: ACCESS: Implement saving and loading savegames --- engines/access/room.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c9e150f8ea..d4e8886cac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -80,7 +80,10 @@ void Room::doRoom() { } // Handle any events + _vm->_canSaveLoad = true; _vm->_events->pollEvents(); + _vm->_canSaveLoad = false; + g_system->delayMillis(5); _vm->_player->walk(); _vm->_sound->midiRepeat(); @@ -432,9 +435,11 @@ void Room::handleCommand(int commandId) { if (commandId == 1) --commandId; - if (commandId == 9) + if (commandId == 9) { + _vm->_canSaveLoad = true; _vm->openMainMenuDialog(); - else if (commandId == _selectCommand) { + _vm->_canSaveLoad = false; + } else if (commandId == _selectCommand) { _vm->_events->debounceLeft(); commandOff(); } else { -- cgit v1.2.3 From 2cca520465dd8005aa3ee21b25961afbde227afd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 11:52:48 -0400 Subject: ACCESS: Add new support for mouse wheel for cycling through cursors --- engines/access/room.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index d4e8886cac..a7b619c238 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -79,7 +79,7 @@ void Room::doRoom() { _vm->_screen->fadeIn(); } - // Handle any events + // Poll for events _vm->_canSaveLoad = true; _vm->_events->pollEvents(); _vm->_canSaveLoad = false; @@ -408,7 +408,16 @@ void Room::doCommands() { if (_vm->_screen->_screenChangeFlag) { _vm->_screen->_screenChangeFlag = false; _vm->_events->_cursorExitFlag = true; - executeCommand(4); + executeCommand(7); + } + else if (_vm->_events->_wheelUp || _vm->_events->_wheelDown) { + // Handle scrolling mouse wheel + cycleCommand(_vm->_events->_wheelUp ? 1 : -1); + + } else if (_vm->_events->_middleButton) { + // Switch back to walking + handleCommand(7); + } else if (_vm->_events->_leftButton) { if (_vm->_events->_mouseRow >= 22) { // Mouse in user interface area @@ -431,6 +440,20 @@ void Room::doCommands() { } } +void Room::cycleCommand(int incr) { + int command = _selectCommand + incr; + if (command < -1) + command = 6; + else if (command == -1) + command = 7; + else if (command == 1) + command = (incr == 1) ? 2 : 0; + else if (command == 4) + command = (incr == 1) ? 5 : 3; + + handleCommand(command); +} + void Room::handleCommand(int commandId) { if (commandId == 1) --commandId; @@ -494,7 +517,7 @@ void Room::executeCommand(int commandId) { _vm->_scripts->executeScript(); } _vm->_boxSelect = true; - break; + return; case 8: events.setCursor(CURSOR_HELP); break; -- cgit v1.2.3 From d38839d64209248e07b5464be8d44fa19ae93b92 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 11:55:02 -0400 Subject: ACCESS: Fix selecting the help cursor --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a7b619c238..c26a811225 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -519,6 +519,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; return; case 8: + events._normalMouse = CURSOR_HELP; events.setCursor(CURSOR_HELP); break; default: -- cgit v1.2.3 From 2cc6d9299ae6a7037704dd72eeebc44ab2c3c1b4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Aug 2014 01:09:29 +0200 Subject: ACCESS: Add a check to work around a difference in hardcoded data between the CD and the floppy version --- engines/access/room.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c26a811225..3696a4cadf 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -162,7 +162,7 @@ void Room::clearRoom() { } void Room::loadRoomData(const byte *roomData) { - RoomInfo roomInfo(roomData, _vm->getGameID()); + RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD()); _roomFlag = roomInfo._roomFlag; @@ -734,14 +734,19 @@ bool Room::checkCode(int v1, int v2) { /*------------------------------------------------------------------------*/ -RoomInfo::RoomInfo(const byte *data, int gameType) { +RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { Common::MemoryReadStream stream(data, 999); _roomFlag = stream.readByte(); - if (gameType != GType_MartianMemorandum) - _estIndex = stream.readSint16LE(); - else + if (gameType == GType_Amazon) { + if (isCD) + _estIndex = stream.readSint16LE(); + else { + _estIndex = -1; + stream.readSint16LE(); + } + } else _estIndex = -1; _musicFile.load(stream); @@ -779,8 +784,7 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { _extraCells.push_back(ec); } - for (int16 fileNum = stream.readSint16LE(); fileNum != -1; - fileNum = stream.readSint16LE()) { + for (int16 fileNum = stream.readSint16LE(); fileNum != -1; fileNum = stream.readSint16LE()) { SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); -- cgit v1.2.3 From c092e0665271541719d34b40da5d856142c42a8e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 20:31:48 -0400 Subject: ACCESS: Fix parameter usage in doEstablish --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3696a4cadf..7df7ca9251 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -171,7 +171,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_establishFlag = true; if (_vm->_establishTable[roomInfo._estIndex] != 1) { _vm->_establishTable[roomInfo._estIndex] = 1; - _vm->establish(0, roomInfo._estIndex); + _vm->establish(roomInfo._estIndex, 0); } } -- cgit v1.2.3 From 2f5fb206d30a77b94aa81feb6b7292c0d3e5e481 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 21:02:22 -0400 Subject: ACCESS: Further cleanup of doEstablish parameters --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 7df7ca9251..3696a4cadf 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -171,7 +171,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_establishFlag = true; if (_vm->_establishTable[roomInfo._estIndex] != 1) { _vm->_establishTable[roomInfo._estIndex] = 1; - _vm->establish(roomInfo._estIndex, 0); + _vm->establish(0, roomInfo._estIndex); } } -- cgit v1.2.3 From 984858b6382de2e2788fca1469fb380b036989ba Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Sep 2014 23:54:31 +0200 Subject: ACCESS: Fix an issue in checkCode --- engines/access/room.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3696a4cadf..2c597609e1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -705,9 +705,10 @@ bool Room::codeWalls() { bool Room::checkCode(int v1, int v2) { Player &p = *_vm->_player; - if (!v1) { - } if (!v2 || (v1 == v2)) { - } else if (v1 & 1) { + if (!v1 || !v2 || (v1 == v2)) + return false; + + if (v1 & 1) { if (v2 & 2) { p._collideFlag = true; return true; -- cgit v1.2.3 From 386aae3ffa60c9ef44181cb730ab947544b2e761 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 13:55:52 -0400 Subject: ACCESS: Workaround for background column rendering bug in original --- engines/access/room.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 2c597609e1..181dcd6c5b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -309,7 +309,10 @@ void Room::buildColumn(int playX, int screenX) { const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; - for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) { + // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns + int h = MIN(_vm->_screen->_vWindowHeight + 1, _playFieldHeight); + + for (int y = 0; y < h; ++y) { byte *pTile = _tile + (*pSrc << 8); byte *pDest = (byte *)_vm->_buffer1.getBasePtr(screenX, y * TILE_HEIGHT); -- cgit v1.2.3 From 21c1d0f920a530b310a68376e9aa8836ed43471b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 14:13:29 -0400 Subject: ACCESS: Workaround for background rendering bug in original --- engines/access/room.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 181dcd6c5b..9b830770af 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -289,14 +289,16 @@ void Room::setWallCodes() { void Room::buildScreen() { int scrollCol = _vm->_screen->_scrollCol; - int cnt = _vm->_screen->_vWindowWidth + 1; int offset = 0; // Clear current background buffer _vm->_buffer1.clearBuffer(); + // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns + int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); + // Loop through drawing each column of tiles forming the background - for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { + for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) { buildColumn(_vm->_screen->_scrollCol, offset); ++_vm->_screen->_scrollCol; } -- cgit v1.2.3 From fb686191a813c633d215f06ca2aadbf3ad9c64ac Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 3 Nov 2014 21:51:11 -0500 Subject: ACCESS: Fix initialisation of Y positioning in rooms with vertical scrolling --- engines/access/room.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9b830770af..76ad29e21a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -267,14 +267,15 @@ void Room::setupRoom() { screen._scrollRow = 0; } else { screen._scrollY = _vm->_player->_rawPlayer.y - - (_vm->_player->_rawPlayer.y >> 4); - int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - + (_vm->_player->_rawPlayer.y / 16) * 16; + int yc = MAX((_vm->_player->_rawPlayer.y >> 4) - (screen._vWindowHeight / 2), 0); - screen._scrollRow = yp; + screen._scrollRow = yc; - yp = yp + screen._vWindowHeight - _playFieldHeight; - if (yp >= 0) { - screen._scrollRow = yp + 1; + yc = yc + screen._vWindowHeight - _playFieldHeight; + if (yc >= 0) { + screen._scrollRow = _playFieldHeight - screen._vWindowHeight; + screen._scrollY = 0; } } } -- cgit v1.2.3 From aea906f7d3c8959337c24ee4507bb245d9f5f744 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 19:16:14 -0500 Subject: ACCESS: Implemented chapter debug command --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 76ad29e21a..c9f4a886a1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -235,7 +235,7 @@ void Room::loadRoomData(const byte *roomData) { } void Room::roomLoop() { - _vm->_scripts->_sequence = 2000; + _vm->_scripts->_sequence = ROOM_SCRIPT; _vm->_scripts->searchForSequence(); _vm->_scripts->executeScript(); } -- cgit v1.2.3 From 876ce794a1545f04aafc1752d2e25d4379fc72ea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 22:53:21 -0500 Subject: ACCESS: Fix crash when exiting game in the middle of a chapter start --- engines/access/room.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c9f4a886a1..02bb3b53c7 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -88,7 +88,10 @@ void Room::doRoom() { _vm->_player->walk(); _vm->_sound->midiRepeat(); _vm->_player->checkScroll(); + doCommands(); + if (_vm->shouldQuit()) + return; // DOROOMFLASHBACK jump point if (_function == FN_CLEAR1) { -- cgit v1.2.3 From 8ef3d551511f2b22c36e2cdbcb50f104eb64871a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 11:19:10 -0500 Subject: ACCESS: Fix scene fade ins --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 02bb3b53c7..e3ac84c231 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -69,12 +69,12 @@ void Room::doRoom() { } reloadFlag = false; - _vm->_startup = 0; + _vm->_startup = 8; _function = 0; while (!_vm->shouldQuit()) { _vm->_images.clear(); - if (_vm->_startup != -1 && --_vm->_startup != 0) { + if (_vm->_startup != -1 && --_vm->_startup == 0) { _vm->_events->showCursor(); _vm->_screen->fadeIn(); } -- cgit v1.2.3 From bbaea32386927c856d22b97c877ddbba41fb142f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 13:54:48 -0500 Subject: ACCESS: Fixes for flying plane cutscene --- engines/access/room.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e3ac84c231..f1e499d1c9 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -126,7 +126,10 @@ void Room::doRoom() { _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; + roomLoop(); + if (_vm->shouldQuit()) + return; if (_function == FN_CLEAR1) { clearRoom(); -- cgit v1.2.3 From 4ce87a51a061c31b0f2db605712ce7e0cab5b5d7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 18:29:15 -0500 Subject: ACCESS: Fix restoring screen after offering a character an inventory item --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f1e499d1c9..e3a46159cf 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -163,6 +163,7 @@ void Room::clearRoom() { _vm->_scripts->freeScriptData(); _vm->freeCells(); freePlayField(); + freeTileData(); _vm->freeInactiveData(); _vm->_player->freeSprites(); } -- cgit v1.2.3 From ea206330813aff730c7af5f1aec931f8720105d9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 22:30:57 -0500 Subject: ACCESS: Fix cutscene of pilot falling out of plane --- engines/access/room.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e3a46159cf..513c1596ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -316,6 +316,9 @@ void Room::buildScreen() { } void Room::buildColumn(int playX, int screenX) { + if (playX < 0 || playX >= _playFieldWidth) + return; + const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; -- cgit v1.2.3 From b2e67a69c6dd53f2ffa720eced127dff97eb856c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Nov 2014 21:42:49 -0500 Subject: ACCESS: Fix incorrect loading of exra cells during room load --- engines/access/room.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 513c1596ac..31d1583c3e 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -796,7 +796,6 @@ RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { ExtraCell ec; ec._vid._fileNum = v; ec._vid._subfile = stream.readSint16LE(); - ec._vidSound.load(stream); _extraCells.push_back(ec); } -- cgit v1.2.3 From a0beb08984b989d6dcb1c9dcbc8bb083e2534891 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 16:15:07 -0500 Subject: ACCESS: Refactor _inactive from AccessEngine to AmazonEngine --- engines/access/room.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 31d1583c3e..37746d1b7c 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -164,7 +164,6 @@ void Room::clearRoom() { _vm->freeCells(); freePlayField(); freeTileData(); - _vm->freeInactiveData(); _vm->_player->freeSprites(); } -- cgit v1.2.3 From 68dc425cd4ba6907be6b1fa46c2251e5715b8803 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 21:13:55 -0500 Subject: ACCESS: Implemented buildRow for vertical screen scrolling --- engines/access/room.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 37746d1b7c..f32bc95ae0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -339,7 +339,27 @@ void Room::buildColumn(int playX, int screenX) { } void Room::buildRow(int playY, int screenY) { - error("TODO: buildRow"); + if (playY < 0 || playY >= _playFieldHeight) + return; + assert(screenY <= (_vm->_screen->h - TILE_HEIGHT)); + + const byte *pSrc = _playField + screenY *_playFieldWidth + _vm->_screen->_scrollCol; + + // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns + int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); + + for (int x = 0; x < w; ++x) { + byte *pTile = _tile + (*pSrc << 8); + byte *pDest = (byte *)_vm->_buffer1.getBasePtr(w * TILE_WIDTH, screenY); + + for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { + Common::copy(pTile, pTile + TILE_WIDTH, pDest); + pTile += TILE_WIDTH; + pDest += _vm->_buffer1.pitch; + } + + ++pSrc; + } } void Room::loadPlayField(int fileNum, int subfile) { -- cgit v1.2.3 From 0cafe2719d56e1acd1b3972737a9f8e031d51136 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Nov 2014 21:02:51 -0500 Subject: ACCESS: Fix for proper vertical scrolling on the ship --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f32bc95ae0..57a5c4a88e 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -343,14 +343,14 @@ void Room::buildRow(int playY, int screenY) { return; assert(screenY <= (_vm->_screen->h - TILE_HEIGHT)); - const byte *pSrc = _playField + screenY *_playFieldWidth + _vm->_screen->_scrollCol; + const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_screen->_scrollCol; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); for (int x = 0; x < w; ++x) { byte *pTile = _tile + (*pSrc << 8); - byte *pDest = (byte *)_vm->_buffer1.getBasePtr(w * TILE_WIDTH, screenY); + byte *pDest = (byte *)_vm->_buffer1.getBasePtr(x * TILE_WIDTH, screenY); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); -- cgit v1.2.3 From bb93268ee21a216162ef077c64462e0ac360df0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 16:56:03 -0500 Subject: ACCESS: Fix left button flag beig stuck after saving & loading games --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 57a5c4a88e..9251db4af4 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -494,6 +494,7 @@ void Room::handleCommand(int commandId) { --commandId; if (commandId == 9) { + _vm->_events->debounceLeft(); _vm->_canSaveLoad = true; _vm->openMainMenuDialog(); _vm->_canSaveLoad = false; -- cgit v1.2.3 From 3be3cb1ac21dcaf8f79907e9ce463c4828cba65c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 21:35:20 -0500 Subject: ACCESS: Cleanup of room _function and river canoe movement --- engines/access/room.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9251db4af4..bc76d48d8d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -29,7 +29,7 @@ namespace Access { Room::Room(AccessEngine *vm) : Manager(vm) { - _function = 0; + _function = FN_NONE; _roomFlag = 0; _playField = nullptr; _playFieldWidth = _playFieldHeight = 0; @@ -70,7 +70,7 @@ void Room::doRoom() { reloadFlag = false; _vm->_startup = 8; - _function = 0; + _function = FN_NONE; while (!_vm->shouldQuit()) { _vm->_images.clear(); @@ -111,7 +111,7 @@ void Room::doRoom() { if (_vm->_player->_scrollFlag) { _vm->copyBF1BF2(); _vm->_newRects.clear(); - _function = 0; + _function = FN_NONE; roomLoop(); if (_function == FN_CLEAR1) { @@ -125,7 +125,7 @@ void Room::doRoom() { } else { _vm->copyBF1BF2(); _vm->_newRects.clear(); - _function = 0; + _function = FN_NONE; roomLoop(); if (_vm->shouldQuit()) -- cgit v1.2.3 From e3322185686f268c0375bcaef93c5ef35209ebdc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 15:06:49 -0500 Subject: ACCESS: Workaround for Exit/walk icon in massacre site scene --- engines/access/room.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index bc76d48d8d..b9ce06959a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -540,19 +540,7 @@ void Room::executeCommand(int commandId) { events.setCursor(CURSOR_TALK); break; case 7: - events._normalMouse = CURSOR_CROSSHAIRS; - events.setCursor(CURSOR_CROSSHAIRS); - _vm->_scripts->_sequence = 5000; - _vm->_scripts->searchForSequence(); - roomMenu(); - _selectCommand = -1; - - _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { - _conFlag = false; - _vm->_scripts->executeScript(); - } - _vm->_boxSelect = true; + walkCursor(); return; case 8: events._normalMouse = CURSOR_HELP; @@ -580,6 +568,25 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; } +void Room::walkCursor() { + EventsManager &events = *_vm->_events; + + events._normalMouse = CURSOR_CROSSHAIRS; + events.setCursor(CURSOR_CROSSHAIRS); + _vm->_scripts->_sequence = 5000; + _vm->_scripts->searchForSequence(); + roomMenu(); + _selectCommand = -1; + + _conFlag = true; + while (_conFlag && !_vm->shouldQuit()) { + _conFlag = false; + _vm->_scripts->executeScript(); + } + + _vm->_boxSelect = true; +} + void Room::commandOff() { _selectCommand = -1; _vm->_events->setCursor(CURSOR_CROSSHAIRS); -- cgit v1.2.3 From 11e920f427312c496b080c280dca7a9eb8b75676 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 07:49:26 +0100 Subject: ACCESS: Split SoundManager and MusicManager --- engines/access/room.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b9ce06959a..7ef3d6937d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -86,7 +86,7 @@ void Room::doRoom() { g_system->delayMillis(5); _vm->_player->walk(); - _vm->_sound->midiRepeat(); + _vm->_midi->midiRepeat(); _vm->_player->checkScroll(); doCommands(); @@ -150,10 +150,10 @@ void Room::doRoom() { } void Room::clearRoom() { - if (_vm->_sound->_music) { - _vm->_sound->stopSong(); - delete _vm->_sound->_music; - _vm->_sound->_music = nullptr; + if (_vm->_midi->_music) { + _vm->_midi->stopSong(); + delete _vm->_midi->_music; + _vm->_midi->_music = nullptr; } _vm->_sound->freeSounds(); @@ -181,11 +181,11 @@ void Room::loadRoomData(const byte *roomData) { } } - _vm->_sound->freeMusic(); + _vm->_midi->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { - _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile); - _vm->_sound->midiPlay(); - _vm->_sound->_musicRepeat = true; + _vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile); + _vm->_midi->midiPlay(); + _vm->_midi->_musicRepeat = true; } _vm->_scaleH1 = roomInfo._scaleH1; -- cgit v1.2.3 From f364782d05cf0772bf2eaa71ea418650e0d9bf27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 08:46:32 +0100 Subject: ACCESS: Some rework in MusicManager --- engines/access/room.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 7ef3d6937d..8ef61a9d68 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -152,8 +152,7 @@ void Room::doRoom() { void Room::clearRoom() { if (_vm->_midi->_music) { _vm->_midi->stopSong(); - delete _vm->_midi->_music; - _vm->_midi->_music = nullptr; + _vm->_midi->freeMusic(); } _vm->_sound->freeSounds(); @@ -183,7 +182,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_midi->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { - _vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile); + _vm->_midi->loadMusic(roomInfo._musicFile); _vm->_midi->midiPlay(); _vm->_midi->_musicRepeat = true; } -- cgit v1.2.3 From 11870c414460d8c9ea70651a979b1842e58569e5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 14:07:09 +0100 Subject: ACCESS: Implement music player (WIP) --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 8ef61a9d68..a5873b2c38 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -184,7 +184,7 @@ void Room::loadRoomData(const byte *roomData) { if (roomInfo._musicFile._fileNum != -1) { _vm->_midi->loadMusic(roomInfo._musicFile); _vm->_midi->midiPlay(); - _vm->_midi->_musicRepeat = true; + _vm->_midi->setLoop(true); } _vm->_scaleH1 = roomInfo._scaleH1; -- cgit v1.2.3 From f9685533292b0301ed9770439e55f39fbc934a7f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 2 Dec 2014 23:50:40 +0100 Subject: ACCESS: Fix RoomInfo for the demo version, fix a typo in a comment --- engines/access/room.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a5873b2c38..97341b04b9 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -167,7 +167,7 @@ void Room::clearRoom() { } void Room::loadRoomData(const byte *roomData) { - RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD()); + RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD(), _vm->isDemo()); _roomFlag = roomInfo._roomFlag; @@ -777,7 +777,7 @@ bool Room::checkCode(int v1, int v2) { /*------------------------------------------------------------------------*/ -RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { +RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD, bool isDemo) { Common::MemoryReadStream stream(data, 999); _roomFlag = stream.readByte(); @@ -787,7 +787,8 @@ RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { _estIndex = stream.readSint16LE(); else { _estIndex = -1; - stream.readSint16LE(); + if (!isDemo) + stream.readSint16LE(); } } else _estIndex = -1; -- cgit v1.2.3 From 84ba0df9b2ce15d6c1d32a6c61794a1accb3fc99 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Dec 2014 14:17:30 +0100 Subject: ACCESS: Janitorial --- engines/access/room.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 97341b04b9..b3c3317307 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -266,7 +266,7 @@ void Room::setupRoom() { screen._scrollCol -= sx + 1; } } - + if (screen._vWindowHeight == _playFieldHeight) { screen._scrollY = 0; screen._scrollRow = 0; @@ -317,7 +317,7 @@ void Room::buildColumn(int playX, int screenX) { if (playX < 0 || playX >= _playFieldWidth) return; - const byte *pSrc = _playField + _vm->_screen->_scrollRow * + const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns @@ -406,7 +406,7 @@ Plotter::Plotter() { void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockCount) { // Load the wall count _walls.resize(wallCount); - + for (int i = 0; i < wallCount; ++i) _walls[i].left = stream->readSint16LE(); for (int i = 0; i < wallCount; ++i) @@ -474,7 +474,7 @@ void Room::doCommands() { } } -void Room::cycleCommand(int incr) { +void Room::cycleCommand(int incr) { int command = _selectCommand + incr; if (command < -1) command = 6; @@ -560,7 +560,7 @@ void Room::executeCommand(int commandId) { delete iconData; // Draw the button as selected - _vm->_screen->plotImage(spr, _selectCommand + 2, + _vm->_screen->plotImage(spr, _selectCommand + 2, Common::Point(RMOUSE[_selectCommand][0], 176)); _vm->_screen->restoreScreen(); @@ -569,7 +569,7 @@ void Room::executeCommand(int commandId) { void Room::walkCursor() { EventsManager &events = *_vm->_events; - + events._normalMouse = CURSOR_CROSSHAIRS; events.setCursor(CURSOR_CROSSHAIRS); _vm->_scripts->_sequence = 5000; @@ -698,7 +698,7 @@ bool Room::codeWalls() { if ((player._rawYTemp >= screen._orgY1) && (player._rawYTemp <= screen._orgY2)) { jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1; - jf._wallCode1 |= (calcLR(player._rawYTemp) - + jf._wallCode1 |= (calcLR(player._rawYTemp) - (player._rawXTemp + player._playerOffset.x)) < 0 ? 2 : 1; } } -- cgit v1.2.3 From 86bee5b48ecbadf9c8f1b4ae2f48c8bcbdf3fce9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 7 Dec 2014 17:53:05 -0500 Subject: ACCESS: Fix function key mapping for game icons --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b3c3317307..a781dab24a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -468,8 +468,8 @@ void Room::doCommands() { mainAreaClick(); } } else if (_vm->_events->getKey(keyState)) { - if (keyState.ascii >= ';' && keyState.ascii <= 'D') { - handleCommand((int)keyState.ascii - ';'); + if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F9) { + handleCommand(keyState.keycode - Common::KEYCODE_F1 + 1); } } } -- cgit v1.2.3 From 8517209bcbef56a1fa68a6e17b04d56c13fa77b2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Dec 2014 23:25:18 +0100 Subject: ACCESS: Implement restart after death --- engines/access/room.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a781dab24a..57332f742d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -90,7 +90,7 @@ void Room::doRoom() { _vm->_player->checkScroll(); doCommands(); - if (_vm->shouldQuit()) + if (_vm->shouldQuitOrRestart()) return; // DOROOMFLASHBACK jump point @@ -128,7 +128,7 @@ void Room::doRoom() { _function = FN_NONE; roomLoop(); - if (_vm->shouldQuit()) + if (_vm->shouldQuitOrRestart()) return; if (_function == FN_CLEAR1) { @@ -578,7 +578,7 @@ void Room::walkCursor() { _selectCommand = -1; _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { + while (_conFlag && !_vm->shouldQuitOrRestart()) { _conFlag = false; _vm->_scripts->executeScript(); } @@ -622,7 +622,7 @@ void Room::checkBoxes3() { _vm->_boxSelect = start; _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { + while (_conFlag && !_vm->shouldQuitOrRestart()) { _conFlag = false; _vm->_scripts->executeScript(); } -- cgit v1.2.3 From 547f3debb2b44dfb8fb3d659ac09f3bd24a017c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Dec 2014 21:27:06 -0500 Subject: ACCESS: Separate timer updates from frame updates, and overall delay cleanup --- engines/access/room.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 57332f742d..e18bd4a329 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -81,9 +81,8 @@ void Room::doRoom() { // Poll for events _vm->_canSaveLoad = true; - _vm->_events->pollEvents(); + _vm->_events->pollEventsAndWait(); _vm->_canSaveLoad = false; - g_system->delayMillis(5); _vm->_player->walk(); _vm->_midi->midiRepeat(); -- cgit v1.2.3 From 27ed5246b8780dc74235478058177abcc1d8e84d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 14 Dec 2014 22:43:01 +0100 Subject: ACCESS: Use the same (weird) key mapping than in the original game --- engines/access/room.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e18bd4a329..b9d13c94cd 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -467,9 +467,10 @@ void Room::doCommands() { mainAreaClick(); } } else if (_vm->_events->getKey(keyState)) { - if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F9) { + if (keyState.keycode == Common::KEYCODE_F1) handleCommand(keyState.keycode - Common::KEYCODE_F1 + 1); - } + else if (keyState.keycode >= Common::KEYCODE_F2 && keyState.keycode <= Common::KEYCODE_F10) + handleCommand(keyState.keycode - Common::KEYCODE_F1); } } -- cgit v1.2.3 From dcc6ceb117549a68a275b5740edea5e5e02030bd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 14 Dec 2014 23:22:54 +0100 Subject: ACCESS: Fix icon when unselecting a menu button --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b9d13c94cd..a33f773bac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -588,6 +588,7 @@ void Room::walkCursor() { void Room::commandOff() { _selectCommand = -1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->setCursor(CURSOR_CROSSHAIRS); roomMenu(); } -- cgit v1.2.3 From 66bf0ec7412949eee758c138be1f81571b1fc56d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 14 Dec 2014 23:51:01 +0100 Subject: ACCESS: Some refactoring concerning the mouse cursor --- engines/access/room.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a33f773bac..f4826090b1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -136,11 +136,11 @@ void Room::doRoom() { } else { _vm->plotList(); - if (_vm->_events->_mousePos.y < 177) { + if (_vm->_events->_mousePos.y < 177) _vm->_events->setCursor(_vm->_events->_normalMouse); - } else { + else _vm->_events->setCursor(CURSOR_ARROW); - } + _vm->copyBlocks(); } } @@ -512,16 +512,13 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - events._normalMouse = CURSOR_LOOK; - events.setCursor(CURSOR_LOOK); + events.forceSetCursor(CURSOR_LOOK); break; case 2: - events._normalMouse = CURSOR_USE; - events.setCursor(CURSOR_USE); + events.forceSetCursor(CURSOR_USE); break; case 3: - events._normalMouse = CURSOR_TAKE; - events.setCursor(CURSOR_TAKE); + events.forceSetCursor(CURSOR_TAKE); break; case 4: events.setCursor(CURSOR_ARROW); @@ -531,19 +528,16 @@ void Room::executeCommand(int commandId) { } break; case 5: - events._normalMouse = CURSOR_CLIMB; - events.setCursor(CURSOR_CLIMB); + events.forceSetCursor(CURSOR_CLIMB); break; case 6: - events._normalMouse = CURSOR_TALK; - events.setCursor(CURSOR_TALK); + events.forceSetCursor(CURSOR_TALK); break; case 7: walkCursor(); return; case 8: - events._normalMouse = CURSOR_HELP; - events.setCursor(CURSOR_HELP); + events.forceSetCursor(CURSOR_HELP); break; default: break; @@ -570,8 +564,7 @@ void Room::executeCommand(int commandId) { void Room::walkCursor() { EventsManager &events = *_vm->_events; - events._normalMouse = CURSOR_CROSSHAIRS; - events.setCursor(CURSOR_CROSSHAIRS); + events.forceSetCursor(CURSOR_CROSSHAIRS); _vm->_scripts->_sequence = 5000; _vm->_scripts->searchForSequence(); roomMenu(); @@ -588,8 +581,7 @@ void Room::walkCursor() { void Room::commandOff() { _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; - _vm->_events->setCursor(CURSOR_CROSSHAIRS); + _vm->_events->forceSetCursor(CURSOR_CROSSHAIRS); roomMenu(); } -- cgit v1.2.3 From 492d974550924522774181cbcfa559c4b7e7b3a1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 18:27:47 +0100 Subject: ACCESS: Some more polishing in the file headers --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f4826090b1..fc9cb6a4a0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -8,12 +8,12 @@ * 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. -- cgit v1.2.3 From 95aa9a13a6ca634af664a3ac4753faf8b8271fd9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 18 Dec 2014 21:45:55 -0500 Subject: ACCESS: Refactor most of ASurface statics to instance variables --- engines/access/room.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index fc9cb6a4a0..f7c2eabd0f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -253,33 +253,33 @@ void Room::setupRoom() { screen.setIconPalette(); if (screen._vWindowWidth == _playFieldWidth) { - screen._scrollX = 0; - screen._scrollCol = 0; + _vm->_scrollX = 0; + _vm->_scrollCol = 0; } else { int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH; - screen._scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; - screen._scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); + _vm->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; + _vm->_scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); - int sx = screen._scrollCol + screen._vWindowWidth - _playFieldWidth; + int sx = _vm->_scrollCol + screen._vWindowWidth - _playFieldWidth; if (sx >= 0) { - screen._scrollCol -= sx + 1; + _vm->_scrollCol -= sx + 1; } } if (screen._vWindowHeight == _playFieldHeight) { - screen._scrollY = 0; - screen._scrollRow = 0; + _vm->_scrollY = 0; + _vm->_scrollRow = 0; } else { - screen._scrollY = _vm->_player->_rawPlayer.y - + _vm->_scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y / 16) * 16; int yc = MAX((_vm->_player->_rawPlayer.y >> 4) - (screen._vWindowHeight / 2), 0); - screen._scrollRow = yc; + _vm->_scrollRow = yc; yc = yc + screen._vWindowHeight - _playFieldHeight; if (yc >= 0) { - screen._scrollRow = _playFieldHeight - screen._vWindowHeight; - screen._scrollY = 0; + _vm->_scrollRow = _playFieldHeight - screen._vWindowHeight; + _vm->_scrollY = 0; } } } @@ -293,7 +293,7 @@ void Room::setWallCodes() { } void Room::buildScreen() { - int scrollCol = _vm->_screen->_scrollCol; + int scrollCol = _vm->_scrollCol; int offset = 0; // Clear current background buffer @@ -304,11 +304,11 @@ void Room::buildScreen() { // Loop through drawing each column of tiles forming the background for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) { - buildColumn(_vm->_screen->_scrollCol, offset); - ++_vm->_screen->_scrollCol; + buildColumn(_vm->_scrollCol, offset); + ++_vm->_scrollCol; } - _vm->_screen->_scrollCol = scrollCol; + _vm->_scrollCol = scrollCol; _vm->copyBF1BF2(); } @@ -316,7 +316,7 @@ void Room::buildColumn(int playX, int screenX) { if (playX < 0 || playX >= _playFieldWidth) return; - const byte *pSrc = _playField + _vm->_screen->_scrollRow * + const byte *pSrc = _playField + _vm->_scrollRow * _playFieldWidth + playX; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns @@ -341,7 +341,7 @@ void Room::buildRow(int playY, int screenY) { return; assert(screenY <= (_vm->_screen->h - TILE_HEIGHT)); - const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_screen->_scrollCol; + const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_scrollCol; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); -- cgit v1.2.3 From d1bc69426eac2458b46ab7fede31c6dd71314ccb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 22 Dec 2014 19:41:40 +0100 Subject: ACCESS: Move variable from Room manager to local function --- engines/access/room.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/access/room.cpp') diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f7c2eabd0f..607259ec6f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -370,9 +370,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]; -- cgit v1.2.3