Prechádzať zdrojové kódy

Removed game data from the repository

- The installer builds the font images (ffvii_en, ffvii_menu, ffvii_digits and ffvii_timer) from WINDOW.BIN, instead of having them in the repository. They are built even when the images are not installed, and the verifier checks them.
- Removed the Japanese font, which is not in the PC version, and ffvii.xml, an unused copy of the English font.
- Removed doc/FFVII, a partial copy of the Gears wiki with game screenshots.
- The decompiler tests (not built) are no longer tracked: some of their fixtures are copies of a game field.
- The agent instructions pointed to doc/code/FFVII, which doesn't exist. They point to the FF7 wiki and the parser headers now.
- Added notes about possible font improvements to the TODO.
Iñigo Valentin 2 dní pred
rodič
commit
7a37381455
92 zmenil súbory, kde vykonal 590 pridanie a 6730 odobranie
  1. 1 1
      .github/agents/ff7-format-researcher.agent.md
  2. 1 1
      .github/copilot-instructions.md
  3. 1 1
      .github/instructions/ff7-data-formats.instructions.md
  4. 2 2
      .github/prompts/new-data-format.prompt.md
  5. 9 0
      .gitignore
  6. 0 3
      data/data/fonts/_fonts.xml
  7. 0 96
      data/data/fonts/ffvii.xml
  8. BIN
      data/data/fonts/ffvii_digits.png
  9. BIN
      data/data/fonts/ffvii_en.png
  10. BIN
      data/data/fonts/ffvii_jp.png
  11. 0 407
      data/data/fonts/ffvii_jp.xml
  12. BIN
      data/data/fonts/ffvii_menu.png
  13. BIN
      data/data/fonts/ffvii_timer.png
  14. 0 225
      doc/FFVII/1_history.html
  15. 0 42
      doc/FFVII/2_engine_basics.html
  16. 0 75
      doc/FFVII/3_1_kernel_overview.html
  17. 0 162
      doc/FFVII/Index.html
  18. BIN
      doc/FFVII/img/2_engine_basics.jpg
  19. 0 47
      doc/FFVII/style.css
  20. 9 0
      doc/TODO.md
  21. 1 0
      src/installer/CMakeLists.txt
  22. 4 0
      src/installer/DataInstaller.cpp
  23. 5 0
      src/installer/InstallVerifier.cpp
  24. 20 0
      src/installer/MediaDataInstaller.cpp
  25. 10 0
      src/installer/MediaDataInstaller.h
  26. 217 0
      src/installer/WindowFonts.cpp
  27. 139 0
      src/installer/WindowFonts.h
  28. BIN
      src/installer/decompiler/test/branches.dmp
  29. 0 5
      src/installer/decompiler/test/branches.txt
  30. BIN
      src/installer/decompiler/test/break-do-while.dmp
  31. 0 14
      src/installer/decompiler/test/break-do-while.txt
  32. BIN
      src/installer/decompiler/test/break-do-while2.dmp
  33. 0 15
      src/installer/decompiler/test/break-do-while2.txt
  34. BIN
      src/installer/decompiler/test/break-while.dmp
  35. 0 15
      src/installer/decompiler/test/break-while.txt
  36. BIN
      src/installer/decompiler/test/bug_fixes.dat
  37. 0 554
      src/installer/decompiler/test/cfg_test.cpp
  38. 0 217
      src/installer/decompiler/test/codegen.cpp
  39. BIN
      src/installer/decompiler/test/continue-do-while.dmp
  40. 0 14
      src/installer/decompiler/test/continue-do-while.txt
  41. BIN
      src/installer/decompiler/test/continue-do-while2.dmp
  42. 0 15
      src/installer/decompiler/test/continue-do-while2.txt
  43. BIN
      src/installer/decompiler/test/continue-while.dmp
  44. 0 15
      src/installer/decompiler/test/continue-while.txt
  45. 0 147
      src/installer/decompiler/test/disassembler/pasc.cpp
  46. 0 39
      src/installer/decompiler/test/disassembler/pasc.h
  47. 0 33
      src/installer/decompiler/test/disassembler/subopcode.cpp
  48. 0 38
      src/installer/decompiler/test/disassembler/subopcode.h
  49. 0 227
      src/installer/decompiler/test/disassembler_test.cpp
  50. BIN
      src/installer/decompiler/test/do-while-in-while.dmp
  51. 0 20
      src/installer/decompiler/test/do-while-in-while.txt
  52. BIN
      src/installer/decompiler/test/do-while.dmp
  53. 0 7
      src/installer/decompiler/test/do-while.txt
  54. BIN
      src/installer/decompiler/test/ff7.dat
  55. BIN
      src/installer/decompiler/test/ff7_all_opcodes.dat
  56. BIN
      src/installer/decompiler/test/ff7_all_opcodes_OLD.dat
  57. BIN
      src/installer/decompiler/test/ff7_all_opcodes_by_category.dat
  58. BIN
      src/installer/decompiler/test/ff7_control_flow_test.dat
  59. 0 422
      src/installer/decompiler/test/ff7_field_all_opcodes_disassembler_test.cpp
  60. 0 95
      src/installer/decompiler/test/ff7_field_control_flow_test.cpp
  61. 0 1978
      src/installer/decompiler/test/ff7_field_disasm_all_opcodes_by_category_test.cpp
  62. 0 61
      src/installer/decompiler/test/ff7_field_dummy_formatter.h
  63. BIN
      src/installer/decompiler/test/hanoi20.pasb
  64. BIN
      src/installer/decompiler/test/if-else.dmp
  65. 0 10
      src/installer/decompiler/test/if-else.txt
  66. BIN
      src/installer/decompiler/test/if-no-else.dmp
  67. 0 9
      src/installer/decompiler/test/if-no-else.txt
  68. BIN
      src/installer/decompiler/test/if.dmp
  69. 0 7
      src/installer/decompiler/test/if.txt
  70. 0 1517
      src/installer/decompiler/test/main.cpp
  71. 0 58
      src/installer/decompiler/test/module.mk
  72. BIN
      src/installer/decompiler/test/nested-do-while.dmp
  73. 0 20
      src/installer/decompiler/test/nested-do-while.txt
  74. BIN
      src/installer/decompiler/test/nested-while.dmp
  75. 0 22
      src/installer/decompiler/test/nested-while.txt
  76. BIN
      src/installer/decompiler/test/nested-while2.dmp
  77. 0 24
      src/installer/decompiler/test/nested-while2.txt
  78. BIN
      src/installer/decompiler/test/short-circuit.dmp
  79. 0 12
      src/installer/decompiler/test/short-circuit.txt
  80. 0 1
      src/installer/decompiler/test/subopcode_test.bin
  81. BIN
      src/installer/decompiler/test/unknownopcode_test.bin
  82. BIN
      src/installer/decompiler/test/unreachable.dmp
  83. 0 5
      src/installer/decompiler/test/unreachable.txt
  84. BIN
      src/installer/decompiler/test/while-in-do-while.dmp
  85. 0 20
      src/installer/decompiler/test/while-in-do-while.txt
  86. BIN
      src/installer/decompiler/test/while-in-do-while2.dmp
  87. 0 22
      src/installer/decompiler/test/while-in-do-while2.txt
  88. BIN
      src/installer/decompiler/test/while.dmp
  89. 0 9
      src/installer/decompiler/test/while.txt
  90. 1 0
      test/CMakeLists.txt
  91. 1 1
      test/installer/InstallLogic.cpp
  92. 169 0
      test/installer/WindowFonts.cpp

+ 1 - 1
.github/agents/ff7-format-researcher.agent.md

@@ -14,7 +14,7 @@ You are a specialist at investigating FF7 binary formats in the V-Gears codebase
 
 ## Approach
 
