page ,132
        title    putsca.asm - no snow screen update routine

;****************************************************************
;* No-snow screen display routine                               *
;*  This routine moves screen attributes to a buffer on the     *
;*  current screen during horizontal retrace time, resulting in *
;*  no screen flicker.                                          *
;*                                                              *
;* definition:                                                  *
;*    void putsca (unsigned , int, int, int);                   *
;*      unsigned int attrib   /* attribute                      *
;*      int start_of_buff     /* row*80 + col                   *
;*      int length            /* # of col                       *
;*      int page              /* video page                     *
;*                                                              *
;* note: designed for use with Microsoft 'C' (4.0)              *
;*                                                              *
;* edit date: 10/19/86         by Mike Elkins                   *
;****************************************************************

_text       segment    byte public 'code'
            assume     cs:_text

            public     _putsca
_putsca        proc    near

; attrib = +6
; offset = +8
; length = +10

                push    bp                      ;save calling environment
                mov     bp,sp
                push    si
                push    di
                push    ds

  		mov	ah,15			;get current mode
   		int	10h			;system video
          	mov	dx,3BAh			;monochrome port address
                mov     di,[bp+6]               ;offset for attribute
                add     di,di                   ;correct for attribute bytes
   		cmp	al,7			;is b/w?
        	je	movmno                  ;skip pages for mono
                mov     dx,3DAh                 ;color port
                mov     ax,0B800h               ;color page 0
                mov     bx,[bp+10]              ;get page
                cmp     bx,0
                je      mov001                  ;page 0
                mov     ax,0B900h
                cmp     bx,1
                je      mov001                  ;page 1
                mov     ax,0BA00h
                cmp     bx,2
                je      mov001                  ;page 2
                mov     ax,0BB00h               ;page 3
                jmp     mov001                  ;skip past mono stuff

movmno:         mov     ax,0B000h                ;set for mono address
mov001:         add     di,1                    ;set to attribute byte
                mov     es,ax

                mov     cx,[bp+8]               ;block length

mov002:
                in      al,dx                   ;screen status
                test    al,1                    ;is 'high'?
                jnz     mov002                  ;yes - wait
mov004:         in      al,dx                   ;screen status
                test    al,1                    ;is 'low'?
                jz      mov004                  ;yes - wait
                mov     ax,[bp+4]
                mov     es:[di],al              ;mov byte to screen
                add     di,2                    ;every other one
                loop    mov002

                pop    ds
                pop    di
                pop    si
                pop    bp
                ret

_putsca         endp

_text           ends

                end

