	section andy,code_c
	opt c-,d+

	*************************
	* Setup V2.1 Rev.3/3/90 *
	*************************

startlist1	equ	38
startlist2	equ	50

plnw		equ	40
plnh		equ	266
plnsize		equ	plnw*plnh
plnnum		equ	2
plndata		equ	plnsize*plnnum

	move.l	4,a6
	move.l	#$10002,d1
	move.l	#plndata,d0
	jsr	-198(a6)
	cmp.l	#$00,d0
	beq	error
	move.l	d0,plnbase

	move.l	4,a6
	move.l	#gfxname,a1
	moveq.l	#0,d0
	jsr	-552(a6)
	move.l	d0,gfxbase

	move.l	gfxbase,a4


	move.l	4,a6
	move.l	#dosname,a1
	moveq.l	#0,d0
	jsr	-552(a6)
	move.l	d0,dosbase

	MOVE.W	#$0080,$dff096
	move.w	$dff01c,sysint
	or.w	#$c000,sysint
	;move.w	#$7fff,$dff09a
	;move.w	#$c020,$dff09a
	move.l	$6c,intsave
	move.l	#newcopper,$dff080
	clr.w	$dff088
	move.w	#$8480,$dff096	
	move.l	plnbase,a1
	move.l	#plnsize,d0
	move.l	a1,stor
	move.l	stor,pln1
	move.w	stor,bp2+2
	move.w	stor+2,bp2+6

	add.l	d0,stor
	move.l	stor,pln2
	move.w	stor,bp1+2
	move.w	stor+2,bp1+6

	add.l	#40*24,pln1	

	move.l	#2559,d0
	lea	screen,a0
	move.l	pln2,a1
loop:	move.l	(a0)+,(a1)+
	dbra	d0,loop

	move.b	#0,xpos
	move.b	#0,ypos

	move.w	#0,bordcol+2
	move.w	#0,backcol+2
	move.w	#$0fff,pencol+2

	lea	starttxt,a0
	jsr	print
wait2:	btst	#6,$bfe001		;wait for mouse.
	bne	wait2


wait3:	btst	#6,$bfe001		;wait for mouse.
	beq	wait3

	move.w	#$089f,bordcol+2
	move.w	#$015b,backcol+2
	move.w	#$089f,pencol+2

	jsr	cls

	lea	txt1,a0
	jsr	print

	;lea	getdirtxt,a0
	;jsr	print

	;move.l	#1,getdir
	
	jsr	killspr

	;move.l	#isr,$6c

wait:	jsr	task			;jmp to our sub.
	btst	#6,$bfe001		;wait for mouse.
	bne	wait
	move.l	gfxbase,a4
	move.l	startlist1(a4),$dff080
	move.l	startlist2(a4),$dff084
	clr.w	$dff088	
	;move.l	intsave,$6c
	;move.w	sysint,$dff09a
	move.w	#$8080,$dff096
	move.w	#$0400,$dff096
	move.l	4,a6
	move.l	plnbase,a1
	move.l	#plndata,d0
	jsr	-210(a6)
	move.l	gfxbase,a1
	jsr	-414(a6)

error:	move.w	#$0fff,$dff180
	rts				;exit.

newcopper:					
	dc.w	$0100,$2200
scrl:	dc.w	$0102,$0000

bp1:	dc.w	$00e0,$0000,$00e2,$0000
bp2:	dc.w	$00e4,$0000,$00e6,$0000
bp3:	dc.w	$00e8,$0000,$00ea,$0000
bp4:	dc.w	$00ec,$0000,$00ee,$0000
bp5:	dc.w	$00f0,$0000,$00f2,$0000

	dc.w	$008E,$2c81,$0090,$2cc1                                 
	dc.w	$0092,$0038,$0094,$00d0
mod:	dc.w	$0108,$0000,$010a,$0000

sp0:	dc.w	$0120,$0000,$0122,$0000	
sp1:	dc.w	$0124,$0000,$0126,$0000	
sp2:	dc.w	$0128,$0000,$012a,$0000	
sp3:	dc.w	$012c,$0000,$012e,$0000	
sp4:	dc.w	$0130,$0000,$0132,$0000	
sp5:	dc.w	$0134,$0000,$0136,$0000	
sp6:	dc.w	$0138,$0000,$013a,$0000	
sp7:	dc.w	$013c,$0000,$013e,$0000	

