Start:
	bsr	Save_Hardware
	move.l	#300,d1
L1:
	bsr	Fill_Line
	dbra	d1,L1

	bsr	Restore_Hardware

	clr	-(sp)			; Izadji iz programa
	trap	#1

;In;d1.l=number of line to fill (0-399)
Fill_Line:
	movem.l	d0-d7/a0-a6,-(sp)
	move.l	$44e.w,a4
	mulu	#80,d1
	adda.l	d1,a4
	moveq.l	#40-1,d4
Fill_Line_1:
	move.w	#$11,-(sp)
	trap	#14
	addq.l	#2,sp
	move.w	d0,(a4)+
	dbra	d4,Fill_Line_1
	movem.l	(sp)+,d0-d7/a0-a6
	rts

; Ulazi u supervisor mod, cuva paletu boja i tekuci ekran
Save_Hardware:
	clr.l	-(sp)			; Udji u Supervisor mod
	move.w	#$20,-(sp)		; GEMDOS funkcija broj 32 ($20)
	trap	#1
	addq.l	#6,sp			; Popravi stek
	move.l	d0,Old_SP		; Stara adresa User steka

	movem.l	$ffff8240.w,d0-d7	; 16 word-ova = 16 kolor registara
	movem.l	d0-d7,Old_Pallete	; Sacuvaj staru paletu boja

	move.l	$44e,Old_Screen		; Stara adresa video memorije

	lea	Video_Registers(pc),a0
	move.b	$ffff820f.w,(a0)+	; Width of scan lines in words-1
	move.b	$ffff8265.w,(a0)+	; Horizontal scroll count 0..15
	rts
Old_SP:		ds.l	1		
Old_Screen:	ds.l	1
Old_Pallete:	ds.w	16
Video_Registers:ds.w	1

; Vraca paletu boja, izlazi iz supervisor moda i vraca tekuci ekran
Restore_Hardware:
	bsr	Vsync
	lea	Video_Registers(pc),a0
	move.b	(a0)+,$ffff820f.w	; Width of scan lines in words-1
	move.b	(a0)+,$ffff8265.w	; Horiyontal scroll count 0..15
	movem.l	Old_Pallete(pc),d0-d7	; Stara paleta boja
	movem.l	d0-d7,$ffff8240.w	; Restauriraj je
	move.l	Old_SP(pc),-(sp)	; Vrati se u User mode
	move.w	#$20,-(sp)		; GEMDOS 32
	trap	#1
	addq.l	#6,sp			; Popravi stek
	move.l	Old_Screen(pc),d0
	bsr	Set_Screen
	rts	
; Ceka da video mlaz dodje u gornji levi ugao
Vsync:
	move.w	#$25,-(sp)
	trap	#14
	addq.l	#2,sp
	rts
; Setuje novu adresu video ekrana, Ulaz je adresa ekrana u d0=$00vvssnn
Set_Screen:
	move.w	#-1,-(sp)		; -1 znaci ne menjaj rezoluciju
	move.l	d0,-(sp)		; Nova adresa GEM ekrana
	move.l	d0,-(sp)		; Nova adresa Video ekrana
	move.w	#5,-(sp)		; XBIOS funkcija 5
	trap	#14
	lea	12(sp),sp		; Popravi stek za 2+4+4+2=12
	rts
	SECTION	BSS
New_Screen:	ds.l	1
My_Screen:	ds.b	120000