コード例 #1
0
ファイル: Cmps.cs プロジェクト: douglasbarnes/vmcs
        protected override void OnInitialise()
        {
            List<byte[]> DestSource = Fetch();

            // Carry out the subtraction and discard the results(That is how comparison works in assembly, it has the same flags as subtraction).
            Result = Bitwise.Subtract(DestSource[0], DestSource[1], out _);
        }
コード例 #2
0
        public Capabilities WithFlags(FlagSet flags)
        {
            var result = this.Copy();

            result.Flags = flags;
            return(result);
        }
コード例 #3
0
 public TaskPathwayPickEdge(RandoLogic logic, LinkedNode node, FlagSet state, bool forceWarp) : base(logic)
 {
     // TODO: advance forward through any obligatory edges
     this.Node      = node;
     this.State     = state;
     this.ForceWarp = forceWarp;
 }
コード例 #4
0
        internal override void Apply(FlagSet set)
        {
            if (!string.IsNullOrEmpty(EnvironmentVariable))
            {
                foreach (var variable in EnvironmentVariable.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var envVar = variable.Trim();
                    var envVal = Environment.GetEnvironmentVariable(envVar);
                    if (string.IsNullOrEmpty(envVal))
                    {
                        continue;
                    }

                    Value = decimal.Parse(envVal);
                    break;
                }
            }

            if (Value == default(decimal) && DefaultValue != default(decimal))
            {
                Value = DefaultValue;
            }

            set.AddFlag(this);
        }
コード例 #5
0
 public WordEntry(string word, FlagSet flags, MorphSet morphs, WordEntryOptions options)
 {
     Word    = word;
     Flags   = flags;
     Morphs  = morphs;
     Options = options;
 }
コード例 #6
0
        internal override void Apply(FlagSet set)
        {
            if (!string.IsNullOrEmpty(EnvironmentVariable))
            {
                foreach (var variable in EnvironmentVariable.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var envVar = variable.Trim();
                    var envVal = Environment.GetEnvironmentVariable(envVar);
                    if (string.IsNullOrEmpty(envVal))
                    {
                        continue;
                    }

                    bool envValBool;

                    if (bool.TryParse(envVal, out envValBool))
                    {
                        Value = envValBool;
                        break;
                    }
                }
            }

            if (!set.HasFlag(this))
            {
                set.AddFlag(this);
            }
        }
コード例 #7
0
 public void ChooseMajorValues(int tieBreaker)
 {
     //don't touch character body layout
     //we'll let the texture do that
     GeneralAge = FlagSet.GetFlagBitValue(GeneralAge, tieBreaker, 1);
     Ethnicity  = FlagSet.GetFlagBitValue(Ethnicity, tieBreaker, 1);
 }
コード例 #8
0
            public static void UpdateState(FlagSet state, string name, bool set)
            {
                var orig = state.TryGetValue(name, out var x) ? x : FlagState.Unset;

                if (set)
                {
                    if (orig == FlagState.One || orig == FlagState.Unset)
                    {
                        state[name] = FlagState.UnsetToSet;
                    }
                    else if (orig == FlagState.SetToUnset)
                    {
                        state[name] = FlagState.Both;
                    }
                }
                else
                {
                    if (orig == FlagState.One || orig == FlagState.Set)
                    {
                        state[name] = FlagState.SetToUnset;
                    }
                    else if (orig == FlagState.UnsetToSet)
                    {
                        state[name] = FlagState.Both;
                    }
                }
            }
コード例 #9
0
            public override bool Next()
            {
                var receipt = this.WorkingPossibility();

                if (receipt == null)
                {
                    return(false);
                }

                this.TriedRooms.Add(receipt.NewRoom.Static);
                this.AddReceipt(receipt);
                var newNode = receipt.NewRoom.Nodes["main"];
                var state   = new FlagSet();

                foreach (var node in LinkedNodeSet.Closure(newNode, this.Logic.Caps.WithFlags(state), null, true).Nodes)
                {
                    foreach (var setter in node.Static.FlagSetters)
                    {
                        TaskPathwayPickRoom.UpdateState(state, setter.Item1, setter.Item2);
                        newNode = node;
                    }
                }
                this.AddNextTask(new TaskPathwayPickEdge(this.Logic, newNode, state, false));
                if (this.Logic.Settings.Strawberries != StrawberryDensity.None)
                {
                    this.AddLastTask(new TaskPathwayBerryOffshoot(this.Logic, newNode, state));
                }

                return(true);
            }
