V-Gears 0
Free Final Fantasy VII engine.
FieldControlFlowInstruction Class Reference

A script flow control instruction. More...

#include <FieldControlFlowInstruction.h>

Inheritance diagram for FieldControlFlowInstruction:
Collaboration diagram for FieldControlFlowInstruction:

Public Member Functions

virtual void ProcessInst (Function &func, ValueStack &stack, Engine *engine, CodeGenerator *code_gen) override
 Processes the instruction. More...
 
- Public Member Functions inherited from KernelCallInstruction
virtual bool IsKernelCall () const
 Checks if the instruction is a call to a kernel function. More...
 
- Public Member Functions inherited from Instruction
virtual std::ostream & Print (std::ostream &output) const
 Print the instruction to a stream. More...
 
virtual bool IsJump () const
 Checks if the instruction is a jump of some sort. More...
 
virtual bool IsCondJump () const
 Checks if the instruction is a conditional jump. More...
 
virtual bool IsUncondJump () const
 Checks if the instruction is an unconditional jump. More...
 
virtual bool IsStackOp () const
 Checks if the instruction is a stack operation. More...
 
virtual bool IsFuncCall () const
 Checks if the instruction is a call to a script function. More...
 
virtual bool IsReturn () const
 Checks if the instruction is a return statement. More...
 
virtual bool IsKernelCall () const
 Checks if the instruction is a call to a kernel function. More...
 
virtual bool IsLoad () const
 Checks if the instruction is a load operation. More...
 
virtual bool IsStore () const
 Checks if the instruction is a store operation. More...
 
virtual uint32 GetDestAddress () const
 Returns the destination address of a jump instruction. More...
 
virtual void ProcessInst (Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen)=0
 Process an instruction for code generation. More...
 
uint32 GetOpcode () const
 Retrieves the instruction opcode. More...
 
void SetOpcode (uint32 opcode)
 Sets the instruction opcode. More...
 
uint32 GetAddress () const
 Retrieves the instruction address. More...
 
void SetAddress (uint32 address)
 Sets the instruction address. More...
 
std::string GetName () const
 Retrieves the instruction name (the opcode name). More...
 
void SetName (std::string name)
 
int16 GetStackChange () const
 Checks how much the instruction changes the stack pointer. More...
 
void SetStackChange (int16 stack_change)
 Defines how much the instruction changes the stack pointer. More...
 
std::vector< ValuePtrGetParams () const
 Retrieves the list of instruction parameters. More...
 
ValuePtr GetParam (uint32 index) const
 Retrieves a instruction parameter. More...
 
void SetParams (std::vector< ValuePtr > params)
 Sets the instructions parameters. More...
 
void AddParam (ValuePtr value)
 Adds a parameter to the instructions. More...
 
std::string GetCodeGenData () const
 Retrieves metadata for code generation. More...
 
void SetCodeGenData (std::string code_gen_data)
 Sets metadata for code generation. More...
 
bool LabelRequired () const
 Checks if the instruction requires a label. More...
 
void SetLabelRequired (bool required)
 Indicates if the instruction needs a label. More...
 

Static Public Member Functions

static InstPtr Create ()
 Create a FieldControlFlowInstruction. More...
 

Private Member Functions

void ProcessREQ (CodeGenerator *code_gen, const FieldEngine &engine)
 Processes a REQ command. More...
 
void ProcessREQSW (CodeGenerator *code_gen, const FieldEngine &engine)
 Processes a REQSW command. More...
 
void ProcessREQEW (CodeGenerator *code_gen, const FieldEngine &engine)
 Processes a REQEW command. More...
 
void ProcessRETTO (CodeGenerator *code_gen)
 Processes a RETTO command. More...
 
void ProcessWAIT (CodeGenerator *code_gen)
 Processes a WAIT command. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Instruction
