TI-85 Game Programming Guide

By Patrick Davidson

This page describes TI-BASIC programming only. Games written for TI-BASIC have much less performance than ZShell games, so there isn't really much of a point in make them anymore.

It is possible to make games on the TI-85 graphics calculator, and it can be done fairly easily. Although TI-85 games can be found at just about any high school, you have to get them from someone else, and if your calculator gets cleared, you lose all of your games, and can't get them back unless you can actually find somebody who has their link! Besides, making games is more fun than playing them. If you have never done any sort of programming, you may think that you will not be able to produce a TI-85 game, but it is easier than at looks. Here is some information that should help people who want to get started in TI-85 games programming.

Syntax of the TI-85 Programming Language

There are many types of data that TI-85 programs can use, but the types that game programmers will be most concerned with are:

Real numbers
Real numbers can hold any real values to a high level of precision. To access a real value simply type the variable's name.
Lists
This stores a list of real numbers. This is useful for statistics in games with more than 2 players, and for the terrain in an artillery game. Values in a list can be accessed with list(element). For example, if you wanted to access element 4 of list TERRAIN, you would enter TERRAIN(4). The length of a list can be read as dimL(listname). Nothing prevents you from using complex expressions in your index, so TERRAIN(4*sin(X+R)) is perfectly fine. The index is always rounded to the nearest integer.
Matrices
Matrices store real numbers along two dimensions. To access a value in a matrix, you need to now the row and column number. You can read from a matrix by typing MATRIX(COLUMN,ROW). The size of a matrix can be accessed with dim(MATRIX). The result of this is a list with two elements, the first being the number of columns and the second being the number of rows.
There are a lot of commands on the TI-85, but only a few are really necessary for game making. These are:
STO
The STO arrows is used to make a variable equal to a value. For example, you can make X equal to X+1 by typing X+1 STO X. You type the value, then the arrow, and then the destination. The value is evaluated immediately, so it is OK to use the variable to determine what its own value will be. You can store to a list with something like 7 STO TERRAIN(X+1). Note that if you were typing this into an actual TI-85 you would use the STO arrow, not just type the letters STO.
ClLCD
This clears the Home (text) screen.
Disp
This displays an expression to the screen. This is always displayed on the line after where the last operation finished, and text will be scrolled up the screen if necessary. Since most games require text to be positioned all over the screen, this is not very good for games! Examples of Disp:
Input
This commands inputs a number. This is useful for getting setup information about how a game should work when the game is started. You type Input N to read the variable N. You can also use the form Input "Enter a number",N which will display the text "Enter a number" and then read the value.
Outpt
This command prints text to a specific position on the screen. The format is Outpt(Y,X,T). Coordinates must be integers and within the screen. For example, Outpt(8,X,"-*-") print the letters "-*-" beginning at line 8, column X on the screen. This is the primary output command for most games done in text mode.
Subprogram calls
A TI-85 program will call a sub-program if you insert the name of the sub-program into the main program. There are absolutely no local variables on the TI-85. Recursion is allowed, however.
Stop
This completely exits the TI-85 program, just as if the user had pressed the ON key.
Return
This exits the current program. If it was called as a subprogram by another program, execution continues right after the subprogram call. This happens automatically when the end of a program is reached.
Lbl
This defines a label in your program. These can be the same as variable names. For example, Lbl START defines a label called START.
Goto
This transfers control to a label. For example, Goto START causes execution to continue at the point marked with Lbl START. Labels are local to the program they are defined in, so the same label can be defined in different programs.
If
This is one of the most important commands. This command tests a condition and executes the next command if the condition is true. Tests for equality are made with the == sign. The comparison signs are in the TEST menu, which can be accessed by pressing 2nd + 2. An example would be : If STRIKES==3:Disp "YOU'RE OUT!". You can allow multiple conditions under one If with a command like If STRIKES==3:Then:Disp "YOU'RE OUT!":OUTS+1 STO OUTS:End. You can, of course, use complex expressions in your conditional. You can also put If statements inside each other, like If STRIKES==3:Then:Disp "YOU'RE OUT!":OUTS+1 STO OUTS:If OUTS==3:Then:Return:End:End .
Pause
This command suspends execution of the program until you press Enter. If you leave the program at this point long enough the TI-85 will power down automatically. When this happens you can still resume your program when you turn the calculator back on. Be careful not to press ON twice, because then you will break the program.
For...End
This is one of the TI-85 looping commands. It is of the form For(N,start,end) or For(N,start,end,step). If the step value is not given, it is assumed to be one. This statement repeats a section of a program. The first time N is equal to the start value. Each time it goes through the step value is added to the value in N. The loop is executed for its final time with N being equal to the highest value. The end of the loop is marked with the End statement. For loops can be placed inside one another, and you can use Ifs in them too. You can skip cycles or go back into previous cycles by modifying N from your program.
While...End
This is similar to the For loop, but a value is not automatically modified. Instead, a condition is tested at the beginning of the loop and the loop is executed again if the condition is true. If not, the loop is exited and the program continues after the loop. The format of this is While condition ... statements ... End. These can be placed inside each other and inside other control structures too.
Graphics Setup
Graphics requires some extra steps to set up. Instead of explaining everything I do, I will just list some code that sets up the display in a way meaningful for games.
FnOff : AxesOff : GridOff : ClDrw : 1 STO xMin : 127 STO xMax : 1 STO yMin : 63 STO yMax
This code clears out the display and sets up the window so that the coordinates you can use are (1,1) in the lower left corner and (127,63) in the upper right corner. When using graphics, of course, you can use fractional coordinates as much as you want.
Why You Should Avoid Graphics
Using graphics in games is generally a very bad idea. Graphics is always going to be much slower than text. You have to draw every line seperately. If you want to erase what you have drawn, you must clear every pixel seperately, or clear the screen totally and redraw everything. This is guaranteed to slow things down tremendously. In addition, if you clear the screen for every frame, the screen will blink in and out, which is certain to be ugly! Drawing a single character is changing 35 pixels, and you can draw several characters in a row in one command. Only in games where you need fine detail (i.e. an artillery game) should you use graphics. Try to use text whenever possible.
ClDrw
This graphics command simply clears the entire display.
PtOn(x,y)
Sets the point at the coordinates (x,y).
PtOff(x,y)
Clears the point at the coordinates (x,y).
PtChg(x,y)
Toggles the point at the coordinates (x,y).
Line(x1,y1,x2,y2)
Draws a straight line from (x1,y1) to (x2,y3)
Circl(x,y,r)
Draws a circle centered at (x,y) with a radius of r. Remember that the X and Y scales are often different, and this therefore this is usually an ellipse.

