THIS PAGE WILL BE UPDATED... My priority are else where right now. Later I'll try to work on the TI-BASIC tutorials. I will have 1 of EVERY TI Graphing Calculator by then and can make a page specific to each calculator's abilities. The lessons will be similar, however, they will not go very far on the TI-80/81. The TI-82/83/86/92 will have extra graphics lessons and samples of uses. The TI-85 will have a less extensive graphics section due to fewer graphics commands. The 85 lessons may use some programs designed to replace the missing commands. I want to also explain how to use acceleration to improve game speed and quality without making the game actualy run faster.
These additions will arrive, but may take time...
First, I have a few hints and tips for programming the TI calculators. I don't have references to all the calcs, but just imagine that whenever I say TI-85, I also mean TI-86, because the 86 has all the TI-85 basic commands and that whenever I say TI-82, I also mean TI-83, because the 83 has all the TI-82 basic commands. I may also add comments about specific calculators. I will say important things about the 80/81, but because they are so limited, I won't do much at all with those. My major goal is to talk about the 82 and up. I don't have the 92, so for now my tutorial will not have much on the TI-92, but I have an 82 and an 85. 83 and 86 users can follow the 82 and 85 instructions respectively.
TI BASIC is a very flexible version of BASIC, when you look at it compared to normal BASIC. The only thing missing is the PEEK and POKE comands (82 doesn't support strings as well), which let BASIC directly control memory locations. I wish TI would have left this feature in, but adding it would leave a lot of people who just type text into their calc with some problems. Other than that loss, It is almost perfect!
I've spent 1 hour and 45 minutes on the first section. (I'll add to it more, but look at your manual and get ideas. This just scratches the surface. If you like, I'll send you the source BASIC for Stickfighters, Starfighters,pong or any of my other programs. These are complex programs that perform numerous commands and instructions. They are for the TI-82, but you can look at them for ideas because the two programming languages are so similar. I'm going to be porting some of these programs to the 85 and they should run on the 86 then, but it may take some time.
To start with, you should get used to a few basic commands and how to stop programs if you mess up.
Just hit ON to stop a program.
Input (variable):
Allows you to type a value into a variable
PROGRAM:BASIC
results in this screen where it asks you to type a number.
:Input A
you need to hit ENTER to continue:
BASIC
Type A and it shows what you Typed
?6
Done
BASIC
?6
Done
A
6Disp (value, var., or string):
Puts a value, contents of a variable,
or a string onto the next line of the string. Adding comma to the
end and another variable will put them in line
PROGRAM:BASIC
Results in (from last program)
:Input A
:Disp A
BASIC
?6
6
Done BASIC
Results in (from last program)
:Input A
:Disp "Score is:",A
BASIC
What if you want to clear the screen so that the input line disapears. Use the command
?6
Score is:
6
DoneClLCD
(spelled different on the 82, 83; CLRHOME
). Add it in the program where you want to clear the screen.
BASIC
Results in (from last program)
:Input A
:ClLCD
:Disp "Score is:",A
__________________ __________________
What if you need to place text in an EXACT LOCATION, like if 6 has to be right behind the phrase "Score is:" Then use the Output command.
|BASIC |
|?6_ | (Cursor still flashing)
| |
|Score is: |
| 6| (when you hit enter)
| Done|
The screen is arranged like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
To draw that message, make the following program:
_____________________________________________________________
1| |
2| |
3| |
4| S o r r y t h e S c r e e n |
5| l o o k s t o W i d e |
6| |
7| |
8|_____________________________________________________________|
PROGRAM:SORRY
This program clears the screen and displays words right in the middle of the screen!!! You should notice too, that the word Done does not appear as in other programs. Whenever the Output command is used, there may be important data on the screen, so the calculator doesn't show done.
:ClLCD
:Output(4,4,"Sorry the screen"
:Output(5,6,"looks too wide"
Now, to display that score:
PROGRAM:BASIC
Results in (from last program)
:Input A
:ClLCD
:Disp "Score is:"
:Output(1,11,A
__________________ __________________
Note:
|BASIC |
|?6_ | (Cursor still flashing)
| |
|Score is: 6 | (when you hit enter)
|_ | (note cursor under line you displayed)
| |Disp 6 Disp A Disp "A=",A Disp "A=",6
are all valid forms.
Now you can display text and values and you can input values into variables. Many games need to know what key you press without stoping for you to press enter. The command you need to use is getky
, but first you need to learn how to make simple loops.
The Lbl
command lets you assign an 8 character name to a location of a program. Say you make a program that needs to loop back to the beggining. You would type Lbl (label name)
. You can type any combination of 8 letters (upper or lower case) and numbers as long as it starts with an upper case letter. The Goto
command is what jumps there.
for example:
PROGRAM:GETKEY
This program displays 6 over and over again and it fills the screen and the lines move up to make room for new ones.
:Lbl Loop
:Disp 6
:Goto Loop
Now for getkey command
PROGRAM:GETKEY
The program just shows line after line of 0s, but hit a key, a number will appear (and quickly dissapear). Each key has a separate number arranged in a grid like this:
:Lbl Loop
:Disp getky
:Goto Loop
25 11 12 13 14 15 (Graphing keys)
If you like, try holding down the arrow keys or DEL. Those keys (but no others) repeat themselves. That's why you can hold down the delete or the arrow keys and the others just do one "press" at a time.
21 22 23 24 26 (Arrow keys)
31 32 33 34
41 42 43 44 45
51 52 53 54 55
61 62 63 64 65
71 72 73 74 75
81 82 83 84 85
91 92 93 94 95
ON 102 103 104 105 (The ON key stops programs
and has no number)
Now for actual use of the getkey command
You need to be able to store and test variables.
Use STO>
to put variables or values into other varables. It appears as an arrow on the screen.
You can't make very good games without being able to check variables. That is what the If
command is for.
If can be used in three ways:
or
:If A==6:If A==6:(Command)
This simply carries out the command dirrectly after if the statement is true and skips to the next command if it is false.
:(Command)
:(Command)
:(Command)
If A==6:Then
This simply carries out the commands up to the next "End" if the statement is true and skips to the command after "End" if it is false.
(Commands)
(Commands)
(Commands)
(Commands)
End
(Command)
If A==6:Then
This carries out the commands up to the "Else" and skips to the command after "End" if the statement is true, but if it is false, it carries out the commands between "Else" and "End" and it skips to the command after "End" when done.
(Commands)
(Commands)
Else
(Commands)
(Commands)
End
(Command)
You can use:
A==6 Equal to (Yes yo need two equal signs)
A<6 Less than
A>6 Greater than
A=<6 Equal to or Less Than
A>=6 Equal to or Greater Than
A<>6 Not Equal to (equal sign with the slash through it)PROGRAM:GETKEY
Now, the program appears to do nothing, but hit a key and you'll see the keys getkey code appear, and stay!
:Lbl Loop
:getky->Key (arrow is the Store (STO>) key over the on key)
:If Key<>0 (not equal to)
:Disp Key
:Goto Loop
Now lets make it show only one code at a time AND clear the screen.
PROGRAM:GETKEY
Would you rather have it appear in the center of the screen?
:Lbl Loop
:getky->Key
:If Key<>0:Then
:ClLCD
:Disp Key
:End
:Goto Loop
PROGRAM:GETKEY
It doesn't want to show anything when you start up, so lets put up a message that goes away after you hit a key.
:Lbl Loop
:getky->Key
:If Key<>0:Then
:ClLCD
:Output(4,10,Key
:End
:Goto Loop
PROGRAM:GETKEY
How about if you make "ENTER" quit the program
:Disp "","",""," Hit any key to see" (the empty quotes
:Disp " it's getkey code" move the text down)
:Lbl Loop
:getky->Key
:If Key<>0:Then
:ClLCD
:Disp Key
:End
:Goto Loop
PROGRAM:GETKEY
Do you want to keep the Done from appearing?
:Disp "","",""," Hit any key to see" (the empty quotes
:Disp " it's getkey code" move the text down)
:Disp ""," Hit ENTER to quit"
:Lbl Loop
:getky->Key
:If Key==105:Then
:ClLCD
:Stop
:Else
:If Key<>0:Then
:ClLCD
:Disp Key
:End
:End
:Goto Loop
Add:
Output(2,1," " after the ClLCD but before the Stop command.
Remember how the output command keeps the Done from showing? You actualy put a space into a place on the screen where there is already an invisible space. That remains invisible, but still tricks the calculator into thinking it's got something on the screen.
What if you want to make a loop that loops a specific number of times or adds or subtracts a value from a variable each time it goes throught the loop.
Text(Vert,Horz, {Var or "String"} )
command. This command draws text or the contents of a variable directly onto the graphics screen. The Line(X1,Y1,X2,Y2[,Draw])
command, unlike the TI-80, 81, and 85, has the option to erase all pixels allong a line rather than turn them on. You simply add ",0" to the end of the command to erase the line (",1" draws the line, but is implied, so you don't ever need to type it in. When a variable determines if the line is drawn or erased, you simply put 1 into it to draw and 0 into it to erase. The TI-92 also has a feature that will inverse each pixel along a line when ",-1" is typed after the line command.). The 82 and 83 both have some "nifty" Pxl {On/Off/Chg} (Vert,Horz)
commands. They map dirrectly to the pixels of the screen, regardless of what the window is set to (the Text(Vert,Horz,Var or "String")
command also maps directly to the screen in the same manner). These are useful for drawing progress bars or anything else that needs to always remain in the same place when the window settings need to be changed. The PxlTest(Vert,Horz)
command allows you to test if a pixel is on or off. This too is also very helpfull with advanced graphics programing. I am good at programming these calculators. I have made and helped to make many games (including scaled down versions of games like Mortal Kombat and Doom). The TI-85, unfortunately, doesn't have these marvelous commands. With the 85, you must turn off pixels one by one using the PtOff(Horz,Vert)
command. This is slow and difficult if the line is a diagonal one. As for the Pxl {On/Off/Chg} (Vert,Horz)
commands, You can achive them by using this formula (TI-85 version): Pt {On/Off/Chg} (X((xMax-xMin)/126),Y((yMax-yMin)/62))
(replace 126 with 94 for the TI-81 and for the TI-80, replace 126 with 64 and 62 with 48). The text command is also not on the 85. I have created a program that draws the text manualy. It is slow, but it works. The program takes around 6K and is easy to use. Just type # -> texx : # -> texy : {"String" or StringVar} -> text : GTEXT
into the home screen or into a program and it will draw the text in the text variable at the location determined by the contents of variables texx and texy. As for the PxlTest command, there is, unfortunately, no way that I know of to test if a pixel is on or off without using assembly language.
Assembly language (which I, unfortunately, don't know how to use to make programs right now), is the most efficient, the most versatile, and the fastest way to run programs on any machine. It may be difficult to program with it if you don't know much about it, but when you see what you can do with it, I think you may take lessons soon! You can create fluid, grayscale images on the screen. You can create fluid animation, just like portable game systems (what do you think those game boy cartriges use as their programming language)! You can control every aspect of your calculator and even add to its functionality! I have even heard of a project ( being done by Mel Tsai) that is underway to create a device that can plug into a TI-85 or a TI-92 link port that gives it 512K or even a full 1024K-ONE MEGABYTE-of external memory. It is a memory chip with a serial interface. It opperates as if you had a hard drive or a tape drive connected (it doesn't actualy add memory. It just provides a place to store memory like a disk or hard drive, just so that's clear. A lot of people thought that it was an actual memory expansion). This device is nice for TI-BASIC programs because you can store them on it and copy them to the calculator when you need them, but assembly language has an advantage with devices such as these! Remember the phrase "control every aspect of your calculator"? You can also control the link port. This means that the device could posibly access data files no larger than the free memory of the calculator, but if you have 10 files, then your program could be over 200K in total size (it isn't quite like virtual memory though. It is more like using a lot of data files on a hard drive and accessing them one at a time)! Virtual memory is a way to use a storage device as temporary memory for programs to run. The assembly language program can access the link port and read specific blocks of the extender's memory! This means you could have hundreds of kilobytes of stuff like graphics and data files. The assembly language can read these files without having to copy the actual file! If you are interested in assembly language, and you think you have the skills to learn it, go for it! It's an excelent programing tool.
LinkExchange Member | Free Home Pages at XOOM | Free Home Pages at GeoCities |
|
The Richfiles is copyright © 1996-2000. All Rights Reserved.