On 09/15/2010 05:39 PM, Nikolay Nikolov wrote:
Currently, the following palette-related things from the fpc graph unit aren't TP7 compatible:

...

What do you think?
There are also 2 other palette-related incompatibilities, that I'd also like to fix. They're relatively independent from the PaletteType/RGBPaletteType issue.

1. SetRGBPalette's range of values for RedValue, GreenValue and BlueValue is 0..63 in TP7 and 0..255 in FPC. So to set the background to bright red, in TP7 you would use:

SetRGBPalette(0, 63, 0, 0)

but this would set it to only dark red in FPC, where you have to use:

SetRGBPalette(0, 255, 0, 0)

this could be supported with a global boolean variable, that enables or disables the extended DAC range. E.g:

ExtendedRGBPaletteRange := true; { use 0..255 range }
ExtendedRGBPaletteRange := false; { use 0..63 range }

This can be implemented without any change to the platform-specific drivers, i.e. TModeInfo.SetRGBPalette and TModeInfo.GetRGBPalette will continue to only support the range 0..255 and not care about the ExtendedRGBPaletteRange flag. However, we'll add new front-end wrapper functions, that'll check the flag and convert the data, if necessary, before calling the internal Set/GetRGBPalette functions:

procedure SetRGBPalette(ColorNum, RedValue, GreenValue, BlueValue: smallint);
begin
  if not ExtendedRGBPaletteRange then
  begin
    RedValue := (RedValue and 63) shl 2;
    GreenValue := (RedValue and 63) shl 2;
    BlueValue := (RedValue and 63) shl 2;
  end;
  InternalSetRGBPalette(ColorNum, RedValue, GreenValue, BlueValue);
end;

2. The second one's trickier and affects SetRGBPalette in 16-colour modes. In FPC, to set the RGB palette value of a colour number ColorNum (in [0..15]) you simply use:

SetRGBPalette(ColorNum, R, G, B)

in TP7, you have to do something like:

SetRGBPalette(DefaultEGAPalette[ColorNum], R, G, B)

where DefaultEGAPalette is (0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58, 59, 60, 61, 62, 63) for most EGA/VGA and VESA 16-colour modes, with the exception of modes 0Dh - 320x200x16 (not supported by BGI or FPC as of now) and 0Eh - 640x200x16 (supported by both BGI and FPC - driver VGA, mode VGALo), where DefaultEGAPalette is (0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23). These EGA palettes can be obtained in TP7, using GetDefaultPalette or GetPalette. You can also decide to combine SetPalette and SetRGBPalette to produce all sorts of tricks.

This could also be emulated in front-end wrapper functions and we could also add a flag to turn the EGA palettes off, but the code would be trickier.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to