Ejemplo n.º 1
0
 public Trainer()
 {
     emu = new Cpu6800();
     // Set keyboard mapped memory 'high'
     emu.Memory[0xC003] = 0xFF;
     emu.Memory[0xC005] = 0xFF;
     emu.Memory[0xC006] = 0xFF;
     emu.Reset();
 }
Ejemplo n.º 2
0
 public void Init()
 {
     emu = new Cpu6800
     {
         State   = new Cpu6800State(),
         ReadMem = loc =>
         {
             loc = loc & 0xFFFF;
             return(Memory[loc]);
         },
         WriteMem = (loc, value) =>
         {
             loc = loc & 0xFFFF;
             if (loc >= 0xFC00)
             {
                 return;
             }
             Memory[loc] = value;
         }
     };
     emu.State.CC = 0;
     emu.State.PC = 0;
 }
Ejemplo n.º 3
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;
        }