static int INST_TYPE_BINARY_OP
 Binary operation (e.g. More...
 
static int INST_TYPE_BOOL_NEGATE
 Boolean negation. More...
 
static int INST_TYPE_CALL
 Regular function call. More...
 
static int INST_TYPE_COND_JUMP
 Conditional jump. More...
 
static int INST_TYPE_DUP
 Instruction duplicates the most recent stack entry. More...
 
static int INST_TYPE_JUMP
 Unconditional jump. More...
 
static int INST_TYPE_KERNEL_CALL
 Kernel functions. More...
 
static int INST_TYPE_LOAD
 Load value from memory. More...
 
static int INST_TYPE_RETURN
 Return from regular function call. More...
 
static int INST_TYPE_STACK
 Stack allocation or deallocation (altering stack pointer). More...
 
static int INST_TYPE_STORE
 Store value in memory. More...
 
static int INST_TYPE_UNARY_OP_PRE
 Unary operation (e.g. More...
 
static int INST_TYPE_UNARY_OP_POST
 Unary operation with operator placed after the operator. More...
 
- Protected Member Functions inherited from RefCounted
 RefCounted ()
 
virtual ~RefCounted ()
 
- Protected Attributes inherited from Instruction
uint32 opcode_
 The instruction opcode. More...
 
uint32 address_
 The instruction address. More...
 
std::string name_
 The instruction name (opcode name). More...
 
int16 stack_change_
 How much this instruction changes the stack pointer by. More...
 
std::vector< ValuePtrparams_
 Array of parameters used for the instruction. More...
 
std::string code_gen_data_
 String containing metadata for code generation. More...
 
bool label_required_ = false
 Indicates if a label is required. More...
 

Detailed Description

A script flow control instruction.

Member Function Documentation

◆ Create()

InstPtr FieldControlFlowInstruction::Create ( )
static

Create a FieldControlFlowInstruction.

Returns
Pointer to the newly created instruction.

◆ ProcessInst()

void FieldControlFlowInstruction::ProcessInst ( Function func,
ValueStack stack,
Engine engine,
CodeGenerator code_gen 
)
overridevirtual

Processes the instruction.

Parameters
[in]funcFunction to process.
[out]stackFunction stack.
[in]engineEngine.
[in]code_genCode generator.

Implements Instruction.

◆ ProcessREQ()

void FieldControlFlowInstruction::ProcessREQ ( CodeGenerator code_gen,
const FieldEngine engine 
)
private

Processes a REQ command.

Opcode: 0x01 Short name: REQ Long name: Request remote execution (asynchronous,non-guaranteed)

Memory layout (3 bytes) |0x01|E|P/F|

Arguments

  • const UByte E: The ID of the target entity.
  • const Bit[3] P: The priority at which we want to execute the remote script (high 3 bits of byte).
  • const Bit[5] F: The ID of the specific member function of E to be executed (low 5 bits of byte).

Requests that a remote entity executes one of its member functions at a specified priority. The request is asynchronous and returns immediately without waiting for the remote execution to start or finish. If the specified priority is already busy executing, the request will fail silently.

Parameters
[in,out]code_genCode generator to append lines.
[in]engineThe engine.

◆ ProcessREQEW()

void FieldControlFlowInstruction::ProcessREQEW ( CodeGenerator code_gen,
const FieldEngine engine 
)
private

Processes a REQEW command.

Opcode: 0x03 Short name: REQEW Long name: Request remote execution (synchronous, guaranteed)

Memory layout (3 bytes) |0x03|E|P/F|

Arguments

  • const UByte E: The ID of the target entity.
  • const Bit[3] P: The priority at which we want to execute the remote script (high 3 bits of byte).
  • const Bit[5] F: The ID of the specific member function of E to be executed (low 5 bits of byte).

Requests that a remote entity executes one of its member functions at a specified priority. The request will block until remote execution has finished before returning.

Parameters
[in,out]code_genCode generator to append lines.
[in]engineThe engine.

◆ ProcessREQSW()

void FieldControlFlowInstruction::ProcessREQSW ( CodeGenerator code_gen,
const FieldEngine engine 
)
private

Processes a REQSW command.

Opcode: 0x02 Short name: REQSW Long name: Request remote execution (asynchronous execution, guaranteed)

Memory layout (3 bytes) |0x02|E|P/F|

Arguments

  • const UByte E: The ID of the target entity.
  • const Bit[3] P: The priority at which we want to execute the remote script (high 3 bits of byte).
  • const Bit[5] F: The ID of the specific member function of E to be executed (low 5 bits of byte).

Requests that a remote entity executes one of its member functions at a specified priority. If the specified priority is already busy executing, the request will block until it becomes available and only then return. The remote execution is still carried out asynchronously, with no notification of completion.

Parameters
[in,out]code_genCode generator to append lines.
[in]engineThe engine.

◆ ProcessRETTO()

void FieldControlFlowInstruction::ProcessRETTO ( CodeGenerator code_gen)
private

Processes a RETTO command.

Opcode: 0x07 Short name: RETTO Long name: Return To

Memory layout (2 bytes) |0x07|P/F|

Arguments

  • const Bit[3] P: The priority at which we want to execute the remote script (high 3 bits of byte).
  • const Bit[5] F: The ID of the specific member function of the current entity to be executed to (low 5 bits of byte).

Stops the active script loop for this entity and also any script loops (except the main) that are queuing to be executed after the current script. This is essentially the same as adding a RET onto each of the active / queued scripts next execution position and returning the current op index to index for each script. Then the script control is passed to the script F within the current entity with the priority P.

Parameters
[in,out]code_genCode generator to append lines.

◆ ProcessWAIT()

void FieldControlFlowInstruction::ProcessWAIT ( CodeGenerator code_gen)
private

Processes a WAIT command.

Opcode: 0x24 Short name: WAIT Long name: Wait

Memory layout (2 bytes) |0x24|A|

Arguments

  • const UShort A: Amount (number of frames) to wait.

Pauses current script execution for a specific amount of time. Rather than a specific time value in milliseconds/seconds, the amount specifies the number of frames that must be drawn before execution resumes. Since the game runs at 30fps, WAIT(0x1E) (or WAIT(30) in decimal) will pause script execution for 1 second, WAIT(0x96) will pause for 5 seconds, and so on.

Parameters
[in,out]code_genCode generator to append lines.

The documentation for this class was generated from the following files: