spumux menu.xml < menu.mpg > menu_final.mpg
四、逻辑控制
1.变量寄存器。DVD虚拟机能够处理16bit数据,含有16个通用寄存器,保留3个留作系统使用,可用通用寄存器序号g0~g12。DVD VM有24个系统寄存器,按照官方文档说法,并不是所有的系统寄存器都能被用户设定,官方给出了4个可设置的系统寄存器。
代码:
audio (s1, rw):Denotes the audio stream, ranging from 0-7.
subtitle (s2, rw):The subtitle track, ranging from 0-31.
详情见官方文档。
angle (s3, rw):Selects the angle (currently untested).
button (s8, rw):Denotes the currently highlighted button. Note that the value is multiplied by 1024, so the first button is 1024, the second is 2048, etc.
2.操作符(EXPRESSION):
代码:
==, !=, >=, >, <=, <, &&, ||, !, eq, ne, ge, gt, le, lt, and, or, xor, not, +, -, *, /, %, &, |, ^
经实际使用,字母操作式比符号操作式好用,如DVDAuthro对eq的辨识度明显比==高。
3.随机函数:random(EXPRESSION) Computes a psuedo-random number, between 1 and the supplied number, inclusively.
4.语句块(Blocks):可以是单句或用{}围起来的多句,支持{}嵌套。超过一个语句必须使用{}。
代码:
官方示例:
g3=s7;
{
audio=1;
subtitle=65;
jump vmgm menu 3;
}
If else可以做为一个单独blocks使用,与官方的if else语句表达略有不同。
如:<post>if (g2 eq 3) {g2=0;jump title 1;} else jump menu 2;</post>
5.主要操作语句:
DVD VM为一个超简易的虚拟处理机,仅支持赋值、条件判断和跳转,就一个贫瘠的汇编语言编译器,虽然号称C风格的语句,但是功能实在太弱爆,C的各种花式语句是不要想有了,如for循环、移位、指针。
(1) 赋值依旧是通用方式:VARIABLE=EXPRESSION;如g1=g1+1
(2) if (EXPRESSION) BLOCK;
(3) if (EXPRESSION) BLOCK; else BLOCK;
如果表达式值为真(1),执行BLOCK。
(4) jump TARGET; 跳至某个特殊的标题或菜单,常用于Menu和Titles跳转。
(5) call TARGET [resume CELL]; 调用某个特殊菜单,用于pgc内的title或chapter返回索引菜单(root)或根菜单(VMGM)的唯一方式。加上rescue CELL可返回调用点。
(6) resume; 具体用法见官方文档,不指定CELL,默认返回CELL 1。
部分官方原文:
代码:
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.
6.内部命令语句:
(1)<fpc>commands;</fpc> VMGM段专用,在进入VMGM菜单前飞入其他对象,可以用之实现片头CG循环播放。
(2) <post>commands;</post> 常出现在vob和pgc标识,用于设定所在的vob或pgc片断完成后所执行的动作。
(3) <pre>commans;</pre>常出现在vob和pgc标识,用于设定进入所在的vob或pgc片断之前所执行的动作。
通过<post><pre>可以实现菜单、标题、章节的循环或连续播放。
(4) pause="seconds|inf"
设定所在片断执行完成后进入下一片断的暂停时间。
7.跳转对象:
代码:
(1)[vmgm | titleset X] menu, [vmgm | titleset X] menu Y, [vmgm | titleset X] menu entry Z
(2)[titleset X] title Y [chapter Z]、
All of the titles on the disc are accessible in the VMGM domain, or you can access them by titleset instead.
(3)chapter Z
Targets a chapter in the current title.
(4)program Z, cell Z
Targets a program or cell in the current PGC. You can use this to create looping menus: jump cell 1;
(5)cell top, next cell, prev cell, program top, next program, prev program, pgc top, next pgc, prev pgc, up pgc, pgc tail
"cell/program/pgc top" goes back to the start of the current Cell/program/PGC; "next/prev cell/program/pgc" goes to the next or previous cell/program/PGC; "up pgc" goes to the "up" PGC (not currently settable indvdauthor); and "pgc tail" goes to the <post> sequence in the current PGC.
Chapters are numbered from 1 in each title, while programs are numbered from 1 in each PGC. Thus, the latter can reset independently of the former when there is more than one PGC in a title.
8.跳转规则:
代码: