home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / edit_dta.zip / QPRINT6.ASM < prev    next >
Assembly Source File  |  1986-04-18  |  5KB  |  224 lines

  1.         page    80,132
  2.         title    QPRINT5 - Place data directly into display buffer
  3.         name    qprint
  4.  
  5. ;   Segment, group definitions
  6.  
  7. qprint_code    segment para public 'CODESG'
  8.  
  9. dseg        segment word public 'DATASG'
  10.  
  11. dseg        ends
  12.  
  13. dgroup        group    dseg
  14.  
  15.         assume    cs:qprint_code,ds:dgroup
  16.  
  17. ;   Other definitions
  18.  
  19. argz        equ    6[bp]            ; Last arg
  20. argy        equ    8[bp]            ; Last arg but one
  21. argx        equ    10[bp]            ; Last arg but two
  22. argw        equ    12[bp]            ; Last arg but three
  23.  
  24.  
  25.         subttl    QPRINT - Direct video I/O
  26.         page    +
  27.  
  28.         comment &
  29.  
  30. ------------------------------------------------------------------------------
  31.  
  32. Name:        QPRINT
  33.  
  34. Description:    Print a string direct to video
  35.  
  36. Usage:        CALL QPRINT(A$,ROW%,CLM%,ATTR%)
  37.  
  38.         where    ATTR% (attribute) examples:
  39.         112    - reverse video
  40.         113    - underlined
  41.         135    - blinking
  42.         15    - high intensity
  43.         7    - normal
  44.  
  45. Authors:    Dan Rollins, Vern Buerg, Tom Neff
  46.  
  47. Revised:    Version 2q, Sept 2, 1984
  48.            Combined into ATORTS 21-Oct-85
  49.            Add /H conditional horizontal retrace delay 10-22-85
  50.         Version 2v, Dec 15, 1985
  51.            Make DESQview/Topview compatible
  52.  
  53. ------------------------------------------------------------------------------
  54.  
  55.         &
  56.  
  57. ; Map the BIOS data area variables we'll use
  58.  
  59. bios_data    segment at 40H            ; set up labels to determine
  60.  
  61.         org    10H            ; color or monochrome card
  62. equip_flag    label    word
  63.  
  64.         org    49H            ; 40 or 80 column display
  65. crt_mode    db    ?            ; CRT mode flag
  66. crt_clms    label    word
  67.  
  68.         org    63H
  69. addr_6845    label    word            ; points to video card ports
  70.  
  71. bios_data    ends
  72.  
  73. ; Here's the common flag for horizontal retrace delay --
  74. ; cleared by QPKHRD
  75.  
  76. do_wait     equ    0FFH
  77. dont_wait    equ    000H
  78.  
  79. hrd_flag    db    do_wait         ; Default setting
  80. init_flag    db    0            ; First time init switch
  81. pad_seg     dw    0            ; Seg addr of video buffer/pad
  82. pad_offset    dw    0            ; -offset addr
  83. card_addr    dw    0            ; Addr of video card
  84.  
  85.         even
  86.  
  87. ;        Rejoin CODE and start the public routine
  88.  
  89.         assume    es:bios_data
  90.  
  91.         public    qprint
  92. qprint        proc    far
  93.  
  94.         push    bp
  95.         mov    bp,sp            ; point to arguments on stack
  96.  
  97.         mov    bx,argy         ; get addr of CLM% storage
  98.         mov    di,[bx]         ; get the column value
  99.         dec    di            ; adjust for LOCATE format
  100.  
  101.         mov    bx,argx         ; get addr of ROW% storage
  102.         mov    ax,[bx]         ; get the screen line value
  103.         dec    ax            ; adjust for LOCATE format
  104.  
  105.         mov    bx,argw         ; get ptr to string descriptor
  106.         mov    ch,0            ; clear hi-byte
  107.         mov    cl,[bx]         ; get length of string
  108.         cmp    cl,0            ; null string?
  109.         jne    get_display
  110.         jmp    exit2            ; if so,do nothing, Else,
  111. get_display:
  112.         mov    si,2[bx]        ; SI => 1st character of VAR$
  113.  
  114.         mov    bx,bios_data        ; get ready to determine card type
  115.         mov    es,bx            ; and number of columns
  116.         mul    crt_clms        ; AX = CLM% * words per line
  117.         add    di,ax            ; DI = words from start of screen
  118.         shl    di,1            ; adjust for attribute bytes
  119.  
  120. ;   CX has the count of characters to write,
  121. ;   SI points to the string data,
  122. ;   DI points to a screen position
  123.  
  124.         cmp    init_flag,0        ; already have video stuff?
  125.         jne    skip_init        ; yup, neato
  126.         mov    init_flag,1
  127.         mov    dx,addr_6845        ; point to 6845 base port
  128.         add    dx,6            ; point to status port
  129.  
  130.         mov    ax,0B800H        ; default to color card
  131. ;;        mov    bx,equip_flag
  132. ;;        and    bx,30H
  133.         cmp    crt_mode,30H        ; is it monochrome?
  134.         jne    card_ok         ; no, go
  135.         mov    ax,0B000H        ; yes, set for monochrome
  136.         mov    hrd_flag,dont_wait    ;  and force /H
  137. card_ok:
  138.         push    cx
  139.         mov    pad_seg,ax        ; save display seg addr
  140.         mov    card_addr,dx
  141.         mov    cx,'DE'                 ; check for DV only
  142.         mov    dx,'SQ'
  143.         mov    ax,2b01h
  144.         int    21h
  145.         pop    cx
  146.         cmp    al,0ffh
  147.         je    skip_init
  148.  
  149.         push    di            ; get display addr from
  150.         sub    di,di            ;  desqview
  151.         mov    es,pad_seg        ; buffer segment
  152.         mov    ah,0feh
  153.         int    10h
  154.         mov    pad_seg,es        ; actual pad addr
  155.         mov    pad_offset,di
  156.         pop    di
  157. skip_init:
  158.         mov    bx,argz         ; Addr of ATTR%
  159.         mov    bh,0[bx]        ; Get the color value
  160.         mov    ax,pad_seg        ; seg addr of video buffer/pad
  161.         mov    es,ax            ; points ES:DI to video area
  162.         add    di,pad_offset
  163.         mov    dx,card_addr        ; addr of video port
  164.  
  165. ; DS points to BASIC variables area
  166. ; ES points to video card memory
  167. ; Now display VAR$ on the screen.
  168.  
  169.         call    print_string
  170.  
  171. exit2:
  172.         pop    bp
  173.         ret    8            ; intersegment return,
  174.                         ; clearing stack of 4 args
  175.  
  176. qprint endp
  177.  
  178. ;   This local routine displays a string of characters.
  179.  
  180. ;   DS:SI => first character of string
  181. ;   ES:DI => screen memory to display it
  182. ;      CX =  number of characters to display
  183. ;      DX => status port of video card
  184. ;      BL =  attribute character
  185.  
  186. print_string    proc    near
  187.  
  188.         lodsb                ; get next char
  189.         mov    bl,al            ; save char
  190.  
  191.         cmp    hrd_flag,dont_wait    ; Horiz retrace delay needed?
  192.         je    write_now        ; No, skip it
  193.  
  194. ; Wait for horizontal retrace
  195.  
  196.  
  197. test_low:
  198.         in    al,dx            ; get status
  199.         test    al,1            ; is it low?
  200.         jnz    test_low        ; no, keep checking
  201.         cli                ; turn off interrupts
  202.  
  203. test_hi:
  204.         in    al,dx            ; get status
  205.         test    al,1            ; is it high?
  206.         jz    test_hi         ; no, keep checking
  207.  
  208. ; okay to write to screen now (no 'hash')
  209.  
  210.  
  211. write_now:
  212.         mov    ax,bx            ; recover char and attr
  213.         stosw                ; char and attr to buffer
  214.         sti                ; turn interrupts back on
  215.         loop    print_string        ; do till end of string
  216.         ret                ; back to qprint proc
  217.  
  218. print_string    endp
  219.  
  220.  
  221. qprint_code    ends
  222.  
  223.         end
  224.