'=========================================================================== ' Subject: MANIPULTAING DAC DATA Date: 03-17-99 (13:15) ' Author: Jacob Wieles Code: QB, QBasic, PDS, PB ' Origin: jacwls@worldonline.nl Packet: EGAVGA.ABC '=========================================================================== 'program : DACAC12C.BAS (16-03-99) 'which basic : PowerBASIC and Q(uick)BASIC 'auteur : Jacob Wieles defint a-z dim dac(63,2),ac(15),ncol(63,2) color 14 cls print" This program shows in the SCREEN 12 the colors" print" yellow, magenta, cyan and gray." print" For compatibility with PowerBASIC and Q(uick)BASIC, the" print" folowing procedures (SUB) are used. :":? print" GetDacData(dummy()) read data from the DAC." print" SetNewDac(dummy(()) set new data in the DAC." print" SetNewColor(index,R,G,B) set new data in one DAC index." print" remove the remouts in front of the" print" lines 141 and 142 to see how" print" SetNewColor works." print" GetAttrContr(dummy()) read the AC setting." print" NewPalette(attr,col) a compatible Palette statement" print" for Power- and Q(uick)BASIC." print print" DAC ---->> Digital Analog Converter." print" AC ---->> Attibute Controler." print print" After a key hit the program tryed screen 12." print" If there an error occurs then the program stop." call NextKeyHit(23,31,"next") on error goto NoVGA screen 12 sub GetDacData(dummy()) out &H3C7,0 for i=0 to 63 for j=0 to 2 dummy(i,j)=inp(&H3C9) next j next i end sub sub SetNewDac(dummy(),index) out &H3C8,0 for i=0 to index for j=0 to 2 out &H3C9,dummy(i,j) next j next i end sub sub SetNewColor(index,R,G,B) out &H3C8,index and 63 out &H3C9,R and 63 out &H3C9,G and 63 out &h3C9,B and 63 end sub sub GetAttrContr(dummy()) dummy=inp(&H3DA) for i=0 to 15 out &H3C0,i out &H3C0,inp(&H3C1) dummy(i)=inp(&H3C1) next i out &H3C0,32 end sub sub NewPalette(attr,col) dummy=inp(&H3DA) out &H3C0,attr and 15 out &H3C0,col and 63 out &H3C0,32 end sub sub NextKeyHit(r,k,fillto$) while inkey$<>"":wend locate r,k print"Hit a key for ";fillto$;"."; while inkey$="":wend locate r,k print" ";space$(len(fillto$)) end sub restore WhichColor for i=0 to 3 read whichcol$(i) next i cls call GetDacData(dac()) ' Save the default DAC data. call GetAttrContr(ac()) ' Save the AC setting. 'Make new data for array ncol to used for fill DAC-index 0 to 15 four times for p=0 to 3 for i=0 to 15 select case p case 0 '==> yellow ncol(p*16+i,0)=18+i*3 'intensity red ncol(p*16+i,1)=18+i*3 'intensity green ncol(p*16+i,2)=0 'intensity blue case 1 '==> magenta ncol(p*16+i,0)=18+i*3 ncol(p*16+i,1)=0 ncol(p*16+i,2)=18+i*3 case 2 '==> cyan ncol(p*16+i,0)=0 ncol(p*16+i,1)=18+i*3 ncol(p*16+i,2)=18+i*3 case 3 '==> gray ncol(p*16+i,0)=18+i*3 ncol(p*16+i,1)=18+i*3 ncol(p*16+i,2)=18+i*3 end select next i next p 'draw boxes with invisible lines and paint for i=0 to 15 call NewPalette(i,0) next i ybox=16 for i=0 to 15 xi=72+i*32 line(xi,ybox+2)-step(30,2*ybox),15,b paint(xi+15,ybox+4),i,15 next i 'and make every things visible for i=0 to 15 call NewPalette(i,i) next i '===========>>> set colors on the screen locate 7,1 print" DAC-INDEX "; print" Red Green Blue" for countcol=0 to 3 locate 1,35 print whichcol$(countcol) for col=0 to 15 ' w!=timer ' while timer set the default data and colors <****** call SetNewDac(dac(),63) 'default data in DAC for i=0 to 15 '========================>>> default colors in AC call NewPalette(i,ac(i)) next i locate 5,20 print"The palette is set to the default colors." locate 7,20 print"The DAC data is set to the default values." call NextKeyHit(18,31,"end") endprog: cls screen 0 w!=timer 'prevent screen flicker while timer