diff options
author | Vladimir Menshakov | 2009-09-05 08:16:35 +0000 |
---|---|---|
committer | Vladimir Menshakov | 2009-09-05 08:16:35 +0000 |
commit | 622c4684fe9cc962f2ebb6e9c48facfda0aba35b (patch) | |
tree | 6f01f7cf108988cd7e4a5dec1407b1f0cb95642f | |
parent | 6af8ed6bf9a481eeb8d2f16dadfb5b098c1daeb3 (diff) | |
download | scummvm-rg350-622c4684fe9cc962f2ebb6e9c48facfda0aba35b.tar.gz scummvm-rg350-622c4684fe9cc962f2ebb6e9c48facfda0aba35b.tar.bz2 scummvm-rg350-622c4684fe9cc962f2ebb6e9c48facfda0aba35b.zip |
removed magic exe offsets, added teenagent.dat support.
svn-id: r43954
-rw-r--r-- | engines/teenagent/callbacks.cpp | 19 | ||||
-rw-r--r-- | engines/teenagent/detection.cpp | 51 | ||||
-rw-r--r-- | engines/teenagent/resources.cpp | 33 | ||||
-rw-r--r-- | engines/teenagent/resources.h | 6 | ||||
-rw-r--r-- | engines/teenagent/segment.cpp | 4 | ||||
-rw-r--r-- | engines/teenagent/teenagent.cpp | 9 | ||||
-rw-r--r-- | engines/teenagent/teenagent.h | 18 |
7 files changed, 72 insertions, 68 deletions
diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp index 7ad369009e..e3a05fff46 100644 --- a/engines/teenagent/callbacks.cpp +++ b/engines/teenagent/callbacks.cpp @@ -1276,6 +1276,25 @@ bool TeenAgentEngine::processCallback(uint16 addr) { } 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); diff --git a/engines/teenagent/detection.cpp b/engines/teenagent/detection.cpp index 33519d4ea5..1125989b4f 100644 --- a/engines/teenagent/detection.cpp +++ b/engines/teenagent/detection.cpp @@ -28,7 +28,6 @@ #include "base/plugins.h" #include "engines/advancedDetector.h" - #include "teenagent/teenagent.h" static const PlainGameDescriptor teenAgentGames[] = { @@ -36,43 +35,33 @@ static const PlainGameDescriptor teenAgentGames[] = { { 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 @@ public: 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; } diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp index 45a9cddd8d..1b4ec7d86c 100644 --- a/engines/teenagent/resources.cpp +++ b/engines/teenagent/resources.cpp @@ -24,6 +24,7 @@ #include "teenagent/resources.h" #include "teenagent/teenagent.h" +#include "common/zlib.h" namespace TeenAgent { @@ -46,7 +47,21 @@ void Resources::deinit() { 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 @@ void Resources::loadArchives(const GameDescription * gd) { 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) { diff --git a/engines/teenagent/resources.h b/engines/teenagent/resources.h index 9b7ab9e96e..80419f58a9 100644 --- a/engines/teenagent/resources.h +++ b/engines/teenagent/resources.h @@ -30,16 +30,16 @@ #include "teenagent/font.h" #include "graphics/surface.h" -namespace TeenAgent { +struct ADGameDescription; -struct GameDescription; +namespace TeenAgent { 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; diff --git a/engines/teenagent/segment.cpp b/engines/teenagent/segment.cpp index 6858f5d65c..7ba680907b 100644 --- a/engines/teenagent/segment.cpp +++ b/engines/teenagent/segment.cpp @@ -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() { diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index 122d5c5963..b4e6db10a6 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -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::saveGameState(int slot, const char *desc) { } 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 @@ Common::Error TeenAgentEngine::run() { scene = new Scene; inventory = new Inventory; - Resources * res = Resources::instance(); - res->loadArchives(_gameDescription); scene->init(this, _system); diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h index 228d581ffd..87df1755da 100644 --- a/engines/teenagent/teenagent.h +++ b/engines/teenagent/teenagent.h @@ -31,7 +31,8 @@ #include "teenagent/inventory.h" #include "sound/audiostream.h" #include "sound/mixer.h" -#include "engines/advancedDetector.h" + +struct ADGameDescription; namespace TeenAgent { @@ -39,22 +40,11 @@ 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 @@ private: Audio::AudioStream *_musicStream; Audio::SoundHandle _musicHandle, _soundHandle; - const GameDescription *_gameDescription; + const ADGameDescription *_gameDescription; }; } // End of namespace TeenAgent |