;:sys36864
	;.opt oo
	*= 49152
;
; searcher - superversion <c> nss 21.11.85
;
;
;
runbrk	= $a82c
crs1	= 204
crs2	= 205
crs3	= 207
latch	= 51200
chrin	= $ffcf
chrout	= $ffd2
open	= $ffc0
chkout	= $ffc9
strout	= $ab1e
getkey	= 65508
j	= "j"
n	= "n"
o	= "o"
a	= "a"
ptr	= 122
temp	= 2
temp2	= 4
temp3	= 6
temp4	= 251
temp5	= 181
getadr	= $b7f7
chrgot	= $79
ascfloat	= $bcf3
round	= $bc1b
return	= $aad7
illquan	= $b248
axout	= $bdcd
cint	= $ff81
vic	= 53248
col1	= vic+32
col2	= vic+33
close	= $ffc3
clall	= $ffe7
pr	= 4
se	= 0
sa	= $b9
ga	= $ba
fl	= $b7
lf	= $b8
basic	= $e385
;
;
	jmp start
;
brkflag	.byt 0
mask	.byt 0
druckflag	.byt 0
anz	.byt 0
;
cron	lda #0
	sta crs1
	rts
croff	pha 
	 lda #2
	sta crs2
crs	lda crs3
	and #1
	bne crs
	lda #1
	sta crs1 
	 pla
	rts
getjn	jsr jn
	jsr cron
get	jsr getkey
	cmp #j
	beq ja
	cmp #n
	bne get
	ldx #0
	beq nein
ja	ldx #1
nein	jsr croff
	jmp chrout2
jn	lda #< text3
	ldy #> text3
	jmp strout
drucker	lda #< text1
	ldy #> text1
	jsr strout
	jsr getjn
	stx druckflag
	rts
runstop	lda #< text2
	ldy #> text2
	jsr strout
	jsr getjn
	stx brkflag
	rts
ramrom	lda #< text4
	ldy #> text4
	jsr strout
	jsr cron
get2	jsr getkey
	cmp #a
	beq ram
	cmp #o
	bne get2
	ldx #55
	bne rom
ram	ldx #48
rom	stx mask
	jsr croff
	jmp chrout2
clrlatch	ldy #0
	tya
clr	sta latch,y
	iny
	bne clr
	rts
getnum	jsr clrlatch
	ldy #0
num	sty temp3
	jsr chrin
	cmp #13
	beq cr
	ldy temp3
	sta latch,y
	iny
	jmp num
cr	lda ptr
	pha
	lda ptr+1
	pha
	lda #<latch
	ldy #>latch
	sta ptr
	sty ptr+1
	jsr chrgot
	jsr ascfloat
	jsr round
	pla
	sta ptr+1
	pla
	sta ptr
	jsr getadr
	sty temp4
	sta temp4+1
	jmp return
chrout2	jsr chrout 
	 jmp return
getvon	lda #< text5
	ldy #> text5
	jsr strout
	jsr getnum
	lda temp4
	sta temp
	lda temp4+1
	sta temp+1
	rts
getbis	lda #< text6
	ldy #> text6
	jsr strout
	jsr getnum
	lda temp4
	sta temp2
	lda temp4+1
	sta temp2+1
	rts
getpar	jsr getvon
	jsr getbis 
	 jsr chkbis
	jsr ramrom
	jsr getanz
	jsr getbytes
	jsr drucker
	jsr runstop
	rts
getnum2	jsr getnum
	lda temp4+1
	beq ok
ill	jmp illquan
ok	ldx temp4
	rts
getanz	lda #< text7
	ldy #> text7
	jsr strout
	jsr getnum2 
	 beq ill
	cpx #255
	beq ill
	stx anz
	rts
getbytes	ldx #0
l	stx temp5
	inx 
	 lda #0
	jsr axout
	lda #< text8
	ldy #> text8
	jsr strout
	jsr getnum2
	txa
	ldx temp5
	sta bytes,x
	inx
	cpx anz
	bcc l
go	rts
title	jsr cint
	lda #0
	sta col1 
	 sta col2
	lda #< text9 
	 ldy #> text9
	jmp strout
start	jsr title 
	 jsr clall
	jsr getpar 
	 jmp loop
popen	lda #pr
	sta ga 
	 sta lf
	lda #se
	sta sa
	lda #0
	sta fl
	jsr open
	ldx #pr
	jsr chkout
	lda #< texta
	ldy #> texta
	jmp strout
hoch	inc temp
	bne lo
	inc temp+1
lo	lda temp+1 
	 cmp temp2+1
	bcc go
	beq eq
	bcs end
eq	lda temp 
	 cmp temp2
	beq go
	bcc go
end	lda #pr
	jsr close
	jsr clall
	lda #< textb 
	 ldy #> textb
	jsr strout 
	 jmp basic
check	lda temp
	sta temp4
	lda temp+1
	sta temp4+1
	ldy #0
l2	lda mask 
	 sei 
	 sta 1
	lda (temp4),y 
	 ldx #55 
	 stx 1
	cli
	cmp bytes,y
	bne not
	iny
	cpy anz
	beq found
	jmp l2
found	lda #< textc
	ldy #> textc
	jsr strout
	lda temp+1
	ldx temp
	jsr axout
	jmp return
not	rts
chkbis	lda temp2
	cmp #255
	bne klar
	lda temp2+1
	cmp #255
	bne klar
	jmp ill
klar	rts
loop	lda druckflag
	beq main
	jsr popen
main	jsr check
	jsr hoch
	jsr ende
	jmp main
ende	lda brkflag
	beq rt
	jmp runbrk
rt	rts
text1	.byte "Drucker"
	.byt 0
text2	.byte "RUN STOP erlaubt"
	.byt 0
text3	.byte " [\x12J\x92a/\x12N\x92ein] ? "
	.byt 0
text4	.byte "R\x12A\x92M oder R\x12O\x92M ? "
	.byt 0
text5	.byte "Suchen von ? "
	.byt 0
text6	.byte "Bis ? "
	.byt 0
text7	.byte "Wieviele Bytes ? "
	.byt 0
text8	.byte ". Byte ? "
	.byt 0
text9	.byte "\x93\x08\x0e\x99\x11  **** NSS SEARCHER\xa0 SUPERVERSION ****" 
	 .byt 13
	.byte "\x11 Programmiert von NICKI HEUSLER Nov. 85\x11\x11"
	.byt 13,0
texta	.byte "nss searcher v3 hat gefunden:"
	.byt 13, 13, 0
textb	.byte "Fertig !" 
	 .byt 0
textc	.byte "in " 
	 .byt 0
bytes	.byt 0
