home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / baswind8.zip / FASTPRT.ASM < prev    next >
Assembly Source File  |  1990-09-14  |  6KB  |  166 lines

  1. ;
  2. ;Title:Fastprt          SEPT 1, 1990
  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. Stack          STRUC
  42. Bpsav          DW       ?                       ;saved by us
  43. Retoff         DW       ?                       ;from callf
  44. Retseg         DW       ?                       ;from basic
  45. Return_code    DW       ?                       ;
  46. Video_attr     DW       ?                       ;pointer to video attribute
  47. Column         DW       ?                       ;pointer to screen column
  48. Row            DW       ?                       ;pointer to screen row
  49. String         DW       ?                       ;pointer to string descriptor
  50. Stack          ENDS
  51.  
  52. ;
  53. Code           SEGMENT  BYTE PUBLIC 'CODE'
  54.                ASSUME   CS:Code,DS:Code
  55.  
  56.                PUBLIC   Fastprt
  57.  
  58. Fastprt        PROC     FAR
  59. Basic_setup                                     ; save bp for far return
  60.  
  61.                MOV      BX,[BP].Return_code
  62.                MOV      WORD PTR [BX],0
  63.  
  64.                MOV      BX,[BP].Column          ; get addr of col% storage
  65.                MOV      DI,[BX]                 ; get the column value
  66.                DEC      DI                      ; adjust for locate format
  67.  
  68.                MOV      BX,[BP].Row             ; get addr of row% storage
  69.                MOV      AX,[BX]                 ; get the row value
  70.                DEC      AX                      ; adjust for locate format
  71.  
  72.                MOV      BX,[BP].String          ; set ptr to string descriptor
  73.                MOV      CX,[BX]                 ; get length of string
  74.                JCXZ     Exit                    ; done if null string
  75.  
  76.                MOV      SI,[BX+2]               ; si = first character of var$
  77.                MOV      BX,Bios_data            ; set ready to determine video card
  78.                MOV      ES,BX                   ; and number of columns
  79.                MUL      ES:Crt_clms             ; ax = col% times words per line
  80.                ADD      DI,AX                   ; di = words from start of screen
  81.                SHL      DI,1                    ; shift for attribute byte
  82.  
  83. ;       CX has the count of characters to write
  84. ;       SI points to the string to print
  85. ;       DI points to the starting screen position
  86.  
  87.                MOV      AX,0B000H               ;default to mono card
  88.                MOV      BX,ES:Equip_flag
  89.                AND      BX,30H
  90.                CMP      BX,30H                  ; monochrome?
  91.                JE       Mono                    ; jump if so
  92.  
  93.                MOV      AX,0B800H               ; set to color card
  94.                MOV      DX,ES:Addr_6845         ; point to 6845 base port
  95.                ADD      DX,6                    ; point to status port
  96.                MOV      BX,[BP].Video_attr      ; get color attribute
  97.                MOV      BX,[BX]
  98.                MOV      ES,AX                   ; point es to video
  99.  
  100.                CALL     Print_string
  101.  
  102.                JMP      Exit
  103.  
  104. MONO:
  105.                MOV      DX,ES:Addr_6845         ; point to 6845 base port
  106.                ADD      DX,6                    ; point to status port
  107.                MOV      BX,[BP].Video_attr      ; get color attribute
  108.                MOV      BX,[BX]
  109.                MOV      ES,AX                   ; point es to video
  110.  
  111. MOVESTR:
  112.                MOVSB                            ; print a character
  113.                MOV      ES:[DI],BL              ; move attribute
  114.                INC      DI                      ; skip attribute byte
  115.                LOOP     Movestr                 ; repeat until end of string
  116. EXIT:
  117.                Basic_cleanup
  118.  
  119.                RET      10
  120. Fastprt        ENDP
  121.  
  122. ;
  123. Print_string   PROC     NEAR                    ; wait for horizontal retrace
  124.                CLI                              ; turn off interrupts
  125. TEST_LOW:
  126.                IN       AL,DX                   ; get status
  127.                JMP      SHORT $+2
  128.  
  129.  
  130.                TEST     AL,1                    ; is it low?
  131.                JNZ      Test_low                ; if not, try again
  132. TEST_HI:
  133.                IN       AL,DX                   ; get status
  134.                JMP      SHORT $+2
  135.                TEST     AL,1                    ; is it high?
  136.                JZ       Test_hi                 ; if not, try again
  137.  
  138.                MOVSB                            ; print a character
  139.  
  140.                STI
  141.                NOP
  142.                CLI
  143.  
  144. TST_LOW2:
  145.                IN       AL,DX                   ; get status
  146.                JMP      SHORT $+2
  147.                TEST     AL,1                    ; is it low?
  148.                JNZ      Tst_low2                ; if not, try again
  149. TST_HI2:
  150.                IN       AL,DX                   ; get status
  151.                JMP      SHORT $+2
  152.                TEST     AL,1                    ; is it high?
  153.                JZ       Tst_hi2                 ; if not, try again
  154.  
  155.                MOV      ES:[DI],BL              ; move attribute
  156.                INC      DI                      ; skip attribute byte
  157.  
  158.                STI                              ; turn interrupts back on
  159.                LOOP     Print_string            ; repeat until end of string
  160.  
  161.                RET                              ; return to the fastprt procedure
  162. Print_string   ENDP
  163.  
  164. Code           ENDS
  165.                END
  166.