
	section	dmsverify,code

	incdir	dh0:include/

code:	include	system
	Include	Misc/EasyStart.i

	;this patches the system so the old 1.51 version of DMS
	;plus warp (WRP) verifies when writing to disk, also it opens
	;a requester if no filename is typed.
	

	move.l	4,a6
	move.l	#myname,a1
	jsr	-294(a6)
	cmp.l	#0,d0
	bne	.error

	Lea	DosName,A1
	Moveq	#0,D0
	CALLEXEC	OpenLibrary
	Move.l 	D0,_DOSBase
	Beq	.error

	lea	code(pc),a0
	move.l	-4(a0),d3
	move.l	d3,segaddress
	move.l	#0,-4(a0)
	
	move.l	_DOSBase,a6
	move.l	#myname,d1
	move.l	#0,d2
	move.l	#4000,d4
	jsr	-138(a6)			; create proc

.error	clr.l	d0	
	rts


	Section	Main,Code
Start:
	Lea	IntName,A1
	Moveq	#0,D0
	CALLEXEC	OpenLibrary
	Move.l	D0,_IntuitionBase
	Beq	Error

	move.l	#savename,d1
	move.l	#1005,d2
	CALLDOS	Open
	move.l	d0,fhand
	beq	.nofile
	
	move.l	#options,d2
	move.l	#6,d3
	move.l	fhand,d1
	CALLDOS	Read
	
	move.l	fhand,d1
	CALLDOS	Close

.nofile	tst.b	options+0
	beq	.not1
	lea	CGad2,a0
	or.w	#SELECTED,12(a0)
.not1	tst.b	options+1
	beq	.not2
	lea	CGad4,a0
	or.w	#SELECTED,12(a0)
.not2	tst.b	options+2
	beq	.not3
	lea	CGad6,a0
	or.w	#SELECTED,12(a0)
.not3	tst.b	options+3
	beq	.not4
	lea	CGad8,a0
	or.w	#SELECTED,12(a0)
.not4	tst.b	options+4
	beq	.not5
	lea	CGad10,a0
	or.w	#SELECTED,12(a0)
.not5	tst.b	options+5
	beq	.not6
	lea	CGad12,a0
	or.w	#SELECTED,12(a0)
.not6


	Lea	MainWindow,a0
	CALLINT	OpenWindow
	Move.l	D0,_MyWinBase
	Beq	CloseInt
	Move.l	D0,A0
	Move.l	wd_RPort(A0),_MyWinRPort
	Move.l	wd_UserPort(a0),_MyWinUserPort

	*-----------------------------------------------*
	
	move.l	4,a0
	lea	-462(a0),a0
	move.l	2(a0),OldBeginIO
	move.l	#My_BeginIo,2(a0)

	move.l	4,a0
	lea	-456(a0),a0
	move.l	2(a0),OldDoIo
	move.l	#My_DoIo,2(a0)
	
	move.l	4,a0
	lea	-444(a0),a0
	move.l	2(a0),oldopendev
	move.l	#my_opendev,2(a0)

	move.l	_IntuitionBase,a1

	lea	-346(a1),a0	; ks 1.2/1.3 offset (autorequest)
	cmp.w	#$4ef9,-588(a1)	; check if jump
	bne	ks210_noalert

	lea	-586(a1),a0	; ks 2.0 offset (autorequest)
	bra	ks13_noalert

ks210_noalert:
	cmp.w	#$4ef9,-594(a1)	; check if jump
	bne	ks13_noalert

	lea	-588(a1),a0	; ks 2.0 offset (autorequest)

ks13_noalert:
	move.l	a0,reqpos
	move.l	(a0),oldreq+2
	move.l	#do_alert,(a0)

	*-----------------------------------------------*

	lea	name2(pc),a1	
	lea	file_req(pc),a2
	move.l	a1,14(a2)
	
	lea	rlib(pc),a1
	moveq	#0,d0
	move.l	4.w,a6
	jsr	-$228(a6)
	tst	d0
	beq	Error
	move.l	d0,reqlib

	clr.l	d0
	move.l	_DOSBase,a0
	sub.l	#30,a0
	cmp.w	#$4ef9,(a0)
	bne	.notjump

	move.l	2(a0),open_jmp+2
	move.l	#my_open,2(a0)
	bra	WaitLoop
	
.notjump	
	move.w	4(a0),d0
	add.l	a0,d0
	add.l	#4,d0
	move.l	d0,open_jmp+2
	
	move.l	0(a0),orig_jmp+0
	move.l	4(a0),orig_jmp+4
	move.w	#$4ef9,0(a0)
	move.l	#my_open,2(a0)

	*-----------------------------------------------*
	
WaitLoop
	Move.l	_MyWinUserPort,A0
	CALLEXEC	WaitPort
	Move.l	_MyWinUserPort,A0
	CALLEXEC	GetMsg
	Move.l	D0,A1
	Move.l	im_Class(A1),D2		;D2=IDCMP Flags Directly
	Move.w	im_Code(A1),D3		;D3=Data ie key why class=Rawkey
	Move.w	im_Qualifier(A1),D4	;D4=things like CTRL SHIFT
	Move.w	im_MouseX(a1),D5		;D5=MouseX Coordinate
	Move.w	im_MouseY(a1),D6		;D5=MouseY Coordinate
	Move.l	im_IAddress(A1),D7	;D7=Addres of Intuition Obj ie Gadget
	Movem.l	D0-D7/A0-A6,-(A7)	
	CALLEXEC	ReplyMsg
	Movem.l	(a7)+,D0-D7/A0-A6
	cmp.l	#MENUPICK,d2
	bne	.ok

	bsr	config

