In analyzing the DVDSP 2 abstraction layer, it is easiest to start with a very simple project. First we will step through the Simple project on paper and examine how the abstraction layer commands accomplish their navigation. Then we will add commands with DVDAfterEdit to implement a Play All button, using mostly the abstraction layer registers themselves.
This document contains two sections: an analysis of the DVDSP 2 abstraction layer, and instructions for turning a VIDEO_TS folder built from the Simple project into the Play All version.
» Click here to download example files for this project.
You may skip the first section if all you want to do is use this project as a template; the instructions alone are sufficient to achieve this goal.
The Simple project contains the following First Play commands:
#DVDAfterEdit Commands V1 #Selected from "Simple:First Play PGC:" 1: Set r5 = $2000 2: Set r4 = 0 3: Set r1 = 1 4: Jump VTS 1 VTS TT 1 Menu Root
Examining the menus for Title Set 1, we see that VTSM PGC 1 has the Menu Type designation root. So this must be the target. It says:
#DVDAfterEdit Commands V1 #Selected from "Simple:Video Title Set Menus:Title Set 1 Menus:English (7 menus):VTSM PGC 1:" 1: if r5 == $4000 then Link PGC 3 2: Set r5 = 0 3: if r1 != 0 then Link PGC 6 4: if r2 != 0 then Link PGC 5 5: Set r0 = VTS title 6: Set r0 *= $100 7: Set r0 |= Part title 8: Nop 9: Nop 10: Nop 11: Nop 12: Nop 13: Nop 14: Nop 15: Nop 16: Nop 17: Nop 18: Link Resume
Following through the commands, r5 is not $4000, so we do not branch. We set r5 to 0. r1 is 1, so link to PGC 6. (That will be VTSM PGC 6 in the same title set).
So far we have the following values for registers which are non-zero:
R1 1
Remember that all registers are initially zero when execution begins. PGC 6 says:
#DVDAfterEdit Commands V1 #PreCommands from "Simple:Video Title Set Menus:Title Set 1 Menus:English (7 menus):VTSM PGC 6:" 1: Set r0 = r1 2: Set r1 = 0 3: Nop 4: Nop 5: Nop 6: Nop 7: Nop 8: Nop 9: Nop 10: Nop 11: Nop 12: if r0 == 1 then Link PGC 7
We test r1 by moving it to r0 first then clearing r1. Now all registers except r0 are zero. Remember that r0 is the scratch register, so we never need to remember it for very long. We link to PGC 7.
Notice that PGC 7 actually contains a program and a cell (it has video). If we preview it, we see the Title Menu. Its pre commands are:
#DVDAfterEdit Commands V1 #PreCommands from "Simple:Video Title Set Menus:Title Set 1 Menus:English (7 menus):VTSM PGC 7 (1 program):" 1: Nop 2: Nop 3: Nop 4: Nop 5: Nop 6: Set r6 = $20 7: Set r0 = r4 8: if r0 != 0 then GoTo Line 10 9: Set r0 = 1 10: Set r0 &= $3f 11: Set r0 *= $400 12: Nop 13: Set r3 = 1 14: Set Button r0 15: Set r1 = 0
We first save a GetLastItem value in r6. Then we move r4 to r0, and see if it had anything in it. It didnt, so we load a value of 1.
We make sure that r0 has a value between 0 and 63. (It will actually be between 1 and 36 to be valid, but we dont check this). Then we multiply it by 1024, since the spec likes to put button numbers in the high part of the word. We set the button number into SPRM 8. We set r3 and clear r1. We now have:
R3 1
We have finished the pre commands with no obstacles (we didnt link out to anyplace else), so we display the title menu with button 1 selected.
Now let us look at the title menu itself. It has one program, one cell, and two nav packs. The button navigation is identical in the two nav packs, so lets not worry about the fact that there are two.
You will see that each of the first four buttons has a LinkTailPGC command. This will cause the post commands of the current PGC to be executed if the button is activated. The fifth button (the Play All) has a Nop, because it is not yet hooked to anything. We will hook it up later, but to a different PGC.
Let us now examine the VTS Menu post commands:
#PostCommands from "Simple:Video Title Set Menus:Title Set 1 Menus:English (7 menus):VTSM PGC 7 (1 program):" 1: Set r3 = 0 2: Set r0 = Button 3: Set r0 /= $400 4: if r0 != 1 then GoTo Line 8 5: Set r3 = $101 6: Jump VMG PGC 2 7: Nop 8: if r0 != 2 then GoTo Line 12 9: Set r3 = $102 10: Jump VMG PGC 2 11: Nop 12: if r0 != 3 then GoTo Line 16 13: Set r3 = $103 14: Jump VMG PGC 2 15: Nop 16: if r0 != 4 then GoTo Line 20 17: Set r3 = $104 18: Jump VMG PGC 2 19: Nop 20: if r0 != 5 then GoTo Line 24 21: Set r3 = $101 22: Jump VMG PGC 2 23: Nop 24: Nop
First we clear r3. Now all of the important registers are zero again. We fetch the button number out of the SPRM. (We convert it back to 1 thru 36 by dividing by 1024).
Now we have five sets of four commands which test for buttons one through five and jump to Video Manager PGC 2 with a value containing the button number in the low part of r3 and a one in the high byte of the word.
For button five it uses button number 1, which will jump to the first title for the play all.
Now let us look at VMG PGC 2:
#PreCommands from "Simple:Manager Menus:English (8 menus):VMG PGC 2:" 1: Set r1 = 0 2: Set r2 = 0 3: if r3 & $ff00 then GoTo Line 5 4: GoTo Line 8 5: Set r5 = r3 6: Set r5 /= $100 7: Set r3 &= $ff 8: if r3 >= 5 then Link PGC 3 9: Set r0 = 1 10: if r0 == r3 then Jump TT 1 11: Set r0 = 2 12: if r0 == r3 then Jump TT 2 13: Set r0 = 3 14: if r0 == r3 then Jump TT 3 15: Set r0 = 4 16: if r0 == r3 then Jump TT 4 17: Jump First Play
Remember if we get here we have a value of $101, $102, $103, or $104 in r3.
We test r3 to see if there is anything in the high order byte. There is, so we go to line 5. We take that value and move it to r5 and divide it by 256, resulting in r5 = 1 (the one that was in the high byte). We then and off the high byte and leave just the button number in r3.
Then we have a series of tests which result in going to the appropriate title for each button, TT 1 thru TT4. Since we know we came here with a valid button number, it can never take the Jump First Play branch.
Now let us look at the Video Manager in the left pane, and then expand the Title Play Map. We see that TT1 is VTS 1, the one and only chapter, TT2 is VTS 2, etc. etc.
Now let us look at a Title. Well start with TT1:
#PreCommands from "Simple:Video Title Sets:VTS 1:PGC 1 TT 1:" 1: Nop 2: Nop 3: Nop 4: Nop 5: Nop 6: Set r6 = $c080 7: Set r7 = r6 8: Set r0 = r5 9: Set r5 = 0 10: Set r1 = 0 11: Set r2 = 0 12: if r0 == 1 then Break
We set the GetLastItem register, r6, with a unique value. We also move the same value to r7. Line 12 is pointless since all a Break accomplishes is to skip any commands that follow and get right to the video display. At this point we have:
R3 $101 R6 $c080 R7 $c080
We now play Track 1. The other three titles pre commands are identical TT1 except for the GetLastItem value.
There are no cell or button commands in the tracks, so when the track is finished it automatically goes to the PGCs post commands.
#PostCommands from "Simple:Video Title Sets:VTS 1:PGC 1 TT 1:" 1: Set r4 = 0 2: Set r1 = 1 3: Call VMG PGC 4 resume C1
We now have the following register values:
R1 1 R3 $101 R6 $c080 R7 $c080
Lets see what PGC 4 says:
#PreCommands from "Simple:Manager Menus:English (8 menus):VMG PGC 4:" 1: Set r5 = 0 2: Set r2 = 0 3: if r1 >= 2 then GoTo Line 5 4: Jump VTS 1 VTS TT 1 Menu Root 5: Jump VTS 4 VTS TT 1 Menu Root 6: Jump First Play
Since r1 == 1 it will jump to the root menu for VTS 1: (Weve seen this before!)
#PreCommands from "Simple:Video Title Set Menus:Title Set 1 Menus:English (7 menus):VTSM PGC 1:" 1: if r5 == $4000 then Link PGC 3 2: Set r5 = 0 3: if r1 != 0 then Link PGC 6 4: if r2 != 0 then Link PGC 5 5: Set r0 = VTS title 6: Set r0 *= $100 7: Set r0 |= Part title 8: Nop 9: Nop 10: Nop 11: Nop 12: Nop 13: Nop 14: Nop 15: Nop 16: Nop 17: Nop 18: Link Resume
We can see that this will go to PGC 6, because r1 is not zero. Then PGC 6 will go to PGC 7, and r1 will be cleared.
Then PGC 7 will display the title menu again, highlighting button 1 because it is the default. (r4 is not set to anything).
If we look at the post commands for TT2, TT3, and TT4, they all set r4 to their own button number. Example for TT2:
#PostCommands from "Simple:Video Title Sets:VTS 2:PGC 1 TT 2:" 1: Set r4 = 2 2: Set r1 = 1 3: Call VMG PGC 4 resume C1
So when navigation finally gets to the title menu, it will highlight the button which instigated the last track play.
It seems there is a lot of jumping back and forth between domains and PGCs. But the Video Manager and Video Title Set 1 domains are very close together, because there is no video in the Video Manager domain. The PGCs for a given Title Set are also close to each other. So the play head doesnt have to move very far on all these branches between PGCs in the menu domains and PGCs in the title domains.
However, since all DVDSP 2 scripts are placed in the Video Title Set 1 Menus, then any script checking what to do after playing a track must be jumped to from the track, and then it must jump back to the next track to be played. So any scripting we do in the track areas will be more efficient, and will execute more quickly if it can jump directly to the next track, if the DVD Spec commands allow it to do so. Certainly any scripting between markers (chapters) in the same VTS will go much more quickly.
I believe we have enough information to develop a play-all script directly in DVDAfterEdit.
It turns out that to make the Play All button completely functional requires us to add 1 command to the title menu PGC, one command each to the title PGCs, and a single routing dummy PGC to the Video Manager Menus, with nine commands. It requires the use of one register.
In the last section of the post commands insert the following command at line 21:
#Selected from "Simple:Video Title Set Menus:Title Set 1 Menus:English (7 menus):VTSM PGC 7 (1 program):" 21: Set r8 = 1
This commands sets the variable that means we are in play all mode, instead of the normal play one track at a time mode.
Insert the following command at line 3 of the post commands:
#Selected from "Simple:Video Title Sets:VTS 1:PGC 1 TT 1:" 3: if r8 == r1 then Call VMG PGC 9 resume C1
Insert this same command at line 3 of the post commands for each of the titles. (TT2, TT3, and TT4).
Insert a dummy PGC in the Video Manager Menus. It will contain the following commands:
#Selected from "Simple:Manager Menus:English (9 menus):VMG PGC 9:" 1: Set r0 = 1 2: if r4 <= r0 then Jump TT 2 3: Set r0 = 2 4: if r4 == r0 then Jump TT 3 5: Set r0 = 3 6: if r4 == r0 then Jump TT 4 7: Set r8 = 0 8: Set r4 = 5 9: Link PGC 4
The first two commands check to see if we came from TT1, and if so jumps to TT2. The next four commands do similar logic for TT2 and TT3.
When we have finished TT4, the last track, we clear the play all variable (r8). Then we set the button number to 5 so that the title menu will highlight button 5 (the play all button) to indicate that is what we did last. Then it eases back into the abstraction layer at VMG PGC 4.
Pretty simple, huh?