I have a question around how to do something that is quite simple for me in Basic but I can't seem to wrap my head around in assembly. Hoping one of the 6502 masters can provide a little bit of direction, once I see it working I can usually adapt for my own needs but I haven't found anything that quite works for what I am after...
What I am trying to do is a simple additive horizontal movement routine, if 'Z' is pressed then variable xAdd is decremented down to a minimum amount and if 'X' is pressed then xAdd is incremented to a maximum amount. Then every frame, xAdd is added to the current horizontal position and the sprite is updated. Obviously Basic sorts out all the fractional maths whereas in Asm I need to code that very carefully to suit the movement of my sprite. I have the sprite drawing code sorted, I am just struggling with the maths for fractional movement.
The following Basic code example is what I am trying to do in Assembly, if anyone can offer any assistance I would be very grateful:
Code: Select all
X%=640 Y%=20 XA=0 YA=0 GP=.2 REPEAT PROCeraseship X%=X%+XA Y%=Y%+YA:YA=YA-GP PROCdrawship IF INKEY(-98) XA=XA-GP IF INKEY(-67) XA=XA+GP IF INKEY(-74) YA=YA+GP*2 UNTIL 0
Let me know if more details are required, any help would be much appreciated.