.ok	Cmp.l	#CLOSEWINDOW,D2
	bne	WaitLoop

Exit	Move.l	_MyWinBase,A0
	CALLINT	CloseWindow

CloseInt
	Move.l	_IntuitionBase,A1
	CALLEXEC	CloseLibrary

	Move.l	reqlib,A1
	cmp.l	#0,a1
	beq	.skip
	CALLEXEC	CloseLibrary

.skip	Move.l	_DOSBase,A1
	CALLEXEC	CloseLibrary

	*-------------------------------*

	move.l	reqpos,a0
	move.l	oldreq+2,(a0)

	*-------------------------------*

	move.l	4,a0
	lea	-462(a0),a0
	move.l	OldBeginIO,2(a0)

	move.l	4,a0
	lea	-456(a0),a0
	move.l	OldDoIo,2(a0)

	move.l	4,a0
	lea	-444(a0),a0
	move.l	oldopendev,2(a0)
	
	*-------------------------------*

	clr.l	d0
	move.l	_DOSBase,a0
	sub.l	#30,a0
	cmp.l	#0,orig_jmp
	bne	.normal

	move.l	open_jmp+2,2(a0)

	move.l	_DOSBase,a6
	move.l	segaddress,d1
	jmp	-156(a6)			; unloadseg
	
.normal	
	move.l	orig_jmp+0,0(a0)
	move.l	orig_jmp+4,4(a0)	

	move.l	_DOSBase,a6
	move.l	segaddress,d1
	jmp	-156(a6)			; unloadseg

Error	Moveq	#1,D0
	Rts

	*-------------------------------*

my_open:	tst.b	options+3
	beq	.skip

	move.l	d1,filename
	moveq	#0,d0
	movem.l	d1-d7/a0-a6,-(a7)
	move.l	d1,a0
	cmp.b	#".",0(a0)
	seq	d0
	cmp.b	#":",3(a0)
	bne	.ok
	cmp.b	#".",4(a0)	
	seq	d0	
.ok	movem.l	(a7)+,d1-d7/a0-a6
	tst	d0
	bne	.no

	moveq	#-1,d0
	bsr	open_jmp

	cmp.l	#0,d0
	bne	open_ok

.no	movem.l	d2-d7/a0-a6,-(a7)

	move.l	filename,a0
.check	cmp.b	#".",(a0)+
	beq	..found
	cmp.b	#32,(a0)
	bge	.check
	
.quit	movem.l	(a7)+,d2-d7/a0-a6
	clr.l	d0
	rts

..found	move.b	0(a0),d0
	or.b	#32,d0
	cmp.b	#"d",d0
	beq	.ok1
	cmp.b	#"w",d0
	bne	.quit

.ok1	move.b	1(a0),d0
	or.b	#32,d0
	cmp.b	#"m",d0
	beq	.ok2
	cmp.b	#"r",d0
	bne	.quit

.ok2	move.b	2(a0),d0
	or.b	#32,d0
	cmp.b	#"s",d0
	beq	.ok3
	cmp.b	#"p",d0
	bne	.quit

.ok3	move.l	filename,a0
	lea	path,a1
.loop	cmp.b	#32,(a0)
	blt	.stoploop
	move.b	(a0)+,(a1)+
	bra	.loop
.stoploop

.loop2	sub.l	#1,a0
	sub.l	#1,a1
	cmp.b	#"/",(a0)
	beq	.fsp
	cmp.b	#":",(a0)
	beq	.fsp
	cmp.l	filename,a0
	bne	.loop2	
	move.b	#0,path

	lea	fsp,a1
	move.l	filename,a0
.fsploop2
	move.b	(a0)+,(a1)+
	cmp.b	#0,(a0)
	bne	.fsploop
	bra	.nofsp

.fsp	move.b	(a0)+,(a1)+
	move.b	#0,(a1)
	lea	fsp,a1
.fsploop
	move.b	#0,(a1)
	cmp.b	#0,(a0)
	beq	.nofsp
	move.b	(a0)+,(a1)+
	bra	.fsploop

.nofsp	move.l	reqlib,a6	
	lea	file_req(pc),a0
	move.l	#path,6(a0)			; initial path
	move.l	#fsp,10(a0)			; initial filename

	jsr	-84(a6)
	beq	req_error
	
	lea	file_req(pc),a0
	move.l	14(a0),d1			; full path & filename

	movem.l	(a7)+,d2-d7/a0-a6
	bra	my_open

.skip	move.l	#-1,d0
	bra	open_jmp

req_error:
	movem.l	(a7)+,d2-d7/a0-a6
	clr.l	d0
open_ok:	rts

open_jmp:	jmp	$12345678

	*-------------------------------*



My_DoIo:
	cmp.w	#$800b,28(a1)
	bne	.skip

	cmp.l	#$1600,d1
	bne	.skip

	tst.b	options+1
	beq	.skip
	
	movem.l	d0-d7/a0-a6,-(a7)

	move.l	d1,tracknumber

	bsr	.skip

	move.l	#2,retries

