# TI-Basic Programs/Printable version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/TI-Basic_Programs

# Writing a Program

There are just a few steps to follow in order to write a program onto your TI-83+ or TI-84 calculator using TI-BASIC.
* Turn on your calculator and press the PRGM button.
* Press the right arrow button twice to move to NEW.
* Press Enter to select Create New.
* Name the program. If the program is of your own creation, give it whatever name you would like it to have using the letters above each button or any of the numbers 0-9. If you are copying a program from this book, type in the name already given.
* Write the code of the program by using the digits and commands found on the calculator and by using the PRGM sub-menus while within the program code. These menus contain lists of many of the most vital programming commands, such as If, Then, End, While, Menu(, and many others. Other helpful menus of commands are the MATH, TEST, and DRAW command lists.
Note: Some of the programs in this book use lower-case letters in their program codes. In order for a TI calculator user to type in lower-case letters you must have MirageOS on your calculator. You must also check the checkbox for Enable Lowercase in Miscellaneous Options on the Options screen within MirageOS. The Options screen can be opened by pressing the ALPHA key in MirageOS. RAOSX is also useful for enabling lowercase letters and other common assembly functions.
For the instructional wikibook on TI-BASIC programming, see TI-Basic Z80 Programming.

# Chase
## Program Description

Chase is a simple yet enjoyable game. In it, players take the role of a "greater-than" symbol (>) who is getting to eat some X's. It is played on the regular typing screen, and there are 6 characters that can move around the screen. One is the player's character, the > sign. Another, the X, is the character that the player is supposed to move towards and eat once he has reached it. The other four, however, are "not-equal-to" symbols (≠) which are vicious and will try to eat the player if they get close enough. Chase has a title screen that draws itself up on the Graph screen through the CSTART program, which must also be on a player's calculator before he can play Chase. The title screen has four options which are: 1) New Game (to start a new game) 2) Continue (to continue a currently saved game) 3) Instructions (to bring up the instructions for Chase) 4) Quit (to leave the program and return to the main screen).
In the Instructions page, much of the above information is covered, as well as other information like which keys are used for the game controls. In the game, the five non-player characters (the four ≠'s and the X) move around on their own, randomly following any of four patterns. For instance, if one of the ≠'s moves a space left, then another will move up, another will move down, and another will move right. Two ≠'s will never move in the same direction as one another in one move. Also, the movement of the X will parallel that of one of the four monsters. The controls that the player uses to move are displayed on the Instructions page. The player can press any of the 9 number keys (1-9) except for the 5 to move his character. For instance, pressing the 7 key will move the player's character up one space and to the left one space, and pressing the 8 key will only move the player's character up one space. This explanation may be difficult to understand but is very easy to figure out by playing the game.
The player's score is displayed in the upper-right corner of the screen throughout the game. Whenever the player eats the X character, one point will be added to his score in the display. Also, the X will disappear and be regenerated somewhere else on the screen. The player's high score is displayed in the Chase title screen every time he starts the game.
One last control is the ENTER key, which pauses/saves the game that you are currently playing. If the player presses it once while he's playing, he can save his game and come back to it whenever he wishes by starting prgmCHASE and choosing option 2, Continue, mentioned above. Also, by pressing the ENTER key twice while playing, once to pause/save the game and then once again, He can resume immediately and play will continue. The effects of this are that all of the variables for things like score and position of each character on the screen are stored and also, the game will regain its regular running speed. Unfortunately, whenever one is running a TI-Basic program that repeats, it will eventually run slower and slower. To avoid or solve this problem when playing Chase, one can use this method of pressing ENTER twice. As stated above, this exits the program and then resumes it again.
Note: The variables used by the calculator to operate Chase are stored in the [J] matrix.

## Program Code

Notes:
* Many of these lines of code can be linked together in one line by just typing a ":" instead of pressing ENTER and typing the next command on the next line. Also, some of the commands displayed here are already linked in this way.
* The "¤" found in the command, " :Output(8,3,"-GAME¤SAVED- ", is actually a very small square and it can be found in the CATALOG menu on your calculator. It will be above what looks like a small plus sign (+), near the bottom of the list.

# CStart
## Program Description

CStart is a title screen start-up program which works in conjunction with prgmCHASE. A user must have both programs on their calculator in order to play Chase. When both programs are in place, the user never needs to actually run prgmCSTART, but it must be un-archived while playing Chase so that Chase can access it. The user simply runs prgmCHASE and the program will then link to CStart automatically. CStart doesn't change any part of the actual gameplay of Chase, but it displays a very cool start-up screen. As outlined in the Program Description section for prgmCHASE in this wikibook, the title screen gives the player four options: 1) New Game (to start a new game) 2) Continue (to continue a currently saved game) 3) Instructions (to bring up the instructions for Chase) 4) Quit (to leave the program and return to the main screen)
It also displays a large drawing of the word "CHASE" with the vicious ≠'s as part of the E. It displays the current High Score in the upper-right (which will show 0 if the user has not played before), and an image of a < sign with angry eyes and sharp teeth chasing a frightened X in order to eat him.
Choice 3 will clear the screen and draw up page 1 of the instructions for Chase. This page gives an introduction and a background for Chase and tells the player what his goal is. The program will be paused when this screen is displayed and it will wait for the player to press ENTER, upon which the screen will be cleared again and page 2 of the instructions will be displayed. On this page, the player will see a diagram of which keys are to be used for controlling the > symbol during gameplay. It also tells of how the game will slow down, and needs to be re-booted using the ENTER key while playing in order to get it back up to speed.

## Program Code

Notes:
* Many of these lines of code can be linked together in one line by just typing a ":" instead of pressing ENTER and typing the next command on the next line. Also, some of the commands displayed here are already linked in this way.
* The "¤" found in the command, " :Text(8,69,"¤ ", is actually a very small square and it can be found in the CATALOG menu on your calculator. It will be above what looks like a small plus sign (+), near the bottom of the list.

# GuessMe
## Program Description

GuessMe is a wonderful, enjoyable game based upon the simple concept of guessing a number. In this game, the player interacts with the calculator in a sort of dialogue. When the program is initiated, a Main Menu opens and the player is given five options:
* 1,000
* 10,000
* 100,000
* HI SCORES
* QUIT
Option 4 types up a screen which displays the current high score for each of the three difficulty levels, and Option 5 simply quits the program and returns to the main calculator entry screen. If the player selects Option 1, 2, or 3, the game will begin. The game begins by the calculator choosing a random number for the player to guess. If the player chose Option 1, then the number chosen by the calculator will be any number from 1 to 1000. The maximum number for Option 2 is 10000 and the maximum number for option 3 is 100000. This means that there are three difficulty levels that the player can choose from and that the calculator will save a separate high score for each difficulty which can all be seen on the High Score page by selecting Option 4 from the Main Menu. After selecting a number for the player to guess, the calculator tells the player what is going on and prompts him for his first guess. It does so with these messages: "Im thinking of a number between 1 and 1,000..." (This will say "10,000" in difficulty 2 and "100,000" in difficulty 3), "What is it?" The player can then enter his first guess.
After each guess, the calculator will respond with a message saying "Higher" if the player's guess was too low or "Lower" if the player's guess was too high. In difficulty 3, the calculator may also say "Much higher" or "Much lower". If the player guesses a number which is less than 1 or more than the maximum, the calculator will respond with, "Hey! I said it was between 1 and 1,000!" (As before, this final number will depend on which Option was chosen). If the player's guess is within 1 number of the answer then the calculator will say "Youre SO close! Just a little higher!" or "Youre SO close! Just a little lower!" After 20 guesses, the calculator will taunt the player with the message, "Hurry it up!" After 30 guesses, the calculator says "Gosh! You take forever!!!" The only other message that the calculator might show to the player is one that will only be displayed if the player cheats to guess the answer on his first try or if by chance he guesses the secret number on his very first try. If this is done, the calculator will simply say, "YOU CHEATER!" and the program will abruptly end.
When the player eventually guesses the correct number, a series of messages will be displayed. The first is: "You got it!!!", followed by the correct answer, then "In this many tries:", followed by the number of guesses it took the player to find the number. Then, if the player has broken the high score for that difficulty level, he will see the message, "HIGH SCORE!!"
Note: The variables used by the calculator to operate GuessMe are stored in the [J] matrix.