private void InternalAddressBus_SendTo(InternalAddressBusConnection target)
 {
     switch (target)
     {
         case InternalAddressBusConnection.AddressBus:
             Address.SetValue(InternalAddressBus);
             break;
         case InternalAddressBusConnection.PC:
             PC = InternalAddressBus;
             break;
         case InternalAddressBusConnection.WZ:
             WZ = InternalAddressBus;
             break;
         default:
             throw new NotImplementedException();
     }
     if (TraceMicroInstructions)
     {
         TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.InternalAddressBusSendTo, target));
         if (target == InternalAddressBusConnection.AddressBus)
         {
             TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.BusConnectorSetValue, target));
         }
     }
 }
        private void InternalAddressBus_SampleFromAndIncrement(InternalAddressBusConnection source)
        {
            switch (source)
            {
               case InternalAddressBusConnection.PC:
                    // The PC is automatically incremented after its contents have been transferred to the address lines
                    InternalAddressBus_SampleFrom(InternalAddressBusConnection.PC);
                    Register16_Increment(InternalAddressBusConnection.PC);
                    break;
               case InternalAddressBusConnection.SP:
                    // The stack pointer is automatically incremented after its contents have been transferred to the address lines
                    InternalAddressBus_SampleFrom(InternalAddressBusConnection.SP);
                    Register16_Increment(InternalAddressBusConnection.SP);
                    break;
               case InternalAddressBusConnection.WZ:
                    InternalAddressBus_SampleFrom(InternalAddressBusConnection.WZ);
                    Register16_Increment(InternalAddressBusConnection.WZ);
                    break;
                case InternalAddressBusConnection.IandR:
                    // During every first machine cycle (beginning of an instruction or part of it, prefixes have their
                    // own M1 two), the memory refresh cycle is issued. The whole I+R register is put on the address
                    // bus, and the RFSH pin is lowered. It is unclear whether the Z80 increases the R register before
                    // or after putting I+R on the bus.
                    InternalAddressBus_SampleFrom(InternalAddressBusConnection.IandR);
                    // The R register is increased at every first machine cycle (M1). Bit 7 of the register is never
                    // changed by this.
                    RegisterR_Increment();
                    break;

                default:
                    throw new NotImplementedException();
            }
        }
 private void InternalAddressBus_SampleFromAndDecrement(InternalAddressBusConnection source)
 {
     switch (source)
     {
         case InternalAddressBusConnection.WZ:
             InternalAddressBus_SampleFrom(InternalAddressBusConnection.WZ);
             Register16_Decrement(InternalAddressBusConnection.WZ);
             break;
         default:
             throw new NotImplementedException();
     }
 }
 private void InternalAddressBus_SampleFrom(InternalAddressBusConnection source)
 {
     switch (source)
     {
         case InternalAddressBusConnection.PC:
             InternalAddressBus = PC;
             break;
         case InternalAddressBusConnection.SP:
             InternalAddressBus = SP;
             break;
         case InternalAddressBusConnection.WZ:
             InternalAddressBus = WZ;
             break;
         case InternalAddressBusConnection.IX:
             InternalAddressBus = IX;
             break;
         case InternalAddressBusConnection.IY:
             InternalAddressBus = IY;
             break;
         case InternalAddressBusConnection.IandR:
             // During every first machine cycle (beginning of an instruction or part of it, prefixes have their
             // own M1 two), the memory refresh cycle is issued. The whole I+R register is put on the address
             // bus, and the RFSH pin is lowered. It is unclear whether the Z80 increases the R register before
             // or after putting I+R on the bus.
             InternalAddressBus = (ushort)((I << 8) + R);
             break;
         default:
             throw new NotImplementedException();
     }
     if (TraceMicroInstructions)
     {
         TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.InternalAddressBusSampleFrom, source));
     }
 }
 private void InternalAddressBus_DecrementAndSampleFrom(InternalAddressBusConnection source)
 {
     switch (source)
     {
         case InternalAddressBusConnection.SP:
             // The stack pointer is automatically decremented before its contents are transferred to the address lines
             Register16_Decrement(Register16.SP);
             InternalAddressBus_SampleFrom(InternalAddressBusConnection.SP);
             break;
         default:
             throw new NotImplementedException();
     }
 }