Getting and using item values
By Hal MacLean
The project file for this tutorial are available for download here
DVD Studio Pro enables you to author a disc by creating menus and tracks, scripts and slideshows. When the layout gets complex, the navigation also gets complex and it is easy to get lost amongst it all. Making sure the menu button connects to the appropriate track, or that the script references the appropriate track, is an issue. Fortunately, not a big one, and certainly not one that is insurmountable. With careful planning even very complex layouts are easily managed.
However, what other ways are there for ensuring the navigation is right?
Every single element in DVDSP has a numerical value, from buttons on a menu to scripts and tracks, even the menus themselves. By now most people who have done even simple scripts will know that buttons on a menu are numbered from 1024 and increment in jumps of 1024. However how many people know that tracks are numbered from 49280 and increment in jumps of 128 each time?
This seems obscure, but actually we can find logic behind this madness! The reasons lie in the way that DVDSP uses eight of your GPRMs as the abstraction layer, and that there are just 16 bits in each GPRM. Take button numbers, for example - in a register, the 11th bit (or 10th if you start counting from zero) has a value of 1024. The bits from 11 to 16 are used to represent the different buttons, but switching combinations of bits on and off. Button 2, for example, uses bits 11 and 12 (or 10 and 11 if you count from zero). In binary, these bits have a decimal value of 2048, which is why we get that value when we use ‘SPRM8′ to tell us the button value on button 2.
Similarly, menus have a value. The very first menu in your project will have the value of 32. If you go to menu 2, the value is 64, leading us to believe that menus increment in jumps of 32 each time. If you can be bothered to extend the project files in the download for this tutorial you’ll see that this is indeed what happens. Therefore, to return to a specifi menu you could use the menu value - jump statements are made more simple by the script editing functions in DVDSP. You don’t get to ‘jump to 32′ you get to Jump to menu 1. However, if you use the ‘Special’ commands, you can start to use the values as part of your ‘if’ statements in your scripts.
Tracks also have a value that starts at 49280 and increments in jumps of 128 each time. You will be aware that a disc can only have 99 tracks, slideshows and stories on it - given the starting value of track 1, this is hardly surprising when you think that the values will be kept within a single GPRM. 49280 is the decimal representation of bits 7, 14 and 15 (if you count from zero) . Checking the other incremental values you will spot that bits 14 and 15 are always set to be on, leaving the remaining bits between 7 and 14 to hold the track values. There is more than enough room to hold 99 different values, and in theory the register could in fact hold 128 different values in that bit range. However, the limit imposed on us is 99.
If you use the ‘Special’ entry when scripting in DVDSP you’ll see that you can get the ‘last item’, the ‘current item’ and the ‘last track’ values very easily. If you post these values into a GPRM you can see just what each item is being allocated. The thing to remember is that these commands relate precisely to where you actually are when you call them. For example, if you are in a menu and you go to a script on the way to start a track, then using the ‘current item’ will in fact get you the value of the script. Getting the track value is usually best done retrospectively, i.e. after the track has played go to a script and get the last item.
Using the values
Ok - so you now see the values and you are wondering why they may be useful. One of the more common uses would be if you regularly move tracks around in the VTS view. You’ll see that the VTS gets renumbered so track 1 in VTS 1 becomes track 1 in VTS3 if you move it down two places. Moving tracks like this helps you re-order the playback on some players which default to the first VTS, and this is useful if later in a project you want to add in a leader, for example. However, if you script jumps according to track names, you may find that you quickly lose the navigation. Using track values however means that you are referring to a particular slot in the VTS order. 49280 will refer to the track content in VTS1. It doesn’t then matter what asset is in that slot, only that the scripting is referring to that slot.
The same is true with menus - by default all menus are put into VTS1, but you can move that to a different slot. You can also move the menus into different VTS. However, menu 1 will hold value 32 wherever you put it in the structure.Knowing this means you can target the right menu no matter what.
Issues
The main issue with this kind of thing is that in different versions of DVDSP the values for the items have changed. However, as f the time of writing, and DVDSP version 4.0.3, the values here hold true. There have at times been subtle changes to the values, with DVDSP assigning increments for tracks of more than 128 in some versions. However, using the project files included here you can easily determine the values that DVDSP is assigning. Note that the project files probably won’t work with versions earlier than 4.0.3.
It gets more complex when you add in stories to a track, or indeed add in a slideshow. Each story adds another 128 to the track count starting with the track that you are in when you add the story. For example, if you are in track 1, it will have a value of 49280. You add a story it will also have a value of 49280. The second story you add in that track will have a value of 49408 (an increment of 128). In your VTS structure, VTS 2 comes next, and it will have a value of 49664, or three lots of 128 above the start value.
Similarly, if you add a sideshow, this acts like a track and will occupy its own VTS. Consequently it will add 128 to the ‘track counter’ according to where it is positioned in your VTS structure.
At first glance, using two stories on track one makes quite a difference to the actual track values, and unless you count in the stories in order you can misunderstand the way the track values are incrementing. Be careful!
