;:sys36864
	;.opt oo
	*= $c000
fe	=2	;nr. des ersten eintrags in cache
s	=4	;schreibzeiger
b	=251	;cache-beginn
le	=181	;nr. des letzten eintrags
ae	=253	;aktuelle nr.
caend	=$c000
cache	=$a000
tmp	=247
p1	=168
beta	=$cf00
m122	=249
f	=6
more	=820
min	=140
new	=178
mode	=179
	lda #<bef
	ldy #>bef
	sta 776
	sty 777
	lda #0
	sta b
	sta s
	ldy #>cache
	sty b+1
	sty s+1
	sta fe
	sta fe+1
	sta le
	sta le+1
	tax
	lda #1
	sta mode
cobe	lda $a09e,x
	sta beta,x
	dex
	bne cobe
	lda #<in
	ldy #>in
	sta 770
	sty 771
	lda #<hi
	ldy #>hi
	sty new
	jmp $ab1e
hi	.byt 13
	.byte "history rev 1.0 (c) 3.93"
	.byt 13,13
	.byte "nikolaus heusler"
	.byt 13
	.byte "zwengauerweg 18"
	.byt 13
	.byte "8000 muenchen 71"
	.byt 13
	.byt 13
	.byte "!!  repeat last order"
	.byt 13
	.byte "!.. repeat order"
	.byt 13
	.byte "!n  repeat order nr. n"
	.byt 13
	.byte "/   history list"
	.byt 13
	.byte "/n  list last n orders"
	.byt 13
	.byte "*n  set filter"
	.byt 13,0
dmo	.byte "direct mode onlY"
ste	.byte "no evenT"
nom	.byte "no matcH"
hext	.byte "0123456789abcdef"
j1	.byte "stat = $"
	brk
let	.byte " ytpme"
qcall	jmp call
bef	lda 122
	sta m122
	lda 123
	sta m122+1
	jsr 115
	cmp #"!"
	beq qcall
exec	lda new
	beq prg
	ldx $3a
	inx
	bne prg
	inc le
	bne ex1
	inc le+1
ex1	lda fe
	ora fe+1
	bne ex2
	inc fe
ex2	lda #0
	sta p1
	cmp mode
	beq ex3
	sta new
ex3	ldy p1
	lda (122),y
	ldy #0
	sta (s),y
	inc p1
	pha
	jsr its
	lda s
	cmp b
	bne ex4
	lda s+1
	cmp b+1
	bne ex4
	jsr ram
	inc fe
	bne ex5
	inc fe+1
ex5	ldy #0
	lda (b),y
	beq ex6
	jsr itb
	jmp ex5
ex6	jsr rom
	jsr itb
ex4	pla
	bne ex3
prg	jsr 121
	cmp #173
	beq list
	cmp #172
	beq qswitch
	jsr 121
	jmp $a7e7
qswitch	jmp switch
list	jsr getmin
	jsr $aad7
	lda fe
	sta ae
	lda fe+1
	sta ae+1
	lda b
	sta tmp
	lda b+1
	sta tmp+1
ll1	lda ae+1
	cmp min+1
	bcc skip
	bne frei
	lda ae
	cmp min
	bcc skip
	beq skip
frei	ldx ae
	lda ae+1
	sta $62
	stx $63
	ldx #144
	sec
	jsr $bc49
	jsr $bddf
	ldy #0
ll2	lda $100,y
	beq ll3
	iny
	bne ll2
ll3	cpy #5
	bcs ll3a
	jsr $ab3f
	iny
	bne ll3
ll3a	jsr $bf0c
	jsr $ab1e
	jsr $ab3f
	jsr $ffd2
	jsr ram
ll4	ldy #0
	lda (tmp),y
	beq ll5
	jsr wr
	jsr it
	jmp ll4
ll5	jsr it
	jsr rom
	jsr $a82c
	jsr $aad7
sk3	lda ae
	cmp le
	bne ll6
	lda ae+1
	cmp le+1
	beq ll7
ll6	inc ae
	bne ll1
	inc ae+1
	jmp ll1
skip	jsr ram
sk1	ldy #0
	lda (tmp),y
	beq sk2
	jsr it
	jmp sk1
sk2	jsr it
	jsr rom
	jmp sk3
ll7	jmp $a7ae
switch	jsr 115
	beq oug
	jsr $b79e
	stx mode
	jmp $a7ae
oug	lda #"*"
	jsr $ffd2
	lda mode
	beq zdr
	lda #1
mod	lda mode
	beq zdr
	lda #1
zdr	ora #48
	jsr $ffd2
	jsr $aad7
	jmp $a7ae
jour	lda #<j1
	ldy #>j1
	jsr $ab1e
	lda #>cache
	jsr hh0
	lda #"-"
	jsr $ffd2
	lda #>caend
	jsr hh0
	jsr $ab3f
	lda b+1
	jsr hex
	lda b
	jsr hex
	jsr $ab3f
	lda s+1
	jsr hex
	lda s
	jsr hex
	jsr $ab3f
	ldx fe
	txa
	ora fe+1
	beq leer
	lda fe+1
	jsr $bdcd
	lda #"-"
	jsr $ffd2
	ldx le
	lda le+1
	jsr $bdcd
	jsr $ab3f
	jmp mod
