Exemple #1
0
        public async Task Setup()
        {
            mem = _serviceProvider.GetService <IAddressMap>();
            mem.Install(new Ram(0x0000, 0x10000));

            _display = _serviceProvider.GetService <IMemoryMappedDisplay>();
            _display.Locate(DISPLAY_BASE_ADDR, DISPLAY_SIZE);
            mem.Install(_display);
            await _display.Initialise();

            _display.Clear();

            _cpu          = (CPU6502)_serviceProvider.GetService <IDebuggableCpu>();
            _cpu.LogLevel = LogLevel.Trace;

            mem.WriteWord(_cpu.RESET_VECTOR, PROG_START);

            _persistence = new MemoryFilePersistence
            {
                WorkingDirectory = "~/6502Programs"
            };

            mem.Labels.Add("DISPLAY_CONTROL_ADDR", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR);
            mem.Labels.Add("DISPLAY_BASE_ADDR", DISPLAY_BASE_ADDR);
            mem.Labels.Add("DISPLAY_SIZE", DISPLAY_SIZE);
            mem.Labels.Add("RESET_VECTOR", _cpu.RESET_VECTOR);
            mem.Labels.Add("IRQ_VECTOR", _cpu.IRQ_VECTOR);
            mem.Labels.Add("NMI_VECTOR", _cpu.NMI_VECTOR);

            mem.Labels.Push();
        }
