Difference between revisions of "User:Mddass/Touhou File Format Specification/ECL"

From Touhou Wiki
Jump to navigation Jump to search
(Main Instruction Table)
Line 225: Line 225:
 
This list below lists the opcode, mnemonic/name, format and a description for each main ECL instruction used in the subroutines section of the ECL file.
 
This list below lists the opcode, mnemonic/name, format and a description for each main ECL instruction used in the subroutines section of the ECL file.
  
Certain things might be game-specific. In which case, they will have a specific text color. This game-specific stuff will apply to the  game that the color corresponds to, as well as any games afterwards. Color code:
+
Certain things might be game-specific. In which case, they will have a specific color. This game-specific stuff will apply to the  game that the color corresponds to, as well as any games afterwards. The only exception to this rule is EoSD (th06), whose color ONLY applies to that game. Color code:
 
* {{User:Mddass/GAME_COLOR_TEXT| EoSD (th06): Dark red. |6}}
 
* {{User:Mddass/GAME_COLOR_TEXT| EoSD (th06): Dark red. |6}}
 
* {{User:Mddass/GAME_COLOR_TEXT| PCB (th07): Medium violet red. |7}}
 
* {{User:Mddass/GAME_COLOR_TEXT| PCB (th07): Medium violet red. |7}}
Line 232: Line 232:
 
* {{User:Mddass/GAME_COLOR_TEXT| StB (th095): Saddle brown. |95}}
 
* {{User:Mddass/GAME_COLOR_TEXT| StB (th095): Saddle brown. |95}}
 
<div style="font-family:monospace;font-size:12px;">
 