コード例 #10
0
            private void HandleRequirements(Requirement r, FlagSet mutState, FlagSet immState)
            {
                switch (r)
                {
                case Possible _:
                    return;

                case Conjunction rc: {
                    foreach (var sr in rc.Children)
                    {
                        this.HandleRequirements(sr, mutState, immState);
                    }
                    break;
                }

                case Disjunction rd: {
                    // maybe this could be handled by having a TaskSatisfyDisjunction which tries to add the children one at a time?
                    var sr = rd.Children[this.Logic.Random.Next(rd.Children.Count)];
                    this.HandleRequirements(sr, mutState, immState);
                    break;
                }

                default: {
                    if (r is FlagRequirement fr)
                    {
                        mutState[fr.Flag] = fr.Set ? FlagState.Set : FlagState.Unset;
                    }
                    this.AddNextTask(new TaskPathwaySatisfyRequirement(this.Logic, this.Node, r, immState));
                    break;
                }
                }
            }
コード例 #11
0
ファイル: Scas.cs プロジェクト: douglasbarnes/vmcs
        protected override void OnInitialise()
        {
            // Fetch operands
            List <byte[]> Operands = Fetch();

            // Subtract and store the result flags. Like cmp, only the flags are stored.
            ResultFlags = Bitwise.Subtract(Operands[1], Operands[0], out _);
        }
コード例 #12
0
        private void RunAsSubcommand(CommandContext context)
        {
            if (this.GetCommand(helpCommand.Name) == null && !HideHelp)
            {
                Commands.Add(helpCommand);
                if (!this.HasFlag(helpFlag))
                {
                    Flags.Add(helpFlag);
                }
            }

            var flagSet = new FlagSet(Name);

            foreach (var flag in Flags)
            {
                flag.Apply(flagSet);
            }

            flagSet.Parse(context.Args().Skip(1).ToArray());
            Flags.NormalizeFlags(flagSet);

            var subContext = new CommandContext(this, flagSet, context);
            //var ctxArgs = subContext.Args();
            var ctxArgs = subContext.Args();

            if (ctxArgs.Any())
            {
                var name = ctxArgs.First();
                var c    = this.GetCommand(name);
                if (c != null)
                {
                    if (c.Flags.Any())
                    {
                        foreach (var flag in c.Flags)
                        {
                            flag.Apply(flagSet);
                        }

                        flagSet.Parse(subContext.Args().ToArray());
                        Flags.NormalizeFlags(flagSet);
                    }
                    subContext.ConsoleCommand = c;
                    if (!CheckHelp(subContext, c))
                    {
                        c.Action(subContext);
                    }
                    return;
                }
                else
                {
                    flagSet.Set("help", true);
                    CheckHelp(subContext, context.ConsoleCommand);
                    return;
                }
            }

            Action(context);
        }
コード例 #13
0
 public TaskPathwaySatisfyRequirement(RandoLogic logic, LinkedNode node, Requirement req, FlagSet state, LinkedNode originalNode = null, bool internalOnly = false, int tries = 0) : base(logic)
 {
     this.Node         = node;
     this.InternalOnly = internalOnly;
     this.Req          = req;
     this.OriginalNode = originalNode ?? node;
     this.Tries        = this.BaseTries = tries;
     this.State        = state;
 }
