[Scummvm-git-logs] scummvm master -> 32167c889c9f40631d40f0f2b6b99d5c48c345c9

bluegr noreply at scummvm.org
Sun Apr 21 11:19:00 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
32167c889c MADS: Add stubs for Once Upon a Forest


Commit: 32167c889c9f40631d40f0f2b6b99d5c48c345c9
    https://github.com/scummvm/scummvm/commit/32167c889c9f40631d40f0f2b6b99d5c48c345c9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2024-04-21T14:18:30+03:00

Commit Message:
MADS: Add stubs for Once Upon a Forest

Changed paths:
  A engines/mads/forest/forest_scenes.cpp
  A engines/mads/forest/forest_scenes.h
  A engines/mads/forest/game_forest.cpp
  A engines/mads/forest/game_forest.h
  A engines/mads/forest/globals_forest.cpp
  A engines/mads/forest/globals_forest.h
    engines/mads/animation.cpp
    engines/mads/audio.cpp
    engines/mads/dialogs.cpp
    engines/mads/dragonsphere/game_dragonsphere.h
    engines/mads/game.cpp
    engines/mads/module.mk
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp


diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 4b8dd574b01..946dcac0f02 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -391,6 +391,11 @@ void Animation::loadBackground(MSurface &backSurface, DepthSurface &depthSurface
 		AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
 	if (header._bgType <= ANIMBG_FULL_SIZE) {
+		if (!sceneInfo) {
+			// Sanity check - should never happen, but happens in Forest
+			warning("Animation::loadBackground(): requested to load a background with empty sceneInfo");
+			return;
+		}
 		_vm->_palette->_paletteUsage.setEmpty();
 		sceneInfo->load(header._roomNumber, 0, header._backgroundFile, flags, depthSurface, backSurface);
 		_scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0;
diff --git a/engines/mads/audio.cpp b/engines/mads/audio.cpp
index 987fa77329e..d1f0ae5a410 100644
--- a/engines/mads/audio.cpp
+++ b/engines/mads/audio.cpp
@@ -54,12 +54,15 @@ void AudioPlayer::setDefaultSoundGroup() {
 		setSoundGroup("rex009.dsr");
 		break;
 	case GType_Dragonsphere:
-	case GType_Forest:
 		setSoundGroup("drag009.dsr");
 		break;
 	case GType_Phantom:
 		setSoundGroup("phan009.dsr");
 		break;
+	case GType_Forest:
+		// TODO: Forest doesn't contain DSR files
+		warning("TODO: setSoundGroup for Forest");
+		break;
 	default:
 		error("setDefaultSoundGroup: Unknown game");
 	}
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 95312ee96c5..3074424c26b 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -451,15 +451,21 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...)
 /*------------------------------------------------------------------------*/
 
 Dialogs *Dialogs::init(MADSEngine *vm) {
-	if (vm->getGameID() == GType_RexNebular)
+	switch (vm->getGameID()) {
+	case GType_RexNebular:
 		return new Nebular::DialogsNebular(vm);
-	//else if (vm->getGameID() == GType_Phantom)
-	//	return new Phantom::DialogsPhantom(vm);
-
-	// Throw a warning for now, since the associated Dialogs class isn't implemented yet
-	warning("Dialogs: Unknown game");
-	// HACK: Reuse the implemented Nebular dialogs for now, to avoid crashing later on
-	return new Nebular::DialogsNebular(vm);
+	case GType_Phantom:
+		// return new Phantom::DialogsPhantom(vm);
+	case GType_Dragonsphere:
+		// return new DragonSphere::DialogsDragonSphere(vm);
+	case GType_Forest:
+		// return new Forest::DialogsForest(vm);
+	default:
+		// Throw a warning for now, since the associated Dialogs class isn't implemented yet
+		warning("Dialogs: Unknown game");
+		// HACK: Reuse the implemented Nebular dialogs for now, to avoid crashing later on
+		return new Nebular::DialogsNebular(vm);
+	}
 }
 
 Dialogs::Dialogs(MADSEngine *vm)
diff --git a/engines/mads/dragonsphere/game_dragonsphere.h b/engines/mads/dragonsphere/game_dragonsphere.h
index b5f5e0af92d..0156f0289f2 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.h
+++ b/engines/mads/dragonsphere/game_dragonsphere.h
@@ -135,7 +135,7 @@ typedef Section1Handler Section6Handler;
 typedef Section1Handler Section7Handler;
 typedef Section1Handler Section8Handler;
 
-} // End of namespace Nebular
+} // End of namespace Dragonsphere
 
 } // End of namespace MADS
 
