[Scummvm-cvs-logs] SF.net SVN: scummvm:[48039] scummvm/trunk/engines/m4

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sat Feb 13 12:49:18 CET 2010


Revision: 48039
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48039&view=rev
Author:   dreammaster
Date:     2010-02-13 11:49:18 +0000 (Sat, 13 Feb 2010)

Log Message:
-----------
Added the beginnings of scene set-up logic

Modified Paths:
--------------
    scummvm/trunk/engines/m4/globals.cpp
    scummvm/trunk/engines/m4/globals.h
    scummvm/trunk/engines/m4/graphics.cpp
    scummvm/trunk/engines/m4/graphics.h
    scummvm/trunk/engines/m4/module.mk
    scummvm/trunk/engines/m4/resource.cpp
    scummvm/trunk/engines/m4/resource.h
    scummvm/trunk/engines/m4/scene.cpp
    scummvm/trunk/engines/m4/scene.h
    scummvm/trunk/engines/m4/sound.cpp
    scummvm/trunk/engines/m4/sound.h

Added Paths:
-----------
    scummvm/trunk/engines/m4/mads_logic.cpp
    scummvm/trunk/engines/m4/mads_logic.h

Modified: scummvm/trunk/engines/m4/globals.cpp
===================================================================
--- scummvm/trunk/engines/m4/globals.cpp	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/globals.cpp	2010-02-13 11:49:18 UTC (rev 48039)
@@ -278,6 +278,8 @@
 
 MadsGlobals::MadsGlobals(MadsEngine *vm): Globals(vm) {
 	_vm = vm;
+
+	playerSpriteChanged = false;
 }
 
 MadsGlobals::~MadsGlobals() {
@@ -408,6 +410,29 @@
 	return (char*)buffer;
 }
 
+/**
+ * Adds the specified scene number to list of scenes previously visited 
+ */
+void MadsGlobals::addVisitedScene(int sceneNumber) {
+	if (!isSceneVisited(sceneNumber))
+		_visitedScenes.push_back(sceneNumber);
+}
+
+/**
+ * Returns true if the specified scene has been previously visited
+ */
+bool MadsGlobals::isSceneVisited(int sceneNumber) {
+	Common::List<int>::iterator i;
+	for (i = _visitedScenes.begin(); i != _visitedScenes.end(); ++i)
+		if (*i == sceneNumber)
+			return true;
+	return false;
+}
+
+void MadsGlobals::removeVisitedScene(int sceneNumber) {
+	_visitedScenes.remove(sceneNumber);
+}
+
 /*--------------------------------------------------------------------------*/
 
 M4Globals::M4Globals(M4Engine *vm): Globals(vm) {

Modified: scummvm/trunk/engines/m4/globals.h
===================================================================
--- scummvm/trunk/engines/m4/globals.h	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/globals.h	2010-02-13 11:49:18 UTC (rev 48039)
@@ -206,6 +206,8 @@
 	bool invSuppressClickSound;
 };
 
+enum RexPlayerSex { SEX_MALE = 0, SEX_FEMALE = 2, SEX_UNKNOWN = 1};
+
 class MadsGlobals : public Globals {
 private:
 	struct MessageItem {
@@ -220,15 +222,18 @@
 	Common::Array<char* > _madsQuotes;
 	Common::Array<MessageItem* > _madsMessages;
 	MadsObjectArray _madsObjects;
+	Common::List<int> _visitedScenes;
 public:
 	MadsGlobals(MadsEngine *vm);
 	~MadsGlobals();
 
 	// MADS variables
+	int _globals[TOTAL_NUM_VARIABLES];
 	bool easyMouse;
 	bool invObjectsStill;
 	bool textWindowStill;
 	int storyMode;
+	bool playerSpriteChanged;
 
 	void loadMadsVocab();
 	uint32 getVocabSize() { return _madsVocab.size(); }
@@ -250,6 +255,10 @@
 	void loadMadsObjects();
 	uint32 getObjectsSize() { return _madsObjects.size(); }
 	MadsObject *getObject(uint32 index) { return _madsObjects[index].get(); }
+
+	void addVisitedScene(int sceneNumber);
+	bool isSceneVisited(int sceneNumber);
+	void removeVisitedScene(int sceneNumber);
 };
 
 #define PLAYER_FIELD_LENGTH 40

Modified: scummvm/trunk/engines/m4/graphics.cpp
===================================================================
--- scummvm/trunk/engines/m4/graphics.cpp	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/graphics.cpp	2010-02-13 11:49:18 UTC (rev 48039)
@@ -767,6 +767,11 @@
 	reset();
 }
 
