home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progbas / baswind4.arj / FASTPRT.ASM < prev    next >
Assembly Source File  |  1987-12-27  |  5KB  |  103 lines

  1.  
  2. bios_data         segment     at 40H      ; set up labels to determine whether
  3.                   org         10H         ; to display in color or monochrome
  4. equip_flag        label       word
  5.                   org         4AH         ; 40 or 80 column display
  6. crt_clms          label       word
  7.                   org         63H
  8. addr_6845         label       word        ; pointer to video card ports
  9. bios_data         ends
  10.  
  11. igroup            group       FASTPRT_text
  12.                   assume      cs:igroup
  13.                   public      FASTPRT
  14. FASTPRT_text      segment     word public 'CODE'
  15. FASTPRT           proc        far
  16.                   push        bp            ; save BP for far return
  17.                   mov         bp,sp         ; point to arguments on stack
  18.                   push        es            ; must save for BASIC
  19.                   push        di
  20.                   push        si 
  21.                   mov         bx,[bp+8]     ; get addr of COL% storage
  22.                   mov         di,[bx]       ; get the column value
  23.                   dec         di            ; adjust for LOCATE format
  24.  
  25.                   mov         bx,[bp+10]    ; get addr of ROW% storage
  26.                   mov         ax,[bx]       ; get the row value
  27.                   dec         ax            ; adjust for LOCATE format
  28.  
  29.                   mov         bx,[bp+12]    ; set ptr to string descriptor
  30.                   mov         cx,[bx]       ; get length of string
  31.                   jcxz        exit          ; Done if null string
  32.                   mov         si,[bx+2]     ; SI = first character of VAR$
  33.  
  34.                   mov         bx,bios_data  ; set ready to determine video card
  35.                   mov         es,bx         ; and number of columns
  36.                   mul         es:crt_clms   ; AX = COL% times words per line
  37.                   add         di,ax         ; DI = words from start of screen
  38.                   shl         di,1          ; shift for attribute byte
  39.  
  40. ;       CX has the count of characters to write
  41. ;       SI points to the string to print
  42. ;       DI points to the starting screen position
  43.  
  44.                   mov         ax,0B000H          ;default to mono card
  45.                   mov         bx,es:equip_flag
  46.                   and         bx,30H
  47.                   cmp         bx,30H             ; monochrome?
  48.                   je          mono               ; jump if so
  49.                   mov         ax,0B800h          ; set to color card
  50.                   mov         dx,es:addr_6845    ; point to 6845 base port
  51.                   add         dx,6               ; point to status port
  52.                   mov         bx,[bp+6]          ; get color attribute
  53.                   mov         bx,[bx]
  54.                   mov         es,ax              ; point ES to video
  55.  
  56.                   call        print_string
  57.  
  58.                   jmp         exit
  59.  
  60. mono:             mov         dx,es:addr_6845    ; point to 6845 base port
  61.                   add         dx,6               ; point to status port
  62.                   mov         bx,[bp+6]          ; get color attribute
  63.                   mov         bx,[bx]
  64.                   mov         es,ax              ; point ES to video
  65.  
  66. movestr:          movsb                          ; print a character
  67.                   mov        es:[di],bl          ; move attribute
  68.                   inc        di                  ; skip attribute byte
  69.                   loop       movestr             ; repeat until end of string
  70. exit:
  71.                   pop         si
  72.                   pop         di
  73.                   pop         es
  74.                   pop         bp
  75.                   ret         8
  76. FASTPRT           endp
  77.  
  78. Print_string      proc       near                ; wait for horizontal retrace
  79.                   cli                            ; turn off interrupts
  80. test_low:         in         al,dx               ; get status
  81.                   test       al,1                ; is it low?
  82.                   jnz        test_low            ; if not, try again
  83. test_hi:          in         al,dx               ; get status
  84.                   test       al,1                ; is it high?
  85.                   jz         test_hi             ; if not, try again
  86.                   movsb                          ; print a character
  87. tst_low2:         in         al,dx               ; get status
  88.                   test       al,1                ; is it low?
  89.                   jnz        tst_low2            ; if not, try again
  90. tst_hi2:          in         al,dx               ; get status
  91.                   test       al,1                ; is it high?
  92.                   jz         tst_hi2             ; if not, try again
  93.                   mov        es:[di],bl          ; move attribute
  94.                   inc        di                  ; skip attribute byte
  95.                   loop       test_low            ; repeat until end of string
  96.                   sti                            ; turn interrupts back on
  97.                   ret                            ; return to the FASTPRT procedure
  98. Print_string      endp
  99.  
  100. FASTPRT_text      ends
  101.                   end
  102. 
  103.