diff --git a/engines/mads/forest/forest_scenes.cpp b/engines/mads/forest/forest_scenes.cpp
new file mode 100644
index 00000000000..c480bb24ff1
--- /dev/null
+++ b/engines/mads/forest/forest_scenes.cpp
@@ -0,0 +1,181 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_MADSV2
+
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/resources.h"
+#include "mads/scene.h"
+#include "mads/forest/game_forest.h"
+#include "mads/forest/forest_scenes.h"
+
+namespace MADS {
+
+namespace Forest {
+
+SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
+	Scene &scene = vm->_game->_scene;
+
+	// TODO
+	//scene.addActiveVocab(NOUN_DROP);
+
+	switch (scene._nextSceneId) {
+	// Scene group #1 (Cornelius's House inside/outside)
+	case 101:	// Cornelius's House inside
+		return new DummyScene(vm);  // TODO
+	case 103:	// Forest, tree
+		return new DummyScene(vm);  // TODO
+	case 104:	// Bedroom
+		return new DummyScene(vm);  // TODO
+	case 106:	// Cornelius's House outside
+		return new DummyScene(vm);	// TODO
+	case 107:	// Tree base
+		return new DummyScene(vm);	// TODO
+	case 199:	// Book
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #2 (Dapplewood Forest Areas 1-4)
+	case 201:	// 
+		return new DummyScene(vm);	// TODO
+	case 203:	// 
+		return new DummyScene(vm);	// TODO
+	case 204:	// 
+		return new DummyScene(vm);	// TODO
+	case 205:	// 
+		return new DummyScene(vm);	// TODO
+	case 210:	// 
+		return new DummyScene(vm);	// TODO
+	case 211:	// 
+		return new DummyScene(vm);	// TODO
+	case 220:	// 
+		return new DummyScene(vm);	// TODO
+	case 221:	// 
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #3 (Dapplewood Nexus)
+	case 301:	// 
+		return new DummyScene(vm);	// TODO
+	case 302:	// 
+		return new DummyScene(vm);	// TODO
+	case 303:	// 
+		return new DummyScene(vm);	// TODO
+	case 304:	// 
+		return new DummyScene(vm);	// TODO
+	case 305:	// 
+		return new DummyScene(vm);	// TODO
+	case 306:	// 
+		return new DummyScene(vm);	// TODO
+	case 307:	// 
+		return new DummyScene(vm);	// TODO
+	case 308:	//
+		return new DummyScene(vm);	// TODO
+	case 321:	//
+		return new DummyScene(vm);	// TODO
+	case 322:	//
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #4 (Yellow Dragons' Lair)
+	case 401:	// 
+		return new DummyScene(vm);	// TODO
+	case 402:	// 
+		return new DummyScene(vm);	// TODO
+	case 403:	// 
+		return new DummyScene(vm);	// TODO
+	case 404:	// 
+		return new DummyScene(vm);	// TODO
+	case 405:	// 
+		return new DummyScene(vm);	// TODO
+	case 420:	// 
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #5 (Meadow & Backtracking)
+	case 501:	// 
+		return new DummyScene(vm);	// TODO
+	case 503:	// 
+		return new DummyScene(vm);	// TODO
+	case 509:	// 
+		return new DummyScene(vm);	// TODO
+	case 510:	// 
+		return new DummyScene(vm);	// TODO
+	case 520:	// 
+		return new DummyScene(vm);	// TODO
+
+	default:
+		error("Invalid scene %d called", scene._nextSceneId);
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+ForestScene::ForestScene(MADSEngine *vm) : SceneLogic(vm),
+		_globals(static_cast<GameForest *>(vm->_game)->_globals),
+		_game(*static_cast<GameForest *>(vm->_game)),
+		_action(vm->_game->_scene._action) {
+}
+
+Common::Path ForestScene::formAnimName(char sepChar, int suffixNum) {
+	return Resources::formatName(_scene->_currentSceneId, sepChar, suffixNum,
+		EXT_NONE, "");
+}
+
+/*------------------------------------------------------------------------*/
+
+void SceneInfoForest::loadCodes(BaseSurface &depthSurface, int variant) {
+	Common::String ext = Common::String::format(".WW%d", variant);
+	Common::Path fileName = Resources::formatName(RESPREFIX_RM, _sceneId, ext);
+	if (!Common::File::exists(fileName))
+		return;
+
+	File f(fileName);
+	MadsPack codesPack(&f);
+	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
+
+	loadCodes(depthSurface, stream);
+
+	delete stream;
+	f.close();
+}
+
+void SceneInfoForest::loadCodes(BaseSurface &depthSurface, Common::SeekableReadStream *stream) {
+	byte *destP = (byte *)depthSurface.getPixels();
+	byte *walkMap = new byte[stream->size()];
+	stream->read(walkMap, stream->size());
+
+	for (int y = 0; y < 156; ++y) {
+		for (int x = 0; x < 320; ++x) {
+			int offset = x + (y * 320);
+			if ((walkMap[offset / 8] << (offset % 8)) & 0x80)
+				*destP++ = 1;		// walkable
+			else
+				*destP++ = 0;
+		}
+	}
+
+	delete[] walkMap;
+}
+
+} // End of namespace Forest
+
+} // End of namespace MADS
+
+#endif
diff --git a/engines/mads/forest/forest_scenes.h b/engines/mads/forest/forest_scenes.h
new file mode 100644
index 00000000000..e75409f272e
--- /dev/null
+++ b/engines/mads/forest/forest_scenes.h
@@ -0,0 +1,241 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_MADSV2
+
+#ifndef MADS_FOREST_SCENES_H
+#define MADS_FOREST_SCENES_H
+
+#include "mads/scene.h"
+#include "mads/forest/game_forest.h"
+#include "mads/forest/globals_forest.h"
+
+namespace MADS {
+
+namespace Forest {
+
+enum Verb {
+	VERB_LOOK = 0x3,
+	VERB_TAKE = 0x4,
+	VERB_PUSH = 0x5,
+	VERB_OPEN = 0x6,
+	VERB_PUT = 0x7,
+	VERB_TALK_TO = 0x8,
+	VERB_GIVE = 0x9,
+	VERB_PULL = 0xa,
+	VERB_CLOSE = 0xb,
+	VERB_THROW = 0xc,
+	VERB_WALK_TO = 0xd,
+	VERB_ATTACK = 0x43,
+	VERB_CARVE_UP = 0x4c,
+	VERB_CLICK_ON = 0x4e,
+	VERB_CLIMB_DOWN = 0x50,
+	VERB_CLIMB_UP = 0x51,
+	VERB_DOWN_PAGE = 0x5a,
+	VERB_EAT = 0x5b,
+	VERB_INVOKE = 0x6c,
+	VERB_LOOK_AT = 0x72,
+	VERB_MAKE_NOISE = 0x73,
+	VERB_POLISH = 0x80,
+	VERB_RUB = 0x88,
+	VERB_THRUST = 0x98,
+	VERB_TIE = 0x99,
+	VERB_UP_PAGE = 0x9c,
+	VERB_USE = 0x9d,
+	VERB_WALK = 0x9f,
+	VERB_WALK_DOWN = 0xa0,
+	VERB_WEAR = 0xa1
+};
+
+enum Noun {
+	NOUN_GAME = 0x1,
+	NOUN_QSAVE = 0x2,
+	NOUN_OWL_TREE = 0x40,
+	NOUN_ABI_BUBBLE = 0x41,
+	NOUN_ALL_BUBBLE = 0x42,
+	NOUN_BEDROOM = 0x44,
+	NOUN_BIRD_FIGURINE = 0x45,
+	NOUN_BIRDCALL = 0x46,
+	NOUN_BOOK = 0x47,
+	NOUN_BOOKCASE = 0x48,
+	NOUN_BOOKS = 0x49,
+	NOUN_BOOKSHELF = 0x4a,
+	NOUN_BUSH = 0x4b,
+	NOUN_CHICORY = 0x4d,
+	NOUN_CLIFF = 0x4f,
+	NOUN_COMFREY = 0x52,
+	NOUN_DANDELION = 0x53,
+	NOUN_DOOR = 0x54,
+	NOUN_DOOR_1 = 0x55,
+	NOUN_DOOR_2 = 0x56,
+	NOUN_DOOR_3 = 0x57,
+	NOUN_DOOR_4 = 0x58,
+	NOUN_DOOR_5 = 0x59,
+	NOUN_EDGE_OF_CLIFF = 0x5c,
+	NOUN_ELM_LEAVES = 0x5d,
+	NOUN_EXIT_JOURNAL = 0x5e,
+	NOUN_EYEBRIGHT = 0x5f,
+	NOUN_FEATHER = 0x60,
+	NOUN_FIVE = 0x61,
+	NOUN_FLOOR = 0x62,
+	NOUN_FLOWERS = 0x63,
+	NOUN_FOREST = 0x64,
+	NOUN_FORKED_STICK = 0x65,
+	NOUN_FOUR = 0x66,
+	NOUN_FOXGLOVE = 0x67,
+	NOUN_FROG = 0x68,
+	NOUN_GEARS = 0x69,
+	NOUN_GROUND = 0x6a,
+	NOUN_HOLE = 0x6b,
+	NOUN_IVY_LEAF = 0x6d,
+	NOUN_JOURNAL = 0x6e,
+	NOUN_LABORATORY = 0x6f,
+	NOUN_LEAVES = 0x70,
+	NOUN_LILY_PAD = 0x71,
+	NOUN_MAP = 0x74,
+	NOUN_MARSH = 0x75,
+	NOUN_MINT = 0x76,
+	NOUN_MOSS = 0x77,
+	NOUN_MUSHROOM = 0x78,
+	NOUN_NEEDLE = 0x79,
+	NOUN_NOTHING = 0x7a,
+	NOUN_ONE = 0x7b,
+	NOUN_OVERHANGING_GRASS = 0x7c,
+	NOUN_PEBBLES = 0x7d,
+	NOUN_PICK_UP = 0x7e,
+	NOUN_PLANT = 0x7f,
+	NOUN_POND = 0x81,
+	NOUN_POSTER = 0x82,
+	NOUN_PRIMROSE = 0x83,
+	NOUN_REEDS = 0x84,
+	NOUN_RIVER = 0x85,
+	NOUN_ROCKS = 0x86,
+	NOUN_ROPE = 0x87,
+	NOUN_RUBBER_BAND = 0x89,
+	NOUN_SANCTUARY_WOODS = 0x8a,
+	NOUN_SHIELDSTONE = 0x8b,
+	NOUN_SIGNET_RING = 0x8c,
+	NOUN_SIX = 0x8d,
+	NOUN_SNAPDRAGON = 0x8e,
+	NOUN_SPIDER_SILK = 0x8f,
+	NOUN_STAIRS = 0x90,
+	NOUN_STICKS = 0x91,
+	NOUN_SUNFLOWER = 0x92,
+	NOUN_SWORD = 0x93,
+	NOUN_TABLE = 0x94,
+	NOUN_TELESCOPE = 0x95,
+	NOUN_THISTLE = 0x96,
+	NOUN_THREE = 0x97,
+	NOUN_TWINE = 0x9a,
+	NOUN_TWO = 0x9b,
+	NOUN_VINE_WEED = 0x9e,
+	NOUN_WEASEL = 0xa2,
+	NOUN_WEB = 0xa3,
+	NOUN_WOOD = 0xa4,
+	NOUN_WOODS = 0xa5,
+	NOUN_WRENCH = 0xa6,
+	NOUN_Y_STICK = 0xa7,
+	NOUN_ABIGAIL = 0xa8,
+	NOUN_EDGAR = 0xa9,
+	NOUN_RUSSEL = 0xaa,
+	NOUN_SNAPDRAGON2 = 0xab,
+	NOUN_LUNGWORT = 0xac,
+	NOUN_GRASS = 0xad,
+	NOUN_FWT = 0xae,
+	NOUN_DRAGON1 = 0xaf,
+	NOUN_DRAGON2 = 0xb0,
+	NOUN_NEST = 0xb1,
+	NOUN_PAINT_CAN = 0xb2,
+	NOUN_DAM = 0xb3,
+	NOUN_BROWN = 0xb4,
+	NOUN_TURTLE = 0xb5,
+	NOUN_DRAGONFLY = 0xb6,
+	NOUN_FENWICK = 0xb7,
+	NOUN_BLUE_BIRD = 0xb8,
+	NOUN_BLACK_BIRD = 0xb9,
+	NOUN_LEVER = 0xba,
+	NOUN_ROCK = 0xbb,
+	NOUN_USED_IT = 0xbc,
+	NOUN_TAIL = 0xbd
+};
+
+class SceneFactory {
+public:
+	static SceneLogic *createScene(MADSEngine *vm);
+};
+
+/**
+ * Specialized base class for Forest game scenes
+ */
+class ForestScene : public SceneLogic {
+protected:
+	ForestGlobals &_globals;
+	GameForest &_game;
+	MADSAction &_action;
+
+	/**
+	 * Forms an animation resource name
+	 */
+	Common::Path formAnimName(char sepChar, int suffixNum);
+
+	/**
+	 * Plays appropriate sound for entering varous rooms
+	 */
+	void lowRoomsEntrySound();
+public:
+	/**
+	 * Constructor
+	 */
+	ForestScene(MADSEngine *vm);
+};
+
+class SceneInfoForest : public SceneInfo {
+	friend class SceneInfo;
+protected:
+	void loadCodes(BaseSurface &depthSurface, int variant) override;
+
+	void loadCodes(BaseSurface &depthSurface, Common::SeekableReadStream *stream) override;
+
+	/**
+	* Constructor
+	*/
+	SceneInfoForest(MADSEngine *vm) : SceneInfo(vm) {}
+};
+
+// TODO: Temporary, remove once implemented properly
+class DummyScene : public ForestScene {
+public:
+	DummyScene(MADSEngine *vm) : ForestScene(vm) {
+		warning("Unimplemented scene");
+	}
+
+	void setup() override {}
+	void enter() override {}
+	void actions() override {}
+};
+
+} // End of namespace Forest
+
+} // End of namespace MADS
+
+#endif /* MADS_FOREST_SCENES_H */
+
+#endif
diff --git a/engines/mads/forest/game_forest.cpp b/engines/mads/forest/game_forest.cpp
new file mode 100644
index 00000000000..0cad71ae52a
--- /dev/null
+++ b/engines/mads/forest/game_forest.cpp
@@ -0,0 +1,165 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_MADSV2
+
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/game.h"
+#include "mads/screen.h"
+#include "mads/msurface.h"
+#include "mads/forest/game_forest.h"
+//#include "mads/nebular/dialogs_nebular.h"
+#include "mads/forest/globals_forest.h"
+//#include "mads/forest/forest_scenes.h"
+
+namespace MADS {
+
+namespace Forest {
+
+GameForest::GameForest(MADSEngine *vm)
+	: Game(vm) {
+	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+	_storyMode = STORYMODE_NAUGHTY;
+}
+
+void GameForest::startGame() {
+	_scene._priorSceneId = 0;
+	_scene._currentSceneId = -1;
+	_scene._nextSceneId = 101;
+
+	initializeGlobals();
+}
+
+void GameForest::initializeGlobals() {
+	//int count, count2;
+	//int bad;
+
+	_globals.reset();
+	//_globals[kTalkInanimateCount] = 8;
+
+	/* Section #1 variables */
+	// TODO
+
+	/* Section #2 variables */
+	// TODO
+
+	/* Section #3 variables */
+	// TODO
+
+	/* Section #4 variables */
+	// TODO
+
+	/* Section #5 variables */
+	// TODO
+
+	/* Section #6 variables */
+	// TODO
+
+	/* Section #9 variables */
+	// TODO
+
+	_player._facing = FACING_NORTH;
+	_player._turnToFacing = FACING_NORTH;
+
+	//Player::preloadSequences("RXM", 1);
+	//Player::preloadSequences("ROX", 1);
+}
+
+void GameForest::setSectionHandler() {
+	delete _sectionHandler;
+
+	switch (_sectionNumber) {
+	case 1:
+		_sectionHandler = new Section1Handler(_vm);
+		break;
+	case 2:
+		_sectionHandler = new Section2Handler(_vm);
+		break;
+	case 3:
+		_sectionHandler = new Section3Handler(_vm);
+		break;
+	case 4:
+		_sectionHandler = new Section4Handler(_vm);
+		break;
+	case 5:
+		_sectionHandler = new Section5Handler(_vm);
+		break;
+	case 6:
+		_sectionHandler = new Section6Handler(_vm);
+		break;
+	case 7:
+		_sectionHandler = new Section7Handler(_vm);
+		break;
+	case 8:
+		_sectionHandler = new Section8Handler(_vm);
+		break;
+	default:
+		break;
+	}
+}
+
+void GameForest::checkShowDialog() {
+	// TODO: Copied from Nebular
+	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[5]) {
+		_player.releasePlayerSprites();
+		_vm->_dialogs->showDialog();
+		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
+	}
+}
+
+void GameForest::doObjectAction() {
+	// TODO: Copied from Nebular
+	//Scene &scene = _scene;
+	MADSAction &action = _scene._action;
+	//Dialogs &dialogs = *_vm->_dialogs;
+	//int id;
+
+	action._inProgress = false;
+}
+
+void GameForest::unhandledAction() {
+	// TODO
+}
+
+void GameForest::step() {
+	if (_player._visible && _player._stepEnabled && !_player._moving &&
+		(_player._facing == _player._turnToFacing)) {
+
+		// TODO
+	}
+
+}
+
+void GameForest::synchronize(Common::Serializer &s, bool phase1) {
+	Game::synchronize(s, phase1);
+
+	// TODO: Copied from Nebular
+	if (!phase1) {
+		_globals.synchronize(s);
+	}
+}
+
+} // End of namespace Forest
+
+} // End of namespace MADS
+
+#endif
diff --git a/engines/mads/forest/game_forest.h b/engines/mads/forest/game_forest.h
new file mode 100644
index 00000000000..77d0c48a28d
--- /dev/null
+++ b/engines/mads/forest/game_forest.h
@@ -0,0 +1,111 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_MADSV2
+
+#ifndef MADS_GAME_FOREST_H
+#define MADS_GAME_FOREST_H
+
+#include "mads/game.h"
+#include "mads/globals.h"
+#include "mads/forest/globals_forest.h"
+
+namespace MADS {
+
+namespace Forest {
+
+// TODO: Adapt for Forest's difficulty setting
+enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
+
+enum InventoryObject {
+	OBJ_NONE = -1,
+	OBJ_GEARS = 0,
+	OBJ_RUBBER_BAND = 1,
+	OBJ_FEATHER = 2,
+	OBJ_NEEDLE = 3,
+	OBJ_LILY_PAD = 4,
+	OBJ_PEBBLES = 5,
+	OBJ_REEDS = 6,
+	OBJ_STICKS = 7,
+	OBJ_TWINE = 8,
+	OBJ_VINE_WEED = 9,
+	OBJ_WEB = 10,
+	OBJ_WOOD = 11,
+	OBJ_LEAVES = 12,
+	OBJ_WRENCH = 13,
+	OBJ_Y_STICK = 14,
+	OBJ_FORKED_STICK = 15
+};
+
+class GameForest : public Game {
+	friend class Game;
+protected:
+	GameForest(MADSEngine *vm);
+
+	void startGame() override;
+
+	void initializeGlobals() override;
+
+	void setSectionHandler() override;
+
+	void checkShowDialog() override;
+public:
+	ForestGlobals _globals;
+	StoryMode _storyMode;
+
+	Globals &globals() override { return _globals; }
+
+	void doObjectAction() override;
+
+	void unhandledAction() override;
+
+	void step() override;
+
+	void synchronize(Common::Serializer &s, bool phase1) override;
+};
+
+
+class Section1Handler : public SectionHandler {
+public:
+	Section1Handler(MADSEngine *vm) : SectionHandler(vm) {}
+
+	// TODO: Properly implement handler methods
+	void preLoadSection() override {}
+	void sectionPtr2() override {}
+	void postLoadSection() override {}
+};
+
+// TODO: Properly implement handler classes
+typedef Section1Handler Section2Handler;
+typedef Section1Handler Section3Handler;
+typedef Section1Handler Section4Handler;
+typedef Section1Handler Section5Handler;
+typedef Section1Handler Section6Handler;
+typedef Section1Handler Section7Handler;
+typedef Section1Handler Section8Handler;
+
+} // End of namespace Forest
+
+} // End of namespace MADS
+
+#endif /* MADS_GAME_FOREST_H */
+
+#endif
diff --git a/engines/mads/forest/globals_forest.cpp b/engines/mads/forest/globals_forest.cpp
new file mode 100644
index 00000000000..46f49417aaa
--- /dev/null
+++ b/engines/mads/forest/globals_forest.cpp
@@ -0,0 +1,52 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_MADSV2
+
+#include "mads/forest/globals_forest.h"
+
+namespace MADS {
+
+namespace Forest {
+
+ForestGlobals::ForestGlobals()
+	: Globals() {
+	// Initialize lists
+	resize(140);
+	_spriteIndexes.resize(30);
+	_sequenceIndexes.resize(30);
+	_animationIndexes.resize(30);
+}
+
+void ForestGlobals::synchronize(Common::Serializer &s) {
+	Globals::synchronize(s);
+
+	_spriteIndexes.synchronize(s);
+	_sequenceIndexes.synchronize(s);
+	_animationIndexes.synchronize(s);
+}
+
+
+} // End of namespace Forest
+
+} // End of namespace MADS
+
+#endif
diff --git a/engines/mads/forest/globals_forest.h b/engines/mads/forest/globals_forest.h
new file mode 100644
index 00000000000..8032e5ba8fa
--- /dev/null
+++ b/engines/mads/forest/globals_forest.h
@@ -0,0 +1,64 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef ENABLE_MADSV2
+
+#ifndef MADS_GLOBALS_FOREST_H
+#define MADS_GLOBALS_FOREST_H
+
+#include "mads/game.h"
+#include "mads/resources.h"
+
+namespace MADS {
+
+namespace Forest {
+
+enum GlobalId {
+	// Global variables
+
+	kWalkerTiming           = 0,
+	kWalkerTiming2			= 1
+	};
+
+class ForestGlobals : public Globals {
+public:
+	SynchronizedList _spriteIndexes;
+	SynchronizedList _sequenceIndexes;
+	SynchronizedList _animationIndexes;
+public:
+	/**
+	 * Constructor
+	 */
+	ForestGlobals();
+
+	/**
+	* Synchronize the globals data
+	*/
+	virtual void synchronize(Common::Serializer &s);
+};
+
+} // End of namespace Forest
+
+} // End of namespace MADS
+
+#endif /* MADS_GLOBALS_FOREST_H */
+
+#endif
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 7e32a04ffe1..92445c576da 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -34,6 +34,7 @@
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/dragonsphere/game_dragonsphere.h"
+#include "mads/forest/game_forest.h"
 #include "mads/nebular/game_nebular.h"
 #include "mads/phantom/game_phantom.h"
 
