VM Editor

Top  Previous  Next

Edit VM Commands using Script Editor

clip0103

When you click Edit button to add new VM Commands you will open either VM Blocks or VM Script Editor, depending on the settings. The VM Script Editor has many features that will help you to write a syntactically-correct script. It features syntax highlighting, auto completion and real time script checking. You can't write command that has the wrong syntax.

vm4

1 - The Edit window

Here you type the commands. The editor features syntax highlighting and auto completion.

Auto completion:

As you type you will notice the command is also being selected in the VM Commands list (4). By pressing the TAB key the selected command in the list will automatically be written at the place you're writing.

For example we start typing:

Link

A LinkPGCN is being selected in the list (4) as we type. By pressing TAB the text will be auto completed:

LinkPGCN

We can also select other commands, for example LinkPTT, and either press TAB or double click the item in the list (4)

2 - The Control Window

This is a very important window for automatic syntax guiding. As you type, this window will guide you by some hints and if the syntax is OK it will show you the full correct syntax.

vm5

Auto-guidance.

The Auto-Guidance will give hints as you type and it will shows how the editor reads your line.

For example we would like to add line if (GPRM1 ==2 ) LinkPGCN 4 on line 3. We start typing

We type

Control window shows

Details

if

Expecting 'if (...'

OK, we need to type parenthesis

if (

Expecting: if (GPRMx...

Next must be a GPRM parameter

if (GPRM1

Expecting operand: if (GPRMx ==, !=, >=, >, <=, <

and operator

if (GPRM1 ==

Expecting: if (GPRMx op 'GPRM/SPRM or constant'

then second parameter is expected

if (GPRM1 ==2

Expecting: if (...')'

and close the parenthesis

if (GPRM1 ==2 )

vmokif (GPRM0 == 0) Nop

The syntax is ok, but we want to type more

if (GPRM1 ==2 ) LinkPGCN

vmokif (GPRM1 == 2) LinkPGCN 0

we are missing parameter which is interpreted as 0

if (GPRM1 ==2 ) LinkPGCN 4

vmokif (GPRM1 == 2) LinkPGCN 4

now the syntax is complete

Line completion button

Whenever we see in control window vmok and a command line we can transfer it to our line in editor. For example we type:

JumpSS VTSM

and the control window shows: vmokJumpSS VTSM (vts 0, tt 0, menu 0)

This is how our command is interpreted, but obviously we need more parameters to specify. Instead of typing this to our editor (1) we can simply click the Line completion button near the control window:

vm6

The whole line will appear in editor. Now we can change the zeros for numbers we need:

JumpSS VTSM (vts 1, tt 1, menu 3)

Quick Link

This will help you to find a correct link to other objects in the DVD-lab project. Let's say we are editing VM command of a Movie and we would like to link to VMG menu from here. The Quick Link will suggest:

vm8

CallSS VMGM (pgc 2, rsm_cell 1) * see note below about PGC numbers

3 - Hex Preview

The hex preview shows how the VM command will be written to the DVD command space. This is good for advanced debugging.

4 - Command List

We already know that selecting a command and pressing TAB or double click will replace the currently edited command in editor. Below the list is a short description about the command and its domain of use.

For example for JumpSS VTSM we see this:

vm7

This tells us that we can use this command in First Play, VMG menu or VTS menu. We cannot use this command from movie.

5 - Reverse VM code

Sometimes we get the VM code in byte code hex format, for example from looking at previously compiled ifo file. As you type HEX numbers the Control Window (2) shows the byte code disassembled command.

Free syntax

There is not one exact way for people to write VM commands. VM Editor understands many different ways a line can be written.

For example a line

GPRM1 = 15

can be also written as

MOV(GPRM1,15)
MOV(GPRM1 15)
MOV GPRM1 15
GPRM1 mov 15
mov GPRM1 0x0F
....

You will see by vmok that the syntax is correct but the Control window will always shows only the one syntax that DVD-lab uses. Also when you close and open the edit window no matter what syntax you typed it will be changed to the one used by DVD-lab. Ths is called Syntax Normalization and without this we will not be able to understand each other.

Syntax normalization

When we close the VM Editor and then open it again all syntax will be normalized.

For example if we type

LinkPGN (2,3)

and then close the editor, our command will be automatically normalized to :

LinkPGN 2 (button 3)

If we type

MOV(GPRM1,0x0F)

the line will be normalized to

GPRM1 = 15

trianglePGC Numbers

As you get familiar with the VM commands and try the Quick Link you will realize that it suggests a PGC number that is always one bigger than it appears in the Connections.

For example we want to link from Menu 2 to Menu 1 (ROOT) and the Quick link will suggest LinkPGCN 2. Why is that? Shouldn't it be LinkPGCN 1 ? No, because:

For VM Command use, add 1 to the PGC number for all menus (VTS and VMG)

The first VTS menu that will shows in connections as ROOT is in DVD-lab PGCN 2.

There is always a shadow (hidden) menu for each VTS (PGCN 1) that has special purpose*. To see its VM commands, right click in the Project window and from menu select VTS Root VM...

The first VMG menu that will shows in connections as TITLE is in DVD-lab PGCN 2.

There is always a shadow (hidden) menu (PGCN 1) before other visible VMG menus that has special purpose*. To see its commands, in Connections right click on the Title Button and select Edit VM Commands.

showpgc

You can instruct the Connection window to display the true PGC number above all objects instead of item order by checking the Show PGC Number button. The PGC number appears in red in top left corner of object.

You can then use this number directly in VM Commands as PGC number

*This doesn't apply if you plan to Compile without Abstraction Layer. Without AL there will be no shadow menu created and therefore the first visible menu in DVD-lab will also become PGC 1 as expected

You have to remember this, otherwise you will be surprised why your commands don't work properly.