;:sys36864
	;.opt oo
	*= $c800
getx	=$b7f1
komma	=$aefd
findvar	=$b08b
frestr	=$b6a3
varadr	=$49
strres	=$b475
para	=$61
bsout	=$ffd2
getin	=$ffe4
strout	=$ab1e
cr	=13
latch	=$c100
quot	=212
return	=$aad7
space	=$ab3f
frmevl	=$ad9e
stradr	=$22
irqvec	=$314
oldirq	=$ea31
sek	=701
min	=sek+1
std	=min+1
bild	=$d1
farb	=$f3
farbram	=$ea24
calc	=$e9f0
zeile	=214
sid	=54272
nmbkey	=198
spd	=25
illquan	=$b248
axout	=$bdcd
vic	=$d000
	jmp inform
	jmp wandel
	jmp setirq
	jmp irqoff
	jmp blocksatz
	jmp music
	jmp effect
lan	.byt 0
blpos	.byt 0
ptr	.byt 0
maxlen	.byt 0
len	.byt 0
lastran	.byt $31
deltxt	.byte " \x9d\x9d"
curtxt	.byte "\xc0\x9d"
	.byt 0
dauer	.byt 0
bitte	jmp illquan
inform	jsr getx
	txa
	beq bitte
	stx maxlen
	jsr komma
	jsr findvar
	sta varadr
	sty varadr+1
	jsr frestr
	jsr clr
	ldx #0
	stx len
	jsr cursor
keylp	jsr getin
	beq keylp
	cmp #cr
	bne text
	lda len
	jsr strres
	ldy #2
setpar	lda para,y
	sta (varadr),y
	dey
	bpl setpar
	iny
settxt	cpy len
	beq carried
	lda latch,y
	sta (para+1),y
	iny
	bne settxt
carried	jsr space
	jmp return
text	cmp #20
	beq del
	cmp #32
	bcs ok1
wrong	jmp keylp
ok1	cmp #95
	beq del
	bcc ok
	cmp #193
	bcc wrong
	cmp #219
	bcs wrong
ok	cmp #65
	bcc ook
	cmp #91
	bcc togr
	cmp #193
	bcc ook
	and #$7f
	bne ook
togr	ora #$80
ook	ldx len
	cpx maxlen
	bcs wrong
	sta latch,x
	jsr bsout
	lda #0
	sta quot
	jsr cursor
	inc len
	bne keylp
del	ldx len
	beq wrong
	lda #<deltxt
	ldy #>deltxt
	jsr strout
	dec len
	jmp keylp
cursor	lda #<curtxt
	ldy #>curtxt
	jmp strout
clr	ldx maxlen
c1	jsr space
	dex
	bpl c1
	lda #"\x9d"
	ldx maxlen
c2	jsr bsout
	dex
	bpl c2
endend	rts
wandel	jsr komma
	jsr frmevl
	jsr frestr
	tay
neu	dey
	bmi endend
	lda (stradr),y
	cmp #193
	bcc neu
	cmp #219
	bcs neu
	and #127
	sta (stradr),y
	bne neu
setirq	sei
	lda #<newirq
	ldy #>newirq
set	sta irqvec
	sty irqvec+1
	cli
	rts
irqoff	sei
	lda #<oldirq
	ldy #>oldirq
	bne set
newirq	inc sek
	ldx sek
	cpx #60
	bcc endirq
	ldx #0
	stx sek
	inc min
	ldx min
	cpx #60
	bcc endirq
	ldx #0
	stx min
	inc std
	ldx std
	cpx #24
	bcc endirq
	ldx #0
	stx std
endirq	jmp oldirq
blocksatz	ldx #0
	lda zeile
	pha
	lda #20
	sta blpos
blocklp	jsr calc
	jsr farbram
testneu	ldy #39
	lda #" "
	cmp (bild),y
	bne voll
	ldy #0
	cmp (bild),y
	beq voll
	lda (bild),y
	cmp #"!"
	beq rump
	jsr testlen
	bcs voll
	jsr sa
	ldy blpos
suchsp	lda (bild),y
	cmp #" "
	beq fund
	iny
	cpy lan
	bcc test2
	ldy #1
test2	cpy blpos
	bne suchsp
	beq voll
fund	iny
	sty blpos
	ldy #39
ruk	dey
	lda (bild),y
	pha
	lda (farb),y
	iny
	sta (farb),y
	pla
	sta (bild),y
	dey
	cpy blpos
	bne ruk
	beq hase
voll	inx
	cpx #24
	beq blocklp
	bcc blocklp
	pla
	sta zeile
	tax
	jmp calc
hase	lda #" "
	sta (bild),y
	inc blpos
	jmp testneu
sa	lda blpos
	beq nu
	cmp lan
	bcc x
	sec
	sbc lan
	sta blpos
	jmp sa
x	rts
nu	inc blpos
	bne sa
testlen	ldy #39
tl	dey
	beq n
	lda (bild),y
	cmp #" "
	beq tl
	iny
	sty lan
	clc
	rts
n	sec
	rts
rump	ldy #1
rulo	lda (bild),y
	pha
	lda (farb),y
	dey
	sta (farb),y
	pla
	sta (bild),y
	iny
	iny
	cpy #40
	bcc rulo
	dey
	lda #" "
	sta (bild),y
	jmp voll
music	ldx #23
	lda #0
	sta nmbkey
mclr	sta sid,x
	dex
	bpl mclr
	lda #15
	sta sid+24
	lda #9
	sta sid+3
	sta sid+10
mneu	lda #0
	sta ptr
mloop	lda ptr
	asl
	asl
	clc
	adc ptr
	inc ptr
	tax
	lda $c002,x
	beq mneu
	sta dauer
	lda $c001,x
	sec
	sbc #5
	sta sid
	lda $c000,x
	sta sid+1
	lda #53
	sta sid+5
	lda #144
	sta sid+6
	lda #65
	sta sid+4
	lda $c004,x
	beq alfi
	clc
	adc #2
	sta sid+7
	lda $c003,x
	sta sid+8
	lda #53
	sta sid+12
	lda #144
	sta sid+13
	lda #65
	sta sid+11
alfi	ldx #0
	ldy #spd
alfred	jsr off
	dex
	bne alfred
	dey
	bne alfred
	ldy #spd
	dec dauer
	bne alfred
	beq mloop
off	lda nmbkey
	beq q
	pla
	pla
	lda #0
	sta sid+24
	sta nmbkey
q	rts
random	lda lastran
	eor #-1
	clc
	adc sek
	eor lastran
	asl
	adc #0
	eor ptr
	ora min
	rol
	sbc lastran
	eor #$aa
	sta lastran
	eor $a2
	lsr
	adc $a2
	sbc vic+18
	asl
	adc #0
	eor lastran
	sta lastran
	rts
effect	jsr random
	and #7
	tay
	sty maxlen
z812	jsr random
	and #15
	cmp #8
	bcc z812
	cmp #13
	bcs z812
	sta latch,y
	tax
	jsr calc
	jsr farbram
s615	jsr random
	and #15
	cmp #6
	bcc s615
	sty ptr
	sta latch+20,y
	tay
	lda #1
	sta (farb),y
	lda #160
	sta (bild),y
	ldy ptr
	dey
	bpl z812
	ldx #-1
	ldy #-1
waits	dex
	bne waits
	dey
	bne waits
	ldy maxlen
weiter	lda latch,y
	tax
	jsr calc
	jsr farbram
	sty ptr
	lda latch+20,y
	tay
	lda #35
	sta (bild),y
	lda #9
	sta (farb),y
	ldy ptr
	dey
	bpl weiter
	rts
