Inside DVD-Video/Interaction Machine

From Wikibooks, open books for an open world
Jump to: navigation, search

DVD-Video specifies a low-level machine-language instruction set that is used to define interactions with the user. Instruction sequences are invoked when the user selects an on-screen button, and may also be triggered at various other points, such as the end of a cell or a PGC, or when the disc is inserted into the player.

The instruction set is commonly referred to as the “VM” (Virtual Machine) language, but the implication of calling it “virtual” is that there cannot be real hardware that directly implements this instruction set. But why not? That’s why I am here using the term “interaction machine”, which makes it clearer what the purpose of the instruction set is.

(Note that I’m avoiding using the term “program” for sequences of instructions in this instruction set, because that already has a completely different meaning in DVD-Video.)

Each instruction is 8 bytes long. This sounds like a lot, because each instruction can do several things at once: for example, perform a comparison, set a register, jump to some location.

(For now: instruction set summary and details)

There are 16 general-purpose parameter registers (GPRMs), each of which can hold an unsigned 16-bit integer. Their use is entirely up to the instruction-sequence writer. They are the only data storage available to instruction sequences. There are no indirect or indexed addressing modes available.

There are also various system parameter registers (SPRMs), with predefined meanings to the player. There are special instructions for accessing these, and some of them are read-only.

(SPRMs are listed here for now)

Interaction instructions can be found in the following places:

  • a cell can end with a single instruction to be executed when the cell has finished playing.
  • a button specifies a single instruction to be executed when the button is selected.
  • the pre- and post-sections of a PGC can each contain a sequence of instructions, to be executed before the PGC starts playing and after it finishes, respectively.
  • the FPC contains a sequence of instructions which automatically start executing when the disc is inserted into the player.

The single-instruction limitation on buttons is not a big issue in practice; it’s easy enough for the single instruction to be “jump to location n in post-section of PGC”, to execute a longer sequence of instructions beginning at that location n.

Most operations can be executed conditionally: the condition is based on comparing either two GPRMs, or a GPRM and a literal value from the instruction, according to a choice of comparison operators.

Besides being conditional, instructions can perform the following sorts of operations:

  • transfer of control within an instruction sequence, or terminate an instruction sequence
  • link (transfer to a cell, program, PTT or PGC within the same domain), optionally specifying a button to show as highlighted
  • jump or call—transfer to a PGC or PTT in another domain. Call differs from jump in that the current (or an alternative specified) cell location is saved as the address to return to on execution of a resume instruction. Only a single such cell location can be saved; executing a new call overwrites the return address from the previous call. Not all combinations are allowed
  • set a GPRM to either a literal value, the value of another GPRM, or the value of an operation involving a GPRM and a literal value
  • set specified SPRMs to specified values (might be literal or from a GPRM, depending on the instruction). Only certain SPRMs can be set this way
  • combination of a set-GPRM and a link (conditionals not allowed)
  • combination of a conditional, set-GPRM and link, in 3 variations: 1) the set is unconditionally done, then the conditional test is used to decide if the link should be done 2) the conditional test is used to decide if the set followed by the link should be done 3) the conditional test is used to decide if the set should be done; in either case, the link is always done

Permitted Jumps/Calls[edit]

Here is a table of the permitted transfers between domains, and the names of the instructions to use.

FPC JumpSS JumpSS JumpTT

Note that, from a VTS (menu or title), it is not permitted to jump directly into another VTS. You have to set up indirect jumps via the VMG. Note also that, from a title, you have to “call” rather than “jump” into a menu; this is to allow the menu to use RSM to resume playback of the title.