Subject:           Re: Farb-Palette   Colour Palette
      Date:           Wed, 24 Jun 1998 00:38:00 +0200
      From:           Michael Knapp <michaelknapp@nol.at>
 Organization:        NETWAY AG
        To:           thomaeum@nordrhein.de
 Newsgroups:          de.comp.lang.pascal.misc

Thomaeum schrieb:

> Hallo,
> gibt es in TP 6 die Möglichkeit, dem System die standardmäßig benutzte
> Farbpalette zu entlocken?
> Does in TP 6 exist a method to obtain the standard colour palette from the system.

VGA Palette



(* für 256 Farben
   for 256 colours  *)
PROCEDURE GetPalette256(var palette);assembler;
ASM
  LES DI,palette
  MOV DX,03C7H
  XOR AL,AL
  OUT DX,AL
  ADD DX,2
  MOV CX,768 {3*256}
(* Franz Glaser suggests: *) CLD
  INSB
END;

(* für 16 Farben
   for 16 colours *)
PROCEDURE GetPalette16(var palette);assembler;
ASM
  LES DI,palette
  MOV DX,03C7H
  XOR AL,AL
  OUT DX,AL
  ADD DX,2
  MOV CX,48 {3*16}
(* Franz Glaser suggests: *)  CLD
  INSB
END;



NOTE: The untyped "Var Palette", which shall get the data, must be big enough!
eg.:
Type PalEntry = Record
                  pe_blue  : byte;
                  pe_green : byte;
                  pe_red   : byte;
                End;
Var Palette_buffer : Array[0..255] of PalEntry;

It is not tested by the compiler / runtime program.

Translation, additions and comments by Franz Glaser
Turbo Pascal links: http://geo.meg-glaser.at/tp.html

More from Michael Knapp on the TP-links site: RGB_386_demo and GraphiX V 6