TIPower Language Reference

Add
And
AsmOff
AsmOn
Byte
Case
CaseElse
ClearMemory
CopyMemoryAbridged
CopyMemoryDown
CopyMemoryUp
Data
DataStart
Dec
DeclareFunction
Div
Djnz
DjnzVar
Do
EndData
EndDjnz
EndDjnzVar
EndExec
EndFor
EndFunction
EndIf
EndSelect
EndSprite
EndSystemFunction
Equate
EscapeFunction
For
Function
If
IfKey
Inc
InterruptRoutine
KeyDown
MathOperators
MemSpace
Mult
Not
Or
Pointer
PreprocessorDirectives
Rem
Select
Set
Sprite16
Sprite8
StartExec
String
Sub
SysFuncRequire
SystemFunction
Title
VarString
While
Word
Xor
Add
 Syntax:   Add( variable, [variable,] value )
 Description:  
Alt: variable += value or variable = variable + value. See
Math Operators.
 Example:  
Byte(a, b)
Function(myadd)
  a = 2
  a += 4 / a now equals 6
  b = a + 3     / b now equals 9
EndFunction


And
 Syntax:   And( variable, [variable,] value )
 Description:  
ANDS variable with value and assigns result to variable. See the example for a good explanation
 Example:  
Byte(a,b,c)
Function(AndTime)
  a = %01001011
  b = %11010010
  And(a, %11111111) / a now equals %01001011
  And(a, a, b) / a now equals %01000010
EndFunction


AsmOff
 Syntax:   AsmOff( void )
 Description:  
See
AsmOn.

AsmOn
 Syntax:   AsmOn( void )
 Description:  
Incorporates ASM code following the statement straight into the final source code. This is useful for programmers who are fluent with ASM and want to add special optimizations, etc. Comments in an AsmOn block use a ';' not a '/'. Labels and variable names should also be in all caps.
 Example:  
AsmOn
  ld hl,(SYSBYTEARG0) ;adds 2 to sysbytearg0
  inc (hl)
  inc (hl)
AsmOff


Byte
 Syntax:   Byte( varname1[, varname2, varname3, etc..] )
 Description:  
Declares a byte size variable. Values for a byte are integers ranging from 0 to 255. If a math operation assigns a value more than 255 to a byte, it is flipped over, like 255+5=4. You can declare up to 16 bytes at a time. All variables declared in TIPower are global and accessable as well as declarable in any place.
 Example:  
Byte(xpos,ypos)

Case
 Syntax:   Case( value )
 Description:  
Value can be anything, including variables. Must be enclosed in parantheses! Variations include Case, CaseLess, and CaseMore. See
Select for an example.

CaseElse
 Syntax:   CaseElse( value )
 Description:  
Traps every possibility not used yet in a Select..Case...EndSelect structure. See
Select for more info and an example.

ClearMemory
 Syntax:   ClearMemory( size, location )
 Description:  
Fills memory at location with 0. Use this really to clear buffers or initialize large amounts data.
 Example:  
/ this clears the screen buffer on any calculator:
  ClearMemory(NUMSCREENBYTES, VIDEOBUFF)


CopyMemoryAbridged
 Syntax:   CopyMemoryAbridged( height, width, skip, destination, source )
 Description:  
This is used for dealing with very large sprites of any width. Height is the width of the sprite in rows. Width is the width of the sprite in bytes (pixels/8). Skip is the difference between the sprite and the screen in width. When copying, the program does this: writes width bytes, skips skip bytes, writes width bytes, etc. There are three variations of CopyMemoryAbridged: CopyMemoryAbridgedSkipBoth (for when you are copying from a large sprite buffer to another large sprite buffer), CopyMemoryAbridgedSkipDest (for when you are copying a large sprite buffer to the screen), and CopyMemoryAbridgedSkipSource (for when you are copying a segment of the screen to a large sprite buffer). See the example for a common usage.
 Example:  
/ Code for a 96x64 title screen:
#onlyTI83P
  CopyMemoryUp(NUMSCREENBYTES,VIDEOBUFF, titlescreenData)
#endonly
/in order to display properly, you have to skip a few bytes
/each row when copying to a TI-86 screen:
#onlyTI86
  CopyMemoryAbridgedSkipDest(64,12,4,$fc02,titlescreenData)
