home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / qkwrite.zip / QKWRITE.ASM
Assembly Source File  |  1987-02-22  |  3KB  |  107 lines

  1. ; QKWRITE.ASM    
  2. ;
  3. ; by Dirk Lesko 
  4. ;
  5. ; Copyright (c) 1987 Dirk Andrew Lesko, All Rights Reserved
  6. ; * modified from a version by Michael Brill
  7. ;
  8.     PAGE     60,132
  9.         PUBLIC  QKWRITE    
  10.     extrn     _ret:far
  11.     include extenda.mac
  12. ;***************************************************
  13. dl_code segment byte public
  14.     assume     cs:dl_code,ds:nothing,es:nothing 
  15. ;---------------------------------------------------
  16. ;
  17. ;       Syntax: call qkwrite with <expN>,<expN>,<expC>,<expN>
  18. ;       Return: nothing
  19. ;       Params: <expN> - integer row
  20. ;        <expN> - integer col
  21. ;        <expC> - character string
  22. ;        <expN> - integer attribute
  23. ;
  24. ;       Notes :    none
  25. ;         
  26. ;                       
  27. ;
  28. ;-----------------
  29. QKWRITE    PROC      FAR
  30.     
  31.     push    bp        ;save
  32.     mov    bp,sp        ;
  33.     push    ds        ; Clippers
  34.     push    es        ;  registers
  35.       
  36.     get_pcount        ;how many params ?
  37.     cmp    ax,4        ;are their 4 ?
  38.     je    _cont        ; yes, go on
  39.     jmp    _done        ;  no go home
  40. _cont:
  41.     get_int 4        ;get attribute
  42.     push    ax        ; save it
  43.     get_char 3        ;get string
  44.     push    bx        ; and
  45.     push    ax        ; save it
  46.     get_int 2        ;get col
  47.     push    ax        ; save it
  48.     get_int 1        ;get row
  49.     push    ax        ; save it
  50.  
  51.     pop    ax        ;get row
  52.     mov    bl,160        ;160 bytes per row 
  53.     mul    bl        ; so multiply by that amount    
  54.     pop    cx        ;get column
  55.     shl    cx,1            ; ready it for screen offset
  56.     add    cx,ax        ; this is our offset into screen buffer
  57.     mov    di,cx        ;  di is dest. index of screen buffer
  58.     pop    ds        ;get string segment
  59.     pop    si        ;get string offset
  60.  
  61.     mov    ax,0b000h    ;assume mono 
  62.     mov    es,ax        ; screen buffer
  63.     cld            ;clear out the direction flag
  64.  
  65.     mov    ah,15        ;lets check monitor type
  66.     int    10h        ;video interrupt
  67.     cmp    al,7        ;is this mono?
  68.     pop    ax        ;(sneak the attribute in here)
  69.     xchg    ah,al        ; (and put it into ah)
  70.     je    _mono        ; if mono, go write the string 
  71.     mov    bx,0b800h    ;  otherwise, setup for color
  72.     mov    es,bx        ;   screen buffer
  73.     mov    dx,3dah        ;check this port for vertical retrace
  74.     jmp short _color    ;continue on for color 
  75.  
  76. _mono:    lodsb            ;get next byte of string, put in al
  77.     cmp    al,0        ;if null, end of string....
  78.     jz    _done         ;....so return to caller 
  79.     cmp    di,4000        ;if end of screen buffer.....
  80.     ja      _done        ;....return to caller too
  81.     stosw            ;if not null, word byte to monitor ram
  82.     jmp    _mono         ;and return for the next character
  83. _color:
  84.     in     al,dx          ;read in vertical retrace status
  85.     test    al,8        ;if retrace bit is set on....
  86.     je     _color         ;....go back and re-poll bit
  87.     lodsb            ;get next byte from string, put in al
  88.     cmp    al,0        ;if null, end of string......
  89.     jz    _done         ;....so return to caller 
  90.     cmp    di,4000        ;are we at the end of the screen?
  91.     ja    _done        ; yes, so we're done
  92.     stosw              ;otherwise, write word to monitor ram
  93.     jmp    _color        ;and return for the next character
  94. _done:
  95.     pop    es        ;restore
  96.     pop     ds        ; Clippers
  97.     pop     bp        ;  registers
  98.  
  99.     call _ret        ;let Clipper check stack
  100.     ret            ;far return to Clipper
  101. QKWRITE    ENDP
  102. ;-----------------------------------------------------------
  103. dl_code ends 
  104. ;***********************************************************
  105.         END  
  106.