bordcol:dc.w	$0180,$089f
backcol:dc.w	$0182,$015b
pencol:	dc.w	$0186,$089f

	dc.w	$ffff,$fffe

	dc.b	'********  Write to me (Mindeater) ********'
	dc.b	'A.Clark    2 Highfield Rise    Eastend Road    Hull    HU12 8RA    '
	dc.b	'********      Thanks!!!     ********'

	
gfxname:dc.b	'graphics.library',0
	even
gfxbase:dc.l	0

dosname:dc.b	'dos.library',0
	even
dosbase:dc.l	0

stor:	dc.l	0
pln1:	dc.l	0
pln2:	dc.l	0
pln3:	dc.l	0
pln4:	dc.l	0
pln5:	dc.l	0
sysint:	dc.w	0
intsave:dc.l	0
int2save:dc.l	0
plnbase:dc.l	0
copsave1:dc.l	0
copsave2:dc.l	0

xpos:	dc.b	0
ypos:	dc.b	0
cstate:	dc.w	0	;1 on
ccount:	dc.w	0
crate:	dc.w	6800
inverse:dc.l	0
getdir:	dc.l	0
shft:	dc.l	0
stringoff:
	dc.l	0
loaded:	dc.l	0
zero:	dc.l	0

isr:	movem.l	d0-d7/a0-a6,-(sp)
	move.w	#$0020,$dff09c
	movem.l	(sp)+,d0-d7/a0-a6
	rte

task:	;move.w	$dff006,d0
	;and.w	#$ff00,d0
	;cmp.w	#$ff00,d0
	;bne	task
	tst.l	getdir
	beq	.lp

	jsr	loaddir
.lp:	jsr	docurs

	jsr	getkey
	tst.l	keyread
	beq	.lp2
	jsr	dokeys
.lp2:	rts


	*****************************
	*Note:-       		    *
	* A-Obj       		    *
	* B-Msk                     *
	* C-Bck                     *
	* D-Bck                     *
	* M-00001111 10111000       *
	*****************************



	******************************
	*Char string print grey chars
	*chars 1 bp,528 pix w,66 chars 
	*screen width equ #40b
	*a0 text string x,y
	*pln num in a6
	*255 cr,0 termination
	*d7,d6
	*a0,a5,a6
	******************************
Print:	
	move.b	xpos,(a0)
	move.b	ypos,1(a0)
	move.l	#0,inverse
	move.l	pln1,a6
	moveq.l	#0,d7
	moveq.l	#0,d6
	move.b	(a0)+,d7	;get x
	add.l	d7,a6
	move.b	(a0)+,d7	;get y
	mulu.w	#40*8,d7
	add.l	d7,a6		;a6 strt addr

prchr2:	moveq.l	#0,d7
	lea	chars,a5
invbac:	move.b	(a0)+,d7	;get char
	beq	prend2
	cmp.b	#255,d7
	beq	print
	cmp.b	#13,d7
	beq	ret
	cmp.b	#128,d7
	bne	noinv
	move.l	#1,inverse
	bra	invbac
noinv:	sub.b	#32,d7
	btst.l	#6,d7
	beq	notlo2
	sub.b	#32,d7
notlo2:	add.l	d7,a5
	
	move.b	(a5),(a6)
	move.b	64(a5),40(a6)
	move.b	128(a5),80(a6)
	move.b	192(a5),120(a6)
	move.b	256(a5),160(a6)
	move.b	320(a5),200(a6)
	move.b	384(a5),240(a6)
	move.b	448(a5),280(a6)
	tst.l	inverse
	beq	noinv2
	eor.b	#-1,(a6)
	eor.b	#-1,40(a6)
	eor.b	#-1,80(a6)
	eor.b	#-1,120(a6)
	eor.b	#-1,160(a6)
	eor.b	#-1,200(a6)
	eor.b	#-1,240(a6)
	eor.b	#-1,280(a6)
noinv2:	add.l	#1,a6
	bra	prchr2
prend2:	rts	
ret:	cmp.b	#24,ypos
	beq	ret2
	add.b	#1,ypos
	bra	invbac
ret2:	
	move.l	pln1,d0
	move.l	d0,d1
	add.l	#8*40,d1
	move.l	d1,$dff050	;a source IM
	move.l	d0,$dff054	;d source
	move.w	#$0000,$dff064	;a mod
	move.w	#$0000,$dff066	;d mod
	move.w	#$ffff,$dff044	;fw mask
	move.w	#$ffff,$dff046	;lw mask
	move.w	#%0000100111110000,$dff040	;con0
	move.w	#%0000000000000000,$dff042	;con1
	move.w	#%0011001000010100,$dff058	;size		
