| compat.h | Header File

Header File Index

Various calc-dependent and AMS-dependent pseudo-constants

This header file contains a set of various pseudo-constants (i.e. macros defined to look and work like constants), dedicated to increase compatibility between the TI-89 and TI-92 Plus and between AMS versions. These "constants" have different values on the TI-89 and TI-92 Plus (or on AMS 1.xx and AMS 2.xx). Using these pseudo-constants, you can, for example, perform keyboard reading and graphic calculations in a more sophisticated way, check the AMS version and perform some AMS-dependent actions (although this is not recommended if not really necessary), etc.
The following table shows all defined pseudo-constants. A lot of them are known from DoorsOS, but they are defined here to work in both "nostub" and "Doors" mode.

Functions

PSEUDO_CONST_CALC
  A macro to construct a pseudo-constant from calculator-based values.
PSEUDO_CONST_KBD
  A macro to construct a pseudo-constant from keyboard-based values.
PSEUDO_CONST_SCREEN
  A macro to construct a pseudo-constant from screen-based values.

Constants

AMS_1xx
  TRUE on AMS 1.xx, FALSE on AMS 2.xx and AMS 3.xx.
AMS_2xx
  TRUE on AMS 2.xx, FALSE on AMS 1.xx and AMS 3.xx.
AMS_3xx
  TRUE on AMS 3.xx, FALSE on AMS 1.xx and AMS 2.xx.
CALCULATOR
  Describes the calculator model.
HW_VERSION
  Describes the hardware version.
KEY_DIAMOND
  The number added to the key code if the Diamond key is pressed with it (see ngetchx).
KEY_DOWN
  Key code for the down arrow key (see ngetchx).
KEY_DOWNLEFT
  Key code for simultaneous pressing of the down and left arrow keys (see ngetchx).
KEY_LEFT
  Key code for the left arrow key (see ngetchx).
KEY_OFF2
  The key code for Diamond+ON (see ngetchx).
KEY_RIGHT
  Key code for the right arrow key (see ngetchx).
KEY_SHIFT
  The number added to the key code if the Shift key is pressed with it (see ngetchx).
KEY_UP
  Key code for the up arrow key (see ngetchx).
KEY_UPRIGHT
  Key code for simultaneous pressing on up and right arrow keys (see ngetchx).
LCD_HEIGHT
  Height of the screen in pixels.
LCD_LINE_BYTES
  Number of bytes in the visible part of a screen line.
LCD_WIDTH
  Width of the screen in pixels.
ROM_base
  Base address of the ROM (0x200000 on TI-89 or V200, 0x400000 on TI-92 Plus, 0x800000 on TI-89 Titanium).
RR_0
  A pseudo-constant pair for the '0' key.
RR_1
  A pseudo-constant pair for the '1' key.
RR_2
  A pseudo-constant pair for the '2' key.
RR_3
  A pseudo-constant pair for the '3' key.
RR_4
  A pseudo-constant pair for the '4' key.
RR_5
  A pseudo-constant pair for the '5' key.
RR_6
  A pseudo-constant pair for the '6' key.
RR_7
  A pseudo-constant pair for the '7' key.
RR_8
  A pseudo-constant pair for the '8' key.
RR_9
  A pseudo-constant pair for the '9' key.
RR_2ND
  A pseudo-constant pair for the '2nd' key.
RR_A
  A pseudo-constant pair for the 'A' key.
RR_ALPHA
  A pseudo-constant pair for the Alpha key.
RR_APPS
  A pseudo-constant pair for the 'APPS' key.
RR_B
  A pseudo-constant pair for the 'B' key.
RR_BCKSPC
  A pseudo-constant pair for the backspace key.
RR_C
  A pseudo-constant pair for the 'C' key.
RR_CATALOG
  A pseudo-constant pair for the 'CATALOG' key.
RR_CLEAR
  A pseudo-constant pair for the 'CLEAR' key.
RR_COMMA
  A pseudo-constant pair for the ',' key.
RR_COS
  A pseudo-constant pair for the 'COS' key.
RR_D
  A pseudo-constant pair for the 'D' key.
RR_DIAMOND
  A pseudo-constant pair for the Diamond key.
RR_DIVIDE
  A pseudo-constant pair for the '/' key.
RR_DOT
  A pseudo-constant pair for the '.' key.
RR_DOWN
  A pseudo-constant pair for the down arrow key.
RR_E
  A pseudo-constant pair for the 'E' key.
RR_EE
  A pseudo-constant pair for the 'EE' key.
RR_ENTER1
  A pseudo-constant pair for the first 'ENTER' key.
RR_ENTER2
  A pseudo-constant pair for the second 'ENTER' key.
RR_ENTER
  A pseudo-constant pair for the 'ENTER' key.
RR_EQUALS
  A pseudo-constant pair for the '=' key.
RR_ESC
  A pseudo-constant pair for the 'ESC' key.
RR_F1
  A pseudo-constant pair for the 'F1' key.
RR_F2
  A pseudo-constant pair for the 'F2' key.
RR_F3
  A pseudo-constant pair for the 'F3' key.
RR_F4
  A pseudo-constant pair for the 'F4' key.
