Hello I'm trying to simply change the sign of an 8.8 fixed point number but I can't get it to work properly.
I declare it with:
dim xspeed0=a.m
And then whenever the player's joystick goes right or left I add or subtract 0.01 to xspeed0.
When the player collides with a vertical wall I want to simply change the sign of the xspeed so that it goes in the opposite direction.
I tried:
xspeed0 = -xspeed0
This changes the sign, but makes the player move inversely fast the other way, so if he hits the wall slowly he'll fly away really fast, and if he hits it fast he'll come away slowly.
I also tried:
a = -a
but that had the same effect.
I've tried it with and without the fixed_point_math.asm included.
I also tried making another 8.8 variable where I added or subtraced 0.01, opposite of whatever is added to xspeed0, and then I just change xspeed0 to that when there is a collision. That worked quite well and exhibited the desired behavior, but I don't have enough memory to do that for all the speed variables I have.
I'm using batari 1.0 for linux. It's using DASM V2.20.09 to compile
I also tried including div_mul.asm and then doing:
xspeed0 = xspeed0 * (-1)
And that compiled but then when I collided with the wall the Stella screen went dim and the game froze.
Oh, by the way, I really love batari so far; it's so easy to get a game going, compared to pure assembly.













