Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: LT21j on May 29, 2011, 12:19:20 am

Title: Noob Help
Post by: LT21j on May 29, 2011, 12:19:20 am
Hey I'm a new for using axe parser, so i don't know alot of tricks and syntex. But I have programed a fair amount to understand basic commands. Anyway the problem I am programing a side scroller and the way I want to program someone walking is by testing getkey in a main repeat loop. And if a getkey equals a certain number like 2, then I want to change what it outputs by changed the value of the string 1. So In the beginning I set string1 to a value, (the character facing to the right), and when someone hits the left arrow key I want the person to turn to the left. So I want change the value of string1 to and image of the person facing to the left. But apparently you can't do that because every time I try to compile the program I get ERR: duplicate. So is there any trick to doing this or am I going in the complete wrong direction? Any help is greatly appreciated! Thanks

In case you couldn't understand what I was trying to say, here is the code:

:.BLA<br />:<br />:ClrDraw<br />:<br />:[4E4E447C440C1222]→Str1<br />:<br />:0→A<br />:56→B<br />:Repeat getKey(15)<br />:If getKey(1) and (B≠56<br />:B+1→B:End<br />:If getKey(2) and (A≠0<br />:A-1→A:End<br />:If getKey(3) and (A≠87<br />:[3A3A121E12182422]→Str1<br />:A+1→A:End<br />:If getKey(4) and (B≠0<br />:B-2→B:End<br />:If B<56<br />:B+1→B:End<br />:ClrDraw<br />:Pt-On(A,B,Str1)<br />:DispGraph<br />:End<br />Generated by <a href="http://sc.cemetech.net">SourceCoder</a>, © 2005-2011 <a href="http://www.cemetech.net">Cemetech</a>
Title: Re: Noob Help
Post by: ztrumpet on May 29, 2011, 12:22:33 am
I'm not quite sure what you mean by that.  Can you type out your source code either by hand or with Source Coder (http://www.cemetech.net/projects/basicelite/sourcecoder2.php) so we can see exactly what you're doing, so we can help you?

By the way, welcome to the forums! :D
Title: Re: Noob Help
Post by: JosJuice on May 29, 2011, 01:55:56 am
I'm not quite sure what you mean by that.  Can you type out your source code either by hand or with Source Coder (http://www.cemetech.net/projects/basicelite/sourcecoder2.php) so we can see exactly what you're doing, so we can help you?
I think he's trying to store a value to Str1 and then store another value to it later in the program.
Title: Re: Noob Help
Post by: Quigibo on May 29, 2011, 02:34:02 am
The Str, Pic, and GDB tokens are NOT variables.  They are static pointers so they can only be assigned to once and keep their value forever.  If you do need to change the value, simply use a variable instead.  Anywhere you can use "Str1" you can also use "A" or any other variable.
Title: Re: Noob Help
Post by: Freyaday on May 29, 2011, 10:48:46 pm
In fact, it gets even worse: They're just placeholders. When The compiler does its second pass, what it's doing is going back through the program and putting in the location of all the different pieces of data you're using, which are added at the end of the program after the last C9 [ret], so that the program ends execution before it reaches a bunch of bytes that are not intended to be executed. This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
Read the documentation (it helps! Really!), keeping in mind that whenever "program memory" is mentioned, what is meant is that those bytes get added to the compiled program as-is, placed in a location code execution will never reach.
Title: Re: Noob Help
Post by: ztrumpet on May 29, 2011, 11:47:42 pm
This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
The only time code will mix with data is when Axe adds its own sub-routines, like with the DispGraph command.  Basically, then any data defined before the first DispGraph is placed before the DispGraph sub-routine in the code, and any data defined after the first DispGraph is after it.
Title: Re: Noob Help
Post by: Freyaday on May 29, 2011, 11:53:05 pm
This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
The only time code will mix with data is when Axe adds its own sub-routines, like with the DispGraph command.  Basically, then any data defined before the first DispGraph is placed before the DispGraph sub-routine in the code, and any data defined after the first DispGraph is after it.
Is this supposed to happen, or is it a big?
Title: Re: Noob Help
Post by: ztrumpet on May 29, 2011, 11:56:19 pm
This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
The only time code will mix with data is when Axe adds its own sub-routines, like with the DispGraph command.  Basically, then any data defined before the first DispGraph is placed before the DispGraph sub-routine in the code, and any data defined after the first DispGraph is after it.
Is this supposed to happen, or is it a big?
bug? ;)
Nope, it's supposed to happen.  Basically the DispGraph routine is big, say around 100 bytes or so.  Each time you referenced it, you'd use 100 bytes or so out of your executable.  However, if you make it its own sub-routine, then it would only be 100 bytes or so (plus 10 or so to call the routine) and then only 10 more bytes or so each subsequent time the routine is called.
Title: Re: Noob Help
Post by: Freyaday on May 29, 2011, 11:59:27 pm
No, the data-mixing thing
Title: Re: Noob Help
Post by: Quigibo on May 30, 2011, 12:34:23 am
Data and code are the same, its all just bytes so it completely depends on how you look at it.  The same way the a single unsigned number can also represent a signed number, or an 8.8 fixed point number, or a pointer, or a character, or a 4x4 sprite, or a hexadecimal number, or an octal number, etc.  The only difference is how you use it.  So only bytes designated by "subroutines" get called and jumped to, and only bytes designated as "Data" read and write to their location in memory.  It doesn't matter that they're mixed because each built-in axe subroutine is self containing and can go anywhere in memory, just like how you can put your own subroutines anywhere in your Axe code.
Title: Re: Noob Help
Post by: Munchor on May 30, 2011, 02:56:50 am
Code: [Select]
.BLA

ClrDraw

[4E4E447C440C1222]→Pic1

0→A
56→B
Repeat getKey(15)

If getKey(1) and (B≠56)
B+1→B
End

If getKey(2) and (A≠0)
A-1→A
End

If getKey(3) and (A≠87)
[3A3A121E12182422]→Pic1
A+1→A
End

If getKey(4) and (B≠0)
B-2→B
End

If B<56
B+1→B
End

Pt-On(A,B,Pic1)
DispGraphClrDraw

End

I think this is fairly better, but haven't tested it yet.
Title: Re: Noob Help
Post by: LT21j on June 01, 2011, 08:54:25 am
It didn't work it gave me the same answer :(
Title: Re: Noob Help
Post by: Munchor on June 01, 2011, 09:18:22 am
It didn't work it gave me the same answer :(

DUPLICATE? Oh yeah sorry, here's a fixed code:

Code: [Select]
.BLA

ClrDraw

[4E4E447C440C1222]→Pic1

0→A
56→B
Repeat getKey(15)
Pic1→O

If getKey(1) and (B≠56)
B+1→B
End

If getKey(2) and (A≠0)
A-1→A
End

If getKey(3) and (A≠87)
[3A3A121E12182422]→O
A+1→A
End

If getKey(4) and (B≠0)
B-2→B
End

If B<56
B+1→B
End

Pt-On(A,B,O)
DispGraphClrDraw

End
Title: Re: Noob Help
Post by: Compynerd255 on June 01, 2011, 10:46:51 am
Actually, the best thing to do to prevent using up so much data is actually to define all of the sprites (right, left, up, down, front, back, etc.) at the beginning of the program, in seperate Pic variables. Then, simply store the correct Pic value to one of your variables.

Even better, if you are simply using left and right flipped sprites, use the flipH() command, which takes a Pic pointer and returns a pointer to the flipped sprite. You can then use that value directly in the Sprite command.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 08:18:33 am
Another solution:
You take a DirectionVariable (let's use D).
You put your 2 sprites at the beginning.
The first one is pointed at Str1+0, The second one is pointed at Str1+8.
Then you guess what's next.
I made a spelling mistake in the word Right but it is on purpose.
If it doesn't work, blame me and give me a -1.
Of course, you have to replace "[FacingLeftSpriteInHex]" by the hex code of your FacingLeftSprite.

:.BLA
:ClrDraw
:[FacingLeftSpriteInHex]→Str1
:[FacingRiteSpriteInHex]
:0→D
:0→A
:56→B
:Repeat getKey(15)
:If getKey(1) and (B≠56
:B+1→B:End
:If getKey(2) and (A≠0
:0→D
:A-1→A:End
:If getKey(3) and (A≠87
:8→D
:A+1→A:End
:If getKey(4) and (B≠0
:B-2→B:End
:If B<56
:B+1→B:End
:ClrDraw
:Pt-On(A,B,Str1+D)
:DispGraph
:End
Title: Re: Noob Help
Post by: aeTIos on June 09, 2011, 10:59:49 am
Or use D=1 \ D=0 and Str1+(D*8 ) but that doesnt really matter.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 11:16:43 am
It doesn't really matter here but in other cases (tilemapping for example) it is necessary.
Title: Re: Noob Help
Post by: aeTIos on June 09, 2011, 11:17:36 am
yeah, thats a bit more convenient.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 11:22:29 am
Yeah, thats a bit more convenient ;)
Did you make the play-on-words or was it me ?
Title: Re: Noob Help
Post by: aeTIos on June 09, 2011, 11:23:55 am
lool. xD. but wait, tilemapping has nothing to do with bits. only with bytes/nibbles.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 11:28:03 am
 :'( Why do all my jokes get killed !?!
Hey, nobody says "that's a byte more convenient" or "that's a nibble more convenient".
By the way, what's a nibble ? Not a snake game ?
Title: Re: Noob Help
Post by: JosJuice on June 09, 2011, 11:49:06 am
lool. xD. but wait, tilemapping has nothing to do with bits. only with bytes/nibbles.
Well, the bits are what make up bytes and nibbles. You could do something like a 1-bit tilemap or 9001-bit tilemap if you want to, but in Axe it would be quite complex (and there wouldn't be much meaning in doing it), so bytes and nibbles are the most commonly used sizes for tiles.
Title: Re: Noob Help
Post by: aeTIos on June 09, 2011, 12:03:10 pm
Yeah, I see that.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 12:09:01 pm
 ??? Still don't know what's a nibble (I know what's a bit and what's a byte, therefore).
Title: Re: Noob Help
Post by: JosJuice on June 09, 2011, 12:10:51 pm
??? Still don't know what's a nibble (I know what's a bit and what's a byte, therefore).
A nibble is 4 bits.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 12:11:27 pm
Ah ok. Thx a lot. 39 as they say in Japan.
Title: Re: Noob Help
Post by: aeTIos on June 09, 2011, 12:12:14 pm
Explain the 39 part.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 12:15:34 pm
39: san kyu: Thank you ;)
Title: Re: Noob Help
Post by: aeTIos on June 09, 2011, 12:17:01 pm
Loolz. Thats fun.
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 12:18:42 pm
Learned that reading a manga. Never let your parents (or anybody else) SAY that comics make you stupid and that you'd better read encyclopedia.
Title: Re: Noob Help
Post by: aeTIos on June 09, 2011, 01:42:08 pm
Wait, there's a spelling/ word choice mistake there, I dont really get the sentence. (Do you mean something like 'never listen to parents when they say that comics are stupid and that you better read encyclopedia'?)
Title: Re: Noob Help
Post by: Hayleia on June 09, 2011, 01:53:12 pm
Wait, I forgot a word: the word "say". Going to edit (also changed the word "this" into "comics").
Now I'll always re-read my sentences after or before posting.
Thx 4 reporting.