-1. Check the format documentation in `doc/code/FFVII/` first.
+1. Check the format documentation in [the FF7 wiki at wiki.ffrtt.ru](https://wiki.ffrtt.ru/index.php/FF7) and in the header comments of existing parsers first.
 2. Find the relevant parser triplet in `src/data/` (`*File`, `*FileSerializer`, `*FileManager`) and read the serializer for the authoritative byte layout.
 3. For installer/decompiler questions, read `src/installer/` and the matching instruction classes under `src/installer/decompiler/`.
 4. Cross-check with the test suite in `test/` — tests often show minimal usage examples.

+ 1 - 1
.github/copilot-instructions.md

@@ -19,7 +19,7 @@ V-Gears is a free, cross-platform reimplementation of the Final Fantasy VII engi
 - LuaJIT is a system dependency.
 - `test/` — Boost.Test suite mirroring `src/` paths; sources are listed manually in `test/CMakeLists.txt`.
 - `data/` — runtime configuration only (Ogre plugins/resources cfgs). Not game data.
-- `doc/` — all guides; `doc/code/FFVII/` documents the original binary formats.
+- `doc/` — all guides. The original binary formats are documented in the header comments of the parsers and in [the FF7 wiki at wiki.ffrtt.ru](https://wiki.ffrtt.ru/index.php/FF7).
 - `_OLD/` — legacy q-gears code kept for reference. Do not modify or reuse without asking.
 
 ## Build and Test

+ 1 - 1
.github/instructions/ff7-data-formats.instructions.md

@@ -13,7 +13,7 @@ Most formats in `src/data/` follow this structure — mirror it when adding form
 - `XFileSerializer` — reads/writes the binary layout (derives from `VGearsSerializer`).
 - `XFileManager` — Ogre `ResourceManager` integration (singleton + `Resource`).
 
-Format documentation lives in [doc/code/FFVII/](../../../doc/code/FFVII/). Check there and at existing similar parsers (e.g. `src/data/worldmap/TxzFile*`) before writing a new one.
+Format documentation lives in [the FF7 wiki at wiki.ffrtt.ru](https://wiki.ffrtt.ru/index.php/FF7) and in the header comments of the parsers. Check there and at existing similar parsers (e.g. `src/data/worldmap/TxzFile*`) before writing a new one.
 
 ## Installer Gotchas (verified, don't regress)
 

+ 2 - 2
.github/prompts/new-data-format.prompt.md

@@ -7,7 +7,7 @@ argument-hint: "Format name and target directory, e.g. 'XYZ in src/data/worldmap
 Scaffold a new FF7 binary format parser for the format named by the user:
 
 1. Research first:
-   - Check `doc/code/FFVII/` for documentation of the format.
+   - Check [the FF7 wiki at wiki.ffrtt.ru](https://wiki.ffrtt.ru/index.php/FF7) for documentation of the format.
    - Read the most similar existing triplet in `src/data/` (e.g. `TxzFile.h/.cpp`, `TxzFileSerializer.h/.cpp`, `TxzFileManager.h/.cpp` in `src/data/worldmap/`) and mirror its structure, base classes, and Doxygen comment style exactly.
 2. Create the triplet in the requested directory:
    - `XFile` — passive data container for the parsed format.
@@ -15,5 +15,5 @@ Scaffold a new FF7 binary format parser for the format named by the user:
    - `XFileManager` — Ogre `ResourceManager` singleton integration, matching the existing pattern.
 3. Follow `doc/STYLE.md` strictly: C++14, `PascalCase` types, `snake_case` variables with trailing underscore for members, `#pragma once`, correct include order.
 4. Register the new sources in the appropriate `src/CMakeLists.txt` source list (no globbing — add them explicitly, in the same grouped style as neighboring entries).
-5. Do not add or reference original game data; document the binary layout from `doc/code/FFVII/` knowledge in the header comments instead.
+5. Do not add or reference original game data; document the binary layout in the header comments instead.
 6. Build the affected target to verify it compiles.

+ 9 - 0
.gitignore

@@ -30,3 +30,12 @@ src/installer/MainWindow.ui.autosave
 
 # Generated from MainWindow.ui at build time.
 src/installer/ui_MainWindow.h
+
+# Built by the installer from the game data.
+data/data/fonts/ffvii_en.png
+data/data/fonts/ffvii_menu.png
+data/data/fonts/ffvii_digits.png
+data/data/fonts/ffvii_timer.png
+
+# Old decompiler tests, not built. Kept locally only, some fixtures are game data.
+src/installer/decompiler/test/

+ 0 - 3
data/data/fonts/_fonts.xml

@@ -1,10 +1,7 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <fonts>
     <font file_name="ffvii_en.xml" />
-    <font file_name="ffvii_jp.xml" />
     <font file_name="ffvii_menu.xml" />
     <font file_name="ffvii_digits.xml" />
     <font file_name="ffvii_timer.xml" />
-    <font file_name="ffvii.xml" />
-    <font file_name="ffvii.xml" />
 </fonts>

+ 0 - 96
data/data/fonts/ffvii.xml

@@ -1,96 +0,0 @@
-<font name="FFVIIFont" language="English" image="ffvii_en.png" image_size="256 256" height="16">
-    <char name=" " x="0" y="0" width="12" height="12" pre="0" post="-9" />
-    <char name="!" x="12" y="0" width="12" height="12" pre="2" post="-7" />
-    <char name="&quot;" x="24" y="0" width="12" height="12" pre="2" post="-4" />
-    <char name="#" x="36" y="0" width="12" height="12" pre="0" post="-2" />
-    <char name="$" x="48" y="0" width="12" height="12" pre="0" post="-5" />
-    <char name="%" x="60" y="0" width="12" height="12" pre="0" post="-2" />
-    <char name="&amp;" x="72" y="0" width="12" height="12" pre="0" post="-3" />
-    <char name="'" x="84" y="0" width="12" height="12" pre="0" post="-9" />
-    <char name="(" x="96" y="0" width="12" height="12" pre="2" post="-4" />
-    <char name=")" x="108" y="0" width="12" height="12" pre="2" post="-4" />
-    <char name="*" x="120" y="0" width="12" height="12" pre="0" post="-5" />
-    <char name="+" x="132" y="0" width="12" height="12" pre="0" post="-5" />
-    <char name="," x="144" y="0" width="12" height="12" pre="1" post="-5" />
-    <char name="-" x="156" y="0" width="12" height="12" pre="0" post="-7" />
-    <char name="." x="168" y="0" width="12" height="12" pre="1" post="-6" />
-    <char name="/" x="180" y="0" width="12" height="12" pre="0" post="-6" />
-    <char name="0" x="192" y="0" width="12" height="12" pre="0" post="-4" />
-    <char name="1" x="204" y="0" width="12" height="12" pre="2" post="-5" />
-    <char name="2" x="216" y="0" width="12" height="12" pre="0" post="-4" />
-    <char name="3" x="228" y="0" width="12" height="12" pre="0" post="-4" />
-    <char name="4" x="240" y="0" width="12" height="12" pre="0" post="-4" />
-    <char name="5" x="0" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="6" x="12" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="7" x="24" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="8" x="36" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="9" x="48" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name=":" x="60" y="12" width="12" height="12" pre="2" post="-7" />
-    <char name=";" x="72" y="12" width="12" height="12" pre="0" post="-8" />
-    <char name="&lt;" x="84" y="12" width="12" height="12" pre="0" post="-5" />
-    <char name="=" x="96" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name=">" x="108" y="12" width="12" height="12" pre="0" post="-5" />
-    <char name="?" x="120" y="12" width="12" height="12" pre="1" post="-5" />
-    <char name="@" x="132" y="12" width="12" height="12" pre="0" post="-2" />
-    <char name="A" x="144" y="12" width="12" height="12" pre="0" post="-3" />
-    <char name="B" x="156" y="12" width="12" height="12" pre="0" post="-5" />
-    <char name="C" x="168" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="D" x="180" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="E" x="192" y="12" width="12" height="12" pre="0" post="-5" />
-    <char name="F" x="204" y="12" width="12" height="12" pre="0" post="-5" />
-    <char name="G" x="216" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="H" x="228" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="I" x="240" y="12" width="12" height="12" pre="0" post="-9" />
-    <char name="J" x="0" y="24" width="12" height="12" pre="0" post="-6" />
-    <char name="K" x="12" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="L" x="24" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="M" x="36" y="24" width="12" height="12" pre="0" post="-1" />
-    <char name="N" x="48" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="O" x="60" y="24" width="12" height="12" pre="0" post="-3" />
-    <char name="P" x="72" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="Q" x="84" y="24" width="12" height="12" pre="0" post="-3" />
-    <char name="R" x="96" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="S" x="108" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="T" x="120" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="U" x="132" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="V" x="144" y="24" width="12" height="12" pre="0" post="-3" />
-    <char name="W" x="156" y="24" width="12" height="12" pre="0" post="-1" />
-    <char name="X" x="168" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="Y" x="180" y="24" width="12" height="12" pre="0" post="-3" />
-    <char name="Z" x="192" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="[" x="204" y="24" width="12" height="12" pre="0" post="-8" />
-    <char name="\" x="216" y="24" width="12" height="12" pre="0" post="-6" />
-    <char name="]" x="228" y="24" width="12" height="12" pre="0" post="-8" />
-    <char name="^" x="240" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="_" x="0" y="36" width="12" height="12" pre="0" post="-4" />
-    <char name="`" x="12" y="36" width="12" height="12" pre="0" post="-8" />
-    <char name="a" x="24" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="b" x="36" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="c" x="48" y="36" width="12" height="12" pre="0" post="-6" />
-    <char name="d" x="60" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="e" x="72" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="f" x="84" y="36" width="12" height="12" pre="0" post="-6" />
-    <char name="g" x="96" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="h" x="108" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="i" x="120" y="36" width="12" height="12" pre="0" post="-9" />
-    <char name="j" x="132" y="36" width="12" height="12" pre="0" post="-8" />
-    <char name="k" x="144" y="36" width="12" height="12" pre="0" post="-6" />
-    <char name="l" x="156" y="36" width="12" height="12" pre="0" post="-9" />
-    <char name="m" x="168" y="36" width="12" height="12" pre="0" post="-1" />
-    <char name="n" x="180" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="o" x="192" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="p" x="204" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="q" x="216" y="36" width="12" height="12" pre="0" post="-5" />
-    <char name="r" x="228" y="36" width="12" height="12" pre="0" post="-7" />
-    <char name="s" x="240" y="36" width="12" height="12" pre="0" post="-6" />
-    <char name="t" x="0" y="48" width="12" height="12" pre="0" post="-6" />
-    <char name="u" x="12" y="48" width="12" height="12" pre="0" post="-5" />
-    <char name="v" x="24" y="48" width="12" height="12" pre="0" post="-5" />
-    <char name="w" x="36" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="x" x="48" y="48" width="12" height="12" pre="0" post="-5" />
-    <char name="y" x="60" y="48" width="12" height="12" pre="0" post="-5" />
-    <char name="z" x="72" y="48" width="12" height="12" pre="0" post="-6" />
-    <char name="…" x="12" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="“" x="120" y="96" width="12" height="12" pre="0" post="-6" />
-    <char name="”" x="132" y="96" width="12" height="12" pre="0" post="-6" />
-</font>

BIN
data/data/fonts/ffvii_digits.png


BIN
data/data/fonts/ffvii_en.png


BIN
data/data/fonts/ffvii_jp.png


+ 0 - 407
data/data/fonts/ffvii_jp.xml

@@ -1,407 +0,0 @@
-<font name="FFVIIFont" language="Japanese" image="ffvii_jp.png" image_size="512 256" height="16">
-    <char name="バ" x="0" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="ば" x="12" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="ビ" x="24" y="0" width="12" height="12" pre="0" post="-1" />
-    <char name="び" x="36" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="ブ" x="48" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="ぶ" x="60" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="ベ" x="72" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="ボ" x="96" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="ぼ" x="108" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="ガ" x="120" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="が" x="132" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="ギ" x="144" y="0" width="12" height="12" pre="0" post="-1" />
-    <char name="ぎ" x="156" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="グ" x="168" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="ぐ" x="180" y="0" width="12" height="12" pre="0" post="-2" />
-    <char name="ゲ" x="192" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="げ" x="204" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="ゴ" x="216" y="0" width="12" height="12" pre="0" post="0" />
-    <char name="ご" x="228" y="0" width="12" height="12" pre="0" post="-1" />
-    <char name="ザ" x="240" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="ざ" x="0" y="12" width="12" height="12" pre="0" post="-1" />
-    <char name="ジ" x="12" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="じ" x="24" y="12" width="12" height="12" pre="0" post="-3" />
-    <char name="ズ" x="36" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="ず" x="48" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="ゼ" x="60" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="ぜ" x="72" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="ゾ" x="84" y="12" width="12" height="12" pre="0" post="-2" />
-    <char name="ぞ" x="96" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="ダ" x="108" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="だ" x="120" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="ヅ" x="156" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="デ" x="180" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="で" x="192" y="12" width="12" height="12" pre="0" post="0" />
-    <char name="ド" x="204" y="12" width="12" height="12" pre="0" post="-4" />
-    <char name="ど" x="216" y="12" width="12" height="12" pre="0" post="-1" />
-    <char name="パ" x="240" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="ぱ" x="0" y="24" width="12" height="12" pre="0" post="0" />
-    <char name="ピ" x="12" y="24" width="12" height="12" pre="0" post="-2" />
-    <char name="プ" x="36" y="24" width="12" height="12" pre="0" post="0" />
-    <char name="ぷ" x="48" y="24" width="12" height="12" pre="0" post="0" />
-    <char name="ペ" x="60" y="24" width="12" height="12" pre="0" post="0" />
-    <char name="ポ" x="84" y="24" width="12" height="12" pre="0" post="-1" />
-    <char name="0" x="108" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="1" x="120" y="24" width="12" height="12" pre="2" post="-6" />
-    <char name="2" x="132" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="3" x="144" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="4" x="156" y="24" width="12" height="12" pre="0" post="-3" />
-    <char name="5" x="168" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="6" x="180" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="7" x="192" y="24" width="12" height="12" pre="0" post="-5" />
-    <char name="8" x="204" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="9" x="216" y="24" width="12" height="12" pre="0" post="-4" />
-    <char name="、" x="228" y="24" width="12" height="12" pre="1" post="-5" />
-    <char name="。" x="240" y="24" width="12" height="12" pre="1" post="-3" />
-    <char name=" " x="0" y="36" width="12" height="12" pre="0" post="-4" />
-    <char name="ハ" x="12" y="36" width="12" height="12" pre="0" post="0" />
-    <char name="は" x="24" y="36" width="12" height="12" pre="0" post="-1" />
-    <char name="ヒ" x="36" y="36" width="12" height="12" pre="0" post="-3" />
-    <char name="ひ" x="48" y="36" width="12" height="12" pre="0" post="-1" />
-    <char name="フ" x="60" y="36" width="12" height="12" pre="0" post="-2" />
-    <char name="ふ" x="72" y="36" width="12" height="12" pre="0" post="0" />
-    <char name="ヘ" x="84" y="36" width="12" height="12" pre="0" post="0" />
-    <char name="へ" x="96" y="36" width="12" height="12" pre="0" post="0" />
-    <char name="ホ" x="108" y="36" width="12" height="12" pre="0" post="-1" />
-    <char name="ほ" x="120" y="36" width="12" height="12" pre="0" post="-1" />
-    <char name="カ" x="132" y="36" width="12" height="12" pre="0" post="-2" />
-    <char name="か" x="144" y="36" width="12" height="12" pre="0" post="0" />
-    <char name="キ" x="156" y="36" width="12" height="12" pre="0" post="-2" />
-    <char name="き" x="168" y="36" width="12" height="12" pre="0" post="-2" />
-    <char name="ク" x="180" y="36" width="12" height="12" pre="0" post="-2" />
-    <char name="く" x="192" y="36" width="12" height="12" pre="0" post="-4" />
-    <char name="ケ" x="204" y="36" width="12" height="12" pre="0" post="-1" />
-    <char name="け" x="216" y="36" width="12" height="12" pre="0" post="-1" />
-    <char name="コ" x="228" y="36" width="12" height="12" pre="0" post="-2" />
-    <char name="こ" x="240" y="36" width="12" height="12" pre="0" post="-3" />
-    <char name="サ" x="0" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="さ" x="12" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="シ" x="24" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="し" x="36" y="48" width="12" height="12" pre="0" post="-3" />
-    <char name="ス" x="48" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="す" x="60" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="セ" x="72" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="せ" x="84" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="ソ" x="96" y="48" width="12" height="12" pre="0" post="-3" />
-    <char name="そ" x="108" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="タ" x="120" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="た" x="132" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="チ" x="144" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="ち" x="156" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="ツ" x="168" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="つ" x="180" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="テ" x="192" y="48" width="12" height="12" pre="0" post="-1" />
-    <char name="て" x="204" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="ト" x="216" y="48" width="12" height="12" pre="0" post="-6" />
-    <char name="と" x="228" y="48" width="12" height="12" pre="0" post="-3" />
-    <char name="ウ" x="240" y="48" width="12" height="12" pre="0" post="-2" />
-    <char name="う" x="0" y="60" width="12" height="12" pre="0" post="-2" />
-    <char name="ア" x="12" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="あ" x="24" y="60" width="12" height="12" pre="0" post="0" />
-    <char name="イ" x="36" y="60" width="12" height="12" pre="0" post="-2" />
-    <char name="い" x="48" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="エ" x="60" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="え" x="72" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="オ" x="84" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="お" x="96" y="60" width="12" height="12" pre="0" post="0" />
-    <char name="ナ" x="108" y="60" width="12" height="12" pre="0" post="-2" />
-    <char name="な" x="120" y="60" width="12" height="12" pre="0" post="0" />
-    <char name="ニ" x="132" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="に" x="144" y="60" width="12" height="12" pre="0" post="-2" />
-    <char name="ぬ" x="168" y="60" width="12" height="12" pre="0" post="0" />
-    <char name="ネ" x="180" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="ね" x="192" y="60" width="12" height="12" pre="0" post="0" />
-    <char name="ノ" x="204" y="60" width="12" height="12" pre="0" post="-3" />
-    <char name="の" x="216" y="60" width="12" height="12" pre="0" post="-1" />
-    <char name="マ" x="228" y="60" width="12" height="12" pre="0" post="-2" />
-    <char name="ま" x="240" y="60" width="12" height="12" pre="0" post="0" />
-    <char name="ミ" x="0" y="72" width="12" height="12" pre="0" post="-3" />
-    <char name="み" x="12" y="72" width="12" height="12" pre="0" post="0" />
-    <char name="ム" x="24" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="む" x="36" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="メ" x="48" y="72" width="12" height="12" pre="0" post="-2" />
-    <char name="め" x="60" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="モ" x="72" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="も" x="84" y="72" width="12" height="12" pre="0" post="-2" />
-    <char name="ラ" x="96" y="72" width="12" height="12" pre="0" post="-2" />
-    <char name="ら" x="108" y="72" width="12" height="12" pre="0" post="-3" />
-    <char name="リ" x="120" y="72" width="12" height="12" pre="0" post="-4" />
-    <char name="り" x="132" y="72" width="12" height="12" pre="0" post="-4" />
-    <char name="ル" x="144" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="る" x="156" y="72" width="12" height="12" pre="0" post="-2" />
-    <char name="レ" x="168" y="72" width="12" height="12" pre="0" post="-4" />
-    <char name="れ" x="180" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="ロ" x="192" y="72" width="12" height="12" pre="0" post="-3" />
-    <char name="ろ" x="204" y="72" width="12" height="12" pre="0" post="-2" />
-    <char name="ヤ" x="216" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="や" x="228" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="ユ" x="240" y="72" width="12" height="12" pre="0" post="-1" />
-    <char name="よ" x="24" y="84" width="12" height="12" pre="0" post="-2" />
-    <char name="ワ" x="36" y="84" width="12" height="12" pre="0" post="-2" />
-    <char name="わ" x="48" y="84" width="12" height="12" pre="0" post="0" />
-    <char name="ン" x="60" y="84" width="12" height="12" pre="0" post="-2" />
-    <char name="ん" x="72" y="84" width="12" height="12" pre="0" post="-1" />
-    <char name="を" x="96" y="84" width="12" height="12" pre="0" post="-2" />
-    <char name="ッ" x="108" y="84" width="12" height="12" pre="0" post="-3" />
-    <char name="っ" x="120" y="84" width="12" height="12" pre="0" post="-4" />
-    <char name="ャ" x="132" y="84" width="12" height="12" pre="0" post="-3" />
-    <char name="ゃ" x="144" y="84" width="12" height="12" pre="0" post="-3" />
-    <char name="ュ" x="156" y="84" width="12" height="12" pre="0" post="-3" />
-    <char name="ゅ" x="168" y="84" width="12" height="12" pre="0" post="-3" />
-    <char name="ョ" x="180" y="84" width="12" height="12" pre="0" post="-5" />
-    <char name="ょ" x="192" y="84" width="12" height="12" pre="0" post="-4" />
-    <char name="ァ" x="204" y="84" width="12" height="12" pre="0" post="-4" />
-    <char name="ぁ" x="216" y="84" width="12" height="12" pre="0" post="-3" />
-    <char name="ィ" x="228" y="84" width="12" height="12" pre="0" post="-4" />
-    <char name="ゥ" x="0" y="96" width="12" height="12" pre="0" post="-5" />
-    <char name="ェ" x="24" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="ぇ" x="36" y="96" width="12" height="12" pre="0" post="-4" />
-    <char name="ぉ" x="60" y="96" width="12" height="12" pre="0" post="-2" />
-    <char name="!" x="72" y="96" width="12" height="12" pre="2" post="-7" />
-    <char name="?" x="84" y="96" width="12" height="12" pre="1" post="-3" />
-    <char name="『" x="96" y="96" width="12" height="12" pre="2" post="-3" />
-    <char name="』" x="108" y="96" width="12" height="12" pre="2" post="-2" />
-    <char name="A" x="144" y="96" width="12" height="12" pre="0" post="-2" />
-    <char name="B" x="156" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="C" x="168" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="D" x="180" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="E" x="192" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="F" x="204" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="G" x="216" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="H" x="228" y="96" width="12" height="12" pre="0" post="-3" />
-    <char name="I" x="240" y="96" width="12" height="12" pre="2" post="-7" />
-    <char name="J" x="0" y="108" width="12" height="12" pre="0" post="-5" />
-    <char name="K" x="12" y="108" width="12" height="12" pre="0" post="-4" />
-    <char name="L" x="24" y="108" width="12" height="12" pre="0" post="-3" />
-    <char name="M" x="36" y="108" width="12" height="12" pre="0" post="-1" />
-    <char name="N" x="48" y="108" width="12" height="12" pre="0" post="-3" />
-    <char name="O" x="60" y="108" width="12" height="12" pre="0" post="-3" />
-    <char name="P" x="72" y="108" width="12" height="12" pre="0" post="-3" />
-    <char name="Q" x="84" y="108" width="12" height="12" pre="0" post="-2" />
-    <char name="R" x="96" y="108" width="12" height="12" pre="0" post="-3" />
-    <char name="S" x="108" y="108" width="12" height="12" pre="0" post="-3" />
-    <char name="T" x="120" y="108" width="12" height="12" pre="0" post="-1" />
-    <char name="・" x="204" y="108" width="12" height="12" pre="2" post="-6" />
-    <char name="ー" x="228" y="108" width="12" height="12" pre="0" post="-3" />
-    <char name="~" x="240" y="108" width="12" height="12" pre="0" post="1" />
-    <char name="…" x="0" y="120" width="12" height="12" pre="0" post="0" />
-    <char name="【" x="60" y="120" width="12" height="12" pre="0" post="-6" />
-    <char name="】" x="72" y="120" width="12" height="12" pre="0" post="-6" />
-    <char name="「" x="132" y="120" width="12" height="12" pre="2" post="-4" />
-    <char name="」" x="144" y="120" width="12" height="12" pre="2" post="-4" />
-    <char name="(" x="156" y="120" width="12" height="12" pre="2" post="-4" />
-    <char name=")" x="168" y="120" width="12" height="12" pre="2" post="-4" />
-    <char name="大" x="108" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="爆" x="132" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="使" x="144" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="破" x="0" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="晄" x="12" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="撃" x="24" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="武" x="120" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="神" x="132" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="風" x="168" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="気" x="192" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="守" x="12" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="命" x="36" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="動" x="60" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="面" x="132" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="合" x="180" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="明" x="228" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="抜" x="12" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="一" x="108" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="者" x="132" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="羅" x="168" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="備" x="216" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="器" x="228" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="魔" x="0" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="法" x="12" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="出" x="72" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="持" x="84" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="相" x="96" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="手" x="108" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="確" x="132" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="方" x="240" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="行" x="0" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="定" x="24" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="前" x="60" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="真" x="72" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="覚" x="96" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="列" x="108" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="後" x="120" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="回" x="192" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="続" x="216" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="敵" x="228" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="尾" x="36" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="興" x="120" y="216" width="12" height="12" pre="0" post="0" />
-    <char name="弾" x="240" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="時" x="36" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="戦" x="72" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="冷" x="144" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="質" x="240" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="反" x="36" y="240" width="12" height="12" pre="0" post="1" />
-    <char name="目" x="60" y="240" width="12" height="12" pre="0" post="-2" />
-    <char name="力" x="96" y="240" width="12" height="12" pre="0" post="0" />
-    <char name="兵" x="180" y="240" width="12" height="12" pre="0" post="1" />
-    <char name="花" x="280" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="下" x="352" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="入" x="376" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="先" x="388" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="不" x="400" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="子" x="412" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="供" x="424" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="屋" x="436" y="0" width="12" height="12" pre="0" post="1" />
-    <char name="階" x="256" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="部" x="292" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="場" x="316" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="仲" x="340" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="間" x="352" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="限" x="388" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="何" x="472" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="料" x="496" y="12" width="12" height="12" pre="0" post="1" />
-    <char name="上" x="268" y="24" width="12" height="12" pre="0" post="1" />
-    <char name="事" x="292" y="24" width="12" height="12" pre="0" post="1" />
-    <char name="奥" x="400" y="24" width="12" height="12" pre="0" post="1" />
-    <char name="初" x="448" y="24" width="12" height="12" pre="0" post="1" />
-    <char name="村" x="460" y="24" width="12" height="12" pre="0" post="1" />
-    <char name="車" x="484" y="36" width="12" height="12" pre="0" post="1" />
-    <char name="螺" x="328" y="48" width="12" height="12" pre="0" post="1" />
-    <char name="具" x="412" y="48" width="12" height="12" pre="0" post="1" />
-    <char name="状" x="304" y="60" width="12" height="12" pre="0" post="1" />
-    <char name="態" x="316" y="60" width="12" height="12" pre="0" post="1" />
-    <char name="開" x="448" y="60" width="12" height="12" pre="0" post="1" />
-    <char name="同" x="292" y="72" width="12" height="12" pre="0" post="1" />
-    <char name="速" x="304" y="72" width="12" height="12" pre="0" post="1" />
-    <char name="遅" x="316" y="72" width="12" height="12" pre="0" post="1" />
-    <char name="味" x="376" y="72" width="12" height="12" pre="0" post="1" />
-    <char name="倍" x="424" y="72" width="12" height="12" pre="0" post="1" />
-    <char name="人" x="484" y="72" width="12" height="12" pre="0" post="1" />
-    <char name="今" x="496" y="72" width="12" height="12" pre="0" post="1" />
-    <char name="当" x="280" y="84" width="12" height="12" pre="0" post="-1" />
-    <char name="飛" x="316" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="以" x="328" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="外" x="340" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="身" x="388" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="旋" x="412" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="機" x="460" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="械" x="472" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="炉" x="496" y="84" width="12" height="12" pre="0" post="1" />
-    <char name="新" x="256" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="両" x="268" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="本" x="280" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="君" x="292" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="内" x="316" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="作" x="328" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="警" x="340" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="特" x="352" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="穴" x="400" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="足" x="472" y="96" width="12" height="12" pre="0" post="1" />
-    <char name="長" x="352" y="108" width="12" height="12" pre="0" post="1" />
-    <char name="塔" x="388" y="108" width="12" height="12" pre="0" post="1" />
-    <char name="見" x="472" y="108" width="12" height="12" pre="0" post="1" />
-    <char name="元" x="304" y="120" width="12" height="12" pre="0" post="1" />
-    <char name="終" x="352" y="120" width="12" height="12" pre="0" post="1" />
-    <char name="名" x="388" y="120" width="12" height="12" pre="0" post="1" />
-    <char name="成" x="436" y="120" width="12" height="12" pre="0" post="1" />
-    <char name="記" x="280" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="選" x="304" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="番" x="316" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="街" x="328" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="墓" x="448" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="心" x="460" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="道" x="268" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="巻" x="328" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="予" x="460" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="落" x="484" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="日" x="328" y="156" width="12" height="12" pre="0" post="-2" />
-    <char name="口" x="436" y="156" width="12" height="12" pre="0" post="0" />
-    <char name="温" x="340" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="走" x="400" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="危" x="484" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="言" x="304" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="失" x="400" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="敗" x="412" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="押" x="364" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="教" x="412" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="参" x="328" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="知" x="340" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="聞" x="352" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="仕" x="376" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="別" x="388" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="集" x="400" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="信" x="412" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="用" x="424" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="早" x="292" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="話" x="352" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="帰" x="364" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="売" x="424" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="浮" x="436" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="加" x="460" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="約" x="484" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="礼" x="256" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="束" x="268" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="男" x="292" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="立" x="340" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="俺" x="364" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="私" x="412" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="倒" x="448" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="休" x="460" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="助" x="256" y="240" width="12" height="12" pre="0" post="1" />
-    <char name="説" x="412" y="240" width="12" height="12" pre="0" post="1" />
-    <char name="柱" x="448" y="240" width="12" height="12" pre="0" post="1" />
-    <char name="伝" x="12" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="探" x="36" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="苦" x="192" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="困" x="216" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="客" x="24" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="夫" x="144" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="貸" x="228" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="期" x="240" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="保" x="48" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="帯" x="60" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="向" x="108" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="襲" x="144" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="次" x="168" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="素" x="192" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="買" x="72" y="168" width="12" height="12" pre="0" post="0" />
-    <char name="幼" x="120" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="禁" x="0" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="店" x="156" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="緊" x="204" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="研" x="216" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="暇" x="0" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="駅" x="84" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="製" x="132" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="録" x="240" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="協" x="120" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="脱" x="204" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="躍" x="228" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="到" x="36" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="功" x="36" y="240" width="12" height="12" pre="0" post="1" />
-    <char name="酒" x="156" y="240" width="12" height="12" pre="0" post="1" />
-    <char name="給" x="292" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="断" x="340" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="油" x="376" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="僕" x="400" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="存" x="412" y="132" width="12" height="12" pre="0" post="1" />
-    <char name="例" x="472" y="144" width="12" height="12" pre="0" post="1" />
-    <char name="増" x="400" y="156" width="12" height="12" pre="0" post="1" />
-    <char name="貴" x="496" y="168" width="12" height="12" pre="0" post="1" />
-    <char name="噂" x="328" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="壱" x="340" y="180" width="12" height="12" pre="0" post="1" />
-    <char name="侵" x="268" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="謝" x="436" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="価" x="484" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="欠" x="496" y="192" width="12" height="12" pre="0" post="1" />
-    <char name="寄" x="256" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="忙" x="268" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="五" x="292" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="度" x="400" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="誘" x="460" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="輩" x="496" y="204" width="12" height="12" pre="0" post="1" />
-    <char name="試" x="316" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="牲" x="484" y="216" width="12" height="12" pre="0" post="1" />
-    <char name="秀" x="472" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="軽" x="496" y="228" width="12" height="12" pre="0" post="1" />
-    <char name="刻" x="472" y="240" width="12" height="12" pre="0" post="1" />
-</font>

BIN
data/data/fonts/ffvii_menu.png


BIN
data/data/fonts/ffvii_timer.png


+ 0 - 225
doc/FFVII/1_history.html

@@ -1,225 +0,0 @@
-<html>
-    <head>
-        <link rel="stylesheet" href="style.css"/>
-    </head>
-    <body>
-        <h2>Preface</h2>
-        <p>
-            On January 31st, 1997, Final Fantasy VII was released to the
-            Japanese public. This single game both revolutionized and raised
-            the bar of Japanese style console role playing games. It success
-            was so staggering, it placed Squaresoft firmly on top the the the
-            genre, displacing the Dragon Quest series created by the rival Enix
-            company.
-        </p>
-        <p>
-            The story of how this game came to be has a story more expansive
-            than the game itself. It starts, as most stories do, with its
-            prequel.
-        </p>
-        <h2>Squaresoft and the "Big N"</h2>
-        <p>
-            In 1994, Squaresoft released Final Fantasy VI in Japan through an
-            exclusive contract with Nintendo. The game was for the Super
-            Famicom, or more internationally known as the Super Nintendo
-            Entertainment System. This game was a massive best-seller, and the
-            powers that be decided to have the game "cross the pond" as it were
-            for the U.S. audiences.
-        </p>
-        <p>
-            Sadly, as Nintendo had exclusive distribution rights to all games
-            in the United States, the decision was made to alter the game. The
-            traditional Final Fantasy logo was changed to one American
-            audiences were more used to. The sequel number was also dropped
-            from VI to III. Nintendo had only released two Final Fantasy games
-            in the states. Part I for the NES, and Part IV for the SNES (Part
-            IV was actually going to be a NES game, but was ported up in the
-            middle of it's development. That, however is another story). The
-            game was also edited for content. Several silly things like a
-            programmers room and a porno book were removed. All in all the
-            sales were modest, but it was nowhere near the success that the
-            game enjoyed in Japan.
-        </p>
-        <p>
-            It was often said that the U.S. market was not appropriate for
-            Japanese-style RPGs.
-        </p>
-        <p>
-            After the release of FF6 in the U.S., Nintendo started work on a
-            new video game system. Codenamed the "Ultra 64" it was boasting a
-            new 3D graphics core and a CD-ROM format for it's games. At the
-            time, Nintendo and Sony were working together to create the
-            "PlayStation Expansion" (PSX) CDROM system as an add-on to the
-            Super Nintendo. It was also rumored that this technology was going
-            to be in the Ultra 64 system as well.
-        </p>
-        <p>
-            Squaresoft decided that movie-like role playing games that took
-            advantage of this new multimedia technology was the future. They
-            invested billions of yen into SGI workstations when it was learned
-            that the Ultra 64 was going to use a 64 bit R4300 MIPS
-            architecture. A new threaded 3D engine was developed for the Final
-            Fantasy series. A demo of the new technology was created on their
-            new development systems. It was a simple battle engine using the
-            characters from FF6. It was assumed that this would be the
-            beginnings of FF7 for the Ultra 64.
-        </p>
-        <p>
-            Then the rug was pulled out from under Square's feet by Nintendo.
-        </p>
-        <p>
-            Nintendo and Sony had a falling out. An issue came about when both
-            companies disagreed over who got to license the games for the new
-            CD-ROM systems. Sony wanted control, but Nintendo balked. Nintendo
-            also had problems as Sony was already making the sound chip for the
-            SNES which was difficult to program for. Nintendo wanted more
-            control.
-        </p>
-        <p>
-            Nintendo went behind Sony and asked Phillips for assistance, as
-            they also could license CD-ROM technology. When Sony found out that
-            Nintendo was going to someone else, (and a foreign one at that!),
-            it was the last straw and pulled their technology. They also
-            convinced Phillips, Matsushita, NEC, and Pioneer not to license any
-            optical drive technology to Nintendo either.
-        </p>
-        <p>
-            Going alone, Sony decided to take their popular System 11 arcade
-            boards, tack on a CD-ROM and called it the Playstation.
-        </p>
-        <p>
-            Nintendo, without a drive system, quietly disclosed to their third
-            parties that the Ultra 64 was going to be cartridge based. The
-            maximum limit that any game could be was 32 megabytes. Squaresoft
-            was now in a bind, they had invested millions of yen into creating
-            a movie-like RPG experience and now had to cut it down to fit on a
-            cartridge. When it was revealed that the PSX would also be using a
-            MIPS CPU, Square abandoned Nintendo and gained an exclusive
-            distribution contract with Sony. The groundwork for Final Fantasy
-            VII was now laid and could continue unobstructed.
-        </p>
-        <h2>The Production</h2>
-        <p>
-            Halfway through the production of Final Fantasy VII, two very
-            important things happened. First a second team was spun off to
-            start production of Final Fantasy VIII. This allowed a staggered
-            development cycle were when one game one done, another would be
-            half done, cutting production time in half. Also half way through
-            production, Hironobu Sakaguchi, the producer, learned that his
-            mother Aki had died. Sakaguchi drew on this death and altered the
-            story in a radical way. It now revolved around life and death and
-            the earth.
-        </p>
-        <h2>The Release</h3>
-        <p>
-            The game was shipped to stores in Japan January 31, 1997, but not
-            without a few problems. First, the game was incomplete. A few
-            scenes were not able to run correctly before release. Also the
-            extra bosses were not added in time. These were minor issues that
-            no one missed, and were later fixed in the U.S. version.
-        </p>
-        <p>
-            In the States, a demo of FF7 was released with the game
-            "Tobal No.1". It was a modified version of the first part of the
-            game using characters not available until later. It was also the
-            first release in the states that called the game by it's proper
-            number. It was also the first time American audiences saw a true
-            Final Fantasy logo. The game was released in the the states
-            September 3rd, 1997. This release fixed several bugs, included the
-            missing bosses, and the nonworking scenes were added properly.
-        </p>
-        <p>
-            Later, Japan got a re-release of the expanded U.S. version, along
-            with a scene viewer and other bonus content. This was called "Final
-            Fantasy VII International"
-        </p>
-        <h2>The PC Port</span></h2>
-        <p>
-            With the wild success of FF7, Square's shareholders were beginning
-            to pressure the company to start diversifying their products. At
-            the time, Square was only making games exclusively for Sony, and
-            limiting their market. It also became apparent that their older
-            games were not suitable for more modern systems. Even Final Fantasy
-            VI, the game previous, was fixed to a single platform and could not
-            be adapted easily to other computer systems. Square made the choice
-            to update their old games to modern programming languages and
-            platforms. They also decided to port Final Fantasy VII to the PC.
-        </p>
-        <p>
-            Square chose Eidos of the publisher for their PC ports. At the time
-            Eidos has successfully handled the conversion and release of Core's
-            widely popular "Tomb Raider" game from the PSX to PC. Having
-            experience in marketing and distributing PSX to PC conversions, the
-            company seemed to be the right choice.
-        </p>
-        <p>
-            In the beginning, however, the PC port suffered many problems. When
-            the contract programmers received the FF7 source code from Square,
-            it was a horrible state of atrophy. When work started on the port,
-            it was soon discovered that they had received an earlier, buggy
-            version of the program. Work had to stop while Square accumulated a
-            later version. It was also discovered that the people and equipment
-            used to create the backgrounds for FF7, were now being used for FF8
-            and FF9. There was no way to re-render the backgrounds and the port
-            team was forced to use the original low color/low resolution PSX
-            dependencies. The movies faired worse. Squaresoft never rendered
-            high resolution versions of the movies. The movie format was
-            incompatible with Microsoft's DirectX system, so it was decided to
-            convert the compressed PSX movies to one more native to a PC
-            platform. This caused disastrous results. The movies were now a
-            copy of a copy of a low resolution render.
-        </p>
-        <p>
-            Square also refused to have anything added. It was to be a straight
-            port of the PSX version with the same exact interface. Concessions
-            were only made to text input. The game could run in a "high
-            resolution" mode of 640x480, which isn't really a lot in terms of
-            PC resolution. It was also limited to 15-bit color.
-        </p>
-        <p>
-            More problems arose. The PSX had the ability to use different color
-            depths on the screen at the same time. Many graphical effects
-            depended on this ability. Many PC graphic cards did not have the
-            ability to use color look up tables when placed into high color
-            modes. This caused the game to go into a low resolution software
-            renderer if this functionality wasn't available. FF7 was also
-            designed for 15 bit graphics. This caused noticeable color
-            banding on a PC screen. The sound architecture is also wildly
-            different and suffered as well.
-        </p>
-        <p>
-            The PC port was released in June of 1998. It was late, buggy, and
-            not very well ported. The game initially was incompatible with
-            Cyrix and AMD CPUs, to which Eidos technical support simply refused
-            to support at first. Many people with high-end graphic cards found
-            themselves forced into a software renderer due to a lack of a color
-            lookup system. Movies played upside down, or crashed the system all
-            together, as it used a 3rd-party renderer. The only solution Eido
-            came up with was to offer a save game past the crash point,
-            destroying hours of work by the user. Many sound cards were not
-            designed for MIDI playback and the software player used too much in
-            the way of resources, slowing the whole system. The initial
-            keyboard configuration was grossly unintuitive, using only the
-            numeric keypad. Many laptops without one couldn't even use the game
-            as you had to use the number pad to access the configuration
-            menu... and the box was ugly.
-        </p>
-        <p>
-            Eidos was dropped when Final Fantasy VIII for the PC was released.
-        </p>
-        <h2>Where are they now?</h3>
-        <p>
-            The PC port is now out of print and does not run on the Windows NT
-            type kernels due to some farflung misallocated pointers. Many now
-            play FF7 via PSX emulation. With this way of playing the game,
-            graphic modes higher than 1024x768 resolution, 32-bit color, and
-            texture filtering, can all be used. The PSX version is also stable
-            and for the most part, bug free. The engine has continued to be
-            built upon. It has also been used in other non-Final Fantasy games
-            such as "Parasite Eve", which was the first to support full body
-            textures before FF8. The PC port is still supported by a small band
-            of users. Unofficial patches have also been released with varying
-            degrees of success. Not bad for a little engine that could.
-        </p>
-    </body>
-</html>

+ 0 - 42
doc/FFVII/2_engine_basics.html

@@ -1,42 +0,0 @@
-<html>
-    <head>
-        <link rel="stylesheet" href="style.css"/>
-    </head>
-    <body>
-        <h2>The Engine Basics</h2>
-        <h3>Parts of the Engine</h3>
-        <p>
-            The engine used to power Final Fantasy 7 is split into several
-            modules. This allowed the programming team to break apart into very
-            distinct groups. It also created a very diverse game playing
-            environment. It also allowed the artists to only have to work
-            within their own module, keeping the artwork as dynamic as
-            possible.
-        </p>
-        <p>
-            The module system allowed for a single point of entry into, and
-            exit out of, each distinct part of the game. The PSX, which the
-            game was originally developed for, had very limited resources. With
-            only 1 megabyte of video ram and 2 megabytes of system ram, data
-            had to be banked in and out efficiently. Modules were a clean way
-            to dump whole parts of the engine to make way for other parts.
-        </p>
-        <p>
-            The core system is made up of six modules. They are called the
-            kernel, field, menu, world map, battle, and mini game. They are
-            arranged in the following order.
-        </p>
-        <p>
-            <img src='img/2_engine_basics.jpg'/>
-        </p>
-        <h3>Generic Program Flow</h3>
-        <p>
-            Not every module is accessible by every other module. There is a
-            distinct flow between them. For example, you can not access the
-            menu from battle, much to the chagrin of the poor user who had
-            forgotten to equip some last minute item. The field module, second
-            only to the kernel, drives the game. It includes a powerful
-            scripting system that can call any module within the game.
-        </p>
-    </body>
-</html>

+ 0 - 75
doc/FFVII/3_1_kernel_overview.html

@@ -1,75 +0,0 @@
-<html>
-    <head>
-        <link rel="stylesheet" href="style.css"/>
-    </head>
-    <body>
-        <h2>Kernel Overview</h2>
-        <h3>History</h3>
-        <p>
-            The kernel is a throwback to the very first Final Fantasy game for
-            the Nintendo's original 8 bit system. The NES could only natively
-            read 32 kilobytes of program ROM. To get around this incredible
-            limitation, Nintendo developed "memory mappers" that allowed parts
-            of the program to be switched out, or "banked" and replaced with
-            other parts stored on the game cartridge.
-        </p>
-        <p>
-            FF1 used Nintendo's "Memory Manager Controller #1" (MMC1) . This
-            controller split the game into sixteen sections, each 16 kilobytes
-            long. (The maximum an MMC1 program could be was 256K). This
-            controller also split the accessible memory from the cartridge into
-            two 16K sections. The top 16K was bankable. The bottom 16K could
-            never be switched out and stayed in memory until you removed the
-            cartridge.
-        </p>
-        <p>
-            The original FF1 kernel was located in this bottom 16K of memory.
-        </p>
-        <p>
-            First and foremost the kernel contained the main program loop. It
-            handled all the low level functions for the game. Some of these
-            included controlling interrupts, banking in and out the appropriate
-            part of the game, jumping control to a particular module, playing
-            the music, and other tasks.
-        </p>
-        <p>
-            As the Final Fantasy franchise grew, so did the size of the games.
-            They all still retained the kernel/module system. During the
-            backporting process, this did cause a few headaches. For example,
-            Final Fantasy 6 was originally developed for the Super Nintendo.
-            When it's menu module was banked in, it was done with electronic
-            bank switching. The later PSX port banked the data from the CD-ROM,
-            which caused an unexpected lag that one wasn't used to. On the PC
-            version for FF7, them menu system was simply integrated into the
-            main executable.
-        </p>
-        <h3>Kernel Functionality</h3>
-        <p>
-            The Kernel is a threaded multitasking program that manages the
-            whole system. It uses a simple software based memory manager that
-            handles both RAM and video memory for all the modules in the game.
-            Assisting the kernel are many statically linked Psy-Q libraries. In
-            the case of the PC port, the Psy-Q libs were replaced with a PC
-            equivalent. For example the SEQ player was replaced with a MIDI
-            player, Both accomplish the same tasks, just with different formats
-            and execution strategies. The table below is a generic
-            representation of how the kernel sits in relation to the other
-            aspects of the program.
-
-        </p>
-        <p>
-            <table id='kernel-functionality'>
-                <tr><td>User</td></tr>
-                <tr><td>Module</td></tr>
-                <tr>
-                    <td>
-                        Kernel
-                        <span id='kernel-psyq'>Psy-Q libraries</span>
-                    </td>
-                </tr>
-                <tr><td>PSX BIOS</td></tr>
-                <tr><td>Hardware</td></tr>
-            </table>
-        </p>
-    </body>
-</html>

+ 0 - 162
doc/FFVII/Index.html

@@ -1,162 +0,0 @@
-<html>
-    <head>
-        <link rel="stylesheet" href="style.css"/>
-    </head>
-    <body>
-        <h1>FF7</h1>
-        <p>This is a Stub article. A Wiki version of Gears should go here. For more information, select the "discussion" tab above so we can best architecture the data. For those who want to start converting, download the <a rel="nofollow" class="external text" href="https://wiki.ffrtt.ru/gears.pdf">Gears pdf</a> <a href="/index.php?title=User:Halkun" title="User:Halkun">Halkun</a> 20:18, 5 Mar 2005 (CST)
-        </p>
-        <h2>Contents</h2>
-        <ul class='no_bullet'>
-            <li><span class='index_num'>1</span> <a href="1_history.html" title="History">History</a></li>
-            <li>
-                <span class='index_num'>2</span>
-                <a href="/index.php?title=FF7/Engine_basics" title="Engine basics">Engine Basics</a>
-                <ul class='no_bullet'>
-                    <li><span class='index_num'>2.1</span> Parts of the Engine</li>
-                    <li><span class='index_num'>2.2</span> Generic Program Flow</li>
-                </ul>
-            </li>
-            <li>
-                <span class='index_num'>3</span>
-                <a href="/index.php?title=FF7/Kernel" title="Kernel">The Kernel</a>
-                <ul class='no_bullet'>
-                    <li>
-                        <span class='index_num'>3.1</span>
-                        <a href="/index.php?title=FF7/Kernel/Overview" title="Kernel/Overview">Kernel Overview</a>
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>3.1.1</span> History</li>
-                            <li><span class='index_num'>3.1.2</span> Kernel Functionality</li>
-                        </ul>
-                    </li>
-                    <li>
-                        <span class='index_num'>3.2</span>
-                        <a href="/index.php?title=FF7/Kernel/Memory_management" title="Kernel/Memory management">Memory Management</a>
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>3.2.1</span> RAM Management</li>
-                            <li><span class='index_num'>3.2.2</span> VRAM Management</li>
-                            <li><span class='index_num'>3.2.3</span> PSX CD-ROM management</li>
-                        </ul>
-                    </li>
-                    <li>
-                        <span class='index_num'>3.3</span>
-                        <a href="/index.php?title=FF7/Kernel/Kernel.bin" title="Kernel/Kernel.bin">Kernel.bin</a>
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>3.3.1</span> The KERNEL.BIN Archive</li>
-                            <li><span class='index_num'>3.3.1</span> The KERNEL2.BIN Archive</li>
-                        </ul>
-                    </li>
-                    <li>
-                        <span class='index_num'>3.4</span>
-                        <a href="/index.php?title=FF7/Kernel/Low_level_libraries" title="Kernel/Low level libraries">Low Level Libraries</a>
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>3.4.1</span> PC to PSX comparison</li>
-                            <li>
-                                <span class='index_num'>3.4.2</span> Data Archives
-                                <ul class='no_bullet'>
-                                    <li><span class='index_num'>3.4.2.1</span> BIN Archive data format</li>
-                                    <li><span class='index_num'>3.4.2.2</span> <a href="/index.php?title=FF7/LZSS_format" title="LZSS format"> LZSS Archives</a></li>
-                                    <li><span class='index_num'>3.4.2.3</span> <a href="/index.php?title=FF7/LGP_format" title="LGP format"> LGP Archives</a></li>
-                                </ul>
-                            </li>
-                            <li>
-                                <span class='index_num'>3.5</span> Textures
-                                <ul class='no_bullet'>
-                                    <li><span class='index_num'>3.5.1</span> <a href="/index.php?title=PSX/TIM_format" title="PSX/TIM format"> TIM texture data format for PSX</a></li>
-                                    <li><span class='index_num'>3.5.2</span> <a href="/index.php?title=FF7/TEX_format" title="TEX format"> TEX texture data format for the PC</a></li>
-                                </ul>
-                            </li>
-                            <li>
-                                <span class='index_num'>3.6</span>File formats for 3D models
-                                <ul class='no_bullet'>
-                                    <li><span class='index_num'>3.6.1</span> <a href="/index.php?title=FF7/Kernel/Low_level_libraries#Model_formats_for_PSX" title="Kernel/Low level libraries">Model Formats for PSX</a></li>
-                                    <li><span class='index_num'>3.6.2</span> Model Formats for PC</li>
-                                </ul>
-                            </li>
-                        </ul>
-                    </li>
-                </ul>
-            </li>
-            <li>
-                <span class='index_num'>4</span>
-                <a href="/index.php?title=FF7/Menu_Module" title="Menu Module">The Menu Module</a>
-                <ul class='no_bullet'>
-                    <li><span class='index_num'>4.1</span> Menu Overview</li>
-                    <li><span class='index_num'>4.2</span> Menu Initialization</li>
-                    <li><span class='index_num'>4.3</span> Menu Modules</li>
-                    <li><span class='index_num'>4.4</span> Calling the various menus</li>
-                    <li><span class='index_num'>4.5</span> Menu dependencies</li>
-                    <li><span class='index_num'>4.6</span> <a href="/index.php?title=FF7/Savemap" title="Savemap">The Save Game format</a></li>
-                </ul>
-            </li>
-            <li>
-                <span class='index_num'>5</span>
-                <a href="/index.php?title=FF7/Field_Module" title="Field Module"> The Field Module</a>
-                <ul class='no_bullet'>
-                    <li><span class='index_num'>5.1</span> Field Overview</li>
-                    <li>
-                        <span class='index_num'>5.2</span> Field Format (PC)
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>5.2.1</span> General PC Field File Format</li>
-                            <li><span class='index_num'>5.2.1</span> PC Field File Header</li>
-                            <li><span class='index_num'>5.2.1</span> File Section Details</li>
-                        </ul>
-                    </li>
-                    <li>
-                        <span class='index_num'>5.3</span>
-                        <a href="/index.php?title=FF7/Field_Module#Field_Format_.28PSX.29" title="Field Module">Field Format (PSX)</a>
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>5.3.1</span> <a href="/index.php?title=FF7/Field_Module#PSX_DAT_Format" title="Field Module">PSX DAT Format</a></li>
-                            <li><span class='index_num'>5.3.2</span> <a href="/index.php?title=FF7/Field_Module#PSX_MIM_Format" title="Field Module">PSX MIM Format</a></li>
-                            <li><span class='index_num'>5.3.3</span> <a href="/index.php?title=FF7/Field_Module#PSX_BSX_Format" title="Field Module">PSX BSX Format</a></li>
-                            <li><span class='index_num'>5.3.4</span> <a href="/index.php?title=FF7/Field_Module#PSX_BCX_Format" title="Field Module">PSX BCX Format</a></li>
-                        </ul>
-                    </li>
-                </ul>
-            </li>
-            <li>
-                <span class='index_num'>6</span> The Battle Module
-                <ul class='no_bullet'>
-                    <li><span class='index_num'>6.1</span> Battle Overview</li>
-                    <li><span class='index_num'>6.2</span> <a href="/index.php?title=FF7/Battle/Battle_Mechanics" title="Battle/Battle Mechanics"> Battle Mechanics</a></li>
-                    <li><span class='index_num'>6.3</span> <a href="/index.php?title=FF7/Battle/Battle_Field" title="Battle/Battle Field"> Battle Field</a></li>
-                    <li>
-                        <span class='index_num'>6.4</span>
-                        <a href="/index.php?title=FF7/Battle/Battle_Scenes" title="Battle/Battle Scenes"> Battle Scenes (scene.bin)</a>
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>6.4.1</span> <a href="/index.php?title=FF7/Battle/Battle_Scenes/Battle_Script" title="Battle/Battle Scenes/Battle Script"> Battle Scripts</a></li>
-                        </ul>
-                    </li>
-                    <li><span class='index_num'>6.5</span> <a href="/index.php?title=FF7/Playstation_Battle_Model_Format" class="mw-redirect" title="Playstation Battle Model Format"> Battle Models (PSX)</a></li>
-                    <li><span class='index_num'>6.6</span> <a href="/index.php?title=FF7/Battle/Battle_Animation_(PC)" title="Battle/Battle Animation (PC)"> Battle Animation (PC)</a></li>
-                </ul>
-            </li>
-            <li>
-                <span class='index_num'>7</span>
-                <a href="/index.php?title=FF7/WorldMap_Module" title="WorldMap Module"> The World Map Module</a>
-                <ul class='no_bullet'>
-                    <li><span class='index_num'>7.1</span> <a href="/index.php?title=FF7/World_Map/BSZ" title="World Map/BSZ"> World Map BSZ model file format (PSX)</a></li>
-                    <li><span class='index_num'>7.2</span> <a href="/index.php?title=FF7/World_Map/TXZ" title="World Map/TXZ"> World Map TXZ file format (PSX)</a></li>
-                    <li><span class='index_num'>7.3</span> <a href="/index.php?title=FF7/WorldMap_Module/Script" title="WorldMap Module/Script"> World Map Script Engine</a></li>
-                </ul>
-            </li>
-            <li>
-                <span class='index_num'>8</span> Sound
-                <ul class='no_bullet'>
-                    <li>
-                        <span class='index_num'>8.1</span>
-                        <a href="/index.php?title=FF7/PSX/PSX_Sound" title="PSX/PSX Sound">PSX Sound</a>
-                        <ul class='no_bullet'>
-                            <li><span class='index_num'>8.1.1</span> <a href="/index.php?title=FF7/PSX/Sound/Overview" title="PSX/Sound/Overview">Overview</a></li>
-                            <li><span class='index_num'>8.1.2</span> <a href="/index.php?title=FF7/PSX/Sound/INSTRx.DAT" title="PSX/Sound/INSTRx.DAT">INSTRx.DAT</a></li>
-                            <li><span class='index_num'>8.1.3</span> <a href="/index.php?title=FF7/PSX/Sound/INSTRx.ALL" title="PSX/Sound/INSTRx.ALL">INSTRx.ALL</a></li>
-                            <li><span class='index_num'>8.1.4</span> <a href="/index.php?title=FF7/PSX/Sound/AKAO_sequence" title="PSX/Sound/AKAO sequence">AKAO sequence</a></li>
-                            <li><span class='index_num'>8.1.5</span> <a href="/index.php?title=FF7/PSX/Sound/Code_Map" title="PSX/Sound/Code Map">Code Map</a></li>
-                        </ul>
-                    </li>
-                    <li><span class='index_num'>8.2</span> PC Sound</li>
-                </ul>
-            </li>
-        </ul>
-    </body>
-</html>

BIN
doc/FFVII/img/2_engine_basics.jpg


+ 0 - 47
doc/FFVII/style.css

@@ -1,47 +0,0 @@
-body{
-    background-color: #000000;
-    color: #ffffff;
-    max-width: 80em;
-    margin: auto;
-}
-
-a{
-    color: #0000ff;
-}
-
-a:hover{
-    color: #6666ff;
-}
-
-a{
-    color: #cc00ff;
-}
-
-ul.no_bullet{
-    list-style-type: none;
-}
-
-ul.no_bullet li span.index_num{
-    font-family: monospace;
-    margin-right: 8px;
-    font-size: 1.2em;
-    color: #999;
-    font-weight: bold;
-}
-
-table#kernel-functionality{
-    margin: auto;
-    border-collapse: collapse;
-}
-
-table#kernel-functionality td{
-    border: 2px solid #ffffff;
-    text-align: center;
-}
-
-table#kernel-functionality td span#kernel-psyq{
-    display: block;
-    margin: 0.5em 0.5em 0.2em 4.2em;
-    padding: 0.2em;
-    border: 2px solid #ffffff;
-}

+ 9 - 0
doc/TODO.md

@@ -130,3 +130,12 @@ remembers of the original). Not done:
 - The records 38 and 39 also have a Warship scene in `world_function_64`; it is not known which fields lead to them and they
   were not tested. The last move of record 37 (direction 176, facing 48) is a plain move without turning.
 - The vehicles may run at 15 frames per second as well (their speeds were tuned by eye).
+
+## Fonts: possible improvements
+
+The fonts are built by the installer from WINDOW.BIN (see `WindowFonts`) and drawn as a texture atlas: the PNG is loaded once, each letter is a quad with its cell as texture coordinates, and the geometry is only rebuilt when the text or the position changes. Converting the fonts to TTF was considered and discarded: an engine that loads TTF files rasterizes them into the same kind of atlas, the FF7 font is a two colour pixel font (glyph and shadow) that an outline format can't keep, and the installer would need a font writing library. Possible improvements, not planned yet:
+
+- `UiFont::GetCharData` searches the list of characters for every letter each time the geometry is rebuilt. An array indexed by the character code would make it a direct lookup.
+- The PC version has a font twice the resolution (24x24 cells) in `usfont_a_h.tex` and `usfont_b_h.tex` of menu_us.lgp, split in two textures. The installer could merge them in one image and write the XML for it, for sharper text at high resolutions.
+- The installer could write `ffvii_en.xml` from the width table in WINDOW.BIN (third file, one byte per character: 3 bits of lead, 5 bits of width) instead of keeping it by hand. The XML in the repository matches the table except for `! " , . : ?`, which were made tighter by hand.
+- Loading TTF files makes sense only to support fonts made by users, not for the fonts of the game.

+ 1 - 0
src/installer/CMakeLists.txt

@@ -26,6 +26,7 @@ set(INSTALLER_SOURCE_FILES
     ScopedLgp.cpp
     TexFile.cpp
     VGearsUtility.cpp
+    WindowFonts.cpp
     WorldInstaller.cpp
     common/BinGZipFile.cpp
     common/DrawSkeleton.cpp

+ 4 - 0
src/installer/DataInstaller.cpp

@@ -310,6 +310,10 @@ float DataInstaller::Progress(){
             installation_state_ = MEDIA_IMAGES;
             return CalcProgress();
         case MEDIA_IMAGES:
+            // The fonts are always needed, even if the rest of the images are skipped.
+            write_output_line_("Extracting fonts...", 2, true);
+            if (!media_installer_->InstallFonts())
+                write_output_line_("WARNING: Couldn't read WINDOW.BIN, the game won't be able to show text.", 2, true);
             // Skip images if option is set.
             if (!options_.images){
                 write_output_line_("Skipping images installation...", 2, true);

+ 5 - 0
src/installer/InstallVerifier.cpp

@@ -183,5 +183,10 @@ VerifyResult VerifyInstallation(const std::string& root, const std::string& refe
     check.Files(music, "data/audio/musics", ".ogg", 50);
     const std::string images = "Images";
     check.Files(images, "data/images/icons", "", 1);
+    // Fonts, built from WINDOW.BIN. They are installed even when images are not.
+    const std::string fonts = "Fonts";
+    for (const char* file : {
+      "data/fonts/ffvii_en.png", "data/fonts/ffvii_menu.png", "data/fonts/ffvii_digits.png", "data/fonts/ffvii_timer.png"
+    }) check.File(fonts, file);
     return result;
 }

+ 20 - 0
src/installer/MediaDataInstaller.cpp

@@ -33,6 +33,7 @@
 #include "data/VGearsLGPArchive.h"
 #include "data/VGearsTexFile.h"
 #include "TexFile.h"
+#include "WindowFonts.h"
 
 int MediaDataInstaller::TOTAL_SOUNDS = 750;
 
@@ -1315,6 +1316,25 @@ void MediaDataInstaller::InstallSprites(){
     }
 }
 
+bool MediaDataInstaller::InstallFonts(){
+    // WINDOW.BIN: the first file is the window graphics TIM, the second one the dialog font TIM.
+    WindowFonts::IndexImage window;
+    WindowFonts::IndexImage text;
+    for (u32 i = 0; i < 2; i ++){
+        std::unique_ptr<File> tim(window_.ExtractGZip(i));
+        if (tim == nullptr) return false;
+        std::vector<u8> buffer(tim->GetFileSize());
+        tim->GetFileBuffer(buffer.data(), 0, buffer.size());
+        if (!WindowFonts::ReadTim4(buffer.data(), buffer.size(), i == 0 ? window : text)) return false;
+    }
+    const std::string font_dir = data_dir_ + "fonts/";
+    WindowFonts::SavePng(WindowFonts::BuildTextFont(text), font_dir + "ffvii_en.png");
+    WindowFonts::SavePng(WindowFonts::BuildMenuFont(window), font_dir + "ffvii_menu.png");
+    WindowFonts::SavePng(WindowFonts::BuildDigitsFont(window), font_dir + "ffvii_digits.png");
+    WindowFonts::SavePng(WindowFonts::BuildTimerFont(window), font_dir + "ffvii_timer.png");
+    return true;
+}
+
 int MediaDataInstaller::InstallSoundsInit(){
     std::unique_ptr<std::string> fmt_path = disk_image_.filePath("data/sound/audio.fmt");
     std::unique_ptr<std::string> data_path = disk_image_.filePath("data/sound/audio.dat");

+ 10 - 0
src/installer/MediaDataInstaller.h

@@ -59,6 +59,16 @@ class MediaDataInstaller{
          */
         void InstallSprites();
 
+        /**
+         * Builds the font images from the textures in WINDOW.BIN and saves them in the "fonts" directory.
+         *
+         * The font XML files that describe them are part of the V-Gears data files. The fonts are always
+         * needed, so this doesn't depend on the images option.
+         *
+         * @return True if all the fonts were saved, false if WINDOW.BIN couldn't be read.
+         */
+        bool InstallFonts();
+
         /**
          * Prepares the installer for the sounds extraction.
          *

+ 217 - 0
src/installer/WindowFonts.cpp

@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <array>
+#include <OgreImage.h>
+#include <OgreColourValue.h>
+#include "WindowFonts.h"
+
+namespace{
+
+    /**
+     * An RGBA colour.
+     */
+    struct Colour{
+        u8 r;
+        u8 g;
+        u8 b;
+        u8 a;
+    };
+
+    /**
+     * Fully transparent colour.
+     */
+    const Colour TRANSPARENT = {0, 0, 0, 0};
+
+    /**
+     * Colour of every palette index of a 4 bpp image.
+     */
+    typedef std::array<Colour, 16> Palette;
+
+    /**
+     * Palette of the dialog font: index 3 is the glyph, index 1 its shadow.
+     */
+    Palette TextPalette(){
+        Palette palette;
+        palette.fill(TRANSPARENT);
+        palette[1] = {32, 32, 32, 255};
+        palette[3] = {230, 230, 230, 255};
+        return palette;
+    }
+
+    /**
+     * Palette of the menu font and the small digits: index 1 is the glyph, index 15 its shadow.
+     */
+    Palette MenuPalette(){
+        Palette palette;
+        palette.fill(TRANSPARENT);
+        palette[1] = {230, 230, 230, 255};
+        palette[15] = {24, 24, 24, 255};
+        return palette;
+    }
+
+    /**
+     * Palette of the timer font. It's opaque: indices 2 to 4 are the glyph, the others the background.
+     */
+    Palette TimerPalette(){
+        Palette palette;
+        palette.fill({0, 0, 0, 255});
+        palette[2] = {255, 0, 255, 255};
+        palette[3] = {197, 0, 197, 255};
+        palette[4] = {139, 0, 139, 255};
+        palette[13] = {41, 41, 41, 255};
+        palette[14] = {24, 24, 24, 255};
+        palette[15] = {24, 24, 24, 255};
+        return palette;
+    }
+
+    /**
+     * Creates an image filled with a colour.
+     *
+     * @param[in] width Image width.
+     * @param[in] height Image height.
+     * @param[in] colour Colour of every pixel.
+     * @return The image.
+     */
+    WindowFonts::RgbaImage CreateImage(int width, int height, const Colour& colour){
+        WindowFonts::RgbaImage image;
+        image.width = width;
+        image.height = height;
+        image.pixels.resize(width * height * 4);
+        for (int i = 0; i < width * height; i ++){
+            image.pixels[i * 4] = colour.r;
+            image.pixels[i * 4 + 1] = colour.g;
+            image.pixels[i * 4 + 2] = colour.b;
+            image.pixels[i * 4 + 3] = colour.a;
+        }
+        return image;
+    }
+
+    /**
+     * Copies a rectangle of a TIM image into an RGBA image, converting it with a palette.
+     *
+     * Pixels outside of the destination are ignored.
+     *
+     * @param[in] src The TIM image.
+     * @param[in] src_x X coordinate of the rectangle in the TIM image.
+     * @param[in] src_y Y coordinate of the rectangle in the TIM image.
+     * @param[in] width Width of the rectangle.
+     * @param[in] height Height of the rectangle.
+     * @param[in] palette Colour of every palette index.
+     * @param[out] dst The destination image.
+     * @param[in] dst_x X coordinate of the rectangle in the destination image.
+     * @param[in] dst_y Y coordinate of the rectangle in the destination image.
+     */
+    void Blit(
+      const WindowFonts::IndexImage& src, int src_x, int src_y, int width, int height, const Palette& palette,
+      WindowFonts::RgbaImage& dst, int dst_x, int dst_y
+    ){
+        for (int y = 0; y < height; y ++){
+            for (int x = 0; x < width; x ++){
+                const int tx = dst_x + x;
+                const int ty = dst_y + y;
+                if (tx < 0 || ty < 0 || tx >= dst.width || ty >= dst.height) continue;
+                const Colour& c = palette[src.At(src_x + x, src_y + y) & 0x0F];
+                const int i = (ty * dst.width + tx) * 4;
+                dst.pixels[i] = c.r;
+                dst.pixels[i + 1] = c.g;
+                dst.pixels[i + 2] = c.b;
+                dst.pixels[i + 3] = c.a;
+            }
+        }
+    }
+
+    /**
+     * Reads a little endian 16 bit value.
+     */
+    u32 ReadU16(const u8* data){return data[0] | (data[1] << 8);}
+
+    /**
+     * Reads a little endian 32 bit value.
+     */
+    u32 ReadU32(const u8* data){return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);}
+}
+
+u8 WindowFonts::IndexImage::At(int x, int y) const{
+    if (x < 0 || y < 0 || x >= width || y >= height) return 0;
+    return pixels[y * width + x];
+}
+
+bool WindowFonts::ReadTim4(const u8* data, size_t size, IndexImage& image){
+    // Header: magic (0x10) and flags. 4 bpp with a palette is 0x08.
+    if (size < 8 || ReadU32(data) != 0x10 || (ReadU32(data + 4) & 0x0F) != 0x08) return false;
+    size_t offset = 8;
+    // Palette block: its length comes first, the colours are not needed.
+    if (offset + 12 > size) return false;
+    offset += ReadU32(data + offset);
+    // Image block: length, x, y, width in 16 bit units, height.
+    if (offset + 12 > size) return false;
+    const int width = ReadU16(data + offset + 8) * 4;
+    const int height = ReadU16(data + offset + 10);
+    offset += 12;
+    if (offset + static_cast<size_t>(width / 2) * height > size) return false;
+    image.width = width;
+    image.height = height;
+    image.pixels.resize(width * height);
+    for (int i = 0; i < width * height / 2; i ++){
+        image.pixels[i * 2] = data[offset + i] & 0x0F;
+        image.pixels[i * 2 + 1] = data[offset + i] >> 4;
+    }
+    return true;
+}
+
+WindowFonts::RgbaImage WindowFonts::BuildTextFont(const IndexImage& font){
+    RgbaImage image = CreateImage(256, 256, TRANSPARENT);
+    Blit(font, 0, 0, 256, 256, TextPalette(), image, 0, 0);
+    return image;
+}
+
+WindowFonts::RgbaImage WindowFonts::BuildMenuFont(const IndexImage& window){
+    RgbaImage image = CreateImage(128, 256, TRANSPARENT);
+    // Twelve rows of 8 pixels at (128, 152).
+    for (int row = 0; row < 12; row ++) Blit(window, 128, 152 + row * 8, 128, 8, MenuPalette(), image, 0, row * 16 + 8);
+    return image;
+}
+
+WindowFonts::RgbaImage WindowFonts::BuildDigitsFont(const IndexImage& window){
+    RgbaImage image = CreateImage(128, 8, TRANSPARENT);
+    const Palette palette = MenuPalette();
+    // Digits 0 to 9, in cells of 8 pixels at (136, 0).
+    Blit(window, 136, 0, 80, 8, palette, image, 0, 0);
+    // Symbols, taken from the menu font: '-', '+', '%' and ':'. Cell 10 is the blank space.
+    Blit(window, 136, 240, 8, 8, palette, image, 88, 0);
+    Blit(window, 152, 216, 8, 8, palette, image, 96, 0);
+    Blit(window, 152, 232, 8, 8, palette, image, 104, 0);
+    Blit(window, 168, 232, 8, 8, palette, image, 112, 0);
+    return image;
+}
+
+WindowFonts::RgbaImage WindowFonts::BuildTimerFont(const IndexImage& window){
+    // Two rows of 24 pixels at (144, 80). The image is wider than what's left of the texture.
+    RgbaImage image = CreateImage(128, 48, {0, 0, 0, 255});
+    Blit(window, 144, 80, 112, 48, TimerPalette(), image, 0, 0);
+    return image;
+}
+
+void WindowFonts::SavePng(const RgbaImage& image, const std::string& file_name){
+    Ogre::Image png(Ogre::PF_R8G8B8A8_UINT, image.width, image.height);
+    for (int y = 0; y < image.height; y ++){
+        for (int x = 0; x < image.width; x ++){
+            const u8* p = &image.pixels[(y * image.width + x) * 4];
+            png.setColourAt(Ogre::ColourValue(p[0] / 255.0f, p[1] / 255.0f, p[2] / 255.0f, p[3] / 255.0f), x, y, 0);
+        }
+    }
+    png.save(file_name);
+}

+ 139 - 0
src/installer/WindowFonts.h

@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+#include "common/TypeDefine.h"
+
+/**
+ * Builds the font images used by the game from the textures in WINDOW.BIN.
+ *
+ * WINDOW.BIN (data/kernel) holds three gzipped files. The first one is a 4 bpp TIM with the window
+ * graphics, including the menu font, the small digits and the timer digits. The second one is a 4 bpp
+ * TIM with the dialog font. The third one is the width table of the dialog font.
+ *
+ * The images built here have the layout described by the font XML files in data/fonts, so the XML
+ * files don't change. Only the palette indices of the TIM files are used, and they are mapped to fixed
+ * colours, because the game tints the text itself.
+ */
+namespace WindowFonts{
+
+    /**
+     * Palette indices of a 4 bpp TIM image, one byte per pixel.
+     */
+    struct IndexImage{
+
+        /**
+         * Image width, in pixels.
+         */
+        int width = 0;
+
+        /**
+         * Image height, in pixels.
+         */
+        int height = 0;
+
+        /**
+         * Palette index of every pixel, row by row.
+         */
+        std::vector<u8> pixels;
+
+        /**
+         * Gets the palette index of a pixel.
+         *
+         * @param[in] x X coordinate.
+         * @param[in] y Y coordinate.
+         * @return The palette index, or 0 if the coordinates are outside the image.
+         */
+        u8 At(int x, int y) const;
+    };
+
+    /**
+     * An RGBA image, four bytes per pixel.
+     */
+    struct RgbaImage{
+
+        /**
+         * Image width, in pixels.
+         */
+        int width = 0;
+
+        /**
+         * Image height, in pixels.
+         */
+        int height = 0;
+
+        /**
+         * Red, green, blue and alpha of every pixel, row by row.
+         */
+        std::vector<u8> pixels;
+    };
+
+    /**
+     * Reads the pixels of a 4 bpp TIM file.
+     *
+     * @param[in] data The TIM file.
+     * @param[in] size Size of the TIM file, in bytes.
+     * @param[out] image The palette indices of the image.
+     * @return True if the data is a valid 4 bpp TIM file, false otherwise.
+     */
+    bool ReadTim4(const u8* data, size_t size, IndexImage& image);
+
+    /**
+     * Builds the dialog font image (ffvii_en.png) from the second TIM of WINDOW.BIN.
+     *
+     * @param[in] font The dialog font TIM.
+     * @return The 256x256 font image.
+     */
+    RgbaImage BuildTextFont(const IndexImage& font);
+
+    /**
+     * Builds the menu font image (ffvii_menu.png) from the first TIM of WINDOW.BIN.
+     *
+     * The menu font is made of rows of 8 pixels. Each row is placed in a slot of 16 pixels, with the
+     * glyphs in the lower half. The four last rows of the image are empty, the PC version doesn't have
+     * the voiced kana that the XML expects there.
+     *
+     * @param[in] window The window graphics TIM.
+     * @return The 128x256 font image.
+     */
+    RgbaImage BuildMenuFont(const IndexImage& window);
+
+    /**
+     * Builds the small digits font image (ffvii_digits.png) from the first TIM of WINDOW.BIN.
+     *
+     * @param[in] window The window graphics TIM.
+     * @return The 128x8 font image.
+     */
+    RgbaImage BuildDigitsFont(const IndexImage& window);
+
+    /**
+     * Builds the timer font image (ffvii_timer.png) from the first TIM of WINDOW.BIN.
+     *
+     * @param[in] window The window graphics TIM.
+     * @return The 128x48 font image.
+     */
+    RgbaImage BuildTimerFont(const IndexImage& window);
+
+    /**
+     * Saves an image as a PNG file.
+     *
+     * @param[in] image The image to save.
+     * @param[in] file_name Path of the PNG file.
+     */
+    void SavePng(const RgbaImage& image, const std::string& file_name);
+}

BIN
src/installer/decompiler/test/branches.dmp


+ 0 - 5
src/installer/decompiler/test/branches.txt

@@ -1,5 +0,0 @@
-pushWord 0
-jumpFalse postBranch
-stopObjectCodeA
-postBranch:
-stopObjectCodeA

BIN
src/installer/decompiler/test/break-do-while.dmp


+ 0 - 14
src/installer/decompiler/test/break-do-while.txt

@@ -1,14 +0,0 @@
-do:
-pushWord 18
-pushWordVar 321
-eq
-jumpTrue postBreak
-jump postDo
-postBreak:
-wordVarInc 123
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue do
-postDo:
-stopObjectCodeA

BIN
src/installer/decompiler/test/break-do-while2.dmp


+ 0 - 15
src/installer/decompiler/test/break-do-while2.txt

@@ -1,15 +0,0 @@
-do:
-wordVarInc 321
-pushWord 18
-pushWordVar 321
-eq
-jumpTrue postBreak
-jump postDo
-postBreak:
-wordVarInc 123
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue do
-postDo:
-stopObjectCodeA

BIN
src/installer/decompiler/test/break-while.dmp


+ 0 - 15
src/installer/decompiler/test/break-while.txt

@@ -1,15 +0,0 @@
-while:
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue postWhile
-pushWord 18
-pushWordVar 321
-eq
-jumpTrue postBreak
-jump postWhile
-postBreak:
-wordVarInc 123
-jump while
-postWhile:
-stopObjectCodeA

BIN
src/installer/decompiler/test/bug_fixes.dat


+ 0 - 554
src/installer/decompiler/test/cfg_test.cpp

@@ -1,554 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "decompiler/scummv6/engine.h"
-#include <gmock/gmock.h>
-#include <vector>
-#include "../ControlFlow.h"
-#include "../Disassembler.h"
-#include "../Graph.h"
-
-#define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
-
-
-TEST(CFG, testUnreachable) {
-    InstVec insts;
-    Scumm::v6::Scummv6Engine *engine = new Scumm::v6::Scummv6Engine();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/unreachable.dmp");
-    d->disassemble();
-    ControlFlow *c = new ControlFlow(insts, *engine);
-    Graph g = c->getGraph();
-    ASSERT_TRUE(boost::num_vertices(g) == 4);
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        switch ((*gr->_start)->_address) {
-        case 0:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
-            break;
-        case 2:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
-            break;
-        case 5:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
-            break;
-        case 6:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
-            break;
-        default:
-            ASSERT_TRUE(false);
-        }
-    }
-    delete c;
-    delete engine;
-};
-
-TEST(CFG, testBranching) {
-    InstVec insts;
-    Scumm::v6::Scummv6Engine *engine = new Scumm::v6::Scummv6Engine();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/branches.dmp");
-    d->disassemble();
-
-    ControlFlow *c = new ControlFlow(insts, *engine);
-    Graph g = c->getGraph();
-    ASSERT_TRUE(boost::num_vertices(g) == 4);
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        switch ((*gr->_start)->_address) {
-        case 0:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 1);
-            break;
-        case 2:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 2);
-            break;
-        case 5:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
-            break;
-        case 6:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
-            break;
-        default:
-            ASSERT_TRUE(false);
-        }
-    }
-    delete c;
-    delete engine;
-}
-
-TEST(CFG, testGrouping) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/branches.dmp");
-    d->disassemble();
-
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->getGraph();
-    ASSERT_TRUE(boost::num_vertices(g) == 3);
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        switch ((*gr->_start)->_address) {
-        case 0:
-            ASSERT_TRUE((*gr->_end)->_address == 2);
-            ASSERT_TRUE(boost::in_degree(*it, g) == 0 && boost::out_degree(*it, g) == 2);
-            break;
-        case 5:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 1 && boost::out_degree(*it, g) == 1);
-            break;
-        case 6:
-            ASSERT_TRUE(boost::in_degree(*it, g) == 2 && boost::out_degree(*it, g) == 0);
-            break;
-        default:
-            ASSERT_TRUE(false);
-            break;
-        }
-    }
-}
-
-// TODO: Fix me, this fails but looks like it shouldn't
-TEST(CFG, DISABLED_testShortCircuitDetection) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/short-circuit.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->getGraph();
-    ASSERT_TRUE(boost::num_vertices(g) == 3);
-}
-
-TEST(CFG, testWhileDetection) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/while.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-    }
-
-}
-
-TEST(CFG, testDoWhileDetection) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/while.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 3)
-            ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
-    }
-}
-
-TEST(CFG, testBreakDetection) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/break-while.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x14)
-            ASSERT_TRUE(gr->_type == kBreakGroupType);
-    }
-
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/break-do-while.dmp");
-    d->disassemble();
-
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0xA)
-            ASSERT_TRUE(gr->_type == kBreakGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/break-do-while2.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0xD)
-            ASSERT_TRUE(gr->_type == kBreakGroupType);
-    }
-
-}
-
-TEST(CFG, testContinueDetection) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/continue-while.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x14)
-            ASSERT_TRUE(gr->_type == kContinueGroupType);
-        if ((*gr->_start)->_address == 0x1a)
-            ASSERT_TRUE(gr->_type == kNormalGroupType);
-    }
-;
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/continue-do-while.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0xA)
-            ASSERT_TRUE(gr->_type == kContinueGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/continue-do-while2.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0xD)
-            ASSERT_TRUE(gr->_type == kContinueGroupType);
-    }
-}
-
-TEST(CFG, testIfDetection) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/if.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kIfCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/break-do-while.dmp");
-    d->disassemble();
-
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kIfCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/break-do-while2.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x3)
-            ASSERT_TRUE(gr->_type == kIfCondGroupType);
-    }
-
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/continue-do-while.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kIfCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/continue-do-while2.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x3)
-            ASSERT_TRUE(gr->_type == kIfCondGroupType);
-    }
-}
-
-TEST(CFG, testElseDetection) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/if-else.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x10) {
-            ASSERT_TRUE(gr->_startElse);
-            ASSERT_TRUE(gr->_endElse.size() == 1 && gr->_endElse[0] == gr);
-        }
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/if-no-else.dmp");
-    d->disassemble();
-
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kIfCondGroupType);
-        ASSERT_TRUE(!gr->_startElse);
-    }
-}
-
-TEST(CFG, testNestedLoops) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/do-while-in-while.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-        if ((*gr->_start)->_address == 0xd)
-            ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/nested-do-while.dmp");
-    d->disassemble();
-
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x6)
-            ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
-        if ((*gr->_start)->_address == 0x10)
-            ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/nested-while.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-        if ((*gr->_start)->_address == 0xa)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/nested-while2.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-        if ((*gr->_start)->_address == 0xd)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/while-in-do-while.dmp");
-    d->disassemble();
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x0)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-        if ((*gr->_start)->_address == 0x10)
-            ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
-    }
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/while-in-do-while2.dmp");
-    d->disassemble();
-
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        if ((*gr->_start)->_address == 0x3)
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-        if ((*gr->_start)->_address == 0x13)
-            ASSERT_TRUE(gr->_type == kDoWhileCondGroupType);
-    }
-}
-
-// This test requires script-30.dmp from Sam & Max: Hit The Road.
-// 6e48faca13e1f6df9341567608962744 *script-30.dmp
-// Disabled as mentioned file is copyrighted
-TEST(CFG, DISABLED_testSamAndMaxScript30) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/script-30.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    VertexRange range = boost::vertices(g);
-    for (VertexIterator it = range.first; it != range.second; ++it) {
-        GroupPtr gr = GET(*it);
-        switch ((*gr->_start)->_address) {
-        case 0x6:
-            ASSERT_TRUE(gr->_type == kWhileCondGroupType);
-            ASSERT_TRUE(!gr->_startElse);
-            ASSERT_TRUE(gr->_endElse.empty());
-            break;
-        case 0x19:
-        case 0x3A:
-        case 0x4F:
-        case 0x68:
-        case 0x74: // Allow inclusion of the pop instruction immediately before
-        case 0x75:
-        case 0x92:
-            ASSERT_TRUE(gr->_type == kIfCondGroupType);
-            ASSERT_TRUE(!gr->_startElse);
-            ASSERT_TRUE(gr->_endElse.empty());
-            break;
-        case 0x8B:
-            ASSERT_TRUE(gr->_type == kNormalGroupType);
-            ASSERT_TRUE(gr->_startElse);
-            ASSERT_TRUE(gr->_endElse.size() == 1 && (*gr->_endElse[0]->_start)->_address == 0x8B);
-            break;
-        case 0x91:
-            ASSERT_TRUE(gr->_type == kNormalGroupType || gr->_type == kIfCondGroupType); // Allow inclusion of the pop instruction immediately before
-            ASSERT_TRUE(gr->_startElse);
-            ASSERT_TRUE(gr->_endElse.empty());
-            break;
-        case 0xA6:
-            ASSERT_TRUE(gr->_type == kNormalGroupType);
-            ASSERT_TRUE(!gr->_startElse);
-            ASSERT_TRUE(gr->_endElse.size() == 1 && (*gr->_endElse[0]->_start)->_address == 0x91);
-            break;
-        default:
-            ASSERT_TRUE(gr->_type == kNormalGroupType);
-            ASSERT_TRUE(!gr->_startElse);
-            ASSERT_TRUE(gr->_endElse.empty());
-            break;
-        }
-    }
-}