+void Palette::setEntry(uint index, uint8 r, uint8 g, uint8 b) {
+	uint32 c = (r << 16) | (g << 8) || b;
+	g_system->setPalette((const byte *)&c, index, 1);
+}
+
 uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
 	byte index = 0;
 	int32 minDist = 0x7fffffff;

Modified: scummvm/trunk/engines/m4/graphics.h
===================================================================
--- scummvm/trunk/engines/m4/graphics.h	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/graphics.h	2010-02-13 11:49:18 UTC (rev 48039)
@@ -190,6 +190,7 @@
 	void grabPalette(RGB8 *colors, uint start, uint num) {
 		grabPalette((byte *)colors, start, num);
 	}
+	void setEntry(uint index, uint8 r, uint8 g, uint8 b);
 	uint8 palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData = NULL);
 
 	void fadeToGreen(int numSteps, uint delayAmount);

Added: scummvm/trunk/engines/m4/mads_logic.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_logic.cpp	                        (rev 0)
+++ scummvm/trunk/engines/m4/mads_logic.cpp	2010-02-13 11:49:18 UTC (rev 48039)
@@ -0,0 +1,108 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "m4/m4.h"
+#include "m4/mads_logic.h"
+#include "m4/scene.h"
+
+namespace M4 {
+
+/*--------------------------------------------------------------------------*/
+
+const char *MadsSceneLogic::formAnimName(char sepChar, int suffixNum) {
+	return MADSResourceManager::getResourceName(sepChar, _sceneNumber, EXTTYPE_NONE, NULL, suffixNum);
+}
+
+void MadsSceneLogic::getSceneSpriteSet() {
+	char *setName = _madsVm->scene()->_playerSpriteName;
+	char oldName[100];
+	strcpy(oldName, setName);
+
+	// Room change sound
+	_madsVm->_sound->playSound(5);
+
+	// Set up sprite set prefix to use
+	if ((_sceneNumber <= 103) || (_sceneNumber == 111)) {
+		if (_madsVm->globals()->_globals[0] == SEX_FEMALE)
+			strcpy(setName, "ROX");
+		else
+			strcpy(setName, "RXM");
+	} else if (_sceneNumber <= 110) {
+		strcpy(setName, "RXSW");
+		_madsVm->globals()->_globals[0] = SEX_UNKNOWN;
+	} else if (_sceneNumber == 112)
+		strcpy(setName, "");
+
+	if (strcmp(setName, oldName) != 0)
+		_madsVm->globals()->playerSpriteChanged = true;
+
+	if ((_sceneNumber == 105)/* || ((_sceneNumber == 109) && (word_84800 != 0))*/)
+		_madsVm->globals()->playerSpriteChanged = true;
+
+	_vm->_palette->setEntry(16, 0x38, 0xFF, 0xFF);
+	_vm->_palette->setEntry(17, 0x38, 0xb4, 0xb4);
+}
+
+void MadsSceneLogic::getAnimName() {
+	const char *newName = MADSResourceManager::getAAName(
+		((_sceneNumber <= 103) || (_sceneNumber > 111)) ? 0 : 1);
+	strcpy(_madsVm->scene()->_aaName, newName);
+}
+
+/*--------------------------------------------------------------------------*/
+
+/**
+ * FIXME:
+ * Currently I'm only working at providing manual implementation of the first Rex Nebular scene.
+ * It will make more sense to convert the remaining game logic from the games into some
+ * kind of bytecode scripts
+ */
+
+void MadsSceneLogic::selectScene(int sceneNum) {
+	assert(sceneNum == 101);
+	_sceneNumber = sceneNum;
+
+
+}
+
+void MadsSceneLogic::setupScene() {
+	// FIXME: This is the hardcoded logic for Rex scene 101 only
+	const char *animName = formAnimName('A', -1);
+warning("anim - %s\n", animName);	
+//	sub_1e754(animName, 3);
+
+	getSceneSpriteSet();
+	getAnimName();
+}
+
+void MadsSceneLogic::enterScene() {
+
+}
+
+void MadsSceneLogic::doAction() {
+
+}
+
+}