.again	CALLDOS	Output
	move.l	d0,handle

	move.l	handle,d1
	move.l	#wrp_vermsg,d2
	move.l	#wrp_vermsgend-wrp_vermsg,d3
	bsr	doswrite

	move.l	#0,a1
	CALLEXEC	FindTask
	move.l	d0,readreply+16
	
	lea	readreply,a1
	CALLEXEC	AddPort
	
	lea	diskio,a1
	move.l	drivenumber,d0			; drive number
	clr.l	d1
	lea	trddevice,a0

	move.l	4,a6
	bsr	my_opendev
	tst.l	d0
	bne	.error			; no td device avail
	
	lea	diskio,a1
	move.l	#readreply,14(a1)
	move.w	#2,28(a1)		; 28 = command
	move.l	#22*512,36(a1)		; 36 = length
	move.l	#diskbuff,40(a1)		; 40 = data
	move.l	tracknumber,44(a1)	; 44 = where
	
	CALLEXEC	DoIO

	cmp.b	#0,31(a1)
	beq	.ok
	
	lea	readreply,a1
	CALLEXEC	RemPort
	
	lea	diskio,a1
	CALLEXEC	CloseDevice

	sub.l	#1,retries
	bmi	.giveup

	move.l	handle,d1
	move.l	#wrp_wrimsg,d2
	move.l	#wrp_wrimsgend-wrp_wrimsg,d3
	bsr	doswrite

	movem.l	(a7)+,d0-d7/a0-a6
	movem.l	d0-d7/a0-a6,-(a7)
	
	bsr	.skip			; beginIO
	movem.l	(a7)+,d0-d7/a0-a6
	movem.l	d0-d7/a0-a6,-(a7)
	jsr	-474(a6)			; waitIO
	
	bra	.again	
	
.giveup	
	Move.l	_MyWinBase,A0
	Move.l	#-399,D0
	Move.l	#-9,D1
	CALLINT	SizeWindow
	
	CALLINT	WBenchToFront
	
	Lea	AlertWindow,a0
	CALLINT	OpenWindow
	Move.l	D0,_MessageWinBase
	Move.l	D0,A0
	Move.l	wd_RPort(A0),_MessageWinRPort
	Move.l	wd_UserPort(a0),_MessageWinUserPort
	Move.l	_MessageWinRPort,A0
	
.loop
	Move.l	_MessageWinUserPort,A0
	CALLEXEC	WaitPort
	Move.l	_MessageWinUserPort,A0
	CALLEXEC	GetMsg
	Move.l	D0,A1
	Move.l	im_Class(A1),D2		;D2=IDCMP Flags Directly
	Move.w	im_Code(A1),D3		;D3=Data ie key why class=Rawkey
	Move.w	im_Qualifier(A1),D4	;D4=things like CTRL SHIFT
	Move.w	im_MouseX(a1),D5		;D5=MouseX Coordinate
	Move.w	im_MouseY(a1),D6		;D5=MouseY Coordinate
	Move.l	im_IAddress(A1),D7	;D7=Addres of Intuition Obj ie Gadget

	Movem.l	D0-D7/A0-A6,-(A7)	
	CALLEXEC	ReplyMsg
	Movem.l	(a7)+,D0-D7/A0-A6

	cmp.l	#VANILLAKEY,D2
	beq	.close

	Cmp.l	#GADGETUP,D2
	Bne	.loop

.close	Move.l	_MessageWinBase,A0
	CALLINT	CloseWindow

	Move.l	_MyWinBase,A0
	Move.l	#399,D0
	Move.l	#9,D1
	CALLINT	SizeWindow

	movem.l	(a7)+,d0-d7/a0-a6
	tst.b	options+2
	beq	.noabort

	bsr	goodbyemessage

	move.l	(a7),a0
	lea	goodbye,a1
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	
	rts	

.noabort	
	rts

.ok	lea	readreply,a1
	CALLEXEC	RemPort
	
	lea	diskio,a1
	CALLEXEC	CloseDevice

.error	movem.l	(a7)+,d0-d7/a0-a6
	rts


	
.skip	dc.w	$4ef9
OldDoIo:	dc.l	0


goodbye:	move.l	#$64,d0
	CALLDOS	Exit

goodbyemessage:
	move.l	handle,d1
	move.l	#quitmsg,d2
	move.l	#quitmsgend-quitmsg,d3
	bsr	doswrite
	rts
	
My_BeginIo:
	cmp.w	#$800b,28(a1)
	bne	.skip

	cmp.l	#$2c00,d6		; not dms!
	bne	.skip
	
	tst.b	options+0
	beq	.skip

	move.l	d0,tracknumber

	movem.l	d0-d7/a0-a6,-(a7)
	
	bsr	.skip			; beginIO
	movem.l	(a7)+,d0-d7/a0-a6
	movem.l	d0-d7/a0-a6,-(a7)
	jsr	-474(a6)			; waitIO

	move.l	#2,retries

