示例#1
0
        public Board(C64Interfaces.IVideoOutput video, C64Interfaces.IFile kernel, C64Interfaces.IFile basic, C64Interfaces.IFile charGen)
        {
            _systemCpu = new CPU.MOS6510((ushort)Map.CpuIOAddress, (ushort)Map.CpuIOSize, _memoryMaps[_currentMap], 1);
            _systemClock.OpFactory = _systemCpu.OpFactory;

            _systemCpu.Port.IOPort.OnPortOut += new IO.IOPort.PortOutDelegate(CpuPort_OnMemoryMapChanged);

            _systemCias = new IO.CIA[]
            {
                new IO.CIA((ushort)Map.Cia1RegistersAddress, (ushort)Map.Cia1RegistersSize, _systemCpu.IRQ, 0x00, 0x00),
                new IO.CIA((ushort)Map.Cia2RegistersAddress, (ushort)Map.Cia2RegistersSize, _systemCpu.IRQ, 0x3f, 0x06)
            };

            _systemVic = new Video.VIC((ushort)Map.VicRegistersAddress, (ushort)Map.VicRegistersSize, (ushort)Map.ColorRamAddress, (ushort)Map.ColorRamSize,
                _systemCpu.IRQ, video);

            _systemSid = new Audio.SID((ushort)Map.SidRegistersAddress, (ushort)Map.SidRegistersSize);

            _systemCias[1].PortA.OnPortOut += new IO.IOPort.PortOutDelegate(Cia1_PortA_OnPortOut);

            _serial = new IO.SerialPort();
            _sDataConn = new IO.SerialPort.BusLineConnection(_serial.DataLine);
            _sClockConn = new IO.SerialPort.BusLineConnection(_serial.ClockLine);

            _serial.ClockLine.OnLineChanged += new IO.SerialPort.LineChangedDelegate(ClockLine_OnLineChanged);
            _serial.DataLine.OnLineChanged += new IO.SerialPort.LineChangedDelegate(DataLine_OnLineChanged);

            _systemRam = new Memory.RAM(0, 0x10000);

            _kernelRom = new Memory.ROM((ushort)Map.KernelRomAddress, (ushort)Map.KernelRomSize, kernel);
            _basicRom = new Memory.ROM((ushort)Map.BasicRomAddress, (ushort)Map.BasicRomSize, basic);
            _charRom = new Memory.ROM((ushort)Map.CharRomAddress, (ushort)Map.CharRomSize, charGen);

            _charRomVic1 = new Memory.ROM((ushort)Map.CharRomAddress_Vic1, (ushort)Map.CharRomSize, charGen);
            _charRomVic2 = new Memory.ROM((ushort)Map.CharRomAddress_Vic2, (ushort)Map.CharRomSize, charGen);

            for (int i = 0; i < _memoryMaps.Length; i++)
            {
                _memoryMaps[i].Map(_systemRam, true);
                _memoryMaps[i].Map(_systemCpu.Port, true);

                if ((i & 2) != 0)
                {
                    _memoryMaps[i].Map(_kernelRom, Memory.MemoryMapEntry.AccessType.Read, true);

                    if ((i & 1) != 0)
                        _memoryMaps[i].Map(_basicRom, Memory.MemoryMapEntry.AccessType.Read, true);
                }

                if ((i & 3) != 0)
                {
                    if ((i & 4) != 0)
                    {
                        _memoryMaps[i].Map(_systemVic, true);
                        _memoryMaps[i].Map(_systemSid, true);
                        _memoryMaps[i].Map(_systemVic.ColorRam, true);
                        _memoryMaps[i].Map(_systemCias[0], true);
                        _memoryMaps[i].Map(_systemCias[1], true);
                    }
                    else
                        _memoryMaps[i].Map(_charRom, Memory.MemoryMapEntry.AccessType.Read, true);
                }
            }

            _systemVic.Memory.Map(_systemRam, true);
            _systemVic.Memory.Map(_charRomVic1, Memory.MemoryMapEntry.AccessType.Read, true);
            _systemVic.Memory.Map(_charRomVic2, Memory.MemoryMapEntry.AccessType.Read, true);

            _systemClock.QueueOpsStart(_systemVic.RasterLine.CreateOps(), 0);
            _systemCpu.Restart(_systemClock, 1);
            _systemClock.QueueOpsStart(_systemCias[0].CreateOps(), 2);
            _systemClock.QueueOpsStart(_systemCias[1].CreateOps(), 3);

            _systemClock.OnTimeSlice += new Clock.Clock.PhaseEndDelegate(_systemCias[0].IncrementTod);
            _systemClock.OnTimeSlice += new Clock.Clock.PhaseEndDelegate(_systemCias[1].IncrementTod);

            _systemClock.OnTimeSlice += new Clock.Clock.PhaseEndDelegate(_checkPendingStateOperations_OnTimeSlice);
        }
