Command Reference for VMU Script Compiler
Quick Index: Statements Functions Internal statements Internal functions Things you should know
ALL COMMANDS MARKED WITH A '*' WERE ADDED IN VERSION 1.72.
THE COMMANDS MARKED WITH A '*' WERE ADDED IN VERSION 1.73
THE COMMANDS MARKED WITH A '*' WERE ADDED IN VERSION 1.74
* There is a new option for the parameter syntax. If you enclose a parameter completely in parenthesis, all commas within the parenthesis will not be treated as delimeters. In other words, this is the solution to the comma proble. Before, you weren't able to use commas in the "!" or "rem" statements. But now, if you use ( ), then it will work. EXAMPLE: "rem:(Hello, World)" writes the comment "Hello, World" into the assembler source. While "rem:Hello, World" just writes "Hello".
|
DESCRIPTION |
|
|
*init |
This command should be the first line in every VMU program. It sets some things REQUIRED for the VMU to function properly! |
|
*play:frequency |
This command starts playing sound at the desired frequency. |
|
*stop |
This command stops playing sound. |
|
if: operator: valueA,valueB ... *[and if:operator:valueA, valueB] [else] ... end if |
This is an IF statement. When the condition 'valueA operator valueB' is met, the code between the "if" and the "end if" is executed. When the "else" keyword is used, the code between the "if" and the "else" is executed if the condition is met, otherwise, the code between the "else" and "end if" is executed.
The operators recognized by this statement are: > (greater than) < (less than) = (equal to) <> (not equal to) >= (greater than or equal to) <= (less than or equal to) The new "and if" statement can be used repetatively but only after an if statement. It provides a way for additional IF conditions without additional nested IF statements which take more time to execute. |
|
call: sub_name, [parameters,...] |
This statement simply executes code named 'sub_name' defined within a "sub" statement. If you defined parameters with an "args" statement, you need to put parameters after sub_name as well. |
|
sub: sub_name ... end sub |
This defines a subroutine. To run a subroutine, use the "call" statement. Otherwise, the code within the subroutine isn't executed. |
|
label: label_name |
This defines a label. The "label" statement can be used instead of the "sub" statement but this isn't recommended. Instead, use the "goto" statement to branch to the location defined by 'label_name' |
|
!: assembler... |
This places a line of assembler in the code. Unfortunately, the line of assembler won't be written to the code properly if it contains any commas... *unless you place everything after the "!:" in parenthesis! |
|
var: variable_name |
OBSOLETE! This statement defines a 1 byte variable. Use the "var" function instead. |
|
rem: text |
Inserts a comment. NOTE: When the code is compiled, the "rem" statement writes a comment into the assembler source code (for use with debugging). |
|
?: text |
Inserts a general comment. NOTE: When the code is compiled, the comment is no longer visible |
|
cc: text |
The CC stands for Compiled Comment. It's not only visible when in assembler form, it's visible in the VMS binary!!! To see how this works, compile a program with the CC statement and, after it's assembled, list the VMS file. You should be able to see your comment. Then try running the file, it will still run perfectly! |
|
loop exit loop: loop_var, exit_when_equal_to, increment_by |
The code within the "loop" and "exit loop" is executed until the variable 'loop_var' is equal to 'exit_when_equal_to'. The value 'increment_by' is also added to 'loop_var' after the inside code is executed. If you use the *"exit loop when zero" command instead of "exit loop" then ignore the last two parameters and just type the variable. The "exit loop when zero" command decrements the variable by one each time and only exits when the variable is equal to zero. |
|
end |
This ends the execution of a VMU game. |
|
set lcd: on/off |
This turns on or off the VMU screen. |
|
set speed: fast/slow |
This sets the VMU processor speed to either RC clock mode (fast) or a slower speed (slow). The slow speed is power conserving. |
|
halt |
This puts the VMU in halt mode. |
|
push: value |
This "pushes" a value 'value' onto the stack. |
|
pop: value |
This "pops" a value off the stack and into the variable 'value' |
|
set: valueA, valueB |
OBSOLETE! This sets 'valueA' to 'valueB'. It has now been replaced with a simpler valueA = valueB syntax. SEE MATH STATEMENTS |
|
set interrupts: blocked/unblocked |
This turns the interrupt blocking of the VMU CPU on or off. |
|
hold |
This puts the VMU in hold mode. |
|
set bit: on/off/invert : value, bit_num |
This either inverts, turns on, or turns off a bit in the value value. |
|
delay: value |
This runs a simple delay loop value times. |
|
Sets a specific byte in a multi-byte variable to value. |
|
|
setsfr: variable, byte_number, value |
Sets a specific byte in a VMU special function register to value. (This can be used to write to the LCD screen, use the calc_row command to calculate the address for a row and then add the column number. If you want to move something to the right or left by a pixel, use the SHIFT function. It will rotate the bits in a value to the right or left one. It will return the rotated bits in one variable and store the left over bits in another) |
|
This branches (goes to) the label label_name. |
|
DESCRIPTION |
|
|
*output = random: random_seed |
Returns a random number from 0-255. Since the random number returned is the same for each seed, make sure to set the seed to the random number. You can even set the seed the the random number plus one, etc. if you want unique random numbers. To make the numbers unique every time the VMU game is run, set the seed to the seconds system variable (address \\$1d). To do this, just type something like: "seed = getsysvar: $1d". |
|
*output = getsysvar: address |
Returns a byte from a system variable (like the date and time). |
|
Returns a byte from a multi-byte variable. |
|
|
output = getsfr: variable, byte_number |
Returns a byte from a VMU special function register. (like the LCD screen, use the calc_row command to calculate the address for a row and then add the column number. If you want to move something to the right or left by a pixel, use the SHIFT function. It will rotate the bits in a value to the right or left one. It will return the rotated bits in one variable and store the left over bits in another) |
|
output = mod: valueA, valueB |
This returns the modulus of valueA and valueB |
|
output = and: valueA, valueB |
This performs bitwise AND between two values. |
|
output = or: valueA, valueB |
This performs bitwise OR between two values. |
|
output = xor: valueA, valueB |
This performs bitwise XOR between two values. |
|
This declares a new variable variable_name and gives it the size size in bytes. NOTE: The compiler won't automatically reference the variable if it is multi-byte. You need to use the "getvar" function to return a specific byte or the "setvar" statement to set a specific byte.
NOTE: If you are using a literal value, you have to prefix it with a # or the compiler will think that it is a memory address!!!! |
|
|
output = calc_row: row_number |
This calculates the memory address of a row on the VMU screen. For example, 'calc_row: 0' returns \\$180. |
|
This command returns a byte of data from within the file relative to the label pointer + offset. Use a "byte map" statement to place data in your file. |
|
|
This command also returns a byte of data from within the file, but uses two 8bit pointers (which form a 16bit pointer) as a reference. Use a "byte map" statement to place data in your file. |
|
|
output = shift: left/right: value, overflow |
This command shifts value to the right/left one bit and returns the resulting value. The overflow from shifting is placed in overflow. |
|
DESCRIPTION |
|
|---|---|
|
value = value [ + or - or * or / ] value ... |
This is a simple math statement. It allows you to write simple equations such as "a = a + b * c" and have them executed. It is limited to 8bit positive integers and order of operations doesn't apply. You can't use parenthesis or brackets either. BUT, this is much easier than trying to write a complex equation in assembler. |
|
DESCRIPTION |
|
|---|---|
|
This allows you to define your own parameters for your subroutines. You simple write out "args:" then the subroutine name, and then all the input variables that you need (separated by commas). When you call the subroutine, the compiler adds code that stores the values that you listed as parameters into the input variables. |
|
|
... end map |
This creates a label label_name and inserts sequential data (you write this between the "byte map" and "end map") after it. You can reference this data using either the "get" or "get8" functions. |
|
You can't call functions with no parameters unless you use the "!args" keyword. For example, if I wanted to call a function named "my_function" but it had no parameters, I would just say: "x = my_function: !args". This compiler uses the same notation as Marcus's assembler. The '\\$' symbolizes a hexadecimal number, a '%' represents binary, a '#' represents a value instead of a memory address, etc. If you ever need to know the syntax of a statement or function and you don't have this reference, you can run the "cmdlist" program with the function library as a command line option. It will list all the statements and functions belonging to that library. EXAMPLE: Typing "cmdlist default.lib" will print all the commands for the function library "default.lib". In order for a program to run you must have some code in a "sub: main" statement. This code is executed first and the program won't assemble properly without it. |
Quick Index: Statements Functions Internal statements Internal functions Things you should know