Welcome, Guest. Please login or register.


Author Topic: Using SET BIAS (Read 6045 times)

Offline JSP

  • Beginner
  • *
  • Posts: 27
  • Country: dk
Using SET BIAS
« on: 2019.February.11. 20:08:42 »
Hi

I am investigating the capabilities of the EP128 Basic. Just now I play with colours, and I would appreciate, if someone could confirm my understanding of how SET BIAS works. Here is how I think it works...

The Enterprise 128 can display up to 256 colours, but the reasonable compromise between resolution and number of colours, when doing graphics, is MODE 4. In this mode we have 16 colours. The first 8 colours can be modified to represent any combination of 8 of the 256 colours available using the PALETTE command. However for the other 8 colours you can only choose between 32 sets of 8 predefined colours. The first set is represented by the numbers 0-7, the next by 8-15, and so on up to 255. The trick is, that there is no physical memory location with the color code. The bit pattern of a number defines what colour it represents. There are 8 bits in the number. Three of those bits represent a value for red intensity between 0-7. Those are bit 6 ,bit 3 and bit, 0 with bit 6 as the most significant bit. Three other bits represent the green intensity. Those are bit 7, bit 4, bit 1 with bit 7 as the most significant. Finally blue intensity is held in bit 5 and bit 2. So for instance the value 22 gives a bit pattern like this:

00010110 (bit 7 on the left and 0 on the right) = Red intensity (0*4 + 0*2 + 0*1 = 0), green intensity (0*4 + 2*1 + 1*1 = 3), blue intensity (0*2 + 1*1 = 1) That is a mix of medium intensity green and weak intensity blue.

You can specify a colour using the RGB function. But i find using the BIN function more easy to use in this situation. Specifying colour intensity in 0.15 intervals between each level is messy as done within the RGB function.

You specify a set by writing:
SET #10: BIAS b
SET BIAS b

where b is any number in the b interval. So for instance to activate interval 1, you could set b to any value between 8-15. Also notice that the channel number is not really needed, since only one bias value can be active at any time no matter how many displays you have activated.

Is there more to SET BIAS than what I have described?

regards
Jesper

Offline ergoGnomik

  • EP addict
  • *
  • Posts: 1291
  • Country: hu
  • Stray cat from Commodore alley
Re: Using SET BIAS
« Reply #1 on: 2019.February.11. 21:20:48 »
Well, either your way of explaining it is a bit strange or your understanding went astray somewhere. The bit assignment of RGB values is correct as you described. BIAS works by replacing the lower 5 bits of the values of colours 0 to 7 with its content. E.g. if colour 0 is C7+C6+C5+C4+C3+C2+C1+C0 then colour 8 is C7+C6+C5+B4+B3+B2+B1+B0, where C means the bits of the colour, B means the bits of the BIAS and the number of power you raise 2 in the given bit position.

Another somewhat related fact is that the four levels of the blue component are equivalent of the other two components' 0, 2, 5 and 7 brightnesses.

Unfortunately, I have no idea how all this translates to IS-BASIC's RGB function.

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14722
  • Country: hu
    • http://enterprise.iko.hu/
Re: Using SET BIAS
« Reply #2 on: 2019.February.11. 21:29:36 »
More easy view in EP color table.

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Using SET BIAS
« Reply #3 on: 2019.February.11. 21:34:19 »
if I understand well, what you wrote is true in basic.
You can set any value for bias color range, bias will not change, ex if you set 0-7 to bias in Basic, bias HW setting will be 00h in all case.
Bit setting of colours are correct what you wrote :)

Offline JSP

  • Beginner
  • *
  • Posts: 27
  • Country: dk
Re: Using SET BIAS
« Reply #4 on: 2019.February.13. 16:31:38 »
Thanks for clearing my somewhat muddled thoughts :-)


Using the Enterprise Colours Scheme is a simple and convenient way of selecting a colour. A very nice program....


However here is my task:

I want to use the BIAS set, where there is a colour mixed from RED (3) and GREEN (3) and BLUE (0). The bit pattern for this colour is:

