### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: Setting own RGB palette on Haiku OS  (Read 170 times)

#### CandyMan30

• New Member
• Posts: 16
##### Setting own RGB palette on Haiku OS
« on: May 22, 2023, 07:49:54 pm »
I tried different ways without results.

Code: Pascal  [Select][+][-]
1. procedure SendEscapeSeq(const S: String);
2. begin
3.   fpWrite(stdoutputhandle, S[1], Length(S));
4. end;
5.
6. function HexChar(A:Byte):Char;
7. begin
8.   A:=A and 15;
9.   if A<10 then HexChar:=Char(Ord('0')+A) else HexChar:=Char(Ord('A')+A-10);
10. end;
11.
12. function Hex2(A:Byte):Str2;
13. begin
14.   Hex2:=HexChar(A shr 4)+HexChar(A)
15. end;
16.
17. const
18.   { palette slot }
19.   SL     : VGASlot = (0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63);
20.
21.   VGA_Default : vga_pal = (
22.   { red   } (0,0,0,0,42,42,42,42,21,21,21,21,63,63,63,63),
23.   { green } (0,0,42,42,0,0,21,42,21,21,63,63,21,21,63,63),
24.   { blue  } (0,42,0,42,0,42,0,42,21,63,21,63,21,63,21,63));
25.
26. procedure Set_palette(Slot:Word; SR,SG,SB:Byte);
27. var
28.   B:Byte;
29. begin
30.   for B:=0 to 15 do
31.   if SL[B]=Slot then
32.   begin
33.     {\$IFDEF HAIKU}
34.   //SendEscapeSeq(#27']P'+HexChar(B)+Hex2(SR)+Hex2(SG)+Hex2(SB));
35.   //SendEscapeSeq(#27']1337;SetColors='+HexChar(B)+Hex2(SR)+Hex2(SG)+Hex2(SB)+#26'\');
36.   //SendEscapeSeq(#27']P4;'+Hex2(B)+';#'+Hex2(SR)+Hex2(SG)+Hex2(SB)+#7);
37.     {\$ENDIF}
38.     Break
39.   end;
40.