Prev: B027 Up: Map Next: B047
B031: Get Whole Pixels
Used by the routines at CalculateNewPosition and MoveActor.
Divides a signed velocity by sixteen, to give the number of whole pixels to move. The direction is kept. For example, 30 gives 03 and D0 (-30) gives FD (-03).
Input
A Velocity
Output
A Pixels to move
GetWholePixels B031 AND A Jump to GetWholePixels_Positive if the velocity is positive.
B032 JP P,GetWholePixels_Positive
B035 NEG Make the velocity positive.
B037 RRCA Divide by sixteen (by rotating right four times).
B038 RRCA
B039 RRCA
B03A RRCA
B03B AND %00001111 Keep only bits 0-3.
B03D NEG Make the result negative again.
B03F RET Return.
GetWholePixels_Positive B040 RRCA Divide by sixteen (by rotating right four times).
B041 RRCA
B042 RRCA
B043 RRCA
B044 AND %00001111 Keep only bits 0-3.
B046 RET Return.
View the equivalent code in;
Prev: B027 Up: Map Next: B047