 |
You want to start using the build in 4 grayscale mode for your programs too?
Why use grayscale?
The only reason why to use grayscale is basiclt that you can do applications/games
more detailed. It's like an eye-candy feature. What you have to have in mind
is that your application will be both bigger, and slower using graymode, and this
because you have to print stuff twice, and define stuff perhaps twice sometimes.
How does it work?
Actualy graymode is just a trick for your eyes. What it does is having
two planes of screen information (what's on the screen that is). Then it
shows those two planes different fast. Light Gray = draw stuff on the plane that
shows very short time (this will trick you to beleve it has a light gray color).
if you want Dark gray, then you choose to draw to the plane which is drawn alittle longer
than the Light plane. And if you want black, then draw to both planes (white is offcause
when you draw to none of the planes).
How to use graymode
Using graymode is very simple. Here's an example taken from the TIGCC documentation:
#define SAVE_SCREEN
#include
int _ti89;
void _main(void)
{
if (!GrayOn ()) return;
SetPlane (LIGHT_PLANE);
ClrScr ();
ScrRectFill (&(SCR_RECT){{20, 20, 40, 40}}, ScrRect, A_NORMAL);
ScrRectFill (&(SCR_RECT){{80, 20, 100, 40}}, ScrRect, A_NORMAL);
SetPlane (DARK_PLANE);
ClrScr ();
ScrRectFill (&(SCR_RECT){{50, 20, 70, 40}}, ScrRect,A_NORMAL);
ScrRectFill (&(SCR_RECT){{80, 20, 100, 40}}, ScrRect,A_NORMAL);
ngetchx ();
GrayOff ();
}
|
Let's explain this. The First line, we check if we succed starting graymode.
If we doesn't, leave the program directly to avoid crashes (return;).
Next step, we switch to the Light plane, and we clear it with ClrScr(); (just like
normal). Then we draw two Light_Gray rectangles. We swith to the Drak plane, and
we clear the Dark plane (Note that the Light plane will still remain now!).
And we draw two Dark_Gray rectangles. Note now, that we have drawn two rectagles at the
same coordinates (80,20,100,40). That rectangle will be Black! The two other will
have the color of what plane it's drawn to (Light/Dark gray). The next line is familiar, wait for a key to be pressed,
and then we have to dissable the grayscale mode. If we don't do that, the calculator will crash very soon after quiting (and
you will get graphical errors as well).
Graymode and Sprites
If you've read the tutorial about making sprites, you might remember that we
drawed the sprite with this line:
Sprite8 (x, y, height, cursor, LCD_MEM, mode);
Now this will not work in Gray mode, because LCD_MEM isn't used. We're using DARK_PLANE and LIGHT_PLANE
instead, so now we have to draw this sprite (if we still want it black) like this:
Sprite8 (x, y, height, cursor, GetPlane(DARK_PLANE), mode);
Sprite8 (x, y, height, cursor, GetPlane(LIGHT_PLANE), mode);
As you can se, you call it twice, one for each plane. Offcause you dont need the same sprite on
those planes, perhaps you want a light gray border on the cursor, and therefor makes a modified
cursor sprite for the Light plane.
Can Graymode damage my calculator?
No it can't damage your calculators hardware, nor software. What you should have
in mind though is that a graymode application will take up more memory, and use
more batteries to run.
If you have any question about this tutorial, be sure to drop me a mail
|
| |