home *** CD-ROM | disk | FTP | other *** search
- program palette;
-
- uses crt,dos,screen;
-
- const daten: array[0..16] of byte =
- { (0,1,2,3,4,5,20,7,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F,0);}
- (0,1,2,$26,4,$38,$14,7,$27,9,$12,$3B,$24,$3D,$36,$3F,0);
- value: array[0..3] of byte = (0,8,1,9);
- att_backgr = brown*16+lightgray;
-
- type control_typ = (li,re,auf,ab,bauf,bab,pos1,end_,key,ext);
-
-
- var farbe,r,g,b,neu: shortint;
- control: control_typ;
- taste: char;
- ende: boolean;
-
- procedure install_palette;
- var regs: registers;
- begin
- with regs do begin
- ax:=$1002;
- dx:=ofs(daten);
- es:=seg(daten);
- intr($10,regs);
- end;
- end; (* install_palette *)
-
-
- procedure bildschirm;
- var lauf,x,y: byte;
- begin
- box(all_double_box,0,0,78,23,att_backgr,att_backgr);
- box(all_single_box,7,1,64,3,att_backgr,att_backgr);
- for lauf:=0 to 15 do for y:=2 to 4 do for x:=8+lauf*4 to 11+lauf*4 do begin
- crt_screen^[y,x,0]:='█'; crt_screen^[y,x,1]:=chr(lauf);
- end;
- end; (* bildschirm *)
-
-
- procedure fill_rgb;
- var wert: byte;
- begin
- r:=0; g:=0; b:=0; wert:=daten[farbe];
- if (wert and 1)>0 then inc(b,2);
- if (wert and 2)>0 then inc(g,2);
- if (wert and 4)>0 then inc(r,2);
- if (wert and 8)>0 then inc(b,1);
- if (wert and 16)>0 then inc(g,1);
- if (wert and 32)>0 then inc(r,1);
- wr(6,9+farbe*4,att_backgr,#24#24); gotoxy(12+farbe*4,7);
- end; (* fill_rgb *)
-
-
- procedure back_rgb;
- begin
- daten[farbe]:=value[b]+value[g]*2+value[r]*4;
- wr(6,9+farbe*4,att_backgr,' ');
- end; (* back_rgb *)
-
-
- procedure zeige_rgb;
- var x,wert: byte;
-
- function strr (zahl: longint; stellen: byte): string;
- var s: string;
- begin
- str(zahl,s); while length(s)<stellen do s:='0'+s;
- strr:=s;
- end; (* strr *)
-
- function hex (zahl: byte): string;
- const hexchars: array[0..$F] of char = '0123456789ABCDEF';
- begin
- hex:=hexchars[(zahl and $F0) shr 4]+hexchars[zahl and $F];
- end; (* hex *)
-
- procedure rgb_box (oben,unten: char; wert,att: byte);
- begin
- box(all_single_box,x,17,2,4,att*16+white,att*16+white);
- wr(17,succ(x),att*16+white,oben); wr(22,x+2,att*16+white,unten);
- wr(21-wert,succ(x),att*16+white,'██');
- inc(x,4);
- end; (* rgb_box *)
-
- begin (* zeige_rgb *)
- x:=34; wert:=value[b]+value[g]*2+value[r]*4;
- box(all_double_box,33,15,12,7,att_backgr,att_backgr);
- wr(16,37,att_backgr,'$'+hex(wert)+'/'+strr(wert,2));
- rgb_box ('Q','A',r,red); rgb_box('W','S',g,green); rgb_box('E','D',b,blue);
- end; (* zeige_rgb *)
-
-
- procedure lies (var control: control_typ; var taste: char; num_pad: boolean);
- begin
- taste:=readkey;
- if taste=#0
- then begin
- taste:=readkey;
- case ord(taste) of
- 72: control:=auf;
- 80: control:=ab;
- 75: control:=li;
- 77: control:=re;
- 73: control:=bauf;
- 81: control:=bab;
- 71: control:=pos1;
- 79: control:=end_;
- else control:=ext;
- end;
- end else
- if num_pad
- then case taste of
- '8': control:=auf;
- '2': control:=ab;
- '4': control:=li;
- '6': control:=re;
- '9': control:=bauf;
- '3': control:=bab;
- '7': control:=pos1;
- '1': control:=end_;
- else control:=key;
- end
- else control:=key;
- end; (* lies *)
-
-
- begin (* palette *)
- bildschirm; farbe:=0;
- repeat
- install_palette;
- fill_rgb; neu:=farbe;
- repeat
- zeige_rgb;
- lies (control,taste,true);
- case control of
- li: begin dec(neu); ende:=true; end;
- re: begin inc(neu); ende:=true; end;
- key: case upcase(taste) of
- 'Q': if r<3 then inc(r);
- 'W': if g<3 then inc(g);
- 'E': if b<3 then inc(b);
- 'A': if r>0 then dec(r);
- 'S': if g>0 then dec(g);
- 'D': if b>0 then dec(b);
- #27: ende:=true;
- end;
- end;
- until ende;
- back_rgb; farbe:=neu and 15;
- until taste=#27;
- end.