#endonly


CopyMemoryDown
 Syntax:   CopyMemoryDown( size, destination, source )
 Description:  
Copies a large amount of memory BACKWARD through memory. Useful really only if you want to scroll the screen down.
 Example:  
#onlyTI86
/ scroll screen down
  CopyMemoryDown(1008, $ffff, $ffef)
#endonly
#onlyTI83P
  Data(VIDEOBUFF+767, VIDEOBUFF+755)
  CopyMemoryDown(756, VIDEOBUFF+767, VIDEOBUFF+755)
#endonly


CopyMemoryUp
 Syntax:   CopyMemoryUp( size, destination, source )
 Description:  
Copies a large amount of memory going FORWARD through memory. Set the destination to be one byte ahead of the source, and then whatever is in the first source byte will fill the rest of size. Use this primarily on TI-86's to copy the buffer or on any calculator to scroll the screen up.
 Example:  
#onlyTI86
/ scroll screen up
  CopyMemoryUp(1008, $fc00, $fc10)
#endonly
#onlyTI83P
/ scroll screen up
  Data(VIDEOBUFF+12)
  CopyMemoryUp(756, VIDEOBUFF+12, VIDEOBUFF)
#endonly


Data
 Syntax:   Data( varname1[, varname2, varname3, etc..] )
 Description:  
Declares any other type of data. This can be used if you wish to use simple arithmetic with addresses. For instance, declaring a sprite named 'man' and data 'man+4' lets you add 4 to the address of 'man' in a function call for instance, letting you send the last 4 bytes of the sprite to a function. If you wich to declare any type of data used for libraries or level data, use the
DataStart command to define the data.
 Example:  
Data(messagedata, leveldata)
DataStart(leveldata)
; first byte of each row is each level's speed, the second is the enemy difficulty
; 10 = slow, 10=hard
  .db 10, 1
  .db 5, 1
  .db 8, 4
  .db 1, 10
EndData

Byte(curlevel, Speed, Difficulty)
Pointer(curlevelpointer)
Function(PlayGame)
  / set pointer to start of leveldata
  curlevelpointer = leveldata
  For(curlevel,1,4)
    Speed = *curlevelpointer
    curlevelpointer++
    Difficulty = *curlevelpointer
    curlevelpointer++
    / .. insert game here
  EndFor
EndFunction


DataStart
 Syntax:   DataStart( variable name )
 Description:  
Begins the declaration of a block of data associated with variable name, which should have already been declared with
Data. Just like AsmOn, you should use ';' inside the declaration.
 Example:  
/The following is data for a MessageBox library call:
Data(mymessage)
DataStart(mymessage)
  .db "Hello!",0
  .db "This is my message!",0,0
EndData


Dec
 Syntax:   Dec( variable )
 Description:  
Alt: variable-- Decrements a byte,word, or pointer by one. See
Increment.

DeclareFunction
 Syntax:   DeclareFunction( function name, [arg0], [arg1], ... )
 Description:  
Declare a function so it can be called before it is defined. See
Function for details on the syntax. Your later definition of the function shouldn't have any arguments.
 Example:  
DeclareFunction(DrawMan, sysbytearg0, sysbytearg1)
Function(Main)
  DrawMan(10,10)
EndFunction
Function(DrawMan)
  Draw88(10, 10, ManSprite)
EndFunction


Div
 Syntax:   Div( variable, [variable,] value )
 Description:  
Alt: variable /= value or variable = variable / value. See
Math Operators. Both Multiplication and Division suck up memory and speed! Please consider this!
 Example:  
Byte(a, b)
Function(mydiv)
  a = 120
  a = 4 / a now equals 30
  b = a  3     / b now equals 10
EndFunction


Djnz
 Syntax:   Djnz( value )
 Description:  