.lp:	btst	#14,$dff002
	bne	.lp

	bra	invbac

chars:	incbin	'charsiff'
	even

	**************************
	*Read keyboard & auto repeat
	*key in keyread.b
	*d0
	**************************

Getkey:	
	move.b	$bfec01,keyread
	beq	.lq
	move.b	#0,$bfec01
.lq:	rts
	cmp.b	#0,keyrep
	beq	tstkey
	move.b	keypress,d0
	cmp.b	$bfec01,d0
	beq	subrep
newkey:	move.b	$bfec01,keypress
	move.b	$bfec01,keyread
	move.b	#4,keyrep
	rts
subrep:	sub.b	#1,keyrep
	move.b	#0,keyread
	rts
tstkey:	move.b	keypress,d0
	cmp.b	$bfec01,d0
	bne	newkey
	move.b	$bfec01,keyread
	rts	
nokeys:
	move.b	#0,keyread
	rts

keyread:
	dc.l	0
slow:	dc.l	0
keyrep:	dc.l	0
keypress:
	dc.l	0
	even
txtdig:	
	dc.b	$eb,$fd,$fb,$f9,$f7,$f5		;nums
	dc.b	$f3,$f1,$ef,$ed

	dc.b	$e1,$c5,$c3,$c1,$a5,$a3,$a1,$85,$83,$81		;keypad

	dc.b	$bf,$95,$99,$bb,$db,$b9			;a-z
	dc.b	$b7,$b5
	dc.b	$d1,$b3,$b1,$af,$91,$93,$cf,$cd
	dc.b	$df,$d9,$bd,$d7,$d3,$97,$dd,$9b
	dc.b	$d5,$9d

	dc.b	$7f,$8f,$8d,$8b,$ad,0

shtxtdig:
	dc.b	$fd,$fb,$f9,$f7,$f5		;nums
	dc.b	$f3,$f1,$ef,$ed,$eb

	dc.b	$ad,$8b,0

txtnum:	dc.b	'0123456789'
	dc.b	'0123456789'	;keypad
	dc.b	'ABCDEFGHIJKLMNOPQRSTUVWXYZ ,./;'''

shtxtnum:
	dc.b	'!"#$%^&*():?'

hexdig:	dc.b	'0123456789abcdef'

string:	dc.b	0,0,' ',0
comline:ds.b	41
	even

dokeys:	;move.b	xpos,-(sp)
	;move.b	ypos,-(sp)
	;move.b	#0,xpos
	;move.b	#0,ypos
	;lea	hexdig,a0
	;moveq.l	#0,d0
	;move.b	keyread,d0
	;and.b	#$0f,d0
	;move.b	(a0,d0),shkeytxt+3
	;move.b	keyread,d0
	;and.b	#$f0,d0
	;lsr.b	#4,d0
	;move.b	(a0,d0),shkeytxt+2
	;lea	shkeytxt,a0
	;jsr	print
	;move.b	(sp)+,ypos
	;move.b	(sp)+,xpos

	move.b	keyread,d0
	cmp.b	#$3f,d0
	beq	shfton
	cmp.b	#$3d,d0
	beq	shfton

	cmp.b	#$7d,d0
	beq	delch

	cmp.b	#$77,d0
	beq	retch

	cmp.b	#$3e,d0
	beq	shftoff
	cmp.b	#$3c,d0
	beq	shftoff

	tst.l	shft
	bne	keyshft


	move.l	stringoff,d2
	cmp.l	#39,d2
	bne	.lp2
	rts

.lp2:	moveq.l	#0,d1
	lea	txtnum,a0
	lea	txtdig,a1
.lp:	cmp.b	(a1,d1),d0
	beq	.gotch
	add.b	#1,d1
	tst.b	(a1,d1)
	bne	.lp
	rts
.gotch:	lea	comline,a1
	move.l	stringoff,d0
	move.b	(a0,d1),(a1,d0)
	move.b	(a0,d1),string+2
	lea	string,a0
	jsr	print
	add.l	#1,stringoff
	add.b	#1,xpos
	move.b	#0,ccount
	move.b	#0,cstate
	rts

keyshft:move.l	stringoff,d2
	cmp.l	#39,d2
	bne	.lp2
	rts

.lp2:	moveq.l	#0,d1
	lea	shtxtnum,a0
	lea	shtxtdig,a1
