A Tutorial for the Ti-83/84+(SE) Series of Calculators by Roberto Sanchez
In this tutorial, I will explain how to make pure BASIC sprites using scatterplots. Using scatterplots allows the programmers to specify the pixel locations using lists. Some advantages of statistical sprites are:
Some of the disadvantages are:
In this tutorial, I will also explain how to use Statistical Sprite Creator , a utility created by Thomas Dickerson
Creating the lists necessary to display the sprites can be tedious work. However, Statistical Sprite Creator , a utility created by Thomas Dickerson , makes this process a lot easier. The next few sections explain the steps necessary to go from pixels to lists.
The first step in creating statistical sprites is getting the data that represents the sprite. This data can be in binary or hexadecimal to represent which pixels are set and which are not. Both hexadecimal and binary can be used, so use the one that's easier for you. Let's use an X as an example. This will be a sprite that is 5 pixels wide and 5 pixels high. In binary, this will be represented as 1000101010001000101010001. However, since the width of the X is not a multiple of 4, you have to round up to the nearest multiple of 8. Therefore, the X is technically 8 pixels wide and 5 pixels hide. The new pixels you added are blank. The hexadecimal data becomes 8850205088. The hexadecimal data may not be equal to the binary data, but both will generate identical lists. Like I said before, pick which number system is easiest for you to represent the sprite data. There are also additional utility programs that may aid you in getting sprite data: BMP to Black and White Hex Converter , which converts a .bmp image store on your computer to hexadecimal sprite data, and Sprite2Hex by Daniel Thorneycroft, which allows you to draw the sprite on your calculator and retrieve the hexadecimal sprite data.
Now that you have your sprite data, you are reasy to use Statistical Sprite Creator. Run the program and the first thing you have to do is input the sprite data. Enter your sprite data and press enter. Next, the program will ask you if you used Hexadecimal or Binary. Press 2nd+Alpha and enter BIN for binary or HEX for hexadecimal. The program now asks you for the width of the sprite. Enter the width of the sprite the sprite data represents. Do the same when the program asks for height. After you're done with all the inputs, Statistical Sprite Creator will create the lists necessary. If you're making large sprites, be ready to wait for the program to finish. When the program is finally finished, you have the lists ready and you can display the sprites! However, in order to do anything other than simply displaying the sprite, you have to perform operations on lists. The next few sections explain some list functions that help when using statistical sprites.
You can perform the four basic arithmetic operations, addition, subtraction, multiplication, and division, on lists. If you store your list to L1 and a number to A, the operations will return the following:
Adding and subtracting will have the effect of moving the sprite to a separate location. Multiplying and dividing will have the effect of expanding and shrinking the sprite, respectively. It should also be noted that these operations can also be performed with two lists instead of one list and one number. However, both lists must have the same dimensions and adding lists isn't needed in stat sprites.
Augment is a list function that can be accessed by 2nd+STAT+RIGHT+9. The syntax for the function is augment(ListA,ListB where both lists can be any list you want. What augment does is insert all the elements of ListB to the end of ListA. This function is worth mentioning because it allows you to use many more sprites than there are stat plots. You can augment the x-location list of one sprite to another x-location list and the y-location list of one sprite to another y-location list. Both sprites will now be displayed. This function is also useful in displaying multiple copies of one sprite.
A list property that is very helpful in creating and using stat sprites is storing a string to a list. This can have the effect of automating the list operations previously mentioned, thereby reducing the amount of code a display loop has to process and making the program faster. To demonstrate how this works, do ``{A,B,C->L1. Then store any numbers to A,B, and C. When you check the contents of L1, you will see the values of A,B, and C. Now store any other values to A,B, and C. You will notice that L1 now displays different values. From now on, whenever you use L1, the values of any variable, operation, or function will be calculated and a list containing these calculated values will be returned. It is essentially the same as doing expr(string)
except you can expr multiple values. This can also be used in situations other than stat sprites. If you have long conditionals that are used repeatedly in the program, you can do ''{conditional->L1. Later in the program, all you have to do is access the first element of L1 (L1(1)) to get the value of the condtional, thus saving memory. The way to use this effect in stat sprites is like this: ``xlist + x -> list and ''ylist + y -> y. (The end quotation marks are omitted to save memory) Let's say L1 is the x list and L2 is the y list. A is the x offset and B is the y offset. Instead of doing L1 + A -> L1 in the program, you can just do ``L1 + A -> L3 and the value will automatically be calculated when needed. This also has the effect of preserving the original sprite list, allowing you to use the same list for multiple sprites. You can also automate the augment function. Let's say L3 holds the x list for a second sprite and L4 holds the y list for a second sprite. C and D are also the X and Y offsets. You can do ''augment(L1 + A,L3 + C-> L5 and ``augment(L2 + B, L4 + D->L6. Then, plot the values of L5 and L6 instead.
Displaying the sprite is as simple as doing Plot1(scatter,x-list,y-list,dot . After this, do any draw command to display and update the sprites. The sprite will not be drawn until you use a draw command. The Plot will also stay activated until you turn off stat plots using PlotsOff. This means you can remove the Plot1(etc command from the display loop, meaning it has to process less commands and go faster. All you have to do is use any draw command to display and update the sprites. (text, pxl-on, etc.) However, before you display the sprite, you have to set up the window first. You can access the window vars in the Vars menu. For stat sprites, do this: 0->Xmin:0->Ymin:94->Xmax:62->Ymax . Next, include these functions in your program: AxesOff, PlotsOff, GridOff, and FnOff. This ensures your sprites will be the only things on the screen and that you won't get any window errors. You're ready to display the sprites to the screen!
That's all you need to know to use stat sprites. Through practice, you will learn to master stat sprites and use them in your own programs. You can also check the source code of the included programs and download this program for code examples.
Questions? Comments? Concerns? Contact me at sanchez@stis.net.
Thomas Dickerson for his Statistical Sprite Creator
And thank you for downloading