ExecBase = 4
FindTask = -294
AddPort  = -354
RemPort  = -360
OpenLib  = -408
CloseLib = -414
OpenDev  = -444
CloseDev = -450
DoIO     = -456
OpenLibrary = -552
Output   = -60
Write    = -48		
AllocMem = -198
FreeMem  = -210
FindName = -276

run:
	movem.l	d0/a0,-(sp)

	move.l	ExecBase,a6
	move.l	148(a6),a0	;a0 pointer naar int5
	cmpi.l	#'Band',-$2aa(a0)
	bne	GeenByte
	move.l	$110(a0),148(a6)
	move.l	$10c(a0),a4	;a4 wijst naar orginele trackdisk
	lea	350(a6),a0	;list ??
	lea	trddevice,a1
	jsr	FindName(a6)
	move.l	d0,a0
	move.l	a4,-28(a0)	;Pointer weer goed zetten
	clr.w	550(a6)		;Resident slopen
	jsr	-612(a6)
	move.l	d0,554(a6)
	lea	alert3,a0
	jsr	alertprog	;Guru
GeenByte:
	tst.l	46(a6)		;test coolcap
	beq	GeenSCA
	cmpi.l	#'SCA ',$7efd2
	bne	GeenSCA
;Uitschakelen van SCA-Virus

	clr.l	46(a6)		;Clear CoolCap
	lea	34(a6),a0
	clr.w	d0		;bereken checksum van execbase
	moveq	#$17,d1
chksum:	add.w	(a0)+,d0
	dbra	d1,chksum
	not.w	d0
	move.w	d0,(a0)
	move.l	$7efde,d0
	move.l	#$-456,a0
	move.l	a6,a1
	jsr	-420(a6)
	lea	alert4,a0
	bsr	alertprog	;Guru
GeenSCA:
	cmpi.l	#$fc06dc,$7fa20
	bne	GeenByteWarrior
	cmpi.l	#$fc06dc,$7fa4e
	bne	GeenByteWarrior

	move.l	4,a6
	clr.w	550(a6)		;Resident slopen
	jsr	-612(a6)
	move.l	d0,554(a6)

	move.l	#$fc06dc,-454(a6)
	clr.l	$7fa20
	clr.l	$7fa4e
	lea	alert5,a0
	bsr	alertprog
GeenByteWarrior:
	move.l	execbase,a6
	lea.l	DosName,a1
	clr.l	d0
	jsr	OpenLibrary(a6)
	move.l	d0,DosBase
	bne	goed
	rts

goed:	move.l	d0,a6
	jsr	Output(a6)
	move.l	d0,OutputHandle	

arg:
	movem.l	(sp)+,d0/a0
	lea	argtekst,a2
	lea	argpointers,a3
	move.l	#0,d2		;arg counter
spaties:
	move.b	(a0)+,d1	;spaties opruimen tussen
	subq.l	#1,d0		;argumenten
	ble.s	parmexit
	cmp.b	#' ',d1
	ble.s	spaties	

;Copieer argumenten naar eigen buffer	
	addq.l	#1,d2		;Weer een argument erbij
	move.l	a2,(a3)+
	bra.s	copyarg

argcopyloop:
	move.b	(a0)+,d1
	subq.l	#1,d0
	cmp.b	#' ',d1
	ble.s	eindcopy
copyarg:
	move.b	d1,(a2)+
	bra	argcopyloop
eindcopy:	
	clr.b	(a2)+		;arg afsluiten met een 0
	bra.s	spaties
parmexit:
	cmpi.l	#1,d2		;# arg = 1  ? 
	bne	usage		;Niet het juiste aantal arg

	move.l	argpointers,a0	;pointer naar het eerste arg



	cmpi.b	#'d',(a0)	
	beq	dgoed
	cmpi.b	#'D',(a0)
	bne	usage
dgoed:	cmpi.b	#'f',1(a0)
	beq	fgoed
	cmpi.b	#'F',1(a0)
	bne	usage
fgoed:	cmpi.b	#':',3(a0)
	bne	usage
	cmpi.b	#'0',2(a0)
	blo	usage
	cmpi.b	#'3',2(a0)
	bhi	usage
;Argment klopt dus doorgaan !!
	clr.l	d0
	move.b	2(a0),d0
	subi.b	#'0',d0
	move.l	d0,drivenummer	

;Geheugen voor file reserveren en file lezen


			
	move.l	#tekst1,d2
	move.w	#endtekst1-tekst1,d3
	jsr	print


	move.l	ExecBase,a6		;ExecBase laden
	move.l	#1024,d0	;aantal bytes
	move.l	#2,d1		;ChipMem
	jsr	AllocMem(a6)
	move.l	d0,bootmem	;Bootmem komt bootblock in te staan

	move.w	#1023,d0	
	move.l	bootmem,a0
	move.l	#buf,a1
copyloop:
	move.b	(a1)+,(a0)+
	dbra	d0,copyloop


opnieuw:
	move.l	#tekst2,d2
	move.w	#endtekst2-tekst2,d3
	jsr	print

WaitMouseButton:
	btst	#6,$bfe001
	beq.s	LeftMouseButton
	btst	#10,$dff016
	beq.s	RightMouseButton
	bra.s	WaitMouseButton

RightMouseButton:
	btst	#10,$dff016
	beq.s	RightMouseButton
	bra	einde