.lp:	cmp.b	(a1,d1),d0
	beq	.gotch
	add.b	#1,d1
	tst.b	(a1,d1)
	bne	.lp
	rts
.gotch:	lea	comline,a1
	move.l	stringoff,d0
	move.b	(a0,d1),(a1,d0)
	move.b	(a0,d1),string+2
	lea	string,a0
	jsr	print
	add.l	#1,stringoff
	add.b	#1,xpos
	move.b	#0,ccount
	move.b	#0,cstate
	rts

shfton:	move.l	#1,shft
	;move.w	#$0fff,col+2
	rts
shftoff:move.l	#0,shft
	;move.w	#$089f,col+2
	rts
delch:	tst.l	stringoff
	beq	.lp
	sub.l	#1,stringoff
	lea	comline,a0
	move.l	stringoff,d0
	move.b	#0,(a0,d0)
	move.b	#32,string+2
	lea	string,a0
	jsr	print
	sub.b	#1,xpos
	lea	string,a0
	jsr	print
	move.b	#0,ccount
	move.b	#0,cstate
.lp:	rts

shkeytxt:
	dc.b	0,0,'00',0
	
	even
	
killspr:
	move.l	#blnkspr,d0
	move.w	d0,sp0+6
	move.w	d0,sp1+6
	move.w	d0,sp2+6
	move.w	d0,sp3+6
	move.w	d0,sp4+6
	move.w	d0,sp5+6
	move.w	d0,sp6+6
	move.w	d0,sp7+6
	swap	d0
	move.w	d0,sp0+2
	move.w	d0,sp1+2
	move.w	d0,sp2+2
	move.w	d0,sp3+2
	move.w	d0,sp4+2
	move.w	d0,sp5+2
	move.w	d0,sp6+2
	move.w	d0,sp7+2
	rts
blnkspr:ds.l	4

txt1:	dc.b	0,0,13,255
	dc.b	0,0,'    ****  commodore 64 basic v2 ****',13,255
	dc.b	0,0,13,255
	dc.b	0,0,' 64k ram system  38911 basic bytes free',13,255
	dc.b	0,0,13,255
	dc.b	0,0,'ready.',13,0
rdytxt:	dc.b	0,0,13,255
	dc.b	0,0,'ready.',13,0
rdy2txt:dc.b	0,0,13,13,255
	dc.b	0,0,'ready.',13,0
rettxt:	dc.b	0,0,13,0
syntxt:	dc.b	0,0,13,13,255
	dc.b	0,0,'?syntax  error',13,255
rdy3txt:dc.b	0,0,'ready.',13,0
fretxt:	dc.b	0,0,'0 blocks free.',13,0
dsktxt:	dc.b	0,0,128,'0    "'
DISKNAM:DC.B	'pussy demo disk ",00,2d',13,0
dirtxt1:dc.b	0,0,13,13,255
	dc.b	0,0,'searching for $',13,0
dirtxt2:dc.b	0,0,'loading',13,0
dirtxt3:dc.b	0,0,'ready.',13,0
helptxt:dc.b	0,0,'        ',128,'commodore 64 boot system',13,255
	dc.b	0,0,'  ',128,'coded by mindeater of pussy 05/08/90',13,255
	dc.b	0,0,'****************************************',13,13,255
	dc.b	0,0,'instrucions:',13,13,255
	dc.b	0,0,'load"$",8 <return>  (loads directory)',13,255
	dc.b	0,0,13,255
	dc.b	0,0,'list <return>  (lists entries)',13,255
	dc.b	0,0,13,255
	dc.b	0,0,'load"filename",8,1 <return> (loads demo)',13,13,255
	dc.b	0,0,13,255
	dc.b	0,0,'there are other commands find them',13,255
	dc.b	0,0,'yourself.',13,255
	dc.b	0,0,'enjoy this disk.',13,0
fnftxt:	dc.b	0,0,'?file not found  error',13,255
	dc.b	0,0,'ready.',13,0
