The problem is just that there are a couple of zeros that should be ones. I've attached a patch.
(This patch is essentially equivalent to Alvin Penner's, because
dx0 = (x1 - x0)/ds # Only works for rectangular coordinates dy0 = fp(xstart)*dx0
in his version can be simplified to
dx0 = 1 # Only works for rectangular coordinates dy0 = fp(xstart)
as (x1 - x0)/ds == 1, and similarly for dx1 and dy1.)
The problem is just that there are a couple of zeros that should be ones. I've attached a patch.
(This patch is essentially equivalent to Alvin Penner's, because
dx0 = (x1 - x0)/ds # Only works for rectangular coordinates
dy0 = fp(xstart)*dx0
in his version can be simplified to
dx0 = 1 # Only works for rectangular coordinates
dy0 = fp(xstart)
as (x1 - x0)/ds == 1, and similarly for dx1 and dy1.)