;:ifpeek(776)<>228then:[ba
;:sys36864
	;.opt oo
statvec	= $308
old	= $a7e7
inter	= $a7ae
tmp	= 2
tmp2	= 4
chrget	= 115
strout	= $ab1e
sign	= "["
syntax	= $af08
konfig	= 1
vector	= $fd15
getx	= $b79e
oben	= 166
unten	= 167
links	= 168
rechts	= 169
stradr	= 34
fehler	= $a445
return	= $aad7
axout	= $bdcd
edit1	= $e5cb
edit2	= $e66f
memkonf	= $fdd6
wvec	= $326
cmd	= $9a
device	= $f1d5
char	= 6
scrout	= $e716
setx	= $e9f0
setcol	= $ea24
ink	= 646
bild	= $d1
farb	= $f3
setcr	= $e56c
spalte	= 211
zeile	= 214
clrx	= $e9ff
insert	= $d8
rvs	= $c7
quote	= $d4
cia1	= $dc00
cia2	= $dc01
memvec	= $fd42
rvout	= $e697
edit3	= $e65a
scnclr	= $e544
edit4	= $e55a
edit5	= $e4db
	*= 49152
	jmp init
bu1	.byte "boudlrsw"
bu2	.byte "afpoeihi"
adr	.word basic,off,sup,sdwn,slef,srig,show,window
mess	.byte " -- nig's window ok. --" 
	 .byt 13,0
err	.byte "illegal koordinateS"
txt1	.byte "\x11oben:   " 
	 .byt 0
txt2	.byte "unten:  " 
	 .byt 0
txt3	.byte "links:  " 
	 .byt 0
txt4	.byte "rechts: " 
	 .byt 0
basic	lda #<old-3 
	 ldy #>old-3
	sta statvec 
	 sty statvec+1 
	 jmp off
trans	lda bild 
	 sta tmp
	lda bild+1 
	 sta tmp+1
	lda farb 
	 sta tmp2
	lda farb+1 
	 sta tmp2+1
	rts
goto	jmp (tmp)
off	lda #55 
	 sta konfig
	sei 
	 jsr vector 
	 cli 
	 rts
sup	jsr getx 
	 cpx unten 
	 bcc noi
ilk	lda #<err 
	 sta stradr
	lda #>err 
	 jmp fehler
noi	stx oben 
	 rts
sdwn	jsr getx 
	 cpx oben 
	 beq ilk
	bcc ilk 
	 cpx #25 
	 bcs ilk
	stx unten 
	 rts
slef	jsr getx 
	 cpx rechts
	bcs ilk 
	 stx links 
	 rts
srig	jsr getx 
	 cpx #40 
	 bcs ilk
	cpx links 
	 beq ilk 
	 bcc ilk
	stx rechts 
	 rts
xout	lda #0 
	 jmp axout
inittab	lda #96 
	 sta edit4
	jsr scnclr 
	 lda #169
	sta edit4 
	 rts
show	lda #<txt1 
	 ldy #>txt1
	jsr strout 
	 ldx oben 
	 jsr xout
	jsr return 
	 lda #<txt2
	ldy #>txt2 
	 jsr strout
	ldx unten 
	 jsr xout 
	 jsr return
	lda #<txt3 
	 ldy #>txt3
	jsr strout 
	 ldx links 
	 jsr xout
	jsr return 
	 lda #<txt4
	ldy #>txt4 
	 jsr strout
	ldx rechts 
	 jsr xout 
	 jmp return
copy	sta stradr+1 
	 ldy #0
	sty stradr 
	 ldx #32
coploop	lda (stradr),y
	sta (stradr),y 
	 iny 
	 bne coploop
	inc stradr+1 
	 dex 
	 bne coploop
	rts
setbetr	lda #55 
	 sta konfig
	lda #160 
	 jsr copy
	lda #224 
	 jsr copy
	lda #53 
	 sta konfig
	sta memkonf
	lda #<write 
	 ldy #>write
	sta edit1 
	 sty edit1+1
	sta edit2 
	 sty edit2+1
	lda #<ink 
	 ldy #>ink
	sta edit5 
	 sty edit5+1
	lda #rechts 
	 sta edit3
	jsr inittab
nix	clc 
	 rts
test	ldy quote 
	 bne trv 
	 ldy insert 
	 beq nix
trv	cmp #32 
	 bcc fnd 
	 cmp #128 
	 bcc nix 
	 cmp #149 
	 bcc fnd
	cmp #156 
	 bcc nix 
	 cmp #160 
	 bcs nix
fnd	lda char 
	 jsr nospe 
	 sec 
	 rts
window	jsr setbetr
	lda #<aus 
	 ldy #>aus
	sta memvec 
	 sty memvec+1
	sta wvec 
	 sty wvec+1 
	 rts
aus	pha 
	 lda cmd 
	 cmp #3
	beq screen 
	 jmp device
screen	pla
write	pha 
	 sta char
	txa 
	 pha 
	 tya 
	 pha
	lda char
	jsr ausgabe
	pla 
	 tay 
	 pla 
	 tax 
	 pla
	clc 
	 rts
invert	ldx unten
ylop	jsr setx 
	 jsr setcol
	ldy rechts
xlop	lda (bild),y 
	 eor #128 
	 sta (bild),y
	dey 
	 cpy links 
	 bcc finn 
	 cpy #255 
	 bne xlop
finn	dex 
	 cpx #255 
	 beq endinv 
	 cpx oben 
	 bcs ylop
endinv	jmp home
clear	ldx unten
yloop	jsr setx 
	 jsr setcol
	ldy rechts
xloop	lda #" " 
	 sta (bild),y
	lda ink 
	 sta (farb),y
	dey 
	 cpy links 
	 bcs xok
dx	dex 
	 cpx oben 
	 bcs yok
home	lda oben 
	 sta zeile
	lda links 
	 sta spalte
	jmp setcr
xok	cpy #255 
	 bne xloop
	beq dx
yok	cpx #255 
	 bne yloop
	beq home
scrollup	ldx oben
z1825	jsr setx 
	 jsr setcol
	jsr trans 
	 inx 
	 jsr setx
	jsr setcol 
	 ldy rechts
z1835	lda (bild),y 
	 sta (tmp),y
	lda (farb),y 
	 sta (tmp2),y
	dey 
	 cpy #255 
	 beq z1845
	cpy links 
	 bcs z1835
z1845	cpx unten 
	 beq z1825 
	 bcc z1825
	jsr clrx 
	 lda #$7f 
	 sta cia1
	lda cia2 
	 cmp #$fb 
	 php 
	 lda #$7f 
	 sta cia1 
	 plp 
	 bne noctrl
	ldx #0 
	 ldy #0
vlop	dex 
	 bne vlop 
	 dey 
	 bne vlop
noctrl	rts
scrdwn	ldx unten
ylp	jsr setx 
	 jsr setcol 
	 jsr trans 
	 dex 
	 jsr setx 
	 jsr setcol
	ldy rechts
xlp	lda (bild),y 
	 sta (tmp),y
	lda (farb),y 
	 sta (tmp2),y
	dey 
	 cpy #255 
	 beq fin
	cpy links 
	 bcs xlp
fin	cpx oben 
	 beq w 
	 bcs ylp
w	jmp clrx
setmax	lda #0 
	 sta links 
	 sta oben
	lda #39 
	 sta rechts 
	 lda #24
	sta unten 
	 rts
init	jsr setmax
	lda #<exec 
	 ldy #>exec
	sta statvec 
	 sty statvec+1
	lda #<mess 
	 ldy #>mess
	jmp strout
exec	jsr chrget 
	 cmp #sign
	beq neu 
	 jmp old
neu	jsr chrget 
	 ldx #bu2-bu1-1
such1	cmp bu1,x 
	 beq found1
	dex 
	 bpl such1
syn	jmp syntax
found1	stx tmp 
	 jsr chrget
	ldx #bu2-bu1-1
such2	cmp bu2,x 
	 beq found2
weiter	dex 
	 bpl such2
	bmi syn
found2	cpx tmp 
	 bne weiter
	txa 
	 asl 
	 tax
	lda adr,x 
	 sta tmp
	lda adr+1,x 
	 sta tmp+1
	jsr chrget 
	 jsr goto
	jmp inter
ausgabe	jsr test 
	 bcc goon 
	 rts
goon	 cmp #"\x93" 
	 bne noclr
	jmp clear
noclr	cmp #"\x13" 
	 bne nohome
	jmp home
nohome	cmp #"\x85" 
	 bne nof1
	jmp invert
nof1	cmp #13 
	 bne nocr
cr	ldx #0 
	 stx rvs 
	 stx insert
	stx quote 
	 ldx links 
	 stx spalte
runter	ldx zeile 
	 inx 
	 cpx unten
	bcc nosc 
	 beq nosc 
	 jsr scrollup
	ldx unten
nosc	stx zeile 
	 jmp setcr
nocr	cmp #"\x86" 
	 bne nof3 
	 jmp setmax
nof3	cmp #141 
	 beq cr
	cmp #"\x11" 
	 beq runter
	cmp #"\x91" 
	 bne noup
up	ldx zeile 
	 dex 
	 cpx #255 
	 beq oberst 
	 cpx oben 
	 bcs xup
oberst	jsr scrdwn 
	 ldx oben
xup	stx zeile 
	 jmp setcr
nospe	jsr scrout
	ldx spalte 
	 cpx rechts 
	 beq xre
	bcc xre 
	 ldx links 
	 stx spalte
	jmp runter
xre	rts
noup	cmp #"\x9d" 
	 bne nospe
	ldx spalte 
	 dex 
	 cpx #255
	beq ach 
	 cpx links 
	 bcs gad
ach	jsr up 
	 ldx rechts
gad	stx spalte 
	 rts
