unit basicunit;
{$mode delphi} {$H+}
interface
uses  Classes, SysUtils;
Procedure ModulesInit;
Procedure ModulesDone;
procedure BASICmain;

Const DrawTimeInterval=0;
Const DrawStartDelay=0;

implementation
uses Forms, math, graphics,
 Unix,dl,
  base,base2,textfrm,textfile,arrays,affine,graphsys,
  math2sub,datalist,baslib,graphlib,debugdg,paintfrm,
  MyThread,assignlib, mathlib0;
{$MAXFPUREGISTERS 0}




procedure _CCURVE(var _X0:double; var _Y0:double; var _X2:double; var _Y2:double; var _N:double); overload; forward;

(* Modules initialize and dispose *)
Procedure ModulesInit;
begin
end;
Procedure ModulesDone;
begin
end;

procedure _CCURVE(var _X0:double; var _Y0:double; var _X2:double; var _Y2:double; var _N:double);  overload;
var _X1:double=0;
var _Y1:double=0;
var arg_n00001:double;
begin
{$MAXFPUREGISTERS 0}
try
//  IF n=0 THEN  
if _N=0 then
 begin
//     PLOT LINES: x0,y0; x2,y2
PlotLinesBeamOff([_X0,_Y0,_X2,_Y2]);
//  ELSE
 end
 else
 begin
//     LET x1=x0+SQR(1/2)*(COS(PI/4)*(x2-x0)-SIN(PI/4)*(y2-y0))
_X1 := _X0+0.70710678118654757*((COS((PI)/4))*(_X2-(_X0))-((SIN((PI)/4))*(_Y2-(_Y0))));
//     LET y1=y0+SQR(1/2)*(SIN(PI/4)*(x2-x0)+COS(PI/4)*(y2-y0))
_Y1 := _Y0+0.70710678118654757*((SIN((PI)/4))*(_X2-(_X0))+(COS((PI)/4))*(_Y2-(_Y0)));
//     CALL CCurve(x0,y0,x1,y1,n-1) 
_CCURVE(_X0,_Y0,_X1,_Y1,NumericVariable(arg_n00001,_N-1)^);
//     CALL CCurve(x1,y1,x2,y2,n-1) 
_CCURVE(_X1,_Y1,_X2,_Y2,NumericVariable(arg_n00001,_N-1)^);
//  END IF
 end;
//  END SUB

except
on E:EMathError do begin
  RecoverFloatException; 
  raise EExtype.create(PropagatedExtype( EXTYPE(E,ExCode))) end;
on E:EDivByZero do begin
  RecoverFloatException; 
   raise EExtype.create(PropagatedExtype( EXTYPE(E,ExCode))) end;
on E:EExType do begin
   E.extype:=PropagatedExtype(E.Extype); raise end;
end;
end;
(* Main Program *)
procedure BASICmain;
var _N:double=0;
var arg_n00001:double;
var arg_n00002:double;
var arg_n00003:double;
var arg_n00004:double;
begin
//  SET WINDOW -0.5,1.5,-0.5,1.5
SetWindow(-0.5,1.5,-0.5,1.5, false );
//  LET n=10
_N := 10;
//  CALL CCurve(0,0,1,0,n)
_CCURVE(NumericVariable(arg_n00001,0)^,NumericVariable(arg_n00002,0)^,NumericVariable(arg_n00003,1)^,NumericVariable(arg_n00004,0)^,_N);
//  END

end;{end main}
initialization
  AppName:='/home/shiraishi/デスクトップ/BASICJa/FRACTAL/CCurve1';
  SystemStackSize := 66846720;
  signiwidth0:=13;
  TextMode := false ;
  GraphMode:= true ;
  BMPSize:=BMP801;
  TextProblemCoordinate:= false ;
  UseCharInput:= false ;
  FontCharSet:=1;
  FontSize:=0;
  FontName:='default';
  FontStyle:=[];
  FirstThreadPriority:=tpNormal;



Finalization



end.
