The <graph.h> header file


  
This header file contains the following functions:
BitmapGet           BitmapInit          BitmapPut           BitmapSize
ClearScreen         ClrScr              DrawChar            DrawClipChar
DrawClipEllipse     DrawClipLine        DrawClipPix         DrawClipRect
DrawFkey            DrawIcon            DrawLine            DrawMultiLines
DrawPix             DrawStr             DrawStrWidth        DrawStrXY
DrawTo              FillLines2          FillTriangle        FontCharWidth
FontGetSys          FontSetSys          GetPix              LCD_restore
LCD_save            LineTo              MakeWinRect         MoveTo
PortRestore         PortSet             QScrRectOverlap     RestoreScrState
SaveScrState        ScrRectFill         ScrRectOverlap      ScrRectScroll
ScrRectShift        ScrToHome           ScrToWin            SetCurAttr
SetCurClip
the following global variables:
ScrRect
and the following constants and predefined types:
Attrs               Bool                BoxAttrs            BITMAP
BITMAP_HDR_SIZE     Fonts               ICON                LCD_BUFFER
LCD_MEM             LCD_SIZE            MULTI_LINE          pICON
SCR_COORDS          SCR_RECT            SCR_STATE           WIN_COORDS
WIN_RECT

Functions


void PortSet (void *vm_addr, short x_max, short y_max);

Sets up the virtual screen

PortSet allows drawing in a virtual screen. All graphic commands which are built-in into TIOS does not expect that the video memory must be at 0x4C00, and that the video memory is always 240 x 128 pixels. Using PortSet you can set up a virtual screen anywhere in a memory, and of any size. After using PortSet, all graphic commands will assume that the video memory starts at vm_addr, and that the dimensions of the video memory are (x_max+1) x (y_max+1) pixels. This allows to you to use graphic functions even when the actual LCD memory is relocated at any other address using a I/O hardware ports, or to draw pictures into virtual screens (not visible on the real screen), then move them (using memcpy or some other function) to the real screen. This will enable possibility to hide actual drawing process, and to display the drawn picture immidiately.

Here is a code fragment which ilustrates usage of virtual screens:
void *virtual = malloc (LCD_SIZE);  // Allocate the buffer
...
if (!virtual) ... // do some error handling - not enough memory!
PortSet (virtual, 239, 127); // redirect drawing routines to buffer
or, even simpler, virtual screen may be simply in any local variable which is enough long:
char virtual[3840];
...
PortSet (virtual, 239, 127);
Note that, in this case, virtual screen memory will be in fact somewhere on the stack. There is nothing bad in this, but keep in mind that the total amount of the stack is 16K, so don't put TOO MANY data (like big arrays etc.) on the stack (i.e. in local variables). If you really need to handle a lot of data, use malloc instead.

After setting up the virtual screen, you can do any drawing you want - it will be redirected to the virtual screen. To copy this to the regular screen (i.e. to display it) do this:
memcpy (LCD_MEM, virtual, LCD_SIZE);
or even simpler (this is the same):
LCD_restore (buffer);
NOTE: Don't forget to do PortRestore before end of the program, else TIOS will be fooled after returning to TI-Basic!

void PortRestore (void);

Cancels the virtual screen

PortRestore restores factory defaults for address and dimensions of the video memory. PortRestore acts exactly like
PortSet((void *) 0x4C00, 239, 127);

void ClearScreen (void);

Clears the entire screen.

ClearScreen fills the entire screen (real or virtual) with zeros.

void ClrScr (void);

Clears the entire screen.

ClrScr is a more common alias for ClearScreen.

short FontSetSys (short Font);

Sets the current font.

FontSetSys changes the current text font. All subsequent characters written to the screen will use this font. The supported values for Font are F_4x6, F_6x8, and F_8x10, and they are defined in enum Fonts. The 4x6 font is a proportional font while the 6x8 and 8x10 fonts are fixed-width. FontSetSys returns previous active font number.

short FontGetSys(void);

Gets the current font number.

FontGetSys returns the current font number. See FontSetSys for more info.

void DrawChar (short x, short y, char c, short Attr);

Draws a character.

DrawChar draws a character c at a specific (xy) location. The following character attributes are supported (the region defined by a character is 8x10 for huge font, 6x8 for large font or nx5 for small font, depending on the current font set by FontSetSys command):

