; Copyright (c) 1996 Brian Fisher
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; 1. Redistributions of source code must retain the above copyright
;    notice, this list of conditions and the following disclaimer.
; 2. Redistributions in binary form must reproduce the above copyright
;    notice, this list of conditions and the following disclaimer in the
;    documentation and/or other materials provided with the distribution.
; 3. The name of the author may not be used to endorse or promote products
;    derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;*****************************************************************************

;*** Copy contents of one screen page to another
;* This should work okay...
;* Brian Fisher
;*
;*

.286
Ideal
Model Small
Public CopyPage,clearpage
CodeSeg

Proc    CopyPage        ; Offset1, Offset2
			;    8        6
	push bp
	mov bp,sp
	push es di ds si

	mov bh,0
	mov bl,1
	mov ax,0a000h
	mov ds,ax
	mov es,ax
	mov ax,[ss:bp+8] ;get source offset
	shl ax,14
	mov si,ax
	mov ax,[ss:bp+6] ;get dest. offset
	shl ax,14
	mov di,ax
	mov ax,0f02h
	mov dx,03c4h
	out dx,ax	 ;turn the write plane enable to all planes
	mov ax,0008h
	mov dx,03ceh
	out dx,ax	 ;set to latches
	mov cx,16000
	rep movsb
	inc dx
	mov al,0ffh
	out dx,al	 ;set to CPU value
	
	pop si ds di es bp
	retf 4
endp    Copypage
Proc    Clearpage       ; page
			;  6
	push bp
	mov bp,sp
	push es di
	mov bx,[ss:bp+06]
	shl bx,14
	mov di,bx
	mov ax,0a000h
	mov es,ax
	mov dx,03c4h
	mov al,02h
	mov ah,0fh
	out dx,ax
	mov ax,0
	mov cx,8000
	cld
	rep stosw
	pop di es bp
	retf 2
endp    clearpage
end