org $30000
load $30000


allocmem = -198
openlib  = -408
closelib = -414
openscr  = -198
openwin  = -204
closescr = -66
closewin = -72
rtdisplay = -390
viewportadd = -300
cbump = -366
cmove = -372
cwait = -378

s:	move.l	4,a6
	move.l	#65538,d1
	moveq	#12,d0
	jsr	allocmem(a6)
	move.l	d0,uc1
	lea 	intnam,a1
	jsr	openlib(a6)
	move.l	d0,intbas
	lea	granam,a1
	jsr	openlib(a6)
	move.l	d0,grabas
	move.l	intbas,a6
	lea	scrdef,a0
	jsr	openscr(a6)
	move.l	d0,scrhd
	lea	windef,a0
	jsr	openwin(a6)
	move.l	d0,winhd
	
	
	move.l	grabas,a6
	move.l	#256,d4
	move.l	#384,a4
xloop:
	moveq	#7,d3
yloop:
	moveq	#7,d2
	sub.l	d3,d2
	move.l	d2,d7
	asl	#8,d7
	asl	#1,d7
	move.l	d2,d1
	asl	#4,d1
	sub.l	d2,d1
	asl 	#3,d2
	add.l	d2,d1
	addi.l	#45,d1
	move.l	#256,d0
	sub.l	d4,d0
	add.l	d0,d7
	move.l	uc1,a1
	jsr	cwait(a6)
	move.l	uc1,a1	
	jsr	cbump(a6)
	move.l	uc1,a1
	move.l	a4,d0
	move.l	d7,d1
	jsr	cmove(a6)
	move.l	uc1,a1
	jsr	cbump(a6)
	
	dbra	d3,yloop
	dbra	d4,xloop
	

	move.l	uc1,a1
	move.l	#10000,d0
	move.l	#256,d1
	jsr	cwait(a6)
	move.l	winhd,a0
	move.l	intbas,a6
	jsr	viewportadd(a6)
	move.l	d0,a0
	move.l	uc1,20(a0)
	jsr	rtdisplay(a6)
	
wait:
	btst	#6,$bfe001
	bne	wait

	move.l	intbas,a6
	move.l	winhd,a0
	jsr	closewin(a6)
	move.l	scrhd,a0
	jsr	closescr(a6)
	move.l	4,a6
	move.l	intbas,a1
	jsr	closelib(a6)
	move.l	grabas,a1
	jsr	closelib(a6)
	rts

intbas:	dc.l	0
grabas:	dc.l	0
winhd:	dc.l	0
uc1:	dc.l	0

scrdef:	dc.w	0,0,640,266,1,0,$8002,15
	dc.l	0,0,0,0
windef:	dc.w	588,0,52,10,0
	dc.l	0,$10000,0,0,0
scrhd:	dc.l	0
	dc.w	0,0,0,0,52,20,15
intnam:	dc.b	"intuition.library",0
granam:	dc.b	"graphics.library",0,0

