GBVM Operations
Core
VM_STOP
VM_STOP
Stops execution of context.
VM_PUSH_CONST
VM_PUSH_CONST VAL
Pushes immediate value to the top of the VM stack.
- VAL: Immediate value to be pushed.
VM_POP
VM_POP N
Removes the top values from the VM stack.
- N: Number of values to be removed from the stack.
VM_CALL
VM_CALL ADDR
Calls script by near address.
- ADDR: Address of the script subroutine.
VM_RET
VM_RET
Returns from the near call.
VM_RET_N
VM_RET_N N
Returns from the near call and clears N arguments on stack.
- N: Number of arguments to be removed from the stack.
VM_GET_FAR
VM_GET_FAR IDX, SIZE, BANK, ADDR
Gets byte or word by the far pointer into variable.
- IDX: Target variable.
- SIZE: Size of the object to be acquired:
.GET_BYTE
- Get 8-bit value.
.GET_WORD
- Get 16-bit value. - BANK: Bank number of the object
- ADDR: Address of the object
VM_LOOP
VM_LOOP IDX, LABEL, N
Loops while variable is not zero, by the near address.
- IDX: Loop counter variable.
- LABEL: Jump label for the next iteration.
- N: Amount of values to be removed from stack on exit.
.CASE
.CASE VAL, LABEL
VM_SWITCH
VM_SWITCH IDX, SIZE, N
Compares variable with a set of values, and if equal, jumps to the specified label.
Values for testing may be defined with the .CASE macro, where VAL parameter is a value for testing and LABEL is a jump label.
- IDX: Variable for compare.
- SIZE: Amount of entries for test.
- N: Amount of values to be cleaned from stack on exit.
VM_JUMP
VM_JUMP LABEL
Jumps to near address.
- ARG0: Jump label.
VM_CALL_FAR
VM_CALL_FAR BANK, ADDR
Calls far routine (inter-bank call).
- BANK: Bank number of the routine.
- ADDR: Address of the routine.
VM_RET_FAR
VM_RET_FAR
Returns from the far call.
VM_RET_FAR_N
VM_RET_FAR_N N
Returns from the far call and removes N arguments from stack.
- N: Number of arguments to be removed from stack.
VM_INVOKE
VM_INVOKE BANK, ADDR, N, PARAMS
Invokes C function until it returns true.
- BANK: Bank number of the function.
- ADDR: Address of the function, currently 2 functions are implemented:
_wait_frames
- Wait for N vblank intervals.
_camera_shake
- Shake camera N times. - N: Number of arguments to be removed from stack on return.
- PARAMS: Points the first parameter to be passed into the C function.
VM_BEGINTHREAD
VM_BEGINTHREAD BANK, THREADPROC, HTHREAD, NARGS
Spawns a thread in a separate context.
- BANK: Bank number of a thread function.
- THREADPROC: Address of a thread function.
- HTHREAD: Variable that receives the thread handle.
- NARGS: Amount of values from the stack to be copied into the stack of the new context.
VM_IF
VM_IF CONDITION, IDXA, IDXB, LABEL, N
Compares two variables using for condition.
- CONDITION: Condition for test:
.EQ
- Variables are equal.
.LT
- A is lower than B.
.LTE
- A is lower or equal than B.
.GT
- A is greater than B.
.GTE
- A is greater or equal than B.
.NE
- A is not equal to B. - IDXA: A variable.
- IDXB: B variable.
- LABEL: Jump label when result is TRUE.
- N: Number of values to be removed from stack after evaluating the condition.
VM_PUSH_VALUE_IND
VM_PUSH_VALUE_IND IDX
Pushes a value on VM stack or a global indirectly from an index in the variable.
- IDX: Variable that contains the index of the variable to be pushed on stack.
VM_PUSH_VALUE
VM_PUSH_VALUE IDX
Pushes a value of the variable onto stack.
- IDX: Variable to be pushed.
VM_RESERVE
VM_RESERVE N
Reserves or disposes amount of values on stack.
- N: Positive value - amount of variables to be reserved on stack, negative value - amount of variables to be popped from stack.
VM_SET
VM_SET IDXA, IDXB
Assigns variable B to variable A.
- IDXA: Variable A.
- IDXB: Variable B.
VM_SET_CONST
VM_SET_CONST IDX, VAL
Assigns immediate value to the variable.
- IDX: Target variable.
- VAL: Source immediate value.
VM_RPN
VM_RPN
Reverse Polish Notation (RPN) calculator, returns result(s) on the VM stack.
.R_INT8
.R_INT8 ARG0
.R_INT16
.R_INT16 ARG0
.R_REF
.R_REF ARG0
.R_REF_IND
.R_REF_IND ARG0
.R_REF_SET
.R_REF_SET ARG0
.R_REF_SET_IND
.R_REF_SET_IND ARG0
.R_REF_MEM
.R_REF_MEM TYP, ADDR
.R_REF_MEM_SET
.R_REF_MEM_SET TYP, ADDR
.R_OPERATOR
.R_OPERATOR ARG0
.R_STOP
.R_STOP