I don't have a lot of experience with assembly, but I can give you the general technique with BASIC (and if you can apply it to assembly, it should work fine):
You want to use "GetKey" (in the PROGRAM:IO menu) to get the value of the last key pressed, and store it in a variable. No key was pressed, then GetKey returns 0. If you want to keep doing stuff but only move sometimes, then you get the key, and if it is 0, then you don't move. If you only want to do something when you move, then you can loop until the key is not zero, and then do something with that key. The value of each key (on the TI83+/84+) is a two-digit number where the first digit is the row (1_ for the top keys, 2_ for the first row under it, etc. and 10_ for the bottom row), and the second digit is the column (_1 for the left-most column, and _5 for the right-most column). One catch is that the left, up, and right keys are considered to be part of the 2nd row (making those 24,25,26), and down is part of the 3rd row (making it 34). Sometimes it is good to use GetKey just one time before a loop just to dump the last value (for example, perhaps the person pressed ENTER to start the program, and you want to ignore that key).
Here is some code which uses A and B for the (row,column) position, K for the key, and changes it according to key presses. The loop goes until they press 2ND (which is 21). The nice thing about "Repeat" loops is that they always go through at least once; and THEN it checks teh condition (for example, "Repeat K=21" will do all the code until the "End", and then will do it again and again until K is 21):
Code: Getkey
Repeat K=21
Getkey -> K
If K=25
A-1 -> A
If K=34
A+1 -> A
If K=24
B-1 -> B
If K=26
B+1 -> B
End
There are ways to shorten that too: whenever you say something like "K=21", it turns into 1 if it is true and 0 if it is not. That means that you can put each comparison in parenthesis and actually add several values together. Thus, that code can be shortened to:
Code:
Getkey
Repeat K=21
Getkey -> K
A-(K=25)+(K=34) -> A
B-(K=24)+(K=26) -> B
End
Some points to consider:
- If you want to move by more than "1" unit at a time, then multiply by however much you want to move (e.g. "A+5 -> A", or perhaps "A-5(K=25)+5(K=34) -> A").
- If you want to keep the movement within certain boundaries, then you also check if the position is not too close to move that way (for example, "If K=34 and A<8" for "if you pressed DOWN and the row-position is not too far down (and 8 is too far)"). This can also be applied to the combination of statements, perhaps "A-(K=25 and A>0)+(K=34 and A<Cool".
- If you want to "wrap around" (when you move off the screen on one side, come back in on the opposite side), then you can move like you would, but then use an "If" to check if it is out of bounds and correct it. You can shorten this into smaller statements similar to how I did with combining keypresses:
"A+8(A<1)-8(A>Cool -> A" wraps A within 8 positions. Replace "8" with the actual size you want.
- The are multiple ways to move the screen around on a map. One way is to position and move things as if you could see the whole map all at once. You can then either compute the "screen position" from the position of something else, or store the screen position and move it around with everything else. Either way, whenever you display or draw stuff, you subtract the screen-position from the position of everything else to find where to draw it on the SCREEN (rather than on the whole map); and then you only draw things that are within the screen boundaries Smile
- Sorry, but there is no way to detect multiple keypresses at once in BASIC (but that are in assembly!). You can get around this either by using 8 keys (4 cardinal directions, and 4 for diagonals), or by storing values for which WAY to move ("momentum"), which would work JUST like moving something around on a screen; except that you are literally moving the "direction of movement". Then you have the position of the thing that is moving change according to that. The code would look something like this (assuming that A and B are the thing that moves [perhaps the screen], and C and D are the direction it is moving):
Code: 0 -> C
0 -> D
Getkey
Repeat K=21
Getkey -> K
C-(K=25 and C> -1)+(K=34 and C<1) -> C
D-(K=24 and D> -1)+(K=26 and D<1) -> D
A+C -> A
B+D -> B
There are MANY tools for tilemaps or sprites etc.; but I'm not familiar with any of them. Take a browse and see what you find in the archives (or perhaps someone else has more helpful info?)