home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / utils / miscutil.zip / TBWINDOW.ZIP / QPRINT.ASM < prev    next >
Assembly Source File  |  1987-06-03  |  5KB  |  101 lines

  1.                 title   QPRINT
  2.                 page    60,132
  3.  
  4. Attr            equ     [bp + 06h]      ; ATTR%
  5. SnoChk          equ     [bp + 0Ah]      ; SNOCHK%
  6. StrDat          equ     [bp + 0Eh]      ; STRDAT$
  7. Column          equ     [bp + 12h]      ; COL%
  8. Row             equ     [bp + 16h]      ; ROW%
  9.  
  10. program         segment                 ; begin program segment
  11.                 assume  cs:program      ; parameters on stack
  12.                 push    bp              ; save registers for return
  13.                 mov     bp,sp           ; establish addressibility of stack
  14.                 push    ds              ; save cause we will manipulate
  15.                 push    es              ; ditto
  16.                 les     di, StrDat      ; load length address
  17.                 mov     cx, es:[di]     ; load length into cx
  18.                 and     cx, 7FFFh       ; and off high byte
  19.                 jcxz    GetOut          ; quit if empty string
  20.                 push    cx
  21.                 mov     dx, ds:[0]      ; get the beginning of the string segment from ds:[0]
  22.                 push    dx              ; push data segment onto stack
  23.                 pop     ds              ; make ds point to string segment
  24.                 mov     si, es:[di + 2] ; get offset into string segment from es:[di + 2]
  25.                 push    ds              ; save address of string to write to screen
  26.                 push    si              ;
  27. Scr_Check:      mov     ah, 15          ; function to get current video state
  28.                 int     10h             ; video bios call
  29.                 mov     dx, 0B000h      ; assume mono
  30.                 push    dx
  31.                 pop     es
  32.                 mov     dx, 03BAh       ; address of 6845 chip for mono
  33.                 cmp     al, 7           ; is it mono?
  34.                 jz      Store_Screen    ; it sure is!
  35.                 mov     dx, 0B800h      ; no - it must be color
  36.                 push    dx
  37.                 pop     es
  38.                 mov     dx, 03DAh       ; address of 6845 chip for CGA
  39. Store_Screen:   push    es              ; push es onto stack - screen segment
  40.                 lds     di, Column      ; get the address of the column
  41.                 mov     bx, ds:[di]     ; BX has the column
  42.                 dec     bx              ; convert into 0-79
  43.                 shl     bx, 1           ; multiply by 2 to accomodate attributes
  44.                 lds     si, Row         ; get the address of the line
  45.                 mov     ax, ds:[si]     ; get line (1-25)
  46.                 dec     ax              ; convert to 0-24
  47. CalcScrnOff:    mov     cl, 05          ; Times 160 bytes per line
  48.                 shl     ax, cl          ; First x 32
  49.                 mov     cx, ax          ; Temp Hold
  50.                 shl     ax, 1
  51.                 shl     ax, 1           ; x 128
  52.                 add     cx, ax          ; X128 + X32 = X160
  53.                 add     bx, cx          ; Add column
  54.                 lds     si, Attr        ; get the address of the attribute
  55.                 mov     ax, ds:[si]     ; load attribute into ax
  56.                 pop     es              ; ditto
  57.                 lds     si, SnoChk      ; Snow Check if not 0
  58.                 mov     cx, ds:[si]     ; to CX
  59.                 jcxz    Snow
  60.                 pop     si              ; ditto
  61.                 pop     ds              ; ditto
  62.                 pop     cx              ; get length back
  63.                 mov     di, bx          ; move over to line/column
  64.                 cld                     ; Clear direction flags
  65. NoSnow1:        movsb                   ; AX has attribute to spread
  66.                 mov     es:[di], al     ; Put attribute
  67.                 inc     di
  68.                 loop    NoSnow1
  69. GetOut:         jmp     endit
  70. Snow:           pop     si              ; get length back
  71.                 pop     ds              ; ditto
  72.                 pop     cx              ; ditto
  73.                 mov     di, bx          ; move over to line/column
  74.                 cld                     ; Clear direction flags
  75.                 cli
  76. Snow1:          push    ax
  77. WaitLo1:        in      al, dx          ; get status
  78.                 shr     al, 1           ; is it low?
  79.                 jc      WaitLo1         ; wait until it is
  80. WaitHi1:        in      al, dx          ; get status
  81.                 shr     al, 1           ; is it high?
  82.                 jnc     WaitHi1         ; wait until it is
  83.                 movsb
  84. WaitLo2:        in      al, dx          ; get status
  85.                 shr     al, 1           ; is it low?
  86.                 jc      WaitLo2         ; wait until it is
  87. WaitHi2:        in      al, dx          ; get status
  88.                 shr     al, 1           ; is it high?
  89.                 jnc     WaitHi2         ; wait until it is
  90.                 pop     ax
  91.                 mov     es:[di], al     ; move attribute byte
  92.                 inc     di
  93.                 loop    Snow1           ; go until all bytes moved
  94.                 sti
  95. Endit:          pop     es              ; pop and restore all the registers
  96.                 pop     ds
  97.                 pop     bp
  98. program         ends                    ; end program segment
  99.                 end
  100.  
  101.