home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / WNDTOOL5.ZIP / FASTPRT.ASM < prev    next >
Assembly Source File  |  1989-05-24  |  7KB  |  152 lines

  1. ;
  2. ;Title:Fastprt
  3.  
  4. BASIC_SETUP MACRO
  5.                PUSH    BP
  6.                MOV     BP,SP
  7.  
  8.                PUSH    AX
  9.                PUSH    BX
  10.                PUSH    DX
  11.                PUSH    CX
  12.                PUSH    SI
  13.                PUSH    DI
  14.                PUSH    DS
  15.                PUSH    ES
  16.                ENDM
  17.  
  18. BASIC_CLEANUP MACRO
  19.                CLD
  20.                POP     ES
  21.                POP     DS
  22.                POP     DI
  23.                POP     SI
  24.                POP     DX
  25.                POP     CX
  26.                POP     BX
  27.                POP     AX
  28.  
  29.                POP     BP
  30.                ENDM
  31.  
  32. Bios_data      SEGMENT  At 40H                                  ; set up labels to determine whether
  33.                ORG      10H                                     ; to display in color or monochrome
  34. Equip_flag     LABEL    WORD
  35.                ORG      4AH                                     ; 40 or 80 column display
  36. Crt_clms       LABEL    WORD
  37.                ORG      63H
  38. Addr_6845      LABEL    WORD                                    ; pointer to video card ports
  39. Bios_data      ENDS
  40.  
  41. ;
  42. Code           SEGMENT  BYTE PUBLIC 'CODE'
  43.                ASSUME   CS:Code,DS:Code
  44.  
  45.                PUBLIC   Fastprt
  46.  
  47. Fastprt        PROC     FAR
  48.                Basic_setup                                      ; save bp for far return
  49.  
  50.                MOV      BX,[BP+8]                               ; get addr of col% storage
  51.                MOV      DI,[BX]                                 ; get the column value
  52.                DEC      DI                                      ; adjust for locate format
  53.  
  54.                MOV      BX,[BP+10]                              ; get addr of row% storage
  55.                MOV      AX,[BX]                                 ; get the row value
  56.                DEC      AX                                      ; adjust for locate format
  57.  
  58.                MOV      BX,[BP+12]                              ; set ptr to string descriptor
  59.                MOV      CX,[BX]                                 ; get length of string
  60.                JCXZ     Exit                                    ; done if null string
  61.  
  62.                MOV      SI,[BX+2]                               ; si = first character of var$
  63.                MOV      BX,Bios_data                            ; set ready to determine video card
  64.                MOV      ES,BX                                   ; and number of columns
  65.                MUL      ES:Crt_clms                             ; ax = col% times words per line
  66.                ADD      DI,AX                                   ; di = words from start of screen
  67.                SHL      DI,1                                    ; shift for attribute byte
  68.  
  69. ;       CX has the count of characters to write
  70. ;       SI points to the string to print
  71. ;       DI points to the starting screen position
  72.  
  73.                MOV      AX,0B000H                               ;default to mono card
  74.                MOV      BX,ES:Equip_flag
  75.                AND      BX,30H
  76.                CMP      BX,30H                                  ; monochrome?
  77.                JE       Mono                                    ; jump if so
  78.  
  79.                MOV      AX,0B800H                               ; set to color card
  80.                MOV      DX,ES:Addr_6845                         ; point to 6845 base port
  81.                ADD      DX,6                                    ; point to status port
  82.                MOV      BX,[BP+6]                               ; get color attribute
  83.                MOV      BX,[BX]
  84.                MOV      ES,AX                                   ; point es to video
  85.  
  86.                CALL     Print_string
  87.  
  88.                JMP      Exit
  89.  
  90. mono:
  91.                MOV      DX,ES:Addr_6845                         ; point to 6845 base port
  92.                ADD      DX,6                                    ; point to status port
  93.                MOV      BX,[BP+6]                               ; get color attribute
  94.                MOV      BX,[BX]
  95.                MOV      ES,AX                                   ; point es to video
  96.  
  97. movestr:
  98.                MOVSB                                            ; print a character
  99.                MOV      ES:[DI],BL                              ; move attribute
  100.                INC      DI                                      ; skip attribute byte
  101.                LOOP     Movestr                                 ; repeat until end of string
  102. exit:
  103.                Basic_cleanup
  104.  
  105.                RET      8
  106. Fastprt        ENDP
  107.  
  108. ;
  109. Print_string   PROC     NEAR                                    ; wait for horizontal retrace
  110.                CLI                                              ; turn off interrupts
  111. test_low:
  112.                IN       AL,DX                                   ; get status
  113.                JMP      SHORT $+2
  114.  
  115.  
  116.                TEST     AL,1                                    ; is it low?
  117.                JNZ      Test_low                                ; if not, try again
  118. test_hi:
  119.                IN       AL,DX                                   ; get status
  120.                JMP      SHORT $+2
  121.                TEST     AL,1                                    ; is it high?
  122.                JZ       Test_hi                                 ; if not, try again
  123.  
  124.                MOVSB                                            ; print a character
  125.  
  126.                STI
  127.                NOP
  128.                CLI
  129.  
  130. tst_low2:
  131.                IN       AL,DX                                   ; get status
  132.                JMP      SHORT $+2
  133.                TEST     AL,1                                    ; is it low?
  134.                JNZ      Tst_low2                                ; if not, try again
  135. tst_hi2:
  136.                IN       AL,DX                                   ; get status
  137.                JMP      SHORT $+2
  138.                TEST     AL,1                                    ; is it high?
  139.                JZ       Tst_hi2                                 ; if not, try again
  140.  
  141.                MOV      ES:[DI],BL                              ; move attribute
  142.                INC      DI                                      ; skip attribute byte
  143.  
  144.                STI                                              ; turn interrupts back on
  145.                LOOP     PRINT_STRING                            ; repeat until end of string
  146.  
  147.                RET                                              ; return to the fastprt procedure
  148. Print_string   ENDP
  149.  
  150. Code           ENDS
  151.                END
  152.