VDU 19

From BeebWiki
Jump to: navigation, search

Define Logical Colour.

VDU 19
Syntax VDU 19,<logical>,<physical>,<red>,<green>,<blue>
Character stream (hex) &13 <logical> <physical> <red> <green> <blue>
Description Set the logical colour <logical> to be the physical colour <physical>.

Description

VDU 19 sets the logical colour, used in GCOL (VDU 18) or COLOUR (VDU 17) to the provided physical colour. The physical colour is set with a physical colour number or, on 32-bit platforms and compatible extensions for 8-bit systems, the individual red/green/blue colour levels set with the last three parameters.

The logical colour value is MODed by the number of colours in the screen mode, so in a four colour mode, defining colour 4 will alter colour 0.

Some platforms support a logical colour of -1 to set the border colour. Some platforms use a physical colour of 16+ to set the border or pointer colours or individual flash colours.

Screen modes with 256 or more logical colours use other methods to control the palette.

Parameters

Logical colour:
 VDU 19,<128 ,p,r,g,b - set logical colour
 VDU 19,128+n,p,r,g,b - provisional: set alpha channel colour
 VDU 19,-1   ,p,r,g,b - set border colour (-1 is sent as CHR$255)
Physical colour:
  0+colour    VDU 19,l,%0000ebgr,r,g,b - set to physical colour
 16+action    VDU 19,l,%0001xxxx,r,g,b - set to RGB colour
 32+colour    VDU 19,l,%0010ebgr,r,g,b - set first flashing physical colour
 48+colour    VDU 19,l,%0011ebgr,r,g,b - set second flashing physical colour
 64+action    VDU 19,l,%01xxxxxx,r,g,b - reserved
128+action    VDU 19,l,%100yyyyy,z,x,x - CPC: flash between colour y and z
255           VDU 19,l,%11111111,r,g,b - DOS: set 6-bit RGB colour

This gives the following implementations:
 VDU 19, l,   0-15, r,g,b - set to 4-bit physical colour
 VDU 19, l,   16,   r,g,b - set to RGB colour
 VDU 19, l,   17,   r,g,b - set first RGB flash colour
 VDU 19, l,   18,   r,g,b - set second RGB flash colour
 VDU 19, l,   24,   r,g,b - set border RGB colour
 VDU 19, l,   25,   r,g,b - set pointer RGB colour
 VDU 19, l, 32+p,   r,g,b - set first physical flashing colour
 VDU 19, l, 48+p,   r,g,b - set second physical flashing colour
 VDU 19, l,128+p1, p2,x,x - set CPC physical colours
 VDU 19, l,   -1,   r,g,b - set to 6-bit RGB colour

Calling from BBC BASIC

On BASIC V and later, and equivalent:

  • COLOUR l,p sends VDU 19,l,p,0,0,0
  • COLOUR l,r,g,b sends VDU 19,l,16,r,g,b

Some implementations support setting the border colour with:

  • COLOUR l,r,g,b sends VDU 19,l,24,r,g,b if l<0

Implementations

BBC/Master/Electron

The native 8-bit Acorn computers only support using 4-bit physical colour numbers, and do not support setting the border colour. The top four bits of the logical colour and physical colour are ignored, as are the r/g/b components, but programs should use 0-15 for the colours and zero for the r/g/b components to allow for expansion.

Expansions such as the Chamelion and the Prisma support using red/green/blue colour components and setting the border colour. [1] Software extensions support setting independent flash colours. [2]

RISC OS

RISC OS supports 4-bit physical colour numbers 0-15 and using physical colour numbers 16-31 to set red/green/blue colour components. Physical colour numbers greater than 31 are ignored completely.

DOS/Windows

DOS/Windows supports 4-bit physical colour numbers and using physical colour numbers 16-31 to set red/green/blue colour components. It also supports using logical colour -1 to set the border colour. On Windows VDU 19 just sets the physical colour for use from that point on, it does not change any colours already displayed on screen. This means that it cannot be used for palette-switching animation.

Millipede Prisma Graphics System

The Prima Graphics System supports:

  • VDU 19,l,p,0,0,0 - sets to physical non-flashing colour if red/green/blue are zero and p<16.
  • VDU 19,l,p,r,g,b - sets to red/green/blue colour components if any are non-zero, ignoring p.
  • VDU 19,l,p,r,g,b - sets to red/green/blue colour components if p=16+, otherwise ignoring p.

Amstrad CPC

Amstrad CPC supports 4-bit physical colour numbers translated to the Amstrad 3*3*3 colour palette and using logical colour -1 to set the border colour. It also supports the following to set colours to the native 3*3*3 Amstrad colour levels:

  • VDU 19,l,128+x,y,0,0 - flash between Amstrad colour x and y

Compatability across platforms

To be compatible across different platforms programs should use the following code:

  • VDU 19,l,0-15,0,0,0 to set a physical colour, specify r/g/b parameters as all zero
  • VDU 19,l,16,r,g,b to set red/green/blue colour components
  • VDU 19,-1,24,r,g,b to set the border colour, use both l=-1 and p=24

References

See also

On a BBC/Master, VDU 19 calls the code that OSBYTE &9B calls to update the ULA palette registers. It will automatically invert the physical colour value as required by the ULA.

--Tautology 13:10, 1 May 2011 (UTC) Jgharston (talk) 23:10, 16 June 2016 (UTC) Jgharston (talk) 07:39, 30 November 2016 (UTC)