> PCHANGE v2.1  R/G/B palette control 4 Mike Cook's Beeb Body Building Course Feb 1990 (@ Updated to allow VDU 19, vNULA, Clwyd, CTS500, PaletteMate 2: <)&87:A%=--20200:A%<0:=+A%:$&600 F3R%(15),G%(15),B%(15),RT(7),GT(7),BT(7),SCOL%16 P%default:HW%=5: Default hardware Z:&87:err d*:5"12-BIT COLOUR PALETTE SELECTOR"' n&"Press digit to select a colour." x)"SHIFT+digit to select colours 8+."' &"R/G/B - Add more Red/Green/Blue" '" Press SHIFT to subtract"' "A - Alter the saturation" "V - Alter the brightness" "H - Alter the hue" "T - Toggle the R/G/B"' -"E - Exchange main & alternate palettes" *"I - Interpolate between two colours" !"D - Select default palette" "L - Load a palette file" "S - Save a palette file" #"P - Select palette hardware"' "Escape - to Quit"' &"PRESS ANY KEY TO CONTINUE";:A%= &82:all:5:L%=015:0,L% (160*(L%7),1015-16*(L%8):0,0,-120 "!81,144,0:0,0,120:81,-144,0 ,/0,L%7:160*(L%7)+40,964-16*(L%8):;~L%; 6:0,0:0,1023:0,760 @&4,28,0,31,19,9,23,1;0;0;0;0:N=1: J37:3,0);hw(HW%);2,1);"WORKING COLOUR ";~N;' T="RED =";R%(N)" "'"GREEN =";G%(N)" "'"BLUE =";B%(N)" " ^OA=015:15-A:A:"COLOUR ";~A;" ";d(R%(A));" ";d(G%(A));" ";d(B%(A)): h=:0,2);:C$=:INC=1+2*-1:"FX15": C$>"_":C$=(C$&DF) r=C$="R":R%(N)=R%(N)+INC:R%(N)<0R%(N)>15:R%(N)=R%(N)-INC |=C$="G":G%(N)=G%(N)+INC:G%(N)<0G%(N)>15:G%(N)=G%(N)-INC =C$="B":B%(N)=B%(N)+INC:B%(N)<0B%(N)>15:B%(N)=B%(N)-INC 8C$="T":R%(N)=R%(N)15:G%(N)=G%(N)15:B%(N)=B%(N)15 C$="E":PSWAP C$="I":INTER $C$="H":HVAL(R%(N),G%(N),B%(N)) $C$="V":VVAL(R%(N),G%(N),B%(N)) $C$="A":SVAL(R%(N),G%(N),B%(N)) /"RGBTIHVA",C$):DCOL(N,R%(N),G%(N),B%(N)) 2N:10,N+6);d(R%(N))" "d(G%(N))" "d(B%(N)) 47:7,3);R%(N)" ";7,4);G%(N)" ";7,5);B%(N)" " C$<":""DSLPE",C$) C$="D":default:all C$="S":FILE(1) C$="L":FILE(0) +C$<":":C$>=" ":N=C$15:C$<"(":N=N+8 tC$="P":0,3)"1:Native 4:Pal'Mate 2:Clwyn 5:Chameleon3:CTS 6:VideoNULA":A%=::A%>48:A%<55:HW%=A%-49:all & 0ݤd(A%)=" "+A%,2) :jݤhw(A%)="NATIVE VDU 19 CLWYD CTS CC500 PALETTEMATE CHAMELEON VIDEONULA ",A%*13+1,13) D default NA=0:L%=07 XL%1:R%(L%)=15R%(L%)=0 bL%2:G%(L%)=15G%(L%)=0 lL%4:B%(L%)=15B%(L%)=0 v*R%(L%+8)=A:G%(L%+8)=A:B%(L%+8)=A:A=A+2 : 0wr(Y%):X%=12:io(96,Y%):io(96,Y%+8):: !io(X%,Y%):A%=151-X%256:0  &FFF4:   ::  &FFF4: all:HW%=5:io(34,64) *A=015:DCOL(A,R%(A),G%(A),B%(A)):: DCOL(N%,R%,G%,B%) 1HW%=0:19,N%,16,R%*16,G%*16,B%*16:: NATIVE !19,N%,N%(23-HW%*8);0;:*FX19 :HW%=5:io(35,N%*16+R%):io(35,G%*16+B%):: VIDEONULA @HW%=4:io(98,&FF):io(108,&AE):io(96,&E0+N%):io(96,R%15)  ?HW%=4:io(96,(G%15)+64):io(96,(R%15)+128):io(96,&E0): BHW%=2:io(&4A0+N%,R%):io(&4A8+N%,G%):io(&4B0+N%,B%):: CTS  JHW%=1:io(98,&FF):wr(N%*16):wr(R%*16+1):wr(G%*16+2):wr(B%*16+3): * 4PSWAP:A=07 >#T=R%(A):R%(A)=R%(A+8):R%(A+8)=T H#T=G%(A):G%(A)=G%(A+8):G%(A+8)=T R#T=B%(A):B%(A)=B%(A+8):B%(A+8)=T \ :all: f INTER p0A=07:RT(A)=R%(A):GT(A)=G%(A):BT(A)=B%(A): z,0,3);(60);0,3);"INTERPOLATE BETWEEN"  " COLOUR: ";:S%=7:;S%  "AND COLOUR: ";:F%=7:;F% S%>F%:T%=S%:S%=F%:F%=T% D%=F%-S%:D%<1: ERI=(R%(F%)-R%(S%))/D%:GI=(G%(F%)-G%(S%))/D%:BI=(B%(F%)-B%(S%))/D% $AGR=R%(S%):AGG=G%(S%):AGB=B%(S%) A=S%+1F%-1 AGR=AGR+RI:RT(A)=(AGR) AGG=AGG+GI:GT(A)=(AGG) AGB=AGB+BI:BT(A)=(AGB) DCOL(A,RT(A),GT(A),BT(A)) :"KEEP/REJECT? (K/R)"; C$=(&DF):"KR",C$) 8C$="K":A=07:R%(A)=RT(A):G%(A)=GT(A):B%(A)=BT(A): all::C$=N: HVAL(RI,GI,BI) $!RGB_HSV(RI,GI,BI):H=H+INC*60 . H<0:H=0 8H>430:H=180:S=1/15 BH>360:H=H-360 LSET_RGB: VVVAL(RI,GI,BI) `#RGB_HSV(RI,GI,BI):V=V+(INC/15) j V>1:V=1 t V<0:V=0 ~SET_RGB: SVAL(RI,GI,BI) #RGB_HSV(RI,GI,BI):S=S+(INC/15)  S>1:S=1  S<0:S=0 S<>0 H>400:H=180 SET_RGB:  SET_RGB /HVS_RGB:CERR=0:R%(N)=RI:G%(N)=GI:B%(N)=BI  RGB_HSV(RI,GI,BI) %RI=RI/15:GI=GI/15:BI=BI/15:MAX=RI RIGI:MIN=GI MIN>BI:MIN=BI (MAX=0:S=0:V=0:DPE 2 V=MAX <S=(MAX-MIN)/MAX FMAX=MIN:S=0 PS=0:H=999:t`E ZRC=(MAX-RI)/(MAX-MIN) dGC=(MAX-GI)/(MAX-MIN) nBC=(MAX-BI)/(MAX-MIN) xRI=MAX:H=BC-GC GI=MAX:H=2+RC-BC BI=MAX:H=4+GC-RC H=H*60:H<0:H=H+360   HVS_RGB  I,F,P,Q  CERR=0 H>400:RI=V:GI=V:BI=V:TlF S=0H<361:CERR=1: H=360:H=0 ?H=H/60:I=H:F=H-I:P=V*(1-S):Q=V*(1-(S*F)):T=V*(1-(S*(1-F))) I=0:RI=V:GI=T:BI=P I=1:RI=Q:GI=V:BI=P I=2:RI=P:GI=V:BI=T I=3:RI=P:GI=Q:BI=V I=4:RI=T:GI=P:BI=V "I=5:RI=V:GI=P:BI=Q ,0RI=(RI*15+.5):GI=(GI*15+.5):BI=(BI*15+.5) 6 @FILE(D%)::*. J*"Enter file to ";:D%:"save""load" T ": "C$ ^D%=1:P%=C$P%=C$ h%P%=0:"Can't open file";:A=:: r'D%=0:D%=#P%:#P%=0:D%<>19:D%=255 |A=015:L=A JD%=1:#P%,19:#P%,L:#P%,16:#P%,R%(L)*17:#P%,G%(L)*17:#P%,B%(L)*17 "D%=255:#P%,R%(L),G%(L),B%(L) KD%=19:A%=#P%:L=#P%:A%=#P%:R%(L)=#P%16:G%(L)=#P%16:B%(L)=#P%16 :#P%:C$=(N+48)::all: *err::''" Press SPACE to continue," ;" Q to quit,"''" or insert your games disk and press" " B to boot it." A=&DF:A=81: A<>66:   *DIR $ *EXEC !BOOT