소스 검색

Values refactored

Iñigo Valentin 3 년 전
부모
커밋
1a83608dd0
33개의 변경된 파일1337개의 추가작업 그리고 1191개의 파일을 삭제
  1. 2 2
      V-Gears-Installer/CMakeLists.txt
  2. 1 1
      V-Gears-Installer/include/decompiler/CodeGenerator.h
  3. 1 1
      V-Gears-Installer/include/decompiler/LuaLanguage.h
  4. 863 0
      V-Gears-Installer/include/decompiler/Value.h
  5. 1 1
      V-Gears-Installer/include/decompiler/instruction/Instruction.h
  6. 0 440
      V-Gears-Installer/include/decompiler/value.h
  7. 5 5
      V-Gears-Installer/src/decompiler/CodeGenerator.cpp
  8. 205 0
      V-Gears-Installer/src/decompiler/Value.cpp
  9. 0 230
      V-Gears-Installer/src/decompiler/decompiler.cpp
  10. 1 1
      V-Gears-Installer/src/decompiler/field/FieldCodeGenerator.cpp
  11. 7 7
      V-Gears-Installer/src/decompiler/field/FieldDisassembler.cpp
  12. 34 34
      V-Gears-Installer/src/decompiler/field/instruction/FieldBackgroundInstruction.cpp
  13. 16 16
      V-Gears-Installer/src/decompiler/field/instruction/FieldCameraInstruction.cpp
  14. 10 10
      V-Gears-Installer/src/decompiler/field/instruction/FieldCondJumpInstruction.cpp
  15. 13 13
      V-Gears-Installer/src/decompiler/field/instruction/FieldControlFlowInstruction.cpp
  16. 24 24
      V-Gears-Installer/src/decompiler/field/instruction/FieldMathInstruction.cpp
  17. 18 18
      V-Gears-Installer/src/decompiler/field/instruction/FieldMediaInstruction.cpp
  18. 61 61
      V-Gears-Installer/src/decompiler/field/instruction/FieldModelInstruction.cpp
  19. 11 11
      V-Gears-Installer/src/decompiler/field/instruction/FieldModuleInstruction.cpp
  20. 5 5
      V-Gears-Installer/src/decompiler/field/instruction/FieldPartyInstruction.cpp
  21. 2 2
      V-Gears-Installer/src/decompiler/field/instruction/FieldUncondJumpInstruction.cpp
  22. 9 9
      V-Gears-Installer/src/decompiler/field/instruction/FieldWalkmeshInstruction.cpp
  23. 10 10
      V-Gears-Installer/src/decompiler/field/instruction/FieldWindowInstruction.cpp
  24. 1 1
      V-Gears-Installer/src/decompiler/instruction/BoolNegateStackInstruction.cpp
  25. 1 1
      V-Gears-Installer/src/decompiler/instruction/DupStackInstruction.cpp
  26. 0 250
      V-Gears-Installer/src/decompiler/value.cpp
  27. 1 1
      V-Gears-Installer/src/decompiler/world/instruction/WorldCondJumpInstruction.cpp
  28. 28 28
      V-Gears-Installer/src/decompiler/world/instruction/WorldKernelCallInstruction.cpp
  29. 1 1
      V-Gears-Installer/src/decompiler/world/instruction/WorldLoadBankInstruction.cpp
  30. 1 3
      V-Gears-Installer/src/decompiler/world/instruction/WorldLoadInstruction.cpp
  31. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldStoreInstruction.cpp
  32. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldSubStackInstruction.cpp
  33. 1 1
      V-Gears-Installer/src/decompiler/world/instruction/WorldUncondJumpInstruction.cpp

+ 2 - 2
V-Gears-Installer/CMakeLists.txt

