The T-Lock System
Sending a code to the video memory
The Bits++ has been designed such that if its video memory is sent a particular combination of 24 bytes it knows that the next few hundred bytes should not be interpretted as pixel colours but should be used to set the values in the CLUT. These 24 bytes are called the T-Lock code. This code and the palette that follows it are not displayed on the screen.
In this way you can change the CLUT using the same commands that you would use to display a line of pixels. For example, you could change the CLUT using the Screen('DrawTexture'...) command provided by the Psychtoolbox. This is how the CLUT is usually changed in the demos provided by CRS for the Bits++. But you could also use any other method which draws on the Bits++ video memory.
Using a bitmap file with a T-Lock code in it
You could create a .bmp file containing the T-Lock code and a palette, open that .bmp file in any graphics application, like Photoshop or Paint, and drag that application's window onto the secondary monitor - the one connected to the computer via the Bits++. As soon as the .bmp is on the secondary screen the Bits++ will see the T-Lock code and the screen will change colour. In fact this is a quick and easy way to confirm that the T-Lock system is working.
Note:
If you look very carefully (perhaps through a microscope!) you might notice that the "red-scale" T-Lock image provided here actually consists of two indentical lines, one of which is shifted one pixel sideways with respect to the other. This is because the T-Lock system requires that the code is aligned on an evenly numbered pixel. Designing the bitmap in this way ensures that one of the two lines triggers the CLUT change wherever it is positioned on the screen.How the Demos Use the T-Lock System
The demos that you can download from the CRS website contain four folders. There is one folder for each of the three modes in which the Bits++ can be used (Mode names: Bits++, Colour++ and Mono++) and there is another folder called 'common'. This is for MatLab scripts and any other files that are generally useful. It contains two MatLab scripts that are used extensively by the demos for changing the CLUT using T-Lock:
- BitsPlusSetClut.m - contains a function which takes a new CLUT as a parameter. The CLUT is in the form of a 256x3 matrix of numbers between 0 and 65535. These are the new RGB values. (Note: they are 16 bit values. The Bits++'s dynamic range is 14 bits, so the lowest 2 bits have no effect.) The function assembles a T-Lock line, much like the one you see in the .bmp image in the previous section of this article, and draws it onto the top line of the screen using the Psychtoolbox command: Screen('PutImage'...). To assemble this T-Lock line it makes use of the function in the file:
- BitsPlusEncodeClutRow.m - The function in this file takes a CLUT as a parameter and returns a line of pixels containing the CLUT and the T-Lock code all formatted ready to be drawn directly onto the Bits++'s screen. As you will see when you look at the demos, when doing palette animation you do not always want to use the BitsPlusSetClut function to create the T-Lock/CLUT row and immediately draw it to the screen. You sometimes prepare it by calling BitsPlusEncodeClutRow directly and then draw it to the screen yourself. This is why BitsPlusEncodeClutRow is a seperate function in a seperate file.