コード例 #14
0
        public override void Execute()
        {
            // Perform the decrement
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.Decrement(Fetch()[0], out Result);

            // Store results
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #15
0
ファイル: Ghost.cs プロジェクト: lukellie/videogame-genres
            public IEnumerable <bool> run_interaction(Inventory inventory, FlagSet flags, UIController controller)
            {
                var entry = ghost.GetEntryPoint("follow");

                if (entry == null)
                {
                    return(null);
                }
                return(ghost.run_graph_interaction(entry, inventory, flags, controller));
            }
コード例 #16
0
            public TaskPathwayPickRoom(RandoLogic Logic, UnlinkedEdge edge, FlagSet state) : base(Logic)
            {
                this.Edge  = edge;
                this.State = state;

                float progress = (Logic.Map.Worth - PathwayMinimums[(int)Logic.Settings.Length]) / PathwayRanges[(int)Logic.Settings.Length];

                this.IsEnd   = progress > Math.Sqrt(Logic.Random.NextFloat());
                this.FakeEnd = this.IsEnd && Logic.Random.Next(100) == 0;
            }
コード例 #17
0
ファイル: Inc.cs プロジェクト: douglasbarnes/vmcs
        public override void Execute()
        {
            // Calculate the result of incrementation
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.Increment(Fetch()[0], out Result);

            // Set the result. Bitwise.Increment() does not set the carry flag.
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #18
0
 public Options(Writer Writer = default, FlagSet Flagset = default, Fetcher Fetch = default, Symbolizer Sym = default, ObjTool Obj = default, UI UI = default, Func <ptr <HTTPServerArgs>, error> HTTPServer = default, http.RoundTripper HTTPTransport = default)
 {
     this.Writer        = Writer;
     this.Flagset       = Flagset;
     this.Fetch         = Fetch;
     this.Sym           = Sym;
     this.Obj           = Obj;
     this.UI            = UI;
     this.HTTPServer    = HTTPServer;
     this.HTTPTransport = HTTPTransport;
 }
コード例 #19
0
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> DestSource = Fetch();

            // Subtract operand 1 from operand 0 and discard the result, keeping only the flags. This is
            // the essence of a compare in assembly.
            FlagSet Result = Bitwise.Subtract(DestSource[0], DestSource[1], out _);

            ControlUnit.SetFlags(Result);
        }
コード例 #20
0
ファイル: FlagTests.cs プロジェクト: mikeruhl/goflag
        public void TestSetOutput()
        {
            var flags  = new FlagSet("test", ErrorHandling.ContinueOnError);
            var writer = new StringWriter();

            flags.SetOutput(writer);
            flags.Parse(new[] { "-unknown" });
            var output = writer.ToString();

            Assert.True(output.Contains("-unknown"), $"expected output mentioning unknown; got \"{output}\"");
        }
コード例 #21
0
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> DestSource = Fetch();

            // AND the operands and discard the result
            FlagSet ResultFlags = Bitwise.And(DestSource[0], DestSource[1], out _);

            // Set the flags to the result.
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #22
0
 private void ShowChoices(FlagSet flag_set)
 {
     if (choice_node.answers.Count > 0)
     {
         var choices = new List <ListController <int> .ListElement>();
         for (int i = 0; i < choice_node.answers.Count; i++)
         {
             Port port   = choice_node.GetPort($"answers[{i}]");
             var  answer = choice_node.answers[i];
             if (port.IsConnected && port.ConnectedPorts[0].node is InteractionNode)
             {
                 if ((port.ConnectedPorts[0].node as InteractionNode).FlagsMeetRequirements(flag_set))
                 {
                     var choice = new ListController <int> .ListElement()
                     {
                         text      = answer.list_text,
                         value     = i,
                         choosable = true,
                     };
                     if (answer.unique_preview)
                     {
                         choice.description = answer.preview;
                     }
                     else if (answer.show_preview && port.ConnectedPorts[0].node is DialogueNode)
                     {
                         choice.description = (port.ConnectedPorts[0].node as DialogueNode).Dialogue;
                     }
                     else
                     {
                         choice.description = null;
                     }
                     choices.Add(choice);
                 }
             }
             else
             {
                 choices.Add(new ListController <int> .ListElement()
                 {
                     text        = answer.list_text,
                     description = answer.show_preview || answer.unique_preview ? answer.preview : null,
                     choosable   = true,
                     value       = i
                 });
             }
         }
         if (choices.Count > 0)
         {
             this.choice_controller.ShowList(choices);
             return;
         }
     }
     choice_node = null;
 }
コード例 #23
0
ファイル: Rxr.cs プロジェクト: douglasbarnes/vmcs
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> Operands = Fetch();

            // Perform the rotate and store the results. The callee will ignore "ControlUnit.Flags.Carry == FlagState.ON" if $UseCarry == false.
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.RotateRight(Operands[0], Operands[1][0], UseCarry, ControlUnit.Flags.Carry == FlagState.ON, out Result);

            // Set the results.
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #24
0
ファイル: Neg.cs プロジェクト: douglasbarnes/vmcs
        public override void Execute()
        {
            // Fetch operand(only one is used/provided)
            byte[] Operand = Fetch()[0];

            // Negate it
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.Negate(Operand, out Result);

            // Set results.
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #25
0
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> Operands = Fetch();

            // Perform multiplication of the last two operands(read summary)
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.Multiply(Operands[Operands.Count - 1], Operands[Operands.Count - 2], (Settings | OpcodeSettings.SIGNED) == Settings, (int)Capacity, out Result);

            // Set results.
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #26
0
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> Operands = Fetch();

            // Perform rotation. See Bitwise.RotateLeft().
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.RotateLeft(Operands[0], Operands[1][0], UseCarry, ControlUnit.Flags.Carry == FlagState.ON, out Result);

            // Set results.
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #27
0
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> DestSource = Fetch();

            // Subtract operands[1] from operands[0]. If the carry flag is set, and would be used as a borrow, tell Bitwise.Subtract to start with a borrow.
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.Subtract(DestSource[0], DestSource[1], out Result, (ControlUnit.Flags.Carry == FlagState.ON && UseBorrow));

            // Set the results
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #28
0
ファイル: And.cs プロジェクト: douglasbarnes/vmcs
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> DestSource = Fetch();

            // Perform AND. The position of the two arguments is not important.
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.And(DestSource[0], DestSource[1], out Result);

            // Set results
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #29
0
ファイル: Xor.cs プロジェクト: douglasbarnes/vmcs
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> DestSource = Fetch();

            // XOR the operands and store in result
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.Xor(DestSource[0], DestSource[1], out Result);

            // Set the result and flags.
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }
コード例 #30
0
ファイル: Or.cs プロジェクト: douglasbarnes/vmcs
        public override void Execute()
        {
            // Fetch operands
            List <byte[]> DestSource = Fetch();

            // Perform the OR.
            byte[]  Result;
            FlagSet ResultFlags = Bitwise.Or(DestSource[0], DestSource[1], out Result);

            // Store results
            Set(Result);
            ControlUnit.SetFlags(ResultFlags);
        }