Was subtracting only integer part of gcode, which inverts the fractional part and produces jagged lines whenever X or Y becomes negative.