A_NORMALThe character is ORed into the destination
A_REVERSEThe region created by inversing the character replaces the destination
A_REPLACEThe region defined by the character replaces the destination
A_XORThe character is XORed into the destination
A_SHADEDThe character is masked so that every other pixel is turned off then ORed into the destination

See SetCurAttr command for a more general info about attributes.

void DrawStr (short x, short y, const char *str, short Attr);

Draws a string.

DrawStr draws a string str at a specific (xy) location. See DrawChar for a description of attribute Attr.

NOTE: Too many people ask me how to draw a content of an integer variable (for example) instead of a string. Although this question is answered in the Frequently Asked Question list, I received a suggestion that it would be better if explained here. Well. You need to use sprintf to convert a non-string variables to a string. For example:
int x, y;
char buffer[50];
...
sprintf (buffer, "%d + %d = %d", x, y, x + y);
DrawStr(0, 0, buffer, A_NORMAL);

void DrawStrXY (short x, short y, const char *str, short Attr);

Draws a string.

DrawStrXY is an alias (known from DoorsOS) for DrawStr.

void DrawLine (short x0, short y0, short x1, short y1, short Attr);

Draws a line between two specified points.

DrawLine draws a line from (x0y0) to (x1y1) using the attribute Attr. The following attributes are supported:

A_NORMALDraw a normal line
A_REVERSEDraw an inverse line (i.e. erase the line)
A_XORDraw a line using XORing with the destination
A_THICK1Draw a double thick line
A_SHADE_VDraw the line using a vertical shading pattern
A_SHADE_HDraw the line using a horizontal shading pattern
A_SHADE_NSDraw the line using a negative slope diagonal shading pattern
A_SHADE_PSDraw the line using a positive slope diagonal shading pattern

See SetCurAttr command for a more general info about attributes. Note that although TI said nothing about it, attributes A_SHADE_V, A_SHADE_H, A_SHADE_NS and A_SHADE_PS work only for lines with slope more than 45 degree (i.e. for lines which are more "vertical" than "horizontal"). For "nearly horizontal" lines all of them act like A_NORMAL. I don't know whether it is a bug, or planned feature. So, if you want to draw shaded-fill rectangle using DrawLine in a loop, use vertical lines for drawing, not horizontal ones!

Using DrawLine (and all other graphic comands which does not clipping) may be harmful if called using parameters which are out of legal range (i.e. out of the screen area).

void DrawPix (short x, short y, short Attr);

Draws a pixel.

DrawPix draws a pixel at (xy), using the attribute Attr. The following attributes are supported:

A_NORMALDraw a pixel
A_REVERSEErase a pixel
A_XORInvert a pixel

See SetCurAttr command for a more general info about attributes.

short GetPix (short x, short y);

Gets the status of a specified pixel.

GetPix gets the status of the pixel located at (xy). Returns TRUE or FALSE depending of whether corresponding pixel is set or reset.

void DrawFkey (short x, short y, short fkey_no, short Attr);

Draws a function key symbol.

DrawFkey draws a string "F<fkey_no>" at (xy), using the attribute Attr, and using small font, regardless of the current font setting. See DrawChar for a description of attribute Attr. fkey_no must be in a range 0-9.

void DrawIcon (short x, short y, const void *Icon, short Attr);

Draws an icon.

DrawIcon draws an icon (a 16x16 bitmap structure given as 16-word group of bits) pointed to by pointer Icon at location (xy) using attribute Attr. Pointer Icon is usually of type pICON (pointer to the ICON structure). The following attributes are supported:

A_NORMALThe icon is ORed into the destination
A_REVERSEThe inversed icon is ANDed into the destination
A_XORThe icon is XORed into the destination
A_SHADEDThe icon is masked so that every other pixel is turned off then ORed into the destination

See SetCurAttr command for a more general info about attributes. See also sprites.h header file for a much faster alternative to the DrawIcon function (useful for games programming).

NOTE: In previous releases of TIGCCLIB (prior 2.0) the documentation said that A_REPLACE attribute is supported. Unfortunately, it seems that this is not true (Daniel Pineo informed me about this problem). Also, information about usage of A_REVERSE was incorrect.

short FontCharWidth (short c);

Determines the character width in pixels.

FontCharWidth returns the actual width of the character c according to current font settings. See also DrawStrWidth.

short DrawStrWidth (const char *str, short Font);