.again	CALLDOS	Output
	move.l	d0,handle


	move.l	handle,d1
	move.l	#vermsg,d2
	move.l	#vermsgend-vermsg,d3
	bsr	doswrite

	move.l	#0,a1
	CALLEXEC	FindTask
	move.l	d0,readreply+16
	
	lea	readreply,a1
	CALLEXEC	AddPort
	
	lea	diskio,a1
	move.l	drivenumber,d0			; drive number
	clr.l	d1
	lea	trddevice,a0

	move.l	4,a6
	bsr	my_opendev
	tst.l	d0
	bne	.error			; no td device avail
	
	lea	diskio,a1
	move.l	#readreply,14(a1)
	move.w	#2,28(a1)			; 28 = command
	move.l	#22*512,36(a1)		; 36 = length
	move.l	#diskbuff,40(a1)		; 40 = data
	move.l	tracknumber,44(a1)		; 44 = where
	
	CALLEXEC	DoIO

	cmp.b	#0,31(a1)
	beq	.ok
	
	lea	readreply,a1
	CALLEXEC	RemPort
	
	lea	diskio,a1
	CALLEXEC	CloseDevice

	sub.l	#1,retries
	bmi	.giveup

	move.l	handle,d1
	move.l	#wrimsg,d2
	move.l	#wrimsgend-wrimsg,d3
	bsr	doswrite

	movem.l	(a7)+,d0-d7/a0-a6
	movem.l	d0-d7/a0-a6,-(a7)
	
	bsr	.skip			; beginIO
	movem.l	(a7)+,d0-d7/a0-a6
	movem.l	d0-d7/a0-a6,-(a7)
	jsr	-474(a6)			; waitIO
	
	bra	.again	
	
.giveup	
	Move.l	_MyWinBase,A0
	Move.l	#-399,D0
	Move.l	#-9,D1
	CALLINT	SizeWindow
	
	CALLINT	WBenchToFront
	
	Lea	AlertWindow,a0
	CALLINT	OpenWindow
	Move.l	D0,_MessageWinBase
	Move.l	D0,A0
	Move.l	wd_RPort(A0),_MessageWinRPort
	Move.l	wd_UserPort(a0),_MessageWinUserPort
	Move.l	_MessageWinRPort,A0
	
.loop
	Move.l	_MessageWinUserPort,A0
	CALLEXEC	WaitPort
	Move.l	_MessageWinUserPort,A0
	CALLEXEC	GetMsg
	Move.l	D0,A1
	Move.l	im_Class(A1),D2		;D2=IDCMP Flags Directly
	Move.w	im_Code(A1),D3		;D3=Data ie key why class=Rawkey
	Move.w	im_Qualifier(A1),D4	;D4=things like CTRL SHIFT
	Move.w	im_MouseX(a1),D5		;D5=MouseX Coordinate
	Move.w	im_MouseY(a1),D6		;D5=MouseY Coordinate
	Move.l	im_IAddress(A1),D7	;D7=Addres of Intuition Obj ie Gadget

	Movem.l	D0-D7/A0-A6,-(A7)	
	CALLEXEC	ReplyMsg
	Movem.l	(a7)+,D0-D7/A0-A6

	cmp.l	#VANILLAKEY,D2
	beq	.close

	Cmp.l	#GADGETUP,D2
	Bne	.loop

.close	Move.l	_MessageWinBase,A0
	CALLINT	CloseWindow

	Move.l	_MyWinBase,A0
	Move.l	#399,D0
	Move.l	#9,D1
	CALLINT	SizeWindow

	move.l	handle,d1
	move.l	#pakmsg,d2
	move.l	#pakmsgend-pakmsg,d3
	bsr	doswrite

	movem.l	(a7)+,d0-d7/a0-a6
	tst.b	options+2
	beq	.noabort

	bsr	goodbyemessage

	move.l	(a7),a0
	lea	goodbye,a1
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	
	rts	

.noabort	
	rts

.ok	lea	readreply,a1
	CALLEXEC	RemPort
	
	lea	diskio,a1
	CALLEXEC	CloseDevice

	move.l	handle,d1
	move.l	#pakmsg,d2
	move.l	#pakmsgend-pakmsg,d3
	bsr	doswrite

.error	movem.l	(a7)+,d0-d7/a0-a6
	rts

.skip	dc.w	$4ef9
OldBeginIO:
	dc.l	0

my_opendev:
	cmp.l	#$fc0000,a0
	bge	.skip

	movem.l	d0-d7/a0-a6,-(a7)

	move.l	a0,a1
	jsr	-534(a6)			; type of mem
	cmp.l	#0,d0
	bgt	.ok
	movem.l	(a7)+,d0-d7/a0-a6
	bra	.skip

.ok	movem.l	(a7)+,d0-d7/a0-a6
	move.l	d0,drivenumber

.skip	dc.w	$4ef9
oldopendev:
	dc.l	0
	
	*-------------------------------*

config:
	Move.l	_MyWinBase,A0
	Move.l	#-399,D0
	Move.l	#-9,D1
	CALLINT	SizeWindow
	
	CALLINT	WBenchToFront
	
	Lea	ConfigWindow,a0
	CALLINT	OpenWindow
	Move.l	D0,_ConfigWinBase
	Move.l	D0,A0
	Move.l	wd_RPort(A0),_ConfigWinRPort
	Move.l	wd_UserPort(a0),_ConfigWinUserPort
	Move.l	_ConfigWinRPort,A0
	