Very small and fast loop structure. Use only when you have a few commands! Using Djnz with a large amount of memory to jump back through will yield an Assembler Error, which you may not catch. Repeats value times through the loop. Use
EndDjnz to end the loop. Value can be a Byte variable or any number from 0 to 255 (Repeating 0 times actually means it repeats 256 times!.
 Example:  
/ Draws Hello! 5 times down the screen
Byte(curx)
Function(DrawHelloLine)
  cury = 0
  Djnz(5)
    DrawString("Hello!", 1, cury)
    cury += 6
  EndDjnz
EndFunction


DjnzVar
 Syntax:   DjnzVar( variable, value )
 Description:  
A little slower than
Djnz but is unlimited in size of the loop. Also, you can assign 1 to variable at any time to make that the last iteration of the loop. The current loop value is stored inside variable.
 Example:  
/ Draws a number line (from 5 - 1) down the screen
Byte(mytempbyte)
Function(DrawNumberLine)
  sysbytearg1 = 0
  DjnzVar(mytempbyte, 5)
    sysbytearg1 += 6
    DrawNumber(mytempbyte, 0, sysbytearg1)
  EndDjnzVar
EndFunction


Do
 Syntax:   Do( void )
 Description:  
Begins a Do...
While Loop.

EndData
 Syntax:   EndData( void )
 Description:  
Ends a
Data declaration.
 Example:  
Data(ABCS)
  .db "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
EndData


EndDjnz
 Syntax:   EndDjnz( void )
 Description:  
Ends a Djnz...EndDjnz loop structure. See
Djnz for details.

EndDjnzVar
 Syntax:   EndDjnzVar( void )
 Description:  
Ends a DjnzVar...EndDjnzVar loop structure. See
DjnzVar for more details.

EndExec
 Syntax:   EndExec( void )
 Description:  
Preferable last statement in Main Function. Helps to stabilize system for it to go back into your OS. See example in
StartExec

EndFor
 Syntax:   EndFor( void )
 Description:  
Ends a For...EndFor loop structure. See
For for more details.

EndFunction
 Syntax:   EndFunction( void )
 Description:  
Ends a function definition. See
Function

EndIf
 Syntax:   EndIf( void )
 Description:  
Ends a If conditional structure

EndSelect
 Syntax:   EndSelect( void )
 Description:  
Ends the definition of a Select...Case...EndSelect structure. See
Select for more info and an example.

EndSprite
 Syntax:   EndSprite( void )
 Description:  
Ends a sprite declared using
Sprite8 or Sprite16.

EndSystemFunction
 Syntax:   EndSystemFunction( void )
 Description:  
End's a function starting with SystemFunction, See
SystemFunction for more info.

Equate
 Syntax:   Equate( name, constant )
 Description:  
This is similar to #define in C except you cannot really define macros. Equate variables are treated as numbers and are later replaced by the assembler with the numbers you assign them. A few system equates exist to make Cross-Plaforming a snap if you use them in programs. One is used in the example.
 Example:  
Function(Center, sysbytearg0)
/ Given the width (sysbytearg0) this function returns the x value of a centered
/ object of that width. This institutes sysbytearg0 = the width of the screen
/ divided by two minus the width of the object divided by 2.
  sysbytearg0 /= 2
  sysbytearg1 = SCREENWIDTH / 2 /make use of the system equate SCREEN WIDTH
  sysbytearg0 = sysbytearg1 - sysbytearg0
EndFunction


EscapeFunction
 Syntax:   EscapeFunction( void )
 Description:  
Exits a function before the end of it's declaration. Useful for stuff like the example.
 Example:  
Function(gameloop)
  Do
  /..game code here...
  IfKey(Exit)
    EscapeFunction
  EndIf
  WhileNotEqual(dead, 1)
EndFunction


For
 Syntax:   For( variable, start, stop [,step] )
 Description:  
Typical FOR loop. Runs from start to stop stepping either 1 at a time or whatever is specified by step. Negative step values are not supported, so you'll have to use Do...While loops for those. Use
EndFor to end the loop.
 Example:  
/ This prints 0-25 down the screen diagonally in steps of 5
Byte(myloopbyte)
For(myloopbyte, 0, 25, 5)
  DrawNumber(myloopbyte, myloopbyte, myloopbyte)
EndFor


Function
 Syntax:   Function( function name, [arg0], [arg1], ... )
 Description:  
Begins a function definition and declares the function if
DeclareFunction has not yet been called. If the function name is 'Main' then this is where program execution begins (like in C). TIPower GOLD does not support recursive functions. Arguments are the names of variables that have already been declared of types Byte,Word, or Pointer. To pass information to functions, these variables are assigned the values in the function call. Thus you can REALLY optimize your programs in size and speed if you use the same variables when calling functions. See the example for a fast function call and slow function call. For information on sysbytearg0 and sysbytearg1, see SystemVariables.
 Example:  
Function(IHaveNoPoint, sysbytearg0, sysbytearg1, sysbytearg2)
EndFunction

Byte(temp1, temp2)
Function(Main)
  / Slow function call:
  temp1 = 4
  temp2 = temp1 * 3
  IHaveNoPoint(temp1, temp2, 0)
  / fast function call:
  sysbytearg0 = 4
  sysbytearg1 = sysbytearg0 * 3
  /sysbytearg2 already equals 0 because it was assigned 0 in the last call
  /and it was not modified in the function (obviously)
  IHaveNoPoint(sysbytearg0, sysbytearg1, sysbytearg2)
EndFunction


If
 Syntax:   If( value1, value2 )
 Description:  
Conditional if statement, variations include IfEqual, IfNotEqual, IfLess, IfMore, IfNotLess, IfNotMore, as well as
IfKey variations. If you wish to have a If..Else..Endif structure instead of a If...EndIf structure, Use the keyword Else After the conditional (like IfEqualElse). All If structures must be multi-line and must end with EndIf.
 Example:  
Word(score, highscore)
/ Checks for a high score
Function(CheckHighScore)
  IfMoreElse(score, highscore)
    DrawString("You got a high score!", 10, 10)
    highscore = score
  Else
    DrawString("Better luck next time!", 10, 10)
  EndIf
EndFunction


IfKey
 Syntax:   IfKey( keyconstant )
 Description:  
New. Allows you to use a direct conditional if a key is being pressed. See
KeyDown for a list of the key constants on each calculator. Variations of IfKey include IfKey, IfKeyElse, IfNotKey, and IfNotKeyElse.
 Example:  
/ Fighting Game Function that prints out practice moves
Function(CheckButtons)
  ifkey(A)
    DrawMyString("Punch!")
  endif
  Ifkey(B)
    DrawMyString("Kick!")
  EndIf
  Ifkey(C)
    DrawMyString("Duck!")
  EndIf
  IfKey(D)
    DrawMyString("Jump!")
  EndIf
EndFunction


Inc
 Syntax:   Inc( variable )
 Description:  
Alt: variable++ Increments a byte,word, or pointer by one. See
Decrement.

InterruptRoutine
 Syntax:   InterruptRoutine( routine name, greyscale? (0|1), 60/40 ratio? (0|1), counter? (0|1), counter name )
 Description:  
For TI-86 only! Defines a custom interrupt routine for use with the
EnableInterrupt system function. Use '0' or '1' in the middle three arguments to set your options. If counter is set to '1' then counter name must be a Byte,Word, or Pointer variable name.
 Example:  
Byte(intcounter)
InterruptRoutine(myint, 1, 0, 1, blahcounter)

Function(Main)
  EnableInterrupt(myint)
  // ... greyscale gfx routines go here ...
  DisableInterrupt
EndFunction


KeyDown
 Syntax:   KeyDown( keyconstant, variable )
 Description:  
If the key in keyconstant is being pressed, then 0 is assigned to variable. If it isn't being pressed a nonzero value is being pressed. In most cases, the new
IfKey convention is better to use than this. But if you find yourself checking a certain key status several times, it is more efficient to assign the key status to a variable using this statement. Most of the key constants are similar on all the calculators, but in order to allow games to keep the same layout over multiple calculators, I've created the key constants A, B, C, and D. Use these instead of actual key names to make cross-platforming easier. (A is the main key (usually 2nd), etc..) Also EXIT is a keyconstant on all of the calculators, as well as UP, DOWN, LEFT, and RIGHT. The following table shows calculator specific key constants:
TI-86 TI-83P
CLEAR, CARROT, DIVIDE, MULT, SUB, PLUS, ENTER, CUSTOM, TAN, ENDPAR, NINE, SIX, THREE, NEG, DEL, PRGM, COS, OPENPAR, EIGHT, FIVE, TWO, PERIOD, XVAR, TABLE, SIN, EE, SEVEN, FOUR, ONE, ZERO, ALPHA, GRAPH, LOG, LN, SQUARED, COMMA, STORE, MORE, SECOND, 2ND, F1, F2, F3, F4, F5 ENTER, PLUS, MINUS, MULT, DIVIDE, CARROT, CLEAR, NEG, THREE, SIX, NINE, RBRACKET, TAN, VARS, PERIOD, TWO, FIVE, EIGHT, LBRACKET, COS, PRGM, STAT, ZERO, ONE, FOUR, SEVEN, COMMA, SIN, MATRIX, X, STORE, LN, LOG, SQUARE, RECIPROCAL, MATH, ALPHA, GRAPH, TRACE, ZOOM, WINDOW, Y, 2ND, MODE, DEL
MathOperators

 Description:  
TIPower GOLD v2.0 introduces new Math Operators into the mix. Use the following table as your guide to the new operators (most, except multiplication and division, are just like C):
Operator Associated
Statement
Meaning
= Set equals
+ Add addition
- Sub subtraction
$ Mult multiplication
\ Div division
% Rem modulo
+= Add self-addition
-= Sub self-subtraction
$= Mult self-multiplication
\= Div self-division
%= Rem self-modulo
++ Inc increment
-- Dec decrement
Unlike C, you can't (yet) have more than one operation per line:
a = b + c /this is legal
a = b + c * d /this is illegal
Such multiple operations will probably be introduced in version 3.0. Stay tuned.

MemSpace
 Syntax:   MemSpace( data variable name, size )
 Description:  
Creates and defines a data variable that is size large. This is useful for loading strings into the data, or using a screen buffer.
 Example:  
MemSpace(mybuffer, NUMSCREENBYTES)

Byte(x)
Function(Main)
  DjnzVar(x, 70) / moves a man (no flicker!)
    VIDEOBUFF = mybuffer
    ClearMemory(mybuffer, NUMSCREENBYTES) / erase entire buffer
    / all sprite routines automatically output to buffer
    Draw8(manspritethatdoesnotexist, x, 20)
    CopyMemory(1024, $fc00, mybuffer) /copy buffer to actual screen
  EndDjnzVar
  WaitForSecond
EndFunction


Mult
 Syntax:   Mult( variable, [variable,] value )
 Description:  
Alt: variable $= value or variable = variable $ value. See
Math Operators. Both Multiplication and Division suck up memory and speed! Please consider this!
 Example:  
Byte(a, b)
Function(mymult)
  a = 10
  a *= 4 / a now equals 40
  b = a * 3     / b now equals 120
EndFunction


Not
 Syntax:   Not( variable, [value] )
 Description:  
NOTS a value and assigns result to variable. See the example for a good explanation
 Example:  
Byte(a,b)
Function(OrTime)
  a = %01001011
  b = %11010010
  Not(a) / a now equals %10110100
  Not(a, b) / a now equals %00101101
EndFunction


Or
 Syntax:   Or( variable, [variable,] value )
 Description:  
ORS variable with value and assigns result to variable. See the example for a good explanation
 Example:  
Byte(a,b,c)
Function(OrTime)
  a = %01001011
  b = %11010010
  Or(a, %00100000) / a now equals %01101011
  Or(a, a, b) / a now equals %11111011
EndFunction


Pointer
 Syntax:   Pointer( varname1[, varname2, varname3, etc..] )
 Description:  
Declares a variable which contains the memory location of other variables and data. Setting a pointer equal to any other variable actually loads that variables memory location into the variable. Use '*' before a pointer to indicate that you wish to do operations on the data at the memory location stored in the pointer, rather than the actual location of memory. Most math operations work with both pointers and pointer references (although most operations assume the pointer points to a
Byte)
 Example:  
Pointer(mypoint)
Byte(xpos)
Function(Main)
  / This actual adds 5 to xpos!
  mypoint = xpos
  *mypoint += 5
EndFunction


PreprocessorDirectives

 Description:  
There are several preprocessor directives at your disposal. To indicate that the following code is only for a particular build type, use #only[buildtype] . Build types include TI86, TI83P, TI83ION, TI83MIRAGE. Please note that preprocessor directives are case-sensitive, so #onlyTI83P will work, but #OnlyTI83p would not. To end your #only structure, use (you guessed it!) #endonly which is also case sensitive. See the examples of CopyMemory functions to see these directives in action. The other directive I offer is #include, which includes after that a filename (never in quotes or '<>'s!). The compiler checks three places for the file specified in the include: the current working directory, the same directory as the current file, and the TIPower GOLD root directory (which is where system.TI6 is located.)

Rem
 Syntax:   Rem( variable, [variable,] value )
 Description:  
Alt: variable %= value or variable = variable % value. See
Math Operators. Useful for determining if a number is even or not, as well as finding random numbers from 0 to value. Both Multiplication and Division suck up memory and speed! Please consider this!
 Example:  
Byte(a, b)
Function(mydiv)
  a = 13
  a %= 4 / a now equals 1 (13 / 4 = 3 r 1)
  b = a % 2     / b now equals 1 (1 / 2 = 0 r 1)
EndFunction


Select
 Syntax:   Select( variable )
 Description:  
A typical BASIC-type SELECT-CASE structure command. Use
Case statements for selecting each option, and CaseElse to catch any other options. Use EndSelect to end the structure. See the following example for the exact syntax.
 Example:  
/ Selects which type of enemy is to be used for this level
Equate(SLIME, 0)
Equate(SKELETON, 1)
Equate(DRAGON, 2)
Equate(TROLL, 3)
SELECT(level)
  CASE(1)
    monster = SLIME  / Level 1
  CASE(2)
    monster = SKELETON / Level 2
  CASEMORE(5)
    monster = DRAGON / Levels 6 and up
  CASEELSE
    monster = TROLL / Levels 3-5
ENDSELECT


Set
 Syntax:   Set( variable, value )
 Description:  
Alt: variable = value. See
Math Operators. Assigns value to variable.
 Example:  
Byte(a)
Word(b)
Pointer(c)

Function(AssignValues)
   set(a, 5) / this sets the Byte a to 5
   b = a /this sets the word b to a
   c = b /this sets the pointer c to the address of b
EndFunction


Sprite16
 Syntax:   Sprite16( sprite name )
 Description:  
Begins the definition of a sprite 16 bits in width. Use either 1's and 0's or X's and '.'s to define the sprite. Sprite can be any height (other than 0) Each row in the definition represents a row in the sprite gfx. Data less than 16 bits wide yields an error. See the example, it's the best way to describe it.
 Example:  
/This defines a 16x16 sprite. A portrait of you!
Sprite16(madmax)
..X..........X..
.X...........X..
.X.XX.....XX..X.
.X...X...X....X.
.X.....X......X.
.X..X...X..X..X.
XX.......X....XX
XX.....XXX....XX
X...........X..X
X...X......X...X
XX...X....XX..XX
..X..XXXXX.X..X.
..X..X.X.XX...X.
..X...XXXX....X.
...X.........X..
....X.......X...
EndSprite


Sprite8
 Syntax:   Sprite8( sprite name )
 Description:  
Begins the definition of a sprite 8 bits in width. Use either 1's and 0's or X's anc '.'s to define the sprite. Sprite can be any height (other than 0) Each row in the definition represents a row in the sprite gfx. Data less than 8 bits wide is finished with 0 data. See the example, it's the best way to describe it.
 Example:  
/This defines a 8x8 sprite
Sprite8(smileygfx)
  .XXXXXX.
  X......X
  X.X..X.X
  X......X
  X.X..X.X
  X..XX..X
  X......X
  .XXXXXX.
EndSprite


StartExec
 Syntax:   StartExec( void )
 Description:  
Preferable first statement in your 'Main' Function. This initializes the system (such as clearing the screen, turning off the run indicator, etc.).
 Example:  
Title("My Game")
#include system.TI6

Function(Main)
  StartExec
  / ... game code goes here ...
  EndExec
EndFunction


String
 Syntax:   String( string name, "value" )
 Description:  
Declares a string variable. Behaves pretty much just like a
Data variable, except you can use it to replace strings as arguments. Only really necessary if you find yourself using the same string in several places, then using a string variable saves memory. See the example.
 Example:  
/This:
DrawString("Hello!", 0, 0)
DrawString("Hello!", 0, 10)
DrawString("Hello!", 0, 20)
/Consumes much more memory than this:
String(hellostring, "Hello!")
DrawString(hellostring, 0, 0)
/ we can now use sysbytearg0 in the first argument because sysbytearg0 had 0 loaded
/ into it last time and it was not changed (most system functions do not change their
/ parameters' values)
DrawString(hellostring, sysbytearg0, 10)
DrawString(hellostring, sysbytearg0, 20)


Sub
 Syntax:   Sub( variable, [variable,] value )
 Description:  
Alt: variable -= value or variable = variable - value. See
Math Operators.
 Example:  
Byte(a, b)
Function(mysub)
  a = 10
  a -= 4 / a now equals 6
  b = a - 3     / b now equals 3
EndFunction


SysFuncRequire
 Syntax:   SysFuncRequire( functionname )
 Description:  
This is the only TIPower statement for use in system functions. A system function may require that another function be included in the source in order for that function to run properly. For instance, a Draw2Pixels system function might require the SetPixel system function. Setting this requirement with SysFuncRequire enables the compiler to make sure that that function is included in the final source
 Example:  
SystemFunction(Draw2Pixels, sysbytearg0, sysbytearg1)
DRAW2PIXELS:
  SysFuncRequire(SetPixel)
  call SETPIXEL
  ld hl,SYSBYTEARG0
  inc (hl)
  jp SETPIXEL
EndSystemFunction


SystemFunction
 Syntax:   SystemFunction( functionname, [arg0], [arg1], ... )
 Description:  
Use SystemFunction to add functions in ASM to your program. All labels in the ASM code must be in ALL CAPS. You must also include the all-caps label at the beginning of the code. Arguments are the same as the
Function statement. You may have up to 15 arguments in one function. SystemFunctions that are not called anywhere in TIPower code will not be included in the final program. This makes them useful for libraries, etc.
 Example:  
SystemFunction(QuickClearScreen)
QUICKCLEARSCREEN:
  ld hl,$fc00
  ld de,$fc01
  ld bc,1023
  ld (hl),l
  ldir
  ret
EndSystemFunction


Title
 Syntax:   Title( "title" )
 Description:  
Must be the first line of EVERY program (not include files)! If not you will have Assembler Errors! Line after Title must be '#include system.TI6' so that all the available system functions are open to you. See
Preprocessor Directives for more information about #include.
 Example:  
Title("Resident Evil 86")
#include system.TI6

#include zombies.TIP
#include guns.TIP


VarString
 Syntax:   VarString( string name )
 Description:  
Used with the system function
LoadString. The string MUST be contained in quotes because it is CASE-SENSITIVE (due to the OS being case sensitive) if you are not sure of the EXACT name of the string, load it on to your calculator and check if you have the case correct. This is also used in library include files to define Library variable names.
 Example:  
VarString("mystring")
MemSpace(stringbuff, 100)
Function(Main)
  LoadString(mystring,stringbuff,2048)
  DrawString(stringbuff, 10,10)
EndFunction


While
 Syntax:   While( variable, value )
 Description:  
Must use a conditional not unlike in the
If statement. Variations include WhileEqual, WhileNotEqual, WhileLess, WhileMore, WhileNotLess, and WhileNotMore. If the condition is true, then the loop is reiterated. Useful for games that monitor health and death.
 Example:  
Byte(dead)
Function(GameLoop)
  Do
    / .. game code here...
    / when you die, code assigns 1 to the byte variable 'dead'
  WhileNotEqual(dead, 1)
EndFunction


Word
 Syntax:   Word( varname1[, varname2, varname3, etc..] )
 Description:  
Declares a 2-byte size variable. Values for a word are integers ranging from 0 to 65535. All other rules are similar to
Byte. Some operations do not allow using a word value. The most common of which is using a word as the second operator in a division statement. Words CANNOT be used in multiplication.
 Example:  
Word(Score, Size)

Xor
 Syntax:   Xor( variable, [variable,] value )
 Description:  
XORS variable with value and assigns result to variable. See the example for a good explanation
 Example:  
Byte(a,b,c)
Function(XorTime)
  a = %01001011
  b = %11010010
  Xor(a, %11111111) / a now equals %10110100
  Xor(a, a, b) / a now equals %01100110
EndFunction