[Scummvm-cvs-logs] SF.net SVN: scummvm:[43954] scummvm/trunk/engines/teenagent

megath at users.sourceforge.net megath at users.sourceforge.net
Sat Sep 5 10:16:35 CEST 2009


Revision: 43954
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43954&view=rev
Author:   megath
Date:     2009-09-05 08:16:35 +0000 (Sat, 05 Sep 2009)

Log Message:
-----------
removed magic exe offsets, added teenagent.dat support.

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/callbacks.cpp
    scummvm/trunk/engines/teenagent/detection.cpp
    scummvm/trunk/engines/teenagent/resources.cpp
    scummvm/trunk/engines/teenagent/resources.h
    scummvm/trunk/engines/teenagent/segment.cpp
    scummvm/trunk/engines/teenagent/teenagent.cpp
    scummvm/trunk/engines/teenagent/teenagent.h

Modified: scummvm/trunk/engines/teenagent/callbacks.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/callbacks.cpp	2009-09-05 08:15:09 UTC (rev 43953)
+++ scummvm/trunk/engines/teenagent/callbacks.cpp	2009-09-05 08:16:35 UTC (rev 43954)
@@ -1276,6 +1276,25 @@
 		}
 		return true;
 		
+	case 0x60b5:
+		if (CHECK_FLAG(0xDBAE, 1)) {
+			processCallback(0x60d9);
+			Dialog::show(scene, 0x2FDD);
+		} else {
+			Dialog::show(scene, 0x2E41);
+			processCallback(0x60d9);
+			Dialog::show(scene, 0x2E6d);
+		}
+		return true;
+		
+	case 0x60d9: {
+			Object *obj = scene->getObject(3);
+			moveTo(obj->actor_rect.right, obj->actor_rect.bottom, obj->actor_orientation);
+			processCallback(0x612b);
+			moveTo(48, 190, 3);
+		}
+		return true;
+		
 	case 0x6176:
 		if (CHECK_FLAG(0xDBA4, 1)) {
 			displayMessage(0x3801);

Modified: scummvm/trunk/engines/teenagent/detection.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/detection.cpp	2009-09-05 08:15:09 UTC (rev 43953)
+++ scummvm/trunk/engines/teenagent/detection.cpp	2009-09-05 08:16:35 UTC (rev 43954)
@@ -28,7 +28,6 @@
 #include "base/plugins.h"
 
 #include "engines/advancedDetector.h"
-
 #include "teenagent/teenagent.h"
 
 static const PlainGameDescriptor teenAgentGames[] = {
@@ -36,43 +35,33 @@
 	{ 0, 0 }
 };
 
-
-static const TeenAgent::GameDescription teenAgentGameDescriptions[] = {
+static const ADGameDescription teenAgentGameDescriptions[] = {
 	{
+		"teenagent",
+		"",
 		{
-			"teenagent",
-			"",
-			AD_ENTRY1s("teenagnt.exe", "5679fba82a1fa008f0d3ab9382588eb3", 152690),
-			Common::EN_ANY,
-			Common::kPlatformPC,
-			ADGF_NO_FLAGS,
-			Common::GUIO_NONE
+			{"off.res", 0, NULL, -1},
+			{"on.res", 0, NULL, -1},
+			{"ons.res", 0, NULL, -1},
+			{"varia.res", 0, NULL, -1},
+			{"lan_000.res", 0, NULL, -1},
+			{"lan_500.res", 0, NULL, -1},
+			{"mmm.res", 0, NULL, -1},
+			{"sam_mmm.res", 0, NULL, -1},
+			{"sam_sam.res", 0, NULL, -1},
+			{NULL, 0, NULL, 0}
 		}, 
-		{0x0200, 0xb5b0, 0x1c890}
-	},
-/*	
-	{
-		{
-			"teenagent",
-			"",
-			AD_ENTRY1s("teenagnt.exe", "7172e0c46cd11e4072ba486e3d220210", 152626),
-			Common::EN_ANY,
-			Common::kPlatformPC,
-			ADGF_NO_FLAGS,
-			Common::GUIO_NONE
-		},
-		{0x00c0, 0xB5E0, 0x1c850}
+		Common::EN_ANY,
+		Common::kPlatformPC,
+		ADGF_NO_FLAGS,
+		Common::GUIO_NONE
 	}, 
-*/	
-	{
-		AD_TABLE_END_MARKER, 
-		{0, 0, 0}
-	}
+	AD_TABLE_END_MARKER, 
 };
 
 static const ADParams detectionParams = {
 	(const byte *)teenAgentGameDescriptions,
-	sizeof(TeenAgent::GameDescription),
+	sizeof(ADGameDescription),
 	5000,
 	teenAgentGames,
 	0,
@@ -111,7 +100,7 @@
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 		if (desc) {
-			*engine = new TeenAgent::TeenAgentEngine(syst, (TeenAgent::GameDescription*)desc);
+			*engine = new TeenAgent::TeenAgentEngine(syst, desc);
 		}
 		return desc != 0;
 	}

Modified: scummvm/trunk/engines/teenagent/resources.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/resources.cpp	2009-09-05 08:15:09 UTC (rev 43953)
+++ scummvm/trunk/engines/teenagent/resources.cpp	2009-09-05 08:16:35 UTC (rev 43954)
@@ -24,6 +24,7 @@
 
 #include "teenagent/resources.h"
 #include "teenagent/teenagent.h"
+#include "common/zlib.h"
 
 namespace TeenAgent {
 
@@ -46,7 +47,21 @@
 	sam_sam.close();
 }
 
-void Resources::loadArchives(const GameDescription * gd) {
+bool Resources::loadArchives(const ADGameDescription * gd) {
+	Common::File dat_file;
+	if (!dat_file.open("teenagent.dat")) {
+		Common::String errorMessage = "You're missing the 'teenagent.dat' file. Get it from the ScummVM website";
+		GUIErrorMessage(errorMessage);
+		warning("%s", errorMessage.c_str());
+		return false;
+	}
+	Common::SeekableReadStream * dat = Common::wrapCompressedReadStream(&dat_file);
+	cseg.read(dat, 0xb3b0);
+	dseg.read(dat, 0xe790);
+	eseg.read(dat, 0x8be2);
+
+	dat_file.close();
+
 	off.open("off.res");
 	varia.open("varia.res");
 	on.open("on.res");
@@ -59,21 +74,7 @@
 
 	font7.load(7);
 	
-	Common::File exe;
-	if (!exe.open("Teenagnt.exe")) {
-		error("cannot open exe file");
-		return;
-	}
-	exe.seek(gd->offsets.cseg_offset);
-	cseg.read(&exe, 0xb3b0); //code
-	
-	exe.seek(gd->offsets.dseg_offset);
-	dseg.read(&exe, 0xe790); //data
-
-	exe.seek(gd->offsets.eseg_offset);
-	eseg.read(&exe, 0x8be2);
-
-	exe.close();
+	return true;
 }
 
 void Resources::loadOff(Graphics::Surface &surface, byte * palette, int id) {

Modified: scummvm/trunk/engines/teenagent/resources.h
===================================================================
--- scummvm/trunk/engines/teenagent/resources.h	2009-09-05 08:15:09 UTC (rev 43953)
+++ scummvm/trunk/engines/teenagent/resources.h	2009-09-05 08:16:35 UTC (rev 43954)
@@ -30,16 +30,16 @@
 #include "teenagent/font.h"
 #include "graphics/surface.h"
 
+struct ADGameDescription;
+
 namespace TeenAgent {
 
-struct GameDescription;
-
 class Resources {
 protected:
 	Resources();
 public: 
 	static Resources * instance();
-	void loadArchives(const GameDescription * gd);
+	bool loadArchives(const ADGameDescription * gd);
 	void deinit();
 	void loadOff(Graphics::Surface &surface, byte *palette, int id);
 	Common::SeekableReadStream * loadLan(uint32 id) const;

Modified: scummvm/trunk/engines/teenagent/segment.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/segment.cpp	2009-09-05 08:15:09 UTC (rev 43953)
+++ scummvm/trunk/engines/teenagent/segment.cpp	2009-09-05 08:16:35 UTC (rev 43954)
@@ -23,13 +23,15 @@
  */
 
 #include "teenagent/segment.h"
+#include "common/util.h"
 
 namespace TeenAgent {
 
 void Segment::read(Common::ReadStream *stream, uint32 s) {
 	_size = s;
 	_data = new byte[_size];
-	stream->read(_data, _size);
+	if (stream->read(_data, _size) != _size)
+		error("Segment::read: corrupted data");
 }
 
 Segment::~Segment() {

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2009-09-05 08:15:09 UTC (rev 43953)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2009-09-05 08:16:35 UTC (rev 43954)
@@ -28,6 +28,7 @@
 #include "common/debug.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
+#include "engines/advancedDetector.h"
 #include "sound/mixer.h"
 #include "teenagent/scene.h"
 #include "teenagent/objects.h"
@@ -35,7 +36,7 @@
 
 namespace TeenAgent {
 
-TeenAgentEngine::TeenAgentEngine(OSystem * system, const GameDescription *gd) : Engine(system), action(ActionNone), _gameDescription(gd) {
+TeenAgentEngine::TeenAgentEngine(OSystem * system, const ADGameDescription *gd) : Engine(system), action(ActionNone), _gameDescription(gd) {
 	music = new MusicPlayer();
 }
 
@@ -193,6 +194,10 @@
 }
 
 Common::Error TeenAgentEngine::run() {
+	Resources * res = Resources::instance();
+	if (!res->loadArchives(_gameDescription))
+		return Common::kUnknownError;
+	
 	Common::EventManager * _event = _system->getEventManager();
 
 	initGraphics(320, 200, false);
@@ -200,8 +205,6 @@
 	scene = new Scene;
 	inventory = new Inventory;
 	
-	Resources * res = Resources::instance();
-	res->loadArchives(_gameDescription);
 	
 	
 	scene->init(this, _system);

Modified: scummvm/trunk/engines/teenagent/teenagent.h
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.h	2009-09-05 08:15:09 UTC (rev 43953)
+++ scummvm/trunk/engines/teenagent/teenagent.h	2009-09-05 08:16:35 UTC (rev 43954)
@@ -31,30 +31,20 @@
 #include "teenagent/inventory.h"
 #include "sound/audiostream.h"
 #include "sound/mixer.h"
-#include "engines/advancedDetector.h"
 
+struct ADGameDescription;
+
 namespace TeenAgent {
 
 struct Object;
 class Scene;
 class MusicPlayer;
 
-struct ExeOffsets {
-	uint32 cseg_offset;
-	uint32 dseg_offset;
-	uint32 eseg_offset;
-};
-
-struct GameDescription {
-	ADGameDescription gd;
-	ExeOffsets offsets;
-};
-
 class TeenAgentEngine: public Engine {
 public: 
 	enum Action { ActionNone, ActionExamine, ActionUse };
 	
-	TeenAgentEngine(OSystem * system, const GameDescription *gd);
+	TeenAgentEngine(OSystem * system, const ADGameDescription *gd);
 
 	virtual Common::Error run();
 	virtual Common::Error loadGameState(int slot);
@@ -113,7 +103,7 @@
 
 	Audio::AudioStream *_musicStream;
 	Audio::SoundHandle _musicHandle, _soundHandle;
-	const GameDescription *_gameDescription;
+	const ADGameDescription *_gameDescription;
 };
 
 } // End of namespace TeenAgent


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