Pyro's Sprite Editor
Version 1.0 BETA 2 by Scott Garrett
Released on July 17, 2006

[[[[[ Platforms ]]]]]

Will run on the TI-83+ and TI-84+ calculators and also the Silver Editions.

[[[[[ Disclaimer ]]]]]

Right off the bat, I'm gonna warn you that I am not responsible for any damage this program does to your calculator. It has been tested on emulators and mostly my own calc, and in the entire history if its development it only crashed twice (I had just finished learning how to work xLIB then), and has not had any problems afterwards. However, this is a beta version, which means, it could have bugs (though I've seen none so far), so use at your own risk.

[[[[[ Contact Me ]]]]]

If you find have questions, comments, suggestions, or found any bugs, drop me a line:
By website: http://pyros.blogsite.org
By email: pyro_xp2k@yahoo.com

[[[[[ Changes and Bugfixes ]]]]]

The cursor moves at 8px intervals again. Press Math in the Pixel Editor to hide it. The sprite being edited will blink so you can see it, you can and the parts of the picture around it. That should help with connecting lines for now until the 16x16 feature is implemented.

The Copy bug has been fixed.

The power-save sub won't crash anymore in the Pixel Editor (and shouldn't crash in mods anymore either, if used).

[[[[[ Introduction ]]]]]

Pyro's Sprite Editor is... well, a sprite editor. Utilizing Patrick Prendergast's xLIB library, it lets you quickly edit pics and individual sprites on your calculator, and comes with many nice features -- you can quick-edit multiple sprites at once, do basic transform functions like flip, invert, transpose, etc, and of course, edit sprites in the pixel editor. And, if that isn't enough for you, you can also create and and add "mods" to the editor to extend it's features by editing the appropriate mod sub, and if you mess up, just take out the buggy code from the mod and the editor will be running like it should.

[[[[[ Installation ]]]]]

Obviously, you'll need the xLIB application, which is included, but I'd recommend you download it from ticalc.org if you want to make sure it's the latest version. That will cost you 16k of archive space. For the program itself, its dependencies, and for temp space, you'll need at least 6500 bytes free.

After you get xLIB (or if you already have it), send the group file PYROEDIT to you calc (if there is not a group files then there probably is a folder called PYROEDIT. Send everything in it to your calc.), ungroup them and you should be good to go. Run prgmAPSE to get started. When you first open the editor you should see the intro screen, then it will pause and wait for you to hit enter, open the first pic, and take you to the editing screen. If you get an error or warning, take a look at the troubleshooting section.

[[[[[ Using the Editor ]]]]]

The Editing Screen

When you are at the editing screen, you'll see the currently open pic and a flickering cursor. Use the arrow keys to move the cursor. It will move in eight-pixel increments. When you want to perform a function on a sprite, select it and press the appropate key. The list of keys are below:

Y=: Open a Pic #. You can open Pics 1 through 255.
2nd: Select and apply function. If you press this once, it will mark the current sprite as the start point and let you select multiple sprites (or halves of sprites) to apply a function to. The cursor stops flashing and inverts when you're in this mode. Pressing MODE will cancel and go back to single-select mode. If you only want to apply a function the one you have selected, just press 2nd again. If you want to apply a function to more sprites (or halves of), use the arrow keys to select the end point and press 2nd. Then you'll be asked what function you want to apply (Flip, Invert, etc.), and the editor will apply the chosen function to the sprite(s) you selected. You'll go back in single-select mode after you apply a function (or cancel).
MODE: Will quit the editor (but will ask first).
DEL: Will delete the current sprite or picture (and will also ask first).
ARROWS: Navigate the cursor around the screen.
C (PRGM): Copy. This will allow you to copy the currently open pic to another, and even open the copy if you want. If you don't want to make a copy, enter a zero and press enter.
E (SIN): Edit. This will open the pixel editor and allow you to edit the selected sprite. You can only edit one sprite at a time, so this will not work in multi-select mode.

F (COS): Flip. Flips the currently selected sprite horizontally. (Vertical flipping not available yet at the editing screen yet, but you can do it in the pixel editor).

