[Scummvm-cvs-logs] SF.net SVN: scummvm:[49296] tools/branches/gsoc2010-decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Fri May 28 22:16:35 CEST 2010
Revision: 49296
http://scummvm.svn.sourceforge.net/scummvm/?rev=49296&view=rev
Author: pidgeot
Date: 2010-05-28 20:16:34 +0000 (Fri, 28 May 2010)
Log Message:
-----------
Partial implementation of SCUMMv6 disassembler
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/Makefile.common
tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
Added Paths:
-----------
tools/branches/gsoc2010-decompiler/decompiler/scummv6/
tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp
tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h
Modified: tools/branches/gsoc2010-decompiler/Makefile.common
===================================================================
--- tools/branches/gsoc2010-decompiler/Makefile.common 2010-05-28 20:15:52 UTC (rev 49295)
+++ tools/branches/gsoc2010-decompiler/Makefile.common 2010-05-28 20:16:34 UTC (rev 49296)
@@ -24,6 +24,7 @@
MODULE_DIRS += \
decompiler/ \
+ decompiler/scummv6 \
decompiler/test/disassembler/
MODULE_DIRS += \
@@ -265,7 +266,8 @@
decompiler/decompiler.o \
decompiler/disassembler.o \
decompiler/simple_disassembler.o \
- decompiler/unknown_opcode.o
+ decompiler/unknown_opcode.o \
+ decompiler/scummv6/disassembler.o
decompile_LIBS := \
-lboost_program_options
Modified: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-05-28 20:15:52 UTC (rev 49295)
+++ tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-05-28 20:16:34 UTC (rev 49296)
@@ -26,6 +26,7 @@
#include "objectFactory.h"
#include "disassembler.h"
+#include "scummv6/disassembler.h"
namespace po = boost::program_options;
@@ -36,6 +37,8 @@
std::map<std::string, std::string> engines;
ObjectFactory<Disassembler> disassemblerFactory;
+ ENGINE("scummv6", "SCUMM v6", ScummV6Disassembler);
+
po::options_description visible("Options");
visible.add_options()
("help", "Produce this help message.")
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/scummv6
___________________________________________________________________
Added: svn:ignore
+ .deps
Added: tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp 2010-05-28 20:16:34 UTC (rev 49296)
@@ -0,0 +1,127 @@
+/* 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 <iostream>
+
+#include "disassembler.h"
+
+std::vector<Instruction> ScummV6Disassembler::disassemble() {
+ std::string blockName;
+ for (int i = 0; i < 4; i++)
+ {
+ blockName += _f.readChar();
+ }
+ if (blockName == "SCRP") {
+ std::cout << "Input is global script\n";
+ _f.seek(8,SEEK_SET);
+ } else if (blockName == "LSCR") {
+ std::cout << "Input is local script\n";
+ _f.seek(9,SEEK_SET);
+ } else if (blockName == "ENCD") {
+ std::cout << "Input is room entry script\n";
+ _f.seek(8,SEEK_SET);
+ } else if (blockName == "EXCD") {
+ std::cout << "Input is room exit script\n";
+ _f.seek(8,SEEK_SET);
+ } else if (blockName == "VERB") {
+ std::cout << "Input is object script\n";
+ _f.seek(8,SEEK_SET);
+ std::cout << "Offset table:\n";
+ uint8 verb = _f.readByte();
+ while (verb != 0) {
+ printf("%02x - %04x", verb, _f.readUint16LE());
+ }
+ }
+
+ START_OPCODES;
+ OPCODE(0x00, "pushByte", kLoad, 1, "B");
+ OPCODE(0x01, "pushWord", kLoad, 1, "w");
+ OPCODE(0x02, "pushByteVar", kLoad, 1, "B");
+ OPCODE(0x03, "pushWordVar", kLoad, 1, "w");
+ OPCODE(0x06, "byteArrayRead", kLoad, 0, "B");
+ OPCODE(0x07, "wordArrayRead", kLoad, 0, "w");
+ OPCODE(0x0A, "byteArrayIndexedRead", kLoad, -1, "B");
+ OPCODE(0x0B, "wordArrayIndexedRead", kLoad, -1, "w");
+ OPCODE(0x0C, "dup", kLoad, 1, "");
+ OPCODE(0x0D, "not", kBoolean, 0, "");
+ OPCODE(0x0E, "eq", kComparison, -1, "");
+ OPCODE(0x0F, "neq", kComparison, -1, "");
+ OPCODE(0x10, "gt", kComparison, -1, "");
+ OPCODE(0x11, "lt", kComparison, -1, "");
+ OPCODE(0x12, "le", kComparison, -1, "");
+ OPCODE(0x13, "ge", kComparison, -1, "");
+ OPCODE(0x14, "add", kArithmetic, -1, "");
+ OPCODE(0x15, "sub", kArithmetic, -1, "");
+ OPCODE(0x16, "mul", kArithmetic, -1, "");
+ OPCODE(0x17, "div", kArithmetic, -1, "");
+ OPCODE(0x18, "land", kBoolean, -1, "");
+ OPCODE(0x19, "lor", kBoolean, -1, "");
+ OPCODE(0x1A, "kill", kStack, -1, "");
+ OPCODE(0x42, "writeByteVar", kStore, -1, "B");
+ OPCODE(0x43, "writeWordVar", kStore, -1, "w");
+ OPCODE(0x46, "byteArrayWrite", kStore, -2, "B");
+ OPCODE(0x47, "wordArrayWrite", kStore, -2, "w");
+ OPCODE(0x4A, "byteArrayIndexedWrite", kStore, -3, "B");
+ OPCODE(0x4B, "wordArrayIndexedWrite", kStore, -3, "w");
+ OPCODE(0x4E, "byteVarInc", kArithmetic, 0, "B");
+ OPCODE(0x4F, "wordVarInc", kArithmetic, 0, "w");
+ OPCODE(0x52, "byteArrayInc", kArithmetic, -1, "B");
+ OPCODE(0x53, "wordArrayInc", kArithmetic, -1, "w");
+ OPCODE(0x56, "byteVarDec", kArithmetic, 0, "B");
+ OPCODE(0x57, "wordVarDec", kArithmetic, 0, "w");
+ OPCODE(0x5A, "byteArrayDec", kArithmetic, -1, "B");
+ OPCODE(0x5B, "wordArrayDec", kArithmetic, -1, "w");
+ OPCODE(0x5C, "jumpTrue", kCondJump, -1, "w");
+ OPCODE(0x5D, "jumpFalse", kCondJump, -1, "w");
+ OPCODE(0x5E, "startScript", kSpecial, 0, ""); //Variable stack arguments
+ OPCODE(0x5F, "startScriptQuick", kSpecial, 0, ""); //Variable stack arguments
+ OPCODE(0x60, "startObject", kSpecial, 0, ""); //Variable stack arguments
+ OPCODE(0x61, "drawObject", kSpecial, -2, "");
+ OPCODE(0x62, "drawObjectAt", kSpecial, -3, "");
+ OPCODE(0x63, "drawBlastObject", kSpecial, 0, "");
+ OPCODE(0x64, "setBlastObjectWindow", kSpecial, -4, "");
+ OPCODE(0x65, "stopObjectCodeA", kSpecial, 0, "");
+ OPCODE(0x66, "stopObjectCodeB", kSpecial, 0, "");
+ OPCODE(0x67, "endCutscene", kSpecial, 0, "");
+ OPCODE(0x68, "beginCutscene", kSpecial, 0, ""); //Variable stack arguments
+ OPCODE(0x69, "stopMusic", kSpecial, 0, "");
+ OPCODE(0x6A, "freezeUnfreeze", kSpecial, -1, "");
+ START_SUBOPCODE(0x6B);
+ OPCODE(0x90, "cursorCmd_CursorOn", kSpecial, 0, "");
+ OPCODE(0x91, "cursorCmd_CursorOff", kSpecial, 0, "");
+ OPCODE(0x92, "cursorCmd_UserputOn", kSpecial, 0, "");
+ OPCODE(0x93, "cursorCmd_UserputOff", kSpecial, 0, "");
+ OPCODE(0x94, "cursorCmd_SoftOn", kSpecial, 0, "");
+ OPCODE(0x95, "cursorCmd_SoftOff", kSpecial, 0, "");
+ OPCODE(0x96, "cursorCmd_UserputSoftOn", kSpecial, 0, "");
+ OPCODE(0x97, "cursorCmd_UserputSoftOff", kSpecial, 0, "");
+ OPCODE(0x99, "cursorCmd_Image", kSpecial, -2, "");
+ OPCODE(0x9A, "cursorCmd_Hotspot", kSpecial, -2, "");
+ OPCODE(0x9C, "cursorCmd_CharsetSet", kSpecial, -1, "");
+ OPCODE(0x9D, "cursorCmd_CharsetColor", kSpecial, 0, ""); //Variable stack arguments
+ OPCODE(0xD6, "cursorCmd_Transparent", kSpecial, -1, "");
+ END_SUBOPCODE;
+ OPCODE(0x6C, "breakHere", kSpecial, 0, "");
+ END_OPCODES;
+
+ return _insts;
+}
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h 2010-05-28 20:16:34 UTC (rev 49296)
@@ -0,0 +1,36 @@
+/* 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 DEC_SCUMMV6_DISASM_H
+#define DEC_SCUMMV6_DISASM_H
+
+#include "decompiler/simple_disassembler.h"
+
+/**
+ * Disassembler for SCUMMv6.
+ */
+class ScummV6Disassembler : public SimpleDisassembler {
+public:
+ virtual std::vector<Instruction> disassemble();
+};
+
+#endif
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
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