Archive for scripting

Making a codelock feature

Once again I was recently asked if there was a way to have a user enter a code to access a hidden part of a DVD. The short answer is ‘yes’, but you must remember that anything on a DVD can be accessed very easily using a computer and a few simple (and free) programs. As such, trying to hide anything behind a code will only provide a nominal level of protection – easily bypassed. It does, however, provide another aspect to the user experience and is always a bit of fun to include.

Making a codelock feature can be done in a few different ways. Using a menu which is set up to look like a number pad you can copy the menu four times and ensure that only one button in each menu links on to the next in the sequence. All others can go to a different screen. That way, the user has to enter the correct number, the menu changes for the second number input and the sequence repeats.

However, you might choose to use a single menu and enter into the world of scripting. Each button on the menu has a value, and you can use a GPRM to track that value, store it and check to see whether or not the entire sequence entered is correct at the end of the sequence. This is probably more secure, but not infallible.

If you go this wa then you’ll need to think about storing and retrieving values from a GPRM… you could end up doing some fairly high level math! Fortunately, Alex Alexzander has provided a way forward, and written a superb tutorial already. Have a look at http://www.sfbaaug.org/tutorials/codelock.html

More about bit-shifting and bitwise operations

calculator imageWe were recently asked why we couldn’t have a disc which allowed the user to pick any number of clips from any number available – like 16 from 16 possible, or 20 from 40 possible. Well, the answer is a bit complex, but in fact you *can* make a disc which allows a certain number of clips to be picked from all those available… but not everything is possible.

The answer lies in the way that DVDSP uses internal memory slots, the GPRMs. These are sixteen bits long and so you can fit a number up to 65535 inside a single register. However, it is not necessary to use all that space to store the value of a user choice. For example, if a user chose clip ’9′ then that number can be held in just four bits. For ease we can divide the register into four sections and so store four user choices per register. The largest four bit number you can get is ’15′, and so unless you want to allow your user to pick more than 15 clips from their menu, you only need to use four bits at a time.

However, imagine that your user had 24 clips to select from. And imagine that your user wanted to pick clip 24 to play. In this case the register would need to store the number ’24′ and to do so it would need to use *five* bits (24 in binary is ’11000′).

OK – this is a challenge, because you can then only store three user choices per register and have a single bit left over. You might naturally think that since we have got eight registers to play with you could easily accommodate all twenty-four clips, but you’d be wrong. Whilst we could store them, we also need memory slots to do our calculations in so that the user choices are placed in the correct spot along the registers, and we keep a count of the number chosen. In short, we need three registers to do the calculations in if we want to keep things short, leaving just five available. This means that you could store up to twenty ’4-bit’ choices (i.e. no more than 15 clips, but the ability to repeat clips up to 20 times), or fifteen ’5-bit’ choices. Since the greatest number that will fit in to five bits is 31, the maximum number of clips cannot exceed 31 on the menu.

So, it is a trade off – if we allow more than 15 clips to be on the menu, we need to use larger bit slots and this complicates the maths involved. If we use 15 clips or less we can easily get these into the registers four bits at a time, and we can store all of them in four GPRMs. This leaves four to do calculations in and track playback and other things. Easy.

I have found that the Calculator in OSX is an invaluable tool when doing this work. I used to use ‘Haxor’ to convert from decimal to binary, but Calculator is so much better. If you use it, go to the ‘view’ menu and choose ‘Programmer’ (or press Apple+3) and you get a display of the binary values above the buttons. Even better, you can click on those binary 1′s and 0′s to change them, and the calculator will update its display. This means it is easy to see what values to use in your scripts according to the bits you turn on and off.

The latest project was to pick fifteen from fifteen available. It works and you can download the resulting disk image here. Unfortunately, this was a commercial project and we cannot give the scripts away free – we will gladly build you a similar project if this is what you want. Please contact us here for more details.

selection menu screen

Multiple Menus with GPRM based button jumps

A recent comment in the Apple discussions prompted this new tutorial – how to combine multiple menus and GPRM based button jumps. The issue is that the viewer needs to go back to the correct menu when there are several that access the same track, and better still, land on the right button… generally the last one they were on!

So here it is, visit the tutorial page, and download the project files to take apart at your leisure.

GPRM Counters

Every now and then a particular feature is explored to see what you can achieve with it. Today the feature was using a GPRM as a counter. In effect, the GPRM can be used as a container, or as a clock. If you set them to be counters they count upwards in one second intervals – which is handy if you want to have something happen within a particular time frame (such as an answer to a quiz question). This article looks at that in more detail, and gives you a link to the project files necessary to explore this for yourself.

GPRM Based Button Jumps

This tutorial has now been added to the site, and is available by clicking on the ‘Tutorials’ link in the navigation bar. There are files to download as well, and these should get you started with creating your own versions of this scripting solution.

GPRM based button jumps are an important thing to be able to do, but they can fail to work if the menu that you are jumping to has got a pre-script attached. If that is the case you either need to remove the pre-script or write out all of the possible button jumps instead of using this rather handy short way of doing things!