;:sys36864
	;.opt oo
	*= 49152
tmp	=2
setcr	=58732
spalte	=211
zeile	=214
return	=$aad7
tmp2	=4
esc	=123
pice	=$e000
bank	=$dd00
lores	=$c400
gralo	=$2000
vicinit	=65409
link	=$a533
pic2	=$2000
pic4	=$3f40
baslo	=$800
basend	=45
nambuf	=$cf00
bsin	=$ffcf
odnam	=$cf80
bsout	=$ffd2
setpar	=$ffba
setnam	=$ffbd
loadr	=$ffd5
fa	=$ba
vic	=$d000
talk	=$ffb4
sa	=$b9
sectalk	=$ff96
iecin	=$ffa5
buff	=631
untalk	=$ffab
clrscr	=$e544
konf	=1
key	=198
getkey	=65508
sendnam	=$f3d5
status	=$90
clsfil	=$f642
axout	=$bdcd
space	=$ab3f
	jmp anfang
tit	.byte "\x1a\x08\x0e\x97\x93  \xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\xa4\x1a"
	.byte "\x12\x1d\x1d          NSS Picturemaker          \x1a\x03"
tit1	.byte "\x11Dieses Programm versieht ein  Hires-Bild"
	.byte "ab $2000  mit einem Basic-Lader, so dass"
	.byte "Sie es mit SAVE ... ,8 speichern koennen"
	.byte "(also nicht absolut)."
	.byte "\x1a\x11Aufruf: SYS 49152"
	.byte "\x11\x1aProgrammiert von Nikolaus Heusler 200187\x1a"
	.byte "<c> NIG Software Service N.S.S.\x1a\x03"
prompt	.byte "\x91Bereit."
	.byt 141
menue	.byte "\x11     A. - Bild laden\x1a"
	.byte "\x11     B. - Bild bearbeiten\x1a"
	.byte "\x11     C. - Lader erstellen\x1a"
	.byte "\x11     D. - Directory\x1a"
	.byte "\x11     E. - Ende\x03"
surt	.byte "Sind Sie sicher ? [J/N]\x1a\x03"
endt	.byte "\x1aErzeugten Lader mit SAVE abspeichern !\x1a\x03"
filt	.byte "\x1aBildname ? _\x9d\x03"
dost	.byte "\x1aDOS: \x03"
keyt	.byte "\x1a(Taste druecken)\x1a\x03"
namt	.byte "\x1aName ? \x03"
btx	.byte "\x11     _\xc0 - Text/Grafik\x1a"
	.byte "\x11      I - Invertieren\x1a"
	.byte "\x11    1-8 - Standartbild mit dem neuen\x1a"
	.byte "          ab $0000/$2000/$4000... ver-\x1a"
	.byte "          tauschen\x1a"
	.byte "\x11      X - Menue\x1a\x03"
adr	.word load,bild,make,dir,end
header	.byt 0,1,1
	.word 1987
	.byt 158
	.byte "2080:"
	.byt 143,32
name	.byte "                "
	brk
	.word 0
	jsr switchon-header+baslo
	lda #<baslo+mode-header
	ldy #>baslo+mode-header
	sta tmp
	sty tmp+1
	lda #<pice
	ldy #>pice
	sta tmp2
	sty tmp2+1
ll3	ldy #0
	lda (tmp),y
	inc tmp
	bne ll1
	inc tmp+1
ll1	cmp #esc
	beq ll2
	sta (tmp2),y
	inc tmp2
	bne ll3
	inc tmp2+1
	bne ll3
ll2	lda (tmp),y
	beq ll4
	inc tmp
	bne ll5
	inc tmp+1
ll5	tax
	lda (tmp),y
	inc tmp
	bne ll6
	inc tmp+1
ll6	sta (tmp2),y
	inc tmp2
	bne ll7
	inc tmp2+1
ll7	inc vic+32
	dex
	bne ll6
	beq ll3
ll4	lda #0
	sta key
ll8	cmp key
	beq ll8
	lda #3
	sta bank
	jmp vicinit
switchon	lda #29
	sta vic+24
	lda #59
	sta vic+17
	lda #0
	sta bank
	ldy #<lores
	lda #>lores
	sty tmp
	sta tmp+1
	lda #15
	ldx #4
