diff --git a/src/arch/z80/translator.py b/src/arch/z80/translator.py index a4f5972c3..f6ac99e69 100644 --- a/src/arch/z80/translator.py +++ b/src/arch/z80/translator.py @@ -709,6 +709,7 @@ def visit_PLOT(self, node): self.ic_fparam(node.children[1].type_, node.children[1].t) self.runtime_call(RuntimeLabel.PLOT, 0) self.HAS_ATTR = TMP_HAS_ATTR is not None + self.norm_attr() def visit_DRAW(self, node): TMP_HAS_ATTR = self.check_attr(node, 2) @@ -719,6 +720,7 @@ def visit_DRAW(self, node): self.ic_fparam(node.children[1].type_, node.children[1].t) self.runtime_call(RuntimeLabel.DRAW, 0) self.HAS_ATTR = TMP_HAS_ATTR is not None + self.norm_attr() def visit_DRAW3(self, node): TMP_HAS_ATTR = self.check_attr(node, 3) @@ -731,6 +733,7 @@ def visit_DRAW3(self, node): self.ic_fparam(node.children[2].type_, node.children[2].t) self.runtime_call(RuntimeLabel.DRAW3, 0) self.HAS_ATTR = TMP_HAS_ATTR is not None + self.norm_attr() def visit_CIRCLE(self, node): TMP_HAS_ATTR = self.check_attr(node, 3) @@ -743,6 +746,7 @@ def visit_CIRCLE(self, node): self.ic_fparam(node.children[2].type_, node.children[2].t) self.runtime_call(RuntimeLabel.CIRCLE, 0) self.HAS_ATTR = TMP_HAS_ATTR is not None + self.norm_attr() # endregion diff --git a/src/arch/zx48k/library-asm/circle.asm b/src/arch/zx48k/library-asm/circle.asm index a5f3515b2..874b58ebe 100644 --- a/src/arch/zx48k/library-asm/circle.asm +++ b/src/arch/zx48k/library-asm/circle.asm @@ -62,7 +62,7 @@ __CIRCLE: ld a, h exx pop de ; D'E' = x0, y0 - ld h, a ; H' = r + ld h, a ; H' = r ld c, e ld a, h @@ -107,6 +107,7 @@ __CIRCLE: __CIRCLE_LOOP: ld a, b + inc a cp c ret nc ; Returns when x >= y @@ -170,6 +171,10 @@ __CIRCLE_NEXT: ld c, a ; C = x0 - x call __CIRCLE_PLOT ; plot(x0 - x, y0 - y) + ld a, l + cp h + jr z, 1f + ld a, d add a, l ld b, a ; B = y0 + x @@ -202,6 +207,7 @@ __CIRCLE_NEXT: ld c, a ; C = x0 + y call __CIRCLE_PLOT ; plot(x0 - y, y0 - x) +1: exx jp __CIRCLE_LOOP diff --git a/src/arch/zxnext/library-asm/circle.asm b/src/arch/zxnext/library-asm/circle.asm index a5f3515b2..874b58ebe 100644 --- a/src/arch/zxnext/library-asm/circle.asm +++ b/src/arch/zxnext/library-asm/circle.asm @@ -62,7 +62,7 @@ __CIRCLE: ld a, h exx pop de ; D'E' = x0, y0 - ld h, a ; H' = r + ld h, a ; H' = r ld c, e ld a, h @@ -107,6 +107,7 @@ __CIRCLE: __CIRCLE_LOOP: ld a, b + inc a cp c ret nc ; Returns when x >= y @@ -170,6 +171,10 @@ __CIRCLE_NEXT: ld c, a ; C = x0 - x call __CIRCLE_PLOT ; plot(x0 - x, y0 - y) + ld a, l + cp h + jr z, 1f + ld a, d add a, l ld b, a ; B = y0 + x @@ -202,6 +207,7 @@ __CIRCLE_NEXT: ld c, a ; C = x0 + y call __CIRCLE_PLOT ; plot(x0 - y, y0 - x) +1: exx jp __CIRCLE_LOOP diff --git a/tests/functional/zx48k/circle.asm b/tests/functional/zx48k/circle.asm index 989a0dc74..7e81f7328 100644 --- a/tests/functional/zx48k/circle.asm +++ b/tests/functional/zx48k/circle.asm @@ -393,7 +393,7 @@ __CIRCLE: ld a, h exx pop de ; D'E' = x0, y0 - ld h, a ; H' = r + ld h, a ; H' = r ld c, e ld a, h add a, d @@ -430,6 +430,7 @@ __CIRCLE: ex af, af' ; Saves it __CIRCLE_LOOP: ld a, b + inc a cp c ret nc ; Returns when x >= y bit 7, h ; HL >= 0? : if (f >= 0)... @@ -482,6 +483,9 @@ __CIRCLE_NEXT: sub l ld c, a ; C = x0 - x call __CIRCLE_PLOT ; plot(x0 - x, y0 - y) + ld a, l + cp h + jr z, 1f ld a, d add a, l ld b, a ; B = y0 + x @@ -510,6 +514,7 @@ __CIRCLE_NEXT: sub h ld c, a ; C = x0 + y call __CIRCLE_PLOT ; plot(x0 - y, y0 - x) +1: exx jp __CIRCLE_LOOP __CIRCLE_PLOT: diff --git a/tests/functional/zx48k/inktemp.asm b/tests/functional/zx48k/inktemp.asm index 5fb5bd5a9..24977a51f 100644 --- a/tests/functional/zx48k/inktemp.asm +++ b/tests/functional/zx48k/inktemp.asm @@ -354,7 +354,7 @@ __CIRCLE: ld a, h exx pop de ; D'E' = x0, y0 - ld h, a ; H' = r + ld h, a ; H' = r ld c, e ld a, h add a, d @@ -391,6 +391,7 @@ __CIRCLE: ex af, af' ; Saves it __CIRCLE_LOOP: ld a, b + inc a cp c ret nc ; Returns when x >= y bit 7, h ; HL >= 0? : if (f >= 0)... @@ -443,6 +444,9 @@ __CIRCLE_NEXT: sub l ld c, a ; C = x0 - x call __CIRCLE_PLOT ; plot(x0 - x, y0 - y) + ld a, l + cp h + jr z, 1f ld a, d add a, l ld b, a ; B = y0 + x @@ -471,6 +475,7 @@ __CIRCLE_NEXT: sub h ld c, a ; C = x0 + y call __CIRCLE_PLOT ; plot(x0 - y, y0 - x) +1: exx jp __CIRCLE_LOOP __CIRCLE_PLOT: diff --git a/tests/functional/zx48k/spfill.asm b/tests/functional/zx48k/spfill.asm index e3a992698..0a959865f 100644 --- a/tests/functional/zx48k/spfill.asm +++ b/tests/functional/zx48k/spfill.asm @@ -969,7 +969,7 @@ __CIRCLE: ld a, h exx pop de ; D'E' = x0, y0 - ld h, a ; H' = r + ld h, a ; H' = r ld c, e ld a, h add a, d @@ -1006,6 +1006,7 @@ __CIRCLE: ex af, af' ; Saves it __CIRCLE_LOOP: ld a, b + inc a cp c ret nc ; Returns when x >= y bit 7, h ; HL >= 0? : if (f >= 0)... @@ -1058,6 +1059,9 @@ __CIRCLE_NEXT: sub l ld c, a ; C = x0 - x call __CIRCLE_PLOT ; plot(x0 - x, y0 - y) + ld a, l + cp h + jr z, 1f ld a, d add a, l ld b, a ; B = y0 + x @@ -1086,6 +1090,7 @@ __CIRCLE_NEXT: sub h ld c, a ; C = x0 + y call __CIRCLE_PLOT ; plot(x0 - y, y0 - x) +1: exx jp __CIRCLE_LOOP __CIRCLE_PLOT: