When (and why) did PLOT 8-15 change?

discussion of beeb/electron applications, languages, utils and educational s/w
Post Reply
User avatar
Richard Russell
Posts: 877
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

When (and why) did PLOT 8-15 change?

Post by Richard Russell » Wed Mar 06, 2019 10:14 am

I have always understood that PLOT 8-15 draw a straight line but with the last point plotted twice. Most of the time they behave identically to PLOT 0-7, but in an XOR (e.g. GCOL 3,7) or inverting (e.g. PLOT 14) plotting mode the effect is that the last point gets 'un-plotted' (this is why you'll sometimes see PLOT 8-15 documented as 'omitting' the last point, but that isn't strictly true).

At least, this is what happens on a BBC Micro and in all my versions of BBC BASIC. However I was shocked today to discover that it isn't what happens on a BBC Master (or an Archimedes)! On those later OSes PLOT 8-15 seem genuinely to 'omit' the last point rather than plotting it twice. Why? What possible reason could there have been for the change?

I have no recollection of the BBC being asked to approve such a change; had we been I expect we would have refused. It means that to this day there's an incompatible difference in the way PLOT 8-15 works on different platforms - and I certainly won't be changing how my BASICs work!

User avatar
BigEd
Posts: 2565
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by BigEd » Wed Mar 06, 2019 11:49 am

Presumably it's faster, and if you're in an XOR mode it's also the same behaviour. And as a bonus, it matches the User Guide!

(It is unexpected to see a change though.)

Now, was the User Guide a specification, of sorts? Or was there a firmer specification somewhere which specified double-plotting? (Or was the behaviour of the 6502 Basics to be treated as a specification? That seems a bit strong, in case of bugs.)

It feels to me like you were caught in an undocumented-behaviour kind of trap, but it's taken a very very long time to notice.

dominicbeesley
Posts: 799
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by dominicbeesley » Wed Mar 06, 2019 11:54 am

From the BBC User Guide:

Code: Select all

Higher values of K have other effects which are related to the effects given by the
values 0 to 7.
8- 15 As 0-7 but with the last point in the line omitted.
16- 23 As 0-7 but with a dotted line.
24- 31 As 0-7 but with a dotted line and without the last point on the line.
32- 63 Reserved.
64- 71 As 0-7 but only a single point is plotted.
72- 79 As 0-7 but to draw a horizontal line to the left and right of the point
until a colour other than the current background colour is reached.
80- 87 As 0-7 but plot and fill a triangle.
So looks like the original MOS was not doing it quite right and it was fixed?

A good point the RTR - what would have been the canonical reference for such things in the early days?

D

User avatar
Richard Russell
Posts: 877
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by Richard Russell » Wed Mar 06, 2019 12:19 pm

dominicbeesley wrote:
Wed Mar 06, 2019 11:54 am
So looks like the original MOS was not doing it quite right and it was fixed?
My belief is that the functionality came first and the documentation afterwards, so it's not a case of the MOS "not doing it right" but of the documentation being imprecise. But irrespective of which you consider to be the 'reference', modifying the functionality to match the documentation introduces an incompatibility so is almost never the right thing to do. This is especially the case when you consider the number of machines with OS 1.2 and OS 2.0 (the B+ matches the Model B in this regard) that were manufactured, and the number of programs written that might have relied on the original behaviour.

There are other considerations that point to the original functionality being preferable. In porting BBC BASIC to other platforms, as I know only too well, one is faced with implementing the graphics facilities in as compatible a way as possible. Virtually every graphics-capable platform has a primitive for drawing a straight line (inclusive of the end points) and for plotting a point, so everything you need for 'plotting the end point twice' is available. But I don't think I've ever come across another platform with the capability of omitting the end point of a line (and you can't simulate it by drawing a line between different end points because the plotted pixels will be different).

To this day the documentation for BBC BASIC for Windows describes PLOT 8-15 as 'omitting the last point' even though it's never been true. I've always been aware of that anomaly, but it's never particularly worried me because the whole purpose of PLOT 8-15 is to allow you to draw a 'polyline' (a series of connected straight-line segments) without gaps, even in an XOR or inverting mode. For that purpose the two ways of achieving it are equivalent.

User avatar
Rich Talbot-Watkins
Posts: 1512
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by Rich Talbot-Watkins » Wed Mar 06, 2019 6:07 pm

Assuming, as you say, that the reason for providing it at all was so that chains of lines plotted in EOR mode would not have their joining points EOR'd away, the approach taken by OS 1.20 was quick and easy, and correct for its main use case, but not really correct overall.

The change in the Master OS could perhaps be considered as a bugfix, just as with the PLOT 85 bugfix (OS 1.20 plotted the nearly flat edges of triangles incorrectly).
Last edited by Rich Talbot-Watkins on Wed Mar 06, 2019 6:08 pm, edited 1 time in total.

User avatar
Richard Russell
Posts: 877
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by Richard Russell » Wed Mar 06, 2019 6:56 pm

Rich Talbot-Watkins wrote:
Wed Mar 06, 2019 6:07 pm
the approach taken by OS 1.20 was quick and easy, and correct for its main use case, but not really correct overall.
Compatibility considerations should have overruled any issue of 'correctness', IMO. If it was felt that a true 'omit last point' feature was needed it should have been implemented as an addition to the established functionality, not as an incompatible substitution. For example a flag bit could have been introduced to determine how PLOT 8-15 behaved, with the OS 1.20 method the default.

User avatar
SarahWalker
Posts: 1178
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by SarahWalker » Wed Mar 06, 2019 9:07 pm

It seems far less likely that this was a deliberate behaviour change, and that whoever reimplemented PLOT in MOS 3.x and Arthur/RISC OS (Richard Manby?) implemented based on the (inaccurate) written documentation and no-one noticed that it didn't match the behaviour in OS 1.20. Simple human error.
Last edited by SarahWalker on Wed Mar 06, 2019 9:07 pm, edited 1 time in total.

User avatar
Rich Talbot-Watkins
Posts: 1512
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by Rich Talbot-Watkins » Thu Mar 07, 2019 10:38 am

Interestingly, the AUG nails it.

Appendix E - Plot Number Summary

8-15 Last point in line omitted when 'inverted' plotting used

...which is exactly the implemented behaviour in OS 1.20.

User avatar
Richard Russell
Posts: 877
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by Richard Russell » Thu Mar 07, 2019 11:47 am

Rich Talbot-Watkins wrote:
Thu Mar 07, 2019 10:38 am
Interestingly, the AUG nails it.
Thanks for finding that!

Soruk
Posts: 413
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by Soruk » Fri Mar 08, 2019 4:37 pm

This does rather mean that my implementation in Matrix Brandy is similarly "incorrect" - as I'm using RISC OS as my reference!

User avatar
jgharston
Posts: 3597
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by jgharston » Fri Mar 08, 2019 5:47 pm

Rich Talbot-Watkins wrote:
Thu Mar 07, 2019 10:38 am
Interestingly, the AUG nails it.

Appendix E - Plot Number Summary

8-15 Last point in line omitted when 'inverted' plotting used

...which is exactly the implemented behaviour in OS 1.20.
So, is/should PLOT 32+n similarly be "first point in line omitted when 'inverted' plotting used" ?

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
Rich Talbot-Watkins
Posts: 1512
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by Rich Talbot-Watkins » Fri Mar 08, 2019 9:05 pm

Hard to say. I don't think anyone ever used those PLOT codes, ever, in the history of the Beeb :wink:

User avatar
kieranhj
Posts: 806
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by kieranhj » Sat Mar 09, 2019 12:12 am

Rich Talbot-Watkins wrote:
Fri Mar 08, 2019 9:05 pm
Hard to say. I don't think anyone ever used those PLOT codes, ever, in the history of the Beeb :wink:
:lol: I love that PLOT 69 is 'plot point' - because there are 68 plot operations more important than plotting a single point to the screen. :)
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
jgharston
Posts: 3597
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: When (and why) did PLOT 8-15 change?

Post by jgharston » Sat Mar 09, 2019 2:42 am

kieranhj wrote:
Sat Mar 09, 2019 12:12 am
Rich Talbot-Watkins wrote:
Fri Mar 08, 2019 9:05 pm
Hard to say. I don't think anyone ever used those PLOT codes, ever, in the history of the Beeb :wink:
:lol: I love that PLOT 69 is 'plot point' - because there are 68 plot operations more important than plotting a single point to the screen. :)
The command is a bitmap.
%00xxxxxx is drawing lines
%01xxxxxx is plotting points

It breaks down a bit after that, bit the top half is always the command and the bottom half is always how the command is done. And with a bitmap there are always going to be redundant combinations, all %xxxxxx00 are 'do action without plotting anything' (ie MOVE). Just like with ARM opcodes you get things like MOV R0,R0 and with Z80 code you get LD D,D.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Post Reply