RR_F5
  A pseudo-constant pair for the 'F5' key.
RR_F6
  A pseudo-constant pair for the 'F6' key.
RR_F7
  A pseudo-constant pair for the 'F7' key.
RR_F8
  A pseudo-constant pair for the 'F8' key.
RR_F
  A pseudo-constant pair for the 'F' key.
RR_G
  A pseudo-constant pair for the 'G' key.
RR_H
  A pseudo-constant pair for the 'H' key.
RR_HAND
  A pseudo-constant pair for the Hand key.
RR_HOME
  A pseudo-constant pair for the 'HOME' key.
RR_I
  A pseudo-constant pair for the 'I' key.
RR_J
  A pseudo-constant pair for the 'J' key.
RR_K
  A pseudo-constant pair for the 'K' key.
RR_L
  A pseudo-constant pair for the 'L' key.
RR_LEFT
  A pseudo-constant pair for the left arrow key.
RR_LN
  A pseudo-constant pair for the 'LN' key.
RR_M
  A pseudo-constant pair for the 'M' key.
RR_MINUS
  A pseudo-constant pair for the '-' key.
RR_MODE
  A pseudo-constant pair for the 'MODE' key.
RR_MULTIPLY
  A pseudo-constant pair for the '*' key.
RR_N
  A pseudo-constant pair for the 'N' key.
RR_NEGATE
  A pseudo-constant pair for the negation key.
RR_NO_KEY
  A constant which means that a specific key does not exist.
RR_O
  A pseudo-constant pair for the 'O' key.
RR_P
  A pseudo-constant pair for the 'P' key.
RR_PAREN_CLOSE
  A pseudo-constant pair for the ')' key.
RR_PAREN_OPEN
  A pseudo-constant pair for the '(' key.
RR_PLUS
  A pseudo-constant pair for the '+' key.
RR_POWER
  A pseudo-constant pair for the '^' key.
RR_Q
  A pseudo-constant pair for the 'Q' key.
RR_R
  A pseudo-constant pair for the 'R' key.
RR_RIGHT
  A pseudo-constant pair for the right arrow key.
RR_S
  A pseudo-constant pair for the 'S' key.
RR_SHIFT
  A pseudo-constant pair for the Shift key.
RR_SIN
  A pseudo-constant pair for the 'SIN' key.
RR_SPACE
  A pseudo-constant pair for the space key.
RR_STORE
  A pseudo-constant pair for the Store key.
RR_T
  A pseudo-constant pair for the 'T' key.
RR_TAN
  A pseudo-constant pair for the 'TAN' key.
RR_THETA
  A pseudo-constant pair for the 'q' key.
RR_U
  A pseudo-constant pair for the 'U' key.
RR_UP
  A pseudo-constant pair for the up arrow key.
RR_V
  A pseudo-constant pair for the 'V' key.
RR_W
  A pseudo-constant pair for the 'W' key.
RR_WITH
  A pseudo-constant pair for the '|' key.
RR_X
  A pseudo-constant pair for the 'X' key.
RR_Y
  A pseudo-constant pair for the 'Y' key.
RR_Z
  A pseudo-constant pair for the 'Z' key.
TI89_CLASSIC
  TRUE on a classic TI-89 (i.e. a TI-89 which is not a TI-89 Titanium), FALSE otherwise.
TI89_TITANIUM
  TRUE on a TI-89 Titanium, FALSE otherwise.
TI89
  TRUE on a TI-89, FALSE otherwise.
TI92PLUS
  TRUE on TI-92 Plus, FALSE otherwise.
TIOS_entries
  Number of entries in the TIOS jump table.
V200
  TRUE on V200, FALSE otherwise.

Note: All of these pseudo-constants are in fact macros. Although they expand to relatively small code (in "Doors" mode they are mainly implemented as RAM calls and managed by kernel), it is recommended to store a pseudo-constant in an ordinary variable if you use it a lot of times in the program (especially in "nostub" mode), and to use this variable instead. For example, if you use the KEY_LEFT pseudo-constant too often, it is recommended to define

    int key_left = KEY_LEFT;

somewhere at the beginning of the program, and to use

    if (key == key_left) ...

instead of

    if (key == KEY_LEFT) ...

Such indirection will save memory, but note that this is necessary only if you use the same pseudo-constant a lot in the program (say, more than 5 times).
There is yet another note. Pseudo-Constants work as constants in nearly all cases, but they are not really constants, so they can not be used in case labels inside switch statements, i.e. the following is not legal:

    switch (ngetchx ())
      {
        case KEY_LEFT:
          ...
        case KEY_RIGHT:
          ...
        ...
      }

Instead, use if...else constructions:

    key = ngetchx ();
    if (key == KEY_LEFT)
      {
        ...
      }
    else if (key == KEY_RIGHT)
      {
        ...
      }
    ...

The pseudo-constants really become constants if you compile only for one calculator model. For example, if you define `USE_TI89` and nothing else, CALCULATOR will have the value `0`, and all other pseudo-constants will be optimized into single values. Or, if you define `MIN_AMS` to be `200`, AMS_1xx will always be false.