Exemple #2
0
        public async Task Setup()
        {
            mem = _serviceProvider.GetService <IAddressMap>();
            mem.Install(new Ram(0x0000, 0x10000));
            _display = _serviceProvider.GetService <IMemoryMappedDisplay>();
            _display.Locate(DISPLAY_BASE_ADDR, DISPLAY_SIZE);
            mem.Install(_display);
            _keyboard = _serviceProvider.GetService <IMemoryMappedKeyboard>();
            _keyboard.StartAddress = KEYBOARD_BASE_ADDR;
            mem.Install((IAddressAssignment)_keyboard);
            await mem.Initialise();

            _display.Clear();
            _cpu          = (CPU6502)_serviceProvider.GetService <IDebuggableCpu>();
            _cpu.LogLevel = LogLevel.Trace;
            _keyboard.RequestInterrupt += async(s, e) => { await _cpu.Interrupt(s, e); };

            mem.WriteWord(_cpu.RESET_VECTOR, PROG_START);

            mem.Labels.Add("DISPLAY_CONTROL_ADDR", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR);
            mem.Labels.Add("DISPLAY_BASE_ADDR", DISPLAY_BASE_ADDR);
            mem.Labels.Add("DISPLAY_SIZE", DISPLAY_SIZE);
            mem.Labels.Add("KEYBOARD_STATUS_REGISTER", MemoryMappedKeyboard.STATUS_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("KEYBOARD_CONTROL_REGISTER", MemoryMappedKeyboard.CONTROL_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("KEYBOARD_DATA_REGISTER", MemoryMappedKeyboard.DATA_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("KEYBOARD_SCAN_CODE_REGISTER", MemoryMappedKeyboard.SCAN_CODE_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("RESET_VECTOR", _cpu.RESET_VECTOR);
            mem.Labels.Add("IRQ_VECTOR", _cpu.IRQ_VECTOR);
            mem.Labels.Add("NMI_VECTOR", _cpu.NMI_VECTOR);
        }
Exemple #3
0
        public void Setup()
        {
            _logger = (UnitTestLogger <CPU6502>)_serviceProvider.GetService <ILogger <CPU6502> >();
            _logger.GetOutput(); // Clear any buffered output

            mem = _serviceProvider.GetService <IAddressMap>();
            mem.Install(new Ram(0x0000, 0x10000));

            _display = _serviceProvider.GetService <IMemoryMappedDisplay>();
            _display.Locate(DISPLAY_BASE_ADDR, DISPLAY_SIZE);
            mem.Install(_display);
            AsyncUtil.RunSync(mem.Initialise);
            _display.Clear();
            _cpu          = (CPU6502)_serviceProvider.GetService <IDebuggableCpu>();
            _cpu.LogLevel = LogLevel.Trace;
            mem.WriteWord(_cpu.RESET_VECTOR, PROG_START);
            mem.Labels.Clear();
            mem.Labels.Add("DISPLAY_CONTROL_ADDR", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR);
            mem.Labels.Add("DISPLAY_BASE_ADDR", DISPLAY_BASE_ADDR);
            mem.Labels.Add("DISPLAY_SIZE", DISPLAY_SIZE);
            mem.Labels.Add("RESET_VECTOR", _cpu.RESET_VECTOR);
            mem.Labels.Add("IRQ_VECTOR", _cpu.IRQ_VECTOR);
            mem.Labels.Add("NMI_VECTOR", _cpu.NMI_VECTOR);
            _cpuHoldEvent             = _serviceProvider.GetService <ICpuHoldEvent>();
            _cpuStepEvent             = _serviceProvider.GetService <ICpuStepEvent>();
            _cancellationTokenWrapper = _serviceProvider.GetService <CancellationTokenWrapper>();
            _cancellationTokenWrapper.Reset();
        }
Exemple #4
0
        public void Save(string name, ushort startAddress, ushort length, IAddressMap mem)
        {
            var folder = CrossPlatformPathExtensions.ResolveCrossPlatformPart(WorkingDirectory);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var combined = CrossPlatformPathExtensions.Combine(WorkingDirectory, name);
            var filename = Path.GetFullPath(combined);

            var buffer = new byte[length + 4];

            buffer[0] = (byte)(startAddress & 0xff);
            buffer[1] = (byte)(startAddress >> 8);
            buffer[2] = (byte)(length & 0xff);
            buffer[3] = (byte)(length >> 8);
            for (var ix = 0; ix < length; ix++)
            {
                buffer[ix + 4] = mem.Read((ushort)(ix + startAddress));
            }

            using (var file = File.Create(filename))
            {
                file.Write(buffer, 0, length + 4);
            }
        }
Exemple #5
0
 public async Task Setup()
 {
     _cpuDebug     = new MockCpuDebug(new MockCpuHoldEvent(), new MockCpuStepEvent());
     _addressMap   = new MockMemoryDebug();
     _labels       = new LabelMap();
     _logFormatter = new DebugLogFormatter(_labels);
     await Task.Delay(0);
 }
Exemple #6
0
 public Loader(IAddressMap addressMap, ILoaderLabelTable labels, ILogger <Loader> logger)
 {
     _addressMap      = addressMap;
     _labels          = labels;
     _labelReferences = new Dictionary <ushort, ReferenceDescriptor>();
     HasErrors        = false;
     _logger          = logger;
 }
Exemple #7
0
        public async Task Setup()
        {
            mem  = _serviceProvider.GetService <IAddressMap>();
            _rom = new Rom(ROM_START, ROM_SIZE);

            mem.Install(new Ram(RAM_BANK_1_START, RAM_BANK_1_SIZE));
            mem.Install(_rom);
            mem.Install(new Ram(RAM_BANK_2_START, RAM_BANK_2_SIZE));
            await mem.Initialise();
        }
Exemple #8
0
        private bool IsMemoryFilledWith(IAddressMap mem, ushort start, ushort size, byte value)
        {
            var end = (ushort)(start + size - 1);

            for (var ix = start; ix <= end; ix++)
            {
                if (mem.Read(ix) != value)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #9
0
 public ReplHost(
     ILabelMap labels,
     CancellationTokenWrapper cancellationToken,
     // CpuHoldEvent debuggerSyncEvent,
     IDebuggableCpu cpu,
     IAddressMap addressMap,
     IMemoryMappedKeyboard keyboard,
     IMemoryMappedDisplay memoryMappedDisplay)
 {
     Labels             = labels;
     _cancellationToken = cancellationToken;
     // _debuggerSyncEvent = debuggerSyncEvent;
     _cpu      = (CPU6502)cpu;
     mem       = addressMap;
     _keyboard = keyboard;
     _display  = memoryMappedDisplay;
 }
Exemple #10
0
        public void Setup()
        {
            _cpuDebug   = _serviceProvider.GetService <IDebuggableCpu>();
            _addressMap = _serviceProvider.GetService <IAddressMap>();
            AsyncUtil.RunSync(_addressMap.Initialise);

            _labels = _serviceProvider.GetService <ILabelMap>();
            _labels.Clear();
            _logFormatter = _serviceProvider.GetService <ILogFormatter>();
            _parser       = _serviceProvider.GetService <IParser>();
            _logger       = (UnitTestLogger <Parser>)_serviceProvider.GetService <ILogger <Parser> >();
            _cpuDebug.Breakpoints.Clear();
            _cpuHoldEvent = (MockCpuHoldEvent)_serviceProvider.GetService <ICpuHoldEvent>();
            _cpuStepEvent = (MockCpuStepEvent)_serviceProvider.GetService <ICpuStepEvent>();
            _cpuHoldEvent.Init();
            _cpuStepEvent.Init();
            _logger.GetOutput(); // Flush any old content
        }
Exemple #11
0
 public Parser(
     IDebuggableCpu cpuDebug,
     IAddressMap addressMap,
     ILabelMap labels,
     ILogFormatter formatter,
     ICpuHoldEvent debuggerSyncEvent,
     ICpuStepEvent debuggerStepEvent,
     ILogger <Parser> logger,
     IRegisterTracker tracker)
 {
     _cpuDebug          = cpuDebug;
     _addressMap        = addressMap;
     _labels            = labels;
     _formatter         = formatter;
     _debuggerSyncEvent = debuggerSyncEvent;
     _debuggerStepEvent = debuggerStepEvent;
     _logger            = logger;
     _tracker           = tracker;
 }
Exemple #12
0
 public ConsoleDebugger(
     IEmulatorHost host,
     IDebuggableCpu cpu,
     IAddressMap addressMap,
     ILogFormatter logFormatter,
     IParser parser,
     ILabelMap labels,
     CancellationTokenWrapper cancel,
     // CpuHoldEvent debuggerSyncEvent,
     ILogger <ConsoleDebugger> logger)
 {
     _host       = host;
     _cpu        = cpu;
     _addressMap = addressMap;
     _formatter  = logFormatter;
     _parser     = parser;
     _labels     = labels;
     _cancel     = cancel;
     // _debuggerSyncEvent = debuggerSyncEvent;
     _logger = logger;
 }
Exemple #13
0
        private void LoadInternal(string name, IAddressMap mem, int overrideStartAddress = -1)
        {
            var combined = CrossPlatformPathExtensions.Combine(WorkingDirectory, name);
            var filename = Path.GetFullPath(combined);

            using (var file = File.OpenRead(filename))
            {
                var address = file.ReadByte() + (256 * file.ReadByte());
                var length  = file.ReadByte() + (256 * file.ReadByte());

                if (overrideStartAddress >= 0)
                {
                    address = overrideStartAddress;
                }

                var byteCount = 0;

                while (byteCount < length)
                {
                    mem.Write((ushort)(address + byteCount), (byte)file.ReadByte());
                    byteCount++;
                }
            }
        }
Exemple #14
0
 public AddressRepository(IInvoiceDbContext dbc, IAddressMap map, ILogger <AddressData> log) : base(log, map)
 {
     entityContext = dbc;
 }
 public AddressRepository(IMainDBContext dbc, IAddressMap map_factory) : base(map_factory)
 {
     entity_context = dbc;
 }
Exemple #16
0
 public void LoadAt(string name, ushort startAddress, IAddressMap mem)
 {
     LoadInternal(name, mem, startAddress);
 }
Exemple #17
0
 public void Load(string name, IAddressMap mem)
 {
     LoadInternal(name, mem);
 }