Property changes on: scummvm/trunk/engines/m4/mads_logic.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/engines/m4/mads_logic.h
===================================================================
--- scummvm/trunk/engines/m4/mads_logic.h	                        (rev 0)
+++ scummvm/trunk/engines/m4/mads_logic.h	2010-02-13 11:49:18 UTC (rev 48039)
@@ -0,0 +1,54 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ * The MADS game logic is all hard-coded into the games, although for Rex at least
+ * it seems to use only a fairly basic set of instructions and function calls, so it should be 
+ * possible 
+ */
+
+#ifndef M4_MADS_LOGIC_H
+#define M4_MADS_LOGIC_H
+
+namespace M4 {
+
+class MadsSceneLogic {
+private:
+	// Library interface methods
+private:
+	int _sceneNumber;
+
+	// Support functions
+	const char *formAnimName(char sepChar, int suffixNum);
+	void getSceneSpriteSet();
+	void getAnimName();
+public:
+	void selectScene(int sceneNum);
+
+	void setupScene();
+	void enterScene();
+	void doAction();
+};
+
+}
+
+#endif


Property changes on: scummvm/trunk/engines/m4/mads_logic.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/engines/m4/module.mk
===================================================================
--- scummvm/trunk/engines/m4/module.mk	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/module.mk	2010-02-13 11:49:18 UTC (rev 48039)
@@ -19,6 +19,7 @@
 	m4_menus.o \
 	m4_views.o \
 	mads_anim.o \
+	mads_logic.o \
 	mads_menus.o \
 	mads_views.o \
 	midi.o \

Modified: scummvm/trunk/engines/m4/resource.cpp
===================================================================
--- scummvm/trunk/engines/m4/resource.cpp	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/resource.cpp	2010-02-13 11:49:18 UTC (rev 48039)
@@ -310,6 +310,71 @@
 	return outputFilename;
 }
 
