Greg kindly reported another bug, which is fixed in the attached version 1.21
This bug (which would have been introduced when I made PING a function as well as a keyword) meant in very specific situations, variable arithmetic went haywire.
It seems to trigger the bug, you needed to be adding to a variable a constant that was equal to the current value of the variable. i.e.
X=X+1 would trigger the bug if (and only if) X was 1 originally. X%=X%+3 would also trigger the bug if X% held the value 3. When the bug occured, the result of the addition would always be 12087 if using an integer variable (e.g. X% ) or 2.95652446E-25 if using floating point variables (e.g. X)
Root cause was I had copied some code out of the BASIC 'get arithmetic element' routine ($AE86) like this:
lda $00 ;<--------- set accumulator to value of memory location $00, which would usually be $2F
sta $0D ;set string flag to not string
when it should be this:
lda #$00 ;<--------- set accumulator to $00
sta $0D ;set string flag to not string
I don't quite understand why the impact of this bug was so low, i.e. why the current value of the variable changed whether the addition got messed up or not. Anyway, 1 bug down, who knows how many more to go
