[Scummvm-cvs-logs] SF.net SVN: scummvm:[54910] tools/branches/gsoc2010-decompiler/decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Tue Dec 14 23:49:34 CET 2010
Revision: 54910
http://scummvm.svn.sourceforge.net/scummvm/?rev=54910&view=rev
Author: pidgeot
Date: 2010-12-14 22:49:34 +0000 (Tue, 14 Dec 2010)
Log Message:
-----------
DECOMPILER: Engine variants
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
tools/branches/gsoc2010-decompiler/decompiler/engine.h
tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp
tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp
tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h
Modified: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-12-14 22:25:10 UTC (rev 54909)
+++ tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-12-14 22:49:34 UTC (rev 54910)
@@ -32,6 +32,9 @@
#include <fstream>
#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
#include <boost/program_options.hpp>
#include <boost/graph/graphviz.hpp>
@@ -57,7 +60,7 @@
("only-disassembly,D", "Stops after disassembly. Implies -d.")
("only-graph,G", "Stops after control flow graph has been generated. Implies -g.")
("show-unreachable,u", "Show the address and contents of unreachable groups in the script.")
- ("is-talkie,t", "Tell the engine that the script is from a talkie version (default is no). Not all engines require this information.");
+ ("variant,v", po::value<std::string>()->default_value(""), "Tell the engine that the script is from a specific variant. To see a list of variants supported by a specific engine, use the -h option and the -e option together.");
po::options_description args("");
args.add(visible).add_options()
@@ -88,20 +91,35 @@
if (vm.count("help") || !vm.count("input-file")) {
std::cout << "Usage: " << argv[0] << " [option...] file" << "\n";
std::cout << visible << "\n";
+ if (vm.count("engine") && engines.find(vm["engine"].as<std::string>()) != engines.end()) {
+ Engine *engine = engineFactory.create(vm["engine"].as<std::string>());
+ std::vector<std::string> variants;
+ engine->getVariants(variants);
+ if (variants.empty()) {
+ std::cout << engines[vm["engine"].as<std::string>()] << " does not use variants.\n";
+ } else {
+ std::cout << "Supported variants for " << engines[vm["engine"].as<std::string>()] << ":\n";
+ for (std::vector<std::string>::iterator i = variants.begin(); i != variants.end(); ++i) {
+ std::cout << " " << *i << "\n";
+ }
+ }
+ delete engine;
+ std::cout << "\n";
+ }
std::cout << "Note: If outputting to stdout, -d or -g must NOT be specified immediately before the input file.\n";
return 1;
}
if (!vm.count("engine")) {
- std::cout << "Engine must be specified." << "\n";
+ std::cout << "Engine must be specified.\n";
return 2;
} else if (engines.find(vm["engine"].as<std::string>()) == engines.end()) {
- std::cout << "Unknown engine." << "\n";
+ std::cout << "Unknown engine.\n";
return 2;
}
Engine *engine = engineFactory.create(vm["engine"].as<std::string>());
- engine->_isTalkie = (bool)(vm.count("is-talkie"));
+ engine->_variant = vm["variant"].as<std::string>();
std::string inputFile = vm["input-file"].as<std::string>();
// Disassembly
Modified: tools/branches/gsoc2010-decompiler/decompiler/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/engine.h 2010-12-14 22:25:10 UTC (rev 54909)
+++ tools/branches/gsoc2010-decompiler/decompiler/engine.h 2010-12-14 22:49:34 UTC (rev 54910)
@@ -27,6 +27,8 @@
#include "codegen.h"
#include <set>
+#include <string>
+#include <vector>
/**
* Structure representing a function.
@@ -126,7 +128,15 @@
FuncMap _functions; ///< Map to functions in the current script, indexed by starting address.
- bool _isTalkie; ///< Whether or not the script is from a talkie version of the game.
+ /**
+ * Fill a vector with the names of all variants supported for this engine.
+ * If variants are not used by this engine, leave the vector empty (default implementation).
+ *
+ * @param variants Vector to add the supported variants to.
+ */
+ virtual void getVariants(std::vector<std::string> &variants) const { };
+
+ std::string _variant; ///< Engine variant to use for the script.
};
#endif
Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp 2010-12-14 22:25:10 UTC (rev 54909)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp 2010-12-14 22:49:34 UTC (rev 54910)
@@ -210,7 +210,7 @@
FUNC("o2_countItemInstances", "rp");
FUNC("o2_removeItemFromScene", "rpp");
FUNC("o2_initObject", "rp");
- FUNC("o2_npcChat", (_engine->_isTalkie ? "rspp": "rsp"));
+ FUNC("o2_npcChat", (_engine->_variant.find("talkie") != std::string::npos ? "rspp": "rsp"));
// 0x8c
FUNC("o2_deinitObject", "rp");
FUNC("o2_playTimSequence", "rs");
Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp 2010-12-14 22:25:10 UTC (rev 54909)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp 2010-12-14 22:49:34 UTC (rev 54910)
@@ -60,6 +60,11 @@
return true;
}
+void Kyra::Kyra2Engine::getVariants(std::vector<std::string> &variants) const {
+ variants.push_back("kyra2");
+ variants.push_back("kyra2-talkie");
+}
+
void Kyra::Kyra2LoadInstruction::processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {
Kyra2CodeGenerator* cg = (Kyra2CodeGenerator *)codeGen;
switch (_opcode) {
Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h 2010-12-14 22:25:10 UTC (rev 54909)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h 2010-12-14 22:49:34 UTC (rev 54910)
@@ -39,6 +39,7 @@
CodeGenerator *getCodeGenerator(std::ostream &output);
void postCFG(InstVec &insts, Graph g);
bool detectMoreFuncs() const;
+ void getVariants(std::vector<std::string> &variants) const;
std::vector<std::string> _textStrings; ///< Container for strings from the TEXT chunk.
};
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