Discussion:
Simple programming query
(too old to reply)
x***@gmail.com
2018-01-11 11:05:58 UTC
Permalink
Hi all.

In BBC BASIC, what is (are) the command(s) to output a filled rectangle with a colour in 256 colour mode 13.

It is for a small utility I have just coded to give the number of colours in a picture.
It runs ok, telling me for colour 0 to 255 there are X pixels displayed on screen, but I'd like to plot a small rectangle with each colour, next to the results.
Alan Adams
2018-01-11 12:11:02 UTC
Permalink
I assume this is not a WIMP programme. If it is, it gets more
complicated.

GCOL will allow you to set the current graphics foreground and
background colours, then RECTANGLE FILL will draw a rectangle filled
with the graphics foreground colour.

HELP will give you the necessary details for each of these.

Alan
Post by x***@gmail.com
Hi all.
In BBC BASIC, what is (are) the command(s) to output a filled
rectangle with a colour in 256 colour mode 13.
It is for a small utility I have just coded to give the number of colours in a picture.
It runs ok, telling me for colour 0 to 255 there are X pixels
displayed on screen, but I'd like to plot a small rectangle with each
colour, next to the results.
--
Alan Adams, from Northamptonshire
***@adamshome.org.uk
http://www.nckc.org.uk/
x***@gmail.com
2018-01-11 14:01:25 UTC
Permalink
ok thanks.
Yes it is a non WIMP BASIC programmer.
j***@mdfs.net
2018-01-11 17:24:39 UTC
Permalink
Post by Alan Adams
Post by x***@gmail.com
In BBC BASIC, what is (are) the command(s) to output a filled
rectangle with a colour in 256 colour mode 13.
GCOL will allow you to set the current graphics foreground and
The OP mentioned a 256-colour screen modes, COLOUR/GCOL only allow
you to select the top 6 bits of a colour number as bit 7 is used
to select foreground or background (and bit 6 for other purposes
on some platforms). In 256-colour screen modes you need:

GCOL 0,colour_bits_7to2 >> 2 TINT colour_bits_1to0 << 6

ie, to select 8-bit colour %abcdefgh you use:

