FOU3/11ASM	;
	ORG	3000H
	NOP
	DEFW	7F7FH
	DEFM	'TEST'
	DEFB	1
	PUSH	AF
	LD	A,L
	LD	(KKB),A
	LD	A,E
	LD	(107EH),A
	LD	A,C
	LD	(107FH),A
	CALL	FOU3
	POP	AF
	RET
	NOP
;---------------------------------------
;ARBEITSZELLEN
;-------------
ADR	DEFW	1000H ;ANFANGSADRESSE
		      ;DATENBEREICH
ADR1	DEFW	0     ;ADRESSZWISCHEN-
		      ;SPEICHER
XP0	DEFW	0     ;ANFANGSPKT. FUER
YP0	DEFB  	0     ;ZEITINTERVALL
XP1	DEFW	0     ;KOORDINATENZWI-
YP1	DEFB	0     ;SCHENSPEICHER
KKB	DEFB	0     ;KONFIGURATIONS-
		      ;KENNBYTE
;  BIT  :       0       :       1
;---------------------------------------
;   0   :               :
;   1   :               :
;   2   :               :
;   3   :               :
;   4   :               :
;   5   :               :
;   6   :               :
;   7   : KC 85/3 - BWS : KC 85/4 - BWS
;---------------------------------------
;FOURIERANALYSE + 3D-DIAGRAMM
;----------------------------
FOU3	PUSH	AF
	PUSH	HL
	PUSH	DE
	PUSH	BC
	PUSH	IY
	LD	HL,0 ;FENSTER EINSTELLEN
	LD	(0B79CH),HL
	LD	HL,2028H
	LD	(0B79EH),HL
	LD	HL,8000H	;CLS
	LD	DE,8001H
	LD	BC,36FFH
	LD	M,0
	LDIR
	LD	HL,0A800H
	LD	DE,0A801H
	LD	BC,9FFH
	LD	M,39H
	LDIR
	LD	BC,7640H ;KOORDINATEN-
	LD	HL,82F6H ;SYSTEM
KS0	PUSH	HL   ;SCHRAEGE ACHSE 1
	LD	A,(KKB) ;KC 85/3 ?
	BIT	7,A
	CALL	Z,UMWA
	LD	M,C
	POP	HL
	LD	A,0FH
	AND	B
	CP	8
	JR	NZ,KS1
	PUSH	HL
	LD	A,(KKB) ;KC 85/3 ?
	BIT	7,A
	CALL	Z,UMWA
	LD	M,3
	POP	HL
	INC	H
	PUSH	HL
	LD	A,(KKB) ;KC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L IN E
RFA12	POP	BC
	LD	A,1EH ;ERSTE FREQUENZ ?
	CP	C
	PUSH	BC
	JP	Z,RFA14 ;KEINE LINIEN-
	LD	HL,(XP1) ;DARSTELLUNG
	LD	A,(YP1)
	LD	D,A
	CP	80H
	JP	Z,RFA15	;LINIENANFANG
	LD	A,E	;AUSSER BEREICH
	LD	(YP1),A
	CP	80H
	JP	Z,RFA16	;LINIENENDE
	LD	B,7	;AUSSER BEREICH
	SUB	D
	JR	C,RFA17	;LINIE FALLEND
	CALL	MUL87
	LD	E,A
	LD	A,7
	AND	E
	SRL	E
	SRL	E
	SRL	E
RFA18	LD	C,D
	INC	B
	BIT	3,B
	JR	NZ,RFA23
	CALL	LIRES ;X IN HL, Y IN C
RFA23	DEC	B
RFA31	LD	C,E
RFA19	CALL	PSET  ;X IN HL, Y IN D
	INC	C
	DEC	C
	JR	Z,RFA40
	INC	D
	DEC	C
	JR	NZ,RFA19
RFA40	CP	0
	LD	(XP1),HL
	JR	Z,RFA20
	CALL	PSET
	INC	D
	DEC	A
RFA20	RRC	L	;NAECHSTE SPALTE
	JR	NC,RFA21
	INC	H
RFA21	DJNZ	RFA18
	JP	RFA24
RFA17	NEG	;FALLENDE LINIE
	CALL	MUL87
	LD	E,A
	LD	A,7
	AND	E
	SRL	E
	SRL	E
	SRL	E
RFA25	LD	C,E
RFA26	CALL	PSET
	INC	C
	DEC	C
	JR	Z,RFA41
	DEC	D
	DEC	C
	JR	NZ,RFA26
RFA41	CP	0
	LD	(XP1),HL
	JR	Z,RFA27
	CALL	PSET
	DEC	D
	DEC	A
RFA27	LD	C,D
	INC	B
	BIT	3,B
	JR	NZ,RFA28
	CALL	LIRES
RFA28	DEC	B
	RRC	L	;NAECHSTE SPALTE
	JR	NC,RFA29
	INC	H
RFA29	DJNZ	RFA25
	JR	RFA24
RFA16	LD	A,7FH ;LINIENENE AUSSER
	SUB	D	;BEREICH
	LD	E,A
	LD	A,3
	AND	E
	SRL	E
	SRL	E
	LD	B,4
	L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