+ 0 - 217
src/installer/decompiler/test/codegen.cpp

@@ -1,217 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-
-#include "decompiler/scummv6/engine.h"
-
-#include <vector>
-
-#include "../CodeGenerator.h"
-#include "../ControlFlow.h"
-#include "../Disassembler.h"
-#include "../Graph.h"
-#define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
-
-#include <streambuf>
-#include <ostream>
-#include <gmock/gmock.h>
-#include "util.h"
-
-std::string removeSpaces(std::string s) {
-    size_t found;
-    while ((found = s.find(' ')) != std::string::npos)
-        s = s.erase(found, 1);
-    return s;
-}
-
-typedef std::vector<std::string>::iterator CodeIterator;
-
-
-TEST(CodeGen, testContinue) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/continue-do-while.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    onullstream ns;
-    auto cg = engine->GetCodeGenerator(insts, ns);
-    cg->generate(insts, g);
-
-    VertexIterator v = boost::vertices(g).first;
-    std::vector<std::string> output, expected;
-    expected.push_back("do{");
-    expected.push_back("if(18 != var321) {");
-    expected.push_back("continue;");
-    expected.push_back("}");
-    expected.push_back("VAR_CHARSET_MASK--;");
-    expected.push_back("} while (42 == VAR_CHARSET_MASK)");
-    expected.push_back("stopObjectCodeA();");
-    GroupPtr gr = GET(*v);
-    // Find first node
-    while (gr->_prev != NULL)
-        gr = gr->_prev;
-    // Copy out all lines of code
-    while (gr != NULL) {
-        for (std::vector<CodeLine>::iterator it = gr->_code.begin(); it != gr->_code.end(); ++it)
-            output.push_back(it->_line);
-        gr = gr->_next;
-    }
-    ASSERT_TRUE(output.size() == expected.size());
-    CodeIterator it, it2;
-    for (it = output.begin(), it2 = expected.begin(); it != output.end() && it2 != expected.end(); ++it, ++it2) {
-        ASSERT_TRUE(removeSpaces(*it).compare(removeSpaces(*it2)) == 0);
-    }
-}
-
-TEST(CodeGen, testBreak) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/break-while.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    onullstream ns;
-    auto cg = engine->GetCodeGenerator(insts, ns);
-    cg->generate(insts, g);
-
-    VertexIterator v = boost::vertices(g).first;
-    std::vector<std::string> output, expected;
-    expected.push_back("while (42 != VAR_CHARSET_MASK) {");
-    expected.push_back("if (18 != var321) {");
-    expected.push_back("break;");
-    expected.push_back("}");
-    expected.push_back("VAR_CHARSET_MASK--;");
-    expected.push_back("}");
-    expected.push_back("stopObjectCodeA();");
-    GroupPtr gr = GET(*v);
-    // Find first node
-    while (gr->_prev != NULL)
-        gr = gr->_prev;
-    // Copy out all lines of code
-    while (gr != NULL) {
-        for (std::vector<CodeLine>::iterator it = gr->_code.begin(); it != gr->_code.end(); ++it)
-            output.push_back(it->_line);
-        gr = gr->_next;
-    }
-    ASSERT_TRUE(output.size() == expected.size());
-    CodeIterator it, it2;
-    for (it = output.begin(), it2 = expected.begin(); it != output.end() && it2 != expected.end(); ++it, ++it2) {
-        ASSERT_TRUE(removeSpaces(*it).compare(removeSpaces(*it2)) == 0);
-    }
-}
-
-TEST(CodeGen, testElse) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/if-else.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    onullstream ns;
-    auto cg = engine->GetCodeGenerator(insts, ns);
-    cg->generate(insts, g);
-
-    VertexIterator v = boost::vertices(g).first;
-    std::vector<std::string> output, expected;
-    expected.push_back("if (42 != VAR_CHARSET_MASK) {");
-    expected.push_back("VAR_CHARSET_MASK--;");
-    expected.push_back("} else {");
-    expected.push_back("VAR_CHARSET_MASK++;");
-    expected.push_back("}");
-    expected.push_back("stopObjectCodeA();");
-    GroupPtr gr = GET(*v);
-    // Find first node
-    while (gr->_prev != NULL)
-        gr = gr->_prev;
-    // Copy out all lines of code
-    while (gr != NULL) {
-        for (std::vector<CodeLine>::iterator it = gr->_code.begin(); it != gr->_code.end(); ++it)
-            output.push_back(it->_line);
-        gr = gr->_next;
-    }
-    ASSERT_TRUE(output.size() == expected.size());
-    CodeIterator it, it2;
-    for (it = output.begin(), it2 = expected.begin(); it != output.end() && it2 != expected.end(); ++it, ++it2) {
-        ASSERT_TRUE(removeSpaces(*it).compare(removeSpaces(*it2)) == 0);
-    }
-}
-
-// This test requires script-30 and script-48.dmp from Sam & Max: Hit The Road.
-// 6e48faca13e1f6df9341567608962744 *script-30.dmp
-// afd7dc5d377894b3b9d0504927adf1b1 *script-48.dmp
-// Disabled as mentioned file is copyrighted
-TEST(CodeGen, DISABLED_testCoalescing) {
-    InstVec insts;
-    auto engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    auto d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/script-30.dmp");
-    d->disassemble();
-    auto c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    Graph g = c->analyze();
-    onullstream ns;
-    auto cg = engine->GetCodeGenerator(insts, ns);
-    cg->generate(insts, g);
-
-    VertexIterator v = boost::vertices(g).first;
-    GroupPtr gr = GET(*v);
-    // Find first node
-    while (gr->_prev != NULL)
-        gr = gr->_prev;
-    // Find vertex to test
-    while ((*gr->_start)->_address != 0x91)
-        gr = gr->_next;
-
-    ASSERT_TRUE(gr->_code.size() == 2);
-    ASSERT_TRUE(removeSpaces(gr->_code[0]._line).compare("}else{") == 0);
-    ASSERT_TRUE(removeSpaces(gr->_code[1]._line).substr(0, 2).compare("if") == 0);
-
-    insts.clear();
-    engine = std::make_unique<Scumm::v6::Scummv6Engine>();
-    d = engine->GetDisassembler(insts);
-    d->open("decompiler/test/script-48.dmp");
-    d->disassemble();
-
-    c = std::make_unique<ControlFlow>(insts, *engine);
-    c->createGroups();
-    g = c->analyze();
-    cg = engine->GetCodeGenerator(insts, ns);
-    cg->generate(insts, g);
-
-    v = boost::vertices(g).first;
-    gr = GET(*v);
-    // Find first node
-    while (gr->_prev != NULL)
-        gr = gr->_prev;
-    // Find vertex to test
-    while ((*gr->_start)->_address != 0x191)
-        gr = gr->_next;
-
-    ASSERT_TRUE(gr->_code.size() == 1);
-    ASSERT_TRUE(removeSpaces(gr->_code[0]._line).substr(0, 7).compare("}elseif") == 0);
-}

