GPRM Based Button Jumps
By Hal MacLean
Quite often when your user is returning to a menu you’ll want them to get back to the last button that they had selected. This is especially true if you have a menu with a lot of buttons on it. If you don’t specify the appropriate button the user will go to the default one, which is usually button1. There are several ways to accomplish this, but by far the neatest is to use a GPRM based button jump.
Fortunately, your DVD player will automatically store the last button the user chose for you, placing the value into an internal register (a ‘System Parameter Register Memory’) called SPRM8. These memory slots are not directly accessible by you as an author to write to, but you can read the values in them easily enough.
So what you need to do is create a script and add three lines by clicking on the ‘+’ button in the script editor window. This will add three ‘Nop’ lines and you click on the first one. in the property inspector you are going to use the drop down menus to create your script. The first line needs to get the button value from SPRM8.
The button values start at 1024 for button1 and increment by 1024 for every subsequent button. This means button 4 would have a value of 4096 and the maximum value for button 36 would be 36864. The line to get the button value is this:
Mov GPRM0, SPRM8
This means that you now need to use line two of your script to convert that value into a useful one which we can use when jumping to a button. Since the button values in your menu start at ‘1′, you need to divide the value in GPRM0 by 1024:
Div GPRM0, 1024
Now, all you have left to do is to write the jump itself. The way this works is that you specify the menu that you want to jump to, and the code fills in the button number automatically. The way you write it is to use the GPRM Button Jump checkbox after using the Jump command in the script editor. Your last line looks like this:
Jump Menu1 [GPRM0]
And that’s it! You can now set your end jump for the track (and your menu call too if you wish) to go to this simple script. You will go back to the menu and land on the last button that was selected. Your final script should look like this:
Mov GPRM0,SPRM8 Div GPRM0, 1024 Jump Menu1 [GPRM0]
Limitations
There are times when a GPRM based button jump will not work. The most common is when you also use a menu pre-script, or set this up as a pre-script. The button jump value is ignored and you will land on the default button every time. The way around this is to make sure that the menu doesn’t have a pre-script. Any such script can be made ‘free standing’ by simply adding a final line which jumps to the menu it was attached to anyway. If you do this your button jumps will work.
Extending the script
You might choose to land on the next logical button on your menu, so that your user doesn’t have to do anything more than press ‘Enter’ on the remote control. How lazy can you get?! It’s OK - we’ve all been there!
All you do is add a ‘1′ to your button value as a new line in your script:
Mov GPRM0,SPRM8 Div GPRM0, 1024 Add GPRM0, 1 Jump Menu1 [GPRM0]
But be careful! What if you were on button 36 before (or whatever your last button is)? Where will you go now? You also need to add a conditional section that checks to see if you were on the last button available. You already know how many buttons you have got on the menu, and you know they increment in jumps of 1024. You need to calculate what the maximum value is for your menu and add in a final line to go to the default button if you were on the last menu button. It’s a bit manual, but it will work. Let’s imagine a four button menu - the top value will be 4096. The script then needs to say:
Mov GPRM0,SPRM8 Div GPRM0, 1024 Jump Menu1 If(GPRM0 = 4) Add GPRM0, 1 Jump Menu1 [GPRM0]
So now the script reads “get the last selected button value and make it usable. If it was the last button on the menu, jump to the first button, otherwise, add ‘1′ to it and then jump to the corresponding button on the menu.
As ever in scripting the order of the lines is crucial to getting the logic right. Scripts are read a line at a time and if there is something to evaluate then that happens first. if it is ‘true’ then the command happens. If not, the next line is read and acted upon. Knowing that you can structure your scripts better!
