		section	killguru,code

_LVOForbid		equ	-$84
_LVODisplayAlert	equ	-$5A
_LVOCloseLibrary	equ	-$19E
_LVOOutput		equ	-$3C
_LVOWrite		equ	-$30
_LVOPermit		equ	-$8A
_LVOOpenLibrary		equ	-$228

Forbid		move.l	4.w,a6
		jsr	_LVOForbid(a6)

		lea	OldExc,a0
		lea	0.w,a1
		moveq	#32-1,d0
copyold		move.l	(a1)+,(a0)+
		dbra	d0,copyold

		lea	OldHRegs,a5
		lea	$DFF000,a6
		move.l	2(a6),(a5)
		move.l	$1C(a6),4(a5)

		move.l	4.w,a6
		lea	GfxName(pc),a1
		jsr	-408(a6)
		move.l	d0,16(a5)
		move.l	d0,a1
		jsr	_LVOCloseLibrary(a6)

		lea	8.w,a0
		move.l	#Err2,(a0)+	;bus
		move.l	#Err2,(a0)+	;adr
		move.l	#Err1,(a0)+	;illeg
		move.l	#Err1,(a0)+	;divu
		lea	$3c.w,a0
		move.l	#Err1,(a0)
		lea	$60.w,a0
		move.l	#Err2,(a0)

		move.l	4.w,a6
		jsr	_LVOPermit(a6)
		lea	Forbid(pc),a0
		clr.l	-(a0)
		moveq	#0,d0
		rts

Err2		lea	8(sp),sp
		bra.s	Exit2Dos

Err1		lea	OldHRegs(pc),a5
		lea	$DFF000,a6
		move.w	#$7FFF,$96(a6)
		move.w	#$7FFF,$9A(a6)
		lea	OldInt(pc),a0
		lea	$64.w,a1
		moveq	#7-1,d0
copyint		move.l	(a0)+,(a1)+
		dbra	d0,copyint
		move.w	(a5),d0
		or.w	#$8000,d0
		move.w	d0,$96(a6)
		move.w	4(a5),d0
		or.w	#$8000,d0
		move.w	d0,$9A(a6)
		move.l	$10(a5),a0
		move.l	$26(a0),$80(a6)
		clr.w	$88(a6)

Exit2Dos	lea	ExitDos(pc),a0
		move.l	a0,2(sp)
		rte

ExitDos		moveq	#0,d0
		rts

GfxName		dc.b	'graphics.library',0
		even
OldExc		ds.l	25
OldInt		ds.l	7
OldHRegs	ds.l	5
