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
Call 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 clear N arguments on stack
- N: number of arguments to be removed from the stack
VM_GET_FAR
VM_GET_FAR IDX, SIZE, BANK, ADDR
Get byte or word by the far pointer into variable
- IDX: Target variable
- SIZE: Size of the ojject 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 jump 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 de 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
Call far routine (inter-bank call)
- BANK: Bank number of the routine
- ADDR: Address of the routine
VM_RET_FAR
VM_RET_FAR
Return from the far call
VM_RET_FAR_N
VM_RET_FAR_N N
Return from the far call and remove 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 if the result is true
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_OPERATOR
.R_OPERATOR ARG0
.R_STOP
.R_STOP
VM_JOIN
VM_JOIN IDX
Joins a thread
- IDX: Thread handle for joining
VM_TERMINATE
VM_TERMINATE IDX
Kills a thread
- IDX: Thread handle for killing
VM_IDLE
VM_IDLE
Signals thread runner, that context is in a waitable state
VM_GET_TLOCAL
VM_GET_TLOCAL IDXA, IDXB
Gets thread local variable.
- IDXA: Target variable
- IDXB: Thread local variable index
VM_IF_CONST
VM_IF_CONST CONDITION, IDXA, B, LABEL, N
Compares a variable to an immediate value
- 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
- B: immediate value to be compared with
- LABEL: Jump label when result is TRUE
- N: Number of values to be removed from stack if the result is true
VM_GET_UINT8
VM_GET_UINT8 IDXA, ADDR
Gets unsigned int8 from WRAM
- IDXA: Target variable
- ADDR: Address of the unsigned 8-bit value in WRAM
VM_GET_INT8
VM_GET_INT8 IDXA, ADDR
Gets signed int8 from WRAM
- IDXA: Target variable
- ADDR: Address of the signed 8-bit value in WRAM
VM_GET_INT16
VM_GET_INT16 IDXA, ADDR
Gets signed int16 from WRAM
- IDXA: Target variable
- ADDR: Address of the signed 16-bit value in WRAM
VM_SET_UINT8
VM_SET_UINT8 ADDR, IDXA
Sets unsigned int8 in WRAM from variable
- ADDR: Address of the unsigned 8-bit value in WRAM
- IDXA: Source variable
VM_SET_INT8
VM_SET_INT8 ADDR, IDXA
Sets signed int8 in WRAM from variable
- ADDR: Address of the signed 8-bit value in WRAM
- IDXA: Source variable
VM_SET_INT16
VM_SET_INT16 ADDR, IDXA
Sets signed int16 in WRAM from variable
- ADDR: Address of the signed 16-bit value in WRAM
- IDXA: Source variable