BIN
src/installer/decompiler/test/continue-do-while.dmp


+ 0 - 14
src/installer/decompiler/test/continue-do-while.txt

@@ -1,14 +0,0 @@
-do:
-pushWord 18
-pushWordVar 321
-eq
-jumpTrue postContinue
-jump while
-postContinue:
-wordVarInc 123
-while:
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue do
-stopObjectCodeA

BIN
src/installer/decompiler/test/continue-do-while2.dmp


+ 0 - 15
src/installer/decompiler/test/continue-do-while2.txt

@@ -1,15 +0,0 @@
-do:
-wordVarInc 321
-pushWord 18
-pushWordVar 321
-eq
-jumpTrue postContinue
-jump while
-postContinue:
-wordVarInc 123
-while:
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue do
-stopObjectCodeA

BIN
src/installer/decompiler/test/continue-while.dmp


+ 0 - 15
src/installer/decompiler/test/continue-while.txt

@@ -1,15 +0,0 @@
-while:
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue postWhile
-pushWord 18
-pushWordVar 321
-eq
-jumpTrue postContinue
-jump while
-postContinue:
-wordVarInc 123
-jump while
-postWhile:
-stopObjectCodeA

+ 0 - 147
src/installer/decompiler/test/disassembler/pasc.cpp

@@ -1,147 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "pasc.h"
-
-PasCDisassembler::PasCDisassembler(InstVec &insts) : ::SimpleDisassembler(insts) {
-}
-
-void PasCDisassembler::doDisassemble(){
-	START_OPCODES;
-		//Basic machine operations
-		OPCODE(0x00, "PUSH", PasCFakeInstruction, 0, "i");
-		OPCODE(0x01, "POP",	PasCFakeInstruction, 0, "i");
-		OPCODE(0x02, "CALL", PasCFakeInstruction, 0, "d");
-		OPCODE(0x03, "RETURN", PasCFakeInstruction, 0, "");
-		OPCODE(0x04, "HALT", PasCFakeInstruction, 0, "");
-
-		//Jumps
-		OPCODE(0x10, "JUMP", PasCFakeInstruction, 0, "a");
-		OPCODE(0x11, "JEQ", PasCFakeInstruction, 0, "a");
-		OPCODE(0x12, "JAEQ", PasCFakeInstruction, 0, "a");
-		OPCODE(0x13, "JGT", PasCFakeInstruction, 0, "a");
-		OPCODE(0x14, "JLT", PasCFakeInstruction, 0, "a");
-		OPCODE(0x15, "JALT", PasCFakeInstruction, 0, "a");
-		OPCODE(0x16, "JAGT", PasCFakeInstruction, 0, "a");
-
-		//Boolean operations
-		OPCODE(0x20, "OR", PasCFakeInstruction, -1, "");
-		OPCODE(0x21, "AND", PasCFakeInstruction, -1, "");
-		OPCODE(0x22, "XOR", PasCFakeInstruction, -1, "");
-		OPCODE(0x23, "NOT", PasCFakeInstruction, -1, "");
-
-		//Padding instructions (smaller integer -> larger integer)
-		OPCODE(0x30, "SPAD", PasCFakeInstruction, 0, "B");
-		OPCODE(0x31, "UPAD", PasCFakeInstruction, 0, "B");
-
-		//32-bit operations
-		OPCODE(0x80, "IADD", PasCFakeInstruction, -4, "");
-		OPCODE(0x81, "ISUB", PasCFakeInstruction, -4, "");
-		OPCODE(0x82, "IMULT", PasCFakeInstruction, -4, "");
-		OPCODE(0x83, "IDIV", PasCFakeInstruction, -4, "");
-		OPCODE(0x84, "IMOD", PasCFakeInstruction, -4, "");
-		OPCODE(0x85, "ISHL", PasCFakeInstruction, -4, "");
-		OPCODE(0x86, "ISHR", PasCFakeInstruction, -4, "");
-		OPCODE(0x87, "ISTOREA [SB]", PasCFakeInstruction, -4, "i");
-		OPCODE(0x88, "ISTOREL [SB]", PasCFakeInstruction, 0, "ii");
-		OPCODE(0x89, "ILOADA [SB]", PasCFakeInstruction, 4, "i");
-		OPCODE(0x8A, "ISTOREA", PasCFakeInstruction, -4, "d");
-		OPCODE(0x8B, "ISTOREL", PasCFakeInstruction, 0, "di");
-		OPCODE(0x8C, "ILOADA", PasCFakeInstruction, 4, "d");
-		OPCODE(0x8D, "ILOADL", PasCFakeInstruction, 0, "i");
-		OPCODE(0x8E, "ICMP", PasCFakeInstruction, -8, "");
-		OPCODE(0x8F, "UICMP", PasCFakeInstruction, -8, "");
-		OPCODE(0x90, "IDUP", PasCFakeInstruction, 4, "");
-		OPCODE(0x91, "IPRINT", PasCFakeInstruction, -4, "");
-		OPCODE(0x92, "UIPRINT", PasCFakeInstruction, -4, "");
-		OPCODE(0x96, "ISTORE [SB]", PasCFakeInstruction, -8, "");
-		OPCODE(0x97, "ISTORE", PasCFakeInstruction, -8, "");
-		OPCODE(0x98, "ILOAD [SB]", PasCFakeInstruction, -8, "");
-		OPCODE(0x99, "ILOAD", PasCFakeInstruction, -8, "");
-
-		//16-bit operations
-		OPCODE(0xA0, "SADD", PasCFakeInstruction, -2, "");
-		OPCODE(0xA1, "SSUB", PasCFakeInstruction, -2, "");
-		OPCODE(0xA2, "SMULT", PasCFakeInstruction, -2, "");
-		OPCODE(0xA3, "SDIV", PasCFakeInstruction, -2, "");
-		OPCODE(0xA4, "SMOD", PasCFakeInstruction, -2, "");
-		OPCODE(0xA5, "SSHL", PasCFakeInstruction, -2, "");
-		OPCODE(0xA6, "SSHR", PasCFakeInstruction, -2, "");
-		OPCODE(0xA7, "SSTOREA [SB]", PasCFakeInstruction, -2, "i");
-		OPCODE(0xA8, "SSTOREL [SB]", PasCFakeInstruction, 0, "is");
-		OPCODE(0xA9, "SLOADA [SB]", PasCFakeInstruction, 2, "i");
-		OPCODE(0xAA, "SSTOREA", PasCFakeInstruction, -2, "d");
-		OPCODE(0xAB, "SSTOREL", PasCFakeInstruction, 0, "ds");
-		OPCODE(0xAC, "SLOADA", PasCFakeInstruction, 2, "d");
-		OPCODE(0xAD, "SLOADL", PasCFakeInstruction, 0, "s");
-		OPCODE(0xAE, "SCMP", PasCFakeInstruction, -4, "");
-		OPCODE(0xAF, "USCMP", PasCFakeInstruction, -4, "");
-		OPCODE(0xB0, "SDUP", PasCFakeInstruction, 2, "");
-		OPCODE(0xB1, "SPRINT", PasCFakeInstruction, -2, "");
-		OPCODE(0xB2, "USPRINT", PasCFakeInstruction, -2, "");
-		OPCODE(0xB6, "SSTORE [SB]", PasCFakeInstruction, -6, "");
-		OPCODE(0xB7, "SSTORE", PasCFakeInstruction, -6, "");
-		OPCODE(0xB8, "SLOAD [SB]", PasCFakeInstruction, -6, "");
-		OPCODE(0xB9, "SLOAD", PasCFakeInstruction, -6, "");
-
-		//8-bit operations
-		OPCODE(0xC0, "BADD", PasCFakeInstruction, -1, "");
-		OPCODE(0xC1, "BSUB", PasCFakeInstruction, -1, "");
-		OPCODE(0xC2, "BMULT", PasCFakeInstruction, -1, "");
-		OPCODE(0xC3, "BDIV", PasCFakeInstruction, -1, "");
-		OPCODE(0xC4, "BMOD", PasCFakeInstruction, -1, "");
-		OPCODE(0xC5, "BSHL", PasCFakeInstruction, -1, "");
-		OPCODE(0xC6, "BSHR", PasCFakeInstruction, -1, "");
-		OPCODE(0xC7, "BSTOREA [SB]", PasCFakeInstruction, -1, "i");
-		OPCODE(0xC8, "BSTOREL [SB]", PasCFakeInstruction, 0, "iB");
-		OPCODE(0xC9, "BLOADA [SB]", PasCFakeInstruction, 1, "i");
-		OPCODE(0xCA, "BSTOREA", PasCFakeInstruction, -1, "d");
-		OPCODE(0xCB, "BSTOREL", PasCFakeInstruction, 0, "dB");
-		OPCODE(0xCC, "BLOADA", PasCFakeInstruction, 1, "d");
-		OPCODE(0xCD, "BLOADL", PasCFakeInstruction, 0, "B");
-		OPCODE(0xCE, "SBCMP", PasCFakeInstruction, -2, "");
-		OPCODE(0xCF, "BCMP", PasCFakeInstruction, -2, "");
-		OPCODE(0xD0, "BDUP", PasCFakeInstruction, 1, "");
-		OPCODE(0xD1, "SBPRINT", PasCFakeInstruction, -1, "");
-		OPCODE(0xD2, "BPRINT", PasCFakeInstruction, -1, "");
-		OPCODE(0xD3, "CPRINT", PasCFakeInstruction, -1, "");
-		OPCODE(0xD6, "BSTORE [SB]", PasCFakeInstruction, -5, "");
-		OPCODE(0xD7, "BSTORE", PasCFakeInstruction, -5, "");
-		OPCODE(0xD8, "BLOAD [SB]", PasCFakeInstruction, -5, "");
-		OPCODE(0xD9, "BLOAD", PasCFakeInstruction, -5, "");
-	END_OPCODES;
-}
-
-ValuePtr PasCDisassembler::readParameter(InstPtr inst, std::string type)
-{
-    ValuePtr retval = NULL;
-    if (type == "a")
-    {
-        retval = new AddressValue(stream_->ReadU32());
-        address_ += 4;
-    }
-    else
-    {
-        // Defer handling to parent implementation
-        retval = SimpleDisassembler::readParameter(inst, type);
-    }
-    return retval;
-}

+ 0 - 39
src/installer/decompiler/test/disassembler/pasc.h

@@ -1,39 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef DEC_TEST_DISASM_PASC_H
-#define DEC_TEST_DISASM_PASC_H
-
-#include "decompiler/simple_disassembler.h"
-
-class PasCDisassembler : public SimpleDisassembler {
-public:
-	PasCDisassembler(InstVec &insts);
-	virtual void doDisassemble() override;
-    virtual ValuePtr readParameter(InstPtr inst, std::string type) override;
-};
-
-class PasCFakeInstruction : public Instruction {
-public:
-    virtual void ProcessInst(Function&, ValueStack&, Engine*, CodeGenerator*) override {}
-};
-
-#endif

+ 0 - 33
src/installer/decompiler/test/disassembler/subopcode.cpp

@@ -1,33 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "subopcode.h"
-
-SubOpcodeDisassembler::SubOpcodeDisassembler(InstVec &insts) : ::SimpleDisassembler(insts) {
-}
-
-void SubOpcodeDisassembler::doDisassemble() {
-	START_OPCODES;
-		START_SUBOPCODE(0xFF)
-			OPCODE(0xFF, "FOO", SubOpcodeFakeInstruction, 0, "");
-		END_SUBOPCODE
-	END_OPCODES;
-}

+ 0 - 38
src/installer/decompiler/test/disassembler/subopcode.h

@@ -1,38 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef DEC_TEST_DISASM_SUBOPCODE_H
-#define DEC_TEST_DISASM_SUBOPCODE_H
-
-#include "decompiler/simple_disassembler.h"
-
-class SubOpcodeDisassembler : public SimpleDisassembler {
-public:
-	SubOpcodeDisassembler(InstVec &insts);
-	void doDisassemble() override;
-};
-
-class SubOpcodeFakeInstruction : public Instruction {
-public:
-    virtual void ProcessInst(Function&, ValueStack&, Engine*, CodeGenerator*) override {}
-};
-
-#endif

+ 0 - 227
src/installer/decompiler/test/disassembler_test.cpp

