Переглянути джерело

FF7 (and similar) namespaces removed.

Iñigo Valentin 3 роки тому
батько
коміт
ff0bda93fe
100 змінених файлів з 4735 додано та 5029 видалено
  1. 1 1
      COPYING.txt
  2. 2 2
      Tests/FinalFantasy7/src/test_FF7FLevelFileSerializer.cpp
  3. 12 12
      Tests/FinalFantasy7/src/test_FF7ModelListFileSerializer.cpp
  4. 1 1
      Tests/FinalFantasy7/src/test_FF7WalkmeshFileSerializer.cpp
  5. 1 1
      V-Gears-Installer/include/common/scummsys.h
  6. 1 1
      V-Gears-Installer/include/decompiler/Decompiler.h
  7. 392 393
      V-Gears-Installer/include/decompiler/field/FieldCodeGenerator.h
  8. 1 1
      V-Gears-Installer/include/decompiler/field/FieldDecompiler.h
  9. 666 676
      V-Gears-Installer/include/decompiler/field/FieldDisassembler.h
  10. 366 379
      V-Gears-Installer/include/decompiler/field/FieldEngine.h
  11. 33 37
      V-Gears-Installer/include/decompiler/field/instruction/FieldBackgroundInstruction.h
  12. 27 30
      V-Gears-Installer/include/decompiler/field/instruction/FieldCameraInstruction.h
  13. 39 42
      V-Gears-Installer/include/decompiler/field/instruction/FieldCondJumpInstruction.h
  14. 155 160
      V-Gears-Installer/include/decompiler/field/instruction/FieldControlFlowInstruction.h
  15. 100 94
      V-Gears-Installer/include/decompiler/field/instruction/FieldMathInstruction.h
  16. 39 35
      V-Gears-Installer/include/decompiler/field/instruction/FieldMediaInstruction.h
  17. 358 358
      V-Gears-Installer/include/decompiler/field/instruction/FieldModelInstruction.h
  18. 90 97
      V-Gears-Installer/include/decompiler/field/instruction/FieldModuleInstruction.h
  19. 29 33
      V-Gears-Installer/include/decompiler/field/instruction/FieldNoOperationInstruction.h
  20. 21 24
      V-Gears-Installer/include/decompiler/field/instruction/FieldPartyInstruction.h
  21. 18 22
      V-Gears-Installer/include/decompiler/field/instruction/FieldUncategorizedInstruction.h
  22. 54 57
      V-Gears-Installer/include/decompiler/field/instruction/FieldUncondJumpInstruction.h
  23. 56 61
      V-Gears-Installer/include/decompiler/field/instruction/FieldWalkmeshInstruction.h
  24. 32 32
      V-Gears-Installer/include/decompiler/field/instruction/FieldWindowInstruction.h
  25. 1 1
      V-Gears-Installer/include/decompiler/test/cfg_test.cpp
  26. 1 1
      V-Gears-Installer/include/decompiler/test/codegen.cpp
  27. 1 1
      V-Gears-Installer/include/decompiler/test/disassembler/pasc.cpp
  28. 1 1
      V-Gears-Installer/include/decompiler/test/disassembler/pasc.h
  29. 1 1
      V-Gears-Installer/include/decompiler/test/disassembler/subopcode.cpp
  30. 1 1
      V-Gears-Installer/include/decompiler/test/disassembler/subopcode.h
  31. 1 1
      V-Gears-Installer/include/decompiler/test/disassembler_test.cpp
  32. 71 71
      V-Gears-Installer/include/decompiler/test/ff7_field_all_opcodes_disassembler_test.cpp
  33. 17 17
      V-Gears-Installer/include/decompiler/test/ff7_field_control_flow_test.cpp
  34. 145 145
      V-Gears-Installer/include/decompiler/test/ff7_field_disasm_all_opcodes_by_category_test.cpp
  35. 13 13
      V-Gears-Installer/include/decompiler/test/main.cpp
  36. 46 49
      V-Gears-Installer/include/decompiler/world/WorldCodeGenerator.h
  37. 51 56
      V-Gears-Installer/include/decompiler/world/WorldDisassembler.h
  38. 89 94
      V-Gears-Installer/include/decompiler/world/WorldEngine.h
  39. 18 22
      V-Gears-Installer/include/decompiler/world/instruction/WorldBinaryEqualStackInstruction.h
  40. 35 39
      V-Gears-Installer/include/decompiler/world/instruction/WorldCondJumpInstruction.h
  41. 18 21
      V-Gears-Installer/include/decompiler/world/instruction/WorldKernelCallInstruction.h
  42. 21 25
      V-Gears-Installer/include/decompiler/world/instruction/WorldLoadBankInstruction.h
  43. 21 25
      V-Gears-Installer/include/decompiler/world/instruction/WorldLoadInstruction.h
  44. 21 25
      V-Gears-Installer/include/decompiler/world/instruction/WorldNoOutputInstruction.h
  45. 18 21
      V-Gears-Installer/include/decompiler/world/instruction/WorldStackInstruction.h
  46. 21 25
      V-Gears-Installer/include/decompiler/world/instruction/WorldStoreInstruction.h
  47. 18 22
      V-Gears-Installer/include/decompiler/world/instruction/WorldSubStackInstruction.h
  48. 65 68
      V-Gears-Installer/include/decompiler/world/instruction/WorldUncondJumpInstruction.h
  49. 8 8
      V-Gears-Installer/src/DataInstaller.cpp
  50. 1 1
      V-Gears-Installer/src/ModelsAndAnimationsDb.cpp
  51. 26 26
      V-Gears-Installer/src/decompiler/field/FieldCodeGenerator.cpp
  52. 3 3
      V-Gears-Installer/src/decompiler/field/FieldDecompiler.cpp
  53. 34 34
      V-Gears-Installer/src/decompiler/field/FieldDisassembler.cpp
  54. 32 33
      V-Gears-Installer/src/decompiler/field/FieldEngine.cpp
  55. 34 34
      V-Gears-Installer/src/decompiler/field/instruction/FieldBackgroundInstruction.cpp
  56. 20 20
      V-Gears-Installer/src/decompiler/field/instruction/FieldCameraInstruction.cpp
  57. 7 7
      V-Gears-Installer/src/decompiler/field/instruction/FieldCondJumpInstruction.cpp
  58. 11 9
      V-Gears-Installer/src/decompiler/field/instruction/FieldControlFlowInstruction.cpp
  59. 38 38
      V-Gears-Installer/src/decompiler/field/instruction/FieldMathInstruction.cpp
  60. 25 25
      V-Gears-Installer/src/decompiler/field/instruction/FieldMediaInstruction.cpp
  61. 82 87
      V-Gears-Installer/src/decompiler/field/instruction/FieldModelInstruction.cpp
  62. 8 8
      V-Gears-Installer/src/decompiler/field/instruction/FieldModuleInstruction.cpp
  63. 2 2
      V-Gears-Installer/src/decompiler/field/instruction/FieldNoOperationInstruction.cpp
  64. 7 7
      V-Gears-Installer/src/decompiler/field/instruction/FieldPartyInstruction.cpp
  65. 3 3
      V-Gears-Installer/src/decompiler/field/instruction/FieldUncategorizedInstruction.cpp
  66. 9 8
      V-Gears-Installer/src/decompiler/field/instruction/FieldUncondJumpInstruction.cpp
  67. 7 7
      V-Gears-Installer/src/decompiler/field/instruction/FieldWalkmeshInstruction.cpp
  68. 10 10
      V-Gears-Installer/src/decompiler/field/instruction/FieldWindowInstruction.cpp
  69. 5 6
      V-Gears-Installer/src/decompiler/world/WorldCodeGenerator.cpp
  70. 38 85
      V-Gears-Installer/src/decompiler/world/WorldDisassembler.cpp
  71. 8 8
      V-Gears-Installer/src/decompiler/world/WorldEngine.cpp
  72. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldBinaryEqualStackInstruction.cpp
  73. 4 4
      V-Gears-Installer/src/decompiler/world/instruction/WorldCondJumpInstruction.cpp
  74. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldKernelCallInstruction.cpp
  75. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldLoadBankInstruction.cpp
  76. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldLoadInstruction.cpp
  77. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldNoOutputInstruction.cpp
  78. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldStackInstruction.cpp
  79. 3 3
      V-Gears-Installer/src/decompiler/world/instruction/WorldStoreInstruction.cpp
  80. 2 2
      V-Gears-Installer/src/decompiler/world/instruction/WorldSubStackInstruction.cpp
  81. 7 7
      V-Gears-Installer/src/decompiler/world/instruction/WorldUncondJumpInstruction.cpp
  82. 78 81
      V-Gears/include/FF7Character.h
  83. 22 25
      V-Gears/include/FF7Common.h
  84. 422 470
      V-Gears/include/common/FinalFantasy7/FF7NameLookup.h
  85. 140 145
      V-Gears/include/data/FinalFantasy7/FF7ModelListFile.h
  86. 47 52
      V-Gears/include/data/FinalFantasy7/FF7ModelListFileManager.h
  87. 64 75
      V-Gears/include/data/FinalFantasy7/FF7ModelListFileSerializer.h
  88. 0 4
      V-Gears/include/data/VGearsFLevelFile.h
  89. 103 114
      V-Gears/include/map/FinalFantasy7/FF7WalkmeshFileSerializer.h
  90. 62 67
      V-Gears/src/FF7Character.cpp
  91. 1 5
      V-Gears/src/FF7Common.cpp
  92. 1 1
      V-Gears/src/common/VGearsApplication.cpp
  93. 19 24
      V-Gears/src/data/FinalFantasy7/FF7ModelListFile.cpp
  94. 25 38
      V-Gears/src/data/FinalFantasy7/FF7ModelListFileManager.cpp
  95. 49 56
      V-Gears/src/data/FinalFantasy7/FF7ModelListFileSerializer.cpp
  96. 4 4
      V-Gears/src/data/VGearsFLevelBackground2DLoader.cpp
  97. 2 2
      V-Gears/src/data/VGearsFLevelFile.cpp
  98. 1 7
      V-Gears/src/data/VGearsFLevelFileSerializer.cpp
  99. 1 1
      V-Gears/src/data/VGearsHRCFile.cpp
  100. 59 67
      V-Gears/src/map/FinalFantasy7/FF7WalkmeshFileSerializer.cpp

+ 1 - 1
COPYING.txt

@@ -300,7 +300,7 @@ the "copyright" line and a pointer to where the full notice is found.
 
 
     This program is distributed in the hope that it will be useful,
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     GNU General Public License for more details.
     GNU General Public License for more details.
 
 
     You should have received a copy of the GNU General Public License along
     You should have received a copy of the GNU General Public License along

+ 2 - 2
Tests/FinalFantasy7/src/test_FF7FLevelFileSerializer.cpp

@@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE( read_file )
     VGears::PaletteFileManager          pmgr;
     VGears::PaletteFileManager          pmgr;
     VGears::BackgroundFileManager       bmgr;
     VGears::BackgroundFileManager       bmgr;
     VGears::Background2DFileManager     b2mgr;
     VGears::Background2DFileManager     b2mgr;
-    VGears::FF7::ModelListFileManager   mmgr;
+    VGears::ModelListFileManager   mmgr;
     VGears::HRCFileManager              hmgr;
     VGears::HRCFileManager              hmgr;
     VGears::LZSFLevelFileManager        fmgr;
     VGears::LZSFLevelFileManager        fmgr;
     logMgr.createLog( "Default Log", true, true, true );
     logMgr.createLog( "Default Log", true, true, true );
@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE( read_file )
 
 
     VGears::BackgroundFilePtr       background   ( file.getBackground() );
     VGears::BackgroundFilePtr       background   ( file.getBackground() );
     VGears::CameraMatrixFilePtr     camera_matrix( file.getCameraMatrix() );
     VGears::CameraMatrixFilePtr     camera_matrix( file.getCameraMatrix() );
-    VGears::FF7::ModelListFilePtr   model_list   ( file.getModelList() );
+    VGears::ModelListFilePtr   model_list   ( file.getModelList() );
     VGears::PaletteFilePtr          palette      ( file.getPalette() );
     VGears::PaletteFilePtr          palette      ( file.getPalette() );
     VGears::WalkmeshFilePtr         walkmesh     ( file.getWalkmesh() );
     VGears::WalkmeshFilePtr         walkmesh     ( file.getWalkmesh() );
 
 

+ 12 - 12
Tests/FinalFantasy7/src/test_FF7ModelListFileSerializer.cpp

@@ -23,10 +23,10 @@ GNU General Public License for more details.
 
 
 BOOST_AUTO_TEST_CASE( read_file )
 BOOST_AUTO_TEST_CASE( read_file )
 {
 {
-    class TestFile : public VGears::FF7::ModelListFile
+    class TestFile : public VGears::ModelListFile
     {
     {
     public:
     public:
-        TestFile() : VGears::FF7::ModelListFile( NULL, "", 0, "" ) {}
+        TestFile() : VGears::ModelListFile( NULL, "", 0, "" ) {}
         size_t getCalculatedSize() const { return calculateSize(); }
         size_t getCalculatedSize() const { return calculateSize(); }
 
 
         virtual void unload( void ) {}
         virtual void unload( void ) {}
@@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE( read_file )
     BOOST_REQUIRE( stream->isReadable() );
     BOOST_REQUIRE( stream->isReadable() );
 
 
     Ogre::LogManager                        logMgr;
     Ogre::LogManager                        logMgr;
-    VGears::FF7::ModelListFileSerializer    ser;
+    VGears::ModelListFileSerializer    ser;
     TestFile                                f;
     TestFile                                f;
 
 
     logMgr.createLog( "Default Log", true, true, true );
     logMgr.createLog( "Default Log", true, true, true );
@@ -48,32 +48,32 @@ BOOST_AUTO_TEST_CASE( read_file )
 
 
     BOOST_CHECK_EQUAL( 512, f.getScale() );
     BOOST_CHECK_EQUAL( 512, f.getScale() );
 
 
-    VGears::FF7::ModelListFile::ModelList &models( f.getModels() );
+    VGears::ModelListFile::ModelList &models( f.getModels() );
     BOOST_CHECK_EQUAL( 10, models.size() );
     BOOST_CHECK_EQUAL( 10, models.size() );
 
 
-    VGears::FF7::ModelListFile::ModelDescription &m1( models.front() );
+    VGears::ModelListFile::ModelDescription &m1( models.front() );
     BOOST_CHECK_EQUAL( "md1stinmain_n_cloud.char", m1.name );
     BOOST_CHECK_EQUAL( "md1stinmain_n_cloud.char", m1.name );
     BOOST_CHECK_EQUAL( "AAAA.HRC", m1.hrc_name );
     BOOST_CHECK_EQUAL( "AAAA.HRC", m1.hrc_name );
     BOOST_CHECK_EQUAL( "512", m1.scale );
     BOOST_CHECK_EQUAL( "512", m1.scale );
-    VGears::FF7::ModelListFile::AnimationList &animations1( m1.animations );
+    VGears::ModelListFile::AnimationList &animations1( m1.animations );
     BOOST_CHECK_EQUAL( 4, animations1.size() );
     BOOST_CHECK_EQUAL( 4, animations1.size() );
-    VGears::FF7::ModelListFile::AnimationDescription &a1_1( animations1.front() );
+    VGears::ModelListFile::AnimationDescription &a1_1( animations1.front() );
     BOOST_CHECK_EQUAL( "ACFE.aki", a1_1.name );
     BOOST_CHECK_EQUAL( "ACFE.aki", a1_1.name );
     BOOST_CHECK_EQUAL( 1, a1_1.unknown );
     BOOST_CHECK_EQUAL( 1, a1_1.unknown );
-    VGears::FF7::ModelListFile::AnimationDescription &a1_2( animations1.back() );
+    VGears::ModelListFile::AnimationDescription &a1_2( animations1.back() );
     BOOST_CHECK_EQUAL( "BVJF.yos", a1_2.name );
     BOOST_CHECK_EQUAL( "BVJF.yos", a1_2.name );
     BOOST_CHECK_EQUAL( 1, a1_2.unknown );
     BOOST_CHECK_EQUAL( 1, a1_2.unknown );
 
 
-    VGears::FF7::ModelListFile::ModelDescription &m2( models.back() );
+    VGears::ModelListFile::ModelDescription &m2( models.back() );
     BOOST_CHECK_EQUAL( "md1stinshinra_guard.char", m2.name );
     BOOST_CHECK_EQUAL( "md1stinshinra_guard.char", m2.name );
     BOOST_CHECK_EQUAL( "AZHE.HRC", m2.hrc_name );
     BOOST_CHECK_EQUAL( "AZHE.HRC", m2.hrc_name );
     BOOST_CHECK_EQUAL( "512", m2.scale );
     BOOST_CHECK_EQUAL( "512", m2.scale );
-    VGears::FF7::ModelListFile::AnimationList &animations2( m2.animations );
+    VGears::ModelListFile::AnimationList &animations2( m2.animations );
     BOOST_CHECK_EQUAL( 8, animations2.size() );
     BOOST_CHECK_EQUAL( 8, animations2.size() );
-    VGears::FF7::ModelListFile::AnimationDescription &a2_1( animations2.front() );
+    VGears::ModelListFile::AnimationDescription &a2_1( animations2.front() );
     BOOST_CHECK_EQUAL( "AAFE.aki", a2_1.name );
     BOOST_CHECK_EQUAL( "AAFE.aki", a2_1.name );
     BOOST_CHECK_EQUAL( 1, a2_1.unknown );
     BOOST_CHECK_EQUAL( 1, a2_1.unknown );
-    VGears::FF7::ModelListFile::AnimationDescription &a2_2( animations2.back() );
+    VGears::ModelListFile::AnimationDescription &a2_2( animations2.back() );
     BOOST_CHECK_EQUAL( "BXIA.yos", a2_2.name );
     BOOST_CHECK_EQUAL( "BXIA.yos", a2_2.name );
     BOOST_CHECK_EQUAL( 1, a2_2.unknown );
     BOOST_CHECK_EQUAL( 1, a2_2.unknown );
 
 

+ 1 - 1
Tests/FinalFantasy7/src/test_FF7WalkmeshFileSerializer.cpp

@@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE( read_file )
     BOOST_REQUIRE( stream->isReadable() );
     BOOST_REQUIRE( stream->isReadable() );
 
 
     Ogre::LogManager                    logMgr;
     Ogre::LogManager                    logMgr;
-    VGears::FF7::WalkmeshFileSerializer ser;
+    VGears::WalkmeshFileSerializer ser;
     TestFile                            f;
     TestFile                            f;
 
 
     logMgr.createLog( "Default Log", true, true, true );
     logMgr.createLog( "Default Log", true, true, true );

+ 1 - 1
V-Gears-Installer/include/common/scummsys.h

@@ -16,7 +16,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

+ 392 - 393
V-Gears-Installer/include/decompiler/field/FieldCodeGenerator.h

@@ -22,397 +22,396 @@
 #include "FieldScriptFormatter.h"
 #include "FieldScriptFormatter.h"
 #include "decompiler/CodeGenerator.h"
 #include "decompiler/CodeGenerator.h"
 
 
-namespace FF7{
-
-    /**
-     * Parses an stores function metadata.
-     *
-     * Function metadata can indicate the entity and character of a function, and
-     * if the function is the first or last in a class.
-     */
-    class FunctionMetaData{
-
-        public:
-
-            /**
-             * Constructor. Parses function metadata.
-             *
-             * Meta data format can be:
-             * - start_end_entityname
-             * - start_entityname
-             * - end_entity_name
-             *
-             * @param meta_data[in] Metadata to parse.
-             */
-            FunctionMetaData(std::string meta_data);
-
-            /**
-             * Checks if the function is the first of a class.
-             *
-             * @return True if the metadata is the first of a class, false
-             * otherwise.
-             */
-            bool IsStart() const;
-
-            /**
-             * Checks if the function is the last of a class.
-             *
-             * @return True if the metadata is the last of a class, false
-             * otherwise.
-             */
-            bool IsEnd() const;
-
-            /**
-             * Retrieves the entity name.
-             *
-             * @return The entity name.
-             */
-            std::string GetEntityName();
-
-            /**
-             * Retrieves the character ID.
-             *
-             * @return The chaacter ID.
-             */
-            int GetCharacterId();
-
-        private:
-
-            /**
-             * Delimiter for metadata tokens.
-             */
-            static const std::string DELIMITER;
-
-            /**
-             * Start tag for metadata.
-             */
-            static const std::string START;
-
-            /**
-             * End tag for metadata.
-             */
-            static const std::string END;
-
-            /**
-             * Parses metadata.
-             *
-             * @param meta_data[in] Metadata to parse.
-             */
-            void Parse(std::string meta_data);
-
-            /**
-             * Parses a metadata item, looking for a start mark.
-             *
-             * If it finds it, marks the metadata as the first function of a
-             * class. It also * calls {@see ParseEnd} with the next token.
-             *
-             * @param item[in] The item to check for a start mark.
-             * @param item[in] All the metadata tokens.
-             */
-            void ParseStart(const std::string& item, std::deque<std::string>& strs);
-
-            /**
-             * Parses a metadata item, looking for an end mark.
-             *
-             * If it finds it, marks the metadata as the last function of a class.
-             * It also calls {@see ParseCharId}.
-             *
-             * @param item[in] The item to check for a start mark.
-             * @param item[in] Metadata tokens, first removed.
-             */
-            void ParseEnd(const std::string& item, std::deque<std::string>& strs);
-
-            /**
-             * Parses a metadata item, looking for a character ID.
-             *
-             * If it finds it, sets the character ID. It also calls
-             * {@see ParseEntity}.
-             *
-             * @param item[in] The item to check for a start mark.
-             * @param item[in] Metadata tokens, first two removed.
-             */
-            void ParseCharId(const std::string& item, std::deque<std::string>& strs);
-
-            /**
-             * Parses a metadata item, looking for an entity name.
-             *
-             * It sets the entity name.
-             *
-             * @param item[in] The item to check for a start mark.
-             * @param item[in] Metadata tokens, first three removed.
-             */
-            void ParseEntity(const std::string& item, std::deque<std::string>& strs);
-
-            /**
-             * Indicates if the function is the last of a class.
-             */
-            bool end_ = false;
-
-            /**
-             * Indicates if the function is the first of a class.
-             */
-            bool start_ = false;
-
-            /**
-             * The entity name.
-             */
-            std::string entity_name_;
-
-            /**
-             * The character ID.
-             */
-            int character_id_ = -1;
-    };
-
-    /**
-     * The code generator.
-     *
-     * Generates code for a field map function.
-     */
-    class FieldCodeGenerator : public CodeGenerator{
-
-        public:
-
-            /**
-             * Type of data.
-             */
-            enum struct ValueType : int{
-
-                /**
-                 * Integer.
-                 */
-                Integer = 0,
-
-                /**
-                 * Float.
-                 */
-                Float = 1
-            };
-
-            /**
-             * Generates code for an unimplemented instruction.
-             *
-             * The code will actually be a comment, indicating where the function
-             * call must have been.
-             *
-             * @param entity[in] The entity name.
-             * @param address[in] The address of the instruction.
-             * @param opcode[in] The opcode not implemented.
-             */
-            static const std::string FormatInstructionNotImplemented(
-              const std::string& entity, uint32 address, uint32 opcode
-            );
-
-            /**
-             * Generates code for an unimplemented instruction.
-             *
-             * The code will actually be a comment, indicating where the function
-             * call must have been.
-             *
-             * @param entity[in] The entity name.
-             * @param address[in] The address of the instruction.
-             * @param opcode[in] The unimplemented instruction.
-             */
-            static const std::string FormatInstructionNotImplemented(
-              const std::string& entity, uint32 address, const Instruction& instruction
-            );
-
-            /**
-             * Formats a value as a boolean.
-             *
-             * @param value[in] The value to format.
-             * @return "false" if the value is 0, "true" otherwise.
-             */
-            static const std::string FormatBool(uint32 value);
-
-            /**
-             * Formats a value as a boolean.
-             *
-             * @param value[in] The value to format.
-             * @return "true" if the value is 0, "false" otherwise.
-             */
-            static const std::string FormatInvertedBool(uint32 value);
-
-            /**
-             * Formats a data access for a map script.
-             *
-             * If possible, it will look for friendly names for variables.
-             *
-             * @param formatter[in] Formatter to look up variable friendly names.
-             * @param bank[in] The memory bank to use.
-             * @param value_or_address[in] The value or memory address to use.
-             * When bank is 0, it will be considered as a value. When bank is non
-             * 0, it will be considered an address of the bank.
-             * @param value_type[in] Data type to use. Used only when getting a
-             * value, not a bank address.
-             * @param scale[in] Scale to scale values to. Used only when using
-             * float values, unused when type is integer or when using a bank
-             * address.
-             * @return String with the friendly variable name, value, or bank
-             * address.
-             */
-            template<typename TValue>static const std::string FormatValueOrVariable(
-              FieldScriptFormatter& formatter, uint32 bank, TValue value_or_address,
-              ValueType type = ValueType::Integer, float scale = 1.0f
-            ){
-                switch (bank){
-                    case 0:
-                        switch (type){
-                            // TODO: check for zero
-                            case ValueType::Float: return std::to_string(value_or_address / scale);
-                            case ValueType::Integer: return std::to_string(value_or_address);
-                            default: return std::to_string(value_or_address);
-                        }
-                    case 1:
-                    case 2:
-                    case 3:
-                    case 13:
-                    case 15:
-                        {
-                            const auto address = static_cast<uint32>(value_or_address) & 0xFF;
-                            const auto friendly_name = formatter.GetFriendlyVarName(bank, value_or_address);
-                            if (friendly_name.empty())
-                                return (boost::format("FFVII.Banks[%1%][%2%]") % bank % address).str();
-                            return (boost::format("FFVII.Data.%1%") % friendly_name).str();
-                        }
-                    case 5:
-                    case 6:
-                        {
-                            const auto address = static_cast<uint32>(value_or_address)& 0xFF;
-                            const  auto friendly_name = formatter.GetFriendlyVarName(bank, address);
-                            if (friendly_name.empty())
-                                return (boost::format("FFVII.Banks[%1%][%2%]") % bank % address).str();
-                            return "FFVII.Data." + friendly_name;
-                        }
-                    default:
-                        return (
-                          boost::format(
-                            "FFVII.Banks[%1%][%2%]"
-                          ) % bank % (static_cast<uint32>(value_or_address) & 0xFF)
-                        ).str();
-                }
+/**
+ * Parses an stores function metadata.
+ *
+ * Function metadata can indicate the entity and character of a function, and
+ * if the function is the first or last in a class.
+ */
+class FunctionMetaData{
+
+    public:
+
+        /**
+         * Constructor. Parses function metadata.
+         *
+         * Meta data format can be:
+         * - start_end_entityname
+         * - start_entityname
+         * - end_entity_name
+         *
+         * @param meta_data[in] Metadata to parse.
+         */
+        FunctionMetaData(std::string meta_data);
+
+        /**
+         * Checks if the function is the first of a class.
+         *
+         * @return True if the metadata is the first of a class, false
+         * otherwise.
+         */
+        bool IsStart() const;
+
+        /**
+         * Checks if the function is the last of a class.
+         *
+         * @return True if the metadata is the last of a class, false
+         * otherwise.
+         */
+        bool IsEnd() const;
+
+        /**
+         * Retrieves the entity name.
+         *
+         * @return The entity name.
+         */
+        std::string GetEntityName();
+
+        /**
+         * Retrieves the character ID.
+         *
+         * @return The character ID.
+         */
+        int GetCharacterId();
+
+    private:
+
+        /**
+         * Delimiter for metadata tokens.
+         */
+        static const std::string DELIMITER;
+
+        /**
+         * Start tag for metadata.
+         */
+        static const std::string START;
+
+        /**
+         * End tag for metadata.
+         */
+        static const std::string END;
+
+        /**
+         * Parses metadata.
+         *
+         * @param meta_data[in] Metadata to parse.
+         */
+        void Parse(std::string meta_data);
+
+        /**
+         * Parses a metadata item, looking for a start mark.
+         *
+         * If it finds it, marks the metadata as the first function of a
+         * class. It also * calls {@see ParseEnd} with the next token.
+         *
+         * @param item[in] The item to check for a start mark.
+         * @param item[in] All the metadata tokens.
+         */
+        void ParseStart(const std::string& item, std::deque<std::string>& strs);
+
+        /**
+         * Parses a metadata item, looking for an end mark.
+         *
+         * If it finds it, marks the metadata as the last function of a class.
+         * It also calls {@see ParseCharId}.
+         *
+         * @param item[in] The item to check for a start mark.
+         * @param item[in] Metadata tokens, first removed.
+         */
+        void ParseEnd(const std::string& item, std::deque<std::string>& strs);
+
+        /**
+         * Parses a metadata item, looking for a character ID.
+         *
+         * If it finds it, sets the character ID. It also calls
+         * {@see ParseEntity}.
+         *
+         * @param item[in] The item to check for a start mark.
+         * @param item[in] Metadata tokens, first two removed.
+         */
+        void ParseCharId(const std::string& item, std::deque<std::string>& strs);
+
+        /**
+         * Parses a metadata item, looking for an entity name.
+         *
+         * It sets the entity name.
+         *
+         * @param item[in] The item to check for a start mark.
+         * @param item[in] Metadata tokens, first three removed.
+         */
+        void ParseEntity(const std::string& item, std::deque<std::string>& strs);
+
+        /**
+         * Indicates if the function is the last of a class.
+         */
+        bool end_ = false;
+
+        /**
+         * Indicates if the function is the first of a class.
+         */
+        bool start_ = false;
+
+        /**
+         * The entity name.
+         */
+        std::string entity_name_;
+
+        /**
+         * The character ID.
+         */
+        int character_id_ = -1;
+};
+
+/**
+ * The code generator.
+ *
+ * Generates code for a field map function.
+ */
+class FieldCodeGenerator : public CodeGenerator{
+
+    public:
+
+        /**
+         * Type of data.
+         */
+        enum struct ValueType : int{
+
+            /**
+             * Integer.
+             */
+            Integer = 0,
+
+            /**
+             * Float.
+             */
+            Float = 1
+        };
+
+        /**
+         * Generates code for an unimplemented instruction.
+         *
+         * The code will actually be a comment, indicating where the function
+         * call must have been.
+         *
+         * @param entity[in] The entity name.
+         * @param address[in] The address of the instruction.
+         * @param opcode[in] The opcode not implemented.
+         */
+        static const std::string FormatInstructionNotImplemented(
+          const std::string& entity, uint32 address, uint32 opcode
+        );
+
+        /**
+         * Generates code for an unimplemented instruction.
+         *
+         * The code will actually be a comment, indicating where the function
+         * call must have been.
+         *
+         * @param entity[in] The entity name.
+         * @param address[in] The address of the instruction.
+         * @param opcode[in] The unimplemented instruction.
+         */
+        static const std::string FormatInstructionNotImplemented(
+          const std::string& entity, uint32 address, const Instruction& instruction
+        );
+
+        /**
+         * Formats a value as a boolean.
+         *
+         * @param value[in] The value to format.
+         * @return "false" if the value is 0, "true" otherwise.
+         */
+        static const std::string FormatBool(uint32 value);
+
+        /**
+         * Formats a value as a boolean.
+         *
+         * @param value[in] The value to format.
+         * @return "true" if the value is 0, "false" otherwise.
+         */
+        static const std::string FormatInvertedBool(uint32 value);
+
+        /**
+         * Formats a data access for a map script.
+         *
+         * If possible, it will look for friendly names for variables.
+         *
+         * @param formatter[in] Formatter to look up variable friendly names.
+         * @param bank[in] The memory bank to use.
+         * @param value_or_address[in] The value or memory address to use.
+         * When bank is 0, it will be considered as a value. When bank is non
+         * 0, it will be considered an address of the bank.
+         * @param value_type[in] Data type to use. Used only when getting a
+         * value, not a bank address.
+         * @param scale[in] Scale to scale values to. Used only when using
+         * float values, unused when type is integer or when using a bank
+         * address.
+         * @return String with the friendly variable name, value, or bank
+         * address.
+         */
+        template<typename TValue>static const std::string FormatValueOrVariable(
+          FieldScriptFormatter& formatter, uint32 bank, TValue value_or_address,
+          ValueType type = ValueType::Integer, float scale = 1.0f
+        ){
+            switch (bank){
+                case 0:
+                    switch (type){
+                        // TODO: check for zero
+                        case ValueType::Float: return std::to_string(value_or_address / scale);
+                        case ValueType::Integer: return std::to_string(value_or_address);
+                        default: return std::to_string(value_or_address);
+                    }
+                case 1:
+                case 2:
+                case 3:
+                case 13:
+                case 15:
+                    {
+                        const auto address = static_cast<uint32>(value_or_address) & 0xFF;
+                        const auto friendly_name = formatter.GetFriendlyVarName(
+                          bank, value_or_address
+                        );
+                        if (friendly_name.empty())
+                            return (boost::format("FFVII.Banks[%1%][%2%]") % bank % address).str();
+                        return (boost::format("FFVII.Data.%1%") % friendly_name).str();
+                    }
+                case 5:
+                case 6:
+                    {
+                        const auto address = static_cast<uint32>(value_or_address)& 0xFF;
+                        const  auto friendly_name = formatter.GetFriendlyVarName(bank, address);
+                        if (friendly_name.empty())
+                            return (boost::format("FFVII.Banks[%1%][%2%]") % bank % address).str();
+                        return "FFVII.Data." + friendly_name;
+                    }
+                default:
+                    return (
+                      boost::format(
+                        "FFVII.Banks[%1%][%2%]"
+                      ) % bank % (static_cast<uint32>(value_or_address) & 0xFF)
+                    ).str();
             }
             }
-
-            /**
-             * Constructor.
-             *
-             * @param engine[in] The engine.
-             * @param insts[in] The list of instructions to parse.
-             * @param output[out] The generated script.
-             * @param formatter[in] The code formatter.
-             */
-            FieldCodeGenerator(
-              Engine *engine, const InstVec& insts, std::ostream &output,
-              FieldScriptFormatter& formatter
-            ) :
-              CodeGenerator(engine, output, FIFO_ARGUMENT_ORDER, LIFO_ARGUMENT_ORDER),
-              insts_(insts), formatter_(formatter)
-            {target_lang_ = std::make_unique<LuaLanguage>();}
-
-            /**
-             * Generates the script from the instructions.
-             *
-             * @param insts[in] The list of instructions.
-             * @param graph[in] Code graph, unused.
-             */
-            virtual void Generate(InstVec& insts, const Graph &graph) override;
-
-            /**
-             * Adds a line to the script.
-             *
-             * @param line[in] The line to add.
-             * @param unindent_before[in] If true, the current script indentation
-             * will be moved back one position before the line.
-             * @param indent_after[in] If true, the current script indentation
-             * will be moved forward one position after the line.
-             */
-            virtual void AddOutputLine(
-              std::string line, bool unindent_before = false, bool indent_after = false
-            ) override;
-
-            /**
-             * Retrieves the engine scale factor.
-             *
-             * @return The scale factor
-             */
-            float GetScaleFactor() const;
-
-            /**
-             * Retrieves the formatter.
-             */
-            FieldScriptFormatter& GetFormatter();
-
-
-
-        protected:
-
-            /**
-             * Constructs the function signature.
-             *
-             * The function signature is the LUA function declaration, and it
-             * looks like this:
-             *
-             * <function_name> = function(self)
-             *
-             * @param function[in] The function to construct the signature for.
-             * @return The function signature.
-             */
-            virtual std::string ConstructFuncSignature(const Function &function) override;
-
-            /**
-             * Finalizes a function.
-             *
-             * It appends an "end" to finalize the function. If the function is
-             * the last of a class, it also closes the class braces.
-             *
-             * @param function[in] The function to end.
-             */
-            virtual void OnEndFunction(const Function& function) override;
-
-            /**
-             * Adds lines to the script before a function.
-             *
-             * If the function is the first in a class, it initializes the class
-             * and, if the function belongs to a character, creates the class
-             * variable for the character. If the function has a comment
-             * associated, it will also be added before the function.
-             *
-             * @param function[in] The function about to start.
-             */
-            virtual void OnBeforeStartFunction(const Function& function) override;
-
-            /**
-             * Initializes a function.
-             *
-             * It adds a comment with the function opcodes.
-             *
-             * @param function[in] The function to start.
-             */
-            virtual void OnStartFunction(const Function& function) override;
-
-            /**
-             * Checks if only required labels are to be written.
-             *
-             * @return Always true.
-             */
-            virtual bool OutputOnlyRequiredLabels() const override;
-
-        private:
-
-            /**
-             * The list of instructions in the function to generate.
-             */
-            const InstVec& insts_;
-
-            /**
-             * Generated lines.
-             */
-            std::vector<CodeLine> lines_;
-
-            /**
-             * The formatter.
-             */
-            FieldScriptFormatter& formatter_;
-
-    };
-}
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param engine[in] The engine.
+         * @param insts[in] The list of instructions to parse.
+         * @param output[out] The generated script.
+         * @param formatter[in] The code formatter.
+         */
+        FieldCodeGenerator(
+          Engine *engine, const InstVec& insts, std::ostream &output,
+          FieldScriptFormatter& formatter
+        ) :
+          CodeGenerator(engine, output, FIFO_ARGUMENT_ORDER, LIFO_ARGUMENT_ORDER),
+          insts_(insts), formatter_(formatter)
+        {target_lang_ = std::make_unique<LuaLanguage>();}
+
+        /**
+         * Generates the script from the instructions.
+         *
+         * @param insts[in] The list of instructions.
+         * @param graph[in] Code graph, unused.
+         */
+        virtual void Generate(InstVec& insts, const Graph &graph) override;
+
+        /**
+         * Adds a line to the script.
+         *
+         * @param line[in] The line to add.
+         * @param unindent_before[in] If true, the current script indentation
+         * will be moved back one position before the line.
+         * @param indent_after[in] If true, the current script indentation
+         * will be moved forward one position after the line.
+         */
+        virtual void AddOutputLine(
+          std::string line, bool unindent_before = false, bool indent_after = false
+        ) override;
+
+        /**
+         * Retrieves the engine scale factor.
+         *
+         * @return The scale factor
+         */
+        float GetScaleFactor() const;
+
+        /**
+         * Retrieves the formatter.
+         */
+        FieldScriptFormatter& GetFormatter();
+
+
+
+    protected:
+
+        /**
+         * Constructs the function signature.
+         *
+         * The function signature is the LUA function declaration, and it
+         * looks like this:
+         *
+         * <function_name> = function(self)
+         *
+         * @param function[in] The function to construct the signature for.
+         * @return The function signature.
+         */
+        virtual std::string ConstructFuncSignature(const Function &function) override;
+
+        /**
+         * Finalizes a function.
+         *
+         * It appends an "end" to finalize the function. If the function is
+         * the last of a class, it also closes the class braces.
+         *
+         * @param function[in] The function to end.
+         */
+        virtual void OnEndFunction(const Function& function) override;
+
+        /**
+         * Adds lines to the script before a function.
+         *
+         * If the function is the first in a class, it initializes the class
+         * and, if the function belongs to a character, creates the class
+         * variable for the character. If the function has a comment
+         * associated, it will also be added before the function.
+         *
+         * @param function[in] The function about to start.
+         */
+        virtual void OnBeforeStartFunction(const Function& function) override;
+
+        /**
+         * Initializes a function.
+         *
+         * It adds a comment with the function opcodes.
+         *
+         * @param function[in] The function to start.
+         */
+        virtual void OnStartFunction(const Function& function) override;
+
+        /**
+         * Checks if only required labels are to be written.
+         *
+         * @return Always true.
+         */
+        virtual bool OutputOnlyRequiredLabels() const override;
+
+    private:
+
+        /**
+         * The list of instructions in the function to generate.
+         */
+        const InstVec& insts_;
+
+        /**
+         * Generated lines.
+         */
+        std::vector<CodeLine> lines_;
+
+        /**
+         * The formatter.
+         */
+        FieldScriptFormatter& formatter_;
+
+};

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

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

@@ -22,768 +22,758 @@
 class BinaryReader;
 class BinaryReader;
 class Function;
 class Function;
 
 
-namespace FF7{
-
-    /**
-     * Field opcodes.
-     */
-    enum OPCODES{
-        RET = 0x0,
-        REQ = 0x01,
-        REQSW = 0x02,
-        REQEW = 0x03,
-        PREQ = 0x04,
-        PRQSW = 0x05,
-        PRQEW = 0x06,
-        RETTO = 0x07,
-        JOIN = 0x08,
-        SPLIT = 0x09,
-        SPTYE = 0x0A,
-        GTPYE = 0x0B,
-        DSKCG = 0x0E,
-        SPECIAL = 0x0F,
-        JMPF = 0x10,
-        JMPFL = 0x11,
-        JMPB = 0x12,
-        JMPBL = 0x13,
-        IFUB = 0x14,
-        IFUBL = 0x15,
-        IFSW = 0x16,
-        IFSWL = 0x17,
-        IFUW = 0x18,
-        IFUWL = 0x19,
-        MINIGAME = 0x20,
-        TUTOR = 0x21,
-        BTMD2 = 0x22,
-        BTRLD = 0x23,
-        WAIT = 0x24,
-        NFADE = 0x25,
-        BLINK = 0x26,
-        BGMOVIE = 0x27,
-        KAWAI = 0x28,
-        KAWIW = 0x29,
-        PMOVA = 0x2A,
-        SLIP = 0x2B,
-        BGPDH = 0x2C,
-        BGSCR = 0x2D,
-        WCLS = 0x2E,
-        WSIZW = 0x2F,
-        IFKEY = 0x30,
-        IFKEYON = 0x31,
-        IFKEYOFF = 0x32,
-        UC = 0x33,
-        PDIRA = 0x34,
-        PTURA = 0x35,
-        WSPCL = 0x36,
-        WNUMB = 0x37,
-        STTIM = 0x38,
-        GOLDU = 0x39,
-        GOLDD = 0x3A,
-        CHGLD = 0x3B,
-        HMPMAX1 = 0x3C,
-        HMPMAX2 = 0x3D,
-        MHMMX = 0x3E,
-        HMPMAX3 = 0x3F,
-        MESSAGE = 0x40,
-        MPARA = 0x41,
-        MPRA2 = 0x42,
-        MPNAM = 0x43,
-        MPU = 0x45,
-        MPD = 0x47,
-        ASK = 0x48,
-        MENU = 0x49,
-        MENU2 = 0x4A,
-        BTLTB = 0x4B,
-        HPU = 0x4D,
-        HPD = 0x4F,
-        WINDOW = 0x50,
-        WMOVE = 0x51,
-        WMODE = 0x52,
-        WREST = 0x53,
-        WCLSE = 0x54,
-        WROW = 0x55,
-        GWCOL = 0x56,
-        SWCOL = 0x57,
-        STITM = 0x58,
-        DLITM = 0x59,
-        CKITM = 0x5A,
-        SMTRA = 0x5B,
-        DMTRA = 0x5C,
-        CMTRA = 0x5D,
-        SHAKE = 0x5E,
-        NOP = 0x5F,
-        MAPJUMP = 0x60,
-        SCRLO = 0x61,
-        SCRLC = 0x62,
-        SCRLA = 0x63,
-        SCR2D = 0x64,
-        SCRCC = 0x65,
-        SCR2DC = 0x66,
-        SCRLW = 0x67,
-        SCR2DL = 0x68,
-        MPDSP = 0x69,
-        VWOFT = 0x6A,
-        FADE = 0x6B,
-        FADEW = 0x6C,
-        IDLCK = 0x6D,
-        LSTMP = 0x6E,
-        SCRLP = 0x6F,
-        BATTLE = 0x70,
-        BTLON = 0x71,
-        BTLMD = 0x72,
-        PGTDR = 0x73,
-        GETPC = 0x74,
-        PXYZI = 0x75,
-        PLUS_ = 0x76, // PLUS!
-        PLUS2_ = 0x77, // PLUS2!
-        MINUS_ = 0x78, // MINUS!
-        MINUS2_ = 0x79, // MINUS2!
-        INC_ = 0x7A, //  INC!
-        INC2_ = 0x7B, // INC2!
-        DEC_ = 0x7C, // DEC!
-        DEC2_ = 0x7D, // DEC2!
-        TLKON = 0x7E,
-        RDMSD = 0x7F,
-        SETBYTE = 0x80,
-        SETWORD = 0x81,
-        BITON = 0x82,
-        BITOFF = 0x83,
-        BITXOR = 0x84,
-        PLUS = 0x85,
-        PLUS2 = 0x86,
-        MINUS = 0x87,
-        MINUS2 = 0x88,
-        MUL = 0x89,
-        MUL2 = 0x8A,
-        DIV = 0x8B,
-        DIV2 = 0x8C,
-        MOD = 0x8D,
-        MOD2 = 0x8E,
-        AND = 0x8F,
-        AND2 = 0x90,
-        OR = 0x91,
-        OR2 = 0x92,
-        XOR = 0x93,
-        XOR2 = 0x94,
-        INC = 0x95,
-        INC2 = 0x96,
-        DEC = 0x97,
-        DEC2 = 0x98,
-        RANDOM = 0x99,
-        LBYTE = 0x9A,
-        HBYTE = 0x9B,
-        TWOBYTE = 0x9C,
-        SETX = 0x9D,
-        GETX = 0x9E,
-        SEARCHX = 0x9F,
-        PC = 0xA0,
-        opCodeCHAR = 0xA1,
-        DFANM = 0xA2,
-        ANIME1 = 0xA3,
-        VISI = 0xA4,
-        XYZI = 0xA5,
-        XYI = 0xA6,
-        XYZ = 0xA7,
-        MOVE = 0xA8,
-        CMOVE = 0xA9,
-        MOVA = 0xAA,
-        TURA = 0xAB,
-        ANIMW = 0xAC,
-        FMOVE = 0xAD,
-        ANIME2 = 0xAE,
-        ANIM_1 = 0xAF, // ANIM!1
-        CANIM1 = 0xB0,
-        CANM_1 = 0xB1, // CANM!1 
-        MSPED = 0xB2,
-        DIR = 0xB3,
-        TURNGEN = 0xB4,
-        TURN = 0xB5,
-        DIRA = 0xB6,
-        GETDIR = 0xB7,
-        GETAXY = 0xB8,
-        GETAI = 0xB9,
-        ANIM_2 = 0xBA, // ANIM!2
-        CANIM2 = 0xBB,
-        CANM_2 = 0xBC, // CANM!2
-        ASPED = 0xBD,
-        CC = 0xBF,
-        JUMP = 0xC0,
-        AXYZI = 0xC1,
-        LADER = 0xC2,
-        OFST = 0xC3,
-        OFSTW = 0xC4,
-        TALKR = 0xC5,
-        SLIDR = 0xC6,
-        SOLID = 0xC7,
-        PRTYP = 0xC8,
-        PRTYM = 0xC9,
-        PRTYE = 0xCA,
-        IFPRTYQ = 0xCB,
-        IFMEMBQ = 0xCC,
-        MMBUD = 0xCD,
-        MMBLK = 0xCE,
-        MMBUK = 0xCF,
-        LINE = 0xD0,
-        LINON = 0xD1,
-        MPJPO = 0xD2,
-        SLINE = 0xD3,
-        SIN = 0xD4,
-        COS = 0xD5,
-        TLKR2 = 0xD6,
-        SLDR2 = 0xD7,
-        PMJMP = 0xD8,
-        PMJMP2 = 0xD9,
-        AKAO2 = 0xDA,
-        FCFIX = 0xDB,
-        CCANM = 0xDC,
-        ANIMB = 0xDD,
-        TURNW = 0xDE,
-        MPPAL = 0xDF,
-        BGON = 0xE0,
-        BGOFF = 0xE1,
-        BGROL = 0xE2,
-        BGROL2 = 0xE3,
-        BGCLR = 0xE4,
-        STPAL = 0xE5,
-        LDPAL = 0xE6,
-        CPPAL = 0xE7,
-        RTPAL = 0xE8,
-        ADPAL = 0xE9,
-        MPPAL2 = 0xEA,
-        STPLS = 0xEB,
-        LDPLS = 0xEC,
-        CPPAL2 = 0xED,
-        RTPAL2 = 0xEE,
-        ADPAL2 = 0xEF,
-        MUSIC = 0xF0,
-        SOUND = 0xF1,
-        AKAO = 0xF2,
-        MUSVT = 0xF3,
-        MUSVM = 0xF4,
-        MULCK = 0xF5,
-        BMUSC = 0xF6,
-        CHMPH = 0xF7,
-        PMVIE = 0xF8,
-        MOVIE = 0xF9,
-        MVIEF = 0xFA,
-        MVCAM = 0xFB,
-        FMUSC = 0xFC,
-        CMUSC = 0xFD,
-        CHMST = 0xFE,
-        GAMEOVER = 0xFF
-    };
-
-    /**
-     * SPECIAL opcodes.
-     *
-     * SPECIAL opcode is a special one. It's a multi-purpose opcode, used to
-     * perform game-specific tasks. It has a sub-opcode, in the next address,
-     * that determines the operation to perform. This is a list of those
-     * sub-opcodes.
-     */
-    enum OPCODES_SPECIAL{
-        ARROW = 0xF5,
-        PNAME = 0xF6,
-        GMSPD = 0xF7,
-        SMSPD = 0xF8,
-        FLMAT = 0xF9,
-        FLITM = 0xFA,
-        BTLCK = 0xFB,
-        MVLCK = 0xFC,
-        SPCNM = 0xFD,
-        RSGLB = 0xFE,
-        CLITM = 0xFF
-    };
-
-    /**
-     * KAWAI opcodes.
-     *
-     * KAWAI opcode is a special one. It's a multi-purpose opcode, used to
-     * perform graphics related tasks. It has a sub-opcode, in the next
-     * address, that determines the operation to perform. This is a list of
-     * those sub-opcodes.
-     */
-    enum OPCODES_KAWAI{
-        EYETX = 0x00,
-        TRNSP = 0x01,
-        AMBNT = 0x02,
-        Unknown03 = 0x03, // Makou Reactor can write these unknowns.
-        Unknown04 = 0x04,
-        Unknown05 = 0x05,
-        LIGHT = 0x06,
-        Unknown07 = 0x07,
-        Unknown08 = 0x08,
-        Unknown09 = 0x09,
-        SBOBJ = 0x0A,
-        Unknown0B = 0x0B,
-        Unknown0C = 0x0C,
-        SHINE = 0x0D,
-        RESET = 0xFF
-    };
-
-    class FieldEngine;
-
-    /**
-     * A disassebler for field maps.
-     */
-    class FieldDisassembler : public Disassembler{
-
-        public:
+/**
+ * Field opcodes.
+ */
+enum OPCODES{
+    RET = 0x0,
+    REQ = 0x01,
+    REQSW = 0x02,
+    REQEW = 0x03,
+    PREQ = 0x04,
+    PRQSW = 0x05,
+    PRQEW = 0x06,
+    RETTO = 0x07,
+    JOIN = 0x08,
+    SPLIT = 0x09,
+    SPTYE = 0x0A,
+    GTPYE = 0x0B,
+    DSKCG = 0x0E,
+    SPECIAL = 0x0F,
+    JMPF = 0x10,
+    JMPFL = 0x11,
+    JMPB = 0x12,
+    JMPBL = 0x13,
+    IFUB = 0x14,
+    IFUBL = 0x15,
+    IFSW = 0x16,
+    IFSWL = 0x17,
+    IFUW = 0x18,
+    IFUWL = 0x19,
+    MINIGAME = 0x20,
+    TUTOR = 0x21,
+    BTMD2 = 0x22,
+    BTRLD = 0x23,
+    WAIT = 0x24,
+    NFADE = 0x25,
+    BLINK = 0x26,
+    BGMOVIE = 0x27,
+    KAWAI = 0x28,
+    KAWIW = 0x29,
+    PMOVA = 0x2A,
+    SLIP = 0x2B,
+    BGPDH = 0x2C,
+    BGSCR = 0x2D,
+    WCLS = 0x2E,
+    WSIZW = 0x2F,
+    IFKEY = 0x30,
+    IFKEYON = 0x31,
+    IFKEYOFF = 0x32,
+    UC = 0x33,
+    PDIRA = 0x34,
+    PTURA = 0x35,
+    WSPCL = 0x36,
+    WNUMB = 0x37,
+    STTIM = 0x38,
+    GOLDU = 0x39,
+    GOLDD = 0x3A,
+    CHGLD = 0x3B,
+    HMPMAX1 = 0x3C,
+    HMPMAX2 = 0x3D,
+    MHMMX = 0x3E,
+    HMPMAX3 = 0x3F,
+    MESSAGE = 0x40,
+    MPARA = 0x41,
+    MPRA2 = 0x42,
+    MPNAM = 0x43,
+    MPU = 0x45,
+    MPD = 0x47,
+    ASK = 0x48,
+    MENU = 0x49,
+    MENU2 = 0x4A,
+    BTLTB = 0x4B,
+    HPU = 0x4D,
+    HPD = 0x4F,
+    WINDOW = 0x50,
+    WMOVE = 0x51,
+    WMODE = 0x52,
+    WREST = 0x53,
+    WCLSE = 0x54,
+    WROW = 0x55,
+    GWCOL = 0x56,
+    SWCOL = 0x57,
+    STITM = 0x58,
+    DLITM = 0x59,
+    CKITM = 0x5A,
+    SMTRA = 0x5B,
+    DMTRA = 0x5C,
+    CMTRA = 0x5D,
+    SHAKE = 0x5E,
+    NOP = 0x5F,
+    MAPJUMP = 0x60,
+    SCRLO = 0x61,
+    SCRLC = 0x62,
+    SCRLA = 0x63,
+    SCR2D = 0x64,
+    SCRCC = 0x65,
+    SCR2DC = 0x66,
+    SCRLW = 0x67,
+    SCR2DL = 0x68,
+    MPDSP = 0x69,
+    VWOFT = 0x6A,
+    FADE = 0x6B,
+    FADEW = 0x6C,
+    IDLCK = 0x6D,
+    LSTMP = 0x6E,
+    SCRLP = 0x6F,
+    BATTLE = 0x70,
+    BTLON = 0x71,
+    BTLMD = 0x72,
+    PGTDR = 0x73,
+    GETPC = 0x74,
+    PXYZI = 0x75,
+    PLUS_ = 0x76, // PLUS!
+    PLUS2_ = 0x77, // PLUS2!
+    MINUS_ = 0x78, // MINUS!
+    MINUS2_ = 0x79, // MINUS2!
+    INC_ = 0x7A, //  INC!
+    INC2_ = 0x7B, // INC2!
+    DEC_ = 0x7C, // DEC!
+    DEC2_ = 0x7D, // DEC2!
+    TLKON = 0x7E,
+    RDMSD = 0x7F,
+    SETBYTE = 0x80,
+    SETWORD = 0x81,
+    BITON = 0x82,
+    BITOFF = 0x83,
+    BITXOR = 0x84,
+    PLUS = 0x85,
+    PLUS2 = 0x86,
+    MINUS = 0x87,
+    MINUS2 = 0x88,
+    MUL = 0x89,
+    MUL2 = 0x8A,
+    DIV = 0x8B,
+    DIV2 = 0x8C,
+    MOD = 0x8D,
+    MOD2 = 0x8E,
+    AND = 0x8F,
+    AND2 = 0x90,
+    OR = 0x91,
+    OR2 = 0x92,
+    XOR = 0x93,
+    XOR2 = 0x94,
+    INC = 0x95,
+    INC2 = 0x96,
+    DEC = 0x97,
+    DEC2 = 0x98,
+    RANDOM = 0x99,
+    LBYTE = 0x9A,
+    HBYTE = 0x9B,
+    TWOBYTE = 0x9C,
+    SETX = 0x9D,
+    GETX = 0x9E,
+    SEARCHX = 0x9F,
+    PC = 0xA0,
+    opCodeCHAR = 0xA1,
+    DFANM = 0xA2,
+    ANIME1 = 0xA3,
+    VISI = 0xA4,
+    XYZI = 0xA5,
+    XYI = 0xA6,
+    XYZ = 0xA7,
+    MOVE = 0xA8,
+    CMOVE = 0xA9,
+    MOVA = 0xAA,
+    TURA = 0xAB,
+    ANIMW = 0xAC,
+    FMOVE = 0xAD,
+    ANIME2 = 0xAE,
+    ANIM_1 = 0xAF, // ANIM!1
+    CANIM1 = 0xB0,
+    CANM_1 = 0xB1, // CANM!1
+    MSPED = 0xB2,
+    DIR = 0xB3,
+    TURNGEN = 0xB4,
+    TURN = 0xB5,
+    DIRA = 0xB6,
+    GETDIR = 0xB7,
+    GETAXY = 0xB8,
+    GETAI = 0xB9,
+    ANIM_2 = 0xBA, // ANIM!2
+    CANIM2 = 0xBB,
+    CANM_2 = 0xBC, // CANM!2
+    ASPED = 0xBD,
+    CC = 0xBF,
+    JUMP = 0xC0,
+    AXYZI = 0xC1,
+    LADER = 0xC2,
+    OFST = 0xC3,
+    OFSTW = 0xC4,
+    TALKR = 0xC5,
+    SLIDR = 0xC6,
+    SOLID = 0xC7,
+    PRTYP = 0xC8,
+    PRTYM = 0xC9,
+    PRTYE = 0xCA,
+    IFPRTYQ = 0xCB,
+    IFMEMBQ = 0xCC,
+    MMBUD = 0xCD,
+    MMBLK = 0xCE,
+    MMBUK = 0xCF,
+    LINE = 0xD0,
+    LINON = 0xD1,
+    MPJPO = 0xD2,
+    SLINE = 0xD3,
+    SIN = 0xD4,
+    COS = 0xD5,
+    TLKR2 = 0xD6,
+    SLDR2 = 0xD7,
+    PMJMP = 0xD8,
+    PMJMP2 = 0xD9,
+    AKAO2 = 0xDA,
+    FCFIX = 0xDB,
+    CCANM = 0xDC,
+    ANIMB = 0xDD,
+    TURNW = 0xDE,
+    MPPAL = 0xDF,
+    BGON = 0xE0,
+    BGOFF = 0xE1,
+    BGROL = 0xE2,
+    BGROL2 = 0xE3,
+    BGCLR = 0xE4,
+    STPAL = 0xE5,
+    LDPAL = 0xE6,
+    CPPAL = 0xE7,
+    RTPAL = 0xE8,
+    ADPAL = 0xE9,
+    MPPAL2 = 0xEA,
+    STPLS = 0xEB,
+    LDPLS = 0xEC,
+    CPPAL2 = 0xED,
+    RTPAL2 = 0xEE,
+    ADPAL2 = 0xEF,
+    MUSIC = 0xF0,
+    SOUND = 0xF1,
+    AKAO = 0xF2,
+    MUSVT = 0xF3,
+    MUSVM = 0xF4,
+    MULCK = 0xF5,
+    BMUSC = 0xF6,
+    CHMPH = 0xF7,
+    PMVIE = 0xF8,
+    MOVIE = 0xF9,
+    MVIEF = 0xFA,
+    MVCAM = 0xFB,
+    FMUSC = 0xFC,
+    CMUSC = 0xFD,
+    CHMST = 0xFE,
+    GAMEOVER = 0xFF
+};
+
+/**
+ * SPECIAL opcodes.
+ *
+ * SPECIAL opcode is a special one. It's a multi-purpose opcode, used to
+ * perform game-specific tasks. It has a sub-opcode, in the next address,
+ * that determines the operation to perform. This is a list of those
+ * sub-opcodes.
+ */
+enum OPCODES_SPECIAL{
+    ARROW = 0xF5,
+    PNAME = 0xF6,
+    GMSPD = 0xF7,
+    SMSPD = 0xF8,
+    FLMAT = 0xF9,
+    FLITM = 0xFA,
+    BTLCK = 0xFB,
+    MVLCK = 0xFC,
+    SPCNM = 0xFD,
+    RSGLB = 0xFE,
+    CLITM = 0xFF
+};
+
+/**
+ * KAWAI opcodes.
+ *
+ * KAWAI opcode is a special one. It's a multi-purpose opcode, used to
+ * perform graphics related tasks. It has a sub-opcode, in the next
+ * address, that determines the operation to perform. This is a list of
+ * those sub-opcodes.
+ */
+enum OPCODES_KAWAI{
+    EYETX = 0x00,
+    TRNSP = 0x01,
+    AMBNT = 0x02,
+    Unknown03 = 0x03, // Makou Reactor can write these unknowns.
+    Unknown04 = 0x04,
+    Unknown05 = 0x05,
+    LIGHT = 0x06,
+    Unknown07 = 0x07,
+    Unknown08 = 0x08,
+    Unknown09 = 0x09,
+    SBOBJ = 0x0A,
+    Unknown0B = 0x0B,
+    Unknown0C = 0x0C,
+    SHINE = 0x0D,
+    RESET = 0xFF
+};
+
+class FieldEngine;
+
+/**
+ * A disassebler for field maps.
+ */
+class FieldDisassembler : public Disassembler{
 
 
-            /**
-             * Information about an instruction.
-             */
-            struct InstructionRecord{
-
-                /**
-                 * The size, in bytes, of the opcode.
-                 */
-                unsigned char opcode_size;
-
-                /**
-                 * The opcode code.
-                 */
-                unsigned int opcode;
-
-                /**
-                 * The opcode short name (mnemonic).
-                 */
-                const char* opcode_name;
-
-                /**
-                 * Format of the opcode arguments.
-                 */
-                const char* argument_format;
-
-                /**
-                 * @todo Document.
-                 */
-                std::function<InstPtr()> factory_function;
-            };
+    public:
 
 
-            /**
-             * A list of flow control opcodes needed by the disassembler.
-             */
-            static InstructionRecord FLOW_OPCODES[];
+        /**
+         * Information about an instruction.
+         */
+        struct InstructionRecord{
 
 
             /**
             /**
-             * Generates a map of control flow instructions.
-             *
-             * @return A map of control flow instructions, by opcode name.
+             * The size, in bytes, of the opcode.
              */
              */
-            static std::map<std::string, const InstructionRecord*> FieldInstructions();
+            unsigned char opcode_size;
 
 
             /**
             /**
-             * Finds the ID of the character a function refers to.
-             *
-             * @param start_addr[in] The starting address of the function.
-             * @param start_addr[in] The starting address of the function.
-             * @param end_addr[in] The ending address of the instruction.
-             * @param insts[in] The lsit of instructions to search.
-             * @return The ID of the character the function refers to, or -1
-             * if the function doesn't belong to a character.
+             * The opcode code.
              */
              */
-            static int FindId(uint32 start_addr, uint32 end_addr, const InstVec& insts);
+            unsigned int opcode;
 
 
             /**
             /**
-             * Constructor.
-             *
-             * @param formatter[in] The code formatter.
-             * @param engine[in] The engine to use to disassemble.
-             * @param insts[in] The list of instructions.
+             * The opcode short name (mnemonic).
              */
              */
-            FieldDisassembler(
-              FieldScriptFormatter& formatter, FieldEngine* engine, InstVec& insts
-            );
+            const char* opcode_name;
 
 
             /**
             /**
-             * Constructor.
-             *
-             * @param formatter[in] The code formatter.
-             * @param engine[in] The engine to use to disassemble.
-             * @param insts[in] The list of instructions.
-             * @param raw_script_data[in] @todo Understand and document.
+             * Format of the opcode arguments.
              */
              */
-            FieldDisassembler(
-              FieldScriptFormatter& formatter, FieldEngine* engine,
-              InstVec& insts, const std::vector<unsigned char>& raw_script_data
-            );
+            const char* argument_format;
 
 
             /**
             /**
-             * Destructor.
+             * @todo Document.
              */
              */
-            ~FieldDisassembler();
+            std::function<InstPtr()> factory_function;
+        };
+
+        /**
+         * A list of flow control opcodes needed by the disassembler.
+         */
+        static InstructionRecord FLOW_OPCODES[];
+
+        /**
+         * Generates a map of control flow instructions.
+         *
+         * @return A map of control flow instructions, by opcode name.
+         */
+        static std::map<std::string, const InstructionRecord*> FieldInstructions();
+
+        /**
+         * Finds the ID of the character a function refers to.
+         *
+         * @param start_addr[in] The starting address of the function.
+         * @param start_addr[in] The starting address of the function.
+         * @param end_addr[in] The ending address of the instruction.
+         * @param insts[in] The lsit of instructions to search.
+         * @return The ID of the character the function refers to, or -1 if
+         * the function doesn't belong to a character.
+         */
+        static int FindId(uint32 start_addr, uint32 end_addr, const InstVec& insts);
+
+        /**
+         * Constructor.
+         *
+         * @param formatter[in] The code formatter.
+         * @param engine[in] The engine to use to disassemble.
+         * @param insts[in] The list of instructions.
+         */
+        FieldDisassembler(FieldScriptFormatter& formatter, FieldEngine* engine, InstVec& insts);
+
+        /**
+         * Constructor.
+         *
+         * @param formatter[in] The code formatter.
+         * @param engine[in] The engine to use to disassemble.
+         * @param insts[in] The list of instructions.
+         * @param raw_script_data[in] @todo Understand and document.
+         */
+        FieldDisassembler(
+          FieldScriptFormatter& formatter, FieldEngine* engine,
+          InstVec& insts, const std::vector<unsigned char>& raw_script_data
+        );
+
+        /**
+         * Destructor.
+         */
+        ~FieldDisassembler();
+
+        /**
+         * Retrieves the scale factor for the field.
+         */
+        float GetScaleFactor() const;
+
+
+        /**
+         * Disassembles the instructions.
+         */
+        virtual void DoDisassemble() override;
+
+    private:
+
+        /**
+         * Field file identification magic number.
+         */
+        static const int MAGIC;
+
+        /**
+         * The number of sections in a field.
+         */
+        static const int NUM_SECTIONS;
+
+        /**
+         * The sections of a field.
+         */
+        enum SECTIONS{
 
 
             /**
             /**
-             * Retrieves the scale factor for the field.
+             * The scripts section.
              */
              */
-            float GetScaleFactor() const;
-
+            SCRIPT = 0,
 
 
             /**
             /**
-             * Disassembles the instructions.
+             * The walkmesh section.
              */
              */
-            virtual void DoDisassemble() override;
-
-        private:
+            WALKMESH = 1,
 
 
             /**
             /**
-             * Field file identification magic number.
+             * The tiles section.
              */
              */
-            static const int MAGIC;
+            TILE_MAP = 2,
 
 
             /**
             /**
-             * The number of sections in a field.
+             * The camera section.
              */
              */
-            static const int NUM_SECTIONS;
+            CAMERA_MATRIX = 3,
 
 
             /**
             /**
-             * The sections of a field.
+             * The triggers section.
              */
              */
-            enum SECTIONS{
-
-                /**
-                 * The scripts section.
-                 */
-                SCRIPT = 0,
-
-                /**
-                 * The walkmesh section.
-                 */
-                WALKMESH = 1,
-
-                /**
-                 * The tiles section.
-                 */
-                TILE_MAP = 2,
-
-                /**
-                 * The camera section.
-                 */
-                CAMERA_MATRIX = 3,
-
-                /**
-                 * The triggers section.
-                 */
-                TRIGGERS = 4,
-
-                /**
-                 * Encounter data section.
-                 */
-                ENCOUNTERS = 5,
-
-                /**
-                 * Field models section.
-                 */
-                MODELS = 6
-            };
+            TRIGGERS = 4,
 
 
             /**
             /**
-             * Info about a script.
+             * Encounter data section.
              */
              */
-            struct ScriptInfo{
-
-                /**
-                 * Address of the script entry point.
-                 */
-                uint16 entry_point;
-
-                /**
-                 * Address of the next script entry point.
-                 *
-                 * I.e. The last address of the script, plus one.
-                 */
-                uint32 next_entry_point;
-
-                /**
-                 * Script index.
-                 */
-                size_t index;
-            };
+            ENCOUNTERS = 5,
 
 
             /**
             /**
-             * A script header.
+             * Field models section.
              */
              */
-            struct ScriptHeader{
-
-                /**
-                 * Field file identification magic number.
-                 */
-                uint16 magic;
-
-                /**
-                 * The number of entities in the field.
-                 */
-                uint8 number_of_entities;
-
-                /**
-                 * The number of models in the field.
-                 */
-                uint8 number_of_models;
-
-                /**
-                 * Offset at which the field text strings begin.
-                 */
-                uint16 offset_to_strings;
-
-                /**
-                 * The number of Akao/tuto blocks/offsets.
-                 */
-                uint16 number_of_akao_offsets;
-
-                /**
-                 * Scale of field.
-                 *
-                 * For move and talk calculation (9bit fixed point).
-                 */
-                uint16 scale;
-
-                /**
-                 * Blank data, unused.
-                 */
-                std::array<uint16, 3> blank;
-
-                /**
-                 * Field creator name.
-                 */
-                std::array<char, 8> creator;
-
-                /**
-                 * The field name.
-                 */
-                std::array<char, 8> name;
-
-                /**
-                 * The list of entity names.
-                 *
-                 * There will be {@see number_of_entities} entities.
-                 */
-                std::vector<std::array<char, 8>> field_entity_names;
-
-                /**
-                 * Akao/Tuto block offsets.
-                 *
-                 * There will be {@see number_of_akao_offsets} offsets.
-                 */
-                std::vector<uint32> akao_offsets;
-
-                /**
-                 * Entity script entry points.
-                 *
-                 * More explicitly, subroutine offsets. There will be
-                 * {@see number_of_entities} entity scripts.
-                 */
-                std::vector<std::array<uint16, 32>> entity_scripts;
-
-                /**
-                 * Reads the header.
-                 *
-                 * @param reader[in] The reader used to read the header.
-                 * @throws ScriptHeaderInvalidException If the magic number for
-                 * the field is wrong.
-                 */
-                void Read(BinaryReader& reader){
-                    magic = reader.ReadU16();
-                    if (magic != MAGIC) throw ScriptHeaderInvalidException();
-                    number_of_entities = reader.ReadU8();
-                    number_of_models = reader.ReadU8();
-                    offset_to_strings = reader.ReadU16();
-                    number_of_akao_offsets = reader.ReadU16();
-                    scale = reader.ReadU16();
-                    for (int i = 0; i < 3; i ++) blank[i] = reader.ReadU16();
-                    for (int i = 0; i < 8; i ++) creator[i] = reader.ReadU8();
-                    for (int i = 0; i < 8; i ++) name[i] = reader.ReadU8();
-                    for (int i = 0; i < number_of_entities; i ++){
-                        std::array<char, 8> name;
-                        for (int j = 0; j < 8; j ++) name[j] = reader.ReadU8();
-                        field_entity_names.emplace_back(name);
-                    }
-                    for (int i = 0; i < number_of_akao_offsets; i ++)
-                        akao_offsets.emplace_back(reader.ReadU32());
-                    entity_scripts.reserve(number_of_entities);
-                    for (int i = 0; i < number_of_entities; i ++){
-                        std::array<uint16, 32> scripts;
-                        for (int j = 0; j < 32; j ++) scripts[j] = reader.ReadU16();
-                        entity_scripts.push_back(scripts);
-                    }
-                }
-            };
+            MODELS = 6
+        };
+
+        /**
+         * Info about a script.
+         */
+        struct ScriptInfo{
 
 
             /**
             /**
-             * Open a file for disassembly.
-             *
-             * @param filename[in] The file to disassemble.
-             * @deprecated Do not use. Load the instructions from the
-             * constructor.
+             * Address of the script entry point.
              */
              */
-            virtual void Open(const char *filename) override;
+            uint16 entry_point;
 
 
             /**
             /**
-             * Disassembles a script (function).
+             * Address of the next script entry point.
              *
              *
-             * @param entity_name[in] Name of the entity the script belongs
-             * to.
-             * @param entity_index[in] Index of the entity the script belongs
-             * to.
-             * @param script_entry_point[in] Address of the first instruction
-             * of the script to disassemble.
-             * @param script index[in] Index of the script, relative to the
-             * entity scripts.
-             * @param next_script_entry_point[in] Address of the first
-             * instruction of the script next to the one to disassemble (i.e.
-             * the last address of the script to disassemble, plus one).
-             * @param is_start[in] Indicates if the script is the first one
-             * for it's entity.
-             * @param is_end[in] Indicates if the script is the last one for
-             * it's entity.
-             * @throws DecompilerException for malformed scripts.
+             * I.e. The last address of the script, plus one.
              */
              */
-            void DisassembleIndivdualScript(
-              std::string entity_name, size_t entity_index, size_t script_index,
-              size_t script_entry_point, uint32 next_script_entry_point, bool is_start, bool is_end
-            );
+            uint32 next_entry_point;
 
 
             /**
             /**
-             * Adds a function to the engine.
-             *
-             * @param entity_name[in] Name of the entity that owns the function.
-             * @param entity_index[in] Index of the entity that owns the function.
-             * @param script_index[in] Index of the script within the entity.
-             * @param next_script_entry_point[in] Start position of the next
-             * script (or the ending position of this one, plus one).
-             * @param is_start[in] @todo Understand and document.
-             * @param is_end[in] @todo Understand and document.
-             * @param to_return_only[in] True to read the script only until the
-             * first return.
-             * @param func_name[in] Name of the function. If the entity is a line,
-             * the provided name will be overridden and set to the standard line
-             * entity script names.
+             * Script index.
              */
              */
-            void AddFunc(
-              std::string entity_name, size_t entity_index, size_t script_index,
-              uint32 next_script_entry_point, const bool is_start, const bool is_end,
-              bool to_return_only, std::string func_name
-            );
+            size_t index;
+        };
+
+        /**
+         * A script header.
+         */
+        struct ScriptHeader{
 
 
             /**
             /**
-             * Reads opcodes from a script, and detects lines.
-             *
-             * It stops when it reaches the ending position or a RET opcode,
-             * whatever comes first. It also detects if one of the read opcodes
-             * LINE, which means that the entity is a line
-             *
-             * @param end_pos[in] The last position to read. Opcodes will be read
-             * until this, or until a RET is found.
-             * @param point_a[out] If a LINE opcode is found, the first point will
-             * be saved here.
-             * @param point_b[out] If a LINE opcode is found, the second point
-             * will be saved here.
-             * @return True if LINE opcode found, false if not.
+             * Field file identification magic number.
              */
              */
-            bool ReadOpCodesToPositionOrReturn(
-              size_t end_pos, std::vector<float>& point_a, std::vector<float>& point_b
-            );
+            uint16 magic;
 
 
             /**
             /**
-             * Initializes a function for an entity.
-             *
-             * @param script_index[in] Index of the script.
+             * The number of entities in the field.
              */
              */
-            std::unique_ptr<Function> StartFunction(size_t scriptIndex);
+            uint8 number_of_entities;
 
 
             /**
             /**
-             * Reads the header.
+             * The number of models in the field.
              */
              */
-            void ReadHeader();
+            uint8 number_of_models;
 
 
             /**
             /**
-             * Reads the header.
-             *
-             * @param reader[in] Reader to use to read.
+             * Offset at which the field text strings begin.
              */
              */
-            void ReadHeader(BinaryReader& reader);
+            uint16 offset_to_strings;
 
 
             /**
             /**
-             * Retrieves the offset of the end of a script.
-             *
-             * @param cur_entry_point[in] @todo Understand and document.
-             * @param entity_index[in] Index of the entity the script belongs to.
-             * @param script_index[in] The script index.
-             * @return The address of the end of the script.
+             * The number of Akao/tuto blocks/offsets.
              */
              */
-            uint32 GetEndOfScriptOffset(
-              uint16 cur_entry_point, size_t entity_index, size_t script_index
-            );
+            uint16 number_of_akao_offsets;
 
 
             /**
             /**
-             * Parses an opcode.
-             *
-             * Adds properties to an instruction, and adds the instruction to
-             * the list.
+             * Scale of field.
              *
              *
-             * @param opcode[in] The opcode code.
-             * @param name[in] the opcode name.
-             * @param instruction[in][out] A newly created instruction of the
-             * type the opcode belongs to.
-             * @param stack_change[in] Indicates how much the instruction
-             * changes the stack pointer by.
-             * @param argument_format[in] The opcode argument format.
+             * For move and talk calculation (9bit fixed point).
              */
              */
-            template<typename T> void ParseOpcode(
-              int opcode, std::string name, T instruction,
-              int stack_change, const char* argument_format
-            ){
-                uint32 full_opcode = (full_opcode << 8) + opcode;
-                this->insts_.push_back(instruction);
-                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);
-            }
+            uint16 scale;
 
 
             /**
             /**
-             * The engine.
+             * Blank data, unused.
              */
              */
-            FieldEngine* engine_;
+            std::array<uint16, 3> blank;
 
 
             /**
             /**
-             * Last address of the header.
+             * Field creator name.
              */
              */
-            uint32 header_end_position_ = 0;
+            std::array<char, 8> creator;
 
 
             /**
             /**
-             * The list of sections.
+             * The field name.
              */
              */
-            std::array<uint32, 7> sections_;
+            std::array<char, 8> name;
 
 
             /**
             /**
-             * Size of the pointers to sections.
+             * The list of entity names.
              *
              *
-             * @todo Understand and document.
+             * There will be {@see number_of_entities} entities.
              */
              */
-            int16 section_pointers_size_;
+            std::vector<std::array<char, 8>> field_entity_names;
 
 
             /**
             /**
-             * The field header.
-             */
-            ScriptHeader header_;
-
-            /**
-             * Indicates if the field has been loaded from raw data.
+             * Akao/Tuto block offsets.
+             *
+             * There will be {@see number_of_akao_offsets} offsets.
              */
              */
-            bool loaded_from_raw_data_ = false;
+            std::vector<uint32> akao_offsets;
 
 
             /**
             /**
-             * The formatter.
+             * Entity script entry points.
+             *
+             * More explicitly, subroutine offsets. There will be
+             * {@see number_of_entities} entity scripts.
              */
              */
-            FieldScriptFormatter& formatter_;
+            std::vector<std::array<uint16, 32>> entity_scripts;
 
 
             /**
             /**
-             * The scale factor of the field.
+             * Reads the header.
+             *
+             * @param reader[in] The reader used to read the header.
+             * @throws ScriptHeaderInvalidException If the magic number for
+             * the field is wrong.
              */
              */
-            float scale_factor_ = 1.0f;
-    };
-
-}
+            void Read(BinaryReader& reader){
+                magic = reader.ReadU16();
+                if (magic != MAGIC) throw ScriptHeaderInvalidException();
+                number_of_entities = reader.ReadU8();
+                number_of_models = reader.ReadU8();
+                offset_to_strings = reader.ReadU16();
+                number_of_akao_offsets = reader.ReadU16();
+                scale = reader.ReadU16();
+                for (int i = 0; i < 3; i ++) blank[i] = reader.ReadU16();
+                for (int i = 0; i < 8; i ++) creator[i] = reader.ReadU8();
+                for (int i = 0; i < 8; i ++) name[i] = reader.ReadU8();
+                for (int i = 0; i < number_of_entities; i ++){
+                    std::array<char, 8> name;
+                    for (int j = 0; j < 8; j ++) name[j] = reader.ReadU8();
+                    field_entity_names.emplace_back(name);
+                }
+                for (int i = 0; i < number_of_akao_offsets; i ++)
+                    akao_offsets.emplace_back(reader.ReadU32());
+                entity_scripts.reserve(number_of_entities);
+                for (int i = 0; i < number_of_entities; i ++){
+                    std::array<uint16, 32> scripts;
+                    for (int j = 0; j < 32; j ++) scripts[j] = reader.ReadU16();
+                    entity_scripts.push_back(scripts);
+                }
+            }
+        };
+
+        /**
+         * Open a file for disassembly.
+         *
+         * @param filename[in] The file to disassemble.
+         * @deprecated Do not use. Load the instructions from the constructor.
+         */
+        virtual void Open(const char *filename) override;
+
+        /**
+         * Disassembles a script (function).
+         *
+         * @param entity_name[in] Name of the entity the script belongs to.
+         * @param entity_index[in] Index of the entity the script belongs to.
+         * @param script_entry_point[in] Address of the first instruction of
+         * the script to disassemble.
+         * @param script index[in] Index of the script, relative to the entity
+         * scripts.
+         * @param next_script_entry_point[in] Address of the first instruction
+         * of the script next to the one to disassemble (i.e. the last address
+         * of the script to disassemble, plus one).
+         * @param is_start[in] Indicates if the script is the first one for
+         * it's entity.
+         * @param is_end[in] Indicates if the script is the last one for it's
+         * entity.
+         * @throws DecompilerException for malformed scripts.
+         */
+        void DisassembleIndivdualScript(
+          std::string entity_name, size_t entity_index, size_t script_index,
+          size_t script_entry_point, uint32 next_script_entry_point, bool is_start, bool is_end
+        );
+
+        /**
+         * Adds a function to the engine.
+         *
+         * @param entity_name[in] Name of the entity that owns the function.
+         * @param entity_index[in] Index of the entity that owns the function.
+         * @param script_index[in] Index of the script within the entity.
+         * @param next_script_entry_point[in] Start position of the next
+         * script (or the ending position of this one, plus one).
+         * @param is_start[in] @todo Understand and document.
+         * @param is_end[in] @todo Understand and document.
+         * @param to_return_only[in] True to read the script only until the
+         * first return.
+         * @param func_name[in] Name of the function. If the entity is a line,
+         * the provided name will be overridden and set to the standard line
+         * entity script names.
+         */
+        void AddFunc(
+          std::string entity_name, size_t entity_index, size_t script_index,
+          uint32 next_script_entry_point, const bool is_start, const bool is_end,
+          bool to_return_only, std::string func_name
+        );
+
+        /**
+         * Reads opcodes from a script, and detects lines.
+         *
+         * It stops when it reaches the ending position or a RET opcode,
+         * whatever comes first. It also detects if one of the read opcodes
+         * LINE, which means that the entity is a line
+         *
+         * @param end_pos[in] The last position to read. Opcodes will be read
+         * until this, or until a RET is found.
+         * @param point_a[out] If a LINE opcode is found, the first point will
+         * be saved here.
+         * @param point_b[out] If a LINE opcode is found, the second point
+         * will be saved here.
+         * @return True if LINE opcode found, false if not.
+         */
+        bool ReadOpCodesToPositionOrReturn(
+          size_t end_pos, std::vector<float>& point_a, std::vector<float>& point_b
+        );
+
+        /**
+         * Initializes a function for an entity.
+         *
+         * @param script_index[in] Index of the script.
+         */
+        std::unique_ptr<Function> StartFunction(size_t scriptIndex);
+
+        /**
+         * Reads the header.
+         */
+        void ReadHeader();
+
+        /**
+         * Reads the header.
+         *
+         * @param reader[in] Reader to use to read.
+         */
+        void ReadHeader(BinaryReader& reader);
+
+        /**
+         * Retrieves the offset of the end of a script.
+         *
+         * @param cur_entry_point[in] @todo Understand and document.
+         * @param entity_index[in] Index of the entity the script belongs to.
+         * @param script_index[in] The script index.
+         * @return The address of the end of the script.
+         */
+        uint32 GetEndOfScriptOffset(
+          uint16 cur_entry_point, size_t entity_index, size_t script_index
+        );
+
+        /**
+         * Parses an opcode.
+         *
+         * Adds properties to an instruction, and adds the instruction to the
+         * list.
+         *
+         * @param opcode[in] The opcode code.
+         * @param name[in] the opcode name.
+         * @param instruction[in][out] A newly created instruction of the type
+         * the opcode belongs to.
+         * @param stack_change[in] Indicates how much the instruction changes
+         * the stack pointer by.
+         * @param argument_format[in] The opcode argument format.
+         */
+        template<typename T> void ParseOpcode(
+          int opcode, std::string name, T instruction, int stack_change, const char* argument_format
+        ){
+            uint32 full_opcode = (full_opcode << 8) + opcode;
+            this->insts_.push_back(instruction);
+            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);
+        }
+
+        /**
+         * The engine.
+         */
+        FieldEngine* engine_;
+
+        /**
+         * Last address of the header.
+         */
+        uint32 header_end_position_ = 0;
+
+        /**
+         * The list of sections.
+         */
+        std::array<uint32, 7> sections_;
+
+        /**
+         * Size of the pointers to sections.
+         *
+         * @todo Understand and document.
+         */
+        int16 section_pointers_size_;
+
+        /**
+         * The field header.
+         */
+        ScriptHeader header_;
+
+        /**
+         * Indicates if the field has been loaded from raw data.
+         */
+        bool loaded_from_raw_data_ = false;
+
+        /**
+         * The formatter.
+         */
+        FieldScriptFormatter& formatter_;
+
+        /**
+         * The scale factor of the field.
+         */
+        float scale_factor_ = 1.0f;
+};

+ 366 - 379
V-Gears-Installer/include/decompiler/field/FieldEngine.h

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -25,381 +25,368 @@
 #include "decompiler/Engine.h"
 #include "decompiler/Engine.h"
 #include "decompiler/field/FieldDecompiler.h"
 #include "decompiler/field/FieldDecompiler.h"
 
 
-namespace FF7{
-
-    /**
-     * Represents the FF7 Field engine.
-     */
-    class FieldEngine : public Engine{
-
-        public:
-
-            /**
-             * Represents an entity.
-             *
-             * An entity can be almost anything in a field map: the playable
-             * character, an NPC, an item, a line...
-             */
-            class Entity{
-                public:
-
-                    /**
-                     * Entity constructor.
-                     *
-                     * It doesn't initialize any of the fields.
-                     */
-                    Entity() = default;
-
-                    /**
-                     * Entity constructor.
-                     *
-                     * Instantiates an entity with a name.
-                     *
-                     * @param name[in] Entity name.
-                     */
-                    Entity(const std::string& name, size_t index);
-
-                    /**
-                     * Retrieves the entity name.
-                     *
-                     * @return The entity name.
-                     */
-                    std::string GetName() const;
-
-                    /**
-                     * Retrieves the entity index.
-                     *
-                     * The index is the one at which appears in the original
-                     * game script.
-                     *
-                     * @return The entity index.
-                     */
-                    size_t GetIndex() const;
-
-                    /**
-                     * Retrieves a function.
-                     *
-                     * Retrieves the name of a function from it's index.
-                     *
-                     * @param index[in] Function index.
-                     * @return Function name.
-                     * @throws DecompilerException if there is no function
-                     * with the specified index.
-                     * @todo What is a function here? An Opcode?
-                     */
-                    std::string FunctionByIndex(size_t index) const;
-
-                    /**
-                     * Adds a function to the engine.
-                     *
-                     * Must be added by name and index.
-                     *
-                     * @param name[in] Function name. If the entity is a line,
-                     * the name will be overridden.
-                     * @param index[in] Function index.
-                     * @todo What is a function here? An Opcode?
-                     */
-                    void AddFunction(const std::string& name, size_t index);
-
-                    /**
-                     * Marks the entity as a line.
-                     *
-                     * @param line[in] True to mark the entity as a line,
-                     * false to unmark it.
-                     * @param point_a[in] First point of the line. Can be null
-                     * if line is false.
-                     * @param point_b[in] Second point of the line. Can be
-                     * null if line is false.
-                     */
-                    void MarkAsLine(
-                      bool line, std::vector<float> point_a, std::vector<float> point_b
-                    );
-
-                    /**
-                     * Checks if the entity is a line.
-                     *
-                     * Note that an entity is not considered to be a line
-                     * until a function has been found containing the opcode
-                     * LINE and {@see MarkAsLine} has been called.
-                     *
-                     * @return true if the entity is a line.
-                     */
-                    bool IsLine();
-
-                    /**
-                     * Retrieves the first point of the line entity.
-                     *
-                     * If the entity is not a line, the behavior is undefined.
-                     *
-                     * @return The first point of the line entity.
-                     */
-                    std::vector<float> GetLinePointA();
-
-                    /**
-                     * Retrieves the second point of the line entity.
-                     *
-                     * If the entity is not a line, the behavior is undefined.
-                     *
-                     * @return The second point of the line entity.
-                     */
-                    std::vector<float> GetLinePointB();
-
-
-
-                private:
-
-                    /**
-                     * Entity name.
-                     */
-                    std::string name_;
-
-                    /**
-                     * Entity index.
-                     */
-                    size_t index_;
-
-                    /**
-                     * Entity function (script) list.
-                     */
-                    std::map< size_t, std::string > functions_;
-
-                    /**
-                     * Indicates if the entity is a line.
-                     */
-                    bool is_line_;
-
-                    /**
-                     * The first point of a line entity.
-                     *
-                     * If the entity is not a line, it may not be initializer.
-                     */
-                    std::vector<float> point_a_;
-
-                    /**
-                     * The second point of a line entity.
-                     *
-                     * If the entity is not a line, it may not be initializer.
-                     */
-                    std::vector<float> point_b_;
-            };
-
-            /**
-             * Constructor.
-             *
-             * @param formatter[in] The formatter to be used by the engine.
-             * @param script_name[in] The script name.
-             */
-            FieldEngine(FieldScriptFormatter& formatter, std::string script_name);
-
-            /**
-             * Copy constructor, disabled.
-             *
-             * @param engine[in] The engine to copy.
-             */
-            FieldEngine(const FieldEngine& engine) = delete;
-
-            /**
-             * Copy constructor, disabled.
-             *
-             * @param engine[in] The engine to copy.
-             */
-            FieldEngine& operator = (const FieldEngine& engine) = delete;
-
-            /**
-             * Retrieves the disasembler.
-             *
-             * @param insts[in] List of instructions.
-             * @param raw_script_data[in] Script data, raw format.
-             * @return Pointer to the disasembler.
-             */
-            virtual std::unique_ptr<Disassembler> GetDisassembler(
-              InstVec &insts, const std::vector<unsigned char>& raw_script_data
-            ) override;
-
-            /**
-             * Retrieves the dissasembler.
-             *
-             * @param insts[in] List of instructions.
-             * @return Pointer to the dissasembler.
-             */
-            virtual std::unique_ptr<Disassembler> GetDisassembler(InstVec &insts) override;
-
-            /**
-             * Retrieves the code generator.
-             *
-             * @param insts[in] List of instructions.
-             * @param output[in] Pointer to the output (file, stream...).
-             * @return Pointer to the generator.
-             */
-            virtual std::unique_ptr<CodeGenerator> GetCodeGenerator(
-              const InstVec& insts, std::ostream &output
-            ) override;
-
-            /**
-             * Post-processing actions to apply to the scripts.
-             *
-             * It actually does nothing. CFG stands for control flow group.
-             *
-             * @param insts[in] Instruction list.
-             * @param graph[in] Code graph.
-             */
-            virtual void PostCFG(InstVec &insts, Graph graph) override;
-
-            /**
-             * Indicates if instructions are purely grouped.
-             *
-             * @return True if instructions are purely grouped. Always false.
-             * @todo What is pure grouping?
-             */
-            virtual bool UsePureGrouping() const override;
-
-            /**
-             * Retrieves all entities in the map.
-             *
-             * @return A map of entities, with the name and index.
-             */
-            std::map<std::string, int> GetEntities() const;
-
-            /**
-             * Retrieves all non-line entities in the map.
-             *
-             * @return A list of non-line entities.
-             */
-            std::vector<FieldDecompiler::FieldEntity> GetEntityList() const;
-
-            /**
-             * Retrieves all line entities in the map.
-             *
-             * @param A list of line entities.
-             */
-            std::vector<FieldDecompiler::Line> GetLineList() const;
-
-            /**
-             * Retrieves all entities in the map.
-             *
-             * @return A map of entities, with the name and index.
-             */
-            std::map<size_t, Entity> GetEntityIndexMap() const{return entity_index_map_;}
-
-            /**
-             * Adds a function to an entity.
-             *
-             * @param entity_name Name of the entity.
-             * @param entity_index Index of the entity.
-             * @param func_name Name of the function.
-             * @param func_index Index of the function.
-             */
-            void AddEntityFunction(
-              const std::string& entity_name, size_t entity_index,
-              const std::string& func_name, size_t func_index
-            );
-
-            /**
-             * Marks an entity as a line.
-             *
-             * @param entity_index Index of the entity.
-             * @param line[in] True to mark the entity as a line, false to
-             * unmark it.
-             * @param point_a[in] First point of the line. Can be null if line
-             * is false.
-             * @param point_b[in] Second point of the line. Can be null if
-             * line is false.
-             */
-            void MarkEntityAsLine(
-                size_t entity_index, bool line,
-                std::vector<float> point_a, std::vector<float> point_b
-            );
-
-            /**
-             * Checks if an entity has been marked as a line.
-             *
-             * @param entity_index[in] Index of the entity to check.
-             * @return True if the entity is a line. False if it isn't, or if
-             * there is no such entity.
-             */
-            bool EntityIsLine(size_t entity_index);
-
-            /**
-             * Retrieves an entity.
-             *
-             * @param index[in] Index of the entity to retrieve.
-             * @throws DecompilerException if there is no entity at the
-             * specified index.
-             */
-            const Entity& EntityByIndex(size_t index) const;
-
-            /**
-             * Retrieves the scale factor for the map.
-             *
-             * @return Map scale factor.
-             */
-            float GetScaleFactor() const;
-
-            /**
-             * Retrieves the script name.
-             *
-             * @return The script name.
-             */
-            const std::string& GetScriptName() const;
-
-        private:
-
-            /**
-             * Removes extraneous return statements.
-             *
-             * Useful for scripts that only contain one one return statement.
-             *
-             * @param insts[in|out] List of instructions to process.
-             * Extraneous return statements will be deleted from the
-             * instructions.
-             * @param graph[in] Code graph. Unused.
-             */
-            void RemoveExtraneousReturnStatements(InstVec& insts, Graph graph);
-
-            /**
-             * Removes trailing infinite loops.
-             *
-             * In FF7 some scripts ends with an infinite loop to keep it
-             * alive. in VGears this isn't required, and can cause infinite
-             * loops, so they can be removed.
-             *
-             * @param insts[in|out] List of instructions to proccess. Trailing
-             * infinite loops will be deleted from the instructions.
-             * @param g[in] Code graph.
-             * @todo What is the graph used to?
-             */
-            void RemoveTrailingInfiniteLoops(InstVec& insts, Graph graph);
-
-            /**
-             * Tries to detect scripts with trailing infinite loops.
-             *
-             * In FF7 some scripts ends with an infinite loop to keep it
-             * alive. in VGears this isn't required, and can cause infinite
-             * loops, so they can be removed. This function marks them, so
-             * they can be deleted with
-             * @{see FieldEngine::RemoveTrailingInfiniteLoops}.
-             */
-            void MarkInfiniteLoopGroups(InstVec& insts, Graph graph);
-
-            /**
-             * The script formatter.
-             */
-            FieldScriptFormatter& formatter_;
-
-            /**
-             * The entity index map for the field.
-             */
-            std::map<size_t, Entity> entity_index_map_;
-
-            /**
-             * The map scale factor.
-             */
-            float scale_factor_;
-
-            /**
-             * The script name.
-             */
-            std::string script_name_;
-    };
-
-}
+/**
+ * Represents the FF7 Field engine.
+ */
+class FieldEngine : public Engine{
+
+    public:
+
+        /**
+         * Represents an entity.
+         *
+         * An entity can be almost anything in a field map: the playable
+         * character, an NPC, an item, a line...
+         */
+        class Entity{
+            public:
+
+                /**
+                 * Entity constructor.
+                 *
+                 * It doesn't initialize any of the fields.
+                 */
+                Entity() = default;
+
+                /**
+                 * Entity constructor.
+                 *
+                 * Instantiates an entity with a name.
+                 *
+                 * @param name[in] Entity name.
+                 */
+                Entity(const std::string& name, size_t index);
+
+                /**
+                 * Retrieves the entity name.
+                 *
+                 * @return The entity name.
+                 */
+                std::string GetName() const;
+
+                /**
+                 * Retrieves the entity index.
+                 *
+                 * The index is the one at which appears in the original game
+                 * script.
+                 *
+                 * @return The entity index.
+                 */
+                size_t GetIndex() const;
+
+                /**
+                 * Retrieves a function.
+                 *
+                 * Retrieves the name of a function from it's index.
+                 *
+                 * @param index[in] Function index.
+                 * @return Function name.
+                 * @throws DecompilerException if there is no function with
+                 * the specified index.
+                 */
+                std::string FunctionByIndex(size_t index) const;
+
+                /**
+                 * Adds a function to the engine.
+                 *
+                 * Must be added by name and index.
+                 *
+                 * @param name[in] Function name. If the entity is a line, the
+                 * name will be overridden.
+                 * @param index[in] Function index.
+                 */
+                void AddFunction(const std::string& name, size_t index);
+
+                /**
+                 * Marks the entity as a line.
+                 *
+                 * @param line[in] True to mark the entity as a line, false to
+                 * unmark it.
+                 * @param point_a[in] First point of the line. Can be null if
+                 * line is false.
+                 * @param point_b[in] Second point of the line. Can be null if
+                 * line is false.
+                 */
+                void MarkAsLine(bool line, std::vector<float> point_a, std::vector<float> point_b);
+
+                /**
+                 * Checks if the entity is a line.
+                 *
+                 * Note that an entity is not considered to be a line until a
+                 * function has been found containing the opcode LINE and
+                 * {@see MarkAsLine} has been called.
+                 *
+                 * @return true if the entity is a line.
+                 */
+                bool IsLine();
+
+                /**
+                 * Retrieves the first point of the line entity.
+                 *
+                 * If the entity is not a line, the behavior is undefined.
+                 *
+                 * @return The first point of the line entity.
+                 */
+                std::vector<float> GetLinePointA();
+
+                /**
+                 * Retrieves the second point of the line entity.
+                 *
+                 * If the entity is not a line, the behavior is undefined.
+                 *
+                 * @return The second point of the line entity.
+                 */
+                std::vector<float> GetLinePointB();
+
+
+
+            private:
+
+                /**
+                 * Entity name.
+                 */
+                std::string name_;
+
+                /**
+                 * Entity index.
+                 */
+                size_t index_;
+
+                /**
+                 * Entity function (script) list.
+                 */
+                std::map<size_t, std::string> functions_;
+
+                /**
+                 * Indicates if the entity is a line.
+                 */
+                bool is_line_;
+
+                /**
+                 * The first point of a line entity.
+                 *
+                 * If the entity is not a line, it may not be initializer.
+                 */
+                std::vector<float> point_a_;
+
+                /**
+                 * The second point of a line entity.
+                 *
+                 * If the entity is not a line, it may not be initializer.
+                 */
+                std::vector<float> point_b_;
+        };
+
+        /**
+         * Constructor.
+         *
+         * @param formatter[in] The formatter to be used by the engine.
+         * @param script_name[in] The script name.
+         */
+        FieldEngine(FieldScriptFormatter& formatter, std::string script_name);
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param engine[in] The engine to copy.
+         */
+        FieldEngine(const FieldEngine& engine) = delete;
+
+        /**
+         * Copy constructor, disabled.
+         *
+         * @param engine[in] The engine to copy.
+         */
+        FieldEngine& operator = (const FieldEngine& engine) = delete;
+
+        /**
+         * Retrieves the disasembler.
+         *
+         * @param insts[in] List of instructions.
+         * @param raw_script_data[in] Script data, raw format.
+         * @return Pointer to the disasembler.
+         */
+        virtual std::unique_ptr<Disassembler> GetDisassembler(
+          InstVec &insts, const std::vector<unsigned char>& raw_script_data
+        ) override;
+
+        /**
+         * Retrieves the dissasembler.
+         *
+         * @param insts[in] List of instructions.
+         * @return Pointer to the dissasembler.
+         */
+        virtual std::unique_ptr<Disassembler> GetDisassembler(InstVec &insts) override;
+
+        /**
+         * Retrieves the code generator.
+         *
+         * @param insts[in] List of instructions.
+         * @param output[in] Pointer to the output (file, stream...).
+         * @return Pointer to the generator.
+         */
+        virtual std::unique_ptr<CodeGenerator> GetCodeGenerator(
+          const InstVec& insts, std::ostream &output
+        ) override;
+
+        /**
+         * Post-processing actions to apply to the scripts.
+         *
+         * It actually does nothing. CFG stands for control flow group.
+         *
+         * @param insts[in] Instruction list.
+         * @param graph[in] Code graph.
+         */
+        virtual void PostCFG(InstVec &insts, Graph graph) override;
+
+        /**
+         * Indicates if instructions are purely grouped.
+         *
+         * @return True if instructions are purely grouped. Always false.
+         */
+        virtual bool UsePureGrouping() const override;
+
+        /**
+         * Retrieves all entities in the map.
+         *
+         * @return A map of entities, with the name and index.
+         */
+        std::map<std::string, int> GetEntities() const;
+
+        /**
+         * Retrieves all non-line entities in the map.
+         *
+         * @return A list of non-line entities.
+         */
+        std::vector<FieldDecompiler::FieldEntity> GetEntityList() const;
+
+        /**
+         * Retrieves all line entities in the map.
+         *
+         * @return A list of line entities.
+         */
+        std::vector<FieldDecompiler::Line> GetLineList() const;
+
+        /**
+         * Retrieves all entities in the map.
+         *
+         * @return A map of entities, with the name and index.
+         */
+        std::map<size_t, Entity> GetEntityIndexMap() const{return entity_index_map_;}
+
+        /**
+         * Adds a function to an entity.
+         *
+         * @param entity_name[in] Name of the entity.
+         * @param entity_index[in] Index of the entity.
+         * @param func_name[in] Name of the function.
+         * @param func_index[in] Index of the function.
+         */
+        void AddEntityFunction(
+          const std::string& entity_name, size_t entity_index,
+          const std::string& func_name, size_t func_index
+        );
+
+        /**
+         * Marks an entity as a line.
+         *
+         * @param entity_index Index of the entity.
+         * @param line[in] True to mark the entity as a line, false to unmark
+         * it.
+         * @param point_a[in] First point of the line. Can be null if line is
+         * false.
+         * @param point_b[in] Second point of the line. Can be null if line is
+         * false.
+         */
+        void MarkEntityAsLine(
+          size_t entity_index, bool line, std::vector<float> point_a, std::vector<float> point_b
+        );
+
+        /**
+         * Checks if an entity has been marked as a line.
+         *
+         * @param entity_index[in] Index of the entity to check.
+         * @return True if the entity is a line. False if it isn't, or if
+         * there is no such entity.
+         */
+        bool EntityIsLine(size_t entity_index);
+
+        /**
+         * Retrieves an entity.
+         *
+         * @param index[in] Index of the entity to retrieve.
+         * @throws DecompilerException if there is no entity at the specified
+         * index.
+         */
+        const Entity& EntityByIndex(size_t index) const;
+
+        /**
+         * Retrieves the scale factor for the map.
+         *
+         * @return Map scale factor.
+         */
+        float GetScaleFactor() const;
+
+        /**
+         * Retrieves the script name.
+         *
+         * @return The script name.
+         */
+        const std::string& GetScriptName() const;
+
+    private:
+
+        /**
+         * Removes extraneous return statements.
+         *
+         * Useful for scripts that only contain one one return statement.
+         *
+         * @param insts[in|out] List of instructions to process. Extraneous
+         * return statements will be deleted from the instructions.
+         * @param graph[in] Code graph. Unused.
+         */
+        void RemoveExtraneousReturnStatements(InstVec& insts, Graph graph);
+
+        /**
+         * Removes trailing infinite loops.
+         *
+         * In FF7 some scripts ends with an infinite loop to keep it alive. In
+         * VGears this isn't required, and can cause infinite loops, so they
+         * can be removed.
+         *
+         * @param insts[in|out] List of instructions to proccess. Trailing
+         * infinite loops will be deleted from the instructions.
+         * @param g[in] Code graph.
+         */
+        void RemoveTrailingInfiniteLoops(InstVec& insts, Graph graph);
+
+        /**
+         * Tries to detect scripts with trailing infinite loops.
+         *
+         * In FF7 some scripts ends with an infinite loop to keep it alive. In
+         * VGears this isn't required, and can cause infinite loops, so they
+         * can be removed. This function marks them, so they can be deleted
+         * with @{see FieldEngine::RemoveTrailingInfiniteLoops}.
+         */
+        void MarkInfiniteLoopGroups(InstVec& insts, Graph graph);
+
+        /**
+         * The script formatter.
+         */
+        FieldScriptFormatter& formatter_;
+
+        /**
+         * The entity index map for the field.
+         */
+        std::map<size_t, Entity> entity_index_map_;
+
+        /**
+         * The map scale factor.
+         */
+        float scale_factor_;
+
+        /**
+         * The script name.
+         */
+        std::string script_name_;
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,39 +20,35 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A background instruction.
-     */
-    class FieldBackgroundInstruction : public KernelCallInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-        private:
-
-            void ProcessBGON(CodeGenerator* code_gen);
-            void ProcessBGOFF(CodeGenerator* code_gen);
-            void ProcessBGCLR(CodeGenerator* code_gen);
-            void ProcessSTPAL(CodeGenerator* code_gen);
-            void ProcessLDPAL(CodeGenerator* code_gen);
-            void ProcessCPPAL(CodeGenerator* code_gen);
-            void ProcessADPAL(CodeGenerator* code_gen);
-            void ProcessMPPAL2(CodeGenerator* code_gen);
-            void ProcessSTPLS(CodeGenerator* code_gen);
-            void ProcessLDPLS(CodeGenerator* code_gen);
-    };
-
-}
+/**
+ * A background instruction.
+ */
+class FieldBackgroundInstruction : public KernelCallInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+    private:
+
+        void ProcessBGON(CodeGenerator* code_gen);
+        void ProcessBGOFF(CodeGenerator* code_gen);
+        void ProcessBGCLR(CodeGenerator* code_gen);
+        void ProcessSTPAL(CodeGenerator* code_gen);
+        void ProcessLDPAL(CodeGenerator* code_gen);
+        void ProcessCPPAL(CodeGenerator* code_gen);
+        void ProcessADPAL(CodeGenerator* code_gen);
+        void ProcessMPPAL2(CodeGenerator* code_gen);
+        void ProcessSTPLS(CodeGenerator* code_gen);
+        void ProcessLDPLS(CodeGenerator* code_gen);
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,33 +20,30 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A camera instruction.
-     */
-    class FieldCameraInstruction : public KernelCallInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-        private:
-
-            void ProcessNFADE(CodeGenerator* code_gen);
-            void ProcessSCR2D(CodeGenerator* code_gen);
-            void ProcessSCR2DC(CodeGenerator* code_gen);
-            void ProcessFADE(CodeGenerator* code_gen);
-    };
+/**
+ * A camera instruction.
+ */
+class FieldCameraInstruction : public KernelCallInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+    private:
+
+        void ProcessNFADE(CodeGenerator* code_gen);
+        void ProcessSCR2D(CodeGenerator* code_gen);
+        void ProcessSCR2DC(CodeGenerator* code_gen);
+        void ProcessFADE(CodeGenerator* code_gen);
+};
 
 
-}

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,44 +20,41 @@
 
 
 #include "decompiler/instruction/CondJumpInstruction.h"
 #include "decompiler/instruction/CondJumpInstruction.h"
 
 
-namespace FF7{
-
-    /**
-     * A conditional map jump instruction.
-     */
-    class FieldCondJumpInstruction : public CondJumpInstruction{
-
-        public:
-
-            /**
-             * Processes a conditional jump instruction.
-             *
-             * Checks if the condition is a function or a comparison, and
-             * adds the function to the stack.
-             *
-             * @param function[in] Function to process. Unused.
-             * @param stack[out] Function stack. The instruction will be added
-             * here.
-             * @param engine[in] Engine. Unused.
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-            /**
-             * Retrieves the destination address of the jump.
-             *
-             * @return The offset (number of bytes) to jump from the beginning
-             * of the instruction.
-             */
-            virtual uint32 GetDestAddress() const override;
-
-            /**
-             * Prints the instruction
-             *
-             * @param output The stream to print the instruction to.
-             */
-            virtual std::ostream& Print(std::ostream &output) const override;
-    };
-}
+/**
+ * A conditional map jump instruction.
+ */
+class FieldCondJumpInstruction : public CondJumpInstruction{
+
+    public:
+
+        /**
+         * Processes a conditional jump instruction.
+         *
+         * Checks if the condition is a function or a comparison, and adds the
+         * function to the stack.
+         *
+         * @param function[in] Function to process. Unused.
+         * @param stack[out] Function stack. The instruction will be added
+         * here.
+         * @param engine[in] Engine. Unused.
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+        /**
+         * Retrieves the destination address of the jump.
+         *
+         * @return The offset (number of bytes) to jump from the beginning of
+         * the instruction.
+         */
+        virtual uint32 GetDestAddress() const override;
+
+        /**
+         * Prints the instruction
+         *
+         * @param output The stream to print the instruction to.
+         */
+        virtual std::ostream& Print(std::ostream &output) const override;
+};

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -21,171 +21,166 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A script flow control instruction.
-     */
-    class FF7ControlFlowInstruction : public KernelCallInstruction{
-
-        public:
+/**
+ * A script flow control instruction.
+ */
+class FieldControlFlowInstruction : public KernelCallInstruction{
 
 
-            /**
-             * Create a FF7ControlFlowInstruction.
-             *
-             * @return Pointer to the newly created instruction.
-             */
-            static InstPtr Create(){return new FF7ControlFlowInstruction();}
+    public:
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+        /**
+         * Create a FieldControlFlowInstruction.
+         *
+         * @return Pointer to the newly created instruction.
+         */
+        static InstPtr Create();
 
 
-        private:
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
 
 
-            /**
-             * Processes a REQ command.
-             *
-             * Opcode: 0x01
-             * Short name: REQ
-             * Long name: Request remote execution (asynchronous,
-             *            non-guaranteed)
-             *
-             * Memory layout (3 bytes)
-             * |0x01|E|P/F|
-             *
-             * Arguments
-             * - const UByte E: The ID of the target entity.
-             * - const Bit[3] P: The priority at which we want to execute the
-             * remote script (high 3 bits of byte).
-             * - const Bit[5] F: The ID of the specific member function of E
-             * to be executed (low 5 bits of byte).
-             *
-             * Requests that a remote entity executes one of its member
-             * functions at a specified priority. The request is asynchronous
-             * and returns immediately without waiting for the remote
-             * execution to start or finish. If the specified priority is
-             * already busy executing, the request will fail silently.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param engine[in] The engine.
-             */
-            void ProcessREQ(CodeGenerator* code_gen, const FieldEngine& engine);
+    private:
 
 
-            /**
-             * Processes a REQSW command.
-             *
-             * Opcode: 0x02
-             * Short name: REQSW
-             * Long name: Request remote execution (asynchronous execution,
-             * guaranteed)
-             *
-             * Memory layout (3 bytes)
-             * |0x02|E|P/F|
-             *
-             * Arguments
-             * - const UByte E: The ID of the target entity.
-             * - const Bit[3] P: The priority at which we want to execute the
-             * remote script (high 3 bits of byte).
-             * - const Bit[5] F: The ID of the specific member function of E
-             * tobe executed (low 5 bits of byte).
-             *
-             * Requests that a remote entity executes one of its member
-             * functions at a specified priority. If the specified priority is
-             * already busy executing, the request will block until it becomes
-             * available and only then return. The remote execution is still
-             * carried out asynchronously, with no notification of completion.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param engine[in] The engine.
-             */
-            void ProcessREQSW(CodeGenerator* code_gen, const FieldEngine& engine);
+        /**
+         * Processes a REQ command.
+         *
+         * Opcode: 0x01
+         * Short name: REQ
+         * Long name: Request remote execution (asynchronous,non-guaranteed)
+         *
+         * Memory layout (3 bytes)
+         * |0x01|E|P/F|
+         *
+         * Arguments
+         * - const UByte E: The ID of the target entity.
+         * - const Bit[3] P: The priority at which we want to execute the
+         * remote script (high 3 bits of byte).
+         * - const Bit[5] F: The ID of the specific member function of E to be
+         * executed (low 5 bits of byte).
+         *
+         * Requests that a remote entity executes one of its member functions
+         * at a specified priority. The request is asynchronous and returns
+         * immediately without waiting for the remote execution to start or
+         * finish. If the specified priority is already busy executing, the
+         * request will fail silently.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param engine[in] The engine.
+         */
+        void ProcessREQ(CodeGenerator* code_gen, const FieldEngine& engine);
 
 
-            /**
-             * Processes a REQEW command.
-             *
-             * Opcode: 0x03
-             * Short name: REQEW
-             * Long name: Request remote execution (synchronous, guaranteed)
-             *
-             * Memory layout (3 bytes)
-             * |0x03|E|P/F|
-             *
-             * Arguments
-             * - const UByte E: The ID of the target entity.
-             * - const Bit[3] P: The priority at which we want to execute the
-             * remote script (high 3 bits of byte).
-             * - const Bit[5] F: The ID of the specific member function of E
-             * to be executed (low 5 bits of byte).
-             *
-             * Requests that a remote entity executes one of its member
-             * functions at a specified priority. The request will block until
-             * remote execution has finished before returning.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param engine[in] The engine.
-             */
-            void ProcessREQEW(CodeGenerator* code_gen, const FieldEngine& engine);
+        /**
+         * Processes a REQSW command.
+         *
+         * Opcode: 0x02
+         * Short name: REQSW
+         * Long name: Request remote execution (asynchronous execution,
+         * guaranteed)
+         *
+         * Memory layout (3 bytes)
+         * |0x02|E|P/F|
+         *
+         * Arguments
+         * - const UByte E: The ID of the target entity.
+         * - const Bit[3] P: The priority at which we want to execute the
+         * remote script (high 3 bits of byte).
+         * - const Bit[5] F: The ID of the specific member function of E to be
+         * executed (low 5 bits of byte).
+         *
+         * Requests that a remote entity executes one of its member functions
+         * at a specified priority. If the specified priority is already busy
+         * executing, the request will block until it becomes available and
+         * only then return. The remote execution is still carried out
+         * asynchronously, with no notification of completion.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param engine[in] The engine.
+         */
+        void ProcessREQSW(CodeGenerator* code_gen, const FieldEngine& engine);
 
 
-            /**
-             * Processes a RETTO command.
-             *
-             * Opcode: 0x07
-             * Short name: RETTO
-             * Long name: Return To
-             *
-             * Memory layout (2 bytes)
-             * |0x07|P/F|
-             *
-             * Arguments
-             * - const Bit[3] P: The priority at which we want to execute the
-             * remote script (high 3 bits of byte).
-             * - const Bit[5] F: The ID of the specific member function of the
-             * current entity to be executed to (low 5 bits of byte).
-             *
-             * Stops the active script loop for this entity and also any
-             * script loops (except the main) that are queuing to be executed
-             * after the current script. This is essentially the same as
-             * adding a RET onto each of the active / queued scripts next
-             * execution position and returning the current op index to index
-             * for each script. Then the script control is passed to the
-             * script F within the current entity with the priority P.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessRETTO(CodeGenerator* code_gen);
+        /**
+         * Processes a REQEW command.
+         *
+         * Opcode: 0x03
+         * Short name: REQEW
+         * Long name: Request remote execution (synchronous, guaranteed)
+         *
+         * Memory layout (3 bytes)
+         * |0x03|E|P/F|
+         *
+         * Arguments
+         * - const UByte E: The ID of the target entity.
+         * - const Bit[3] P: The priority at which we want to execute the
+         * remote script (high 3 bits of byte).
+         * - const Bit[5] F: The ID of the specific member function of E to be
+         * executed (low 5 bits of byte).
+         *
+         * Requests that a remote entity executes one of its member functions
+         * at a specified priority. The request will block until remote
+         * execution has finished before returning.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param engine[in] The engine.
+         */
+        void ProcessREQEW(CodeGenerator* code_gen, const FieldEngine& engine);
 
 
-            /**
-             * Processes a WAIT command.
-             *
-             * Opcode: 0x24
-             * Short name: WAIT
-             * Long name: Wait
-             *
-             * Memory layout (2 bytes)
-             * |0x24|A|
-             *
-             * Arguments
-             * - const UShort A: Amount (number of frames) to wait.
-             *
-             * Pauses current script execution for a specific amount of time.
-             * Rather than a specific time value in milliseconds/seconds,
-             * the amount specifies the number of frames that must be drawn
-             * before execution resumes. Since the game runs at 30fps,
-             * WAIT(0x1E) (or WAIT(30) in decimal) will pause script execution
-             * for 1 second, WAIT(0x96) will pause for 5 seconds, and so on.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessWAIT(CodeGenerator* code_gen);
-    };
+        /**
+         * Processes a RETTO command.
+         *
+         * Opcode: 0x07
+         * Short name: RETTO
+         * Long name: Return To
+         *
+         * Memory layout (2 bytes)
+         * |0x07|P/F|
+         *
+         * Arguments
+         * - const Bit[3] P: The priority at which we want to execute the
+         * remote script (high 3 bits of byte).
+         * - const Bit[5] F: The ID of the specific member function of the
+         * current entity to be executed to (low 5 bits of byte).
+         *
+         * Stops the active script loop for this entity and also any script
+         * loops (except the main) that are queuing to be executed after the
+         * current script. This is essentially the same as adding a RET onto
+         * each of the active / queued scripts next execution position and
+         * returning the current op index to index for each script. Then the
+         * script control is passed to the script F within the current entity
+         * with the priority P.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessRETTO(CodeGenerator* code_gen);
 
 
-}
+        /**
+         * Processes a WAIT command.
+         *
+         * Opcode: 0x24
+         * Short name: WAIT
+         * Long name: Wait
+         *
+         * Memory layout (2 bytes)
+         * |0x24|A|
+         *
+         * Arguments
+         * - const UShort A: Amount (number of frames) to wait.
+         *
+         * Pauses current script execution for a specific amount of time.
+         * Rather than a specific time value in milliseconds/seconds, the
+         * amount specifies the number of frames that must be drawn before
+         * execution resumes. Since the game runs at 30fps, WAIT(0x1E) (or
+         * WAIT(30) in decimal) will pause script execution for 1 second,
+         * WAIT(0x96) will pause for 5 seconds, and so on.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessWAIT(CodeGenerator* code_gen);
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,96 +20,102 @@
 #include "decompiler/instruction/StoreInstruction.h"
 #include "decompiler/instruction/StoreInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A math instruction.
-     */
-    class FieldMathInstruction : public StoreInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-        private:
-
-            void ProcessSaturatedPLUS(CodeGenerator* code_gen);
-            void ProcessSaturatedPLUS2(CodeGenerator* code_gen);
-            void ProcessSaturatedMINUS(CodeGenerator* code_gen);
-            void ProcessSaturatedMINUS2(CodeGenerator* code_gen);
-            void ProcessSaturatedINC(CodeGenerator* code_gen);
-            void ProcessSaturatedINC2(CodeGenerator* code_gen);
-            void ProcessSaturatedDEC(CodeGenerator* code_gen);
-            void ProcessSaturatedDEC2(CodeGenerator* code_gen);
-            void ProcessRDMSD(CodeGenerator* code_gen);
-            void ProcessSETBYTE_SETWORD(CodeGenerator* code_gen);
-
-            /**
-             * Processes a BITON opcode.
-             *
-             * Opcode: 0x82
-             * Short name: BITON
-             * Long name: Set Bit
-             *
-             * Memory layout (4 bytes)
-             * |0x82|D/S|A|B|
-             *
-             * Arguments
-             * - const Bit[4] D: Destination bank.
-             * - const Bit[4] S: Source bank.
-             * - const UByte A: Destination address.
-             * - const UByte Bit: The number of the bit to turn on.
-             *
-             * Sets the nth bit in the "A" location, where n is a number
-             * between 0-7 supplied in B. A value of zero in B will set the
-             * least significant bit. If the Source Bank is 0 then the bit to
-             * be set is taken from "Bit". If the Source Bank is an 8 bit
-             * bank, then the bit is the address in that bank where the
-             * operand is.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessBITON(CodeGenerator* code_gen);
-
-            /**
-             * Processes a BITON opcode.
-             *
-             * Opcode: 0x83
-             * Short name: BITOFF
-             * Long name: Reset Bit
-             *
-             * Memory layout (4 bytes)
-             * |0x83|D/S|A|B|
-             *
-             * Arguments
-             * - const Bit[4] D: Destination bank.
-             * - const Bit[4] S: Source bank.
-             * - const UByte A: Destination address.
-             * - const UByte Bit: The number of the bit to turn off.
-             *
-             * Sets the nth bit in the "A" location, where n is a number
-             * between 0-7 supplied in B. A value of zero in B will reset the
-             * least significant bit. If the Source Bank is 0 then the bit to
-             * be set is taken from "Bit". If the Source Bank is an 8 bit
-             * bank, then the bit is the address in that bank where the
-             * operand is.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessBITOFF(CodeGenerator* code_gen);
-            void ProcessPLUSx_MINUSx(CodeGenerator* code_gen, const std::string& op);
-            void ProcessINCx_DECx(CodeGenerator* code_gen, const std::string& op);
-            void ProcessRANDOM(CodeGenerator* code_gen);
-    };
-
-}
+/**
+ * A math instruction.
+ */
+class FieldMathInstruction : public StoreInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+    private:
+
+        void ProcessSaturatedPLUS(CodeGenerator* code_gen);
+
+        void ProcessSaturatedPLUS2(CodeGenerator* code_gen);
+
+        void ProcessSaturatedMINUS(CodeGenerator* code_gen);
+
+        void ProcessSaturatedMINUS2(CodeGenerator* code_gen);
+
+        void ProcessSaturatedINC(CodeGenerator* code_gen);
+
+        void ProcessSaturatedINC2(CodeGenerator* code_gen);
+
+        void ProcessSaturatedDEC(CodeGenerator* code_gen);
+
+        void ProcessSaturatedDEC2(CodeGenerator* code_gen);
+
+        void ProcessRDMSD(CodeGenerator* code_gen);
+
+        void ProcessSETBYTE_SETWORD(CodeGenerator* code_gen);
+
+        /**
+         * Processes a BITON opcode.
+         *
+         * Opcode: 0x82
+         * Short name: BITON
+         * Long name: Set Bit
+         *
+         * Memory layout (4 bytes)
+         * |0x82|D/S|A|B|
+         *
+         * Arguments
+         * - const Bit[4] D: Destination bank.
+         * - const Bit[4] S: Source bank.
+         * - const UByte A: Destination address.
+         * - const UByte Bit: The number of the bit to turn on.
+         *
+         * Sets the nth bit in the "A" location, where n is a number between
+         * 0-7 supplied in B. A value of zero in B will set the least
+         * significant bit. If the Source Bank is 0 then the bit to be set is
+         * taken from "Bit". If the Source Bank is an 8 bit bank, then the bit
+         * is the address in that bank where the operand is.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessBITON(CodeGenerator* code_gen);
+
+        /**
+         * Processes a BITON opcode.
+         *
+         * Opcode: 0x83
+         * Short name: BITOFF
+         * Long name: Reset Bit
+         *
+         * Memory layout (4 bytes)
+         * |0x83|D/S|A|B|
+         *
+         * Arguments
+         * - const Bit[4] D: Destination bank.
+         * - const Bit[4] S: Source bank.
+         * - const UByte A: Destination address.
+         * - const UByte Bit: The number of the bit to turn off.
+         *
+         * Sets the nth bit in the "A" location, where n is a number between
+         * 0-7 supplied in B. A value of zero in B will reset the least
+         * significant bit. If the Source Bank is 0 then the bit to be set is
+         * taken from "Bit". If the Source Bank is an 8 bit bank, then the bit
+         * is the address in that bank where the operand is.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessBITOFF(CodeGenerator* code_gen);
+
+        void ProcessPLUSx_MINUSx(CodeGenerator* code_gen, const std::string& op);
+
+        void ProcessINCx_DECx(CodeGenerator* code_gen, const std::string& op);
+
+        void ProcessRANDOM(CodeGenerator* code_gen);
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,37 +20,41 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * An audio or video (or both) instruction.
-     */
-    class FieldMediaInstruction : public KernelCallInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-        private:
-
-            void ProcessAKAO2(CodeGenerator* code_gen);
-            void ProcessMUSIC(CodeGenerator* code_gen);
-            void ProcessSOUND(CodeGenerator* code_gen);
-            void ProcessAKAO(CodeGenerator* code_gen);
-            void ProcessMULCK(CodeGenerator* code_gen);
-            void ProcessPMVIE(CodeGenerator* code_gen);
-            void ProcessMOVIE(CodeGenerator* code_gen);
-            void ProcessMVIEF(CodeGenerator* code_gen);
-    };
-
-}
+/**
+ * An audio or video (or both) instruction.
+ */
+class FieldMediaInstruction : public KernelCallInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+    private:
+
+        void ProcessAKAO2(CodeGenerator* code_gen);
+
+        void ProcessMUSIC(CodeGenerator* code_gen);
+
+        void ProcessSOUND(CodeGenerator* code_gen);
+
+        void ProcessAKAO(CodeGenerator* code_gen);
+
+        void ProcessMULCK(CodeGenerator* code_gen);
+
+        void ProcessPMVIE(CodeGenerator* code_gen);
+
+        void ProcessMOVIE(CodeGenerator* code_gen);
+
+        void ProcessMVIEF(CodeGenerator* code_gen);
+};
+

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,372 +20,372 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
+/**
+ * A model instruction.
+ */
+class FieldModelInstruction : public KernelCallInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+    private:
+
+        /**
+         * Processes a JOIN opcode.
+         *
+         * Opcode: 0x08
+         * Short name: JOIN
+         * Long name: Party Field Join
+         * Memory layout (2 bytes)
+         * |0x08|S|
+         *
+         * Arguments
+         * - const UByte S: Speed that the characters join back together.
+         *
+         * Causes seperated party characters that have previously been SPLIT
+         * onto the field, to be joined back together again; that is, only the
+         * party leader becomes visible on the field. This should be called if
+         * a previous SPLIT has completed (the party members have finished
+         * speaking, or performing their actions, for example). As with SPLIT,
+         * the speed of the join is specified, from a scale of 1 (almost
+         * instant) to FF (very slow walk), and must be non-zero. In contrast
+         * to most MOVE related op codes, the speed is this setting is
+         * actually the total number of frames required. Depending on the
+         * distance from the player character and the number of frames
+         * required, the entity plays a run or walk animation. Also, all
+         * characters take the same time irrespective of distance. Calling
+         * JOIN without having previously SPLIT the characters will cause the
+         * party members to appear at the walkmesh origin and attempt to JOIN
+         * from there. This is not normally the required behaviour and should
+         * be avoided.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessJOIN(CodeGenerator* code_gen);
+
+        /**
+         * Processes a SPLIT opcode.
+         *
+         * Opcode: 0x09
+         * Short name: SPLIT
+         * Long name: Party Field Split
+         *
+         * Memory layout (15 bytes)
+         * |0x20|B1/B2|B3/B4|B5/B6|XA|XA|YA|YA|DA|XB|XB|YB|YB|DB|S|
+         *
+         * Arguments
+         * - const Bit[4] B1: Bank for XA, or zero if XA is specified as a
+         * literal value.
+         * - const Bit[4] B2: Bank for YA, or zero if YA is specified as a
+         * literal value.
+         * - const Bit[4] B3: Bank for DA, or zero if DA is specified as a
+         * literal value.
+         * - const Bit[4] B4: Bank for XB, or zero if XB is specified as a
+         * literal value.
+         * - const Bit[4] B5: Bank for YB, or zero if YB is specified as a
+         * literal value.
+         * - const Bit[4] B6: Bank for DB, or zero if DB is specified as a
+         * literal value.
+         * - const Short XA: X-coordinate of the second character in the party
+         * after the split, or address for the value if B1 is non-zero.
+         * - const Short YA: Y-coordinate of the second character in the party
+         * after the split, or address for the value if B2 is non-zero.
+         * - const UByte DA: Direction the second character faces after the
+         * split, or address for the value if B3 is non-zero.
+         * - const Short XB: X-coordinate of the third character in the party
+         * after the split, or address for the value if B4 is non-zero.
+         * - const Short YB: Y-coordinate of the third character in the party
+         * after the split, or address for the value if B5 is non-zero.
+         * - const UByte DB: Direction the third character faces after the
+         * split, or address for the value if B6 is non-zero.
+         * - const UByte S: Speed that the characters split.
+         *
+         * Causes the common 'split effect' whereby the second and third
+         * characters in the current party 'come out' from the party leader.
+         * That is, they become visible in the field, starting from the center
+         * of the party leader, and move out to the coordinates specified in
+         * the argument list. This is commonly used when the other characters
+         * in the current party have an action or dialog to perform and must
+         * be individually visible in the field. As well as specifying final
+         * coordinates for the two other party characters, the directions each
+         * character faces after the split are specified as a byte, using the
+         * common direction values found throughout the game. Speed is also
+         * given and is used to specify the rate at which the characters leave
+         * the party leader, using a scale from 1 (almost instant) to FF
+         * (extremely slow walk); this must be non-zero. In contrast to most
+         * MOVE related op codes, the speed is this setting is actually the
+         * total number of frames required. Depending on the distance from the
+         * player character and the number of frames required, the entity
+         * plays a run or walk animation. Also, all characters take the same
+         * time irrespective of distance.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessSPLIT(CodeGenerator* code_gen);
+
+        void ProcessTLKON(CodeGenerator* code_gen, const std::string& entity);
+
+        void ProcessPC(CodeGenerator* code_gen, const std::string& entity);
+
+        void ProcessCHAR(CodeGenerator* code_gen, const std::string& entity);
+
+        void ProcessDFANM(CodeGenerator* code_gen, const std::string& entity, int char_id);
+
+        void ProcessANIME1(CodeGenerator* code_gen, const std::string& entity, int char_id);
+
+        void ProcessVISI(CodeGenerator* code_gen, const std::string& entity);
+
+        void ProcessXYZI(CodeGenerator* code_gen, const std::string& entity);
+
+        void ProcessMOVE(CodeGenerator* code_gen, const std::string& entity);
+
+        void ProcessMSPED(CodeGenerator* code_gen, const std::string& entity);
+
+        void ProcessDIR(CodeGenerator* code_gen, const std::string& entity);
 
 
-    /**
-     * A model instruction.
-     */
-    class FieldModelInstruction : public KernelCallInstruction{
+        void ProcessTURNGEN(CodeGenerator* code_gen, const std::string& entity);
 
 
-        public:
+        void ProcessGETAI(CodeGenerator* code_gen, const FieldEngine& engine);
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+        void ProcessANIM_2(CodeGenerator* code_gen, const std::string& entity, int char_id);
 
 
-        private:
+        void ProcessCANIM2(CodeGenerator* code_gen, const std::string& entity, int char_id);
 
 
-            /**
-             * Processes a JOIN opcode.
-             *
-             * Opcode: 0x08
-             * Short name: JOIN
-             * Long name: Party Field Join
-             * Memory layout (2 bytes)
-             * |0x08|S|
-             *
-             * Arguments
-             * - const UByte S: Speed that the characters join back together.
-             *
-             * Causes seperated party characters that have previously been
-             * SPLIT onto the field, to be joined back together again; that
-             * is, only the party leader becomes visible on the field. This
-             * should be called if a previous SPLIT has completed (the party
-             * members have finished speaking, or performing their actions,
-             * for example). As with SPLIT, the speed of the join is
-             * specified, from a scale of 1 (almost instant) to FF (very slow
-             * walk), and must be non-zero. In contrast to most MOVE related
-             * op codes, the speed is this setting is actually the total
-             * number of frames required. Depending on the distance from the
-             * player character and the number of frames required, the entity
-             * plays a run or walk animation. Also, all characters take the
-             * same time irrespective of distance. Calling JOIN without having
-             * previously SPLIT the characters will cause the party members to
-             * appear at the walkmesh origin and attempt to JOIN from there.
-             * This is not normally the required behaviour and should be
-             * avoided.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessJOIN(CodeGenerator* code_gen);
+        void ProcessCANM_2(CodeGenerator* code_gen, const std::string& entity, int char_id);
 
 
-            /**
-             * Processes a SPLIT opcode.
-             *
-             * Opcode: 0x09
-             * Short name: SPLIT
-             * Long name: Party Field Split
-             *
-             * Memory layout (15 bytes)
-             * |0x20|B1/B2|B3/B4|B5/B6|XA|XA|YA|YA|DA|XB|XB|YB|YB|DB|S|
-             *
-             * Arguments
-             * - const Bit[4] B1: Bank for XA, or zero if XA is specified as a
-             * literal value.
-             * - const Bit[4] B2: Bank for YA, or zero if YA is specified as a
-             * literal value.
-             * - const Bit[4] B3: Bank for DA, or zero if DA is specified as a
-             * literal value.
-             * - const Bit[4] B4: Bank for XB, or zero if XB is specified as a
-             * literal value.
-             * - const Bit[4] B5: Bank for YB, or zero if YB is specified as a
-             * literal value.
-             * - const Bit[4] B6: Bank for DB, or zero if DB is specified as a
-             * literal value.
-             * - const Short XA: X-coordinate of the second character in the
-             * party after the split, or address for the value if B1 is
-             * non-zero.
-             * - const Short YA: Y-coordinate of the second character in the
-             * party after the split, or address for the value if B2 is
-             * non-zero.
-             * - const UByte DA: Direction the second character faces after the
-             * split, or address for the value if B3 is non-zero.
-             * - const Short XB: X-coordinate of the third character in the
-             * party after the split, or address for the value if B4 is
-             * non-zero.
-             * - const Short YB: Y-coordinate of the third character in the
-             * party after the split, or address for the value if B5 is
-             * non-zero.
-             * - const UByte DB: Direction the third character faces after the
-             * split, or address for the value if B6 is non-zero.
-             * - const UByte S: Speed that the characters split.
-             *
-             * Causes the common 'split effect' whereby the second and third
-             * characters in the current party 'come out' from the party
-             * leader. That is, they become visible in the field, starting
-             * from the center of the party leader, and move out to the
-             * coordinates specified in the argument list. This is commonly
-             * used when the other characters in the current party have an
-             * action or dialog to perform and must be individually visible in
-             * the field. As well as specifying final coordinates for the two
-             * other party characters, the directions each character faces
-             * after the split are specified as a byte, using the common
-             * direction values found throughout the game. Speed is also given
-             * and is used to specify the rate at which the characters leave
-             * the party leader, using a scale from 1 (almost instant) to FF
-             * (extremely slow walk); this must be non-zero. In contrast to
-             * most MOVE related op codes, the speed is this setting is
-             * actually the total number of frames required. Depending on the
-             * distance from the player character and the number of frames
-             * required, the entity plays a run or walk animation. Also, all
-             * characters take the same time irrespective of distance.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessSPLIT(CodeGenerator* code_gen);
-            void ProcessTLKON(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessPC(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessCHAR(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessDFANM(CodeGenerator* code_gen, const std::string& entity, int char_id);
-            void ProcessANIME1(CodeGenerator* code_gen, const std::string& entity, int char_id);
-            void ProcessVISI(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessXYZI(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessMOVE(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessMSPED(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessDIR(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessTURNGEN(CodeGenerator* code_gen, const std::string& entity);
-            void ProcessGETAI(CodeGenerator* code_gen, const FieldEngine& engine);
-            void ProcessANIM_2(CodeGenerator* code_gen, const std::string& entity, int char_id);
-            void ProcessCANIM2(CodeGenerator* code_gen, const std::string& entity, int char_id);
-            void ProcessCANM_2(CodeGenerator* code_gen, const std::string& entity, int char_id);
-            void ProcessCC(CodeGenerator* code_gen, const FieldEngine& engine);
+        void ProcessCC(CodeGenerator* code_gen, const FieldEngine& engine);
 
 
-            /**
-             * Processes a JUMP opcode.
-             *
-             * Opcode: 0xC0
-             * Short name: JUMP
-             * Long name: Jump
-             *
-             * Memory layout (7 bytes)
-             * |0xC2|B1/B2|B3/B4|X|Y|I|Steps|
-             *
-             * Arguments
-             * - const Bit[4] B1: Bank to retrieve X-coordinate, or zero if
-             * specifying X as a literal value.
-             * - const Bit[4] B2: Bank to retrieve Y-coordinate, or zero if
-             * specifying Y as a literal value.
-             * - const Bit[4] B3: Bank to retrieve triangle ID, or zero if
-             * specifying Z as a literal value.
-             * - const Bit[4] B4: Bank to retrieve jump height, or zero if
-             * specifying H as a literal value.
-             * - const Short X: X-coordinate of the target to jump to, or
-             * lower byte specifying address if B1 is non-zero.
-             * - const Short Y: Y-coordinate of the target to jump to, or
-             * lower byte specifying address if B2 is non-zero.
-             * - const Short I: Triangle ID of the target to jump to, or
-             * lower byte specifying address if B3 is non-zero.
-             * - const UShort Steps: Steps in jump. Must be non-zero if a
-             * literal value. Alternatively, lower byte specifies address if
-             * B4 is non-zero.
-             *
-             * Causes the character to jump to the specified point and
-             * triangle ID, with the jump curve peaking at a height which is
-             * increased by using a larger value for the H argument. In
-             * addition, the larger the number, the longer the jump will take
-             * to complete. A "normal" value is around 0x15, 0x01 is fast and
-             * instantaneous; the argument must not be zero or the game will
-             * crash. Whilst this is an unsigned two-byte number, a large
-             * value (beyond around 0x60) will not only cause a vast jump
-             * height, but also cause the screen to scroll erratically (the
-             * larger the number, the more erratic).
-             * Main update function go through all entity with JUMP state and
-             * if stage is 0 it calculates final Z point according to triangle
-             * id. It sets current coords as start coords. The main thing this
-             * function does is set B coefficient for later calculation. It
-             * defines as follows:
-             *   B = (Z_final - Z_start) / steps - steps * 1.45;
-             * Then it set current step to 0 and stage to 1. On next update
-             * other part of function works. It's calculate real position.
-             * First it increment current step number. Then it calculate X and
-             * Y. They change linear so nothing interesting here. The Z
-             * calculation is as follows:
-             *   Z_current = - step^2 * 1.45 + step * B + Z_start;
-             * If current substep equal number of steps then we set current
-             * triangle to final triangle and set stage to 2. Which finalizes
-             * the routine on next opcode call. Neither animation nor sound is
-             * specified in this opcode. An animation is played by using an
-             * animation opcode such as DFANM, and a SOUND played, before the
-             * jump.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param entity[in] The name of the entity.
-             */
-            void ProcessJUMP(CodeGenerator* code_gen, const std::string& entity);
+        /**
+         * Processes a JUMP opcode.
+         *
+         * Opcode: 0xC0
+         * Short name: JUMP
+         * Long name: Jump
+         *
+         * Memory layout (7 bytes)
+         * |0xC2|B1/B2|B3/B4|X|Y|I|Steps|
+         *
+         * Arguments
+         * - const Bit[4] B1: Bank to retrieve X-coordinate, or zero if
+         * specifying X as a literal value.
+         * - const Bit[4] B2: Bank to retrieve Y-coordinate, or zero if
+         * specifying Y as a literal value.
+         * - const Bit[4] B3: Bank to retrieve triangle ID, or zero if
+         * specifying Z as a literal value.
+         * - const Bit[4] B4: Bank to retrieve jump height, or zero if
+         * specifying H as a literal value.
+         * - const Short X: X-coordinate of the target to jump to, or lower
+         * byte specifying address if B1 is non-zero.
+         * - const Short Y: Y-coordinate of the target to jump to, or lower
+         * byte specifying address if B2 is non-zero.
+         * - const Short I: Triangle ID of the target to jump to, or lower
+         * byte specifying address if B3 is non-zero.
+         * - const UShort Steps: Steps in jump. Must be non-zero if a literal
+         * value. Alternatively, lower byte specifies address if B4 is
+         * non-zero.
+         *
+         * Causes the character to jump to the specified point and triangle
+         * ID, with the jump curve peaking at a height which is increased by
+         * using a larger value for the H argument. In addition, the larger
+         * the number, the longer the jump will take to complete. A "normal"
+         * value is around 0x15, 0x01 is fast and instantaneous; the argument
+         * must not be zero or the game will crash. Whilst this is an unsigned
+         * two-byte number, a large value (beyond around 0x60) will not only
+         * cause a vast jump height, but also cause the screen to scroll
+         * erratically (the larger the number, the more erratic). Main update
+         * function go through all entity with JUMP state and if stage is 0 it
+         * calculates final Z point according to triangle id. It sets current
+         * coords as start coords. The main thing this function does is set B
+         * coefficient for later calculation. It defines as follows:
+         *   B = (Z_final - Z_start) / steps - steps * 1.45;
+         * Then it set current step to 0 and stage to 1. On next update other
+         * part of function works. It's calculate real position. First it
+         * increment current step number. Then it calculate X and Y. They
+         * change linear so nothing interesting here. The Z calculation is as
+         * follows:
+         *   Z_current = - step^2 * 1.45 + step * B + Z_start;
+         * If current substep equal number of steps then we set current
+         * triangle to final triangle and set stage to 2. Which finalizes the
+         * routine on next opcode call. Neither animation nor sound is
+         * specified in this opcode. An animation is played by using an
+         * animation opcode such as DFANM, and a SOUND played, before the
+         * jump.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param entity[in] The name of the entity.
+         */
+        void ProcessJUMP(CodeGenerator* code_gen, const std::string& entity);
 
 
-            /**
-             * Processes a AXYZI opcode
-             *
-             * Opcode: 0xC1
-             * Short name: AXYZI
-             * Long name: Entity Get Position
-             *
-             * Memory layout (8 bytes)
-             * |0xC1|B1/B2|B3/B4|A|X|Y|Z|I|
-             *
-             * Arguments
-             * - const Bit[4] B1: Bank to store X.
-             * - const Bit[4] B2: Bank to store Y.
-             * - const Bit[4] B3: Bank to store Z.
-             * - const Bit[4] B4: Bank to store I.
-             * - const UByte A: Entity ID whose field object will have its
-             * position retrieved from.
-             * - const UByte X: Address to store the X-coordinate.
-             * - const UByte Y: Address to store the Y-coordinate.
-             * - const UByte Z: Address to store the Z-coordinate.
-             * - const UByte I: Address to store the ID of the walkmesh
-             * triangle the object is standing on.
-             *
-             * Retrieves the coordinates of the field object that the entity,
-             * whose ID specified in A, is associated with. This opcode uses
-             * an entity ID, not a field object offset; as such, if an entity
-             * ID is given that does not have a field object, this opcode will
-             * store zero in each of the four address specified.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessAXYZI(CodeGenerator* code_gen);
+        /**
+         * Processes a AXYZI opcode
+         *
+         * Opcode: 0xC1
+         * Short name: AXYZI
+         * Long name: Entity Get Position
+         *
+         * Memory layout (8 bytes)
+         * |0xC1|B1/B2|B3/B4|A|X|Y|Z|I|
+         *
+         * Arguments
+         * - const Bit[4] B1: Bank to store X.
+         * - const Bit[4] B2: Bank to store Y.
+         * - const Bit[4] B3: Bank to store Z.
+         * - const Bit[4] B4: Bank to store I.
+         * - const UByte A: Entity ID whose field object will have its
+         * position retrieved from.
+         * - const UByte X: Address to store the X-coordinate.
+         * - const UByte Y: Address to store the Y-coordinate.
+         * - const UByte Z: Address to store the Z-coordinate.
+         * - const UByte I: Address to store the ID of the walkmesh triangle
+         * the object is standing on.
+         *
+         * Retrieves the coordinates of the field object that the entity,
+         * whose ID specified in A, is associated with. This opcode uses an
+         * entity ID, not a field object offset; as such, if an entity ID is
+         * given that does not have a field object, this opcode will store
+         * zero in each of the four address specified.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessAXYZI(CodeGenerator* code_gen);
 
 
-            /**
-             * Processes a LADER opcode.
-             *
-             * Opcode: 0xC2
-             * Short name: LADER
-             * Long name: Ladder
-             *
-             * Memory layout (15 bytes)
-             * |0xC2|B1/B2|B3/B4|X|X|Y|Y|Z|Z|I|I|K|A|D|S|
-             *
-             * Arguments
-             * - const Bit[4] B1: Bank to retrieve X-coordinate, or zero if X
-             * is specified as a literal value.
-             * - const Bit[4] B2: Bank to retrieve Y-coordinate, or zero if Y
-             * is specified as a literal value.
-             * - const Bit[4] B3: Bank to retrieve Z-coordinate, or zero if Z
-             * is specified as a literal value.
-             * - const Bit[4] B4: Bank to retrieve ID, or zero if I is
-             * specified as a literal value.
-             * - const Short X: X-coordinate of the end of the ladder, or
-             * address to find X-coordinate if B1 is non-zero.
-             * - const Short Y: Y-coordinate of the end of the ladder, or
-             * address to find Y-coordinate if B2 is non-zero.
-             * - const Short Z: Z-coordinate of the end of the ladder, or
-             * address to find Z-coordinate if B3 is non-zero.
-             * - const UShort I: ID of the walkmesh triangle found at the end
-             * of the ladder, or address to find ID if B4 is non-zero.
-             * - const UByte K: The keys used to move the character on the
-             * ladder.
-             * - const UByte A: Animation ID for the field object's movement
-             * animation.
-             * - const UByte D: Direction the character faces when climbing
-             * the ladder.
-             * - const UByte S: Speed of the animation whilst climbing the
-             * ladder.
-             *
-             * Causes the character to climb a ladder; that is, switching from
-             * standard walkmesh movement, to climbing along a line connecting
-             * two points on the walkmesh. If B1, B2, B3 or B4 is non-zero,
-             * then the value for that particular component is taken from
-             * memory using the corresponding bank and address specified,
-             * rather than as a literal value. Both retrieved values and
-             * literals can be used for different components. If using X, Y, Z
-             * or I as addresses, the lower byte should hold the address
-             * whilst the higher byte should be zero. The coordinates specify
-             * the end-point of the ladder; the current position of the
-             * character is used as the start point. The ID of the walkmesh
-             * triangle must be specified; this is the triangle the character
-             * will step onto after reaching the end point of the ladder. The
-             * K value specifies the keys used to move the character across
-             * the ladder; keys outside the range found in the table will
-             * cause unpredictable behaviour. The animation ID specifies an
-             * offset into the field object's animation list; this animation
-             * is played at the speed specified by S whilst the character
-             * climbs. Finally, the D argument is a direction value in the
-             * game's standard direction format, which orients the character
-             * on the ladder. This opcode is used as part of the character's
-             * entity, rather than in a seperate entity, as with a LINE. A
-             * LINE is used to set the start point of the ladder on the
-             * walkmesh. When this LINE is crossed by the player, a script in
-             * the LINE then uses a PREQ (or one of its variants), calling the
-             * script in the party leader that defines the LADER, causing the
-             * character to switch to 'climbing mode'. To set up a two-way
-             * ladder, two LINEs are used at either end, with different values
-             * for the LADER arguments, such as differing end points. If this
-             * opcode is used as part of a non-playable character entity, the
-             * NPC object will automatically climb from the start to the end
-             * point without need for player interaction.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param entity[in] The name of the entity.
-             */
-            void ProcessLADER(CodeGenerator* code_gen, const std::string& entity);
+        /**
+         * Processes a LADER opcode.
+         *
+         * Opcode: 0xC2
+         * Short name: LADER
+         * Long name: Ladder
+         *
+         * Memory layout (15 bytes)
+         * |0xC2|B1/B2|B3/B4|X|X|Y|Y|Z|Z|I|I|K|A|D|S|
+         *
+         * Arguments
+         * - const Bit[4] B1: Bank to retrieve X-coordinate, or zero if X is
+         * specified as a literal value.
+         * - const Bit[4] B2: Bank to retrieve Y-coordinate, or zero if Y is
+         * specified as a literal value.
+         * - const Bit[4] B3: Bank to retrieve Z-coordinate, or zero if Z is
+         * specified as a literal value.
+         * - const Bit[4] B4: Bank to retrieve ID, or zero if I is specified
+         * as a literal value.
+         * - const Short X: X-coordinate of the end of the ladder, or address
+         * to find X-coordinate if B1 is non-zero.
+         * - const Short Y: Y-coordinate of the end of the ladder, or address
+         * to find Y-coordinate if B2 is non-zero.
+         * - const Short Z: Z-coordinate of the end of the ladder, or address
+         * to find Z-coordinate if B3 is non-zero.
+         * - const UShort I: ID of the walkmesh triangle found at the end of
+         * the ladder, or address to find ID if B4 is non-zero.
+         * - const UByte K: The keys used to move the character on the ladder.
+         * - const UByte A: Animation ID for the field object's movement
+         * animation.
+         * - const UByte D: Direction the character faces when climbing the
+         * ladder.
+         * - const UByte S: Speed of the animation whilst climbing the ladder.
+         *
+         * Causes the character to climb a ladder; that is, switching from
+         * standard walkmesh movement, to climbing along a line connecting two
+         * points on the walkmesh. If B1, B2, B3 or B4 is non-zero, then the
+         * value for that particular component is taken from memory using the
+         * corresponding bank and address specified, rather than as a literal
+         * value. Both retrieved values and literals can be used for different
+         * components. If using X, Y, Z or I as addresses, the lower byte
+         * should hold the address whilst the higher byte should be zero. The
+         * coordinates specify the end-point of the ladder; the current
+         * position of the character is used as the start point. The ID of the
+         * walkmesh triangle must be specified; this is the triangle the
+         * character will step onto after reaching the end point of the ladder.
+         * The K value specifies the keys used to move the character across
+         * the ladder; keys outside the range found in the table will cause
+         * unpredictable behavior. The animation ID specifies an offset into
+         * the field object's animation list; this animation is played at the
+         * speed specified by S whilst the character climbs. Finally, the D
+         * argument is a direction value in the game's standard direction
+         * format, which orients the character on the ladder. This opcode is
+         * used as part of the character's entity, rather than in a separate
+         * entity, as with a LINE. A LINE is used to set the start point of
+         * the ladder on the walkmesh. When this LINE is crossed by the
+         * player, a script in the LINE then uses a PREQ (or one of its
+         * variants), calling the script in the party leader that defines the
+         * LADER, causing the character to switch to 'climbing mode'. To set
+         * up a two-way ladder, two LINEs are used at either end, with
+         * different values for the LADER arguments, such as differing end
+         * points. If this opcode is used as part of a non-playable character
+         * entity, the NPC object will automatically climb from the start to
+         * the end point without need for player interaction.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param entity[in] The name of the entity.
+         */
+        void ProcessLADER(CodeGenerator* code_gen, const std::string& entity);
 
 
-            void ProcessSOLID(CodeGenerator* code_gen, const std::string& entity);
+        void ProcessSOLID(CodeGenerator* code_gen, const std::string& entity);
 
 
-            /**
-             * Processes an OFST opcode.
-             *
-             * Opcode: 0xC3
-             * Short name: OFST
-             * Long name: Offset Object
-             *
-             * Memory layout (8 bytes)
-             * |0xC3|B1/B2|B3/B4|T|X|Y|Z|S|
-             *
-             * Arguments:
-             * - const Bit[4] B1: Bank to retrieve X offset, or zero if X is
-             * specified as a literal.
-             * - const Bit[4] B2: Bank to retrieve Y offset, or zero if Y is
-             * specified as a literal.
-             * - const Bit[4] B3: Bank to retrieve Z offset, or zero if Z is
-             * specified as a literal.
-             * - const Bit[4] B4: Bank to retrieve speed, or zero if S is
-             * specified as a literal.
-             * - const UByte T: Type of movement.
-             * - const Short X: X offset amount, relative to current position,
-             * or address to find X offset, if B1 is non-zero.
-             * - const Short Y: Y offset amount, relative to current position,
-             * or address to find Y offset, if B2 is non-zero.
-             * - const Short Z: Z offset amount, relative to current position,
-             * or address to find Z offset, if B3 is non-zero.
-             * - const UShort S: Speed of the offset movement, if type is
-             * non-zero, or address to find speed, if B4 is non-zero.
-             *
-             * Offsets the field object, belonging to the entity whose script
-             * this opcode resides in, by a certain amount. After being
-             * offset, the character continues to be constrained in movement
-             * as defined by the walkmesh's shape, but at a certain distance
-             * away from the normal walkmesh position. Other field objects are
-             * unaffected, and their position or movements are maintained on
-             * the walkmesh's original position. If B1, B2, B3 or B4 is
-             * non-zero, then the value for that particular component is taken
-             * from memory using the corresponding bank and address specified,
-             * rather than as a literal value. Both retrieved values and
-             * literals can be used for different components. If using T, X, Y
-             * or S as addresses, the lower byte should hold the address
-             * whilst the higher byte should be zero. The amount to offset is
-             * specified relative to the current position. If Type is
-             * specified, the object moves gradually from its current point to
-             * the offset position; this can be used to simulate movements
-             * such as elevators. Any type outside the range in the table will
-             * cause the offset not to occur. If the object is set to move
-             * gradually, then the speed of offset can be set; the greater the
-             * number, the slower the object moves to its target offset.
-             * Script execution may also be halted until the gradual offset
-             * has been completed. For this, see OFSTW.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param entity[in] The entity name.
-             */
-            void ProcessOFST(CodeGenerator* codegen, const std::string& entity);
-    };
+        /**
+         * Processes an OFST opcode.
+         *
+         * Opcode: 0xC3
+         * Short name: OFST
+         * Long name: Offset Object
+         *
+         * Memory layout (8 bytes)
+         * |0xC3|B1/B2|B3/B4|T|X|Y|Z|S|
+         *
+         * Arguments:
+         * - const Bit[4] B1: Bank to retrieve X offset, or zero if X is
+         * specified as a literal.
+         * - const Bit[4] B2: Bank to retrieve Y offset, or zero if Y is
+         * specified as a literal.
+         * - const Bit[4] B3: Bank to retrieve Z offset, or zero if Z is
+         * specified as a literal.
+         * - const Bit[4] B4: Bank to retrieve speed, or zero if S is
+         * specified as a literal.
+         * - const UByte T: Type of movement.
+         * - const Short X: X offset amount, relative to current position, or
+         * address to find X offset, if B1 is non-zero.
+         * - const Short Y: Y offset amount, relative to current position, or
+         * address to find Y offset, if B2 is non-zero.
+         * - const Short Z: Z offset amount, relative to current position, or
+         * address to find Z offset, if B3 is non-zero.
+         * - const UShort S: Speed of the offset movement, if type is
+         * non-zero, or address to find speed, if B4 is non-zero.
+         *
+         * Offsets the field object, belonging to the entity whose script this
+         * opcode resides in, by a certain amount. After being offset, the
+         * character continues to be constrained in movement as defined by the
+         * walkmesh's shape, but at a certain distance away from the normal
+         * walkmesh position. Other field objects are unaffected, and their
+         * position or movements are maintained on the walkmesh's original
+         * position. If B1, B2, B3 or B4 is non-zero, then the value for that
+         * particular component is taken from memory using the corresponding
+         * bank and address specified, rather than as a literal value. Both
+         * retrieved values and literals can be used for different components.
+         * If using T, X, Y or S as addresses, the lower byte should hold the
+         * address whilst the higher byte should be zero. The amount to offset
+         * is specified relative to the current position. If Type is
+         * specified, the object moves gradually from its current point to the
+         * offset position; this can be used to simulate movements such as
+         * elevators. Any type outside the range in the table will cause the
+         * offset not to occur. If the object is set to move gradually, then
+         * the speed of offset can be set; the greater the number, the slower
+         * the object moves to its target offset. Script execution may also be
+         * halted until the gradual offset has been completed. For this, see
+         * OFSTW.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param entity[in] The entity name.
+         */
+        void ProcessOFST(CodeGenerator* codegen, const std::string& entity);
+};
 
 
-}

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -21,105 +21,98 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A module instruction.
-     */
-    class FieldModuleInstruction : public KernelCallInstruction{
-
-        public:
+/**
+ * A module instruction.
+ */
+class FieldModuleInstruction : public KernelCallInstruction{
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+    public:
 
 
-        private:
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
 
 
-            /**
-             * Processes a BATTLE opcode.
-             *
-             * Opcode: 0x70
-             * Short name: BATTLE
-             * Long name: Start battle
-             *
-             * Memory layout (4 bytes)
-             * |0x70|B|N|N|
-             *
-             * Arguments
-             * - const UByte B: Bank (16-bit) to retrieve the address of the
-             * battle ID, or zero if it is given as a literal value.
-             * - const UWord N: Battle ID, or address to find ID if B is
-             * non-zero.
-             *
-             * This launches the battle module with whatever battle number is
-             * used in the argument, or the value retrieved from memory
-             * location N if B is non-zero. Battle 1, 2, and 999 (0x03E7) are
-             * debug battles.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessBATTLE(CodeGenerator* code_gen);
+    private:
 
 
-            /**
-             * Processes a BTLON opcode.
-             *
-             * Opcode: 0x71
-             * Short name: BTLON
-             * Long name: Battle switch
-             *
-             * Memory layout (2 bytes)
-             * |0x71|S|
-             *
-             * Arguments
-             * - const UByte S: Switch battles on/off (0/1, respectively).
-             *
-             * Turns random encounters on or off for this field. Note that if
-             * a field does not have any Encounter Data set in its field file,
-             * battles will not occur regardless of the argument passed with
-             * this opcode.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            void ProcessBTLON(CodeGenerator* code_gen);
+        /**
+         * Processes a BATTLE opcode.
+         *
+         * Opcode: 0x70
+         * Short name: BATTLE
+         * Long name: Start battle
+         *
+         * Memory layout (4 bytes)
+         * |0x70|B|N|N|
+         *
+         * Arguments
+         * - const UByte B: Bank (16-bit) to retrieve the address of the
+         * battle ID, or zero if it is given as a literal value.
+         * - const UWord N: Battle ID, or address to find ID if B is non-zero.
+         *
+         * This launches the battle module with whatever battle number is used
+         * in the argument, or the value retrieved from memory location N if B
+         * is non-zero. Battle 1, 2, and 999 (0x03E7) are debug battles.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessBATTLE(CodeGenerator* code_gen);
 
 
-            /**
-             * Processes a MAPJUMP opcode.
-             *
-             * Opcode: 0x60
-             * Short name: BTLON
-             * Long name: Change Field
-             *
-             * Memory layout
-             * |0x60|I|I|X|X|Y|Y|Z|Z|D|
-             *
-             * Arguments
-             * - const UShort I: Field ID of the map to jump to.
-             * - const Short X: X-coordinate of the player on the next field.
-             * - const Short Y: Y-coordinate of the player on the next field.
-             * - const Short Z: Z-coordinate of the player on the next field.
-             * - const UByte D: Direction the character will be facing on the
-             * next field, in the standard game format.
-             *
-             * Switches fields to the one indicated by I, and places the
-             * character at the coordinates and direction specified. This is
-             * an alternative to using a gateway, and can complement their
-             * usage as it allows for more than 12 gateways by simulating
-             * their behavior through a LINE which, when crossed, executes a
-             * MAPJUMP.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param func[in] Function to get the spawn point from.
-             */
-            void ProcessMAPJUMP(CodeGenerator* code_gen, Function& func);
-    };
+        /**
+         * Processes a BTLON opcode.
+         *
+         * Opcode: 0x71
+         * Short name: BTLON
+         * Long name: Battle switch
+         *
+         * Memory layout (2 bytes)
+         * |0x71|S|
+         *
+         * Arguments
+         * - const UByte S: Switch battles on/off (0/1, respectively).
+         *
+         * Turns random encounters on or off for this field. Note that if a
+         * field does not have any Encounter Data set in its field file,
+         * battles will not occur regardless of the argument passed with this
+         * opcode.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        void ProcessBTLON(CodeGenerator* code_gen);
 
 
-}
+        /**
+         * Processes a MAPJUMP opcode.
+         *
+         * Opcode: 0x60
+         * Short name: BTLON
+         * Long name: Change Field
+         *
+         * Memory layout
+         * |0x60|I|I|X|X|Y|Y|Z|Z|D|
+         *
+         * Arguments
+         * - const UShort I: Field ID of the map to jump to.
+         * - const Short X: X-coordinate of the player on the next field.
+         * - const Short Y: Y-coordinate of the player on the next field.
+         * - const Short Z: Z-coordinate of the player on the next field.
+         * - const UByte D: Direction the character will be facing on the next
+         * field, in the standard game format.
+         *
+         * Switches fields to the one indicated by I, and places the character
+         * at the coordinates and direction specified. This is an alternative
+         * to using a gateway, and can complement their usage as it allows for
+         * more than 12 gateways by simulating their behavior through a LINE
+         * which, when crossed, executes a MAPJUMP.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param func[in] Function to get the spawn point from.
+         */
+        void ProcessMAPJUMP(CodeGenerator* code_gen, Function& func);
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,35 +20,31 @@
 #include "decompiler/instruction/Instruction.h"
 #include "decompiler/instruction/Instruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * An instruction that does nothing.
-     */
-    class FieldNoOperationInstruction : public Instruction{
-
-        public:
-
-            /**
-             * Generates a instruction that does nothing.
-             *
-             * @return The generated instruction.
-             */
-            static InstPtr Create(){return new FieldNoOperationInstruction();}
-
-            /**
-             * Processes the instruction.
-             *
-             * It doesn't do anything.
-             *
-             * @param func[in] Function to process. Unused.
-             * @param stack[out] Function stack. Unused.
-             * @param engine[in] Engine. Unused.
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-    };
-
-}
+/**
+ * An instruction that does nothing.
+ */
+class FieldNoOperationInstruction : public Instruction{
+
+    public:
+
+        /**
+         * Generates a instruction that does nothing.
+         *
+         * @return The generated instruction.
+         */
+        static InstPtr Create(){return new FieldNoOperationInstruction();}
+
+        /**
+         * Processes the instruction.
+         *
+         * It doesn't do anything.
+         *
+         * @param func[in] Function to process. Unused.
+         * @param stack[out] Function stack. Unused.
+         * @param engine[in] Engine. Unused.
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,31 +20,28 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A party instruction
-     */
-    class FieldPartyInstruction : public KernelCallInstruction{
+/**
+ * A party instruction
+ */
+class FieldPartyInstruction : public KernelCallInstruction{
 
 
-        public:
+    public:
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] The engine. Unused
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] The engine. Unused
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
 
 
-        private:
+    private:
 
 
-            void ProcessSTITM(CodeGenerator* code_gen);
-            void ProcessPRTYE(CodeGenerator* code_gen);
-    };
+        void ProcessSTITM(CodeGenerator* code_gen);
 
 
-}
+        void ProcessPRTYE(CodeGenerator* code_gen);
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,26 +20,22 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * An instructions that doesn't fall in any other category.
-     */
-    class FieldUncategorizedInstruction : public KernelCallInstruction{
-
-        public:
+/**
+ * An instructions that doesn't fall in any other category.
+ */
+class FieldUncategorizedInstruction : public KernelCallInstruction{
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-    };
+    public:
 
 
-}
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,68 +20,65 @@
 
 
 #include "decompiler/instruction/UncondJumpInstruction.h"
 #include "decompiler/instruction/UncondJumpInstruction.h"
 
 
-namespace FF7{
-
-    /**
-     * An unconditional map jump instruction.
-     */
-    class FieldUncondJumpInstruction : public UncondJumpInstruction{
+/**
+ * An unconditional map jump instruction.
+ */
+class FieldUncondJumpInstruction : public UncondJumpInstruction{
 
 
-        public:
+    public:
 
 
-            /**
-             * Constructor.
-             */
-            FieldUncondJumpInstruction();
+        /**
+         * Constructor.
+         */
+        FieldUncondJumpInstruction();
 
 
-            /**
-             * Indicates if the instruction is a function call.
-             *
-             * @return true if the instruction is a function call, false if not.
-             */
-            virtual bool IsFuncCall() const;
+        /**
+         * Indicates if the instruction is a function call.
+         *
+         * @return true if the instruction is a function call, false if not.
+         */
+        virtual bool IsFuncCall() const;
 
 
-            /**
-             * Indicates if the instruction is an unconditional jump.
-             *
-             * @return true if the instruction is an unconditional jump, false
-             * if it's not.
-             */
-            virtual bool IsUncondJump() const;
+        /**
+         * Indicates if the instruction is an unconditional jump.
+         *
+         * @return true if the instruction is an unconditional jump, false if
+         * it's not.
+         */
+        virtual bool IsUncondJump() const;
 
 
-            /**
-             * Retrieves the destination address of the jump.
-             *
-             * @return The offset (number of bytes) to jump from the beginning
-             * of the instruction.
-             */
-            virtual uint32 GetDestAddress() const;
+        /**
+         * Retrieves the destination address of the jump.
+         *
+         * @return The offset (number of bytes) to jump from the beginning of
+         * the instruction.
+         */
+        virtual uint32 GetDestAddress() const;
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack. Unused.
-             * @param engine[in] The engine. Unused
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack. Unused.
+         * @param engine[in] The engine. Unused
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
 
 
-            /**
-             * Prints the instruction
-             *
-             * @param[in] output The stream to print the instruction to.
-             * @return The same output.
-             */
-            virtual std::ostream& Print(std::ostream &output) const override;
+        /**
+         * Prints the instruction
+         *
+         * @param[in] output The stream to print the instruction to.
+         * @return The same output.
+         */
+        virtual std::ostream& Print(std::ostream &output) const override;
 
 
-        private:
+    private:
 
 
-            /**
-             * Whether or not this is really a call to a script function.
-             */
-            bool is_func_call_;
-    };
-}
+        /**
+         * Whether or not this is really a call to a script function.
+         */
+        bool is_func_call_;
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,68 +20,63 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A walkmesh instruction.
-     */
-    class FieldWalkmeshInstruction : public KernelCallInstruction{
-
-        public:
+/**
+ * A walkmesh instruction.
+ */
+class FieldWalkmeshInstruction : public KernelCallInstruction{
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+    public:
 
 
-        private:
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
 
 
-            void ProcessUC(CodeGenerator* code_gen);
+    private:
 
 
-            /**
-             * Processes a LINE opcode.
-             *
-             * Opcode: 0xD0
-             * Short name: LINE
-             * Long name: Line definition
-             *
-             * Memory layout (7 bytes)
-             * |0xD0|XA|YA|ZA|XB|YB|ZB|
-             *
-             * Arguments:
-             * - const Short XA: X-coordinate of the first point of the line.
-             * - const Short YA: Y-coordinate of the first point of the line.
-             * - const Short ZA: Z-coordinate of the first point of the line.
-             * - const Short XB: X-coordinate of the second point of the line.
-             * - const Short YB: Y-coordinate of the second point of the line.
-             * - const Short ZB: Z-coordinate of the second point of the line.
-             *
-             * Defines a line on the walkmesh that, when crossed by a playable
-             * character, causes one of the entity's scripts to be executed.
-             * These are similar to the triggers in Section 8. All the lines
-             * in the current field can be turned on or off by using the LINON
-             * opcode.
-             *
-             * There are generally 6 scripts (other than the init and main) if
-             * the entity is a LINE.
-             * - script index 2 -> S1 - [OK].
-             * - script index 3 -> S2 - Move.
-             * - script index 4 -> S3 - Move.
-             * - script index 5 -> S4 - Go.
-             * - script index 6 -> S5 - Go 1x.
-             * - script index 7 -> S6 - Go away.
-             *
-             * @param codegen[in|out] Code generator to append lines.
-             * @param entity[in] The entity name.
-             */
-            void ProcessLINE(CodeGenerator* code_gen, const std::string& entity);
-    };
+        void ProcessUC(CodeGenerator* code_gen);
 
 
-}
+        /**
+         * Processes a LINE opcode.
+         *
+         * Opcode: 0xD0
+         * Short name: LINE
+         * Long name: Line definition
+         *
+         * Memory layout (7 bytes)
+         * |0xD0|XA|YA|ZA|XB|YB|ZB|
+         *
+         * Arguments:
+         * - const Short XA: X-coordinate of the first point of the line.
+         * - const Short YA: Y-coordinate of the first point of the line.
+         * - const Short ZA: Z-coordinate of the first point of the line.
+         * - const Short XB: X-coordinate of the second point of the line.
+         * - const Short YB: Y-coordinate of the second point of the line.
+         * - const Short ZB: Z-coordinate of the second point of the line.
+         *
+         * Defines a line on the walkmesh that, when crossed by a playable
+         * character, causes one of the entity's scripts to be executed. These
+         * are similar to the triggers in Section 8. All the lines in the
+         * current field can be turned on or off by using the LINON opcode.
+         *
+         * There are generally 6 scripts (other than the init and main) if the
+         * entity is a LINE.
+         * - script index 2 -> S1 - [OK].
+         * - script index 3 -> S2 - Move.
+         * - script index 4 -> S3 - Move.
+         * - script index 5 -> S4 - Go.
+         * - script index 6 -> S5 - Go 1x.
+         * - script index 7 -> S6 - Go away.
+         *
+         * @param codegen[in|out] Code generator to append lines.
+         * @param entity[in] The entity name.
+         */
+        void ProcessLINE(CodeGenerator* code_gen, const std::string& entity);
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,34 +20,34 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A window instruction.
-     */
-    class FieldWindowInstruction : public KernelCallInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process.
-             * @param stack[out] Function stack. Unused.
-             * @param engine[in] Engine.
-             * @param codegen[in|out] Code generator to append lines.
-             */
-            virtual void ProcessInst(
-              Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-        private:
-
-            void ProcessMESSAGE(CodeGenerator* code_gen, const std::string& script_name);
-            void ProcessMPNAM(CodeGenerator* code_gen);
-            void ProcessMENU2(CodeGenerator* code_gen);
-            void ProcessWINDOW(CodeGenerator* code_gen);
-            void ProcessWCLSE(CodeGenerator* code_gen);
-    };
-
-}
+/**
+ * A window instruction.
+ */
+class FieldWindowInstruction : public KernelCallInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process.
+         * @param stack[out] Function stack. Unused.
+         * @param engine[in] Engine.
+         * @param codegen[in|out] Code generator to append lines.
+         */
+        virtual void ProcessInst(
+          Function& func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+    private:
+
+        void ProcessMESSAGE(CodeGenerator* code_gen, const std::string& script_name);
+
+        void ProcessMPNAM(CodeGenerator* code_gen);
+
+        void ProcessMENU2(CodeGenerator* code_gen);
+
+        void ProcessWINDOW(CodeGenerator* code_gen);
+
+        void ProcessWCLSE(CodeGenerator* code_gen);
+};

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

@@ -11,7 +11,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

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

@@ -11,7 +11,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

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

@@ -11,7 +11,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

+ 1 - 1
V-Gears-Installer/include/decompiler/test/disassembler/pasc.h

@@ -11,7 +11,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

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

@@ -11,7 +11,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

+ 1 - 1
V-Gears-Installer/include/decompiler/test/disassembler/subopcode.h

@@ -11,7 +11,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

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

@@ -11,7 +11,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License

+ 71 - 71
V-Gears-Installer/include/decompiler/test/ff7_field_all_opcodes_disassembler_test.cpp

@@ -13,7 +13,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 {
 {
     InstVec insts;
     InstVec insts;
     DummyFormatter formatter;
     DummyFormatter formatter;
-    FF7::FieldEngine engine(formatter);
+    FieldEngine engine(formatter);
 
 
     auto d = engine.GetDisassembler(insts);
     auto d = engine.GetDisassembler(insts);
     d->open("decompiler/test/ff7_all_opcodes.dat");
     d->open("decompiler/test/ff7_all_opcodes.dat");
@@ -22,50 +22,50 @@ TEST(FF7Field, AllOpcodesDisassembler)
     std::cout << std::endl;
     std::cout << std::endl;
 
 
 
 
-    ASSERT_EQ(insts[0]->_opcode, FF7::eOpcodes::RET);
+    ASSERT_EQ(insts[0]->_opcode, eOpcodes::RET);
     ASSERT_EQ(insts[0]->_params.size(), 0);
     ASSERT_EQ(insts[0]->_params.size(), 0);
 
 
-	ASSERT_EQ(insts[1]->_opcode, FF7::eOpcodes::REQ);
+	ASSERT_EQ(insts[1]->_opcode, eOpcodes::REQ);
 	ASSERT_EQ(insts[1]->_params.size(), 3);
 	ASSERT_EQ(insts[1]->_params.size(), 3);
 	ASSERT_EQ(insts[1]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[1]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[1]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[1]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[1]->_params[2]->getSigned(), 1);
 	ASSERT_EQ(insts[1]->_params[2]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[2]->_opcode, FF7::eOpcodes::REQSW);
+	ASSERT_EQ(insts[2]->_opcode, eOpcodes::REQSW);
 	ASSERT_EQ(insts[2]->_params.size(), 3);
 	ASSERT_EQ(insts[2]->_params.size(), 3);
 	ASSERT_EQ(insts[2]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[2]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[2]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[2]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[2]->_params[2]->getSigned(), 1);
 	ASSERT_EQ(insts[2]->_params[2]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[3]->_opcode, FF7::eOpcodes::REQEW);
+	ASSERT_EQ(insts[3]->_opcode, eOpcodes::REQEW);
 	ASSERT_EQ(insts[3]->_params.size(), 3);
 	ASSERT_EQ(insts[3]->_params.size(), 3);
 	ASSERT_EQ(insts[3]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[3]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[3]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[3]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[3]->_params[2]->getSigned(), 1);
 	ASSERT_EQ(insts[3]->_params[2]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[4]->_opcode, FF7::eOpcodes::PREQ);
+	ASSERT_EQ(insts[4]->_opcode, eOpcodes::PREQ);
 	ASSERT_EQ(insts[4]->_params.size(), 3);
 	ASSERT_EQ(insts[4]->_params.size(), 3);
 	ASSERT_EQ(insts[4]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[4]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[4]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[4]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[4]->_params[2]->getSigned(), 1);
 	ASSERT_EQ(insts[4]->_params[2]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[5]->_opcode, FF7::eOpcodes::PREQSW);
+	ASSERT_EQ(insts[5]->_opcode, eOpcodes::PREQSW);
 	ASSERT_EQ(insts[5]->_params.size(), 3);
 	ASSERT_EQ(insts[5]->_params.size(), 3);
 	ASSERT_EQ(insts[5]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[5]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[5]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[5]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[5]->_params[2]->getSigned(), 1);
 	ASSERT_EQ(insts[5]->_params[2]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[6]->_opcode, FF7::eOpcodes::PREQEW);
+	ASSERT_EQ(insts[6]->_opcode, eOpcodes::PREQEW);
 	ASSERT_EQ(insts[6]->_params.size(), 3);
 	ASSERT_EQ(insts[6]->_params.size(), 3);
 	ASSERT_EQ(insts[6]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[6]->_params[0]->getSigned(), 0);
 	ASSERT_EQ(insts[6]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[6]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[6]->_params[2]->getSigned(), 1);
 	ASSERT_EQ(insts[6]->_params[2]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[7]->_opcode, FF7::eOpcodes::JOIN);
+	ASSERT_EQ(insts[7]->_opcode, eOpcodes::JOIN);
 	ASSERT_EQ(insts[7]->_params.size(), 1);
 	ASSERT_EQ(insts[7]->_params.size(), 1);
 	ASSERT_EQ(insts[7]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[7]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[8]->_opcode, FF7::eOpcodes::SPLIT);
+	ASSERT_EQ(insts[8]->_opcode, eOpcodes::SPLIT);
 	ASSERT_EQ(insts[8]->_params.size(), 13);
 	ASSERT_EQ(insts[8]->_params.size(), 13);
 	ASSERT_EQ(insts[8]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[8]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[8]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[8]->_params[1]->getSigned(), 2);
@@ -81,7 +81,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[8]->_params[11]->getSigned(), 12);
 	ASSERT_EQ(insts[8]->_params[11]->getSigned(), 12);
 	ASSERT_EQ(insts[8]->_params[12]->getSigned(), 13);
 	ASSERT_EQ(insts[8]->_params[12]->getSigned(), 13);
 
 
-	ASSERT_EQ(insts[9]->_opcode, FF7::eOpcodes::SPTYE);
+	ASSERT_EQ(insts[9]->_opcode, eOpcodes::SPTYE);
 	ASSERT_EQ(insts[9]->_params.size(), 7);
 	ASSERT_EQ(insts[9]->_params.size(), 7);
 	ASSERT_EQ(insts[9]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[9]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[9]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[9]->_params[1]->getSigned(), 2);
@@ -91,7 +91,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[9]->_params[5]->getSigned(), 6);
 	ASSERT_EQ(insts[9]->_params[5]->getSigned(), 6);
 	ASSERT_EQ(insts[9]->_params[6]->getSigned(), 7);
 	ASSERT_EQ(insts[9]->_params[6]->getSigned(), 7);
 
 
-	ASSERT_EQ(insts[10]->_opcode, FF7::eOpcodes::GTPYE);
+	ASSERT_EQ(insts[10]->_opcode, eOpcodes::GTPYE);
 	ASSERT_EQ(insts[10]->_params.size(), 7);
 	ASSERT_EQ(insts[10]->_params.size(), 7);
 	ASSERT_EQ(insts[10]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[10]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[10]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[10]->_params[1]->getSigned(), 2);
@@ -101,66 +101,66 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[10]->_params[5]->getSigned(), 6);
 	ASSERT_EQ(insts[10]->_params[5]->getSigned(), 6);
 	ASSERT_EQ(insts[10]->_params[6]->getSigned(), 7);
 	ASSERT_EQ(insts[10]->_params[6]->getSigned(), 7);
 
 
-	ASSERT_EQ(insts[11]->_opcode, FF7::eOpcodes::DSKCG);
+	ASSERT_EQ(insts[11]->_opcode, eOpcodes::DSKCG);
 	ASSERT_EQ(insts[11]->_params.size(), 1);
 	ASSERT_EQ(insts[11]->_params.size(), 1);
 	ASSERT_EQ(insts[11]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[11]->_params[0]->getSigned(), 1);
 
 
 	
 	
-	ASSERT_EQ(insts[12]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::ARROW));
+	ASSERT_EQ(insts[12]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::ARROW));
 	ASSERT_EQ(insts[12]->_params.size(), 1);
 	ASSERT_EQ(insts[12]->_params.size(), 1);
 	ASSERT_EQ(insts[12]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[12]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[13]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::PNAME));
+	ASSERT_EQ(insts[13]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::PNAME));
 	ASSERT_EQ(insts[13]->_params.size(), 1);
 	ASSERT_EQ(insts[13]->_params.size(), 1);
 	ASSERT_EQ(insts[13]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[13]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[14]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::GMSPD));
+	ASSERT_EQ(insts[14]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::GMSPD));
 	ASSERT_EQ(insts[14]->_params.size(), 1);
 	ASSERT_EQ(insts[14]->_params.size(), 1);
 	ASSERT_EQ(insts[14]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[14]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[15]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::SMSPD));
+	ASSERT_EQ(insts[15]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::SMSPD));
 	ASSERT_EQ(insts[15]->_params.size(), 2);
 	ASSERT_EQ(insts[15]->_params.size(), 2);
 	ASSERT_EQ(insts[15]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[15]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[15]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[15]->_params[1]->getSigned(), 2);
 
 
-	ASSERT_EQ(insts[16]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::FLMAT));
+	ASSERT_EQ(insts[16]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::FLMAT));
 	ASSERT_EQ(insts[16]->_params.size(), 0);
 	ASSERT_EQ(insts[16]->_params.size(), 0);
 
 
-	ASSERT_EQ(insts[17]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::FLITM));
+	ASSERT_EQ(insts[17]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::FLITM));
 	ASSERT_EQ(insts[17]->_params.size(), 0);
 	ASSERT_EQ(insts[17]->_params.size(), 0);
 
 
-	ASSERT_EQ(insts[18]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::BTLCK));
+	ASSERT_EQ(insts[18]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::BTLCK));
 	ASSERT_EQ(insts[18]->_params.size(), 1);
 	ASSERT_EQ(insts[18]->_params.size(), 1);
 	ASSERT_EQ(insts[18]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[18]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[19]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::MVLCK));
+	ASSERT_EQ(insts[19]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::MVLCK));
 	ASSERT_EQ(insts[19]->_params.size(), 1);
 	ASSERT_EQ(insts[19]->_params.size(), 1);
 	ASSERT_EQ(insts[19]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[19]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[20]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::SPCNM));
+	ASSERT_EQ(insts[20]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::SPCNM));
 	ASSERT_EQ(insts[20]->_params.size(), 2);
 	ASSERT_EQ(insts[20]->_params.size(), 2);
 	ASSERT_EQ(insts[20]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[20]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[20]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[20]->_params[1]->getSigned(), 2);
 
 
-	ASSERT_EQ(insts[21]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::RSGLB));
+	ASSERT_EQ(insts[21]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::RSGLB));
 	ASSERT_EQ(insts[21]->_params.size(), 0);
 	ASSERT_EQ(insts[21]->_params.size(), 0);
 
 
-	ASSERT_EQ(insts[22]->_opcode, MAKE_SUBOPCODE(FF7::eOpcodes::SPECIAL, FF7::eSpecialOpcodes::CLITM));
+	ASSERT_EQ(insts[22]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::CLITM));
 	ASSERT_EQ(insts[22]->_params.size(), 0);
 	ASSERT_EQ(insts[22]->_params.size(), 0);
 
 
-	ASSERT_EQ(insts[23]->_opcode, FF7::eOpcodes::JMPF);
+	ASSERT_EQ(insts[23]->_opcode, eOpcodes::JMPF);
 	ASSERT_EQ(insts[23]->_params.size(), 1);
 	ASSERT_EQ(insts[23]->_params.size(), 1);
 
 
-	ASSERT_EQ(insts[24]->_opcode, FF7::eOpcodes::JMPFL);
+	ASSERT_EQ(insts[24]->_opcode, eOpcodes::JMPFL);
 	ASSERT_EQ(insts[24]->_params.size(), 1);
 	ASSERT_EQ(insts[24]->_params.size(), 1);
 
 
-	ASSERT_EQ(insts[25]->_opcode, FF7::eOpcodes::JMPB);
+	ASSERT_EQ(insts[25]->_opcode, eOpcodes::JMPB);
 	ASSERT_EQ(insts[25]->_params.size(), 1);
 	ASSERT_EQ(insts[25]->_params.size(), 1);
 
 
-	ASSERT_EQ(insts[26]->_opcode, FF7::eOpcodes::JMPBL);
+	ASSERT_EQ(insts[26]->_opcode, eOpcodes::JMPBL);
 	ASSERT_EQ(insts[26]->_params.size(), 1);
 	ASSERT_EQ(insts[26]->_params.size(), 1);
 
 
-	ASSERT_EQ(insts[27]->_opcode, FF7::eOpcodes::IFUB);
+	ASSERT_EQ(insts[27]->_opcode, eOpcodes::IFUB);
 	ASSERT_EQ(insts[27]->_params.size(), 6);
 	ASSERT_EQ(insts[27]->_params.size(), 6);
 	ASSERT_EQ(insts[27]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[27]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[27]->_params[1]->getSigned(), 3);
 	ASSERT_EQ(insts[27]->_params[1]->getSigned(), 3);
@@ -169,7 +169,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[27]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[27]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[27]->_params[5]->getSigned(), 1);
 	ASSERT_EQ(insts[27]->_params[5]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[28]->_opcode, FF7::eOpcodes::IFUBL);
+	ASSERT_EQ(insts[28]->_opcode, eOpcodes::IFUBL);
 	ASSERT_EQ(insts[28]->_params.size(), 6);
 	ASSERT_EQ(insts[28]->_params.size(), 6);
 	ASSERT_EQ(insts[28]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[28]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[28]->_params[1]->getSigned(), 3);
 	ASSERT_EQ(insts[28]->_params[1]->getSigned(), 3);
@@ -178,7 +178,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[28]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[28]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[28]->_params[5]->getSigned(), 2); // For some reason this one has to be 2
 	ASSERT_EQ(insts[28]->_params[5]->getSigned(), 2); // For some reason this one has to be 2
 
 
-	ASSERT_EQ(insts[29]->_opcode, FF7::eOpcodes::IFSW);
+	ASSERT_EQ(insts[29]->_opcode, eOpcodes::IFSW);
 	ASSERT_EQ(insts[29]->_params.size(), 6);
 	ASSERT_EQ(insts[29]->_params.size(), 6);
 	ASSERT_EQ(insts[29]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[29]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[29]->_params[1]->getSigned(), 3);
 	ASSERT_EQ(insts[29]->_params[1]->getSigned(), 3);
@@ -187,7 +187,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[29]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[29]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[29]->_params[5]->getSigned(), 1);
 	ASSERT_EQ(insts[29]->_params[5]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[30]->_opcode, FF7::eOpcodes::IFSWL);
+	ASSERT_EQ(insts[30]->_opcode, eOpcodes::IFSWL);
 	ASSERT_EQ(insts[30]->_params.size(), 6);
 	ASSERT_EQ(insts[30]->_params.size(), 6);
 	ASSERT_EQ(insts[30]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[30]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[30]->_params[1]->getSigned(), 3);
 	ASSERT_EQ(insts[30]->_params[1]->getSigned(), 3);
@@ -196,7 +196,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[30]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[30]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[30]->_params[5]->getSigned(), 2); // For some reason this one has to be 2
 	ASSERT_EQ(insts[30]->_params[5]->getSigned(), 2); // For some reason this one has to be 2
 
 
-	ASSERT_EQ(insts[31]->_opcode, FF7::eOpcodes::IFUW);
+	ASSERT_EQ(insts[31]->_opcode, eOpcodes::IFUW);
 	ASSERT_EQ(insts[31]->_params.size(), 6);
 	ASSERT_EQ(insts[31]->_params.size(), 6);
 	ASSERT_EQ(insts[31]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[31]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[31]->_params[1]->getSigned(), 3);
 	ASSERT_EQ(insts[31]->_params[1]->getSigned(), 3);
@@ -205,7 +205,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[31]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[31]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[31]->_params[5]->getSigned(), 1);
 	ASSERT_EQ(insts[31]->_params[5]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[32]->_opcode, FF7::eOpcodes::IFUWL);
+	ASSERT_EQ(insts[32]->_opcode, eOpcodes::IFUWL);
 	ASSERT_EQ(insts[32]->_params.size(), 6);
 	ASSERT_EQ(insts[32]->_params.size(), 6);
 	ASSERT_EQ(insts[32]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[32]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[32]->_params[1]->getSigned(), 3);
 	ASSERT_EQ(insts[32]->_params[1]->getSigned(), 3);
@@ -214,7 +214,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[32]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[32]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[32]->_params[5]->getSigned(), 2); // For some reason this one has to be 2
 	ASSERT_EQ(insts[32]->_params[5]->getSigned(), 2); // For some reason this one has to be 2
 
 
-	ASSERT_EQ(insts[33]->_opcode, FF7::eOpcodes::MINIGAME);
+	ASSERT_EQ(insts[33]->_opcode, eOpcodes::MINIGAME);
 	ASSERT_EQ(insts[33]->_params.size(), 6);
 	ASSERT_EQ(insts[33]->_params.size(), 6);
 	ASSERT_EQ(insts[33]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[33]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[33]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[33]->_params[1]->getSigned(), 2);
@@ -223,54 +223,54 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[33]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[33]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[33]->_params[5]->getSigned(), 6);
 	ASSERT_EQ(insts[33]->_params[5]->getSigned(), 6);
 
 
-	ASSERT_EQ(insts[34]->_opcode, FF7::eOpcodes::TUTOR);
+	ASSERT_EQ(insts[34]->_opcode, eOpcodes::TUTOR);
 	ASSERT_EQ(insts[34]->_params.size(), 1);
 	ASSERT_EQ(insts[34]->_params.size(), 1);
 	ASSERT_EQ(insts[34]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[34]->_params[0]->getSigned(), 1);
 
 
 	// BATTLE MODE STATES START
 	// BATTLE MODE STATES START
 
 
-	ASSERT_EQ(insts[35]->_opcode, FF7::eOpcodes::BTMD2);
+	ASSERT_EQ(insts[35]->_opcode, eOpcodes::BTMD2);
 	ASSERT_EQ(insts[35]->_params.size(), 4);
 	ASSERT_EQ(insts[35]->_params.size(), 4);
 	ASSERT_EQ(insts[35]->_params[0]->getSigned(), 0x80);
 	ASSERT_EQ(insts[35]->_params[0]->getSigned(), 0x80);
 
 
-	ASSERT_EQ(insts[36]->_opcode, FF7::eOpcodes::BTMD2);
+	ASSERT_EQ(insts[36]->_opcode, eOpcodes::BTMD2);
 	ASSERT_EQ(insts[36]->_params.size(), 4);
 	ASSERT_EQ(insts[36]->_params.size(), 4);
 	ASSERT_EQ(insts[36]->_params[0]->getSigned(), 0x40);
 	ASSERT_EQ(insts[36]->_params[0]->getSigned(), 0x40);
 
 
-	ASSERT_EQ(insts[37]->_opcode, FF7::eOpcodes::BTMD2);
+	ASSERT_EQ(insts[37]->_opcode, eOpcodes::BTMD2);
 	ASSERT_EQ(insts[37]->_params.size(), 4);
 	ASSERT_EQ(insts[37]->_params.size(), 4);
 	ASSERT_EQ(insts[37]->_params[0]->getSigned(), 0x20);
 	ASSERT_EQ(insts[37]->_params[0]->getSigned(), 0x20);
 
 
-	ASSERT_EQ(insts[38]->_opcode, FF7::eOpcodes::BTMD2);
+	ASSERT_EQ(insts[38]->_opcode, eOpcodes::BTMD2);
 	ASSERT_EQ(insts[38]->_params.size(), 4);
 	ASSERT_EQ(insts[38]->_params.size(), 4);
 	ASSERT_EQ(insts[38]->_params[0]->getSigned(), 0x10);
 	ASSERT_EQ(insts[38]->_params[0]->getSigned(), 0x10);
 
 
-	ASSERT_EQ(insts[39]->_opcode, FF7::eOpcodes::BTMD2);
+	ASSERT_EQ(insts[39]->_opcode, eOpcodes::BTMD2);
 	ASSERT_EQ(insts[39]->_params.size(), 4);
 	ASSERT_EQ(insts[39]->_params.size(), 4);
 	ASSERT_EQ(insts[39]->_params[0]->getSigned(), 0x08);
 	ASSERT_EQ(insts[39]->_params[0]->getSigned(), 0x08);
 
 
-	ASSERT_EQ(insts[40]->_opcode, FF7::eOpcodes::BTMD2);
+	ASSERT_EQ(insts[40]->_opcode, eOpcodes::BTMD2);
 	ASSERT_EQ(insts[40]->_params.size(), 4);
 	ASSERT_EQ(insts[40]->_params.size(), 4);
 	ASSERT_EQ(insts[40]->_params[0]->getSigned(), 0x04);
 	ASSERT_EQ(insts[40]->_params[0]->getSigned(), 0x04);
 
 
-	ASSERT_EQ(insts[41]->_opcode, FF7::eOpcodes::BTMD2);
+	ASSERT_EQ(insts[41]->_opcode, eOpcodes::BTMD2);
 	ASSERT_EQ(insts[41]->_params.size(), 4);
 	ASSERT_EQ(insts[41]->_params.size(), 4);
 	ASSERT_EQ(insts[41]->_params[0]->getSigned(), 0x02);
 	ASSERT_EQ(insts[41]->_params[0]->getSigned(), 0x02);
 
 
-	//ASSERT_EQ(insts[42]->_opcode, FF7::eOpcodes::BTMD2);
+	//ASSERT_EQ(insts[42]->_opcode, eOpcodes::BTMD2);
 	//ASSERT_EQ(insts[42]->_params.size(), 4);
 	//ASSERT_EQ(insts[42]->_params.size(), 4);
 	//ASSERT_EQ(insts[42]->_params[1]->getSigned(), 0x80);
 	//ASSERT_EQ(insts[42]->_params[1]->getSigned(), 0x80);
 
 
-	ASSERT_EQ(insts[67]->_opcode, FF7::eOpcodes::BTRLD);
+	ASSERT_EQ(insts[67]->_opcode, eOpcodes::BTRLD);
 	ASSERT_EQ(insts[67]->_params.size(), 2);
 	ASSERT_EQ(insts[67]->_params.size(), 2);
 	ASSERT_EQ(insts[67]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[67]->_params[0]->getSigned(), 1);
 	//ASSERT_EQ(insts[67]->_params[0]->getSigned(), 1);
 	//ASSERT_EQ(insts[67]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[68]->_opcode, FF7::eOpcodes::WAIT);
+	ASSERT_EQ(insts[68]->_opcode, eOpcodes::WAIT);
 	ASSERT_EQ(insts[68]->_params.size(), 1);
 	ASSERT_EQ(insts[68]->_params.size(), 1);
 	ASSERT_EQ(insts[68]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[68]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[69]->_opcode, FF7::eOpcodes::NFADE);
+	ASSERT_EQ(insts[69]->_opcode, eOpcodes::NFADE);
 	ASSERT_EQ(insts[69]->_params.size(), 8);
 	ASSERT_EQ(insts[69]->_params.size(), 8);
 	//ASSERT_EQ(insts[69]->_params[0]->getSigned(), 1); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(18)
 	//ASSERT_EQ(insts[69]->_params[0]->getSigned(), 1); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(18)
 	//ASSERT_EQ(insts[69]->_params[1]->getSigned(), 2); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(52)
 	//ASSERT_EQ(insts[69]->_params[1]->getSigned(), 2); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(52)
@@ -281,35 +281,35 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[69]->_params[6]->getSigned(), 7);
 	ASSERT_EQ(insts[69]->_params[6]->getSigned(), 7);
 	ASSERT_EQ(insts[69]->_params[7]->getSigned(), 8);
 	ASSERT_EQ(insts[69]->_params[7]->getSigned(), 8);
 
 
-	ASSERT_EQ(insts[70]->_opcode, FF7::eOpcodes::BLINK);
+	ASSERT_EQ(insts[70]->_opcode, eOpcodes::BLINK);
 	ASSERT_EQ(insts[70]->_params.size(), 1);
 	ASSERT_EQ(insts[70]->_params.size(), 1);
 	ASSERT_EQ(insts[70]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[70]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[71]->_opcode, FF7::eOpcodes::BGMOVIE);
+	ASSERT_EQ(insts[71]->_opcode, eOpcodes::BGMOVIE);
 	ASSERT_EQ(insts[71]->_params.size(), 1);
 	ASSERT_EQ(insts[71]->_params.size(), 1);
 	ASSERT_EQ(insts[71]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[71]->_params[0]->getSigned(), 1);
 
 
 	//KAWAI is normally here
 	//KAWAI is normally here
 
 
-	ASSERT_EQ(insts[72]->_opcode, FF7::eOpcodes::KAWIW);
+	ASSERT_EQ(insts[72]->_opcode, eOpcodes::KAWIW);
 	ASSERT_EQ(insts[72]->_params.size(), 0);
 	ASSERT_EQ(insts[72]->_params.size(), 0);
 
 
-	ASSERT_EQ(insts[73]->_opcode, FF7::eOpcodes::PMOVA);
+	ASSERT_EQ(insts[73]->_opcode, eOpcodes::PMOVA);
 	ASSERT_EQ(insts[73]->_params.size(), 1);
 	ASSERT_EQ(insts[73]->_params.size(), 1);
 	ASSERT_EQ(insts[73]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[73]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[74]->_opcode, FF7::eOpcodes::SLIP);
+	ASSERT_EQ(insts[74]->_opcode, eOpcodes::SLIP);
 	ASSERT_EQ(insts[74]->_params.size(), 1);
 	ASSERT_EQ(insts[74]->_params.size(), 1);
 	ASSERT_EQ(insts[74]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[74]->_params[0]->getSigned(), 1);
 
 
-	ASSERT_EQ(insts[75]->_opcode, FF7::eOpcodes::BGPDH);
+	ASSERT_EQ(insts[75]->_opcode, eOpcodes::BGPDH);
 	ASSERT_EQ(insts[75]->_params.size(), 4);
 	ASSERT_EQ(insts[75]->_params.size(), 4);
 	ASSERT_EQ(insts[75]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[75]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[75]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[75]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[75]->_params[2]->getSigned(), 3);
 	ASSERT_EQ(insts[75]->_params[2]->getSigned(), 3);
 	ASSERT_EQ(insts[75]->_params[3]->getSigned(), 4);
 	ASSERT_EQ(insts[75]->_params[3]->getSigned(), 4);
 
 
-	//ASSERT_EQ(insts[76]->_opcode, FF7::eOpcodes::BGSCR);
+	//ASSERT_EQ(insts[76]->_opcode, eOpcodes::BGSCR);
 	//ASSERT_EQ(insts[76]->_params.size(), 5);
 	//ASSERT_EQ(insts[76]->_params.size(), 5);
 	//ASSERT_EQ(insts[76]->_params[0]->getSigned(), 1);
 	//ASSERT_EQ(insts[76]->_params[0]->getSigned(), 1);
 	//ASSERT_EQ(insts[76]->_params[1]->getSigned(), 2);
 	//ASSERT_EQ(insts[76]->_params[1]->getSigned(), 2);
@@ -317,7 +317,7 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	//ASSERT_EQ(insts[76]->_params[3]->getSigned(), 4);
 	//ASSERT_EQ(insts[76]->_params[3]->getSigned(), 4);
 	//ASSERT_EQ(insts[76]->_params[4]->getSigned(), 5);
 	//ASSERT_EQ(insts[76]->_params[4]->getSigned(), 5);
 
 
-	ASSERT_EQ(insts[78]->_opcode, FF7::eOpcodes::WSIZW);
+	ASSERT_EQ(insts[78]->_opcode, eOpcodes::WSIZW);
 	ASSERT_EQ(insts[78]->_params.size(), 5);
 	ASSERT_EQ(insts[78]->_params.size(), 5);
 	ASSERT_EQ(insts[78]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[78]->_params[0]->getSigned(), 1);
 	ASSERT_EQ(insts[78]->_params[1]->getSigned(), 2);
 	ASSERT_EQ(insts[78]->_params[1]->getSigned(), 2);
@@ -325,52 +325,52 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(insts[78]->_params[3]->getSigned(), 4);
 	ASSERT_EQ(insts[78]->_params[3]->getSigned(), 4);
 	ASSERT_EQ(insts[78]->_params[4]->getSigned(), 5);
 	ASSERT_EQ(insts[78]->_params[4]->getSigned(), 5);
 
 
-	//ASSERT_EQ(insts[79]->_opcode, FF7::eOpcodes::IFKEY); // TODO
+	//ASSERT_EQ(insts[79]->_opcode, eOpcodes::IFKEY); // TODO
 	//ASSERT_EQ(insts[79]->_params.size(), 2);
 	//ASSERT_EQ(insts[79]->_params.size(), 2);
 	//ASSERT_EQ(0x0001, insts[79]->_params[0]->getSigned());
 	//ASSERT_EQ(0x0001, insts[79]->_params[0]->getSigned());
 
 
-	//ASSERT_EQ(insts[80]->_opcode, FF7::eOpcodes::IFKEY); // TODO
+	//ASSERT_EQ(insts[80]->_opcode, eOpcodes::IFKEY); // TODO
 	//ASSERT_EQ(insts[80]->_params.size(), 2);
 	//ASSERT_EQ(insts[80]->_params.size(), 2);
 	//ASSERT_EQ(0x8000, insts[78]->_params[0]->getSigned());
 	//ASSERT_EQ(0x8000, insts[78]->_params[0]->getSigned());
 
 
-	//ASSERT_EQ(insts[81]->_opcode, FF7::eOpcodes::IFKEYON); // TODO
+	//ASSERT_EQ(insts[81]->_opcode, eOpcodes::IFKEYON); // TODO
 	//ASSERT_EQ(insts[81]->_params.size(), 2);
 	//ASSERT_EQ(insts[81]->_params.size(), 2);
 	//ASSERT_EQ(0x0001, insts[81]->_params[0]->getSigned());
 	//ASSERT_EQ(0x0001, insts[81]->_params[0]->getSigned());
 
 
-	//ASSERT_EQ(insts[82]->_opcode, FF7::eOpcodes::IFKEYON); // TODO
+	//ASSERT_EQ(insts[82]->_opcode, eOpcodes::IFKEYON); // TODO
 	//ASSERT_EQ(insts[82]->_params.size(), 2);
 	//ASSERT_EQ(insts[82]->_params.size(), 2);
 	//ASSERT_EQ(0x8000, insts[82]->_params[0]->getSigned());
 	//ASSERT_EQ(0x8000, insts[82]->_params[0]->getSigned());
 
 
-	//ASSERT_EQ(insts[83]->_opcode, FF7::eOpcodes::IFKEYOFF); // TODO
+	//ASSERT_EQ(insts[83]->_opcode, eOpcodes::IFKEYOFF); // TODO
 	//ASSERT_EQ(insts[83]->_params.size(), 2);
 	//ASSERT_EQ(insts[83]->_params.size(), 2);
 	//ASSERT_EQ(0x0001, insts[83]->_params[0]->getSigned());
 	//ASSERT_EQ(0x0001, insts[83]->_params[0]->getSigned());
 
 
-	//ASSERT_EQ(insts[84]->_opcode, FF7::eOpcodes::IFKEYOFF); // TODO
+	//ASSERT_EQ(insts[84]->_opcode, eOpcodes::IFKEYOFF); // TODO
 	//ASSERT_EQ(insts[84]->_params.size(), 2);
 	//ASSERT_EQ(insts[84]->_params.size(), 2);
 	//ASSERT_EQ(0x8000, insts[84]->_params[0]->getSigned());
 	//ASSERT_EQ(0x8000, insts[84]->_params[0]->getSigned());
 
 
-	ASSERT_EQ(insts[85]->_opcode, FF7::eOpcodes::UC);
+	ASSERT_EQ(insts[85]->_opcode, eOpcodes::UC);
 	ASSERT_EQ(1, insts[85]->_params.size());
 	ASSERT_EQ(1, insts[85]->_params.size());
 	ASSERT_EQ(1, insts[85]->_params[0]->getSigned());
 	ASSERT_EQ(1, insts[85]->_params[0]->getSigned());
 
 
-	ASSERT_EQ(insts[86]->_opcode, FF7::eOpcodes::PDIRA);
+	ASSERT_EQ(insts[86]->_opcode, eOpcodes::PDIRA);
 	ASSERT_EQ(1, insts[86]->_params.size());
 	ASSERT_EQ(1, insts[86]->_params.size());
 	ASSERT_EQ(1, insts[86]->_params[0]->getSigned());
 	ASSERT_EQ(1, insts[86]->_params[0]->getSigned());
 
 
-	ASSERT_EQ(insts[87]->_opcode, FF7::eOpcodes::PTURA);
+	ASSERT_EQ(insts[87]->_opcode, eOpcodes::PTURA);
 	ASSERT_EQ(3, insts[87]->_params.size());
 	ASSERT_EQ(3, insts[87]->_params.size());
 	ASSERT_EQ(1, insts[87]->_params[0]->getSigned());
 	ASSERT_EQ(1, insts[87]->_params[0]->getSigned());
 	ASSERT_EQ(2, insts[87]->_params[1]->getSigned());
 	ASSERT_EQ(2, insts[87]->_params[1]->getSigned());
 	ASSERT_EQ(3, insts[87]->_params[2]->getSigned());
 	ASSERT_EQ(3, insts[87]->_params[2]->getSigned());
 
 
-	ASSERT_EQ(insts[88]->_opcode, FF7::eOpcodes::WSPCL);
+	ASSERT_EQ(insts[88]->_opcode, eOpcodes::WSPCL);
 	ASSERT_EQ(4, insts[88]->_params.size());
 	ASSERT_EQ(4, insts[88]->_params.size());
 	ASSERT_EQ(1, insts[88]->_params[0]->getSigned());
 	ASSERT_EQ(1, insts[88]->_params[0]->getSigned());
 	ASSERT_EQ(2, insts[88]->_params[1]->getSigned());
 	ASSERT_EQ(2, insts[88]->_params[1]->getSigned());
 	ASSERT_EQ(3, insts[88]->_params[2]->getSigned());
 	ASSERT_EQ(3, insts[88]->_params[2]->getSigned());
 	ASSERT_EQ(4, insts[88]->_params[3]->getSigned());
 	ASSERT_EQ(4, insts[88]->_params[3]->getSigned());
 
 
-	ASSERT_EQ(insts[89]->_opcode, FF7::eOpcodes::STTIM);
+	ASSERT_EQ(insts[89]->_opcode, eOpcodes::STTIM);
 	ASSERT_EQ(7, insts[89]->_params.size());
 	ASSERT_EQ(7, insts[89]->_params.size());
 	ASSERT_EQ(1, insts[89]->_params[0]->getSigned());
 	ASSERT_EQ(1, insts[89]->_params[0]->getSigned());
 	ASSERT_EQ(2, insts[89]->_params[1]->getSigned());
 	ASSERT_EQ(2, insts[89]->_params[1]->getSigned());
@@ -380,31 +380,31 @@ TEST(FF7Field, AllOpcodesDisassembler)
 	ASSERT_EQ(6, insts[89]->_params[5]->getSigned());
 	ASSERT_EQ(6, insts[89]->_params[5]->getSigned());
 	ASSERT_EQ(7, insts[89]->_params[6]->getSigned());
 	ASSERT_EQ(7, insts[89]->_params[6]->getSigned());
 
 
-    ASSERT_EQ(insts[90]->_opcode, FF7::eOpcodes::GOLDU);
+    ASSERT_EQ(insts[90]->_opcode, eOpcodes::GOLDU);
     ASSERT_EQ(3, insts[90]->_params.size());
     ASSERT_EQ(3, insts[90]->_params.size());
     ASSERT_EQ(0, insts[90]->_params[0]->getSigned());
     ASSERT_EQ(0, insts[90]->_params[0]->getSigned());
     ASSERT_EQ(0, insts[90]->_params[1]->getSigned());
     ASSERT_EQ(0, insts[90]->_params[1]->getSigned());
     ASSERT_EQ(1, insts[90]->_params[2]->getSigned());
     ASSERT_EQ(1, insts[90]->_params[2]->getSigned());
 
 
-    ASSERT_EQ(insts[91]->_opcode, FF7::eOpcodes::GOLDU);
+    ASSERT_EQ(insts[91]->_opcode, eOpcodes::GOLDU);
     ASSERT_EQ(3, insts[91]->_params.size());
     ASSERT_EQ(3, insts[91]->_params.size());
     ASSERT_EQ(1, insts[91]->_params[0]->getSigned());
     ASSERT_EQ(1, insts[91]->_params[0]->getSigned());
     ASSERT_EQ(2, insts[91]->_params[1]->getSigned());
     ASSERT_EQ(2, insts[91]->_params[1]->getSigned());
     ASSERT_EQ(0, insts[91]->_params[2]->getSigned());
     ASSERT_EQ(0, insts[91]->_params[2]->getSigned());
 
 
-    ASSERT_EQ(insts[92]->_opcode, FF7::eOpcodes::GOLDD);
+    ASSERT_EQ(insts[92]->_opcode, eOpcodes::GOLDD);
     ASSERT_EQ(3, insts[92]->_params.size());
     ASSERT_EQ(3, insts[92]->_params.size());
     ASSERT_EQ(0, insts[92]->_params[0]->getSigned());
     ASSERT_EQ(0, insts[92]->_params[0]->getSigned());
     ASSERT_EQ(0, insts[92]->_params[1]->getSigned());
     ASSERT_EQ(0, insts[92]->_params[1]->getSigned());
     ASSERT_EQ(1, insts[92]->_params[2]->getSigned());
     ASSERT_EQ(1, insts[92]->_params[2]->getSigned());
 
 
-    ASSERT_EQ(insts[93]->_opcode, FF7::eOpcodes::GOLDD);
+    ASSERT_EQ(insts[93]->_opcode, eOpcodes::GOLDD);
     ASSERT_EQ(3, insts[93]->_params.size());
     ASSERT_EQ(3, insts[93]->_params.size());
     ASSERT_EQ(1, insts[93]->_params[0]->getSigned());
     ASSERT_EQ(1, insts[93]->_params[0]->getSigned());
     ASSERT_EQ(2, insts[93]->_params[1]->getSigned());
     ASSERT_EQ(2, insts[93]->_params[1]->getSigned());
     ASSERT_EQ(0, insts[93]->_params[2]->getSigned());
     ASSERT_EQ(0, insts[93]->_params[2]->getSigned());
 
 
-    ASSERT_EQ(insts[94]->_opcode, FF7::eOpcodes::CHGLD);
+    ASSERT_EQ(insts[94]->_opcode, eOpcodes::CHGLD);
     ASSERT_EQ(4, insts[94]->_params.size());
     ASSERT_EQ(4, insts[94]->_params.size());
     ASSERT_EQ(1, insts[94]->_params[0]->getSigned());
     ASSERT_EQ(1, insts[94]->_params[0]->getSigned());
     ASSERT_EQ(2, insts[94]->_params[1]->getSigned());
     ASSERT_EQ(2, insts[94]->_params[1]->getSigned());

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

@@ -13,7 +13,7 @@ static uint32 Is3Nops(InstVec& insts, uint32& pos)
     for (int i = 0; i < 3; i++)
     for (int i = 0; i < 3; i++)
     {
     {
         pos++;
         pos++;
-        EXPECT_EQ(insts[pos]->opcode_, FF7::eOpcodes::NOP);
+        EXPECT_EQ(insts[pos]->opcode_, eOpcodes::NOP);
         EXPECT_EQ(insts[pos]->params_.size(), 0);
         EXPECT_EQ(insts[pos]->params_.size(), 0);
     }
     }
     return insts[pos]->_address;
     return insts[pos]->_address;
@@ -22,7 +22,7 @@ static uint32 Is3Nops(InstVec& insts, uint32& pos)
 // Each forward jump type has its own script that starts with the
 // Each forward jump type has its own script that starts with the
 // jump opcode followed by 2 NOP's, the 3rd NOP is the end of the script
 // jump opcode followed by 2 NOP's, the 3rd NOP is the end of the script
 // and should be the target address of the jump.
 // and should be the target address of the jump.
-static void CheckForwardJump(FF7::eOpcodes opCode, size_t paramsSize, InstVec& insts, uint32& pos)
+static void CheckForwardJump(eOpcodes opCode, size_t paramsSize, InstVec& insts, uint32& pos)
 {
 {
     pos++;
     pos++;
     const InstPtr& jumpInst = insts[pos];
     const InstPtr& jumpInst = insts[pos];
@@ -37,7 +37,7 @@ static void CheckForwardJump(FF7::eOpcodes opCode, size_t paramsSize, InstVec& i
 static uint32 IsNop(InstVec& insts, uint32& pos)
 static uint32 IsNop(InstVec& insts, uint32& pos)
 {
 {
     pos++;
     pos++;
-    EXPECT_EQ(insts[pos]->opcode_, FF7::eOpcodes::NOP);
+    EXPECT_EQ(insts[pos]->opcode_, eOpcodes::NOP);
     EXPECT_EQ(insts[pos]->params_.size(), 0);
     EXPECT_EQ(insts[pos]->params_.size(), 0);
     return insts[pos]->_address;
     return insts[pos]->_address;
 }
 }
@@ -45,7 +45,7 @@ static uint32 IsNop(InstVec& insts, uint32& pos)
 
 
 // For a backwards jump we start with 3 NOPS and the last instruction is the jump itself which
 // For a backwards jump we start with 3 NOPS and the last instruction is the jump itself which
 // should be targeting the second/middle NOP
 // should be targeting the second/middle NOP
-static void CheckBackwardJump(FF7::eOpcodes opCode, size_t paramsSize, InstVec& insts, uint32& pos)
+static void CheckBackwardJump(eOpcodes opCode, size_t paramsSize, InstVec& insts, uint32& pos)
 {
 {
     IsNop(insts, pos);
     IsNop(insts, pos);
 
 
@@ -69,7 +69,7 @@ TEST(FF7Field, ControlFlow)
 {
 {
     InstVec insts;
     InstVec insts;
     DummyFormatter formatter;
     DummyFormatter formatter;
-    FF7::FieldEngine engine(formatter, "test");
+    FieldEngine engine(formatter, "test");
 
 
     auto d = engine.GetDisassembler(insts);
     auto d = engine.GetDisassembler(insts);
     d->open("decompiler/test/ff7_control_flow_test.dat");
     d->open("decompiler/test/ff7_control_flow_test.dat");
@@ -78,18 +78,18 @@ TEST(FF7Field, ControlFlow)
     std::cout << std::endl;
     std::cout << std::endl;
 
 
     uint32 pos = 0;
     uint32 pos = 0;
-    ASSERT_EQ(insts[pos]->opcode_, FF7::eOpcodes::RET);
+    ASSERT_EQ(insts[pos]->opcode_, eOpcodes::RET);
     ASSERT_EQ(insts[pos]->params_.size(), 0);
     ASSERT_EQ(insts[pos]->params_.size(), 0);
 
 
-    CheckForwardJump(FF7::eOpcodes::IFUB, 6, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::IFSWL, 6, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::JMPF, 1, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::JMPFL, 1, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::IFKEY, 2, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::IFKEYON, 2, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::IFKEYOFF, 2, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::IFPRTYQ, 2, insts, pos);
-    CheckForwardJump(FF7::eOpcodes::IFMEMBQ, 2, insts, pos);
-    CheckBackwardJump(FF7::eOpcodes::JMPB, 1, insts, pos);
-    CheckBackwardJump(FF7::eOpcodes::JMPBL, 1, insts, pos);
+    CheckForwardJump(eOpcodes::IFUB, 6, insts, pos);
+    CheckForwardJump(eOpcodes::IFSWL, 6, insts, pos);
+    CheckForwardJump(eOpcodes::JMPF, 1, insts, pos);
+    CheckForwardJump(eOpcodes::JMPFL, 1, insts, pos);
+    CheckForwardJump(eOpcodes::IFKEY, 2, insts, pos);
+    CheckForwardJump(eOpcodes::IFKEYON, 2, insts, pos);
+    CheckForwardJump(eOpcodes::IFKEYOFF, 2, insts, pos);
+    CheckForwardJump(eOpcodes::IFPRTYQ, 2, insts, pos);
+    CheckForwardJump(eOpcodes::IFMEMBQ, 2, insts, pos);
+    CheckBackwardJump(eOpcodes::JMPB, 1, insts, pos);
+    CheckBackwardJump(eOpcodes::JMPBL, 1, insts, pos);
 }
 }

Різницю між файлами не показано, бо вона завелика
+ 145 - 145
V-Gears-Installer/include/decompiler/test/ff7_field_disasm_all_opcodes_by_category_test.cpp


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

@@ -43,7 +43,7 @@ static InstPtr DoReadParameterTest(std::string str, std::vector<unsigned char> d
 {
 {
     InstVec insts;
     InstVec insts;
     TestReadParameterDisassembler d(std::move(data), insts);
     TestReadParameterDisassembler d(std::move(data), insts);
-    InstPtr inst = new FF7::FieldNoOperationInstruction();
+    InstPtr inst = new FieldNoOperationInstruction();
     d.readParams(inst, str.c_str());
     d.readParams(inst, str.c_str());
     return inst;
     return inst;
 }
 }
@@ -124,7 +124,7 @@ TEST(SimpleDisassembler, readParameter_d)
 
 
 TEST(FF7Field, FunctionMetaData_Parse_Empty)
 TEST(FF7Field, FunctionMetaData_Parse_Empty)
 {
 {
-    FF7::FunctionMetaData meta("");
+    FunctionMetaData meta("");
     ASSERT_EQ("", meta.EntityName());
     ASSERT_EQ("", meta.EntityName());
     ASSERT_EQ(false, meta.IsEnd());
     ASSERT_EQ(false, meta.IsEnd());
     ASSERT_EQ(false, meta.IsStart());
     ASSERT_EQ(false, meta.IsStart());
@@ -132,7 +132,7 @@ TEST(FF7Field, FunctionMetaData_Parse_Empty)
 
 
 TEST(FF7Field, FunctionMetaData_Parse_Empties)
 TEST(FF7Field, FunctionMetaData_Parse_Empties)
 {
 {
-    FF7::FunctionMetaData meta("__________________");
+    FunctionMetaData meta("__________________");
     ASSERT_EQ("", meta.EntityName());
     ASSERT_EQ("", meta.EntityName());
     ASSERT_EQ(false, meta.IsEnd());
     ASSERT_EQ(false, meta.IsEnd());
     ASSERT_EQ(false, meta.IsStart());
     ASSERT_EQ(false, meta.IsStart());
@@ -140,7 +140,7 @@ TEST(FF7Field, FunctionMetaData_Parse_Empties)
 
 
 TEST(FF7Field, FunctionMetaData_Parse_Start)
 TEST(FF7Field, FunctionMetaData_Parse_Start)
 {
 {
-    FF7::FunctionMetaData meta("start_-1_entity");
+    FunctionMetaData meta("start_-1_entity");
     ASSERT_EQ("entity", meta.EntityName());
     ASSERT_EQ("entity", meta.EntityName());
     ASSERT_EQ(false, meta.IsEnd());
     ASSERT_EQ(false, meta.IsEnd());
     ASSERT_EQ(true, meta.IsStart());
     ASSERT_EQ(true, meta.IsStart());
@@ -148,7 +148,7 @@ TEST(FF7Field, FunctionMetaData_Parse_Start)
 
 
 TEST(FF7Field, FunctionMetaData_Parse_End)
 TEST(FF7Field, FunctionMetaData_Parse_End)
 {
 {
-    FF7::FunctionMetaData meta("end_-1_entity");
+    FunctionMetaData meta("end_-1_entity");
     ASSERT_EQ("entity", meta.EntityName());
     ASSERT_EQ("entity", meta.EntityName());
     ASSERT_EQ(true, meta.IsEnd());
     ASSERT_EQ(true, meta.IsEnd());
     ASSERT_EQ(false, meta.IsStart());
     ASSERT_EQ(false, meta.IsStart());
@@ -156,7 +156,7 @@ TEST(FF7Field, FunctionMetaData_Parse_End)
 
 
 TEST(FF7Field, FunctionMetaData_Parse_EntityName)
 TEST(FF7Field, FunctionMetaData_Parse_EntityName)
 {
 {
-    FF7::FunctionMetaData meta("end_-1_TheName");
+    FunctionMetaData meta("end_-1_TheName");
     ASSERT_EQ("TheName", meta.EntityName());
     ASSERT_EQ("TheName", meta.EntityName());
     ASSERT_EQ(true, meta.IsEnd());
     ASSERT_EQ(true, meta.IsEnd());
     ASSERT_EQ(false, meta.IsStart());
     ASSERT_EQ(false, meta.IsStart());
@@ -166,7 +166,7 @@ TEST(FF7Field, FunctionMetaData_Parse_EntityName)
 
 
 TEST(FF7Field, FunctionMetaData_Parse_EntityNameAndId)
 TEST(FF7Field, FunctionMetaData_Parse_EntityNameAndId)
 {
 {
-    FF7::FunctionMetaData meta("end_99_The_Name");
+    FunctionMetaData meta("end_99_The_Name");
     ASSERT_EQ("The_Name", meta.EntityName());
     ASSERT_EQ("The_Name", meta.EntityName());
     ASSERT_EQ(99, meta.CharacterId());
     ASSERT_EQ(99, meta.CharacterId());
 
 
@@ -177,7 +177,7 @@ TEST(FF7Field, FunctionMetaData_Parse_EntityNameAndId)
 
 
 TEST(FF7Field, FunctionMetaData_Parse_StartEnd)
 TEST(FF7Field, FunctionMetaData_Parse_StartEnd)
 {
 {
-    FF7::FunctionMetaData meta("start_end_-1_entity");
+    FunctionMetaData meta("start_end_-1_entity");
     ASSERT_EQ("entity", meta.EntityName());
     ASSERT_EQ("entity", meta.EntityName());
     ASSERT_EQ(true, meta.IsEnd());
     ASSERT_EQ(true, meta.IsEnd());
     ASSERT_EQ(true, meta.IsStart());
     ASSERT_EQ(true, meta.IsStart());
@@ -188,7 +188,7 @@ TEST(FF7World, DisAsm)
 {
 {
     for (int i = 0; i < 256; i++)
     for (int i = 0; i < 256; i++)
     {
     {
-        FF7::WorldEngine engine(i);
+        WorldEngine engine(i);
 
 
 
 
         InstVec insts;
         InstVec insts;
@@ -1151,7 +1151,7 @@ private:
 
 
     void ParseInstruction(const Tokenzier::Token& inst, std::deque<Tokenzier::Token>& tokens, Assembler::Method& method)
     void ParseInstruction(const Tokenzier::Token& inst, std::deque<Tokenzier::Token>& tokens, Assembler::Method& method)
     {
     {
-        const auto insts = FF7::FieldInstructions();
+        const auto insts = FieldInstructions();
         auto it = insts.find(inst.AsString());
         auto it = insts.find(inst.AsString());
         if (it == std::end(insts))
         if (it == std::end(insts))
         {
         {
@@ -1159,7 +1159,7 @@ private:
         }
         }
 
 
         // TODO: Handle arguments correctly, validate labels
         // TODO: Handle arguments correctly, validate labels
-        const FF7::TInstructRecord* rec = it->second;
+        const TInstructRecord* rec = it->second;
         const char* fmt = rec->mArgumentFormat;
         const char* fmt = rec->mArgumentFormat;
 
 
         // method.AddInstruction(rec->mOpCode, rec->mOpCodeSize);
         // method.AddInstruction(rec->mOpCode, rec->mOpCodeSize);
@@ -1507,10 +1507,10 @@ TEST(Parser, ZeroGapIf)
 TEST(FF7Field, Asm)
 TEST(FF7Field, Asm)
 {
 {
     DummyFormatter dummy;
     DummyFormatter dummy;
-    FF7::FieldEngine eng(dummy, "test");
+    FieldEngine eng(dummy, "test");
 
 
     InstVec insts;
     InstVec insts;
-    FF7::FieldDisassembler d(dummy, &eng, insts);
+    FieldDisassembler d(dummy, &eng, insts);
 
 
 
 
 }
 }

+ 46 - 49
V-Gears-Installer/include/decompiler/world/WorldCodeGenerator.h

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -18,59 +18,56 @@
 
 
 #pragma once
 #pragma once
 
 
-#include "../CodeGenerator.h"
+#include "decompiler/CodeGenerator.h"
 
 
-namespace FF7{
+class WorldCodeGenerator : public CodeGenerator{
 
 
-    class WorldCodeGenerator : public CodeGenerator{
+    public:
 
 
-        public:
+        /**
+         * Constructor.
+         *
+         * @param engine[in] The engine.
+         * @param output[out] The generated script.
+         */
+        WorldCodeGenerator(Engine *engine, std::ostream &output);
 
 
-            /**
-             * Constructor.
-             *
-             * @param engine[in] The engine.
-             * @param output[out] The generated script.
-             */
-            WorldCodeGenerator(Engine *engine, std::ostream &output);
+        /**
+         * Finds the first function call.
+         *
+         * @return A pointer to the first call instruction.
+         */
+        const InstPtr FindFirstCall();
 
 
-            /**
-             * Finds the first function call.
-             *
-             * @return A pointer to the first call instruction.
-             */
-            const InstPtr FindFirstCall();
+        /**
+         * Finds the last function call.
+         *
+         * @return A pointer to the last call instruction.
+         */
+        const InstPtr FindLastCall();
 
 
-            /**
-             * Finds the last function call.
-             *
-             * @return A pointer to the last call instruction.
-             */
-            const InstPtr FindLastCall();
+        /**
+         * Processes special metadata in an instruction.
+         *
+         * @param inst[in] The instruction to process.
+         * @param c[in]
+         * @param pos[in]
+         * @todo understand and document.
+         */
+        virtual void ProcessSpecialMetadata(const InstPtr inst, char c, int pos);
 
 
-            /**
-             * Processes special metadata in an instruction.
-             *
-             * @param inst[in] The instruction to process.
-             * @param c[in]
-             * @param pos[in]
-             * @todo understand and document.
-             */
-            virtual void ProcessSpecialMetadata(const InstPtr inst, char c, int pos);
+    protected:
 
 
-        protected:
-
-            /**
-             * Constructs the function signature.
-             *
-             * The function signature is the LUA function declaration, and it
-             * looks like this:
-             *
-             * <function_name> = function(self)
-             *
-             * @param function[in] The function to construct the signature for.
-             * @return The function signature.
-             */
-            std::string ConstructFuncSignature(const Function &function);
-    };
-}
+        /**
+         * Constructs the function signature.
+         *
+         * The function signature is the LUA function declaration, and it
+         * looks like this:
+         *
+         * <function_name> = function(self)
+         *
+         * @param function[in] The function to construct the signature for.
+         * @return The function signature.
+         */
+        std::string ConstructFuncSignature(const Function &function);
+};

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

@@ -17,67 +17,62 @@
 
 
 #include "decompiler/Disassembler.h"
 #include "decompiler/Disassembler.h"
 
 
-namespace FF7{
+class WorldEngine;
 
 
-    class WorldEngine;
+class WorldDisassembler : public Disassembler{
 
 
-    class WorldDisassembler : public Disassembler{
+    public:
 
 
-        public:
+        /**
+         * CConstructor.
+         *
+         * @param engine[in] The engine to use to disassemble.
+         * @param insts[in] The list of instructions.
+         * @param script_number[in] The script number to process.
+         */
+        WorldDisassembler(WorldEngine* engine, InstVec& insts, int script_number);
 
 
-            /**
-             * CConstructor.
-             *
-             * @param engine[in] The engine to use to disassemble.
-             * @param insts[in] The list of instructions.
-             * @param script_number[in] The script number to process.
-             */
-            WorldDisassembler(WorldEngine* engine, InstVec& insts, int script_number);
+        /**
+         * Destructor.
+         */
+        ~WorldDisassembler();
 
 
-            /**
-             * Destructor.
-             */
-            ~WorldDisassembler();
+        /**
+         * Disassembles the instructions.
+         */
+        void DoDisassemble() override;
 
 
-            /**
-             * Disassembles the instructions.
-             */
-            void DoDisassemble() override;
+    private:
 
 
-        private:
+        /**
+         * Parses an opcode.
+         *
+         * Adds properties to an instruction, and adds the instruction to the
+         * list.
+         *
+         * @param opcode[in] The opcode code.
+         * @param name[in] the opcode name.
+         * @param instruction[in][out] A newly created instruction of the type
+         * the opcode belongs to.
+         * @param stack_change[in] Indicates how much the instruction changes
+         * the stack pointer by.
+         * @param argument_format[in] The opcode argument format.
+         */
+        template<typename T> void ParseOpcode(
+          int opcode, std::string name, T instruction, int stack_change, const char* argument_format
+        ){
+            uint32 full_opcode = (full_opcode << 8) + opcode;
+            this->insts_.push_back(instruction);
+            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);
+        }
 
 
-            /**
-             * Parses an opcode.
-             *
-             * Adds properties to an instruction, and adds the instruction to
-             * the list.
-             *
-             * @param opcode[in] The opcode code.
-             * @param name[in] the opcode name.
-             * @param instruction[in][out] A newly created instruction of the
-             * type the opcode belongs to.
-             * @param stack_change[in] Indicates how much the instruction
-             * changes the stack pointer by.
-             * @param argument_format[in] The opcode argument format.
-             */
-            template<typename T> void ParseOpcode(
-              int opcode, std::string name, T instruction,
-              int stack_change, const char* argument_format
-            ){
-                uint32 full_opcode = (full_opcode << 8) + opcode;
-                this->insts_.push_back(instruction);
-                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);
-            }
-
-            /**
-             * The script number.
-             */
-            int script_number_ = 0;
-    };
-
-} 
+        /**
+         * The script number.
+         */
+        int script_number_ = 0;
+};

+ 89 - 94
V-Gears-Installer/include/decompiler/world/WorldEngine.h

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -21,96 +21,91 @@
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
-#include "../Engine.h"
-
-namespace FF7{
-
-    /**
-     * Represents the FF7 world map engine.
-     */
-    class WorldEngine : public Engine{
-
-        public:
-
-            /**
-             * A bank value.
-             *
-             * @todo Understand and document.
-             */
-            class BankValue : public VarValue{
-
-                public:
-
-                    /**
-                     * Constructor.
-                     *
-                     * @param name[in] Variable name.
-                     */
-                    BankValue(std::string name);
-            };
-
-            /**
-             * Constructor.
-             *
-             * @param script_number[in] The script number.
-             */
-            WorldEngine(int script_number);
-
-            /**
-             * Retrieves the disassembler.
-             *
-             * @param insts[in] List of instructions.
-             * @return Pointer to the disassembler.
-             */
-            std::unique_ptr<Disassembler> GetDisassembler(InstVec &insts) override;
-
-            /**
-             * Retrieves the code generator.
-             *
-             * @param insts[in] List of instructions. Unused.
-             * @param output[in] Pointer to the output (file, stream...).
-             * @return Pointer to the generator.
-             */
-            std::unique_ptr<CodeGenerator> GetCodeGenerator(
-              const InstVec& insts, std::ostream &output
-            ) override;
-
-            /**
-             * Post-processing actions to apply to the scripts.
-             *
-             * It actually does nothing. CFG stands for control flow group.
-             *
-             * @param insts[in] Instruction list.
-             * @param graph[in] Code graph.
-             */
-            virtual void PostCFG(InstVec &insts, Graph graph) override;
-
-            /**
-             * Retrieves the variants.
-             *
-             * @todo Variants of what? What is this supposed to do?
-             */
-            virtual void GetVariants(std::vector<std::string> &variants) const override;
-
-            /**
-             * Indicates if instructions are purely grouped.
-             *
-             * @return True if instructions are purely grouped. Always false.
-             * @todo What is pure grouping?
-             */
-            virtual bool UsePureGrouping() const override;
-
-        private:
-
-            /**
-             * The script number.
-             */
-            int script_number_;
-
-            /**
-             * Container for strings from the TEXT chunk.
-             */
-            std::vector<std::string> text_strings_;
-    };
-
-}
+#include "decompiler/Engine.h"
+
+/**
+ * Represents the FF7 world map engine.
+ */
+class WorldEngine : public Engine{
+
+    public:
+
+        /**
+         * A bank value.
+         *
+         * @todo Understand and document.
+         */
+        class BankValue : public VarValue{
+
+            public:
+
+                /**
+                 * Constructor.
+                 *
+                 * @param name[in] Variable name.
+                 */
+                BankValue(std::string name);
+        };
+
+        /**
+         * Constructor.
+         *
+         * @param script_number[in] The script number.
+         */
+        WorldEngine(int script_number);
+
+        /**
+         * Retrieves the disassembler.
+         *
+         * @param insts[in] List of instructions.
+         * @return Pointer to the disassembler.
+         */
+        std::unique_ptr<Disassembler> GetDisassembler(InstVec &insts) override;
+
+        /**
+         * Retrieves the code generator.
+         *
+         * @param insts[in] List of instructions. Unused.
+         * @param output[in] Pointer to the output (file, stream...).
+         * @return Pointer to the generator.
+         */
+        std::unique_ptr<CodeGenerator> GetCodeGenerator(
+          const InstVec& insts, std::ostream &output
+        ) override;
+
+        /**
+         * Post-processing actions to apply to the scripts.
+         *
+         * It actually does nothing. CFG stands for control flow group.
+         *
+         * @param insts[in] Instruction list.
+         * @param graph[in] Code graph.
+         */
+        virtual void PostCFG(InstVec &insts, Graph graph) override;
+
+        /**
+         * Retrieves the variants.
+         *
+         * @todo Variants of what? What is this supposed to do?
+         */
+        virtual void GetVariants(std::vector<std::string> &variants) const override;
+
+        /**
+         * Indicates if instructions are purely grouped.
+         *
+         * @return True if instructions are purely grouped. Always false.
+         */
+        virtual bool UsePureGrouping() const override;
+
+    private:
+
+        /**
+         * The script number.
+         */
+        int script_number_;
+
+        /**
+         * Container for strings from the TEXT chunk.
+         */
+        std::vector<std::string> text_strings_;
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,26 +20,22 @@
 #include "decompiler/instruction/BinaryOpStackInstruction.h"
 #include "decompiler/instruction/BinaryOpStackInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A binary equals stack instruction.
-     */
-    class WorldBinaryEqualStackInstruction : public BinaryOpStackInstruction{
-
-        public:
+/**
+ * A binary equals stack instruction.
+ */
+class WorldBinaryEqualStackInstruction : public BinaryOpStackInstruction{
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-    };
+    public:
 
 
-}
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,41 +20,37 @@
 #include "decompiler/instruction/CondJumpInstruction.h"
 #include "decompiler/instruction/CondJumpInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A conditional jump instruction.
-     */
-    class WorldCondJumpInstruction : public CondJumpInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-            /**
-             * Retrieves the destination address of the jump.
-             *
-             * @return The destination address.
-             */
-            virtual uint32 GetDestAddress() const;
-
-            /**
-             * Prints the instruction.
-             *
-             * @param output[in] The output to print.
-             * @return The same as output.
-             */
-            virtual std::ostream& Print(std::ostream &output) const override;
-        };
-
-}
+/**
+ * A conditional jump instruction.
+ */
+class WorldCondJumpInstruction : public CondJumpInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+        /**
+         * Retrieves the destination address of the jump.
+         *
+         * @return The destination address.
+         */
+        virtual uint32 GetDestAddress() const;
+
+        /**
+         * Prints the instruction.
+         *
+         * @param output[in] The output to print.
+         * @return The same as output.
+         */
+        virtual std::ostream& Print(std::ostream &output) const override;
+    };

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,26 +20,23 @@
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/instruction/KernelCallInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A kernel call instruction.
-     */
-    class WorldKernelCallInstruction : public KernelCallInstruction{
+/**
+ * A kernel call instruction.
+ */
+class WorldKernelCallInstruction : public KernelCallInstruction{
 
 
-        public:
+    public:
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process. Unused.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process. Unused.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
 
 
-    };
-}
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,27 +20,23 @@
 #include "decompiler/instruction/LoadInstruction.h"
 #include "decompiler/instruction/LoadInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A bank loading instruction.
-     */
-    class WorldLoadBankInstruction : public LoadInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process. Unused.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param code_gen[in] Code generator. Unused.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-    };
-
-}
+/**
+ * A bank loading instruction.
+ */
+class WorldLoadBankInstruction : public LoadInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process. Unused.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param code_gen[in] Code generator. Unused.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,27 +20,23 @@
 #include "decompiler/instruction/LoadInstruction.h"
 #include "decompiler/instruction/LoadInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A load instruction.
-     */
-    class WorldLoadInstruction : public LoadInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process. Unused.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param code_gen[in] Code generator. Unused.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-    };
-
-}
+/**
+ * A load instruction.
+ */
+class WorldLoadInstruction : public LoadInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process. Unused.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param code_gen[in] Code generator. Unused.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,27 +20,23 @@
 #include "decompiler/instruction/Instruction.h"
 #include "decompiler/instruction/Instruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * An instruction without output.
-     */
-    class WorldNoOutputInstruction : public Instruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-    };
-
-}
+/**
+ * An instruction without output.
+ */
+class WorldNoOutputInstruction : public Instruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,27 +20,24 @@
 #include "decompiler/instruction/StackInstruction.h"
 #include "decompiler/instruction/StackInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A stack instruction.
-     */
-    class WorldStackInstruction : public StackInstruction{
+/**
+ * A stack instruction.
+ */
+class WorldStackInstruction : public StackInstruction{
 
 
-        public:
+    public:
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
 
 
-    };
+};
 
 
-}

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,27 +20,23 @@
 #include "decompiler/instruction/StoreInstruction.h"
 #include "decompiler/instruction/StoreInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A store instruction.
-     */
-    class WorldStoreInstruction : public StoreInstruction{
-
-        public:
-
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process. Unused.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-    };
-
-}
+/**
+ * A store instruction.
+ */
+class WorldStoreInstruction : public StoreInstruction{
+
+    public:
+
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process. Unused.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,26 +20,22 @@
 #include "decompiler/instruction/StackInstruction.h"
 #include "decompiler/instruction/StackInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * A substack instruction.
-     */
-    class WorldSubStackInstruction : public StackInstruction{
-
-        public:
+/**
+ * A substack instruction.
+ */
+class WorldSubStackInstruction : public StackInstruction{
 
 
-            /**
-             * Processes the instruction.
-             *
-             * @param func[in] Function to process. Unused.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine. Unused.
-             * @param code_gen[in] Code generator. Unused.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-    };
+    public:
 
 
-}
+        /**
+         * Processes the instruction.
+         *
+         * @param func[in] Function to process. Unused.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine. Unused.
+         * @param code_gen[in] Code generator. Unused.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+};

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

@@ -8,7 +8,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -20,71 +20,68 @@
 #include "decompiler/instruction/UncondJumpInstruction.h"
 #include "decompiler/instruction/UncondJumpInstruction.h"
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-namespace FF7{
-
-    /**
-     * An unconditional jump instruction.
-     */
-    class WorldUncondJumpInstruction : public UncondJumpInstruction{
-
-        public:
-
-            /**
-             * Constructor.
-             */
-            WorldUncondJumpInstruction();
-
-
-            /**
-             * Indicates if the instruction is a function call.
-             *
-             * @return true if the instruction is a function call, false if not.
-             */
-            virtual bool IsFuncCall() const;
-
-            /**
-             * Indicates if the instruction is an unconditional jump.
-             *
-             * @return true if the instruction is an unconditional jump, false
-             * if it's not.
-             */
-            virtual bool IsUncondJump() const;
-
-            /**
-             * Retrieves the destination address of the jump.
-             *
-             * @return The offset (number of bytes) to jump from the beginning
-             * of the instruction.
-             */
-            virtual uint32 GetDestAddress() const;
-
-            /**
-             * Prints the instruction
-             *
-             * @param[in] output The stream to print the instruction to.
-             * @return The same output.
-             */
-            virtual std::ostream& Print(std::ostream &output) const override;
-
-            /**
-             * Processes the instruction.
-             *
-             * @param function[in] Function to process.
-             * @param stack[out] Function stack.
-             * @param engine[in] Engine.
-             * @param code_gen[in] Code generator.
-             */
-            virtual void ProcessInst(
-              Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-            ) override;
-
-        private:
-
-            /**
-             * Whether or not this is really a call to a script function.
-             */
-            bool is_call_;
-
-    };
+/**
+ * An unconditional jump instruction.
+ */
+class WorldUncondJumpInstruction : public UncondJumpInstruction{
+
+    public:
+
+        /**
+         * Constructor.
+         */
+        WorldUncondJumpInstruction();
+
+
+        /**
+         * Indicates if the instruction is a function call.
+         *
+         * @return true if the instruction is a function call, false if not.
+         */
+        virtual bool IsFuncCall() const;
+
+        /**
+         * Indicates if the instruction is an unconditional jump.
+         *
+         * @return true if the instruction is an unconditional jump, false if
+         * it's not.
+         */
+        virtual bool IsUncondJump() const;
+
+        /**
+         * Retrieves the destination address of the jump.
+         *
+         * @return The offset (number of bytes) to jump from the beginning of
+         * the instruction.
+         */
+        virtual uint32 GetDestAddress() const;
+
+        /**
+         * Prints the instruction
+         *
+         * @param[in] output The stream to print the instruction to.
+         * @return The same output.
+         */
+        virtual std::ostream& Print(std::ostream &output) const override;
+
+        /**
+         * Processes the instruction.
+         *
+         * @param function[in] Function to process.
+         * @param stack[out] Function stack.
+         * @param engine[in] Engine.
+         * @param code_gen[in] Code generator.
+         */
+        virtual void ProcessInst(
+          Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+        ) override;
+
+    private:
+
+        /**
+         * Whether or not this is really a call to a script function.
+         */
+        bool is_call_;
+
+};
 
 
-}

+ 8 - 8
V-Gears-Installer/src/DataInstaller.cpp

@@ -365,7 +365,7 @@ class BaseFF7FieldScriptFormatter : public FieldScriptFormatter{
         virtual std::string GetFriendlyVarName(
         virtual std::string GetFriendlyVarName(
           unsigned int bank, unsigned int addr
           unsigned int bank, unsigned int addr
         ) override{
         ) override{
-            return VGears::FF7::NameLookup::FieldScriptVarName(bank, addr);
+            return VGears::NameLookup::FieldScriptVarName(bank, addr);
         }
         }
 
 
         /**
         /**
@@ -376,7 +376,7 @@ class BaseFF7FieldScriptFormatter : public FieldScriptFormatter{
          * doesn't have one assigned.
          * doesn't have one assigned.
          */
          */
         virtual std::string GetFriendlyEntityName(const std::string& entity) override{
         virtual std::string GetFriendlyEntityName(const std::string& entity) override{
-            return VGears::FF7::NameLookup::FieldScriptEntityName(entity);
+            return VGears::NameLookup::FieldScriptEntityName(entity);
         }
         }
 
 
         /**
         /**
@@ -387,7 +387,7 @@ class BaseFF7FieldScriptFormatter : public FieldScriptFormatter{
          * doesn't have one assigned.
          * doesn't have one assigned.
          */
          */
         virtual std::string GetFriendlyCharName(int char_id) override{
         virtual std::string GetFriendlyCharName(int char_id) override{
-            return VGears::FF7::NameLookup::CharName(char_id);
+            return VGears::NameLookup::CharName(char_id);
         }
         }
 
 
         /**
         /**
@@ -401,7 +401,7 @@ class BaseFF7FieldScriptFormatter : public FieldScriptFormatter{
         virtual std::string GetFriendlyFunctionName(
         virtual std::string GetFriendlyFunctionName(
           const std::string& entity, const std::string& function_name
           const std::string& entity, const std::string& function_name
         ) override{
         ) override{
-            return VGears::FF7::NameLookup::FieldScriptFunctionName(
+            return VGears::NameLookup::FieldScriptFunctionName(
               field_name_, entity, function_name
               field_name_, entity, function_name
             );
             );
         }
         }
@@ -417,7 +417,7 @@ class BaseFF7FieldScriptFormatter : public FieldScriptFormatter{
         virtual std::string GetFunctionComment(
         virtual std::string GetFunctionComment(
           const std::string& entity, const std::string& function_name
           const std::string& entity, const std::string& function_name
         ) override{
         ) override{
-            return VGears::FF7::NameLookup::FieldScriptFunctionComment(
+            return VGears::NameLookup::FieldScriptFunctionComment(
               field_name_, entity, function_name
               field_name_, entity, function_name
             );
             );
         }
         }
@@ -494,7 +494,7 @@ class FF7FieldScriptFormatter : public BaseFF7FieldScriptFormatter{
             Ogre::String base_name;
             Ogre::String base_name;
             VGears::StringUtil::splitBase(raw_name, base_name);
             VGears::StringUtil::splitBase(raw_name, base_name);
             VGears::StringUtil::toLowerCase(base_name);
             VGears::StringUtil::toLowerCase(base_name);
-            return VGears::FF7::NameLookup::Animation(base_name);
+            return VGears::NameLookup::Animation(base_name);
         }
         }
 
 
     private:
     private:
@@ -1390,7 +1390,7 @@ void DataInstaller::ConvertFieldModelsIteration(){
                   );
                   );
                 Ogre::String base_name;
                 Ogre::String base_name;
                 VGears::StringUtil::splitBase(model_animation_map_iterator_->first, base_name);
                 VGears::StringUtil::splitBase(model_animation_map_iterator_->first, base_name);
-                auto mesh_name = VGears::FF7::NameLookup::model(base_name) + ".mesh";
+                auto mesh_name = VGears::NameLookup::model(base_name) + ".mesh";
                 Ogre::MeshPtr mesh(Ogre::MeshManager::getSingleton().load(mesh_name, "FFVII"));
                 Ogre::MeshPtr mesh(Ogre::MeshManager::getSingleton().load(mesh_name, "FFVII"));
                 Ogre::SkeletonPtr skeleton(mesh->getSkeleton());
                 Ogre::SkeletonPtr skeleton(mesh->getSkeleton());
                 for (auto& anim : model_animation_map_iterator_->second){
                 for (auto& anim : model_animation_map_iterator_->second){
@@ -1398,7 +1398,7 @@ void DataInstaller::ConvertFieldModelsIteration(){
                     VGears::AFilePtr a = afl_mgr.load(anim, "FFVII").staticCast<VGears::AFile>();
                     VGears::AFilePtr a = afl_mgr.load(anim, "FFVII").staticCast<VGears::AFile>();
                     // Convert the FF7 name to a more readable name set in the meta data.
                     // Convert the FF7 name to a more readable name set in the meta data.
                     VGears::StringUtil::splitBase(anim, base_name);
                     VGears::StringUtil::splitBase(anim, base_name);
-                    a->AddTo(skeleton, VGears::FF7::NameLookup::Animation(base_name));
+                    a->AddTo(skeleton, VGears::NameLookup::Animation(base_name));
                 }
                 }
                 ExportMesh(output_dir_ + "/" + FieldModelDir() + "/", mesh);
                 ExportMesh(output_dir_ + "/" + FieldModelDir() + "/", mesh);
             }
             }

+ 1 - 1
V-Gears-Installer/src/ModelsAndAnimationsDb.cpp

@@ -39,6 +39,6 @@ std::string ModelsAndAnimationsDb::ModelMetaDataName(const std::string& model_na
     // If not in meta data then just replace .hrc with .mesh.
     // If not in meta data then just replace .hrc with .mesh.
     Ogre::String base_name;
     Ogre::String base_name;
     VGears::StringUtil::splitBase(model_name, base_name);
     VGears::StringUtil::splitBase(model_name, base_name);
-    return VGears::FF7::NameLookup::model(base_name) + ".mesh";
+    return VGears::NameLookup::model(base_name) + ".mesh";
 }
 }
 
 

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

@@ -17,23 +17,23 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/FieldEngine.h"
 
 
-const std::string FF7::FunctionMetaData::DELIMITER("_");
+const std::string FunctionMetaData::DELIMITER("_");
 
 
-const std::string FF7::FunctionMetaData::START("start");
+const std::string FunctionMetaData::START("start");
 
 
-const std::string FF7::FunctionMetaData::END("end");
+const std::string FunctionMetaData::END("end");
 
 
-FF7::FunctionMetaData::FunctionMetaData(std::string meta_data){Parse(meta_data);}
+FunctionMetaData::FunctionMetaData(std::string meta_data){Parse(meta_data);}
 
 
-bool FF7::FunctionMetaData::IsStart() const{return start_;}
+bool FunctionMetaData::IsStart() const{return start_;}
 
 
-bool FF7::FunctionMetaData::IsEnd() const{return end_;}
+bool FunctionMetaData::IsEnd() const{return end_;}
 
 
-std::string FF7::FunctionMetaData::GetEntityName(){return entity_name_;}
+std::string FunctionMetaData::GetEntityName(){return entity_name_;}
 
 
-int FF7::FunctionMetaData::GetCharacterId(){return character_id_;}
+int FunctionMetaData::GetCharacterId(){return character_id_;}
 
 
-void FF7::FunctionMetaData::Parse(std::string meta_data){
+void FunctionMetaData::Parse(std::string meta_data){
     std::deque<std::string> strs;
     std::deque<std::string> strs;
     boost::split(strs, meta_data, boost::is_any_of(DELIMITER), boost::token_compress_on);
     boost::split(strs, meta_data, boost::is_any_of(DELIMITER), boost::token_compress_on);
     if (!strs.empty()){
     if (!strs.empty()){
@@ -43,7 +43,7 @@ void FF7::FunctionMetaData::Parse(std::string meta_data){
     }
     }
 }
 }
 
 
-void FF7::FunctionMetaData::ParseStart(const std::string& item, std::deque<std::string>& strs){
+void FunctionMetaData::ParseStart(const std::string& item, std::deque<std::string>& strs){
     if (item == START){
     if (item == START){
         start_ = true;
         start_ = true;
         if (!strs.empty()){
         if (!strs.empty()){
@@ -55,7 +55,7 @@ void FF7::FunctionMetaData::ParseStart(const std::string& item, std::deque<std::
     else ParseEnd(item, strs);
     else ParseEnd(item, strs);
 }
 }
 
 
-void FF7::FunctionMetaData::ParseEnd(const std::string& item, std::deque<std::string>& strs){
+void FunctionMetaData::ParseEnd(const std::string& item, std::deque<std::string>& strs){
     if (item == END){
     if (item == END){
         end_ = true;
         end_ = true;
         if (!strs.empty()){
         if (!strs.empty()){
@@ -67,7 +67,7 @@ void FF7::FunctionMetaData::ParseEnd(const std::string& item, std::deque<std::st
     else ParseCharId(item, strs);
     else ParseCharId(item, strs);
 }
 }
 
 
-void FF7::FunctionMetaData::ParseCharId(const std::string& item, std::deque<std::string>& strs){
+void FunctionMetaData::ParseCharId(const std::string& item, std::deque<std::string>& strs){
     if (!item.empty()) character_id_ = std::stoi(item);
     if (!item.empty()) character_id_ = std::stoi(item);
     if (!strs.empty()){
     if (!strs.empty()){
         auto tmp = strs.front();
         auto tmp = strs.front();
@@ -76,13 +76,13 @@ void FF7::FunctionMetaData::ParseCharId(const std::string& item, std::deque<std:
     }
     }
 }
 }
 
 
-void FF7::FunctionMetaData::ParseEntity(const std::string& item, std::deque<std::string>& strs){
+void FunctionMetaData::ParseEntity(const std::string& item, std::deque<std::string>& strs){
     entity_name_ = item;
     entity_name_ = item;
     for (auto& part : strs)
     for (auto& part : strs)
         if (!part.empty()) entity_name_ += "_" + part;
         if (!part.empty()) entity_name_ += "_" + part;
 }
 }
 
 
-void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
+void FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
     // TODO: Break into parts
     // TODO: Break into parts
     auto instruction = insts.begin();
     auto instruction = insts.begin();
     
     
@@ -209,14 +209,14 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
     }
     }
 }
 }
 
 
-void FF7::FieldCodeGenerator::AddOutputLine(
+void FieldCodeGenerator::AddOutputLine(
   std::string line, bool unindent_before, bool indent_after
   std::string line, bool unindent_before, bool indent_after
 ){lines_.push_back(CodeLine(line, unindent_before, indent_after));}
 ){lines_.push_back(CodeLine(line, unindent_before, indent_after));}
 
 
-float FF7::FieldCodeGenerator::GetScaleFactor() const
+float FieldCodeGenerator::GetScaleFactor() const
 {return static_cast<FieldEngine*>(engine_)->GetScaleFactor();}
 {return static_cast<FieldEngine*>(engine_)->GetScaleFactor();}
 
 
-void FF7::FieldCodeGenerator::OnBeforeStartFunction(const Function& function){
+void FieldCodeGenerator::OnBeforeStartFunction(const Function& function){
     FunctionMetaData meta_data(function.metadata);
     FunctionMetaData meta_data(function.metadata);
     if (meta_data.IsStart()){
     if (meta_data.IsStart()){
         AddOutputLine("EntityContainer[\"" + meta_data.GetEntityName() + "\"] = {", false, true);
         AddOutputLine("EntityContainer[\"" + meta_data.GetEntityName() + "\"] = {", false, true);
@@ -227,7 +227,7 @@ void FF7::FieldCodeGenerator::OnBeforeStartFunction(const Function& function){
     if (!comment.empty()) AddOutputLine("-- " + comment);
     if (!comment.empty()) AddOutputLine("-- " + comment);
 }
 }
 
 
-void FF7::FieldCodeGenerator::OnStartFunction(const Function& func){
+void FieldCodeGenerator::OnStartFunction(const Function& func){
     AddOutputLine("--[[");
     AddOutputLine("--[[");
     for (const auto& inst : insts_){
     for (const auto& inst : insts_){
         if (inst->GetAddress() >= func.start_addr && inst->GetAddress() <= func.end_addr){
         if (inst->GetAddress() >= func.start_addr && inst->GetAddress() <= func.end_addr){
@@ -244,7 +244,7 @@ void FF7::FieldCodeGenerator::OnStartFunction(const Function& func){
     }
     }
 }
 }
 
 
-void FF7::FieldCodeGenerator::OnEndFunction(const Function& function){
+void FieldCodeGenerator::OnEndFunction(const Function& function){
     // End function.
     // End function.
     AddOutputLine("end,", true, false);
     AddOutputLine("end,", true, false);
     // End class?
     // End class?
@@ -253,18 +253,18 @@ void FF7::FieldCodeGenerator::OnEndFunction(const Function& function){
     else AddOutputLine("\n");
     else AddOutputLine("\n");
 }
 }
 
 
-std::string FF7::FieldCodeGenerator::ConstructFuncSignature(const Function &function){
+std::string FieldCodeGenerator::ConstructFuncSignature(const Function &function){
     // Generate name
     // Generate name
     FunctionMetaData meta_data(function.metadata);
     FunctionMetaData meta_data(function.metadata);
     return formatter_.GetFriendlyFunctionName(meta_data.GetEntityName(), function.name)
     return formatter_.GetFriendlyFunctionName(meta_data.GetEntityName(), function.name)
       + " = function(self)";
       + " = function(self)";
 }
 }
 
 
-bool FF7::FieldCodeGenerator::OutputOnlyRequiredLabels() const{return true;}
+bool FieldCodeGenerator::OutputOnlyRequiredLabels() const{return true;}
 
 
-FieldScriptFormatter& FF7::FieldCodeGenerator::GetFormatter(){return formatter_;}
+FieldScriptFormatter& FieldCodeGenerator::GetFormatter(){return formatter_;}
 
 
-const std::string FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+const std::string FieldCodeGenerator::FormatInstructionNotImplemented(
   const std::string& entity, uint32 address, uint32 opcode
   const std::string& entity, uint32 address, uint32 opcode
 ){
 ){
     return (
     return (
@@ -275,7 +275,7 @@ const std::string FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
     ).str();
     ).str();
 }
 }
 
 
-const std::string FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+const std::string FieldCodeGenerator::FormatInstructionNotImplemented(
   const std::string& entity, uint32 address, const Instruction& instruction
   const std::string& entity, uint32 address, const Instruction& instruction
 ){
 ){
     std::stringstream parameterList;
     std::stringstream parameterList;
@@ -293,10 +293,10 @@ const std::string FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
       ).str();
       ).str();
 }
 }
 
 
-const std::string FF7::FieldCodeGenerator::FormatBool(uint32 value){
+const std::string FieldCodeGenerator::FormatBool(uint32 value){
     return value == 0 ? "false" : "true";
     return value == 0 ? "false" : "true";
 }
 }
 
 
-const std::string FF7::FieldCodeGenerator::FormatInvertedBool(uint32 value){
+const std::string FieldCodeGenerator::FormatInvertedBool(uint32 value){
     return value == 0 ? "true" : "false";
     return value == 0 ? "true" : "false";
 }
 }

+ 3 - 3
V-Gears-Installer/src/decompiler/field/FieldDecompiler.cpp

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -23,7 +23,7 @@
 float FieldDecompiler::ScaleFactor(const std::vector<unsigned char>& script_bytes){
 float FieldDecompiler::ScaleFactor(const std::vector<unsigned char>& script_bytes){
     // Could be cleaner, but just does enough work to pull out the fields scale.
     // Could be cleaner, but just does enough work to pull out the fields scale.
     FieldScriptFormatter formatter;
     FieldScriptFormatter formatter;
-    ::FF7::FieldEngine engine(formatter, "Unused");
+    FieldEngine engine(formatter, "Unused");
     InstVec insts;
     InstVec insts;
     engine.GetDisassembler(insts, script_bytes);
     engine.GetDisassembler(insts, script_bytes);
     return engine.GetScaleFactor();
     return engine.GetScaleFactor();
@@ -34,7 +34,7 @@ FieldDecompiler::DecompiledScript FieldDecompiler::Decompile(
   FieldScriptFormatter& formatter, std::string text_after, std::string text_before
   FieldScriptFormatter& formatter, std::string text_after, std::string text_before
 ){
 ){
     // Disassemble the script.
     // Disassemble the script.
-    ::FF7::FieldEngine engine(formatter, script_name);
+    FieldEngine engine(formatter, script_name);
     InstVec insts;
     InstVec insts;
     auto disassembler = engine.GetDisassembler(insts, script_bytes);
     auto disassembler = engine.GetDisassembler(insts, script_bytes);
     disassembler->Disassemble();
     disassembler->Disassemble();

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

@@ -38,11 +38,11 @@
 #include "common/Lzs.h"
 #include "common/Lzs.h"
 
 
 
 
-const int FF7::FieldDisassembler::MAGIC(0x0502);
+const int FieldDisassembler::MAGIC(0x0502);
 
 
-const int FF7::FieldDisassembler::NUM_SECTIONS(7);
+const int FieldDisassembler::NUM_SECTIONS(7);
 
 
-FF7::FieldDisassembler::FieldDisassembler(
+FieldDisassembler::FieldDisassembler(
   FieldScriptFormatter& formatter, FieldEngine* engine,
   FieldScriptFormatter& formatter, FieldEngine* engine,
   InstVec& insts, const std::vector<unsigned char>& raw_script_data
   InstVec& insts, const std::vector<unsigned char>& raw_script_data
 ): Disassembler(insts), engine_(engine), formatter_(formatter){
 ): Disassembler(insts), engine_(engine), formatter_(formatter){
@@ -54,17 +54,17 @@ FF7::FieldDisassembler::FieldDisassembler(
     ReadHeader();
     ReadHeader();
 }
 }
 
 
-FF7::FieldDisassembler::FieldDisassembler(
+FieldDisassembler::FieldDisassembler(
   FieldScriptFormatter& formatter, FieldEngine *engine, InstVec &insts
   FieldScriptFormatter& formatter, FieldEngine *engine, InstVec &insts
 ): Disassembler(insts), engine_(engine), formatter_(formatter){
 ): Disassembler(insts), engine_(engine), formatter_(formatter){
     section_pointers_size_ = (sizeof(uint32) * NUM_SECTIONS);
     section_pointers_size_ = (sizeof(uint32) * NUM_SECTIONS);
 }
 }
 
 
-float FF7::FieldDisassembler::GetScaleFactor() const{return scale_factor_;}
+float FieldDisassembler::GetScaleFactor() const{return scale_factor_;}
 
 
-FF7::FieldDisassembler::~FieldDisassembler(){}
+FieldDisassembler::~FieldDisassembler(){}
 
 
-void FF7::FieldDisassembler::ReadHeader(){
+void FieldDisassembler::ReadHeader(){
     if (!loaded_from_raw_data_){
     if (!loaded_from_raw_data_){
         // First read the file section pointers.
         // First read the file section pointers.
         for (int i = 0; i < NUM_SECTIONS; i ++) sections_[i] = stream_->ReadU32();
         for (int i = 0; i < NUM_SECTIONS; i ++) sections_[i] = stream_->ReadU32();
@@ -80,13 +80,13 @@ void FF7::FieldDisassembler::ReadHeader(){
     scale_factor_ = static_cast<float>(header_.scale) / 512.0f;
     scale_factor_ = static_cast<float>(header_.scale) / 512.0f;
 }
 }
 
 
-void FF7::FieldDisassembler::Open(const char *filename){
+void FieldDisassembler::Open(const char *filename){
     // Read all of the file, decompress it, then stuff it into a stream.
     // Read all of the file, decompress it, then stuff it into a stream.
     stream_ = std::make_unique<BinaryReader>(Lzs::Decompress(BinaryReader::ReadAll(filename)));
     stream_ = std::make_unique<BinaryReader>(Lzs::Decompress(BinaryReader::ReadAll(filename)));
     ReadHeader();
     ReadHeader();
 }
 }
 
 
-uint32 FF7::FieldDisassembler::GetEndOfScriptOffset(
+uint32 FieldDisassembler::GetEndOfScriptOffset(
   uint16 cur_entry_point, size_t entity_index, size_t script_index
   uint16 cur_entry_point, size_t entity_index, size_t script_index
 ){
 ){
     uint16 next_entry_point = cur_entry_point;
     uint16 next_entry_point = cur_entry_point;
@@ -108,7 +108,7 @@ uint32 FF7::FieldDisassembler::GetEndOfScriptOffset(
     return next_entry_point;
     return next_entry_point;
 }
 }
 
 
-std::unique_ptr<Function> FF7::FieldDisassembler::StartFunction(size_t script_index){
+std::unique_ptr<Function> FieldDisassembler::StartFunction(size_t script_index){
     auto func = std::make_unique<Function>();
     auto func = std::make_unique<Function>();
     func->ret_val = false;
     func->ret_val = false;
     func->num_args = 0;
     func->num_args = 0;
@@ -117,7 +117,7 @@ std::unique_ptr<Function> FF7::FieldDisassembler::StartFunction(size_t script_in
     return func;
     return func;
 }
 }
 
 
-void FF7::FieldDisassembler::DoDisassemble(){
+void FieldDisassembler::DoDisassemble(){
     // Loop through the scripts for each entity.
     // Loop through the scripts for each entity.
     for (size_t entity_number = 0; entity_number < header_.entity_scripts.size(); entity_number ++){
     for (size_t entity_number = 0; entity_number < header_.entity_scripts.size(); entity_number ++){
         std::string original_name = header_.field_entity_names[entity_number].data();
         std::string original_name = header_.field_entity_names[entity_number].data();
@@ -158,17 +158,17 @@ void FF7::FieldDisassembler::DoDisassemble(){
     }
     }
 }
 }
 
 
-int FF7::FieldDisassembler::FindId(uint32 start_addr, uint32 end_addr, const InstVec& insts){
+int FieldDisassembler::FindId(uint32 start_addr, uint32 end_addr, const InstVec& insts){
     for (const InstPtr& instruction : insts){
     for (const InstPtr& instruction : insts){
         if (instruction->GetAddress() >= start_addr && instruction->GetAddress() <= end_addr){
         if (instruction->GetAddress() >= start_addr && instruction->GetAddress() <= end_addr){
-            if (instruction->GetOpcode() == FF7::OPCODES::opCodeCHAR)
+            if (instruction->GetOpcode() == OPCODES::opCodeCHAR)
                 return instruction->GetParam(0)->GetSigned();
                 return instruction->GetParam(0)->GetSigned();
         }
         }
     }
     }
     return -1;
     return -1;
 }
 }
 
 
-void FF7::FieldDisassembler::AddFunc(
+void FieldDisassembler::AddFunc(
   std::string entity_name, size_t entity_index, size_t script_index, uint32 next_script_entry_point,
   std::string entity_name, size_t entity_index, size_t script_index, uint32 next_script_entry_point,
   const bool is_start, bool is_end, bool to_return_only, std::string func_name
   const bool is_start, bool is_end, bool to_return_only, std::string func_name
 ){
 ){
@@ -248,7 +248,7 @@ void FF7::FieldDisassembler::AddFunc(
     if (is_line) engine_->MarkEntityAsLine(entity_index, true, point_a, point_b);
     if (is_line) engine_->MarkEntityAsLine(entity_index, true, point_a, point_b);
 }
 }
 
 
-void FF7::FieldDisassembler::DisassembleIndivdualScript(
+void FieldDisassembler::DisassembleIndivdualScript(
   std::string entity_name, size_t entity_index, size_t script_index,
   std::string entity_name, size_t entity_index, size_t script_index,
   size_t script_entry_point, uint32 next_script_entry_point, bool is_start, bool is_end)
   size_t script_entry_point, uint32 next_script_entry_point, bool is_start, bool is_end)
 {
 {
@@ -294,17 +294,17 @@ void FF7::FieldDisassembler::DisassembleIndivdualScript(
 }
 }
 
 
 
 
-FF7::FieldDisassembler::InstructionRecord FF7::FieldDisassembler::FLOW_OPCODES[] ={
-    {1, FF7::OPCODES::RET, "RET", "", FF7::FF7ControlFlowInstruction::Create},
-    {1, FF7::OPCODES::REQ, "REQ", "BU", FF7::FF7ControlFlowInstruction::Create},
-    {1, FF7::OPCODES::REQSW, "REQSW", "BU", FF7::FF7ControlFlowInstruction::Create},
-    {1, FF7::OPCODES::REQEW, "REQEW", "BU", FF7::FF7ControlFlowInstruction::Create},
-    {1, FF7::OPCODES::NOP, "NOP", "", FF7::FieldNoOperationInstruction::Create},
-    {1, FF7::OPCODES::IFUB, "IFUB", "NNBBBL", FF7::FieldNoOperationInstruction::Create}
+FieldDisassembler::InstructionRecord FieldDisassembler::FLOW_OPCODES[] ={
+    {1, OPCODES::RET, "RET", "", FieldControlFlowInstruction::Create},
+    {1, OPCODES::REQ, "REQ", "BU", FieldControlFlowInstruction::Create},
+    {1, OPCODES::REQSW, "REQSW", "BU", FieldControlFlowInstruction::Create},
+    {1, OPCODES::REQEW, "REQEW", "BU", FieldControlFlowInstruction::Create},
+    {1, OPCODES::NOP, "NOP", "", FieldNoOperationInstruction::Create},
+    {1, OPCODES::IFUB, "IFUB", "NNBBBL", FieldNoOperationInstruction::Create}
 };
 };
 
 
-std::map<std::string, const FF7::FieldDisassembler::InstructionRecord*>
-  FF7::FieldDisassembler::FieldInstructions(){
+std::map<std::string, const FieldDisassembler::InstructionRecord*>
+  FieldDisassembler::FieldInstructions(){
     // Convert the array to a map that we can query on by opcode name.
     // Convert the array to a map that we can query on by opcode name.
     std::map<std::string, const InstructionRecord*> name_to_instruction_records;
     std::map<std::string, const InstructionRecord*> name_to_instruction_records;
     for (size_t i = 0; i < boost::size(FLOW_OPCODES); i ++)
     for (size_t i = 0; i < boost::size(FLOW_OPCODES); i ++)
@@ -312,7 +312,7 @@ std::map<std::string, const FF7::FieldDisassembler::InstructionRecord*>
     return name_to_instruction_records;
     return name_to_instruction_records;
 }
 }
 
 
-bool FF7::FieldDisassembler::ReadOpCodesToPositionOrReturn(
+bool FieldDisassembler::ReadOpCodesToPositionOrReturn(
   size_t end_pos, std::vector<float>& point_a, std::vector<float>& point_b
   size_t end_pos, std::vector<float>& point_a, std::vector<float>& point_b
 ){
 ){
     bool is_line = false;
     bool is_line = false;
@@ -328,28 +328,28 @@ bool FF7::FieldDisassembler::ReadOpCodesToPositionOrReturn(
                 ParseOpcode(full_opcode, "IFUB", new FieldCondJumpInstruction(), 0, "NBBBB");
                 ParseOpcode(full_opcode, "IFUB", new FieldCondJumpInstruction(), 0, "NBBBB");
                 break;
                 break;
             case OPCODES::RET:
             case OPCODES::RET:
-                ParseOpcode(full_opcode, "RET", new FF7ControlFlowInstruction(), 0, "");
+                ParseOpcode(full_opcode, "RET", new FieldControlFlowInstruction(), 0, "");
                 break;
                 break;
             case OPCODES::REQ:
             case OPCODES::REQ:
-                ParseOpcode(full_opcode, "REQ", new FF7ControlFlowInstruction(), 0, "BU");
+                ParseOpcode(full_opcode, "REQ", new FieldControlFlowInstruction(), 0, "BU");
                 break;
                 break;
             case OPCODES::REQSW:
             case OPCODES::REQSW:
-                ParseOpcode(full_opcode, "REQSW", new FF7ControlFlowInstruction(), 0, "BU");
+                ParseOpcode(full_opcode, "REQSW", new FieldControlFlowInstruction(), 0, "BU");
                 break;
                 break;
             case OPCODES::REQEW:
             case OPCODES::REQEW:
-                ParseOpcode(full_opcode, "REQEW", new FF7ControlFlowInstruction(), 0, "BU");
+                ParseOpcode(full_opcode, "REQEW", new FieldControlFlowInstruction(), 0, "BU");
                 break;
                 break;
             case OPCODES::PREQ:
             case OPCODES::PREQ:
-                ParseOpcode(full_opcode, "PREQ", new FF7ControlFlowInstruction(), 0, "BU");
+                ParseOpcode(full_opcode, "PREQ", new FieldControlFlowInstruction(), 0, "BU");
                 break;
                 break;
             case OPCODES::PRQSW:
             case OPCODES::PRQSW:
-                ParseOpcode(full_opcode, "PRQSW", new FF7ControlFlowInstruction(), 0, "BU");
+                ParseOpcode(full_opcode, "PRQSW", new FieldControlFlowInstruction(), 0, "BU");
                 break;
                 break;
             case OPCODES::PRQEW:
             case OPCODES::PRQEW:
-                ParseOpcode(full_opcode, "PRQEW", new FF7ControlFlowInstruction(), 0, "BU");
+                ParseOpcode(full_opcode, "PRQEW", new FieldControlFlowInstruction(), 0, "BU");
                 break;
                 break;
             case OPCODES::RETTO:
             case OPCODES::RETTO:
-                ParseOpcode(full_opcode, "RETTO", new FF7ControlFlowInstruction(), 0, "U");
+                ParseOpcode(full_opcode, "RETTO", new FieldControlFlowInstruction(), 0, "U");
                 break;
                 break;
             case OPCODES::JMPF:
             case OPCODES::JMPF:
                 ParseOpcode(full_opcode, "JMPF", new FieldUncondJumpInstruction(), 0, "B");
                 ParseOpcode(full_opcode, "JMPF", new FieldUncondJumpInstruction(), 0, "B");
@@ -379,7 +379,7 @@ bool FF7::FieldDisassembler::ReadOpCodesToPositionOrReturn(
                 ParseOpcode(full_opcode, "IFUWL", new FieldCondJumpInstruction(), 0, "NwwBw");
                 ParseOpcode(full_opcode, "IFUWL", new FieldCondJumpInstruction(), 0, "NwwBw");
                 break;
                 break;
             case OPCODES::WAIT:
             case OPCODES::WAIT:
-                ParseOpcode(full_opcode, "WAIT", new FF7ControlFlowInstruction(), 0, "w");
+                ParseOpcode(full_opcode, "WAIT", new FieldControlFlowInstruction(), 0, "w");
                 break;
                 break;
             case OPCODES::IFKEY:
             case OPCODES::IFKEY:
                 ParseOpcode(full_opcode, "IFKEY", new FieldCondJumpInstruction(), 0, "wB");
                 ParseOpcode(full_opcode, "IFKEY", new FieldCondJumpInstruction(), 0, "wB");

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -52,25 +52,24 @@
  * TURNW
  * TURNW
  */
  */
 
 
-FF7::FieldEngine::Entity::Entity(const std::string& name, size_t index):
-  name_(name), index_(index), is_line_(false)
-{}
+FieldEngine::Entity::Entity(const std::string& name, size_t index):
+  name_(name), index_(index), is_line_(false){}
 
 
-std::string FF7::FieldEngine::Entity::GetName() const{return name_;}
+std::string FieldEngine::Entity::GetName() const{return name_;}
 
 
-size_t FF7::FieldEngine::Entity::GetIndex() const{return index_;}
+size_t FieldEngine::Entity::GetIndex() const{return index_;}
 
 
-std::string FF7::FieldEngine::Entity::FunctionByIndex(size_t index) const{
+std::string FieldEngine::Entity::FunctionByIndex(size_t index) const{
     auto it = functions_.find(index);
     auto it = functions_.find(index);
     if (it == std::end(functions_)) throw DecompilerException();
     if (it == std::end(functions_)) throw DecompilerException();
     return it->second;
     return it->second;
 }
 }
 
 
-void FF7::FieldEngine::Entity::AddFunction(const std::string& name, size_t index){
+void FieldEngine::Entity::AddFunction(const std::string& name, size_t index){
     functions_[index] = name;
     functions_[index] = name;
 }
 }
 
 
-void FF7::FieldEngine::Entity::MarkAsLine(
+void FieldEngine::Entity::MarkAsLine(
   bool line, std::vector<float> point_a, std::vector<float> point_b
   bool line, std::vector<float> point_a, std::vector<float> point_b
 ){
 ){
     is_line_ = line;
     is_line_ = line;
@@ -95,17 +94,17 @@ void FF7::FieldEngine::Entity::MarkAsLine(
     AddFunction("on_leave_line", 4);
     AddFunction("on_leave_line", 4);
 }
 }
 
 
-bool FF7::FieldEngine::Entity::IsLine(){return is_line_;}
+bool FieldEngine::Entity::IsLine(){return is_line_;}
 
 
-std::vector<float> FF7::FieldEngine::Entity::GetLinePointA(){return point_a_;}
+std::vector<float> FieldEngine::Entity::GetLinePointA(){return point_a_;}
 
 
-std::vector<float> FF7::FieldEngine::Entity::GetLinePointB(){return point_b_;}
+std::vector<float> FieldEngine::Entity::GetLinePointB(){return point_b_;}
 
 
-FF7::FieldEngine::FieldEngine(FieldScriptFormatter& formatter, std::string script_name) :
+FieldEngine::FieldEngine(FieldScriptFormatter& formatter, std::string script_name) :
   formatter_(formatter), script_name_(script_name), scale_factor_(1.0f)
   formatter_(formatter), script_name_(script_name), scale_factor_(1.0f)
 {SetOutputStackEffect(false);}
 {SetOutputStackEffect(false);}
 
 
-std::unique_ptr<Disassembler> FF7::FieldEngine::GetDisassembler(
+std::unique_ptr<Disassembler> FieldEngine::GetDisassembler(
   InstVec &insts, const std::vector<unsigned char>& raw_script_data
   InstVec &insts, const std::vector<unsigned char>& raw_script_data
 ){
 ){
     auto ret = std::make_unique<FieldDisassembler>(formatter_, this, insts, raw_script_data);
     auto ret = std::make_unique<FieldDisassembler>(formatter_, this, insts, raw_script_data);
@@ -113,22 +112,22 @@ std::unique_ptr<Disassembler> FF7::FieldEngine::GetDisassembler(
     return std::move(ret);
     return std::move(ret);
 }
 }
 
 
-std::unique_ptr<Disassembler> FF7::FieldEngine::GetDisassembler(InstVec &insts){
+std::unique_ptr<Disassembler> FieldEngine::GetDisassembler(InstVec &insts){
     auto ret = std::make_unique<FieldDisassembler>(formatter_, this, insts);
     auto ret = std::make_unique<FieldDisassembler>(formatter_, this, insts);
     scale_factor_ = ret->GetScaleFactor();
     scale_factor_ = ret->GetScaleFactor();
     return std::move(ret);
     return std::move(ret);
 }
 }
 
 
-std::unique_ptr<CodeGenerator> FF7::FieldEngine::GetCodeGenerator(
+std::unique_ptr<CodeGenerator> FieldEngine::GetCodeGenerator(
   const InstVec& insts, std::ostream &output
   const InstVec& insts, std::ostream &output
 ){
 ){
     // The broken version:
     // The broken version:
     //return std::make_unique<FieldCodeGenerator>(this, insts, output);
     //return std::make_unique<FieldCodeGenerator>(this, insts, output);
     // The not-as-nice-but-at-least-it-works version:
     // The not-as-nice-but-at-least-it-works version:
-    return std::make_unique<FF7::FieldCodeGenerator>(this, insts, output, formatter_);
+    return std::make_unique<FieldCodeGenerator>(this, insts, output, formatter_);
 }
 }
 
 
-void FF7::FieldEngine::PostCFG(InstVec& insts, Graph graph){
+void FieldEngine::PostCFG(InstVec& insts, Graph graph){
     // In FF7 some scripts ends with an infinite loop to "keep it alive"
     // In FF7 some scripts ends with an infinite loop to "keep it alive"
     // in V-Gears this isn't required so they can be removed.
     // in V-Gears this isn't required so they can be removed.
     //RemoveTrailingInfiniteLoops(insts, graph);
     //RemoveTrailingInfiniteLoops(insts, graph);
@@ -142,13 +141,13 @@ void FF7::FieldEngine::PostCFG(InstVec& insts, Graph graph){
     //RemoveExtraneousReturnStatements(insts, graph);
     //RemoveExtraneousReturnStatements(insts, graph);
 }
 }
 
 
-bool FF7::FieldEngine::UsePureGrouping() const{return false;}
+bool FieldEngine::UsePureGrouping() const{return false;}
 
 
-std::map<std::string, int> FF7::FieldEngine::GetEntities() const{
+std::map<std::string, int> FieldEngine::GetEntities() const{
     std::map<std::string, int> r;
     std::map<std::string, int> r;
     for (auto& f : functions){
     for (auto& f : functions){
         const Function& func = f.second;
         const Function& func = f.second;
-        FF7::FunctionMetaData meta(func.metadata);
+        FunctionMetaData meta(func.metadata);
         auto it = r.find(meta.GetEntityName());
         auto it = r.find(meta.GetEntityName());
         if (it != std::end(r)){
         if (it != std::end(r)){
             // Try to find a function in this entity has that has a char id.
             // Try to find a function in this entity has that has a char id.
@@ -161,7 +160,7 @@ std::map<std::string, int> FF7::FieldEngine::GetEntities() const{
     return r;
     return r;
 }
 }
 
 
-std::vector<FieldDecompiler::FieldEntity> FF7::FieldEngine::GetEntityList() const{
+std::vector<FieldDecompiler::FieldEntity> FieldEngine::GetEntityList() const{
     std::vector<FieldDecompiler::FieldEntity> entities;
     std::vector<FieldDecompiler::FieldEntity> entities;
     for (auto entity: entity_index_map_){
     for (auto entity: entity_index_map_){
         if (entity.second.IsLine() == false){
         if (entity.second.IsLine() == false){
@@ -174,7 +173,7 @@ std::vector<FieldDecompiler::FieldEntity> FF7::FieldEngine::GetEntityList() cons
             std::map<std::string, int> r;
             std::map<std::string, int> r;
             for (auto& f : functions){
             for (auto& f : functions){
                 const Function& func = f.second;
                 const Function& func = f.second;
-                FF7::FunctionMetaData meta(func.metadata);
+                FunctionMetaData meta(func.metadata);
                 if (meta.GetEntityName() == ent.name){
                 if (meta.GetEntityName() == ent.name){
                     ent.char_id = meta.GetCharacterId();
                     ent.char_id = meta.GetCharacterId();
                     break;
                     break;
@@ -186,7 +185,7 @@ std::vector<FieldDecompiler::FieldEntity> FF7::FieldEngine::GetEntityList() cons
     return entities;
     return entities;
 }
 }
 
 
-std::vector<FieldDecompiler::Line> FF7::FieldEngine::GetLineList() const{
+std::vector<FieldDecompiler::Line> FieldEngine::GetLineList() const{
     std::vector<FieldDecompiler::Line> lines;
     std::vector<FieldDecompiler::Line> lines;
     for (auto entity: entity_index_map_){
     for (auto entity: entity_index_map_){
         if (entity.second.IsLine() == true){
         if (entity.second.IsLine() == true){
@@ -200,7 +199,7 @@ std::vector<FieldDecompiler::Line> FF7::FieldEngine::GetLineList() const{
     return lines;
     return lines;
 }
 }
 
 
-void FF7::FieldEngine::AddEntityFunction(
+void FieldEngine::AddEntityFunction(
   const std::string& entity_name, size_t entity_index,
   const std::string& entity_name, size_t entity_index,
   const std::string& func_name, size_t func_index
   const std::string& func_name, size_t func_index
 ){
 ){
@@ -213,7 +212,7 @@ void FF7::FieldEngine::AddEntityFunction(
     }
     }
 }
 }
 
 
-void FF7::FieldEngine::MarkEntityAsLine(
+void FieldEngine::MarkEntityAsLine(
   size_t entity_index, bool line, std::vector<float> point_a, std::vector<float> point_b
   size_t entity_index, bool line, std::vector<float> point_a, std::vector<float> point_b
 ){
 ){
     auto it = entity_index_map_.find(entity_index);
     auto it = entity_index_map_.find(entity_index);
@@ -222,23 +221,23 @@ void FF7::FieldEngine::MarkEntityAsLine(
     }
     }
 }
 }
 
 
-bool FF7::FieldEngine::EntityIsLine(size_t entity_index){
+bool FieldEngine::EntityIsLine(size_t entity_index){
     auto it = entity_index_map_.find(entity_index);
     auto it = entity_index_map_.find(entity_index);
     if (it != std::end(entity_index_map_)) return (*it).second.IsLine();
     if (it != std::end(entity_index_map_)) return (*it).second.IsLine();
     return false;
     return false;
 }
 }
 
 
-const FF7::FieldEngine::Entity& FF7::FieldEngine::EntityByIndex(size_t index) const{
+const FieldEngine::Entity& FieldEngine::EntityByIndex(size_t index) const{
     auto it = entity_index_map_.find(index);
     auto it = entity_index_map_.find(index);
     if (it == std::end(entity_index_map_)) throw DecompilerException();
     if (it == std::end(entity_index_map_)) throw DecompilerException();
     return it->second;
     return it->second;
 }
 }
 
 
-float FF7::FieldEngine::GetScaleFactor() const {return scale_factor_;}
+float FieldEngine::GetScaleFactor() const {return scale_factor_;}
 
 
-const std::string& FF7::FieldEngine::GetScriptName() const {return script_name_;}
+const std::string& FieldEngine::GetScriptName() const {return script_name_;}
 
 
-void FF7::FieldEngine::RemoveExtraneousReturnStatements(InstVec& insts, Graph graph){
+void FieldEngine::RemoveExtraneousReturnStatements(InstVec& insts, Graph graph){
     for (auto& f : functions){
     for (auto& f : functions){
         Function& func = f.second;
         Function& func = f.second;
         for (auto it = insts.begin(); it != insts.end(); it ++){
         for (auto it = insts.begin(); it != insts.end(); it ++){
@@ -259,7 +258,7 @@ void FF7::FieldEngine::RemoveExtraneousReturnStatements(InstVec& insts, Graph gr
     }
     }
 }
 }
 
 
-void FF7::FieldEngine::RemoveTrailingInfiniteLoops(InstVec& insts, Graph graph){
+void FieldEngine::RemoveTrailingInfiniteLoops(InstVec& insts, Graph graph){
     for (auto& f : functions){
     for (auto& f : functions){
         Function& func = f.second;
         Function& func = f.second;
         for (auto it = insts.begin(); it != insts.end(); it ++){
         for (auto it = insts.begin(); it != insts.end(); it ++){
@@ -280,7 +279,7 @@ void FF7::FieldEngine::RemoveTrailingInfiniteLoops(InstVec& insts, Graph graph){
     }
     }
 }
 }
 
 
-void FF7::FieldEngine::MarkInfiniteLoopGroups(InstVec& insts, Graph graph){
+void FieldEngine::MarkInfiniteLoopGroups(InstVec& insts, Graph graph){
     for (auto& f : functions){
     for (auto& f : functions){
         Function& func = f.second;
         Function& func = f.second;
         for (auto it = insts.begin(); it != insts.end(); it ++){
         for (auto it = insts.begin(); it != insts.end(); it ++){

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldBackgroundInstruction::ProcessInst(
+void FieldBackgroundInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
@@ -49,18 +49,18 @@ void FF7::FieldBackgroundInstruction::ProcessInst(
         case OPCODES::ADPAL2: code_gen->WriteTodo(md.GetEntityName(), "ADPAL2"); break;
         case OPCODES::ADPAL2: code_gen->WriteTodo(md.GetEntityName(), "ADPAL2"); break;
         case OPCODES::RTPAL2: code_gen->WriteTodo(md.GetEntityName(), "RTPAL2"); break;
         case OPCODES::RTPAL2: code_gen->WriteTodo(md.GetEntityName(), "RTPAL2"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessBGON(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessBGON(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& background_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& background_id = 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(
+    const auto& layer_id = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     );
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
@@ -68,12 +68,12 @@ void FF7::FieldBackgroundInstruction::ProcessBGON(CodeGenerator* code_gen){
     );
     );
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessBGOFF(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessBGOFF(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& background_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& background_id = 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(
+    const auto& layer_id = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     );
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
@@ -81,9 +81,9 @@ void FF7::FieldBackgroundInstruction::ProcessBGOFF(CodeGenerator* code_gen){
     );
     );
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessBGCLR(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessBGCLR(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& background_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& background_id = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
@@ -91,12 +91,12 @@ void FF7::FieldBackgroundInstruction::ProcessBGCLR(CodeGenerator* code_gen){
     );
     );
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessSTPAL(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessSTPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& source = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = 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;
@@ -106,12 +106,12 @@ void FF7::FieldBackgroundInstruction::ProcessSTPAL(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessLDPAL(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessLDPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& source = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = 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;
@@ -121,12 +121,12 @@ void FF7::FieldBackgroundInstruction::ProcessLDPAL(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessCPPAL(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessCPPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& source = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = 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;
@@ -136,21 +136,21 @@ void FF7::FieldBackgroundInstruction::ProcessCPPAL(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessADPAL(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessADPAL(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& source = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetUnsigned()
     );
     );
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     );
-    const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& r = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetUnsigned()
       cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     );
-    const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& g = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetUnsigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     );
-    const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& b = 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;
@@ -162,21 +162,21 @@ void FF7::FieldBackgroundInstruction::ProcessADPAL(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessMPPAL2(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessMPPAL2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& source = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetUnsigned()
     );
     );
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     );
-    const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& r = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetUnsigned()
       cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     );
-    const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& g = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetUnsigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     );
-    const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& b = 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;
@@ -187,7 +187,7 @@ void FF7::FieldBackgroundInstruction::ProcessMPPAL2(CodeGenerator* code_gen){
       ) % source % destination % r % g % b % num_entries).str());
       ) % source % destination % r % g % b % num_entries).str());
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessSTPLS(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessSTPLS(CodeGenerator* code_gen){
     auto source = params_[0]->GetUnsigned();
     auto source = params_[0]->GetUnsigned();
     auto destination = params_[1]->GetUnsigned();
     auto destination = params_[1]->GetUnsigned();
     auto start_clut = params_[2]->GetUnsigned();
     auto start_clut = params_[2]->GetUnsigned();
@@ -198,7 +198,7 @@ void FF7::FieldBackgroundInstruction::ProcessSTPLS(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldBackgroundInstruction::ProcessLDPLS(CodeGenerator* code_gen){
+void FieldBackgroundInstruction::ProcessLDPLS(CodeGenerator* code_gen){
     auto source = params_[0]->GetUnsigned();
     auto source = params_[0]->GetUnsigned();
     auto destination = params_[1]->GetUnsigned();
     auto destination = params_[1]->GetUnsigned();
     auto startClut = params_[2]->GetUnsigned();
     auto startClut = params_[2]->GetUnsigned();

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldCameraInstruction::ProcessInst(
+void FieldCameraInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
@@ -45,13 +45,13 @@ void FF7::FieldCameraInstruction::ProcessInst(
     case OPCODES::MVCAM: code_gen->WriteTodo(md.GetEntityName(), "MVCAM"); break;
     case OPCODES::MVCAM: code_gen->WriteTodo(md.GetEntityName(), "MVCAM"); break;
     case OPCODES::SCRLA: code_gen->WriteTodo(md.GetEntityName(), "SCRLA"); break;
     case OPCODES::SCRLA: code_gen->WriteTodo(md.GetEntityName(), "SCRLA"); break;
     default:
     default:
-        code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+        code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
           md.GetEntityName(), address_, opcode_
           md.GetEntityName(), address_, opcode_
         ));
         ));
     }
     }
 }
 }
 
 
-void FF7::FieldCameraInstruction::ProcessNFADE(CodeGenerator* code_gen){
+void FieldCameraInstruction::ProcessNFADE(CodeGenerator* code_gen){
     // TODO: Not fully reversed.
     // TODO: Not fully reversed.
     auto raw_type = params_[4]->GetUnsigned();
     auto raw_type = params_[4]->GetUnsigned();
     if (raw_type == 0){
     if (raw_type == 0){
@@ -60,16 +60,16 @@ void FF7::FieldCameraInstruction::ProcessNFADE(CodeGenerator* code_gen){
     }
     }
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const std::string type = raw_type == 12 ? "Fade.SUBTRACT" : "Fade.ADD";
     const std::string type = raw_type == 12 ? "Fade.SUBTRACT" : "Fade.ADD";
-    const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& r = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[5]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[5]->GetUnsigned()
     );
     );
-    const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& g = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[6]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[6]->GetUnsigned()
     );
     );
-    const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& b = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[7]->GetUnsigned()
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     );
-    const auto& unknown = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& unknown = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[8]->GetUnsigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[8]->GetUnsigned()
     );
     );
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
@@ -77,13 +77,13 @@ void FF7::FieldCameraInstruction::ProcessNFADE(CodeGenerator* code_gen){
     );
     );
 }
 }
 
 
-void FF7::FieldCameraInstruction::ProcessSCR2D(CodeGenerator* code_gen){
+void FieldCameraInstruction::ProcessSCR2D(CodeGenerator* code_gen){
     // kUpScaler.
     // kUpScaler.
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& x = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetSigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetSigned()
     );
     );
-    const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& y = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetSigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetSigned()
     );
     );
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
@@ -92,17 +92,17 @@ void FF7::FieldCameraInstruction::ProcessSCR2D(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldCameraInstruction::ProcessSCR2DC(CodeGenerator* code_gen){
+void FieldCameraInstruction::ProcessSCR2DC(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& x = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned()
     );
     );
-    const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& y = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned()
     );
     );
-    const auto& speed = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& speed = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[6]->GetUnsigned(),
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[6]->GetUnsigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, 30.0f
+      FieldCodeGenerator::ValueType::Float, 30.0f
     );
     );
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("background2d:scroll_to_position(%1% * 3, %2% * 3, Background2D.SMOOTH, %3%)")
       boost::format("background2d:scroll_to_position(%1% * 3, %2% * 3, Background2D.SMOOTH, %3%)")
@@ -110,7 +110,7 @@ void FF7::FieldCameraInstruction::ProcessSCR2DC(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldCameraInstruction::ProcessFADE(CodeGenerator* code_gen){
+void FieldCameraInstruction::ProcessFADE(CodeGenerator* code_gen){
     // TODO: not fully reversed
     // TODO: not fully reversed
     auto raw_type = params_[8]->GetUnsigned();
     auto raw_type = params_[8]->GetUnsigned();
     std::string type;
     std::string type;
@@ -126,13 +126,13 @@ void FF7::FieldCameraInstruction::ProcessFADE(CodeGenerator* code_gen){
     }
     }
 
 
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& r = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& r = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetUnsigned()
     );
     );
-    const auto& g = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& g = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetUnsigned()
     );
     );
-    const auto& b = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& b = 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?
     // TODO: needs to be divided by 30.0f?

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,10 +24,10 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldCondJumpInstruction::ProcessInst(
+void FieldCondJumpInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
 ){
 ){
-    FF7::FieldCodeGenerator* cg = static_cast<FF7::FieldCodeGenerator*>(code_gen);
+    FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     std::string func_name;
     std::string func_name;
     if (opcode_ == OPCODES::IFKEYON) func_name = "entity_manager:is_key_on";
     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::IFKEYOFF) func_name = "entity_manager:is_key_off";
@@ -55,10 +55,10 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
     }
     }
     std::string op;
     std::string op;
     uint32 type = params_[4]->GetUnsigned();
     uint32 type = params_[4]->GetUnsigned();
-    const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& source = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     );
 
 
@@ -94,7 +94,7 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
     stack.Push(v);
     stack.Push(v);
 }
 }
 
 
-uint32 FF7::FieldCondJumpInstruction::GetDestAddress() const{
+uint32 FieldCondJumpInstruction::GetDestAddress() const{
     uint32 params_size = 0;
     uint32 params_size = 0;
     uint32 jump_param_index = 5;
     uint32 jump_param_index = 5;
     switch (opcode_){
     switch (opcode_){
@@ -120,7 +120,7 @@ uint32 FF7::FieldCondJumpInstruction::GetDestAddress() const{
     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{
+std::ostream& FieldCondJumpInstruction::Print(std::ostream &output) const{
     Instruction::Print(output);
     Instruction::Print(output);
     output << " (False target address: 0x" << std::hex << GetDestAddress() << std::dec << ")";
     output << " (False target address: 0x" << std::hex << GetDestAddress() << std::dec << ")";
     return output;
     return output;

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,10 +24,12 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FF7ControlFlowInstruction::ProcessInst(
+InstPtr FieldControlFlowInstruction::Create(){return new FieldControlFlowInstruction();}
+
+void FieldControlFlowInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
-    FF7::FieldEngine& eng = static_cast<FF7::FieldEngine&>(*engine);
+    FieldEngine& eng = static_cast<FieldEngine&>(*engine);
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
     switch (opcode_){
     switch (opcode_){
         case OPCODES::RET:
         case OPCODES::RET:
@@ -50,13 +52,13 @@ void FF7::FF7ControlFlowInstruction::ProcessInst(
         case OPCODES::RETTO: ProcessRETTO(code_gen); break;
         case OPCODES::RETTO: ProcessRETTO(code_gen); break;
         case OPCODES::WAIT: ProcessWAIT(code_gen); break;
         case OPCODES::WAIT: ProcessWAIT(code_gen); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FF7ControlFlowInstruction::ProcessREQ(
+void FieldControlFlowInstruction::ProcessREQ(
   CodeGenerator* code_gen, const FieldEngine& engine
   CodeGenerator* code_gen, const FieldEngine& engine
 ){
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
@@ -71,7 +73,7 @@ void FF7::FF7ControlFlowInstruction::ProcessREQ(
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FF7ControlFlowInstruction::ProcessREQSW(
+void FieldControlFlowInstruction::ProcessREQSW(
   CodeGenerator* code_gen, const FieldEngine& engine
   CodeGenerator* code_gen, const FieldEngine& engine
 ){
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
@@ -86,7 +88,7 @@ void FF7::FF7ControlFlowInstruction::ProcessREQSW(
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FF7ControlFlowInstruction::ProcessREQEW(
+void FieldControlFlowInstruction::ProcessREQEW(
   CodeGenerator* code_gen, const FieldEngine& engine
   CodeGenerator* code_gen, const FieldEngine& engine
 ){
 ){
     try{
     try{
@@ -109,7 +111,7 @@ void FF7::FF7ControlFlowInstruction::ProcessREQEW(
     }
     }
 }
 }
 
 
-void FF7::FF7ControlFlowInstruction::ProcessRETTO(CodeGenerator* code_gen){
+void FieldControlFlowInstruction::ProcessRETTO(CodeGenerator* code_gen){
     auto entity_index = params_[0]->GetUnsigned();
     auto entity_index = params_[0]->GetUnsigned();
     auto priority = params_[1]->GetUnsigned();
     auto priority = params_[1]->GetUnsigned();
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
@@ -118,7 +120,7 @@ void FF7::FF7ControlFlowInstruction::ProcessRETTO(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FF7ControlFlowInstruction::ProcessWAIT(CodeGenerator* code_gen){
+void FieldControlFlowInstruction::ProcessWAIT(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("script:wait(%1%)") % (params_[0]->GetUnsigned() / 30.0f)
       boost::format("script:wait(%1%)") % (params_[0]->GetUnsigned() / 30.0f)
     ).str());
     ).str());

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldMathInstruction::ProcessInst(
+void FieldMathInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
@@ -62,12 +62,12 @@ void FF7::FieldMathInstruction::ProcessInst(
             {
             {
                 const uint32 source_bank = params_[0]->GetUnsigned();
                 const uint32 source_bank = params_[0]->GetUnsigned();
                 const uint32 sourceaddress__or_value = params_[2]->GetUnsigned();
                 const uint32 sourceaddress__or_value = params_[2]->GetUnsigned();
-                auto source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+                auto source = FieldCodeGenerator::FormatValueOrVariable(
                   cg->GetFormatter(), source_bank, sourceaddress__or_value
                   cg->GetFormatter(), source_bank, sourceaddress__or_value
                 );
                 );
                 const uint32 dest_bank = params_[1]->GetUnsigned();
                 const uint32 dest_bank = params_[1]->GetUnsigned();
                 const uint32 destaddress_ = params_[3]->GetUnsigned();
                 const uint32 destaddress_ = params_[3]->GetUnsigned();
-                auto dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
+                auto dest = FieldCodeGenerator::FormatValueOrVariable(
                   cg->GetFormatter(), dest_bank, destaddress_
                   cg->GetFormatter(), dest_bank, destaddress_
                 );
                 );
                 code_gen->AddOutputLine(
                 code_gen->AddOutputLine(
@@ -97,19 +97,19 @@ void FF7::FieldMathInstruction::ProcessInst(
         case OPCODES::SIN: code_gen->WriteTodo(md.GetEntityName(), "SIN"); break;
         case OPCODES::SIN: code_gen->WriteTodo(md.GetEntityName(), "SIN"); break;
         case OPCODES::COS: code_gen->WriteTodo(md.GetEntityName(), "COS"); break;
         case OPCODES::COS: code_gen->WriteTodo(md.GetEntityName(), "COS"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedPLUS(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedPLUS(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& lhs = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& rhs = 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.
     // TODO: Respect destination bank sizes and negative wrap-around.
@@ -117,13 +117,13 @@ void FF7::FieldMathInstruction::ProcessSaturatedPLUS(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% > 255); %1% = 255; end") % lhs).str());
     code_gen->AddOutputLine((boost::format("--if (%1% > 255); %1% = 255; end") % lhs).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedPLUS2(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedPLUS2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& lhs = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& rhs = 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.
     // TODO: Respect destination bank sizes and negative wrap-around.
@@ -131,13 +131,13 @@ void FF7::FieldMathInstruction::ProcessSaturatedPLUS2(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% > 32767); %1% = 32767; end") % lhs).str());
     code_gen->AddOutputLine((boost::format("--if (%1% > 32767); %1% = 32767; end") % lhs).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedMINUS(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedMINUS(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& lhs = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& rhs = 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.
     // TODO: Respect destination bank sizes and positive wrap-around.
@@ -145,13 +145,13 @@ void FF7::FieldMathInstruction::ProcessSaturatedMINUS(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % lhs).str());
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % lhs).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedMINUS2(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedMINUS2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& lhs = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& rhs = 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.
     // TODO: Respect destination bank sizes and positive wrap-around.
@@ -159,10 +159,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedMINUS2(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % lhs).str());
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % lhs).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedINC(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedINC(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& dest = 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.
     // TODO: Respect destination bank sizes and negative wrap-around.
@@ -170,10 +170,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedINC(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% > 255); %1% = 255; end") % dest).str());
     code_gen->AddOutputLine((boost::format("--if (%1% > 255); %1% = 255; end") % dest).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedINC2(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedINC2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& dest = 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.
     // TODO: Respect destination bank sizes and negative wrap-around.
@@ -181,10 +181,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedINC2(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% > 32767); %1% = 32767; end") % dest).str());
     code_gen->AddOutputLine((boost::format("--if (%1% > 32767); %1% = 32767; end") % dest).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedDEC(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedDEC(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& dest = 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.
     // TODO: Respect destination bank sizes and positive wrap-around.
@@ -192,10 +192,10 @@ void FF7::FieldMathInstruction::ProcessSaturatedDEC(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % dest).str());
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % dest).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSaturatedDEC2(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSaturatedDEC2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& dest = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& dest = 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.
     // TODO: Respect destination bank sizes and positive wrap-around.
@@ -203,64 +203,64 @@ void FF7::FieldMathInstruction::ProcessSaturatedDEC2(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % dest).str());
     code_gen->AddOutputLine((boost::format("--if (%1% < 0); %1% = 0; end") % dest).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessRDMSD(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessRDMSD(CodeGenerator* code_gen){
     // TODO: we don't have os.time...
     // TODO: we don't have os.time...
     // TODO: RNG emulation?
     // TODO: RNG emulation?
     code_gen->AddOutputLine("math.randomseed(os.time())");
     code_gen->AddOutputLine("math.randomseed(os.time())");
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessSETBYTE_SETWORD(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessSETBYTE_SETWORD(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& source = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& source = 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)
     // TODO: respect destination bank sizes (16-bit writes only affect low byte)
     code_gen->AddOutputLine((boost::format("%1% = %2%") % destination % source).str());
     code_gen->AddOutputLine((boost::format("%1% = %2%") % destination % source).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessBITON(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessBITON(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("bit_on(%1%, %2%, %3%)")
     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());
     ).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessBITOFF(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessBITOFF(CodeGenerator* code_gen){
     code_gen->AddOutputLine((boost::format("bit_off(%1%, %2%, %3%)")
     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());
     ).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessPLUSx_MINUSx(CodeGenerator* code_gen, const std::string& op){
+void FieldMathInstruction::ProcessPLUSx_MINUSx(CodeGenerator* code_gen, const std::string& op){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& lhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& lhs = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& rhs = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& rhs = 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
     // TODO: repect destination bank sizes and wraparound
     code_gen->AddOutputLine((boost::format("%1% = %1% %2% %3%") % lhs % op % rhs).str());
     code_gen->AddOutputLine((boost::format("%1% = %1% %2% %3%") % lhs % op % rhs).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessINCx_DECx(CodeGenerator* code_gen, const std::string& op){
+void FieldMathInstruction::ProcessINCx_DECx(CodeGenerator* code_gen, const std::string& op){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = 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
     // TODO: repect destination bank sizes and wraparound
     code_gen->AddOutputLine((boost::format("%1% = %1% %2% 1") % destination % op).str());
     code_gen->AddOutputLine((boost::format("%1% = %1% %2% 1") % destination % op).str());
 }
 }
 
 
-void FF7::FieldMathInstruction::ProcessRANDOM(CodeGenerator* code_gen){
+void FieldMathInstruction::ProcessRANDOM(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = 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: Respect destination bank sizes (16-bit writes only affect low byte).

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldMediaInstruction::ProcessInst(
+void FieldMediaInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
@@ -46,27 +46,27 @@ void FF7::FieldMediaInstruction::ProcessInst(
         case OPCODES::CMUSC: code_gen->WriteTodo(md.GetEntityName(), "CMUSC"); break;
         case OPCODES::CMUSC: code_gen->WriteTodo(md.GetEntityName(), "CMUSC"); break;
         case OPCODES::CHMST: code_gen->WriteTodo(md.GetEntityName(), "CHMST"); break;
         case OPCODES::CHMST: code_gen->WriteTodo(md.GetEntityName(), "CHMST"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessAKAO2(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessAKAO2(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& param1 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param1 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[7]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     );
-    const auto& param2 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param2 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[8]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[8]->GetUnsigned()
     );
     );
-    const auto& param3 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param3 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[9]->GetUnsigned()
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     );
-    const auto& param4 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param4 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[10]->GetUnsigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     );
-    const auto& param5 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param5 = 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();
@@ -76,19 +76,19 @@ void FF7::FieldMediaInstruction::ProcessAKAO2(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessMUSIC(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessMUSIC(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("-- music:execute_akao(0x10, pointer_to_field_AKAO_%1%)")
       boost::format("-- music:execute_akao(0x10, pointer_to_field_AKAO_%1%)")
       % params_[0]->GetUnsigned()
       % params_[0]->GetUnsigned()
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessSOUND(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessSOUND(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& soundId = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& soundId = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& panning = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& panning = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetUnsigned()
     );
     );
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
@@ -96,21 +96,21 @@ void FF7::FieldMediaInstruction::ProcessSOUND(CodeGenerator* code_gen){
     );
     );
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessAKAO(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessAKAO(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& param1 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param1 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[7]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     );
-    const auto& param2 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param2 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[8]->GetUnsigned()
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[8]->GetUnsigned()
     );
     );
-    const auto& param3 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param3 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[9]->GetUnsigned()
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[9]->GetUnsigned()
     );
     );
-    const auto& param4 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param4 = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[10]->GetUnsigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[10]->GetUnsigned()
     );
     );
-    const auto& param5 = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& param5 = 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();
@@ -120,27 +120,27 @@ void FF7::FieldMediaInstruction::ProcessAKAO(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessMULCK(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessMULCK(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("-- music:lock(%1%)")
       boost::format("-- music:lock(%1%)")
-      % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
+      % FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessPMVIE(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessPMVIE(CodeGenerator* code_gen){
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
       (boost::format("-- field:movie_set(%1%)") % params_[0]->GetUnsigned()
       (boost::format("-- field:movie_set(%1%)") % params_[0]->GetUnsigned()
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessMOVIE(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessMOVIE(CodeGenerator* code_gen){
     code_gen->AddOutputLine("-- field:play_movie()");
     code_gen->AddOutputLine("-- field:play_movie()");
 }
 }
 
 
-void FF7::FieldMediaInstruction::ProcessMVIEF(CodeGenerator* code_gen){
+void FieldMediaInstruction::ProcessMVIEF(CodeGenerator* code_gen){
     // TODO: Check for assignment to value.
     // TODO: Check for assignment to value.
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& destination = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& destination = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned());
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[2]->GetUnsigned());
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
       (boost::format("-- %1% = field:get_movie_frame()") % destination).str()
       (boost::format("-- %1% = field:get_movie_frame()") % destination).str()

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,10 +24,10 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldModelInstruction::ProcessInst(
+void FieldModelInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
-    FF7::FieldEngine& eng = static_cast<FF7::FieldEngine&>(*engine);
+    FieldEngine& eng = static_cast<FieldEngine&>(*engine);
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
     switch (opcode_){
     switch (opcode_){
         case OPCODES::JOIN: ProcessJOIN(code_gen); break;
         case OPCODES::JOIN: ProcessJOIN(code_gen); break;
@@ -141,42 +141,42 @@ void FF7::FieldModelInstruction::ProcessInst(
         case OPCODES::ANIMB: code_gen->WriteTodo(md.GetEntityName(), "ANIMB"); break;
         case OPCODES::ANIMB: code_gen->WriteTodo(md.GetEntityName(), "ANIMB"); break;
         case OPCODES::TURNW: code_gen->WriteTodo(md.GetEntityName(), "TURNW"); break;
         case OPCODES::TURNW: code_gen->WriteTodo(md.GetEntityName(), "TURNW"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessJOIN(CodeGenerator* code_gen){
+void 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){
+void FieldModelInstruction::ProcessSPLIT(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
-    const auto& ax = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& ax = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetSigned(),
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[6]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& ay = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& ay = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetSigned(),
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[7]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& ar = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& ar = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[8]->GetSigned(),
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[8]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& bx = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& bx = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetSigned(),
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[9]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& by = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& by = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetSigned(),
       cg->GetFormatter(), params_[4]->GetUnsigned(), params_[10]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& br = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& br = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[5]->GetUnsigned(), params_[11]->GetSigned(),
       cg->GetFormatter(), params_[5]->GetUnsigned(), params_[11]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
     const auto& speed = params_[12]->GetUnsigned();
     const auto& speed = params_[12]->GetUnsigned();
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
@@ -185,26 +185,26 @@ void FF7::FieldModelInstruction::ProcessSPLIT(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessTLKON(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessTLKON(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_talkable(%2%)")
       boost::format("self.%1%:set_talkable(%2%)")
-      % entity % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
+      % entity % FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessPC(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessPC(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
       (boost::format("set_entity_to_character(\"%1%\", \"%1%\")") % entity).str()
       (boost::format("set_entity_to_character(\"%1%\", \"%1%\")") % entity).str()
     );
     );
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessCHAR(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessCHAR(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
       (boost::format("self.%1% = entity_manager:get_entity(\"%1%\")") % entity).str()
       (boost::format("self.%1% = entity_manager:get_entity(\"%1%\")") % entity).str()
     );
     );
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessDFANM(
+void FieldModelInstruction::ProcessDFANM(
   CodeGenerator* code_gen, const std::string& entity, int char_id
   CodeGenerator* code_gen, const std::string& entity, int char_id
 ){
 ){
     // ID will be fixed-up downstream.
     // ID will be fixed-up downstream.
@@ -222,7 +222,7 @@ void FF7::FieldModelInstruction::ProcessDFANM(
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessANIME1(
+void FieldModelInstruction::ProcessANIME1(
   CodeGenerator* code_gen, const std::string& entity, int char_id
   CodeGenerator* code_gen, const std::string& entity, int char_id
 ){
 ){
     // ID will be fixed-up downstream.
     // ID will be fixed-up downstream.
@@ -237,29 +237,29 @@ void FF7::FieldModelInstruction::ProcessANIME1(
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessVISI(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessVISI(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_visible(%2%)")
       boost::format("self.%1%:set_visible(%2%)")
-      % entity % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
+      % entity % FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessXYZI(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessXYZI(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
-    const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& x = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& y = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& z = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& z = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned(),
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& triangle_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& triangle_id = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetUnsigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetUnsigned()
     );
     );
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
@@ -268,16 +268,16 @@ void FF7::FieldModelInstruction::ProcessXYZI(CodeGenerator* code_gen, const std:
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessMOVE(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessMOVE(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
-    const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& x = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetSigned(),
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& y = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetSigned(),
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[3]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
       (boost::format("self.%1%:move_to_position(%2%, %3%)") % entity % x % y).str()
       (boost::format("self.%1%:move_to_position(%2%, %3%)") % entity % x % y).str()
@@ -285,32 +285,32 @@ void FF7::FieldModelInstruction::ProcessMOVE(CodeGenerator* code_gen, const std:
     code_gen->AddOutputLine((boost::format("self.%1%:move_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:move_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessMSPED(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessMSPED(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
-    const auto& speed = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& speed = 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
+      FieldCodeGenerator::ValueType::Float, 256.0f * scale / 30.0f
     );
     );
     code_gen->AddOutputLine(
     code_gen->AddOutputLine(
       (boost::format("self.%1%:set_move_auto_speed(%2%)") % entity % speed).str()
       (boost::format("self.%1%:set_move_auto_speed(%2%)") % entity % speed).str()
     );
     );
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessDIR(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessDIR(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& degrees = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& degrees = 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
+      FieldCodeGenerator::ValueType::Float, 256.0f / 360.0f
     );
     );
     code_gen->AddOutputLine((boost::format("self.%1%:set_rotation(%2%)") % entity % degrees).str());
     code_gen->AddOutputLine((boost::format("self.%1%:set_rotation(%2%)") % entity % degrees).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessTURNGEN(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessTURNGEN(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& degrees = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& degrees = 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
+      FieldCodeGenerator::ValueType::Float, 256.0f / 360.0f
     );
     );
     std::string direction;
     std::string direction;
     switch (params_[3]->GetUnsigned()){
     switch (params_[3]->GetUnsigned()){
@@ -336,10 +336,10 @@ void FF7::FieldModelInstruction::ProcessTURNGEN(CodeGenerator* code_gen, const s
     code_gen->AddOutputLine((boost::format("self.%1%:turn_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:turn_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessGETAI(CodeGenerator* code_gen, const FieldEngine& engine){
+void FieldModelInstruction::ProcessGETAI(CodeGenerator* code_gen, const FieldEngine& engine){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     // TODO: check for assignment to literal.
     // TODO: check for assignment to literal.
-    const auto& variable = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& variable = 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());
@@ -349,7 +349,7 @@ void FF7::FieldModelInstruction::ProcessGETAI(CodeGenerator* code_gen, const Fie
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessANIM_2(
+void FieldModelInstruction::ProcessANIM_2(
   CodeGenerator* code_gen, const std::string& entity, int char_id
   CodeGenerator* code_gen, const std::string& entity, int char_id
 ){
 ){
     // ID will be fixed-up downstream.
     // ID will be fixed-up downstream.
@@ -364,7 +364,7 @@ void FF7::FieldModelInstruction::ProcessANIM_2(
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessCANIM2(
+void FieldModelInstruction::ProcessCANIM2(
   CodeGenerator* code_gen, const std::string& entity, int char_id
   CodeGenerator* code_gen, const std::string& entity, int char_id
 ){
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
@@ -381,7 +381,7 @@ void FF7::FieldModelInstruction::ProcessCANIM2(
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessCANM_2(
+void FieldModelInstruction::ProcessCANM_2(
   CodeGenerator* code_gen, const std::string& entity, int char_id
   CodeGenerator* code_gen, const std::string& entity, int char_id
 ){
 ){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
@@ -399,28 +399,28 @@ void FF7::FieldModelInstruction::ProcessCANM_2(
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:animation_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessCC(CodeGenerator* code_gen, const FieldEngine& engine){
+void 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(
     code_gen->AddOutputLine(
       (boost::format("entity_manager:set_player_entity(\"%1%\")") % entity.GetName()).str()
       (boost::format("entity_manager:set_player_entity(\"%1%\")") % entity.GetName()).str()
     );
     );
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessJUMP(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessJUMP(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
-    float x = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    float x = std::stof(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     ));
     ));
-    float y = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    float y = std::stof(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     ));
     ));
-    int i = atoi(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    int i = atoi(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned()
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned()
     ).c_str());
     ).c_str());
-    int steps = atoi(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    int steps = atoi(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetSigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetSigned()
     ).c_str());
     ).c_str());
     //x *= 0.00781250273224;
     //x *= 0.00781250273224;
@@ -438,7 +438,7 @@ void FF7::FieldModelInstruction::ProcessJUMP(CodeGenerator* code_gen, const std:
     code_gen->AddOutputLine((boost::format("self.%1%:jump_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:jump_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessAXYZI(CodeGenerator* code_gen){
+void FieldModelInstruction::ProcessAXYZI(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
@@ -450,30 +450,30 @@ void FF7::FieldModelInstruction::ProcessAXYZI(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessLADER(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessLADER(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
-    const auto& x = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& x = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[4]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& y = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& y = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
       cg->GetFormatter(), params_[1]->GetUnsigned(), params_[5]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    const auto& z = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& z = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned(),
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[6]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     );
     );
-    uint end_triangle = atoi(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    uint end_triangle = atoi(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetUnsigned()
       cg->GetFormatter(), params_[3]->GetUnsigned(), params_[7]->GetUnsigned()
     ).c_str());
     ).c_str());
     uint keys = params_[8]->GetUnsigned();
     uint keys = params_[8]->GetUnsigned();
     uint animation = params_[9]->GetUnsigned();
     uint animation = params_[9]->GetUnsigned();
     //float orientation = params_[10]->GetUnsigned() / (256.0f / 360.0f);
     //float orientation = params_[10]->GetUnsigned() / (256.0f / 360.0f);
-    const auto& orientation = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& orientation = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), 0, params_[10]->GetSigned(),
       cg->GetFormatter(), 0, params_[10]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, 256.0f / 360.0f
+      FieldCodeGenerator::ValueType::Float, 256.0f / 360.0f
     );
     );
     uint speed = params_[11]->GetUnsigned();
     uint speed = params_[11]->GetUnsigned();
     // TODO: Animation hardcoded as "btce".
     // TODO: Animation hardcoded as "btce".
@@ -487,36 +487,31 @@ void FF7::FieldModelInstruction::ProcessLADER(CodeGenerator* code_gen, const std
     code_gen->AddOutputLine((boost::format("self.%1%:linear_sync()") % entity).str());
     code_gen->AddOutputLine((boost::format("self.%1%:linear_sync()") % entity).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessSOLID(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessSOLID(CodeGenerator* code_gen, const std::string& entity){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("self.%1%:set_solid(%2%)")
       boost::format("self.%1%:set_solid(%2%)")
-      % entity % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
+      % entity % FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModelInstruction::ProcessOFST(CodeGenerator* code_gen, const std::string& entity){
+void FieldModelInstruction::ProcessOFST(CodeGenerator* code_gen, const std::string& entity){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     const float scale = 128.0f * cg->GetScaleFactor();
     const float scale = 128.0f * cg->GetScaleFactor();
-    float x = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    float x = std::stof(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[5]->GetSigned(),
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[5]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     ));
     ));
-    float y = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    float y = std::stof(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[1]->GetUnsigned(),params_[6]->GetSigned(),
       cg->GetFormatter(), params_[1]->GetUnsigned(),params_[6]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     ));
     ));
-    float z = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    float z = std::stof(FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[7]->GetSigned(),
       cg->GetFormatter(), params_[2]->GetUnsigned(), params_[7]->GetSigned(),
-      FF7::FieldCodeGenerator::ValueType::Float, scale
+      FieldCodeGenerator::ValueType::Float, scale
     ));
     ));
-    float speed = std::stof(FF7::FieldCodeGenerator::FormatValueOrVariable(
+    float speed = std::stof(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?
-    //x *= 0.00390f;
-    //y *= 0.00390f;
-    //z *= 0.00390f;
     // Speed needs to be scaled down by the frame rate.
     // Speed needs to be scaled down by the frame rate.
     speed /= 30.0f;
     speed /= 30.0f;
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldModuleInstruction::ProcessInst(
+void FieldModuleInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
@@ -95,28 +95,28 @@ void FF7::FieldModuleInstruction::ProcessInst(
         case OPCODES::PMJMP2: code_gen->AddOutputLine("-- Prepare map change 2"); break;
         case OPCODES::PMJMP2: code_gen->AddOutputLine("-- Prepare map change 2"); break;
         case OPCODES::GAMEOVER: code_gen->WriteTodo(md.GetEntityName(), "GAMEOVER"); break;
         case OPCODES::GAMEOVER: code_gen->WriteTodo(md.GetEntityName(), "GAMEOVER"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldModuleInstruction::ProcessBATTLE(CodeGenerator* code_gen){
+void FieldModuleInstruction::ProcessBATTLE(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& battle_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& battle_id = 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());
     code_gen->AddOutputLine((boost::format("entity_manager:battle_run(%1%)") % battle_id).str());
 }
 }
 
 
-void FF7::FieldModuleInstruction::ProcessBTLON(CodeGenerator* code_gen){
+void FieldModuleInstruction::ProcessBTLON(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("entity_manager:random_encounters_on(%1%)")
       boost::format("entity_manager:random_encounters_on(%1%)")
-      % FF7::FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
+      % FieldCodeGenerator::FormatInvertedBool(params_[0]->GetUnsigned())
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldModuleInstruction::ProcessMAPJUMP(CodeGenerator* code_gen, Function& func){
+void FieldModuleInstruction::ProcessMAPJUMP(CodeGenerator* code_gen, Function& func){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     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);
     FunctionMetaData md(func.metadata);

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,6 +24,6 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldNoOperationInstruction::ProcessInst(
+void FieldNoOperationInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){}
 ){}

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldPartyInstruction::ProcessInst(
+void FieldPartyInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
@@ -56,24 +56,24 @@ void FF7::FieldPartyInstruction::ProcessInst(
         case OPCODES::MMBUK: code_gen->WriteTodo(md.GetEntityName(), "MMBUK"); break;
         case OPCODES::MMBUK: code_gen->WriteTodo(md.GetEntityName(), "MMBUK"); break;
         case OPCODES::CHGLD: code_gen->WriteTodo(md.GetEntityName(), "CHGLD"); break;
         case OPCODES::CHGLD: code_gen->WriteTodo(md.GetEntityName(), "CHGLD"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldPartyInstruction::ProcessSTITM(CodeGenerator* code_gen){
+void FieldPartyInstruction::ProcessSTITM(CodeGenerator* code_gen){
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* cg = static_cast<FieldCodeGenerator*>(code_gen);
-    const auto& item_id = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& item_id = FieldCodeGenerator::FormatValueOrVariable(
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
       cg->GetFormatter(), params_[0]->GetUnsigned(), params_[2]->GetUnsigned()
     );
     );
-    const auto& amount = FF7::FieldCodeGenerator::FormatValueOrVariable(
+    const auto& amount = 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());
     code_gen->AddOutputLine((boost::format("FFVII.add_item(%1%, %2%)") % item_id % amount).str());
 }
 }
 
 
-void FF7::FieldPartyInstruction::ProcessPRTYE(CodeGenerator* code_gen){
+void FieldPartyInstruction::ProcessPRTYE(CodeGenerator* code_gen){
     FieldCodeGenerator* gc = static_cast<FieldCodeGenerator*>(code_gen);
     FieldCodeGenerator* gc = static_cast<FieldCodeGenerator*>(code_gen);
     auto char_id_1 = gc->GetFormatter().GetFriendlyCharName(params_[0]->GetUnsigned());
     auto char_id_1 = gc->GetFormatter().GetFriendlyCharName(params_[0]->GetUnsigned());
     char_id_1 = (char_id_1 == "") ? "nil" : ("\"" + char_id_1 + "\"");
     char_id_1 = (char_id_1 == "") ? "nil" : ("\"" + char_id_1 + "\"");

+ 3 - 3
V-Gears-Installer/src/decompiler/field/instruction/FieldUncategorizedInstruction.cpp

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldUncategorizedInstruction::ProcessInst(
+void FieldUncategorizedInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
@@ -34,7 +34,7 @@ void FF7::FieldUncategorizedInstruction::ProcessInst(
         case OPCODES::GETX: code_gen->WriteTodo(md.GetEntityName(), "GETX"); break;
         case OPCODES::GETX: code_gen->WriteTodo(md.GetEntityName(), "GETX"); break;
         case OPCODES::SEARCHX: code_gen->WriteTodo(md.GetEntityName(), "SEARCHX"); break;
         case OPCODES::SEARCHX: code_gen->WriteTodo(md.GetEntityName(), "SEARCHX"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_)
               md.GetEntityName(), address_, opcode_)
             );
             );
     }
     }

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,16 +24,17 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-FF7::FieldUncondJumpInstruction::FieldUncondJumpInstruction() : is_func_call_(false) {}
+FieldUncondJumpInstruction::FieldUncondJumpInstruction() : is_func_call_(false) {}
 
 
-bool FF7::FieldUncondJumpInstruction::IsFuncCall() const{return is_func_call_;}
+bool FieldUncondJumpInstruction::IsFuncCall() const{return is_func_call_;}
 
 
-bool FF7::FieldUncondJumpInstruction::IsUncondJump() const{return !is_func_call_;}
+bool FieldUncondJumpInstruction::IsUncondJump() const{return !is_func_call_;}
 
 
-uint32 FF7::FieldUncondJumpInstruction::GetDestAddress() const{
+uint32 FieldUncondJumpInstruction::GetDestAddress() const{
     if (
     if (
       static_cast<OPCODES>(opcode_) == OPCODES::JMPF
       static_cast<OPCODES>(opcode_) == OPCODES::JMPF
-      || static_cast<OPCODES>(opcode_) == OPCODES::JMPFL){
+      || static_cast<OPCODES>(opcode_) == OPCODES::JMPFL
+    ){
         // Short or long forward jump.
         // Short or long forward jump.
         return address_ + params_[0]->GetUnsigned() + 1;
         return address_ + params_[0]->GetUnsigned() + 1;
     }
     }
@@ -41,14 +42,14 @@ uint32 FF7::FieldUncondJumpInstruction::GetDestAddress() const{
     return address_ - params_[0]->GetUnsigned();
     return address_ - params_[0]->GetUnsigned();
 }
 }
 
 
-std::ostream& FF7::FieldUncondJumpInstruction::Print(std::ostream &output) const{
+std::ostream& FieldUncondJumpInstruction::Print(std::ostream &output) const{
     Instruction::Print(output);
     Instruction::Print(output);
     output << " (Jump target address: 0x" << std::hex << GetDestAddress() << std::dec << ")";
     output << " (Jump target address: 0x" << std::hex << GetDestAddress() << std::dec << ")";
     return output;
     return output;
 }
 }
 
 
 
 
-void FF7::FieldUncondJumpInstruction::ProcessInst(
+void FieldUncondJumpInstruction::ProcessInst(
   Function& func, ValueStack& stack, Engine* engine, CodeGenerator* code_gen
   Function& func, ValueStack& stack, Engine* engine, CodeGenerator* code_gen
 ){
 ){
     switch (opcode_){
     switch (opcode_){

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldWalkmeshInstruction::ProcessInst(
+void FieldWalkmeshInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
@@ -36,26 +36,26 @@ void FF7::FieldWalkmeshInstruction::ProcessInst(
             code_gen->AddOutputLine(
             code_gen->AddOutputLine(
                 (boost::format("walkmesh:lock_walkmesh(%1%, %2%)")
                 (boost::format("walkmesh:lock_walkmesh(%1%, %2%)")
                 % params_[0]->GetUnsigned()
                 % params_[0]->GetUnsigned()
-                % FF7::FieldCodeGenerator::FormatBool(params_[1]->GetUnsigned())).str());
+                % FieldCodeGenerator::FormatBool(params_[1]->GetUnsigned())).str());
             break;
             break;
         case OPCODES::LINE: ProcessLINE(code_gen, md.GetEntityName()); break;
         case OPCODES::LINE: ProcessLINE(code_gen, md.GetEntityName()); break;
         case OPCODES::LINON: code_gen->WriteTodo(md.GetEntityName(), "LINON"); break;
         case OPCODES::LINON: code_gen->WriteTodo(md.GetEntityName(), "LINON"); break;
         case OPCODES::SLINE: code_gen->WriteTodo(md.GetEntityName(), "SLINE"); break;
         case OPCODES::SLINE: code_gen->WriteTodo(md.GetEntityName(), "SLINE"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldWalkmeshInstruction::ProcessUC(CodeGenerator* code_gen){
+void FieldWalkmeshInstruction::ProcessUC(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("entity_manager:player_lock(%1%)")
       boost::format("entity_manager:player_lock(%1%)")
-      % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
+      % FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldWalkmeshInstruction::ProcessLINE(CodeGenerator* code_gen, const std::string& entity){
+void FieldWalkmeshInstruction::ProcessLINE(CodeGenerator* code_gen, const std::string& entity){
     float xa = params_[0]->GetSigned();
     float xa = params_[0]->GetSigned();
     float ya = params_[1]->GetSigned();
     float ya = params_[1]->GetSigned();
     float za = params_[2]->GetSigned();
     float za = params_[2]->GetSigned();

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,10 +24,10 @@
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
 #include "decompiler/field/FieldDisassembler.h"
 
 
-void FF7::FieldWindowInstruction::ProcessInst(
+void FieldWindowInstruction::ProcessInst(
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
   Function& func, ValueStack&, Engine* engine, CodeGenerator *code_gen
 ){
 ){
-    FF7::FieldEngine& eng = static_cast<FF7::FieldEngine&>(*engine);
+    FieldEngine& eng = static_cast<FieldEngine&>(*engine);
     FunctionMetaData md(func.metadata);
     FunctionMetaData md(func.metadata);
     switch (opcode_){
     switch (opcode_){
         case OPCODES::TUTOR: code_gen->WriteTodo(md.GetEntityName(), "TUTOR"); break;
         case OPCODES::TUTOR: code_gen->WriteTodo(md.GetEntityName(), "TUTOR"); break;
@@ -52,13 +52,13 @@ void FF7::FieldWindowInstruction::ProcessInst(
         case OPCODES::GWCOL: code_gen->WriteTodo(md.GetEntityName(), "GWCOL"); break;
         case OPCODES::GWCOL: code_gen->WriteTodo(md.GetEntityName(), "GWCOL"); break;
         case OPCODES::SWCOL: code_gen->WriteTodo(md.GetEntityName(), "SWCOL"); break;
         case OPCODES::SWCOL: code_gen->WriteTodo(md.GetEntityName(), "SWCOL"); break;
         default:
         default:
-            code_gen->AddOutputLine(FF7::FieldCodeGenerator::FormatInstructionNotImplemented(
+            code_gen->AddOutputLine(FieldCodeGenerator::FormatInstructionNotImplemented(
               md.GetEntityName(), address_, opcode_
               md.GetEntityName(), address_, opcode_
             ));
             ));
     }
     }
 }
 }
 
 
-void FF7::FieldWindowInstruction::ProcessWINDOW(CodeGenerator* code_gen){
+void FieldWindowInstruction::ProcessWINDOW(CodeGenerator* code_gen){
     // Initializes a new window. It won't be displayed until MESSAGE is used.
     // Initializes a new window. It won't be displayed until MESSAGE is used.
     auto windowId = params_[0]->GetUnsigned();
     auto windowId = params_[0]->GetUnsigned();
     auto x = params_[1]->GetUnsigned();
     auto x = params_[1]->GetUnsigned();
@@ -71,7 +71,7 @@ void FF7::FieldWindowInstruction::ProcessWINDOW(CodeGenerator* code_gen){
     ).str());
     ).str());
 }
 }
 
 
-void FF7::FieldWindowInstruction::ProcessMESSAGE(
+void FieldWindowInstruction::ProcessMESSAGE(
   CodeGenerator* code_gen, const std::string& script_name
   CodeGenerator* code_gen, const std::string& script_name
 ){
 ){
     // Displays a dialog in the WINDOW that has previously been initialized to display this dialog.
     // Displays a dialog in the WINDOW that has previously been initialized to display this dialog.
@@ -87,21 +87,21 @@ void FF7::FieldWindowInstruction::ProcessMESSAGE(
 
 
 }
 }
 
 
-void FF7::FieldWindowInstruction::ProcessWCLSE(CodeGenerator* code_gen){
+void FieldWindowInstruction::ProcessWCLSE(CodeGenerator* code_gen){
     // Close a dialog.
     // Close a dialog.
     auto windowId = params_[0]->GetUnsigned();
     auto windowId = params_[0]->GetUnsigned();
     code_gen->AddOutputLine((boost::format("dialog:dialog_close(\"%1%\")") % windowId).str());
     code_gen->AddOutputLine((boost::format("dialog:dialog_close(\"%1%\")") % windowId).str());
 }
 }
 
 
-void FF7::FieldWindowInstruction::ProcessMPNAM(CodeGenerator* code_gen){
+void FieldWindowInstruction::ProcessMPNAM(CodeGenerator* code_gen){
     code_gen->AddOutputLine(
     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){
+void FieldWindowInstruction::ProcessMENU2(CodeGenerator* code_gen){
     code_gen->AddOutputLine((
     code_gen->AddOutputLine((
       boost::format("-- field:menu_lock(%1%)")
       boost::format("-- field:menu_lock(%1%)")
-      % FF7::FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
+      % FieldCodeGenerator::FormatBool(params_[0]->GetUnsigned())
     ).str());
     ).str());
 }
 }

+ 5 - 6
V-Gears-Installer/src/decompiler/world/WorldCodeGenerator.cpp

@@ -14,18 +14,17 @@
  */
  */
 
 
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
-
 #include "decompiler/world/WorldEngine.h"
 #include "decompiler/world/WorldEngine.h"
 
 
-FF7::WorldCodeGenerator::WorldCodeGenerator(Engine *engine, std::ostream &output)
+WorldCodeGenerator::WorldCodeGenerator(Engine *engine, std::ostream &output)
 : CodeGenerator(engine, output, FIFO_ARGUMENT_ORDER, LIFO_ARGUMENT_ORDER){}
 : CodeGenerator(engine, output, FIFO_ARGUMENT_ORDER, LIFO_ARGUMENT_ORDER){}
 
 
-std::string FF7::WorldCodeGenerator::ConstructFuncSignature(const Function& function){
+std::string WorldCodeGenerator::ConstructFuncSignature(const Function& function){
     // TODO: Implement.
     // TODO: Implement.
     return function.name + " = function(self)";
     return function.name + " = function(self)";
 }
 }
 
 
-const InstPtr FF7::WorldCodeGenerator::FindFirstCall(){
+const InstPtr WorldCodeGenerator::FindFirstCall(){
     ConstInstIterator it = cur_group_->start;
     ConstInstIterator it = cur_group_->start;
     do{
     do{
         if ((*it)->IsFuncCall() || (*it)->IsKernelCall()) return *it;
         if ((*it)->IsFuncCall() || (*it)->IsKernelCall()) return *it;
@@ -33,7 +32,7 @@ const InstPtr FF7::WorldCodeGenerator::FindFirstCall(){
     return *cur_group_->start;
     return *cur_group_->start;
 }
 }
 
 
-const InstPtr FF7::WorldCodeGenerator::FindLastCall(){
+const InstPtr WorldCodeGenerator::FindLastCall(){
     ConstInstIterator it = cur_group_->end;
     ConstInstIterator it = cur_group_->end;
     do {
     do {
         if ((*it)->IsFuncCall() || (*it)->IsKernelCall()) return *it;
         if ((*it)->IsFuncCall() || (*it)->IsKernelCall()) return *it;
@@ -41,4 +40,4 @@ const InstPtr FF7::WorldCodeGenerator::FindLastCall(){
     return *cur_group_->end;
     return *cur_group_->end;
 }
 }
 
 
-void FF7::WorldCodeGenerator::ProcessSpecialMetadata(const InstPtr inst, char c, int pos){}
+void WorldCodeGenerator::ProcessSpecialMetadata(const InstPtr inst, char c, int pos){}

+ 38 - 85
V-Gears-Installer/src/decompiler/world/WorldDisassembler.cpp

@@ -27,10 +27,10 @@
 #include "decompiler/world/instruction/WorldSubStackInstruction.h"
 #include "decompiler/world/instruction/WorldSubStackInstruction.h"
 #include "decompiler/world/instruction/WorldUncondJumpInstruction.h"
 #include "decompiler/world/instruction/WorldUncondJumpInstruction.h"
 
 
-FF7::WorldDisassembler::WorldDisassembler(WorldEngine*, InstVec &insts, int script_number):
+WorldDisassembler::WorldDisassembler(WorldEngine*, InstVec &insts, int script_number):
   Disassembler(insts), script_number_(script_number){}
   Disassembler(insts), script_number_(script_number){}
 
 
-FF7::WorldDisassembler::~WorldDisassembler(){}
+WorldDisassembler::~WorldDisassembler(){}
 
 
 /*
 /*
 00000202: reset stack (0)
 00000202: reset stack (0)
@@ -63,7 +63,7 @@ if(!Read(897))
 }
 }
 
 
 */
 */
-void FF7::WorldDisassembler::DoDisassemble(){
+void WorldDisassembler::DoDisassemble(){
     struct WorldScriptData{
     struct WorldScriptData{
         uint16 type = 0;
         uint16 type = 0;
         uint16 instruction_pointer = 0;
         uint16 instruction_pointer = 0;
@@ -93,9 +93,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
             else{
             else{
                 switch (opcode){
                 switch (opcode){
                     case 0x100:
                     case 0x100:
-                        ParseOpcode(
-                          opcode, "reset stack", new WorldNoOutputInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "reset stack", new WorldNoOutputInstruction(), 0, "");
                         break;
                         break;
                     case 0x201:
                     case 0x201:
                         ParseOpcode(
                         ParseOpcode(
@@ -141,9 +139,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         ParseOpcode(opcode, "push special", new WorldLoadInstruction(), 2, "w");
                         ParseOpcode(opcode, "push special", new WorldLoadInstruction(), 2, "w");
                         break;
                         break;
                     case 0x117:
                     case 0x117:
-                        ParseOpcode(
-                          opcode, "push special", new WorldLoadBankInstruction(), 2, "w"
-                        );
+                        ParseOpcode(opcode, "push special", new WorldLoadBankInstruction(), 2, "w");
                         break;
                         break;
 
 
                     case 0x0e0:
                     case 0x0e0:
@@ -169,7 +165,9 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         ParseOpcode(opcode, "push logicand", new WorldSubStackInstruction(), 2, "");
                         ParseOpcode(opcode, "push logicand", new WorldSubStackInstruction(), 2, "");
                         break;
                         break;
                     case 0x062:
                     case 0x062:
-                        ParseOpcode(opcode, "push lessequal", new WorldSubStackInstruction(), 2, "");
+                        ParseOpcode(
+                          opcode, "push lessequal", new WorldSubStackInstruction(), 2, ""
+                        );
                         break;
                         break;
                     case 0x030:
                     case 0x030:
                         ParseOpcode(opcode, "push mul", new WorldSubStackInstruction(), 2, "");
                         ParseOpcode(opcode, "push mul", new WorldSubStackInstruction(), 2, "");
@@ -184,7 +182,9 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         ParseOpcode(opcode, "push or", new WorldSubStackInstruction(), 2, "");
                         ParseOpcode(opcode, "push or", new WorldSubStackInstruction(), 2, "");
                         break;
                         break;
                     case 0x070:
                     case 0x070:
-                        ParseOpcode(opcode, "push equal", new WorldBinaryEqualStackInstruction(), 2, "");
+                        ParseOpcode(
+                          opcode, "push equal", new WorldBinaryEqualStackInstruction(), 2, ""
+                        );
                         break;
                         break;
                     case 0x041:
                     case 0x041:
                         ParseOpcode(opcode, "push sub", new WorldSubStackInstruction(), 2, "");
                         ParseOpcode(opcode, "push sub", new WorldSubStackInstruction(), 2, "");
@@ -211,94 +211,58 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         break;
                         break;
 
 
                     case 0x320:
                     case 0x320:
-                        ParseOpcode(
-                          opcode, "unknown 320", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 320", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x34a:
                     case 0x34a:
-                        ParseOpcode(
-                          opcode, "unknown 34a", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 34a", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x334:
                     case 0x334:
-                        ParseOpcode(
-                          opcode, "unknown 334", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 334", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x33a:
                     case 0x33a:
-                        ParseOpcode(
-                          opcode, "unknown 33a", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 33a", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x31c:
                     case 0x31c:
-                        ParseOpcode(
-                          opcode, "unknown 31c", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 31c", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x32f:
                     case 0x32f:
-                        ParseOpcode(
-                          opcode, "unknown 32f", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 32f", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x339:
                     case 0x339:
-                        ParseOpcode(
-                          opcode, "unknown 339", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 339", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x30d:
                     case 0x30d:
-                        ParseOpcode(
-                          opcode, "unknown 30d", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 30d", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x354:
                     case 0x354:
-                        ParseOpcode(
-                          opcode, "unknown 354", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 354", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x332:
                     case 0x332:
-                        ParseOpcode(
-                          opcode, "unknown 332", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 332", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x31f:
                     case 0x31f:
-                        ParseOpcode(
-                          opcode, "unknown 31f", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 31f", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x329:
                     case 0x329:
-                        ParseOpcode(
-                          opcode, "unknown 329", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 329", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x32a:
                     case 0x32a:
-                        ParseOpcode(
-                          opcode, "unknown 32a", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 32a", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x34d:
                     case 0x34d:
-                        ParseOpcode(
-                          opcode, "unknown 3d4", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 3d4", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x34e:
                     case 0x34e:
-                        ParseOpcode(
-                          opcode, "unknown 3de", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 3de", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x30a:
                     case 0x30a:
-                        ParseOpcode(
-                          opcode, "unknown 30a", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 30a", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x333:
                     case 0x333:
-                        ParseOpcode(
-                          opcode, "unknown 333", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 333", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x331:
                     case 0x331:
-                        ParseOpcode(
-                          opcode, "unknown 331", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 331", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x319:
                     case 0x319:
                         ParseOpcode(
                         ParseOpcode(
@@ -306,9 +270,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         );
                         );
                         break;
                         break;
                     case 0x353:
                     case 0x353:
-                        ParseOpcode(
-                          opcode, "unknown 353", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 353", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
                     case 0x33e:
                     case 0x33e:
                         ParseOpcode(
                         ParseOpcode(
@@ -316,9 +278,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         );
                         );
                         break;
                         break;
                     case 0x321:
                     case 0x321:
-                        ParseOpcode(
-                          opcode, "unknown 321", new WorldKernelCallInstruction(), 0, ""
-                        );
+                        ParseOpcode(opcode, "unknown 321", new WorldKernelCallInstruction(), 0, "");
                         break;
                         break;
 
 
                     case 0x31d:
                     case 0x31d:
@@ -340,8 +300,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         break;
                         break;
                     case 0x33d:
                     case 0x33d:
                         ParseOpcode(
                         ParseOpcode(
-                          opcode, "set field entry point2?",
-                          new WorldKernelCallInstruction(), 0, ""
+                          opcode, "set field entry point2?", new WorldKernelCallInstruction(), 0, ""
                         );
                         );
                         break;
                         break;
                     case 0x351:
                     case 0x351:
@@ -351,8 +310,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         break;
                         break;
                     case 0x352:
                     case 0x352:
                         ParseOpcode(
                         ParseOpcode(
-                          opcode, "shake camera on / off",
-                          new WorldKernelCallInstruction(), 0, ""
+                          opcode, "shake camera on / off", new WorldKernelCallInstruction(), 0, ""
                         );
                         );
                         break;
                         break;
                     case 0x34f:
                     case 0x34f:
@@ -400,20 +358,17 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         break;
                         break;
                     case 0x32c:
                     case 0x32c:
                         ParseOpcode(
                         ParseOpcode(
-                          opcode, "set window parameters",
-                          new WorldKernelCallInstruction(), 0, ""
+                          opcode, "set window parameters", new WorldKernelCallInstruction(), 0, ""
                         );
                         );
                         break;
                         break;
                     case 0x32d:
                     case 0x32d:
                         ParseOpcode(
                         ParseOpcode(
-                          opcode, "wait for window ready",
-                          new WorldKernelCallInstruction(), 0, ""
+                          opcode, "wait for window ready", new WorldKernelCallInstruction(), 0, ""
                         );
                         );
                         break;
                         break;
                     case 0x324:
                     case 0x324:
                         ParseOpcode(
                         ParseOpcode(
-                          opcode, "set window dimensions",
-                          new WorldKernelCallInstruction(), 0, ""
+                          opcode, "set window dimensions", new WorldKernelCallInstruction(), 0, ""
                         );
                         );
                         break;
                         break;
                     case 0x325:
                     case 0x325:
@@ -536,8 +491,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
                         break;
                         break;
                     case 0x313:
                     case 0x313:
                         ParseOpcode(
                         ParseOpcode(
-                          opcode, "set point terrain BGR",
-                          new WorldKernelCallInstruction(), 0, ""
+                          opcode, "set point terrain BGR", new WorldKernelCallInstruction(), 0, ""
                         );
                         );
                         break;
                         break;
                     case 0x314:
                     case 0x314:
@@ -561,8 +515,7 @@ void FF7::WorldDisassembler::DoDisassemble(){
                           opcode, "trigger battle", new WorldKernelCallInstruction(), 0, ""
                           opcode, "trigger battle", new WorldKernelCallInstruction(), 0, ""
                         );
                         );
                         break;
                         break;
-                    default:
-                        throw UnknownOpcodeException(this->address_, opcode);
+                    default: throw UnknownOpcodeException(this->address_, opcode);
                 }
                 }
             }
             }
             this->address_ += 2;
             this->address_ += 2;

+ 8 - 8
V-Gears-Installer/src/decompiler/world/WorldEngine.cpp

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -28,22 +28,22 @@
  */
  */
 #define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
 #define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
 
 
-FF7::WorldEngine::BankValue::BankValue(std::string name) : VarValue(name){}
+WorldEngine::BankValue::BankValue(std::string name) : VarValue(name){}
 
 
-FF7::WorldEngine::WorldEngine(int script_number) : script_number_(script_number){
+WorldEngine::WorldEngine(int script_number) : script_number_(script_number){
     SetOutputStackEffect(true);
     SetOutputStackEffect(true);
 }
 }
 
 
-std::unique_ptr<Disassembler> FF7::WorldEngine::GetDisassembler(InstVec &insts){
+std::unique_ptr<Disassembler> WorldEngine::GetDisassembler(InstVec &insts){
     return std::make_unique<WorldDisassembler>(this, insts, script_number_);
     return std::make_unique<WorldDisassembler>(this, insts, script_number_);
 }
 }
 
 
-std::unique_ptr<CodeGenerator> FF7::WorldEngine::GetCodeGenerator(
+std::unique_ptr<CodeGenerator> WorldEngine::GetCodeGenerator(
   const InstVec& insts, std::ostream &output){
   const InstVec& insts, std::ostream &output){
     return std::make_unique<WorldCodeGenerator>(this, output);
     return std::make_unique<WorldCodeGenerator>(this, output);
 }
 }
 
 
-void FF7::WorldEngine::PostCFG(InstVec&, Graph graph){
+void WorldEngine::PostCFG(InstVec&, Graph graph){
     /*
     /*
     VertexRange vr = boost::vertices(graph);
     VertexRange vr = boost::vertices(graph);
     for (VertexIterator v = vr.first; v != vr.second; ++ v){
     for (VertexIterator v = vr.first; v != vr.second; ++ v){
@@ -56,6 +56,6 @@ void FF7::WorldEngine::PostCFG(InstVec&, Graph graph){
     }*/
     }*/
 }
 }
 
 
-void FF7::WorldEngine::GetVariants(std::vector<std::string>&) const{}
+void WorldEngine::GetVariants(std::vector<std::string>&) const{}
 
 
-bool FF7::WorldEngine::UsePureGrouping() const {return false;}
+bool WorldEngine::UsePureGrouping() const {return false;}

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

@@ -10,7 +10,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -25,7 +25,7 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldBinaryEqualStackInstruction::ProcessInst(
+void WorldBinaryEqualStackInstruction::ProcessInst(
     Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
     Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
 ){
     code_gen_data_ = "==";
     code_gen_data_ = "==";

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

@@ -10,7 +10,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -25,15 +25,15 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldCondJumpInstruction::ProcessInst(Function&, ValueStack&, Engine*, CodeGenerator*){
+void WorldCondJumpInstruction::ProcessInst(Function&, ValueStack&, Engine*, CodeGenerator*){
     // TODO
     // TODO
 }
 }
 
 
-uint32 FF7::WorldCondJumpInstruction::GetDestAddress() const{
+uint32 WorldCondJumpInstruction::GetDestAddress() const{
     return 0x200 + params_[0]->GetUnsigned();
     return 0x200 + params_[0]->GetUnsigned();
 }
 }
 
 
-std::ostream& FF7::WorldCondJumpInstruction::Print(std::ostream &output) const{
+std::ostream& WorldCondJumpInstruction::Print(std::ostream &output) const{
     Instruction::Print(output);
     Instruction::Print(output);
     return output;
     return output;
 }
 }

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

@@ -10,7 +10,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -25,7 +25,7 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldKernelCallInstruction::ProcessInst(
+void WorldKernelCallInstruction::ProcessInst(
     Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
     Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
 ){
     std::string func;
     std::string func;

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,6 +24,6 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldLoadBankInstruction::ProcessInst(
+void WorldLoadBankInstruction::ProcessInst(
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){stack.Push(new WorldEngine::BankValue("Read(" + params_[0]->GetString() + ")"));}
 ){stack.Push(new WorldEngine::BankValue("Read(" + params_[0]->GetString() + ")"));}

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,6 +24,6 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldLoadInstruction::ProcessInst(
+void WorldLoadInstruction::ProcessInst(
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){stack.Push(new VarValue(params_[0]->GetString()));}
 ){stack.Push(new VarValue(params_[0]->GetString()));}

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

@@ -10,7 +10,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -25,7 +25,7 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldNoOutputInstruction::ProcessInst(
+void WorldNoOutputInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
 ){
     // TODO
     // TODO

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

@@ -10,7 +10,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -25,7 +25,7 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldStackInstruction::ProcessInst(
+void WorldStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
 ){
     // TODO
     // TODO

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

@@ -10,7 +10,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -25,12 +25,12 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldStoreInstruction::ProcessInst(
+void WorldStoreInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
 ){
     std::string value = stack.Pop()->GetString();
     std::string value = stack.Pop()->GetString();
     // If the bank address is from a load bank instruction, then only
     // If the bank address is from a load bank instruction, then only
-    // the bank address is needed, not whats *at* the bank address.
+    // the bank address is needed, not what's *at* the bank address.
     ValuePtr bank_addr = stack.Pop();
     ValuePtr bank_addr = stack.Pop();
     code_gen->AddOutputLine("Write(" + bank_addr->GetString() + ", " + value + ");");
     code_gen->AddOutputLine("Write(" + bank_addr->GetString() + ", " + value + ");");
 }
 }

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,7 +24,7 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-void FF7::WorldSubStackInstruction::ProcessInst(
+void WorldSubStackInstruction::ProcessInst(
     Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
     Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
 ){
     std::string op;
     std::string op;

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

@@ -9,7 +9,7 @@
  *
  *
  * This program is distributed in the hope that it will be useful,
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  * GNU General Public License for more details.
  *
  *
  * You should have received a copy of the GNU General Public License
  * You should have received a copy of the GNU General Public License
@@ -24,26 +24,26 @@
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldCodeGenerator.h"
 #include "decompiler/world/WorldDisassembler.h"
 #include "decompiler/world/WorldDisassembler.h"
 
 
-FF7::WorldUncondJumpInstruction::WorldUncondJumpInstruction() : is_call_(false) { }
+WorldUncondJumpInstruction::WorldUncondJumpInstruction() : is_call_(false) { }
 
 
-bool FF7::WorldUncondJumpInstruction::IsFuncCall() const{return is_call_;}
+bool WorldUncondJumpInstruction::IsFuncCall() const{return is_call_;}
 
 
-bool FF7::WorldUncondJumpInstruction::IsUncondJump() const{return !is_call_;}
+bool WorldUncondJumpInstruction::IsUncondJump() const{return !is_call_;}
 
 
-uint32 FF7::WorldUncondJumpInstruction::GetDestAddress() const{
+uint32 WorldUncondJumpInstruction::GetDestAddress() const{
     // The world map while loops are incorrect without +1'in this, but
     // The world map while loops are incorrect without +1'in this, but
     // doing that will break some if elses...
     // doing that will break some if elses...
     return 0x200 + params_[0]->GetUnsigned();// +1; // TODO: +1 to skip param?
     return 0x200 + params_[0]->GetUnsigned();// +1; // TODO: +1 to skip param?
 }
 }
 
 
-std::ostream& FF7::WorldUncondJumpInstruction::Print(std::ostream &output) const{
+std::ostream& WorldUncondJumpInstruction::Print(std::ostream &output) const{
     Instruction::Print(output);
     Instruction::Print(output);
     // output << " (Jump target address: 0x" << std::hex << GetDestAddress() << std::dec << ")";
     // output << " (Jump target address: 0x" << std::hex << GetDestAddress() << std::dec << ")";
     return output;
     return output;
 }
 }
 
 
 
 
-void FF7::WorldUncondJumpInstruction::ProcessInst(
+void WorldUncondJumpInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
   Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
 ){
     // TODO
     // TODO

+ 78 - 81
V-Gears/include/FF7Character.h

@@ -15,106 +15,103 @@
 
 
 #include "common/TypeDefine.h"
 #include "common/TypeDefine.h"
 
 
-namespace FFVII{
+/**
+ * A playable character.
+ */
+class Character{
+
+    public:
 
 
-    /**
-     * A playable character.
-     */
-    class Character{
+        /**
+         * Constructor.
+         */
+        Character();
 
 
-        public:
+        /**
+         * Destructor.
+         */
+        virtual ~Character();
+
+        /**
+         * List of character IDs.
+         */
+        enum CharacterId{
 
 
             /**
             /**
-             * Constructor.
+             * Cloud's ID.
              */
              */
-            Character();
+            CLOUD   = 0,
 
 
             /**
             /**
-             * Destructor.
+             * Tifa's ID.
              */
              */
-            virtual ~Character();
+            TIFA = 1,
 
 
             /**
             /**
-             * List of character IDs.
+             * Aerith's ID.
              */
              */
-            enum CharacterId{
-
-                /**
-                 * Cloud's ID.
-                 */
-                CLOUD   = 0,
-
-                /**
-                 * Tifa's ID.
-                 */
-                TIFA = 1,
-
-                /**
-                 * Aerith's ID.
-                 */
-                AERIS = 2,
-
-                /**
-                 * Barret's ID.
-                 */
-                BARRET = 3,
-
-                /**
-                 * Red XIII's ID.
-                 */
-                RED = 4,
-
-                /**
-                 * Cid's ID.
-                 */
-                CID = 5,
-
-                /**
-                 * Vincent's ID.
-                 */
-                VINCENT = 6,
-
-                /**
-                 * Yuffie's ID.
-                 */
-                YUVI = 7,
-
-                /**
-                 * Cait Sith's ID.
-                 */
-                KETCY = 8,
-
-                /**
-                 * Unknown character ID.
-                 */
-                UNKNOWN = 9
-            };
+            AERIS = 2,
 
 
             /**
             /**
-             * Retrieves a character ID from it's name.
-             *
-             * @param name[in] Chaarcter name.
-             * @return ID of the character with the specified name, or {@see
-             * UNKNOWN} if the character doesn't exist.
+             * Barret's ID.
              */
              */
-            static CharacterId GetIdByName( const VGears::String& name);
+            BARRET = 3,
 
 
-        private:
+            /**
+             * Red XIII's ID.
+             */
+            RED = 4,
+
+            /**
+             * Cid's ID.
+             */
+            CID = 5,
 
 
-            typedef std::map<VGears::String, CharacterId> CharacterIdLookupMap;
+            /**
+             * Vincent's ID.
+             */
+            VINCENT = 6,
 
 
             /**
             /**
-             * Creates a lookup map for character names.
-             *
-             * Names frequently used in the field scripts for the playable
-             * characters are included in the lookup map.
-             *
-             * @return The character name lookup map.
+             * Yuffie's ID.
              */
              */
-            static CharacterIdLookupMap CreateLookupMap();
+            YUVI = 7,
 
 
+            /**
+             * Cait Sith's ID.
+             */
+            KETCY = 8,
 
 
-            static const CharacterIdLookupMap character_id_lookup_;
-    };
-}
+            /**
+             * Unknown character ID.
+             */
+            UNKNOWN = 9
+        };
+
+        /**
+         * Retrieves a character ID from it's name.
+         *
+         * @param name[in] Chaarcter name.
+         * @return ID of the character with the specified name, or {@see
+         * UNKNOWN} if the character doesn't exist.
+         */
+        static CharacterId GetIdByName( const VGears::String& name);
+
+    private:
+
+        typedef std::map<VGears::String, CharacterId> CharacterIdLookupMap;
+
+        /**
+         * Creates a lookup map for character names.
+         *
+         * Names frequently used in the field scripts for the playable
+         * characters are included in the lookup map.
+         *
+         * @return The character name lookup map.
+         */
+        static CharacterIdLookupMap CreateLookupMap();
+
+
+        static const CharacterIdLookupMap character_id_lookup_;
+};
 
 

+ 22 - 25
V-Gears/include/FF7Common.h

@@ -19,37 +19,34 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
+    /**
+     * Defines game dimensions.
+     */
+    enum{
 
 
         /**
         /**
-         * Defines game dimensions.
+         * Game horizontal resolution, in pixels.
          */
          */
-        enum{
+        SCREEN_WIDTH = 320,
 
 
-            /**
-             * Game horizontal resolution, in pixels.
-             */
-            SCREEN_WIDTH = 320,
-
-            /**
-             * Game vertical resolution, in pixels.
-             */
-            SCREEN_HEIGHT = 240,
-
-            /**
-             * @todo Understand and document.
-             */
-            FIELD_POSITION_SCALE = 128,
+        /**
+         * Game vertical resolution, in pixels.
+         */
+        SCREEN_HEIGHT = 240,
 
 
-            /**
-             * @todo Understand and document.
-             */
-            FIELD_DEPTH_SCALE = 32
-        };
+        /**
+         * @todo Understand and document.
+         */
+        FIELD_POSITION_SCALE = 128,
 
 
         /**
         /**
-         * Extension for A files.
+         * @todo Understand and document.
          */
          */
-        extern const String EXT_A;
-    }
+        FIELD_DEPTH_SCALE = 32
+    };
+
+    /**
+     * Extension for A files.
+     */
+    extern const String EXT_A;
 }
 }

+ 422 - 470
V-Gears/include/common/FinalFantasy7/FF7NameLookup.h

@@ -23,512 +23,464 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
 
 
-        /**
-         * Handles Final Fantasy VII Metadata.
-         */
-        class FF7Metadata : public XmlFile{
-
-            public:
+    /**
+     * Handles Final Fantasy VII Metadata.
+     */
+    class FF7Metadata : public XmlFile{
+
+        public:
+
+            /**
+             * Constructor.
+             *
+             * @param file[in] The XML file.
+             */
+            FF7Metadata(Ogre::String file) : XmlFile(file){
+                TiXmlNode* node = file_.RootElement();
+                if (node == nullptr || node->ValueStr() != "metadata"){
+                    throw std::runtime_error(
+                      "FF7Metadata: " + file_.ValueStr()
+                      + " is not a valid metadata file! No <metadata> in root."
+                    );
+                }
 
 
-                /**
-                 * Constructor.
-                 *
-                 * @param file[in] The XML file.
-                 */
-                FF7Metadata(Ogre::String file) : XmlFile(file){
-                    TiXmlNode* node = file_.RootElement();
-                    if (node == nullptr || node->ValueStr() != "metadata"){
-                        throw std::runtime_error(
-                          "FF7Metadata: " + file_.ValueStr()
-                          + " is not a valid metadata file! "
-                          + "No <metadata> in root."
-                        );
+                node = node->FirstChild();
+                while (node){
+                    if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "models")
+                        ReadModels(node->FirstChild());
+                    else if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT&& node->ValueStr() == "animations"
+                    ){
+                        ReadAnimations(node->FirstChild());
                     }
                     }
-
-                    node = node->FirstChild();
-                    while (node){
-                        if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "models"
-                        ){
-                            ReadModels(node->FirstChild());
-                        }
-                        else if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "animations"
-                        ){
-                            ReadAnimations(node->FirstChild());
-                        }
-                        else if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "scripts"
-                        ){
-                            ReadScripts(node->FirstChild());
-                        }
-                        node = node->NextSibling();
+                    else if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "scripts"
+                    ){
+                        ReadScripts(node->FirstChild());
                     }
                     }
+                    node = node->NextSibling();
                 }
                 }
-
-                /**
-                 * Matches animation names.
-                 *
-                 * Looks for defined names associated to the original game
-                 * animation names. Defined names are more user friendly, more
-                 * readable and more descriptive.
-                 *
-                 * @param key[in] Original game animation name.
-                 * @return Friendly name associated to the animation, or the
-                 * original name if there is no name associated.
-                 */
-                const String& Animation(const String &key) const{
-                    auto it = animations_.find(key);
-                    if (it != std::end(animations_)) return it->second;
-                    String base_name;
-                    StringUtil::splitBase(key, base_name);
-                    it = animations_.find(base_name);
-                    if (it != std::end(animations_)) return it->second;
-                    return key;
+            }
+
+            /**
+             * Matches animation names.
+             *
+             * Looks for defined names associated to the original game
+             * animation names. Defined names are more user friendly, more
+             * readable and more descriptive.
+             *
+             * @param key[in] Original game animation name.
+             * @return Friendly name associated to the animation, or the
+             * original name if there is no name associated.
+             */
+            const String& Animation(const String &key) const{
+                auto it = animations_.find(key);
+                if (it != std::end(animations_)) return it->second;
+                String base_name;
+                StringUtil::splitBase(key, base_name);
+                it = animations_.find(base_name);
+                if (it != std::end(animations_)) return it->second;
+                return key;
+            }
+
+            /**
+             * Matches model names.
+             *
+             * Looks for defined names associated to the original game
+             * model names. Defined names are more user friendly, more
+             * readable and more descriptive.
+             *
+             * @param key[in] Original game model name.
+             * @return Friendly name associated to the model, or the
+             * original name if there is no name associated.
+             */
+            const String& Model(const String &key) const{
+                auto it = models_.find(key);
+                if (it != std::end(models_)) return it->second;
+                String base_name;
+                StringUtil::splitBase(key, base_name);
+                it = models_.find(base_name);
+                if (it != std::end(models_)) return it->second;
+                return key;
+            }
+
+        private:
+
+            /**
+             * Reads all models from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadModels(TiXmlNode* node){
+                while (node){
+                    const auto src = GetString(node, "name");
+                    const auto dst = GetString(node, "target");
+                    models_[src] = dst;
+                    node = node->NextSibling();
                 }
                 }
-
-                /**
-                 * Matches model names.
-                 *
-                 * Looks for defined names associated to the original game
-                 * model names. Defined names are more user friendly, more
-                 * readable and more descriptive.
-                 *
-                 * @param key[in] Original game model name.
-                 * @return Friendly name associated to the model, or the
-                 * original name if there is no name associated.
-                 */
-                const String& Model(const String &key) const{
-                    auto it = models_.find(key);
-                    if (it != std::end(models_)) return it->second;
-                    String base_name;
-                    StringUtil::splitBase(key, base_name);
-                    it = models_.find(base_name);
-                    if (it != std::end(models_)) return it->second;
-                    return key;
+            }
+
+            /**
+             * Reads all models from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadAnimations(TiXmlNode* node){
+                while (node){
+                    const auto src = GetString(node, "name");
+                    const auto dst = GetString(node, "target");
+                    animations_[src] = dst;
+                    node = node->NextSibling();
                 }
                 }
-
-            private:
-
-                /**
-                 * Reads all models from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadModels(TiXmlNode* node){
-                    while (node){
-                        const auto src = GetString(node, "name");
-                        const auto dst = GetString(node, "target");
-                        models_[src] = dst;
-                        node = node->NextSibling();
+            }
+
+
+            /**
+             * Reads all scripts from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadScripts(TiXmlNode* node){
+                while (node){
+                    if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT
+                      && node->ValueStr() == "CharacterIds"
+                    ){ReadCharacterIds(node->FirstChild());}
+                    else if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT
+                      && node->ValueStr() == "var_names"
+                    ){ReadVarNames(node->FirstChild());}
+                    else if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT
+                      && node->ValueStr() == "entity_names"
+                    ){ReadEntityNames(node->FirstChild());}
+                    else if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT
+                      && node->ValueStr() == "field"
+                    ){
+                        const auto name = GetString(node, "name");
+                        ReadField(node->FirstChild(), name);
                     }
                     }
+                    node = node->NextSibling();
                 }
                 }
-
-                /**
-                 * Reads all models from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadAnimations(TiXmlNode* node){
-                    while (node){
-                        const auto src = GetString(node, "name");
-                        const auto dst = GetString(node, "target");
-                        animations_[src] = dst;
-                        node = node->NextSibling();
+            }
+
+            /**
+             * Reads field information from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadField(TiXmlNode* node, const std::string& name){
+                while (node){
+                    if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "function"
+                    ){ReadFunction(node, name);}
+                    else if (
+                      node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity"
+                    ){
+                        const auto old_name = GetString(node, "name");
+                        const auto new_name = GetString(node, "new");
+                        field_data_[name].entity_name_map[old_name] = new_name;
                     }
                     }
+                    node = node->NextSibling();
                 }
                 }
-
-
-                /**
-                 * Reads all scripts from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadScripts(TiXmlNode* node){
-                    while (node){
-                        if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "CharacterIds"
-                        ){ReadCharacterIds(node->FirstChild());}
-                        else if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "var_names"
-                        ){ReadVarNames(node->FirstChild());}
-                        else if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "entity_names"
-                        ){ReadEntityNames(node->FirstChild());}
-                        else if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "field"
-                        ){
-                            const auto name = GetString(node, "name");
-                            ReadField(node->FirstChild(), name);
-                        }
-                        node = node->NextSibling();
+            }
+
+            /**
+             * Reads a function of a field from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadFunction(
+              TiXmlNode* node, const std::string& field_name
+            ){
+                const auto entity_name = GetString(node, "entity_name");
+                const auto old_name = GetString(node, "name");
+                const auto new_name = GetString(node, "new");
+                const auto comment = GetString(node, "Comment");
+                field_data_[field_name].function_map[entity_name][old_name]
+                  = std::make_pair(new_name, comment);
+            }
+
+            /**
+             * Reads all entity from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadEntityNames(TiXmlNode* node){
+                while (node){
+                    if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity"){
+                        const auto old_name = GetString(node, "name");
+                        const auto new_name = GetString(node, "new");
+                        entity_name_map_[old_name] = new_name;
                     }
                     }
+                    node = node->NextSibling();
                 }
                 }
-
-                /**
-                 * Reads field information from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadField(TiXmlNode* node, const std::string& name){
-                    while (node){
-                        if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "function"
-                        ){ReadFunction(node, name);}
-                        else if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "entity"
-                        ){
-                            const auto old_name = GetString(node, "name");
-                            const auto new_name = GetString(node, "new");
-                            field_data_[name].entity_name_map[old_name]
-                              = new_name;
-                        }
-                        node = node->NextSibling();
+            }
+
+            /**
+             * Reads all variable names from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadVarNames(TiXmlNode* node){
+                while (node){
+                    if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "var"){
+                        const auto bank = GetInt(node, "Bank");
+                        const auto address = GetInt(node, "Address");
+                        const auto name = GetString(node, "Name");
+                        var_map_[bank][address] = name;
                     }
                     }
+                    node = node->NextSibling();
                 }
                 }
-
-                /**
-                 * Reads a function of a field from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadFunction(
-                  TiXmlNode* node, const std::string& field_name
-                ){
-                    const auto entity_name = GetString(node, "entity_name");
-                    const auto old_name = GetString(node, "name");
-                    const auto new_name = GetString(node, "new");
-                    const auto comment = GetString(node, "Comment");
-                    field_data_[field_name].function_map[entity_name][old_name]
-                      = std::make_pair(new_name, comment);
-                }
-
-                /**
-                 * Reads all entity from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadEntityNames(TiXmlNode* node){
-                    while (node){
-                        if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "entity"
-                        ){
-                            const auto old_name = GetString(node, "name");
-                            const auto new_name = GetString(node, "new");
-                            entity_name_map_[old_name] = new_name;
-                        }
-                        node = node->NextSibling();
-                    }
-                }
-
-                /**
-                 * Reads all variable names from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadVarNames(TiXmlNode* node){
-                    while (node){
-                        if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "var"
-                        ){
-                            const auto bank = GetInt(node, "Bank");
-                            const auto address = GetInt(node, "Address");
-                            const auto name = GetString(node, "Name");
-                            var_map_[bank][address] = name;
-                        }
-                        node = node->NextSibling();
-                    }
-                }
-
-                /**
-                 * Reads all character identifiers from an XML node.
-                 *
-                 * @param node[in] XML node to read.
-                 */
-                void ReadCharacterIds(TiXmlNode* node){
-                    while (node){
-                        if (
-                          node->Type() == TiXmlNode::TINYXML_ELEMENT
-                          && node->ValueStr() == "char"
-                        ){
-                            const auto id = GetInt(node, "Id");
-                            const auto name = GetString(node, "Name");
-                            character_ids_[id] = name;
-                            node = node->NextSibling();
-                        }
+            }
+
+            /**
+             * Reads all character identifiers from an XML node.
+             *
+             * @param node[in] XML node to read.
+             */
+            void ReadCharacterIds(TiXmlNode* node){
+                while (node){
+                    if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "char"){
+                        const auto id = GetInt(node, "Id");
+                        const auto name = GetString(node, "Name");
+                        character_ids_[id] = name;
                         node = node->NextSibling();
                         node = node->NextSibling();
                     }
                     }
+                    node = node->NextSibling();
                 }
                 }
-
-                /**
-                 * Retrieves a field script function data.
-                 *
-                 * @param field_name[in] The name of the field from witch to
-                 * get the data.
-                 * @param entity_name[in] Name of the entity rom witch to
-                 * get the data.
-                 * @param old_function_name[in] The original function name.
-                 * @return Associated function name pair. An empty pair if the
-                 * field, entity or function don't exist.
-                 * @todo Verify documentation for old_function name and return
-                 * value.
-                 */
-                std::pair<String,String> FieldScriptFunctionData(
-                  const String& field_name, const String& entity_name,
-                  const String& old_function_name
-                ){
-                    // Find a collection of field data for this field.
-                    auto field_iterator = field_data_.find(field_name);
-                    if (field_iterator != std::end(field_data_)){
-                        // See if there is any info for this entity.
-                        auto entity_iterator
-                          = field_iterator->second.function_map.find(
-                            entity_name
-                          );
-                        if (
-                          entity_iterator
-                          != std::end(field_iterator->second.function_map)
-                        ){
-                            // See if there is any info for this function in
-                            // this entity.
-                            auto function_iterator
-                              = entity_iterator->second.find(old_function_name);
-                            if (
-                              function_iterator
-                              != std::end(entity_iterator->second)
-                            ){
-                                return function_iterator->second;
-                            }
-                        }
+            }
+
+            /**
+             * Retrieves a field script function data.
+             *
+             * @param field_name[in] The name of the field from witch to
+             * get the data.
+             * @param entity_name[in] Name of the entity rom witch to
+             * get the data.
+             * @param old_function_name[in] The original function name.
+             * @return Associated function name pair. An empty pair if the
+             * field, entity or function don't exist.
+             * @todo Verify documentation for old_function name and return
+             * value.
+             */
+            std::pair<String,String> FieldScriptFunctionData(
+              const String& field_name, const String& entity_name, const String& old_function_name
+            ){
+                // Find a collection of field data for this field.
+                auto field_iterator = field_data_.find(field_name);
+                if (field_iterator != std::end(field_data_)){
+                    // See if there is any info for this entity.
+                    auto entity_iterator = field_iterator->second.function_map.find(entity_name);
+                    if (entity_iterator != std::end(field_iterator->second.function_map)){
+                        // See if there is any info for this function in
+                        // this entity.
+                        auto function_iterator = entity_iterator->second.find(old_function_name);
+                        if (function_iterator != std::end(entity_iterator->second))
+                            return function_iterator->second;
                     }
                     }
-                    return std::make_pair("", "");
                 }
                 }
+                return std::make_pair("", "");
+            }
 
 
 
 
-                typedef std::map<String, String> LookupMap;
-
-                /**
-                 * The list of models.
-                 */
-                LookupMap models_;
-
-                /**
-                 * The list of animations.
-                 */
-                LookupMap animations_;
-
-                /**
-                 * Character identifier map.
-                 */
-                std::map<int, String> character_ids_;
-
-                /**
-                 * Variable map.
-                 */
-                std::map<int, std::map<int, String>> var_map_;
-
-                /**
-                 * Entity name map.
-                 */
-                LookupMap entity_name_map_;
-
-                /**
-                 * A field metadata representation.
-                 */
-                struct FieldMetaData{
-
-                    /**
-                     * Function map.
-                     *
-                     * Entity name to old function name finds new function name
-                     * and comment.
-                     */
-                    std::map<String, std::map<String, std::pair<String,String>>>
-                      function_map;
-
-                    /**
-                     * Entity name map.
-                     *
-                     * Old name finds new name
-                     */
-                    LookupMap entity_name_map;
-                };
-                std::map<String, FieldMetaData> field_data_;
+            typedef std::map<String, String> LookupMap;
 
 
-                friend class NameLookup;
+            /**
+             * The list of models.
+             */
+            LookupMap models_;
 
 
-        };
+            /**
+             * The list of animations.
+             */
+            LookupMap animations_;
 
 
-        /**
-         * Name lookup convenience class.
-         */
-        class NameLookup{
+            /**
+             * Character identifier map.
+             */
+            std::map<int, String> character_ids_;
 
 
-            public:
+            /**
+             * Variable map.
+             */
+            std::map<int, std::map<int, String>> var_map_;
 
 
-                /**
-                 * Constructor, not to use.
-                 */
-                NameLookup() = delete;
+            /**
+             * Entity name map.
+             */
+            LookupMap entity_name_map_;
 
 
-                /**
-                 * Retrieves a character name from an ID.
-                 */
-                static String CharName(int char_id){
-                    auto it = Data().character_ids_.find(char_id);
-                    if (it != std::end(Data().character_ids_))
-                        return it->second;
-                    // Empty becomes lua "nil" value for this special case:
-                    if (char_id == 254) return "";
-                    return std::to_string(char_id);
-                }
+            /**
+             * A field metadata representation.
+             */
+            struct FieldMetaData{
 
 
                 /**
                 /**
-                 * Matches animation names.
+                 * Function map.
                  *
                  *
-                 * Looks for defined names associated to the original game
-                 * animation names. Defined names are more user friendly, more
-                 * readable and more descriptive.
-                 *
-                 * @param key[in] Original game animation name.
-                 * @return Friendly name associated to the animation, or the
-                 * original name if there is no name associated.
+                 * Entity name to old function name finds new function name
+                 * and comment.
                  */
                  */
-                static const String& Animation(const String &key){
-                    return Data().Animation(key);
-                }
+                std::map<String, std::map<String, std::pair<String,String>>> function_map;
 
 
                 /**
                 /**
-                 * Matches model names.
-                 *
-                 * Looks for defined names associated to the original game
-                 * model names. Defined names are more user friendly, more
-                 * readable and more descriptive.
-                 *
-                 * @param key[in] Original game model name.
-                 * @return Friendly name associated to the model, or the
-                 * original name if there is no name associated.
-                 */
-                static const String& model(const String &key){
-                    return Data().Model(key);
-                }
-
-                /**
-                 * Retrieves a variable name.
-                 *
-                 * Variables that are frequently used across the game may
-                 * have an associated name, more fiendly and descriptive.
+                 * Entity name map.
                  *
                  *
-                 * @param bank[in] Variable bank.
-                 * @param addr[in] Variable address.
-                 * @return Friendly name associated to the variable, or an
-                 * empty string if it has no associated friendly name.
+                 * Old name finds new name
                  */
                  */
-                static String FieldScriptVarName(int bank, int addr){
-                    auto bank_iterator = Data().var_map_.find(bank);
-                    if (bank_iterator != std::end(Data().var_map_)){
-                        auto address_iterator
-                          = bank_iterator->second.find(addr);
-                        if (
-                          address_iterator != std::end(bank_iterator->second)
-                        ){
-                            if (address_iterator->second.empty() == false)
-                                return address_iterator->second;
-                        }
+                LookupMap entity_name_map;
+            };
+            std::map<String, FieldMetaData> field_data_;
+
+            friend class NameLookup;
+
+    };
+
+    /**
+     * Name lookup convenience class.
+     */
+    class NameLookup{
+
+        public:
+
+            /**
+             * Constructor, not to use.
+             */
+            NameLookup() = delete;
+
+            /**
+             * Retrieves a character name from an ID.
+             */
+            static String CharName(int char_id){
+                auto it = Data().character_ids_.find(char_id);
+                if (it != std::end(Data().character_ids_)) return it->second;
+                // Empty becomes lua "nil" value for this special case:
+                if (char_id == 254) return "";
+                return std::to_string(char_id);
+            }
+
+            /**
+             * Matches animation names.
+             *
+             * Looks for defined names associated to the original game
+             * animation names. Defined names are more user friendly, more
+             * readable and more descriptive.
+             *
+             * @param key[in] Original game animation name.
+             * @return Friendly name associated to the animation, or the
+             * original name if there is no name associated.
+             */
+            static const String& Animation(const String &key){return Data().Animation(key);}
+
+            /**
+             * Matches model names.
+             *
+             * Looks for defined names associated to the original game model
+             * names. Defined names are more user friendly, more readable and
+             * more descriptive.
+             *
+             * @param key[in] Original game model name.
+             * @return Friendly name associated to the model, or the original
+             * name if there is no name associated.
+             */
+            static const String& model(const String &key){return Data().Model(key);}
+
+            /**
+             * Retrieves a variable name.
+             *
+             * Variables that are frequently used across the game may have an
+             * associated name, more fiendly and descriptive.
+             *
+             * @param bank[in] Variable bank.
+             * @param addr[in] Variable address.
+             * @return Friendly name associated to the variable, or an empty
+             * string if it has no associated friendly name.
+             */
+            static String FieldScriptVarName(int bank, int addr){
+                auto bank_iterator = Data().var_map_.find(bank);
+                if (bank_iterator != std::end(Data().var_map_)){
+                    auto address_iterator = bank_iterator->second.find(addr);
+                    if (address_iterator != std::end(bank_iterator->second)){
+                        if (address_iterator->second.empty() == false)
+                            return address_iterator->second;
                     }
                     }
-                    return "";
-                }
-
-                /**
-                 * Matches entity names.
-                 *
-                 * Looks for defined names associated to the original game
-                 * entity name. Defined names are more user friendly, more
-                 * readable and more descriptive.
-                 *
-                 * @param old_entity_name[in] Original game entity name.
-                 * @return Friendly name associated to the entity, or the
-                 * original name if there is no name associated.
-                 */
-                static String FieldScriptEntityName(
-                  const String& old_entity_name
-                ){
-                    auto it = Data().entity_name_map_.find(old_entity_name);
-                    if (it != std::end(Data().entity_name_map_))
-                        return it->second;
-                    return old_entity_name;
-                }
-
-                /**
-                 * Matches function comments.
-                 *
-                 * @param field_name[in] The name of the field from witch to
-                 * get the data.
-                 * @param entity_name[in] Name of the entity rom witch to
-                 * get the data.
-                 * @param old_function_name[in] The original function name.
-                 * @return Associated function name pair. An empty pair if the
-                 * field, entity or function don't exist.
-                 * @todo Does this maps comments, or functions with comments?
-                 */
-                static String FieldScriptFunctionComment(
-                  const String& field_name, const String& entity_name,
-                  const String& old_function_name){
-                    return Data().FieldScriptFunctionData(
-                      field_name, entity_name, old_function_name
-                    ).second;
-                }
-
-                /**
-                 * Matches function names.
-                 *
-                 * Looks for defined names associated to the original game
-                 * function name. Defined names are more user friendly, more
-                 * readable and more descriptive.
-                 *
-                 * @param field_name[in] The name of the field from witch to
-                 * get the data.
-                 * @param entity_name[in] Name of the entity rom witch to
-                 * get the data.
-                 * @param old_function_name[in] The original function name.
-                 * @return Associated function name, or the original name if
-                 * there is no name associated.
-                 */
-                static String FieldScriptFunctionName(
-                  const String& field_name, const String& entity_name,
-                  const String& old_function_name
-                ){
-                    auto name = Data().FieldScriptFunctionData(
-                      field_name, entity_name, old_function_name
-                    ).first;
-                    if (name.empty()) return old_function_name;
-                    return name;
-                }
-
-                /**
-                 * Retrieves game metadata.
-                 *
-                 * @return The game metadata.
-                 */
-                static FF7Metadata& Data(){
-                    static FF7Metadata data(
-                      "field_models_and_animation_metadata.xml"
-                    );
-                    return data;
                 }
                 }
-        };
-    }
+                return "";
+            }
+
+            /**
+             * Matches entity names.
+             *
+             * Looks for defined names associated to the original game entity
+             * name. Defined names are more user friendly, more readable and
+             * more descriptive.
+             *
+             * @param old_entity_name[in] Original game entity name.
+             * @return Friendly name associated to the entity, or the original
+             * name if there is no name associated.
+             */
+            static String FieldScriptEntityName(const String& old_entity_name){
+                auto it = Data().entity_name_map_.find(old_entity_name);
+                if (it != std::end(Data().entity_name_map_)) return it->second;
+                return old_entity_name;
+            }
+
+            /**
+             * Matches function comments.
+             *
+             * @param field_name[in] The name of the field from witch to
+             * get the data.
+             * @param entity_name[in] Name of the entity rom witch to
+             * get the data.
+             * @param old_function_name[in] The original function name.
+             * @return Associated function name pair. An empty pair if the
+             * field, entity or function don't exist.
+             * @todo Does this maps comments, or functions with comments?
+             */
+            static String FieldScriptFunctionComment(
+              const String& field_name, const String& entity_name, const String& old_function_name
+            ){
+                return Data().FieldScriptFunctionData(
+                  field_name, entity_name, old_function_name
+                ).second;
+            }
+
+            /**
+             * Matches function names.
+             *
+             * Looks for defined names associated to the original game
+             * function name. Defined names are more user friendly, more
+             * readable and more descriptive.
+             *
+             * @param field_name[in] The name of the field from witch to
+             * get the data.
+             * @param entity_name[in] Name of the entity rom witch to
+             * get the data.
+             * @param old_function_name[in] The original function name.
+             * @return Associated function name, or the original name if
+             * there is no name associated.
+             */
+            static String FieldScriptFunctionName(
+              const String& field_name, const String& entity_name, const String& old_function_name
+            ){
+                auto name = Data().FieldScriptFunctionData(
+                  field_name, entity_name, old_function_name
+                ).first;
+                if (name.empty()) return old_function_name;
+                return name;
+            }
+
+            /**
+             * Retrieves game metadata.
+             *
+             * @return The game metadata.
+             */
+            static FF7Metadata& Data(){
+                static FF7Metadata data("field_models_and_animation_metadata.xml");
+                return data;
+            }
+    };
 }
 }

+ 140 - 145
V-Gears/include/data/FinalFantasy7/FF7ModelListFile.h

@@ -20,184 +20,179 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
-
-        /**
-         * Handles model list files.
-         */
-        class ModelListFile : public Resource{
-
-            public:
-
-                /**
-                 * Constructor.
-                 *
-                 * @param creator[in] Pointer to the ResourceManager that is
-                 * creating this resource.
-                 * @param name[in] The unique name of the resource.
-                 * @param handle[in] @todo Understand and document.
-                 * @param group[in] The name of the resource group to which this
-                 * resource belong.
-                 * @param is_manual[in] True if the resource is manually loaded,
-                 * false otherwise.
-                 * @param loader[in] Pointer to a ManualResourceLoader
-                 * implementation which will be called when the Resource wishes to
-                 * load (should be supplied if is_manual is set to true). It can be
-                 * null, but the Resource will never be able to reload if anything
-                 * ever causes it to unload. Therefore provision of a proper
-                 * ManualResourceLoader instance is strongly recommended.
-                 */
-                ModelListFile(
-                  Ogre::ResourceManager* creator, const String &name,
-                  Ogre::ResourceHandle handle, const String& group,
-                  bool is_manual = false,
-                  Ogre::ManualResourceLoader* loader = NULL
-                );
-
-                /**
-                * Destructor.
-                */
-                virtual ~ModelListFile();
+    /**
+     * Handles model list files.
+     */
+    class ModelListFile : public Resource{
+
+        public:
+
+            /**
+             * Constructor.
+             *
+             * @param creator[in] Pointer to the ResourceManager that is
+             * this resource.
+             * @param name[in] The unique name of the resource.
+             * @param handle[in] @todo Understand and document.
+             * @param group[in] The name of the resource group to which this
+             * resource belong.
+             * @param is_manual[in] True if the resource is manually loaded,
+             * false otherwise.
+             * @param loader[in] Pointer to a ManualResourceLoader
+             * implementation which will be called when the Resource wishes to
+             * load (should be supplied if is_manual is set to true). It can
+             * be null, but the Resource will never be able to reload if
+             * anything ever causes it to unload. Therefore provision of a
+             * proper ManualResourceLoader instance is strongly recommended.
+             */
+            ModelListFile(
+              Ogre::ResourceManager* creator, const String &name,
+              Ogre::ResourceHandle handle, const String& group,
+              bool is_manual = false, Ogre::ManualResourceLoader* loader = NULL
+            );
+
+            /**
+            * Destructor.
+            */
+            virtual ~ModelListFile();
+
+            /**
+             * The type of resource.
+             */
+            static const String RESOURCE_TYPE;
+
+            /**
+             * An animation description.
+             */
+            struct AnimationDescription{
 
 
                 /**
                 /**
-                 * The type of resource.
+                 * The animation name.
                  */
                  */
-                static const String RESOURCE_TYPE;
+                String  name;
 
 
                 /**
                 /**
-                 * An animation description.
+                 * Unknown data.
                  */
                  */
-                struct AnimationDescription{
+                uint16  unknown;
+            };
 
 
-                    /**
-                     * The animation name.
-                     */
-                    String  name;
+            typedef std::vector<AnimationDescription> AnimationList;
 
 
-                    /**
-                     * Unknown data.
-                     */
-                    uint16  unknown;
-                };
-
-                typedef std::vector<AnimationDescription> AnimationList;
+            /**
+             * Types of models.
+             */
+            enum ModelType{
 
 
                 /**
                 /**
-                 * Types of models.
+                 * Playable character.
                  */
                  */
-                enum ModelType{
-
-                    /**
-                     * Playable character.
-                     */
-                    PLAYER = 0,
-
-                    /**
-                     * Non playable character.
-                     */
-                    NPC = 1,
-
-                    /**
-                     * Unknown character type
-                     */
-                    UNKNOWN
-                };
+                PLAYER = 0,
 
 
                 /**
                 /**
-                 * A model.
+                 * Non playable character.
                  */
                  */
-                struct ModelDescription{
-
-                    /**
-                     * The model name.
-                     */
-                    String name;
-
-                    /**
-                     * The model type.
-                     */
-                    ModelType type;
-
-                    /**
-                     * HRC file name.
-                     *
-                     * HRC files describe bone hierarchy.
-                     */
-                    String hrc_name;
-
-                    /**
-                     * Scale for the model.
-                     */
-                    String scale;
-
-
-                    Ogre::ColourValue   light_colors[10];
-
-                    /**
-                     * List of animations assigned to the model.
-                     */
-                    AnimationList animations;
-                };
-
-                typedef std::vector<ModelDescription>   ModelList;
+                NPC = 1,
 
 
                 /**
                 /**
-                 * Retrieves the scale for the models.
-                 *
-                 * @return The scale.
+                 * Unknown character type
                  */
                  */
-                virtual uint16 GetScale() const;
+                UNKNOWN
+            };
 
 
-                /**
-                 * Sets the scale for the models.
-                 *
-                 * @param scale[in] The scale.
-                 */
-                virtual void SetScale(uint16 scale);
+            /**
+             * A model.
+             */
+            struct ModelDescription{
 
 
                 /**
                 /**
-                 * Retrieves the model list.
+                 * The model name.
                  */
                  */
-                virtual ModelList& GetModels();
-
-            protected:
-
+                String name;
 
 
                 /**
                 /**
-                 * Loads the file.
+                 * The model type.
                  */
                  */
-                virtual void loadImpl() override;
+                ModelType type;
 
 
                 /**
                 /**
-                 * Unloads the file.
+                 * HRC file name.
+                 *
+                 * HRC files describe bone hierarchy.
                  */
                  */
-                virtual void unloadImpl() override;
+                String hrc_name;
 
 
                 /**
                 /**
-                 * Calculates the size of the palette.
-                 *
-                 * @return The size of the palette.
-                 * @todo Units?
+                 * Scale for the model.
                  */
                  */
-                virtual size_t calculateSize( void ) const;
+                String scale;
 
 
-            private:
 
 
-                /**
-                 * The models scale.
-                 *
-                 * @todo Each model has it's own scale. Is this some kind of
-                 * global scale? If so, is it to be applied over each model
-                 * scale, or instead of it?
-                 */
-                uint16 scale_;
+                Ogre::ColourValue   light_colors[10];
 
 
                 /**
                 /**
-                 * The list of models.
+                 * List of animations assigned to the model.
                  */
                  */
-                ModelList models_;
-        };
-
-        typedef Ogre::SharedPtr<ModelListFile> ModelListFilePtr;
-    }
+                AnimationList animations;
+            };
+
+            typedef std::vector<ModelDescription>   ModelList;
+
+            /**
+             * Retrieves the scale for the models.
+             *
+             * @return The scale.
+             */
+            virtual uint16 GetScale() const;
+
+            /**
+             * Sets the scale for the models.
+             *
+             * @param scale[in] The scale.
+             */
+            virtual void SetScale(uint16 scale);
+
+            /**
+             * Retrieves the model list.
+             */
+            virtual ModelList& GetModels();
+
+        protected:
+
+            /**
+             * Loads the file.
+             */
+            virtual void loadImpl() override;
+
+            /**
+             * Unloads the file.
+             */
+            virtual void unloadImpl() override;
+
+            /**
+             * Calculates the size of the palette.
+             *
+             * @return The size of the palette.
+             * @todo Units?
+             */
+            virtual size_t calculateSize( void ) const;
+
+        private:
+
+            /**
+             * The models scale.
+             *
+             * @todo Each model has it's own scale. Is this some kind of
+             * global scale? If so, is it to be applied over each model
+             * scale, or instead of it?
+             */
+            uint16 scale_;
+
+            /**
+             * The list of models.
+             */
+            ModelList models_;
+    };
+
+    typedef Ogre::SharedPtr<ModelListFile> ModelListFilePtr;
 }
 }

+ 47 - 52
V-Gears/include/data/FinalFantasy7/FF7ModelListFileManager.h

@@ -21,62 +21,57 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
+    /**
+     * A manager for model list files.
+     */
+    class _VGearsExport ModelListFileManager:
+      public Ogre::ResourceManager, public Ogre::Singleton<ModelListFileManager>
+    {
+        public:
 
 
-        /**
-         * A manager for model list files.
-         */
-        class _VGearsExport ModelListFileManager :
-          public Ogre::ResourceManager,
-          public Ogre::Singleton<ModelListFileManager>
-        {
-            public:
+            /**
+             * Constructor.
+             */
+            ModelListFileManager();
 
 
-                /**
-                 * Constructor.
-                 */
-                ModelListFileManager();
+            /**
+             * Destructor.
+             */
+            virtual ~ModelListFileManager();
 
 
-                /**
-                 * Destructor.
-                 */
-                virtual ~ModelListFileManager();
+            /**
+             * Retrieves a singleton to the manager.
+             */
+            static ModelListFileManager& GetSingleton();
 
 
-                /**
-                 * Retrieves a singleton to the manager.
-                 */
-                static ModelListFileManager& GetSingleton();
+            /**
+             * Retrieves a pointer to the manager singleton.
+             */
+            static ModelListFileManager *GetSingletonPtr();
 
 
-                /**
-                 * Retrieves a pointer to the manager singleton.
-                 */
-                static ModelListFileManager *GetSingletonPtr();
+        protected:
 
 
-            protected:
-
-                /**
-                 * Loads the manager.
-                 *
-                 * @param name[in] The unique name of the manager.
-                 * @param handle[in] @todo Understand and document.
-                 * @param group[in] The name of the resource group to which this
-                 * resource belong.
-                 * @param is_manual[in] True if the resource is manually loaded,
-                 * false otherwise.
-                 * @param loader[in] Pointer to a ManualResourceLoader
-                 * implementation which will be called when the Resource wishes to
-                 * load (should be supplied if is_manual is set to true). It can be
-                 * null, but the Resource will never be able to reload if anything
-                 * ever causes it to unload. Therefore provision of a proper
-                 * ManualResourceLoader instance is strongly recommended.
-                 * @param create_params[in] Unused.
-                 */
-                Ogre::Resource *createImpl(
-                  const Ogre::String &name, Ogre::ResourceHandle handle,
-                  const Ogre::String &group, bool is_manual,
-                  Ogre::ManualResourceLoader *loader,
-                  const Ogre::NameValuePairList *create_params
-                );
-        };
-    }
+            /**
+             * Loads the manager.
+             *
+             * @param name[in] The unique name of the manager.
+             * @param handle[in] @todo Understand and document.
+             * @param group[in] The name of the resource group to which this
+             * resource belong.
+             * @param is_manual[in] True if the resource is manually loaded,
+             * false otherwise.
+             * @param loader[in] Pointer to a ManualResourceLoader
+             * implementation which will be called when the Resource wishes to
+             * load (should be supplied if is_manual is set to true). It can
+             * be null, but the Resource will never be able to reload if
+             * anything ever causes it to unload. Therefore provision of a
+             * proper ManualResourceLoader instance is strongly recommended.
+             * @param create_params[in] Unused.
+             */
+            Ogre::Resource *createImpl(
+              const Ogre::String &name, Ogre::ResourceHandle handle,
+              const Ogre::String &group, bool is_manual,
+              Ogre::ManualResourceLoader *loader, const Ogre::NameValuePairList *create_params
+            );
+    };
 }
 }

+ 64 - 75
V-Gears/include/data/FinalFantasy7/FF7ModelListFileSerializer.h

@@ -22,92 +22,81 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
+    /**
+     * Handles the serialization of model list files.
+     */
+    class ModelListFileSerializer : public Serializer{
 
 
-        /**
-         * Handles the serialization of model list files.
-         */
-        class ModelListFileSerializer : public Serializer{
+        public:
 
 
-            public:
+            /**
+             * Constructor.
+             */
+            ModelListFileSerializer();
 
 
-                /**
-                 * Constructor.
-                 */
-                ModelListFileSerializer();
+            /**
+             * Destructor.
+             */
+            virtual ~ModelListFileSerializer();
 
 
-                /**
-                 * Destructor.
-                 */
-                virtual ~ModelListFileSerializer();
+            /**
+             * Imports a model list file.
+             *
+             * @param stream[in] The contents of the model list file.
+             * @param dest[out] The formed model list file.
+             */
+            virtual void ImportModelListFile(Ogre::DataStreamPtr &stream, ModelListFile *dest);
 
 
-                /**
-                 * Imports a model list file.
-                 *
-                 * @param stream[in] The contents of the model list file.
-                 * @param dest[out] The formed model list file.
-                 */
-                virtual void ImportModelListFile(
-                  Ogre::DataStreamPtr &stream, ModelListFile *dest
-                );
+            typedef ModelListFile::AnimationDescription AnimationDescription;
 
 
-                typedef ModelListFile::AnimationDescription
-                  AnimationDescription;
+            typedef ModelListFile::ModelDescription ModelDescription;
 
 
-                typedef ModelListFile::ModelDescription ModelDescription;
+            /**
+             * Data sizes in the file.
+             */
+            enum {
 
 
                 /**
                 /**
-                 * Data sizes in the file.
+                 * Length of the name of the HRC file assigned to a model.
                  */
                  */
-                enum {
-
-                    /**
-                     * Length of the name of the HRC file assigned to a model.
-                     */
-                    HRC_NAME_LENGTH = 8,
-
-                    /**
-                     * Scale data length.
-                     */
-                    SCALE_LENGTH = 4
-                };
-
-            protected:
+                HRC_NAME_LENGTH = 8,
 
 
                 /**
                 /**
-                 * Reads an object as an animation description.
-                 *
-                 * @param stream[in] Input data.
-                 * @param dest[out] The formed animation description data.
+                 * Scale data length.
                  */
                  */
-                virtual void readObject(
-                  Ogre::DataStreamPtr &stream, AnimationDescription &dest
-                );
-
-                /**
-                 * Reads an object as a model description.
-                 *
-                 * @param stream[in] Input data.
-                 * @param dest[out] The formed model description data.
-                 */
-                virtual void readObject(
-                  Ogre::DataStreamPtr &stream, ModelDescription &dest
-                );
-
-                using Serializer::readObject;
-
-                /**
-                 * Reads an object as a vector.
-                 *
-                 * @param stream[in] Input data.
-                 * @param dest[out] The formed vector data.
-                 * @param count[in] The size of the data to read.
-                 */
-                template<typename ValueType> void ReadVector(
-                  Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest,
-                  size_t count
-                );
-
-        };
-    }
+                SCALE_LENGTH = 4
+            };
+
+        protected:
+
+            /**
+             * Reads an object as an animation description.
+             *
+             * @param stream[in] Input data.
+             * @param dest[out] The formed animation description data.
+             */
+            virtual void readObject(Ogre::DataStreamPtr &stream, AnimationDescription &dest);
+
+            /**
+             * Reads an object as a model description.
+             *
+             * @param stream[in] Input data.
+             * @param dest[out] The formed model description data.
+             */
+            virtual void readObject(Ogre::DataStreamPtr &stream, ModelDescription &dest);
+
+            using Serializer::readObject;
+
+            /**
+             * Reads an object as a vector.
+             *
+             * @param stream[in] Input data.
+             * @param dest[out] The formed vector data.
+             * @param count[in] The size of the data to read.
+             */
+            template<typename ValueType> void ReadVector(
+              Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest, size_t count
+            );
+
+    };
 }
 }

+ 0 - 4
V-Gears/include/data/VGearsFLevelFile.h

@@ -30,10 +30,6 @@
 namespace VGears{
 namespace VGears{
     // TODO: move flevel stuff to ff7 as it is ff7 related!?
     // TODO: move flevel stuff to ff7 as it is ff7 related!?
 
 
-    using FF7::ModelListFile;
-
-    using FF7::ModelListFilePtr;
-
     class FLevelTextureLoader;
     class FLevelTextureLoader;
 
 
     class FLevelBackground2DLoader;
     class FLevelBackground2DLoader;

+ 103 - 114
V-Gears/include/map/FinalFantasy7/FF7WalkmeshFileSerializer.h

@@ -21,148 +21,137 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
+    /**
+     * Handles the serialization of walkmesh files.
+     */
+    class WalkmeshFileSerializer : public Serializer{
 
 
-        /**
-         * Handles the serialization of walkmesh files.
-         */
-        class WalkmeshFileSerializer : public Serializer{
+        public:
 
 
-            public:
+            /**
+             * Constructor.
+             */
+            WalkmeshFileSerializer();
 
 
-                /**
-                 * Constructor.
-                 */
-                WalkmeshFileSerializer();
+            /**
+             * Destructor.
+             */
+            virtual ~WalkmeshFileSerializer();
+
+            /**
+             * Imports a walkmesh file.
+             *
+             * @param stream[in] The contents of the walkmesh file.
+             * @param dest[out] The formed walkmesh file.
+             */
+            virtual void ImportWalkmeshFile(Ogre::DataStreamPtr &stream, WalkmeshFile *dest);
+
+            typedef WalkmeshFile::Triangle WalkmeshTriangle;
+
+            typedef WalkmeshFile::TriangleList WalkmeshTriangleList;
+
+            /**
+             * @todo Understand and document.
+             */
+            enum{
 
 
                 /**
                 /**
-                 * Destructor.
+                 * @todo Understand and document.
                  */
                  */
-                virtual ~WalkmeshFileSerializer();
+                VERTEX_PADDING_COUNT = 1,
 
 
                 /**
                 /**
-                 * Imports a walkmesh file.
-                 *
-                 * @param stream[in] The contents of the walkmesh file.
-                 * @param dest[out] The formed walkmesh file.
+                 * @todo Understand and document.
                  */
                  */
-                virtual void ImportWalkmeshFile(
-                  Ogre::DataStreamPtr &stream, WalkmeshFile *dest
-                );
-
-                typedef WalkmeshFile::Triangle WalkmeshTriangle;
-                typedef WalkmeshFile::TriangleList WalkmeshTriangleList;
+                VERTEX_COMPONENT_COUNT = 3 + VERTEX_PADDING_COUNT,
 
 
                 /**
                 /**
                  * @todo Understand and document.
                  * @todo Understand and document.
                  */
                  */
-                enum{
-
-                    /**
-                     * @todo Understand and document.
-                     */
-                    VERTEX_PADDING_COUNT = 1,
-
-                    /**
-                     * @todo Understand and document.
-                     */
-                    VERTEX_COMPONENT_COUNT = 3 + VERTEX_PADDING_COUNT,
+                ACCESS_COMPONENT_COUNT = 3
+            };
 
 
-                    /**
-                     * @todo Understand and document.
-                     */
-                    ACCESS_COMPONENT_COUNT = 3
-                };
+            /**
+             * A walkmesh triangle.
+             */
+            struct Triangle{
 
 
                 /**
                 /**
-                 * A walkmesh triangle.
+                 * A side of the triangle.
                  */
                  */
-                struct Triangle{
-
-                    /**
-                     * A side of the triangle.
-                     */
-                    Ogre::Vector3 a;
-
-                    /**
-                     * A side of the triangle.
-                     */
-                    Ogre::Vector3 b;
-
-                    /**
-                     * A side of the triangle.
-                     */
-                    Ogre::Vector3 c;
-                };
+                Ogre::Vector3 a;
 
 
                 /**
                 /**
-                 * Defines the access to a triangle.
+                 * A side of the triangle.
                  */
                  */
-                struct Access{
-                    /**
-                     * @todo Understand and document.
-                     */
-                    sint16 a;
-                    /**
-                     * @todo Understand and document.
-                     */
-                    sint16 b;
-                    /**
-                     * @todo Understand and document.
-                     */
-                    sint16 c;
-                };
-
-                typedef std::vector<Triangle> TriangleList;
-
-                typedef std::vector<Access> AccessList;
-
-            protected:
+                Ogre::Vector3 b;
 
 
                 /**
                 /**
-                 * Reads an object as a walkmesh triangle.
-                 *
-                 * @param stream[in] Input data.
-                 * @param dest[out] The formed triangle data.
+                 * A side of the triangle.
                  */
                  */
-                virtual void readObject(
-                  Ogre::DataStreamPtr &stream, Triangle &dest
-                );
+                Ogre::Vector3 c;
+            };
 
 
+            /**
+             * Defines the access to a triangle.
+             */
+            struct Access{
                 /**
                 /**
-                 * Reads an object as a 3-dimensional vector.
-                 *
-                 * @param stream[in] Input data.
-                 * @param dest[out] The formed vector data.
+                 * @todo Understand and document.
                  */
                  */
-                virtual void readObject(
-                  Ogre::DataStreamPtr &stream, Ogre::Vector3 &dest
-                );
-
+                sint16 a;
                 /**
                 /**
-                 * Reads an object as a triangle access point.
-                 *
-                 * @param stream[in] Input data.
-                 * @param dest[out] The formed access point data.
+                 * @todo Understand and document.
                  */
                  */
-                virtual void readObject(
-                  Ogre::DataStreamPtr &stream, Access &dest
-                );
-
-                using Serializer::readObject;
-
+                sint16 b;
                 /**
                 /**
-                 * Reads an object as a vector.
-                 *
-                 * @param stream[in] Input data.
-                 * @param dest[out] The formed vector data.
-                 * @param count[in] The size of the data to read.
+                 * @todo Understand and document.
                  */
                  */
-                template<typename ValueType> void ReadVector(
-                  Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest,
-                  size_t count
-                );
-
-        };
-    }
+                sint16 c;
+            };
+
+            typedef std::vector<Triangle> TriangleList;
+
+            typedef std::vector<Access> AccessList;
+
+        protected:
+
+            /**
+             * Reads an object as a walkmesh triangle.
+             *
+             * @param stream[in] Input data.
+             * @param dest[out] The formed triangle data.
+             */
+            virtual void readObject(Ogre::DataStreamPtr &stream, Triangle &dest);
+
+            /**
+             * Reads an object as a 3-dimensional vector.
+             *
+             * @param stream[in] Input data.
+             * @param dest[out] The formed vector data.
+             */
+            virtual void readObject(Ogre::DataStreamPtr &stream, Ogre::Vector3 &dest);
+
+            /**
+             * Reads an object as a triangle access point.
+             *
+             * @param stream[in] Input data.
+             * @param dest[out] The formed access point data.
+             */
+            virtual void readObject(Ogre::DataStreamPtr &stream, Access &dest);
+
+            using Serializer::readObject;
+
+            /**
+             * Reads an object as a vector.
+             *
+             * @param stream[in] Input data.
+             * @param dest[out] The formed vector data.
+             * @param count[in] The size of the data to read.
+             */
+            template<typename ValueType> void ReadVector(
+              Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest, size_t count
+            );
+
+    };
 }
 }

+ 62 - 67
V-Gears/src/FF7Character.cpp

@@ -16,75 +16,70 @@
 
 
 #include "FF7Character.h"
 #include "FF7Character.h"
 
 
-namespace FFVII{
+Character::Character(){}
 
 
-    Character::Character(){}
+Character::~Character(){}
 
 
-    Character::~Character(){}
-
-    Character::CharacterIdLookupMap Character::CreateLookupMap(){
-        CharacterIdLookupMap lookup;
-        lookup["Cloud"] = CLOUD;
-        lookup["cloud"] = CLOUD;
-        lookup["CLOUD"] = CLOUD;
-        lookup["AAAA"] = CLOUD;
-        lookup["n_cloud"] = CLOUD;
-        lookup["Tifa"] = TIFA;
-        lookup["tifa"] = TIFA;
-        lookup["TIFA"] = TIFA;
-        lookup["AAGB"] = TIFA;
-        lookup["n_tifa"] = TIFA;
-        lookup["Aeris"] = AERIS;
-        lookup["AERIS"] = AERIS;
-        lookup["aerit"] = AERIS;
-        lookup["AUFF"] = AERIS;
-        lookup["CAHC"] = AERIS;
-        lookup["n_erith"] = AERIS;
-        lookup["earithf"] = AERIS;
-        lookup["Barret"] = BARRET;
-        lookup["barret"] = BARRET;
-        lookup["BARRET"] = BARRET;
-        lookup["ACGD"] = BARRET;
-        lookup["ballet"] = BARRET;
-        lookup["Red"] = RED;
-        lookup["red"] = RED;
-        lookup["RED"] = RED;
-        lookup["Red XIII"] = RED;
-        lookup["RedXIII"] = RED;
-        lookup["ADDA"] = RED;
-        lookup["red"] = RED;
-        lookup["Cid"] = CID;
-        lookup["CID"] = CID;
-        lookup["cid"] = CID;
-        lookup["ABDA"] = CID;
-        lookup["AEHD"] = VINCENT;
-        lookup["Vincent"] = VINCENT;
-        lookup["VINCENT"] = VINCENT;
-        lookup["vincent"] = VINCENT;
-        lookup["Yuffie"] = YUVI;
-        lookup["yuffie"] = YUVI;
-        lookup["YUFFIE"] = YUVI;
-        lookup["ABJB"] = YUVI;
-        lookup["yufi"] = YUVI;
-        lookup["Cait Sith"] = KETCY;
-        lookup["Cait sith"] = KETCY;
-        lookup["CAIT SITH"] = KETCY;
-        lookup["CaitSith"] = KETCY;
-        lookup["Caitsith"] = KETCY;
-        lookup["CAITSITH"] = KETCY;
-        lookup["AEBC"] = KETCY;
-        lookup["ketcy"] = KETCY;
-        return lookup;
-    }
+Character::CharacterIdLookupMap Character::CreateLookupMap(){
+    CharacterIdLookupMap lookup;
+    lookup["Cloud"] = CLOUD;
+    lookup["cloud"] = CLOUD;
+    lookup["CLOUD"] = CLOUD;
+    lookup["AAAA"] = CLOUD;
+    lookup["n_cloud"] = CLOUD;
+    lookup["Tifa"] = TIFA;
+    lookup["tifa"] = TIFA;
+    lookup["TIFA"] = TIFA;
+    lookup["AAGB"] = TIFA;
+    lookup["n_tifa"] = TIFA;
+    lookup["Aeris"] = AERIS;
+    lookup["AERIS"] = AERIS;
+    lookup["aerit"] = AERIS;
+    lookup["AUFF"] = AERIS;
+    lookup["CAHC"] = AERIS;
+    lookup["n_erith"] = AERIS;
+    lookup["earithf"] = AERIS;
+    lookup["Barret"] = BARRET;
+    lookup["barret"] = BARRET;
+    lookup["BARRET"] = BARRET;
+    lookup["ACGD"] = BARRET;
+    lookup["ballet"] = BARRET;
+    lookup["Red"] = RED;
+    lookup["red"] = RED;
+    lookup["RED"] = RED;
+    lookup["Red XIII"] = RED;
+    lookup["RedXIII"] = RED;
+    lookup["ADDA"] = RED;
+    lookup["red"] = RED;
+    lookup["Cid"] = CID;
+    lookup["CID"] = CID;
+    lookup["cid"] = CID;
+    lookup["ABDA"] = CID;
+    lookup["AEHD"] = VINCENT;
+    lookup["Vincent"] = VINCENT;
+    lookup["VINCENT"] = VINCENT;
+    lookup["vincent"] = VINCENT;
+    lookup["Yuffie"] = YUVI;
+    lookup["yuffie"] = YUVI;
+    lookup["YUFFIE"] = YUVI;
+    lookup["ABJB"] = YUVI;
+    lookup["yufi"] = YUVI;
+    lookup["Cait Sith"] = KETCY;
+    lookup["Cait sith"] = KETCY;
+    lookup["CAIT SITH"] = KETCY;
+    lookup["CaitSith"] = KETCY;
+    lookup["Caitsith"] = KETCY;
+    lookup["CAITSITH"] = KETCY;
+    lookup["AEBC"] = KETCY;
+    lookup["ketcy"] = KETCY;
+    return lookup;
+}
 
 
-    const Character::CharacterIdLookupMap Character::character_id_lookup_(
-      Character::CreateLookupMap()
-    );
+const Character::CharacterIdLookupMap Character::character_id_lookup_(Character::CreateLookupMap());
 
 
-    Character::CharacterId Character::GetIdByName(const VGears::String& name){
-        CharacterIdLookupMap::const_iterator entry;
-        entry = character_id_lookup_.find(name);
-        if (entry != character_id_lookup_.end()) return entry->second;
-        return UNKNOWN;
-    }
+Character::CharacterId Character::GetIdByName(const VGears::String& name){
+    CharacterIdLookupMap::const_iterator entry;
+    entry = character_id_lookup_.find(name);
+    if (entry != character_id_lookup_.end()) return entry->second;
+    return UNKNOWN;
 }
 }

+ 1 - 5
V-Gears/src/FF7Common.cpp

@@ -16,9 +16,5 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
-
-        const String EXT_A(".a");
-
-    }
+    const String EXT_A(".a");
 }
 }

+ 1 - 1
V-Gears/src/common/VGearsApplication.cpp

@@ -231,7 +231,7 @@ namespace VGears{
           std::make_shared<VGears::WalkmeshFileManager>()
           std::make_shared<VGears::WalkmeshFileManager>()
         );
         );
         _resource_managers.emplace_back(
         _resource_managers.emplace_back(
-          std::make_shared<VGears::FF7::ModelListFileManager>()
+          std::make_shared<VGears::ModelListFileManager>()
         );
         );
         _resource_managers.emplace_back(
         _resource_managers.emplace_back(
           std::make_shared<VGears::HRCFileManager>()
           std::make_shared<VGears::HRCFileManager>()

+ 19 - 24
V-Gears/src/data/FinalFantasy7/FF7ModelListFile.cpp

@@ -18,37 +18,32 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
-        const String ModelListFile::RESOURCE_TYPE("FF7ModelListFile");
+    const String ModelListFile::RESOURCE_TYPE("FF7ModelListFile");
 
 
-        ModelListFile::ModelListFile(
-          Ogre::ResourceManager *creator, const String &name,
-          Ogre::ResourceHandle handle, const String &group, bool is_manual,
-          Ogre::ManualResourceLoader *loader
-        ) :
-            Resource(creator, name, handle, group, is_manual, loader),
-            scale_(0){}
+    ModelListFile::ModelListFile(
+      Ogre::ResourceManager *creator, const String &name, Ogre::ResourceHandle handle,
+      const String &group, bool is_manual, Ogre::ManualResourceLoader *loader
+    ): Resource(creator, name, handle, group, is_manual, loader), scale_(0){}
 
 
-        ModelListFile::~ModelListFile(){unload();}
+    ModelListFile::~ModelListFile(){unload();}
 
 
-        void ModelListFile::loadImpl(){
-            ModelListFileSerializer serializer;
-            Ogre::DataStreamPtr stream(openResource());
-            serializer.ImportModelListFile(stream, this);
-        }
+    void ModelListFile::loadImpl(){
+        ModelListFileSerializer serializer;
+        Ogre::DataStreamPtr stream(openResource());
+        serializer.ImportModelListFile(stream, this);
+    }
 
 
-        void ModelListFile::unloadImpl(){
-            scale_ = 0;
-            models_.clear();
-        }
+    void ModelListFile::unloadImpl(){
+        scale_ = 0;
+        models_.clear();
+    }
 
 
-        size_t ModelListFile::calculateSize() const{return 0;}
+    size_t ModelListFile::calculateSize() const{return 0;}
 
 
-        ModelListFile::ModelList&ModelListFile::GetModels(){return models_;}
+    ModelListFile::ModelList&ModelListFile::GetModels(){return models_;}
 
 
-        uint16 ModelListFile::GetScale() const{return scale_;}
+    uint16 ModelListFile::GetScale() const{return scale_;}
 
 
-        void ModelListFile::SetScale(uint16 scale){scale_ = scale;}
+    void ModelListFile::SetScale(uint16 scale){scale_ = scale;}
 
 
-    }
 }
 }

+ 25 - 38
V-Gears/src/data/FinalFantasy7/FF7ModelListFileManager.cpp

@@ -15,47 +15,34 @@
 
 
 #include "data/FinalFantasy7/FF7ModelListFileManager.h"
 #include "data/FinalFantasy7/FF7ModelListFileManager.h"
 
 
-template<> VGears::FF7::ModelListFileManager
-  *Ogre::Singleton<VGears::FF7::ModelListFileManager>::msSingleton = NULL;
+template<> VGears::ModelListFileManager
+  *Ogre::Singleton<VGears::ModelListFileManager>::msSingleton = NULL;
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
-
-        ModelListFileManager *ModelListFileManager::GetSingletonPtr(){
-            return msSingleton;
-        }
-
-        ModelListFileManager &ModelListFileManager::GetSingleton(){
-            assert( msSingleton );
-            return(*msSingleton );
-        }
-
-        ModelListFileManager::ModelListFileManager(){
-            mResourceType = ModelListFile::RESOURCE_TYPE;
-            // Low, because it will likely reference other resources.
-            mLoadOrder = 30.0f;
-            // This is how the ResourceManager registers with OGRE.
-            Ogre::ResourceGroupManager::getSingleton()._registerResourceManager(
-              mResourceType, this
-            );
-        }
-
-        ModelListFileManager::~ModelListFileManager(){
-            Ogre::ResourceGroupManager::getSingleton()
-              ._unregisterResourceManager(mResourceType);
-        }
-
-        Ogre::Resource *ModelListFileManager::createImpl(
-          const Ogre::String &name, Ogre::ResourceHandle handle,
-          const Ogre::String &group, bool is_manual,
-          Ogre::ManualResourceLoader *loader,
-          const Ogre::NameValuePairList *create_params
-        ){
-            return new ModelListFile(
-              this, name, handle, group, is_manual, loader
-            );
-        }
+    ModelListFileManager *ModelListFileManager::GetSingletonPtr(){return msSingleton;}
 
 
+    ModelListFileManager &ModelListFileManager::GetSingleton(){
+        assert(msSingleton);
+        return(*msSingleton);
     }
     }
+
+    ModelListFileManager::ModelListFileManager(){
+        mResourceType = ModelListFile::RESOURCE_TYPE;
+        // Low, because it will likely reference other resources.
+        mLoadOrder = 30.0f;
+        // This is how the ResourceManager registers with OGRE.
+        Ogre::ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this);
+    }
+
+    ModelListFileManager::~ModelListFileManager(){
+        Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType);
+    }
+
+    Ogre::Resource *ModelListFileManager::createImpl(
+      const Ogre::String &name, Ogre::ResourceHandle handle,
+      const Ogre::String &group, bool is_manual,
+      Ogre::ManualResourceLoader *loader, const Ogre::NameValuePairList *create_params
+    ){return new ModelListFile(this, name, handle, group, is_manual, loader);}
+
 }
 }

+ 49 - 56
V-Gears/src/data/FinalFantasy7/FF7ModelListFileSerializer.cpp

@@ -19,67 +19,60 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
+    ModelListFileSerializer::ModelListFileSerializer(): Serializer(){}
 
 
-        ModelListFileSerializer::ModelListFileSerializer() : Serializer(){}
+    ModelListFileSerializer::~ModelListFileSerializer(){}
 
 
-        ModelListFileSerializer::~ModelListFileSerializer(){}
-
-        template<typename ValueType> void ModelListFileSerializer::ReadVector(
-          Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest,
-          size_t count
-        ){
-            dest.clear();
-            dest.reserve(count);
-            for (size_t i(count); i-- ;){
-                ValueType in_tmp;
-                readObject(stream, in_tmp);
-                dest.push_back(in_tmp);
-            }
-        }
-
-        void ModelListFileSerializer::ImportModelListFile(
-          Ogre::DataStreamPtr &stream, ModelListFile *dest){
-            stream->skip(2); // uint16 unused.
-            uint16 model_count;
-            ReadShort(stream, model_count);
-            uint16 model_scale;
-            ReadShort(stream, model_scale);
-            dest->SetScale(model_scale);
-            ReadVector(stream, dest->GetModels(), model_count);
+    template<typename ValueType> void ModelListFileSerializer::ReadVector(
+      Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest, size_t count
+    ){
+        dest.clear();
+        dest.reserve(count);
+        for (size_t i(count); i-- ;){
+            ValueType in_tmp;
+            readObject(stream, in_tmp);
+            dest.push_back(in_tmp);
         }
         }
+    }
 
 
-        void ModelListFileSerializer::readObject(
-          Ogre::DataStreamPtr &stream,
-          ModelListFileSerializer::ModelDescription &dest
-        ){
-            uint16 name_length;
-            ReadShort(stream, name_length);
-            dest.name = readString(stream, name_length);
-            uint16 type;
-            ReadShort(stream, type);
-            dest.type = ModelListFile::UNKNOWN;
-            if (type == ModelListFile::PLAYER)
-                dest.type = ModelListFile::PLAYER;
-            else if (type == ModelListFile::NPC) dest.type = ModelListFile::NPC;
-            dest.hrc_name = readString(stream, HRC_NAME_LENGTH);
-            dest.scale = readString(stream, SCALE_LENGTH);
-            uint16 animation_count;
-            ReadShort(stream, animation_count);
-            // 3 *(3 uint8 + 3 uint16) + 3 uint8 light colors
-            stream->skip(3 * (3 + 6) + 3);
-            ReadVector(stream, dest.animations, animation_count);
-        }
+    void ModelListFileSerializer::ImportModelListFile(
+      Ogre::DataStreamPtr &stream, ModelListFile *dest){
+        stream->skip(2); // uint16 unused.
+        uint16 model_count;
+        ReadShort(stream, model_count);
+        uint16 model_scale;
+        ReadShort(stream, model_scale);
+        dest->SetScale(model_scale);
+        ReadVector(stream, dest->GetModels(), model_count);
+    }
 
 
-        void ModelListFileSerializer::readObject(
-          Ogre::DataStreamPtr &stream,
-          ModelListFileSerializer::AnimationDescription &dest
-        ){
-            uint16 name_length;
-            ReadShort(stream, name_length);
-            dest.name = readString(stream, name_length);
-            ReadShort(stream, dest.unknown);
-        }
+    void ModelListFileSerializer::readObject(
+      Ogre::DataStreamPtr &stream, ModelListFileSerializer::ModelDescription &dest
+    ){
+        uint16 name_length;
+        ReadShort(stream, name_length);
+        dest.name = readString(stream, name_length);
+        uint16 type;
+        ReadShort(stream, type);
+        dest.type = ModelListFile::UNKNOWN;
+        if (type == ModelListFile::PLAYER) dest.type = ModelListFile::PLAYER;
+        else if (type == ModelListFile::NPC) dest.type = ModelListFile::NPC;
+        dest.hrc_name = readString(stream, HRC_NAME_LENGTH);
+        dest.scale = readString(stream, SCALE_LENGTH);
+        uint16 animation_count;
+        ReadShort(stream, animation_count);
+        // 3 *(3 uint8 + 3 uint16) + 3 uint8 light colors
+        stream->skip(3 * (3 + 6) + 3);
+        ReadVector(stream, dest.animations, animation_count);
+    }
 
 
+    void ModelListFileSerializer::readObject(
+      Ogre::DataStreamPtr &stream, ModelListFileSerializer::AnimationDescription &dest
+    ){
+        uint16 name_length;
+        ReadShort(stream, name_length);
+        dest.name = readString(stream, name_length);
+        ReadShort(stream, dest.unknown);
     }
     }
+
 }
 }

+ 4 - 4
V-Gears/src/data/VGearsFLevelBackground2DLoader.cpp

@@ -34,15 +34,15 @@ namespace VGears{
         background_2d->_notifyOrigin(flevel_file_.getName());
         background_2d->_notifyOrigin(flevel_file_.getName());
         background_2d->SetTextureName(flevel_file_.GetBackgroundTextureName());
         background_2d->SetTextureName(flevel_file_.GetBackgroundTextureName());
         background_2d->SetClip(
         background_2d->SetClip(
-          Ogre::Vector2(FF7::SCREEN_WIDTH, FF7::SCREEN_HEIGHT)
+          Ogre::Vector2(SCREEN_WIDTH, SCREEN_HEIGHT)
         );
         );
         CameraMatrixFilePtr camera_matrix(flevel_file_.GetCameraMatrix());
         CameraMatrixFilePtr camera_matrix(flevel_file_.GetCameraMatrix());
         Ogre::Real scale(Ogre::Real(camera_matrix->GetCount()));
         Ogre::Real scale(Ogre::Real(camera_matrix->GetCount()));
         background_2d->SetPosition(
         background_2d->SetPosition(
-          camera_matrix->GetPosition() / -(scale * FF7::FIELD_POSITION_SCALE)
+          camera_matrix->GetPosition() / -(scale * FIELD_POSITION_SCALE)
         );
         );
         background_2d->SetOrientation(camera_matrix->GetOrientation());
         background_2d->SetOrientation(camera_matrix->GetOrientation());
-        background_2d->SetFov(camera_matrix->GetFov(FF7::SCREEN_WIDTH));
+        background_2d->SetFov(camera_matrix->GetFov(SCREEN_WIDTH));
         Ogre::Vector4 range(0, 0, 0, 0);
         Ogre::Vector4 range(0, 0, 0, 0);
         TileList& tiles(background_2d->GetTiles());
         TileList& tiles(background_2d->GetTiles());
         BackgroundFilePtr background(flevel_file_.GetBackground());
         BackgroundFilePtr background(flevel_file_.GetBackground());
@@ -60,7 +60,7 @@ namespace VGears{
             tile.width  = BackgroundFile::SPRITE_WIDTH;
             tile.width  = BackgroundFile::SPRITE_WIDTH;
             tile.height = BackgroundFile::SPRITE_HEIGHT;
             tile.height = BackgroundFile::SPRITE_HEIGHT;
             tile.blending = B_ALPHA;
             tile.blending = B_ALPHA;
-            tile.depth = sprite.depth / (scale * FF7::FIELD_DEPTH_SCALE);
+            tile.depth = sprite.depth / (scale * FIELD_DEPTH_SCALE);
             /*
             /*
             if depth >= 1
             if depth >= 1
                 if(??? / 4.0 < depth)
                 if(??? / 4.0 < depth)

+ 2 - 2
V-Gears/src/data/VGearsFLevelFile.cpp

@@ -116,12 +116,12 @@ namespace VGears{
             String animation_name;
             String animation_name;
             StringUtil::splitBase(it->name, animation_name);
             StringUtil::splitBase(it->name, animation_name);
             StringUtil::toLowerCase(animation_name);
             StringUtil::toLowerCase(animation_name);
-            String animation_filename(animation_name + FF7::EXT_A);
+            String animation_filename(animation_name + EXT_A);
             AFilePtr animation
             AFilePtr animation
               = a_mgr.load(
               = a_mgr.load(
                 animation_filename, model->getGroup()
                 animation_filename, model->getGroup()
               ).staticCast<AFile>();
               ).staticCast<AFile>();
-            animation_name = FF7::NameLookup::Animation(animation_name);
+            animation_name = NameLookup::Animation(animation_name);
             Ogre::LogManager::getSingleton().stream() << " Adding Animation: "
             Ogre::LogManager::getSingleton().stream() << " Adding Animation: "
               << animation_name;
               << animation_name;
             animation->AddTo(model->GetSkeleton(), animation_name);
             animation->AddTo(model->GetSkeleton(), animation_name);

+ 1 - 7
V-Gears/src/data/VGearsFLevelFileSerializer.cpp

@@ -33,12 +33,6 @@
 namespace VGears{
 namespace VGears{
     // TODO: move flevel stuff to ff7 as it is ff7 related
     // TODO: move flevel stuff to ff7 as it is ff7 related
 
 
-    using FF7::ModelListFileManager;
-
-    using FF7::ModelListFileSerializer;
-
-    using FF7::WalkmeshFileSerializer;
-
     const String FLevelFileSerializer::TAG_FILE_END("FINAL FANTASY7");
     const String FLevelFileSerializer::TAG_FILE_END("FINAL FANTASY7");
 
 
     FLevelFileSerializer::FLevelFileSerializer() : Serializer(){}
     FLevelFileSerializer::FLevelFileSerializer() : Serializer(){}
@@ -239,7 +233,7 @@ namespace VGears{
         WalkmeshFile::TriangleList::const_iterator it_end(triangles.end());
         WalkmeshFile::TriangleList::const_iterator it_end(triangles.end());
         Ogre::Real scale
         Ogre::Real scale
           = static_cast<Ogre::Real>(dest->GetCameraMatrix()->GetCount());
           = static_cast<Ogre::Real>(dest->GetCameraMatrix()->GetCount());
-        scale *= FF7::FIELD_POSITION_SCALE;
+        scale *= FIELD_POSITION_SCALE;
         while (it != it_end){
         while (it != it_end){
             it->a /= scale;
             it->a /= scale;
             it->b /= scale;
             it->b /= scale;

+ 1 - 1
V-Gears/src/data/VGearsHRCFile.cpp

@@ -137,7 +137,7 @@ namespace VGears{
     String HRCFile::GetMeshFileName(void) const{
     String HRCFile::GetMeshFileName(void) const{
         String base_name;
         String base_name;
         StringUtil::splitBase(getName(), base_name);
         StringUtil::splitBase(getName(), base_name);
-        return FF7::NameLookup::model(base_name) + EXT_MESH;
+        return NameLookup::model(base_name) + EXT_MESH;
     }
     }
 
 
     Ogre::SkeletonPtr HRCFile::GetSkeleton(void) const{
     Ogre::SkeletonPtr HRCFile::GetSkeleton(void) const{

+ 59 - 67
V-Gears/src/map/FinalFantasy7/FF7WalkmeshFileSerializer.cpp

@@ -19,80 +19,72 @@
 
 
 namespace VGears{
 namespace VGears{
 
 
-    namespace FF7{
+    WalkmeshFileSerializer::WalkmeshFileSerializer(): Serializer(){}
 
 
-        WalkmeshFileSerializer::WalkmeshFileSerializer() : Serializer(){}
+    WalkmeshFileSerializer::~WalkmeshFileSerializer(){}
 
 
-        WalkmeshFileSerializer::~WalkmeshFileSerializer(){}
-
-        template<typename ValueType> void WalkmeshFileSerializer::ReadVector(
-          Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest,
-          size_t count
-        ){
-            dest.clear();
-            dest.reserve(count);
-            for (size_t i(count); i --;){
-                ValueType in_tmp;
-                readObject(stream, in_tmp);
-                dest.push_back(in_tmp);
-            }
-        }
-
-        void WalkmeshFileSerializer::ImportWalkmeshFile(
-          Ogre::DataStreamPtr &stream, WalkmeshFile *dest
-        ){
-            uint32 triangle_count(0);
-            ReadUInt32(stream, triangle_count);
-            TriangleList triangles;
-            ReadVector(stream, triangles, triangle_count);
-            AccessList access;
-            ReadVector(stream, access, triangle_count);
-            WalkmeshTriangleList &triangle_list(dest->GetTriangles());
-            triangle_list.clear();
-            triangle_list.reserve(triangle_count);
-            for (uint32 i(0); i < triangle_count; ++ i){
-                Triangle &in_triangle(triangles[i]);
-                Access &in_access(access[i]);
-                WalkmeshTriangle tmp_triangle;
-                tmp_triangle.a = in_triangle.a;
-                tmp_triangle.b = in_triangle.b;
-                tmp_triangle.c = in_triangle.c;
-                tmp_triangle.access_side[0] = in_access.a;
-                tmp_triangle.access_side[1] = in_access.b;
-                tmp_triangle.access_side[2] = in_access.c;
-                triangle_list.push_back(tmp_triangle);
-            }
+    template<typename ValueType> void WalkmeshFileSerializer::ReadVector(
+      Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest, size_t count
+    ){
+        dest.clear();
+        dest.reserve(count);
+        for (size_t i(count); i --;){
+            ValueType in_tmp;
+            readObject(stream, in_tmp);
+            dest.push_back(in_tmp);
         }
         }
+    }
 
 
-        void WalkmeshFileSerializer::readObject(
-          Ogre::DataStreamPtr &stream, WalkmeshFileSerializer::Triangle &dest
-        ){
-            readObject(stream, dest.a);
-            readObject(stream, dest.b);
-            readObject(stream, dest.c);
+    void WalkmeshFileSerializer::ImportWalkmeshFile(
+      Ogre::DataStreamPtr &stream, WalkmeshFile *dest
+    ){
+        uint32 triangle_count(0);
+        ReadUInt32(stream, triangle_count);
+        TriangleList triangles;
+        ReadVector(stream, triangles, triangle_count);
+        AccessList access;
+        ReadVector(stream, access, triangle_count);
+        WalkmeshTriangleList &triangle_list(dest->GetTriangles());
+        triangle_list.clear();
+        triangle_list.reserve(triangle_count);
+        for (uint32 i(0); i < triangle_count; ++ i){
+            Triangle &in_triangle(triangles[i]);
+            Access &in_access(access[i]);
+            WalkmeshTriangle tmp_triangle;
+            tmp_triangle.a = in_triangle.a;
+            tmp_triangle.b = in_triangle.b;
+            tmp_triangle.c = in_triangle.c;
+            tmp_triangle.access_side[0] = in_access.a;
+            tmp_triangle.access_side[1] = in_access.b;
+            tmp_triangle.access_side[2] = in_access.c;
+            triangle_list.push_back(tmp_triangle);
         }
         }
+    }
 
 
-        void WalkmeshFileSerializer::readObject(
-          Ogre::DataStreamPtr &stream, Ogre::Vector3 &dest
-        ){
-            sint16 tmp[VERTEX_COMPONENT_COUNT];
-            readShorts(
-              stream, reinterpret_cast<uint16*>(tmp), VERTEX_COMPONENT_COUNT
-            );
-            dest.x = static_cast<Ogre::Real>(tmp[0]);
-            dest.y = static_cast<Ogre::Real>(tmp[1]);
-            dest.z = static_cast<Ogre::Real>(tmp[2]);
-        }
+    void WalkmeshFileSerializer::readObject(
+      Ogre::DataStreamPtr &stream, WalkmeshFileSerializer::Triangle &dest
+    ){
+        readObject(stream, dest.a);
+        readObject(stream, dest.b);
+        readObject(stream, dest.c);
+    }
 
 
-        void WalkmeshFileSerializer::readObject(
-          Ogre::DataStreamPtr &stream, WalkmeshFileSerializer::Access &dest
-        ){
-            uint16 tmp[ACCESS_COMPONENT_COUNT];
-            readShorts(stream, tmp, ACCESS_COMPONENT_COUNT);
-            dest.a = tmp[0];
-            dest.b = tmp[1];
-            dest.c = tmp[2];
-        }
+    void WalkmeshFileSerializer::readObject(Ogre::DataStreamPtr &stream, Ogre::Vector3 &dest){
+        sint16 tmp[VERTEX_COMPONENT_COUNT];
+        readShorts(stream, reinterpret_cast<uint16*>(tmp), VERTEX_COMPONENT_COUNT);
+        dest.x = static_cast<Ogre::Real>(tmp[0]);
+        dest.y = static_cast<Ogre::Real>(tmp[1]);
+        dest.z = static_cast<Ogre::Real>(tmp[2]);
+    }
 
 
+    void WalkmeshFileSerializer::readObject(
+      Ogre::DataStreamPtr &stream, WalkmeshFileSerializer::Access &dest
+    ){
+        uint16 tmp[ACCESS_COMPONENT_COUNT];
+        readShorts(stream, tmp, ACCESS_COMPONENT_COUNT);
+        dest.a = tmp[0];
+        dest.b = tmp[1];
+        dest.c = tmp[2];
     }
     }
+
 }
 }

Деякі файли не було показано, через те що забагато файлів було змінено