Date : Sat, 24 Oct 2015 23:13:05 +0100
From : jgh@... (J.G.Harston)
Subject: Reading current colours
OSBYTE 160,87-90 reads the current text and graphics foreground and
background colours:
OSBYTE 160,87: read foreground text colour
OSBYTE 160,88: read background text colour
OSBYTE 160,89: read foreground graphics colour
OSBYTE 160,90: read background graphics colour
However, these don't return the actual logical colour supplied as the
parameter to COLOUR or GCOL. They return the bitmap that that colour
stores in the screen memory. For example, in a 4-colour mode such as
MODE 1 OSBYTE 160,87 returns the following:
COLOUR 0 &00
COLOUR 1 &0F
COLOUR 2 &F0
COLOUR 3 &FF
Now, that can be fairly easily converted to a colour number with DIV 8,
and the values returned in a 2-colour mode are &00 and &FF which can be
reduced with AND 1. However, 16-colour modes return 00 03 0C 0F 30 33 3C
3F C0 C3 CC CF F0 F3 FC FF.
I've been trying to convert these colour fill value into colour numbers.
OSBYTE 160,96 also returns the maximum colour number (ie 1, 3, 15), and
before checking the MODE 2 values I'd thought: Ah ha! Just AND with
MaxColour, but that only works with 2-colour modes, and only with colour
0 and 3 in 4-colour modes, and fails completely with 16-colour modes.
Has anybody ever worked out how to work out the current colours numbers,
preferably using the VDU workspace values read with OSBYTE 160, or seen
published somewhere? I'm sure this is the sort of programming tip that
would have been published in something like the bottom corner of a page
in a Beebug.
--
J.G.Harston - jgh@... - mdfs.net/jgh