From 5a7ea9318d54bd725dd2493277dc0daf17f8abb4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 18 Mar 2015 23:01:47 -0400 Subject: SHERLOCK: Refactor Rooms to Scene, added skeletons for Chess and Darts --- engines/sherlock/debugger.cpp | 2 +- engines/sherlock/module.mk | 4 +- engines/sherlock/room.cpp | 34 ----------- engines/sherlock/room.h | 106 ----------------------------------- engines/sherlock/scalpel/chess.cpp | 37 ++++++++++++ engines/sherlock/scalpel/chess.h | 45 +++++++++++++++ engines/sherlock/scalpel/darts.cpp | 36 ++++++++++++ engines/sherlock/scalpel/darts.h | 45 +++++++++++++++ engines/sherlock/scalpel/scalpel.cpp | 69 ++++++++++++----------- engines/sherlock/scalpel/scalpel.h | 10 ++-- engines/sherlock/scene.cpp | 41 ++++++++++++++ engines/sherlock/scene.h | 55 ++++++++++++++++++ engines/sherlock/sherlock.cpp | 8 ++- engines/sherlock/sherlock.h | 4 +- 14 files changed, 310 insertions(+), 186 deletions(-) delete mode 100644 engines/sherlock/room.cpp delete mode 100644 engines/sherlock/room.h create mode 100644 engines/sherlock/scalpel/chess.cpp create mode 100644 engines/sherlock/scalpel/chess.h create mode 100644 engines/sherlock/scalpel/darts.cpp create mode 100644 engines/sherlock/scalpel/darts.h create mode 100644 engines/sherlock/scene.cpp create mode 100644 engines/sherlock/scene.h diff --git a/engines/sherlock/debugger.cpp b/engines/sherlock/debugger.cpp index 50300322ef..1e0716c3d3 100644 --- a/engines/sherlock/debugger.cpp +++ b/engines/sherlock/debugger.cpp @@ -51,7 +51,7 @@ bool Debugger::cmd_scene(int argc, const char **argv) { debugPrintf("Format: scene \n"); return true; } else { - _vm->_rooms->_goToRoom = strToInt(argv[1]); + _vm->_scene->_goToRoom = strToInt(argv[1]); return false; } } diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk index 06186f1504..eef27aa0b1 100644 --- a/engines/sherlock/module.mk +++ b/engines/sherlock/module.mk @@ -1,6 +1,8 @@ MODULE := engines/sherlock MODULE_OBJS = \ + scalpel/chess.o \ + scalpel/darts.o \ scalpel/scalpel.o \ tattoo/tattoo.o \ animation.o \ @@ -11,7 +13,7 @@ MODULE_OBJS = \ graphics.o \ journal.o \ resources.o \ - room.o \ + scene.o \ screen.o \ sherlock.o \ sound.o \ diff --git a/engines/sherlock/room.cpp b/engines/sherlock/room.cpp deleted file mode 100644 index c06d707b40..0000000000 --- a/engines/sherlock/room.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* 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 "sherlock/room.h" - -namespace Sherlock { - -Rooms::Rooms() { - for (int roomNum = 0; roomNum < ROOMS_COUNT; ++roomNum) - Common::fill(&_stats[roomNum][0], &_stats[roomNum][9], false); - _goToRoom = -1; - _oldCharPoint = 0; -} - -} // End of namespace Sherlock diff --git a/engines/sherlock/room.h b/engines/sherlock/room.h deleted file mode 100644 index 0f2bc56a45..0000000000 --- a/engines/sherlock/room.h +++ /dev/null @@ -1,106 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SHERLOCK_ROOM_H -#define SHERLOCK_ROOM_H - -#include "common/scummsys.h" -#include "sherlock/sprite.h" - -namespace Sherlock { - -#define ROOMS_COUNT 63 - -/* -struct RoomBounds { - int x, y, width, height; -}; - -struct BgshapeSub { - uint16 value; -}; - -struct Bgshape { - char name[12]; - char description[41]; - char *textBufferPtr; - byte *seqBufPtr; - Sprite *sprite; - SpriteFrame *spriteFrame; - byte byte05; - byte seqBigCountFlag; - int16 seqIndex; - int16 canimIndex; - int16 x, y; - int16 xIncr, yIncr, - uint16 status; - int16 x2, y2; - int16 width2, height2; - uint16 word02; - uint16 word03; - byte flag; - byte itemValue; - uint16 word01; - uint16 word05; - uint16 stringIndex; - int16 width, height; - uint16 word04; - byte flagsAndIndex; - uint16 frameCount; - byte spriteFlags; - char string1[50]; - byte byte07; - byte byte01; - byte byte02; - int16 boundsX, boundsY; - byte direction; - byte animIndex; - char string2[50]; - byte byte06; - byte seqByte; - uint16 textBufferOfs; - byte byte03; - uint16 framesCopyCount; - byte byte08; - char string3[51]; - uint16 word06; - uint16 word07; - uint16 word08; - uint16 word09; - BgshapeSub subItems[4]; -}; -*/ -class Rooms { -public: - bool _stats[ROOMS_COUNT][9]; - bool _savedStats[ROOMS_COUNT][9]; - int _goToRoom; - Common::Point _bigPos; - Common::Point _overPos; - int _oldCharPoint; -public: - Rooms(); -}; - -} // End of namespace Sherlock - -#endif diff --git a/engines/sherlock/scalpel/chess.cpp b/engines/sherlock/scalpel/chess.cpp new file mode 100644 index 0000000000..95c662dd01 --- /dev/null +++ b/engines/sherlock/scalpel/chess.cpp @@ -0,0 +1,37 @@ +/* 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 "sherlock/scalpel/chess.h" +#include "sherlock/scalpel/scalpel.h" + +namespace Sherlock { + +namespace Scalpel { + +int Chess::doChessBoard() { + // TODO + return 0; +} + +} // End of namespace Scalpel + +} // End of namespace Scalpel diff --git a/engines/sherlock/scalpel/chess.h b/engines/sherlock/scalpel/chess.h new file mode 100644 index 0000000000..70607472c2 --- /dev/null +++ b/engines/sherlock/scalpel/chess.h @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHERLOCK_CHESS_H +#define SHERLOCK_CHESS_H + +namespace Sherlock { + +namespace Scalpel { + +class ScalpelEngine; + +class Chess { +private: + ScalpelEngine *_vm; +public: + Chess(ScalpelEngine *vm) : _vm(vm) {} + + int doChessBoard(); +}; + +} // End of namespace Scalpel + +} // End of namespace Sherlock + +#endif diff --git a/engines/sherlock/scalpel/darts.cpp b/engines/sherlock/scalpel/darts.cpp new file mode 100644 index 0000000000..857ac63f8c --- /dev/null +++ b/engines/sherlock/scalpel/darts.cpp @@ -0,0 +1,36 @@ +/* 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 "sherlock/scalpel/darts.h" +#include "sherlock/scalpel/scalpel.h" + +namespace Sherlock { + +namespace Scalpel { + +void Darts::playDarts() { + // TODO +} + +} // End of namespace Scalpel + +} // End of namespace Scalpel diff --git a/engines/sherlock/scalpel/darts.h b/engines/sherlock/scalpel/darts.h new file mode 100644 index 0000000000..22164156c9 --- /dev/null +++ b/engines/sherlock/scalpel/darts.h @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHERLOCK_DARTS_H +#define SHERLOCK_DARTS_H + +namespace Sherlock { + +namespace Scalpel { + +class ScalpelEngine; + +class Darts { +private: + ScalpelEngine *_vm; +public: + Darts(ScalpelEngine *vm) : _vm(vm) {} + + void playDarts(); +}; + +} // End of namespace Scalpel + +} // End of namespace Sherlock + +#endif diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp index d691bbd8bb..d5f63b9c0d 100644 --- a/engines/sherlock/scalpel/scalpel.cpp +++ b/engines/sherlock/scalpel/scalpel.cpp @@ -29,22 +29,32 @@ namespace Scalpel { ScalpelEngine::ScalpelEngine(OSystem *syst, const SherlockGameDescription *gameDesc) : SherlockEngine(syst, gameDesc) { + _chess = nullptr; + _darts = nullptr; _tempFadeStyle = 0; _chessResult = 0; } +ScalpelEngine::~ScalpelEngine() { + delete _chess; + delete _darts; +} + /** * Game initialization */ void ScalpelEngine::initialize() { SherlockEngine::initialize(); + _chess = new Chess(this); + _darts = new Darts(this); + _flags.resize(100 * 8); _flags[3] = true; // Turn on Alley _flags[39] = true; // Turn on Baker Street - // Starting room - _rooms->_goToRoom = 4; + // Starting scene + _scene->_goToRoom = 4; } /** @@ -151,20 +161,11 @@ bool ScalpelEngine::showOfficeCutscene() { return true; } -int ScalpelEngine::doChessBoard() { - // TODO - return 0; -} - -void ScalpelEngine::playDarts() { - // TODO -} - /** * Starting a scene within the game */ void ScalpelEngine::startScene() { - if (_rooms->_goToRoom == 100 || _rooms->_goToRoom == 98) { + if (_scene->_goToRoom == 100 || _scene->_goToRoom == 98) { // Chessboard selection if (_sound->_musicEnabled) { if (_sound->loadSong(100)) { @@ -173,7 +174,7 @@ void ScalpelEngine::startScene() { } } - _rooms->_goToRoom = doChessBoard(); + _scene->_goToRoom = _chess->doChessBoard(); _sound->freeSong(); _hsavedPos = Common::Point(-1, -1); @@ -186,17 +187,17 @@ void ScalpelEngine::startScene() { // 53: Moorehead's death / subway train // 55: Fade out and exit // 70: Brumwell suicide - switch (_rooms->_goToRoom) { + switch (_scene->_goToRoom) { case 2: case 52: case 53: case 70: - if (_sound->_musicEnabled && _sound->loadSong(_rooms->_goToRoom)) { + if (_sound->_musicEnabled && _sound->loadSong(_scene->_goToRoom)) { if (_sound->_music) _sound->startSong(); } - switch (_rooms->_goToRoom) { + switch (_scene->_goToRoom) { case 2: // Blackwood's capture _res->addToCache("final2.vda", "epilogue.lib"); @@ -265,31 +266,31 @@ void ScalpelEngine::startScene() { } // Except for the Moorehead Murder scene, fade to black first - if (_rooms->_goToRoom != 53) { + if (_scene->_goToRoom != 53) { _events->wait(40); _screen->fadeToBlack(3); } - switch (_rooms->_goToRoom) { + switch (_scene->_goToRoom) { case 52: - _rooms->_goToRoom = 27; // Go to the Lawyer's Office - _rooms->_bigPos = Common::Point(0, 0); // Overland scroll position - _rooms->_overPos = Common::Point(22900 - 600, 9400 + 900); // Overland position - _rooms->_oldCharPoint = 27; + _scene->_goToRoom = 27; // Go to the Lawyer's Office + _scene->_bigPos = Common::Point(0, 0); // Overland scroll position + _scene->_overPos = Common::Point(22900 - 600, 9400 + 900); // Overland position + _scene->_oldCharPoint = 27; break; case 53: - _rooms->_goToRoom = 17; // Go to St. Pancras Station - _rooms->_bigPos = Common::Point(0, 0); // Overland scroll position - _rooms->_overPos = Common::Point(32500 - 600, 3000 + 900); // Overland position - _rooms->_oldCharPoint = 17; + _scene->_goToRoom = 17; // Go to St. Pancras Station + _scene->_bigPos = Common::Point(0, 0); // Overland scroll position + _scene->_overPos = Common::Point(32500 - 600, 3000 + 900); // Overland position + _scene->_oldCharPoint = 17; break; default: - _rooms->_goToRoom = 4; // Back to Baker st. - _rooms->_bigPos = Common::Point(0, 0); // Overland scroll position - _rooms->_overPos = Common::Point(14500 - 600, 8400 + 900); // Overland position - _rooms->_oldCharPoint = 4; + _scene->_goToRoom = 4; // Back to Baker st. + _scene->_bigPos = Common::Point(0, 0); // Overland scroll position + _scene->_overPos = Common::Point(14500 - 600, 8400 + 900); // Overland position + _scene->_oldCharPoint = 4; break; } @@ -310,13 +311,13 @@ void ScalpelEngine::startScene() { _events->loadCursors("rmouse.vgs"); _events->changeCursor(0); - if (_rooms->_goToRoom == 99) { + if (_scene->_goToRoom == 99) { // Chess Board - playDarts(); - _chessResult = _rooms->_goToRoom = 19; // Go back to the bar + _darts->playDarts(); + _chessResult = _scene->_goToRoom = 19; // Go back to the bar } - _chessResult = _rooms->_goToRoom; + _chessResult = _scene->_goToRoom; } } // End of namespace Scalpel diff --git a/engines/sherlock/scalpel/scalpel.h b/engines/sherlock/scalpel/scalpel.h index 83510064fa..b096599ee1 100644 --- a/engines/sherlock/scalpel/scalpel.h +++ b/engines/sherlock/scalpel/scalpel.h @@ -24,6 +24,8 @@ #define SHERLOCK_SCALPEL_H #include "sherlock/sherlock.h" +#include "sherlock/scalpel/chess.h" +#include "sherlock/scalpel/darts.h" namespace Sherlock { @@ -31,6 +33,8 @@ namespace Scalpel { class ScalpelEngine : public SherlockEngine { private: + Chess *_chess; + Darts *_darts; int _tempFadeStyle; int _chessResult; @@ -38,10 +42,6 @@ private: bool showAlleyCutscene(); bool showStreetCutscene(); bool showOfficeCutscene(); - - int doChessBoard(); - - void playDarts(); protected: virtual void initialize(); @@ -50,7 +50,7 @@ protected: virtual void startScene(); public: ScalpelEngine(OSystem *syst, const SherlockGameDescription *gameDesc); - virtual ~ScalpelEngine() {} + virtual ~ScalpelEngine(); }; } // End of namespace Scalpel diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp new file mode 100644 index 0000000000..de351a5561 --- /dev/null +++ b/engines/sherlock/scene.cpp @@ -0,0 +1,41 @@ +/* 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 "sherlock/scene.h" + +namespace Sherlock { + +Scene::Scene(SherlockEngine *vm): _vm(vm) { + for (int idx = 0; idx < SCENES_COUNT; ++idx) + Common::fill(&_stats[idx][0], &_stats[idx][9], false); + _goToRoom = -1; + _oldCharPoint = 0; + _numExits = 0; + + _controlSprites = new Sprite("menu.all"); +} + +Scene::~Scene() { + delete _controlSprites; +} + +} // End of namespace Sherlock diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h new file mode 100644 index 0000000000..031245b122 --- /dev/null +++ b/engines/sherlock/scene.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHERLOCK_SCENE_H +#define SHERLOCK_SCENE_H + +#include "common/scummsys.h" +#include "sherlock/sprite.h" + +namespace Sherlock { + +#define SCENES_COUNT 63 + +class SherlockEngine; + +class Scene { +private: + SherlockEngine *_vm; +public: + bool _stats[SCENES_COUNT][9]; + bool _savedStats[SCENES_COUNT][9]; + int _goToRoom; + Common::Point _bigPos; + Common::Point _overPos; + int _oldCharPoint; + Sprite *_controlSprites; + int _numExits; +public: + Scene(SherlockEngine *vm); + + ~Scene(); +}; + +} // End of namespace Sherlock + +#endif diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 907f0a5a16..8b597df31b 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -35,7 +35,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam _events = nullptr; _journal = nullptr; _res = nullptr; - _rooms = nullptr; + _scene = nullptr; _screen = nullptr; _sound = nullptr; _talk = nullptr; @@ -50,7 +50,7 @@ SherlockEngine::~SherlockEngine() { delete _events; delete _journal; delete _res; - delete _rooms; + delete _scene; delete _screen; delete _sound; delete _talk; @@ -79,7 +79,7 @@ void SherlockEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _journal = new Journal(); - _rooms = new Rooms(); + _scene = new Scene(this); _screen = new Screen(this); _sound = new Sound(this); _talk = new Talk(); @@ -94,6 +94,8 @@ Common::Error SherlockEngine::run() { while (!shouldQuit()) { // Prepare for scene, and handle any game-specific scenes startScene(); + if (shouldQuit()) + break; // TODO: Implement game and remove this dummy loop while (!shouldQuit()) diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h index 7906417d7e..c6023684b4 100644 --- a/engines/sherlock/sherlock.h +++ b/engines/sherlock/sherlock.h @@ -36,7 +36,7 @@ #include "sherlock/events.h" #include "sherlock/journal.h" #include "sherlock/resources.h" -#include "sherlock/room.h" +#include "sherlock/scene.h" #include "sherlock/screen.h" #include "sherlock/sound.h" #include "sherlock/talk.h" @@ -78,7 +78,7 @@ public: EventsManager *_events; Journal *_journal; Resources *_res; - Rooms *_rooms; + Scene *_scene; Screen *_screen; Sound *_sound; Talk *_talk; -- cgit v1.2.3