;:poke56,32:clr
;:sys36864
	;.opt oo
	*= $c000
gr	=2
ft	=4
sc	=166
ch	=6
font	=8192
scrn	=1024
hires	=16384
buff	=820
grend	=hires+8000
gr2	=251
sc2	=253
	jmp bild
	jmp convert
	jmp off
	jmp save
convert	lda #24
	sta 53272
	ldy #0
	lda #>font
	sta ft+1
	sty ft
	ldx #8
	tya
clrft	sta (ft),y
	iny
	bne clrft
	inc ft+1
	dex
	bne clrft
	lda #>font
	sta ft+1
	stx sc
	stx ch
	stx gr
	lda #>hires
	sta gr+1
	jsr $e544
	lda #216
	sta sc+1
	lda #1
	ldx #4
	ldy #0
colin	sta (sc),y
	iny
	bne colin
	inc sc+1
	dex
	bne colin
	lda #>scrn
	sta sc+1
mainlp	lda ch
	cmp #32
	bne allow
sperr	lda #8
	clc
	adc ft
	sta ft
	bcc l1
	inc ft+1
l1	inc ch
	beq out
	bne mainlp
out	jsr $e544
	lda #21
	sta 53272
	lda #<err
	sta 34
	lda #>err
	jmp $a445
err	.byte "picture too compleX"
allow	sec
	ldy #7
mark	lda (gr),y
	beq not1
	clc
not1	sta buff,y
	dey
	bpl mark
	bcc full
	lda #8
	clc
	adc gr
	sta gr
	bcc l2
	inc gr+1
l2	inc sc
	bne l3
	inc sc+1
l3	lda gr
	cmp #<grend
	bne allow
	lda gr+1
	cmp #>grend
	bne allow
	rts
full	lda ch
	ldy #0
	sta (sc),y
	ldy #7
merke	lda buff,y
	sta (ft),y
	dey
	bpl merke
	lda #8
	clc
	adc gr
	sta gr
	bcc l4
	inc gr+1
l4	inc sc
	bne l5
	inc sc+1
l5	lda gr
	cmp #<grend
	bne ok
	lda gr+1
	cmp #>grend
	bne ok
	rts
ok	lda gr
	sta gr2
	lda gr+1
	sta gr2+1
	lda sc
	sta sc2
	lda sc+1
	sta sc2+1
epsilon	ldy #7
very	lda (gr2),y
	cmp buff,y
	bne anders
	dey
	bpl very
	ldy #0
	lda ch
	sta (sc2),y
	ldy #7
	lda #0
erase	sta (gr2),y
	dey
	bpl erase
anders	lda #8
	clc
	adc gr2
	sta gr2
	bcc l6
	inc gr2+1
l6	inc sc2
	bne l7
	inc sc2+1
l7	lda gr2
	cmp #<grend
	bne epsilon
	lda gr2+1
	cmp #>grend
	bne epsilon
	jmp sperr
off	lda #21
	sta 53272
	rts
bild	lda #<pic
	ldy #>pic
	jmp $ab1e
pic	.byt 13,13
	.byte "hitoloko version 2  nikolaus heusler"
	.byt 13
	.byte "(c) nh-270490-arr / m&t 64'er-sh.55"
	.byt 13
	.byte "\x11sys 49155: konvertieren (bild ab $4000)"
	.byt 13
	.byte "sys 49158: textmodus einschalten"
	.byt 13
	.byte "sys 49161: bild und zeichen speichern"
	.byt 13,13,0
save	jsr $aefd
	jsr $ad9e
	jsr $b6a3
	cmp #0
	bne nonul
	jmp $b248
nonul	stx 2
	sty 3
	tay
	tax
	lda #"."
	sta 821
trana	dey
	bmi schluss
	lda (2),y
	sta 822,y
	bne trana
schluss	lda #"z"
	sta 820
	inx
	inx
	txa
	ldx #<820
	ldy #>820
	jsr $ffbd
	ldx #8
	ldy #1
	jsr $ffba
	ldx #0
	ldy #>10240
	stx 2
	lda #>8192
	sta 3
	lda #2
	jsr $ffd8
	lda #"s"
	sta 820
	ldx #<2024
	ldy #>2024
	lda #>1024
	sta 3
	lda #2
	jmp $ffd8