GCOL 0,%00abcdef TINT %gh000000 for plot foreground colour and
GCOL 0,%10abcdef TINT %gh000000 for plot background colour
x***@gmail.com
2018-01-11 18:15:13 UTC
Permalink
Post by j***@mdfs.net
Post by Alan Adams
Post by x***@gmail.com
In BBC BASIC, what is (are) the command(s) to output a filled
rectangle with a colour in 256 colour mode 13.
GCOL will allow you to set the current graphics foreground and
The OP mentioned a 256-colour screen modes, COLOUR/GCOL only allow
you to select the top 6 bits of a colour number as bit 7 is used
to select foreground or background (and bit 6 for other purposes
GCOL 0,colour_bits_7to2 >> 2 TINT colour_bits_1to0 << 6
GCOL 0,%00abcdef TINT %gh000000 for plot foreground colour and
GCOL 0,%10abcdef TINT %gh000000 for plot background colour
Thanks.
I will try to use that tonight.
I should have said my machine is a BBCA3000 with RISC OS 3.11.
(old VIDC with its not freely selectable 256 colour screen modes).
Richard Ashbery
2018-01-12 21:24:00 UTC
Permalink
Post by x***@gmail.com
Post by j***@mdfs.net
Post by x***@gmail.com
In BBC BASIC, what is (are) the command(s) to output a filled
rectangle with a colour in 256 colour mode 13.
[snip]
Post by x***@gmail.com
Post by j***@mdfs.net
GCOL 0,%00abcdef TINT %gh000000 for plot foreground colour and
GCOL 0,%10abcdef TINT %gh000000 for plot background colour
Thanks.
I will try to use that tonight.
I should have said my machine is a BBCA3000 with RISC OS 3.11.
(old VIDC with its not freely selectable 256 colour screen modes).
My understanding of the VIDC system colour system is that you only
have a total of 64 colours but their shade can be altered with the
TINT keyword. This gives 256 possible colour variations (64 different
colours multiplied by 4 shades). Although the TINT keyword can handle
256 variations it only has 4 distinct levels.....
(0-64,64-128,128-192,192-255). So a TINT range of 0-63 for example only
gives a single effective TINT level (no additional brightness). You can
see this action with a simple example...

MODE 13
PRINT "Press any key to new display tint value"
FOR x = 0 TO 128
GCOL 0,3 TINT x
RECTANGLE FILL 200,200,100
g = GET
PRINT TAB(0,30)"Tint value = ";x
NEXT

TINT transitions are at 63(64-1) and 127(128-1).

***@mdfs.net examples show the binary equivalent - this is useful
because it shows the bits that need setting for GCOL - bit 7 sets
foreground/background colour (0 for foreground, 1 for background).

The TINT statement requires bits 6 and 7 to be set to 00 (0-64),01
(64-128),10 (128-192) and 11 (192-255).

Richard
Rick Murray
2018-01-13 10:16:34 UTC
Permalink
Post by Richard Ashbery
TINT keyword. This gives 256 possible colour variations (64 different
colours multiplied by 4 shades). Although the TINT keyword can handle
256 variations it only has 4 distinct levels.....
You can see this semi-visually by looking at the default Paint palette for
a 256 colour sprite, where the colours are displayed in groups of four
(tints).

Boring code of how it works here:
https://www.riscosopen.org/viewer/view/~checkout~/castle/RiscOS/Sources/Apps/Paint/c/Colours?rev=4.8
--
___
/__/ o __ /_
/ \ / /__ / \ (heyrick one nine seven three at yahoo dot co dot uk)
x***@gmail.com
2018-03-02 07:09:36 UTC
Permalink
Thanks to all of you.
I eventually coded it in assembly.


From your various explanations, I think I will never understand why some say there are 64 colours, when anyway the VIDC has only 16 truely selectable colours among 4096 ...
Rick Murray
2018-03-02 21:45:19 UTC
Permalink
Post by x***@gmail.com
From your various explanations, I think I will never understand why some
say there are 64 colours, when anyway the VIDC has only 16 truely
selectable colours among 4096 ...
Huh?

Palette is 256 colours. They are in groups of four (four tints to a
colour). 256 ÷ 4 = 64.

Where did you get the 16 from?
--
___
/__/ o __ /_
/ \ / /__ / \ (heyrick one nine seven three at yahoo dot co dot uk)
x***@gmail.com
2018-04-07 07:38:13 UTC
Permalink
Post by Rick Murray
Post by x***@gmail.com
From your various explanations, I think I will never understand why some
say there are 64 colours, when anyway the VIDC has only 16 truely
selectable colours among 4096 ...
Huh?
Palette is 256 colours. They are in groups of four (four tints to a
colour). 256 ÷ 4 = 64.
Where did you get the 16 from?
--
___
/__/ o __ /_
/ \ / /__ / \ (heyrick one nine seven three at yahoo dot co dot uk)
Simply from the VLSI ARM datasheet.
Clearly the palette selection has only 16 entries, thus only 16 colours are freely selectable, all other colours come from this free choice of 16 colours.
David Feugey
2018-04-07 11:50:13 UTC
Permalink
Post by x***@gmail.com
Post by Rick Murray
Post by x***@gmail.com
From your various explanations, I think I will never understand why some
say there are 64 colours, when anyway the VIDC has only 16 truely
selectable colours among 4096 ...
Huh?
Palette is 256 colours. They are in groups of four (four tints to a
colour). 256 ÷ 4 = 64.
Where did you get the 16 from?
--
___
/__/ o __ /_
/ \ / /__ / \ (heyrick one nine seven three at yahoo dot co dot uk)
Simply from the VLSI ARM datasheet.
Clearly the palette selection has only 16 entries, thus only 16
colours are freely selectable, all other colours come from this free
choice of 16 colours.
That's right. You have 256 colours, but based on a palette where you
fix only 16 significative ones. So it's true to say that only 16
colours are freely selectable. But you'll get a gradiant of 256 real &
different colours.

"the VIDC1a had 16 hardware palette registers. This meant that in
screen modes with sixteen colours or fewer, the colours could be
mapped to any of the 4096 available. However, in 256 colour modes, 4
bits of the colour data were hardware derived and could not be
adjusted. The net result was 256 colours, but only 16 of them could be
assigned as desired, covering a range of the 4096 available colours."

https://en.wikipedia.org/wiki/Acorn_Archimedes

On the other hand, VIDC1 is really old technology :)

