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
IF INKEY(-98) XA=XA-GP
IF INKEY(-67) XA=XA+GP
IF INKEY(-74) YA=YA+GP*2
I've tried a number of approaches like a counter that trigger a horizontal update and using 2 bytes with the lo byte as an counter and the hi byte as the horizontal adder but I can't seem to get these approaches working.
Let me know if more details are required, any help would be much appreciated.