org	$50000
load	$50000

DosCheck="This"
WindPlace=$380

st:	dc.b	'DOS',0
	dc.b	'This is '

	dc.b "`Hallonboot 2.0a' by Mahoney & Kaktus!"

S:	movem.l	A0-A6/D0-D7,-(a7)
	move.w	#9,28(a1)
	clr.l	36(a1)
	jsr	-456(a6)
	lea	$dff180,A5
	LEA	$BFE001,A4
	OR.B	#2,(A4)

	bra.s	cont
	bra.s	s	;obs! hit hoppar programmet in
cont:
	tst.l	$226(a6)
	bne.s	virus
	lea	$2a(a6),a0
	move.l	a0,a1
	tst.l	(a0)+
	bne.s	Virus
	tst.l	(a0)+
	bne.s	Virus2
ItWasDiskRemove:
	tst.l	(a0)+
	beq.S	NoVirus
Virus2:	cmp.w	#$0300,-2(a0)
	beq.s	ItWasDiskRemove
virus:	clr.l	$226(a6)
	clr.l	(a1)+
	clr.l	(a1)+
	clr.l	(a1)+
virusl:	move.w	#$f23,(a5)
	bra.s	virusl

NOVIRUS:move.l	#$00840084,d7
	move.l	d7,(a5)
	move.l	(A6),A3
	move.l	(a3),a3
	move.l	38(a3),$0104.w

	lea	WindPlace.w,A1
	move.l	a1,a0
	moveq	#[L280-NewWindRut]/4,D0
	lea	NewWindRut(PC),A2
MoveW:	move.l	(A2)+,(A1)+
	dbf	D0,MoveW
	move.l	(a3),a1
	move.l	(a1),a1	;a1=intumem
	move.l	-202(A1),OLDOPENWINDOW-NewWindRut+WindPlace.W
	move.l	a0,-202(a1)

	BTST	#2,$16-$180(A5)
	BEQ	SmallCLI
	btst	#6,(A4)
	Bne	IngenBoot

	lea	FastMemFlag(PC),A2
	tst.l	78(A6)
	beq.s	FastmemArOff
	clr.b	(A2)	;on
FastmemArOff:
	move.l	$150(a6),a0	;Find resident disk.resource
	move.l	(a0),a0
	move.l	(a0),a0
	move.l	(a0),a0
	move.l	(a0),a0
	lea	52(a0),a0
	tst.l	(a0)+
	beq.s	DrvOn
	tst.l	(a0)+
	beq.s	DrvOn
	tst.l	(a0)+
	bne.s	DrvOff
DrvOn:	clr.b	ExtDrvFlag-FastmemFlag(A2)
DrvOff:

	move.l	a3,a6
	lea	$78000,a0
	move.l	a0,$0108.w
PrintText:
	move.w	#$1eb,D0	;$7b0 bytes - scrsize x=$18*y=$52
ClrLop:	clr.l	(A0)+
	dbf	D0,ClrLop
	lea	-4096(A0),A1
	jsr	-198(A6)
	move.l	148(A6),52(A1)
	move.w	#$8,58(A1)
	move.w	#$4,28(A1)
	lea	128(A1),A0
	move.l	A0,4(A1)
	moveq	#1,D0
	move.w	#$c0,D1	;320
	move.w	#$c8,D2
	jsr	-390(A6)
	move.l	$0108.w,136(A1)
	lea	L280(PC),A0
L1f8:	moveq	#0,D0
	move.w	d0,36(A1)
	move.b	(A0)+,D0
	move.b	(A0)+,56(A1)
	move.b	(A0)+,37(A1)
	move.b	(A0)+,39(A1)
	movem.l	A0-A1/D0,-(A7)
	jsr	-60(A6)
	movem.l	(A7)+,A0-A1/D0
	add.w	D0,A0
	tst.b	(A0)
	bne.s	L1f8
	move.l	$04.w,A6

	lea	Copper(PC),A2
	move.l	A2,$80-$180(A5)
	move.w	#$8380,$96-$180(A5)
	move.l	a5,a0
	moveq	#$f,d0
	move.l	#$05450545,d7
GreyLop:move.l	d7,(a0)+
	dbf	d0,GreyLop

MainLoop:
	or.b	#$80,-$f01(A4)	;$bfd100
	and.b	#$f7,-$f01(A4)	;$bfd100

	move.b	$c00(A4),D0	;$bfec01
	cmp.b	#$59,D0
	beq.s	SmallCLI
	cmp.b	#$57,D0
	beq.s	LargeCLI
	cmp.b	#$5d,D0
	beq.s	SetDrivesOff
	cmp.b	#$5b,D0
	beq.s	HardReset
	cmp.b	#$5f,D0
	beq.s	SetFastmemOff
	cmp.b	#$55,D0
MainL:	bne.s	MainLoop

NormalCLI:
	move.l	$0104.w,$80-$180(A5)
	move.w	#$0100,$96-$180(a5)
	move.l	D7,(A5)
IngenBoot:
	movem.l	(A7)+,A0-A6/D0-D7
	move.l	$12c(a6),a0	;normal boot-continue
	move.l	$54(a0),a0
	move.l	22(a0),a0
	moveq	#0,D0
	rts

SmallCLI:
	MOVE.W	#142,WindPlace+2.w
	MOVE.W	#50,WindPlace+2+6.w
	bra.s	NormalCli