Bye, David
--
RISC OS FR - www.riscos.fr
Informations sur RISC OS et sa communauté
Licences ABC et Raspberry Pi gratuits !
x***@gmail.com
2018-04-09 18:40:33 UTC
Permalink
Post by David Feugey
Post by x***@gmail.com
Post by Rick Murray
Post by x***@gmail.com
From your various explanations, I think I will never understand why some
say there are 64 colours, when anyway the VIDC has only 16 truely
selectable colours among 4096 ...
Huh?
Palette is 256 colours. They are in groups of four (four tints to a
colour). 256 ÷ 4 = 64.
Where did you get the 16 from?
--
___
/__/ o __ /_
/ \ / /__ / \ (heyrick one nine seven three at yahoo dot co dot uk)
Simply from the VLSI ARM datasheet.
Clearly the palette selection has only 16 entries, thus only 16
colours are freely selectable, all other colours come from this free
choice of 16 colours.
That's right. You have 256 colours, but based on a palette where you
fix only 16 significative ones. So it's true to say that only 16
colours are freely selectable. But you'll get a gradiant of 256 real &
different colours.
"the VIDC1a had 16 hardware palette registers. This meant that in
screen modes with sixteen colours or fewer, the colours could be
mapped to any of the 4096 available. However, in 256 colour modes, 4
bits of the colour data were hardware derived and could not be
adjusted. The net result was 256 colours, but only 16 of them could be
assigned as desired, covering a range of the 4096 available colours."
https://en.wikipedia.org/wiki/Acorn_Archimedes
On the other hand, VIDC1 is really old technology :)
Bye, David
--
RISC OS FR - www.riscos.fr
Informations sur RISC OS et sa communauté
Licences ABC et Raspberry Pi gratuits !
So why is that this 64 colours spring in almost all explanations ?
That's not the 1st time I read that (and each time I wonder).
David Feugey
2018-04-10 06:31:21 UTC
Permalink
Post by x***@gmail.com
So why is that this 64 colours spring in almost all explanations ?
That's not the 1st time I read that (and each time I wonder).
No idea :)
--
RISC OS FR - www.riscos.fr
Informations sur RISC OS et sa communauté
Licences ABC et Raspberry Pi gratuits !
druck
2018-04-09 20:05:37 UTC
Permalink
Post by David Feugey
That's right. You have 256 colours, but based on a palette where you
fix only 16 significative ones. So it's true to say that only 16
colours are freely selectable. But you'll get a gradiant of 256 real &
different colours.
"the VIDC1a had 16 hardware palette registers. This meant that in
screen modes with sixteen colours or fewer, the colours could be
mapped to any of the 4096 available. However, in 256 colour modes, 4
bits of the colour data were hardware derived and could not be
adjusted. The net result was 256 colours, but only 16 of them could be
assigned as desired, covering a range of the 4096 available colours."
https://en.wikipedia.org/wiki/Acorn_Archimedes
That's not really a good description. Although the 16 pallet entries are
used in 256 colour modes, they affect the bottom 4 bits of all colours
in a completely un-useful way.

The only sensible action is to accept the default palette of 64 base
colours (4x4x4 RGB) with 16 tint (white levels) variations.
Post by David Feugey
On the other hand, VIDC1 is really old technology
The VIDC20's (and later) true 256 colour modes with 256 palette entries,
is far more useful, you can do some great effects.

---druck
Loading...