	move.l	sp,stack

	move.l	a0,-(sp)
	lea	dosname,a1
	move.l	4,a6
	moveq	#36,d0
	jsr	-552(a6)
	move.l	(sp)+,a0
	tst.l	d0
	beq.w	end
	move.l	d0,dosbase

	move.l	#format,d1
	move.l	#table,d2
	clr.l	d3
	move.l	dosbase,a6
	jsr	-798(a6)
	tst.l	d0
	beq.w	error
	move.l	d0,rdargs

	lea	iconname,a1
	move.l	4,a6
	moveq	#36,d0
	jsr	-552(a6)
	tst.b	d0
	beq.w	end
	move.l	d0,iconbase

	tst.l	t_project
	beq.s	nop
	move.b	#4,type
nop:	tst.l	t_tool
	beq.s	not
	move.b	#3,type
not:	tst.l	t_disk
	beq.s	nod
	move.b	#1,type
nod:	tst.l	t_drawer
	beq.s	nodr
	move.b	#2,type
nodr:	tst.l	t_garbage
	beq.s	nog
	move.b	#5,type
nog:
	move.l	iconbase,a6
	move.l	t_name,a0
	jsr	-78(a6)
	tst.l	d0
	bne.b	ok

	tst.l	t_new
	beq.w	noicon

	move.l	iconbase,a6
	move.b	type,d0
	ext.w	d0
	ext.l	d0
	jsr	-120(a6)
	tst.l	d0
	beq.w	deferr

ok:	move.l	d0,diskobj

	move.l	diskobj,a1
	tst.b	type
	beq.s	notype
	move.b	type,48(a1)
notype:
	tst.l	t_deftool
	beq.s	nodt
	move.l	t_deftool,50(a1)
nodt:	tst.l	t_tooltypes
	beq.s	nott
	move.l	t_tooltypes,54(a1)
nott:	tst.l	t_stack
	beq.s	nostack
	move.l	t_stack,a2
	move.l	(a2),d0
	move.l	d0,74(a1)
nostack:

	move.l	diskobj,a1
	move.l	t_name,a0
	move.l	iconbase,a6
	jsr	-84(a6)

	move.l	diskobj,a0
	move.l	iconbase,a6
	jsr	-90(a6)

	move.l	stack,sp

	bsr.b	closelib

	move.l	#0,d0
	rts

closelib:
	tst.l	rdargs
	beq.s	nordargs

	move.l	rdargs,d1
	move.l	dosbase,a6
	jsr	-858(a6)

nordargs:
	tst.l	iconbase
	beq.s	noiconb
	move.l	iconbase,a1
	move.l	4,a6
	jsr	-414(a6)

noiconb:
	tst.l	dosbase
	beq.s	nodosb
	move.l	dosbase,a1
	move.l	4,a6
	jsr	-414(a6)
nodosb:
	rts

noicon:
	move.l	stack,sp

	bsr.b	closelib

	move.l	#205,d1
	move.l	#errtxt,d2
	move.l	dosbase,a6
	jsr	-474(a6)

	move.l	#205,d0
	rts

end:
	move.l	stack,sp
	bsr.b	closelib
	moveq	#0,d0
	rts

errtxt:
	dc.b	'Cannot change icon',0

	even

error:
	move.l	#badargs,d1
	clr.l	d2
	move.l	dosbase,a6
	jsr	-954(a6)
	bra.s	end

deferr:
	move.l	#deferrtxt,d1
	clr.l	d2
	move.l	dosbase,a6
	jsr	-954(a6)
	bra.s	end

iconname:
	dc.b	'icon.library',0
	even
dosname:
	dc.b	'dos.library',0
	even

format:
	dc.b	'NAME/A,TOOL/S,PROJECT/S,DRAWER/S,DISK/S,'
	dc.b	'GARBAGE/S,NEW/S,STACK/N/K,DEFTOOL,TOOLTYPES/M',0
badargs:
	dc.b	'Bad arguments',10,0
deferrtxt:
	dc.b	'Cannot create default icon',10,0
	even

version:
	dc.b	'$VER: SetIcon 1.2 (11.06.95)',0

type:
	dc.b	0

	section free,bss

dosbase:
	ds.l	1
iconbase:
	ds.l	1
diskobj:
	ds.l	1
rdargs:
	ds.l	1
table:
t_name:
	ds.l	1
t_tool:
	ds.l	1
t_project:
	ds.l	1
t_drawer:
	ds.l	1
t_disk:
	ds.l	1
t_garbage:
	ds.l	1
t_new:
	ds.l	1
t_stack:
	ds.l	1
t_deftool:
	ds.l	1
t_tooltypes:
	ds.l	1
stack:
	ds.l	1