<div style="font-family:monospace;font-size:12px;">
{| border="1"
+
{| border="1" class="sortable"
 
|-
 
|-
 
!style="background-color:papayawhip;"|Name
 
!style="background-color:papayawhip;"|Name
Line 238: Line 238:
 
!style="background-color:papayawhip;"|Format
 
!style="background-color:papayawhip;"|Format
 
!style="background-color:papayawhip;"|Description
 
!style="background-color:papayawhip;"|Description
|-
+
{{User:Mddass/ECL_TABLE_ROW|nop|0x0000 (0)|void|No operation.}}
|nop
+
{{User:Mddass/ECL_TABLE_ROW|delete|0x0001 (1)|{{User:Mddass/GAME_COLOR_TEXT|int a|6}}
|0
+
void|{{User:Mddass/GAME_COLOR_TEXT|Stop script execution on this enemy and delete it if a {{=}}{{=}} 1.|6}}
|void
+
Stop script execution on this enemy and delete it.}}
|No operation.
+
{{User:Mddass/ECL_TABLE_ROW|jmp|0x0002 (2)
|-
+
{{User:Mddass/GAME_COLOR_TEXT|0x0004 (4)|8}}|int t, int cp|Unconditionally sets current time to t and sets the current seek offset in this function to cp.}}
|delete
+
{{User:Mddass/ECL_TABLE_ROW|jmp_ex|0x0003 (3)
|1
+
{{User:Mddass/GAME_COLOR_TEXT|0x0005 (5)|8}}|int t, int cp, int& var|If var !{{=}} 0, sets current time to t, sets the current seek offset in this function to cp and decrements var by 1.}}
|<span style="color:darkred;">int a</span>
+
{{User:Mddass/ECL_TABLE_ROW|iset|0x0004 (4)
<span style="color:mediumvioletred;">void</span>
+
{{User:Mddass/GAME_COLOR_TEXT|0x0006 (6)|8}}|int &var, int a|Sets var to a. Equiv.: var {{=}} a}}
|<span style="color:darkred;">Stop script execution on this enemy and delete it if a == 1.</span>
+
{{User:Mddass/ECL_TABLE_ROW|fset|0x0005 (5)
<span style="color:mediumvioletred;">Stop script execution on this enemy and delete it.</span>
+
{{User:Mddass/GAME_COLOR_TEXT|0x0007 (7)|8}}|int &var, float a
|-
+
{{User:Mddass/GAME_COLOR_TEXT|float &var, float a|7}}|Sets var to a.}}
|jmp
+
{{User:Mddass/ECL_TABLE_ROW|iset_r|0x0006 (6)|int &var, int a|Sets var to a random value in the range [0, a). Equiv.: var {{=}} rand()}}
|2
+
% a
<span style="color:OrangeRed;">4</span>
+
{{User:Mddass/ECL_TABLE_ROW|iset_r2|0x0007 (6)|int &var, int min, int a|Sets var to a random value in the range [min, min+a). Equiv.: var {{=}} rand()}}
|int t, int cp
+
% a + min
|Unconditionally sets current time to t and sets the current seek offset in this function to cp.
+
{{User:Mddass/ECL_TABLE_ROW|fset_r|0x0008 (8)|int &var, float a
|-
+
{{User:Mddass/GAME_COLOR_TEXT|int &var, float a|7}}|Sets var to a random value in the range [0, a).}}
|jmp_ex
+
{{User:Mddass/ECL_TABLE_ROW|fset_r2|0x0009 (9)|int &var, float min, float a
|3
+
{{User:Mddass/GAME_COLOR_TEXT|int &var, float min, float a|7}}|Sets var to a random value in the range [min, min+a).}}
<span style="color:OrangeRed;">5</span>
+
{{User:Mddass/ECL_TABLE_ROW|get_x|0x000A (10)|int &var|Sets var to the enemy's x-position.}}
|int t, int cp, int& var
+
{{User:Mddass/ECL_TABLE_ROW|get_y|0x000B (11)|int &var|Sets var to the enemy's y-position.}}
|If var != 0, sets current time to t, sets the current seek offset in this function to cp and decrements var by 1.
+
{{User:Mddass/ECL_TABLE_ROW|get_z|0x000C (12)|int &var|Sets var to the enemy's z-position.}}
|-
+
{{User:Mddass/ECL_TABLE_ROW|iadd|0x000D (13)|int &var, int l, int r|Sets var to the result of l + r. Equiv.: var {{=}} l + r}}
|iset
+
{{User:Mddass/ECL_TABLE_ROW|isub|0x000E (14)|int &var, int l, int r|Sets var to the result of l - r. Equiv.: var {{=}} l - r}}
|4
+
{{User:Mddass/ECL_TABLE_ROW|imul|0x000F (15)|int &var, int l, int r|Sets var to the result of l * r. Equiv.: var {{=}} l * r}}
<span style="color:OrangeRed;">6</span>
+
{{User:Mddass/ECL_TABLE_ROW|idiv|0x0010 (16)|int &var, int l, int r|Sets var to the result of l / r. Equiv.: var {{=}} l / r}}
|int &var, int a
+
{{User:Mddass/ECL_TABLE_ROW|imod|0x0011 (17)|int &var, int l, int r|Sets var to the result of l}}
|Sets var to a. Equiv.: var = a
+
% r. Equiv.: var {{=}} l % r
|-
+
{{User:Mddass/ECL_TABLE_ROW|inc|0x0012 (18)|int &var|Increment var by 1.}}
|fset
+
{{User:Mddass/ECL_TABLE_ROW|dec|0x0013 (19)|int &var|Decrement var by 1.}}
|5
+
{{User:Mddass/ECL_TABLE_ROW|fadd|0x0014 (20)|int &var, float l, float r|Sets var to the result of l + r. Equiv.: var {{=}} l + r}}
<span style="color:OrangeRed;">7</span>
+
{{User:Mddass/ECL_TABLE_ROW|fsub|0x0015 (21)|int &var, float l, float r|Sets var to the result of l - r. Equiv.: var {{=}} l - r}}
|int &var, float a
+
{{User:Mddass/ECL_TABLE_ROW|fmul|0x0016 (22)|int &var, float l, float r|Sets var to the result of l * r. Equiv.: var {{=}} l * r}}
<span style="color:mediumvioletred;">float &var, float a</span>
+
{{User:Mddass/ECL_TABLE_ROW|fdiv|0x0017 (23)|int &var, float l, float r|Sets var to the result of l / r. Equiv.: var {{=}} l / r}}
|Sets var to a.
+
{{User:Mddass/ECL_TABLE_ROW|fmod|0x0018 (24)|int &var, float l, float r|Sets var to the result of l}}
|-
+
% r. Equiv.: var {{=}} l % r
|iset_r
+
{{User:Mddass/ECL_TABLE_ROW|atan2|0x0019 (25)|int &var, float ox, float oy, float tx, float ty|Sets var to the result of atan2(tx - ox, ty - oy). Effectively gives the angle towards tx,ty with ox,oy as the origin.}}
|6
+
{{User:Mddass/ECL_TABLE_ROW|norm_r|0x001A (26)|int &var|Normalizes var into a value that's within the (-pi, pi) range. var will be reduced by 2*pi until it is within that range if it is greater than pi, or incresed by 2*pi until it is within that range if it is lower than pi.}}
|int &var, int a
+
{{User:Mddass/ECL_TABLE_ROW|itest|0x001B (27)|int a, int b|Compares a with b (integer values). The result will be stored in the enemy's comparison register. The result is -1 if a < b, 0 if a {{=}}{{=}} b or 1 if a > b.}}
|Sets var to a random value in the range [0, a). Equiv.: var = rand() % a
+
{{User:Mddass/ECL_TABLE_ROW|ftest|0x001C (28)|float a, float b|Compares a with b (floating-point values). The result will be stored in the enemy's comparison register. The result is -1 if a < b, 0 if a {{=}}{{=}} b or 1 if a > b.}}
|-
+
{{User:Mddass/ECL_TABLE_ROW|jmp_l|0x001D (29)|int t, int cp|If the comparison register is -1, sets current time to t and sets the current seek offset in this function to cp.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|iset_r2
+
{{User:Mddass/ECL_TABLE_ROW|jmp_le|0x001E (30)|int t, int cp|If the comparison register is -1 or 0, sets current time to t and sets the current seek offset in this function to cp.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|7
+
{{User:Mddass/ECL_TABLE_ROW|jmp_e|0x001F (31)|int t, int cp|If the comparison register is 0, sets current time to t and sets the current seek offset in this function to cp.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|int &var, int min, int a
+
{{User:Mddass/ECL_TABLE_ROW|jmp_g|0x0020 (32)|int t, int cp|If the comparison register is 1, sets current time to t and sets the current seek offset in this function to cp.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|Sets var to a random value in the range [min, min+a). Equiv.: var = rand() % a + min
+
{{User:Mddass/ECL_TABLE_ROW|jmp_ge|0x0021 (33)|int t, int cp|If the comparison register is 1 or 0, sets current time to t and sets the current seek offset in this function to cp.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|-
+
{{User:Mddass/ECL_TABLE_ROW|jmp_n|0x0022 (34)|int t, int cp|If the comparison register is -1 or 1, sets current time to t and sets the current seek offset in this function to cp.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|fset_r
+
{{User:Mddass/ECL_TABLE_ROW|call|0x0023 (35)|int func, int iarg, float farg|Copies variables -10001 to -10012 to backup registers and calls function func. Also, -10001 is set to iarg and -10005 is set to farg.}}
|8
+
{{User:Mddass/ECL_TABLE_ROW|return|0x0024 (36)|void|Returns to the parent function and copies variables -10001 to -10012 from the backup registers. Crashes the game if there is no parent function.}}
|int &var, float a
+
{{User:Mddass/ECL_TABLE_ROW|call_l|0x0025 (37)|int func, int iarg, float farg, int a, int b|Runs call(func, iarg, farg) if a < b.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
<span style="color:mediumvioletred;">int &var, float a</span>
+
{{User:Mddass/ECL_TABLE_ROW|call_le|0x0026 (38)|int func, int iarg, float farg, int a, int b|Runs call(func, iarg, farg) if a <{{=}} b.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|Sets var to a random value in the range [0, a).
+
{{User:Mddass/ECL_TABLE_ROW|call_e|0x0027 (39)|int func, int iarg, float farg, int a, int b|Runs call(func, iarg, farg) if a {{=}}{{=}} b.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|-
+
{{User:Mddass/ECL_TABLE_ROW|call_g|0x0028 (40)|int func, int iarg, float farg, int a, int b|Runs call(func, iarg, farg) if a > b.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|fset_r2
+
{{User:Mddass/ECL_TABLE_ROW|call_ge|0x0029 (41)|int func, int iarg, float farg, int a, int b|Runs call(func, iarg, farg) if a >{{=}} b.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|9
+
{{User:Mddass/ECL_TABLE_ROW|call_n|0x002A (42)|int func, int iarg, float farg, int a, int b|Runs call(func, iarg, farg) if a !{{=}} b.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|int &var, float min, float a
+
{{User:Mddass/ECL_TABLE_ROW|dir|0x002B (43)|float x, float y, float z|Sets the enemy position accordingly.}}
<span style="color:mediumvioletred;">int &var, float min, float a</span>
+
{{User:Mddass/ECL_TABLE_ROW||0x002C (44)|float a, float b, float c|Unknown. Sets 3 values in the enemy.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
|Sets var to a random value in the range [min, min+a).
+
{{User:Mddass/ECL_TABLE_ROW|dir|0x002D (45)|float r, float s|Sets enemy movement direction to r and movement speed to s.}}
|-
 
|get_x
 
|10
 
|int &var
 
|Sets var to the enemy's x-position.
 
|-
 
|get_y
 
|11
 
|int &var
 
|Sets var to the enemy's y-position.
 
|-
 
|get_z
 
|12
 
|int &var
 
|Sets var to the enemy's z-position.
 
|-
 
|iadd
 
|13
 
|int &var, int l, int r
 
|Sets var to the result of l + r. Equiv.: var = l + r
 
|-
 
|isub
 
|14
 
|int &var, int l, int r
 
|Sets var to the result of l - r. Equiv.: var = l - r
 
|-
 
|imul
 
|15
 
|int &var, int l, int r
 
|Sets var to the result of l * r. Equiv.: var = l * r
 
|-
 
|idiv
 
|16
 
|int &var, int l, int r
 
|Sets var to the result of l / r. Equiv.: var = l / r
 
|-
 
|imod
 
|17
 
|int &var, int l, int r
 
|Sets var to the result of l % r. Equiv.: var = l % r
 
|-
 
|inc
 
|18
 
|int &var
 
|Increment var by 1.
 
|-
 
|dec
 
|19
 
|int &var
 
|Decrement var by 1.
 
|-
 
|fadd
 
|20
 
|int &var, float l, float r
 
|Sets var to the result of l + r. Equiv.: var = l + r
 
|-
 
|fsub
 
|21
 
|int &var, float l, float r
 
|Sets var to the result of l - r. Equiv.: var = l - r
 
|-
 
|fmul
 
|22
 
|int &var, float l, float r
 
|Sets var to the result of l * r. Equiv.: var = l * r
 
|-
 
|fdiv
 
|23
 
|int &var, float l, float r
 
|Sets var to the result of l / r. Equiv.: var = l / r
 
|-
 
|fmod
 
|24
 
|int &var, float l, float r
 
|Sets var to the result of l % r. Equiv.: var = l % r
 
|-
 
|atan2
 
|25
 
|int &var, float ox, float oy, float tx, float ty
 
|Sets var to the result of atan2(tx - ox, ty - oy). Effectively gives the angle towards tx,ty with ox,oy as the origin.
 
|-
 
|norm_r
 
|26
 
|int &var
 
|Normalizes var into a value that's within the (-pi, pi) range. var will be reduced by 2*pi until it is within that range if it is greater than pi, or incresed by 2*pi until it is within that range if it is lower than pi.
 
|-
 
|itest
 
|27
 
|int a, int b
 
|Compares a with b (integer values). The result will be stored in the enemy's comparison register. The result is -1 if a < b, 0 if a == b or 1 if a > b.
 
|-
 
|ftest
 
|28
 
|float a, float b
 
|Compares a with b (floating-point values). The result will be stored in the enemy's comparison register. The result is -1 if a < b, 0 if a == b or 1 if a > b.
 
|-
 
|jmp_l
 
|29
 
|int t, int cp
 
|If the comparison register is -1, sets current time to t and sets the current seek offset in this function to cp.
 
|-
 
|jmp_le
 
|30
 
|int t, int cp
 
|If the comparison register is -1 or 0, sets current time to t and sets the current seek offset in this function to cp.
 
|-
 
|jmp_e
 
|31
 
|int t, int cp
 
|If the comparison register is 0, sets current time to t and sets the current seek offset in this function to cp.
 
|-
 
|jmp_g
 
|32
 
|int t, int cp
 
|If the comparison register is 1, sets current time to t and sets the current seek offset in this function to cp.
 
|-
 
|jmp_ge
 
|33
 
|int t, int cp
 
|If the comparison register is 1 or 0, sets current time to t and sets the current seek offset in this function to cp.
 
|-
 
|jmp_n
 
|34
 
|int t, int cp
 
|If the comparison register is -1 or 1, sets current time to t and sets the current seek offset in this function to cp.
 
|-
 
|call
 
|35
 
|int func, int iarg, float farg
 
|Copies variables -10001 to -10012 to backup registers and calls function func. Also, -10001 is set to iarg and -10005 is set to farg.
 
|-
 
|return
 
|36
 
|void
 
|Returns to the parent function and copies variables -10001 to -10012 from the backup registers. Crashes the game if there is no parent function.
 
|-
 
|call_l
 
|37
 
|int func, int iarg, float farg, int a, int b
 
|Runs call(func, iarg, farg) if a < b.
 
|-
 
|call_le
 
|38
 
|int func, int iarg, float farg, int a, int b
 
|Runs call(func, iarg, farg) if a <= b.
 
|-
 
|call_e
 
|39
 
|int func, int iarg, float farg, int a, int b
 
|Runs call(func, iarg, farg) if a == b.
 
|-
 
|call_g
 
|40
 
|int func, int iarg, float farg, int a, int b
 
|Runs call(func, iarg, farg) if a > b.
 
|-
 
|call_ge
 
|41
 
|int func, int iarg, float farg, int a, int b
 
|Runs call(func, iarg, farg) if a >= b.
 
|-
 
|call_n
 
|42
 
|int func, int iarg, float farg, int a, int b
 
|Runs call(func, iarg, farg) if a != b.
 
|-
 
|pos
 
|43
 
|float x, float y, float z
 
|Sets the enemy position accordingly.
 
{{User:Mddass/ECL_TABLE_ROW||44|float a, float b, float c|Unknown. Sets 3 values in the enemy.|color={{User:Mddass/GAME_COLOR|text|6}}|bgcolor={{User:Mddass/GAME_COLOR|bg|6}}}}
 
{{User:Mddass/ECL_TABLE_ROW|dir|45|float r, float s|Sets enemy movement direction to r and movement speed to s.}}
 
 
|-
 
|-
 
|}
 
|}
 
</div>
 
</div>

Revision as of 18:21, 17 April 2019

ECL/.ecl files (敵コントロール言語 teki-kontorōru gengo, enemy control language) are compiled scripts (stack-based in V2+) and correspond to the stage enemies in the Touhou games, basically making them the veins and arteries from which the game's blood engine flows. They're responsible for stage enemy timings, bullet patterns, enemy movement, some background (3D) particle effects, boss setup, etc..

Versions[edit]

The ECL format has changed constantly over the years, specially in regards to the functions that it executes. From MoF onwards (version 2), ECL is a stack-based compiled script language.

  • ECL V1: Th06-Th095 - First version of ECL, notable for not using a stack and having timeline sections for stage timing.
  • ECL V2: Th10-Th16 - Complete revamp of the first version. Functions are named now, and introduces the stack system.

Syntax (thtk)[edit]

TBD

Syntax (TSA)[edit]

TBD, there are enough screenshots to know.

Variables (V1)[edit]

These lists are incomplete and are subject to change over time.

Th06: EoSD[edit]

These are the variables that can be used in EoSD ECL. They're very few (just 25), even when compared to its immediate successor: PCB.

  • [-10001]: Local variable (32-bit integer).
  • [-10002]: Local variable (32-bit integer).
  • [-10003]: Local variable (32-bit integer).
  • [-10004]: Local variable (32-bit integer).
  • [-10005.0f]: Local variable (single-precision floating point).
  • [-10006.0f]: Local variable (single-precision floating point).
  • [-10007.0f]: Local variable (single-precision floating point).
  • [-10008.0f]: Local variable (single-precision floating point).
  • [-10009]: Local variable (32-bit integer).
  • [-10010]: Local variable (32-bit integer).
  • [-10011]: Local variable (32-bit integer).
  • [-10012]: Local variable (32-bit integer).
  • [-10013]: Rank (Easy: 0; Normal: 1; Hard: 2; Lunatic: 3; Extra: 4)
  • [-10014]: Difficulty.
  • [-10015.0f]: Self X-position.
  • [-10016.0f]: Self Y-position.
  • [-10017.0f]: Self Z-position.
  • [-10018.0f]: Player X-position.
  • [-10019.0f]: Player Y-position.
  • [-10020.0f]: Player Z-position.
  • [-10021.0f]: Angle to player.
  • [-10022]: Current time.
  • [-10023.0f]: Distance from player.
  • [-10024]: Current life.
  • [-10025]: Shot-type. (ReimuA: 0; MarisaA: 2; etc.)

Th07: PCB (Final)[edit]

The variables that can be used in PCB ECL are much more than that of EoSD ECL. Improvements include more local variables, inheritable variables, randomness variables, movement-related variables, and much more.

  • [10000]: Local variable (32-bit integer).
  • [10001]: Local variable (32-bit integer).
  • [10002]: Local variable (32-bit integer).
  • [10003]: Local variable (32-bit integer).
  • [10004.0f]: Local variable (single-precision floating point).
  • [10005.0f]: Local variable (single-precision floating point).
  • [10006.0f]: Local variable (single-precision floating point).
  • [10007.0f]: Local variable (single-precision floating point).
  • [10008.0f]: Local variable (single-precision floating point).
  • [10009.0f]: Local variable (single-precision floating point).
  • [10010.0f]: Local variable (single-precision floating point).
  • [10011.0f]: Local variable (single-precision floating point).
  • [10012]: Local variable (32-bit integer).
  • [10013]: Local variable (32-bit integer).
  • [10014]: Local variable (32-bit integer).
  • [10015]: Local variable (32-bit integer).
  • [10016]: Rank (Easy: 0; Normal: 1; Hard: 2; Lunatic: 3; Extra: 4; Phantasm: 5)
  • [10017]: Difficulty.
  • [10018.0f]: Self X-position.
  • [10019.0f]: Self Y-position.
  • [10020.0f]: Self Z-position.
  • [10021.0f]: Player X-position.
  • [10022.0f]: Player Y-position.
  • [10023.0f]: Player Z-position.
  • [10024.0f]: Angle to player.
  • [10025]: Current time.
  • [10026.0f]: Distance from player.
  • [10027]: Current life.
  • [10028]: Shot-type. (ReimuA: 0; MarisaA: 2; SakuyaA: 4; etc.)
  • [10029]: Function-wide integer.
  • [10030]: Function-wide integer.
  • [10031]: Function-wide integer.
  • [10032]: Function-wide integer.
  • [10033.0f]: Function-wide float.
  • [10034.0f]: Function-wide float.
  • [10035.0f]: Function-wide float.
  • [10036.0f]: Function-wide float.
  • [10037]: Function-wide integer. When a function is called from this, copied to the function's [-10029].
  • [10038]: Function-wide integer. When a function is called from this, copied to the function's [-10030].
  • [10039]: Function-wide integer. When a function is called from this, copied to the function's [-10031].
  • [10040]: Function-wide integer. When a function is called from this, copied to the function's [-10032].
  • [10041.0f]: Function-wide float. When a function is called from this, copied to the function's [-10033.0f].
  • [10042.0f]: Function-wide float. When a function is called from this, copied to the function's [-10034.0f].
  • [10043.0f]: Function-wide float. When a function is called from this, copied to the function's [-10035.0f].
  • [10044.0f]: Function-wide float. When a function is called from this, copied to the function's [-10036.0f].
  • [10045.0f]: Angle to origin point (orbital movement).
  • [10046.0f]: Rotation speed (orbital movement).
  • [10049.0f]: Distance from origin point (orbital movement).
  • [10050.0f]: Origin point X-coord (orbital movement).
  • [10051.0f]: Origin point Y-coord (orbital movement).
  • [10052.0f]: Origin point Z-coord (orbital movement).
  • [10053.0f]: Unknown float. Used by Yukari's last spell to store some angle. Angle to origin point + pi?
  • [10054.0f]: Current angle.
  • [10055.0f]: Returns a random value between 0.0f and 1.0f.
  • [10056.0f]: Returns a random value between [10034.0f] and [10034.0f] + [10033.0f].
  • [10057.0f]: X-offset to target point.
  • [10058.0f]: Y-offset to target point.
  • [10059.0f]: Z-offset to target point.
  • [10060.0f]: Returns a random radian value.
  • [10061]: Unknown. Used by the Prismrivers.
  • [10062]: Unknown byte. Seems to be some state byte. Used by the Prismrivers.
  • [10066]: Boss life threshold.
  • [10067]: Boss life threshold. What's the difference from [10066]?
  • [10068]: Minimum life. If the enemy life drops down to this, it will immediately be deleted.
  • [10069]: Minimum life. If the enemy life drops down to this, it will immediately be deleted. What's the difference from [10068]?
  • [10070]: Item reward on death.
  • [10071]: Score reward on death.
  • [10072.0f]: Local variable? Used by Yuyuko to store X-offset to spawn bullets from.
  • [10073.0f]: Local variable? Used by Yuyuko to store Y-offset to spawn bullets from.

Variables (V2)[edit]

Note: All variables from MoF onwards carry over to the next games.

Missing variables are either unknown or unused.

Th10: MoF[edit]

  • [-10000]: Random integer value.
  • [-9999.0f]: Random float value from 0.0f to 1.0f.
  • [-9998.0f]: Random value from -pi to pi.
  • [-9997.0f]: Final X-coordinate.
  • [-9996.0f]: Final Y-coordinate.
  • [-9995.0f]: Absolute X-coordinate.
  • [-9994.0f]: Abdolute Y-coordinate.
  • [-9993.0f]: Relative X-coordinate.
  • [-9992.0f]: Relative Y-coordinate.
  • [-9991.0f]: Player X-pos.
  • [-9990.0f]: Player Y-pos.
  • [-9989.0f]: Angle to player (based on current position).
  • [-9988]: Time elapsed (in current sub?)
  • [-9987.0f]: Random float value from -1.0f to 1.0f.
  • [-9986]: Becomes non-null when a timeout occurs.
  • [-9985]: Local variable.
  • [-9984]: Local variable.
  • [-9983]: Local variable.
  • [-9982]: Local variable.
  • [-9981.0f]: Local variable.
  • [-9980.0f]: Local variable.
  • [-9979.0f]: Local variable.
  • [-9978.0f]: Local variable.
  • [-9977.0f]: Same as [-9997.0f].
  • [-9976.0f]: Same as [-9996.0f].
  • [-9975.0f]: Same as [-9995.0f].
  • [-9974.0f]: Same as [-9994.0f].
  • [-9973.0f]: Same as [-9993.0f].
  • [-9972.0f]: Same as [-9992.0f].
  • [-9971.0f]: Absolute current angular direction.
  • [-9970.0f]: Relative current angular direction.
  • [-9969.0f]: Absolute current movement speed.
  • [-9968.0f]: Relative current movement speed.
  • [-9967.0f]: Absolute radius from origin point.
  • [-9966.0f]: Relative radius from origin point.
  • [-9965.0f]: Same as [-9991.0f].
  • [-9964.0f]: Same as [-9990.0f].
  • [-9963.0f]: Boss 0 X-pos.
  • [-9962.0f]: Boss 0 Y-pos.
  • [-9961]: 未知 (地址1120)
  • [-9960]: Game difficulty.
  • [-9959]: Rank. E = 0; N = 1; H = 2; L = 3; X = 4; O = 5.
  • [-9958]: Final angular direction.
  • [-9957]: 1
  • [-9954]: Current life.
  • [-9953]: Easy mode flag.
  • [-9952]: Normal mode flag.
  • [-9951]: Hard mode flag.
  • [-9950]: Lunatic mode flag.

Th11: SA[edit]

  • [-9949]: Miss count
  • [-9948]: Bomb count
  • [-9947]: Becomes null on timeout, miss or bomb (or any other game-specific condition i.e. trance).
  • [-9946]: Amount of units on-screen.
  • [-9945]: Shot type.
  • [-9944.0f]: Distance from player.
  • [-9943]: Boss local variable.
  • [-9942]: Boss local variable.
  • [-9941]: Boss local variable.
  • [-9940]: Boss local variable.
  • [-9939.0f]: Boss local variable.
  • [-9938.0f]: Boss local variable.
  • [-9937.0f]: Boss local variable.
  • [-9936.0f]: Boss local variable.
  • [-9935.0f]: Local variable.
  • [-9934.0f]: Local variable.
  • [-9933.0f]: Local variable.
  • [-9932.0f]: Local variable.

Th12: UFO[edit]

  • [-9931]: 已经出现单位数量-1,包含main
  • [-9930]: Power.

Th12.5: DS[edit]

  • [-9926]: Global variable.
  • [-9925]: Global variable.
  • [-9924]: Global variable.
  • [-9923]: Global variable.
  • [-9922.0f]: Global variable.
  • [-9921.0f]: Global variable.
  • [-9920.0f]: Global variable.
  • [-9919.0f]: Global variable.
  • [-9918.0f]: Global variable.
  • [-9917.0f]: Global variable.
  • [-9916.0f]: Global variable.
  • [-9915.0f]: Global variable.
  • [-9914]: Unit ID.
  • [-9913]: Photo count.
  • [-9911.0f]: Current movement angle.

Th12.8: GFW[edit]

Th13: TD[edit]

  • [-9908]: Killable unit count.
  • [-9907]: Current spell practice spellcard ID.

Th16: HSiFS[edit]

  • [-9903]: Current subseason.

ECL Instruction Table (V1)[edit]

Main Instruction Table[edit]

NOTE: Currently, only EoSD (th06) and PCB (th07) have been properly and thourougly checked. This table will most likely not be accurate for games other than those.

This list below lists the opcode, mnemonic/name, format and a description for each main ECL instruction used in the subroutines section of the ECL file.

Certain things might be game-specific. In which case, they will have a specific color. This game-specific stuff will apply to the game that the color corresponds to, as well as any games afterwards. The only exception to this rule is EoSD (th06), whose color ONLY applies to that game. Color code:

  • EoSD (th06): Dark red.
  • PCB (th07): Medium violet red.
  • IN (th08): Orange red.
  • PoFV (th09): Green.
  • StB (th095): Saddle brown.
Name Opcode Format Description
nop 0x0000 (0) void No operation.
delete 0x0001 (1) int a

void

Stop script execution on this enemy and delete it if a == 1.

Stop script execution on this enemy and delete it.

jmp 0x0002 (2)

0x0004 (4)

int t, int cp Unconditionally sets current time to t and sets the current seek offset in this function to cp.
jmp_ex 0x0003 (3)

0x0005 (5)

int t, int cp, int& var If var != 0, sets current time to t, sets the current seek offset in this function to cp and decrements var by 1.
iset 0x0004 (4)

0x0006 (6)

int &var, int a Sets var to a. Equiv.: var = a
fset 0x0005 (5)

0x0007 (7)

int &var, float a

float &var, float a

Sets var to a.
iset_r 0x0006 (6) int &var, int a Sets var to a random value in the range [0, a). Equiv.: var = rand()

% a

iset_r2 0x0007 (6) int &var, int min, int a Sets var to a random value in the range [min, min+a). Equiv.: var = rand()

% a + min

fset_r 0x0008 (8) int &var, float a

int &var, float a

Sets var to a random value in the range [0, a).
fset_r2 0x0009 (9) int &var, float min, float a

int &var, float min, float a

Sets var to a random value in the range [min, min+a).
get_x 0x000A (10) int &var Sets var to the enemy's x-position.
get_y 0x000B (11) int &var Sets var to the enemy's y-position.
get_z 0x000C (12) int &var Sets var to the enemy's z-position.
iadd 0x000D (13) int &var, int l, int r Sets var to the result of l + r. Equiv.: var = l + r
isub 0x000E (14) int &var, int l, int r Sets var to the result of l - r. Equiv.: var = l - r
imul 0x000F (15) int &var, int l, int r Sets var to the result of l * r. Equiv.: var = l * r
idiv 0x0010 (16) int &var, int l, int r Sets var to the result of l / r. Equiv.: var = l / r
imod 0x0011 (17) int &var, int l, int r Sets var to the result of l

% r. Equiv.: var = l % r

inc 0x0012 (18) int &var Increment var by 1.
dec 0x0013 (19) int &var Decrement var by 1.
fadd 0x0014 (20) int &var, float l, float r Sets var to the result of l + r. Equiv.: var = l + r
fsub 0x0015 (21) int &var, float l, float r Sets var to the result of l - r. Equiv.: var = l - r
fmul 0x0016 (22) int &var, float l, float r Sets var to the result of l * r. Equiv.: var = l * r
fdiv 0x0017 (23) int &var, float l, float r Sets var to the result of l / r. Equiv.: var = l / r
fmod 0x0018 (24) int &var, float l, float r Sets var to the result of l

% r. Equiv.: var = l % r

atan2 0x0019 (25) int &var, float ox, float oy, float tx, float ty Sets var to the result of atan2(tx - ox, ty - oy). Effectively gives the angle towards tx,ty with ox,oy as the origin.
norm_r 0x001A (26) int &var Normalizes var into a value that's within the (-pi, pi) range. var will be reduced by 2*pi until it is within that range if it is greater than pi, or incresed by 2*pi until it is within that range if it is lower than pi.
itest 0x001B (27) int a, int b Compares a with b (integer values). The result will be stored in the enemy's comparison register. The result is -1 if a < b, 0 if a == b or 1 if a > b.
ftest 0x001C (28) float a, float b Compares a with b (floating-point values). The result will be stored in the enemy's comparison register. The result is -1 if a < b, 0 if a == b or 1 if a > b.
jmp_l 0x001D (29) int t, int cp If the comparison register is -1, sets current time to t and sets the current seek offset in this function to cp.
jmp_le 0x001E (30) int t, int cp If the comparison register is -1 or 0, sets current time to t and sets the current seek offset in this function to cp.
jmp_e 0x001F (31) int t, int cp If the comparison register is 0, sets current time to t and sets the current seek offset in this function to cp.
jmp_g 0x0020 (32) int t, int cp If the comparison register is 1, sets current time to t and sets the current seek offset in this function to cp.
jmp_ge 0x0021 (33) int t, int cp If the comparison register is 1 or 0, sets current time to t and sets the current seek offset in this function to cp.
jmp_n 0x0022 (34) int t, int cp If the comparison register is -1 or 1, sets current time to t and sets the current seek offset in this function to cp.
call 0x0023 (35) int func, int iarg, float farg Copies variables -10001 to -10012 to backup registers and calls function func. Also, -10001 is set to iarg and -10005 is set to farg.
return 0x0024 (36) void Returns to the parent function and copies variables -10001 to -10012 from the backup registers. Crashes the game if there is no parent function.
call_l 0x0025 (37) int func, int iarg, float farg, int a, int b Runs call(func, iarg, farg) if a < b.
call_le 0x0026 (38) int func, int iarg, float farg, int a, int b Runs call(func, iarg, farg) if a <= b.
call_e 0x0027 (39) int func, int iarg, float farg, int a, int b Runs call(func, iarg, farg) if a == b.
call_g 0x0028 (40) int func, int iarg, float farg, int a, int b Runs call(func, iarg, farg) if a > b.
call_ge 0x0029 (41) int func, int iarg, float farg, int a, int b Runs call(func, iarg, farg) if a >= b.
call_n 0x002A (42) int func, int iarg, float farg, int a, int b Runs call(func, iarg, farg) if a != b.
dir 0x002B (43) float x, float y, float z Sets the enemy position accordingly.
0x002C (44) float a, float b, float c Unknown. Sets 3 values in the enemy.
dir 0x002D (45) float r, float s Sets enemy movement direction to r and movement speed to s.