<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Sun, 25 Oct 2015 00:53:45 +0100 (WET-DST)
From   : bbcmicro@... (Peter Coghlan)
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, 
>

Looks ok for COLOUR 0 and COLOUR 1 but not for COLOUR 2 and COLOUR 3.

How about something like this (not tested):

Value obtained from OSBYTE 160, 87 etc in A:

LSR A
LSR A
LSR A
LSR A
ROR result
LSR A
LSR A
LSR A
LSR A
ROR result
LSR result
LSR result
LSR result
LSR result
LSR result
LSR result

>
> 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.
>

For 16-colour mode (again, not tested):

Value obtained from OSBYTE 160, 87 etc in A:

LSR A
LSR A
ROR result
LSR A
LSR A
ROR result
LSR A
LSR A
ROR result
LSR A
LSR A
ROR result
LSR result
LSR result
LSR result
LSR result

>
> 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.
>

Regards,
Peter Coghlan.
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>