Anonymous

Changes

From Final Fantasy Inside

FF7/Battle/Battle Scenes/Battle Script

1,630 bytes added, 05:10, 23 May 2019
m
20 revisions imported
There are four actions to be explained when dealing with any opcode in AI script: Arguments, Values to take from the stack, what to do with Arguments and Values, and what to put back on the stack. So to fully understand what is happening a brief explanation of the stack is necessary.
The stack is more-or-less a list of values with different lengths. Only the top of the stack (the most recently added value) can be accessed at any given time, but when that value is accessed it leaves is removed from the top of the stack and the previously added value now becomes the top of the stack. Adding to the stack is called "Pushing" a value and taking a value off is called "Popping". When pushing a value to the stack, the value of the number is pushed followed by the value type. The value type can be one of three different things:
<br/>
<br/>
|-
| align="center" | 1Xh
| [[FF7/Battle/Battle_Scenes/Battle_AI_Addresses| Address]]
|-
| align="center" | 2Xh
|}
<br/>
They are stored as DWords, but the X will determine how many bytes to use: 0 = bit, 1 = Byte, 2 = Word, 3 = DWordThree bytes
Now that we've seen the stack, here are the opcodes:
|-
| 0Xh
| 2 byte Memory Address
|
| Type 0X stored at translated Address
|-
| 1Xh
| 2 byte Memory Address
|
| Argument Type 1XAddress value with a scope of X
|-
! style="background:rgb(224,224,224)" align="center" colspan = "4" | Mathematical and Bit-wise Operators
|-
| 60h
| One Byte1 byte Value
|
| Argument of type 01
|-
| 61h
| Two Bytes2 byte Value
|
| Argument of type 02
|-
| 62h
| Four Bytes3 byte Value
|
| Argument of type 03
|-
! style="background:rgb(224,224,224)" align="center" colspan = "4" | Script Jumps(No Pushes)
|-
| 70h
| Two Bytes2 byte Script Address
| One of any type
| Jumps to script address in argument if pop is 0
|-
| 71h
| Two Bytes2 byte Script Address
| One of any type
| Jumps to script address in argument if pop and top of stack are not equal
|-
| 72h
| Two Bytes2 byte Script Address
|
| Jumps to script address in argument
|-
| 74h
|
| One of any type
| Pops one value from stack. (Not used)
|-
| 75h
| 80h
|
| One of type 0X or 2X, One Two of any type| First pop ANDed with masked by second pop.
|-
| 81h
|
| One of any type
| If pop is Type 01, Type 01 with count of number of bits set in pop<br/>If pop is Type 02, Type 02 filled with value of first non-null value in pop
|-
| 84h
| Type 02 with only bit in pop turned on (1 << [pop])
|-
|}<p>&nbsp;</p>{| border="1" cellspacing="1" cellpadding="3" align="center" style="border: 1px solid black; border-collapse: collapse;"! style="background:rgb(204,204,204)" align="center" colspan = "4" | Command |-! style="background:rgb(224,224,224)" align="center" | Code! style="background:rgb(224,224,224)" align="center" colspan | Arguments! style="background:rgb(224,224,224)" align= "3center" | CommandsValue(s) to pop
! style="background:rgb(224,224,224)" align="center" | Effect
|-
|
| One of any type
| Pops variable one value from stack.
|-
| 92h
|
| Two of any type
| First pop is attack ID to perform. Second pop action type (0x20 - enemy attack or 0x24 - display string)<br>
|-
| 93h
| NULL terminated string
| colspan="2" align = "center"| Displays string
|-
| 94h
|
| One of type 1X, one of type 00
| If second pop is 1, takes value at local address 2010 and writes value at [[FF7/Savemap#Save_Memory_Bank_1.2F2|memory bank1bank 1/2 ]] at offset specified by first pop<br/> otherwise If second pop is 0, data at memory bank1/2 at offset specified by first pop is stored at local address 2010.<br/>Otherwise, command is ignored.
|-
| 96h
|-
| A1h
| ?| ?Two values of any type| ?Pops two values from stack (Not Used, but valid command)
|-
|}
<br/>
GENERAL NOTES:
*Commands Command 90h and 95h are is overloaded.
*If a type 2X is popped and any type is accepted, only the first value will be considered.
*If specific type is expected and that type is not available, the game with either crash or ignore that entire line.
*TRUE and FALSE are stored as type 00 as '1' and '0' respectively.
*Commands 74h and A1h are never used, but have been documented as valid commands.
*Commands 75h and 96h only appear in the Character AI found in the KERNEL.BIN.
*Commands of group 2X, BX, CX, DX, EX, and FX are treated as NOPs. The script will ignore them and continue processing. Also, any 5X, 6X, 7X, 8X, and 9X value that isn't listed above appear to be treated the same way, but it's safest to use a value from the 2X group. An incorrect 0X, 1X, 3X, or 4X will have unintended side-effects.
 
0X & 1X CODES NOTES:
*Valid values for X are 0, 1, 2, and 3.
**These will store a bit, byte, word, and dword respectively.
3X CODES NOTES:
The pushed value is, thus, the MP cost of the defined ability as a type 02. Note that 0x00 to 0xFF are standard magic and always loaded, while 0x100+ are the unique abilities loaded through scene.bin.
 
92 CODE NOTES:
*Second pop must be one of the following:
:[[FF7/Command_data|Command index]] in case of character AI
:20h - For enemy attack
:22h - Force execution of script (referenced by first pop)
:24h - Pauses battle engine while string is displayed (in conjunction with code 93)