The Developer's Guide
This guide will explain how to modify the RPG Starter Kit so that you can make your own custom game, whether it be an RPG, a maze game, or what ever you can think of. This guide will assume that you have some basic understanding of TI-BASIC for the Z80 calcs, and if you don't you will want to review the tutorials found
here. All modifications should be done on-calc, so you can test new features that you add immediately after coding them in, to know how the new code will effect the program.
Assuming you already have the files on your calculator from the zip file found by clicking the download link, run prgmA. prgmA is the setup program, that sets up variables, and calls on the other programs to begin running. So to start out, you want to substitute prgmA with the name of the program you wish to start the game with. It will be important that you have the variables set up correctly, before running any of the other programs so you don't get errors. As far as I have been able to tell, everything is working perfectly as is.
prgmA: 58 bytes
ClrHome
3->W:50->T
1->L:4->Q
2->M:2->P
"XθDEG"->Str2
prgmZLVL
prgmZGA
As stated above, this program sets up your variables. It will be very important that you get a sheet of paper and write now all variables on paper (A-θ) and next to them, write down what each one does. A break down of what this program/game uses:
K: This is the getkey variable, do not store important data to this variable
L: This stores horizontal map data
M: This stores vertical map data
P: This is the character's position, going left and right
Q: This is the character's position, going up and down
T: This keeps track of the characters position in the string for hit detection purposes
W: This is for the While loops
Str1: This contains the map data
Str2: This contains the characters for hit detection
Keeping track of variables will save you a lot of headaches if you have any problems within the game.
Moving on, editing the maps is very simple. The map is set up in 128 character blocks, stored in to Str1. The way the calc tells which level it should display is by variables L and M. The way the current maping system is set up, L=1/M=1 is the top left corner, with L increasing as the maps go down, and M increasing as the maps go right. Theoretically, the rpgsk is capable handling any amount of maps that you can program in.
When making maps, I suggest that you get graph paper, and make boxes of 8x16 squares. This will be the area that you need to program in to your calc, and will give you a very rough idea what it will look like before programming it into your calculator. Fill the page as best you can, but leave room on the sides for you to make notes of where the maps are at, where L and M are concerned.
The test map looks like this:
| M=1 | M=2 |
L=0 |
X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
X | X | | | | | E | G | | | | | | | | |
X | | | θ | D | | | | | G | G | G | | X | | X |
X | | | θ | G | E | D | X | X | X | X | X | | X | X | X |
X | V | | | X | X | X | X | X | X | X | X | | X | X | X |
X | X | X | | X | X | | | | | | X | | X | X | X |
X | X | | | X | X | | X | X | X | | X | | X | X | X |
X | | | X | X | X | | X | X | X | | X | | X | X | X | |
X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
| | | | | | | | | | | | | | | X |
X | | | | X | | | | | | | | | | | X |
X | | | | X | | | | | X | X | X | X | | | X |
X | X | X | X | X | X | X | | | X | | X | | X | | X |
X | | X | X | X | | X | | | X | | X | | X | | X |
X | | | | | | X | X | X | X | | | | X | | X |
X | | | | | | X | | | | | | | X | | X | |
L=2 |
X | | | X | X | X | | X | X | X | | X | | X | X | X |
X | | | | X | | | X | X | X | | | | | | |
X | | | X | | | | X | X | | | X | X | X | | |
X | | X | X | | | | X | X | | X | X | X | X | | X |
X | X | | X | | | | X | X | | X | X | X | X | | X |
X | | | X | | | | X | X | X | | | | | | X |
X | | | | | | | X | X | X | | | | | | X |
X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | |
X | | | | | | X | | | | | | | X | | X |
| | | | | | | | X | X | X | | | X | | X |
| | X | X | X | | X | X | X | X | X | | | X | | X |
X | | X | X | X | | X | X | X | | | | X | X | | X |
X | | X | X | X | | X | X | X | X | | X | X | X | | X |
X | | | | | | X | X | | | | | | | | X |
X | | | | | | X | X | | | | | | | | X |
X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | |
prgmZLVL - size: 612 bytes
If L=1:Then
If M=1:Then
"XXXXXXXXXXXXXXXXXX XX X XX XXX X XX XXXXXXXXX XXXXV XXXXXXXX XXXXXX XX X XXXXX XX XXX X XXXX XXX
XXX X XXX"->Str1
End
If M=2:Then
"XXXXXXXXXXXXXXXX XX X XX X XXXX XXXXXXXX X X X XX XXX X X X X XX XXXX X XX
X X X"->Str1
End:End
If L=2:Then
If M=1:Then
"X XXX XXX X XXXX X XXX X X XX XXX X XX XX XXXX XXX X XX XXXX XX X XXX XX XXX XXXXXXXXXX
XXXXXXX"->Str1
End
If M=2:Then
"X X X X XXX X X XXX XXXXX X XX XXX XXXX XX XX XXX XXXX XXX XX XX XX T XX XXXXXXXXX
XXXXXXXX"->Str1
End:End
ClrHome
Output(1,1,Str1
As you can see, the very first thing that the map data program does is to see what horizontal line you are on. If you start on the second level, it will skip everything between the If L=1:Then and the End statements. If you forget to place an end statement at the end of a horizontal or vertical levelset, it may skip all of them all together... Keeping track of If:Then:End combinations will save you alot of debugging later on.
If you are going to have a lot of levels going vertical instead of horizontal, then you can change the variables to search for M first. Just make sure you keep the same general layout as shown above.
After it figures out where the character is at and stores this information to Str1, the program tells the calc to clear the homescreen, and then uses Output( to display the entire string. The great thing about Output( is that it has automatic text wrapping, so it will display the map extremely fast, and doesn't need any complicated routine to display it, like using matrices and lists require.
Now that you have the levels programmed in (or you have the files that came in the zip loaded on to your calc) it is time to do movement and hit detection. Take a look at the coding for
prgmZGA:
prgmZGA: 448 bytes
While W=3
Output(Q,P,"θ
If sub(Str1,T,1)n=" ":Then:prgmZCH:End
getKey->K
If K=24:Then
If P=1:Then
M-1->M:T+15->T
15+P->P
prgmZLVL
End
If P>1:Then
If not(inString(Str2,sub(Str1,T-1,1):Then
Output(Q,P,"
P-1->P:T-1->T
End:End:End
If K=25:Then
If Q=1:Then
L-1->L:T+112->T
Q+7->Q
prgmZLVL
End
If Q>1:Then
If not(inString(Str2,sub(Str1,T-16,1):Then
Output(Q,P,"
Q-1->Q:T-16->T
End:End:End
If K=26:Then
If P=16:Then
M+1->M:T-15->T
P-15->P
prgmZLVL
End
If P<16:Then
If not(inString(Str2,sub(Str1,T+1,1):Then
Output(Q,P,"
P+1->P:T+1->T
End:End:End
If K=34:Then
If Q=8:Then
L+1->L:T-112->T
Q-7->Q
prgmZLVL
End
If Q<8:Then
If not(inString(Str2,sub(Str1,T+16,1):Then
Output(Q,P,"
Q+1->Q:T+16->T
End:End:End
End
Starting from the top... the While command starts the loop off, then you have Output(Q,P,"θ, which will display the character. The next bit of code (If sub(Str1,T,1)n=" ":Then:prgmZCH:End) is the all important event detection. This will allow your character to land on a particular ascii graphic, and the calculator will call on prgmZCH to 'check' what it is supposed to do. We will look into the events part a little later.
Next is the getkey command, and I am sure you know how important that is to a game like this. :) Now for the key detection. I will only cover one direction (left) fully, and talk about how and why up/down works.
Starting with "If K=24", The first thing the calc does is to detect the position of the character on the screen. So, "If P=1" means that if the character is on the far left of the screen, Then it subtracts from its vertical level amount, and adds 15 to T, so it is dynamic enough that you don't have to worry about variable Q's value. After the equations are complete, it calls prgmZLVL and then Ends.
Next it checks to see if it is anywhere but on the far left side of the screen. If it is, then it checks Str2 to see if there is anything that is one character to the left of it. If not, then it clears out where the character is at, (Output(Q,P," ") then subtracts one from P and T, to make sure it keeps track of the character in the string. That is pretty much all there is to each of the movement segments.
The only differences with K=25 and K=34 (down and up) is that the calc subtracts/adds different variables, but when it shifts to the next screen, it adds/subtracts 112, to keep it as dynamic as possible. Moving up and down inside the screen borders only increases/decreases T by 16.
The next program that needs to be created is the checking routine. It simply looks to see what character that the θ stepped on that wasn't restricted by Str2. After it determines the character type, it then proceeds to follow the directions that you encoded into it. For the demo, they are very simple.
prgmZCH: 171 bytes
If sub(Str1,T,1)="V":Then
ClrHome
Disp "The vilage has","not been built
Pause
T+1->T:P+1->P
prgmZLVL
Return:End
If sub(Str1,T,1)="T":Then
If L=2 and M=2:Then
ClrHome
Disp "There is no","spoon...
Pause
T+1->T:P+1->P
prgmZLVL:Return
End:End
Quite simply, this code merely checks to see if it lands on V or T. In the case of T, It also checks to see where at on the map that T was jumped on. You also have to make sure that you add or subtract for the character placement, otherwise everytime you return back to prgmZGA, it will just send you back to this program. Add to this program as much as you want. This is the event handler, and can be used for numerous things.
Now I am sure you are thinking, "Wow, this has everything!", but I can assure you, it is just a basic 'foundation' if you will. You can add enemies and battles, a maze system, etc. There are a great many possibilities for this starter kit. I will try to give you an over view of a few of the ideas that people have wanted me to include in this documentation.
Adding random battles with enemies is fairly easy. What you need to do is create a program, call it ZEN. For randomness, just do:
prgmZEN
randInt(1,6)->θ
If θ!=3:Return
If θ=3:Then
randInt(1,#)->θ
Begin enemy code here
prgmZBA
Output(1,1,Str1
End
Battle engines are someting that cannot really be explained, since each battle engine would be unique to each developer. Because of this, I cannot really explain the battle engine system, since there are so many ways you could build one. If you do require some assistance, plese check out
my forums and ask your questions there. :)
For the most part, this is about as much as can be explained for the starter kit itself. If you have any particular questions you want answered, please refer to my forum.