示例#2
0
        public Board(C64Interfaces.IVideoOutput video, C64Interfaces.IFile kernel, C64Interfaces.IFile basic, C64Interfaces.IFile charGen)
        {
            _systemCpu             = new CPU.MOS6510((ushort)Map.CpuIOAddress, (ushort)Map.CpuIOSize, _memoryMaps[_currentMap], 1);
            _systemClock.OpFactory = _systemCpu.OpFactory;

            _systemCpu.Port.IOPort.OnPortOut += new IO.IOPort.PortOutDelegate(CpuPort_OnMemoryMapChanged);

            _systemCias = new IO.CIA[]
            {
                new IO.CIA((ushort)Map.Cia1RegistersAddress, (ushort)Map.Cia1RegistersSize, _systemCpu.IRQ, 0x00, 0x00),
                new IO.CIA((ushort)Map.Cia2RegistersAddress, (ushort)Map.Cia2RegistersSize, _systemCpu.IRQ, 0x3f, 0x06)
            };

            _systemVic = new Video.VIC((ushort)Map.VicRegistersAddress, (ushort)Map.VicRegistersSize, (ushort)Map.ColorRamAddress, (ushort)Map.ColorRamSize,
                                       _systemCpu.IRQ, video);

            _systemSid = new Audio.SID((ushort)Map.SidRegistersAddress, (ushort)Map.SidRegistersSize);

            _systemCias[1].PortA.OnPortOut += new IO.IOPort.PortOutDelegate(Cia1_PortA_OnPortOut);

            _serial     = new IO.SerialPort();
            _sDataConn  = new IO.SerialPort.BusLineConnection(_serial.DataLine);
            _sClockConn = new IO.SerialPort.BusLineConnection(_serial.ClockLine);

            _serial.ClockLine.OnLineChanged += new IO.SerialPort.LineChangedDelegate(ClockLine_OnLineChanged);
            _serial.DataLine.OnLineChanged  += new IO.SerialPort.LineChangedDelegate(DataLine_OnLineChanged);

            _systemRam = new Memory.RAM(0, 0x10000);

            _kernelRom = new Memory.ROM((ushort)Map.KernelRomAddress, (ushort)Map.KernelRomSize, kernel);
            _basicRom  = new Memory.ROM((ushort)Map.BasicRomAddress, (ushort)Map.BasicRomSize, basic);
            _charRom   = new Memory.ROM((ushort)Map.CharRomAddress, (ushort)Map.CharRomSize, charGen);

            _charRomVic1 = new Memory.ROM((ushort)Map.CharRomAddress_Vic1, (ushort)Map.CharRomSize, charGen);
            _charRomVic2 = new Memory.ROM((ushort)Map.CharRomAddress_Vic2, (ushort)Map.CharRomSize, charGen);

            for (int i = 0; i < _memoryMaps.Length; i++)
            {
                _memoryMaps[i].Map(_systemRam, true);
                _memoryMaps[i].Map(_systemCpu.Port, true);

                if ((i & 2) != 0)
                {
                    _memoryMaps[i].Map(_kernelRom, Memory.MemoryMapEntry.AccessType.Read, true);

                    if ((i & 1) != 0)
                    {
                        _memoryMaps[i].Map(_basicRom, Memory.MemoryMapEntry.AccessType.Read, true);
                    }
                }

                if ((i & 3) != 0)
                {
                    if ((i & 4) != 0)
                    {
                        _memoryMaps[i].Map(_systemVic, true);
                        _memoryMaps[i].Map(_systemSid, true);
                        _memoryMaps[i].Map(_systemVic.ColorRam, true);
                        _memoryMaps[i].Map(_systemCias[0], true);
                        _memoryMaps[i].Map(_systemCias[1], true);
                    }
                    else
                    {
                        _memoryMaps[i].Map(_charRom, Memory.MemoryMapEntry.AccessType.Read, true);
                    }
                }
            }

            _systemVic.Memory.Map(_systemRam, true);
            _systemVic.Memory.Map(_charRomVic1, Memory.MemoryMapEntry.AccessType.Read, true);
            _systemVic.Memory.Map(_charRomVic2, Memory.MemoryMapEntry.AccessType.Read, true);

            _systemClock.QueueOpsStart(_systemVic.RasterLine.CreateOps(), 0);
            _systemCpu.Restart(_systemClock, 1);
            _systemClock.QueueOpsStart(_systemCias[0].CreateOps(), 2);
            _systemClock.QueueOpsStart(_systemCias[1].CreateOps(), 3);

            _systemClock.OnTimeSlice += new Clock.Clock.PhaseEndDelegate(_systemCias[0].IncrementTod);
            _systemClock.OnTimeSlice += new Clock.Clock.PhaseEndDelegate(_systemCias[1].IncrementTod);

            _systemClock.OnTimeSlice += new Clock.Clock.PhaseEndDelegate(_checkPendingStateOperations_OnTimeSlice);
        }