home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progbas / hgclib.arj / HGCLIB.BAS next >
Encoding:
BASIC Source File  |  1991-03-29  |  3.0 KB  |  166 lines

  1. sub const
  2.  %index=&h03b4
  3.  %cntrl=&h03b8
  4.  %config=&h03bf
  5.  %scr.on=&h08
  6.  %pageseg=&hb800
  7. end sub
  8.  
  9. sub htext
  10.  rem set mode to full
  11.  out %config,3
  12.  rem set to text
  13.  out %cntrl,0
  14.  rem initialise the 6845
  15.  out %index,0
  16.  out %index+1,97
  17.  out %index,1
  18.  out %index+1,80
  19.  out %index,2
  20.  out %index+1,82
  21.  out %index,3
  22.  out %index+1,15
  23.  out %index,4
  24.  out %index+1,25
  25.  out %index,5
  26.  out %index+1,6
  27.  out %index,6
  28.  out %index+1,25
  29.  out %index,7
  30.  out %index+1,25
  31.  out %index,8
  32.  out %index+1,2
  33.  out %index,9
  34.  out %index+1,13
  35.  out %index,10
  36.  out %index+1,&h0d
  37.  out %index,11
  38.  out %index+1,&h0c
  39.  rem turn display on page 0
  40.  out %cntrl,&h28
  41. end sub
  42.  
  43. sub hgraph
  44.  rem set mode to full
  45.  out %config,3
  46.  rem set graphics with screen off
  47.  out %cntrl,2
  48.  rem initialise the 6845
  49.  out %index,0
  50.  out %index+1,&h35
  51.  out %index,1
  52.  out %index+1,&h2d
  53.  out %index,2
  54.  out %index+1,&h2e
  55.  out %index,3
  56.  out %index+1,&h07
  57.  out %index,4
  58.  out %index+1,&h5b
  59.  out %index,5
  60.  out %index+1,&h02
  61.  out %index,6
  62.  out %index+1,&h57
  63.  out %index,7
  64.  out %index+1,&h57
  65.  out %index,8
  66.  out %index+1,&h02
  67.  out %index,9
  68.  out %index+1,&h03
  69.  out %index,10
  70.  out %index+1,&h00
  71.  out %index,11
  72.  out %index+1,&h00
  73.  rem screen on page 1
  74.  out %cntrl,10+128
  75. end sub
  76.  
  77. sub hclr
  78.  def seg=%pageseg
  79.  for i%=0 to &h7fff-361
  80.   poke i%,&h00
  81.  next i%
  82. end sub
  83.  
  84. sub hpset(x%,y%,c%)
  85.  def seg=%pageseg
  86.  if x%<0 or x%>719 then exit sub
  87.  if y%<0 or y%>347 then exit sub
  88.  a%=&h2000*(y% mod 4)+90*(y%\4)+x%\8
  89.  b%=7-(x% mod 8)
  90.  m%=exp2(b%)
  91.  d%=peek(a%)
  92.  if c%=0 then d%=d% and (not m%) else d%=d% or m%
  93.  poke a%,d%
  94. end sub
  95.  
  96. sub hline(x1%,y1%,x2%,y2%,c%)
  97.  if x1%>x2% then swap x1%,x2%:swap y1%,y2%
  98.  if abs(y2%-y1%)<(x2%-x1%) then
  99.   s=(y2%-y1%)/(x2%-x1%)
  100.   y=y1%
  101.   for x%=x1% to x2%
  102.    y%=int(y)
  103.    call hpset(x%,y%,c%)
  104.    y=y+s
  105.   next x%
  106.  else
  107.   s=(x2%-x1%)/(y2%-y1%)
  108.   x=x1%
  109.   for y%=y1% to y2%
  110.    x%=int(x)
  111.    call hpset(x%,y%,c%)
  112.    x=x+s
  113.   next y%
  114.  end if
  115. end sub
  116.  
  117. sub hbox(x1%,y1%,x2%,y2%,c%)
  118.  if x1%>x2% then swap x1%,x2%
  119.  for x%=x1% to x2%
  120.   call hpset(x%,y1%,c%)
  121.   call hpset(x%,y2%,c%)
  122.  next x%
  123.  if y1%>y2% then swap y1%,y2%
  124.  for y%=y1% to y2%
  125.   call hpset(x1%,y%,c%)
  126.   call hpset(x2%,y%,c%)
  127.  next y%
  128. end sub
  129.  
  130. sub hcircle(a%,b%,r%,e,c%)
  131.  inc=1/r%
  132.  ic=cos(inc):is=sin(inc)
  133.  x=r%:y=0
  134.  call hpset(a%-int(x),b%+int(y*e),c%)
  135.  call hpset(a%+int(x),b%+int(y*e),c%)
  136.  for t=0 to 3.14156/2 step inc
  137.   z=x
  138.   x=x*ic-y*is
  139.   y=z*is+y*ic
  140.   call hpset(a%+int(x),b%+int(y*e),c%)
  141.   call hpset(a%-int(x),b%+int(y*e),c%)
  142.   call hpset(a%+int(x),b%-int(y*e),c%)
  143.   call hpset(a%-int(x),b%-int(y*e),c%)
  144.  next t
  145. end sub
  146.  
  147. sub hprint(r%,c%,s$)
  148.  if len(s$)=0 then exit sub
  149.  if r%>33 then exit sub
  150.  for j%=1 to len(s$)
  151.   ch%=asc(mid$(s$,j%,1))
  152.   p%=ch%*8
  153.   l%=r%*10
  154.   for i%=0 to 7
  155.    def seg=&hf000
  156.    b%=peek((&hfa6e+p%+i%))
  157.    rem def seg=%pageseg
  158.    rem b%=peek(&hfa6e+p%+i%))
  159.    def seg=%pageseg
  160.    a%=&h2000*((l%+i%) mod 4)+((l%+i%)\4)*90+c%+j%-1
  161.    if a%<&h7fff-361 then poke a%,b%
  162.   next i%
  163.  next j%
  164. end sub
  165.  
  166.