.loop
	Move.l	_ConfigWinUserPort,A0
	CALLEXEC	WaitPort
	Move.l	_ConfigWinUserPort,A0
	CALLEXEC	GetMsg
	Move.l	D0,A1
	Move.l	im_Class(A1),D2		;D2=IDCMP Flags Directly
	Move.w	im_Code(A1),D3		;D3=Data ie key why class=Rawkey
	Move.w	im_Qualifier(A1),D4	;D4=things like CTRL SHIFT
	Move.w	im_MouseX(a1),D5		;D5=MouseX Coordinate
	Move.w	im_MouseY(a1),D6		;D5=MouseY Coordinate
	Move.l	im_IAddress(A1),D7	;D7=Addres of Intuition Obj ie Gadget

	Movem.l	D0-D7/A0-A6,-(A7)	
	CALLEXEC	ReplyMsg
	Movem.l	(a7)+,D0-D7/A0-A6

	Cmp.l	#GADGETUP,D2
	Bne	.loop

	Move.l	D7,A0
	Move.l	gg_UserData(a0),d0
	cmp.l	#$11,d0
	bne	.loop

	lea	CGad2,a0
	move.w	12(a0),d0
	and.w	#SELECTED,d0
	sne.b	options+0

	lea	CGad4,a0
	move.w	12(a0),d0
	and.w	#SELECTED,d0
	sne.b	options+1
	
	lea	CGad6,a0
	move.w	12(a0),d0
	and.w	#SELECTED,d0
	sne.b	options+2
	
	lea	CGad8,a0
	move.w	12(a0),d0
	and.w	#SELECTED,d0
	sne.b	options+3

	lea	CGad10,a0
	move.w	12(a0),d0
	and.w	#SELECTED,d0
	sne.b	options+4
	
	lea	CGad12,a0
	move.w	12(a0),d0
	and.w	#SELECTED,d0
	sne.b	options+5
	

	Move.l	_ConfigWinBase,A0
	CALLINT	CloseWindow

	Move.l	_MyWinBase,A0
	Move.l	#399,D0
	Move.l	#9,D1
	CALLINT	SizeWindow

	move.l	#savename,d1
	move.l	#1006,d2
	CALLDOS	Open
	move.l	d0,fhand
	beq	.nofile
	
	move.l	#options,d2
	move.l	#6,d3
	move.l	fhand,d1
	CALLDOS	Write
	
	move.l	fhand,d1
	CALLDOS	Close

.nofile	rts

	*-------------------------------*

do_alert:	movem.l	d0-d7/a0-a6,-(a7)

	move.b	options+4,d0
	or.b	options+5,d0
	beq	ks2_req

	Move.l	_IntuitionBase,A0
	move.l	ib_ActiveWindow(a0),_activewindow
	move.l	ib_ActiveScreen(a0),_activescreen

	move.l	4,a6
	move.l	20(a6),d0
	cmp.l	#$00220002,d0
	bgt	ks2_req

	tst.b	options+4
	beq	req_off

	move.l	#0,lengths

	move.l	a1,a0
	
	move.l	12(a0),a1
	move.b	-1(a1),lengths+0

	move.l	16(a0),a0		; line 2
	cmp.l	#0,a0
	beq	req_err
	move.l	12(a0),a1
	move.b	-1(a1),lengths+1
	
	move.l	16(a0),a0		; line 3
	cmp.l	#0,a0
	beq	req_err
	move.l	12(a0),a1
	move.b	-1(a1),lengths+2

req_err:	movem.l	(a7)+,d0-d7/a0-a6

	cmp.l	#$16011700,lengths	; key 880 already set
	beq	req_no
	cmp.l	#$171d0000,lengths	; disk is corrupt, use diskdoctor
	beq	req_no
	cmp.l	#$0f0f0000,lengths	; not a dos disk in unit 
	beq	req_no
	cmp.l	#$16011300,lengths	; disk is unreadable, use disk doctor
	beq	req_no

	bsr	oldreq	

	tst.b	options+5
	beq	req_no

	movem.l	d0-d7/a0-a6,-(a7)

	move.l	_activescreen,a0
	CALLINT	ScreenToFront
		
	movem.l	(a7)+,d0-d7/a0-a6
	rts	

ks2_req:	movem.l	(a7)+,d0-d7/a0-a6
oldreq:	jmp	$12345678

req_no:	clr.l	d0
	rts

req_off:	movem.l	(a7)+,d0-d7/a0-a6
	bsr	oldreq	

	tst.b	options+5
	beq	req_no

	movem.l	d0-d7/a0-a6,-(a7)

	move.l	_activescreen,a0
	CALLINT	ScreenToFront
		
	movem.l	(a7)+,d0-d7/a0-a6
	rts	

	*-------------------------------*
doswrite:	
	cmp.l	#0,d1
	beq	.nowrite
	CALLDOS	Write
.nowrite	rts
	*-------------------------------*

_IntuitionBase		Dc.l	0
_DOSBase			Dc.l	0
_MyWinBase		Dc.l	0
_MessageWinBase		Dc.l	0
_GfxBase			Dc.l	0
_MyWinRPort		Dc.l	0
_MessageWinRPort		Dc.l	0
_MyWinUserPort		Dc.l	0
_MessageWinUserPort	Dc.l	0

