home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / graf / iconmakr.zip / DOTGRAPH.TXT next >
Text File  |  1985-10-17  |  6KB  |  129 lines

  1.  
  2.                   SIXTEEN COLOR DOT GRAPHICS FOR THE PC
  3.  
  4.     The  PC junior is the only member of the IBM PC family  that  can 
  5.     produce  the 16 color all points addressable 320 by 200  graphics 
  6.     without  the  recently  announced but  scarce  enhanced  graphics 
  7.     boards.   It seems at best that the PC will produce only a choice 
  8.     of two sets of 4 colors in an all points addressable mode.  I was 
  9.     working on a program that required graphics and wanted it to work 
  10.     on  all IBM PC machines and found a compromise that I would  like 
  11.     to share with you in this short note. 
  12.  
  13.     I  found  that the Junior has a mode that displays all 16  colors 
  14.     in  160  by 200 resolution.  It requires 16000 bytes  of  display 
  15.     memory  since each byte contains two 4 bit nibbles of color  data 
  16.     to  display two such elongated dots.   In order to make  anything 
  17.     look  well  with  that mode however,  the dots must  actually  be 
  18.     displayed  two at a time  to produce square pixels thus  reducing 
  19.     to  a  160  by 100 display mode of  16  colors.   With  a  little 
  20.     experimenting  I was able to do this on the PC as well and in  so 
  21.     doing,  utilized the same code on both without using the ROM BIOS 
  22.     support provided on the Junior.
  23.  
  24.     It  seems  that  the only way to get 16  colors  with  the  color 
  25.     display adapter is to be in one of the color text modes.  This is 
  26.     the  only clue you need to proceed.   Notice that there are  some 
  27.     special  non ASCII characters displayed with codes from 80 to  FF 
  28.     hex.   One  of  those  codes is DE hex or 222  decimal  and  will 
  29.     display  an  80 column character with the left half that  of  the 
  30.     foreground  color  and  the  right  half  the  background  color.  
  31.     Fortunately both colors are defined in the attribute byte so that 
  32.     the  left and right halves can be  controlled  separately.   This 
  33.     produces  a  160  by 25 display that is dot addressable  with  16 
  34.     colors.   Notice  that we have used two bytes for  each  adjacent 
  35.     pair so that only one fourth of the display memory is used.
  36.  
  37.     Now for the tricky part.  By getting into debug and experimenting 
  38.     with  the 6845 video controller registers I was able to get  some 
  39.     rather interesting effects.   I have been told that you can cause 
  40.     damage to the video system by doing the wrong thing here so I was 
  41.     cautious.   What I wanted was a squish in the vertical  direction 
  42.     by a factor of four.  Therefore, after setting up for the 80 X 25 
  43.     color graphics text mode,  I knew that something might be done to 
  44.     the  6845 registers that controlled the vertical  characteristics 
  45.     of  the  display  if it were to be possible at  all.   These  are 
  46.     R4,R5,R6, and R7.  Then too there is R9 which has something to do 
  47.     with the scan line count per character.  In the 80 character mode 
  48.     register  4  contains 31 meaning that there is provision  for  31 
  49.     rows  not the 25 that we might expect.   This means  simply  that 
  50.     there  are  6  rows  to provide for the  vertical  retrace  time.  
  51.     Register  6 contains the expected 25 and register 7  contains  28 
  52.     which  is the vertical sync position.   This set up allows for  3 
  53.     undisplayed rows,  25 display rows and finally 3 undisplayed rows 
  54.     at  the bottom.   Meanwhile register 9 contains 7 which  actually 
  55.     allocates  scans  zero to 7 for a total of 8 scan lines per  row.  
  56.     The  total count on the scan lines is 248 with only 200  of  them 
  57.     actually displayed.
  58.  
  59.  
  60.  
  61.  
  62.                                     1
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.     Thus assign 124 to register 4, 100 to register 6, 112 to register 
  70.     7,  and 1 to register 9.   There will be 124 rows with 12 at  the 
  71.     top  and bottom.   Each row has two scan lines for a total of 248 
  72.     scan  lines with only 200 of them actually displayed.   While  in 
  73.     debug I tried this and found that all of my 80 column text showed 
  74.     only  the top two scan lines but that I could display about  four 
  75.     times as many of them.   So that is the  solution.   Actually,  I 
  76.     coded  it in assembly language but to communicate  here,  I  will 
  77.     include a short segment of basic which does the same thing.   The 
  78.     assembly  language program is much much faster than this routine.  
  79.  
  80.     10 WIDTH "SCRN:" 80                 ' 80 COLUMN MODE
  81.     20 SCREEN 0,1,0,0                   ' COLOR MODE
  82.     30 OUT &H3D8,9                      ' DISABLES BLINK BIT
  83.     40 DEF SEG = &HB800                 ' COLOR DISPLAY AREA
  84.     50 FOR I = 0 TO 80*100*2 STEP 2     ' FILL "SCREEN"
  85.     60 POKE I,222                       ' HALF AND HALF CHAR
  86.     70 POKE I + 1,0                     ' BLACK ON BLACK
  87.     80 NEXT I
  88.     90 OUT &H3D4,4                      ' R4  SELECTED
  89.     100 OUT &H3D5,124                   ' R4  VERTICAL TOTAL
  90.     110 OUT &H3D4,6                     ' R6  SELECTED
  91.     120 OUT &H3D5,100                   ' R6  VERTICAL DISPLAYED
  92.     130 OUT &H3D4,7                     ' R7  SELECTED
  93.     140 OUT &H3D5,112                   ' R7  VERTICAL SYNC
  94.     150 OUT &H3D4,9                     ' R9  SELECTED
  95.     160 OUT &H3D5,1                     ' R9  SCAN LINES (2)
  96.  
  97.  
  98.     Statement  number 40 is necessary to disable the blink else color 
  99.     codes larger than 7 produce a blinking display.  Now you have all 
  100.     of  the screen filled with black foreground and black  background 
  101.     "dots".   To  draw  a line of yellow dots in  column  25  without 
  102.     changing the other dot color in column 24, write:
  103.  
  104.     1000 FOR I = 0 TO 100
  105.     1010 A = I * 160 + (25\2) * 2 + 1    ' LOCATION OF ATTRIBUTE
  106.     1020 N = PEEK(A)                     ' GET ATTRIBUTE BYTE
  107.     1030 POKE A,(N AND &HF0) OR &H0E     ' CHANGE DOT TO YELLOW
  108.     1040 NEXT I
  109.  
  110.     When  you  exit  this program you will not be able  to  read  the 
  111.     display  messages because of being in this strange graphics mode.  
  112.     Just set the width to 40 to see what you are doing.
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                                 2
  129.