#include "vgadef.h"
.text
	.globl	_asm_scroll
	.comm	_graph_mem,4
	.align 4

SY =	8
EY = 	12
LINE = 	16
MCOLOR=	20


	
_asm_scroll:	
	pushl	%ebp
	movl	%ebp,%esp
	pushl	%esi
	pushl	%edi
	pushl 	%ds
	popl	%es
	# calculate the source base
	# Y * 80
	movl	SY(%ebp),%edi
	movl	EY(%ebp),%ecx
	subl	%edi,%ecx
	leal	0(%edi,%edi,4),%edi
	sall	$4,%edi
	# graph_mem[Y*80]
	addl	_graph_mem,%edi
	movl	LINE(%ebp),%esi
	subl	%esi,%ecx

	leal	0(%esi,%esi,4),%esi
	sall	$4,%esi
	addl	%edi,%esi
	# set to write mode 1
	mov	$GRA_I,%dx
	movw	$0x0105,%ax
	outw	%ax,%dx
#ifdef VGA_16BIT
	#CX*40
	leal	0(%ecx,%ecx,4),%ecx
	sall	$3,%ecx
	rep
	movsw
#else
	# CX*80
	leal	0(%ecx,%ecx,4),%ecx
	sall	$4,%ecx		

	rep 
	movsb
#endif

	# blank the below line
	# use mode 
	movw	$0x0a05,%ax
	outw	%ax,%dx
	movw	$0xff08,%ax
	outw	%ax,%dx
	movw	$7,%ax
	outw	%ax,%dx
	movw	$3,%ax
	outw	%ax,%dx
	movw	MCOLOR(%ebp),%ax
	movb	%ah,%al
	movl	LINE(%ebp),%ecx
#ifdef VGA_16BIT
	leal	0(%ecx,%ecx,4),%ecx
	sall	$3,%ecx
	rep
	stosw
#else
	leal	0(%ecx,%ecx,4),%ecx
	sall	$4,%ecx

	rep 
	stosb
#endif
L1:
	mov	$0x0805,%ax
	outw	%ax,%dx
	pop	%edi
	pop	%esi
	movl	%ebp,%esp
	pop	%ebp
	ret

	
	
	
		
	