@@ -1,227 +0,0 @@
-/* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-
-#include "disassembler/pasc.h"
-#include "disassembler/subopcode.h"
-#include "decompiler/scummv6/disassembler.h"
-#include <gmock/gmock.h>
-
-
-TEST(Disassembler, testDisassembly) {
-    try {
-        InstVec insts;
-        PasCDisassembler p(insts);
-        p.open("decompiler/test/hanoi20.pasb");
-        p.disassemble();
-        ASSERT_EQ(insts[0]->_address, 0);
-        ASSERT_EQ(insts[0]->_opcode, 0x00);
-        ASSERT_EQ(insts[0]->_name, "PUSH");
-        ASSERT_EQ(insts[0]->_stackChange, 0);
-        ASSERT_TRUE(insts[0]->_params[0]->isInteger());
-        ASSERT_EQ(insts[0]->_params[0]->getSigned(), 0x60);
-    }
-    catch (UnknownOpcodeException &uoe) {
-        printf("Exception message: %s\n", uoe.what());
-        ASSERT_TRUE(false);
-    }
-    catch (std::exception &ex) {
-        printf("Exception message: %s\n", ex.what());
-        ASSERT_TRUE(false);
-    }
-}
-
-TEST(Disassembler, testSubOpcodeDisassembly) {
-    InstVec insts;
-    SubOpcodeDisassembler s(insts);
-    s.open("decompiler/test/subopcode_test.bin");
-    s.disassemble();
-    ASSERT_TRUE(insts[0]->_name == "FOO");
-    ASSERT_TRUE(insts[0]->_opcode == 0xFFFF);
-}
-
-TEST(Disassembler, testUnknownOpcodeException) {
-    try {
-        InstVec insts;
-        SubOpcodeDisassembler s(insts);
-        s.open("decompiler/test/unknownopcode_test.bin");
-        s.disassemble();
-        ASSERT_TRUE(false);
-    }
-    catch (UnknownOpcodeException) {
-        ASSERT_TRUE(true);
-    }
-}
-
-// This test requires script-15.dmp from Sam & Max: Hit The Road.
-// 1ab08298c9c8fb4c77953756989c7449 *script-15.dmp
-// Disabled as mentioned file is copyrighted
-TEST(Disassembler, DISABLED_testScummv6DisassemblerScript15) {
-    InstVec insts;
-    Scumm::v6::Scummv6Disassembler s(insts);
-    s.open("decompiler/test/script-15.dmp");
-    s.disassemble();
-    ASSERT_TRUE(insts.size() == 11);
-    ASSERT_TRUE(insts[0]->_address == 0);
-    ASSERT_TRUE(insts[0]->_opcode == 0x03);
-    ASSERT_TRUE(insts[0]->_name == "pushWordVar");
-    ASSERT_TRUE(insts[0]->_params[0]->getUnsigned() == 16384);
-    ASSERT_TRUE(insts[1]->_address == 3);
-    ASSERT_TRUE(insts[1]->_opcode == 0x43);
-    ASSERT_TRUE(insts[1]->_name == "writeWordVar");
-    ASSERT_TRUE(insts[1]->_params[0]->getUnsigned() == 197);
-    ASSERT_TRUE(insts[2]->_address == 6);
-    ASSERT_TRUE(insts[2]->_opcode == 0x01);
-    ASSERT_TRUE(insts[2]->_name == "pushWord");
-    ASSERT_TRUE(insts[2]->_params[0]->getSigned() == 0);
-    ASSERT_TRUE(insts[3]->_address == 9);
-    ASSERT_TRUE(insts[3]->_opcode == 0x01);
-    ASSERT_TRUE(insts[3]->_name == "pushWord");
-    ASSERT_TRUE(insts[3]->_params[0]->getSigned() == 11);
-    ASSERT_TRUE(insts[4]->_address == 12);
-    ASSERT_TRUE(insts[4]->_opcode == 0x01);
-    ASSERT_TRUE(insts[4]->_name == "pushWord");
-    ASSERT_TRUE(insts[4]->_params[0]->getSigned() == 0);
-    ASSERT_TRUE(insts[5]->_address == 15);
-    ASSERT_TRUE(insts[5]->_opcode == 0x5E);
-    ASSERT_TRUE(insts[5]->_name == "startScript");
-    ASSERT_TRUE(insts[6]->_address == 16);
-    ASSERT_TRUE(insts[6]->_opcode == 0x01);
-    ASSERT_TRUE(insts[6]->_name == "pushWord");
-    ASSERT_TRUE(insts[6]->_params[0]->getSigned() == 0);
-    ASSERT_TRUE(insts[7]->_address == 19);
-    ASSERT_TRUE(insts[7]->_opcode == 0x01);
-    ASSERT_TRUE(insts[7]->_name == "pushWord");
-    ASSERT_TRUE(insts[7]->_params[0]->getSigned() == 14);
-    ASSERT_TRUE(insts[8]->_address == 22);
-    ASSERT_TRUE(insts[8]->_opcode == 0x01);
-    ASSERT_TRUE(insts[8]->_name == "pushWord");
-    ASSERT_TRUE(insts[8]->_params[0]->getSigned() == 0);
-    ASSERT_TRUE(insts[9]->_address == 25);
-    ASSERT_TRUE(insts[9]->_opcode == 0x5E);
-    ASSERT_TRUE(insts[9]->_name == "startScript");
-    ASSERT_TRUE(insts[10]->_address == 26);
-    ASSERT_TRUE(insts[10]->_opcode == 0x66);
-    ASSERT_TRUE(insts[10]->_name == "stopObjectCodeB");
-}
-
-// This test requires script-31.dmp from Sam & Max: Hit The Road.
-// f75f7ce110f378735d449f8eeb4a68e5 *script-31.dmp
-// Disabled as mentioned file is copyrighted
-TEST(Disassembler, DISABLED_testScummv6DisassemblerScript31) {
-    InstVec insts;
-    Scumm::v6::Scummv6Disassembler s(insts);
-    s.open("decompiler/test/script-31.dmp");
-    s.disassemble();
-    ASSERT_TRUE(insts.size() == 5);
-    ASSERT_TRUE(insts[0]->_address == 0);
-    ASSERT_TRUE(insts[0]->_opcode == 0x01);
-    ASSERT_TRUE(insts[0]->_name == "pushWord");
-    ASSERT_TRUE(insts[0]->_params[0]->getSigned() == 0);
-    ASSERT_TRUE(insts[1]->_address == 3);
-    ASSERT_TRUE(insts[1]->_opcode == 0x43);
-    ASSERT_TRUE(insts[1]->_name == "writeWordVar");
-    ASSERT_TRUE(insts[1]->_params[0]->getUnsigned() == 180);
-    ASSERT_TRUE(insts[2]->_address == 6);
-    ASSERT_TRUE(insts[2]->_opcode == 0x01);
-    ASSERT_TRUE(insts[2]->_name == "pushWord");
-    ASSERT_TRUE(insts[2]->_params[0]->getSigned() == 0);
-    ASSERT_TRUE(insts[3]->_address == 9);
-    ASSERT_TRUE(insts[3]->_opcode == 0x43);
-    ASSERT_TRUE(insts[3]->_name == "writeWordVar");
-    ASSERT_TRUE(insts[3]->_params[0]->getUnsigned() == 181);
-    ASSERT_TRUE(insts[4]->_address == 12);
-    ASSERT_TRUE(insts[4]->_opcode == 0x66);
-    ASSERT_TRUE(insts[4]->_name == "stopObjectCodeB");
-}
-
-// This test requires script-33.dmp from Sam & Max: Hit The Road.
-// 9f09418bf34abbdec0ec54f388d8dca4 *script-33.dmp
-// Disabled as mentioned file is copyrighted
-TEST(Disassembler, DISABLED_testScummv6DisassemblerScript33) {
-    InstVec insts;
-    Scumm::v6::Scummv6Disassembler s(insts);
-    s.open("decompiler/test/script-33.dmp");
-    s.disassemble();
-    ASSERT_TRUE(insts.size() == 10);
-    ASSERT_TRUE(insts[0]->_address == 0);
-    ASSERT_TRUE(insts[0]->_opcode == 0x01);
-    ASSERT_TRUE(insts[0]->_name == "pushWord");
-    ASSERT_TRUE(insts[0]->_params[0]->getSigned() == 0);
-    ASSERT_TRUE(insts[1]->_address == 3);
-    ASSERT_TRUE(insts[1]->_opcode == 0x43);
-    ASSERT_TRUE(insts[1]->_name == "writeWordVar");
-    ASSERT_TRUE(insts[1]->_params[0]->getUnsigned() == 71);
-    ASSERT_TRUE(insts[2]->_address == 6);
-    ASSERT_TRUE(insts[2]->_opcode == 0x03);
-    ASSERT_TRUE(insts[2]->_name == "pushWordVar");
-    ASSERT_TRUE(insts[2]->_params[0]->getUnsigned() == 177);
-    ASSERT_TRUE(insts[3]->_address == 9);
-    ASSERT_TRUE(insts[3]->_opcode == 0x43);
-    ASSERT_TRUE(insts[3]->_name == "writeWordVar");
-    ASSERT_TRUE(insts[3]->_params[0]->getUnsigned() == 173);
-    ASSERT_TRUE(insts[4]->_address == 12);
-    ASSERT_TRUE(insts[4]->_opcode == 0x01);
-    ASSERT_TRUE(insts[4]->_name == "pushWord");
-    ASSERT_TRUE(insts[4]->_params[0]->getSigned() == 874);
-    ASSERT_TRUE(insts[5]->_address == 15);
-    ASSERT_TRUE(insts[5]->_opcode == 0x43);
-    ASSERT_TRUE(insts[5]->_name == "writeWordVar");
-    ASSERT_TRUE(insts[5]->_params[0]->getUnsigned() == 177);
-    ASSERT_TRUE(insts[6]->_address == 18);
-    ASSERT_TRUE(insts[6]->_opcode == 0x03);
-    ASSERT_TRUE(insts[6]->_name == "pushWordVar");
-    ASSERT_TRUE(insts[6]->_params[0]->getUnsigned() == 177);
-    ASSERT_TRUE(insts[7]->_address == 21);
-    ASSERT_TRUE(insts[7]->_opcode == 0x01);
-    ASSERT_TRUE(insts[7]->_name == "pushWord");
-    ASSERT_TRUE(insts[7]->_params[0]->getSigned() == 93);
-    ASSERT_TRUE(insts[8]->_address == 24);
-    ASSERT_TRUE(insts[8]->_opcode == 0x6B99);
-    ASSERT_TRUE(insts[8]->_name == "cursorCommand.setCursorImg");
-    ASSERT_TRUE(insts[9]->_address == 26);
-    ASSERT_TRUE(insts[9]->_opcode == 0x66);
-    ASSERT_TRUE(insts[9]->_name == "stopObjectCodeB");
-}
-
-// This test requires room-9-202.dmp from Sam & Max: Hit The Road.
-// f010dc659264674a2b6da298acd0b88b *room-9-202.dmp
-TEST(Disassembler, DISABLED_testScummv6StackChangeFixRoom9202) {
-    InstVec insts;
-    Scumm::v6::Scummv6Disassembler s(insts);
-    s.open("decompiler/test/room-9-202.dmp");
-    s.disassemble();
-    InstIterator it = insts.end();
-    it -= 8;
-    ASSERT_TRUE((*it)->_stackChange == -3);
-}
-
-// This test requires script-30.dmp from Sam & Max: Hit The Road.
-// 6e48faca13e1f6df9341567608962744 *script-30.dmp
-TEST(Disassembler, DISABLED_testScummv6StackChangeFixScript30) {
-    InstVec insts;
-    Scumm::v6::Scummv6Disassembler s(insts);
-    s.open("decompiler/test/script-30.dmp");
-    s.disassemble();
-    InstIterator it = insts.end();
-    it -= 3;
-    ASSERT_TRUE((*it)->_stackChange == -6);
-}

BIN
src/installer/decompiler/test/do-while-in-while.dmp


+ 0 - 20
src/installer/decompiler/test/do-while-in-while.txt

@@ -1,20 +0,0 @@
-while (var123 != 18) {
-	do {
-		var123++
-	} while (var321 != 42)
-}
-
-while:
-pushWord 18
-pushWordVar 123
-eq
-jumpTrue postWhile
-do:
-wordVarInc 123
-pushWord 42
-pushWordVar 321
-eq
-jumpTrue do
-jump while
-postWhile:
-stopObjectCodeA

BIN
src/installer/decompiler/test/do-while.dmp


+ 0 - 7
src/installer/decompiler/test/do-while.txt

@@ -1,7 +0,0 @@
-do:
-wordVarInc 123
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue do
-stopObjectCodeA

BIN
src/installer/decompiler/test/ff7.dat


BIN
src/installer/decompiler/test/ff7_all_opcodes.dat


BIN
src/installer/decompiler/test/ff7_all_opcodes_OLD.dat


BIN
src/installer/decompiler/test/ff7_all_opcodes_by_category.dat


BIN
src/installer/decompiler/test/ff7_control_flow_test.dat


+ 0 - 422
src/installer/decompiler/test/ff7_field_all_opcodes_disassembler_test.cpp

@@ -1,422 +0,0 @@
-#include <gmock/gmock.h>
-
-#include "../ControlFlow.h"
-#include "decompiler/ff7_field/ff7_field_disassembler.h"
-#include "decompiler/ff7_field/ff7_field_engine.h"
-#include "decompiler/ff7_field/ff7_field_codegen.h"
-#include "util.h"
-#include "ff7_field_dummy_formatter.h"
-
-#define MAKE_SUBOPCODE(high, low) ((uint16)(((uint8)(low)) | ((uint16)((uint8)(high))) << 8))
-
-TEST(FF7Field, AllOpcodesDisassembler)
-{
-    InstVec insts;
-    DummyFormatter formatter;
-    FieldEngine engine(formatter);
-
-    auto d = engine.GetDisassembler(insts);
-    d->open("decompiler/test/ff7_all_opcodes.dat");
-    d->disassemble();
-    d->dumpDisassembly(std::cout);
-    std::cout << std::endl;
-
-
-    ASSERT_EQ(insts[0]->_opcode, eOpcodes::RET);
-    ASSERT_EQ(insts[0]->_params.size(), 0);
-
-	ASSERT_EQ(insts[1]->_opcode, eOpcodes::REQ);
-	ASSERT_EQ(insts[1]->_params.size(), 3);
-	ASSERT_EQ(insts[1]->_params[0]->getSigned(), 0);
-	ASSERT_EQ(insts[1]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[1]->_params[2]->getSigned(), 1);
-
-	ASSERT_EQ(insts[2]->_opcode, eOpcodes::REQSW);
-	ASSERT_EQ(insts[2]->_params.size(), 3);
-	ASSERT_EQ(insts[2]->_params[0]->getSigned(), 0);
-	ASSERT_EQ(insts[2]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[2]->_params[2]->getSigned(), 1);
-
-	ASSERT_EQ(insts[3]->_opcode, eOpcodes::REQEW);
-	ASSERT_EQ(insts[3]->_params.size(), 3);
-	ASSERT_EQ(insts[3]->_params[0]->getSigned(), 0);
-	ASSERT_EQ(insts[3]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[3]->_params[2]->getSigned(), 1);
-
-	ASSERT_EQ(insts[4]->_opcode, eOpcodes::PREQ);
-	ASSERT_EQ(insts[4]->_params.size(), 3);
-	ASSERT_EQ(insts[4]->_params[0]->getSigned(), 0);
-	ASSERT_EQ(insts[4]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[4]->_params[2]->getSigned(), 1);
-
-	ASSERT_EQ(insts[5]->_opcode, eOpcodes::PREQSW);
-	ASSERT_EQ(insts[5]->_params.size(), 3);
-	ASSERT_EQ(insts[5]->_params[0]->getSigned(), 0);
-	ASSERT_EQ(insts[5]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[5]->_params[2]->getSigned(), 1);
-
-	ASSERT_EQ(insts[6]->_opcode, eOpcodes::PREQEW);
-	ASSERT_EQ(insts[6]->_params.size(), 3);
-	ASSERT_EQ(insts[6]->_params[0]->getSigned(), 0);
-	ASSERT_EQ(insts[6]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[6]->_params[2]->getSigned(), 1);
-
-	ASSERT_EQ(insts[7]->_opcode, eOpcodes::JOIN);
-	ASSERT_EQ(insts[7]->_params.size(), 1);
-	ASSERT_EQ(insts[7]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[8]->_opcode, eOpcodes::SPLIT);
-	ASSERT_EQ(insts[8]->_params.size(), 13);
-	ASSERT_EQ(insts[8]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[8]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[8]->_params[2]->getSigned(), 3);
-	ASSERT_EQ(insts[8]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[8]->_params[4]->getSigned(), 5);
-	ASSERT_EQ(insts[8]->_params[5]->getSigned(), 6);
-	ASSERT_EQ(insts[8]->_params[6]->getSigned(), 7);
-	ASSERT_EQ(insts[8]->_params[7]->getSigned(), 8);
-	ASSERT_EQ(insts[8]->_params[8]->getSigned(), 9);
-	ASSERT_EQ(insts[8]->_params[9]->getSigned(), 10);
-	ASSERT_EQ(insts[8]->_params[10]->getSigned(), 11);
-	ASSERT_EQ(insts[8]->_params[11]->getSigned(), 12);
-	ASSERT_EQ(insts[8]->_params[12]->getSigned(), 13);
-
-	ASSERT_EQ(insts[9]->_opcode, eOpcodes::SPTYE);
-	ASSERT_EQ(insts[9]->_params.size(), 7);
-	ASSERT_EQ(insts[9]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[9]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[9]->_params[2]->getSigned(), 3);
-	ASSERT_EQ(insts[9]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[9]->_params[4]->getSigned(), 5);
-	ASSERT_EQ(insts[9]->_params[5]->getSigned(), 6);
-	ASSERT_EQ(insts[9]->_params[6]->getSigned(), 7);
-
-	ASSERT_EQ(insts[10]->_opcode, eOpcodes::GTPYE);
-	ASSERT_EQ(insts[10]->_params.size(), 7);
-	ASSERT_EQ(insts[10]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[10]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[10]->_params[2]->getSigned(), 3);
-	ASSERT_EQ(insts[10]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[10]->_params[4]->getSigned(), 5);
-	ASSERT_EQ(insts[10]->_params[5]->getSigned(), 6);
-	ASSERT_EQ(insts[10]->_params[6]->getSigned(), 7);
-
-	ASSERT_EQ(insts[11]->_opcode, eOpcodes::DSKCG);
-	ASSERT_EQ(insts[11]->_params.size(), 1);
-	ASSERT_EQ(insts[11]->_params[0]->getSigned(), 1);
-
-	
-	ASSERT_EQ(insts[12]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::ARROW));
-	ASSERT_EQ(insts[12]->_params.size(), 1);
-	ASSERT_EQ(insts[12]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[13]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::PNAME));
-	ASSERT_EQ(insts[13]->_params.size(), 1);
-	ASSERT_EQ(insts[13]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[14]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::GMSPD));
-	ASSERT_EQ(insts[14]->_params.size(), 1);
-	ASSERT_EQ(insts[14]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[15]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::SMSPD));
-	ASSERT_EQ(insts[15]->_params.size(), 2);
-	ASSERT_EQ(insts[15]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[15]->_params[1]->getSigned(), 2);
-
-	ASSERT_EQ(insts[16]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::FLMAT));
-	ASSERT_EQ(insts[16]->_params.size(), 0);
-
-	ASSERT_EQ(insts[17]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::FLITM));
-	ASSERT_EQ(insts[17]->_params.size(), 0);
-
-	ASSERT_EQ(insts[18]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::BTLCK));
-	ASSERT_EQ(insts[18]->_params.size(), 1);
-	ASSERT_EQ(insts[18]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[19]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::MVLCK));
-	ASSERT_EQ(insts[19]->_params.size(), 1);
-	ASSERT_EQ(insts[19]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[20]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::SPCNM));
-	ASSERT_EQ(insts[20]->_params.size(), 2);
-	ASSERT_EQ(insts[20]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[20]->_params[1]->getSigned(), 2);
-
-	ASSERT_EQ(insts[21]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::RSGLB));
-	ASSERT_EQ(insts[21]->_params.size(), 0);
-
-	ASSERT_EQ(insts[22]->_opcode, MAKE_SUBOPCODE(eOpcodes::SPECIAL, eSpecialOpcodes::CLITM));
-	ASSERT_EQ(insts[22]->_params.size(), 0);
-
-	ASSERT_EQ(insts[23]->_opcode, eOpcodes::JMPF);
-	ASSERT_EQ(insts[23]->_params.size(), 1);
-
-	ASSERT_EQ(insts[24]->_opcode, eOpcodes::JMPFL);
-	ASSERT_EQ(insts[24]->_params.size(), 1);
-
-	ASSERT_EQ(insts[25]->_opcode, eOpcodes::JMPB);
-	ASSERT_EQ(insts[25]->_params.size(), 1);
-
-	ASSERT_EQ(insts[26]->_opcode, eOpcodes::JMPBL);
-	ASSERT_EQ(insts[26]->_params.size(), 1);
-
-	ASSERT_EQ(insts[27]->_opcode, eOpcodes::IFUB);
-	ASSERT_EQ(insts[27]->_params.size(), 6);
-	ASSERT_EQ(insts[27]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[27]->_params[1]->getSigned(), 3);
-	ASSERT_EQ(insts[27]->_params[2]->getSigned(), 2);
-	ASSERT_EQ(insts[27]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[27]->_params[4]->getSigned(), 5);
-	ASSERT_EQ(insts[27]->_params[5]->getSigned(), 1);
-
-	ASSERT_EQ(insts[28]->_opcode, eOpcodes::IFUBL);
-	ASSERT_EQ(insts[28]->_params.size(), 6);
-	ASSERT_EQ(insts[28]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[28]->_params[1]->getSigned(), 3);
-	ASSERT_EQ(insts[28]->_params[2]->getSigned(), 2);
-	ASSERT_EQ(insts[28]->_params[3]->getSigned(), 4);
-	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[29]->_opcode, eOpcodes::IFSW);
-	ASSERT_EQ(insts[29]->_params.size(), 6);
-	ASSERT_EQ(insts[29]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[29]->_params[1]->getSigned(), 3);
-	ASSERT_EQ(insts[29]->_params[2]->getSigned(), 2);
-	ASSERT_EQ(insts[29]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[29]->_params[4]->getSigned(), 5);
-	ASSERT_EQ(insts[29]->_params[5]->getSigned(), 1);
-
-	ASSERT_EQ(insts[30]->_opcode, eOpcodes::IFSWL);
-	ASSERT_EQ(insts[30]->_params.size(), 6);
-	ASSERT_EQ(insts[30]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[30]->_params[1]->getSigned(), 3);
-	ASSERT_EQ(insts[30]->_params[2]->getSigned(), 2);
-	ASSERT_EQ(insts[30]->_params[3]->getSigned(), 4);
-	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[31]->_opcode, eOpcodes::IFUW);
-	ASSERT_EQ(insts[31]->_params.size(), 6);
-	ASSERT_EQ(insts[31]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[31]->_params[1]->getSigned(), 3);
-	ASSERT_EQ(insts[31]->_params[2]->getSigned(), 2);
-	ASSERT_EQ(insts[31]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[31]->_params[4]->getSigned(), 5);
-	ASSERT_EQ(insts[31]->_params[5]->getSigned(), 1);
-
-	ASSERT_EQ(insts[32]->_opcode, eOpcodes::IFUWL);
-	ASSERT_EQ(insts[32]->_params.size(), 6);
-	ASSERT_EQ(insts[32]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[32]->_params[1]->getSigned(), 3);
-	ASSERT_EQ(insts[32]->_params[2]->getSigned(), 2);
-	ASSERT_EQ(insts[32]->_params[3]->getSigned(), 4);
-	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[33]->_opcode, eOpcodes::MINIGAME);
-	ASSERT_EQ(insts[33]->_params.size(), 6);
-	ASSERT_EQ(insts[33]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[33]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[33]->_params[2]->getSigned(), 3);
-	ASSERT_EQ(insts[33]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[33]->_params[4]->getSigned(), 5);
-	ASSERT_EQ(insts[33]->_params[5]->getSigned(), 6);
-
-	ASSERT_EQ(insts[34]->_opcode, eOpcodes::TUTOR);
-	ASSERT_EQ(insts[34]->_params.size(), 1);
-	ASSERT_EQ(insts[34]->_params[0]->getSigned(), 1);
-
-	// BATTLE MODE STATES START
-
-	ASSERT_EQ(insts[35]->_opcode, eOpcodes::BTMD2);
-	ASSERT_EQ(insts[35]->_params.size(), 4);
-	ASSERT_EQ(insts[35]->_params[0]->getSigned(), 0x80);
-
-	ASSERT_EQ(insts[36]->_opcode, eOpcodes::BTMD2);
-	ASSERT_EQ(insts[36]->_params.size(), 4);
-	ASSERT_EQ(insts[36]->_params[0]->getSigned(), 0x40);
-
-	ASSERT_EQ(insts[37]->_opcode, eOpcodes::BTMD2);
-	ASSERT_EQ(insts[37]->_params.size(), 4);
-	ASSERT_EQ(insts[37]->_params[0]->getSigned(), 0x20);
-
-	ASSERT_EQ(insts[38]->_opcode, eOpcodes::BTMD2);
-	ASSERT_EQ(insts[38]->_params.size(), 4);
-	ASSERT_EQ(insts[38]->_params[0]->getSigned(), 0x10);
-
-	ASSERT_EQ(insts[39]->_opcode, eOpcodes::BTMD2);
-	ASSERT_EQ(insts[39]->_params.size(), 4);
-	ASSERT_EQ(insts[39]->_params[0]->getSigned(), 0x08);
-
-	ASSERT_EQ(insts[40]->_opcode, eOpcodes::BTMD2);
-	ASSERT_EQ(insts[40]->_params.size(), 4);
-	ASSERT_EQ(insts[40]->_params[0]->getSigned(), 0x04);
-
-	ASSERT_EQ(insts[41]->_opcode, eOpcodes::BTMD2);
-	ASSERT_EQ(insts[41]->_params.size(), 4);
-	ASSERT_EQ(insts[41]->_params[0]->getSigned(), 0x02);
-
-	//ASSERT_EQ(insts[42]->_opcode, eOpcodes::BTMD2);
-	//ASSERT_EQ(insts[42]->_params.size(), 4);
-	//ASSERT_EQ(insts[42]->_params[1]->getSigned(), 0x80);
-
-	ASSERT_EQ(insts[67]->_opcode, eOpcodes::BTRLD);
-	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[68]->_opcode, eOpcodes::WAIT);
-	ASSERT_EQ(insts[68]->_params.size(), 1);
-	ASSERT_EQ(insts[68]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[69]->_opcode, eOpcodes::NFADE);
-	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[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[2]->getSigned(), 3); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(5)
-	//ASSERT_EQ(insts[69]->_params[3]->getSigned(), 4); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(6)
-	//ASSERT_EQ(insts[69]->_params[4]->getSigned(), 5); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(0)
-	//ASSERT_EQ(insts[69]->_params[5]->getSigned(), 6); // TODO:These values are what they are set to in Makou Reactor however SUDM reads them as something else Reads:(0)
-	ASSERT_EQ(insts[69]->_params[6]->getSigned(), 7);
-	ASSERT_EQ(insts[69]->_params[7]->getSigned(), 8);
-
-	ASSERT_EQ(insts[70]->_opcode, eOpcodes::BLINK);
-	ASSERT_EQ(insts[70]->_params.size(), 1);
-	ASSERT_EQ(insts[70]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[71]->_opcode, eOpcodes::BGMOVIE);
-	ASSERT_EQ(insts[71]->_params.size(), 1);
-	ASSERT_EQ(insts[71]->_params[0]->getSigned(), 1);
-
-	//KAWAI is normally here
-
-	ASSERT_EQ(insts[72]->_opcode, eOpcodes::KAWIW);
-	ASSERT_EQ(insts[72]->_params.size(), 0);
-
-	ASSERT_EQ(insts[73]->_opcode, eOpcodes::PMOVA);
-	ASSERT_EQ(insts[73]->_params.size(), 1);
-	ASSERT_EQ(insts[73]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[74]->_opcode, eOpcodes::SLIP);
-	ASSERT_EQ(insts[74]->_params.size(), 1);
-	ASSERT_EQ(insts[74]->_params[0]->getSigned(), 1);
-
-	ASSERT_EQ(insts[75]->_opcode, eOpcodes::BGPDH);
-	ASSERT_EQ(insts[75]->_params.size(), 4);
-	ASSERT_EQ(insts[75]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[75]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[75]->_params[2]->getSigned(), 3);
-	ASSERT_EQ(insts[75]->_params[3]->getSigned(), 4);
-
-	//ASSERT_EQ(insts[76]->_opcode, eOpcodes::BGSCR);
-	//ASSERT_EQ(insts[76]->_params.size(), 5);
-	//ASSERT_EQ(insts[76]->_params[0]->getSigned(), 1);
-	//ASSERT_EQ(insts[76]->_params[1]->getSigned(), 2);
-	//ASSERT_EQ(insts[76]->_params[2]->getSigned(), 3);
-	//ASSERT_EQ(insts[76]->_params[3]->getSigned(), 4);
-	//ASSERT_EQ(insts[76]->_params[4]->getSigned(), 5);
-
-	ASSERT_EQ(insts[78]->_opcode, eOpcodes::WSIZW);
-	ASSERT_EQ(insts[78]->_params.size(), 5);
-	ASSERT_EQ(insts[78]->_params[0]->getSigned(), 1);
-	ASSERT_EQ(insts[78]->_params[1]->getSigned(), 2);
-	ASSERT_EQ(insts[78]->_params[2]->getSigned(), 3);
-	ASSERT_EQ(insts[78]->_params[3]->getSigned(), 4);
-	ASSERT_EQ(insts[78]->_params[4]->getSigned(), 5);
-
-	//ASSERT_EQ(insts[79]->_opcode, eOpcodes::IFKEY); // TODO
-	//ASSERT_EQ(insts[79]->_params.size(), 2);
-	//ASSERT_EQ(0x0001, insts[79]->_params[0]->getSigned());
-
-	//ASSERT_EQ(insts[80]->_opcode, eOpcodes::IFKEY); // TODO
-	//ASSERT_EQ(insts[80]->_params.size(), 2);
-	//ASSERT_EQ(0x8000, insts[78]->_params[0]->getSigned());
-
-	//ASSERT_EQ(insts[81]->_opcode, eOpcodes::IFKEYON); // TODO
-	//ASSERT_EQ(insts[81]->_params.size(), 2);
-	//ASSERT_EQ(0x0001, insts[81]->_params[0]->getSigned());
-
-	//ASSERT_EQ(insts[82]->_opcode, eOpcodes::IFKEYON); // TODO
-	//ASSERT_EQ(insts[82]->_params.size(), 2);
-	//ASSERT_EQ(0x8000, insts[82]->_params[0]->getSigned());
-
-	//ASSERT_EQ(insts[83]->_opcode, eOpcodes::IFKEYOFF); // TODO
-	//ASSERT_EQ(insts[83]->_params.size(), 2);
-	//ASSERT_EQ(0x0001, insts[83]->_params[0]->getSigned());
-
-	//ASSERT_EQ(insts[84]->_opcode, eOpcodes::IFKEYOFF); // TODO
-	//ASSERT_EQ(insts[84]->_params.size(), 2);
-	//ASSERT_EQ(0x8000, insts[84]->_params[0]->getSigned());
-
-	ASSERT_EQ(insts[85]->_opcode, eOpcodes::UC);
-	ASSERT_EQ(1, insts[85]->_params.size());
-	ASSERT_EQ(1, insts[85]->_params[0]->getSigned());
-
-	ASSERT_EQ(insts[86]->_opcode, eOpcodes::PDIRA);
-	ASSERT_EQ(1, insts[86]->_params.size());
-	ASSERT_EQ(1, insts[86]->_params[0]->getSigned());
-
-	ASSERT_EQ(insts[87]->_opcode, eOpcodes::PTURA);
-	ASSERT_EQ(3, insts[87]->_params.size());
-	ASSERT_EQ(1, insts[87]->_params[0]->getSigned());
-	ASSERT_EQ(2, insts[87]->_params[1]->getSigned());
-	ASSERT_EQ(3, insts[87]->_params[2]->getSigned());
-
-	ASSERT_EQ(insts[88]->_opcode, eOpcodes::WSPCL);
-	ASSERT_EQ(4, insts[88]->_params.size());
-	ASSERT_EQ(1, insts[88]->_params[0]->getSigned());
-	ASSERT_EQ(2, insts[88]->_params[1]->getSigned());
-	ASSERT_EQ(3, insts[88]->_params[2]->getSigned());
-	ASSERT_EQ(4, insts[88]->_params[3]->getSigned());
-
-	ASSERT_EQ(insts[89]->_opcode, eOpcodes::STTIM);
-	ASSERT_EQ(7, insts[89]->_params.size());
-	ASSERT_EQ(1, insts[89]->_params[0]->getSigned());
-	ASSERT_EQ(2, insts[89]->_params[1]->getSigned());
-	ASSERT_EQ(3, insts[89]->_params[2]->getSigned());
-	ASSERT_EQ(4, insts[89]->_params[3]->getSigned());
-	ASSERT_EQ(5, insts[89]->_params[4]->getSigned());
-	ASSERT_EQ(6, insts[89]->_params[5]->getSigned());
-	ASSERT_EQ(7, insts[89]->_params[6]->getSigned());
-
-    ASSERT_EQ(insts[90]->_opcode, eOpcodes::GOLDU);
-    ASSERT_EQ(3, insts[90]->_params.size());
-    ASSERT_EQ(0, insts[90]->_params[0]->getSigned());
-    ASSERT_EQ(0, insts[90]->_params[1]->getSigned());
-    ASSERT_EQ(1, insts[90]->_params[2]->getSigned());
-
-    ASSERT_EQ(insts[91]->_opcode, eOpcodes::GOLDU);
-    ASSERT_EQ(3, insts[91]->_params.size());
-    ASSERT_EQ(1, insts[91]->_params[0]->getSigned());
-    ASSERT_EQ(2, insts[91]->_params[1]->getSigned());
-    ASSERT_EQ(0, insts[91]->_params[2]->getSigned());
-
-    ASSERT_EQ(insts[92]->_opcode, eOpcodes::GOLDD);
-    ASSERT_EQ(3, insts[92]->_params.size());
-    ASSERT_EQ(0, insts[92]->_params[0]->getSigned());
-    ASSERT_EQ(0, insts[92]->_params[1]->getSigned());
-    ASSERT_EQ(1, insts[92]->_params[2]->getSigned());
-
-    ASSERT_EQ(insts[93]->_opcode, eOpcodes::GOLDD);
-    ASSERT_EQ(3, insts[93]->_params.size());
-    ASSERT_EQ(1, insts[93]->_params[0]->getSigned());
-    ASSERT_EQ(2, insts[93]->_params[1]->getSigned());
-    ASSERT_EQ(0, insts[93]->_params[2]->getSigned());
-
-    ASSERT_EQ(insts[94]->_opcode, eOpcodes::CHGLD);
-    ASSERT_EQ(4, insts[94]->_params.size());
-    ASSERT_EQ(1, insts[94]->_params[0]->getSigned());
-    ASSERT_EQ(2, insts[94]->_params[1]->getSigned());
-    ASSERT_EQ(3, insts[94]->_params[2]->getSigned());
-    ASSERT_EQ(4, insts[94]->_params[3]->getSigned());
-
-
-
-    // If it had a value then check the values using:
-    //ASSERT_EQ(insts[0]->_params[0]->getSigned(), 1);
-
-	// To check amount of parameters use:
-	//ASSERT_EQ(insts[1]->_params.size(), 1);
-
-}

+ 0 - 95
src/installer/decompiler/test/ff7_field_control_flow_test.cpp

@@ -1,95 +0,0 @@
-#include <gmock/gmock.h>
-
-#include "../ControlFlow.h"
-#include "decompiler/ff7_field/ff7_field_disassembler.h"
-#include "decompiler/ff7_field/ff7_field_engine.h"
-#include "decompiler/ff7_field/ff7_field_codegen.h"
-#include "util.h"
-#include "ff7_field_dummy_formatter.h"
-
-// Verify next 3 instructions are NOP's and return address of final NOP
-static uint32 Is3Nops(InstVec& insts, uint32& pos)
-{
-    for (int i = 0; i < 3; i++)
-    {
-        pos++;
-        EXPECT_EQ(insts[pos]->opcode_, eOpcodes::NOP);
-        EXPECT_EQ(insts[pos]->params_.size(), 0);
-    }
-    return insts[pos]->_address;
-}
-
-// 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
-// and should be the target address of the jump.
-static void CheckForwardJump(eOpcodes opCode, size_t paramsSize, InstVec& insts, uint32& pos)
-{
-    pos++;
-    const InstPtr& jumpInst = insts[pos];
-    ASSERT_EQ(jumpInst->opcode_, opCode);
-    ASSERT_EQ(jumpInst->params_.size(), paramsSize);
-
-    const uint32 lastNopAddr = Is3Nops(insts, pos);
-    ASSERT_EQ(jumpInst->GetDestAddress(), lastNopAddr);
-}
-
-// Verify next instructions is a NOP and return address of final NOP
-static uint32 IsNop(InstVec& insts, uint32& pos)
-{
-    pos++;
-    EXPECT_EQ(insts[pos]->opcode_, eOpcodes::NOP);
-    EXPECT_EQ(insts[pos]->params_.size(), 0);
-    return insts[pos]->_address;
-}
-
-
-// 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
-static void CheckBackwardJump(eOpcodes opCode, size_t paramsSize, InstVec& insts, uint32& pos)
-{
-    IsNop(insts, pos);
-
-    // Second is the target, so check is NOP & grab addr
-    const uint32 firstNopAddr = IsNop(insts, pos);
-
-    IsNop(insts, pos);
-
-    // Grab the final instruction, the jump itself
-    pos++;
-    const InstPtr& jumpInst = insts[pos];
-
-    ASSERT_EQ(jumpInst->opcode_, opCode);
-    ASSERT_EQ(jumpInst->params_.size(), paramsSize);
-    ASSERT_EQ(jumpInst->GetDestAddress(), firstNopAddr);
-}
-
-
-
-TEST(FF7Field, ControlFlow)
-{
-    InstVec insts;
-    DummyFormatter formatter;
-    FieldEngine engine(formatter, "test");
-
-    auto d = engine.GetDisassembler(insts);
-    d->open("decompiler/test/ff7_control_flow_test.dat");
-    d->disassemble();
-    d->dumpDisassembly(std::cout);
-    std::cout << std::endl;
-
-    uint32 pos = 0;
-    ASSERT_EQ(insts[pos]->opcode_, eOpcodes::RET);
-    ASSERT_EQ(insts[pos]->params_.size(), 0);
-
-    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);
-}

+ 0 - 1978
src/installer/decompiler/test/ff7_field_disasm_all_opcodes_by_category_test.cpp

@@ -1,1978 +0,0 @@
-#include <gmock/gmock.h>
-
-#include "../../common/Lzs.h"
-#include "../ControlFlow.h"
-#include "decompiler/ff7_field/ff7_field_disassembler.h"
-#include "decompiler/ff7_field/ff7_field_engine.h"
-#include "decompiler/ff7_field/ff7_field_codegen.h"
-#include "util.h"
-#include "ff7_field_dummy_formatter.h"
-
-#define FLOW_BASE 0
-#define FLOW_LABELS 13
-#define FLOW_OPCODES (1/*init RET*/ + 37/*main, incl labels*/ - FLOW_LABELS)
-#define MODULE_BASE (FLOW_BASE + FLOW_OPCODES + 1/*init RET*/)
-#define MODULE_OPCODES 25
-#define MATH_BASE (MODULE_BASE + MODULE_OPCODES + 1/*init RET*/)
-#define MATH_OPCODES 40
-#define WINDOW_BASE (MATH_BASE + MATH_OPCODES + 1/*init RET*/)
-#define WINDOW_OPCODES 21
-#define PARTY_BASE (WINDOW_BASE + WINDOW_OPCODES + 1/*init RET*/)
-#define PARTY_OPCODES 26
-#define MODEL_BASE (PARTY_BASE + PARTY_OPCODES + 1/*init RET*/)
-#define MODEL_OPCODES 70
-#define WALKMESH_BASE (MODEL_BASE + MODEL_OPCODES + 1/*init RET*/)
-#define WALKMESH_OPCODES 6
-#define BACKGND_BASE (WALKMESH_BASE + WALKMESH_OPCODES + 1/*init RET*/)
-#define BACKGND_OPCODES 19
-#define CAMERA_BASE (BACKGND_BASE + BACKGND_OPCODES + 1/*init RET*/)
-#define CAMERA_OPCODES 15
-#define AV_BASE (CAMERA_BASE + CAMERA_OPCODES + 1/*init RET*/)
-#define AV_OPCODES 16
-#define UNCAT_BASE (AV_BASE + AV_OPCODES + 1/*init RET*/)
-#define UNCAT_OPCODES 4
-
-#define MAKE_SUBOPCODE(high, low) ((uint16)(((uint8)(low)) | ((uint16)((uint8)(high))) << 8))
-
-#define ASSERT_OP_LEN(opcode, length) \
-    ASSERT_EQ(insts[index]->_opcode, (opcode)); \
-    ASSERT_EQ(insts[index]->_params.size(), (length)); \
-    paramIndex = 0
-
-#define ASSERT_OP_SUBOP_LEN(opcode, subopcode, length) \
-    ASSERT_EQ(insts[index]->_opcode, MAKE_SUBOPCODE((opcode), (subopcode))); \
-    ASSERT_EQ(insts[index]->_params.size(), (length)); \
-    paramIndex = 0
-
-#define ASSERT_PARAM_UNSIGNED(value) ASSERT_EQ(insts[index]->_params[paramIndex++]->getUnsigned(), (value))
-#define ASSERT_PARAM_SIGNED(value) ASSERT_EQ(insts[index]->_params[paramIndex++]->getSigned(), (value))
-
-
-void checkFlow(const InstVec& insts);
-void checkModule(const InstVec& insts);
-void checkMath(const InstVec& insts);
-void checkWindow(const InstVec& insts);
-void checkParty(const InstVec& insts);
-void checkModel(const InstVec& insts);
-void checkWalkmesh(const InstVec& insts);
-void checkBackgnd(const InstVec& insts);
-void checkCamera(const InstVec& insts);
-void checkAv(const InstVec& insts);
-void checkUncat(const InstVec& insts);
-
-TEST(FF7Field, BugFixes)
-{
-
-    auto scriptBytes = Lzs::Decompress(BinaryReader::ReadAll("decompiler/test/bug_fixes.dat"));
-
-    // Remove section pointers, leave everything after the script data as this doesn't matter
-    const int kNumSections = 7;
-    scriptBytes.erase(scriptBytes.begin(), scriptBytes.begin() + kNumSections * sizeof(uint32));
-    DummyFormatter formatter;
-    SUDM::Field::DecompiledScript ds = SUDM::Field::Decompile("bug_fixes", scriptBytes, formatter, "", "EntityContainer = {}\n\n");
-    ASSERT_FALSE(ds.luaScript.empty());
-
-    // TODO: This check should be more robust
-    std::string expected =
-        "        self.BugTest:set_talkable( true )\n"
-        "        self.BugTest:set_talkable( false )\n"
-        "        self.BugTest:set_talkable( false )\n"
-        "        self.BugTest:set_visible( false )\n"
-        "        self.BugTest:set_visible( true )\n"
-        "        self.BugTest:set_visible( true )\n"
-        "        self.BugTest:set_solid( true )\n"
-        "        self.BugTest:set_solid( false )\n"
-        "        self.BugTest:set_solid( false )\n";
-    ASSERT_NE(std::string::npos, ds.luaScript.find(expected));
-
-    std::ofstream tmp("bug_fixes.lua");
-    if (!tmp.is_open())
-    {
-        throw std::runtime_error("Can't open bug_fixes.lua for writing");
-    }
-
-    tmp << ds.luaScript;
-
-}
-
-
-TEST(FF7Field, DisasmAllOpcodes)
-{
-    std::ofstream tmp("ff7_all_opcodes_by_category.fieldasm");
-    if (!tmp.is_open())
-    {
-        throw std::runtime_error("Can't open ff7_all_opcodes_by_category.fieldasm for writing");
-    }
-
-    InstVec insts;
-    DummyFormatter formatter;
-    FieldEngine engine(formatter, "test");
-
-    auto d = engine.GetDisassembler(insts);
-    d->open("decompiler/test/ff7_all_opcodes_by_category.dat");
-    d->disassemble();
-    d->dumpDisassembly(tmp);
-    tmp << std::endl;
-
-    checkFlow(insts);
-    checkModule(insts);
-    checkMath(insts);
-    checkWindow(insts);
-    checkParty(insts);
-    checkModel(insts);
-    checkWalkmesh(insts);
-    checkBackgnd(insts);
-    checkCamera(insts);
-    checkAv(insts);
-    checkUncat(insts);
-}
-
-
-
-void checkFlow(const InstVec& insts)
-{
-    int index = FLOW_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::RET, 0);
-    index++;
-    
-    ASSERT_OP_LEN(eOpcodes::REQ, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::REQSW, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::REQEW, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PREQ, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PRQSW, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PRQEW, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::RETTO, 2);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::JMPF, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::JMPFL, 1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::JMPB, 1);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::JMPBL, 1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFUB, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFUBL, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFSW, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFSWL, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFUW, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFUWL, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WAIT, 1);
-    ASSERT_PARAM_UNSIGNED(1000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFKEY, 2);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFKEYON, 2);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFKEYOFF, 2);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::NOP, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFPRTYQ, 2);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IFMEMBQ, 2);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-}
-
-
-void checkModule(const InstVec& insts)
-{
-    int index = MODULE_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::DSKCG, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::ARROW, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::PNAME, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::GMSPD, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::SMSPD, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::FLMAT, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::FLITM, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::BTLCK, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::MVLCK, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::SPCNM, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::RSGLB, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::SPECIAL, eSpecialOpcodes::CLITM, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MINIGAME, 6);
-    ASSERT_PARAM_UNSIGNED(786);
-    ASSERT_PARAM_SIGNED(-2000);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_UNSIGNED(4000);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BTMD2, 1);
-    ASSERT_PARAM_UNSIGNED(0xFFFFFFFF);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BTRLD, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BTLTB, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MAPJUMP, 5);
-    ASSERT_PARAM_UNSIGNED(786);
-    ASSERT_PARAM_SIGNED(-2000);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_UNSIGNED(4000);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::LSTMP, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BATTLE, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BTLON, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BTLMD, 1);
-    ASSERT_PARAM_UNSIGNED(0xFFFF);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPJPO, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PMJMP, 1);
-    ASSERT_PARAM_UNSIGNED(786);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PMJMP2, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GAMEOVER, 0);
-    index++;
-}
-
-
-void checkMath(const InstVec& insts)
-{
-    int index = MATH_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::PLUS_, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PLUS2_, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MINUS_, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MINUS2_, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::INC_, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::INC2_, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DEC_, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DEC2_, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::RDMSD, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SETBYTE, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SETWORD, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BITON, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BITOFF, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BITXOR, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PLUS, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PLUS2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MINUS, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MINUS2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MUL, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MUL2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DIV, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DIV2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MOD, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MOD2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::AND, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::AND2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::OR, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::OR2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::XOR, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::XOR2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::INC, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::INC2, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DEC, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DEC2, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::RANDOM, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::LBYTE, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::HBYTE, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TWOBYTE, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SIN, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5000);
-    ASSERT_PARAM_UNSIGNED(6000);
-    ASSERT_PARAM_UNSIGNED(7000);
-    ASSERT_PARAM_UNSIGNED(8);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::COS, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5000);
-    ASSERT_PARAM_UNSIGNED(6000);
-    ASSERT_PARAM_UNSIGNED(7000);
-    ASSERT_PARAM_UNSIGNED(8);
-    index++;
-}
-
-
-void checkWindow(const InstVec& insts)
-{
-    int index = WINDOW_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::TUTOR, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WCLS, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WSIZW, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2000);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4000);
-    ASSERT_PARAM_UNSIGNED(5000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WSPCL, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WNUMB, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4000);
-    ASSERT_PARAM_UNSIGNED(5000);
-    ASSERT_PARAM_UNSIGNED(6);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::STTIM, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MESSAGE, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPARA, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPRA2, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPNAM, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ASK, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MENU, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MENU2, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WINDOW, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2000);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4000);
-    ASSERT_PARAM_UNSIGNED(5000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WMOVE, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_SIGNED(-2000);
-    ASSERT_PARAM_SIGNED(-3000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WMODE, 3);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WREST, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WCLSE, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::WROW, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GWCOL, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SWCOL, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    index++;
-}
-
-
-void checkParty(const InstVec& insts)
-{
-    int index = PARTY_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::SPTYE, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GTPYE, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GOLDU, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GOLDD, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CHGLD, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::HMPMAX1, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::HMPMAX2, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MHMMX, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::HMPMAX3, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPU, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPD, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::HPU, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::HPD, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::STITM, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DLITM, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CKITM, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SMTRA, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DMTRA, 9);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CMTRA, 12);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    ASSERT_PARAM_UNSIGNED(11);
-    ASSERT_PARAM_UNSIGNED(12);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GETPC, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PRTYP, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PRTYM, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PRTYE, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MMBUD, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MMBLK, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MMBUK, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-}
-
-
-void checkModel(const InstVec& insts)
-{
-    int index = MODEL_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::JOIN, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SPLIT, 13);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_SIGNED(-7000);
-    ASSERT_PARAM_SIGNED(-8000);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_SIGNED(-10000);
-    ASSERT_PARAM_SIGNED(-11000);
-    ASSERT_PARAM_UNSIGNED(12);
-    ASSERT_PARAM_UNSIGNED(13);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BLINK, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::EYETX, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(72);
-    ASSERT_PARAM_UNSIGNED(137);
-    ASSERT_PARAM_UNSIGNED(206);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::TRNSP, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::AMBNT, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(232);
-    ASSERT_PARAM_UNSIGNED(111);
-    ASSERT_PARAM_UNSIGNED(112);
-    ASSERT_PARAM_UNSIGNED(12);
-    ASSERT_PARAM_UNSIGNED(219);
-    ASSERT_PARAM_UNSIGNED(139);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown03, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown04, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown05, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::LIGHT, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown07, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown08, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown09, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::SBOBJ, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown0B, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::Unknown0C, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::SHINE, 0);
-    index++;
-
-    ASSERT_OP_SUBOP_LEN(eOpcodes::KAWAI, eKawaiOpcodes::RESET, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::KAWIW, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PMOVA, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PDIRA, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PTURA, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PGTDR, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PXYZI, 9);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TLKON, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PC, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::opCodeCHAR, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DFANM, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ANIME1, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::VISI, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::XYZI, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_SIGNED(-7000);
-    ASSERT_PARAM_UNSIGNED(8000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::XYI, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_UNSIGNED(7000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::XYZ, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_SIGNED(-7000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MOVE, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_SIGNED(-4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CMOVE, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_SIGNED(-4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MOVA, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TURA, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ANIMW, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::FMOVE, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_SIGNED(-4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ANIME2, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ANIM_1, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CANIM1, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CANM_1, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MSPED, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DIR, 2);
-    ASSERT_PARAM_UNSIGNED(0x12);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TURNGEN, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TURN, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::DIRA, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GETDIR, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GETAXY, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GETAI, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ANIM_2, 2);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CANIM2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CANM_2, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ASPED, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CC, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::JUMP, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_UNSIGNED(7000);
-    ASSERT_PARAM_UNSIGNED(8000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::AXYZI, 9);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::LADER, 12);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_SIGNED(-7000);
-    ASSERT_PARAM_UNSIGNED(8000);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    ASSERT_PARAM_UNSIGNED(11);
-    ASSERT_PARAM_UNSIGNED(12);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::OFST, 9);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_SIGNED(-7000);
-    ASSERT_PARAM_SIGNED(-8000);
-    ASSERT_PARAM_UNSIGNED(9000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::OFSTW, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TALKR, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SLIDR, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SOLID, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TLKR2, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SLDR2, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CCANM, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::FCFIX, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ANIMB, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::TURNW, 0);
-    index++;
-}
-
-
-void checkWalkmesh(const InstVec& insts)
-{
-    int index = WALKMESH_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::SLIP, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::UC, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::IDLCK, 2);
-    ASSERT_PARAM_UNSIGNED(1000);
-    ASSERT_PARAM_UNSIGNED(2);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::LINE, 6);
-    ASSERT_PARAM_SIGNED(-1000);
-    ASSERT_PARAM_SIGNED(-2000);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_SIGNED(-4000);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::LINON, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SLINE, 12);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_SIGNED(-7000);
-    ASSERT_PARAM_SIGNED(-8000);
-    ASSERT_PARAM_SIGNED(-9000);
-    ASSERT_PARAM_SIGNED(-10000);
-    ASSERT_PARAM_SIGNED(-11000);
-    ASSERT_PARAM_SIGNED(-12000);
-    index++;
-}
-
-
-void checkBackgnd(const InstVec& insts)
-{
-    int index = BACKGND_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::BGPDH, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_SIGNED(-4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BGSCR, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_SIGNED(-4000);
-    ASSERT_PARAM_SIGNED(-5000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPPAL, 13);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    ASSERT_PARAM_UNSIGNED(11);
-    ASSERT_PARAM_UNSIGNED(12);
-    ASSERT_PARAM_UNSIGNED(13);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BGON, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BGOFF, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BGROL, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BGROL2, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BGCLR, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::STPAL, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::LDPAL, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CPPAL, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::RTPAL, 8);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ADPAL, 12);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    ASSERT_PARAM_UNSIGNED(11);
-    ASSERT_PARAM_UNSIGNED(12);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MPPAL2, 12);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    ASSERT_PARAM_UNSIGNED(11);
-    ASSERT_PARAM_UNSIGNED(12);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::STPLS, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::LDPLS, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CPPAL2, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::RTPAL2, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::ADPAL2, 10);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    index++;
-}
-
-
-void checkCamera(const InstVec& insts)
-{
-    int index = CAMERA_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::NFADE, 10);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SHAKE, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCRLO, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCRLC, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCRLA, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCR2D, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_SIGNED(-4000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCRCC, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCR2DC, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_UNSIGNED(7000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCRLW, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCR2DL, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_SIGNED(-5000);
-    ASSERT_PARAM_SIGNED(-6000);
-    ASSERT_PARAM_UNSIGNED(7000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::VWOFT, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_SIGNED(-3000);
-    ASSERT_PARAM_SIGNED(-4000);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::FADE, 10);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::FADEW, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SCRLP, 5);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MVCAM, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-}
-
-
-void checkAv(const InstVec& insts)
-{
-    int index = AV_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::BGMOVIE, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::AKAO2, 12);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8000);
-    ASSERT_PARAM_UNSIGNED(9000);
-    ASSERT_PARAM_UNSIGNED(10000);
-    ASSERT_PARAM_UNSIGNED(11000);
-    ASSERT_PARAM_UNSIGNED(12000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MUSIC, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SOUND, 4);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3000);
-    ASSERT_PARAM_UNSIGNED(4);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::AKAO, 12);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9000);
-    ASSERT_PARAM_UNSIGNED(10000);
-    ASSERT_PARAM_UNSIGNED(11000);
-    ASSERT_PARAM_UNSIGNED(12000);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MUSVT, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MUSVM, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MULCK, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::BMUSC, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CHMPH, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::PMVIE, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MOVIE, 0);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::MVIEF, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::FMUSC, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CMUSC, 7);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::CHMST, 3);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    index++;
-}
-
-
-void checkUncat(const InstVec& insts)
-{
-    int index = UNCAT_BASE, paramIndex = 0;
-
-    ASSERT_OP_LEN(eOpcodes::MPDSP, 1);
-    ASSERT_PARAM_UNSIGNED(1);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SETX, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::GETX, 6);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    index++;
-
-    ASSERT_OP_LEN(eOpcodes::SEARCHX, 10);
-    ASSERT_PARAM_UNSIGNED(1);
-    ASSERT_PARAM_UNSIGNED(2);
-    ASSERT_PARAM_UNSIGNED(3);
-    ASSERT_PARAM_UNSIGNED(4);
-    ASSERT_PARAM_UNSIGNED(5);
-    ASSERT_PARAM_UNSIGNED(6);
-    ASSERT_PARAM_UNSIGNED(7);
-    ASSERT_PARAM_UNSIGNED(8);
-    ASSERT_PARAM_UNSIGNED(9);
-    ASSERT_PARAM_UNSIGNED(10);
-    index++;
-}
-
-
-#undef ASSERT_OP_LEN
-#undef ASSERT_OP_SUBOP_LEN
-#undef ASSERT_PARAM_UNSIGNED
-#undef ASSERT_PARAM_SIGNED
-
-#undef FLOW_BASE
-#undef FLOW_LABELS
-#undef FLOW_OPCODES
-#undef MODULE_BASE
-#undef MODULE_OPCODES
-#undef MATH_BASE
-#undef MATH_OPCODES
-#undef WINDOW_BASE
-#undef WINDOW_OPCODES
-#undef PARTY_BASE
-#undef PARTY_OPCODES
-#undef MODEL_BASE
-#undef MODEL_OPCODES
-#undef WALKMESH_BASE
-#undef WALKMESH_OPCODES
-#undef BACKGND_BASE
-#undef BACKGND_OPCODES
-#undef CAMERA_BASE
-#undef CAMERA_OPCODES
-#undef AV_BASE
-#undef AV_OPCODES
-#undef UNCAT_BASE
-#undef UNCAT_OPCODES
-
-
-
-TEST(FF7Field, Decomp_AllOpcodes)
-//TEST(FF7Field, Decomp_AllOpcodes)
-{
-    // TODO:
-    // this "fails", but it appears to be due to the .dat making references to scripts that don't exist
-    // to get it working, the Flow section of the .dat needs to be corrected, and then the DisasmAllOpcodes test needs to be adjusted so it still works
-
-    //std::cout << "ready" << std::endl;
-   // std::cin.ignore();
-
-    auto scriptBytes = Lzs::Decompress(BinaryReader::ReadAll("decompiler/test/ff7_all_opcodes_by_category.dat"));
-    //auto scriptBytes = Lzs::Decompress(BinaryReader::ReadAll("decompiler/test/anfrst_1.dat"));
-
-    // Remove section pointers, leave everything after the script data as this doesn't matter
-    const int kNumSections = 7;
-    scriptBytes.erase(scriptBytes.begin(), scriptBytes.begin() + kNumSections * sizeof(uint32));
-    DummyFormatter formatter;
-    SUDM::Field::DecompiledScript ds = SUDM::Field::Decompile("ff7_all_opcodes_by_category", scriptBytes, formatter, "", "EntityContainer = {}\n\n");
-    ASSERT_FALSE(ds.luaScript.empty());
-
-
-    std::ofstream tmp("ff7_all_opcodes_by_category.lua");
-    if (!tmp.is_open())
-    {
-        throw std::runtime_error("Can't open ff7_all_opcodes_by_category.lua for writing");
-    }
-
-    tmp << ds.luaScript;
-}

