; This source file is part of the LynxLib miscellaneous library by
; Robert Fischer, and is Copyright 1990 by Robert Fischer.  It costs no
; money, and you may not make money off of it, but you may redistribute
; it.  It comes with ABSOLUTELY NO WARRANTY.  See the file LYNXLIB.DOC
; for more details.
; To contact the author:
; 	Robert Fischer \\80 Killdeer Rd \\Hamden, CT   06517   USA
; 	(203) 288-9599     fischer-robert@cs.yale.edu

; unjar.c: Clear cookie pointer on warm boot

; Installs a new reset handler which clears _p_cookies on warm boots,
; for TOS ROMs which don't do that themselves.  This procedure must be
; executed in Supervisor mode.  Reshand itself will run in Supervisor
; mode, too.

.include "atari.s"

RESMAGIC	equ		$31415926

_unjar::
	Super
	move.l	resvalid, valsave
	move.l	resvector, vecsave
	move.l	#reshand, resvector
	move.l	#RESMAGIC, resvalid
	User
	rts

		.data
	dc.b "XBRAUJAR"
		.bss
vecsave:	ds.l	1
		.text
reshand:		; This gets run in supervisor mode
	clr.l	p_cookies
	move.l	vecsave, resvector
	move.l	valsave, resvalid
	jmp		(a6)

	.bss
valsave:	ds.l	1