lodtxt:	dc.b	0,0,'loading',13,0
starttxt:
	dc.b	0,0,'             64 boot system',13,13,255
	dc.b	0,0,'                   by',13,13,255
	dc.b	0,0,'      ****** ****** ****** ******',13,255
	dc.b	0,0,'      **     **  ** **     **  **',13,255
	dc.b	0,0,'      ****** ****** ** *** ******',13,255
	dc.b	0,0,'          ** **  ** **  ** **  **',13,255
	dc.b	0,0,'      ****** **  ** ****** **  **',13,13,255
	dc.b	0,0,'          coding by mindeater',13,13,13,255
	dc.b	0,0,'members are:-',13,13,255
	dc.b	0,0,'      mystik            mindeater',13,255
	dc.b	0,0,'      wizoid             overkill',13,255
	dc.b	0,0,'      xeno                 techno',13,255
	dc.b	0,0,'      electro          electronic',13,255
	dc.b	0,0,'      stryx                iceman',13,255
	dc.b	0,0,'      the jedi               andy',13,13,13,255
	dc.b	0,0,'    press left mouse button to start',0

	dc.b	'********  Write to me (Mindeater) ********'
	dc.b	'A.Clark    2 Highfield Rise    Eastend Road    Hull    HU12 8RA    '
	dc.b	'********      Thanks!!!     ********'
	even
screen:	incbin	'screeniff'
	even

docurs:	tst.w	ccount
	beq	.lp
	sub.w	#1,ccount
	rts
.lp:	move.w	crate,ccount
	bchg.b	#0,cstate+1
	move.l	pln1,a0
	moveq.l	#0,d0
	move.b	xpos,d0
	add.l	d0,a0
	moveq.l	#0,d0
	move.b	ypos,d0
	mulu	#40*8,d0
	add.l	d0,a0
	eor.b	#-1,(a0)
	eor.b	#-1,40(a0)
	eor.b	#-1,80(a0)
	eor.b	#-1,120(a0)
	eor.b	#-1,160(a0)
	eor.b	#-1,200(a0)
	eor.b	#-1,240(a0)
	eor.b	#-1,280(a0)
	rts

loaddir:
	move.l	dosbase,a6
	move.l	#locknam,d1
	move.l	#-2,d2
	jsr	-84(a6)		;lock
	move.l	d0,lock

	move.l	dosbase,a6
	move.l	lock,d1
	move.l	#infodata,d2
	jsr	-102(a6)	;GET NAME OF DISK
	
	lea	infodata+8,a0
	lea	disknam,a1
	moveq.l	#15,d0
.lp:	move.b	(a0)+,(a1)+
	beq	.lp2
	dbra	d0,.lp
	bra	.lp4

.lp2:	sub.l	#1,a1
.lp3	move.b	#32,(a1)+
	dbra	d0,.lp3

.lp4:	
	tst.l	getdir
	bmi	.lq1

	lea	dirtxt2,a0
	jsr	print

.lq1:	move.l	dosbase,a6
	move.l	lock,d1
	jsr	-90(a6)		;unlock df0:
	move.l	d0,lock

	move.l	dosbase,a6
	move.l	#dirnam,d1
	move.l	#-2,d2
	jsr	-84(a6)		;lock
	move.l	d0,lock

	lea	dirlist,a0
	move.l	#0,numdir

	move.l	a0,-(sp)

.lp8:	move.l	dosbase,a6
	move.l	lock,d1
	move.l	#infodata,d2
	jsr	-108(a6)	;examine next
	tst.l	d0
	beq	.lp5		;no more

	move.l	#0,d2		;num chars written
	lea	infodata+124,a1	;get length
	move.l	(a1),d0
	lsr.l	#8,d0
	move.l	(sp)+,a0
	move.l	a0,-(sp)
	add.l	#2,a0

	move.l	#0,zero
	move.l	d0,d1
	divu	#1000,d0
	tst.l	zero
	bne	.zdun1
	tst.w	d0
	beq	.len1
.zdun1:	add.b	#48,d0
	move.b	d0,(a0)+
	sub.b	#48,d0
	mulu	#1000,d0
	sub.l	d0,d1
	add.l	#1,d2
	move.l	#-1,zero

.len1:	move.l	d1,d0
	divu	#100,d0
	tst.l	zero
	bne	.zdun2
	tst.w	d0
	beq	.len2
.zdun2	add.b	#48,d0
	move.b	d0,(a0)+
	sub.b	#48,d0
	mulu	#100,d0
	sub.l	d0,d1
	add.l	#1,d2

.len2:	move.l	d1,d0
	divu	#10,d0
	tst.l	zero
	bne	.zdun3
	tst.w	d0
	beq	.len3
.zdun3	add.b	#48,d0
	move.b	d0,(a0)+
	sub.b	#48,d0
	mulu	#10,d0
	sub.l	d0,d1
	add.l	#1,d2