+/**
+ * Forms a resource name based on the passed specifiers
+ */
+const char *MADSResourceManager::getResourceName(char asciiCh, int prefix, ExtensionType extType, 
+												 const char *suffix, int index) {
+	static char resourceName[100];
+
+	if (prefix <= 0)
+		strcpy(resourceName, "*");
+	else {
+		if (prefix < 100)
+			strcpy(resourceName, "*SC");
+		else
+			strcpy(resourceName, "*RM");
+		sprintf(resourceName + 3, "%.3d", prefix);
+	}
+
+	// Append the specified ascii prefix character
+	char asciiStr[2];
+	asciiStr[0] = asciiCh;
+	asciiStr[1] = '\0';
+	strcat(resourceName, asciiStr);
+
+	// Add in the index specified
+	if (index > 0)
+		sprintf(resourceName + strlen(resourceName), "%d", index);
+
+	// Add in any suffix
+	if (suffix)
+		strcat(resourceName, suffix);
+
+	// Handle extension types
+	switch (extType) {
+	case EXTTYPE_SS:
+		strcat(resourceName, ".SS");
+		break;
+	case EXTTYPE_AA:
+		strcat(resourceName, ".AA");
+		break;
+	case EXTTYPE_DAT:
+		strcat(resourceName, ".DAT");
+		break;
+	case EXTTYPE_HH:
+		strcat(resourceName, ".HH");
+		break;
+	case EXTTYPE_ART:
+		strcat(resourceName, ".ART");
+		break;
+	case EXTTYPE_INT:
+		strcat(resourceName, ".INT");
+		break;
+	default:
+		break;
+	}
+
+	return &resourceName[0];
+}
+
+/**
+ * Forms an AA resource name based on the given passed index
+ */
+const char *MADSResourceManager::getAAName(int index) {
+	return getResourceName('I', 0, EXTTYPE_AA, NULL, index);
+}
+
 Common::SeekableReadStream *MADSResourceManager::loadResource(const char *resourceName, bool loadFlag) {
 	Common::File hagFile;
 	uint32 offset = 0, size = 0;

Modified: scummvm/trunk/engines/m4/resource.h
===================================================================
--- scummvm/trunk/engines/m4/resource.h	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/resource.h	2010-02-13 11:49:18 UTC (rev 48039)
@@ -112,6 +112,9 @@
 enum ResourceType {RESTYPE_ROOM, RESTYPE_SC, RESTYPE_TEXT, RESTYPE_QUO, RESTYPE_I,
 	RESTYPE_OB, RESTYPE_FONT, RESTYPE_SOUND, RESTYPE_SPEECH, RESTYPE_HAS_EXT, RESTYPE_NO_EXT};
 
+enum ExtensionType {EXTTYPE_SS = 1, EXTTYPE_AA = 2, EXTTYPE_DAT = 3, EXTTYPE_HH = 4, EXTTYPE_ART = 5, 
+	EXTTYPE_INT = 6, EXTTYPE_NONE = -1};
+
 class MADSResourceManager : public ResourceManager {
 private:
 	ResourceType getResourceType(const char *resourceName);
@@ -121,6 +124,9 @@
 public:
 	MADSResourceManager(MadsM4Engine *vm): ResourceManager(vm) {};
 	bool resourceExists(const char *resourceName);
+
+	static const char *getResourceName(char asciiCh, int prefix, ExtensionType extType, const char *suffix, int index);
+	static const char *getAAName(int index);
 };
 
 class M4ResourceManager : public ResourceManager {

Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/scene.cpp	2010-02-13 11:49:18 UTC (rev 48039)
@@ -603,6 +603,7 @@
 	_vm = vm;
 
 	strcpy(_statusText, "");
+	strcpy(_playerSpriteName, "");
 	_interfaceSurface = new MadsInterfaceView(vm);
 	_currentAction = kVerbNone;
 }
@@ -617,10 +618,10 @@
 	// Handle common scene setting
 	Scene::loadScene(sceneNumber);
 
+	_sceneLogic.selectScene(sceneNumber);
+	_vm->globals()->addVisitedScene(sceneNumber);
+	_sceneLogic.setupScene();
 
-	// TODO: Check if we were loading a game
-
-
 	// Set system palette entries
 	_vm->_palette->blockRange(0, 7);
 	RGB8 sysColors[3] = { {0x1f<<2, 0x2d<<2, 0x31<<2, 0}, {0x24<<2, 0x37<<2, 0x3a<<2, 0},

Modified: scummvm/trunk/engines/m4/scene.h
===================================================================
--- scummvm/trunk/engines/m4/scene.h	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/scene.h	2010-02-13 11:49:18 UTC (rev 48039)
@@ -34,6 +34,7 @@
 #include "m4/viewmgr.h"
 #include "m4/gui.h"
 #include "m4/m4_views.h"
+#include "m4/mads_logic.h"
 #include "m4/mads_views.h"
 
 namespace M4 {
@@ -163,7 +164,12 @@
 
 	int _currentAction;
 	char _statusText[100];
+	MadsSceneLogic _sceneLogic;
+	SpriteAsset *_playerSprites;
 public:
+	char _playerSpriteName[100];
+	char _aaName[100];
+public:
 	MadsScene(MadsEngine *vm);
 	virtual ~MadsScene() {};
 

Modified: scummvm/trunk/engines/m4/sound.cpp
===================================================================
--- scummvm/trunk/engines/m4/sound.cpp	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/sound.cpp	2010-02-13 11:49:18 UTC (rev 48039)
@@ -99,6 +99,10 @@
 	_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume);
 }
 
+void Sound::playSound(int soundNum) { 
+	warning("TODO: playSound(%d)", soundNum); 
+}
+
 void Sound::pauseSound() {
 	for (int i = 0; i < SOUND_HANDLES; i++) {
 		if (_handles[i].type == kEffectHandle)

Modified: scummvm/trunk/engines/m4/sound.h
===================================================================
--- scummvm/trunk/engines/m4/sound.h	2010-02-13 11:45:54 UTC (rev 48038)
+++ scummvm/trunk/engines/m4/sound.h	2010-02-13 11:49:18 UTC (rev 48039)
@@ -77,6 +77,7 @@
 	~Sound();
 
 	void playSound(const char *soundName, int volume, bool loop, int channel = -1);
+	void playSound(int soundNum);
 	void pauseSound();
 	void resumeSound();
 	void stopSound(int channel = -1);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list