setcc	sta (tmp),y
	dey
	bne setcc
	inc tmp+1
	dex
	bne setcc
	rts
mode	brk
wert	brk
anz	brk
made	brk
odlen	brk
nr	brk
titout	ldx #14
	stx vic+32
	inx
	stx vic+33
	lda #<tit
	ldy #>tit
strout	sta tmp
	sty tmp+1
strlp	ldy #0
	lda (tmp),y
	beq fin
	cmp #"\x03"
	beq fin
	cmp #"\x1a"
	bne nocr
	lda #13
nocr	jsr bsout
	inc tmp
	bne strlp
	inc tmp+1
	bne strlp
fin	rts
tpt	pha
	lda nr
	beq naa
	cmp #6
	beq naa
	pla
	sta (tmp),y
	rts
naa	pla
	rts
display	tya
	asl
	clc
	adc #3
	sta zeile
	lda #3
	sta spalte
	jsr setcr
	lda #"\xba"
	jsr bsout
	jsr return
	lda #14
	sta zeile
	jmp setcr
getsure	lda #<surt
	ldy #>surt
	jsr strout
	jsr getjn
	beq rt
	pla
	pla
rt	rts
getjn	jsr getkey
	cmp #"j"
	beq ja
	cmp #"n"
	bne getjn
	lda #-1
ja	rts
dos	lda #<dost
	ldy #>dost
	jsr strout
	lda #8
	sta fa
	jsr talk
	lda #$6f
	sta sa
	jsr sectalk
getdos	jsr iecin
	jsr bsout
	cmp #13
	bne getdos
	jsr untalk
waitkey	lda #<keyt
	ldy #>keyt
	jsr strout
	lda #0
	sta key
wk	lda key
	beq wk
	dec key
	rts
picon	lda #29
	sta vic+24
	lda #59
	sta vic+17
	ldx #4
	ldy #0
	sty tmp
	lda #$f
	stx tmp+1
piccon	sta (tmp),y
	iny
	bne piccon
	inc tmp+1
	dex
	bne piccon
	rts
picoff	lda #21
	sta vic+24
	lda #27
	sta vic+17
	jmp clrscr
get	ldy #0
	lda (tmp),y
	inc tmp
	bne l1
	inc tmp+1
l1	rts
put	inc vic+32
	ldy #0
	sta (tmp2),y
	inc tmp2
	bne l2
	inc tmp2+1
l2	rts
back	lda tmp
	sec
	sbc #1
	sta tmp
	lda tmp+1
	sbc #0
	sta tmp+1
	rts
testend	lda tmp+1
	cmp #>pic4
	bne l5
	lda tmp
	cmp #<pic4
	bne l5
	sec
	rts
l5	clc
	rts
anfang	lda #0
	sta made
	sta nambuf
	lda mode
	bne profi
	jsr titout
	inc mode
	lda #<tit1
	ldy #>tit1
	jsr strout
ende	ldx #menue-prompt
	stx key
	dex
setpmt	lda prompt,x
	sta buff,x
	dex
	bpl setpmt
	rts
profi	jsr titout
	lda #<menue
	ldy #>menue
	jsr strout
getmen	jsr getkey
	cmp #"a"
	bcc getmen
	cmp #"f"
	bcs getmen
	sec
	sbc #"a"
	tay
	asl
	tax
	lda adr,x
	sta jump+1
	lda adr+1,x
	sta jump+2
	jsr display
jump	jsr 0
	jmp profi
end	jsr getsure
	pla
	pla
	lda made
	beq lassma
	lda #<endt
	ldy #>endt
	jsr strout
lassma	jmp ende
make	jsr getsure
	inc made
	jsr entername
	ldx #mode-header
sethdr	lda header,x
	sta baslo,x
	dex
	cpx #-1
	bne sethdr
	jsr link
	lda #<baslo+(mode-header)
	ldy #>baslo+(mode-header)
	sta tmp2
	sty tmp2+1
	lda #<pic2
	ldy #>pic2
	sta tmp
	sty tmp+1
l4	lda #0
	sta anz
	jsr testend
	bcs l6
	inc anz
	jsr get
	sta wert
l3	jsr testend
	bcs l6
	jsr get
	cmp wert
	bne neu
	inc anz
	bne l3
	lda #esc
	jsr put
	lda #-1
	jsr put
	lda wert
	jsr put
	jsr back
	jmp l4
