;:ifpeek(777)<>167then:]ex
;:sys36864
	;.opt oo
	*= $c000
chrget	=115
sig	="]"
basvec	=776
chrgot	=121
tpoke	=$97
sid	=$d400
val	=$cf00
inter	=$a7ae
oldinter	=$a7e7
strout	=$ab1e
oldpoke	=$b824
byt	=$14
fehler	=$a445
stradr	=34
axout	=$bdcd
bsout	=$ffd2
return	=$aad7
cnt	=val+8
vce	=cnt+8
irqvec	=788
syntax	=$af08
illquan	=$b248
getx	=$b79e
ioinit	=65418
vecinit	=58451
	jmp losgehts
echoon	.byte "\x93\x11    **** nss echo system v 1.0 ****"
	.byt 13
	.byte "\x11 von nicki heusler 210387 (c) nss 1987"
	.byt 13,13
	.byte "]xx = hilfe\x11"
	.byt 0
wrong1	.byte "illegal voicE"
wrong2	.byte "no statemenT"
helptxt	.byte "\x91]xx    hilfe"
	.byt 13
	.byte "]sp x  x = verzoeg."
	.byt 13
	.byte "]vc x  x = anz. stimmen\xa0(1/2)"
	.byt 13
	.byte "]ex    voellig abschalten"
	.byt 13
	.byte "]ac x  echo an/aus (x=1/0)"
	.byt 13
	.byte "]bl x  blockade an/aus (x=1/0)"
	.byt 13
	.byte "]st    status"
	.byt 13
	.byte "]wa    ausfuehrung abwarten"
	.byt 13,0
stt1	.byte "]sp"
	.byt 0
stt2	.byte ":]vc"
	.byt 0
stt3	.byte ":]ac"
	.byt 0
stt4	.byte ":]bl"
	.byt 0
ch1	.byte "xsebvasw"
ch2	.byte "xpxlccta"
cadr	.word help,speed,off,blockate,voice,onoff,status
	.word wait
worth	brk
timing	.byt 8
cr1	brk
cr2	brk
voices	brk
sperr	sei
echo10	sei
losgehts	lda #<new
	ldy #>new
	sta basvec
	sty basvec+1
	jsr init
	jsr initirq
	lda #<echoon
	ldy #>echoon
	jmp strout
new	jsr chrget
	cmp #tpoke
	bne nopoke
	jmp poke
nopoke	cmp #sig
	beq ne
	jsr chrgot
	jmp oldinter
ne	jsr chrget
	beq wrg2
	sta cr1
	jsr chrget
	beq wrg2
	sta cr2
	ldx #ch2-ch1-1
vergl	lda cr1
	cmp ch1,x
	beq ja1
null	dex
	bpl vergl
	jmp syntax
wrg2	lda #<wrong2
	sta stradr
	lda #>wrong2
	jmp fehler
ja1	lda cr2
	cmp ch2,x
	beq ja2
	bne null
ja2	txa
	asl
	tax
	lda cadr,x
	sta goto+1
	lda cadr+1,x
	sta goto+2
	jsr chrget
goto	jsr 0
	jmp inter
poke	jsr chrget
	jsr oldpoke
	sta worth
	lda byt+1
	cmp #>sid
	beq intosid
pokeoff	jmp inter
intosid	lda byt
	and #31
	cmp #7
	bcc sidok
	cmp #21
	bcs pokeoff
	lda #<wrong1
	sta stradr
	lda #>wrong1
	jmp fehler
sidok	ldx echo10
	beq pokeoff
	tax
	lda sperr
	beq nosp
waitrdy	lda cnt,x
	bne waitrdy
nosp	lda worth
	sta val,x
	lda timing
	sta cnt,x
	lda #7
	sta vce,x
	bne pokeoff
init	lda #0
	ldx #24
clrsid	sta sid,x
	sta val,x
	dex
	bpl clrsid
	rts
initirq	sei
	lda irqvec+1
	cmp #>newirq
	beq sat
	sta oldirq+2
	lda irqvec
	sta oldirq+1
	lda #<newirq
	ldy #>newirq
	sta irqvec
	sty irqvec+1
sat	cli
	rts
newirq	jsr irq
oldirq	jmp $ea31
irq	ldx #7
irqexec	lda cnt,x
	beq parked
	dec cnt,x
	bne parked
	txa
	clc
	adc vce,x
	tay
	lda val,x
	sta sid,y
	lda voices
	beq parked
	lda #14
	cmp vce,x
	beq parked
	sta vce,x
	lda timing
	sta cnt,x
parked	dex
	bpl irqexec
	rts
help	lda #<helptxt
	ldy #>helptxt
	jmp strout
speed	jsr getx
	txa
	beq ill
	sta timing
	rts
ill	jmp illquan
voice	jsr getx
	dex
	cpx #2
	bcs ill
	stx voices
	rts
blockate	jsr getx
	cpx #2
	bcs ill
	stx sperr
	rts
onoff	jsr getx
	cpx #2
	bcs ill
	stx echo10
	rts
off	sei
	jsr ioinit
	jsr vecinit
	cli
	rts
status	lda #<stt1
	ldy #>stt1
	jsr strout
	ldx timing
	lda #0
	jsr axout
	lda #<stt2
	ldy #>stt2
	jsr strout
	ldx voices
	inx
	lda #0
	jsr axout
	lda #<stt3
	ldy #>stt3
	jsr strout
	ldx echo10
	jsr axout2
	lda #<stt4
	ldy #>stt4
	jsr strout
	ldx sperr
	jsr axout2
	jmp return
axout2	txa
	beq nuller
	ldx #1
nuller	lda #0
	jmp axout
wait	ldx #7
wend	lda cnt,x
	bne wend
	dex
	bpl wend
	rts