.len3:	move.l	d1,d0
	tst.l	zero
	bne	.zdun4
	tst.w	d0
	beq	.len4
.zdun4	add.b	#48,d0
	move.b	d0,(a0)+
	add.l	#1,d2

.len4:	cmp.l	#4,d2
	beq	.len5
	move.b	#32,(a0)+
	add.l	#1,d2
	bra	.len4

.len5:	lea	infodata+8,a1
	move.l	(sp)+,a0
	move.l	a0,a2
	add.l	#8,a0
	moveq.l	#15,d0
.lpa:	move.b	(a1)+,d7
	beq	.notlo3
	sub.b	#32,d7
	btst.l	#6,d7
	beq	.notlo2
	sub.b	#32,d7
.notlo2:add.b	#32,d7
.notlo3:move.b	d7,(a0)+
	beq	.lp6
	dbra	d0,.lpa
	bra	.lp7

.lp6:	sub.l	#1,a0
	move.b	#34,(a0)+
.lp9:	move.b	#32,(a0)+
	dbra	d0,.lp9
.lp7:	;move.b	#34,(a0)+
	add.l	#7,a0
	move.b	#255,(a0)+

	;jsr	print
	add.l	#1,numdir
	add.l	#33,a2
	move.l	a2,-(sp)
	bra	.lp8

.lp5:	move.l	(sp)+,a0
	move.b	#0,-(a0)

	tst.l	getdir
	bmi	.lq2	

	lea	dirtxt3,a0
	jsr	print
.lq2:	move.l	#0,getdir
	rts

prntdir:lea	rettxt,a0
	jsr	print

	lea	dsktxt,a0
	jsr	print

	lea	dirlist,a0
	jsr	print

	lea	fretxt,a0
	jsr	print

	lea	rdytxt,a0
	jsr	print
	rts

retch:	tst.l	stringoff
	beq	nocomm
	lea	comline,a0	;get commands
	move.l	a0,a4	
	lea	commaddr,a1
	lea	commrout,a2
	moveq.l	#0,d0		;comm count * 4
	moveq.l	#0,d2		;comm count
morcomm:move.l	(a1,d0),a3
	move.l	a4,a0
	moveq.l	#0,d1		;index into string/comm
.lp:	tst.b	(a3,d1)
	beq	gotcomm
	move.b	(a0,d1),d3
	cmp.b	#32,d3		;get rid of spaces
	bne	.lp2
	add.l	#1,a0
	bra	.lp
.lp2:	cmp.b	(a3,d1),d3
	bne	notcomm
	add.b	#1,d1
	bra	.lp
notcomm:add.l	#1,d2
	add.l	#4,d0
	cmp.l	#numcomm,d2
	bne	morcomm
	jsr	clrcurs
	move.b	#0,xpos
	lea	syntxt,a0
	jsr	print
	jsr	clrcomm
	rts	
nocomm:	jsr	clrcurs
	lea	rettxt,a0
	jsr	print
	bra	clrcomm
gotcomm:move.l	(a2,d0),a1
	jmp	(a1)

numcomm	equ	9

commaddr:dc.l	comm1,comm2,comm3,comm4,comm5,comm6,comm7,comm8,comm9
commrout:dc.l	dirload,list,bord,back,help,load,cls,cls,reset

comm1:	dc.b	'LOAD"$",8',0
comm2:	dc.b	'LIST',0
comm3:	dc.b	'POKE53280,',0
comm4:	dc.b	'POKE53281,',0
comm5:	dc.b	'HELP',0
comm6:	dc.b	'LOAD"',0
comm7:	dc.b	'?CHR$(147)',0
comm8:	dc.b	'PRINTCHR$(147)',0
comm9:	dc.b	'SYS64738',0
	dc.b	'********  Write to me (Mindeater) ********'
	dc.b	'A.Clark    2 Highfield Rise    Eastend Road    Hull    HU12 8RA    '
	dc.b	'********      Thanks!!!     ********'

	even

dirload:
	move.l	#1,loaded
	jsr	clrcurs
	jsr	clrcomm
	move.b	#0,xpos	
	lea	dirtxt1,a0
	jsr	print
	move.l	#1,getdir
	rts
list:
	jsr	clrcurs
	jsr	clrcomm
	move.b	#0,xpos	
	tst.l	loaded
	beq	.lp
	lea	rettxt,a0
	jsr	print
	jsr	prntdir
	rts
.lp:	lea	rdy2txt,a0
	jsr	print
	rts
