'===========================================================================
' Subject: PLAYING WITH GET/PUT AND DAC       Date: 03-17-99 (13:15)       
'  Author: Jacob Wieles                       Code: QB, QBasic, PDS, PB    
'  Origin: jacwls@worldonline.nl            Packet: EGAVGA.ABC
'===========================================================================
'program         : DACAC12D    (16-03-99)
'                  Playing with get, put and change data DAC.
'                  See how many colors you have for making
'                  a 16 color palette.  (Even with PowerBASIC)
'auteur          : Jacob Wieles
'basic ?         : PowerBASIC and Q(uick)BASIC

defint a-z
Esc=27:Ent=13

sub NewPalette(attr,col)
  dummy=inp(&H3DA)
  out &H3C0,attr and 15
  out &H3C0,col and 63
  out &H3C0,32
end sub

sub SetNewColor(index,R,G,B)
  out &H3C8,index
  out &H3C9,R and 63
  out &H3C9,G and 63
  out &H3C9,B and 63
end sub
cls
screen 12
w!=timer
while timer<w!+1:wend
for i=0 to 15             'set attr-col (0-15)-(0-15) for PowerBASIC
  call NewPalette(i,i)
next i
call SetNewColor(0,21,42,21)  'set new background
call SetNewColor(15,0,0,0)    'set new foreground
ax=200:ay=200
bx=100:by=40
for i=0 to 9
  line(bx+i*10,by+i*10)-(bx+ax-i*10,by+ay-i*10),1+i,bf
next i
dm=2+int((ax*4+7)/8*ay):dim fig(dm-1)
get(bx,by)-(bx+ax,by+ay),fig
while inkey$<>"":wend
locate 1,2
print"Hit a key for (put,xor) the picture.  "
hitakey$=input$(1)
locate 1,1:print space$(78)

for i=1 to 20
  put(bx+i*10,by+i*10),fig,xor
next i
while inkey$<>"":wend
locate 1,25
print"      Hit a key for start       "
begin$=input$(1)

R=21:B=62:G=42:R1=21:G1=42:B1=21          'start colors
RF=+1:BF=+1:GF=+1:R1F=+1:B1F=+1:GF1=+1    'values change colors
do
  locate 1,25
  print"      Hit a key for stop.     "
  do while inkey$=""
    R=R+RF:if R=63 or R=0 then RF=-RF
    G=G-GF:if G=63 or G=0 then GF=-GF
    B=B+BF:if B=63 or B=0 then BF=-BF
    R1=R1-R1F:if R1=10 or R1=50 then R1F=-R1F
    B1=B1+B1F:if B1=10 or B1=50 then B1F=-B1F
    G1=G1-G1F:if G1=10 or G1=50 then G1F=-G1F
    call SetNewColor(1,R,G,B)
    call SetnewColor(2,G,B,R)
    call SetnewColor(3,B,R,G)
    call SetnewColor(4,B,G,R)
    call SetNewColor(5,R,B,G)
    call SetNewColor(6,G,R,B)
    call SetNewColor(7,R1,R,B1)
    call SetNewColor(8,R,G1,B1)
    call SetNewColor(9,B1,G,R1)
    call SetNewColor(0,R1,G1,B1)
    w!=timer
    while timer<w!+.05:wend
  loop
  locate 1,25
  print"Enter for go on. Esc for stop."
  do
    choice=asc(input$(1))
  loop until choice=Esc or choice=Ent
loop while choice=Ent
cls
screen 0
print"  Tanks for running. Hit a key for the source."
end