@@ -48,9 +49,11 @@ Game *Game::init(MADSEngine *vm) {
 		return new Dragonsphere::GameDragonsphere(vm);
 	case GType_Phantom:
 		return new Phantom::GamePhantom(vm);
+	case GType_Forest:
+		return new Forest::GameForest(vm);
 #endif
 	default:
-		error("Game: Unknown game");
+		error("Game::init(): Unknown game");
 	}
 
 	return nullptr;
@@ -91,6 +94,10 @@ Game::Game(MADSEngine *vm)
 
 	// Load the quotes
 	loadQuotes();
+
+	// HACK for Forest
+	if (_vm->getGameID() == GType_Forest)
+		_aaName = "DISP_ED1.AA";
 }
 
 Game::~Game() {
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 9d80ac35ff6..69daf80be8d 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -5,6 +5,9 @@ MODULE_OBJS := \
 	dragonsphere/dragonsphere_scenes.o \
 	dragonsphere/dragonsphere_scenes1.o \
 	dragonsphere/globals_dragonsphere.o \
+	forest/game_forest.o \
+	forest/forest_scenes.o \
+	forest/globals_forest.o \
 	phantom/game_phantom.o \
 	phantom/globals_phantom.o \
 	phantom/phantom_scenes.o \
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 8e417fc4bdc..2d39c41e768 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -25,6 +25,7 @@
 #include "mads/mads.h"
 #include "mads/audio.h"
 #include "mads/dragonsphere/dragonsphere_scenes.h"
+#include "mads/forest/forest_scenes.h"
 #include "mads/nebular/nebular_scenes.h"
 #include "mads/phantom/phantom_scenes.h"
 
@@ -135,6 +136,9 @@ void Scene::loadSceneLogic() {
 	case GType_Phantom:
 		_sceneLogic = Phantom::SceneFactory::createScene(_vm);
 		break;
+	case GType_Forest:
+		_sceneLogic = Forest::SceneFactory::createScene(_vm);
+		break;
 #endif
 	default:
 		error("Scene logic: Unknown game");
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 2ac264e651a..04143046e5b 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -26,6 +26,7 @@
 #include "mads/screen.h"
 #include "mads/resources.h"
 #include "mads/dragonsphere/dragonsphere_scenes.h"
+#include "mads/forest/forest_scenes.h"
 #include "mads/nebular/nebular_scenes.h"
 #include "mads/phantom/phantom_scenes.h"
 
@@ -120,6 +121,8 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) {
 		return new Dragonsphere::SceneInfoDragonsphere(vm);
 	case GType_Phantom:
 		return new Phantom::SceneInfoPhantom(vm);
+	case GType_Forest:
+		return new Forest::SceneInfoForest(vm);
 #endif
 	default:
 		error("SceneInfo: Unknown game");




More information about the Scummvm-git-logs mailing list