(18 . 8)(18 . 8)
24 ------------------------------------------------------------------------------
25
26 -- Basics
27 with OS; use OS;
28 with CmdLine; use CmdLine;
29 with OS; use OS;
30 with CmdLine; use CmdLine;
31
32 -- FFA
33 with FZ_Lim; use FZ_Lim;
(39 . 14)(39 . 19)
35 -- For Output
36 with FFA_IO; use FFA_IO;
37
38 -- For RNG:
39 with FFA_RNG; use FFA_RNG;
40
41
42 procedure FFA_Calc is
43
44 Width : Positive; -- Desired FFA Width
45 Height : Positive; -- Desired Height of Stack
46 Width : Positive; -- Desired FFA Width
47 Height : Positive; -- Desired Height of Stack
48 RNG : RNG_Device; -- The active RNG device.
49
50 begin
51 if Arg_Count /= 3 then
52 Eggog("Usage: ./ffa_calc WIDTH HEIGHT");
53 if Arg_Count < 3 or Arg_Count > 4 then
54 Eggog("Usage: ./ffa_calc WIDTH HEIGHT [/dev/rng]");
55 end if;
56
57 declare
(57 . 6)(62 . 24)
59 Get_Argument(1, Arg1); -- First arg
60 Get_Argument(2, Arg2); -- Second arg
61
62 if Arg_Count = 4 then
63 -- RNG was specified:
64 declare
65 Arg3 : CmdLineArg;
66 begin
67 Get_Argument(3, Arg3); -- Third arg (optional)
68
69 -- Ada.Sequential_IO chokes on paths with trailing whitespace!
70 -- So we have to give it a trimmed path. But we can't use
71 -- Ada.Strings.Fixed.Trim, because it suffers from
72 -- SecondaryStackism-syphilis. Instead we are stuck doing this:
73 Init_RNG(RNG, Arg3(Arg3'First .. Len_Arg(3)));
74 end;
75 else
76 -- RNG was NOT specified:
77 Init_RNG(RNG); -- Use the machine default then
78 end if;
79
80 -- Parse into Positives:
81 Width := Positive'Value(Arg1);
82 Height := Positive'Value(Arg2);
(422 . 6)(445 . 12)
84 -- Other --
85 -----------
86
87 -- Push a FZ of RNGolade onto the stack
88 when '?' =>
89 Push;
90 FZ_Clear(Stack(SP));
91 FZ_Random(RNG, Stack(SP));
92
93 -- mUx
94 when 'U' =>
95 Want(3);