_ConfigWinRPort		Dc.l	0
_ConfigWinBase		Dc.l	0
_ConfigWinUserPort	Dc.l	0


_LastItem		Dc.l	0
_MyWinVPort		Dc.l	0
_activewindow		dc.l	0
_activescreen		dc.l	0
IntName			INTNAME
DosName			DOSNAME

reqpos:			dc.l	0
lengths			dc.l	0
segaddress:		dc.l	0
tracknumber:		dc.l	0
drivenumber:		dc.l	0
handle:			dc.l	0
handle2:			dc.l	0
fhand:			dc.l	0
retries:			dc.l	0
reqlib:			dc.l	0
orig_jmp:		dc.l	0,0
filename:		dc.l	0
dmswin:			dc.l	0

rlib:			dc.b	"req.library",0
name1:			dc.b	"File Not Found",0
name2:			dcb.b	100,0
fsp:			dcb.b	100,0
path:			dcb.b	100,0

	even
file_req:	dc.w	0
		dc.l	name1	; title string
		dc.l	0	; initial path
		dc.l	0	; initital name
		dc.l	0	; full filename
		
		dc.w	0
		dc.w	0
		dc.w	0
		
		dc.w	0	; 1 = half height
		dc.w	0	; 1 = half width
		dc.w	0	; 1 = half width (assigned) 

		dc.w	0	; ??
		dc.w	2150	; xpos,ypos,fonts & other bits??
		
		dc.w	1	; colour of dirs
		dc.w	0	; colour of files
		dc.w	2	; colour of volumes
		dc.w	0	; ??
		dc.w	0	; ??

		dc.w	0	; border colour
		dc.w	0	; ??
		
		dcb.b	316,0

		even
**************************************************
** 	       window defs for DMSV	   **
**************************************************

MainWindow:
	dc.w	100,0	
	dc.w	400,10
	dc.b	0,1	
	dc.l	CLOSEWINDOW+DISKINSERTED+MENUPICK
	dc.l	NOCAREREFRESH+WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH
	dc.l	0	
	dc.l	0	
	dc.l	winname
	dc.l	0	
	dc.l	0	
	dc.w	5,5	
	dc.w	-1,-1	
	dc.w	WBENCHSCREEN	

winname:	dc.b	'DMSV version 1.0 by SHAGRATT/LSD',0
	cnop 0,2

**************************************************
** 	   window defs for error window 	   **
**************************************************

AlertWindow:
	dc.w	145,63
	dc.w	351,59
	dc.b	0,1
	dc.l	GADGETUP+VANILLAKEY
	dc.l	ACTIVATE+NOCAREREFRESH
	dc.l	GadgetList1
	dc.l	0
	dc.l	NewWindowName1
	dc.l	0
	dc.l	0
	dc.w	5,5
	dc.w	-1,-1
	dc.w	WBENCHSCREEN
NewWindowName1:
	dc.b	'     DMSV version 1.0 by SHAGRATT/LSD',0
	cnop 0,2
GadgetList1:
Gadget1:
	dc.l	Gadget2
	dc.w	29,17
	dc.w	292,9
	dc.w	GADGHBOX+GADGHIMAGE
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border1a
	dc.l	0
	dc.l	IText1
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Border1a:
	dc.w	-1,-1
	dc.b	0,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors1a
	dc.l	0

BorderVectors1a:
	dc.w	0,0
	dc.w	293,0
	dc.w	293,10
	dc.w	0,10
	dc.w	0,0

IText1:	dc.b	1,0,RP_JAM2,0
	dc.w	55,1
	dc.l	0
	dc.l	ITextText1
	dc.l	0
ITextText1:
	dc.b	'***** WRITE ERROR *****',0
	cnop 0,2
Gadget2:
	dc.l	0
	dc.w	146,34
	dc.w	60,17
	dc.w	0
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border2a
	dc.l	0
	dc.l	IText2
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0

Border2a:
	dc.w	-1,-1
	dc.b	2,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors2a
	dc.l	Border2b
Border2b:
	dc.w	-1,-1
	dc.b	1,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors2b
	dc.l	0
BorderVectors2a:
	dc.w	0,0
	dc.w	61,0
	dc.w	61,18
	dc.w	62,18
	dc.w	62,0
BorderVectors2b:
	dc.w	61,18
	dc.w	0,18
	dc.w	0,0
	dc.w	-1,0
	dc.w	-1,18
IText2:
	dc.b	1,0,RP_JAM2,0
	dc.w	22,5
	dc.l	0
	dc.l	ITextText2
	dc.l	0
ITextText2:
	dc.b	'OK',0
	cnop 0,2

**************************************************
** 	   window defs for config window 	   **
**************************************************

ConfigWindow:
	dc.w	105,33
	dc.w	256,116
	dc.b	0,1
	dc.l	GADGETUP
	dc.l	WINDOWDRAG+WINDOWDEPTH+ACTIVATE+NOCAREREFRESH
	dc.l	ConGL1
	dc.l	0
	dc.l	ConfigWindowName
	dc.l	0
	dc.l	0
	dc.w	5,5
	dc.w	-1,-1
	dc.w	WBENCHSCREEN
ConfigWindowName:
	dc.b	'DMSV CONFIG',0
	cnop 0,2