+ 0 - 61
src/installer/decompiler/test/ff7_field_dummy_formatter.h

@@ -1,61 +0,0 @@
-#include "../ScriptFormatter.h"
-
-class DummyFormatter : public ScriptFormatter
-{
-public:
-    // Renames a variable, return empty string for generated name
-    virtual std::string VarName(uint32, uint32) override
-    {
-        return "";
-    }
-
-    // Renames an entity
-    virtual std::string EntityName(const std::string& entity) override
-    {
-        if (entity == "dir")
-        {
-            return "Director";
-        }
-        else if (entity == "cl")
-        {
-            return "Cloud";
-        }
-        else if (entity == "av_b")
-        {
-            return "Biggs";
-        }
-        else if (entity == "av_c")
-        {
-            return "Jessie";
-        }
-        else if (entity == "av_w")
-        {
-            return "Wedge";
-        }
-        return entity;
-    }
-
-    // Names an animation
-    virtual std::string AnimationName(int /*charId*/, int id) override
-    {
-        return std::to_string(id);
-    }
-
-    // Get name of char from its id
-    virtual std::string CharName(int charId) override
-    {
-        return std::to_string(charId);
-    }
-
-    // Renames a function in an entity
-    virtual std::string FunctionName(const std::string&, const std::string& funcName) override
-    {
-        return funcName;
-    }
-
-    // Sets the header comment for a function in an entity
-    virtual std::string FunctionComment(const std::string& , const std::string& ) override
-    {
-        return "function comment";
-    }
-};

BIN
src/installer/decompiler/test/hanoi20.pasb


BIN
src/installer/decompiler/test/if-else.dmp


+ 0 - 10
src/installer/decompiler/test/if-else.txt

@@ -1,10 +0,0 @@
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue postIf
-wordVarDec 123
-jump postElse
-postIf:
-wordVarInc 123
-postElse:
-stopObjectCodeA

BIN
src/installer/decompiler/test/if-no-else.dmp


+ 0 - 9
src/installer/decompiler/test/if-no-else.txt

@@ -1,9 +0,0 @@
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue postIf
-wordVarDec 123
-jump postIf
-postIf:
-wordVarDec 123
-stopObjectCodeA

BIN
src/installer/decompiler/test/if.dmp


+ 0 - 7
src/installer/decompiler/test/if.txt

@@ -1,7 +0,0 @@
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue postIf
-wordVarInc 123
-postIf:
-stopObjectCodeA

+ 0 - 1517
src/installer/decompiler/test/main.cpp