Determines the string width in pixels.

DrawStrWidth returns the actual width of the string str according to the font number given by parameter Font. For 8x10 and 6x8 fonts, this is just 8 or 6 times the length of the string, but the 4x6 font is proportional. See FontSetSys for more info on fonts.

short SetCurAttr (short Attr);

Sets the default attribute.

SetCurAttr sets the default attribute for all commands which haven't an attribute as an explicite parameter to Attr. The interpretation of the attribute depends of concrete graphic command. Some attributes are only valid for certain graphic operation. Legal attribute values are defined in enum Attrs. In a general, the following attributes are supported:

A_REVERSEDestination pixels turned off
A_NORMALDestination pixels turned on
A_XORSource pixels XORed with destination pixels
A_SHADEDDestination pixels masked so that every other pixel turned off
A_REPLACESource pixels replace destination pixels
A_ORSource pixels ORed with destination pixels

For lines the following additional attributes are supported:

A_THICK1Draw a double thick line
A_SHADE_VDraw the line using a vertical shading pattern
A_SHADE_HDraw the line using a horizontal shading pattern
A_SHADE_NSDraw the line using a negative slope diagonal shading pattern
A_SHADE_PSDraw the line using a positive slope diagonal shading pattern

SetCurAttr returns the previous current attribute.

NOTE: Although TI said nothing about it, attributes A_SHADE_V, A_SHADE_H, A_SHADE_NS and A_SHADE_PS work only for lines with slope more than 45 degree (i.e. for lines which are more "vertical" than "horizontal"). For "nearly horizontal" lines all of them act like A_NORMAL. I don't know whether it is a bug, or planned feature. So, if you want to draw shaded-fill rectangle using a line drawing command (for example, DrawLine) in a loop, use vertical lines for drawing, not horizontal ones! Note also that these additional attributes work fine with FillTriangle and FillLines2, but not with ScrRectFill!

void SetCurClip (const SCR_RECT *clip);

Sets the default clipping area.

SetCurClip sets the default clipping area for commands which are sensitive to clipping, but which does not need a clipping area as an explicite parameter (such commands are LineTo, DrawTo and DrawClipPix). Clipping area is a rectangle with corners (x0, y0) and (x1, y1) which is given using a SCR_RECT structure clip. All clip-sensitive drawings will be clipped (truncated) at the current clipping area boundaries. Be awared: the default clipping area at the beginning of the program is not the full screen!

NOTE: TIGCC is a GNU C, so it allows cast constructors. That's why, constructions like
SetCurClip (&(SCR_RECT){{0, 0, 159, 99}})
are legal.

void MoveTo (short x, short y);

Sets the current pen position.

MoveTo sets the current pen position to (xy).

void LineTo (short x, short y);

Draws a clipped line from the current pen position.

LineTo draws a line from the current pen position to the pixel (xy) using the current attribute given with SetCurAttr command, then updates the pen position to those coordinates. The line will be clipped at the current clipping area boundaries given with SetCurClip command.

void DrawTo (short x, short y);

Draws a clipped line from the current pen position.

DrawTo is an alias (known from DoorsOS) for the command LineTo.

void DrawClipPix (short x, short y);

Draws a clipped pixel.

DrawClipPix works exactly like DrawPix, except the pixel will not be drawn if its coordinates are out of clipping zone given by SetCurClip command, and an attribute is not given as an explicite parameter (the attribute given with SetCurAttr command will be used instead).

void DrawClipChar (short x, short y, short c, const SCR_RECT *clip, short Attr);

Draws a clipped character.

DrawClipChar works exactly like DrawChar, except the character will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas.

WIN_RECT *MakeWinRect (short x0, short y0, short x1, short y1);

Builds a structure for representing rectangular area.

MakeWinRect accepts coordinates of two corners (x0y0) and (x1y1) of an rectangular area, and returns the pointer to the structure of type WIN_RECT in which these coordinates are embeded. This command is useful in combination with commands which expect a structure of type WIN_RECT as explicite argument, like DrawClipLine and DrawClipRect.

NOTE: This function returns a static pointer, which will be rewritten with each call. So, you must not use it inside functions which needs more than one parameter of type WIN_RECT like WinFillLines2 etc.

void DrawClipLine (const WIN_RECT *Line, const SCR_RECT *clip, short Attr);

Draws a clipped line.

