Help with GCOL in Mode or Not

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
User avatar
zachnoland
Posts: 11
Joined: Sat 07 Dec 2024, 15:22
Location: somewhere in Southeast Asia

Help with GCOL in Mode or Not

Post by zachnoland »

I tried this code but there is no result from the color output from GCOL. Btw i use BBC BASIC Android. This is the code I wrote:

Code: Select all

10 MODE 5
20 PLOT 85, RND(1000), RND(1200)
30 GCOL 0, RND(3)
It should produce a color PLOT . But I tried it didn't change any color just white 🤔
User avatar
zachnoland
Posts: 11
Joined: Sat 07 Dec 2024, 15:22
Location: somewhere in Southeast Asia

Re: Help with GCOL in Mode or Not

Post by zachnoland »

Richard Russell wrote: Sat 14 Dec 2024, 12:53 In practice there are a number of workarounds. Most programs don't actually rely on palette animation and only fail because the GCOL value is set after rather than before the graphics are plotted. In that case the solution is trivial: move the GCOL to before the plotting:

Code: Select all

10 MODE 5
20 GCOL 3, RND(3)
30 PLOT 85, RND(1000), RND(1200)
Thank you. I understand now :)
BBC BASIC is awesome!
nvingo
Posts: 41
Joined: Sat 28 May 2022, 22:40

Re: Help with GCOL in Mode or Not

Post by nvingo »

zachnoland wrote: Sat 14 Dec 2024, 13:51
Richard Russell wrote: Sat 14 Dec 2024, 12:53 In practice there are a number of workarounds. Most programs don't actually rely on palette animation and only fail because the GCOL value is set after rather than before the graphics are plotted. In that case the solution is trivial: move the GCOL to before the plotting:

Code: Select all

10 MODE 5
20 GCOL 3, RND(3)
30 PLOT 85, RND(1000), RND(1200)
Thank you. I understand now :)
BBC BASIC is awesome!
The whole 'palette animation' explanation was excessive for the issue - the re-ordering of the colour-setting and pixel-setting statements was sufficient.
Exactly the same for text;

Code: Select all

10 PRINT "RED"
20 COLOUR 1
fails, simply reverse it to

Code: Select all

10 COLOUR 1
20 PRINT "RED"
(Provided colour 1 has been defined as red in the palette -

Code: Select all

VDU 19,1,1,0,0,0
)
Started using BASIC circa 1981 with CP/M, Video Genie, Sinclair ZX81, Acorn Atom, and progressed with ZX Spectrum, BBC Micro and Sinclair QL, Cambridge Z88, DOS, Windows. Wrote A-level project using school's BBC Micro with dual 800K floppy drive.
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Help with GCOL in Mode or Not

Post by Richard Russell »

nvingo wrote: Sat 14 Dec 2024, 16:03 The whole 'palette animation' explanation was excessive for the issue - the re-ordering of the colour-setting and pixel-setting statements was sufficient.
It was not possible to tell from the OP's original post that re-ordering alone would solve his issue. He quoted only a code snippet which, on its own, doesn't work even if re-ordered (PLOT 85 needs to be preceded by two MOVEs) so it could have been part of a program relying on palette animation.

There are two ways to answer a question which is ambiguous like that. One way is to request more information before answering, which perhaps you would have preferred, the other way is to give a sufficiently comprehensive answer that it should suffice whatever the original intention was.
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Help with GCOL in Mode or Not

Post by Richard Russell »

Richard Russell wrote: Sat 14 Dec 2024, 17:18 the other way is to give a sufficiently comprehensive answer that it should suffice whatever the original intention was.
But, of course, I do not want any of my posts to be the cause of complaint, so I have deleted it.
nvingo
Posts: 41
Joined: Sat 28 May 2022, 22:40

Re: Help with GCOL in Mode or Not

Post by nvingo »

Richard Russell wrote: Sat 14 Dec 2024, 17:33
Richard Russell wrote: Sat 14 Dec 2024, 17:18 the other way is to give a sufficiently comprehensive answer that it should suffice whatever the original intention was.
But, of course, I do not want any of my posts to be the cause of complaint, so I have deleted it.
It is never necessary to do that; at least quotes have preserved the pertinent information.
I apologise for appearing to criticise your reply; my view of the OP's query was that as he hadn't realised that the computer needs to know which colour to draw in before drawing, palette manipulation was a concept for later on.
Richard Russell wrote: Sat 14 Dec 2024, 17:18doesn't work even if re-ordered (PLOT 85 needs to be preceded by two MOVEs)
In the versions I've experienced, the three points of the triangle (PLOT 85) are defined as the coordinates in the statement and the two previously visited - these default to the origin if not specified so the first encountered PLOT 85 draws a straight line from the origin to the specified coordinates, the second draws a triangle with one point at the origin, etc. So omitting any statements to define the initial two coordinates is merely inelegant.
Started using BASIC circa 1981 with CP/M, Video Genie, Sinclair ZX81, Acorn Atom, and progressed with ZX Spectrum, BBC Micro and Sinclair QL, Cambridge Z88, DOS, Windows. Wrote A-level project using school's BBC Micro with dual 800K floppy drive.
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Help with GCOL in Mode or Not

Post by Richard Russell »

nvingo wrote: Sat 14 Dec 2024, 18:36 So omitting any statements to define the initial two coordinates is merely inelegant.
My point was that the listed code snippet was incomplete, since the intention clearly wasn't to draw just a straight line (and I doubt that a zero-thickness triangle can be guaranteed to do that in all versions of BBC BASIC anyway). As a snippet from a bigger program, I decided that not much could reliably be deduced as to the purpose of the code.

For example if one encloses the quoted code within a loop, it actually does do something sensible despite the order of the statements seeming to be wrong:

Code: Select all

10 MODE 5
15 REPEAT
20   PLOT 85, RND(1000), RND(1200)
30   GCOL 0, RND(3)
35 UNTIL FALSE
It also seemed unlikely to me that anybody would think you can specify the colour of a plotted object after plotting it, at least not in a procedural language like BASIC. Therefore a more complicated explanation seemed more probable; perhaps I overthought it.
I apologise for appearing to criticise your reply
No need. My return to this forum was permitted on the condition that complaints not be received, so it's important that anybody who is unhappy makes that known. Feel free to use the 'report' button to alert the admin to my transgression.