public void When_setting_register_state()
        {
            var state = RngFactory.Build <AccumulatorAndFlagsRegisterState>()();

            Subject.ResetToState(state);

            Subject.A.ShouldBe(state.A);

            The <IFlagsRegister>().VerifySet(x => x.Register = It.Is <byte>(y => y == state.F));
        }
Example #2
0
        public ExecuteFixture()
        {
            _setups     = new List <Action <ExecutionContext> >();
            _assertions = new EditableList <Action <ExecutionContext> >();
            _halt       = true;

            _address            = Rng.Word(0x6000, 0xaaaa);
            Operation           = new OperationFactory(_address);
            _registersFactory   = RngFactory.Build <GeneralPurposeRegisterState>();
            _accumulatorFactory = RngFactory.Build <AccumulatorAndFlagsRegisterState>();
        }
Example #3
0
 public void RotateRightDigit()
 {
     using (var fixture = new ExecuteFixture())
     {
         var result = RngFactory.Build <AccumulatorAndResult>()();
         fixture.Operation.OpCode(OpCode.RotateRightDigit);
         fixture.With(c => c.Mmu.Setup(x => x.ReadByte(c.Registers.HL)).Returns(c.Byte).Verifiable(),
                      c => c.Alu.Setup(x => x.RotateRightDigit(c.InitialAccumulator.A, c.Byte)).Returns(result).Verifiable());
         fixture.Assert(c => c.Accumulator.A.ShouldBe(result.Accumulator),
                        c => c.Mmu.Verify(x => x.WriteByte(c.Registers.HL, result.Result)));
     }
 }
        public void When_setting_register_state()
        {
            var state = RngFactory.Build <GeneralPurposeRegisterState>()();

            Subject.ResetToState(state);

            Subject.B.ShouldBe(state.B);
            Subject.C.ShouldBe(state.C);
            Subject.D.ShouldBe(state.D);
            Subject.E.ShouldBe(state.E);
            Subject.H.ShouldBe(state.H);
            Subject.L.ShouldBe(state.L);
        }
Example #5
0
 public IRng Get(string name) =>
 _rngs.GetOrAdd(name, n =>
 {
     var sb = new StringBuilder(_seed);
     if (name != null)
     {
         sb.Append('@').Append(name);
     }
     var seed = Context.Fire(new RngEvent.Create(Context, name)
     {
         Seed = sb.ToString()
     }).Seed;
     return(RngFactory.CreateSeeded(seed));
 });