bord:
	move.w	#0,d0
	add.l	d1,a0
	move.b	(a0)+,d0
	tst.b	(a0)
	beq	.1dig
	lsl.l	#8,d0
	move.b	(a0),d0
.1dig:	move.l	#0,d1
	lea	colwords,a0
.lp:	cmp.w	(a0,d1),d0
	beq	.gotcol
	add.l	#2,d1
	cmp.l	#32,d1
	bne	.lp
	jsr	clrcurs
	move.b	#0,xpos	
	jsr	clrcomm
	lea	syntxt,a0
	jsr	print
	rts
.gotcol:lea	realcols,a0
	move.w	(a0,d1),bordcol+2
	jsr	clrcurs
	move.b	#0,xpos	
	jsr	clrcomm
	lea	rdy2txt,a0
	jsr	print
	rts

back:
	move.w	#0,d0
	add.l	d1,a0
	move.b	(a0)+,d0
	tst.b	(a0)
	beq	.1dig
	lsl.l	#8,d0
	move.b	(a0),d0
.1dig:	move.l	#0,d1
	lea	colwords,a0
.lp:	cmp.w	(a0,d1),d0
	beq	.gotcol
	add.l	#2,d1
	cmp.l	#32,d1
	bne	.lp
	jsr	clrcurs
	move.b	#0,xpos	
	jsr	clrcomm
	lea	syntxt,a0
	jsr	print
	rts
.gotcol:lea	realcols,a0
	move.w	(a0,d1),backcol+2
	jsr	clrcurs
	move.b	#0,xpos	
	jsr	clrcomm
	lea	rdy2txt,a0
	jsr	print
	rts

help:	
	jsr	cls
	lea	helptxt,a0
	jsr	print
	lea	rdytxt,a0
	jsr	print
	rts
load:	
	add.l	d1,a0
	move.l	a0,-(sp)
	jsr	clrcurs
	move.b	#0,xpos	
	tst.l	loaded
	bne	.lp
	move.l	#-1,getdir
	jsr	loaddir
.lp:	
	move.l	(sp)+,a1

	lea	filename,a0
.lp2:	move.b	(a1)+,(a0)+
	beq	.lp3
	cmp.b	#34,(a1)
	bne	.lp2
	move.b	#0,(a0)
	add.l	#1,a1
	cmp.b	#',',(a1)+
	bne	.lp3
	cmp.b	#'8',(a1)+
	bne	.lp3
	cmp.b	#',',(a1)+
	beq	.lp8
	sub.l	#1,a1
	cmp.b	#0,(a1)+
	beq	.lp9
.lp8:	cmp.b	#'1',(a1)+
	bne	.lp3
.lp9:	lea	rettxt,a0
	jsr	print
	lea	seartxt,a0
	jsr	print
	lea	rettxt,a0
	jsr	print
	tst.l	numdir		;any entries
	beq	.lp4		;none

	moveq.l	#0,d0		;entrie number
	moveq.l	#0,d1		;index into names
	lea	dirlist+8,a0
	lea	filename,a1
.lp5:	cmp.b	#42,(a1,d1)
	beq	.gotentry
	tst.b	(a1,d1)
	beq	.gotentry
	move.b	(a1,d1),d2
	cmp.b	(a0,d1),d2
	bne	.nope
	tst.b	d2
	beq	.gotentry
	add.b	#1,d1
	bra	.lp5
.nope:	add.l	#33,a0
	moveq.l	#0,d1
	add.l	#1,d0
	cmp.l	numdir,d0
	bne	.lp5
	lea	fnftxt,a0
	jsr	print
	jsr	clrcomm
	rts
.lp3:	jsr	clrcomm
	lea	syntxt,a0
	jsr	print
	rts
.lp4:	jsr	clrcomm
	lea	fnftxt,a0
	jsr	print
	rts
.gotentry:
	lea	realfile+3,a1
.lp6:	cmp.b	#34,(a0)
	beq	.lp7		;ends with "
	move.b	(a0)+,(a1)+
	bra	.lp6
.lp7:	move.b	#0,(a1)
	lea	lodtxt,a0
	jsr	print
	jsr	clrcomm
	move.l	dosbase,a6
	move.l	#realfile,d1
	moveq.l	#0,d2
	moveq.l	#0,d3
	move.l	$6c,intsave
	jsr	-222(a6)
	move.l	intsave,$6c
	lea	rdy3txt,a0
	jsr	print

	lea	newcopper,a0
	lea	copycopper,a1
