Difference between revisions of "GCOL"

From BeebWiki
Jump to: navigation, search
m (Added BASIC I/O category.)
 
m (Added extension syntax.)
 
(8 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
| colspan="2" | Present in all original versions of BBC BASIC.
 
| colspan="2" | Present in all original versions of BBC BASIC.
 
|- style="vertical-align:top"
 
|- style="vertical-align:top"
| rowspan="2" | [[BASIC metasyntax|Syntax]]
+
| rowspan="3" | [[BASIC metasyntax|Syntax]]
| BASIC I-IV
+
| BASIC I-IV
| <code>GCOL</code> &lt;numeric&gt;<code>,</code>&lt;numeric&gt;
+
| <code>GCOL</code> <numeric><code>,</code><numeric>
 
|- style="vertical-align:top"
 
|- style="vertical-align:top"
 
| BASIC V
 
| BASIC V
| <code>GCOL</code> &lt;numeric&gt;<code>,</code>&lt;numeric&gt;<nowiki>
+
| <code>GCOL</code> <numeric><code>,</code><numeric> [<code>TINT</code> <numeric>]
</nowiki>[<code>TINT</code> &lt;numeric&gt;]
+
|- style="vertical-align:top"
 +
| Extensions
 +
| <code>GCOL</code> <numeric>
 +
<code>GCOL</code> <numeric><code>,</code><numeric><code>,</code><numeric>
 +
<br><code>GCOL ON</code> <numeric><code>,</code><numeric><code>,</code><numeric>
 
|- style="vertical-align:top"
 
|- style="vertical-align:top"
 
| Token (hex)
 
| Token (hex)
| BASIC I-V
+
| BASIC&nbsp;I-V
 
| <code>E6</code> (statement)
 
| <code>E6</code> (statement)
 
|- style="vertical-align:top"
 
|- style="vertical-align:top"
 
| Description
 
| Description
| BASIC I-V
+
| BASIC&nbsp;I-V
| If bit 7 of the second &lt;numeric&gt; is 0 <nowiki>
+
| If bit 7 of the second <numeric> is 0 <nowiki>
</nowiki>then <code>GCOL</code> sets the foreground graphics paint mode to the first &lt;numeric&gt; <nowiki>
+
</nowiki>then <code>GCOL</code> sets the foreground graphics paint mode to the first <numeric> <nowiki>
</nowiki>and the foreground graphics colour to the second &lt;numeric&gt; [[MOD|modulo]] 128.<br><nowiki>
+
</nowiki>and the foreground graphics colour to the second <numeric> [[MOD|modulo]] 128.<br><nowiki>
</nowiki>If bit 7 of the second &lt;numeric&gt; is 1 <nowiki>
+
</nowiki>If bit 7 of the second <numeric> is 1 <nowiki>
 
</nowiki>then <code>GCOL</code> sets the colour and paint mode of background graphics instead.<br><nowiki>
 
</nowiki>then <code>GCOL</code> sets the colour and paint mode of background graphics instead.<br><nowiki>
 
</nowiki>The current contents of the screen are not affected.<br><nowiki>
 
</nowiki>The current contents of the screen are not affected.<br><nowiki>
Line 36: Line 40:
  
 
= Description =
 
= Description =
This statement sets the colour to be used by all subsequent graphics operations. It can set the foreground and background graphics colours. It also specifies how the colour is to be placed on the screen.
+
This statement sends a VDU 18 sequence to set the colour and action to be used by
 +
all subsequent graphics operations. It can set the foreground and background graphics
 +
colours. It also specifies how the colour is to be placed on the screen.
  
 
The first number specifies the mode of action.
 
The first number specifies the mode of action.
 +
* 0 plot the specified colour
 +
* 1 OR the colour with the colour already there
 +
* 2 AND the colour with the colour already there
 +
* 3 XOR (exclusive-OR) the colour with the colour already there
 +
* 4 NOT (invert) the colour already there
 +
* 5 no change to colour already there (not initially documented)
 +
* 6 clear the colour - set it to colour 0 (not initially documented)
 +
* 7 various actions resulting from a table overflow
 +
 +
With the Graphics Extension ROM, the Master and later:
 +
* n*16+k - select fill pattern n for n=1,2,3,4
 +
 +
On Arthur and later:
 +
* 6 sets the pixel to (NOT colour AND the colour already there)
 +
* 7 sets the pixel to (NOT colour OR the colour already there)
 +
* 8+k - fill pattern uses a transparent background
 +
* 5*16+k - select a fill pattern made from all four fill patterns in a block
 +
* 6*16+k - select a large fill pattern
 +
* 7*16+k - select a large fill pattern
  
0 plot the specified colour
+
The second number specifies the logical colour. If the number is less than 128
 +
then it defines the graphics foreground colour. If the number is greater than
 +
127 then it defines the graphics background colour.
  
1 OR the colour with the colour already there
+
GCOL simply sends <code>[[VDU 18]],action,colour</code>. Some versions of
 +
BASIC allow <code>GCOL <colour></code> which sends VDU 18,0,colour.
  
2 AND the colour with the colour already there
+
The BBC VDU driver does no range checking on the GCOL action, so using
 +
out-of-range actions can cause odd effects.
  
3 Exclusive-OR the colour with the colour already there
+
==Extensions==
 +
The defined GCOL actions are &00-&7F in blocks of 16:
 +
* &00+x plot action
 +
* &10+x fill pattern 1
 +
* &20+x fill pattern 2
 +
* &30+x fill pattern 3
 +
* &40+x fill pattern 4
 +
* &50+x super fill pattern 1-4
 +
* &60+x large fill pattern
 +
* &70+x large fill pattern
  
4 invert the colour already there.
+
GCOL actions &80-&FF are undefined, and selecting them will result in undefined behaviour. Some applications have taken advantage of these unused actions to intercept OSWRCH to have a useful one-byte VDU command sequence.
  
The second number specifies the logical colour. If the number is less than 128 then it defines the graphics foreground colour. If the number is greater than 127 then it defines the graphics background colour.
+
* &89 (also GCOL -ASC"w") - select a window <ref>https://mdfs.net/System/ROMs/Extensions/NewMOS.ROM</ref>
 +
* &8C (also GCOL -ASC"t") - select a text style <ref>https://mdfs.net/Apps/Text/Utils/FontStyle</ref>
 +
* &8D (also GCOL -ASC"s") - select a text style <ref>https://mdfs.net/Apps/Text/Utils/FontStyle</ref>
 +
* &A0+x reserved
 +
* &E0+x application use
 +
* &F0+x application use
  
In the two-argument form it is simply a veneer for <code>[[VDU 18]]</code>.
+
=References=
 +
<references />

Latest revision as of 13:09, 15 February 2024

GCOL is used to select the logical colours used by graphics statements.

GCOL
Availability Present in all original versions of BBC BASIC.
Syntax BASIC I-IV GCOL <numeric>,<numeric>
BASIC V GCOL <numeric>,<numeric> [TINT <numeric>]
Extensions GCOL <numeric>

GCOL <numeric>,<numeric>,<numeric>
GCOL ON <numeric>,<numeric>,<numeric>

Token (hex) BASIC I-V E6 (statement)
Description BASIC I-V If bit 7 of the second <numeric> is 0 then GCOL sets the foreground graphics paint mode to the first <numeric> and the foreground graphics colour to the second <numeric> modulo 128.
If bit 7 of the second <numeric> is 1 then GCOL sets the colour and paint mode of background graphics instead.
The current contents of the screen are not affected.
In BASIC V the TINT argument sets the foreground or background tint.
Associated keywords CLG, CLS, COLOUR, MODE, PLOT

Description

This statement sends a VDU 18 sequence to set the colour and action to be used by all subsequent graphics operations. It can set the foreground and background graphics colours. It also specifies how the colour is to be placed on the screen.

The first number specifies the mode of action.

  • 0 plot the specified colour
  • 1 OR the colour with the colour already there
  • 2 AND the colour with the colour already there
  • 3 XOR (exclusive-OR) the colour with the colour already there
  • 4 NOT (invert) the colour already there
  • 5 no change to colour already there (not initially documented)
  • 6 clear the colour - set it to colour 0 (not initially documented)
  • 7 various actions resulting from a table overflow

With the Graphics Extension ROM, the Master and later:

  • n*16+k - select fill pattern n for n=1,2,3,4

On Arthur and later:

  • 6 sets the pixel to (NOT colour AND the colour already there)
  • 7 sets the pixel to (NOT colour OR the colour already there)
  • 8+k - fill pattern uses a transparent background
  • 5*16+k - select a fill pattern made from all four fill patterns in a block
  • 6*16+k - select a large fill pattern
  • 7*16+k - select a large fill pattern

The second number specifies the logical colour. If the number is less than 128 then it defines the graphics foreground colour. If the number is greater than 127 then it defines the graphics background colour.

GCOL simply sends VDU 18,action,colour. Some versions of BASIC allow GCOL <colour> which sends VDU 18,0,colour.

The BBC VDU driver does no range checking on the GCOL action, so using out-of-range actions can cause odd effects.

Extensions

The defined GCOL actions are &00-&7F in blocks of 16:

  • &00+x plot action
  • &10+x fill pattern 1
  • &20+x fill pattern 2
  • &30+x fill pattern 3
  • &40+x fill pattern 4
  • &50+x super fill pattern 1-4
  • &60+x large fill pattern
  • &70+x large fill pattern

GCOL actions &80-&FF are undefined, and selecting them will result in undefined behaviour. Some applications have taken advantage of these unused actions to intercept OSWRCH to have a useful one-byte VDU command sequence.

  • &89 (also GCOL -ASC"w") - select a window [1]
  • &8C (also GCOL -ASC"t") - select a text style [2]
  • &8D (also GCOL -ASC"s") - select a text style [3]
  • &A0+x reserved
  • &E0+x application use
  • &F0+x application use

References