.model large ,c
.code

moveUp	proc far uses si di ds es, x1:word,y1:word,x:word,y:word,step:word
public	moveUp
	mov	ax,0a000h
	mov	es,ax
	mov	ds,ax

	mov	dx,3ceh 
	mov	ax,0105h
	out	dx,ax

	mov	dx,3c4h
	mov	al,2
	mov	ah,1111b
	out	dx,ax
	
	mov	cx,y1
	mov	ax,80
	mul	cx
	mov	si,ax
	add	si,x1

	mov	cx,step
	mov	ax,80
	mul	cx
	mov	di,si
	sub	di,ax
	
	cld
	mov	cx,y
do:	push	cx
	mov	cx,x
	rep	movsb
	sub	si,x
	sub	di,x
	add	si,80
	add	di,80
	pop	cx
	loop	do

	ret
moveUp	endp
	
moveDn	proc far uses si di ds es, x1:word,y1:word,x:word,y:word,step:word
public	moveDn
	mov	ax,0a000h
	mov	es,ax
	mov	ds,ax

	mov	dx,3ceh ;set 2 mode
	mov	ax,0105h
	out	dx,ax

	mov	dx,3c4h
	mov	al,2
	mov	ah,1111b
	out	dx,ax
	
	mov	cx,y1
	add	cx,y
	dec	cx	;?
	mov	ax,80
	mul	cx
	mov	si,ax
	add	si,x1
	add	si,x
	dec	si	;?

	mov	cx,step
	mov	ax,80
	mul	cx
	mov	di,si
	add	di,ax
	
	std
	mov	cx,y
do1:	push	cx
	mov	cx,x
	rep	movsb
	add	si,x
	add	di,x
	sub	si,80
	sub	di,80
	pop	cx
	loop	do1

	ret
moveDn	endp

moveLeft proc far uses si di ds es, x1:word,y1:word,x:word,y:word,step:word
public	moveLeft
	mov	ax,0a000h
	mov	es,ax
	mov	ds,ax

	mov	dx,3ceh ;set 2 mode
	mov	ax,0105h
	out	dx,ax

	mov	dx,3c4h
	mov	al,2
	mov	ah,1111b
	out	dx,ax
	
	mov	cx,y1
	mov	ax,80
	mul	cx
	mov	si,ax
	add	si,x1

	mov	di,si
	sub	di,step
	
	cld
	mov	cx,y
do3:	push	cx
	mov	cx,x
	rep	movsb
	sub	si,x
	sub	di,x
	add	si,80
	add	di,80
	pop	cx
	loop	do3
	ret
moveLeft	endp

moveRight proc far uses si di ds es, x1:word,y1:word,x:word,y:word,step:word
public	moveRight
	mov	ax,0a000h
	mov	es,ax
	mov	ds,ax

	mov	dx,3ceh 
	mov	ax,0105h
	out	dx,ax

	mov	dx,3c4h
	mov	al,2
	mov	ah,1111b
	out	dx,ax
	
	mov	cx,y1
	add	cx,y
	dec	cx	;?
	mov	ax,80
	mul	cx
	mov	si,ax
	add	si,x1
	add	si,x
	dec	si	;?

	mov	di,si
	add	di,step
	
	std
	mov	cx,y
do4:	push	cx
	mov	cx,x
	rep	movsb
	add	si,x
	add	di,x
	sub	si,80
	sub	di,80
	pop	cx
	loop	do4

	ret
moveRight	endp

end