@@ -1,1517 +0,0 @@
-#include <gmock/gmock.h>
-
-#include "../../common/Lzs.h"
-#include "../ControlFlow.h"
-#include "../Graph.h"
-#include "../ScriptFormatter.h"
-#include "decompiler/ff7_field/ff7_field_disassembler.h"
-#include "decompiler/ff7_field/ff7_field_engine.h"
-#include "decompiler/ff7_field/ff7_field_codegen.h"
-
-#include "decompiler/ff7_world/ff7_world_disassembler.h"
-#include "decompiler/ff7_world/ff7_world_engine.h"
-
-#include "util.h"
-#include "ff7_field_dummy_formatter.h"
-
-#define GET(vertex) (boost::get(boost::vertex_name, g, vertex))
-
-
-class TestReadParameterDisassembler : public SimpleDisassembler
-{
-public:
-    TestReadParameterDisassembler(std::vector<unsigned char>&& data, InstVec& insts)
-        : SimpleDisassembler(insts)
-    {
-        mStream = std::make_unique<BinaryReader>(std::move(data));
-    }
-
-    void readParams(InstPtr inst, const char *typeString)
-    {
-        return SimpleDisassembler::readParams(inst, typeString);
-    }
-
-
-    virtual void doDisassemble() override final
-    {
-        // NOP
-    }
-
-};
-
-static InstPtr DoReadParameterTest(std::string str, std::vector<unsigned char> data)
-{
-    InstVec insts;
-    TestReadParameterDisassembler d(std::move(data), insts);
-    InstPtr inst = new FieldNoOperationInstruction();
-    d.readParams(inst, str.c_str());
-    return inst;
-}
-
-TEST(SimpleDisassembler, readParameter_U)
-{
-    std::vector<unsigned char> data = { 0xAA };
-    InstPtr inst = DoReadParameterTest("U", data);
-
-    ASSERT_EQ(inst->_params.size(), 2);
-    ASSERT_EQ(inst->_params[0]->getSigned(), 0x5);
-    ASSERT_EQ(inst->_params[1]->getSigned(), 0xA);
-}
-
-TEST(SimpleDisassembler, readParameter_N)
-{
-    std::vector<unsigned char> data = { 0xAB };
-    InstPtr inst = DoReadParameterTest("N", data);
-
-    ASSERT_EQ(inst->_params.size(), 2);
-    ASSERT_EQ(inst->_params[0]->getSigned(), 0xA);
-    ASSERT_EQ(inst->_params[1]->getSigned(), 0xB);
-}
-
-TEST(SimpleDisassembler, readParameter_b)
-{
-    std::vector<unsigned char> data = { (unsigned char)-100 };
-    InstPtr inst = DoReadParameterTest("b", data);
-
-    ASSERT_EQ(inst->_params.size(), 1);
-    ASSERT_EQ(inst->_params[0]->getSigned(), -100);
-}
-
-TEST(SimpleDisassembler, readParameter_B)
-{
-    std::vector<unsigned char> data = { 100 };
-    InstPtr inst = DoReadParameterTest("B", data);
-
-    ASSERT_EQ(inst->_params.size(), 1);
-    ASSERT_EQ(inst->_params[0]->getSigned(), 100);
-}
-
-TEST(SimpleDisassembler, readParameter_s)
-{
-    std::vector<unsigned char> data = { (unsigned char)-40, 0x0 };
-    InstPtr inst = DoReadParameterTest("s", data);
-
-    ASSERT_EQ(inst->_params.size(), 1);
-    ASSERT_EQ(inst->_params[0]->getSigned(), 216); // TODO: Casting removes the sign
-}
-
-TEST(SimpleDisassembler, readParameter_w)
-{
-    std::vector<unsigned char> data = { 0xFE, 0xAA };
-    InstPtr inst = DoReadParameterTest("w", data);
-
-    ASSERT_EQ(inst->_params.size(), 1);
-    ASSERT_EQ(inst->_params[0]->getSigned(), 0xAAFE);
-}
-
-TEST(SimpleDisassembler, readParameter_i)
-{
-    std::vector<unsigned char> data = { (unsigned char)-0x30, 0x0, 0x0, 0x0 };
-    InstPtr inst = DoReadParameterTest("i", data);
-
-    ASSERT_EQ(inst->_params.size(), 1);
-    ASSERT_EQ(inst->_params[0]->getSigned(), 208); // TODO: Casting removes the sign
-}
-
-TEST(SimpleDisassembler, readParameter_d)
-{
-    std::vector<unsigned char> data = { 0xde, 0xad, 0xbe, 0xef };
-    InstPtr inst = DoReadParameterTest("d", data);
-
-    ASSERT_EQ(inst->_params.size(), 1);
-    ASSERT_EQ(inst->_params[0]->getUnsigned(), 0xEFBEADDE);
-}
-
-TEST(FF7Field, FunctionMetaData_Parse_Empty)
-{
-    FunctionMetaData meta("");
-    ASSERT_EQ("", meta.EntityName());
-    ASSERT_EQ(false, meta.IsEnd());
-    ASSERT_EQ(false, meta.IsStart());
-}
-
-TEST(FF7Field, FunctionMetaData_Parse_Empties)
-{
-    FunctionMetaData meta("__________________");
-    ASSERT_EQ("", meta.EntityName());
-    ASSERT_EQ(false, meta.IsEnd());
-    ASSERT_EQ(false, meta.IsStart());
-}
-
-TEST(FF7Field, FunctionMetaData_Parse_Start)
-{
-    FunctionMetaData meta("start_-1_entity");
-    ASSERT_EQ("entity", meta.EntityName());
-    ASSERT_EQ(false, meta.IsEnd());
-    ASSERT_EQ(true, meta.IsStart());
-}
-
-TEST(FF7Field, FunctionMetaData_Parse_End)
-{
-    FunctionMetaData meta("end_-1_entity");
-    ASSERT_EQ("entity", meta.EntityName());
-    ASSERT_EQ(true, meta.IsEnd());
-    ASSERT_EQ(false, meta.IsStart());
-}
-
-TEST(FF7Field, FunctionMetaData_Parse_EntityName)
-{
-    FunctionMetaData meta("end_-1_TheName");
-    ASSERT_EQ("TheName", meta.EntityName());
-    ASSERT_EQ(true, meta.IsEnd());
-    ASSERT_EQ(false, meta.IsStart());
-    ASSERT_EQ(-1, meta.CharacterId());
-
-}
-
-TEST(FF7Field, FunctionMetaData_Parse_EntityNameAndId)
-{
-    FunctionMetaData meta("end_99_The_Name");
-    ASSERT_EQ("The_Name", meta.EntityName());
-    ASSERT_EQ(99, meta.CharacterId());
-
-    ASSERT_EQ(true, meta.IsEnd());
-    ASSERT_EQ(false, meta.IsStart());
-}
-
-
-TEST(FF7Field, FunctionMetaData_Parse_StartEnd)
-{
-    FunctionMetaData meta("start_end_-1_entity");
-    ASSERT_EQ("entity", meta.EntityName());
-    ASSERT_EQ(true, meta.IsEnd());
-    ASSERT_EQ(true, meta.IsStart());
-}
-
-/*
-TEST(FF7World, DisAsm)
-{
-    for (int i = 0; i < 256; i++)
-    {
-        WorldEngine engine(i);
-
-
-        InstVec insts;
-        std::cout << std::endl;
-
-        std::cout << std::endl;
-
-        std::cout << "SCRIPT(" << i << ")" << std::endl;
-
-
-        auto d = engine.GetDisassembler(insts);
-        d->open("decompiler/ff7_world/wm0.ev");
-        d->disassemble();
-        d->dumpDisassembly(std::cout);
-        std::cout << std::endl;
-
-
-        auto c = std::make_unique<ControlFlow>(insts, engine);
-        c->createGroups();
-
-
-
-
-        Graph g = c->analyze();
-
-        engine.PostCFG(insts, g);
-
-
-        onullstream ns;
-        auto cg = engine.GetCodeGenerator(insts, std::cout);
-
-        std::ofstream out;
-        out.open("graph.dot");
-        if (out.is_open())
-        {
-            auto& g = c->getGraph();
-            boost::write_graphviz(
-                out, g, boost::make_label_writer(get(boost::vertex_name, g)),
-                boost::MakeArrowheadWriter(get(boost::edge_attribute, g)), GraphProperties(&engine, g));
-        }
-        out.close();
-
-        cg->generate(insts, g);
-
-        VertexIterator v = boost::vertices(g).first;
-        GroupPtr gr = GET(*v);
-
-        // Find first node
-        while (gr->_prev != NULL)
-        {
-            gr = gr->_prev;
-        }
-
-        // Copy out all lines of code
-        std::vector<std::string> output;
-        while (gr != NULL)
-        {
-            for (std::vector<CodeLine>::iterator it = gr->_code.begin(); it != gr->_code.end(); ++it)
-            {
-                output.push_back(it->_line);
-            }
-            gr = gr->_next;
-        }
-
-        ASSERT_TRUE(output.empty() == false);
-    }
-}
-*/
-
-int main(int argc, char** argv)
-{
-    ::testing::InitGoogleMock(&argc, argv);
-    return RUN_ALL_TESTS();
-}
-
-class Tokenzier
-{
-public:
-    Tokenzier(const std::string& input)
-        : mData(input)
-    {
-
-    }
-
-    enum class eTokenType
-    {
-        eWhiteSpace,
-        eText,
-        eNumber,
-        eInvalid,
-        eArgumentDelmiter,
-        eOpenBracket,
-        eCloseBracket,
-        eOpenCurlyBracket,
-        eCloseCurlyBracket,
-        eQuote,
-        eEof
-    };
-
-    class Token
-    {
-    public:
-        Token() = default;
-
-        Token(eTokenType type, std::string text, int line, int column)
-            : mType(type), mText(text), mColumn(column), mLine(line)
-        {
-
-        }
-
-        Token(eTokenType type, int number, int line, int column)
-            : mType(type), mNumber(number), mColumn(column), mLine(line)
-        {
-
-        }
-
-        Token(eTokenType type, int line, int column)
-            : mType(type), mColumn(column), mLine(line)
-        {
-
-        }
-
-        std::string AsString() const
-        {
-            return mText;
-        }
-
-        int AsNumber() const
-        {
-            return mNumber;
-        }
-
-        eTokenType Type() const { return mType; }
-        int Line() const { return mLine; }
-        int Column() const { return mColumn; }
-
-    private:
-        std::string mText;
-        int mNumber = 0;
-        eTokenType mType = eTokenType::eInvalid;
-        int mLine = -1;
-        int mColumn = -1;
-    };
-
-    bool IsLineBreak(char item)
-    {
-        return item == '\r' || item == '\n';
-    }
-
-    bool IsSpace(char item, std::locale& loc)
-    {
-        return std::isspace(item, loc) && !IsLineBreak(item);
-    }
-
-    bool IsAlpha(char item)
-    {
-        return
-            (item >= 'A' && item <= 'Z') || 
-            (item >= 'a' && item <= 'z') ||
-            item == '_';
-    }
-
-    bool IsDigit(char item, std::locale& loc)
-    {
-        return std::isdigit(item, loc);
-    }
-
-    Token Next()
-    {
-        char item = ' ';
-
-        if (!mData)
-        {
-            return Token(eTokenType::eEof, mCurLine, mCurCol);
-        }
-
-        ReadChar(item);
-
-        bool eof = false;
-        item = ConsumeWhiteSpace(item, eof);
-        if (eof)
-        {
-            return Token(eTokenType::eEof, mCurLine, mCurCol-1);
-        }
-
-        // Begin comment, consume until eLineBreak
-        const bool startComment = item == ';';
-        if (startComment)
-        {
-            bool isLineBreak = false;
-            do
-            {
-                if (!ReadChar(item))
-                {
-                    return Token(eTokenType::eEof, mCurLine, mCurCol - 1);
-                }
-                isLineBreak = IsLineBreak(item);
-            } while (!isLineBreak);
-
-            item = ConsumeWhiteSpace(item, eof);
-            if (eof)
-            {
-                return Token(eTokenType::eEof, mCurLine, mCurCol - 1);
-            }
-        }
-        
-        if (item == ',')
-        {
-            return Token(eTokenType::eArgumentDelmiter, ",", mCurLine, mCurCol - 1);
-        }
-        else if (item == '(')
-        {
-            return Token(eTokenType::eOpenBracket, "(", mCurLine, mCurCol - 1);
-        }
-        else if (item == ')')
-        {
-            return Token(eTokenType::eCloseBracket, ")", mCurLine, mCurCol - 1);
-        }
-        else if (item == '{')
-        {
-            return Token(eTokenType::eOpenCurlyBracket, "{", mCurLine, mCurCol - 1);
-        }
-        else if (item == '}')
-        {
-            return Token(eTokenType::eCloseCurlyBracket, "}", mCurLine, mCurCol - 1);
-        }
-        else if (item == '"')
-        {
-            return Token(eTokenType::eQuote, "\"", mCurLine, mCurCol-1);
-        }
-        const bool alpha = IsAlpha(item) || item == ';';
-        if (alpha)
-        {
-            const int startCol = mCurCol - 1;
-
-            std::string text(1, item);
-
-            // eText, consume until eLineBreak or whitespace
-            bool stillAlphaOrDigit = false;
-            do
-            {
-                if (!ReadChar(item))
-                {
-                    return Token(eTokenType::eText, text, mCurLine, startCol);
-                }
-                // Strings can end with a :
-                stillAlphaOrDigit = IsAlpha(item) || IsDigit(item, mLoc) || item == ':';
-                if (stillAlphaOrDigit)
-                {
-                    text.push_back(item);
-                    if (item == ':')
-                    {
-                        break;
-                    }
-                }
-                else
-                {
-                    // Put the char back
-                    mData.seekg(-1, std::ios::cur);
-                }
-            } while (stillAlphaOrDigit);
-
-            return Token(eTokenType::eText, text, mCurLine, startCol);
-
-        }
-        else if (IsDigit(item, mLoc) || item == '-') // Start of negative number
-        {
-            // eNumber, consume until eLineBreak or whitespace, each item before that must be a digit
-            const int startCol = mCurCol - 1;
-            std::string text(1, item);
-            bool isANumber = true;
-            do
-            {
-                ReadChar(item);
-                if (!mData && item == '-')
-                {
-                    // We ONLY have a -, this is invalid
-                    return Token(eTokenType::eInvalid, mCurLine, startCol);
-                }
-                else if (!mData)
-                {
-                    return Token(eTokenType::eNumber, std::stoi(text), mCurLine, startCol);
-                }
-                isANumber = IsDigit(item, mLoc);
-                if (isANumber)
-                {
-                    text.push_back(item);
-                }
-                else
-                {
-                    // Put the char back
-                    mData.seekg(-1, std::ios::cur);
-                }
-            } while (isANumber);
-            return Token(eTokenType::eNumber, std::stoi(text), mCurLine, startCol);
-        }
-        else
-        {
-            // eInvalid
-            return Token(eTokenType::eInvalid, mCurLine, mCurCol-1);
-        }
-    }
-
-private:
-    char ConsumeWhiteSpace(char item, bool& eof)
-    {
-        // Eat all whitespace
-        bool space = IsSpace(item, mLoc) || IsLineBreak(item);
-        if (space)
-        {
-            do
-            {
-                if (!ReadChar(item))
-                {
-                    eof = true;
-                    return item;
-                }
-                space = IsSpace(item, mLoc) || IsLineBreak(item);
-            } while (space);
-        }
-        return item;
-    }
-
-    bool ReadChar(char& output)
-    {
-        mData.read(&output, 1);
-        if (mData)
-        {
-            if (IsLineBreak(output))
-            {
-                mCurLine++;
-                mCurCol = 1;
-            }
-            else
-            {
-                mCurCol++;
-            }
-            return true;
-        }
-        return false;
-    }
-
-    std::locale mLoc;
-    std::stringstream mData;
-    int mCurLine = 1;
-    int mCurCol = 1;
-};
-
-
-
-TEST(Tokenzier, Empty)
-{
-    Tokenzier t("");
-    ASSERT_EQ(Tokenzier::eTokenType::eEof, t.Next().Type());
-}
-
-TEST(Tokenzier, ReadText)
-{
-    Tokenzier t("Hello");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("Hello", token.AsString());
-}
-
-TEST(Tokenzier, ReadText2)
-{
-    Tokenzier t("Hello world");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("Hello", token.AsString());
-
-    token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("world", token.AsString());
-}
-
-
-// Check !"£$%^&*-+<>?;'[]#\/`¬ are marked as invalid and () is not part of text
-TEST(Tokenzier, ReadInvalidText)
-{
-    const char kInvalidChars[] = R"(;!£$%^&*-+<>?'[]#\/`¬)";
-    const int kNumChars = sizeof(kInvalidChars) / sizeof(char);
-    for (int i = 0; i < kNumChars; i++)
-    {
-        Tokenzier t(std::string(1,kInvalidChars[i]));
-        Tokenzier::Token token = t.Next();
-        if (i == 0)
-        {
-            // ; without a line break becomes EOF
-            ASSERT_EQ(Tokenzier::eTokenType::eEof, token.Type());
-        }
-        else
-        {
-            ASSERT_EQ(Tokenzier::eTokenType::eInvalid, token.Type());
-        }
-        ASSERT_EQ("", token.AsString());
-    }
-}
-
-TEST(Tokenzier, ReadInvalidText2)
-{
-    Tokenzier t("H!£$%^");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("H", token.AsString());
-
-    token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eInvalid, token.Type());
-    ASSERT_EQ("", token.AsString());
-
-}
-
-
-TEST(Tokenzier, ReadBrackets)
-{
-    {
-        Tokenzier t("(");
-        Tokenzier::Token token = t.Next();
-        ASSERT_EQ(Tokenzier::eTokenType::eOpenBracket, token.Type());
-        ASSERT_EQ("(", token.AsString());
-    }
-    {
-        Tokenzier t(")");
-        Tokenzier::Token token = t.Next();
-        ASSERT_EQ(Tokenzier::eTokenType::eCloseBracket, token.Type());
-        ASSERT_EQ(")", token.AsString());
-    }
-}
-
-TEST(Tokenzier, ReadLabel)
-{
-    Tokenzier t("Hello:");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("Hello:", token.AsString());
-}
-
-TEST(Tokenzier, ReadLabel2)
-{
-    Tokenzier t("Hello:a");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("Hello:", token.AsString());
-}
-
-TEST(Tokenzier, ReadWhiteSpace)
-{
-    Tokenzier t("\t ");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eEof, token.Type());
-    ASSERT_EQ("", token.AsString());
-
-}
-
-TEST(Tokenzier, ReadArgumentDelimiter)
-{
-    Tokenzier t(",");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eArgumentDelmiter, token.Type());
-    ASSERT_EQ(",", token.AsString());
-
-}
-
-TEST(Tokenzier, ReadNewLine)
-{
-    Tokenzier t("\r\n\r\r\n\n");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eEof, token.Type());
-    ASSERT_EQ("", token.AsString());
-}
-
-TEST(Tokenzier, ReadNegativeNumber)
-{
-    Tokenzier t("-12345");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eNumber, token.Type());
-    ASSERT_EQ(-12345, token.AsNumber());
-}
-
-TEST(Tokenzier, ReadNumber)
-{
-    Tokenzier t("12345");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eNumber, token.Type());
-    ASSERT_EQ(12345, token.AsNumber());
-}
-
-TEST(Tokenzier, ReadQuote)
-{
-    Tokenzier t("\"");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eQuote, token.Type());
-    ASSERT_EQ("\"", token.AsString());
-}
-
-TEST(Tokenzier, ReadCurlyBrackets)
-{
-    Tokenzier t("{}");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eOpenCurlyBracket, token.Type());
-    ASSERT_EQ("{", token.AsString());
-
-    token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eCloseCurlyBracket, token.Type());
-    ASSERT_EQ("}", token.AsString());
-}
-
-// Combos, whitespace, new line, text, number, argument delimiter eof
-TEST(Tokenzier, Combos)
-{
-
-    Tokenzier t(" \nText1234:1234,;Fool1\nFool2");
-    Tokenzier::Token token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("Text1234:", token.AsString());
-    ASSERT_EQ(2, token.Line());
-    ASSERT_EQ(1, token.Column());
-
-    token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eNumber, token.Type());
-    ASSERT_EQ(1234, token.AsNumber());
-    ASSERT_EQ(2, token.Line());
-    ASSERT_EQ(10, token.Column());
-
-    token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eArgumentDelmiter, token.Type());
-    ASSERT_EQ(",", token.AsString());
-    ASSERT_EQ(2, token.Line());
-    ASSERT_EQ(15, token.Column());
-
-    token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eText, token.Type());
-    ASSERT_EQ("Fool2", token.AsString());
-    ASSERT_EQ(3, token.Line());
-    ASSERT_EQ(1, token.Column());
-
-    token = t.Next();
-    ASSERT_EQ(Tokenzier::eTokenType::eEof, token.Type());
-    ASSERT_EQ("", token.AsString());
-}
-
-typedef std::vector<std::pair<std::string, Tokenzier::Token>> JumpToken;
-
-class Assembler
-{
-public:
-    class Method
-    {
-    public:
-        Method(const std::string& name)
-            : mName(name)
-        {
-
-        }
-
-        bool AddLabel(std::string name, const Tokenzier::Token& token)
-        {
-            // Labels end with ":" so chop that char off
-            name = name.substr(0, name.length() - 1);
-
-            auto it = mLabels.find(name);
-            if (it != std::end(mLabels))
-            {
-                return false;
-            }
-            mLabels.insert(std::make_pair(name, token));
-            return true;
-        }
-
-        void AddJump(const std::string& label, const Tokenzier::Token& token)
-        {
-            auto it = mJumps.find(label);
-            if (it != std::end(mJumps))
-            {
-                it->second.push_back(token);
-            }
-            else
-            {
-                std::vector<Tokenzier::Token> t;
-                t.push_back(token);
-                mJumps.insert(std::make_pair(label, t));
-            }
-        }
-
-        void VerifyAndResolveLabels(JumpToken& unreferencedLabels, JumpToken& undefinedLabels)
-        {
-            
-            for (const auto& jumpTarget : mJumps)
-            {
-                auto it = mLabels.find(jumpTarget.first);
-                if (it == std::end(mLabels))
-                {
-                    undefinedLabels.push_back(std::make_pair(jumpTarget.first, jumpTarget.second[0]));
-                }
-            }
-
-            for (const auto& label : mLabels)
-            {
-                auto it = mJumps.find(label.first);
-                if (it == std::end(mJumps))
-                {
-                    unreferencedLabels.push_back(std::make_pair(label.first, label.second));
-                }
-            }
-
-        }
-
-    private:
-        std::string mName;
-        std::map<std::string, Tokenzier::Token> mLabels;
-        std::map<std::string, std::vector<Tokenzier::Token>> mJumps;
-    };
-
-    class Object
-    {
-    public:
-        Object(const std::string& name)
-            : mName(name)
-        {
-
-        }
-
-        const std::string& Name() const { return mName; }
-
-        Method* AddMethod(const std::string& name)
-        {
-            auto method = FindMethod(name);
-            if (!method)
-            {
-                mMethods[name] = std::make_unique<Method>(name);
-                return FindMethod(name);
-            }
-            return nullptr;
-        }
-
-        size_t MethodCount() const { return mMethods.size(); }
-        bool HasMethod(const std::string& name) const
-        {
-            return FindMethod(name) != nullptr;
-        }
-
-    private:
-        Method* FindMethod(const std::string& name) const
-        {
-            auto it = mMethods.find(name);
-            if (it == std::end(mMethods))
-            {
-                return nullptr;
-            }
-            return it->second.get();
-        }
-
-        std::string mName;
-        std::map<std::string, std::unique_ptr<Method>> mMethods;
-    };
-
-    Assembler()
-    {
-
-    }
-
-    // Something which wraps "methods"
-    Object* AddObject(const std::string& objectName)
-    {
-        auto obj = FindObject(objectName);
-        if (!obj)
-        {
-            mObjects[objectName] = std::make_unique<Object>(objectName);
-            return FindObject(objectName);
-        }
-        return nullptr;
-    }
-
-    size_t ObjectCount() const { return mObjects.size(); }
-private:
-    Object* FindObject(const std::string& objectName) const
-    {
-        auto it = mObjects.find(objectName);
-        if (it == std::end(mObjects))
-        {
-            return nullptr;
-        }
-        return it->second.get();
-    }
-
-    std::map<std::string, std::unique_ptr<Object>> mObjects;
-};
-
-class Parser
-{
-public:
-    class Exception : public std::exception
-    {
-    public:
-        Exception(const std::string& msg)
-            : mMsg(msg)
-        {
-
-        }
-
-        Exception(const std::string& msg, const Tokenzier::Token& token)
-            : mMsg(msg)
-        {
-            mMsg += " on line: " + std::to_string(token.Line()) + ", col: " + std::to_string(token.Column());
-            if (token.Type() == Tokenzier::eTokenType::eNumber)
-            {
-                mMsg += ", with value: '" + std::to_string(token.AsNumber()) + "'";
-            }
-            else if (token.AsString().empty() == false)
-            {
-                mMsg += ", with value: '" + token.AsString() + "'";
-            }
-        }
-
-        virtual const char* what() const throw() override
-        {
-            return mMsg.c_str();
-        }
-
-    private:
-        std::string mMsg;
-    };
-
-    class DuplicateObjectNameException : public Exception
-    {
-    public:
-        DuplicateObjectNameException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class DuplicateMethodNameException : public Exception
-    {
-    public:
-        DuplicateMethodNameException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class TooManyObjectsException : public Exception
-    {
-    public:
-        TooManyObjectsException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class TooManyMethodsException : public Exception
-    {
-    public:
-        TooManyMethodsException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class TooManyArgumentsException : public Exception
-    {
-    public:
-        TooManyArgumentsException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class ArgumentOutOfRangeException : public Exception
-    {
-    public:
-        ArgumentOutOfRangeException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class DuplicateLabelException : public Exception
-    {
-    public:
-        DuplicateLabelException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class UndefinedLabelException : public Exception
-    {
-    public:
-        UndefinedLabelException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    class UnknownOpCodeException : public Exception
-    {
-    public:
-        UnknownOpCodeException(const std::string& msg, const Tokenzier::Token& token) : Exception(msg, token) { }
-    };
-
-    Parser(const std::string& src)
-        : mTokenzier(src)
-    {
-
-    }
-
-    void Parse()
-    {
-        std::deque<Tokenzier::Token> tokenStack;
-        for (;;)
-        {
-            Tokenzier::Token token = mTokenzier.Next();
-            if (token.Type() == Tokenzier::eTokenType::eInvalid)
-            {
-                throw Exception("Invalid syntax", token);
-            }
-
-            if (token.Type() == Tokenzier::eTokenType::eEof)
-            {
-                break;
-            }
-            tokenStack.push_back(token);
-        }
-        Parse(tokenStack);
-    }
-
-private:
-    void Parse(std::deque<Tokenzier::Token>& tokens)
-    {
-        while (tokens.empty() == false)
-        {
-            // Everything at the top level should be an entity
-            ParseEntity(tokens);
-        }
-    }
-
-    void ParseEntity(std::deque<Tokenzier::Token>& tokens)
-    {
-        // Starts with entity keyword
-        ExpectText("Entity", NextToken(tokens));
-
-        // Entity name is quoted string within brackets
-        ExpectToken(Tokenzier::eTokenType::eOpenBracket, tokens);
-        Tokenzier::Token entityNameToken = ExpectQuotedString(tokens);
-        ExpectToken(Tokenzier::eTokenType::eCloseBracket, tokens);
-
-        std::cout << "ParseEntity: " << entityNameToken.AsString().c_str() << std::endl;
-
-        auto pObj = mAssembler.AddObject(entityNameToken.AsString());
-        if (!pObj)
-        {
-            throw DuplicateObjectNameException("Duplicated entity name", entityNameToken);
-        }
-
-        if (mAssembler.ObjectCount() >= 32)
-        {
-            throw TooManyObjectsException("There can only be 32 entities", entityNameToken);
-        }
-
-        // Entity body within { }'s
-        ExpectToken(Tokenzier::eTokenType::eOpenCurlyBracket, tokens);
-
-        // Handle empty {}'s case
-        if (PeekTokenType(tokens) != Tokenzier::eTokenType::eCloseCurlyBracket)
-        {
-            ParseEntityMethods(tokens, *pObj);
-        }
-        ExpectToken(Tokenzier::eTokenType::eCloseCurlyBracket, tokens);
-
-    }
-    
-    void ParseEntityMethods(std::deque<Tokenzier::Token>& tokens, Assembler::Object& obj)
-    {
-        while (tokens.empty() == false)
-        {
-            // Marks the end of functions
-            if (PeekTokenType(tokens) == Tokenzier::eTokenType::eCloseCurlyBracket)
-            {
-                break;
-            }
-            // Otherwise must be fn name() { } decl
-            ParseEntityMethod(tokens, obj);
-        }
-    }
-
-    void ParseEntityMethod(std::deque<Tokenzier::Token>& tokens, Assembler::Object& obj)
-    {
-        // Starts with fn keyword
-        ExpectText("fn", NextToken(tokens));
-
-        // Function name
-        Tokenzier::Token text = NextToken(tokens);
-        ExpectTokenType(Tokenzier::eTokenType::eText, text);
-      
-        std::cout << "Entity function: " << text.AsString().c_str() << std::endl;
-        auto pMethod = obj.AddMethod(text.AsString());
-        if (!pMethod)
-        {
-            throw DuplicateMethodNameException("Duplicated function name", text);
-        }
-
-        size_t methodCount = obj.MethodCount();
-        if (obj.HasMethod("init") && obj.HasMethod("main"))
-        {
-            // init and main count as 1 script
-            methodCount--;
-        }
-        if (methodCount >= 32)
-        {
-            throw TooManyMethodsException("There can only be 31 scripts excluding init and main", text);
-        }
-
-        // Brackets end function name
-        ExpectToken(Tokenzier::eTokenType::eOpenBracket, tokens);
-        ExpectToken(Tokenzier::eTokenType::eCloseBracket, tokens);
-
-        //  Body within { } 's,
-        ExpectToken(Tokenzier::eTokenType::eOpenCurlyBracket, tokens);
-
-        // handle empty {}'s case
-        if (PeekTokenType(tokens) != Tokenzier::eTokenType::eCloseCurlyBracket)
-        {
-            ParseEntityMethodBody(tokens, *pMethod);
-        }
-        ExpectToken(Tokenzier::eTokenType::eCloseCurlyBracket, tokens);
-
-        JumpToken unreferencedLabels;
-        JumpToken undefinedLabels;
-        pMethod->VerifyAndResolveLabels(unreferencedLabels, undefinedLabels);
-        if (!undefinedLabels.empty())
-        {
-            throw UndefinedLabelException("Undefined label", undefinedLabels[0].second);
-        }
-        if (!unreferencedLabels.empty())
-        {
-            // Warn about unused labels
-            for (const auto& label : unreferencedLabels)
-            {
-                std::cout << "WARNING: label " + label.first + " is not used on line : " + std::to_string(label.second.Line()) + ", col : " + std::to_string(label.second.Column()) << std::endl;
-            }
-        }
-    }
-    
-    void ParseEntityMethodBody(std::deque<Tokenzier::Token>& tokens, Assembler::Method& method)
-    {
-        while (tokens.empty() == false)
-        {
-            // } is the end of the function
-            if (PeekTokenType(tokens) == Tokenzier::eTokenType::eCloseCurlyBracket)
-            {
-                // TODO: Validate semantics of instructions parsed
-
-                break;
-            }
-            Tokenzier::Token text = NextToken(tokens);
-
-            // Probably someone has a passed a number argument to an opcode that takes no arguments
-            if (text.Type() == Tokenzier::eTokenType::eNumber)
-            {
-                throw UnknownOpCodeException("Expected opcode text", text);
-            }
-
-            ExpectTokenType(Tokenzier::eTokenType::eText, text);
-
-            // Label
-            std::string str = text.AsString();
-            if (str.back() == ':')
-            {
-                std::cout << "LABEL:" << str.c_str() << std::endl;
-                if (!method.AddLabel(str.c_str(), text))
-                {
-                    throw DuplicateLabelException("Duplicated label", text);
-                }
-            }
-            // instruction/mnemonic
-            else
-            {
-                std::cout << "INSTRUCTION:" << str.c_str() << std::endl;
-                ParseInstruction(text, tokens, method);
-            }
-        }
-    }
-
-    void ParseInstruction(const Tokenzier::Token& inst, std::deque<Tokenzier::Token>& tokens, Assembler::Method& method)
-    {
-        const auto insts = FieldInstructions();
-        auto it = insts.find(inst.AsString());
-        if (it == std::end(insts))
-        {
-            throw UnknownOpCodeException(inst.AsString() + " is not a known instruction", inst);
-        }
-
-        // TODO: Handle arguments correctly, validate labels
-        const TInstructRecord* rec = it->second;
-        const char* fmt = rec->mArgumentFormat;
-
-        // method.AddInstruction(rec->mOpCode, rec->mOpCodeSize);
-        // TODO: Flow control needs special handling
-
-        while (*fmt)
-        {
-            bool handled = false;
-            switch (*fmt)
-            {
-                // TODO: Handle nibbles correctly
-                /*
-            case 'N':
-            {
-                // TODO
-                ExpectTokenType(Tokenzier::eTokenType::eNumber, PeekToken(tokens));
-                NextToken(tokens);
-                secondNib = !secondNib;
-            }
-            break;*/
-            case 'N':
-            case 'B':
-            {
-                ExpectTokenType(Tokenzier::eTokenType::eNumber, PeekToken(tokens));
-                const auto token = NextToken(tokens);
-                if (token.AsNumber() < 0 || token.AsNumber() > 255)
-                {
-                    throw ArgumentOutOfRangeException("Byte argument must be between 0 and 255", token);
-                }
-                //method.AddInstructionArgument<unsigned char>(token.AsNumber());
-                handled = true;
-            }
-            break;
-
-            case 'U':
-            {
-                ExpectTokenType(Tokenzier::eTokenType::eNumber, PeekToken(tokens));
-                const auto token = NextToken(tokens);
-                if (token.AsNumber() < 0 || token.AsNumber() > 65535)
-                {
-                    throw ArgumentOutOfRangeException("Unsigned short argument must be between 0 and 65535", token);
-                }
-                //method.AddInstructionArgument<unsigned short int>(token.AsNumber());
-                handled = true;
-            }
-            break;
-
-            // Single byte label
-            case 'L':
-            {
-                ExpectTokenType(Tokenzier::eTokenType::eText, PeekToken(tokens));
-                const auto token = NextToken(tokens);
-                std::cout << "ADD JUMP: " << token.AsString() << std::endl;
-                method.AddJump(token.AsString(), token);
-                handled = true;
-            }
-            break;
-
-            default:
-                // TODO: Throw
-                break;
-            }
-            
-            fmt++;
-
-            // If we parsed and argument and there is another argument, then they
-            // should be separated by an argument delimiter
-            if (handled && *fmt)
-            {
-                ExpectTokenType(Tokenzier::eTokenType::eArgumentDelmiter, NextToken(tokens));
-            }
-        }
-
-        if (PeekTokenType(tokens) == Tokenzier::eTokenType::eArgumentDelmiter)
-        {
-            throw TooManyArgumentsException("Too many arguments for opcode", NextToken(tokens));
-        }
-    }
-
-    Tokenzier::Token ExpectQuotedString(std::deque<Tokenzier::Token>& tokens)
-    {
-        ExpectToken(Tokenzier::eTokenType::eQuote, tokens);
-        Tokenzier::Token text = NextToken(tokens);
-        ExpectTokenType(Tokenzier::eTokenType::eText, text);
-        ExpectToken(Tokenzier::eTokenType::eQuote, tokens);
-        return text;
-    }
-
-    Tokenzier::eTokenType PeekTokenType(const std::deque<Tokenzier::Token>& tokens)
-    {
-        return PeekToken(tokens).Type();
-    }
-
-    void ExpectTokenType(Tokenzier::eTokenType type, const Tokenzier::Token& token)
-    {
-        if (token.Type() != type)
-        {
-            throw Exception("Expected token of type: " + ToString(type) + " but got: " + ToString(token.Type()), token);
-        }
-    }
-
-    void ExpectToken(Tokenzier::eTokenType type, std::deque<Tokenzier::Token>& tokens)
-    {
-        ExpectTokenType(type, NextToken(tokens));
-    }
-
-    void ExpectText(const std::string& expectedText, const Tokenzier::Token& token)
-    {
-        if (token.Type() != Tokenzier::eTokenType::eText)
-        {
-            throw Exception("Expected token of type: " + ToString(Tokenzier::eTokenType::eText) + " but got: " + ToString(token.Type()), token);
-        }
-
-        if (token.AsString() != expectedText)
-        {
-            throw Exception("Expected keyword: " + expectedText + " but got: " + token.AsString(), token);
-        }
-    }
-
-    Tokenzier::Token NextToken(std::deque<Tokenzier::Token>& tokens)
-    {
-        if (tokens.empty())
-        {
-            throw Exception("Expected more tokens before end of input");
-        }
-        Tokenzier::Token ret = tokens.front();
-        tokens.pop_front();
-        return ret;
-    }
-
-    Tokenzier::Token PeekToken(const std::deque<Tokenzier::Token>& tokens)
-    {
-        if (tokens.empty())
-        {
-            throw Exception("Expected more tokens before end of input");
-        }
-        return tokens.front();
-    }
-
-    std::string ToString(Tokenzier::eTokenType type)
-    {
-        std::string ret;
-        switch (type)
-        {
-        case Tokenzier::eTokenType::eArgumentDelmiter:
-            ret = "argument delimiter";
-            break;
-
-        case Tokenzier::eTokenType::eWhiteSpace:
-            ret = "white space";
-            break;
-
-        case Tokenzier::eTokenType::eText:
-            ret = "text";
-            break;
-
-        case Tokenzier::eTokenType::eNumber:
-            ret = "number";
-            break;
-
-        case Tokenzier::eTokenType::eInvalid:
-            ret = "invalid";
-            break;
-
-        case Tokenzier::eTokenType::eOpenBracket:
-            ret = "open bracket";
-            break;
-
-        case Tokenzier::eTokenType::eCloseBracket:
-            ret = "close bracket";
-            break;
-
-        case Tokenzier::eTokenType::eOpenCurlyBracket:
-            ret = "open curly brace";
-            break;
-
-        case Tokenzier::eTokenType::eCloseCurlyBracket:
-            ret = "close curly brace";
-            break;
-
-        case Tokenzier::eTokenType::eQuote:
-            ret = "quote";
-            break;
-
-        case Tokenzier::eTokenType::eEof:
-            ret = "end of file";
-            break;
-
-        default:
-            // Shouldn't actually be possible
-            throw Exception("Unknown token type: " + std::to_string(static_cast<int>(type)));
-        }
-        return ret;
-    }
-
-    Tokenzier mTokenzier;
-    Assembler mAssembler;
-};
-
-TEST(Parser, SimpleScript)
-{
-    Parser p("Entity(\"Testing\") { fn init() { start: NOP REQ 1,2 ;JMPB start\r\n  } fn main() { }  fn script1() { ;IFUB 0, 0, 1, 2, 0, lfalse NOP lfalse:\n  }  } ; Example\n Entity(\"Second\")\n {\n fn\n init()\n {\n }\n }");
-    ASSERT_NO_THROW(p.Parse());
-}
-
-// Parse unknown opcode
-TEST(Parser, UnknownOpcode)
-{
-    Parser p("Entity(\"Testing\") { fn init() { FLUB } } ");
-    ASSERT_THROW(p.Parse(), Parser::UnknownOpCodeException);
-}
-
-// Parse duplicate entity name
-TEST(Parser, DuplicateObjectName)
-{
-    Parser p("Entity(\"Testing\") { fn init() {  } } Entity(\"Testing\") { fn init() {  } } ");
-    ASSERT_THROW(p.Parse(), Parser::DuplicateObjectNameException);
-}
-
-// Parse duplicate function name
-TEST(Parser, DuplicateMethodName)
-{
-    Parser p("Entity(\"Testing\") { fn init() { } fn init() { }  }");
-    ASSERT_THROW(p.Parse(), Parser::DuplicateMethodNameException);
-}
-
-// Parse too many entities
-TEST(Parser, TooManyEntities)
-{
-    std::string strScript;
-    for (int i = 0; i < 32; i++) // TODO: Find out what the actual limit is
-    {
-        const std::string entityName = "Test" + std::to_string(i);
-        const std::string entity = "Entity(\"" +  entityName  + "\") { fn init() { } }";
-        strScript += entity;
-    }
-    Parser p(strScript);
-    ASSERT_THROW(p.Parse(), Parser::TooManyObjectsException);
-}
-
-
-// Parse too many functions
-TEST(Parser, TooManyFunctions)
-{
-    std::string strFunctions;
-    for (int i = 0; i < 31; i++)
-    {
-        strFunctions += "fn test" + std::to_string(i) +"() { NOP NOP } ";
-    }
-
-    Parser p("Entity(\"Testing\") { fn init() { } fn main() { }" + strFunctions  +"}");
-    ASSERT_THROW(p.Parse(), Parser::TooManyMethodsException);
-}
-
-
-// Parse too many arguments
-TEST(Parser, TooManyArguments)
-{
-    {
-        Parser p("Entity(\"Testing\") { fn init() { NOP 1 } }");
-        ASSERT_THROW(p.Parse(), Parser::UnknownOpCodeException);
-    }
-
-    {
-         Parser p("Entity(\"Testing\") { fn init() { REQSW 1,2,3 } }");
-         ASSERT_THROW(p.Parse(), Parser::TooManyArgumentsException);
-    }
-}
-
-
-// Parse not enough arguments
-TEST(Parser, NotEnoughArguments)
-{
-    Parser p("Entity(\"Testing\") { fn init() { REQSW 1 } }");
-    ASSERT_THROW(p.Parse(), Parser::Exception); // Expects , after 1
-}
-
-// Parse argument value out of range
-TEST(Parser, ArgumentOutOfRange)
-{
-    Parser p("Entity(\"Testing\") { fn init() { REQSW 256, 9999999 } }");
-    ASSERT_THROW(p.Parse(), Parser::ArgumentOutOfRangeException);
-}
-
-// Parse duplicated labels
-TEST(Parser, DuplicatedLabels)
-{
-    Parser p("Entity(\"Testing\") { fn init() { label: label: } }");
-    ASSERT_THROW(p.Parse(), Parser::DuplicateLabelException);
-}
-
-// Parse IF
-TEST(Parser, ParseIf)
-{
-    // TODO: Could allow cleaner syntax:
-    //Parser p("Entity(\"Testing\") { fn init() { IFUB Var(1,2) > Var(0,4) foo NOP foo:  } }");
-    Parser p("Entity(\"Testing\") { fn init() { IFUB 1, 0, 20, 30, 1, foo NOP foo: } }");
-    p.Parse();
-}
-
-// Parse IF's with missing labels
-TEST(Parser, ParseIfMissingLabel)
-{
-    Parser p("Entity(\"Testing\") { fn init() { IFUB 1, 0, 20, 30, 1, foo NOP } }");
-    ASSERT_THROW(p.Parse(), Parser::UndefinedLabelException);
-}
-
-// Parse generates warning on unused label
-TEST(Parser, WarnsOnUnusedLabels)
-{
-    // TODO: Not auto checked as writes to std out, it should probably call back to us so we can check
-    Parser p("Entity(\"Testing\") { fn init() { IFUB 1, 0, 20, 30, 1, foo NOP foo: asdf: \nasdsds: \nhello: } }");
-    p.Parse();
-
-}
-
-// Simple assemble / disassemble
-TEST(Parser, AssembleDisassemble)
-{
-    Parser p("Entity(\"Testing\") { fn main() { NOP }  fn init() { NOP } }");
-
-}
-
-// Parse IF's that jump after the if with no "gap"
-/*
-TEST(Parser, ZeroGapIf)
-{
-    Parser p("Entity(\"Testing\") { fn init() { IFUB 1, 0, 20, 30, 1, foo foo: } }");
-    ASSERT_THROW(p.Parse(), Parser::JumpHasNoGap);
-}
-*/
-
-// Parse var length arguments
-
-// Parse double meaning arguments
-
-// Parse all op codes
-
-// Assemble all op codes
-
-// Disassemble all assembled op codes + compare
-
-// Check function ends with RET or JUMPB/JMPBL - is this actually required?
-
-TEST(FF7Field, Asm)
-{
-    DummyFormatter dummy;
-    FieldEngine eng(dummy, "test");
-
-    InstVec insts;
-    FieldDisassembler d(dummy, &eng, insts);
-
-
-}
-

+ 0 - 58
src/installer/decompiler/test/module.mk

@@ -1,58 +0,0 @@
-######################################################################
-# Unit/regression tests, based on CxxTest.
-# Use the 'test' target to run them.
-# Edit TESTS and TESTLIBS to add more tests.
-#
-######################################################################
-
-TESTS        := $(srcdir)/decompiler/test/*.h
-TEST_LIBS    := \
-	common/file.o\
-	decompiler/codegen.o \
-	decompiler/control_flow.o \
-	decompiler/disassembler.o \
-	decompiler/instruction.o \
-	decompiler/simple_disassembler.o \
-	decompiler/value.o \
-	decompiler/scummv6/disassembler.o \
-	decompiler/scummv6/codegen.o \
-	decompiler/scummv6/engine.o \
-	decompiler/kyra/disassembler.o \
-	decompiler/kyra/codegen.o \
-	decompiler/kyra/engine.o \
-	decompiler/test/disassembler/pasc.o \
-	decompiler/test/disassembler/subopcode.o	\
-	decompiler/unknown_opcode.o \
-
-#
-TEST_FLAGS   := --runner=StdioPrinter
-TEST_CFLAGS  := -I$(srcdir)/decompiler/test/cxxtest
-TEST_LDFLAGS := $(decompile_LIBS) $(LDFLAGS)
-
-ifdef HAVE_GCC3
-# In test/common/str.h, we test a zero length format string. This causes GCC
-# to generate a warning which in turn poses a problem when building with -Werror.
-# To work around this, we disable -Wformat here.
-TEST_CFLAGS  +=  -Wno-format
-endif
-
-# Enable this to get an X11 GUI for the error reporter.
-#TEST_FLAGS   += --gui=X11Gui
-#TEST_LDFLAGS += -L/usr/X11R6/lib -lX11
-
-
-test: decompiler/test/runner
-	./decompiler/test/runner
-decompiler/test/runner: decompiler/test/runner.cpp $(TEST_LIBS)
-	$(QUIET_LINK)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TEST_LDFLAGS) $(TEST_CFLAGS) -o $@ $+
-decompiler/test/runner.cpp: $(TESTS)
-	@mkdir -p decompiler
-	@mkdir -p decompiler/test
-	python $(srcdir)/decompiler/test/cxxtest/cxxtestgen.py $(TEST_FLAGS) -o $@ $+
-
-
-clean: clean-test
-clean-test:
-	-$(RM) decompiler/test/runner.cpp decompiler/test/runner
-
-.PHONY: test clean-test

BIN
src/installer/decompiler/test/nested-do-while.dmp


+ 0 - 20
src/installer/decompiler/test/nested-do-while.txt

@@ -1,20 +0,0 @@
-do {
-	var123++;
-	do {
-		var321++;
-	} while (var321 == 42)
-} while (var123 == 18)
-
-do:
-wordVarInc 123
-do2:
-wordVarInc 321
-pushWord 42
-pushWordVar 321
-eq
-jumpTrue do2
-pushWord 18
-pushWordVar 123
-eq
-jumpTrue do
-stopObjectCodeA

BIN
src/installer/decompiler/test/nested-while.dmp


+ 0 - 22
src/installer/decompiler/test/nested-while.txt

@@ -1,22 +0,0 @@
-while (var123 == 18) {
-	while (var321 == 42) {
-		var321++;
-	}
-}
-
-while:
-pushWord 18
-pushWordVar 123
-eq
-jumpTrue postWhile
-while2:
-pushWord 42
-pushWordVar 321
-eq
-jumpTrue postWhile2
-wordVarInc 321
-jump while2
-postWhile2:
-jump while
-postWhile:
-stopObjectCodeA

BIN
src/installer/decompiler/test/nested-while2.dmp


+ 0 - 24
src/installer/decompiler/test/nested-while2.txt

@@ -1,24 +0,0 @@
-while (var123 == 18) {
-	var123++;
-	while (var321 == 42) {
-		var321++;
-	}
-}
-
-while:
-pushWord 18
-pushWordVar 123
-eq
-jumpTrue postWhile
-wordVarInc 123
-while2:
-pushWord 42
-pushWordVar 321
-eq
-jumpTrue postWhile2
-wordVarInc 321
-jump while2
-postWhile2:
-jump while
-postWhile:
-stopObjectCodeA

BIN
src/installer/decompiler/test/short-circuit.dmp


+ 0 - 12
src/installer/decompiler/test/short-circuit.txt

@@ -1,12 +0,0 @@
-do:
-wordVarInc 123
-pushWord 41
-pushWordVar 321
-eq
-jumptrue postWhile
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue do
-postWhile:
-stopObjectCodeA

+ 0 - 1
src/installer/decompiler/test/subopcode_test.bin

@@ -1 +0,0 @@
-��

BIN
src/installer/decompiler/test/unknownopcode_test.bin


BIN
src/installer/decompiler/test/unreachable.dmp


+ 0 - 5
src/installer/decompiler/test/unreachable.txt

@@ -1,5 +0,0 @@
-waitForMessage
-goto lbl_0x6
-stopObjectCodeA
-lbl_0x6:
-stopObjectCodeA

BIN
src/installer/decompiler/test/while-in-do-while.dmp


+ 0 - 20
src/installer/decompiler/test/while-in-do-while.txt

@@ -1,20 +0,0 @@
-do {
-	while (var123 == 18) {
-		var123++
-	}
-} while (var321 == 42)
-
-do:
-while:
-pushWord 18
-pushWordVar 123
-eq
-jumpTrue postWhile
-wordVarInc 123
-jump while
-postWhile:
-pushWord 42
-pushWordVar 321
-eq
-jumpTrue do
-stopObjectCodeA

BIN
src/installer/decompiler/test/while-in-do-while2.dmp


+ 0 - 22
src/installer/decompiler/test/while-in-do-while2.txt

@@ -1,22 +0,0 @@
-do {
-	var321++;
-	while (var123 == 18) {
-		var123++
-	}
-} while (var321 == 42)
-
-do:
-wordVarInc 321
-while:
-pushWord 18
-pushWordVar 123
-eq
-jumpTrue postWhile
-wordVarInc 123
-jump while
-postWhile:
-pushWord 42
-pushWordVar 321
-eq
-jumpTrue do
-stopObjectCodeA

BIN
src/installer/decompiler/test/while.dmp


+ 0 - 9
src/installer/decompiler/test/while.txt

@@ -1,9 +0,0 @@
-while:
-pushWord 42
-pushWordVar 123
-eq
-jumpTrue postWhile
-wordVarInc 123
-jump while
-postWhile:
-stopObjectCodeA

+ 1 - 0
test/CMakeLists.txt

@@ -171,6 +171,7 @@ set(SOURCE_FILES
     installer/SfxDump.cpp
     installer/TexFile.cpp
     installer/VGearsUtility.cpp
+    installer/WindowFonts.cpp
     installer/WorldInstaller.cpp
     installer/common/BinGZipFile.cpp
     installer/common/DrawSkeleton.cpp

+ 1 - 1
test/installer/InstallLogic.cpp

@@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(EmptyDirectoryMissesEverything){
     BOOST_CHECK(!result.Ok());
     for (const char* group : {
       "Configuration", "Game files", "Kernel data", "Battle data", "Battle models", "Field maps", "Field models",
-      "World map", "World map models", "Sound effects", "Music", "Images"
+      "World map", "World map models", "Sound effects", "Music", "Images", "Fonts"
     }) BOOST_CHECK_MESSAGE(HasProblem(result, group), "no problem reported for " << group);
     BOOST_CHECK_GT(result.checked, 0);
 }

+ 169 - 0
test/installer/WindowFonts.cpp

@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include "installer/WindowFonts.h"
+
+namespace{
+
+    void PutU16(std::vector<u8>& data, u32 value){
+        data.push_back(value & 0xFF);
+        data.push_back((value >> 8) & 0xFF);
+    }
+
+    void PutU32(std::vector<u8>& data, u32 value){
+        PutU16(data, value & 0xFFFF);
+        PutU16(data, value >> 16);
+    }
+
+    /**
+     * Builds a 4 bpp TIM with one palette. Pixel (x, y) has index (x + y) % 16.
+     */
+    std::vector<u8> MakeTim(int width, int height){
+        std::vector<u8> data;
+        PutU32(data, 0x10);
+        PutU32(data, 0x08);
+        // Palette block: 16 colours.
+        PutU32(data, 12 + 32);
+        PutU16(data, 0);
+        PutU16(data, 0);
+        PutU16(data, 16);
+        PutU16(data, 1);
+        for (int i = 0; i < 16; i ++) PutU16(data, 0x7FFF);
+        // Image block.
+        PutU32(data, 12 + width * height / 2);
+        PutU16(data, 0);
+        PutU16(data, 0);
+        PutU16(data, width / 4);
+        PutU16(data, height);
+        for (int y = 0; y < height; y ++){
+            for (int x = 0; x < width; x += 2)
+                data.push_back(((x + y) % 16) | (((x + 1 + y) % 16) << 4));
+        }
+        return data;
+    }
+
+    /**
+     * Makes an index image of the size of the WINDOW.BIN textures, filled with one index.
+     */
+    WindowFonts::IndexImage MakeImage(u8 index){
+        WindowFonts::IndexImage image;
+        image.width = 256;
+        image.height = 256;
+        image.pixels.assign(256 * 256, index);
+        return image;
+    }
+
+    /**
+     * Gets a pixel of an RGBA image as a 32 bit value, 0xRRGGBBAA.
+     */
+    u32 Pixel(const WindowFonts::RgbaImage& image, int x, int y){
+        const u8* p = &image.pixels[(y * image.width + x) * 4];
+        return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+    }
+}
+
+BOOST_AUTO_TEST_CASE(WindowFontsReadTim4){
+    const std::vector<u8> tim = MakeTim(16, 4);
+    WindowFonts::IndexImage image;
+    BOOST_REQUIRE(WindowFonts::ReadTim4(tim.data(), tim.size(), image));
+    BOOST_CHECK_EQUAL(image.width, 16);
+    BOOST_CHECK_EQUAL(image.height, 4);
+    for (int y = 0; y < 4; y ++)
+        for (int x = 0; x < 16; x ++) BOOST_CHECK_EQUAL(image.At(x, y), (x + y) % 16);
+    // Outside of the image.
+    BOOST_CHECK_EQUAL(image.At(16, 0), 0);
+    BOOST_CHECK_EQUAL(image.At(0, -1), 0);
+}
+
+BOOST_AUTO_TEST_CASE(WindowFontsReadTim4Invalid){
+    WindowFonts::IndexImage image;
+    std::vector<u8> tim = MakeTim(16, 4);
+    // Truncated.
+    BOOST_CHECK(!WindowFonts::ReadTim4(tim.data(), tim.size() - 1, image));
+    // 8 bpp.
+    tim[4] = 0x09;
+    BOOST_CHECK(!WindowFonts::ReadTim4(tim.data(), tim.size(), image));
+    // Not a TIM.
+    tim[0] = 0x11;
+    BOOST_CHECK(!WindowFonts::ReadTim4(tim.data(), tim.size(), image));
+}
+
+BOOST_AUTO_TEST_CASE(WindowFontsTextFont){
+    WindowFonts::IndexImage font = MakeImage(0);
+    font.pixels[0] = 3;
+    font.pixels[1] = 1;
+    font.pixels[2] = 2;
+    const WindowFonts::RgbaImage image = WindowFonts::BuildTextFont(font);
+    BOOST_CHECK_EQUAL(image.width, 256);
+    BOOST_CHECK_EQUAL(image.height, 256);
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 0), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 1, 0), 0x202020FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 2, 0), 0x00000000);
+    BOOST_CHECK_EQUAL(Pixel(image, 3, 0), 0x00000000);
+}
+
+BOOST_AUTO_TEST_CASE(WindowFontsMenuFont){
+    WindowFonts::IndexImage window = MakeImage(1);
+    // Shadow on the first row of the second glyph row.
+    for (int x = 128; x < 256; x ++) window.pixels[160 * 256 + x] = 15;
+    const WindowFonts::RgbaImage image = WindowFonts::BuildMenuFont(window);
+    BOOST_CHECK_EQUAL(image.width, 128);
+    BOOST_CHECK_EQUAL(image.height, 256);
+    // Each 8 pixel row goes to the lower half of a 16 pixel slot.
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 7), 0x00000000);
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 8), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 127, 15), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 5, 24), 0x181818FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 5, 25), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 191), 0xE6E6E6FF);
+    // The last four slots are empty.
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 200), 0x00000000);
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 255), 0x00000000);
+}
+
+BOOST_AUTO_TEST_CASE(WindowFontsDigitsFont){
+    WindowFonts::IndexImage window = MakeImage(0);
+    window.pixels[0 * 256 + 136] = 1; // '0'
+    window.pixels[3 * 256 + 215] = 15; // '9', last column.
+    window.pixels[240 * 256 + 137] = 1; // '-'
+    window.pixels[216 * 256 + 152] = 1; // '+'
+    window.pixels[232 * 256 + 152] = 1; // '%'
+    window.pixels[232 * 256 + 168] = 1; // ':'
+    window.pixels[0 * 256 + 216] = 1; // After the digits, not copied.
+    const WindowFonts::RgbaImage image = WindowFonts::BuildDigitsFont(window);
+    BOOST_CHECK_EQUAL(image.width, 128);
+    BOOST_CHECK_EQUAL(image.height, 8);
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 0), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 79, 3), 0x181818FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 80, 0), 0x00000000);
+    BOOST_CHECK_EQUAL(Pixel(image, 89, 0), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 96, 0), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 104, 0), 0xE6E6E6FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 112, 0), 0xE6E6E6FF);
+}
+
+BOOST_AUTO_TEST_CASE(WindowFontsTimerFont){
+    WindowFonts::IndexImage window = MakeImage(2);
+    window.pixels[80 * 256 + 144] = 13;
+    const WindowFonts::RgbaImage image = WindowFonts::BuildTimerFont(window);
+    BOOST_CHECK_EQUAL(image.width, 128);
+    BOOST_CHECK_EQUAL(image.height, 48);
+    BOOST_CHECK_EQUAL(Pixel(image, 0, 0), 0x292929FF);
+    BOOST_CHECK_EQUAL(Pixel(image, 1, 0), 0xFF00FFFF);
+    BOOST_CHECK_EQUAL(Pixel(image, 111, 47), 0xFF00FFFF);
+    // Past the right edge of the texture.
+    BOOST_CHECK_EQUAL(Pixel(image, 112, 0), 0x000000FF);
+}