diff --git a/images/apple/PLEIADES-2.20.po b/images/apple/PLEIADES-2.20.po index 0efe123..75679ec 100644 Binary files a/images/apple/PLEIADES-2.20.po and b/images/apple/PLEIADES-2.20.po differ diff --git a/images/apple/PLFORTH.po b/images/apple/PLFORTH.po index 500acd0..ecfb56d 100644 Binary files a/images/apple/PLFORTH.po and b/images/apple/PLFORTH.po differ diff --git a/src/libsrc/turtle.pla b/src/libsrc/turtle.pla index 63c9dca..8f122f0 100644 --- a/src/libsrc/turtle.pla +++ b/src/libsrc/turtle.pla @@ -7,7 +7,7 @@ const CLIP_RIGHT = 2 const CLIP_TOP = 4 const CLIP_BOTTOM = 8 -var turtleX, turtleY, turtleAngle, drawLine +var turtleXp4, turtleYp4, turtleAngle, drawLine byte pen var clipLeft, clipRight, clipTop, clipBottom @@ -35,7 +35,7 @@ def lerp(a1, b1, a2, b2, n)#1 word[2] i32 if b2 == b1; return b1; fin // Horizontal lerp - if a2 == a1; return n; fin // Vertical lerp + if a2 == a1; return n; fin // Vertical lerp loadi16(b2 - b1) muli16(n - a1) divi16(a2 - a1) @@ -105,8 +105,8 @@ end export def initTurtle(width, height, linefunc)#0 drawLine = linefunc clipRect(0, 0, width - 1, height - 1) - turtleX = width / 2 - turtleY = height / 2 + turtleXp4 = width << 3 + turtleYp4 = height << 3 turtleAngle = 0 pen = 1 end @@ -127,18 +127,26 @@ end export def moveTo(x, y)#0 if pen - clipLine(turtleX, turtleY, x, y) + clipLine(turtleXp4 >> 4, turtleYp4 >> 4, x, y) fin - turtleX = x - turtleY = y + turtleXp4 = x << 4 + turtleYp4 = y << 4 end export def moveForward(dist)#0 - moveTo(turtleX + mulcos(dist, turtleAngle), turtleY + mulsin(dist, turtleAngle)) + var oldX, oldY + + oldX = turtleXp4 >> 4 + oldY = turtleYp4 >> 4 + turtleXp4 = turtleXp4 + mulcos(dist << 4, turtleAngle) + turtleYp4 = turtleYp4 + mulsin(dist << 4, turtleAngle) + if pen + clipLine(turtleXp4 >> 4, turtleYp4 >> 4, oldX, oldY) + fin end export def moveBackward(dist)#0 - moveTo(turtleX - mulcos(dist, turtleAngle), turtleY - mulsin(dist, turtleAngle)) + moveForward(-dist) end export def penUp#0