Пример #1
0
        //public bool IsDirty { get; set; }

        public MemoryMapRegion(MemoryMapEventBus memoryMapEventBus)
        {
            MemoryMapCollection = new MemoryMapCollection(memoryMapEventBus);
        }
Пример #2
0
        public Trainer(ET3400Settings settings, PictureBox displayTarget)
        {
            Memory            = new int[65536];
            Breakpoints       = new BreakpointCollection();
            Settings          = settings;
            Watches           = new List <Watch>();
            MemoryMapManager  = new MemoryMapManager();
            MemoryMapEventBus = new MemoryMapEventBus();


            _mc6820 = new MC6820();
            _debugConsoleAdapter       = new DebugConsoleAdapter();
            _mc6820.OnPeripheralWrite += OnPeripheralWrite;
            _mc6820.OnPeripheralRead  += OnPeripheralRead;

            Settings.SettingsUpdated += (sender, args) =>
            {
                Runner.Recalibrate();
            };

            State = new Cpu6800State();

            Emulator = new Cpu6800
            {
                State = State,

                ReadMem = address =>
                {
                    address = address & 0xFFFF;

                    if (address >= 0x1000 && address <= 0x1003)
                    {
                        //_mc6820.RegisterSelect(address & 3);
                        //return _mc6820.Get();
                        return(_mc6820.Get(address & 3));
                    }

                    //foreach (var watch in Watches.ToList())
                    //{
                    //    if (watch.EventType == EventType.Read)
                    //    {
                    //        //if (watch.Address == address)
                    //        //{

                    //        //}
                    //        watch.Action(new WatchEventArgs() { Address = address });
                    //    }
                    //}

                    return(Memory[address]);
                },

                WriteMem = (address, value) =>
                {
                    address = address & 0xFFFF;

                    foreach (var watch in Watches.ToList())
                    {
                        if (watch.EventType == EventType.Write)
                        {
                            //if (watch.Address == address)
                            //{

                            //}

                            watch.Action(new WatchEventArgs()
                            {
                                Address = address
                            });
                        }
                    }

                    if (address >= 0x1000 && address <= 0x1003)
                    {
                        //_mc6820.RegisterSelect(address & 3);
                        //_mc6820.Set(value);
                        _mc6820.Set(address & 3, value);
                        return;
                    }

                    if (address >= 0x1400 && address <= 0x1BFF)
                    {
                        // Prevent writing to ROM-mapped space
                        return;
                    }

                    if (address >= 0x1C00 && address <= 0x23FF)
                    {
                        // Prevent writing to ROM-mapped space
                        return;
                    }

                    if (address >= 0xFC00)
                    {
                        // Prevent writing to ROM-mapped space
                        return;
                    }

                    // Limit writing to RAM addresses only?
                    Memory[address] = value;
                }
            };

            //Runner = new StandardRunner(this);
            Runner = new CycleExactRunner(this);

            _display        = new LedDisplay(displayTarget, this);
            Runner.OnSleep += OnSleep;

            // Set keyboard mapped memory 'high'
            Memory[0xC003] = 0xFF;
            Memory[0xC005] = 0xFF;
            Memory[0xC006] = 0xFF;
        }