@@ -53,7 +53,7 @@ set(HEADER_FILES
     include/decompiler/RefCounted.h
     include/decompiler/Stack.h
     include/decompiler/DecompilerException.h
-    include/decompiler/value.h
+    include/decompiler/Value.h
     include/decompiler/field/instruction/FieldBackgroundInstruction.h
     include/decompiler/field/instruction/FieldCameraInstruction.h
     include/decompiler/field/instruction/FieldCondJumpInstruction.h
@@ -124,7 +124,7 @@ set(SOURCE_FILES
     src/decompiler/instruction/UnaryOpPrefixStackInstruction.cpp
     src/decompiler/instruction/UncondJumpInstruction.cpp
     src/decompiler/DecompilerException.cpp
-    src/decompiler/value.cpp
+    src/decompiler/Value.cpp
     src/decompiler/field/instruction/FieldBackgroundInstruction.cpp
     src/decompiler/field/instruction/FieldCameraInstruction.cpp
     src/decompiler/field/instruction/FieldCondJumpInstruction.cpp

+ 1 - 1
V-Gears-Installer/include/decompiler/CodeGenerator.h

@@ -23,7 +23,7 @@
 #include "DecompilerException.h"
 #include "Graph.h"
 #include "LuaLanguage.h"
-#include "value.h"
+#include "Value.h"
 
 
 class Engine;

+ 1 - 1
V-Gears-Installer/include/decompiler/LuaLanguage.h

@@ -15,7 +15,7 @@
 
 #pragma once
 
-#include "value.h"
+#include "Value.h"
 
 /**
  * Provides formatters and keywords for the LUA language.

+ 863 - 0
V-Gears-Installer/include/decompiler/Value.h

@@ -0,0 +1,863 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears 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.
+ */
+
+#pragma once
+
+#include <deque>
+#include <exception>
+#include <ostream>
+#include <string>
+#include <boost/intrusive_ptr.hpp>
+#include "common/scummsys.h"
+#include "RefCounted.h"
+#include "Stack.h"
+#include "DecompilerException.h"
+
+class Value;
+
+/**
+ * Precedence value for individual values with no operations.
+ */
+const int PRECEDENCE_NO = 0;
+
+/**
+ * Precedence value for a unary operation. (!, -, ~, etc.).
+ */
+const int PRECEDENCE_UNARY = 1;
+
+/**
+ * Precedence value for multiplication, division, modulus (*, /, %).
+ */
+const int PRECEDENCE_MULT = 2;
+
+/**
+ * Precedence value for addition and subtraction (+, -).
+ */
+const int PRECEDENCE_ADD = 3;
+
+/**
+ * Precedence value for bit shifting (<<, >>).
+ */
+const int PRECEDENCE_SHIFT = 4;
+
+/**
+ * Precedence value for relative comparison (<, <=, >=, >).
+ */
+const int PRECEDENCE_RELATION = 5;
+
+/**
+ * Precedence value for equality comparisons (==, !=).
+ */
+const int PRECEDENCE_EQUALITY = 6;
+
+/**
+ * Precedence value for bitwise AND (&).
+ */
+const int PRECEDENCE_BIT_AND = 7;
+
+/**
+ * Precedence value for bitwise XOR (^).
+ */
+const int PRECEDENCE_BIT_XOR = 8;
+
+/**
+ * Precedence value for bitwise OR (|).
+ */
+const int PRECEDENCE_BIT_OR = 9;
+
+/**
+ * Precedence value for logical AND (&&).
+ */
+const int PRECEDENCE_LOGIC_AND = 10;
+
+/**
+ * Precedence value for logical OR (||).
+ */
+const int PRECEDENCE_LOGIC_OR = 11;
+
+/**
+ * Pointer to a Value.
+ */
+typedef boost::intrusive_ptr<Value> ValuePtr;
+
+/**
+ * Type representing a list of values, e.g. for indexes used to access an array.
+ */
+typedef std::deque<ValuePtr> ValueList;
+
+/**
+ * Type representing a stack.
+ */
+typedef Stack<ValuePtr> ValueStack;
+
+/**
+ * Class representing a value (stack entry, parameter, etc.)
+ */
+class Value : public RefCounted{
+
+    public:
+
+        /**
+         * Destructor.
+         */
+        virtual ~Value() { }
+
+        /**
+         * Return whether or not the Value is an integer.
+         *
+         * @return True if the Value is an integer, otherwise false.
+         */
+        virtual bool IsInteger();
+
+        /**
+         * Return whether or not the Value is an address.
+         *
+         * @return True if the Value is an address, otherwise false.
+         */
+        virtual bool IsAddress();
+
+        /**
+         * Returns whether or not any stored integer value is signed.
+         *
+         * @return True if the integer value is signed, false if it is not.
+         * @throws WrongTypeException if the value is not an integer.
+         */
+        virtual bool IsSignedValue();
+
+        /**
+         * Retrieves a signed integer representing the value, if possible.
+         *
+         * @return A signed integer representing the value, if possible.
+         * @throws WrongTypeException if the value is not an integer.
+         */
+        virtual int32 GetSigned();
+
+        /**
+         * Retrieves an unsigned integer representing the value, if possible.
+         *
+         * @return An unsigned integer representing the value, if possible.
+         * @throws WrongTypeException if the value is not an integer.
+         */
+        virtual uint32 GetUnsigned();
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream& Print(std::ostream &output) const = 0;
+
+        /**
+         * Retrieves the string representation of the value.
+         *
+         * @return The string representation of the value.
+         */
+        virtual std::string GetString() const;
+
+        /**
+         * Duplicates a value.
+         *
+         * @param output[out] The stream to output any necessary assignment.
+         * @return A Value corresponding to a duplicate of this entry.
+         */
+        virtual ValuePtr Dup(std::ostream &output);
+
+        /**
+         * Negates a value.
+         *
+         * @return The current Value, negated.
+         * @throws WrongTypeException if negation is not possible.
+         */
+        virtual ValuePtr Negate();
+
+        /**
+         * Operator precedence for this value.
+         *
+         * Lower values bind stronger, i.e. they are resolved earlier.
+         * If an operand has a higher precedence value than the operator,
+         * parentheses are not required for that operand.
+         *
+         * @return The order of precedence.
+         */
+        virtual int GetPrecedence() const;
+
+        /**
+         * Output a value to a stream.
+         *
+         * @param output[out] The  stream to output to.
+         * @param value[in] Reference counted pointer to the value to output.
+         * @return The stream used for output.
+         */
+        friend std::ostream &operator<<(std::ostream &output, Value *value) {
+            return value->Print(output);
+        }
+
+};
+
+/**
+ * Value containing an integer.
+ */
+class IntValue : public Value {
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        IntValue(const IntValue& value) = delete;
+
+        /**
+         * Copy constructor, disabled
+         *
+         * @param value[in] The value to copy.
+         */
+        IntValue& operator = (const IntValue& value) = delete;
+
+        /**
+         * Constructor for IntValue.
+         *
+         * @param val The integer value to be contained.
+         * @param isSigned Whether or not the value is signed. This will affect output.
+         */
+        IntValue(int32 val, bool is_signed);
+
+        /**
+         * Constructor for IntValue.
+         *
+         * @param val The integer value to be contained.
+         * @param isSigned Whether or not the value is signed. This will affect output.
+         */
+        IntValue(uint32 val, bool is_signed);
+
+        /**
+         * Return whether or not the Value is an integer.
+         *
+         * @return True.
+         */
+        bool IsInteger() override;
+
+        /**
+         * Returns whether or not the stored integer value is signed.
+         *
+         * @return True if the integer value is signed, false if it is not.
+         */
+        bool IsSignedValue() override;
+
+        /**
+         * Retrieves a signed integer representing the value, if possible.
+         *
+         * @return A signed integer representing the value, if possible.
+         */
+        int32 GetSigned() override;
+
+        /**
+         * Retrieves an unsigned integer representing the value, if possible.
+         *
+         * @return An unsigned integer representing the value, if possible.
+         * @throws WrongTypeException if the value is not an integer.
+         */
+        uint32 GetUnsigned() override;
+
+        /**
+         * Duplicates the value.
+         *
+         * @param output[out] The stream to output any necessary assignment.
+         * @return A Value corresponding to a duplicate of the value.
+         */
+        ValuePtr Dup(std::ostream &output) override;
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream& Print(std::ostream &output) const override;
+
+    protected:
+
+        /**
+         * The value of the integer.
+         */
+        const int32 val_;
+
+        /**
+         * True if the value is signed, false if it's not.
+         */
+        const bool signed_;
+};
+
+/**
+ * Value containing an absolute address.
+ */
+class AddressValue: public IntValue{
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        AddressValue(const AddressValue& value) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        AddressValue& operator = (const AddressValue& value) = delete;
+
+        /**
+         * Constructor for AddressValue.
+         *
+         * @param addr The absolute address represented by the value.
+         */
+        AddressValue(uint32 addr);
+
+        /**
+         * Return whether or not the Value is an address.
+         *
+         * @return True.
+         */
+        bool IsAddress() override;
+
+        /**
+         * Always throws {@see WrongTypeException}.
+         *
+         * A memory address can't ever be signed.
+         *
+         * @return Nothing.
+         * @throws WrongTypeException always.
+         */
+        int32 GetSigned() override;
+
+        /**
+         * Duplicates the value.
+         *
+         * @param output[out] The stream to output any necessary assignment.
+         * @return A Value corresponding to a duplicate of the value.
+         */
+        ValuePtr Dup(std::ostream &output) override;
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const;
+};
+
+/**
+ * Value containing a signed, relative address.
+ *
+ * When asking for unsigned integer value, exact address is returned; when
+ * printing or getting signed value, relative address is used.
+ */
+class RelAddressValue : public IntValue{
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        RelAddressValue(const RelAddressValue&) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        RelAddressValue& operator = (const RelAddressValue&) = delete;
+
+        /**
+         * Constructor.
+         *
+         * @param base_addr[in] The base address for the offset.
+         * @param offset[in] The relative offset to the base address.
+         */
+        RelAddressValue(uint32 base_addr, int32 offset);
+
+        /**
+         * Return whether or not the Value is an address.
+         *
+         * @return True.
+         */
+        bool IsAddress() override;
+
+        /**
+         * Retrieves the exact address.
+         *
+         * @return The exact address.
+         * @throws WrongTypeException if the value is not an integer.
+         */
+        uint32 GetUnsigned() override;
+
+        /**
+         * Duplicates the value.
+         *
+         * @param output[out] The stream to output any necessary assignment.
+         * @return A Value corresponding to a duplicate of the value.
+         */
+        ValuePtr Dup(std::ostream &output) override;
+
+        /**
+         * Print the relative address to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+    protected:
+
+        /**
+         * The base address for the offset.
+         */
+        const uint32 base_addr_;
+};
+
+/**
+ * Duplicated value.
+ */
+class DupValue : public Value {
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        DupValue(const DupValue& value) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        DupValue& operator = (const DupValue& value) = delete;
+
+        /**
+         * Constructor.
+         *
+         * @param idx Index to distinguish multiple duplicated entries.
+         */
+        DupValue(int idx);
+
+        /**
+         * Duplicates the value.
+         *
+         * @param output[out] The stream to output any necessary assignment.
+         * @return A Value corresponding to a duplicate of the value.
+         */
+        ValuePtr Dup(std::ostream &output) override;
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+    protected:
+
+        /**
+         * Index to distinguish multiple duplicated entries.
+         */
+        const int index_;
+};
+
+/**
+ * String value.
+ */
+class StringValue : public Value {
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        StringValue(const StringValue& value) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        StringValue& operator = (const StringValue&value) = delete;
+
+        /**
+         * Constructor.
+         *
+         * @param str[in] The string value.
+         */
+        StringValue(std::string str);
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+    protected:
+
+        /**
+         * The string value.
+         */
+        const std::string str_;
+};
+
+/**
+ * A string value, unquoted.
+ */
+class UnquotedStringValue : public StringValue{
+
+    public:
+
+        /**
+         * Constructor.
+         *
+         * @param str[in] The string value.
+         */
+        UnquotedStringValue(std::string str);
+
+        /**
+         * Prints the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+};
+
+/**
+ * Value representing a variable.
+ */
+class VarValue : public Value {
+
+    public:
+        /**
+         * Constructor for VarValue.
+         *
+         * @param name The variable name.
+         */
+        VarValue(std::string name);
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+    protected:
+
+        /**
+         * The variable name.
+         */
+        std::string name_;
+};
+
+/**
+ * Value representing array access.
+ */
+class ArrayValue : public VarValue {
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        ArrayValue(const ArrayValue&) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        ArrayValue& operator = (const ArrayValue&) = delete;
+
+        /**
+         * Constructor for ArrayValue.
+         *
+         * @param name The name of the array.
+         * @param indexes List of stack entries representing the indexes used
+         * (left-to-right).
+         */
+        ArrayValue(std::string name, ValueList indexes): VarValue(name), indexes_(indexes){}
+
+        /**
+         * Print the value to a stream.
+         *
+         * Every item in the array will be printed.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+    protected:
+
+        /**
+         * Values representing the indexes used (left-to-right).
+         */
+        const ValueList indexes_;
+};
+
+/**
+ * Value representing the result of a binary operation.
+ */
+class BinaryOpValue : public Value {
+
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        BinaryOpValue(const BinaryOpValue&) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        BinaryOpValue& operator = (const BinaryOpValue&) = delete;
+
+        /**
+         * Constructor.
+         *
+         * @param left[in] Value representing the left side of the operator.
+         * @param right[in] Value representing the right side of the operator.
+         * @param operator[in] The operator for this value.
+         */
+        BinaryOpValue(ValuePtr left, ValuePtr right, std::string oper);
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+        /**
+         * Negates a value.
+         *
+         * @return The value, negated.
+         */
+        virtual ValuePtr Negate() override;
+
+        /**
+         * Retrieves the operator precedence for this operation.
+         *
+         * Lower values bind stronger, i.e. they are resolved earlier.
+         * If an operand has a higher precedence value than the operator,
+         * parentheses are not required for that operand.
+         *
+         * @return the order of precedence for the operation.
+         */
+        virtual int GetPrecedence() const override;
+
+    protected:
+
+        /**
+         * Value at the left side of the operator.
+         */
+        const ValuePtr left_val_;
+
+        /**
+         * Value at the right side of the operator.
+         */
+        const ValuePtr right_val_;
+
+        /**
+         * The operator.
+         */
+        const std::string oper_;
+};
+
+/**
+ * Value representing the result of a unary operation.
+ *
+ * Used as base class for prefix and postfix variants.
+ */
+class UnaryOpValue : public Value{
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        UnaryOpValue(const UnaryOpValue&) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        UnaryOpValue& operator = (const UnaryOpValue&) = delete;
+
+        /**
+         * Constructor..
+         *
+         * @param operand[in] Value representing the operand of the operation.
+         * @param oper[in] The operator for this value.
+         * @param postfix[in] Whether or not the operator should be postfixed
+         * to the operand.
+         */
+        UnaryOpValue(ValuePtr operand, std::string oper, bool postfix);
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+        /**
+         * Retrieves the operator precedence for this operation.
+         *
+         * Lower values bind stronger, i.e. they are resolved earlier.
+         * If an operand has a higher precedence value than the operator,
+         * parentheses are not required for that operand.
+         *
+         * @return {@see PRECEDENCE_UNARY_OP}.
+         */
+        virtual int GetPrecedence() const override;
+
+    protected:
+
+        /**
+         * The operand of the operation
+         */
+        const ValuePtr operand_;
+
+        /**
+         * The operator for this value
+         */
+        const std::string oper_;
+
+        /**
+         * True if the operator is postfixed to the operand, false otherwise.
+         */
+        const bool postfix_;
+};
+
+/**
+ * Negated value.
+ */
+class NegatedValue : public UnaryOpValue{
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        NegatedValue(const NegatedValue&) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        NegatedValue& operator = (const NegatedValue&) = delete;
+
+        /**
+         * Constructor.
+         *
+         * @param val[in] The value to negate.
+         */
+        NegatedValue(ValuePtr val);
+
+        /**
+         * Negates the value.
+         *
+         * @return The value, negated.
+         */
+        virtual ValuePtr Negate() override;
+};
+
+/**
+ * Value representing a function call.
+ */
+class CallValue : public Value {
+
+    public:
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        CallValue(const CallValue& value) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param value[in] The value to copy.
+         */
+        CallValue& operator = (const CallValue& value) = delete;
+
+        /**
+         * Constructor for CallValue.
+         *
+         * @param function[in] The name of the function.
+         * @param args[in] List of values representing the arguments used.
+         */
+        CallValue(std::string function, ValueList args);
+
+        /**
+         * Print the value to a stream.
+         *
+         * @param output[out] The stream to write to.
+         * @return The stream used for output.
+         */
+        virtual std::ostream &Print(std::ostream &output) const override;
+
+    protected:
+
+        /**
+         * The name of the function.
+         */
+        const std::string function_;
+
+        /**
+         * List of values used as function arguments.
+         */
+        const ValueList args_;
+
+};

+ 1 - 1
V-Gears-Installer/include/decompiler/instruction/Instruction.h

@@ -21,8 +21,8 @@
 #include <boost/intrusive_ptr.hpp>
 
 #include "../RefCounted.h"
+#include "../Value.h"
 #include "common/scummsys.h"
-#include "decompiler/value.h"
 #include "decompiler/DecompilerException.h"
 
 class CodeGenerator;

+ 0 - 440
V-Gears-Installer/include/decompiler/value.h

@@ -1,440 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * 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.
- */
-
-#ifndef VALUE_H
-#define VALUE_H
-
-#include <deque>
-#include <exception>
-#include <ostream>
-#include <string>
-#include <boost/intrusive_ptr.hpp>
-
-#include "common/scummsys.h"
-#include "RefCounted.h"
-#include "Stack.h"
-#include "DecompilerException.h"
-
-class Value;
-
-const int kNoPrecedence = 0;          ///< Precedence value for individual values with no operations.
-const int kUnaryOpPrecedence = 1;     ///< Precedence value for a unary operation. (!, -, ~, etc.)
-const int kMultOpPrecedence = 2;      ///< Precedence value for multiplication, division, modulus (*, /, %)
-const int kAddOpPrecedence = 3;       ///< Precedence value for addition and subtraction (+, -)
-const int kShiftOpPrecedence = 4;     ///< precedence value for bit shifting (<<, >>)
-const int kRelationOpPrecedence = 5;  ///< Precedence value for relative comparison (<, <=, >=, >)
-const int kEqualityOpPrecedence = 6;  ///< Precedence value for equality comparisons (==, !=)
-const int kBitwiseAndPrecedence = 7;  ///< Precedence value for bitwise AND (&)
-const int kBitwiseXorPrecedence = 8;  ///< Precedence value for bitwise XOR (^)
-const int kBitwiseOrPrecedence = 9;   ///< Precedence value for bitwise OR (|)
-const int kLogicalAndPrecedence = 10; ///< Precedence value for logical AND (&&)
-const int kLogicalOrPrecedence = 11;  ///< Precedence value for logical OR (||)
-
-/**
- * Pointer to a Value.
- */
-typedef boost::intrusive_ptr<Value> ValuePtr;
-
-/**
- * Type representing a list of values, e.g. for indexes used to access an array.
- */
-typedef std::deque<ValuePtr> ValueList;
-
-/**
- * Type representing a stack.
- */
-typedef Stack<ValuePtr> ValueStack;
-
-/**
- * Class representing a value (stack entry, parameter, etc.)
- */
-class Value : public RefCounted {
-public:
-	virtual ~Value() { }
-
-	/**
-	 * Return whether or not the Value is an integer.
-	 *
-	 * @return True if the Value is an integer, otherwise false.
-	 */
-	virtual bool isInteger();
-
-	/**
-	 * Return whether or not the Value is an address.
-	 *
-	 * @return True if the Value is an address, otherwise false.
-	 */
-	virtual bool isAddress();
-
-	/**
-	 * Returns whether or not any stored integer value is signed.
-	 *
-	 * @return True if the integer value is signed, false if it is not.
-	 * @throws WrongTypeException if the value is not an integer.
-	 */
-	virtual bool isSignedValue();
-
-	/**
-	 * Retrieves a signed integer representing the value, if possible.
-	 *
-	 * @return A signed integer representing the value, if possible.
-	 * @throws WrongTypeException if the value is not an integer.
-	 */
-	virtual int32 getSigned();
-
-	/**
-	 * Retrieves an unsigned integer representing the value, if possible.
-	 *
-	 * @return An unsigned integer representing the value, if possible.
-	 * @throws WrongTypeException if the value is not an integer.
-	 */
-	virtual uint32 getUnsigned();
-
-	/**
-	 * Print the value to an std::ostream.
-	 *
-	 * @param output The std::ostream to write to.
-	 * @return The std::ostream used for output.
-	 */
-	virtual std::ostream &print(std::ostream &output) const = 0;
-
-	/**
-	 * Retrieves the string representation of the value.
-	 *
-	 * @return The string representation of the value.
-	 */
-	virtual std::string getString() const;
-
-	/**
-	 * Duplicates a value.
-	 *
-	 * @param output The std::ostream to output any necessary assignment to.
-	 * @return A Value corresponding to a duplicate of this entry.
-	 */
-	virtual ValuePtr dup(std::ostream &output);
-
-	/**
-	 * Negates a value.
-	 *
-	 * @return The current Value, only negated.
-	 * @throws WrongTypeException if negation is not possible.
-	 */
-	virtual ValuePtr negate();
-
-	/**
-	 * Operator precedence for this value.
-	 * Lower values bind stronger, i.e. they are resolved earlier.
-	 * In other words, if an operand has a higher precedence value than the
-	 * operator, parentheses are not required for that operand.
-	 */
-	virtual int precedence() const;
-
-	/**
-	 * Output a value to an std::ostream.
-	 *
-	 * @param output The std::ostream to output to.
-	 * @param value  Reference counted pointer to the value to output.
-	 * @return The std::ostream used for output.
-	 */
-	friend std::ostream &operator<<(std::ostream &output, Value *value) {
-		return value->print(output);
-	}
-
-};
-
-/**
- * Value containing an integer.
- */
-class IntValue : public Value {
-protected:
-	const int32 _val;     ///< The value of the integer.
-	const bool _isSigned; ///< True if the value is signed, false if it's not.
-
-public:
-    IntValue(const IntValue&) = delete;
-    IntValue& operator = (const IntValue&) = delete;
-
-	/**
-	 * Constructor for IntValue.
-	 *
-	 * @param val The integer value to be contained.
-	 * @param isSigned Whether or not the value is signed. This will affect output.
-	 */
-	IntValue(int32 val, bool isSigned) : _val(val), _isSigned(isSigned) { }
-
-	/**
-	 * Constructor for IntValue.
-	 *
-	 * @param val The integer value to be contained.
-	 * @param isSigned Whether or not the value is signed. This will affect output.
-	 */
-	IntValue(uint32 val, bool isSigned) : _val(val), _isSigned(isSigned) { }
-
-	bool isInteger();
-	bool isSignedValue();
-	int32 getSigned();
-	uint32 getUnsigned();
-
-	ValuePtr dup(std::ostream &output);
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-/**
- * Value containing an absolute address.
- */
-class AddressValue : public IntValue {
-public:
-    AddressValue(const AddressValue&) = delete;
-    AddressValue& operator = (const AddressValue&) = delete;
-
-	/**
-	 * Constructor for AddressValue.
-	 *
-	 * @param addr The absolute address represented by the value.
-	 */
-	AddressValue(uint32 addr) : IntValue(addr, false) { }
-
-	bool isAddress();
-	int32 getSigned();
-
-	ValuePtr dup(std::ostream &output);
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-/**
- * Value containing a signed, relative address. When asking for unsigned integer value, exact address is returned; when printing or getting signed value, relative address is used.
- */
-class RelAddressValue : public IntValue {
-protected:
-	const uint32 _baseaddr; ///< The base address for the offset.
-
-public:
-    RelAddressValue(const RelAddressValue&) = delete;
-    RelAddressValue& operator = (const RelAddressValue&) = delete;
-
-	/**
-	 * Constructor for AddressValue.
-	 *
-	 * @param baseaddr The base address for the offset.
-	 * @param offset The relative offset to the base address.
-	 */
-	RelAddressValue(uint32 baseaddr, int32 offset) : IntValue(offset, true), _baseaddr(baseaddr) { };
-
-	bool isAddress();
-	uint32 getUnsigned();
-
-	ValuePtr dup(std::ostream &output);
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-/**
- * Duplicated value.
- */
-class DupValue : public Value {
-protected:
-	const int _idx; ///< Index to distinguish multiple duplicated entries.
-
-public:
-    DupValue(const DupValue&) = delete;
-    DupValue& operator = (const DupValue&) = delete;
-
-	/**
-	 * Constructor for DupEntry.
-	 *
-	 * @param idx Index to distinguish multiple duplicated entries.
-	 */
-	DupValue(int idx) : _idx(idx) { }
-
-	ValuePtr dup(std::ostream &output);
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-/**
- * String value.
- */
-class StringValue : public Value {
-protected:
-	const std::string _str; ///< The string value.
-
-public:
-    StringValue(const StringValue&) = delete;
-    StringValue& operator = (const StringValue&) = delete;
-
-	/**
-	 * Constructor for StringValue.
-	 *
-	 * @param str The string value.
-	 */
-	StringValue(std::string str) : _str(str) { }
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-class UnqotedStringValue : public StringValue
-{
-public:
-    UnqotedStringValue(std::string str) : StringValue(str) { }
-    virtual std::ostream &print(std::ostream &output) const override;
-};
-
-/**
- * Value representing a variable.
- */
-class VarValue : public Value {
-protected:
-	std::string _varName; ///< The variable name.
-
-public:
-	/**
-	 * Constructor for VarValue.
-	 *
-	 * @param varName The variable name.
-	 */
-	VarValue(std::string varName) : _varName(varName) { }
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-/**
- * Value representing array access.
- */
-class ArrayValue : public VarValue {
-protected:
-	const ValueList _idxs; ///< std::deque of values representing the indexes used (left-to-right).
-
-public:
-    ArrayValue(const ArrayValue&) = delete;
-    ArrayValue& operator = (const ArrayValue&) = delete;
-
-	/**
-	 * Constructor for ArrayValue.
-	 *
-	 * @param arrayName The name of the array.
-	 * @param idxs std::deque of stack entries representing the indexes used (left-to-right).
-	 */
-	ArrayValue(std::string arrayName, ValueList idxs) : VarValue(arrayName), _idxs(idxs) { }
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-/**
- * Value representing the result of a binary operation.
- */
-class BinaryOpValue : public Value {
-protected:
-	const ValuePtr _lhs;   ///< Value representing the left side of the operator.
-	const ValuePtr _rhs;   ///< Value representing the right side of the operator.
-	const std::string _op; ///< The operator for this value.
-
-public:
-    BinaryOpValue(const BinaryOpValue&) = delete;
-    BinaryOpValue& operator = (const BinaryOpValue&) = delete;
-
-	/**
-	 * Constructor for BinaryOpValue.
-	 *
-	 * @param lhs Value representing the left side of the operator.
-	 * @param rhs Value representing the right side of the operator.
-	 * @param op The operator for this value.
-	 */
-	BinaryOpValue(ValuePtr lhs, ValuePtr rhs, std::string op) : _lhs(lhs), _rhs(rhs), _op(op) { }
-
-	virtual std::ostream &print(std::ostream &output) const;
-
-	virtual ValuePtr negate();
-
-	virtual int precedence() const;
-};
-
-/**
- * Value representing the result of a unary operation.
- * Used as base class for prefix and postfix variants.
- */
-class UnaryOpValue : public Value {
-protected:
-	const ValuePtr _operand; ///< Value representing the operand of the operation.
-	const std::string _op;   ///< The operator for this value.
-	const bool _isPostfix;   ///< Whether or not the operator should be postfixed to the operand.
-
-public:
-    UnaryOpValue(const UnaryOpValue&) = delete;
-    UnaryOpValue& operator = (const UnaryOpValue&) = delete;
-
-	/**
-	 * Constructor for UnaryOpValue.
-	 *
-	 * @param operand Value representing the operand of the operation.
-	 * @param op The operator for this value.
-	 * @param isPostfix Whether or not the operator should be postfixed to the operand.
-	 */
-	UnaryOpValue(ValuePtr operand, std::string op, bool isPostfix) :
-		_operand(operand), _op(op), _isPostfix(isPostfix) { }
-
-	virtual std::ostream &print(std::ostream &output) const;
-
-	virtual int precedence() const;
-};
-
-/**
- * Negated value.
- */
-class NegatedValue : public UnaryOpValue {
-public:
-    NegatedValue(const NegatedValue&) = delete;
-    NegatedValue& operator = (const NegatedValue&) = delete;
-
-	/**
-	 * Constructor for NegatedValue.
-	 *
-	 * @param val The value to negate.
-	 */
-	NegatedValue(ValuePtr val) : UnaryOpValue(val, "!", false) { }
-	virtual ValuePtr negate();
-};
-
-/**
- * Value representing a function call.
- */
-class CallValue : public Value {
-protected:
-	const std::string _funcName; ///< The name of the function.
-	const ValueList _args;       ///< std::deque of values representing the arguments used (stored left-to-right).
-
-public:
-    CallValue(const CallValue&) = delete;
-    CallValue& operator = (const CallValue&) = delete;
-
-	/**
-	 * Constructor for CallValue.
-	 *
-	 * @param funcName The name of the function.
-	 * @param args std::deque of values representing the arguments used.
-	 */
-	CallValue(std::string funcName, ValueList args) : _funcName(funcName), _args(args) { }
-
-	virtual std::ostream &print(std::ostream &output) const;
-};
-
-#endif

+ 5 - 5
V-Gears-Installer/src/decompiler/CodeGenerator.cpp

@@ -50,11 +50,11 @@ void CodeGenerator::WriteFunctionCall(
     while (*format){
         bool skip_argument = false;
         switch (*format){
-            case 'b': func_call += params[param_index]->getUnsigned() ? "true" : "false"; break;
-            case 'n': func_call += std::to_string(params[param_index]->getUnsigned()); break;
+            case 'b': func_call += params[param_index]->GetUnsigned() ? "true" : "false"; break;
+            case 'n': func_call += std::to_string(params[param_index]->GetUnsigned()); break;
             case 'f':
                 func_call += std::to_string(
-                  static_cast<float>(params[param_index]->getUnsigned()) / 30.0f
+                  static_cast<float>(params[param_index]->GetUnsigned()) / 30.0f
                 );
                 break;
             case '_': skip_argument = true; break;// Ignore param
@@ -217,11 +217,11 @@ void CodeGenerator::ProcessCondJumpInst(const InstPtr inst){
                       << " " << target_lang_->Else() << " ";
                 }
             }
-            s << target_lang_->If(true) << stack_.Pop()->negate() << target_lang_->If(false);
+            s << target_lang_->If(true) << stack_.Pop()->Negate() << target_lang_->If(false);
             AddOutputLine(s.str(), cur_group_->coalesced_else, true);
             break;
         case GROUP_TYPE_WHILE:
-            s << target_lang_->WhileHeader(true) << stack_.Pop()->negate()
+            s << target_lang_->WhileHeader(true) << stack_.Pop()->Negate()
               << target_lang_->WhileHeader(false) << " "
               << target_lang_->StartBlock(LuaLanguage::BEGIN_WHILE);
             AddOutputLine(s.str(), false, true);

+ 205 - 0
V-Gears-Installer/src/decompiler/Value.cpp

@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears 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.
+ */
+
+#include "decompiler/Value.h"
+#include <boost/format.hpp>
+#include <map>
+#include <sstream>
+#include <string>
+
+static int dupindex = 0;
+static std::map<std::string, int> binary_op_precedence;
+static std::map<std::string, std::string> negate_map;
+
+void InitPrecedence() {
+    binary_op_precedence["||"] = PRECEDENCE_LOGIC_OR;
+    binary_op_precedence["&&"] = PRECEDENCE_LOGIC_AND;
+    binary_op_precedence["|"] = PRECEDENCE_BIT_OR;
+    binary_op_precedence["^"] = PRECEDENCE_BIT_XOR;
+    binary_op_precedence["&"] = PRECEDENCE_BIT_AND;
+    binary_op_precedence["=="] = PRECEDENCE_EQUALITY;
+    binary_op_precedence["!="] = PRECEDENCE_EQUALITY;
+    binary_op_precedence["<"] = PRECEDENCE_RELATION;
+    binary_op_precedence["<="] = PRECEDENCE_RELATION;
+    binary_op_precedence[">="] = PRECEDENCE_RELATION;
+    binary_op_precedence[">"] = PRECEDENCE_RELATION;
+    binary_op_precedence["<<"] = PRECEDENCE_SHIFT;
+    binary_op_precedence[">>"] = PRECEDENCE_SHIFT;
+    binary_op_precedence["+"] = PRECEDENCE_ADD;
+    binary_op_precedence["-"] = PRECEDENCE_ADD;
+    binary_op_precedence["*"] = PRECEDENCE_MULT;
+    binary_op_precedence["/"] = PRECEDENCE_MULT;
+    binary_op_precedence["%"] = PRECEDENCE_MULT;
+}
+
+void InitNegateMap() {
+    negate_map["=="] = "!=";
+    negate_map["!="] = "==";
+    negate_map["<"] = ">=";
+    negate_map["<="] = ">";
+    negate_map[">="] = "<";
+    negate_map[">"] = "<=";
+}
+
+bool Value::IsInteger(){return false;}
+
+bool Value::IsAddress(){return false;}
+
+bool Value::IsSignedValue(){throw WrongTypeException();}
+
+int32 Value::GetSigned(){throw WrongTypeException();}
+
+uint32 Value::GetUnsigned(){throw WrongTypeException();}
+
+ValuePtr Value::Dup(std::ostream &output) {
+    ValuePtr dup_value = new DupValue(++dupindex);
+    output << dup_value << " = " << this << ";";
+    return dup_value;
+}
+
+ValuePtr Value::Negate(){return new NegatedValue(this);}
+
+std::string Value::GetString() const {
+    std::stringstream s;
+    Print(s);
+    return s.str();
+}
+
+int Value::GetPrecedence() const{return PRECEDENCE_NO;}
+
+IntValue::IntValue(int32 val, bool is_signed) : val_(val), signed_(is_signed){}
+
+IntValue::IntValue(uint32 val, bool is_signed) : val_(val), signed_(is_signed){}
+
+bool IntValue::IsInteger(){return true;}
+
+bool IntValue::IsSignedValue(){return signed_;}
+
+int32 IntValue::GetSigned(){return val_;}
+
+uint32 IntValue::GetUnsigned(){return (uint32)val_;}
+
+ValuePtr IntValue::Dup(std::ostream&){return new IntValue(val_, signed_);}
+
+std::ostream &IntValue::Print(std::ostream &output) const{
+    if (signed_) output << (int32)val_;
+    else output << (uint32)val_;
+    return output;
+}
+
+AddressValue::AddressValue(uint32 addr): IntValue(addr, false){}
+
+bool AddressValue::IsAddress(){return true;}
+
+int32 AddressValue::GetSigned(){throw WrongTypeException();}
+
+ValuePtr AddressValue::Dup(std::ostream&){return new AddressValue(val_);}
+
+std::ostream &AddressValue::Print(std::ostream &output) const{
+    return output << boost::format("0x%X") % val_;
+}
+
+RelAddressValue::RelAddressValue(uint32 base_addr, int32 offset):
+  IntValue(offset, true), base_addr_(base_addr){};
+
+bool RelAddressValue::IsAddress(){return true;}
+
+uint32 RelAddressValue::GetUnsigned(){return base_addr_ + val_;}
+
+ValuePtr RelAddressValue::Dup(std::ostream&){return new RelAddressValue(base_addr_, val_);}
+
+std::ostream &RelAddressValue::Print(std::ostream &output) const{
+    if (val_ < 0)   return output << boost::format("-0x%X") % -val_;
+    return output << boost::format("+0x%X") % val_;
+}
+
+DupValue::DupValue(int index): index_(index){}
+
+ValuePtr DupValue::Dup(std::ostream&){return this;}
+
+std::ostream &DupValue::Print(std::ostream &output) const{return output << "temp" << index_;}
+
+StringValue::StringValue(std::string str): str_(str){}
+
+std::ostream &StringValue::Print(std::ostream &output) const{
+    return output << "\"" << str_ << "\"";
+}
+
+UnquotedStringValue::UnquotedStringValue(std::string str): StringValue(str){}
+
+std::ostream& UnquotedStringValue::Print(std::ostream& output) const{return output << str_;}
+
+VarValue::VarValue(std::string name): name_(name){}
+
+std::ostream &VarValue::Print(std::ostream &output) const{return output << name_;}
+
+std::ostream &ArrayValue::Print(std::ostream &output) const {
+    output << name_;
+    for (ValueList::const_iterator i = indexes_.begin(); i != indexes_.end(); ++ i)
+        output << "[" << *i << "]";
+    return output;
+}
+
+BinaryOpValue::BinaryOpValue(ValuePtr left, ValuePtr right, std::string oper):
+  left_val_(left), right_val_(right), oper_(oper){}
+
+std::ostream &BinaryOpValue::Print(std::ostream &output) const {
+    if (left_val_->GetPrecedence() > GetPrecedence()) output <<  "(" << left_val_ << ")";
+    else output << left_val_;
+    output << " " << oper_ << " ";
+    if (right_val_->GetPrecedence() > GetPrecedence()) output << "(" << right_val_ << ")";
+    else output << right_val_;
+    return output;
+}
+
+int BinaryOpValue::GetPrecedence() const {
+    if (binary_op_precedence.empty()) InitPrecedence();
+    return binary_op_precedence[oper_];
+}
+
+ValuePtr BinaryOpValue::Negate(){
+    if (negate_map.empty()) InitNegateMap();
+    if (negate_map.find(oper_) == negate_map.end()) return Value::Negate();
+    else return new BinaryOpValue(left_val_, right_val_, negate_map[oper_]);
+}
+
+UnaryOpValue::UnaryOpValue(ValuePtr operand, std::string oper, bool postfix):
+  operand_(operand), oper_(oper), postfix_(postfix){}
+
+std::ostream &UnaryOpValue::Print(std::ostream &output) const {
+    if (!postfix_) output << oper_;
+    if (operand_->GetPrecedence() > GetPrecedence()) output << "(" << operand_ << ")";
+    else output << operand_;
+    if (postfix_) output << oper_;
+    return output;
+}
+
+int UnaryOpValue::GetPrecedence() const {return PRECEDENCE_UNARY;}
+
+NegatedValue::NegatedValue(ValuePtr val): UnaryOpValue(val, "!", false){}
+
+ValuePtr NegatedValue::Negate(){return operand_;}
+
+CallValue::CallValue(std::string function, ValueList args): function_(function), args_(args){}
+
+std::ostream &CallValue::Print(std::ostream &output) const {
+    output << function_ << "(";
+    for (ValueList::const_iterator i = args_.begin(); i != args_.end(); ++i) {
+        if (i != args_.begin()) output << ", ";
+        output << *i;
+    }
+    output << ")";
+    return output;
+}

+ 0 - 230
V-Gears-Installer/src/decompiler/decompiler.cpp

@@ -1,230 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * 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.
- */
-
-#include <fstream>
-#include <iostream>
-#include <map>
-#include <string>
-#include <vector>
-#include "../../include/decompiler/ControlFlow.h"
-#include "../../include/decompiler/Disassembler.h"
-#include "../../include/decompiler/Engine.h"
-#include "../../include/decompiler/Instruction.h"
-#include "../../include/decompiler/ObjectFactory.h"
-
-#ifdef _MSC_VER
-#pragma warning (push)
-#pragma warning(disable:4512)
-#pragma warning(disable:4100)
-#endif
-#include <boost/program_options.hpp>
-#include <boost/graph/graphviz.hpp>
-#ifdef _MSC_VER
-#pragma warning (pop)
-#endif
-
-
-namespace po = boost::program_options;
-
-#define ENGINE(id, description, engineClass) engines[std::string(id)] = description; engineFactory.addEntry<engineClass>(std::string(id));
-
-int main(int argc, char** argv) {
-	try {
-		std::map<std::string, std::string> engines;
-		ObjectFactory<std::string, Engine> engineFactory;
-
-		ENGINE("scummv6", "SCUMM v6", Scumm::v6::Scummv6Engine);
-
-        po::options_description visible("Options", 1024);
-		visible.add_options()
-			("help,h", "Produce this help message.")
-			("engine,e", po::value<std::string>(), "Engine the script originates from.")
-			("list,l", "List the supported engines.")
-			("dump-disassembly,d", po::value<std::string>()->implicit_value(""), "Dump the disassembly to a file. Leave out filename to output to stdout.")
-			("dump-graph,g", po::value<std::string>()->implicit_value(""), "Output the control flow graph in dot format to a file. Leave out filename to output to stdout.")
-			("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.")
-			("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.")
-			("no-stack-effect,s", "Leave out the stack effect when printing raw instructions.");
-
-
-        po::options_description args("", 1024);
-		args.add(visible).add_options()
-			("input-file", po::value<std::string>(), "Input file");
-
-		po::positional_options_description fileArg;
-		fileArg.add("input-file", -1);
-
-		po::variables_map vm;
-		try {
-			// FIXME: If specified as the last parameter before the input file name, -d currently requires a filename to specified. -d must be specified earlier than that if outputting to stdout.
-			po::store(po::command_line_parser(argc, argv).options(args).positional(fileArg).run(), vm);
-			po::notify(vm);
-		} catch (std::exception& e) {
-			std::cout << e.what() << std::endl;
-		}
-
-		if (vm.count("list")) {
-			std::cout << "Available engines:" << "\n";
-
-			std::map<std::string, std::string>::iterator it;
-			for (it = engines.begin(); it != engines.end(); it++)
-				std::cout << (*it).first << " " << (*it).second << "\n";
-
-			return 0;
-		}
-
-		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";
-			return 2;
-		} else if (engines.find(vm["engine"].as<std::string>()) == engines.end()) {
-			std::cout << "Unknown engine.\n";
-			return 2;
-		}
-
-		if (vm.count("no-stack-effect")) {
-			setOutputStackEffect(false);
-		}
-
-		std::unique_ptr<Engine> engine(engineFactory.create(vm["engine"].as<std::string>()));
-		engine->_variant = vm["variant"].as<std::string>();
-		std::string inputFile = vm["input-file"].as<std::string>();
-
-		// Disassembly
-		InstVec insts;
-		auto disassembler = engine->GetDisassembler(insts);
-		disassembler->open(inputFile.c_str());
-
-		disassembler->disassemble();
-		if (vm.count("dump-disassembly")) {
-			std::streambuf *buf;
-			std::ofstream of;
-
-			if (vm["dump-disassembly"].as<std::string>() != "") {
-				of.open(vm["dump-disassembly"].as<std::string>().c_str());
-				buf = of.rdbuf();
-			} else {
-				buf = std::cout.rdbuf();
-			}
-			std::ostream out(buf);
-			disassembler->dumpDisassembly(out);
-		}
-
-		if (!engine->supportsCodeFlow() || vm.count("only-disassembly") || insts.empty()) {
-			if (!vm.count("dump-disassembly")) {
-				disassembler->dumpDisassembly(std::cout);
-			}
-			return 0;
-		}
-
-		// Control flow analysis
-		auto cf = std::make_unique<ControlFlow>(insts, *engine);
-		cf->createGroups();
-		Graph g = cf->analyze();
-
-		if (vm.count("dump-graph")) {
-			std::streambuf *buf;
-			std::ofstream of;
-
-			if (vm["dump-graph"].as<std::string>() != "") {
-				of.open(vm["dump-graph"].as<std::string>().c_str());
-				buf = of.rdbuf();
-			} else {
-				buf = std::cout.rdbuf();
-			}
-			std::ostream out(buf);
-			boost::write_graphviz(out, g, boost::make_label_writer(get(boost::vertex_name, g)), boost::MakeArrowheadWriter(get(boost::edge_attribute, g)), GraphProperties(engine.get(), g));
-		}
-
-		if (!engine->supportsCodeGen() || vm.count("only-graph")) {
-			if (!vm.count("dump-graph")) {
-				boost::write_graphviz(std::cout, g, boost::make_label_writer(get(boost::vertex_name, g)), boost::MakeArrowheadWriter(get(boost::edge_attribute, g)), GraphProperties(engine.get(), g));
-			}
-			return 0;
-		}
-
-		// Post-processing of CFG
-		engine->PostCFG(insts, g);
-
-		// Code generation
-        auto cg = engine->GetCodeGenerator(insts, std::cout);
-        cg->generate(insts, g);
-
-		if (vm.count("show-unreachable")) {
-			std::vector<GroupPtr> unreachable;
-			VertexRange vr = boost::vertices(g);
-			for (VertexIterator v = vr.first; v != vr.second; ++v)
-			{
-				GroupPtr gr = boost::get(boost::vertex_name, g, *v);
-				if (gr->stack_level == -1)
-					unreachable.push_back(gr);
-			}
-			if (!unreachable.empty()) {
-				for (size_t i = 0; i < unreachable.size(); i++) {
-					if (i == 0) {
-						if (unreachable.size() == 1)
-							std::cout << boost::format("\n%d unreachable group detected.\n") % unreachable.size();
-						else
-							std::cout << boost::format("\n%d unreachable groups detected.\n") % unreachable.size();
-					}
-					std::cout << "Group " << (i + 1) << ":\n";
-					ConstInstIterator inst = unreachable[i]->_start;
-					do {
-						std::cout << *inst;
-					} while (inst++ != unreachable[i]->_end);
-					std::cout << "----------\n";
-				}
-			}
-		}
-
-	} catch (UnknownOpcodeException &e) {
-		std::cerr << "ERROR: " << e.what() << "\n";
-		return 3;
-	} catch (std::exception &e) {
-		std::cerr << "ERROR: " << e.what() << "\n";
-		return 4;
-	}
-
-	return 0;
-}

+ 1 - 1
V-Gears-Installer/src/decompiler/field/FieldCodeGenerator.cpp

@@ -154,7 +154,7 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
             }
             if ((*instruction)->IsCondJump()){
                 AddOutputLine(
-                  (boost::format("if (%s) then") % stack.Pop()->getString()).str(), false, true
+                  (boost::format("if (%s) then") % stack.Pop()->GetString()).str(), false, true
                 );
                 // If the next instruction is the last in the function, mark the next pass to
                 // add an 'end' after the instruction to close the if.

+ 7 - 7
V-Gears-Installer/src/decompiler/field/FieldDisassembler.cpp

@@ -162,7 +162,7 @@ int FF7::FieldDisassembler::FindId(uint32 start_addr, uint32 end_addr, const Ins
     for (const InstPtr& instruction : insts){
         if (instruction->GetAddress() >= start_addr && instruction->GetAddress() <= end_addr){
             if (instruction->GetOpcode() == FF7::OPCODES::opCodeCHAR)
-                return instruction->GetParam(0)->getSigned();
+                return instruction->GetParam(0)->GetSigned();
         }
     }
     return -1;
@@ -1046,12 +1046,12 @@ bool FF7::FieldDisassembler::ReadOpCodesToPositionOrReturn(
                 // Mark function entity owner as line.
                 is_line = true;
                 ParseOpcode(full_opcode, "LINE", new FieldWalkmeshInstruction(), 0, "ssssss");
-                point_a[0] = this->insts_.back()->GetParam(0)->getSigned();
-                point_a[1] = this->insts_.back()->GetParam(1)->getSigned();
-                point_a[2] = this->insts_.back()->GetParam(2)->getSigned();
-                point_b[0] = this->insts_.back()->GetParam(3)->getSigned();
-                point_b[1] = this->insts_.back()->GetParam(4)->getSigned();
-                point_b[2] = this->insts_.back()->GetParam(5)->getSigned();
+                point_a[0] = this->insts_.back()->GetParam(0)->GetSigned();
+                point_a[1] = this->insts_.back()->GetParam(1)->GetSigned();
+                point_a[2] = this->insts_.back()->GetParam(2)->GetSigned();
+                point_b[0] = this->insts_.back()->GetParam(3)->GetSigned();
+                point_b[1] = this->insts_.back()->GetParam(4)->GetSigned();
+                point_b[2] = this->insts_.back()->GetParam(5)->GetSigned();
                 break;
 
             // Backgnd

+ 34 - 34
V-Gears-Installer/src/decompiler/field/instruction/FieldBackgroundInstruction.cpp

@@ -58,10 +58,10 @@ void FF7::FieldBackgroundInstruction::ProcessInst(
 void FF7::FieldBackgroundInstruction::ProcessBGON(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& background_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& layer_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     code_gen->AddOutputLine(
       (boost::format("-- field:background_on(%1%, %2%)") % background_id % layer_id).str()
@@ -71,10 +71,10 @@ void FF7::FieldBackgroundInstruction::ProcessBGON(CodeGenerator* code_gen){
 void FF7::FieldBackgroundInstruction::ProcessBGOFF(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& background_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& layer_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     code_gen->AddOutputLine(
       (boost::format("-- field:background_off(%1%, %2%)") % background_id % layer_id).str()
@@ -84,7 +84,7 @@ void FF7::FieldBackgroundInstruction::ProcessBGOFF(CodeGenerator* code_gen){
 void FF7::FieldBackgroundInstruction::ProcessBGCLR(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& background_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     code_gen->AddOutputLine(
       (boost::format("-- field:background_clear(%1%)") % background_id).str()
@@ -94,12 +94,12 @@ void FF7::FieldBackgroundInstruction::ProcessBGCLR(CodeGenerator* code_gen){
 void FF7::FieldBackgroundInstruction::ProcessSTPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
-    auto num_entries = params_[4]->getUnsigned() + 1;
+    auto num_entries = params_[4]->GetUnsigned() + 1;
     code_gen->AddOutputLine((
       boost::format("-- store palette %1% to position %2%, start CLUT index 0, %3% entries")
       % source % destination % num_entries
@@ -109,12 +109,12 @@ void FF7::FieldBackgroundInstruction::ProcessSTPAL(CodeGenerator* code_gen){
 void FF7::FieldBackgroundInstruction::ProcessLDPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
-    auto num_entries = params_[4]->getUnsigned() + 1;
+    auto num_entries = params_[4]->GetUnsigned() + 1;
     code_gen->AddOutputLine((
       boost::format("-- load palette %2% from position %1%, start CLUT index 0, %3% entries")
       % source % destination % num_entries
@@ -124,12 +124,12 @@ void FF7::FieldBackgroundInstruction::ProcessLDPAL(CodeGenerator* code_gen){
 void FF7::FieldBackgroundInstruction::ProcessCPPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
-    auto num_entries = params_[4]->getUnsigned() + 1;
+    auto num_entries = params_[4]->GetUnsigned() + 1;
     code_gen->AddOutputLine((
       boost::format("-- copy palette %1% to palette %2%, %3% entries")
       % source % destination % num_entries
@@ -139,21 +139,21 @@ void FF7::FieldBackgroundInstruction::ProcessCPPAL(CodeGenerator* code_gen){
 void FF7::FieldBackgroundInstruction::ProcessADPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[6]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetUnsigned()
     );
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[7]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[4]->getUnsigned(), params_[10]->getUnsigned()
+      cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[9]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[8]->getUnsigned()
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[8]->GetUnsigned()
     );
-    auto num_entries = params_[11]->getUnsigned() + 1;
+    auto num_entries = params_[11]->GetUnsigned() + 1;
     code_gen->AddOutputLine((
       boost::format(
         "-- add RGB(%3%, %4%, %5%) to %6% entries of palette stored at position %1%, "
@@ -165,21 +165,21 @@ void FF7::FieldBackgroundInstruction::ProcessADPAL(CodeGenerator* code_gen){
 void FF7::FieldBackgroundInstruction::ProcessMPPAL2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[6]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetUnsigned()
     );
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[7]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[4]->getUnsigned(), params_[10]->getUnsigned()
+      cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[9]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[8]->getUnsigned()
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[8]->GetUnsigned()
     );
-    auto num_entries = params_[11]->getUnsigned() + 1;
+    auto num_entries = params_[11]->GetUnsigned() + 1;
     code_gen->AddOutputLine((
       boost::format(
         "-- multiply RGB(%3%, %4%, %5%) by %6% entries of palette stored at position %1%, "
@@ -188,10 +188,10 @@ void FF7::FieldBackgroundInstruction::ProcessMPPAL2(CodeGenerator* code_gen){
 }
 
 void FF7::FieldBackgroundInstruction::ProcessSTPLS(CodeGenerator* code_gen){
-    auto source = params_[0]->getUnsigned();
-    auto destination = params_[1]->getUnsigned();
-    auto start_clut = params_[2]->getUnsigned();
-    auto num_entries = params_[3]->getUnsigned() + 1;
+    auto source = params_[0]->GetUnsigned();
+    auto destination = params_[1]->GetUnsigned();
+    auto start_clut = params_[2]->GetUnsigned();
+    auto num_entries = params_[3]->GetUnsigned() + 1;
     code_gen->AddOutputLine((
       boost::format("-- store palette %1% to position %2%, start CLUT index %3%, %4% entries")
       % source % destination % start_clut % num_entries
@@ -199,10 +199,10 @@ void FF7::FieldBackgroundInstruction::ProcessSTPLS(CodeGenerator* code_gen){
 }
 
 void FF7::FieldBackgroundInstruction::ProcessLDPLS(CodeGenerator* code_gen){
-    auto source = params_[0]->getUnsigned();
-    auto destination = params_[1]->getUnsigned();
-    auto startClut = params_[2]->getUnsigned();
-    auto num_entries = params_[3]->getUnsigned() + 1;
+    auto source = params_[0]->GetUnsigned();
+    auto destination = params_[1]->GetUnsigned();
+    auto startClut = params_[2]->GetUnsigned();
+    auto num_entries = params_[3]->GetUnsigned() + 1;
     code_gen->AddOutputLine((
       boost::format("-- load palette %2% from position %1%, start CLUT index %3%, %4% entries")
       % source % destination % startClut % num_entries

+ 16 - 16
V-Gears-Installer/src/decompiler/field/instruction/FieldCameraInstruction.cpp

@@ -53,7 +53,7 @@ void FF7::FieldCameraInstruction::ProcessInst(
 
 void FF7::FieldCameraInstruction::ProcessNFADE(CodeGenerator* code_gen){
     // TODO: Not fully reversed.
-    auto raw_type = params_[4]->getUnsigned();
+    auto raw_type = params_[4]->GetUnsigned();
     if (raw_type == 0){
         code_gen->AddOutputLine("-- fade:clear()");
         return;
@@ -61,16 +61,16 @@ void FF7::FieldCameraInstruction::ProcessNFADE(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const std::string type = raw_type == 12 ? "Fade.SUBTRACT" : "Fade.ADD";
     const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[5]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[5]->GetUnsigned()
     );
     const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[6]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[6]->GetUnsigned()
     );
     const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[7]->getUnsigned()
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     const auto& unknown = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[8]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[8]->GetUnsigned()
     );
     code_gen->AddOutputLine(
       (boost::format("-- fade:fade(%2%, %3%, %4%, %1%, %5%)") % type % r % g % b % unknown).str()
@@ -81,10 +81,10 @@ void FF7::FieldCameraInstruction::ProcessSCR2D(CodeGenerator* code_gen){
     // kUpScaler.
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getSigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetSigned()
     );
     const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getSigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetSigned()
     );
     code_gen->AddOutputLine((
       boost::format("background2d:scroll_to_position(%1% * 3, %2% * 3, Background2D.NONE, 0)")
@@ -95,13 +95,13 @@ void FF7::FieldCameraInstruction::ProcessSCR2D(CodeGenerator* code_gen){
 void FF7::FieldCameraInstruction::ProcessSCR2DC(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[4]->getSigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned()
     );
     const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[5]->getSigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned()
     );
     const auto& speed = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[6]->getUnsigned(),
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[6]->GetUnsigned(),
       FF7::FieldCodeGenerator::ValueType::Float, 30.0f
     );
     code_gen->AddOutputLine((
@@ -112,7 +112,7 @@ void FF7::FieldCameraInstruction::ProcessSCR2DC(CodeGenerator* code_gen){
 
 void FF7::FieldCameraInstruction::ProcessFADE(CodeGenerator* code_gen){
     // TODO: not fully reversed
-    auto raw_type = params_[8]->getUnsigned();
+    auto raw_type = params_[8]->GetUnsigned();
     std::string type;
     switch (raw_type) {
         case 1:
@@ -127,17 +127,17 @@ void FF7::FieldCameraInstruction::ProcessFADE(CodeGenerator* code_gen){
 
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[4]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetUnsigned()
     );
     const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[5]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetUnsigned()
     );
     const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[6]->getUnsigned()
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetUnsigned()
     );
     // TODO: needs to be divided by 30.0f?
-    auto speed = params_[7]->getUnsigned();
-    auto start = params_[9]->getUnsigned();
+    auto speed = params_[7]->GetUnsigned();
+    auto start = params_[9]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("-- fade:fade(%2%, %3%, %4%, %1%, %5%, %6%)") % type % r % g % b % speed % start
     ).str());

+ 10 - 10
V-Gears-Installer/src/decompiler/field/instruction/FieldCondJumpInstruction.cpp

@@ -37,7 +37,7 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
 
     // If condition is a function, add and stop.
     if (!func_name.empty()){
-        uint32 param = params_[0]->getUnsigned();
+        uint32 param = params_[0]->GetUnsigned();
         // Special cases. The first parameter of IFKEY, IFKEYON and IFKEYOFF
         // can be ORed to get the individual keys, but there are two invalid
         // ones: 512 and 1024. They must be XORed.
@@ -49,17 +49,17 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
             if (param >= 1024) param = param ^ 1024;
             if (param >= 512) param = param ^ 512;
         }
-        ValuePtr v = new UnqotedStringValue(func_name + "(" + std::to_string(param) + ")");
+        ValuePtr v = new UnquotedStringValue(func_name + "(" + std::to_string(param) + ")");
         stack.Push(v);
         return;
     }
     std::string op;
-    uint32 type = params_[4]->getUnsigned();
+    uint32 type = params_[4]->GetUnsigned();
     const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
 
     switch (type){
@@ -74,17 +74,17 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
         case 8: op = "|"; break;
         case 9:
             {
-                op = "bit(" + params_[0]->getString() + ", " + params_[2]->getString()
+                op = "bit(" + params_[0]->GetString() + ", " + params_[2]->GetString()
                   + ", " + destination + ") == 1";
-                ValuePtr v = new UnqotedStringValue(op);
+                ValuePtr v = new UnquotedStringValue(op);
                 stack.Push(v);
             }
             return;
         case 0xA:
             {
-                op = "bit(" + params_[0]->getString() + ", " + params_[2]->getString()
+                op = "bit(" + params_[0]->GetString() + ", " + params_[2]->GetString()
                   + ", " + destination + ") == 0";
-                ValuePtr v = new UnqotedStringValue(op);
+                ValuePtr v = new UnquotedStringValue(op);
                 stack.Push(v);
             }
             return;
@@ -117,7 +117,7 @@ uint32 FF7::FieldCondJumpInstruction::GetDestAddress() const{
             break;
         default: throw UnknownJumpTypeException(address_, opcode_);
     }
-    return address_ + params_[jump_param_index]->getUnsigned() + params_size;
+    return address_ + params_[jump_param_index]->GetUnsigned() + params_size;
 }
 
 std::ostream& FF7::FieldCondJumpInstruction::Print(std::ostream &output) const{

+ 13 - 13
V-Gears-Installer/src/decompiler/field/instruction/FieldControlFlowInstruction.cpp

@@ -60,11 +60,11 @@ void FF7::FF7ControlFlowInstruction::ProcessREQ(
   CodeGenerator* code_gen, const FieldEngine& engine
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& entity = engine.EntityByIndex(params_[0]->getSigned());
+    const auto& entity = engine.EntityByIndex(params_[0]->GetSigned());
     const auto& script_name = cg->GetFormatter().FunctionName(
-      entity.GetName(), entity.FunctionByIndex(params_[2]->getUnsigned())
+      entity.GetName(), entity.FunctionByIndex(params_[2]->GetUnsigned())
     );
-    auto priority = params_[1]->getUnsigned();
+    auto priority = params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("script:request(Script.ENTITY, \"%1%\", \"%2%\", %3%)")
       % entity.GetName() % script_name % priority
@@ -75,11 +75,11 @@ void FF7::FF7ControlFlowInstruction::ProcessREQSW(
   CodeGenerator* code_gen, const FieldEngine& engine
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& entity = engine.EntityByIndex(params_[0]->getSigned());
+    const auto& entity = engine.EntityByIndex(params_[0]->GetSigned());
     const auto& script_name = cg->GetFormatter().FunctionName(
-      entity.GetName(), entity.FunctionByIndex(params_[2]->getUnsigned())
+      entity.GetName(), entity.FunctionByIndex(params_[2]->GetUnsigned())
     );
-    auto priority = params_[1]->getUnsigned();
+    auto priority = params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("script:request_start_sync(Script.ENTITY, \"%1%\", \"%2%\", %3%)")
       % entity.GetName() % script_name % priority
@@ -91,11 +91,11 @@ void FF7::FF7ControlFlowInstruction::ProcessREQEW(
 ){
     try{
         FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-        const auto& entity = engine.EntityByIndex(params_[0]->getSigned());
+        const auto& entity = engine.EntityByIndex(params_[0]->GetSigned());
         const auto& script_name = cg->GetFormatter().FunctionName(
-          entity.GetName(), entity.FunctionByIndex(params_[2]->getUnsigned())
+          entity.GetName(), entity.FunctionByIndex(params_[2]->GetUnsigned())
         );
-        auto priority = params_[1]->getUnsigned();
+        auto priority = params_[1]->GetUnsigned();
         code_gen->AddOutputLine((
           boost::format("script:request_end_sync(Script.ENTITY, \"%1%\", \"%2%\", %3%)")
           % entity.GetName() % script_name % priority
@@ -104,14 +104,14 @@ void FF7::FF7ControlFlowInstruction::ProcessREQEW(
     catch (const DecompilerException&){
         code_gen->AddOutputLine((
           boost::format("-- ERROR call to non existing function index %1%")
-          % params_[2]->getUnsigned()
+          % params_[2]->GetUnsigned()
         ).str());
     }
 }
 
 void FF7::FF7ControlFlowInstruction::ProcessRETTO(CodeGenerator* code_gen){
-    auto entity_index = params_[0]->getUnsigned();
-    auto priority = params_[1]->getUnsigned();
+    auto entity_index = params_[0]->GetUnsigned();
+    auto priority = params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("-- return_to(script_id_in_current_entity=%2%, priority=%1%)")
       % entity_index % priority
@@ -120,6 +120,6 @@ void FF7::FF7ControlFlowInstruction::ProcessRETTO(CodeGenerator* code_gen){
 
 void FF7::FF7ControlFlowInstruction::ProcessWAIT(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
-      boost::format("script:wait(%1%)") % (params_[0]->getUnsigned() / 30.0f)
+      boost::format("script:wait(%1%)") % (params_[0]->GetUnsigned() / 30.0f)
     ).str());
 }

+ 24 - 24
V-Gears-Installer/src/decompiler/field/instruction/FieldMathInstruction.cpp

@@ -60,13 +60,13 @@ void FF7::FieldMathInstruction::ProcessInst(
         case OPCODES::DIV2: code_gen->WriteTodo(md.GetEntityName(), "DIV2"); break;
         case OPCODES::MOD:
             {
-                const uint32 source_bank = params_[0]->getUnsigned();
-                const uint32 sourceaddress__or_value = params_[2]->getUnsigned();
+                const uint32 source_bank = params_[0]->GetUnsigned();
+                const uint32 sourceaddress__or_value = params_[2]->GetUnsigned();
                 auto source = FF7::FieldCodeGenerator::FormatValueOrVariable(
                   cg->GetFormatter(), source_bank, sourceaddress__or_value
                 );
-                const uint32 dest_bank = params_[1]->getUnsigned();
-                const uint32 destaddress_ = params_[3]->getUnsigned();
+                const uint32 dest_bank = params_[1]->GetUnsigned();
+                const uint32 destaddress_ = params_[3]->GetUnsigned();
                 auto dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
                   cg->GetFormatter(), dest_bank, destaddress_
                 );
@@ -107,10 +107,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedPLUS(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and negative wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% + %2%") % lhs % rhs).str());
@@ -121,10 +121,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedPLUS2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and negative wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% + %2%") % lhs % rhs).str());
@@ -135,10 +135,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedMINUS(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and positive wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% - %2%") % lhs % rhs).str());
@@ -149,10 +149,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedMINUS2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and positive wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% - %2%") % lhs % rhs).str());
@@ -163,7 +163,7 @@ void FF7::FieldMathInstruction::ProcessSaturatedINC(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and negative wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% + 1") % dest).str());
@@ -174,7 +174,7 @@ void FF7::FieldMathInstruction::ProcessSaturatedINC2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and negative wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% + 1") % dest).str());
@@ -185,7 +185,7 @@ void FF7::FieldMathInstruction::ProcessSaturatedDEC(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and positive wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% - 1") % dest).str());
@@ -196,7 +196,7 @@ void FF7::FieldMathInstruction::ProcessSaturatedDEC2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes and positive wrap-around.
     code_gen->AddOutputLine((boost::format("%1% = %1% - 1") % dest).str());
@@ -213,10 +213,10 @@ void FF7::FieldMathInstruction::ProcessSETBYTE_SETWORD(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     // TODO: respect destination bank sizes (16-bit writes only affect low byte)
     code_gen->AddOutputLine((boost::format("%1% = %2%") % destination % source).str());
@@ -224,13 +224,13 @@ void FF7::FieldMathInstruction::ProcessSETBYTE_SETWORD(CodeGenerator* code_gen){
 
 void FF7::FieldMathInstruction::ProcessBITON(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("bit_on(%1%, %2%, %3%)")
-      % params_[0]->getUnsigned() % params_[2]->getUnsigned() % params_[3]->getUnsigned()
+      % params_[0]->GetUnsigned() % params_[2]->GetUnsigned() % params_[3]->GetUnsigned()
     ).str());
 }
 
 void FF7::FieldMathInstruction::ProcessBITOFF(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("bit_off(%1%, %2%, %3%)")
-      % params_[0]->getUnsigned() % params_[2]->getUnsigned() % params_[3]->getUnsigned()
+      % params_[0]->GetUnsigned() % params_[2]->GetUnsigned() % params_[3]->GetUnsigned()
     ).str());
 }
 
@@ -238,10 +238,10 @@ void FF7::FieldMathInstruction::ProcessPLUSx_MINUSx(CodeGenerator* code_gen, con
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     // TODO: repect destination bank sizes and wraparound
     code_gen->AddOutputLine((boost::format("%1% = %1% %2% %3%") % lhs % op % rhs).str());
@@ -251,7 +251,7 @@ void FF7::FieldMathInstruction::ProcessINCx_DECx(CodeGenerator* code_gen, const
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned()
     );
     // TODO: repect destination bank sizes and wraparound
     code_gen->AddOutputLine((boost::format("%1% = %1% %2% 1") % destination % op).str());
@@ -261,7 +261,7 @@ void FF7::FieldMathInstruction::ProcessRANDOM(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned()
     );
     // TODO: Respect destination bank sizes (16-bit writes only affect low byte).
     // TODO: RNG emulation?

+ 18 - 18
V-Gears-Installer/src/decompiler/field/instruction/FieldMediaInstruction.cpp

@@ -55,21 +55,21 @@ void FF7::FieldMediaInstruction::ProcessInst(
 void FF7::FieldMediaInstruction::ProcessAKAO2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& param1 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[7]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     const auto& param2 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[8]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[8]->GetUnsigned()
     );
     const auto& param3 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[9]->getUnsigned()
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     const auto& param4 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[10]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     const auto& param5 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[5]->getUnsigned(), params_[11]->getUnsigned()
+      cg->GetFormatter(), params_[5]->GetUnsigned(), params_[11]->GetUnsigned()
     );
-    auto op = params_[6]->getUnsigned();
+    auto op = params_[6]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("-- music:execute_akao(0x%6$02x, %1%, %2%, %3%, %4%, %5%)")
       % param1 % param2 % param3 % param4 % param5 % op
@@ -79,17 +79,17 @@ void FF7::FieldMediaInstruction::ProcessAKAO2(CodeGenerator* code_gen){
 void FF7::FieldMediaInstruction::ProcessMUSIC(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
       boost::format("-- music:execute_akao(0x10, pointer_to_field_AKAO_%1%)")
-      % params_[0]->getUnsigned()
+      % params_[0]->GetUnsigned()
     ).str());
 }
 
 void FF7::FieldMediaInstruction::ProcessSOUND(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& soundId = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& panning = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     code_gen->AddOutputLine(
       (boost::format("-- music:execute_akao(0x20, %1%, %2%)") % soundId % panning).str()
@@ -99,21 +99,21 @@ void FF7::FieldMediaInstruction::ProcessSOUND(CodeGenerator* code_gen){
 void FF7::FieldMediaInstruction::ProcessAKAO(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& param1 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[7]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     const auto& param2 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[8]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[8]->GetUnsigned()
     );
     const auto& param3 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[9]->getUnsigned()
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     const auto& param4 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[10]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     const auto& param5 = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[5]->getUnsigned(), params_[11]->getUnsigned()
+      cg->GetFormatter(), params_[5]->GetUnsigned(), params_[11]->GetUnsigned()
     );
-    auto op = params_[6]->getUnsigned();
+    auto op = params_[6]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("-- music:execute_akao(0x%6$02x, %1%, %2%, %3%, %4%, %5%)")
       % param1 % param2 % param3 % param4 % param5 % op
@@ -123,13 +123,13 @@ void FF7::FieldMediaInstruction::ProcessAKAO(CodeGenerator* code_gen){
 void FF7::FieldMediaInstruction::ProcessMULCK(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
       boost::format("-- music:lock(%1%)")
-      % FF7::FieldCodeGenerator::FormatBool(params_[0]->getUnsigned())
+      % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
 }
 
 void FF7::FieldMediaInstruction::ProcessPMVIE(CodeGenerator* code_gen){
     code_gen->AddOutputLine(
-      (boost::format("-- field:movie_set(%1%)") % params_[0]->getUnsigned()
+      (boost::format("-- field:movie_set(%1%)") % params_[0]->GetUnsigned()
     ).str());
 }
 
@@ -141,7 +141,7 @@ void FF7::FieldMediaInstruction::ProcessMVIEF(CodeGenerator* code_gen){
     // TODO: Check for assignment to value.
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[2]->getUnsigned());
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned());
     code_gen->AddOutputLine(
       (boost::format("-- %1% = field:get_movie_frame()") % destination).str()
     );

+ 61 - 61
V-Gears-Installer/src/decompiler/field/instruction/FieldModelInstruction.cpp

@@ -148,37 +148,37 @@ void FF7::FieldModelInstruction::ProcessInst(
 }
 
 void FF7::FieldModelInstruction::ProcessJOIN(CodeGenerator* code_gen){
-    code_gen->AddOutputLine("join_party(" + std::to_string(params_[0]->getUnsigned()) + ")");
+    code_gen->AddOutputLine("join_party(" + std::to_string(params_[0]->GetUnsigned()) + ")");
 }
 
 void FF7::FieldModelInstruction::ProcessSPLIT(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const auto& ax = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[6]->getSigned(),
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& ay = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[7]->getSigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& ar = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[8]->getSigned(),
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[8]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& bx = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[9]->getSigned(),
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& by = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[4]->getUnsigned(), params_[10]->getSigned(),
+      cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& br = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[5]->getUnsigned(), params_[11]->getSigned(),
+      cg->GetFormatter(), params_[5]->GetUnsigned(), params_[11]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
-    const auto& speed = params_[12]->getUnsigned();
+    const auto& speed = params_[12]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("split_party(%1%, %2%, %3%, %4%, %5%, %6%, %7%)")
       % ax % ay % ar % bx % by % br % speed
@@ -188,7 +188,7 @@ void FF7::FieldModelInstruction::ProcessSPLIT(CodeGenerator* code_gen){
 void FF7::FieldModelInstruction::ProcessTLKON(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_talkable(%2%)")
-      % entity % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->getUnsigned())
+      % entity % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
     ).str());
 }
 
@@ -209,9 +209,9 @@ void FF7::FieldModelInstruction::ProcessDFANM(
 ){
     // ID will be fixed-up downstream.
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    auto animation_id = params_[0]->getUnsigned();
+    auto animation_id = params_[0]->GetUnsigned();
     // TODO: check for zero.
-    auto speed = 1.0f / params_[1]->getUnsigned();
+    auto speed = 1.0f / params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_default_animation(\"%2%\") -- speed %3%")
       % entity % cg->GetFormatter().AnimationName(char_id, animation_id) % speed
@@ -227,9 +227,9 @@ void FF7::FieldModelInstruction::ProcessANIME1(
 ){
     // ID will be fixed-up downstream.
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    auto animation_id = params_[0]->getUnsigned();
+    auto animation_id = params_[0]->GetUnsigned();
     // TODO: check for zero.
-    auto speed = 1.0f / params_[1]->getUnsigned();
+    auto speed = 1.0f / params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("self.%1%:play_animation(\"%2%\") -- speed %3%")
       % entity % cg->GetFormatter().AnimationName(char_id, animation_id) % speed
@@ -240,7 +240,7 @@ void FF7::FieldModelInstruction::ProcessANIME1(
 void FF7::FieldModelInstruction::ProcessVISI(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_visible(%2%)")
-      % entity % FF7::FieldCodeGenerator::FormatBool(params_[0]->getUnsigned())
+      % entity % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
 }
 
@@ -248,19 +248,19 @@ void FF7::FieldModelInstruction::ProcessXYZI(CodeGenerator* code_gen, const std:
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[4]->getSigned(),
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[5]->getSigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& z = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[6]->getSigned(),
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& triangle_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[7]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_position(%2%, %3%, %4%) -- triangle ID %5%")
@@ -272,11 +272,11 @@ void FF7::FieldModelInstruction::ProcessMOVE(CodeGenerator* code_gen, const std:
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getSigned(),
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getSigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     code_gen->AddOutputLine(
@@ -289,7 +289,7 @@ void FF7::FieldModelInstruction::ProcessMSPED(CodeGenerator* code_gen, const std
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const auto& speed = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[2]->getUnsigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned(),
       FF7::FieldCodeGenerator::ValueType::Float, 256.0f * scale / 30.0f
     );
     code_gen->AddOutputLine(
@@ -300,7 +300,7 @@ void FF7::FieldModelInstruction::ProcessMSPED(CodeGenerator* code_gen, const std
 void FF7::FieldModelInstruction::ProcessDIR(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& degrees = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned(),
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned(),
       FF7::FieldCodeGenerator::ValueType::Float, 256.0f / 360.0f
     );
     code_gen->AddOutputLine((boost::format("self.%1%:set_rotation(%2%)") % entity % degrees).str());
@@ -309,20 +309,20 @@ void FF7::FieldModelInstruction::ProcessDIR(CodeGenerator* code_gen, const std::
 void FF7::FieldModelInstruction::ProcessTURNGEN(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& degrees = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[2]->getUnsigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned(),
       FF7::FieldCodeGenerator::ValueType::Float, 256.0f / 360.0f
     );
     std::string direction;
-    switch (params_[3]->getUnsigned()){
+    switch (params_[3]->GetUnsigned()){
         case 0: direction = "Entity.CLOCKWISE"; break;
         case 1: direction = "Entity.ANTICLOCKWISE"; break;
         case 2: direction = "Entity.CLOSEST"; break;
         // Default to closest:
         default: direction = "Entity.CLOSEST"; break;
     }
-    auto steps = params_[4]->getUnsigned();
+    auto steps = params_[4]->GetUnsigned();
     std::string step_type;
-    switch (params_[5]->getUnsigned()){
+    switch (params_[5]->GetUnsigned()){
         case 1: step_type = "Entity.LINEAR"; break;
         case 2: step_type = "Entity.SMOOTH"; break;
         // Default to smooth
@@ -340,9 +340,9 @@ void FF7::FieldModelInstruction::ProcessGETAI(CodeGenerator* code_gen, const Fie
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: check for assignment to literal.
     const auto& variable = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
-    const auto& entity = engine.EntityByIndex(params_[2]->getUnsigned());
+    const auto& entity = engine.EntityByIndex(params_[2]->GetUnsigned());
     code_gen->AddOutputLine(
       (boost::format("%1% = entity_manager:get_entity(\"%2%\"):get_move_triangle_id()")
       % variable % entity.GetName()
@@ -354,9 +354,9 @@ void FF7::FieldModelInstruction::ProcessANIM_2(
 ){
     // ID will be fixed-up downstream.
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    auto animation_id = params_[0]->getUnsigned();
+    auto animation_id = params_[0]->GetUnsigned();
     // TODO: check for zero.
-    auto speed = 1.0f / params_[1]->getUnsigned();
+    auto speed = 1.0f / params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("self.%1%:play_animation_stop(\"%2%\") -- speed %3%")
       % entity % cg->GetFormatter().AnimationName(char_id, animation_id) % speed
@@ -368,11 +368,11 @@ void FF7::FieldModelInstruction::ProcessCANIM2(
   CodeGenerator* code_gen, const std::string& entity, int char_id
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    auto animation_id = params_[0]->getUnsigned();
-    auto start_frame = params_[1]->getUnsigned() / 30.0f;
-    auto end_frame = params_[2]->getUnsigned() / 30.0f;
+    auto animation_id = params_[0]->GetUnsigned();
+    auto start_frame = params_[1]->GetUnsigned() / 30.0f;
+    auto end_frame = params_[2]->GetUnsigned() / 30.0f;
     // TODO: check for zero.
-    auto speed = 1.0f / params_[3]->getUnsigned();
+    auto speed = 1.0f / params_[3]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("self.%1%:play_animation(\"%2%\", %3%, %4%) -- speed %5%")
       % entity % cg->GetFormatter().AnimationName(char_id, animation_id)
@@ -386,11 +386,11 @@ void FF7::FieldModelInstruction::ProcessCANM_2(
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // ID will be fixed-up downstream.
-    auto animation_id = params_[0]->getUnsigned();
-    auto start_frame = params_[1]->getUnsigned() / 30.0f;
-    auto end_frame = params_[2]->getUnsigned() / 30.0f;
+    auto animation_id = params_[0]->GetUnsigned();
+    auto start_frame = params_[1]->GetUnsigned() / 30.0f;
+    auto end_frame = params_[2]->GetUnsigned() / 30.0f;
     // TODO: check for zero.
-    auto speed = 1.0f / params_[3]->getUnsigned();
+    auto speed = 1.0f / params_[3]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("self.%1%:play_animation_stop(\"%2%\", %3%, %4%) -- speed %5%")
       % entity % cg->GetFormatter().AnimationName(char_id, animation_id)
@@ -400,7 +400,7 @@ void FF7::FieldModelInstruction::ProcessCANM_2(
 }
 
 void FF7::FieldModelInstruction::ProcessCC(CodeGenerator* code_gen, const FieldEngine& engine){
-    const auto& entity = engine.EntityByIndex(params_[0]->getUnsigned());
+    const auto& entity = engine.EntityByIndex(params_[0]->GetUnsigned());
     code_gen->AddOutputLine(
       (boost::format("entity_manager:set_player_entity(\"%1%\")") % entity.GetName()).str()
     );
@@ -410,18 +410,18 @@ void FF7::FieldModelInstruction::ProcessJUMP(CodeGenerator* code_gen, const std:
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     float x = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[4]->getSigned(),
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     ));
     float y = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[5]->getSigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     ));
     int i = atoi(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[6]->getSigned()
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned()
     ).c_str());
     int steps = atoi(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[7]->getSigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetSigned()
     ).c_str());
     //x *= 0.00781250273224;
     //y *= 0.00781250273224;
@@ -443,9 +443,9 @@ void FF7::FieldModelInstruction::ProcessAXYZI(CodeGenerator* code_gen){
     const float scale = 128.0f * cg->GetScaleFactor();
     code_gen->AddOutputLine((
       boost::format("axyzi(%1%, %2%, %3%, %4%, %5%, %6%, %7%, %8%, %9%, %10%)")
-      % params_[0]->getSigned() % params_[1]->getSigned() % params_[2]->getSigned()
-      % params_[3]->getSigned() % params_[4]->getSigned() % params_[5]->getSigned()
-      % params_[6]->getSigned() % params_[7]->getSigned() % params_[8]->getSigned()
+      % params_[0]->GetSigned() % params_[1]->GetSigned() % params_[2]->GetSigned()
+      % params_[3]->GetSigned() % params_[4]->GetSigned() % params_[5]->GetSigned()
+      % params_[6]->GetSigned() % params_[7]->GetSigned() % params_[8]->GetSigned()
       % scale
     ).str());
 }
@@ -454,28 +454,28 @@ void FF7::FieldModelInstruction::ProcessLADER(CodeGenerator* code_gen, const std
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[4]->getSigned(),
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[5]->getSigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     const auto& z = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[6]->getSigned(),
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     );
     uint end_triangle = atoi(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[7]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetUnsigned()
     ).c_str());
-    uint keys = params_[8]->getUnsigned();
-    uint animation = params_[9]->getUnsigned();
-    //float orientation = params_[10]->getUnsigned() / (256.0f / 360.0f);
+    uint keys = params_[8]->GetUnsigned();
+    uint animation = params_[9]->GetUnsigned();
+    //float orientation = params_[10]->GetUnsigned() / (256.0f / 360.0f);
     const auto& orientation = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), 0, params_[10]->getSigned(),
+      cg->GetFormatter(), 0, params_[10]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, 256.0f / 360.0f
     );
-    uint speed = params_[11]->getUnsigned();
+    uint speed = params_[11]->GetUnsigned();
     // TODO: Animation hardcoded as "btce".
     // TODO: Orientation and speed not set.
     code_gen->AddOutputLine((
@@ -490,7 +490,7 @@ void FF7::FieldModelInstruction::ProcessLADER(CodeGenerator* code_gen, const std
 void FF7::FieldModelInstruction::ProcessSOLID(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_solid(%2%)")
-      % entity % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->getUnsigned())
+      % entity % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
     ).str());
 }
 
@@ -498,19 +498,19 @@ void FF7::FieldModelInstruction::ProcessOFST(CodeGenerator* code_gen, const std:
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     float x = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[5]->getSigned(),
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[5]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     ));
     float y = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(),params_[6]->getSigned(),
+      cg->GetFormatter(), params_[1]->GetUnsigned(),params_[6]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     ));
     float z = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[2]->getUnsigned(), params_[7]->getSigned(),
+      cg->GetFormatter(), params_[2]->GetUnsigned(), params_[7]->GetSigned(),
       FF7::FieldCodeGenerator::ValueType::Float, scale
     ));
     float speed = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[3]->getUnsigned(), params_[8]->getUnsigned()
+      cg->GetFormatter(), params_[3]->GetUnsigned(), params_[8]->GetUnsigned()
     ));
     // Spatial coordinates need to be scaled down.
     // TODO: This number is empirically deducted. Why this number?
@@ -522,6 +522,6 @@ void FF7::FieldModelInstruction::ProcessOFST(CodeGenerator* code_gen, const std:
     code_gen->AddOutputLine((
       boost::format("self.%1%:offset_to_position(%2%, %3%, %4%, %5%, %6%)")
       % entity % x % y % z
-      % (params_[4]->getUnsigned() ? "Entity.SMOOTH" : "Entity.LINEAR")% speed
+      % (params_[4]->GetUnsigned() ? "Entity.SMOOTH" : "Entity.LINEAR")% speed
     ).str());
 }

+ 11 - 11
V-Gears-Installer/src/decompiler/field/instruction/FieldModuleInstruction.cpp

@@ -33,7 +33,7 @@ void FF7::FieldModuleInstruction::ProcessInst(
         case (OPCODES::SPECIAL << 8) | OPCODES_SPECIAL::ARROW:
             code_gen->AddOutputLine((
               boost::format("game:pointer_enable(%1%)")
-              % (params_[0]->getUnsigned() ? "true" : "false")
+              % (params_[0]->GetUnsigned() ? "true" : "false")
             ).str());
             break;
         case (OPCODES::SPECIAL << 8) | OPCODES_SPECIAL::PNAME:
@@ -54,13 +54,13 @@ void FF7::FieldModuleInstruction::ProcessInst(
         case (OPCODES::SPECIAL << 8) | OPCODES_SPECIAL::BTLCK:
             code_gen->AddOutputLine((
               boost::format("game:battle_enable(%1%)")
-              % (params_[0]->getUnsigned() ? "true" : "false")
+              % (params_[0]->GetUnsigned() ? "true" : "false")
             ).str());
             break;
         case (OPCODES::SPECIAL << 8) | OPCODES_SPECIAL::MVLCK:
             code_gen->AddOutputLine((
               boost::format("game:movie_enable(%1%)")
-              % (params_[0]->getUnsigned() ? "true" : "false")
+              % (params_[0]->GetUnsigned() ? "true" : "false")
             ).str());
             break;
         case (OPCODES::SPECIAL << 8) | OPCODES_SPECIAL::SPCNM:
@@ -85,7 +85,7 @@ void FF7::FieldModuleInstruction::ProcessInst(
             // Gateway function will do nothing if this is set to true
             code_gen->AddOutputLine(
               std::string("FFVII.Data.DisableGateways=")
-              + (params_[0]->getUnsigned() ? "true" : "false")
+              + (params_[0]->GetUnsigned() ? "true" : "false")
             );
             break;
         // Prepare to change map, don't need to output anything for this.
@@ -104,7 +104,7 @@ void FF7::FieldModuleInstruction::ProcessInst(
 void FF7::FieldModuleInstruction::ProcessBATTLE(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& battle_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[1]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[1]->GetUnsigned()
     );
     code_gen->AddOutputLine((boost::format("entity_manager:battle_run(%1%)") % battle_id).str());
 }
@@ -112,23 +112,23 @@ void FF7::FieldModuleInstruction::ProcessBATTLE(CodeGenerator* code_gen){
 void FF7::FieldModuleInstruction::ProcessBTLON(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
       boost::format("entity_manager:random_encounters_on(%1%)")
-      % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->getUnsigned())
+      % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
     ).str());
 }
 
 void FF7::FieldModuleInstruction::ProcessMAPJUMP(CodeGenerator* code_gen, Function& func){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto target_map_id = params_[0]->getUnsigned();
+    const auto target_map_id = params_[0]->GetUnsigned();
     FunctionMetaData md(func.metadata);
     const std::string source_spawn_point_name = cg->GetFormatter().SpawnPointName(
       target_map_id, md.GetEntityName(), func.name, address_
     );
     cg->GetFormatter().AddSpawnPoint(
       target_map_id, md.GetEntityName(), func.name, address_,
-      params_[1]->getSigned(), // X
-      params_[2]->getSigned(), // Y
-      params_[3]->getSigned(), // Walk mesh triangle ID
-      params_[4]->getSigned()  // Angle
+      params_[1]->GetSigned(), // X
+      params_[2]->GetSigned(), // Y
+      params_[3]->GetSigned(), // Walk mesh triangle ID
+      params_[4]->GetSigned()  // Angle
     );
     const std::string target_map_name = cg->GetFormatter().MapName(target_map_id);
     code_gen->AddOutputLine(

+ 5 - 5
V-Gears-Installer/src/decompiler/field/instruction/FieldPartyInstruction.cpp

@@ -65,21 +65,21 @@ void FF7::FieldPartyInstruction::ProcessInst(
 void FF7::FieldPartyInstruction::ProcessSTITM(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const auto& item_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[0]->getUnsigned(), params_[2]->getUnsigned()
+      cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     const auto& amount = FF7::FieldCodeGenerator::FormatValueOrVariable(
-      cg->GetFormatter(), params_[1]->getUnsigned(), params_[3]->getUnsigned()
+      cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     code_gen->AddOutputLine((boost::format("FFVII.add_item(%1%, %2%)") % item_id % amount).str());
 }
 
 void FF7::FieldPartyInstruction::ProcessPRTYE(CodeGenerator* code_gen){
     FieldCodeGenerator* gc = static_cast<FieldCodeGenerator*>(code_gen);
-    auto char_id_1 = gc->GetFormatter().CharName(params_[0]->getUnsigned());
+    auto char_id_1 = gc->GetFormatter().CharName(params_[0]->GetUnsigned());
     char_id_1 = (char_id_1 == "") ? "nil" : ("\"" + char_id_1 + "\"");
-    auto char_id_2 = gc->GetFormatter().CharName(params_[1]->getUnsigned());
+    auto char_id_2 = gc->GetFormatter().CharName(params_[1]->GetUnsigned());
     char_id_2 = (char_id_2 == "") ? "nil" : ("\"" + char_id_2 + "\"");
-    auto char_id_3 = gc->GetFormatter().CharName(params_[2]->getUnsigned());
+    auto char_id_3 = gc->GetFormatter().CharName(params_[2]->GetUnsigned());
     char_id_3 = (char_id_3 == "") ? "nil" : ("\"" + char_id_3 + "\"");
     code_gen->AddOutputLine((
       boost::format("FFVII.set_party(%1%, %2%, %3%)") % char_id_1 % char_id_2 % char_id_3

+ 2 - 2
V-Gears-Installer/src/decompiler/field/instruction/FieldUncondJumpInstruction.cpp

@@ -35,10 +35,10 @@ uint32 FF7::FieldUncondJumpInstruction::GetDestAddress() const{
       static_cast<OPCODES>(opcode_) == OPCODES::JMPF
       || static_cast<OPCODES>(opcode_) == OPCODES::JMPFL){
         // Short or long forward jump.
-        return address_ + params_[0]->getUnsigned() + 1;
+        return address_ + params_[0]->GetUnsigned() + 1;
     }
     // Backwards jump,  eOpcodes::JMPB/L.
-    return address_ - params_[0]->getUnsigned();
+    return address_ - params_[0]->GetUnsigned();
 }
 
 std::ostream& FF7::FieldUncondJumpInstruction::Print(std::ostream &output) const{

+ 9 - 9
V-Gears-Installer/src/decompiler/field/instruction/FieldWalkmeshInstruction.cpp

@@ -35,8 +35,8 @@ void FF7::FieldWalkmeshInstruction::ProcessInst(
             // Triangle id, on or off
             code_gen->AddOutputLine(
                 (boost::format("walkmesh:lock_walkmesh(%1%, %2%)")
-                % params_[0]->getUnsigned()
-                % FF7::FieldCodeGenerator::FormatBool(params_[1]->getUnsigned())).str());
+                % params_[0]->GetUnsigned()
+                % FF7::FieldCodeGenerator::FormatBool(params_[1]->GetUnsigned())).str());
             break;
         case OPCODES::LINE: ProcessLINE(code_gen, md.GetEntityName()); break;
         case OPCODES::LINON: code_gen->WriteTodo(md.GetEntityName(), "LINON"); break;
@@ -51,17 +51,17 @@ void FF7::FieldWalkmeshInstruction::ProcessInst(
 void FF7::FieldWalkmeshInstruction::ProcessUC(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
       boost::format("entity_manager:player_lock(%1%)")
-      % FF7::FieldCodeGenerator::FormatBool(params_[0]->getUnsigned())
+      % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
 }
 
 void FF7::FieldWalkmeshInstruction::ProcessLINE(CodeGenerator* code_gen, const std::string& entity){
-    float xa = params_[0]->getSigned();
-    float ya = params_[1]->getSigned();
-    float za = params_[2]->getSigned();
-    float xb = params_[3]->getSigned();
-    float yb = params_[4]->getSigned();
-    float zb = params_[5]->getSigned();
+    float xa = params_[0]->GetSigned();
+    float ya = params_[1]->GetSigned();
+    float za = params_[2]->GetSigned();
+    float xb = params_[3]->GetSigned();
+    float yb = params_[4]->GetSigned();
+    float zb = params_[5]->GetSigned();
     // Scale down. TODO: Why this number?
     xa *= 0.00781249709639;
     ya *= 0.00781249709639;

+ 10 - 10
V-Gears-Installer/src/decompiler/field/instruction/FieldWindowInstruction.cpp

@@ -60,11 +60,11 @@ void FF7::FieldWindowInstruction::ProcessInst(
 
 void FF7::FieldWindowInstruction::ProcessWINDOW(CodeGenerator* code_gen){
     // Initializes a new window. It won't be displayed until MESSAGE is used.
-    auto windowId = params_[0]->getUnsigned();
-    auto x = params_[1]->getUnsigned();
-    auto y = params_[2]->getUnsigned();
-    auto width = params_[3]->getUnsigned();
-    auto height = params_[4]->getUnsigned();
+    auto windowId = params_[0]->GetUnsigned();
+    auto x = params_[1]->GetUnsigned();
+    auto y = params_[2]->GetUnsigned();
+    auto width = params_[3]->GetUnsigned();
+    auto height = params_[4]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("dialog:dialog_open(\"%1%\", %2%, %3%, %4%, %5%)")
       % windowId % x % y % width % height
@@ -75,8 +75,8 @@ void FF7::FieldWindowInstruction::ProcessMESSAGE(
   CodeGenerator* code_gen, const std::string& script_name
 ){
     // Displays a dialog in the WINDOW that has previously been initialized to display this dialog.
-    auto window_id = params_[0]->getUnsigned();
-    auto dialog_id = params_[1]->getUnsigned();
+    auto window_id = params_[0]->GetUnsigned();
+    auto dialog_id = params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
       boost::format("dialog:dialog_set_text(\"%1%\", \"%2%_%3%\")")
       % window_id % script_name % dialog_id
@@ -89,19 +89,19 @@ void FF7::FieldWindowInstruction::ProcessMESSAGE(
 
 void FF7::FieldWindowInstruction::ProcessWCLSE(CodeGenerator* code_gen){
     // Close a dialog.
-    auto windowId = params_[0]->getUnsigned();
+    auto windowId = params_[0]->GetUnsigned();
     code_gen->AddOutputLine((boost::format("dialog:dialog_close(\"%1%\")") % windowId).str());
 }
 
 void FF7::FieldWindowInstruction::ProcessMPNAM(CodeGenerator* code_gen){
     code_gen->AddOutputLine(
-      (boost::format("-- field:map_name(%1%)") % params_[0]->getUnsigned()).str()
+      (boost::format("-- field:map_name(%1%)") % params_[0]->GetUnsigned()).str()
     );
 }
 
 void FF7::FieldWindowInstruction::ProcessMENU2(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
       boost::format("-- field:menu_lock(%1%)")
-      % FF7::FieldCodeGenerator::FormatBool(params_[0]->getUnsigned())
+      % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
 }

+ 1 - 1
V-Gears-Installer/src/decompiler/instruction/BoolNegateStackInstruction.cpp

@@ -17,4 +17,4 @@
 
 void BoolNegateStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
-){stack.Push(stack.Pop()->negate());}
+){stack.Push(stack.Pop()->Negate());}

+ 1 - 1
V-Gears-Installer/src/decompiler/instruction/DupStackInstruction.cpp

@@ -20,7 +20,7 @@ void DupStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator *code_gen
 ){
     std::stringstream s;
-    ValuePtr p = stack.Pop()->dup(s);
+    ValuePtr p = stack.Pop()->Dup(s);
     if (s.str().length() > 0) code_gen->AddOutputLine(s.str());
     stack.Push(p);
     stack.Push(p);

+ 0 - 250
V-Gears-Installer/src/decompiler/value.cpp

@@ -1,250 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * 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.
- */
-
-#include "decompiler/value.h"
-
-#include <boost/format.hpp>
-#include <map>
-#include <sstream>
-#include <string>
-
-static int dupindex = 0;
-static std::map<std::string, int> binaryOpPrecedence;
-static std::map<std::string, std::string> negateMap;
-
-void initPrecedence() {
-	binaryOpPrecedence["||"] = kLogicalOrPrecedence;
-	binaryOpPrecedence["&&"] = kLogicalAndPrecedence;
-	binaryOpPrecedence["|"] = kBitwiseOrPrecedence;
-	binaryOpPrecedence["^"] = kBitwiseXorPrecedence;
-	binaryOpPrecedence["&"] = kBitwiseAndPrecedence;
-	binaryOpPrecedence["=="] = kEqualityOpPrecedence;
-	binaryOpPrecedence["!="] = kEqualityOpPrecedence;
-	binaryOpPrecedence["<"] = kRelationOpPrecedence;
-	binaryOpPrecedence["<="] = kRelationOpPrecedence;
-	binaryOpPrecedence[">="] = kRelationOpPrecedence;
-	binaryOpPrecedence[">"] = kRelationOpPrecedence;
-	binaryOpPrecedence["<<"] = kShiftOpPrecedence;
-	binaryOpPrecedence[">>"] = kShiftOpPrecedence;
-	binaryOpPrecedence["+"] = kAddOpPrecedence;
-	binaryOpPrecedence["-"] = kAddOpPrecedence;
-	binaryOpPrecedence["*"] = kMultOpPrecedence;
-	binaryOpPrecedence["/"] = kMultOpPrecedence;
-	binaryOpPrecedence["%"] = kMultOpPrecedence;
-}
-
-void initNegateMap() {
-	negateMap["=="] = "!=";
-	negateMap["!="] = "==";
-	negateMap["<"] = ">=";
-	negateMap["<="] = ">";
-	negateMap[">="] = "<";
-	negateMap[">"] = "<=";
-}
-
-bool Value::isInteger() {
-	return false;
-}
-
-bool Value::isAddress() {
-	return false;
-}
-
-bool Value::isSignedValue(){
-	throw WrongTypeException();
-}
-
-int32 Value::getSigned(){
-	throw WrongTypeException();
-}
-
-uint32 Value::getUnsigned(){
-	throw WrongTypeException();
-}
-
-ValuePtr Value::dup(std::ostream &output) {
-	ValuePtr dupValue = new DupValue(++dupindex);
-	output << dupValue << " = " << this << ";";
-	return dupValue;
-}
-
-ValuePtr Value::negate(){
-	return new NegatedValue(this);
-}
-
-std::string Value::getString() const {
-	std::stringstream s;
-	print(s);
-	return s.str();
-}
-
-int Value::precedence() const {
-	return kNoPrecedence;
-}
-
-bool IntValue::isInteger() {
-	return true;
-}
-
-bool IntValue::isSignedValue(){
-	return _isSigned;
-}
-
-int32 IntValue::getSigned() {
-	return _val;
-}
-
-uint32 IntValue::getUnsigned(){
-	return (uint32)_val;
-}
-
-ValuePtr IntValue::dup(std::ostream&) {
-	return new IntValue(_val, _isSigned);
-}
-
-std::ostream &IntValue::print(std::ostream &output) const {
-	if (_isSigned)
-		output << (int32)_val;
-	else
-		output << (uint32)_val;
-	return output;
-}
-
-bool AddressValue::isAddress() {
-	return true;
-}
-
-int32 AddressValue::getSigned(){
-	throw WrongTypeException();
-}
-
-ValuePtr AddressValue::dup(std::ostream&) {
-	return new AddressValue(_val);
-}
-
-std::ostream &AddressValue::print(std::ostream &output) const {
-	return output << boost::format("0x%X") % _val;
-}
-
-bool RelAddressValue::isAddress() {
-	return true;
-}
-
-uint32 RelAddressValue::getUnsigned(){
-	return _baseaddr + _val;
-}
-
-ValuePtr RelAddressValue::dup(std::ostream&) {
-	return new RelAddressValue(_baseaddr, _val);
-}
-
-std::ostream &RelAddressValue::print(std::ostream &output) const {
-	if (_val < 0)
-		return output << boost::format("-0x%X") % -_val;
-	return output << boost::format("+0x%X") % _val;
-}
-
-ValuePtr DupValue::dup(std::ostream&) {
-	return this;
-}
-
-std::ostream &DupValue::print(std::ostream &output) const {
-	return output << "temp" << _idx;
-}
-
-std::ostream &StringValue::print(std::ostream &output) const {
-	return output << "\"" << _str << "\"";
-}
-
-std::ostream& UnqotedStringValue::print(std::ostream& output) const
-{
-    return output << _str;
-}
-
-std::ostream &VarValue::print(std::ostream &output) const {
-	return output << _varName;
-}
-
-std::ostream &ArrayValue::print(std::ostream &output) const {
-	output << _varName;
-	for (ValueList::const_iterator i = _idxs.begin(); i != _idxs.end(); ++i)
-		output << "[" << *i << "]";
-	return output;
-}
-
-std::ostream &BinaryOpValue::print(std::ostream &output) const {
-	if (_lhs->precedence() > precedence())
-		output <<  "(" << _lhs << ")";
-	else
-		output << _lhs;
-	output << " " << _op << " ";
-	if (_rhs->precedence() > precedence())
-		output << "(" << _rhs << ")";
-	else
-		output << _rhs;
-	return output;
-}
-
-int BinaryOpValue::precedence() const {
-	if (binaryOpPrecedence.empty())
-		initPrecedence();
-	return binaryOpPrecedence[_op];
-}
-
-ValuePtr BinaryOpValue::negate(){
-	if (negateMap.empty())
-		initNegateMap();
-	if (negateMap.find(_op) == negateMap.end())
-		return Value::negate();
-	else
-		return new BinaryOpValue(_lhs, _rhs, negateMap[_op]);
-}
-
-std::ostream &UnaryOpValue::print(std::ostream &output) const {
-	if (!_isPostfix)
-		output << _op;
-	if (_operand->precedence() > precedence())
-		output << "(" << _operand << ")";
-	else
-		output << _operand;
-	if (_isPostfix)
-		output << _op;
-	return output;
-}
-
-int UnaryOpValue::precedence() const {
-	return kUnaryOpPrecedence;
-}
-
-ValuePtr NegatedValue::negate(){
-	return _operand;
-}
-
-std::ostream &CallValue::print(std::ostream &output) const {
-	output << _funcName << "(";
-	for (ValueList::const_iterator i = _args.begin(); i != _args.end(); ++i) {
-		if (i != _args.begin())
-			output << ", ";
-		output << *i;
-	}
-	output << ")";
-	return output;
-}

+ 1 - 1
V-Gears-Installer/src/decompiler/world/instruction/WorldCondJumpInstruction.cpp

@@ -30,7 +30,7 @@ void FF7::WorldCondJumpInstruction::ProcessInst(Function&, ValueStack&, Engine*,
 }
 
 uint32 FF7::WorldCondJumpInstruction::GetDestAddress() const{
-    return 0x200 + params_[0]->getUnsigned();
+    return 0x200 + params_[0]->GetUnsigned();
 }
 
 std::ostream& FF7::WorldCondJumpInstruction::Print(std::ostream &output) const{

+ 28 - 28
V-Gears-Installer/src/decompiler/world/instruction/WorldKernelCallInstruction.cpp

@@ -31,72 +31,72 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
     std::string func;
     switch (opcode_){
         case 0x203: func = "return;"; break;
-        case 0x317: func = "TriggerBattle(" + stack.Pop()->getString() + ");"; break;
+        case 0x317: func = "TriggerBattle(" + stack.Pop()->GetString() + ");"; break;
         case 0x324:
             // x, y, w, h
             func = "SetWindowDimensions("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ", "
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ", "
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x32D: func = "WaitForWindowReady();"; break;
-        case 0x325: func = "SetWindowMessage(" + stack.Pop()->getString() + ");"; break;
+        case 0x325: func = "SetWindowMessage(" + stack.Pop()->GetString() + ");"; break;
         case 0x333:
             func = "Unknown333("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x308:
             func = "SetActiveEntityMeshCoordinates("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x309:
             func = "SetActiveEntityMeshCoordinatesInMesh("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x32e: func = "WaitForMessageAcknowledge();"; break;
         case 0x32c:
             // Mode, Permanency.
             func = "SetWindowParameters("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x318:
             func = "EnterFieldScene("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x348:
-            func = "FadeIn(" + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+            func = "FadeIn(" + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x33b:
-            func = "FadeOut(" + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+            func = "FadeOut(" + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x310:
             func = "SetActivePoint("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x311:
             func = "SetLightMeshCoordinates("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
         case 0x312:
             func = "SetLightMeshCoordinatesInMesh("
-              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
+              + stack.Pop()->GetString() + ", " + stack.Pop()->GetString() + ");";
             break;
-        case 0x31D: func = "PlaySoundEffect(" + stack.Pop()->getString() + ");"; break;
-        case 0x328: func = "SetActiveEntityDirection(" + stack.Pop()->getString() + ");"; break;
+        case 0x31D: func = "PlaySoundEffect(" + stack.Pop()->GetString() + ");"; break;
+        case 0x328: func = "SetActiveEntityDirection(" + stack.Pop()->GetString() + ");"; break;
         case 0x336: // Honor walk mesh.
         case 0x303:
-            func = "SetActiveEntityMovespeed(" + stack.Pop()->getString() + ");";
+            func = "SetActiveEntityMovespeed(" + stack.Pop()->GetString() + ");";
             break;
         case 0x304:
-            func = "SetActiveEntityDirectionAndFacing(" + stack.Pop()->getString() + ");";
+            func = "SetActiveEntityDirectionAndFacing(" + stack.Pop()->GetString() + ");";
             break;
-        case 0x32b: func = "SetBattleLock(" + stack.Pop()->getString() + ");"; break;
-        case 0x305: func = "SetWaitFrames(" + stack.Pop()->getString() + ");"; break;
-        case 0x33e: func = "Unknown_AKAO(" + stack.Pop()->getString() + ");"; break;
+        case 0x32b: func = "SetBattleLock(" + stack.Pop()->GetString() + ");"; break;
+        case 0x305: func = "SetWaitFrames(" + stack.Pop()->GetString() + ");"; break;
+        case 0x33e: func = "Unknown_AKAO(" + stack.Pop()->GetString() + ");"; break;
         case 0x306: func = "Wait();"; break;
-        case 0x350: func = "SetMeteorTexture(" + stack.Pop()->getString() + ");"; break;
+        case 0x350: func = "SetMeteorTexture(" + stack.Pop()->GetString() + ");"; break;
         case 0x34b:
             {
-                std::string type = stack.Pop()->getString();
+                std::string type = stack.Pop()->GetString();
                 switch (std::stoi(type)){
                     case 0: type = "yellow"; break;
                     case 1: type = "green"; break;
@@ -109,7 +109,7 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
             break;
         case 0x34c:
             {
-                std::string type = stack.Pop()->getString();
+                std::string type = stack.Pop()->GetString();
                 switch (std::stoi(type)){
                     case 0: type = "red"; break;
                     case 1: type = "blue"; break;
@@ -122,7 +122,7 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
             break;
         case 0x349:
             {
-                std::string type = stack.Pop()->getString();
+                std::string type = stack.Pop()->GetString();
                 std::string comment = "// ";
                 switch (std::stoi(type)){
                     case 0: comment += "before temple of the ancients,"; break;
@@ -137,7 +137,7 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
             break;
         case 0x300:
             {
-                std::string type = stack.Pop()->getString();
+                std::string type = stack.Pop()->GetString();
                 std::string comment = "// ";
                 try{
                     switch (std::stoi(type)){
@@ -174,9 +174,9 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
                 func = "LoadModel(" + type + "); " + comment;
             }
             break;
-        case 0x307: func = "SetControlLock(" + stack.Pop()->getString() + ");"; break;
+        case 0x307: func = "SetControlLock(" + stack.Pop()->GetString() + ");"; break;
         case 0x30c: func = "EnterVehicle();"; break;
-        default: func = "kernel_unknown_" + AddressValue(opcode_).getString() + "();"; break;
+        default: func = "kernel_unknown_" + AddressValue(opcode_).GetString() + "();"; break;
     }
     code_gen->AddOutputLine(func);
 }

+ 1 - 1
V-Gears-Installer/src/decompiler/world/instruction/WorldLoadBankInstruction.cpp

@@ -26,4 +26,4 @@
 
 void FF7::WorldLoadBankInstruction::ProcessInst(
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-){stack.Push(new WorldEngine::BankValue("Read(" + params_[0]->getString() + ")"));}
+){stack.Push(new WorldEngine::BankValue("Read(" + params_[0]->GetString() + ")"));}

+ 1 - 3
V-Gears-Installer/src/decompiler/world/instruction/WorldLoadInstruction.cpp

@@ -26,6 +26,4 @@
 
 void FF7::WorldLoadInstruction::ProcessInst(
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-){
-    stack.Push(new VarValue(params_[0]->getString()));
-}
+){stack.Push(new VarValue(params_[0]->GetString()));}

+ 2 - 2
V-Gears-Installer/src/decompiler/world/instruction/WorldStoreInstruction.cpp

@@ -28,9 +28,9 @@
 void FF7::WorldStoreInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
-    std::string value = stack.Pop()->getString();
+    std::string value = stack.Pop()->GetString();
     // If the bank address is from a load bank instruction, then only
     // the bank address is needed, not whats *at* the bank address.
     ValuePtr bank_addr = stack.Pop();
-    code_gen->AddOutputLine("Write(" + bank_addr->getString() + ", " + value + ");");
+    code_gen->AddOutputLine("Write(" + bank_addr->GetString() + ", " + value + ");");
 }

+ 2 - 2
V-Gears-Installer/src/decompiler/world/instruction/WorldSubStackInstruction.cpp

@@ -36,7 +36,7 @@ void FF7::WorldSubStackInstruction::ProcessInst(
         case 0xc0: op = "|"; break;
         case 0x15: // neg
         case 0x17: // not
-            stack.Push(stack.Pop()->negate());
+            stack.Push(stack.Pop()->Negate());
             return;
             break;
         case 0x30: op = "*";break;
@@ -48,6 +48,6 @@ void FF7::WorldSubStackInstruction::ProcessInst(
         case 0x51: op = "<<"; break;
         default:op = "unknown_operation";
     }
-    std::string value = stack.Pop()->getString() + " " + op + " " + stack.Pop()->getString();
+    std::string value = stack.Pop()->GetString() + " " + op + " " + stack.Pop()->GetString();
     stack.Push(new VarValue(value));
 }

+ 1 - 1
V-Gears-Installer/src/decompiler/world/instruction/WorldUncondJumpInstruction.cpp

@@ -33,7 +33,7 @@ bool FF7::WorldUncondJumpInstruction::IsUncondJump() const{return !is_call_;}
 uint32 FF7::WorldUncondJumpInstruction::GetDestAddress() const{
     // The world map while loops are incorrect without +1'in this, but
     // doing that will break some if elses...
-    return 0x200 + params_[0]->getUnsigned();// +1; // TODO: +1 to skip param?
+    return 0x200 + params_[0]->GetUnsigned();// +1; // TODO: +1 to skip param?
 }
 
 std::ostream& FF7::WorldUncondJumpInstruction::Print(std::ostream &output) const{