ConGL1:
CGad1:
	dc.l	CGad2
	dc.w	32,15
	dc.w	209,8
	dc.w	GADGHBOX+GADGHIMAGE
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border1
	dc.l	0
	dc.l	CIText1
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Border1:
	dc.w	-1,-1
	dc.b	0,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors1
	dc.l	0
BorderVectors1:
	dc.w	0,0
	dc.w	210,0
	dc.w	210,9
	dc.w	0,9
	dc.w	0,0
CIText1:
	dc.b	1,0,RP_JAM2,0
	dc.w	2,0
	dc.l	0
	dc.l	CITextText1
	dc.l	0
CITextText1:
	dc.b	'Verify DMS writes',0
	cnop 0,2
CGad2:
	dc.l	CGad3
	dc.w	10,14
	dc.w	15,9
	dc.w	GADGHIMAGE+GADGIMAGE
	dc.w	RELVERIFY+TOGGLESELECT
	dc.w	BOOLGADGET
	dc.l	Image1
	dc.l	Image2
	dc.l	0
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Image1:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData1
	dc.b	$0003,$0000
	dc.l	0
Image2:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData2
	dc.b	$0003,$0000
	dc.l	0
CGad3:
	dc.l	CGad4
	dc.w	31,27
	dc.w	209,8
	dc.w	GADGHBOX+GADGHIMAGE
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border2
	dc.l	0
	dc.l	CIText2
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Border2:
	dc.w	-1,-1
	dc.b	0,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors2
	dc.l	0
BorderVectors2:
	dc.w	0,0
	dc.w	210,0
	dc.w	210,9
	dc.w	0,9
	dc.w	0,0
CIText2:
	dc.b	1,0,RP_JAM2,0
	dc.w	2,0
	dc.l	0
	dc.l	CITextText2
	dc.l	0
CITextText2:
	dc.b	'Verfiy WARP writes',0
	cnop 0,2
CGad4:
	dc.l	CGad5
	dc.w	10,26
	dc.w	19,10
	dc.w	GADGHIMAGE+GADGIMAGE
	dc.w	RELVERIFY+TOGGLESELECT
	dc.w	BOOLGADGET
	dc.l	Image3
	dc.l	Image4
	dc.l	0
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Image3:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData1
	dc.b	$0003,$0000
	dc.l	0
Image4:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData2
	dc.b	$0003,$0000
	dc.l	0
CGad5:
	dc.l	CGad6
	dc.w	31,39
	dc.w	209,8
	dc.w	GADGHBOX+GADGHIMAGE
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border3
	dc.l	0
	dc.l	CIText3
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Border3:
	dc.w	-1,-1
	dc.b	0,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors3
	dc.l	0
BorderVectors3:
	dc.w	0,0
	dc.w	210,0
	dc.w	210,9
	dc.w	0,9
	dc.w	0,0
CIText3:
	dc.b	1,0,RP_JAM2,0
	dc.w	2,0
	dc.l	0
	dc.l	CITextText3
	dc.l	0
CITextText3:
	dc.b	'Quit DMS/WARP on error',0
	cnop 0,2
CGad6:
	dc.l	CGad7
	dc.w	10,38
	dc.w	19,10
	dc.w	GADGHIMAGE+GADGIMAGE
	dc.w	RELVERIFY+TOGGLESELECT
	dc.w	BOOLGADGET
	dc.l	Image5
	dc.l	Image6
	dc.l	0
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Image5:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData1
	dc.b	$0003,$0000
	dc.l	0
Image6:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData2
	dc.b	$0003,$0000
	dc.l	0
CGad7:
	dc.l	CGad8
	dc.w	32,51
	dc.w	209,8
	dc.w	GADGHBOX+GADGHIMAGE
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border4
	dc.l	0
	dc.l	CIText4
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Border4:
	dc.w	-1,-1
	dc.b	0,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors4
	dc.l	0
BorderVectors4:
	dc.w	0,0
	dc.w	210,0
	dc.w	210,9
	dc.w	0,9
	dc.w	0,0
CIText4:
	dc.b	1,0,RP_JAM2,0
	dc.w	2,0
	dc.l	0
	dc.l	CITextText4
	dc.l	0
CITextText4:
	dc.b	'Use Req.Library',0
	cnop 0,2
CGad8:
	dc.l	CGad9
	dc.w	10,50
	dc.w	19,10
	dc.w	GADGHIMAGE+GADGIMAGE
	dc.w	RELVERIFY+TOGGLESELECT
	dc.w	BOOLGADGET
	dc.l	Image7
	dc.l	Image8
	dc.l	0
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Image7:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData1
	dc.b	$0003,$0000
	dc.l	0
Image8:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData2
	dc.b	$0003,$0000
	dc.l	0
CGad9:
	dc.l	CGad10
	dc.w	32,63
	dc.w	209,8
	dc.w	GADGHBOX+GADGHIMAGE
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border5
	dc.l	0
	dc.l	CIText5
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Border5:
	dc.w	-1,-1
	dc.b	0,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors5
	dc.l	0
BorderVectors5:
	dc.w	0,0
	dc.w	210,0
	dc.w	210,9
	dc.w	0,9
	dc.w	0,0
CIText5:
	dc.b	1,0,RP_JAM2,0
	dc.w	2,0
	dc.l	0
	dc.l	CITextText5
	dc.l	0
