# System Register

## DVDAuthor / VMLanguage

The DVDAuthor Virtual Machine Language is used to provide code to be executed by the DVD player in response to events such as menu button presses by users.

The following text takes the manual page for DVD author as a starting point.

The language is quite simple and roughly looks like C.

- Statements are terminated with a semicolon.
- Statements can span multiple lines.
- Multiple statements can appear on one line.
- Whitespace (space, tab, newlines) are not important, except to separate keywords and identifiers.

#### Variables

The DVD virtual machine processes 16 bit values. It supports up to 16 general purpose registers; however dvdauthor reserves 3 for internal use. Thus registers 0-12 are avaialable for use and are referred to as g0 through g12.

There are also 24 system registers, which can be referred to as s0 through s23. Not all of these can be set. Many of these have pseodonyms.

Name | Pseudonym | Writable | Description
s0 |  |  | Menu Description Language Code
s1 | audio | yes | Denotes the audio channel, ranging from 0-7.
s2 | subtitle | yes | The subtitle track, ranging from 0-31. If you want the subtitle to always be displayed, then you should add 64 (i.e. choose 64-95). Simply selecting the track (0-31) means that only the forced subtitles will be displayed, whereas enabling the track (64-95) means that all the subtitles will be displayed. This allows you to have forced subtitles only for the parts of the movie where the actors are speaking a foreign (to the viewer) language, but still have normal subtitles for the hearing impaired. The hearing impaired viewers would enable the track (64-95) while the other viewers would just select the track (0-31) they would be able to share the track.
s3 | angle | yes | Selects the angle (currently untested).
s4 |  |  | Title Track Number
s5 |  |  | VTS Title Track Number
s6 |  |  | VTS PGC Number
s7 |  |  | PTT Number for One_Sequential_PGC_Title
s8 | button | yes | Denotes the currently highlighted button. Note that the value is multiplied by 1024, so the first button is 1024, the second is 2048, etc.
s9 |  |  | Navigation Timer
s10 |  |  | Title PGC Number for Navigation Timer
s11 |  |  | Audio Mixing Mode for Karaoke
s12 |  |  | Country Code for Parental Management
s13 |  |  | Parental Level
s14 |  |  | Player Configurations for Video
s15 |  |  | Player Configurations for Audio
s16 |  |  | Initial Language Code for Audio
s17 |  |  | Initial Language Code Extension for Audio
s18 |  |  | Initial Language Code for Sub-picture
s19 | region |  | Initial Language Code Extension for Sub-picture
s21 |  |  | Reserved 21
s22 |  |  | Reserved 22
s23 |  |  | Reserved 23

#### Expressions

Expressions follow typical C syntax except that booleans are not convertible to integers and vice versa. Operators and comparisons are:

==, !=, >=, >, <=, <, &&, ||, !, eq, ne, ge, gt, le, lt, and, or, xor, not, +, -, *, /, %, &, |, ^

Since the code is encapsulated in XML, the parser will catch any unescaped < characters, thus alphabetic mnemonics have been provided for all comparison operators for consistency.

There is also a numerical function:

random(EXPRESSION)

computes a psuedo-random number, between 1 and the supplied number, inclusively.

#### Blocks

Blocks are either a single statement (terminated by a semicolon), or a group of statements wrapped in curly braces. For example:

     g3=s7;

     {
       audio=1;
       subtitle=65;
       jump vmgm menu 3;
     }

#### Statements

The statements supported are fairly simple at the moment.

     VARIABLE=EXPRESSION;

Sets a variable equal to the result of an equation.

     if (EXPRESSION) BLOCK;

     if (EXPRESSION) BLOCK; else BLOCK;

Calculates the expression; if true, then it executes the block of code.

     jump TARGET;

     call TARGET [resume CELL];

     resume;

Jumps to a particular title or menu, or calls a particular menu, or returns to the calling title. You can only execute a call from a title to a menu; all other forms are illegal. The purpose of using call instead of jump (besides the fact that they support a mutually exclusive list of targets) is to allow the menu to return to the point in the title where the call originated using resume. You can manually specify the return cell by using the resume keyword, however if you do not specify one and you use the command in a post instruction block, then it will presume cell 1.

The following are possible targets:

     [vmgm | titleset X] menu

     [vmgm | titleset X] menu Y

     [vmgm | titleset X] menu entry Z

Targets either the default menu, a menu number Y, or the menu denoted as the entry for Z. The menu is in either the VMGM or titleset domain. If you wish to target a menu in the current domain then you can omit the domain moniker.

     [vmgm | titleset X] title Y [chapter Z]

Targets a title, or a chapter in a title. Numbering starts at 1. All of the titles on the disc are accessible in the VMGM domain, numbered sequentially no matter what titleset they are located in, so that in a DVD with two titlesets, each of which contains one title, the second title may be accessed with "title 2" . Or you can access them by titleset instead.

     chapter Z

     program Z

     cell Z

Targets a chapter, program, or cell in the current title or menu (note that menus do not have chapters). You can use this to create looping menus: jump cell 1;

According to the changelog for dvdauthor-0.6.12, break and goto have been added to the vm language as statements.

Last modified: Mon Oct 30 13:33:37 EST 2006