leer	ldx #5
ldt	lda let,x
	jsr $ffd2
	dex
	bpl ldt
	bmi mod
call	jsr dm
	jsr 115
	beq jour
	cmp #"!"
	beq last
	cmp #"0"
	bcc such
	cmp #"9"+1
	bcs steu
	jsr 121
	jsr $a96b
	jmp aufruf
steu	cmp #171
	bne such
	jsr 115
	jsr $a96b
	sec
	lda le
	sbc $14
	tay
	lda le+1
	sbc $15
	jmp conv
last	jsr 115
	ldy le
	lda le+1
conv	jsr $b808
	jmp aufruf
such	lda s
	sta tmp
	lda s+1
	sta tmp+1
	jsr ram
	lda #0
	sta more
su1	lda tmp
	cmp b
	bne su2
	lda tmp+1
	cmp b+1
	bne su2
feh	jsr rom
	lda #<nom
	sta $22
	lda #>nom
	jmp 42053
su2	jsr det
su3	jsr det
	ldy #0
	lda (tmp),y
	beq su4
	lda tmp
	cmp b
	bne su3
	lda tmp+1
	cmp b+1
	bne su3
	jsr det
su4	jsr it
	lda tmp
	sta ae
	lda tmp+1
	sta ae+1
	ldy #0
	sty f
	jsr det
su5	jsr it
	ldy f
	inc f
	lda (122),y
	beq found
	ldy #0
	cmp (tmp),y
	beq su5
	lda ae
	sta tmp
	lda ae+1
	sta tmp+1
	bne su1
found	lda ae
	sta tmp
	lda ae+1
	sta tmp+1
	bne lieg
aufruf	jsr fuell
	lda $14
	ora $15
	bne nonull
err	lda #<ste
	sta $22
	lda #>ste
	jmp 42053
nonull	lda $15
	cmp le+1
	bcc nuok
	bne err
	lda $14
	cmp le
	bcc nuok
	bne err
nuok	jsr ram
	lda #0
	sta tmp
	lda #>cache
	sta tmp+1
sea	lda $15
	bne hopp
	lda $14
	cmp #2
	bcc lieg
hopp	lda $14
	bne nocy
	dec $15
nocy	dec $14
su0	ldy #0
	lda (tmp),y
	beq erloes
	jsr it
	jmp su0
erloes	jsr it
	jmp sea
lieg	lda #1
	sta ae
	lda m122
	sta 122
	lda m122+1
	sta 123
neu	ldy #0
	lda (tmp),y
	beq off
	ldy ae
	inc ae
	sta (122),y
	jsr wr
	jsr it
	jmp neu
off	jsr rom
	lda #0
	sta ae+1
mehr	ldx ae+1
	inc ae+1
	lda more,x
	pha
	ldy ae
	inc ae
	sta (122),y
	jsr wr
	pla
	bne mehr
	ldy ae
	iny
	sta (122),y
	jsr $aad7
	jmp bef
dek	lda 122
	bne hh
	dec 123
hh	dec 122
	rts
dm	ldx $3a
	inx
	beq aussen
	lda #<dmo
	sta $22
	lda #>dmo
	jmp 42053
aussen	rts
it	inc tmp
	bne h2
	inc tmp+1
	lda tmp+1
	cmp #>caend
	bcc h2
	lda #>cache
	sta tmp+1
h2	rts
its	inc s
	bne h2
	inc s+1
	lda s+1
	cmp #>caend
	bcc h2
	lda #>cache
	sta s+1
	rts
itb	inc b
	bne h2
	inc b+1
	lda b+1
	cmp #>caend
	bcc h2
	lda #>cache
	sta b+1
	rts
det	lda tmp
	bne de1
	dec tmp+1
	lda tmp+1
	cmp #>cache
	bcs de1
	lda #>caend-256
	sta tmp+1
de1	dec tmp
	rts
ram	lda #54
	sei
	sta 1
	rts
rom	lda #55
	sta 1
	cli
	rts
wr	tax
	bpl so
	inx
	beq so+2
	ldx 212
	bne so+2
	sec
	sbc #$7f
	tax
	ldy #-1
w1	dex
	beq w2
w3	iny
	lda beta,y
	bpl w3
	bmi w1
w2	iny
	lda beta,y
	bmi so
	jsr $ffd2
	bcc w2
so	and #127
	tax
	beq h2
	jmp $ffd2
fuell	ldy #-1
fu1	iny
	lda (122),y
	sta more,y
	bne fu1
	rts
getmin	jsr 115
	jsr $a96b
	lda $14
	ora $15
	bne wert
	sta min
	sta min+1
	rts
wert	sec
	lda le
	sbc $14
	sta min
	lda le+1
	sbc $15
	sta min+1
	bcs klar
	lda #0
	sta min
	sta min+1
klar	rts
hh0	jsr hex
	lda #0
hex	pha
	lsr
	lsr
	lsr
	lsr
	jsr hex1
	pla
hex1	and #15
	tax
	lda hext,x
	jmp $ffd2
in	lda #1
	sta new
	jmp $a483