00011011 = 27

As ergoGnomics describes in his mail, the top 5 bits (00011) translates into the BIAS set number and the low 3 bits provides the index of the colour in the BIAS set.

00011 = 3 (That is BIAS set 3).
011 = 3 (Colour in BIAS set).

A set has 8 colours, so for instance colour 8-15 are members of set 1. So you have to multiply the set number with 8 to get a number within that set. And as the 8 colours from a set are mapped to palette colour 8-15 you have to add 8 to the index of the colour in the set when specifying your ink.

Here is some code, that demonstrates how it works.

100 PROGRAM "a:biastest.bas"
110 GRAPHICS HIRES 16
120 LET BIAS_NO = 3
130 LET COL_NO = 3
140 SET BIAS BIAS_NO * 8
150 SET INK COL_NO + 8
160 SET BEAM OFF
170 PLOT 100,100; 300,100; 300,200; 100,200; 100,100, 200,150, PAINT


The cool thing is that the bit pattern for the number of the colour also implicitly has information about the intensity of the RGB colours used to mix it, as well as information about BIAS sets and colours. So knowing any of the three facts can be used to deduce the others.

And yes, on second thoughts I don't understand the RGB function either :-)

regard
Jesper

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: Using SET BIAS
« Reply #5 on: 2019.February.14. 07:39:25 »
If I remember well RGB is quite simple too, you specify the intensity of the colour by the numbers.
RGB(1,1,1) is the highest intensity for each component so it gives back white
RGB(1,0,0) is the highest intensity of red, and lowest of green and blue, so it gives back highest intensity red, which is colour 73 (01001001)
RGB(0.5,0,0) gives back half intensity of red which is colour 72

Offline JSP

  • Beginner
  • *
  • Posts: 27
  • Country: dk
Re: Using SET BIAS
« Reply #6 on: 2019.February.14. 09:50:05 »
Hi

Well... In fact I think I do understand how the RGB function works. But it is very convoluted. The values you specify between 0.0 and 1.0 are translated to intensities based on their bit patterns. You therefore have to understand how bit patterns are translated to intensities - discussed in some earlier mails in this debate. But if you know the bit pattern used to specify intensities and therefore the colour, you already have the answer (the colour number) and do not need an RGB function. So the function is nearly useless. It would have made sense if you had entered the intensity values directly like this RGB(3,3,0) with values ranging from 0-7 for RED and GREEN and 0-3 for BLUE.

Here are the patterns created by the RED component.

Return value  Bit pattern   Decimal      Intensity
for RED       return value   spec. in   
          for RED      RGB func.   
---------------------------------------------------------
00         00000000     .00-.14      0
64         01000000    .15-.28      4
08         00001000      .29-.42      3
72         01001000     .43-.57      6
01         00000001     .58-.71      1
65         01000001     .72-.85      5
09         00001001     .86-.99      3
73         01001001     1.00              7

Similar patterns with other bits provides the GREEN and BLUE component. These three patterns are then OR-ed and the resulting bit pattern is the colour number you can use in a COLOUR or INK or PALETTE command.

regards
Jesper

Offline ergoGnomik

  • EP addict
  • *
  • Posts: 1291
  • Country: hu
  • Stray cat from Commodore alley
Re: Using SET BIAS
« Reply #7 on: 2019.February.14. 10:25:56 »
Some off topic things:
  • ergoGnomik and not ergoGnomics, please. I'm not multiple persons nor any kind of science. ;)
  • You can insert tables in your posts with that green-blob-on-a-spreadsheet looking icon in the bar above the text entry field. (The 8th from the right.)
  • Your table somehow has the 3 twice while 2 is missing in the Intensity column.
  • And that RGB mapping looks to be some weird sh*t. Never would've guess it working that way.

And a question somewhat pertaining to the topic: Why do you keep referring to BIAS as set? AFAIK, BIAS modifies the first eight entries of the palette to derive the second eight. That is not something existing in itself.

Offline JSP

  • Beginner
  • *
  • Posts: 27
  • Country: dk
