Skip to content

Bin/PicoCalc SD/bifdiag.bas Out of border write, two bugs #47

Description

@Selorax

bifdiag.bas

First of all, from For i = 0 To W we conclude that i is iterating along the horizontal axis (along screen width), however on PicoCalc r goes from top to bottom, according to title picture from clockworkpi.com, not left to right, therefore arguments in Pixel H - Int(x * H), i statement are swapped.

Second, last i equals W, which is 320, but the screen scan lines go from 0 to 319, it's off by one.

So either diagram is rotated 90° to the right from intended position, or it is the intended position and then variables W and H are used in wrong order. It doesn't cause a problem because they are equal, but if one tried to draw on non-square display it will cause a problem.

Same off-by-one bug is within expression H - Int(x * H): if x = 0.0, then Int(0.0) = 0 and you get H in the Pixel argument, while you need (H - 1) instead. If x = 1.0 then H - H = 0, this is correct.

I do not have access to PicoCalc to verify it, however.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions