Using the T-Lock System with BitsPlusSetClut and BitsPlusEncodeClutRow
The demos that you can download from the CRS website contain a folder called 'common'. This is for general purpose Matlab scripts. 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 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.