Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: lookitsan00b on November 04, 2010, 06:12:04 pm
-
Why doesn't this work? ???
.Ball move
{B-1}+{B-3}→{B-1} .move X
{B}+{B-2}→{B} .move Y
If -2>=>={B-1} or ({B-1}>=>=90)
0-{B-3}→{B-3}
End
If -4>=>={B} or ({B}>=>=56)
0-{B-2}→{B-2}
End
where:
{B-3} = xvel
{B-2} = yvel
{B-1} = x
{B} = y
The ball does not bounce off the left and top walls. It eventually bounces, but REALLY far off screen.
Btw the reason for the odd numbers is I'm using a padded sprite... (4 on top, 2 on each side)
-
It looks like you are having problems with unsigned numbers. Try this:
.Ball move
{B-1}+{B-3}→{B-1} .move X
{B}+{B-2}→{B} .move Y
If -2>=>=sign{B-1} or (sign{B-1}>=>=90)
0-{B-3}→{B-3}
End
If -4>=>=sign{B} or (sign{B}>=>=56)
0-{B-2}→{B-2}
End
where:
{B-3} = xvel
{B-2} = yvel
{B-1} = x
{B} = y
-
hello, and welcome here. I'm that sure at the moment, but are you using the B as a location in RAM or as a variable?
EDIT: ninja'd
-
So it doesn't just assume that my numbers are signed, even if I use the signed comparisons?
I never really understood signed numbers, thanks.
EDIT: B is a location in ram, L1 + 3, to be exact.
-
Welcome, lookitsan00b! :D
yeah, signed numbers have a different range of numbers to them all together.
EDIT: well maybe not all together, but they are kinda different
For example, an unsigned byte is 0-255, but a signed one is -128-127.
For words (two bytes), it's 0-65535 unsigned, -32768-32767 signed.
Though unless you use sign{, they're read as the same numbers.
-
1 byte signed = -128 to 127
1 byte unsigned = 0 to 255
2 byte signed = -32768 to 32767
2 byte unsigned = 0 to 65535
Welcome here, by the way :)
EDIT: I got ninja'd
-
Welcome to Omnimaga, by the way. Here's a quick overview of how signed numbers work:
You really can't store negative numbers on a computer. You probably know you can store any number in a single byte from 0-255. However, we have decided that from 0-127 will be 0 to 127, and from 128-255 will be -1 to -128. So for example, if you have -1, it would be stored as 255. However, if you add 1 to -1, you should get zero, right? Well, this works because when you hit 256 or higher adding single bytes, you start over at zero. So, adding 1 (1) to -1 (255) is the same as 255+1, which equals 256, which rolls over to zero (-1+1). Don't worry if you have trouble, this is one of the hardest concepts in computing ever.
Axe gives you the option of using signed or unsigned numbers. So with signed numbers that are single bytes, you have to specify what kind of numbers they are.
-
I understand signed numbers, I did a little asm before moving to axe. I just assumed that the signed comparisons took care of that for me...
Speaking of which, where do i find "Sign{"? I know I saw it somewhere, but I can't seem to find it again.
-
It's in the Math menu. They key is int(.
-
Okay thanks!
-
It's needed for loading signed 8-bit values, because the value is extended to 16-bit after the load. So for example, you'll want the 16-bit result to end up as -1 (aka 65535) instead of 255. The sign{} instruction does this for you.
-
I found it in the math menu, instead of int( methinks
EDIT: super ninja'd
-
yeah, thats the Axe Tokens, it intalls a hook when you have an Axe header.
Edit: oh, I thought that was a question.
-
Wow! I just expected it to keep it as an 8-bit number. That explains it. Now what happens when I load 255 from B, increment it, and store it back?
Btw, works like a charm. Time to add hittesting for the paddle and blocks!
(btw, yes, it is a breakout clone, figured it was a good first project)
-
Very nice! Glad to help! And may I direct you to our Introduce Yourself board?
-
Sure! *looks around* Where is it? XD
-
http://www.omnimaga.org/index.php?board=10.0
-
... I was joking lol
-
lol, got me there, wow I'm so gullible today for some reason :D
EDIT: I felt introduced already, but yeah introducing yourself there is always cool :)