[Scummvm-cvs-logs] SF.net SVN: scummvm:[55199] tools/trunk
jvprat at users.sourceforge.net
jvprat at users.sourceforge.net
Tue Jan 11 03:05:17 CET 2011
Revision: 55199
http://scummvm.svn.sourceforge.net/scummvm/?rev=55199&view=rev
Author: jvprat
Date: 2011-01-11 02:05:17 +0000 (Tue, 11 Jan 2011)
Log Message:
-----------
TOOLS: Add a basic Groovie disassembler to the new decompiler framework.
Modified Paths:
--------------
tools/trunk/Makefile.common
tools/trunk/decompiler/decompiler.cpp
tools/trunk/decompiler/kyra/disassembler.cpp
Added Paths:
-----------
tools/trunk/decompiler/groovie/
tools/trunk/decompiler/groovie/disassembler.cpp
tools/trunk/decompiler/groovie/disassembler.h
tools/trunk/decompiler/groovie/engine.cpp
tools/trunk/decompiler/groovie/engine.h
tools/trunk/decompiler/groovie/opcodes.h
Modified: tools/trunk/Makefile.common
===================================================================
--- tools/trunk/Makefile.common 2011-01-11 01:35:38 UTC (rev 55198)
+++ tools/trunk/Makefile.common 2011-01-11 02:05:17 UTC (rev 55199)
@@ -254,6 +254,8 @@
decompiler/simple_disassembler.o \
decompiler/unknown_opcode.o \
decompiler/value.o \
+ decompiler/groovie/disassembler.o \
+ decompiler/groovie/engine.o \
decompiler/kyra/codegen.o \
decompiler/kyra/disassembler.o \
decompiler/kyra/engine.o \
Modified: tools/trunk/decompiler/decompiler.cpp
===================================================================
--- tools/trunk/decompiler/decompiler.cpp 2011-01-11 01:35:38 UTC (rev 55198)
+++ tools/trunk/decompiler/decompiler.cpp 2011-01-11 02:05:17 UTC (rev 55199)
@@ -28,6 +28,7 @@
#include "control_flow.h"
+#include "groovie/engine.h"
#include "kyra/engine.h"
#include "scummv6/engine.h"
@@ -48,6 +49,7 @@
std::map<std::string, std::string> engines;
ObjectFactory<std::string, Engine> engineFactory;
+ ENGINE("groovie", "Groovie", Groovie::GroovieEngine);
ENGINE("kyra2", "Legend of Kyrandia: Hand of Fate", Kyra::Kyra2Engine);
ENGINE("scummv6", "SCUMM v6", Scumm::v6::Scummv6Engine);
@@ -211,7 +213,7 @@
else
std::cout << boost::format("\n%d unreachable groups detected.\n") % unreachable.size();
}
- std::cout << "Group " << (i+1) << ":\n";
+ std::cout << "Group " << (i + 1) << ":\n";
ConstInstIterator inst = unreachable[i]->_start;
do {
std::cout << *inst;
Property changes on: tools/trunk/decompiler/groovie
___________________________________________________________________
Added: svn:ignore
+ .deps
Added: tools/trunk/decompiler/groovie/disassembler.cpp
===================================================================
--- tools/trunk/decompiler/groovie/disassembler.cpp (rev 0)
+++ tools/trunk/decompiler/groovie/disassembler.cpp 2011-01-11 02:05:17 UTC (rev 55199)
@@ -0,0 +1,358 @@
+/* ScummVM Tools
+* Copyright (C) 2010 The ScummVM project
+*
+* 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 "disassembler.h"
+#include "opcodes.h"
+
+#include "common/util.h"
+
+namespace Groovie {
+
+/**
+ * Value representing an array of values.
+ */
+class ValuesArrayValue : public Value {
+protected:
+ const ValueList _values;
+
+public:
+ /**
+ * Constructor for ValuesArrayValue.
+ *
+ * @param values std::deque of values (left-to-right).
+ */
+ ValuesArrayValue(ValueList values) : _values(values) { }
+ //TODO: implement dup()?
+
+ std::ostream &print(std::ostream &output) const;
+};
+
+std::ostream &ValuesArrayValue::print(std::ostream &output) const {
+ output << "[";
+ for (ValueList::const_iterator i = _values.begin(); i != _values.end(); ++i) {
+ if (i != _values.begin())
+ output << ", ";
+ output << *i;
+ }
+ output << "]";
+ return output;
+}
+
+class GroovieJumpInstruction : public Instruction {
+public:
+ bool isJump() const { return true; }
+ uint32 getDestAddress() const;
+ void processInst(ValueStack &stack, Engine *engine, CodeGenerator *codeGen) {}
+};
+
+uint32 GroovieJumpInstruction::getDestAddress() const {
+ std::vector<ValuePtr>::const_iterator i = _params.begin();
+ while (i != _params.end()) {
+ if ((*i)->isAddress())
+ return (*i)->getUnsigned();
+ i++;
+ }
+ return 0;
+}
+
+class GroovieCondJumpInstruction : public GroovieJumpInstruction {
+public:
+ bool isCondJump() const { return true; }
+};
+
+class GroovieUncondJumpInstruction : public GroovieJumpInstruction {
+public:
+ bool isUncondJump() const { return true; }
+};
+
+
+// GroovieDisassembler
+
+GroovieDisassembler::GroovieDisassembler(InstVec &insts, const GroovieOpcode *opcodes) :
+ Disassembler(insts), _opcodes(opcodes) {
+}
+
+InstPtr GroovieDisassembler::readInstruction() {
+ // Read the next opcode
+ byte opcode;
+ try {
+ opcode = _f.readByte();
+ } catch (Common::FileException e) {
+ return NULL;
+ }
+ if (_f.eos())
+ return NULL;
+
+ return createInstruction(opcode);
+}
+
+InstPtr GroovieDisassembler::createInstruction(byte opcode) {
+ // Extract the first bit
+ _firstBit = opcode & 0x80;
+ opcode &= 0x7F;
+
+ // Verify it's a valid opcode
+ if (opcode > 0x59) // TODO: make it depend on the real number of opcodes
+ throw UnknownOpcodeException(_address, opcode);
+
+ // Create the new instruction
+ InstPtr i;
+ switch (_opcodes[opcode].type) {
+ case kUnaryOpPreInst:
+ i = new UnaryOpPrefixStackInstruction();
+ break;
+ case kBinaryOpInst:
+ i = new BinaryOpStackInstruction();
+ break;
+ case kKernelCallInst:
+ i = new KernelCallStackInstruction();
+ break;
+ case kReturnInst:
+ i = new ReturnInstruction();
+ break;
+ case kJumpInst:
+ i = new GroovieUncondJumpInstruction();
+ break;
+ case kCondJumpInst:
+ i = new GroovieCondJumpInstruction();
+ break;
+ case kCallInst:
+ // TODO: mark beginning of functions?
+ i = new KernelCallStackInstruction();
+ break;
+ }
+ if (!i)
+ return NULL;
+
+ // Fill the instruction information
+ i->_opcode = opcode;
+ i->_address = _address++;
+ i->_stackChange = 0;
+ i->_name = _opcodes[opcode].name;
+
+ // Handle special cases
+ switch (opcode) {
+ case 0x0B: // Input Loop Start
+ // save its address so the Input Loop End can jump here
+ _inputLoopStart = i->_address;
+ break;
+ case 0x13: // Input Loop End
+ // Jump to the address of the Input Loop Start
+ i->_params.push_back(new AddressValue(_inputLoopStart));
+ break;
+ }
+
+ // Read the current instruction's parameters
+ readParams(i, _opcodes[opcode].params);
+ return i;
+}
+
+void GroovieDisassembler::readParams(InstPtr inst, const char *typeString) {
+ while (*typeString) {
+ inst->_params.push_back(readParameter(inst, *typeString));
+ typeString++;
+ }
+}
+
+ValuePtr GroovieDisassembler::readParameter(InstPtr inst, char type) {
+ ValuePtr retval = NULL;
+ switch (type) {
+ case '1': // 8 bits
+ retval = new IntValue(_f.readByte(), false);
+ _address++;
+ break;
+ case '2': // 16 bits
+ retval = new IntValue(_f.readUint16LE(), false);
+ _address += 2;
+ break;
+ case '3': // 8 or 16 bits
+ if (_firstBit)
+ retval = readParameter(inst, '1');
+ else
+ retval = readParameter(inst, '2');
+ break;
+ case '4': // 32 bits
+ retval = new IntValue(_f.readUint32LE(), false);
+ _address += 4;
+ break;
+ case '@': // Address
+ retval = new AddressValue(_f.readUint16LE());
+ _address += 2;
+ if (retval->getUnsigned() > _maxTargetAddress)
+ _maxTargetAddress = retval->getUnsigned();
+ break;
+ case 'A': // Array
+ retval = readParameterArray();
+ break;
+ case 'S': // Script name
+ retval = readParameterScriptName();
+ break;
+ case 'V': // Video name
+ retval = readParameterVideoName();
+ break;
+ case 'C': // Indexed value
+ retval = readParameterIndexed(false, true, true);
+ break;
+ default:
+ std::cout << " UNKNOWN param type: " << type << std::endl;
+ }
+ return retval;
+}
+
+ValuePtr GroovieDisassembler::readParameterIndexed(bool allow7C, bool limitVal, bool limitVar) {
+ ValuePtr result;
+ uint8 data = _f.readByte();
+ _address++;
+
+ if (limitVal) {
+ _firstBit = data & 0x80;
+ data &= 0x7F;
+ }
+
+ if (allow7C && (data == 0x7C)) {
+ // Index a bidimensional array:
+ // M[part1, part2]
+ // M[0x19 + 10 * part1 + part2]
+
+ ValuePtr part1 = readParameterIndexed(false, false, false);
+ ValuePtr part2 = readParameterIndexed(false, true, true);
+
+ ValueList idxs;
+ idxs.push_back(part1);
+ idxs.push_back(part2);
+ result = new ArrayValue("M", idxs);
+ } else if (data == 0x23) {
+ // Index an array:
+ // M[data - 0x61]
+
+ data = _f.readByte();
+ _address++;
+ if (limitVar) {
+ _firstBit = data & 0x80;
+ data &= 0x7F;
+ }
+
+ ValueList idxs;
+ idxs.push_back(new IntValue(data - 0x61, false));
+ result = new ArrayValue("M", idxs);
+ } else {
+ // Immediate value
+ result = new IntValue(data - 0x30, true);
+ }
+ return result;
+}
+
+ValuePtr GroovieDisassembler::readParameterArray() {
+ ValueList values;
+ do {
+ values.push_back(readParameterIndexed(true, true, true));
+ } while (!_firstBit);
+
+ return new ValuesArrayValue(values);
+}
+
+ValuePtr GroovieDisassembler::readParameterScriptName() {
+ std::string result = "";
+ byte c;
+ _address++;
+ while ((c = _f.readByte())) {
+ result += (char)c;
+ _address++;
+ }
+
+ // Return the read string
+ return new StringValue(result);
+}
+
+ValuePtr GroovieDisassembler::readParameterVideoName() {
+ ValueList values;
+
+ std::string stringLiteral = "";
+ byte data;
+ _address++;
+ while ((data = _f.readByte())) {
+ if (data == 0x7C || data == 0x23) {
+ // Check if it breaks a previous string literal
+ if (!stringLiteral.empty()) {
+ values.push_back(new StringValue(stringLiteral));
+ stringLiteral = "";
+ }
+
+ ValueList idxs;
+ if (data == 0x7C) {
+ // Indexing a bidimensional array
+ idxs.push_back(readParameterIndexed(false, false, false));
+ idxs.push_back(readParameterIndexed(false, false, false));
+ } else if (data == 0x23) {
+ // Indexing an unidimensional array
+ data = _f.readByte();
+ _address++;
+ idxs.push_back(new IntValue(data - 0x61, false));
+ }
+ // TODO BinaryOpValue: M[...] + 0x30
+ values.push_back(new ArrayValue("M", idxs));
+ } else {
+ // To lowercase?
+ if (data >= 0x41 && data <= 0x5A) {
+ data += 0x20;
+ }
+ // Append the current character at the end of the string
+ stringLiteral += (char)data;
+ }
+ _address++;
+ }
+
+ // Check if there's a spare string literal
+ if (!stringLiteral.empty())
+ values.push_back(new StringValue(stringLiteral));
+
+ // Return the array built of string parts
+ return new ValuesArrayValue(values);
+}
+
+void GroovieDisassembler::doDisassemble() throw (UnknownOpcodeException) {
+ // Prepare to read the input script
+ _f.seek(0, SEEK_SET);
+
+ // Reset the status
+ _addressBase = 0;
+ _address = _addressBase;
+ _maxTargetAddress = 0;
+ _inputLoopStart = 0;
+
+ bool cont = true;
+ while (cont) {
+ InstPtr i = readInstruction();
+
+ if (i)
+ _insts.push_back(i);
+ else
+ cont = false;
+ }
+
+ // HACK: insert additional NOPs, since some jumps target beyond
+ // the end of the script
+ while (_maxTargetAddress >= _address)
+ _insts.push_back(createInstruction(0));
+}
+
+} // End of namespace Groovie
Property changes on: tools/trunk/decompiler/groovie/disassembler.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/trunk/decompiler/groovie/disassembler.h
===================================================================
--- tools/trunk/decompiler/groovie/disassembler.h (rev 0)
+++ tools/trunk/decompiler/groovie/disassembler.h 2011-01-11 02:05:17 UTC (rev 55199)
@@ -0,0 +1,62 @@
+/* ScummVM Tools
+* Copyright (C) 2010 The ScummVM project
+*
+* 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$
+*
+*/
+
+#ifndef GROOVIE_DISASSEMBLER_H
+#define GROOVIE_DISASSEMBLER_H
+
+#include "decompiler/disassembler.h"
+
+namespace Groovie {
+
+struct GroovieOpcode;
+
+/**
+ * Disassembler for Groovie scripts.
+ */
+class GroovieDisassembler : public Disassembler {
+public:
+ GroovieDisassembler(InstVec &insts, const GroovieOpcode *opcodes);
+
+protected:
+ void doDisassemble() throw(UnknownOpcodeException);
+
+
+ InstPtr readInstruction();
+ InstPtr createInstruction(byte opcode);
+ void readParams(InstPtr inst, const char *typeString);
+ ValuePtr readParameter(InstPtr inst, char type);
+
+ ValuePtr readParameterIndexed(bool allow7C, bool limitVal, bool limitVar);
+ ValuePtr readParameterArray();
+ ValuePtr readParameterScriptName();
+ ValuePtr readParameterVideoName();
+
+ const GroovieOpcode *_opcodes;
+ uint32 _address;
+ uint32 _maxTargetAddress;
+ bool _firstBit;
+ uint32 _inputLoopStart;
+};
+
+} // End of namespace Groovie
+
+#endif // GROOVIE_DISASSEMBLER_H
Property changes on: tools/trunk/decompiler/groovie/disassembler.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/trunk/decompiler/groovie/engine.cpp
===================================================================
--- tools/trunk/decompiler/groovie/engine.cpp (rev 0)
+++ tools/trunk/decompiler/groovie/engine.cpp 2011-01-11 02:05:17 UTC (rev 55199)
@@ -0,0 +1,249 @@
+/* ScummVM Tools
+ * Copyright (C) 2010 The ScummVM project
+ *
+ * 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 "engine.h"
+#include "disassembler.h"
+
+namespace Groovie {
+
+GroovieEngine::GroovieEngine() {
+ setOutputStackEffect(false);
+}
+
+void GroovieEngine::getVariants(std::vector<std::string> &variants) const {
+ variants.push_back("t7g");
+ variants.push_back("v2");
+}
+
+Disassembler *GroovieEngine::getDisassembler(InstVec &insts) {
+ return new GroovieDisassembler(insts, getOpcodes());
+}
+
+CodeGenerator *GroovieEngine::getCodeGenerator(std::ostream &output) {
+ return NULL;
+}
+
+const GroovieOpcode *GroovieEngine::getOpcodes() const {
+ if (!_variant.compare("t7g"))
+ return opcodesT7G;
+ else if (!_variant.compare("v2"))
+ return opcodesV2;
+ else
+ //return NULL;
+ return opcodesT7G;
+}
+
+const GroovieOpcode GroovieEngine::opcodesT7G[] = {
+ {0x00, kKernelCallInst, "Nop", ""},
+ {0x01, kKernelCallInst, "Nop", ""},
+ {0x02, kKernelCallInst, "PlaySong", "2"},
+ {0x03, kKernelCallInst, "BitFlag 9 ON", ""},
+ {0x04, kKernelCallInst, "Palette Fade Out", ""},
+ {0x05, kKernelCallInst, "BitFlag 8 ON", ""},
+ {0x06, kKernelCallInst, "BitFlag 6 ON", ""},
+ {0x07, kKernelCallInst, "BitFlag 7 ON", ""},
+ {0x08, kKernelCallInst, "SetBackgroundSong", "2"},
+ {0x09, kKernelCallInst, "VideoFromRef", "2"},
+ {0x0A, kKernelCallInst, "BitFlag 5 ON", ""},
+ {0x0B, kKernelCallInst, "Input Loop Start", ""},
+ {0x0C, kCondJumpInst, "Keyboard Action", "1@"},
+ {0x0D, kCondJumpInst, "Hotspot Rect", "2222 at 1"},
+ {0x0E, kCondJumpInst, "Hotspot Left", "@"},
+ {0x0F, kCondJumpInst, "Hotspot Right", "@"},
+ {0x10, kCondJumpInst, "Hotspot Center", "@"},
+ {0x11, kCondJumpInst, "Hotspot Center", "@"},
+ {0x12, kCondJumpInst, "Hotspot Current", "@"},
+ {0x13, kJumpInst, "Input Loop End", ""},
+ {0x14, kKernelCallInst, "Random", "31"},
+ {0x15, kJumpInst, "Jmp", "@"},
+ {0x16, kKernelCallInst, "LoadString", "3A"},
+ {0x17, kReturnInst, "Return", "1"},
+ {0x18, kCallInst, "Call", "@"},
+ {0x19, kKernelCallInst, "Sleep", "2"},
+ {0x1A, kCondJumpInst, "JmpStrCmp-NE", "3A@"},
+ {0x1B, kKernelCallInst, "XOR Obfuscate", "3A"},
+ {0x1C, kKernelCallInst, "VDX Transition", "2"},
+ {0x1D, kKernelCallInst, "Swap", "22"},
+ {0x1E, kKernelCallInst, "Nop8", "1"},
+ {0x1F, kUnaryOpPreInst, "Inc", "3"},
+ {0x20, kUnaryOpPreInst, "Dec", "3"},
+ {0x21, kCondJumpInst, "JmpStrCmpVar-NE", "2A@"},
+ {0x22, kKernelCallInst, "Copy BG to FG", ""},
+ {0x23, kCondJumpInst, "JmpStrCmp-EQ", "3A@"},
+ {0x24, kKernelCallInst, "Mov", "32"},
+ {0x25, kBinaryOpInst, "Add", "32"},
+ {0x26, kKernelCallInst, "VideoFromString1", "V"},
+ {0x27, kKernelCallInst, "VideoFromString2", "V"},
+ {0x28, kKernelCallInst, "Nop16", "2"},
+ {0x29, kKernelCallInst, "Stop MIDI", ""},
+ {0x2A, kKernelCallInst, "End Script", ""},
+ {0x2B, kKernelCallInst, "Nop", ""},
+ {0x2C, kCondJumpInst, "Set Hotspot Top", "@1"},
+ {0x2D, kCondJumpInst, "Set Hotspot Bottom", "@1"},
+ {0x2E, kKernelCallInst, "Load Game", "3"},
+ {0x2F, kKernelCallInst, "Save Game", "3"},
+ {0x30, kCondJumpInst, "Hotspot Bottom 4", "@"},
+ {0x31, kKernelCallInst, "MIDI Volume", "22"},
+ {0x32, kCondJumpInst, "JNE", "32@"},
+ {0x33, kKernelCallInst, "Load String Var", "3A"},
+ {0x34, kCondJumpInst, "JmpCharGreat", "3A@"},
+ {0x35, kKernelCallInst, "BitFlag 7 OFF", ""},
+ {0x36, kCondJumpInst, "JmpCharLess", "3A@"},
+ {0x37, kKernelCallInst, "Copy Rect to BG", "2222"},
+ {0x38, kKernelCallInst, "Restore Stack Pointer", ""},
+ {0x39, kKernelCallInst, "Obscure Swap", "CCCC"},
+ {0x3A, kKernelCallInst, "Print String", "A"},
+ {0x3B, kCondJumpInst, "Hotspot Slot", "12222 at 1"},
+ {0x3C, kKernelCallInst, "Check Valid Saves", ""},
+ {0x3D, kKernelCallInst, "Reset Variables", ""},
+ {0x3E, kBinaryOpInst, "Mod", "31"},
+ {0x3F, kKernelCallInst, "Load Script", "S"},
+ {0x40, kKernelCallInst, "Set Video Origin", "22"},
+ {0x41, kBinaryOpInst, "Sub", "32"},
+ {0x42, kKernelCallInst, "Cell Move", "1"},
+ {0x43, kKernelCallInst, "Return Script", "1"},
+ {0x44, kCondJumpInst, "Set Hotspot Right", "@"},
+ {0x45, kCondJumpInst, "Set Hotspot Left", "@"},
+ {0x46, kKernelCallInst, "Nop", ""},
+ {0x47, kKernelCallInst, "Nop", ""},
+ {0x48, kKernelCallInst, "Nop8", "1"},
+ {0x49, kKernelCallInst, "Nop", ""},
+ {0x4A, kKernelCallInst, "Nop16", "2"},
+ {0x4B, kKernelCallInst, "Nop8", "1"},
+ {0x4C, kKernelCallInst, "Get CD", ""},
+ {0x4D, kKernelCallInst, "Play CD", "1"},
+ {0x4E, kKernelCallInst, "Music Delay", "2"},
+ {0x4F, kKernelCallInst, "Nop16", "2"},
+ {0x50, kKernelCallInst, "Nop16", "2"},
+ {0x51, kKernelCallInst, "Nop16", "2"},
+ {0x52, kKernelCallInst, "UNKNOWN52", "1"},
+ {0x53, kCondJumpInst, "Hotspot OutRect", "2222@"},
+ {0x54, kKernelCallInst, "Nop", ""},
+ {0x55, kKernelCallInst, "Nop16", "2"},
+ {0x56, kKernelCallInst, "Stub56", "411"},
+ {0x57, kKernelCallInst, "UNKNOWN57", "4"},
+ {0x58, kKernelCallInst, "UNKNOWN58", ""},
+ {0x59, kKernelCallInst, "UNKNOWN59", "31"},
+};
+
+// TODO: fill with the known v2 opcodes
+const GroovieOpcode GroovieEngine::opcodesV2[] = {
+ {0x00, kKernelCallInst, "", ""},
+ {0x59, kKernelCallInst, "", ""},
+};
+
+/*
+const GroovieOpcode GroovieEngine::opcodesV2[] = {
+ o_invalid, // 0x00
+ o_nop,
+ o2_playsong,
+ o_nop,
+ o_nop, // 0x04
+ o_nop,
+ o_nop,
+ o_nop,
+ o2_setbackgroundsong, // 0x08
+ o2_videofromref,
+ o_bf5on,
+ o_inputloopstart,
+ o_keyboardaction, // 0x0C
+ o_hotspot_rect,
+ o_hotspot_left,
+ o_hotspot_right,
+ o_hotspot_center, // 0x10
+ o_hotspot_center,
+ o_hotspot_current,
+ o_inputloopend,
+ o_random, // 0x14
+ o_jmp,
+ o_loadstring,
+ o_ret,
+ o_call, // 0x18
+ o_sleep,
+ o_strcmpnejmp,
+ o_xor_obfuscate,
+ o2_vdxtransition, // 0x1C
+ o_swap,
+ o_invalid,
+ o_inc,
+ o_dec, // 0x20
+ o_strcmpnejmp_var,
+ o_copybgtofg,
+ o_strcmpeqjmp,
+ o_mov, // 0x24
+ o_add,
+ o_videofromstring1,
+ o_videofromstring2,
+ o_invalid, // 0x28
+ o_nop,
+ o_endscript,
+ o_invalid,
+ o_sethotspottop, // 0x2C
+ o_sethotspotbottom,
+ o_loadgame,
+ o_savegame,
+ o_hotspotbottom_4, // 0x30
+ o_midivolume,
+ o_jne,
+ o_loadstringvar,
+ o_chargreatjmp, // 0x34
+ o_bf7off,
+ o_charlessjmp,
+ o_copyrecttobg,
+ o_restorestkpnt, // 0x38
+ o_obscureswap,
+ o_printstring,
+ o_hotspot_slot,
+ o_checkvalidsaves, // 0x3C
+ o_resetvars,
+ o_mod,
+ o_loadscript,
+ o_setvideoorigin, // 0x40
+ o_sub,
+ o_cellmove,
+ o_returnscript,
+ o_sethotspotright, // 0x44
+ o_sethotspotleft,
+ o_invalid,
+ o_invalid,
+ o_invalid, // 0x48
+ o_invalid,
+ o_nop16,
+ o_invalid,
+ o_invalid, // 0x4C
+ o_invalid,
+ o_invalid,
+ o2_copyscreentobg,
+ o2_copybgtoscreen, // 0x50
+ o2_setvideoskip,
+ o2_stub52,
+ o_hotspot_outrect,
+ o_invalid, // 0x54
+ o2_setscriptend,
+ o_stub56,
+ o_invalid,
+ o_invalid, // 0x58
+ o_stub59
+};
+*/
+
+} // End of namespace Groovie
Property changes on: tools/trunk/decompiler/groovie/engine.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/trunk/decompiler/groovie/engine.h
===================================================================
--- tools/trunk/decompiler/groovie/engine.h (rev 0)
+++ tools/trunk/decompiler/groovie/engine.h 2011-01-11 02:05:17 UTC (rev 55199)
@@ -0,0 +1,51 @@
+/* ScummVM Tools
+ * Copyright (C) 2010 The ScummVM project
+ *
+ * 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$
+ *
+ */
+
+#ifndef GROOVIE_ENGINE_H
+#define GROOVIE_ENGINE_H
+
+#include "decompiler/engine.h"
+#include "opcodes.h"
+
+namespace Groovie {
+
+class GroovieEngine : public Engine {
+public:
+ GroovieEngine();
+
+ void getVariants(std::vector<std::string> &variants) const;
+
+ Disassembler *getDisassembler(InstVec &insts);
+
+ CodeGenerator *getCodeGenerator(std::ostream &output);
+ bool supportsCodeGen() const { return false; }
+
+private:
+ const GroovieOpcode *getOpcodes() const;
+
+ static const GroovieOpcode opcodesT7G[];
+ static const GroovieOpcode opcodesV2[];
+};
+
+} // End of namespace Groovie
+
+#endif // GROOVIE_ENGINE_H
Property changes on: tools/trunk/decompiler/groovie/engine.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/trunk/decompiler/groovie/opcodes.h
===================================================================
--- tools/trunk/decompiler/groovie/opcodes.h (rev 0)
+++ tools/trunk/decompiler/groovie/opcodes.h 2011-01-11 02:05:17 UTC (rev 55199)
@@ -0,0 +1,41 @@
+/* ScummVM Tools
+* Copyright (C) 2010 The ScummVM project
+*
+* 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$
+*
+*/
+
+namespace Groovie {
+
+struct GroovieOpcode {
+ uint32 opcode;
+ int type;
+ const char *name;
+ const char *params;
+ // 1 = 8 bits
+ // 2 = 16 bits
+ // 3 = 8 or 16 bits
+ // 4 = 32 bits
+ // @ = Address
+ // A = Array
+ // S = Script name
+ // V = Video name
+ // C = Indexed value
+};
+
+} // End of namespace Groovie
Property changes on: tools/trunk/decompiler/groovie/opcodes.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: tools/trunk/decompiler/kyra/disassembler.cpp
===================================================================
--- tools/trunk/decompiler/kyra/disassembler.cpp 2011-01-11 01:35:38 UTC (rev 55198)
+++ tools/trunk/decompiler/kyra/disassembler.cpp 2011-01-11 02:05:17 UTC (rev 55199)
@@ -370,7 +370,7 @@
std::set<uint16> jumpTargets;
uint16 numInsts = _dataChunk._size / 2;
for (uint16 i = 0; i < numInsts; ++i) {
- uint16 address = i*2;
+ uint16 address = i * 2;
uint16 code = READ_BE_UINT16(&((uint16 *)_dataChunk._data)[i]);
int16 opcode = (code >> 8) & 0x1F;
int16 parameter;
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