Exemplo n.º 1
0
        public Processor(IMemoryBank memory = null, IMemoryMap map = null, ushort?topOfStackAddress = null, float frequencyInMHz = 4, bool enableFlagPrecalculation = true)
        {
            // You can supply your own memory implementations, for example if you need to do RAM paging for >64K implementations.
            // Since there are several different methods for doing this and no 'official' method, there is no paged RAM implementation in the core code.

            FrequencyInMHz          = frequencyInMHz;
            _windowsTicksPerZ80Tick = (int)Math.Ceiling(10 / frequencyInMHz);

            Registers = new Registers(this);
            Ports     = new Ports(this);
            Memory    = memory ?? new MemoryBank();
            Memory.Initialise(this, map ?? new MemoryMap(MAX_MEMORY_SIZE_IN_BYTES, true));
            IO = new ProcessorIO(this);

            TimingMode    = TimingMode.FastAndFurious;
            InterruptMode = InterruptMode.IM0;

            _topOfStack  = topOfStackAddress ?? 0;
            Registers.SP = _topOfStack;

            // If precalculation is enabled, all flag combinations for all input values for 8-bit ALU / bitwise operations are pre-built now
            // (but not the 16-bit ALU operations, the number space is far too big).
            // This is *slightly* faster than calculating them in real-time, but if you need to debug flag calculation you should
            // disable this and attach a debugger to the flag calculation methods in FlagLookup.cs.
            FlagLookup.EnablePrecalculation = enableFlagPrecalculation;
            FlagLookup.BuildFlagLookupTables();

            // The Z80 instruction set needs to be built (all Instruction objects are created, bound to the microcode instances, and indexed into a hashtable - undocumented 'overloads' are built here too)
            InstructionSet.Build();

            _debugging = Debugger.IsAttached;
        }
Exemplo n.º 2
0
 public DeviceViewModel(PortViewModel owner, IMemoryMap memoryMap)
 {
     Owner          = owner;
     type           = NodeTypes.device;
     Name           = "Device";
     Icon           = "/Images/device.png";
     this.memoryMap = memoryMap;
     this.memoryMap.HoldingRegisterChanged += MemoryMap_HoldingRegisterChanged;
 }
Exemplo n.º 3
0
 public SpriteHandler(
     IPPUMemoryMap ppuMemoryMap,
     PPURegisters registers,
     PaletteHandler paletteHandler)
 {
     this.registers      = registers;
     this.ppuMemoryMap   = ppuMemoryMap;
     this.paletteHandler = paletteHandler;
 }
Exemplo n.º 4
0
        public Mmu(IMemoryMap memoryMap, IRegisters registers)
        {
            this.MemoryMap = memoryMap;
            this.Registers = registers;

            // TODO: Initialize IO memory

            this.Stack = new Stack(this.MemoryMap, this.Registers.Sp);

            this.Reset();
        }
Exemplo n.º 5
0
        public void CreateSlaves(CancellationToken token)
        {
            PortViewModel portModel;

            foreach (var port in Children)
            {
                portModel = (PortViewModel)port;
                foreach (var device in portModel.Children)
                {
                    IMemoryMap map     = ((DeviceViewModel)device).GetMemory();
                    ushort     address = ((DeviceViewModel)device).Address;
                    new Slave(address, portModel.GetPort(), map, token);
                }
            }
        }
Exemplo n.º 6
0
        public Processor(
            IMemoryMap memoryMap,
            Registers registers,
            FlagProcessor flagProcessor,
            OpcodeCycles opcodeCycles,
            InterruptController interruptController)
        {
            this.memoryMap           = memoryMap;
            this.registers           = registers;
            this.flagProcessor       = flagProcessor;
            this.opcodeCycles        = opcodeCycles;
            this.interruptController = interruptController;

            flags             = registers.Flags;
            interruptsEnabled = true;
        }
Exemplo n.º 7
0
        public MirroredMemory(int lowerIndex, int upperIndex, int mirroredLowerIndex, int mirroredUpperIndex, IMemoryMap memoryMapper, string name)
            : base(new Range(lowerIndex, upperIndex), name)
        {
            this.mirroredRange = new Range(mirroredLowerIndex, mirroredUpperIndex);

            this.moduloValue = this.mirroredRange.Max - this.mirroredRange.Min;

            this.memoryMapper = memoryMapper;

            foreach (var memorySegment in this.memoryMapper)
            {
                if (this.mirroredRange.IsOverlapped(memorySegment.Range) || this.mirroredRange.Equals(memorySegment.Range))
                {
                    this.realMemorySegments.Add(memorySegment);
                }
            }

            if (!this.realMemorySegments.Any())
            {
                throw new InvalidOperationException($"Mirrored memory ({this.Name}) setup, but it can't find another memory segment to link to.");
            }
        }
Exemplo n.º 8
0
 public FunctionsImplementation(IMemoryMap memory)
 {
     memoryMap = memory;
 }
Exemplo n.º 9
0
 public MOS6502(IMemoryMap memoryMap)
 => this.MemoryMap = memoryMap;
Exemplo n.º 10
0
 public RamRegister(IMemoryMap ram, IDoubleRegister doubleRegister)
 {
     this.ram_            = ram;
     this.doubleRegister_ = doubleRegister;
 }
Exemplo n.º 11
0
 public Ricoh2A03(IMemoryMap memoryMap)
     : base(memoryMap)
 {
 }
Exemplo n.º 12
0
 public void Initialise(Processor cpu, IMemoryMap map)
 {
     _cpu         = cpu;
     _map         = map;
     _initialised = true;
 }
Exemplo n.º 13
0
 public GameBoyCpu(IMemoryMap memoryMap, Registers registers, Processor opcodeProcessor)
 {
     this.memoryMap = memoryMap;
     this.registers = registers;
     this.processor = opcodeProcessor;
 }
Exemplo n.º 14
0
 public ExternalFacade(IMemoryMap memoryMap, Range range, string name)
 {
     this.memoryMap = memoryMap;
     this.range     = range;
     this.Name      = name;
 }
Exemplo n.º 15
0
 public Stack(IMemoryMap memoryMap, IDoubleRegister sp)
 {
     this.memoryMap_ = memoryMap;
     this.sp_        = sp;
 }
Exemplo n.º 16
0
 public Device(IMemoryMap memoryMap)
 {
     this.memoryMap = memoryMap;
     observers      = new List <IObserver>();
 }