Programming Guidelines for Beginners

  1. Before you try to make a complete game, experiment around with simple programs to get the hang of TI-85 programming.
  2. Start out with simple games first.
  3. Before you begin to make a game (especially your first one) be sure to have a clear idea of what you intend to do. If you can't keep the entire plan in your mind, write it down!
  4. Program the game in segments instead of all at once. Test each segment as soon as you complete it. This will allow you to correct mistakes in your programs more easily.
  5. If your game does not work at first, do not get discouraged. Keep trying, you can do it eventually.
  6. Your first game should not be MineSweeper. The lack of local variables can cause some difficulties on the TI-85. Although this is not really very hard to get around (look back on my main page to download a working MineSweeper), a beginner may have trouble.
  7. It might be a good idea to program your game to use text instead of graphics (if you have only a TI-81 or TI-82 you pretty much have to use graphics). This eliminates the need to set range parameters, as well as greatly increases the speed of your game. Clones of games such as Arkanoid, PacMan, Space Invaders, and various role-playing games can be done quite well in text mode. If you are making an artillery game, you pretty much have to use graphics, though.
  8. Stay away from Tetris! The TI-85 is too slow to do such a game properly (I think a TI-92 can handle it). The result will be so slow that it isn't worth making such a game.
  9. Once your game is working, it is not finished! You can still make the game faster or add extra features to it (be careful that this doesn't slow it down too much).
  10. If you are moving a text object to the left or right, do not redraw erase the entire object and redraw it. Redraw and erase in one command, like Outpt(8,1," -+-") to move the start of the object from column 1 to column 2 or Outpt(8,1,"-+- ") to move it from column 2 to column 1. This is much faster than clearing and redrawing the whole thing!
  11. It is generally not a good idea to look at programs written by other people. Since TI-85 programs are almost always uncommented (the only way to insert comments is by inserting strings into the code, which will be sure to slow it down) it is genrally much easier to write your own programs from scratch than to figure out a program you did not write.
  12. If you still have a problem (or even if you don't), you could always send me some E-mail.
1