MODULE Miller;
(* $!f+ :  (* bei aktivierter Option f FPU-Modul verwenden *)
FROM FPU IMPORT SIN, COS, EXTEND, WHOLE;
*)
FROM MathLib0 IMPORT Sin, Cos;
FROM InOut IMPORT Write, WriteLn, WriteString, WriteInt, Read;
IMPORT appl, graf, VDI, v, vsm, SysVar;

FROM SYSTEM IMPORT CODE;

CONST N = 251500;

VAR
	hdl,
	ScrW, ScrH: SHORTINT;

PROCEDURE init(): BOOLEAN;
VAR
	in: ARRAY [0..10] OF SHORTINT;
	out: ARRAY [0..56] OF SHORTINT;
	(*$R+*)i , j, w, h: SHORTINT;
BEGIN
	IF appl.init() < 0 THEN RETURN FALSE END;
	(*VDI init*)
	FOR i := 0 TO 9 DO in[i] := 1 END; in[10] := 2;
	hdl := graf.handle (j, j, j, j);
	v.opnvwk (in, hdl, out);
	IF hdl > 0 THEN
		ScrW := out[0]+1;
		ScrH := out[1]+1;
		RETURN TRUE
	ELSE
		appl.exit;
		RETURN FALSE
	END;
END init;

TYPE
	tPoint = ARRAY [0..0] OF VDI.tPoint;

PROCEDURE Main;
VAR
	(*$Reg*) w2, (*$Reg*) h2: LONGINT;
(*$Q+*)
	(*$Reg*) a,
	(*$Reg*) b,
	(*$Reg*) t: LONGREAL;
(*$Q=*)
	(*$R+*)i: LONGINT;
	(*$R+*)T: LONGCARD;
	msg: ARRAY [0..79] OF CHAR;
	Point: tPoint;
BEGIN
	IF init() THEN
		graf.mouseform (graf.Off);
		v.clrwk(hdl);
		w2 := ScrW DIV 2;
		h2 := ScrH DIV 2;
(* $!f- :
		a := FLOAT (w2) / 2.0;
		b := FLOAT (h2) / 1.3;
*)
(* $!f+ :
		a := EXTEND (w2) / 2.0;
		b := EXTEND (h2) / 1.3;
*)
		t := 0.0;
		VOID (vsm.color (hdl, VDI.Black));
		T := SysVar.T200Hz();
		FOR i := 0 TO N DO
			INC (t, 0.0025);
			Point := tPoint{{
(* $!f- :
									w2 + INT (a * (Sin (0.99 * t) - 0.7 * Cos (3.01 * t))),
									h2 + INT (b * (Cos (1.01 * t) + 0.1 * Sin (15.03 * t)))
*)
(* $!f+ :
									w2 + WHOLE (a * (SIN (0.99 * t) - 0.7 * COS (3.01 * t))),
									h2 + WHOLE (b * (COS (1.01 * t) + 0.1 * SIN (15.03 * t)))
*)
								}};
			v.pmarker (hdl, 1, Point);
		END;
		T := SysVar.T200Hz() - T;
		msg := FORM (33C+'H', N, ' Durchl„ufe -> ', T DIV 200, ' sec; ',
								 N*200 DIV T, ' Durchl„ufe/sec'+15C+12C); WriteString(msg);
		Read(msg[0]);
		graf.mouseform (graf.On);
		v.clsvwk(hdl);
		appl.exit()
	END;
END Main;

BEGIN
	Main
END Miller.
		
	
	