Răsfoiți Sursa

Some more old SDUM code formatted and documented.
Most notably, all the instructions are refactored and separated in files.

Iñigo Valentin 3 ani în urmă
părinte
comite
b834f89ece
100 a modificat fișierele cu 2599 adăugiri și 1580 ștergeri
  1. 38 5
      V-Gears-Installer/CMakeLists.txt
  2. 2 1
      V-Gears-Installer/include/decompiler/CodeGenerator.h
  3. 1 1
      V-Gears-Installer/include/decompiler/ControlFlow.h
  4. 2 2
      V-Gears-Installer/include/decompiler/Disassembler.h
  5. 2 1
      V-Gears-Installer/include/decompiler/Engine.h
  6. 1 0
      V-Gears-Installer/include/decompiler/Function.h
  7. 405 0
      V-Gears-Installer/include/decompiler/Graph.h
  8. 72 0
      V-Gears-Installer/include/decompiler/ObjectFactory.h
  9. 62 0
      V-Gears-Installer/include/decompiler/RefCounted.h
  10. 5 5
      V-Gears-Installer/include/decompiler/field/FieldDisassembler.h
  11. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldBackgroundInstruction.h
  12. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldCameraInstruction.h
  13. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldCondJumpInstruction.h
  14. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldControlFlowInstruction.h
  15. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldMathInstruction.h
  16. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldMediaInstruction.h
  17. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldModelInstruction.h
  18. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldModuleInstruction.h
  19. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldNoOperationInstruction.h
  20. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldPartyInstruction.h
  21. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldUncategorizedInstruction.h
  22. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldUncondJumpInstruction.h
  23. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldWalkmeshInstruction.h
  24. 1 1
      V-Gears-Installer/include/decompiler/field/instruction/FieldWindowInstruction.h
  25. 0 386
      V-Gears-Installer/include/decompiler/graph.h
  26. 0 343
      V-Gears-Installer/include/decompiler/instruction.h
  27. 23 0
      V-Gears-Installer/include/decompiler/instruction/BinaryOpInstruction.h
  28. 37 0
      V-Gears-Installer/include/decompiler/instruction/BinaryOpStackInstruction.h
  29. 23 0
      V-Gears-Installer/include/decompiler/instruction/BoolNegateInstruction.h
  30. 37 0
      V-Gears-Installer/include/decompiler/instruction/BoolNegateStackInstruction.h
  31. 34 0
      V-Gears-Installer/include/decompiler/instruction/CallInstruction.h
  32. 34 0
      V-Gears-Installer/include/decompiler/instruction/CondJumpInstruction.h
  33. 23 0
      V-Gears-Installer/include/decompiler/instruction/DupInstruction.h
  34. 37 0
      V-Gears-Installer/include/decompiler/instruction/DupStackInstruction.h
  35. 392 0
      V-Gears-Installer/include/decompiler/instruction/Instruction.h
  36. 23 0
      V-Gears-Installer/include/decompiler/instruction/JumpInstruction.h
  37. 34 0
      V-Gears-Installer/include/decompiler/instruction/KernelCallInstruction.h
  38. 37 0
      V-Gears-Installer/include/decompiler/instruction/KernelCallStackInstruction.h
  39. 34 0
      V-Gears-Installer/include/decompiler/instruction/LoadInstruction.h
  40. 45 0
      V-Gears-Installer/include/decompiler/instruction/ReturnInstruction.h
  41. 34 0
      V-Gears-Installer/include/decompiler/instruction/StackInstruction.h
  42. 34 0
      V-Gears-Installer/include/decompiler/instruction/StoreInstruction.h
  43. 23 0
      V-Gears-Installer/include/decompiler/instruction/UnaryOpInstruction.h
  44. 37 0
      V-Gears-Installer/include/decompiler/instruction/UnaryOpPostfixStackInstruction.h
  45. 37 0
      V-Gears-Installer/include/decompiler/instruction/UnaryOpPrefixStackInstruction.h
  46. 45 0
      V-Gears-Installer/include/decompiler/instruction/UncondJumpInstruction.h
  47. 0 82
      V-Gears-Installer/include/decompiler/objectFactory.h
  48. 0 59
      V-Gears-Installer/include/decompiler/refcounted.h
  49. 1 1
      V-Gears-Installer/include/decompiler/test/cfg_test.cpp
  50. 1 1
      V-Gears-Installer/include/decompiler/test/codegen.cpp
  51. 10 10
      V-Gears-Installer/include/decompiler/test/ff7_field_control_flow_test.cpp
  52. 2 2
      V-Gears-Installer/include/decompiler/test/main.cpp
  53. 1 1
      V-Gears-Installer/include/decompiler/value.h
  54. 5 5
      V-Gears-Installer/include/decompiler/world/WorldDisassembler.h
  55. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldBinaryEqualStackInstruction.h
  56. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldCondJumpInstruction.h
  57. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldKernelCallInstruction.h
  58. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldLoadBankInstruction.h
  59. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldLoadInstruction.h
  60. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldNoOutputInstruction.h
  61. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldStackInstruction.h
  62. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldStoreInstruction.h
  63. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldSubStackInstruction.h
  64. 1 1
      V-Gears-Installer/include/decompiler/world/instruction/WorldUncondJumpInstruction.h
  65. 46 45
      V-Gears-Installer/src/decompiler/CodeGenerator.cpp
  66. 108 108
      V-Gears-Installer/src/decompiler/ControlFlow.cpp
  67. 66 0
      V-Gears-Installer/src/decompiler/Graph.cpp
  68. 5 7
      V-Gears-Installer/src/decompiler/decompiler.cpp
  69. 17 15
      V-Gears-Installer/src/decompiler/field/FieldCodeGenerator.cpp
  70. 12 12
      V-Gears-Installer/src/decompiler/field/FieldDisassembler.cpp
  71. 14 14
      V-Gears-Installer/src/decompiler/field/FieldEngine.cpp
  72. 36 36
      V-Gears-Installer/src/decompiler/field/instruction/FieldBackgroundInstruction.cpp
  73. 18 18
      V-Gears-Installer/src/decompiler/field/instruction/FieldCameraInstruction.cpp
  74. 18 18
      V-Gears-Installer/src/decompiler/field/instruction/FieldCondJumpInstruction.cpp
  75. 15 15
      V-Gears-Installer/src/decompiler/field/instruction/FieldControlFlowInstruction.cpp
  76. 28 28
      V-Gears-Installer/src/decompiler/field/instruction/FieldMathInstruction.cpp
  77. 20 20
      V-Gears-Installer/src/decompiler/field/instruction/FieldMediaInstruction.cpp
  78. 63 63
      V-Gears-Installer/src/decompiler/field/instruction/FieldModelInstruction.cpp
  79. 15 15
      V-Gears-Installer/src/decompiler/field/instruction/FieldModuleInstruction.cpp
  80. 7 7
      V-Gears-Installer/src/decompiler/field/instruction/FieldPartyInstruction.cpp
  81. 2 2
      V-Gears-Installer/src/decompiler/field/instruction/FieldUncategorizedInstruction.cpp
  82. 5 5
      V-Gears-Installer/src/decompiler/field/instruction/FieldUncondJumpInstruction.cpp
  83. 11 11
      V-Gears-Installer/src/decompiler/field/instruction/FieldWalkmeshInstruction.cpp
  84. 12 12
      V-Gears-Installer/src/decompiler/field/instruction/FieldWindowInstruction.cpp
  85. 0 33
      V-Gears-Installer/src/decompiler/graph.cpp
  86. 0 167
      V-Gears-Installer/src/decompiler/instruction.cpp
  87. 28 0
      V-Gears-Installer/src/decompiler/instruction/BinaryOpStackInstruction.cpp
  88. 20 0
      V-Gears-Installer/src/decompiler/instruction/BoolNegateStackInstruction.cpp
  89. 18 0
      V-Gears-Installer/src/decompiler/instruction/CallInstruction.cpp
  90. 18 0
      V-Gears-Installer/src/decompiler/instruction/CondJumpInstruction.cpp
  91. 27 0
      V-Gears-Installer/src/decompiler/instruction/DupStackInstruction.cpp
  92. 145 0
      V-Gears-Installer/src/decompiler/instruction/Instruction.cpp
  93. 18 0
      V-Gears-Installer/src/decompiler/instruction/KernelCallInstruction.cpp
  94. 33 0
      V-Gears-Installer/src/decompiler/instruction/KernelCallStackInstruction.cpp
  95. 18 0
      V-Gears-Installer/src/decompiler/instruction/LoadInstruction.cpp
  96. 23 0
      V-Gears-Installer/src/decompiler/instruction/ReturnInstruction.cpp
  97. 18 0
      V-Gears-Installer/src/decompiler/instruction/StackInstruction.cpp
  98. 18 0
      V-Gears-Installer/src/decompiler/instruction/StoreInstruction.cpp
  99. 20 0
      V-Gears-Installer/src/decompiler/instruction/UnaryOpPostfixStackInstruction.cpp
  100. 20 0
      V-Gears-Installer/src/decompiler/instruction/UnaryOpPrefixStackInstruction.cpp

+ 38 - 5
V-Gears-Installer/CMakeLists.txt