.cop:	move.l	(a1)+,(a0)+
	cmp.l	#$fffffffe,(a1)
	bne	.cop
	move.l	(a1)+,(a0)+

	move.l	plnbase,a1
	move.l	#plnsize,d0
	move.l	a1,stor
	move.l	stor,pln1
	move.w	stor,bp2+2
	move.w	stor+2,bp2+6

	add.l	d0,stor
	move.l	stor,pln2
	move.w	stor,bp1+2
	move.w	stor+2,bp1+6

	add.l	#40*24,pln1	

	jsr	killspr
	move.l	#newcopper,$dff080
	move.l	#newcopper,$dff084
	rts	

cls:	jsr	clrcurs
	jsr	clrcomm
	move.l	pln1,a0
	move.l	#1999,d0
.lp:	move.l	#0,(a0)+
	dbra	d0,.lp
	move.b	#0,xpos
	move.b	#0,ypos
	rts

reset:	jsr	cls
	lea	txt1,a0
	jsr	print
	rts


realcols:
	dc.w	$0000,$0fff,$0a33,$0cff,$0f9d,$07b7,$015b,$0ff8
	dc.w	$0fb8,$0962,$0f9a,$0666,$0aaa,$0cfc,$089f,$0ddd
colwords:
	dc.b	0,'0'
	dc.b	0,'1'
	dc.b	0,'2'
	dc.b	0,'3'
	dc.b	0,'4'
	dc.b	0,'5'
	dc.b	0,'6'
	dc.b	0,'7'
	dc.b	0,'8'
	dc.b	0,'9'

	dc.b	'10'
	dc.b	'11'
	dc.b	'12'
	dc.b	'13'
	dc.b	'14'
	dc.b	'15'

clrcomm:lea	string,a0
	move.l	#39,d0
.lp:	move.b	#0,(a0)+
	dbra	d0,.lp
	move.l	#0,stringoff
	rts
clrcurs:
	move.l	pln1,a0
	moveq.l	#0,d0
	move.b	xpos,d0
	add.l	d0,a0
	moveq.l	#0,d0
	move.b	ypos,d0
	mulu	#40*8,d0
	add.l	d0,a0
	move.b	#0,(a0)
	move.b	#0,40(a0)
	move.b	#0,80(a0)
	move.b	#0,120(a0)
	move.b	#0,160(a0)
	move.b	#0,200(a0)
	move.b	#0,240(a0)
	move.b	#0,280(a0)

	move.w	#0,ccount
	move.b	#0,cstate
	rts


locknam:dc.b	'df0:',0
	even
dirnam:dc.b	'df0:64/',0
	even

lock:	dc.l	0
	cnop	0,4
infodata:
	ds.b	300
numdir:	dc.l	0		;number of entry's 33 bytes each
dirlist:rept	20
	dc.b	0,0,'0000 "                "   prg',13,0
	endr
	even
seartxt:dc.b	0,0,13,255,0,0,'searching for '
filename:
	ds.b	18
realfile:
	dc.b	'64/'
	ds.b	18

	even

copycopper:					
	dc.w	$0100,$2200
	dc.w	$0102,$0000

	dc.w	$00e0,$0000,$00e2,$0000
	dc.w	$00e4,$0000,$00e6,$0000
	dc.w	$00e8,$0000,$00ea,$0000
	dc.w	$00ec,$0000,$00ee,$0000
	dc.w	$00f0,$0000,$00f2,$0000

	dc.w	$008E,$2c81,$0090,$2cc1                                 
	dc.w	$0092,$0038,$0094,$00d0
	dc.w	$0108,$0000,$010a,$0000

	dc.w	$0120,$0000,$0122,$0000	
	dc.w	$0124,$0000,$0126,$0000	
	dc.w	$0128,$0000,$012a,$0000	
	dc.w	$012c,$0000,$012e,$0000	
	dc.w	$0130,$0000,$0132,$0000	
	dc.w	$0134,$0000,$0136,$0000	
	dc.w	$0138,$0000,$013a,$0000	
	dc.w	$013c,$0000,$013e,$0000	

	dc.w	$0180,$089f
	dc.w	$0182,$015b
	dc.w	$0186,$089f

	dc.w	$ffff,$fffe

	dc.b	'********  Write to me (Mindeater) ********'
	dc.b	'A.Clark    2 Highfield Rise    Eastend Road    Hull    HU12 8RA    '
	dc.b	'********      Thanks!!!     ********'