Re: Using SET BIAS
« Reply #8 on: 2019.February.14. 15:24:52 »
Hi

Ups! Sorry! Calling people by the wrong name.... I stand corrected :-)

Wrong number. The correct line is...
08         00001000      .29-.42      2

When I started to look at how colours work, I expected a table of values somewhere in memory for the 256 colours. But it seems that colours do not need a table if the bits in the colour number are used, as thet are in the Enterprise. The bit pattern provides the RED, GREEN and BLUE intensities that define the colour. Therefore colours 0-7 have their intensity definitions made from their matching bit patterns 00000000 - 00000111. So colour 7 is made from RED(1), GREEN(1) and BLUE(1).

The 256 colours are divided into 32 parts, each of 8 consecutive numbers. 0-7, 8-15, ...248-255. If you want the location of colour 14 (00001 110) it is item 6 (items indexed from 0-7) in part 1 (the second part)  among the colour groups. I call these groups for sets.

I think colours are implemented in this way, because you only have 256 colours, and it turns out you can save 256 bytes of memory if you can represent the intensities with every third bit instead of the first three bits for RED, the next 3 bits for GREEN and the last 2 for BLUE. Thus a colour's number doubles as the intensity definition, and you don't need to store anything explicitly. It is all very clever.

Offline Povi

  • EP addict
  • *
  • Posts: 2296
  • Country: hu
    • http://povi.fw.hu
Re: Using SET BIAS
« Reply #9 on: 2019.February.14. 17:06:49 »
there is a nice homepage made by lgb about bias and color seleceting
*** Speicherplatz zu klein

Offline JSP

  • Beginner
  • *
  • Posts: 27
  • Country: dk
Re: Using SET BIAS
« Reply #10 on: 2019.February.14. 20:34:16 »
Hi

Thanks! I am familiar with that page, which is all you need for normal use. What it does not tell you is why the colours are in the order they are (How they are defined and constructed). I hope this discussion has clarified that.

This knowledge may also have a practical application. Assume that you need to have a specific colour among your 16 available colours. Ideally the BIAS fixed part of your palette  (ink 8-15) should include as many of the colours you need as possible, so you can use the variable ink (0-7) colours freely by assigning colour numbers to them. With the knowledge we have gained in this discussion, we can decide on a colour with a specific combination of intensities, find its number and which of the 32 BIAS groups of 8 numbers, that i is a part of, and which number (0-7) it has in this group, and make sure the group is selected for BIAS. Then just add 8 to the number it has in the BIAS group and you have the INK number. (Between 8-15)

regards
Jesper

Offline dangerman

  • EP fan
  • *
  • Posts: 100
Re: Using SET BIAS
« Reply #11 on: 2019.February.16. 12:16:05 »
Related to the bias...

If I have a full colour picture - like a jpg photograph, is there any way to choose the best palette to approximate the picture on the Enterprise?

If we had free choice on all of the 16 colours, then I could just use a PC to reduce the resolution and dither it to 16 colours. Then convert that 16-colour  palette to EP colours by taking the most significant bits of the RGB values.

But because of bias, we don't have complete freedom over 8 of those colours. Does anyone have any suggestions for how to make a "best choice" for the bias?



Offline ergoGnomik

  • EP addict
  • *
  • Posts: 1291
  • Country: hu
  • Stray cat from Commodore alley
Re: Using SET BIAS
« Reply #12 on: 2019.February.16. 13:13:14 »
IstvanV's wonderful ep128emu package also has an image converter utility that works almost miracles. And, as the whole package, comes with open sources. You should take a peek to see how it can be done.

Offline dangerman

  • EP fan
  • *
  • Posts: 100
Re: Using SET BIAS
« Reply #13 on: 2019.February.16. 17:04:03 »
IstvanV's wonderful ep128emu package also has an image converter utility that works almost miracles.

Wow, brilliant! Thank you!

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14722
  • Country: hu
    • http://enterprise.iko.hu/
Re: Using SET BIAS
« Reply #14 on: 2019.February.16. 19:19:08 »