neu	jsr back
	ldx anz
	cpx #4
	bcs l9
	lda wert
	cmp #esc
	beq l9
la	jsr put
	dex
	bne la
	jmp l4
l9	lda #esc
	jsr put
	lda anz
	jsr put
	lda wert
	jsr put
	jmp l4
l6	ldx anz
	beq l7
	cpx #4
	bcc lb
ld	lda #esc
	jsr put
	lda anz
	jsr put
	lda wert
	jsr put
	jmp l7
lb	lda wert
	cmp #esc
	beq ld
lc	jsr put
	dex
	bne lb
l7	lda #esc
	jsr put
	lda #0
	jsr put
	lda tmp2
	ldy tmp2+1
	sta basend
	sty basend+1
	sta basend+2
	sty basend+3
	sta basend+4
	sty basend+5
	ldx #0
stod	lda odnam,x
	sta baslo-header+name,x
	inx
	cpx odlen
	bcc stod
	rts
entername	lda #<namt
	ldy #>namt
	jsr strout
	lda #<nambuf
	ldy #>nambuf
	jsr strout
	jsr return
	dec zeile
	lda #7
	sta spalte
	jsr setcr
	ldx #0
gettit	jsr bsin
	cmp #13
	beq crlf
	sta odnam,x
	inx
	cpx #16
	bcc gettit
crlf	stx odlen
	rts
load	lda #<filt
	ldy #>filt
	jsr strout
	ldx #0
getlnm	jsr bsin
	cmp #13
	beq cerl
	sta nambuf,x
	inx
	cpx #16
	bcc getlnm
cerl	lda #0
	sta nambuf,x
	cpx #1
	bne pfpf
	lda nambuf
	cmp #"_"
	bne pfpf
	rts
pfpf	txa
	ldx #<nambuf
	ldy #>nambuf
	jsr setnam
	ldx #8
	ldy #0
	jsr setpar
	ldx #<pic2
	ldy #>pic2
	lda #0
	jsr loadr
	jmp dos
bild	jsr picoff
	jsr titout
	lda #<btx
	ldy #>btx
	jsr strout
	jmp getbtx
bildan	jsr picon
getbtx	jsr getkey
	beq getbtx
	cmp #"_"
	bne nospa
	lda vic+17
	and #32
	beq bildan
	bne bild
nospa	cmp #"i"
	bne noi
	ldy #<pic2
	ldx #>pic2
	sty tmp
	stx tmp+1
invit	lda (tmp),y
	eor #-1
	sta (tmp),y
	dey
	bne invit
	inc tmp+1
	dex
	bne invit
	beq getbtx
noi	cmp #"x"
	bne nox
	jmp picoff
nox	cmp #"1"
	bcc getbtx
	cmp #"9"
	bcs getbtx
	sec
	sbc #"1"
	sta nr
	asl
	asl
	asl
	asl
	asl
	sta tmp+1
	ldx #>pic2
	stx tmp2+1
	ldy #0
	sty tmp
	sty tmp2
	lda #48
	sei
	sta konf
swap	lda (tmp2),y
	pha
	lda (tmp),y
	sta (tmp2),y
	pla
	jsr tpt
	dey
	bne swap
	inc tmp+1
	inc 1+tmp2
	dex
	bne swap
	lda #55
	sta konf
	cli
	bne getbtx
dir	jsr titout
	lda #"$"
	sta tmp
	ldx #<tmp
	ldy #>tmp
	lda #1
	jsr setnam
	jsr rand
	ldx #8
	ldy #$60
	jsr setpar
	jsr sendnam
	lda fa
	jsr talk
	lda sa
	jsr sectalk
	lda #0
	sta status
	ldy #3
dir1	sty tmp
	jsr iecin
	sta tmp+1
	ldy status
	bne dir4
	jsr iecin
	ldy status
	bne dir4
	ldy tmp
	dey
	bne dir1
	ldx tmp+1
	jsr axout
	jsr space
dir3	jsr iecin
	ldx status
	bne dir4
	tax
	beq dir2
	jsr bsout
	bcc dir3
dir2	jsr rand
	ldy #2
	bne dir1
dir4	jsr clsfil
	jmp dos
rand	jsr return
	ldy #3
raab	jsr space
	dey
	bne raab
	rts