DrawClipLine draws a line from (x0, y0) to (x1, y1) where coordinates (x0, y0) and (x1, y1) are given in a WIN_RECT structure Line, using the attribute Attr. The line will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas. See DrawLine for a description of supported atributes.

void DrawClipRect (const WIN_RECT *rect, const SCR_RECT *clip, short Attr);

Draws a clipped rectangle.

DrawClipRect draws a rectangle with (x0, y0) and (x1, y1) as corners, where coordinates (x0, y0) and (x1, y1) are given in a WIN_RECT structure rect. The rectangle will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas. The interior of the rectangle remains intact (no fill). The border lines of the rectangle will be drawn using the attribute Attr. See DrawLine for a description of supported line atributes. In addition, the attribute may be ORed with one or more following constants (which are defined in enum BoxAttrs:

B_NORMALDraw a normal rectangle
B_DOUBLEDraw a double thick rectangle
B_ROUNDEDDraw a rectangle with rounded corners
B_CUTDraw a rectangle with the upper corners cut (like in toolboxes)

NOTE: I cannot conclude which is the difference if you OR the attribute with B_NORMAL or if you do not so. Maybe I am stupid.

void DrawClipEllipse (short x, short y, short a, short b, const SCR_RECT *clip, short Attr);

Draws a clipped ellipse

DrawClipEllipse draws an ellipse with centre at (xy), and with semiaxes a and b. The ellipse will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas. The interior of the ellipse remains intact (no fill). The ellipse will be drawn using the attribute Attr. Supported attributes are:

A_NORMALDraw a elipse
A_REVERSEErase a ellipse
A_XORXORs a ellipse into the destination

See SetCurAttr command for a more general info about attributes.
NOTE: Set a = b to draw a circle.

void DrawMultiLines (short x, short y, const void *multi_lines);

Draws a set of lines in one turn.

DrawMultiLines draws a whole set of lines using the single command. The parameter multi_lines is a pointer to the byte-area structure organized as follows: The line will be clipped at the current clipping area boundaries given with SetCurClip command. multi_lines is usually a pointer to the MULTI_LINE structure. See DrawLine for more info about line attributes.

Parameters x and y act as a translation shifters. They are added to all line coordinates before drawing (the structure itself remains intact), so by using the same multi_line with various x-s and y-s, it is possible to draw several instances of the same-shape objects on various places on the screen.

The following example will draw two stars on the screen:
static MULTI_LINE star_shape = {3, 1, 30, 50, 70, 50, 1, 35, 35, 65,
  65, 1, 35, 65, 65, 35};
...
DrawMultiLines(0, 0, &star_shape);
DrawMultiLines(80, 0, &star_shape);

void FillTriangle (short x0, short y0, short x1, short y1, short x2, short y2, const SCR_RECT *clip, short Attr);

Draws a filled triangle.

FillTriangle draws a filled triangle with vertices (x0y0), (x1y1) and (x2y2) using the attribute Attr. The triangle will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas. Supported attributes are:

A_NORMALDraws a solid fill triangle
A_REVERSEDraws an empty triangle (i.e. erase a triangular area)
A_XORXORs a solid fill triangle into the destination
A_SHADE_VDraws a triangle filled using a vertical shading pattern
A_SHADE_HDraws a triangle filled using a horizontal shading pattern
A_SHADE_NSDraws a triangle filled using a negative slope diagonal shading pattern
A_SHADE_PSDraws a triangle filled using a positive slope diagonal shading pattern

See SetCurAttr command for a more general info about attributes.

void FillLines2 (const WIN_RECT *lower_line, const WIN_RECT *upper_line, const SCR_RECT *clip, short Attr);

Draws a filled area between two lines.

FillLines2 fills an area bounded with two lines which coordinates are given in two WIN_RECT structures lower_line (lower bound) and upper_line (upper bound). In fact, it draws a filled polygon whose vertices are (lower_line.x0, lower_line.y0), (lower_line.x1, lower_line.y1), (upper_line.x0, upper_line.y0) and (upper_line.x1, upper_line.y1) using the attribute Attr. Supported attributes are the same as in command FillTriangle. The drawn polygon will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas. If lower_line is above upper_line, nothing will be drawn. To be more precise, "above" means "closer to the top of the screen".

void BitmapGet (const SCR_RECT *rect, void *BitMap);

Gets a bitmap from the screen.

BitmapGet stores a series of bytes (the size of which is defined by BitmapSize) defining a bitmap for a rectangular area (whose boundaries are given using SCR_RECT structure rect) into a buffer pointed to by BitMap. The first two words at address BitMap will contain the height and the width (in pixels) of the rectangular area respectively, then actual data follows. BitMap is usually a pointer to a BITMAP structure.

Here is a simple example which uses BitmapGet and BitmapPut to get a content of TI-89 screen and to restore it later:
#include <tigcclib.h>

int _ti89;

void _main (void)
{
  SCR_RECT full_screen = {{0, 0, 159, 99}};
  char buffer [BITMAP_HDR_SIZE + 160*100/8];   // or 2004 if you like it more
  BitmapGet (&full_screen, buffer);            // store screen in buffer
  clrscr ();
  printf ("Press any key to\nrestore screen...");
  ngetchx ();
  BitmapPut (0, 0, buffer, &full_screen, A_REPLACE);
  ngetchx ();
}
Note that this is just an example: for saving/restoring the whole screen, functions LCD_save and LCD_restore are much more efficient! And, 'buffer' will probably be allocated using malloc in a more realictic example...

void BitmapInit (const SCR_RECT *rect, void *BitMap);

Initializes a bitmap structure.

BitmapInit is an auxilary command (used internally in BitmapGet, so it is not particularly useful). It initializes first two words at address BitMap to the height and the width (in pixels) of the rectangular area rect.

void BitmapPut (short x, short y, void *BitMap, const SCR_RECT *clip, short Attr);

Puts a bitmap to the screen.

BitmapPut puts a bitmap BitMap (which was taken using BitmapGet) on the screen at position (xy), using the attribute Attr. The drawn bitmap will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas. The following attributes are supported:

A_REPLACEReplace the destination region with the source bitmap
A_REVERSEReplace the destination region with the inverse of the source bitmap
A_NORMALOR the source bitmap into the destination region
A_XORExculsive-OR the source bitmap into the destination region
A_OROR the source bitmap into the destination region
A_ANDAND the source bitmap into the destination region
A_SHADEDMask the source bitmap so that every other pixel is turned off and replace the destination region with that result (the source region is left unchanged)

See SetCurAttr command for a more general info about attributes.

NOTE: sprites.h header file supports much faster alternatives to the BitmapPut function for bitmap shapes which are not wider than 32 pixels (useful for games programming).

unsigned short BitmapSize (const SCR_RECT *rect);

Determines a bitmap size in bytes.

BitmapSize returns the size in bytes of a bitmap for a rectangular area given by parameter rect. This size includes the data for the bitmap and the header. See BitmapGet for more info about bitmaps.

short ScrRectOverlap (const SCR_RECT *r1, const SCR_RECT *r2, SCR_RECT *r);

Finds an intersection of two rectangular areas.

ScrRectOverlap finds an intersection of two rectangular areas given in two SCR_RECT structures r1 and r2, and stores coordinates of the intersection in r. ScrRectOverlap returns TRUE or FALSE depending of whether r1 and r2 overlap or not.

short QScrRectOverlap (const SCR_RECT *r1, const SCR_RECT *r2);

Determines whether two rectangular areas overlap or not.

QScrRectOverlap returns TRUE or FALSE depending of whether two rectangular areas given in two SCR_RECT structures r1 and r2 overlap or not.

WIN_RECT *ScrToWin (const SCR_RECT *rect);

Converts structure of type SCR_RECT to type WIN_RECT.

ScrToWin accepts a pointer rect to the structure of type SCR_RECT and returns a static pointer to the structure of type WIN_RECT which represents the same rectangular area.

SCR_RECT *ScrToHome (SCR_RECT *rect);

Shifts structure of type SCR_RECT to the home position.

ScrToHome modifies the structure pointed to by rect so that the modified structure will represent the same-shape rectangular area, but with topleft corner at position (0, 0). ScrToHome returns rect back (but note that the structure pointed to by it is modified).

void ScrRectFill (const SCR_RECT *rect, const SCR_RECT *clip, short Attr);

Draws a filled rectangle.

ScrRectFill draws a filled rectangle given by SCR_RECT structure rect, using the attribute Attr. The rectangle will be clipped at the boundaries of the area given by parameter clip. See SetCurClip for more info about clipping areas. Supported attributes are:

A_NORMALFill with black pixels
A_REVERSEFill with white pixels
A_XORAll pixels in the rectangle will be reversed

FillLines2 is more complicated and slower function than ScrRectFill, but it supports much more attributes. See SetCurAttr for more info about attributes.

NOTE: TI said that attribute A_SHADED (set to a pattern of pixels on and off) is also supported, but it didn't work when I tried it; at least, it does not work on AMS 1.00.

void ScrRectScroll (const SCR_RECT *rect, const SCR_RECT *clip, short NumRows, short Attr);

Scrols a rectangular area upwards or downwards.

ScrRectScroll scrolls a rectangular area which is an intersection of two rectangular areas given using two SCR_RECT structures rect and clip upwards by NumRows pixels (or downwards if NumRows < 0). rect usually represents the actual area which need to be scrolled, and clip is the clipping area. See SetCurClip for more info about clipping areas. The attribute Attr determines what happens with pixels in a vacant space produced after scrolling:

A_NORMALPixels in a vacant space are set
A_REVERSEPixels in a vacant space are reset
A_XORPixels in a vacant space are inverted

See SetCurAttr command for a more general info about attributes.

NOTE: This command is internally realized stupidly using BitmapGet and BitmapPut, so it is slow.

void ScrRectShift (const SCR_RECT *rect, const SCR_RECT *clip, short NumCols, short Attr);

Shifts a rectangular area left or right.

ScrRectShift shifts a rectangular area which is an intersection of two rectangular areas given using two SCR_RECT structures rect and clip left by NumRows pixels (or right if NumRows < 0). The attribute Attr determines what happens with pixels in a vacant space produced after shifting. For more info, see ScrRectScroll command.

void SaveScrState (void *buffer);

Saves a state of the graphic system.

SaveStrState saves a current state of the graphic system (including the address and dimensions of the virtual screen, current font, attribute, clipping area and pen position) into a 18-byte structure pointed to by buffer. buffer is usually a pointer to SCR_STATE structure.

void RestoreScrState (const void *buffer);

Restores a a saved state of the graphic system.

RestoreScrState restores a saved state of the graphic system (saved using SaveScrState command) from a structure pointed to by buffer.

void LCD_save (void *buffer);

Saves the content of the LCD screen.

LCD_save saves the whole content of the screen into the 3840-bytes long buffer pointed to by buffer. buffer is usually of type LCD_BUFFER. LCD_save is a small macro which calls memcpy function.

void LCD_restore (void *buffer);

Restores the saved content of the LCD screen.

LCD_restore restores the content of the screen (saved using LCD_save from the buffer pointed to by buffer. buffer is usually of type LCD_BUFFER. LCD_restore is a small macro which calls memcpy function.


Global variables


SCR_RECT *const ScrRect;

ScrRect is a (constant) pointer to a SCR_RECT structure set by TIOS to point to a structure which represents the whole screen area without the help line. So, if you don't need drawing in the help line, you can set the default clipping area using SetCurClip command like
SetCurClip (ScrRect);
or, you can use ScrRect in a command which needs clipping area parameter explicitely (such command is DrawClipEllipse, for example):
DrawClipEllipse(50, 50, 30, 20, ScrRect, A_NORMAL);
ScrRect may be used also to determine a calculator type. If
ScrRect->xy.x1 == 159
then the calculator is TI-89, else it is TI-92 Plus.

NOTE: ScrRect is a variable, so it may be changed (more precise, the structure on which it points may be changed). By changing it, it is possible to force some TIOS commands which normally can not access to the status line area to get the access to this "forbiden" zone, or to force some commands to use only smaller part of the screen. Use this possibility with great care, and only if you know exactly what you are doing!


Constants and predefined types


enum Bool

Bool is enumerated type for describing true or false values. It is defined as
enum Bool {FALSE, TRUE};

enum Attrs

Attrs is enumerated type for describing legal attribute values. It is defined as
enum Attrs {A_REVERSE, A_NORMAL, A_XOR, A_SHADED, A_REPLACE, A_OR, A_AND,
  A_THICK1, A_SHADE_V, A_SHADE_H, A_SHADE_NS, A_SHADE_PS};
For more info about attributes, see SetCurAttr command.

enum BoxAttrs

BoxAttrs is enumerated type for describing addittional box attribute values. It is defined as
enum BoxAttrs {B_NORMAL = 0x10, B_ROUNDED = 0x20, B_DOUBLE = 0x40,
  B_CUT = 0x80};
For more info about box attributes, see DrawClipRect command.

enum Fonts

Fonts is enumerated type for describing legal font values. It is defined as
enum Fonts {F_4x6, F_6x8, F_8x10};
For more info about fonts, see FontSetSys command.

type SCR_COORDS

SCR_COORDS is an alias type for defining physical screen coordinates. It is defined as
typedef unsigned char SCR_COORDS;

type WIN_COORDS

WIN_COORDS is an alias type for defining logical screen coordinates. It is defined as
typedef short WIN_COORDS;

type SCR_RECT

SCR_RECT is a scructure (more precise, an union) for defining a rectangular area using psysical screen coordinates. It is defined as
typedef union
  {
    struct
      {
        unsigned char x0, y0, x1, y1;
      } xy;
    unsigned long l;
  } SCR_RECT;
Instead of giving four coordinates x0, y0, x1 and y1, it is possible to give all together using a field l which is a packed long number. See also ScrRect global variable.

NOTE: TIGCC is a GNU C, so it allows cast constructors. That's why, constructions like
DrawClipEllipse (50, 50, 30, 20, &(SCR_RECT){{0, 0, 159, 99}}, A_NORMAL);
are legal. See DrawClipEllipse for info about this command.

type WIN_RECT

WIN_RECT is a scructure for defining a rectangular area using logical screen coordinates. It is defined as
typedef struct
  {
    short x0, y0, x1, y1;
  } WIN_RECT;
As some TIOS commands accepts structure of type WIN_RECT as explicite parameter, function MakeWinRect is implemented, which returns a pointer to the WIN_RECT scructure. You can use it like in following example:
DrawClipRect (MakeWinRect (20, 20, 80, 60), ScrRect, A_NORMAL);
See DrawClipRect and ScrRect for more info about command used in this example.

type ICON

ICON is a structure which describes an icon (a 16x16 pixel area), which is used in DrawIcon command. It is defined as
typedef struct
  {
    unsigned short i[16];
  } ICON;

type pICON

pICON is a pointer to the ICON scructure. It is defined as
typedef unsigned short *pICON;

const BITMAP_HDR_SIZE

BITMAP_HDR_SIZE is a constant (with value 4) which defines the size of a header of the BITMAP structure.

type BITMAP

BITMAP is a structure for defining a bitmap, used in commands like BitmapGet. It is defined as
typedef struct
  {
    unsigned short NumRows, NumCols;
    unsigned char Data[0];
  } BITMAP;
Note that Data[0] is GNU C extension for variable-length areas (TIGCC is GNU C).

type SCR_STATE

SCR_STATE is a structure used for saving state of the graphic system, used in commands SaveScrState and RestoreScrState. It is defined as
typedef struct
  {
    void *ScrAddr;
    unsigned char XMax, YMax;
    short CurFont, CurAttr, CurX, CurY;
    SCR_RECT CurClip;
  } SCR_STATE;

type MULTI_LINE

MULTI_LINE is a structure used for defining multiple lines for DrawMultiLines command. It is defined as
typedef struct
  {
    unsigned char Count;
    struct
      {
        unsigned char Attr, x0, y0, x1, y1;
      } Data[0];
  } MULTI_LINE;
Note that Data[0] is GNU C extension for variable-length areas (TIGCC is GNU C). Static variables of such types may be initialized with a variable-length constructor, for example:
static MULTI_LINE star_shape = {3, 1, 30, 50, 70, 50, 1, 35, 35,
  65, 65, 1, 35, 65, 65, 35};
Initialization with a variable-length constructor is not suitable for non-static (auto) variables, because the amount of stack storage will not be determined properly.

type LCD_BUFFER

LCD_BUFFER is a 3840-bytes long array type. Its main purpose is to declare a buffer for saving and restoring content of the LCD screen using functions LCD_save and LCD_restore. It is defined as
typedef char LCD_BUFFER[3840];
so, it is long enough to accept the content of the screen on both TI-89 and TI-92 Plus.

const LCD_MEM

LCD_MEM is a void pointer with value (void *)0x4C00 which points to the LCD screen.

const LCD_SIZE

LCD_SIZE is an integer constant (with value 3840) which represents size in bytes of the LCD screen.

Return to the main index