CITextText5:
	dc.b	'Stop 880 checksum errors',0
	cnop 0,2
CGad10:
	dc.l	CGad11
	dc.w	10,62
	dc.w	19,10
	dc.w	GADGHIMAGE+GADGIMAGE
	dc.w	RELVERIFY+TOGGLESELECT
	dc.w	BOOLGADGET
	dc.l	Image9
	dc.l	Image10
	dc.l	0
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Image9:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData1
	dc.b	$0003,$0000
	dc.l	0
Image10:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData2
	dc.b	$0003,$0000
	dc.l	0
CGad11:
	dc.l	CGad12
	dc.w	32,75
	dc.w	209,8
	dc.w	GADGHBOX+GADGHIMAGE
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border6
	dc.l	0
	dc.l	CIText6
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Border6:
	dc.w	-1,-1
	dc.b	0,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors6
	dc.l	0
BorderVectors6:
	dc.w	0,0
	dc.w	210,0
	dc.w	210,9
	dc.w	0,9
	dc.w	0,0
CIText6:
	dc.b	1,0,RP_JAM2,0
	dc.w	2,0
	dc.l	0
	dc.l	CITextText6
	dc.l	0
CITextText6:
	dc.b	'Restore Screen after Alert',0
	cnop 0,2
CGad12:
	dc.l	CGad13
	dc.w	10,74
	dc.w	19,10
	dc.w	GADGHIMAGE+GADGIMAGE
	dc.w	RELVERIFY+TOGGLESELECT
	dc.w	BOOLGADGET
	dc.l	Image11
	dc.l	Image12
	dc.l	0
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	0
Image11:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData1
	dc.b	$0003,$0000
	dc.l	0
Image12:
	dc.w	0,0
	dc.w	19,10
	dc.w	2
	dc.l	ImageData2
	dc.b	$0003,$0000
	dc.l	0
CGad13:
	dc.l	0
	dc.w	94,90
	dc.w	59,17
	dc.w	0
	dc.w	RELVERIFY
	dc.w	BOOLGADGET
	dc.l	Border7a
	dc.l	0
	dc.l	CIText7
	dc.l	0
	dc.l	0
	dc.w	0
	dc.l	$11
	
Border7a:
	dc.w	-1,-1
	dc.b	2,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors7a
	dc.l	Border7b
Border7b:
	dc.w	-1,-1
	dc.b	1,0,RP_JAM1
	dc.b	5
	dc.l	BorderVectors7b
	dc.l	0
BorderVectors7a:
	dc.w	0,0
	dc.w	61,0
	dc.w	61,18
	dc.w	62,18
	dc.w	62,0
BorderVectors7b:
	dc.w	61,18
	dc.w	0,18
	dc.w	0,0
	dc.w	-1,0
	dc.w	-1,18
CIText7:
	dc.b	1,0,RP_JAM2,0
	dc.w	22,5
	dc.l	0
	dc.l	CITextText7
	dc.l	0
CITextText7:
	dc.b	'OK',0
	cnop 0,2



myname:		dc.b	"DMSV",0
trddevice:		dc.b	"trackdisk.device",0
vermsg:		dc.b	" Verifying",8,8,8,8,8,8,8,8,8,8
vermsgend:
wrimsg:		dc.b	" Retrying ",8,8,8,8,8,8,8,8,8,8
wrimsgend:
pakmsg:		dc.b	" unPacking",8,8,8,8,8,8,8,8,8,8
pakmsgend:

quitmsg:		dc.b	10,13,10,13,"Aborted",10,13,10,13
quitmsgend:

wrp_vermsg:		dc.b	11,$09b,"0;33;40mVerifying",$09b,"0;31;40m",10,13
wrp_vermsgend:
wrp_wrimsg:		dc.b	11,$09b,"0;33;40mReTrying ",$09b,"0;31;40m",10,13
wrp_wrimsgend:

savename:	dc.b	"S:DMSV.prefs",0
abortcommand:	dc.b	3
	even

	section	stuff,bss

diskio:		ds.l	20
readreply:	ds.l	8
diskbuff:	ds.l	512*6
options:		dcb.b	6

	section	images,data_c
	
ImageData1:	dc.w	$0000,$6000,$0000,$6000,$0000,$6000,$0000,$6000
	dc.w	$0000,$6000,$0000,$6000,$0000,$6000,$0000,$6000
	dc.w	$0000,$6000,$7FFF,$E000,$FFFF,$8000,$C000,$0000
	dc.w	$C000,$0000,$C000,$0000,$C000,$0000,$C000,$0000
	dc.w	$C000,$0000,$C000,$0000,$C000,$0000,$8000,$0000

ImageData2:	dc.w	$FFFF,$C000,$FFFF,$8000,$FFF9,$8000,$FFF3,$8000
	dc.w	$FFE7,$8000,$F3CF,$8000,$F99F,$8000,$FC3F,$8000
	dc.w	$FFFF,$8000,$C000,$0000,$0000,$2000,$3FFF,$E000
	dc.w	$3FFF,$E000,$3FFF,$E000,$3FFF,$E000,$3FFF,$E000
	dc.w	$3FFF,$E000,$3FFF,$E000,$3FFF,$E000,$3FFF,$E000