*NEW* T (4): Will let you insert text at the current point. Typing a colon at the prompt will cancel. Text will be placed from where the cursor is and can go across the entire screen horizontally (but it will not wrap). Make sure you are careful with this as you can overwrite parts of other sprites if you enter text near them.


The Pixel Editor

Pressing E on the selected sprite will fire up the pixel editor. It takes a few secs to load and render, and when its done, you'll be greeted by a zoomed version of the sprite placed next to the original, and a flashing cursor at the top left. The keys for the pixel editor is as follows:

2nd: Turns the selected pixel on or off.
MODE: Closes the editor and prompts you to save changes you made to the sprite.
ARROWS: Navigate the cursor.
MATH: This will hide the editor window and let you see sprites under it (and the sprite you're editing). Press any key to show the editor again.
DEL: Clear the drawing canvas (will prompt).
F: Will show the Flip and Turn menu, letting you apply some basic transform functions to the sprite. The first option -- "<" -- will go back without doing anything.

[[[[[ Troubleshooting ]]]]]


When I run the program, it tells me "ERR:XLIB?" and makes me exit.

>> You probably don't have the xLIB app installed.

I do have xLIB installed!
>> Make sure it is enabled. Go to the xLIB app and press 1 to install the hook, then 3 to exit, and try running the editor again.


When I run the program, it tells me "ERR:RAM < 2500" and and gives me the options to exit or return.

>> You need at least 2500 bytes of RAM for the editor to work without crashing with a ERR:MEMORY error. If you want to risk it, go ahead and choose "Return," but I wouldn't recommend it. Go clean up some vars and trash on your calc and try to run the program again.

In the middle of editing, I suddenly get a message like this:

>> That is the "graph cache" subroutine talking. It is part of a subroutine I made the editor uses that remembers what is on the screen and saves them to be recalled later.

Sometimes the coder who writes a program (or mod sub) that uses ZGCS (that usually means me [^_^] ) screws up and/or forgets to tell the program to run the sub that recall the pic and cleans it out the cache. The cache builds up, and eventually ZGCS begins to worry that it could could overwrite one of your pics, so it gives you this warning, telling you which pic would be destroyed next and asks you want you want to do about it.

Just hit Enter and click "Stop and Clear" - which will actually STOP the entire program hierarchy and clear out the cache. Unless there's something you need to save, then do this. Otherwise you can click "Return" if you know you have no pic in the "NEXT TARGET PIC." In that case, go save your stuff, then exit the program immediately and restart.

You should almost never get this warning unless you're developing mods that use this sub (and don't include all the subs in you're supposed to).

[[[[[ Adding Mods to the Editor ]]]]]

If you want more features in the editor, you can edit the "mod programs". These let you change how to editor works, look, or acts - to an extent. There are five mod programs (four for the editor itself, and one for the pixel editor) - programs APSE0 through APSE3 and APSED0 for the pixel editor. The documentation that comes with most mods should probably tell you what code to insert where (and if you're developing mods, you should be nice an include documentation [^_^]).

prgmAPSE0 is executed at start-up. Mods that need to do things at the start of the program should be inserted here.
prgmAPSE1, executed before the getKey loop (waits for the user to press a key), and after the user presses a key. Some types of key hooks could go here, or possibly a mod that draws or removes things from the screen before it waits for the user to press a key, just to name some examples. Not ran in the multi-select loop to prevent problems.
prgmAPSE2, executed after the user presses a key, and is ran from the key-processor sub, so you can override keys. Most key hooks will go here. Not ran in the multi-select loop to prevent problems.
prgmAPSE3, executed on exit. Mods that do things when the user exits (such as clean up trash from other mods) would go here.

prgmAPSED0, executed after the user presses a key in the pixel editor.

Screw all that for now - let's try installing two mods. In this archive there should be a group called MODS (if there's not a group file then there should be a folder. Send everything it in to your calc.). Send it to your calculator and ungroup it. There are two mods in the group. The first one, XPSE2RND, will let you generate a random sprite wherever your cursor is when you press "R" on a selected sprite. The second, XPSE2XLB, will generate xLIB code [real(1,...)] for the sprite you select when you press the "X" on a selected sprite. Go transfer both of those to your calc (or whichever one you think is more useful). Now go to the PRGM menu and edit APSE2. It should be blank. Add the following two lines:



Then quit back to the home screen and run the editor. Select an empty space on the editor screen and hit "R". The Random Generator mod should fire up. Play around with it if you want. You won't be able to move your cursor until you quit the generator (MODE key). Select Go and press 2nd until it generates something you like, then press MODE, and select SAVE + Return. You should be able to move your cursor now.
.

Now, press "X". It should tell you it's generating code and then show you the xLIB code for your sprite in a few seconds. Press Enter to exit out of that mod.


[[[[[ Developing Mods ]]]]]

The mod developing guide will be included in the next release (because I'll have some new features to add in and some more time). But if the "Beast of BASIC" within you can't wait and you want to start making mods now, then you can just simply examine the editor's (and/or subroutines') code and that should help you out. Also, here is a little bit of info some info on vars and subs. Until the entire tuturial is written, you'll have to figure out things on your own, but if you need help, just ask me. Not unlike your favorite insurance company, I'm [almost] always availible. [^_^]

Useful subs:
ZPSAVE: The power-saving sub. Look at the S var below to see how to use it.
ZSTAT: Display a statusbar message. Syntax:

" Status message. " (put the space before it so that ZCGS will save the screen)
prgmZSTAT
[stuff to do]
//If you want to change the status message://
"New status message" (don't put the space before)
prgmZSTAT
//When you're done//
":" (a colon in quotes)
prgmZSTAT

ZMSG: (included with the sample mods). Displays an message on the screen. Syntax:

"Title =<16 chars:Text you want to display in message."
prgmZMSG

Variables used in the editor:
If it says "tempvar," you can use it but don't expect it to last too long.

A - This should always be six!
W, X, Y - temp vars. You can use these, but just don't expect them to stay what you set them to. K is also a tempvar. Always use this for determining what the user pressed in APSE's getKey loop. You can use your own tempvar in your own getKey loops, if you use K, you may need to delete it before the mod exits.
P - the currently open pic. If you should change this, then do 1:prgmPSEPS if you need to save the currently open pic and then real(3,P to put the one you're opening on the screen.
H8,V - The coords of the cursor. H alone is the horizontal coordinate in BYTES (as it is in xLIB). V is the vertical coordinate in PIXELS.
I8,J - Tempvars used to store coordinate in the pixel editor and in the multi-select feature.
L8, M - Ttempvars used to store coordinates in the pixel editor and the multi-select feature.
S - the power-save counter. If you want to include the power-save sub in your mod, set your getKey loop up something like this:

DelVar S
Repeat Ans
Repeat Ans
prgmZPSAVE
getkey->K
End
[stuff to do afterwards]
End

Theta - A tempvar used by the parser (which is not included in the group but is included with the mods). The number of items the parser finds in a string is stored in this, otherwise it's unused.
Matrix A - Tempvar used by the pixel editor. Use a tempvar if you use it.

U - Used as a flag the pixel editor for functions that need to update the display (like transpose, flip, etc).
D, E, F - Used in the pixel editor. D and E are the coords to display the editor at. F is the size of the pixels.
Str0, Str9: Tempvars.
Pics255 to Pic249 are reserved for graph cache, but I would not use anything over 245, just to be safe.
List 6 - Tempvar.
List 2 - Used by the parser (if you used this). Psedoarray index are stored in this and the string would be stored in Str0. If you're not using the parser (and the parent program isn't) then feel free to use this var.
Do not use List 4 or BAD THINGS COULD HAPPEN!!!!!!!!!!!!!! (Reseved for the graph-caching sub)

[[[[[ Credits ]]]]]

I'd like to thank Patrick Prendergast, who created the xLIB library, the guys at Omnimaga for the helping me with things along the way, and Alexander Weissman's BASIC Optimization and Cemetech's 1337 BASIC guides, which really helped with speeding things up and saving a ton of memory. Without these people, this program would not have been possible (and/or really big and crappy).

If you find any of my subroutines that come with the editor (or mods I've made) useful, feel free to use them. But do please give me some credit :-) and if you use xLIB, give Patrick Prendergast credit, too (he really deserves it for all the work he's done with the revolutionary xLIB app)