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

;************************************************************************
;* No-snow screen display routine			        	*
;*  This routine moves screen data from a user buffer to the     	*
;*  screen buffer during horizontal retrace time, resulting in	        *
;*  no screen flicker.					             	*
;*							         	*
;* definition:  void putscrn (char *, int); 			        *
;* definition:  void getscrn (char *, int); 		        	*
;* calling sequence:  putscrn (buffer, video page);	        	*
;*   where:  buffer = (character, attribute) array, 2 * 80 * 25 (4000)	*
;*           video page = Text page to move buffer to                   *
;*   returns: void					        	*
;*							        	*
;* note: designed for use with Microsoft 'C' (4.0)	        	*
;*     : set switches PROG, DATA for memory model type	        	*
;*							        	*
;* edit date: 9/30/86	      by Mike Elkins		        	*
;* release: 2.0                                                         *
;************************************************************************

SMALL	=	0		;near
LARGE	=	1		;far
PROG	=	SMALL		;set this as req'd  ***
DATA	=	SMALL		;set this as req'd  ***

_text		segment	byte public 'code'
		assume	cs:_text

		public	_putscrn,_getscrn
		if	PROG
_putscrn	proc	far
		else
_putscrn	proc	near
		endif

; buffer = +4
; page = +6
		push	bp			;save calling environment
		mov	bp,sp
		push	si
		push	di

  		mov	ah,15			;get current mode
   		int	10h			;system video
          	mov	dx,3BAh			;monochrome port address
         	mov	di,0			;offset for monochrome buffer
   		cmp	al,7			;is b/w?
        	je	put001                  ;no pages for mono
		mov	dx,3DAh			;color port
		mov	di,8000h		;offset for color buffer
                mov     ax,[bp+6]               ;get page
                cmp     ax,0
                je      put001
                mov     di,9000h                ;page 1
                cmp     ax,1
                je      put001
                mov     di,0A000h               ;page 2
                cmp     ax,2
                je      put001
                mov     di,0B000h               ;page3

put001:		mov	ax,0B000h
		mov	es,ax

		if	DATA
		push	ds
		lds	si,[bp+4]
		else
		mov	si,[bp+4]		;source buffer pointer
		endif
		mov	cx,80*25		;block length

put002:		in	al,dx			;screen status
		test	al,1			;is 'high'?
		jnz	put002			;yes - wait
put004:		in	al,dx			;screen status
		test	al,1			;is 'low'?
		jz	put004			;yes - wait
		movsw				;mov 2 bytes to screen
                                                ;ds:si -> es:di
		loop	put002			;do until done

		if	DATA
		pop	ds
		endif
		pop	di
		pop	si
		pop	bp
		ret

_putscrn	endp

		if	PROG
_getscrn	proc	far
		else
_getscrn	proc	near
		endif

; buffer = +4

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

 		mov	ah,15			;get current mode
 		int	10h			;system video
 		mov	dx,3BAh			;monochrome port address
 		mov	si,0			;offset for monochrome buffer
 		cmp	al,7			;is b/w?
 		je	get001
		mov	dx,3DAh			;color port
		mov	si,8000h		;offset for color buffer
                mov     ax,[bp+6]               ;get page
                cmp     ax,0
                je      get001
                mov     si,9000h                ;page 1
                cmp     ax,1
                je      get001
                mov     si,0A000h               ;page 2
                cmp     ax,2
                je      get001
                mov     si,0B000h               ;page3


get001:		mov	ax,0B000h
		push	ds
                pop     es
		mov	ds,ax

		if	DATA
		les	di,[bp+4]
		else
		mov	di,[bp+4]		;source buffer pointer
		endif
		mov	cx,80*25		;block length

get002:		in	al,dx			;screen status
		test	al,1			;is 'high'?
		jnz	get002			;yes - wait
;get003:		cli				;the timing is very tight - no interruption wanted
get004:		in	al,dx			;screen status
		test	al,1			;is 'low'?
		jz	get004			;yes - wait
		movsw				;mov 2 bytes to screen
                                                ;ds:si -> es:di
;		sti
		loop	get002			;do until done

		pop	es
		pop	ds
		pop	di
		pop	si
		pop	bp
		ret

_getscrn	endp

_text		ends

		end


