home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB140 / grlib03a.arj / ASSERT.ASM < prev    next >
Assembly Source File  |  1988-12-08  |  12KB  |  298 lines

  1. PAGE ,132
  2. TITLE ASSERT.ASM
  3. ;UPDATE HISTORY:
  4. ;===============
  5. ;14/11/84  convert to v2 ci86
  6. ;29/11/84  fix bug in repl mode
  7. ; 4 dec 84 move PATTERN.ASM into this program
  8. ;27 Dec 84 move delay loop from gdc_nb to fifo_mt
  9. ;26 Apr 85 add enb_gr and dis_gr
  10.  
  11.     include    asmc.h
  12.  
  13.     SEGEND    CODE
  14.  
  15.     SEGDEF    DATA
  16. include asmd.h
  17.     SEGEND    DATA
  18.  
  19.     SEGDEF    CODE
  20.  
  21. PUBLIC    gdc_nb, fifo_mt, g_off, g_on, a_mode
  22. PUBLIC    a_fgbg, a_alups, a_gbmsk, a_wmode
  23. PUBLIC    enb_gr, dis_gr, a_patrn
  24.  
  25.  
  26. ;********************************************************************
  27. ;*                                                                  *
  28. ;*      f u n c t i o n     gdc_nb()                                *
  29. ;*                                                                  *
  30. ;*      gdc_not_busy will put a harmless command into the GDC and   *
  31. ;*      wait for the command to be read out of the command FIFO.    *
  32. ;*      This means that the GDC is not busy doing a write or read   *
  33. ;*      operation.                                                  *
  34. ;*                                                                  *
  35. ;*      entry:          none                                        *
  36. ;*      exit:           ax = 0 if more than approx 74ms elapsed     *
  37. ;*                      without "gdc not busy"                      *
  38. ;********************************************************************
  39.  
  40.     PROCDEF gdc_nb
  41.     call    fifo_mt        ;wait for fifo to empty
  42. L2:     in      al,56H         ;wait for vert. or horiz. sync
  43.     and     al,60H
  44.     jz      L2
  45.     in      al,56H
  46.     and     al,8        ;is GDC still drawing ?
  47.     jnz     L2
  48.  
  49.     ret                     ;ax = 1  ==  TRUE
  50.     PROCEND gdc_nb
  51.  
  52. ;This routine is in as a fast check that the GDC's fifo is empty but does
  53. ;not check anything else.
  54.  
  55.     PROCDEF  fifo_mt
  56.     push    cx              ;use cx as a time-out loop counter.
  57.     mov     cx,8000H       ;wait for FIFO not full or reasonable time.
  58. L0:     in    al,56H        ;first check if the FIFO is full.
  59.     and     al,2
  60.     loopnz  L0
  61.  
  62.     mov     ax,46FH
  63.     out     57H,al
  64. L5:     in      al,56H
  65.     test    al,ah
  66.     jz      L5
  67.     pop     cx
  68.     ret
  69.     PROCEND  fifo_mt
  70.  
  71. ;********************************************************************
  72. ;*                                                                  *
  73. ;*      f u n c t i o n      g_off()                                *
  74. ;*                                                                  *
  75. ;*      purpose:        disable graphics output                     *
  76. ;*                                                                  *
  77. ;********************************************************************
  78.  
  79.     PROCDEF  g_off
  80. exit_graf:
  81.     call    dis_gr
  82.     and    BYTE PTR gbmod,7FH  ;disable graphics output in gbmod
  83.     call    a_mode             ;assert new mode register
  84.     mov    al,83H
  85.     out    0AH,al               ;turn off graphics on monochrome line
  86.     ret
  87.     PROCEND  g_off
  88.  
  89. ;********************************************************************
  90. ;*                                                                  *
  91. ;*      f u n c t i o n      g_on()                                 *
  92. ;*                                                                  *
  93. ;*      purpose:        enable graphics output                      *
  94. ;*                                                                  *
  95. ;********************************************************************
  96.  
  97.     PROCDEF  g_on
  98. enter_graf:
  99.     call    enb_gr
  100.     mov     al,BYTE PTR ws_type    ;chk work_station loaded 
  101.     or      al,al
  102.     jz      Leg
  103.     mov    al,87H
  104.     out    0AH,al                   ;enable graphics on monochrome line
  105.     or    BYTE PTR gbmod,80H      ;enable graphics output in gbmod
  106.     jmp    a_mode
  107. Leg:    ret
  108.     PROCEND  g_on
  109.  
  110. ;********************************************************************
  111. ;*                                                                  *
  112. ;*      f u n c t i o n s     a_mode()                              *
  113. ;*                                                                  *
  114. ;*      purpose:        set mode register to the value held in      *
  115. ;*                      gbmod                                       *
  116. ;*                                                                  *
  117. ;********************************************************************
  118.  
  119.     PROCDEF  a_mode
  120.     mov     al,0BFH ;address the mode register through 
  121.     out     53H,al          ;the indirect register
  122.     mov     al,BYTE PTR gbmod
  123.     out     51H,al          ;load the mode register
  124.     ret
  125.     PROCEND  a_mode
  126.  
  127. ;*****************************************************************************
  128. ;*                                                                           *
  129. ;*       f u n c t i o n     a_fgbg()                                        *
  130. ;*                                                                           *
  131. ;*       purpose:        Load the Foreground;Background Register             *
  132. ;*                                                                           *
  133. ;*****************************************************************************
  134.  
  135.     PROCDEF  a_fgbg
  136.     mov    al, 0F7H    ;select the Foreground;Background Register
  137.     out    53H, al
  138.     mov    al, BYTE PTR fgbg
  139.     out    51H, al        ;load the Foreground;Background Register
  140.     ret
  141.     PROCEND  a_fgbg
  142.  
  143. ;*****************************************************************************
  144. ;*                                                                           *
  145. ;*       F U N C T I O N    a_alups()                                        *
  146. ;*                                                                           *
  147. ;*       purpose:        Set the ALU ; Plane Select Register                 *
  148. ;*                                                                           *
  149. ;*****************************************************************************
  150.  
  151.     PROCDEF  a_alups
  152.     mov    al,0EFH       ;select the ALU;PS Register
  153.     out    53H,al
  154.     mov    al, BYTE PTR alups      ;move ALU;PS value to al
  155.     out    51H,al         ;load value into ALU;PS Register
  156.     ret
  157.     PROCEND  a_alups
  158.  
  159. ;*****************************************************************************
  160. ;*                                                                           *
  161. ;*       F U N C T I O N    a_gbmsk()                                        *
  162. ;*                                                                           *
  163. ;*       purpose:        Set the graphics board mask to values held          *
  164. ;*                       in gbmskl and gbmskh                                *
  165. ;*                                                                           *
  166. ;*****************************************************************************
  167.  
  168.     PROCDEF  a_gbmsk
  169.     mov    ax,WORD PTR gbmskl      ;get the mask value to load
  170.     out    54H,al
  171.     mov    al, ah
  172.     out    55H,al
  173.     ret
  174.     PROCEND  a_gbmsk
  175.  
  176. ;*****************************************************************************
  177. ;*                                                                           *
  178. ;*       F U N C T I O N    a_wmode()                         *
  179. ;*                                                                           *
  180. ;*       purpose:       Juggle fgbg reg. & alups reg. to make GDC            *
  181. ;*                      write the correct colours in the correct             *
  182. ;*                      manner to the bit map.                               *
  183. ;*                                                                           *
  184. ;*****************************************************************************
  185.  
  186.     PROCDEF  a_wmode
  187.     push    bp
  188.     mov     bp,sp
  189.  
  190.     call    gdc_nb
  191.     mov     al,BYTE PTR ws_wmo      ;get the write mode requested.
  192.     cmp     al,3            ;check for erase mode.
  193.     jz      La0
  194.     mov     cl,4
  195.     shl     al,cl
  196.     mov     ah,BYTE PTR alups       ;get old alups
  197.     and     ah,0FH          ;mask off plane writes
  198.     or      al,ah           ;add to new write mode
  199.     mov     BYTE PTR alups,al       ;and save.
  200.     call    a_alups
  201.     mov     al,0F0H         ;enable fore_ground writes in case the last
  202.     jmp     La1             ;write mode was erase.
  203. La0:    mov     BYTE PTR alups,0  ;put alu into replace mode, all planes.
  204.     call    a_alups
  205.     xor     al,al           ;write zero's to all planes no matter what.
  206. La1:    mov     BYTE PTR fgbg,al
  207.     call    a_fgbg
  208.  
  209.     pop     bp
  210.     ret
  211.     PROCEND  a_wmode
  212.  
  213. ;*****************************************************************************
  214. ;*                                                                           *
  215. ;*       F U N C T I O N    enb_gr()                                         *
  216. ;*                                                                           *
  217. ;*       purpose: Enable graphics out to the screen. THIS IS NOT THE SAME AS *
  218. ;          g_on(), you are still in graphics mode             *
  219. ;*                                                                           *
  220. ;*****************************************************************************
  221.  
  222.     PROCDEF  enb_gr
  223.     call    gdc_nb
  224.     mov    al,0DH
  225.     out    57H,al
  226.     ret
  227.     PROCEND  enb_gr
  228.  
  229. ;*****************************************************************************
  230. ;*                                                                           *
  231. ;*       F U N C T I O N    dis_gr()                                         *
  232. ;*                                                                           *
  233. ;*       purpose: Disable graphics out to the screen. THIS IS NOT THE SAME AS*
  234. ;*          g_off(), you are still in graphics mode             *
  235. ;*                                                                           *
  236. ;*****************************************************************************
  237.  
  238.     PROCDEF  dis_gr
  239.     call    gdc_nb
  240.     mov    al,0CH
  241.     out    57H,al
  242.     ret
  243.     PROCEND  dis_gr
  244.  
  245. ;*****************************************************************************
  246. ;                                                                            *
  247. ;        f u n c t i o n    a_patrn()                                        *
  248. ;                                                                            *
  249. ;        purpose:       Load the Pattern Multiplier and Pattern Register     *
  250. ;                       for line drawing.                                    *
  251. ;                                                                            *
  252. ;        caution:       You must load the Pattern Multiplier before          *
  253. ;                       loading the Pattern Register                         *
  254. ;                                                                            *
  255. ;*****************************************************************************
  256. ;
  257. ;The following are some register values and the corresponding output patterns 
  258. ;when the repeat factor is:
  259. ;
  260. ;                 1            2                    3
  261. ;    0FFh         |--------|   |----------------|   |------------------------|
  262. ;    0AAh         |- - - - |   |--  --  --  --  |   |---   ---   ---   ---   |
  263. ;    0F0h         |----    |   |--------        |   |------------            |
  264. ;    0CDh         |--  -- -|   |----    ----  --|   |------      ------   ---|
  265. ;
  266.     PROCDEF    a_patrn
  267.     push    bx
  268.     push    cx
  269.  
  270.     mov     cl,BYTE PTR l_type
  271.     xor     ch,ch
  272.     add     cx,cx
  273.     lea     bx,  pattbl
  274.     add     bx,cx
  275.     mov     al,0FDH         ;select the Pattern Multiplier
  276.     out    53H, al
  277.     mov     al, 1[bx]
  278.     dec    al              ;adjust bl to be zero-relative
  279.     not    al              ;invert it [remember Pattern Register is
  280.                             ;multiplied by 16 minus multiplier value]
  281.     and     al,0FH          ;load the Pattern Multiplier 
  282.     out    51H, al
  283.  
  284.     mov     al,0FBH ;select the Pattern Register
  285.     out     53H, al
  286.     mov     al, [bx]        ;get the pattern data
  287.     out     51H, al ;load the Pattern Register
  288.  
  289.     pop     cx
  290.     pop     bx
  291.     ret
  292.     PROCEND    a_patrn
  293.  
  294.     include epilogue.h
  295.  
  296.     END
  297. 
  298.