LeftMouseButton:
	btst	#6,$bfe001
	beq.s	LeftMouseButton



	;Bootblock wegschrijven
	sub.l	a1,a1
	jsr	FindTask(a6)
	move.l	d0,readreply+$10


	lea	readreply,a1
	jsr	AddPort(a6)

	lea	diskio,a1
	move.l	drivenummer,d0		;drive nummer
	clr.l	d1
	lea	trddevice,a0
	jsr	OpenDev(a6)
	tst.l	d0
	bne	einde2

	lea	diskio,a1
	move.l	#readreply,14(a1)
	move.w	#15,28(a1)		;TD_PROTSTATUS
	move.l	execbase,a6
	jsr	DoIO(a6)	
	move.l	diskio+32,d0
	beq	schrijven
	
	move.l	#tekst5,d2		;Disk is Write protect
	move.w	#endtekst5-tekst5,d3
	jsr	print
	bra	verwijderdev		

schrijven:	
	lea	diskio,a1
	move.w	#3,28(a1)
	move.l	bootmem,40(a1)
	move.l	#2*512,36(a1)
	move.l	#0,44(a1)
	move.l	execbase,a6
	jsr	DoIO(a6)

	move.l	diskio+32,d6
	lea	diskio,a1
	move.w	#4,28(a1)
	move.l	#0,36(a1)
	jsr	DoIO(a6)

	lea	diskio,a1
	move.w	#9,28(a1)
	move.l	#0,36(a1)
	jsr	DoIO(a6)

verwijderdev:	
	lea	diskio,a1
	jsr	CloseDev(a6)

	lea	readreply,a1
	jsr	RemPort(a6)

	bra	opnieuw

einde2:
	lea	readreply,a1
	jsr	RemPort(a6)

einde:
	move.l	ExecBase,a6
	move.l	#1024,d0
	move.l	bootmem,a1
	jsr	FreeMem(a6)
	clr.l	d0
	rts


print:		;print tekst op scherm d3.w = lengte d2 = tekst
	movem.l	d1/a6,-(sp)
	move.l	DosBase,a6
	move.l	OutputHandle,d1
	jsr	Write(a6)
	movem.l	(sp)+,d1/a6
	rts

usage:
	move.l	#tekst3,d2
	move.w	#endtekst3-tekst3,d3
	jsr	print
	rts				;einde prog


alertprog:	;a0 moet alert struct bevatten
	move.l	a0,-(sp)
	lea	intuitionname(pc),a1	
	clr.l	d0	
	jsr	-$228(a6)	;open intuition library
	move.l	d0,a6
	move.l	#60,d1		;hoogte van alert
	clr.l	d0
	move.l	(sp)+,a0
	jsr	-90(a6)		;display alert
	move.l	a6,a1
	move.l	$4,a6
	jsr	-414(a6)	;CloseLibrary
	rts
IntuitionName:
	dc.b	'intuition.library',0
	even

DosName:
	dc.b	'dos.library',0
	even
DosBase:
	dc.l	0
OutputHandle:
	dc.l	0
bootmem:
	dc.l	0
drivenummer:
	dc.l	0
argtekst:
	blk.l	40
argpointers:
	blk.l	10
trddevice:	
	dc.b	'trackdisk.device',0
	even
diskio:
	blk.l	20,0
readreply:
	blk.l	8,0
buf:
	blk.b	512*2,'a'

tekst1:
	dc.b	'VirusProtectorBootBlockWriter V4.0',10
	dc.b	'Against SCA, ByteBandit and Byte-Warrior.',10
	dc.b	'Coding by A.Nonymous',10
	dc.b	'(C) 1988 by SYSTEM Z.(ASS & MADNESS)',10,10
endtekst1:
tekst2:
	dc.b	'Press LEFT mouse button to WRITE, Right mouse '
	dc.b	'button to QUIT',10,10
endtekst2:
tekst3:
	dc.b	'USAGE: Prot dfx:',10,10
endtekst3:
tekst5:
	dc.b	'Error: Disk is writeprotect!',10,10
endtekst5:

	even
Alert4:
	dc.w	180
	dc.b	20
	dc.b	'Something wonderful tried to screw up your disks.',0
	dc.b	1
	dc.w	200
	dc.b	30
	dc.b	'That is history. The SCA-Virus is eliminated.',0
	dc.b	1
	dc.w	140
	dc.b	46
	dc.b	'*** Thanks to the SYSTEM Z VIRUS KILLER V4.0 ***',0
	dc.b	0

	even	

Alert3:
	dc.w	160
	dc.b	20
	dc.b	'ByteBandit was playing with your AMIGA.',0
	dc.b	1
	dc.w	110
	dc.b	30
	dc.b	'That is history. The ByteBandit Virus is destroyed.',0
	dc.b	1
	dc.w	140
	dc.b	46
	dc.b	'*** Thanks to the SYSTEM Z VIRUS KILLER V4.0 ***',0
	dc.b	0

	even
Alert5:
	dc.w	160
	dc.b	20
	dc.b	"ByteWarrior was '??? protecting ???' your disks. ",0
	dc.b	1
	dc.w	110
	dc.b	30
	dc.b	'That is history. The ByteWarrior Virus is destroyed. ',0
	dc.b	1
	dc.w	140
	dc.b	46
	dc.b	'*** Thanks to the SYSTEM Z VIRUS KILLER V4.0 ***',0
	dc.b	0