LargeCLI:
	MOVE.W	#$100,windplace+2+6.w
	bra.s	NormalCli

SetDrivesOff:
	lea	L382(PC),A0
	tst.b	ExtDrvFlag-L382(a0)
	bne.s	MainLoop
	moveq	#[L400+4-L382]/4,D0
	lea	$0300.w,A1
	move.l	A1,46(A6)
L354:	move.l	(A0)+,(A1)+
	dbf	D0,L354
	bsr.s	L3a8
	bra.s	L100

HardReset:
	clr.l	38(A6)
L100:	move.l	$fc0004,$80.w
	trap	#0


SetFastmemOff:
	tst.b	FastMemFlag-Copper(A2)
	bne.s	MainL
	move.l	#$7fff7fff,$9a-$180(a5)
	move.w	#$7fff,$96-$180(a5)
	lea	$fc0280,a5
moff_1:	cmp.w	#$21fc,-(a5)
	bne.s	moff_1
	sub.l	a4,a4
	lea	$0676.w,a6
	lea	$80000,a3
	move.l	a5,$80.w
	trap	#0



L382:	movem.l	A0-A6/D0-D7,-(A7)	;Slakta Drives-reset-rut
	lea	L382(pc),a0	;lea	$0300.w,A0
	move.l	A0,46(A6)
	bsr.s	L3a8
	move.l	-100(A6),L400-L382(A0)	;byt ut "InitResident"-rut
	lea	L3BC(pc),A0
	move.l	A0,-100(A6)
	movem.l	(A7)+,A0-A6/D0-D7
	rts
L3a8:	moveq	#0,D0
	lea	34(A6),A1
	moveq	#$17,D1
L3b0:	add.w	(A1)+,D0
	dbf	D1,L3b0
	not.w	D0
	move.w	D0,(A1)
	rts
L3bc:	cmp.w	#"di",$1a(a1)	;kolla om "disk.resource"
	bne.s	L3fe
	movem.l	A0/a2/D0-D1,-(A7)
	lea	$0100.w,A0
	move.l	a0,a2
	moveq	#$73,D1
L3d6:	move.l	(A1)+,(A2)+
	dbf	D1,L3d6
	lea	68(A0),A1
	move.l	A1,22(A0)
	move.l	#$26fcffff,392(A0)	;move.l	#-1,(a3)+
	move.l	#$ffff4e75,396(A0)	;rts istallet for enable drives
	move.l	A0,A1
	movem.l	(A7)+,A0/a2/D0-D1
L3fe:	DC.W	$4EF9	;JMP $
L400:


NEWWINDRUT:
	MOVE.W	#$0280,4(A0)
	move.w	#$00c8,6(A0)
	move.l	oldopenwindow-NewWindRut+WindPlace.w,-202(a6)
ol:	jsr	0
	movem.l	d0-d7/a0-a6,-(a7)
	moveq	#-1,d0
WindWai:dbf	d0,WindWai
	move.l	56(A6),A1	;a6=intu
	move.l	88(A1),A0
	move.b	#$01,5(A0)
	move.w	12(A1),D0
	move.w	14(A1),D1
	move.l	196(A1),A0
	move.l	4(a6),a5
	move.l	4(a5),a5	;a5=gramem
	jsr	-498(A5)	;FreeRaster (planeptr,width,height)
				;		a0	d0	d1
	jsr	-384(A6)	;RemakeDisplay (a6=intu)
	movem.l	(a7)+,d0-d7/a0-a6
	rts

OLDOPENWINDOW=ol+2

L280:	dc.b 15,$07,14,$07,'HallonBoot 2.0a'
	dc.b 18
FastMemFlag:
	dc.b    $04,08,$14
			dc.b 'F1. Remove fastmem'
	dc.b 17
ExtDrvFlag:
	dc.b    $04,09,$1d,'F2. Remove drives'
	dc.b 18,$00,10,$26,'F3. Reset/Clearmem'
	dc.b 13,$00,11,$2f,'F4. Small CLI'
	dc.b 13,$00,12,$38,'F5. Large CLI'
	dc.b 08,$00,13,$41,'F6. Exit'
	dc.b 22,$02,00,$50,'© Mahoney & Kaktus -90'
;	dc.b $00

Copper:	dc.w $00e0,$0007,$00e2,$8000
	dc.w $0100,$9200,$0102,$0020,$0104,$0000
	dc.w $008e,$44a1,$0090,$9608,$0092,$0050,$0094,$0078
	dc.w $0182,$0fff
	dc.w $ffff,$fffe

dc.b "My love to ES+US+JA+PB+MH+LN"

end:
blk.b	$100,0

org	$40000
load	$40000
Mycheck=ol+2
c:	lea	st+8,a0
	move.l	#$444f5300,d0	;"DOS",0
	move.w	#$fd,d1
c_0:	add.l	(a0)+,d0
	bcc.s	c_1
	addq.l	#1,d0
c_1:	dbf	d1,c_0
	not.l	d0
	move.l	#DosCheck,d1
	sub.l	d1,d0
	bcc.s	c_2
	subq.l	#1,d0
c_2:	move.l	#DosCheck,st+4	;dos-checksum
	move.l	#ol+2,d1
	and.l	#$2,d1
	beq.s	c_3
	swap	d0
c_3:	move.l	d0,ol+2		;place to insert mychecksum
	rts

