Wednesday Jan 16, 2019
Often people ask how to make games in DVD SP. The general answer is DVDs are not the bes things for games, and often, for the most part, other programs and media, such as Flash or Director on a CD-ROM, may provide more pleasent and repsonsive results. Plus the programing languages, when compared to DVD SPs scripting, are often more robust and/or just generally easier to deal with than drop downs for scripting. That being said, there wwas a question on how to make a Bingo Game. I did the brute force method to start with the caveat that it was, well just brute force, and there are better ways to approach it - meaning less coding and faster interactivity.
The first thing I did was to patirtion the first GPRM into 2 sections, called RandomomSelected and RandomHolder. I then namesed 5 GRPMs as in the list below. This is also a script, called "Clearer", which sets the variables to 0 and then jumps to another script called mixer. (As an aside the DVD starts with a Menu that has a button that when pressed calls "Clearer")
The next script is Mixer, where most of the action occurs.<
Before going further, it is important to note how DVD SP holds" numbers - the maximum number value in a NON-partitioned GPRM is 65535, and the GRPMs have 16 bits which are either on or off. As the able below shows, if bit 0 is one it represents a value of 1. If bit 11 is on it represents a value of 2048. If any bit is off, it is a value of 0. If all 16 bits are on, the total value is 65535. And by combining the on and offs you can get every value in between. The table right below shows the names I used for the GPRMs and the respective Bingo Numbers for the bits. If, for example, bit 3 in GPRM 1-16 is On (not equal to 0) then it has been selected, otherwise it has not. Now onto the script.
Lines 1 -5 check to see if all balls have been selected. If the GPRMs are equal to 65535 (or 2047 for Balls 65 through 75) then all balls for the GPRM have been pulled. If the script makes through line 5 then all have been pulled, so it goes to the game over screen (Line 6). Otherwise the lines break the script out by calling line 7 and starting the random process.
Line 7 places the value into RandomHolder.
Line 8 moves the RandomSelected into RandomHolder and Line 9 makes the RandomHolder mod 16 (values of 0 through 15).
Since mod 16 will produce 0-15 (with 0 being 16 for purposes of this script), line 10 changes Mod 0 to 16
Line 11 sets a GPRM which I called MaskValue, to 1
Line 12 jumps to line 14 which subtracts 1 from the value of RandomHolder (which is a number between 1-16). If RandomHolder is > 0 then the line 15 of the script goes back to line 13 and multiplies the MaskValue by two. This process will generate one of the following numbers 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192 and you can probably guess the rest - they are the numbers in the table above.
Lines 16-20 moves (mov) the value of the GPRMs representing the balls we want to look at into GPRM 7. You could jump lines after each of these lines (i.e., make line 17 jump line x if RandomSelected is y) but I saved a few lines of code. 21 is the important line, the "and" operator masks a GPRM to isolate certain registers and values. For instance add GPRM 7, 2 means the value in bit 2. If the bit has not been turned on it is 0 and if the value HAS been turned on then the value is NOT equal to 0. And line 22 kicks up to Line 7 to run another RandomSelected if the bit is already on (ball selected) or it adds the MaskValue to the proper BallSelection GPRM (23-32).
Lines 32 through 35 then go to the proper menu. NOTE THAT JUMP INDIRECT MAY NOT BEHAVE PROPERLY SOMETIMES SO BEWARE!!! Also depending on the version of DVD SP lines 33 and 34 may need to be changed!! Anyway, Line 32 moves the RandomSelected (values of 1-75) into GPRM 7 Line 33 multiplies the number by 32. Here's the trick - DVD SP "knows" which menu to jump to based on this value. For instance Menu 1, is 32 and so on. (Again keeping the earlier warnings in mind and also noting that if you look in VTS view the menus are in the order of the image below.)
NOTE: To hard code the items (changing lines 32 and on) you can route to the menus, though it will be a bit slower. I am fairly certain these scripts work properly, but have not all the debugging and testing I would do if this was "for real". You can download the zip files with both versions here