{...}
{установка 256-цветной палитры}
procedure SetPal(var pal:byte;nbegpal,lenpal:integer);
var
	i : integer;
	p : array [0..767]of byte absolute pal;
begin
	for i := nbegpal to nbegpal+lenpal-1 do begin
		port[$3c8] := lo(i);
		port[$3c9] := p[i*3+0];
		port[$3c9] := p[i*3+1];
		port[$3c9] := p[i*3+2];
	end;
end;

{чтение 256-цветной палитры}
procedure getpal(var pal:byte;nbegpal,lenpal:integer);
var
	i : integer;
	p : array [0..767]of byte absolute pal;
begin
	for i := nbegpal to nbegpal+lenpal-1 do begin
		port[$3c7] := lo(i);
		p[i*3+0] := port[$3c9];
		p[i*3+1] := port[$3c9];
		p[i*3+2] := port[$3c9];
	end;
end;
{...}