aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Tamper/Operations/ForBlock.cs
blob: ef95fa2bf1151322c7271e86412dd5aefd783ded (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections.Generic;

namespace Ryujinx.HLE.HOS.Tamper.Operations
{
    class ForBlock : IOperation
    {
        private ulong _count;
        private Register _register;
        private IEnumerable<IOperation> _operations;

        public ForBlock(ulong count, Register register, IEnumerable<IOperation> operations)
        {
            _count = count;
            _register = register;
            _operations = operations;
        }

        public ForBlock(ulong count, Register register, params IOperation[] operations)
        {
            _count = count;
            _register = register;
            _operations = operations;
        }

        public void Execute()
        {
            for (ulong i = 0; i < _count; i++)
            {
                // Set the register and execute the operations so that changing the
                // register during runtime does not break iteration.

                _register.Set<ulong>(i);

                foreach (IOperation op in _operations)
                {
                    op.Execute();
                }
            }
        }
    }
}