@@ -27,10 +27,29 @@ set(HEADER_FILES
     include/decompiler/ControlFlow.h
     include/decompiler/Disassembler.h
     include/decompiler/Engine.h
+    include/decompiler/Graph.h
     include/decompiler/Function.h
-    include/decompiler/graph.h
-    include/decompiler/instruction.h
-    include/decompiler/objectFactory.h
+    include/decompiler/instruction/Instruction.h
+    include/decompiler/instruction/BinaryOpInstruction.h
+    include/decompiler/instruction/BinaryOpStackInstruction.h
+    include/decompiler/instruction/BoolNegateInstruction.h
+    include/decompiler/instruction/BoolNegateStackInstruction.h
+    include/decompiler/instruction/CallInstruction.h
+    include/decompiler/instruction/CondJumpInstruction.h
+    include/decompiler/instruction/DupInstruction.h
+    include/decompiler/instruction/DupStackInstruction.h
+    include/decompiler/instruction/JumpInstruction.h
+    include/decompiler/instruction/KernelCallInstruction.h
+    include/decompiler/instruction/KernelCallStackInstruction.h
+    include/decompiler/instruction/LoadInstruction.h
+    include/decompiler/instruction/ReturnInstruction.h
+    include/decompiler/instruction/StackInstruction.h
+    include/decompiler/instruction/StoreInstruction.h
+    include/decompiler/instruction/UnaryOpInstruction.h
+    include/decompiler/instruction/UnaryOpPostfixStackInstruction.h
+    include/decompiler/instruction/UnaryOpPrefixStackInstruction.h
+    include/decompiler/instruction/UncondJumpInstruction.h
+    include/decompiler/ObjectFactory.h
     include/decompiler/refcounted.h
     include/decompiler/simple_disassembler.h
     include/decompiler/stack.h
@@ -90,8 +109,22 @@ set(SOURCE_FILES
     src/decompiler/ControlFlow.cpp
     src/decompiler/Disassembler.cpp
     src/decompiler/Engine.cpp
-    src/decompiler/graph.cpp
-    src/decompiler/instruction.cpp
+    src/decompiler/Graph.cpp
+    src/decompiler/instruction/Instruction.cpp
+    src/decompiler/instruction/BinaryOpStackInstruction.cpp
+    src/decompiler/instruction/BoolNegateStackInstruction.cpp
+    src/decompiler/instruction/CallInstruction.cpp
+    src/decompiler/instruction/CondJumpInstruction.cpp
+    src/decompiler/instruction/DupStackInstruction.cpp
+    src/decompiler/instruction/KernelCallInstruction.cpp
+    src/decompiler/instruction/KernelCallStackInstruction.cpp
+    src/decompiler/instruction/LoadInstruction.cpp
+    src/decompiler/instruction/ReturnInstruction.cpp
+    src/decompiler/instruction/StackInstruction.cpp
+    src/decompiler/instruction/StoreInstruction.cpp
+    src/decompiler/instruction/UnaryOpPostfixStackInstruction.cpp
+    src/decompiler/instruction/UnaryOpPrefixStackInstruction.cpp
+    src/decompiler/instruction/UncondJumpInstruction.cpp
     src/decompiler/simple_disassembler.cpp
     src/decompiler/unknown_opcode_exception.cpp
     src/decompiler/value.cpp

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

@@ -19,8 +19,9 @@
 #include <utility>
 #include <memory>
 #include <boost/intrusive_ptr.hpp>
+
+#include "Graph.h"
 #include "LuaLanguage.h"
-#include "graph.h"
 #include "value.h"
 #include "unknown_opcode_exception.h"
 

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

@@ -16,7 +16,7 @@
 #pragma once
 
 #include "Engine.h"
-#include "graph.h"
+#include "Graph.h"
 
 /**
  * Class for doing code flow analysis.

+ 2 - 2
V-Gears-Installer/include/decompiler/Disassembler.h

@@ -18,9 +18,9 @@
 #include <iostream>
 #include <vector>
 #include "common/BinaryReader.h"
-#include "instruction.h"
+#include "instruction/Instruction.h"
+#include "ObjectFactory.h"
 #include "unknown_opcode_exception.h"
-#include "objectFactory.h"
 
 /**
  * Base class for disassemblers.

+ 2 - 1
V-Gears-Installer/include/decompiler/Engine.h

@@ -18,9 +18,10 @@
 #include <set>
 #include <string>
 #include <vector>
+#include "Function.h"
+#include "Graph.h"
 #include "CodeGenerator.h"
 #include "Disassembler.h"
-#include "Function.h"
 
 /**
  * Type representing a map of functions, indexed by starting address.

+ 1 - 0
V-Gears-Installer/include/decompiler/Function.h

@@ -18,6 +18,7 @@
 #include <set>
 #include "CodeGenerator.h"
 #include "Disassembler.h"
+#include "Graph.h"
 
 /**
  * Structure representing a function.

+ 405 - 0
V-Gears-Installer/include/decompiler/Graph.h

@@ -0,0 +1,405 @@
+/*
+ * 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 <ostream>
+#include <utility>
+#include <vector>
+#include <boost/format.hpp>
+#include <boost/version.hpp>
+#ifdef _MSC_VER
+#pragma warning (push)
+#pragma warning(disable:4512)
+#pragma warning(disable:4100)
+#endif
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/graphviz.hpp>
+#ifdef _MSC_VER
+#pragma warning (pop)
+#endif
+#include <boost/intrusive_ptr.hpp>
+#include "instruction/Instruction.h"
+#include "RefCounted.h"
+
+/**
+ * Enumeration representing the different kinds of groups.
+ */
+enum GROUP_TYPE {
+
+    /**
+     * Normal group.
+     */
+    GROUP_TYPE_NORMAL,
+
+    /**
+     * Group is the condition check for a while-loop.
+     */
+    GROUP_TYPE_WHILE,
+
+    /**
+     * Group is the condition check for a do-while-loop.
+     */
+    GROUP_TYPE_DO_WHILE,
+
+    /**
+     * Group is the condition check for an if.
+     */
+    GROUP_TYPE_IF,
+
+    /**
+     * Group is a break.
+     */
+    GROUP_TYPE_BREAK,
+
+    /**
+     * Group is a continue.
+     */
+    GROUP_TYPE_CONTINUE
+};
+
+struct Group;
+
+typedef boost::intrusive_ptr<Group> GroupPtr;
+
+typedef boost::property<boost::vertex_name_t, GroupPtr> GroupProperty;
+
+typedef boost::property<boost::vertex_index_t, int, GroupProperty> GraphProperty;
+
+/**
+ * Structure representing whether or not an edge is a jump.
+ */
+struct IsJump {
+
+    /**
+     * Whether or not the edge is a jump.
+     */
+    bool is_jump = false;
+
+    /**
+     * Parameterless constructor.
+     *
+     * Required for use with STL and Boost, should not be called manually.
+     */
+    IsJump();
+
+    /**
+     * Constructor.
+     *
+     * @param jump[is] Whether or not the edge is a jump.
+     */
+    IsJump(bool jump);
+
+    /**
+     * Output edge information as a graphviz edge property.
+     *
+     * @param output[out] The stream to output to.
+     * @param is_jump[in] The IsJump to output.
+     * @return The stream used for output.
+     */
+    friend std::ostream &operator<<(std::ostream &output, IsJump is_jump){
+        if (is_jump.is_jump) output << "empty";
+        else output << "normal";
+        return output;
+    }
+};
+
+namespace boost {
+
+    /**
+     * Property writer for the IsJump property.
+     */
+    template <class Name> class ArrowheadWriter{
+
+        public:
+
+            /**
+             * Constructor.
+             *
+             * @param name[in] The name of the attribute to use.
+             */
+            ArrowheadWriter(Name name): name(name){}
+
+            /**
+             * Outputs the arrowhead edge property.
+             *
+             * @param out[out] The stream to output to.
+             * @param v[in] The vertex or edge to output the attribute for.
+             */
+            template <class VertexOrEdge> void operator()(
+              std::ostream& out, const VertexOrEdge& v
+            ) const {
+                out << "[arrowhead=\"" << get(name, v) << "\"]";
+            }
+
+        private:
+
+            /**
+             * The name of the attribute to use.
+             */
+            Name name;
+    };
+
+    /**
+     * Creates an arrowhead property writer.
+     *
+     * @param _name The name of the attribute to use.
+     */
+    template <class Name> inline ArrowheadWriter<Name> MakeArrowheadWriter(Name n) {
+        return ArrowheadWriter<Name>(n);
+    }
+
+}
+
+typedef boost::property<boost::edge_attribute_t, IsJump> EdgeProperty;
+
+typedef boost::adjacency_list<boost::setS, boost::listS, boost::bidirectionalS, GraphProperty, EdgeProperty> Graph;
+
+typedef Graph::vertex_descriptor GraphVertex;
+
+typedef Graph::vertex_iterator VertexIterator;
+
+typedef Graph::edge_descriptor GraphEdge;
+
+typedef Graph::out_edge_iterator OutEdgeIterator;
+
+typedef Graph::in_edge_iterator InEdgeIterator;
+
+typedef std::pair<VertexIterator, VertexIterator> VertexRange;
+
+typedef std::pair<OutEdgeIterator, OutEdgeIterator> OutEdgeRange;
+
+typedef std::pair<InEdgeIterator, InEdgeIterator> InEdgeRange;
+
+/**
+ * Structure representing a line of code.
+ */
+struct CodeLine {
+
+    /**
+     * The line of code.
+     */
+    std::string line = "0";
+
+    /**
+     * Whether or not to add an indentation level before outputting the line.
+     */
+    bool unindent_before = false;
+
+    /**
+     * Whether to remove an indentation level after outputting the line.
+     */
+    bool indent_after = false;
+
+    /**
+     * Constructor for CodeLine.
+     *
+     * @param line[in] The line of code.
+     * @param unindent_before[in] Whether or not to remove an indentation
+     * level before the line. Defaults to false.
+     * @param indent_after[in] Whether or not to add an indentation level
+     * after the line. Defaults to false.
+     */
+    CodeLine(const std::string& line, bool unindent_before, bool indent_after);
+};
+
+typedef std::vector<Group *> ElseEnds; // Weak references to groups ending else blocks.
+
+typedef ElseEnds::iterator ElseEndIterator;
+
+/**
+ * Structure representing a group of instructions.
+ */
+struct Group : public RefCounted {
+
+        /**
+         * Vertex the group belongs to.
+         */
+        GraphVertex vertex;
+
+        /**
+         * First instruction in the group.
+         */
+        InstIterator start;
+
+        /**
+         * Last instruction in the group.
+         */
+        InstIterator end;
+
+        /**
+         * Level of the stack upon entry.
+         */
+        int stack_level;
+
+        /**
+         * Type of the group.
+         */
+        GROUP_TYPE type;
+
+        /**
+         * Group is start of an else block.
+         */
+        bool start_else;
+
+        /**
+         * Group is end of an else block.
+         */
+        ElseEnds end_else;
+
+        /**
+         * Pointer to the previous group, when ordered by address.
+         *
+         * Used for short-circuit analysis.
+         */
+        Group *prev;
+
+        /**
+         * Pointer to the next group, when ordered by address.
+         */
+        Group *next;
+
+        /**
+         * Decompiled lines of code.
+         */
+        std::vector<CodeLine> code;
+
+        /**
+         * Indicates if an starting else coalesces with another block.
+         *
+         * True if an else starting has been coalesced with another block
+         * (e.g. "else if"). If true, an else starting here should not be
+         * closed explicitly, but left to the other block.
+         */
+        bool coalesced_else;
+
+        /**
+         * Parameterless constructor.
+         *
+         * Required for use with STL and Boost, should not be called manually.
+         */
+        Group();
+
+        /**
+         * Constructor.
+         *
+         * @param vertex[in] The vertex the group belongs to.
+         * @param start[in] First instruction in the group.
+         * @param end[in] Last instruction in the group.
+         * @param prev[in] Pointer to the previous group, when ordered by
+         * address.
+         */
+        Group(GraphVertex vertex, InstIterator start, InstIterator end, GroupPtr prev);
+
+        /**
+         * Output a group to an stream as a graphviz label.
+         *
+         * @param output[out] The stream to output to.
+         * @param group[in] The Group to output.
+         * @return The stream used for output.
+         */
+        friend std::ostream &operator<<(std::ostream &output, GroupPtr group){
+            output << "{Block type: ";
+            switch(group->type) {
+                case GROUP_TYPE_NORMAL: output << "Normal"; break;
+                case GROUP_TYPE_WHILE: output << "While condition"; break;
+                case GROUP_TYPE_DO_WHILE: output << "Do-while condition"; break;
+                case GROUP_TYPE_IF: output << "If condition"; break;
+                case GROUP_TYPE_BREAK: output << "Break"; break;
+                case GROUP_TYPE_CONTINUE: output << "Continue"; break;
+            }
+            output << "\\n";
+            output << "Expected stack level: " << group->stack_level << "\\n";
+            if (group->start_else) output << "Start of else\\n";
+            for (ElseEndIterator it = group->end_else.begin(); it != group->end_else.end(); ++ it)
+                output << boost::format("End of else at %08x\\n") % (*(*it)->start)->GetAddress();
+            output << "|";
+            ConstInstIterator inst = group->start;
+            do {
+                std::stringstream stream;
+                stream << *inst;
+#if (BOOST_VERSION >= 104500)
+                output << stream.str();
+#else
+                std::string s = stream.str();
+                for (std::string::iterator it = s.begin(); it != s.end(); ++it)
+                    if (*it == '"') output << "\\\"";
+                    else if (*it == '|') output << "\\|";
+                    else if (*it == '{') output << "\\{";
+                    else if (*it == '}') output << "\\}";
+                    else output << *it;
+#endif
+                output << "\\n";
+            } while (inst ++ != group->end);
+            output << "}";
+            return output;
+        }
+};
+
+class Engine;
+
+/**
+ * Type used to set properties for dot output.
+ */
+struct GraphProperties {
+
+    public:
+
+        /**
+         * Constructor.
+         *
+         * @param engine[in] The engine with function information for the
+         * script.
+         * @param greaph[in] he graph for the script.
+         */
+        GraphProperties(Engine *engine, const Graph &graph);
+
+        /**
+         * Copy constructor.
+         *
+         * @param rhs[in] Graph properties to copy.
+         */
+        GraphProperties(const GraphProperties& rhs);
+
+        /**
+         * Copy constructor.
+         *
+         * @param rhs[in] Graph properties to copy.
+         */
+        GraphProperties& operator = (const GraphProperties& rhs);
+
+        /**
+         * Print properties of the graph.
+         *
+         * Called by write_graphviz from Boost.Graph
+         *
+         * @param out[out] The stream write_graphviz is writing to.
+         */
+        void operator()(std::ostream& out) const;
+
+    private:
+
+        /**
+         * Engine containing function information for the script.
+         */
+        Engine *engine;
+
+        /**
+         * Pointer to the to the graph for the script.
+         */
+        const Graph* graph;
+};
+

+ 72 - 0
V-Gears-Installer/include/decompiler/ObjectFactory.h

@@ -0,0 +1,72 @@
+/*
+ * 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 <map>
+#include <string>
+#include "common/scummsys.h"
+
+/**
+ * Template function for creating an instance of Type.
+ */
+template<typename BaseType, typename Type> BaseType *CreateObject(){return new Type();}
+
+/**
+ * Generic factory for a class and its subclasses.
+ */
+template<typename KeyType, typename BaseType> class ObjectFactory{
+
+    public:
+        /**
+         * Register a new entry.
+         *
+         * @param key[in] The key to register the class under.
+         */
+        template<typename Type> void AddEntry(const KeyType &key) {
+            registry_[key] = &CreateObject<BaseType, Type>;
+        }
+
+        /**
+         * Creates an instance of some registered class.
+         *
+         * @param key[in] The key associated with the desired class.
+         * @return NULL if the name is not registered, else an instance of the
+         * associated class.
+         */
+        BaseType *Create(const KeyType &key) const{
+            typename RegistryMap::const_iterator entry = registry_.find(key);
+            if (entry == registry_.end()) return NULL;
+            return (entry->second)();
+        }
+
+    private:
+
+        /**
+         * Function pointer to the object creation function.
+         */
+        typedef BaseType *(*CreateFunc)();
+
+        /**
+         * Type used to store registered entries.
+         */
+        typedef std::map<KeyType, CreateFunc> RegistryMap;
+
+        /**
+         * Map from an identifier to a creation function.
+         */
+        RegistryMap registry_;
+};
+

+ 62 - 0
V-Gears-Installer/include/decompiler/RefCounted.h

@@ -0,0 +1,62 @@
+/*
+ * 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
+
+class RefCounted;
+
+inline void intrusive_ptr_add_ref(RefCounted *ptr);
+inline void intrusive_ptr_release(RefCounted *ptr);
+
+/**
+ * Provides a base implementation of reference counting.
+ *
+ * To be used with boost::intrusive_ptr.
+ */
+class RefCounted{
+
+    protected:
+        RefCounted(): ref_count_(0){}
+        virtual ~RefCounted(){}
+
+    private:
+
+        /**
+         * Reference count used for boost::intrusive_ptr.
+         */
+        long ref_count_;
+
+        friend void ::intrusive_ptr_add_ref(RefCounted *ptr);
+
+        friend void ::intrusive_ptr_release(RefCounted *ptr);
+
+
+};
+
+/**
+ * Add a reference to a pointer.
+ *
+ * @param ptr[in] Pointer to reference.
+ */
+inline void intrusive_ptr_add_ref(RefCounted *ptr){++ (ptr->ref_count_);}
+
+/**
+ * Remove a reference from a pointer.
+ *
+ * @param ptr[in] Pointer to de-reference.
+ */
+inline void intrusive_ptr_release(RefCounted *ptr){
+    if (-- (ptr->ref_count_) == 0) delete ptr;
+}

+ 5 - 5
V-Gears-Installer/include/decompiler/field/FieldDisassembler.h

@@ -735,11 +735,11 @@ namespace FF7{
             ){
                 uint32 full_opcode = (full_opcode << 8) + opcode;
                 this->insts_.push_back(instruction);
-                this->insts_.back()->_opcode = full_opcode;
-                this->insts_.back()->_address = this->address_;
-                this->insts_.back()->_stackChange = 0;
-                this->insts_.back()->_name = std::string(name);
-                this->insts_.back()->_codeGenData = "";
+                this->insts_.back()->SetOpcode(full_opcode);
+                this->insts_.back()->SetAddress(this->address_);
+                this->insts_.back()->SetStackChange(0);
+                this->insts_.back()->SetName(std::string(name));
+                this->insts_.back()->SetCodeGenData("");
                 this->readParams(this->insts_.back(), argument_format);
             }
 

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/CondJumpInstruction.h"
 
 namespace FF7{
 

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

@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/StoreInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/Instruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/UncondJumpInstruction.h"
 
 namespace FF7{
 

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 
 namespace FF7{

+ 0 - 386
V-Gears-Installer/include/decompiler/graph.h

@@ -1,386 +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 DEC_GRAPH_H
-#define DEC_GRAPH_H
-
-#include "instruction.h"
-#include "refcounted.h"
-
-#include <ostream>
-#include <utility>
-#include <vector>
-
-#include <boost/format.hpp>
-#include <boost/version.hpp>
-
-
-#ifdef _MSC_VER
-#pragma warning (push)
-#pragma warning(disable:4512)
-#pragma warning(disable:4100)
-#endif
-#include <boost/graph/graph_traits.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/graphviz.hpp>
-#ifdef _MSC_VER
-#pragma warning (pop)
-#endif
-
-#include <boost/intrusive_ptr.hpp>
-
-/**
- * Enumeration representing the different kinds of groups.
- */
-enum GroupType {
-	kNormalGroupType,      ///< Normal group.
-	kWhileCondGroupType,   ///< Group is the condition check for a while-loop.
-	kDoWhileCondGroupType, ///< Group is the condition check for a do-while-loop.
-	kIfCondGroupType,      ///< Group is the condition check for an if.
-	kBreakGroupType,       ///< Group is a break.
-	kContinueGroupType     ///< Group is a continue.
-};
-
-struct Group;
-
-/**
- * Pointer to a Group.
- */
-typedef boost::intrusive_ptr<Group> GroupPtr;
-
-/**
- * Type representing properties containing a pointer to a Group.
- */
-typedef boost::property<boost::vertex_name_t, GroupPtr> GroupProperty;
-
-/**
- * Type representing properties containing an index, followed by a GroupProperty.
- */
-typedef boost::property<boost::vertex_index_t, int, GroupProperty> GraphProperty;
-
-/**
- * Structure representing whether or not an edge is a jump.
- */
-struct IsJump {
-	bool _isJump = false; ///< Whether or not the edge is a jump.
-
-	/**
-	 * Parameterless constructor for Group. Required for use with STL and Boost, should not be called manually.
-	 */
-	IsJump() { _isJump = false; };
-
-	/**
-	 * Constructor for IsJump.
-	 *
-	 * @param isJump Whether or not the edge is a jump.
-	 */
-	IsJump(bool isJump) : _isJump(isJump) {};
-
-	/**
-	 * Output edge information to an std::ostream as a graphviz edge property.
-	 *
-	 * @param output The std::ostream to output to.
-	 * @param isJump The IsJump to output.
-	 * @return The std::ostream used for output.
-	 */
-	friend std::ostream &operator<<(std::ostream &output, IsJump isJump) {
-		if (isJump._isJump)
-			output << "empty";
-		else
-			output << "normal";
-		return output;
-	}
-};
-
-namespace boost {
-
-/**
- * Property writer for the isJump property.
- */
-template <class Name>
-class arrowheadWriter {
-public:
-
-	/**
-	 * Constructor for arrowheadWriter.
-	 *
-	 * @param _name The name of the attribute to use.
-	 */
-	arrowheadWriter(Name _name) : name(_name) {}
-
-	/**
-	 * Outputs the arrowhead edge property.
-	 *
-	 * @param out The std::ostream to output to.
-	 * @param v   The vertex or edge to output the attribute for.
-	 */
-	template <class VertexOrEdge>
-	void operator()(std::ostream& out, const VertexOrEdge& v) const {
-		out << "[arrowhead=\"" << get(name, v) << "\"]";
-	}
-private:
-	Name name; ///< The name of the attribute to use.
-};
-
-/**
- * Creates an arrowhead property writer.
- *
- * @param _name The name of the attribute to use.
- */
-template <class Name>
-inline arrowheadWriter<Name>
-makeArrowheadWriter(Name n) {
-	return arrowheadWriter<Name>(n);
-}
-
-} // End of namespace boost
-
-typedef boost::property<boost::edge_attribute_t, IsJump> EdgeProperty;
-
-/**
- * Type used for the code flow graph.
- */
-typedef boost::adjacency_list<boost::setS, boost::listS, boost::bidirectionalS, GraphProperty, EdgeProperty> Graph;
-
-/**
- * Type representing a vertex in the graph.
- */
-typedef Graph::vertex_descriptor GraphVertex;
-
-/**
- * Type representing an iterator for vertices.
- */
-typedef Graph::vertex_iterator VertexIterator;
-
-/**
- * Type representing an edge in the graph.
- */
-typedef Graph::edge_descriptor GraphEdge;
-
-/**
- * Type representing an iterator for outgoing edges.
- */
-typedef Graph::out_edge_iterator OutEdgeIterator;
-
-/**
- * Type representing an iterator for ingoing edges.
- */
-typedef Graph::in_edge_iterator InEdgeIterator;
-
-/**
- * Type representing a range of vertices from boost::vertices.
- */
-typedef std::pair<VertexIterator, VertexIterator> VertexRange;
-
-/**
- * Type representing a range of edges from boost::out_edges.
- */
-typedef std::pair<OutEdgeIterator, OutEdgeIterator> OutEdgeRange;
-
-/**
- * Type representing a range of edges from boost::in_edges.
- */
-typedef std::pair<InEdgeIterator, InEdgeIterator> InEdgeRange;
-
-/**
- * Structure representing a line of code.
- */
-struct CodeLine {
-	std::string _line = "0";    ///< The line of code.
-	bool _unindentBefore = false; ///< Whether or not to add an indentation level before outputting the line.
-	bool _indentAfter = false;    ///< Whether or not to remove an indentation level after outputting the line.
-
-	/**
-	 * Constructor for CodeLine.
-	 *
-	 * @param line The line of code.
-	 * @param unindentBefore Whether or not to remove an indentation level before the line. Defaults to false.
-	 * @param indentAfter Whether or not to add an indentation level after the line. Defaults to false.
-	 */
-	CodeLine(const std::string& line, bool unindentBefore, bool indentAfter) {
-		_line = line;
-		_unindentBefore = unindentBefore;
-		_indentAfter = indentAfter;
-	}
-};
-
-/**
- * Weak references to groups ending else blocks.
- */
-typedef std::vector<Group *> ElseEnds;
-
-/**
- * Iterator type for ElseEnds
- */
-typedef ElseEnds::iterator ElseEndIterator;
-
-/**
- * Structure representing a group of instructions.
- */
-struct Group : public RefCounted {
-public:
-	GraphVertex _vertex;         ///< Vertex the group belongs to.
-	InstIterator start_;    ///< First instruction in the group.
-	InstIterator end_;      ///< Last instruction in the group.
-	int _stackLevel;             ///< Level of the stack upon entry.
-	GroupType _type;             ///< Type of the group.
-	bool _startElse;             ///< Group is start of an else block.
-	ElseEnds _endElse;           ///< Group is end of an else block.
-	Group *_prev;                ///< Pointer to the previous group, when ordered by address. Used for short-circuit analysis.
-	Group *_next;                ///< Pointer to the next group, when ordered by address.
-	std::vector<CodeLine> _code; ///< Container for decompiled lines of code.
-	bool _coalescedElse;         ///< True if an else starting has been coalesced with another block (e.g. "else if"). If true, an else starting here should not be closed explicitly, but left to the other block.
-
-	/**
-	 * Parameterless constructor for Group. Required for use with STL and Boost, should not be called manually.
-	 */
-	Group() : _stackLevel(-1), _type(kNormalGroupType) { }
-
-	/**
-	 * Constructor for Group.
-	 *
-	 * @param v     The vertex the group belongs to.
-	 * @param start First instruction in the group.
-	 * @param end   Last instruction in the group.
-	 * @param prev  Pointer to the previous group, when ordered by address.
-	 */
-	Group(GraphVertex v,InstIterator start, InstIterator end, GroupPtr prev) {
-		_vertex = v;
-		start_ = start;
-		end_ = end;
-		_stackLevel = -1;
-		_type = kNormalGroupType;
-		_prev = prev.get();
-		_startElse = false;
-		if (_prev != NULL)
-			_prev->_next = this;
-		_next = NULL;
-		_coalescedElse = false;
-	}
-
-	/**
-	 * Output a group to an std::ostream as a graphviz label.
-	 *
-	 * @param output The std::ostream to output to.
-	 * @param group  The Group to output.
-	 * @return The std::ostream used for output.
-	 */
-	friend std::ostream &operator<<(std::ostream &output, GroupPtr group) {
-		output << "{Block type: ";
-		switch(group->_type) {
-		case kNormalGroupType:
-			output << "Normal";
-			break;
-		case kWhileCondGroupType:
-			output << "While condition";
-			break;
-		case kDoWhileCondGroupType:
-			output << "Do-while condition";
-			break;
-		case kIfCondGroupType:
-			output << "If condition";
-			break;
-		case kBreakGroupType:
-			output << "Break";
-			break;
-		case kContinueGroupType:
-			output << "Continue";
-			break;
-		}
-		output << "\\n";
-		output << "Expected stack level: " << group->_stackLevel << "\\n";
-		if (group->_startElse)
-			output << "Start of else\\n";
-		for (ElseEndIterator it = group->_endElse.begin(); it != group->_endElse.end(); ++it) {
-			output << boost::format("End of else at %08x\\n") % (*(*it)->start_)->_address;
-		}
-		output << "|";
-		ConstInstIterator inst = group->start_;
-		do {
-			std::stringstream stream;
-			stream << *inst;
-#if (BOOST_VERSION >= 104500)
-				output << stream.str();
-#else
-				std::string s = stream.str();
-				for (std::string::iterator it = s.begin(); it != s.end(); ++it)
-					if (*it == '"')
-						output << "\\\"";
-					else if (*it == '|')
-						output << "\\|";
-					else if (*it == '{')
-						output << "\\{";
-					else if (*it == '}')
-						output << "\\}";
-					else
-						output << *it;
-#endif
-			output << "\\n";
-		} while (inst++ != group->end_);
-		output << "}";
-		return output;
-	}
-};
-
-class Engine;
-
-/**
- * Type used to set properties for dot output.
- */
-struct GraphProperties {
-private:
-	Engine *_engine; ///< Pointer to the engine containing function information for the script.
-	const Graph* _g; ///<  Pointer to the to the graph for the script.
-
-public:
-    GraphProperties(const GraphProperties& rhs)
-    {
-        *this = rhs;
-    }
-
-    GraphProperties& operator = (const GraphProperties& rhs)
-    {
-        if (this != &rhs)
-        {
-            _engine = rhs._engine;
-            _g = rhs._g;
-        }
-        return *this;
-    }
-
-	/**
-	 * Constructor for GraphProperties.
-	 *
-	 * @param engine Pointer to the engine containing function information for the script.
-	 * @param g Const reference to the graph for the script.
-	 */
-	GraphProperties(Engine *engine, const Graph &g) : _engine(engine), _g(&g) {
-	}
-
-	/**
-	 * Called by write_graphviz from Boost.Graph to print properties of the graph.
-	 *
-	 * @param out The std::ostream write_graphviz is writing to.
-	 */
-	void operator()(std::ostream& out) const;
-};
-
-#endif

+ 0 - 343
V-Gears-Installer/include/decompiler/instruction.h

@@ -1,343 +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 DEC_INSTRUCTION_H
-#define DEC_INSTRUCTION_H
-
-#include <string>
-#include <vector>
-#include <boost/format.hpp>
-#include <boost/intrusive_ptr.hpp>
-
-#include "common/scummsys.h"
-#include "refcounted.h"
-#include "value.h"
-#include "wrongtype.h"
-
-class CodeGenerator;
-class Engine;
-
-/**
- * Changes whether or not to output the stack effect for an instruction.
- */
-void setOutputStackEffect(bool value);
-
-/**
- * Constants for categorizing the different kinds of instructions.
- */
-const int kBinaryOpInst = 0;     ///< Binary operation (e.g. +, &&, etc.), including comparisons.
-const int kBoolNegateInst = 1;   ///< Boolean negation.
-const int kCallInst = 2;         ///< Regular function call.
-const int kCondJumpInst = 3;     ///< Conditional jump.
-const int kDupInst = 4;          ///< Instruction duplicates the most recent stack entry.
-const int kJumpInst = 5;         ///< Unconditional jump.
-const int kKernelCallInst = 6;   ///< Kernel functions.
-const int kLoadInst = 7;         ///< Load value from memory.
-const int kReturnInst = 8;       ///< Return from regular function call.
-const int kStackInst = 9;        ///< Stack allocation or deallocation (altering stack pointer)
-const int kStoreInst = 10;       ///< Store value in memory.
-const int kUnaryOpPreInst = 11;  ///< Unary operation (e.g. !) with operator placed before the operator.
-const int kUnaryOpPostInst = 12; ///< Unary operation with operator placed after the operator.
-
-const int kFirstCustomInst = kUnaryOpPostInst + 1; ///< First unused key. Add your custom type keys starting with this value.
-
-struct Instruction;
-
-/**
- * Pointer to an Instruction.
- */
-typedef boost::intrusive_ptr<Instruction> InstPtr;
-
-class Function;
-
-/**
- * Structure for representing an instruction.
- */
-struct Instruction : public RefCounted {
-public:
-	uint32 _opcode;                 ///< The instruction opcode.
-	uint32 _address;                ///< The instruction address.
-	std::string _name;              ///< The instruction name (opcode name).
-	int16 _stackChange;             ///< How much this instruction changes the stack pointer by.
-	std::vector<ValuePtr> _params;  ///< Array of parameters used for the instruction.
-	std::string _codeGenData;       ///< String containing metadata for code generation. See the extended documentation for details.
-    bool mLabelRequired = false;
-
-	/**
-	 * Operator overload to output an Instruction to a std::ostream.
-	 *
-	 * @param output The std::ostream to output to.
-	 * @param inst   The Instruction to output.
-	 * @return The std::ostream used for output.
-	 */
-	friend std::ostream &operator<<(std::ostream &output, const Instruction *inst) {
-		return inst->Print(output);
-	}
-
-	/**
-	 * Print the instruction 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;
-
-	/**
-	 * Returns whether or not the instruction is a jump of some sort.
-	 *
-	 * @return True if the instruction is a jump, otherwise false.
-	 */
-	virtual bool isJump() const;
-
-	/**
-	 * Returns whether or not the instruction is a conditional jump.
-	 *
-	 * @return True if the instruction is a conditional jump, otherwise false.
-	 */
-	virtual bool isCondJump() const;
-
-	/**
-	 * Returns whether or not the instruction is an unconditional jump.
-	 *
-	 * @return True if the instruction is an unconditional jump, otherwise false.
-	 */
-	virtual bool IsUncondJump() const;
-
-	/**
-	 * Returns whether or not the instruction is a stack operation.
-	 *
-	 * @return True if the instruction is a stack operation, otherwise false.
-	 */
-	virtual bool isStackOp() const;
-
-	/**
-	 * Returns whether or not the instruction is a call to a script function.
-	 *
-	 * @return True if the instruction is a script function call, otherwise false.
-	 */
-	virtual bool IsFuncCall() const;
-
-	/**
-	 * Returns whether or not the instruction is a return statement.
-	 *
-	 * @return True if the instruction is a return statement, otherwise false.
-	 */
-	virtual bool isReturn() const;
-
-	/**
-	 * Returns whether or not the instruction is a call to a kernel function.
-	 *
-	 * @return True if the instruction is a kernel function call, otherwise false.
-	 */
-	virtual bool isKernelCall() const;
-
-	/**
-	 * Returns whether or not the instruction is a load operation.
-	 *
-	 * @return True if the instruction is a load operation, otherwise false.
-	 */
-	virtual bool isLoad() const;
-
-	/**
-	 * Returns whether or not the instruction is a store operation.
-	 *
-	 * @return True if the instruction is a store operation, otherwise false.
-	 */
-	virtual bool isStore() const;
-
-	/**
-	 * Returns the destination address of a jump instruction.
-	 *
-	 * @return Destination address of a jump instruction.
-	 * @throws WrongTypeException if instruction is not a jump.
-	 */
-	virtual uint32 GetDestAddress() const;
-
-	/**
-	 * Process an instruction for code generation.
-	 *
-	 * @param stack The current stack.
-	 * @param engine Pointer to the Engine used for code generation.
-	 * @param codeGen Pointer to the CodeGenerator used for code generation.
-	 */
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) = 0;
-};
-
-/**
- * Instruction performing a jump.
- */
-struct JumpInstruction : public Instruction {
-};
-
-/**
- * Instruction performing a conditional jump.
- */
-struct CondJumpInstruction : public JumpInstruction {
-public:
-	virtual bool isCondJump() const;
-};
-
-/**
- * Instruction performing an unconditional jump.
- */
-struct UncondJumpInstruction : public JumpInstruction {
-public:
-	virtual bool IsUncondJump() const override;
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-};
-
-/**
- * Instruction performing a stack operation.
- */
-struct StackInstruction : public Instruction {
-public:
-	virtual bool isStackOp() const;
-};
-
-/**
- * Instruction performing a script function call.
- */
-struct CallInstruction : public Instruction {
-public:
-	virtual bool IsFuncCall() const;
-};
-
-/**
- * Instruction which loads data from memory.
- */
-struct LoadInstruction : public Instruction {
-public:
-	virtual bool isLoad() const;
-};
-
-/**
- * Instruction which stores data to memory.
- */
-struct StoreInstruction : public Instruction {
-public:
-	virtual bool isStore() const;
-};
-
-/**
- * Instruction duplicating the topmost stack value.
- */
-struct DupInstruction : public Instruction {
-};
-
-/**
- * Instruction performing boolean negation.
- */
-struct BoolNegateInstruction : public Instruction {
-};
-
-/**
- * Instruction performing a binary operation.
- */
-struct BinaryOpInstruction : public Instruction {
-};
-
-/**
- * Instruction performing a unary operation.
- */
-struct UnaryOpInstruction : public Instruction {
-};
-
-/**
- * Instruction performing a kernel function call.
- */
-struct KernelCallInstruction : public Instruction {
-public:
-	virtual bool isKernelCall() const;
-};
-
-/**
- * Default implementation for stack-based instruction duplicating the topmost stack value.
- */
-struct DupStackInstruction : public DupInstruction {
-public:
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-};
-
-/**
- * Default implementation for stack-based instruction performing boolean negation.
- */
-struct BoolNegateStackInstruction : public BoolNegateInstruction {
-public:
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-};
-
-/**
- * Default implementation for stack-based instruction performing a binary operation.
- */
-struct BinaryOpStackInstruction : public BinaryOpInstruction {
-public:
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-};
-
-/**
- * Instruction which returns from a function.
- */
-struct ReturnInstruction : public Instruction {
-public:
-    virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-	virtual bool isReturn() const;
-};
-
-/**
- * Default implementation for stack-based instruction performing a unary operation, with a prefixed operator.
- */
-struct UnaryOpPrefixStackInstruction : public UnaryOpInstruction {
-public:
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-};
-
-/**
- * Default implementation for stack-based instruction performing a unary operation, with a postfixed operator.
- */
-struct UnaryOpPostfixStackInstruction : public UnaryOpInstruction {
-public:
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-};
-
-/**
- * Default implementation for stack-based instruction performing a kernel function call.
- */
-struct KernelCallStackInstruction : public Instruction {
-public:
-	virtual void ProcessInst(Function& func, ValueStack &stack, Engine *engine, CodeGenerator *codeGen) override;
-};
-
-/**
- * Type representing a vector of InstPtrs.
- */
-typedef std::vector<InstPtr> InstVec;
-
-/**
- * Type representing an iterator over InstPtrs.
- */
-typedef InstVec::iterator InstIterator;
-
-/**
- * Type representing a const_iterator over InstPtrs.
- */
-typedef InstVec::const_iterator ConstInstIterator;
-
-#endif

+ 23 - 0
V-Gears-Installer/include/decompiler/instruction/BinaryOpInstruction.h

@@ -0,0 +1,23 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction performing a binary operation.
+ */
+class BinaryOpInstruction : public Instruction{};

+ 37 - 0
V-Gears-Installer/include/decompiler/instruction/BinaryOpStackInstruction.h

@@ -0,0 +1,37 @@
+/*
+ * 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 "BinaryOpInstruction.h"
+
+/**
+ * Default implementation for stack-based instruction performing a binary operation.
+ */
+class BinaryOpStackInstruction: public BinaryOpInstruction{
+
+    public:
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

+ 23 - 0
V-Gears-Installer/include/decompiler/instruction/BoolNegateInstruction.h

@@ -0,0 +1,23 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction performing boolean negation.
+ */
+class BoolNegateInstruction: public Instruction{};

+ 37 - 0
V-Gears-Installer/include/decompiler/instruction/BoolNegateStackInstruction.h

@@ -0,0 +1,37 @@
+/*
+ * 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 "BoolNegateInstruction.h"
+
+/**
+ * Default implementation for stack-based instruction performing boolean negation.
+ */
+class BoolNegateStackInstruction: public BoolNegateInstruction{
+
+    public:
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

+ 34 - 0
V-Gears-Installer/include/decompiler/instruction/CallInstruction.h

@@ -0,0 +1,34 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction performing a script function call.
+ */
+class CallInstruction: public Instruction{
+
+    public:
+
+        /**
+         * Checks if the instruction is a call to a script function.
+         *
+         * @return True if the instruction is a script function call, false
+         * otherwise.
+         */
+        virtual bool IsFuncCall() const;
+};

+ 34 - 0
V-Gears-Installer/include/decompiler/instruction/CondJumpInstruction.h

@@ -0,0 +1,34 @@
+/*
+ * 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 "JumpInstruction.h"
+
+/**
+ * Instruction performing a conditional jump.
+ */
+class CondJumpInstruction: public JumpInstruction{
+
+    public:
+
+        /**
+         * Checks if the instruction is a conditional jump.
+         *
+         * @return True if the instruction is a conditional jump, false
+         * otherwise.
+         */
+        virtual bool IsCondJump() const;
+};

+ 23 - 0
V-Gears-Installer/include/decompiler/instruction/DupInstruction.h

@@ -0,0 +1,23 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction duplicating the topmost stack value.
+ */
+class DupInstruction: public Instruction{};

+ 37 - 0
V-Gears-Installer/include/decompiler/instruction/DupStackInstruction.h

@@ -0,0 +1,37 @@
+/*
+ * 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 "DupInstruction.h"
+
+/**
+ * Default implementation for stack-based instruction duplicating the topmost stack value.
+ */
+class DupStackInstruction: public DupInstruction{
+
+    public:
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

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

@@ -0,0 +1,392 @@
+/*
+ * 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 <string>
+#include <vector>
+#include <boost/format.hpp>
+#include <boost/intrusive_ptr.hpp>
+
+#include "../RefCounted.h"
+#include "common/scummsys.h"
+#include "decompiler/value.h"
+#include "decompiler/wrongtype.h"
+
+class CodeGenerator;
+
+class Engine;
+
+/**
+ * Changes whether or not to output the stack effect for an instruction.
+ *
+ * @param value[in] True to output the effect, false not to.
+ */
+void SetOutputStackEffect(bool value);
+
+class Instruction;
+
+/**
+ * Pointer to an Instruction.
+ */
+typedef boost::intrusive_ptr<Instruction> InstPtr;
+
+class Function;
+
+/**
+ * Structure for representing an instruction.
+ */
+class Instruction : public RefCounted {
+
+    public:
+
+        /**
+         * Binary operation (e.g. +, &&, etc.), including comparisons.
+         */
+        static int INST_TYPE_BINARY_OP;
+
+        /**
+         * Boolean negation.
+         */
+        static int INST_TYPE_BOOL_NEGATE;
+
+        /**
+         * Regular function call.
+         */
+        static int INST_TYPE_CALL;
+
+        /**
+         * Conditional jump.
+         */
+        static int INST_TYPE_COND_JUMP;
+
+        /**
+         * Instruction duplicates the most recent stack entry.
+         */
+        static int INST_TYPE_DUP;
+
+        /**
+         * Unconditional jump.
+         */
+        static int INST_TYPE_JUMP;
+
+        /**
+         * Kernel functions.
+         */
+        static int INST_TYPE_KERNEL_CALL;
+
+        /**
+         * Load value from memory.
+         */
+        static int INST_TYPE_LOAD;
+
+        /**
+         * Return from regular function call.
+         */
+        static int INST_TYPE_RETURN;
+
+        /**
+         * Stack allocation or deallocation (altering stack pointer).
+         */
+        static int INST_TYPE_STACK;
+
+        /**
+         * Store value in memory.
+         */
+        static int INST_TYPE_STORE;
+
+        /**
+         * Unary operation (e.g. !) with operator placed before the operator.
+         */
+        static int INST_TYPE_UNARY_OP_PRE;
+
+        /**
+         * Unary operation with operator placed after the operator.
+         */
+        static int INST_TYPE_UNARY_OP_POST;
+
+        /**
+         * Operator overload to output an Instruction to a stream.
+         *
+         * @param output[out] The stream to output to.
+         * @param inst[in] The Instruction to output.
+         * @return The stream used for output.
+         */
+        friend std::ostream& operator<<(std::ostream &output, const Instruction *inst) {
+            return inst->Print(output);
+        }
+
+        /**
+         * Print the instruction 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;
+
+        /**
+         * Checks if the instruction is a jump of some sort.
+         *
+         * @return True if the instruction is a jump, otherwise false.
+         */
+        virtual bool IsJump() const;
+
+        /**
+         * Checks if the instruction is a conditional jump.
+         *
+         * @return True if the instruction is a conditional jump, false
+         * otherwise.
+         */
+        virtual bool IsCondJump() const;
+
+        /**
+         * Checks if the instruction is an unconditional jump.
+         *
+         * @return True if the instruction is an unconditional jump, false
+         * otherwise.
+         */
+        virtual bool IsUncondJump() const;
+
+        /**
+         * Checks if the instruction is a stack operation.
+         *
+         * @return True if the instruction is a stack operation, false
+         * otherwise.
+         */
+        virtual bool IsStackOp() const;
+
+        /**
+         * Checks if the instruction is a call to a script function.
+         *
+         * @return True if the instruction is a script function call, false
+         * otherwise.
+         */
+        virtual bool IsFuncCall() const;
+
+        /**
+         * Checks if the instruction is a return statement.
+         *
+         * @return True if the instruction is a return statement, false
+         * otherwise.
+         */
+        virtual bool IsReturn() const;
+
+        /**
+         * Checks if the instruction is a call to a kernel function.
+         *
+         * @return True if the instruction is a kernel function call, false
+         * otherwise.
+         */
+        virtual bool IsKernelCall() const;
+
+        /**
+         * Checks if the instruction is a load operation.
+         *
+         * @return True if the instruction is a load operation, false
+         * otherwise.
+         */
+        virtual bool IsLoad() const;
+
+        /**
+         * Checks if the instruction is a store operation.
+         *
+         * @return True if the instruction is a store operation, false
+         * otherwise.
+         */
+        virtual bool IsStore() const;
+
+        /**
+         * Returns the destination address of a jump instruction.
+         *
+         * @return Destination address of a jump instruction.
+         * @throws WrongTypeException if instruction is not a jump.
+         */
+        virtual uint32 GetDestAddress() const;
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack& stack, Engine* engine, CodeGenerator* code_gen
+        ) = 0;
+
+        /**
+         * Retrieves the instruction opcode.
+         *
+         * @return The opcode.
+         */
+        uint32 GetOpcode() const;
+
+        /**
+         * Sets the instruction opcode.
+         *
+         * @param opcode[in] The opcode.
+         */
+        void SetOpcode(uint32 opcode);
+
+        /**
+         * Retrieves the instruction address.
+         *
+         * @return The address.
+         */
+        uint32 GetAddress() const;
+
+        /**
+         * Sets the instruction address.
+         *
+         * @param address[in] The address.
+         */
+        void SetAddress(uint32 address);
+
+        /**
+         * Retrieves the instruction name (the opcode name).
+         *
+         * @return The name.
+         */
+        std::string GetName() const;
+
+        void SetName(std::string name);
+
+        /**
+         * Checks how much the instruction changes the stack pointer.
+         *
+         * @return The stack pointer change, in bytes.
+         */
+        int16 GetStackChange() const;
+
+        /**
+         * Defines how much the instruction changes the stack pointer.
+         *
+         * @param stack_change[in] Bytes the instruction changes the stack
+         * pointer by.
+         */
+        void SetStackChange(int16 stack_change);
+
+        /**
+         * Retrieves the list of instruction parameters.
+         *
+         * @return The list of parameters.
+         */
+        std::vector<ValuePtr> GetParams() const;
+
+        /**
+         * Retrieves a instruction parameter.
+         *
+         * @param index[in] Index of the parameter to retrieve.
+         * @return The parameter at the specified index, or nullptr if there
+         * is not that many parameters.
+         */
+        ValuePtr GetParam(uint32 index) const;
+
+        /**
+         * Sets the instructions parameters.
+         *
+         * @param params[in] The list of instruction parameters.
+         */
+        void SetParams(std::vector<ValuePtr> params);
+
+        /**
+         * Adds a parameter to the instructions.
+         *
+         * @param value[in] The parameter to add.
+         */
+        void AddParam(ValuePtr value);
+
+        /**
+         * Retrieves metadata for code generation.
+         *
+         * See the extended documentation for details.
+         *
+         * @return Code generator metadata.
+         */
+        std::string GetCodeGenData() const;
+
+        /**
+         * Sets metadata for code generation.
+         *
+         * See the extended documentation for details.
+         *
+         * @params code_gen_data[in] Code generator metadata.
+         */
+        void SetCodeGenData(std::string code_gen_data);
+
+        /**
+         * Checks if the instruction requires a label.
+         */
+        bool LabelRequired() const;
+
+        /**
+         * Indicates if the instruction needs a label.
+         */
+        void SetLabelRequired(bool required);
+
+    protected:
+
+        /**
+         * The instruction opcode.
+         */
+        uint32 opcode_;
+
+        /**
+         * The instruction address.
+         */
+        uint32 address_;
+
+        /**
+         * The instruction name (opcode name).
+         */
+        std::string name_;
+
+        /**
+         * How much this instruction changes the stack pointer by.
+         */
+        int16 stack_change_;
+
+        /**
+         * Array of parameters used for the instruction.
+         */
+        std::vector<ValuePtr> params_;
+
+        /**
+         * String containing metadata for code generation.
+         *
+         * See the extended documentation for details.
+         */
+        std::string code_gen_data_;
+
+        /**
+         * Indicates if a label is required.
+         */
+        bool label_required_ = false;
+};
+
+/**
+ * Type representing a vector of InstPtrs.
+ */
+typedef std::vector<InstPtr> InstVec;
+
+/**
+ * Type representing an iterator over InstPtrs.
+ */
+typedef InstVec::iterator InstIterator;
+
+/**
+ * Type representing a const_iterator over InstPtrs.
+ */
+typedef InstVec::const_iterator ConstInstIterator;

+ 23 - 0
V-Gears-Installer/include/decompiler/instruction/JumpInstruction.h

@@ -0,0 +1,23 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction performing a jump.
+ */
+class JumpInstruction: public Instruction {};

+ 34 - 0
V-Gears-Installer/include/decompiler/instruction/KernelCallInstruction.h

@@ -0,0 +1,34 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction performing a kernel function call.
+ */
+class KernelCallInstruction: public Instruction{
+
+    public:
+
+        /**
+         * Checks if the instruction is a call to a kernel function.
+         *
+         * @return True if the instruction is a kernel function call, false
+         * otherwise.
+         */
+        virtual bool IsKernelCall() const;
+};

+ 37 - 0
V-Gears-Installer/include/decompiler/instruction/KernelCallStackInstruction.h

@@ -0,0 +1,37 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Default implementation for stack-based instruction performing a kernel function call.
+ */
+class KernelCallStackInstruction : public Instruction{
+
+    public:
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

+ 34 - 0
V-Gears-Installer/include/decompiler/instruction/LoadInstruction.h

@@ -0,0 +1,34 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction which loads data from memory.
+ */
+class LoadInstruction: public Instruction{
+
+    public:
+
+        /**
+         * Checks if the instruction is a load operation.
+         *
+         * @return True if the instruction is a load operation, false
+         * otherwise.
+         */
+        virtual bool IsLoad() const;
+};

+ 45 - 0
V-Gears-Installer/include/decompiler/instruction/ReturnInstruction.h

@@ -0,0 +1,45 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction which returns from a function.
+ */
+class ReturnInstruction: public Instruction{
+
+    public:
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+        /**
+         * Checks if the instruction is a return statement.
+         *
+         * @return True if the instruction is a return statement, false
+         * otherwise.
+         */
+        virtual bool IsReturn() const;
+};

+ 34 - 0
V-Gears-Installer/include/decompiler/instruction/StackInstruction.h

@@ -0,0 +1,34 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction performing a stack operation.
+ */
+class StackInstruction: public Instruction{
+
+    public:
+
+        /**
+         * Checks if the instruction is a stack operation.
+         *
+         * @return True if the instruction is a stack operation, false
+         * otherwise.
+         */
+        virtual bool IsStackOp() const;
+};

+ 34 - 0
V-Gears-Installer/include/decompiler/instruction/StoreInstruction.h

@@ -0,0 +1,34 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction which stores data to memory.
+ */
+class StoreInstruction: public Instruction{
+
+    public:
+
+        /**
+         * Checks if the instruction is a store operation.
+         *
+         * @return True if the instruction is a store operation, false
+         * otherwise.
+         */
+        virtual bool IsStore() const;
+};

+ 23 - 0
V-Gears-Installer/include/decompiler/instruction/UnaryOpInstruction.h

@@ -0,0 +1,23 @@
+/*
+ * 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 "Instruction.h"
+
+/**
+ * Instruction performing a unary operation.
+ */
+class UnaryOpInstruction: public Instruction{};

+ 37 - 0
V-Gears-Installer/include/decompiler/instruction/UnaryOpPostfixStackInstruction.h

@@ -0,0 +1,37 @@
+/*
+ * 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 "UnaryOpInstruction.h"
+
+/**
+ * Default implementation for stack-based instruction performing a unary operation, with a postfixed operator.
+ */
+class UnaryOpPostfixStackInstruction: public UnaryOpInstruction{
+
+    public:
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

+ 37 - 0
V-Gears-Installer/include/decompiler/instruction/UnaryOpPrefixStackInstruction.h

@@ -0,0 +1,37 @@
+/*
+ * 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 "UnaryOpInstruction.h"
+
+/**
+ * Default implementation for stack-based instruction performing a unary operation, with a prefixed operator.
+ */
+class UnaryOpPrefixStackInstruction: public UnaryOpInstruction{
+
+    public:
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

+ 45 - 0
V-Gears-Installer/include/decompiler/instruction/UncondJumpInstruction.h

@@ -0,0 +1,45 @@
+/*
+ * 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 "JumpInstruction.h"
+
+/**
+ * Instruction performing an unconditional jump.
+ */
+class UncondJumpInstruction: public JumpInstruction{
+
+    public:
+
+        /**
+         * Checks if the instruction is an unconditional jump.
+         *
+         * @return True if the instruction is an unconditional jump, false
+         * otherwise.
+         */
+        virtual bool IsUncondJump() const override;
+
+        /**
+         * Process an instruction for code generation.
+         *
+         * @param stack[in] The current stack.
+         * @param engine[in] The Engine used for code generation.
+         * @param code_gen[in] The CodeGenerator used for code generation.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

+ 0 - 82
V-Gears-Installer/include/decompiler/objectFactory.h

@@ -1,82 +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 DEC_OBJECTFACTORY_H
-#define DEC_OBJECTFACTORY_H
-
-#include <map>
-#include <string>
-
-#include "common/scummsys.h"
-
-/**
- * Template function for creating an instance of Type.
- */
-template<typename BaseType, typename Type>
-BaseType *createObject() {
-	return new Type();
-}
-
-/**
- * Generic factory for a class and its subclasses.
- */
-template<typename KeyType, typename BaseType>
-class ObjectFactory {
-private:
-
-	/**
-	 * Function pointer to the object creation function.
-	 */
-	typedef BaseType *(*CreateFunc)();
-
-	/**
-	 * Type used to store registered entries.
-	 */
-	typedef std::map<KeyType, CreateFunc> RegistryMap;
-
-	RegistryMap _registry; ///< Map from an identifier to a creation function.
-
-public:
-	/**
-	 * Register a new entry.
-	 *
-	 * @param key The key to register the class under.
-	 */
-	template<typename Type>
-	void addEntry(const KeyType &key) {
-		_registry[key] = &createObject<BaseType, Type>;
-	}
-
-	/**
-	 * Creates an instance of some registered class.
-	 *
-	 * @param key The key associated with the desired class.
-	 * @return NULL if the name is not registered, else an instance of the associated class.
-	 */
-	BaseType *create(const KeyType &key) const {
-		typename RegistryMap::const_iterator entry = _registry.find(key);
-		if (entry == _registry.end())
-			return NULL;
-		return (entry->second)();
-	}
-};
-
-#endif

+ 0 - 59
V-Gears-Installer/include/decompiler/refcounted.h

@@ -1,59 +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 REFCOUNTED_H
-#define REFCOUNTED_H
-
-class RefCounted;
-
-inline void intrusive_ptr_add_ref(RefCounted *p);
-inline void intrusive_ptr_release(RefCounted *p);
-
-/**
- * Provides a base implementation of reference counting for use with boost::intrusive_ptr.
- */
-class RefCounted {
-private:
-	long _refCount; ///< Reference count used for boost::intrusive_ptr.
-	friend void ::intrusive_ptr_add_ref(RefCounted *p); ///< Allow access by reference counting methods.
-	friend void ::intrusive_ptr_release(RefCounted *p); ///< Allow access by reference counting methods.
-
-protected:
-	RefCounted() : _refCount(0) { }
-	virtual ~RefCounted() { }
-};
-
-/**
- * Add a reference to a pointer.
- */
-inline void intrusive_ptr_add_ref(RefCounted *p) {
-	++(p->_refCount);
-}
-
-/**
- * Remove a reference from a pointer.
- */
-inline void intrusive_ptr_release(RefCounted *p) {
-	if (--(p->_refCount) == 0)
-		delete p;
-}
-
-#endif

+ 1 - 1
V-Gears-Installer/include/decompiler/test/cfg_test.cpp

@@ -19,12 +19,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include "decompiler/graph.h"
 #include "decompiler/scummv6/engine.h"
 #include <gmock/gmock.h>
 #include <vector>
 #include "../ControlFlow.h"
 #include "../Disassembler.h"
+#include "../Graph.h"
 
 #define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
 

+ 1 - 1
V-Gears-Installer/include/decompiler/test/codegen.cpp

@@ -20,7 +20,6 @@
  */
 
 
-#include "decompiler/graph.h"
 #include "decompiler/scummv6/engine.h"
 
 #include <vector>
@@ -28,6 +27,7 @@
 #include "../CodeGenerator.h"
 #include "../ControlFlow.h"
 #include "../Disassembler.h"
+#include "../Graph.h"
 #define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
 
 #include <streambuf>

+ 10 - 10
V-Gears-Installer/include/decompiler/test/ff7_field_control_flow_test.cpp

@@ -13,8 +13,8 @@ static uint32 Is3Nops(InstVec& insts, uint32& pos)
     for (int i = 0; i < 3; i++)
     {
         pos++;
-        EXPECT_EQ(insts[pos]->_opcode, FF7::eOpcodes::NOP);
-        EXPECT_EQ(insts[pos]->_params.size(), 0);
+        EXPECT_EQ(insts[pos]->opcode_, FF7::eOpcodes::NOP);
+        EXPECT_EQ(insts[pos]->params_.size(), 0);
     }
     return insts[pos]->_address;
 }
@@ -26,8 +26,8 @@ static void CheckForwardJump(FF7::eOpcodes opCode, size_t paramsSize, InstVec& i
 {
     pos++;
     const InstPtr& jumpInst = insts[pos];
-    ASSERT_EQ(jumpInst->_opcode, opCode);
-    ASSERT_EQ(jumpInst->_params.size(), paramsSize);
+    ASSERT_EQ(jumpInst->opcode_, opCode);
+    ASSERT_EQ(jumpInst->params_.size(), paramsSize);
 
     const uint32 lastNopAddr = Is3Nops(insts, pos);
     ASSERT_EQ(jumpInst->GetDestAddress(), lastNopAddr);
@@ -37,8 +37,8 @@ static void CheckForwardJump(FF7::eOpcodes opCode, size_t paramsSize, InstVec& i
 static uint32 IsNop(InstVec& insts, uint32& pos)
 {
     pos++;
-    EXPECT_EQ(insts[pos]->_opcode, FF7::eOpcodes::NOP);
-    EXPECT_EQ(insts[pos]->_params.size(), 0);
+    EXPECT_EQ(insts[pos]->opcode_, FF7::eOpcodes::NOP);
+    EXPECT_EQ(insts[pos]->params_.size(), 0);
     return insts[pos]->_address;
 }
 
@@ -58,8 +58,8 @@ static void CheckBackwardJump(FF7::eOpcodes opCode, size_t paramsSize, InstVec&
     pos++;
     const InstPtr& jumpInst = insts[pos];
 
-    ASSERT_EQ(jumpInst->_opcode, opCode);
-    ASSERT_EQ(jumpInst->_params.size(), paramsSize);
+    ASSERT_EQ(jumpInst->opcode_, opCode);
+    ASSERT_EQ(jumpInst->params_.size(), paramsSize);
     ASSERT_EQ(jumpInst->GetDestAddress(), firstNopAddr);
 }
 
@@ -78,8 +78,8 @@ TEST(FF7Field, ControlFlow)
     std::cout << std::endl;
 
     uint32 pos = 0;
-    ASSERT_EQ(insts[pos]->_opcode, FF7::eOpcodes::RET);
-    ASSERT_EQ(insts[pos]->_params.size(), 0);
+    ASSERT_EQ(insts[pos]->opcode_, FF7::eOpcodes::RET);
+    ASSERT_EQ(insts[pos]->params_.size(), 0);
 
     CheckForwardJump(FF7::eOpcodes::IFUB, 6, insts, pos);
     CheckForwardJump(FF7::eOpcodes::IFSWL, 6, insts, pos);

+ 2 - 2
V-Gears-Installer/include/decompiler/test/main.cpp

@@ -2,6 +2,7 @@
 
 #include "../../common/Lzs.h"
 #include "../ControlFlow.h"
+#include "../Graph.h"
 #include "decompiler/ff7_field/ff7_field_disassembler.h"
 #include "decompiler/ff7_field/ff7_field_engine.h"
 #include "decompiler/ff7_field/ff7_field_codegen.h"
@@ -10,7 +11,6 @@
 #include "decompiler/ff7_world/ff7_world_engine.h"
 
 #include "util.h"
-#include "graph.h"
 #include "sudm.h"
 #include "ff7_field_dummy_formatter.h"
 
@@ -227,7 +227,7 @@ TEST(FF7World, DisAsm)
             auto& g = c->getGraph();
             boost::write_graphviz(
                 out, g, boost::make_label_writer(get(boost::vertex_name, g)),
-                boost::makeArrowheadWriter(get(boost::edge_attribute, g)), GraphProperties(&engine, g));
+                boost::MakeArrowheadWriter(get(boost::edge_attribute, g)), GraphProperties(&engine, g));
         }
         out.close();
 

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

@@ -29,7 +29,7 @@
 #include <boost/intrusive_ptr.hpp>
 
 #include "common/scummsys.h"
-#include "refcounted.h"
+#include "RefCounted.h"
 #include "stack.h"
 #include "wrongtype.h"
 

+ 5 - 5
V-Gears-Installer/include/decompiler/world/WorldDisassembler.h

@@ -66,11 +66,11 @@ namespace FF7{
             ){
                 uint32 full_opcode = (full_opcode << 8) + opcode;
                 this->insts_.push_back(instruction);
-                this->insts_.back()->_opcode = full_opcode;
-                this->insts_.back()->_address = this->address_;
-                this->insts_.back()->_stackChange = 0;
-                this->insts_.back()->_name = std::string(name);
-                this->insts_.back()->_codeGenData = "";
+                this->insts_.back()->SetOpcode(full_opcode);
+                this->insts_.back()->SetAddress(this->address_);
+                this->insts_.back()->SetStackChange(0);
+                this->insts_.back()->SetName(std::string(name));
+                this->insts_.back()->SetCodeGenData("");
                 this->readParams(this->insts_.back(), argument_format);
             }
 

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/BinaryOpStackInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/CondJumpInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/LoadInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/LoadInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/Instruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/StackInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/StoreInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/StackInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

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

@@ -17,7 +17,7 @@
 
 #pragma once
 
-#include "decompiler/instruction.h"
+#include "decompiler/instruction/UncondJumpInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 
 namespace FF7{

+ 46 - 45
V-Gears-Installer/src/decompiler/CodeGenerator.cpp

@@ -85,7 +85,7 @@ void CodeGenerator::Generate(InstVec& insts, const Graph &graph){
 void CodeGenerator::AddOutputLine(std::string line, bool unindent_before, bool indent_after){
     // Don't generate output in the labels pass, just find
     // instructions that require a label to be outputted.
-    if (!is_label_pass_) cur_group_->_code.push_back(CodeLine(line, unindent_before, indent_after));
+    if (!is_label_pass_) cur_group_->code.push_back(CodeLine(line, unindent_before, indent_after));
 }
 
 void CodeGenerator::WriteTodo(std::string class_name, std::string instruction){
@@ -118,14 +118,14 @@ ARGUMENT_ORDER CodeGenerator::GetBinaryOrder(){return bin_order_;}
 
 void CodeGenerator::ProcessInst(Function& function, InstVec& insts, const InstPtr inst){
     inst->ProcessInst(function, stack_, engine_, this);
-    if (inst->isCondJump()) ProcessCondJumpInst(inst);
+    if (inst->IsCondJump()) ProcessCondJumpInst(inst);
     else if (inst->IsUncondJump()) ProcessUncondJumpInst(function, insts, inst);
 }
 
 void CodeGenerator::ProcessUncondJumpInst(Function& function, InstVec& insts, const InstPtr inst){
-    switch (cur_group_->_type){
-        case kBreakGroupType: AddOutputLine(target_lang_->LoopBreak()); break;
-        case kContinueGroupType: AddOutputLine(target_lang_->LoopContinue()); break;
+    switch (cur_group_->type){
+        case GROUP_TYPE_BREAK: AddOutputLine(target_lang_->LoopBreak()); break;
+        case GROUP_TYPE_CONTINUE: AddOutputLine(target_lang_->LoopContinue()); break;
         default: // Might be a goto.
             {
                 bool print_jump = true;
@@ -135,15 +135,15 @@ void CodeGenerator::ProcessUncondJumpInst(Function& function, InstVec& insts, co
                   target != jump_targets.second && print_jump;
                   ++ target
                 ){
-                    Group* next = cur_group_->_next;
+                    Group* next = cur_group_->next;
                     if (next){
                         // Don't output jump to next vertex.
-                        if (boost::target(*target, graph_) == next->_vertex){
+                        if (boost::target(*target, graph_) == next->vertex){
                             print_jump = false;
                             break;
                         }
                         // Don't output jump if next vertex starts an else block.
-                        if (next->_startElse){
+                        if (next->start_else){
                             print_jump = false;
                             break;
                         }
@@ -156,14 +156,15 @@ void CodeGenerator::ProcessUncondJumpInst(Function& function, InstVec& insts, co
                           ++ target_it
                         ){
                             // Don't output jump to while loop that has jump to next vertex.
-                            if (boost::target(*target_it, graph_) == next->_vertex) print_jump = false;
+                            if (boost::target(*target_it, graph_) == next->vertex)
+                                print_jump = false;
                         }
                         if (print_jump){
                             // Check if this instruction is the last instruction in the function
                             // and its an uncond jump.
                             if (
-                              cur_group_->_type == kDoWhileCondGroupType
-                              && inst->_address == function.end_addr
+                              cur_group_->type == GROUP_TYPE_DO_WHILE
+                              && inst->GetAddress() == function.end_addr
                               && inst->IsUncondJump()
                             ){
                                 print_jump = false;
@@ -180,8 +181,8 @@ void CodeGenerator::ProcessUncondJumpInst(Function& function, InstVec& insts, co
                     if (is_label_pass_){
                         // Mark the goto target.
                         for (auto& i : insts){
-                            if (i->_address == dst_addr){
-                                i->mLabelRequired = true;
+                            if (i->GetAddress() == dst_addr){
+                                i->SetLabelRequired(true);
                                 break;
                             }
                         }
@@ -195,37 +196,37 @@ void CodeGenerator::ProcessUncondJumpInst(Function& function, InstVec& insts, co
 
 void CodeGenerator::ProcessCondJumpInst(const InstPtr inst){
     std::stringstream s;
-    switch (cur_group_->_type){
-        case kIfCondGroupType:
-            if (cur_group_->_startElse && cur_group_->_code.size() == 1){
+    switch (cur_group_->type){
+        case GROUP_TYPE_IF:
+            if (cur_group_->start_else && cur_group_->code.size() == 1){
                 OutEdgeRange oer = boost::out_edges(cur_vertex_, graph_);
                 bool coalesce_else = false;
                 for (OutEdgeIterator oe = oer.first; oe != oer.second; ++ oe){
-                    GroupPtr oGr = GET(boost::target(*oe, graph_))->_prev;
+                    GroupPtr oGr = GET(boost::target(*oe, graph_))->prev;
                     if (
-                      std::find(oGr->_endElse.begin(), oGr->_endElse.end(), cur_group_.get())
-                      != oGr->_endElse.end()
+                      std::find(oGr->end_else.begin(), oGr->end_else.end(), cur_group_.get())
+                      != oGr->end_else.end()
                     ){
                         coalesce_else = true;
                     }
                 }
                 if (coalesce_else){
-                    cur_group_->_code.clear();
-                    cur_group_->_coalescedElse = true;
+                    cur_group_->code.clear();
+                    cur_group_->coalesced_else = true;
                     s << target_lang_->EndBlock(LuaLanguage::TO_ELSE_BLOCK)
                       << " " << target_lang_->Else() << " ";
                 }
             }
             s << target_lang_->If(true) << stack_.pop()->negate() << target_lang_->If(false);
-            AddOutputLine(s.str(), cur_group_->_coalescedElse, true);
+            AddOutputLine(s.str(), cur_group_->coalesced_else, true);
             break;
-        case kWhileCondGroupType:
+        case GROUP_TYPE_WHILE:
             s << target_lang_->WhileHeader(true) << stack_.pop()->negate()
               << target_lang_->WhileHeader(false) << " "
               << target_lang_->StartBlock(LuaLanguage::BEGIN_WHILE);
             AddOutputLine(s.str(), false, true);
             break;
-        case kDoWhileCondGroupType:
+        case GROUP_TYPE_DO_WHILE:
             s << target_lang_->EndBlock(LuaLanguage::END_WHILE) <<  " "
               << target_lang_->WhileHeader(true) << stack_.pop()
               << target_lang_->WhileHeader(false);
@@ -282,7 +283,7 @@ void CodeGenerator::GeneratePass(InstVec& insts, const Graph& graph){
         while (!dfs_stack.empty()){
             DFSEntry e = dfs_stack.pop();
             GroupPtr tmp = GET(e.first);
-            if ((*tmp->start_)->_address > (*last_group->start_)->_address) last_group = tmp;
+            if ((*tmp->start)->GetAddress() > (*last_group->start)->GetAddress()) last_group = tmp;
             stack_ = e.second;
             GraphVertex v = e.first;
             Process(fn->second, insts, v);
@@ -303,20 +304,20 @@ void CodeGenerator::GeneratePass(InstVec& insts, const Graph& graph){
         // Print output.
         GroupPtr p = GET(entry_point);
         while (p != NULL){
-            for (auto it = p->_code.begin(); it != p->_code.end(); ++ it){
-                if (it->_unindentBefore){
+            for (auto it = p->code.begin(); it != p->code.end(); ++ it){
+                if (it->unindent_before){
                     assert(indent_level_ > 0);
                     indent_level_--;
                 }
-                if (OutputOnlyRequiredLabels()) output_ << IndentString(it->_line) << std::endl;
+                if (OutputOnlyRequiredLabels()) output_ << IndentString(it->line) << std::endl;
                 else{
                     output_ << (
-                      boost::format("%08X: %s") % (*p->start_)->_address % IndentString(it->_line)
+                      boost::format("%08X: %s") % (*p->start)->GetAddress() % IndentString(it->line)
                     ) << std::endl;
                 }
-                if (it->_indentAfter) indent_level_++;
+                if (it->indent_after) indent_level_++;
             }
-            p = p->_next;
+            p = p->next;
         }
     }
 }
@@ -326,7 +327,7 @@ void CodeGenerator::Process(Function& function, InstVec& insts, GraphVertex vert
     cur_group_ = GET(vertex);
 
     // Check if we should add else start
-    if (cur_group_->_startElse){
+    if (cur_group_->start_else){
         AddOutputLine(
           target_lang_->EndBlock(LuaLanguage::TO_ELSE_BLOCK) + " " + target_lang_->Else()
           + " " + target_lang_->StartBlock(LuaLanguage::BEGIN_ELSE), true, true
@@ -337,39 +338,39 @@ void CodeGenerator::Process(Function& function, InstVec& insts, GraphVertex vert
     for (InEdgeIterator ie = ier.first; ie != ier.second; ++ ie){
         GraphVertex in = boost::source(*ie, graph_);
         GroupPtr in_group = GET(in);
-        if (!boost::get(boost::edge_attribute, graph_, *ie)._isJump || in_group->_stackLevel == -1)
+        if (!boost::get(boost::edge_attribute, graph_, *ie).is_jump || in_group->stack_level == -1)
             continue;
-        switch (in_group->_type){
-            case kDoWhileCondGroupType:
+        switch (in_group->type){
+            case GROUP_TYPE_DO_WHILE:
                 AddOutputLine(target_lang_->DoLoopHeader(), false, true);
                 break;
-            case kIfCondGroupType:
-                if (!cur_group_->_startElse)
+            case GROUP_TYPE_IF:
+                if (!cur_group_->start_else)
                     AddOutputLine(target_lang_->EndBlock(LuaLanguage::END_OF_IF), true, false);
                 break;
-            case kWhileCondGroupType:
+            case GROUP_TYPE_WHILE:
                 AddOutputLine(target_lang_->EndBlock(LuaLanguage::END_OF_WHILE), true, false);
                 break;
             default:
                 break;
         }
     }
-    ConstInstIterator it = cur_group_->start_;
+    ConstInstIterator it = cur_group_->start;
     do{
         // If we only want to write labels that targets of goto's then check
         // if this is the pass after we've setup mLabelRequired on each
         // instruction. If this is set then it needs a label so write one out.
-        if (OutputOnlyRequiredLabels() && !is_label_pass_ && (*it)->mLabelRequired)
-            AddOutputLine(target_lang_->Label((*it)->_address));
+        if (OutputOnlyRequiredLabels() && !is_label_pass_ && (*it)->LabelRequired())
+            AddOutputLine(target_lang_->Label((*it)->GetAddress()));
         ProcessInst(function, insts, *it);
-    } while (it++ != cur_group_->end_);
+    } while (it++ != cur_group_->end);
     // Add else end if necessary
     for (
-      ElseEndIterator else_it = cur_group_->_endElse.begin();
-      else_it != cur_group_->_endElse.end();
+      ElseEndIterator else_it = cur_group_->end_else.begin();
+      else_it != cur_group_->end_else.end();
       ++ else_it
     ){
-        if (!(*else_it)->_coalescedElse)
+        if (!(*else_it)->coalesced_else)
             AddOutputLine(target_lang_->EndBlock(LuaLanguage::END_OF_IF_ELSE_CHAIN), true, false);
     }
 }

+ 108 - 108
V-Gears-Installer/src/decompiler/ControlFlow.cpp

@@ -66,8 +66,8 @@ ControlFlow::ControlFlow(InstVec& insts, Engine& engine): insts_(insts),engine_(
     // and no functions are defined.
     // This avoids a special case for when no real functions exist in the script.
     if (engine_.functions.empty()){
-        engine_.functions[(*insts.begin())->_address]= Function(
-          (*insts.begin())->_address, (insts.back())->_address
+        engine_.functions[(*insts.begin())->GetAddress()]= Function(
+          (*insts.begin())->GetAddress(), (insts.back())->GetAddress()
         );
     }
     GroupPtr prev = NULL;
@@ -75,13 +75,13 @@ ControlFlow::ControlFlow(InstVec& insts, Engine& engine): insts_(insts),engine_(
     // Create vertices.
     for (InstIterator it = insts.begin(); it != insts.end(); ++ it){
         GraphVertex cur = boost::add_vertex(graph_);
-        addr_map_[(*it)->_address] = cur;
+        addr_map_[(*it)->GetAddress()] = cur;
         PUT(cur, new Group(cur, it, it, prev));
         PUT_ID(cur, id);
         id ++;
         // Add reference to vertex if function starts here.
-        if (engine_.functions.find((*it)->_address) != engine_.functions.end()){
-            engine_.functions[(*it)->_address].vertex = cur;
+        if (engine_.functions.find((*it)->GetAddress()) != engine_.functions.end()){
+            engine_.functions[(*it)->GetAddress()].vertex = cur;
         }
         prev = GET(cur);
     }
@@ -91,7 +91,7 @@ ControlFlow::ControlFlow(InstVec& insts, Engine& engine): insts_(insts),engine_(
     bool add_edge = false;
     prev = NULL;
     for (InstIterator it = insts.begin(); it != insts.end(); ++it){
-        if (engine_.functions.find((*it)->_address) != engine_.functions.end())
+        if (engine_.functions.find((*it)->GetAddress()) != engine_.functions.end())
             add_edge = false;
         GraphVertex cur = Find(it);
         if (add_edge){
@@ -99,13 +99,13 @@ ControlFlow::ControlFlow(InstVec& insts, Engine& engine): insts_(insts),engine_(
             PUT_EDGE(e, false);
         }
         last = cur;
-        add_edge = !((*it)->IsUncondJump() || (*it)->isReturn());
+        add_edge = !((*it)->IsUncondJump() || (*it)->IsReturn());
         prev = GET(cur);
 
     }
     // Add jump edges.
     for (InstIterator it = insts.begin(); it != insts.end(); ++ it){
-        if ((*it)->isJump()){
+        if ((*it)->IsJump()){
             GraphEdge e = boost::add_edge(Find(it), Find((*it)->GetDestAddress()), graph_).first;
             PUT_EDGE(e, true);
         }
@@ -114,9 +114,9 @@ ControlFlow::ControlFlow(InstVec& insts, Engine& engine): insts_(insts),engine_(
 
 const Graph& ControlFlow::GetGraph() const{return graph_;}
 
-GraphVertex ControlFlow::Find(const InstPtr inst){return addr_map_[inst->_address];}
+GraphVertex ControlFlow::Find(const InstPtr inst){return addr_map_[inst->GetAddress()];}
 
-GraphVertex ControlFlow::Find(ConstInstIterator it){return addr_map_[(*it)->_address];}
+GraphVertex ControlFlow::Find(ConstInstIterator it){return addr_map_[(*it)->GetAddress()];}
 
 GraphVertex ControlFlow::Find(uint32 address){
     std::map<uint32, GraphVertex>::iterator it = addr_map_.find(address);
@@ -131,14 +131,14 @@ void ControlFlow::Merge(GraphVertex graph_1, GraphVertex graph_2){
     // Update property.
     GroupPtr gr1 = GET(graph_1);
     GroupPtr gr2 = GET(graph_2);
-    gr1->end_ = gr2->end_;
+    gr1->end = gr2->end;
     PUT(graph_1, gr1);
     // Update address map.
-    ConstInstIterator it = gr2->start_;
+    ConstInstIterator it = gr2->start;
     do{
-        addr_map_[(*it)->_address] = graph_1;
+        addr_map_[(*it)->GetAddress()] = graph_1;
         ++ it;
-    } while (gr2->start_ != gr2->end_ && it != gr2->end_);
+    } while (gr2->start != gr2->end && it != gr2->end);
     // Add outgoing edges from graph_2.
     OutEdgeRange r = boost::out_edges(graph_2, graph_);
     for (OutEdgeIterator e = r.first; e != r.second; ++e){
@@ -146,8 +146,8 @@ void ControlFlow::Merge(GraphVertex graph_1, GraphVertex graph_2){
         PUT_EDGE(newE, GET_EDGE(*e));
     }
     // Update _next pointer.
-    gr1->_next = gr2->_next;
-    if (gr2->_next != NULL) gr2->_next->_prev = gr2->_prev;
+    gr1->next = gr2->next;
+    if (gr2->next != NULL) gr2->next->prev = gr2->prev;
     // Remove edges to/from graph_2
     boost::clear_vertex(graph_2, graph_);
     // Remove vertex.
@@ -164,20 +164,20 @@ void ControlFlow::SetStackLevel(GraphVertex graph, int level){
     while (!level_stack.empty()){
         LevelEntry e = level_stack.pop();
         GroupPtr gr = GET(e.first);
-        if (gr->_stackLevel != -1){
-            if (gr->_stackLevel != e.second)
+        if (gr->stack_level != -1){
+            if (gr->stack_level != e.second)
                 std::cerr << boost::format(
                   "WARNING: Inconsistency in expected stack level for instruction "
                   "at address 0x%08x (current: %d, requested: %d)\n"
-                ) % (*gr->start_)->_address % gr->_stackLevel % e.second;
+                ) % (*gr->start)->GetAddress() % gr->stack_level % e.second;
             continue;
         }
-        gr->_stackLevel = e.second;
+        gr->stack_level = e.second;
         OutEdgeRange r = boost::out_edges(e.first, graph_);
         for (OutEdgeIterator oe = r.first; oe != r.second; ++ oe){
             GraphVertex target = boost::target(*oe, graph_);
             if (seen.find(target) == seen.end()){
-                level_stack.push(LevelEntry(target, e.second + (*gr->start_)->_stackChange));
+                level_stack.push(LevelEntry(target, e.second + (*gr->start)->GetStackChange()));
                 seen.insert(target);
             }
         }
@@ -189,7 +189,7 @@ void ControlFlow::CreateGroups(){
       !engine_.functions.empty()
       //&& GET(engine_.functions.begin()->second.GetVertex())->_stackLevel != -1
       //&& GET(engine_.functions.begin()->second.vertex_)->_stackLevel != -1
-      && GET(engine_.functions.begin()->second.vertex)->_stackLevel != -1
+      && GET(engine_.functions.begin()->second.vertex)->stack_level != -1
     ){
         return;
     }
@@ -212,52 +212,52 @@ void ControlFlow::CreateGroups(){
         GroupPtr group_cur = GET(cur);
         GroupPtr group_next = GET(next);
         // Don't process unreachable code.
-        if (group_cur->_stackLevel < 0){
-            stack_level = group_next->_stackLevel;
+        if (group_cur->stack_level < 0){
+            stack_level = group_next->stack_level;
             continue;
         }
-        expected_stack_level = group_cur->_stackLevel;
+        expected_stack_level = group_cur->stack_level;
         // If expected stack level decreases in next vertex, then
         // use next vertex level as expected level.
-        if (expected_stack_level > group_next->_stackLevel && group_next->_stackLevel >= 0){
-            expected_stack_level = group_next->_stackLevel;
+        if (expected_stack_level > group_next->stack_level && group_next->stack_level >= 0){
+            expected_stack_level = group_next->stack_level;
             // Also set the stack level of the current group
             // to remember that we expect it to be lower.
-            group_cur->_stackLevel = expected_stack_level;
+            group_cur->stack_level = expected_stack_level;
         }
-        stack_level += (*cur_inst)->_stackChange;
+        stack_level += (*cur_inst)->GetStackChange();
         // For stack operations, the new stack level becomes the
         // expected stack level starting from the next group.
-        if ((*cur_inst)->isStackOp()){
+        if ((*cur_inst)->IsStackOp()){
             expected_stack_level = stack_level;
-            group_next->_stackLevel = stack_level;
+            group_next->stack_level = stack_level;
         }
         // Group ends after a jump.
-        if ((*cur_inst)->isJump()){
-            stack_level = group_next->_stackLevel;
+        if ((*cur_inst)->IsJump()){
+            stack_level = group_next->stack_level;
             continue;
         }
         // Group ends with a return.
-        if ((*cur_inst)->isReturn()){
-            stack_level = group_next->_stackLevel;
+        if ((*cur_inst)->IsReturn()){
+            stack_level = group_next->stack_level;
             continue;
         }
         // Group ends before target of a jump.
         if (in_degree(next, graph_) != 1){
-            stack_level = group_next->_stackLevel;
+            stack_level = group_next->stack_level;
             continue;
         }
         // This part is only relevant if we use the stack level.
         if (!engine_.UsePureGrouping()){
             // If group has no instructions with stack effect >= 0, don't merge on balanced stack.
             bool forceMerge = true;
-            ConstInstIterator it = group_cur->start_;
+            ConstInstIterator it = group_cur->start;
             do{
-                if ((*it)->_stackChange >= 0) forceMerge = false;
+                if ((*it)->GetStackChange() >= 0) forceMerge = false;
                 ++ it;
-            } while (group_cur->start_ != group_cur->end_ && it != group_cur->end_);
+            } while (group_cur->start != group_cur->end && it != group_cur->end);
             // Group ends when stack is balanced, unless just before conditional jump.
-            if (stack_level == expected_stack_level && !forceMerge && !(*next_inst)->isCondJump())
+            if (stack_level == expected_stack_level && !forceMerge && !(*next_inst)->IsCondJump())
                 continue;
         }
         // All checks passed, merge groups
@@ -278,10 +278,10 @@ void ControlFlow::DetectShortCircuit(){
     -- last_inst;
     GraphVertex cur = Find(last_inst);
     GroupPtr gr = GET(cur);
-    while (gr->_prev != NULL){
+    while (gr->prev != NULL){
         bool do_merge = false;
-        cur = Find(gr->start_);
-        GraphVertex prev = Find(gr->_prev->start_);
+        cur = Find(gr->start);
+        GraphVertex prev = Find(gr->prev->start);
         // Block is candidate for short-circuit merging if it and the
         // preceding block both end with conditional jumps.
         if (out_degree(cur, graph_) == 2 && out_degree(prev, graph_) == 2){
@@ -300,12 +300,12 @@ void ControlFlow::DetectShortCircuit(){
                 );
             }
             if (do_merge){
-                gr = gr->_prev;
+                gr = gr->prev;
                 Merge(prev, cur);
                 continue;
             }
         }
-        gr = gr->_prev;
+        gr = gr->prev;
     }
 }
 
@@ -324,7 +324,7 @@ void ControlFlow::DetectWhile(){
     for (VertexIterator v = vertex_range.first; v != vertex_range.second; ++ v){
         GroupPtr gr = GET(*v);
         // Undetermined block that ends with conditional jump.
-        if (out_degree(*v, graph_) == 2 && gr->_type == kNormalGroupType){
+        if (out_degree(*v, graph_) == 2 && gr->type == GROUP_TYPE_NORMAL){
             InEdgeRange ier = boost::in_edges(*v, graph_);
             bool is_while = false;
             for (InEdgeIterator e = ier.first; e != ier.second; ++ e){
@@ -332,13 +332,13 @@ void ControlFlow::DetectWhile(){
                 // Block has ingoing edge from block later in the
                 // code that isn't a do-while condition.
                 if (
-                  (*source_gr->start_)->_address > (*gr->start_)->_address
-                  && source_gr->_type != kDoWhileCondGroupType
+                  (*source_gr->start)->GetAddress() > (*gr->start)->GetAddress()
+                  && source_gr->type != GROUP_TYPE_DO_WHILE
                 ){
                     is_while = true;
                 }
             }
-            if (is_while) gr->_type = kWhileCondGroupType;
+            if (is_while) gr->type = GROUP_TYPE_WHILE;
         }
     }
 }
@@ -348,13 +348,13 @@ void ControlFlow::DetectDoWhile(){
     for (VertexIterator v = vertex_range.first; v != vertex_range.second; ++ v){
         GroupPtr gr = GET(*v);
         // Undetermined block that ends with conditional jump...
-        if (out_degree(*v, graph_) == 2 && gr->_type == kNormalGroupType){
+        if (out_degree(*v, graph_) == 2 && gr->type == GROUP_TYPE_NORMAL){
             OutEdgeRange oer = boost::out_edges(*v, graph_);
             for (OutEdgeIterator e = oer.first; e != oer.second; ++e){
                 GroupPtr target_gr = GET(boost::target(*e, graph_));
                 // ...to earlier in code.
-                if ((*target_gr->start_)->_address < (*gr->start_)->_address)
-                    gr->_type = kDoWhileCondGroupType;
+                if ((*target_gr->start)->GetAddress() < (*gr->start)->GetAddress())
+                    gr->type = GROUP_TYPE_DO_WHILE;
             }
         }
     }
@@ -366,25 +366,25 @@ void ControlFlow::DetectBreak(){
         GroupPtr gr = GET(*v);
         // Undetermined block with unconditional jump...
         if (
-          gr->_type == kNormalGroupType
-          && ((*gr->end_)->IsUncondJump())
+          gr->type == GROUP_TYPE_NORMAL
+          && ((*gr->end)->IsUncondJump())
           && out_degree(*v, graph_) == 1
         ){
             OutEdgeIterator oe = boost::out_edges(*v, graph_).first;
             GraphVertex target = boost::target(*oe, graph_);
             GroupPtr target_gr = GET(target);
             // ...to somewhere later in the code...
-            if ((*gr->start_)->_address >= (*target_gr->start_)->_address) continue;
+            if ((*gr->start)->GetAddress() >= (*target_gr->start)->GetAddress()) continue;
             InEdgeRange ier = boost::in_edges(target, graph_);
             for (InEdgeIterator ie = ier.first; ie != ier.second; ++ ie){
                 GroupPtr source_gr = GET(boost::source(*ie, graph_));
                 // ...to block immediately after a do-while condition,
                 // or to jump target of a while condition.
                 if (
-                  (target_gr->_prev == source_gr && source_gr->_type == kDoWhileCondGroupType)
-                  || source_gr->_type == kWhileCondGroupType
+                  (target_gr->prev == source_gr && source_gr->type == GROUP_TYPE_DO_WHILE)
+                  || source_gr->type == GROUP_TYPE_WHILE
                 ){
-                    if (ValidateBreakOrContinue(gr, source_gr)) gr->_type = kBreakGroupType;
+                    if (ValidateBreakOrContinue(gr, source_gr)) gr->type = GROUP_TYPE_BREAK;
                 }
             }
         }
@@ -397,8 +397,8 @@ void ControlFlow::DetectContinue(){
         GroupPtr gr = GET(*v);
         // Undetermined block with unconditional jump...
         if (
-          gr->_type == kNormalGroupType
-          && ((*gr->end_)->IsUncondJump())
+          gr->type == GROUP_TYPE_NORMAL
+          && ((*gr->end)->IsUncondJump())
           && out_degree(*v, graph_) == 1
         ){
             OutEdgeIterator oe = boost::out_edges(*v, graph_).first;
@@ -406,7 +406,7 @@ void ControlFlow::DetectContinue(){
             GroupPtr target_gr = GET(target);
             // ...to a while or do-while condition...
             if (
-              target_gr->_type == kWhileCondGroupType || target_gr->_type == kDoWhileCondGroupType
+              target_gr->type == GROUP_TYPE_WHILE || target_gr->type == GROUP_TYPE_DO_WHILE
             ){
                 bool is_continue = true;
                 // ...unless...
@@ -415,15 +415,15 @@ void ControlFlow::DetectContinue(){
                 for (OutEdgeIterator toe = toer.first; toe != toer.second; ++ toe){
                     // ...it is targeting a while condition which jumps to the next sequential group
                     if (
-                      target_gr->_type == kWhileCondGroupType
-                      && GET(boost::target(*toe, graph_)) == gr->_next
+                      target_gr->type == GROUP_TYPE_WHILE
+                      && GET(boost::target(*toe, graph_)) == gr->next
                     ){
                         is_continue = false;
                     }
                     // ...or the instruction is placed after all jump targets from condition.
                     if (
-                      (*GET(boost::target(*toe, graph_))->start_)->_address
-                        > (*gr->start_)->_address
+                      (*GET(boost::target(*toe, graph_))->start)->GetAddress()
+                        > (*gr->start)->GetAddress()
                     ){
                         after_jump_jargets = false;
                     }
@@ -431,7 +431,7 @@ void ControlFlow::DetectContinue(){
                 if (after_jump_jargets) is_continue = false;
 
                 if (is_continue && ValidateBreakOrContinue(gr, target_gr))
-                    gr->_type = kContinueGroupType;
+                    gr->type = GROUP_TYPE_CONTINUE;
             }
         }
     }
@@ -441,21 +441,21 @@ bool ControlFlow::ValidateBreakOrContinue(GroupPtr group, GroupPtr condition_gro
     GroupPtr from;
     GroupPtr to;
     GroupPtr cursor;
-    if (condition_group->_type == kDoWhileCondGroupType){
+    if (condition_group->type == GROUP_TYPE_DO_WHILE){
         to = condition_group;
         from = group;
     }
     else{
         to = group;
-        from = condition_group->_next;
+        from = condition_group->next;
     }
-    GroupType ogt = (
-      condition_group->_type == kDoWhileCondGroupType ? kWhileCondGroupType : kDoWhileCondGroupType
+    GROUP_TYPE ogt = (
+      condition_group->type == GROUP_TYPE_DO_WHILE ? GROUP_TYPE_WHILE : GROUP_TYPE_DO_WHILE
     );
     // Verify that destination deals with innermost while/do-while.
-    for (cursor = from; cursor->_next != NULL && cursor != to; cursor = cursor->_next){
-        if (cursor->_type == condition_group->_type){
-            OutEdgeRange oer_validate = boost::out_edges(Find(cursor->start_), graph_);
+    for (cursor = from; cursor->next != NULL && cursor != to; cursor = cursor->next){
+        if (cursor->type == condition_group->type){
+            OutEdgeRange oer_validate = boost::out_edges(Find(cursor->start), graph_);
             for (
               OutEdgeIterator oe_validate = oer_validate.first;
               oe_validate != oer_validate.second;
@@ -466,8 +466,8 @@ bool ControlFlow::ValidateBreakOrContinue(GroupPtr group, GroupPtr condition_gro
                 // For all other loops of same type found in range,
                 // all targets must fall within that range.
                 if (
-                  (*g_validate->start_)->_address < (*from->start_)->_address
-                  || (*g_validate->start_)->_address > (*to->start_)->_address
+                  (*g_validate->start)->GetAddress() < (*from->start)->GetAddress()
+                  || (*g_validate->start)->GetAddress() > (*to->start)->GetAddress()
                 ){
                     return false;
                 }
@@ -480,10 +480,10 @@ bool ControlFlow::ValidateBreakOrContinue(GroupPtr group, GroupPtr condition_gro
                     GroupPtr ig_validate = GET(boost::source(*ie_validate, graph_));
                     // All loops of other type going into range must be placed within range.
                     if (
-                      ig_validate->_type == ogt
+                      ig_validate->type == ogt
                       && (
-                        (*ig_validate->start_)->_address < (*from->start_)->_address
-                        || (*ig_validate->start_)->_address > (*to->start_)->_address
+                        (*ig_validate->start)->GetAddress() < (*from->start)->GetAddress()
+                        || (*ig_validate->start)->GetAddress() > (*to->start)->GetAddress()
                       )
                     ){
                         return false;
@@ -500,8 +500,8 @@ void ControlFlow::DetectIf(){
     for (VertexIterator v = vr.first; v != vr.second; ++v){
         GroupPtr gr = GET(*v);
         // If: Undetermined block with conditional jump.
-        if (gr->_type == kNormalGroupType && ((*gr->end_)->isCondJump()))
-            gr->_type = kIfCondGroupType;
+        if (gr->type == GROUP_TYPE_NORMAL && ((*gr->end)->IsCondJump()))
+            gr->type = GROUP_TYPE_IF;
     }
 }
 
@@ -509,7 +509,7 @@ void ControlFlow::DetectElse(){
     VertexRange vr = boost::vertices(graph_);
     for (VertexIterator v = vr.first; v != vr.second; ++v){
         GroupPtr gr = GET(*v);
-        if (gr->_type == kIfCondGroupType){
+        if (gr->type == GROUP_TYPE_IF){
             OutEdgeRange oer = boost::out_edges(*v, graph_);
             GraphVertex target;
             uint32 max_address = 0;
@@ -517,30 +517,30 @@ void ControlFlow::DetectElse(){
             // Find jump target.
             for (OutEdgeIterator oe = oer.first; oe != oer.second; ++ oe){
                 target_gr = GET(boost::target(*oe, graph_));
-                if ((*target_gr->start_)->_address > max_address){
+                if ((*target_gr->start)->GetAddress() > max_address){
                     target = boost::target(*oe, graph_);
-                    max_address = (*target_gr->start_)->_address;
+                    max_address = (*target_gr->start)->GetAddress();
                 }
             }
             target_gr = GET(target);
             // Else: Jump target of if immediately preceded by an unconditional jump...
-            if (!(*target_gr->_prev->end_)->IsUncondJump()) continue;
+            if (!(*target_gr->prev->end)->IsUncondJump()) continue;
             // ...which is not a break or a continue...
             if (
-              target_gr->_prev->_type == kContinueGroupType
-              || target_gr->_prev->_type == kBreakGroupType
+              target_gr->prev->type == GROUP_TYPE_CONTINUE
+              || target_gr->prev->type == GROUP_TYPE_BREAK
             ){
                 continue;
             }
             // ...to later in the code.
             OutEdgeIterator toe = boost::out_edges(
-              Find((*target_gr->_prev->start_)->_address), graph_
+              Find((*target_gr->prev->start)->GetAddress()), graph_
             ).first;
             GroupPtr target_target_gr = GET(boost::target(*toe, graph_));
-            if ((*target_target_gr->start_)->_address > (*target_gr->end_)->_address){
+            if ((*target_target_gr->start)->GetAddress() > (*target_gr->end)->GetAddress()){
                 if (ValidateElseBlock(gr, target_gr, target_target_gr)){
-                    target_gr->_startElse = true;
-                    target_target_gr->_prev->_endElse.push_back(target_gr.get());
+                    target_gr->start_else = true;
+                    target_target_gr->prev->end_else.push_back(target_gr.get());
                 }
             }
         }
@@ -548,21 +548,21 @@ void ControlFlow::DetectElse(){
 }
 
 bool ControlFlow::ValidateElseBlock(GroupPtr if_group, GroupPtr start, GroupPtr end){
-    for (GroupPtr cursor = start; cursor != end; cursor = cursor->_next){
+    for (GroupPtr cursor = start; cursor != end; cursor = cursor->next){
         if (
-          cursor->_type == kIfCondGroupType
-          || cursor->_type == kWhileCondGroupType
-          || cursor->_type == kDoWhileCondGroupType
+          cursor->type == GROUP_TYPE_IF
+          || cursor->type == GROUP_TYPE_WHILE
+          || cursor->type == GROUP_TYPE_DO_WHILE
         ){
             // Validate outgoing edges of conditions.
-            OutEdgeRange oer = boost::out_edges(Find(cursor->start_), graph_);
+            OutEdgeRange oer = boost::out_edges(Find(cursor->start), graph_);
             for (OutEdgeIterator oe = oer.first; oe != oer.second; ++ oe){
                 GraphVertex target = boost::target(*oe, graph_);
                 GroupPtr target_gr = GET(target);
                 // Each edge from condition must not leave the range [start, end].
                 if (
-                  (*start->start_)->_address > (*target_gr->start_)->_address
-                  || (*target_gr->start_)->_address > (*end->start_)->_address
+                  (*start->start)->GetAddress() > (*target_gr->start)->GetAddress()
+                  || (*target_gr->start)->GetAddress() > (*end->start)->GetAddress()
                 ){
                     return false;
                 }
@@ -570,32 +570,32 @@ bool ControlFlow::ValidateElseBlock(GroupPtr if_group, GroupPtr start, GroupPtr
         }
         // If previous group ends an else, that else must start inside the range.
         for (
-          ElseEndIterator it = cursor->_prev->_endElse.begin();
-          it != cursor->_prev->_endElse.end();
+          ElseEndIterator it = cursor->prev->end_else.begin();
+          it != cursor->prev->end_else.end();
           ++ it
         ){
-            if ((*(*it)->start_)->_address < (*start->start_)->_address) return false;
+            if ((*(*it)->start)->GetAddress() < (*start->start)->GetAddress()) return false;
         }
         // Unless group is a simple unconditional jump...
-        if ((*cursor->start_)->IsUncondJump()) continue;
+        if ((*cursor->start)->IsUncondJump()) continue;
         // ...validate ingoing edges
-        InEdgeRange ier = boost::in_edges(Find(cursor->start_), graph_);
+        InEdgeRange ier = boost::in_edges(Find(cursor->start), graph_);
         for (InEdgeIterator ie = ier.first; ie != ier.second; ++ie){
             GraphVertex source = boost::source(*ie, graph_);
             GroupPtr source_gr = GET(source);
             // Edges going to conditions...
             if (
-              source_gr->_type == kIfCondGroupType
-              || source_gr->_type == kWhileCondGroupType
-              || source_gr->_type == kDoWhileCondGroupType
+              source_gr->type == GROUP_TYPE_IF
+              || source_gr->type == GROUP_TYPE_WHILE
+              || source_gr->type == GROUP_TYPE_DO_WHILE
             ){
                 // ...must not come from outside the range [start, end]...
                 if (
-                  (*start->start_)->_address > (*source_gr->start_)->_address
-                  || (*source_gr->start_)->_address > (*end->start_)->_address
+                  (*start->start)->GetAddress() > (*source_gr->start)->GetAddress()
+                  || (*source_gr->start)->GetAddress() > (*end->start)->GetAddress()
                 ){
                     // ...unless source is simple unconditional jump...
-                    if ((*source_gr->start_)->IsUncondJump()) continue;
+                    if ((*source_gr->start)->IsUncondJump()) continue;
                     // ...or the edge is from the if condition associated with this else.
                     if (if_group == source_gr) continue;
                     return false;

+ 66 - 0
V-Gears-Installer/src/decompiler/Graph.cpp

@@ -0,0 +1,66 @@
+/*
+ * 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/Graph.h"
+#include "decompiler/Engine.h"
+
+IsJump::IsJump(){is_jump = false;};
+
+IsJump::IsJump(bool jump): is_jump(jump){};
+
+CodeLine::CodeLine(const std::string& line, bool unindent_before, bool indent_after):
+  line(line), unindent_before(unindent_before), indent_after(indent_after){}
+
+Group::Group(): stack_level(-1), type(GROUP_TYPE_NORMAL){}
+
+Group::Group(GraphVertex vertex, InstIterator start, InstIterator end, GroupPtr prev){
+    this->vertex = vertex;
+    this->start = start;
+    this->end = end;
+    stack_level = -1;
+    type = GROUP_TYPE_NORMAL;
+    this->prev = prev.get();
+    start_else = false;
+    if (prev != NULL) prev->next = this;
+    next = NULL;
+    coalesced_else = false;
+}
+
+GraphProperties::GraphProperties(Engine *engine, const Graph &graph): engine(engine), graph(&graph)
+{}
+
+GraphProperties::GraphProperties(const GraphProperties& rhs){*this = rhs;}
+
+GraphProperties& GraphProperties::operator = (const GraphProperties& rhs){
+    if (this != &rhs){
+        engine = rhs.engine;
+        graph = rhs.graph;
+    }
+    return *this;
+}
+
+void GraphProperties::operator()(std::ostream& out) const{
+    out << "node [shape=record]" << std::endl;
+    for (
+      FuncMap::iterator fn = engine->functions.begin();
+      fn != engine->functions.end();
+      ++ fn
+    ){
+        int index = (boost::get(boost::vertex_index, *graph, fn->second.vertex));
+        out << "XXX" << index << " [shape=none, label=\"\", height=0]" << std::endl;
+        out << "XXX" << index << " -> " << index << std::endl;
+    }
+}

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

@@ -19,10 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include "objectFactory.h"
-
-#include "instruction.h"
-
 #include <fstream>
 #include <iostream>
 #include <map>
@@ -31,6 +27,8 @@
 #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)
@@ -176,12 +174,12 @@ int main(int argc, char** argv) {
 				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));
+			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));
+				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;
 		}
@@ -199,7 +197,7 @@ int main(int argc, char** argv) {
 			for (VertexIterator v = vr.first; v != vr.second; ++v)
 			{
 				GroupPtr gr = boost::get(boost::vertex_name, g, *v);
-				if (gr->_stackLevel == -1)
+				if (gr->stack_level == -1)
 					unreachable.push_back(gr);
 			}
 			if (!unreachable.empty()) {

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

@@ -116,7 +116,7 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
           instruction != function->second.end();
           ++ instruction
         ){
-            if ((*instruction)->isCondJump() || (*instruction)->IsUncondJump()){
+            if ((*instruction)->IsCondJump() || (*instruction)->IsUncondJump()){
                 auto targetAddr = (*instruction)->GetDestAddress();
                 auto label = labels.find(targetAddr);
                 if (label == labels.end()) labels.insert({targetAddr, InstVec()});
@@ -131,12 +131,12 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
           instruction != function->second.end();
           ++instruction
         ){
-            auto label = labels.find((*instruction)->_address);
+            auto label = labels.find((*instruction)->GetAddress());
             if (label != labels.end()){
                 bool needs_label = false;
                 bool needs_new_line = false;
                 for (auto origin = label->second.begin(); origin != label->second.end(); ++ origin){
-                    if ((*origin)->isCondJump()){
+                    if ((*origin)->IsCondJump()){
                         AddOutputLine("end", true, false);
                         needs_new_line = true;
                     }
@@ -152,13 +152,13 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
                 AddOutputLine("end -- end if", true, false);
                 end_needed = false;
             }
-            if ((*instruction)->isCondJump()){
+            if ((*instruction)->IsCondJump()){
                 AddOutputLine(
                   (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.
-                if ((*(instruction + 1))->_address == (*(function->second.back()))._address)
+                if ((*(instruction + 1))->GetAddress() == (*(function->second.back())).GetAddress())
                     end_needed = true;
             }
             else if ((*instruction)->IsUncondJump()){
@@ -175,7 +175,7 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
                 // Prevent backward jumps in the on_start script.
                 else if (
                   "on_start" == function->first.name
-                  && (*instruction)->GetDestAddress() <= (*instruction)->_address
+                  && (*instruction)->GetDestAddress() <= (*instruction)->GetAddress()
                 ){
                     AddOutputLine("-- No infinite loops in the on_start script.");
                     AddOutputLine((
@@ -192,8 +192,8 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
         }
         // Add missing return:
         if (
-          "return 0" != lines_.at(lines_.size() - 1)._line
-          && "do return 0 end" != lines_.at(lines_.size() - 1)._line
+          "return 0" != lines_.at(lines_.size() - 1).line
+          && "do return 0 end" != lines_.at(lines_.size() - 1).line
         ){
             AddOutputLine("do return 0 end", false, false);
         }
@@ -201,11 +201,11 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
     }
 
     for (auto i = lines_.begin(); i != lines_.end(); ++i){
-        if (i->_unindentBefore && indent_level_ > 0){
+        if (i->unindent_before && indent_level_ > 0){
             indent_level_ --;
         }
-        output_ << IndentString(i->_line) << std::endl;
-        if (i->_indentAfter) indent_level_++;
+        output_ << IndentString(i->line) << std::endl;
+        if (i->indent_after) indent_level_++;
     }
 }
 
@@ -230,7 +230,7 @@ void FF7::FieldCodeGenerator::OnBeforeStartFunction(const Function& function){
 void FF7::FieldCodeGenerator::OnStartFunction(const Function& func){
     AddOutputLine("--[[");
     for (const auto& inst : insts_){
-        if (inst->_address >= func.start_addr && inst->_address <= func.end_addr){
+        if (inst->GetAddress() >= func.start_addr && inst->GetAddress() <= func.end_addr){
             std::stringstream output;
             output << inst;
             AddOutputLine(output.str());
@@ -278,15 +278,17 @@ const std::string FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
   const std::string& entity, uint32 address, const Instruction& instruction
 ){
     std::stringstream parameterList;
-    for (auto i = instruction._params.begin(); i != instruction._params.end(); ++ i){
-        if (i != instruction._params.begin()) parameterList << ", ";
+    //for (auto i = instruction._params.begin(); i != instruction._params.end(); ++ i){
+    for (auto i = instruction.GetParams().begin(); i != instruction.GetParams().end(); ++ i){
+        //if (i != instruction._params.begin()) parameterList << ", ";
+        if (i != instruction.GetParams().begin()) parameterList << ", ";
         parameterList << *i;
     }
     return(
       boost::format(
         "-- log:log(\"In entity \\\"%1%\\\", address 0x%2$08x: "
         "instruction %3%(%4%) not implemented\")"
-        ) % entity % address % instruction._name % parameterList.str()
+        ) % entity % address % instruction.GetName() % parameterList.str()
       ).str();
 }
 

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

@@ -161,9 +161,9 @@ void FF7::FieldDisassembler::DoDisassemble(){
 
 int FF7::FieldDisassembler::FindId(uint32 start_addr, uint32 end_addr, const InstVec& insts){
     for (const InstPtr& instruction : insts){
-        if (instruction->_address >= start_addr && instruction->_address <= end_addr){
-            if (instruction->_opcode == FF7::OPCODES::opCodeCHAR)
-                return instruction->_params[0]->getSigned();
+        if (instruction->GetAddress() >= start_addr && instruction->GetAddress() <= end_addr){
+            if (instruction->GetOpcode() == FF7::OPCODES::opCodeCHAR)
+                return instruction->GetParam(0)->getSigned();
         }
     }
     return -1;
@@ -209,7 +209,7 @@ void FF7::FieldDisassembler::AddFunc(
 
     const size_t new_num_instructions = insts_.size();
     func->num_instructions = new_num_instructions - old_num_instructions;
-    func->end_addr = insts_.back()->_address;
+    func->end_addr = insts_.back()->GetAddress();
     if (!func_name.empty()) func->name = func_name;
     if (engine_->EntityIsLine(entity_index)){
         switch (script_index){
@@ -1047,12 +1047,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()->_params[0]->getSigned();
-                point_a[1] = this->insts_.back()->_params[1]->getSigned();
-                point_a[2] = this->insts_.back()->_params[2]->getSigned();
-                point_b[0] = this->insts_.back()->_params[3]->getSigned();
-                point_b[1] = this->insts_.back()->_params[4]->getSigned();
-                point_b[2] = this->insts_.back()->_params[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
@@ -1234,9 +1234,9 @@ bool FF7::FieldDisassembler::ReadOpCodesToPositionOrReturn(
 
         // Is it within an "if" statement tracking?
         InstPtr i = this->insts_.back();
-        if (i->isCondJump()) exitAddrs.push_back(i->GetDestAddress());
+        if (i->IsCondJump()) exitAddrs.push_back(i->GetDestAddress());
         if (!exitAddrs.empty())
-            if (i->_address == exitAddrs.back()) exitAddrs.pop_back();
+            if (i->GetAddress() == exitAddrs.back()) exitAddrs.pop_back();
         // Only bail if its the first RET that isn't within an "if" block.
         if (full_opcode == OPCODES::RET && exitAddrs.empty()) return is_line;
     }

+ 14 - 14
V-Gears-Installer/src/decompiler/field/FieldEngine.cpp

@@ -103,7 +103,7 @@ std::vector<float> FF7::FieldEngine::Entity::GetLinePointB(){return point_b_;}
 
 FF7::FieldEngine::FieldEngine(SUDM::IScriptFormatter& formatter, std::string script_name) :
   formatter_(formatter), script_name_(script_name), scale_factor_(1.0f)
-{setOutputStackEffect(false);}
+{SetOutputStackEffect(false);}
 
 std::unique_ptr<Disassembler> FF7::FieldEngine::GetDisassembler(
   InstVec &insts, const std::vector<unsigned char>& raw_script_data
@@ -243,14 +243,14 @@ void FF7::FieldEngine::RemoveExtraneousReturnStatements(InstVec& insts, Graph gr
         Function& func = f.second;
         for (auto it = insts.begin(); it != insts.end(); it ++){
             // Is it the last instruction in the function, and is it a return statement?
-            if ((*it)->_address == func.end_addr){
-                if ((*it)->_opcode == OPCODES::RET){
+            if ((*it)->GetAddress() == func.end_addr){
+                if ((*it)->GetOpcode() == OPCODES::RET){
                     // Set new end address to be before the NOP.
-                    func.end_addr =(*(it - 1))->_address;
+                    func.end_addr = (*(it - 1))->GetAddress();
                     func.num_instructions --;
                     Instruction* nop = new FieldNoOperationInstruction();
-                    nop->_opcode = OPCODES::NOP;
-                    nop->_address = (*it)->_address;
+                    nop->SetOpcode(OPCODES::NOP);
+                    nop->SetAddress((*it)->GetAddress());
                     (*it).reset(nop);
                     break;
                 }
@@ -264,14 +264,14 @@ void FF7::FieldEngine::RemoveTrailingInfiniteLoops(InstVec& insts, Graph graph){
         Function& func = f.second;
         for (auto it = insts.begin(); it != insts.end(); it ++){
             // Is it the last instruction in the function, a jump, and a jumping to itself?
-            if ((*it)->_address == func.end_addr){
-                if ((*it)->isJump() && (*it)->GetDestAddress() == (*it)->_address){
+            if ((*it)->GetAddress() == func.end_addr){
+                if ((*it)->IsJump() && (*it)->GetDestAddress() == (*it)->GetAddress()){
                     // Set new end address to be before the NOP
-                    func.end_addr =(*(it - 1))->_address;
+                    func.end_addr = (*(it - 1))->GetAddress();
                     func.num_instructions --;
                     Instruction* nop = new FieldNoOperationInstruction();
-                    nop->_opcode = OPCODES::NOP;
-                    nop->_address = (*it)->_address;
+                    nop->SetOpcode(OPCODES::NOP);
+                    nop->SetAddress((*it)->GetAddress());
                     (*it).reset(nop);
                     break;
                 }
@@ -284,7 +284,7 @@ void FF7::FieldEngine::MarkInfiniteLoopGroups(InstVec& insts, Graph graph){
     for (auto& f : functions){
         Function& func = f.second;
         for (auto it = insts.begin(); it != insts.end(); it ++){
-            if ((*it)->_address == func.end_addr){
+            if ((*it)->GetAddress() == func.end_addr){
                 // Note: This is a "best effort heuristic", so quite a few loops will
                 // still end up as goto's. This could potentially generate invalid code too.
                 if ((*it)->IsUncondJump()){
@@ -293,10 +293,10 @@ void FF7::FieldEngine::MarkInfiniteLoopGroups(InstVec& insts, Graph graph){
                     VertexRange vr = boost::vertices(graph);
                     for (VertexIterator v = vr.first; v != vr.second; ++ v){
                         GroupPtr gr = GET(*v);
-                        if ((*gr->start_)->_address == func.end_addr){
+                        if ((*gr->start)->GetAddress() == func.end_addr){
                             // Then assume its an infinite do { } while(true) loop
                             // that wraps part of the script.
-                            gr->_type = kDoWhileCondGroupType;
+                            gr->type = GROUP_TYPE_DO_WHILE;
                         }
                     }
                 }

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

@@ -28,7 +28,7 @@ void FF7::FieldBackgroundInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::BGPDH: code_gen->WriteTodo(md.GetEntityName(), "BGPDH");break;
         case OPCODES::BGSCR: code_gen->WriteTodo(md.GetEntityName(), "BGSCR"); break;
         case OPCODES::MPPAL: code_gen->WriteTodo(md.GetEntityName(), "MPPAL"); break;
@@ -50,7 +50,7 @@ void FF7::FieldBackgroundInstruction::ProcessInst(
         case OPCODES::RTPAL2: code_gen->WriteTodo(md.GetEntityName(), "RTPAL2"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
@@ -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

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

@@ -28,7 +28,7 @@ void FF7::FieldCameraInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
     case OPCODES::NFADE: ProcessNFADE(code_gen); break;
     case OPCODES::SHAKE: code_gen->WriteTodo(md.GetEntityName(), "SHAKE"); break;
     case OPCODES::SCRLO: code_gen->WriteTodo(md.GetEntityName(), "SCRLO"); break;
@@ -46,14 +46,14 @@ void FF7::FieldCameraInstruction::ProcessInst(
     case OPCODES::SCRLA: code_gen->WriteTodo(md.GetEntityName(), "SCRLA"); break;
     default:
         code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-          md.GetEntityName(), _address, _opcode
+          md.GetEntityName(), address_, opcode_
         ));
     }
 }
 
 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());

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

@@ -29,22 +29,22 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
 ){
     FF7::FieldCodeGenerator* cg = static_cast<FF7::FieldCodeGenerator*>(code_gen);
     std::string func_name;
-    if (_opcode == OPCODES::IFKEYON) func_name = "entity_manager:is_key_on";
-    else if (_opcode == OPCODES::IFKEYOFF) func_name = "entity_manager:is_key_off";
-    else if (_opcode == OPCODES::IFKEY) func_name = "Key";
-    else if (_opcode == OPCODES::IFMEMBQ) func_name = "IFMEMBQ";
-    else if (_opcode == OPCODES::IFPRTYQ) func_name = "IFPRTYQ";
+    if (opcode_ == OPCODES::IFKEYON) func_name = "entity_manager:is_key_on";
+    else if (opcode_ == OPCODES::IFKEYOFF) func_name = "entity_manager:is_key_off";
+    else if (opcode_ == OPCODES::IFKEY) func_name = "Key";
+    else if (opcode_ == OPCODES::IFMEMBQ) func_name = "IFMEMBQ";
+    else if (opcode_ == OPCODES::IFPRTYQ) func_name = "IFPRTYQ";
 
     // 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.
         if (
-          _opcode == OPCODES::IFKEY
-          || _opcode == OPCODES::IFKEYON
-          || _opcode == OPCODES::IFKEYOFF
+          opcode_ == OPCODES::IFKEY
+          || opcode_ == OPCODES::IFKEYON
+          || opcode_ == OPCODES::IFKEYOFF
         ){
             if (param >= 1024) param = param ^ 1024;
             if (param >= 512) param = param ^ 512;
@@ -54,12 +54,12 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
         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,7 +74,7 @@ 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);
                 stack.push(v);
@@ -82,13 +82,13 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
             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);
                 stack.push(v);
             }
             return;
-        default: throw UnknownConditionalOperatorException(_address, type);
+        default: throw UnknownConditionalOperatorException(address_, type);
     }
     ValuePtr v = new BinaryOpValue(new VarValue(source), new VarValue(destination), op);
     stack.push(v);
@@ -97,7 +97,7 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
 uint32 FF7::FieldCondJumpInstruction::GetDestAddress() const{
     uint32 params_size = 0;
     uint32 jump_param_index = 5;
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::IFUB: params_size = 5; break;
         case OPCODES::IFUBL: params_size = 5; break;
         case OPCODES::IFSW: params_size = 7; break;
@@ -115,9 +115,9 @@ uint32 FF7::FieldCondJumpInstruction::GetDestAddress() const{
             params_size = 2;
             jump_param_index = 1;
             break;
-        default: throw UnknownJumpTypeException(_address, _opcode);
+        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{

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

@@ -29,7 +29,7 @@ void FF7::FF7ControlFlowInstruction::ProcessInst(
 ){
     FF7::FieldEngine& eng = static_cast<FF7::FieldEngine&>(*engine);
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::RET:
             // A few notes in RET.
             // - Lua requires all functions to end with a return.
@@ -51,7 +51,7 @@ void FF7::FF7ControlFlowInstruction::ProcessInst(
         case OPCODES::WAIT: ProcessWAIT(code_gen); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
@@ -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 InternalDecompilerError&){
         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());
 }

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

@@ -29,7 +29,7 @@ void FF7::FieldMathInstruction::ProcessInst(
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::PLUS_: ProcessSaturatedPLUS(code_gen); break;
         case OPCODES::PLUS2_: ProcessSaturatedPLUS2(code_gen); break;
         case OPCODES::MINUS_: ProcessSaturatedMINUS(code_gen); break;
@@ -60,15 +60,15 @@ 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 source_address_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, source_address_or_value
+                  cg->GetFormatter(), source_bank, sourceaddress__or_value
                 );
-                const uint32 dest_bank = _params[1]->getUnsigned();
-                const uint32 dest_address = _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, dest_address
+                  cg->GetFormatter(), dest_bank, destaddress_
                 );
                 code_gen->AddOutputLine(
                   source + " = " + source + " % " + dest + code_gen->GetLanguage().LineTerminator()
@@ -98,7 +98,7 @@ void FF7::FieldMathInstruction::ProcessInst(
         case OPCODES::COS: code_gen->WriteTodo(md.GetEntityName(), "COS"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
@@ -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?

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

@@ -28,7 +28,7 @@ void FF7::FieldMediaInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::BGMOVIE: code_gen->WriteTodo(md.GetEntityName(), "BGMOVIE"); break;
         case OPCODES::AKAO2: ProcessAKAO2(code_gen); break;
         case OPCODES::MUSIC: ProcessMUSIC(code_gen); break;
@@ -47,7 +47,7 @@ void FF7::FieldMediaInstruction::ProcessInst(
         case OPCODES::CHMST: code_gen->WriteTodo(md.GetEntityName(), "CHMST"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
@@ -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()
     );

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

@@ -29,7 +29,7 @@ void FF7::FieldModelInstruction::ProcessInst(
 ){
     FF7::FieldEngine& eng = static_cast<FF7::FieldEngine&>(*engine);
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::JOIN: ProcessJOIN(code_gen); break;
         case OPCODES::SPLIT: ProcessSPLIT(code_gen); break;
         case OPCODES::BLINK: code_gen->WriteTodo(md.GetEntityName(), "BLINK"); break;
@@ -142,43 +142,43 @@ void FF7::FieldModelInstruction::ProcessInst(
         case OPCODES::TURNW: code_gen->WriteTodo(md.GetEntityName(), "TURNW"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
 
 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());
 }

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

@@ -28,12 +28,12 @@ void FF7::FieldModuleInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::DSKCG: code_gen->WriteTodo(md.GetEntityName(), "DSKCG"); break;
         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.
@@ -96,7 +96,7 @@ void FF7::FieldModuleInstruction::ProcessInst(
         case OPCODES::GAMEOVER: code_gen->WriteTodo(md.GetEntityName(), "GAMEOVER"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
@@ -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
+      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
+      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
     );
     const std::string target_map_name = cg->GetFormatter().MapName(target_map_id);
     code_gen->AddOutputLine(

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

@@ -28,7 +28,7 @@ void FF7::FieldPartyInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::SPTYE: code_gen->WriteTodo(md.GetEntityName(), "SPTYE"); break;
         case OPCODES::GTPYE: code_gen->WriteTodo(md.GetEntityName(), "GTPYE"); break;
         case OPCODES::GOLDU: code_gen->WriteTodo(md.GetEntityName(), "GOLDU"); break;
@@ -57,7 +57,7 @@ void FF7::FieldPartyInstruction::ProcessInst(
         case OPCODES::CHGLD: code_gen->WriteTodo(md.GetEntityName(), "CHGLD"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
@@ -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/FieldUncategorizedInstruction.cpp

@@ -28,14 +28,14 @@ void FF7::FieldUncategorizedInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::MPDSP: code_gen->WriteTodo(md.GetEntityName(), "MPDSP"); break;
         case OPCODES::SETX: code_gen->WriteTodo(md.GetEntityName(), "SETX"); break;
         case OPCODES::GETX: code_gen->WriteTodo(md.GetEntityName(), "GETX"); break;
         case OPCODES::SEARCHX: code_gen->WriteTodo(md.GetEntityName(), "SEARCHX"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode)
+              md.GetEntityName(), address_, opcode_)
             );
     }
 }

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

@@ -32,13 +32,13 @@ bool FF7::FieldUncondJumpInstruction::IsUncondJump() const{return !is_func_call_
 
 uint32 FF7::FieldUncondJumpInstruction::GetDestAddress() const{
     if (
-      static_cast<OPCODES>(_opcode) == OPCODES::JMPF
-      || static_cast<OPCODES>(_opcode) == OPCODES::JMPFL){
+      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{
@@ -51,7 +51,7 @@ std::ostream& FF7::FieldUncondJumpInstruction::Print(std::ostream &output) const
 void FF7::FieldUncondJumpInstruction::ProcessInst(
   Function& func, ValueStack& stack, Engine* engine, CodeGenerator* code_gen
 ){
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::JMPB:
         case OPCODES::JMPBL:
             // HACK: Hard loop will hang the game, insert a wait to yield control.

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

@@ -28,22 +28,22 @@ void FF7::FieldWalkmeshInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::SLIP: code_gen->WriteTodo(md.GetEntityName(), "SLIP"); break;
         case OPCODES::UC: ProcessUC(code_gen); break;
         case OPCODES::IDLCK:
             // 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;
         case OPCODES::SLINE: code_gen->WriteTodo(md.GetEntityName(), "SLINE"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
@@ -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;

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

@@ -29,7 +29,7 @@ void FF7::FieldWindowInstruction::ProcessInst(
 ){
     FF7::FieldEngine& eng = static_cast<FF7::FieldEngine&>(*engine);
     FunctionMetaData md(func.metadata);
-    switch (_opcode){
+    switch (opcode_){
         case OPCODES::TUTOR: code_gen->WriteTodo(md.GetEntityName(), "TUTOR"); break;
         case OPCODES::WCLS: code_gen->WriteTodo(md.GetEntityName(), "WCLS"); break;
         case OPCODES::WSIZW: code_gen->WriteTodo(md.GetEntityName(), "WSIZW"); break;
@@ -53,18 +53,18 @@ void FF7::FieldWindowInstruction::ProcessInst(
         case OPCODES::SWCOL: code_gen->WriteTodo(md.GetEntityName(), "SWCOL"); break;
         default:
             code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
-              md.GetEntityName(), _address, _opcode
+              md.GetEntityName(), address_, opcode_
             ));
     }
 }
 
 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());
 }

+ 0 - 33
V-Gears-Installer/src/decompiler/graph.cpp

@@ -1,33 +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/graph.h"
-
-#include "../../include/decompiler/Engine.h"
-
-void GraphProperties::operator()(std::ostream& out) const {
-	out << "node [shape=record]" << std::endl;
-	for (FuncMap::iterator fn = _engine->functions.begin(); fn != _engine->functions.end(); ++fn) {
-		int index = (boost::get(boost::vertex_index, *_g, fn->second.vertex));
-		out << "XXX" << index << " [shape=none, label=\"\", height=0]" << std::endl;
-		out << "XXX" << index << " -> " << index << std::endl;
-	}
-}

+ 0 - 167
V-Gears-Installer/src/decompiler/instruction.cpp

@@ -1,167 +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/instruction.h"
-
-#include "../../include/decompiler/CodeGenerator.h"
-#include "../../include/decompiler/Engine.h"
-
-bool outputStackEffect = true;
-
-void setOutputStackEffect(bool value) {
-	outputStackEffect = value;
-}
-
-bool Instruction::isJump() const {
-	return isCondJump() || IsUncondJump();
-}
-
-bool Instruction::isCondJump() const {
-	return false;
-}
-
-bool Instruction::IsUncondJump() const {
-	return false;
-}
-
-bool Instruction::isStackOp() const {
-	return false;
-}
-
-bool Instruction::IsFuncCall() const {
-	return false;
-}
-
-bool Instruction::isReturn() const {
-	return false;
-}
-
-bool Instruction::isKernelCall() const {
-	return false;
-}
-
-bool Instruction::isLoad() const {
-	return false;
-}
-
-bool Instruction::isStore() const {
-	return false;
-}
-
-uint32 Instruction::GetDestAddress() const {
-	throw WrongTypeException();
-}
-
-std::ostream &Instruction::Print(std::ostream &output) const {
-	output << boost::format("%08x: %s") % _address % _name;
-	std::vector<ValuePtr>::const_iterator param;
-	for (param = _params.begin(); param != _params.end(); ++param) {
-		if (param != _params.begin())
-			output << ",";
-		output << " " << *param;
-	}
-	if (outputStackEffect)
-		output << boost::format(" (%d)") % _stackChange;
-	return output;
-}
-
-bool CondJumpInstruction::isCondJump() const {
-	return true;
-}
-
-bool UncondJumpInstruction::IsUncondJump() const {
-	return true;
-}
-
-void UncondJumpInstruction::ProcessInst(Function&, ValueStack&, Engine*, CodeGenerator*) {
-}
-
-bool StackInstruction::isStackOp() const {
-	return true;
-}
-
-bool CallInstruction::IsFuncCall() const {
-	return true;
-}
-
-bool LoadInstruction::isLoad() const {
-	return true;
-}
-
-bool StoreInstruction::isStore() const {
-	return true;
-}
-
-void DupStackInstruction::ProcessInst(Function&, ValueStack &stack, Engine*, CodeGenerator *codeGen) {
-	std::stringstream s;
-	ValuePtr p = stack.pop()->dup(s);
-	if (s.str().length() > 0)
-		codeGen->AddOutputLine(s.str());
-	stack.push(p);
-	stack.push(p);
-}
-
-void BoolNegateStackInstruction::ProcessInst(Function&, ValueStack &stack, Engine*, CodeGenerator*) {
-	stack.push(stack.pop()->negate());
-}
-
-void BinaryOpStackInstruction::ProcessInst(Function&, ValueStack &stack, Engine*, CodeGenerator *codeGen) {
-	ValuePtr op1 = stack.pop();
-	ValuePtr op2 = stack.pop();
-	if (codeGen->GetBinaryOrder() == FIFO_ARGUMENT_ORDER)
-		stack.push(new BinaryOpValue(op2, op1, _codeGenData));
-	else if (codeGen->GetBinaryOrder() == LIFO_ARGUMENT_ORDER)
-		stack.push(new BinaryOpValue(op1, op2, _codeGenData));
-}
-
-bool ReturnInstruction::isReturn() const {
-	return true;
-}
-
-void ReturnInstruction::ProcessInst(Function&, ValueStack&, Engine*, CodeGenerator *codeGen) {
-	codeGen->AddOutputLine("return;");
-}
-
-void UnaryOpPrefixStackInstruction::ProcessInst(Function&, ValueStack &stack, Engine*, CodeGenerator*) {
-	stack.push(new UnaryOpValue(stack.pop(), _codeGenData, false));
-}
-
-void UnaryOpPostfixStackInstruction::ProcessInst(Function& , ValueStack &stack, Engine*, CodeGenerator*) {
-	stack.push(new UnaryOpValue(stack.pop(), _codeGenData, true));
-}
-
-void KernelCallStackInstruction::ProcessInst(Function&, ValueStack &stack, Engine*, CodeGenerator *codeGen) {
-	codeGen->GetArgList().clear();
-	bool returnsValue = (_codeGenData.find("r") == 0);
-	std::string metadata = (!returnsValue ? _codeGenData : _codeGenData.substr(1));
-	for (size_t i = 0; i < metadata.length(); i++)
-		codeGen->ProcessSpecialMetadata(this, metadata[i], i);
-	stack.push(new CallValue(_name, codeGen->GetArgList()));
-	if (!returnsValue) {
-		std::stringstream stream;
-		stream << stack.pop() << ";";
-		codeGen->AddOutputLine(stream.str());
-	}
-}
-
-bool KernelCallInstruction::isKernelCall() const {
-	return true;
-}

+ 28 - 0
V-Gears-Installer/src/decompiler/instruction/BinaryOpStackInstruction.cpp

@@ -0,0 +1,28 @@
+/*
+ * 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/instruction/BinaryOpStackInstruction.h"
+#include "decompiler/CodeGenerator.h"
+
+void BinaryOpStackInstruction::ProcessInst(
+  Function& function, ValueStack &stack, Engine* engine, CodeGenerator *code_gen
+){
+    ValuePtr op1 = stack.pop();
+    ValuePtr op2 = stack.pop();
+    if (code_gen->GetBinaryOrder() == FIFO_ARGUMENT_ORDER)
+        stack.push(new BinaryOpValue(op2, op1, code_gen_data_));
+    else if (code_gen->GetBinaryOrder() == LIFO_ARGUMENT_ORDER)
+        stack.push(new BinaryOpValue(op1, op2, code_gen_data_));
+}

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

@@ -0,0 +1,20 @@
+/*
+ * 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/instruction/BoolNegateStackInstruction.h"
+
+void BoolNegateStackInstruction::ProcessInst(
+  Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
+){stack.push(stack.pop()->negate());}

+ 18 - 0
V-Gears-Installer/src/decompiler/instruction/CallInstruction.cpp

@@ -0,0 +1,18 @@
+/*
+ * 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/instruction/CallInstruction.h"
+
+bool CallInstruction::IsFuncCall() const{return true;}

+ 18 - 0
V-Gears-Installer/src/decompiler/instruction/CondJumpInstruction.cpp

@@ -0,0 +1,18 @@
+/*
+ * 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/instruction/CondJumpInstruction.h"
+
+bool CondJumpInstruction::IsCondJump() const{return true;}

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

@@ -0,0 +1,27 @@
+/*
+ * 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/instruction/DupStackInstruction.h"
+#include "decompiler/CodeGenerator.h"
+
+void DupStackInstruction::ProcessInst(
+  Function& function, ValueStack &stack, Engine* engine, CodeGenerator *code_gen
+){
+    std::stringstream s;
+    ValuePtr p = stack.pop()->dup(s);
+    if (s.str().length() > 0) code_gen->AddOutputLine(s.str());
+    stack.push(p);
+    stack.push(p);
+}

+ 145 - 0
V-Gears-Installer/src/decompiler/instruction/Instruction.cpp

@@ -0,0 +1,145 @@
+/*
+ * 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/instruction/Instruction.h"
+#include "decompiler/CodeGenerator.h"
+#include "decompiler/Engine.h"
+
+bool output_stack_effect = true;
+
+void SetOutputStackEffect(bool value){output_stack_effect = value;}
+
+int Instruction::INST_TYPE_BINARY_OP(0);
+
+int Instruction::INST_TYPE_BOOL_NEGATE(1);
+
+int Instruction::INST_TYPE_CALL(2);
+
+int Instruction::INST_TYPE_COND_JUMP(3);
+
+int Instruction::INST_TYPE_DUP(4);
+
+int Instruction::INST_TYPE_JUMP(5);
+
+int Instruction::INST_TYPE_KERNEL_CALL(6);
+
+int Instruction::INST_TYPE_LOAD(7);
+
+int Instruction::INST_TYPE_RETURN(8);
+
+int Instruction::INST_TYPE_STACK(9);
+
+int Instruction::INST_TYPE_STORE(10);
+
+int Instruction::INST_TYPE_UNARY_OP_PRE(11);
+
+int Instruction::INST_TYPE_UNARY_OP_POST(12);
+
+std::ostream &Instruction::Print(std::ostream &output) const {
+    output << boost::format("%08x: %s") % address_ % name_;
+    std::vector<ValuePtr>::const_iterator param;
+    for (param = params_.begin(); param != params_.end(); ++param) {
+        if (param != params_.begin()) output << ",";
+        output << " " << *param;
+    }
+    if (output_stack_effect) output << boost::format(" (%d)") % stack_change_;
+    return output;
+}
+
+bool Instruction::IsJump() const{return IsCondJump() || IsUncondJump();}
+
+bool Instruction::IsCondJump() const{return false;}
+
+bool Instruction::IsUncondJump() const{return false;}
+
+bool Instruction::IsStackOp() const{return false;}
+
+bool Instruction::IsFuncCall() const{return false;}
+
+bool Instruction::IsReturn() const{return false;}
+
+bool Instruction::IsKernelCall() const{return false;}
+
+bool Instruction::IsLoad() const{return false;}
+
+bool Instruction::IsStore() const{return false;}
+
+uint32 Instruction::GetDestAddress() const{throw WrongTypeException();}
+
+uint32 Instruction::GetOpcode() const{return opcode_;}
+
+void Instruction::SetOpcode(uint32 opcode){opcode_ = opcode;}
+
+uint32 Instruction::GetAddress() const{return address_;}
+
+void Instruction::SetAddress(uint32 address){address_ = address;}
+
+std::string Instruction::GetName() const{return name_;}
+
+void Instruction::SetName(std::string name){name_ = name;}
+
+int16 Instruction::GetStackChange() const{return stack_change_;}
+
+void Instruction::SetStackChange(int16 stack_change){stack_change_ = stack_change;}
+
+std::vector<ValuePtr> Instruction::GetParams() const{return params_;}
+
+ValuePtr Instruction::GetParam(uint32 index) const{
+    if (params_.size() > index) return params_[index];
+    else return nullptr;
+}
+
+void Instruction::SetParams(std::vector<ValuePtr> params){params_ = params;}
+
+void Instruction::AddParam(ValuePtr value){params_.push_back(value);}
+
+std::string Instruction::GetCodeGenData() const{return code_gen_data_;}
+
+void Instruction::SetCodeGenData(std::string code_gen_data){code_gen_data_ = code_gen_data;}
+
+bool Instruction::LabelRequired() const{return label_required_;}
+
+void Instruction::SetLabelRequired(bool required){label_required_ = required;}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 18 - 0
V-Gears-Installer/src/decompiler/instruction/KernelCallInstruction.cpp

@@ -0,0 +1,18 @@
+/*
+ * 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/instruction/KernelCallInstruction.h"
+
+bool KernelCallInstruction::IsKernelCall() const{return true;}

+ 33 - 0
V-Gears-Installer/src/decompiler/instruction/KernelCallStackInstruction.cpp

@@ -0,0 +1,33 @@
+/*
+ * 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/instruction/KernelCallStackInstruction.h"
+#include "decompiler/CodeGenerator.h"
+
+void KernelCallStackInstruction::ProcessInst(
+  Function& function, ValueStack &stack, Engine* engine, CodeGenerator *code_gen
+){
+    code_gen->GetArgList().clear();
+    bool returns_value = (code_gen_data_.find("r") == 0);
+    std::string metadata = (!returns_value ? code_gen_data_ : code_gen_data_.substr(1));
+    for (size_t i = 0; i < metadata.length(); i ++)
+        code_gen->ProcessSpecialMetadata(this, metadata[i], i);
+    stack.push(new CallValue(name_, code_gen->GetArgList()));
+    if (!returns_value){
+        std::stringstream stream;
+        stream << stack.pop() << ";";
+        code_gen->AddOutputLine(stream.str());
+    }
+}

+ 18 - 0
V-Gears-Installer/src/decompiler/instruction/LoadInstruction.cpp

@@ -0,0 +1,18 @@
+/*
+ * 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/instruction/LoadInstruction.h"
+
+bool LoadInstruction::IsLoad() const{return true;}

+ 23 - 0
V-Gears-Installer/src/decompiler/instruction/ReturnInstruction.cpp

@@ -0,0 +1,23 @@
+/*
+ * 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/instruction/ReturnInstruction.h"
+#include "decompiler/CodeGenerator.h"
+
+bool ReturnInstruction::IsReturn() const{return true;}
+
+void ReturnInstruction::ProcessInst(
+  Function& function, ValueStack& stack, Engine* engine, CodeGenerator *code_gen
+){code_gen->AddOutputLine("return;");}

+ 18 - 0
V-Gears-Installer/src/decompiler/instruction/StackInstruction.cpp

@@ -0,0 +1,18 @@
+/*
+ * 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/instruction/StackInstruction.h"
+
+bool StackInstruction::IsStackOp() const{return true;}

+ 18 - 0
V-Gears-Installer/src/decompiler/instruction/StoreInstruction.cpp

@@ -0,0 +1,18 @@
+/*
+ * 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/instruction/StoreInstruction.h"
+
+bool StoreInstruction::IsStore() const{return true;}

+ 20 - 0
V-Gears-Installer/src/decompiler/instruction/UnaryOpPostfixStackInstruction.cpp

@@ -0,0 +1,20 @@
+/*
+ * 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/instruction/UnaryOpPostfixStackInstruction.h"
+
+void UnaryOpPostfixStackInstruction::ProcessInst(
+  Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
+){stack.push(new UnaryOpValue(stack.pop(), code_gen_data_, true));}

+ 20 - 0
V-Gears-Installer/src/decompiler/instruction/UnaryOpPrefixStackInstruction.cpp

@@ -0,0 +1,20 @@
+/*
+ * 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/instruction/UnaryOpPrefixStackInstruction.h"
+
+void UnaryOpPrefixStackInstruction::ProcessInst(
+  Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
+){stack.push(new UnaryOpValue(stack.pop(), code_gen_data_, false));}

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff