byte IMemoryBus.Read(int address) { if (this.readBreakpointsArray.Length != 0) { for (int i = 0; i < this.readBreakpointsArray.Length; i++) { if (this.readBreakpointsArray[i].TargetAddress == address) { this.readBreakpointsArray[i].OnBreakpointHit(); } } } IMemoryMappedDevice device = this.GetDeviceAtAddress(ref address); if (device == null) { Debug.WriteLine("Read of unmapped address 0x{0,8:X8} on bus '{1}'!", address, this.Name); return(4); // Uninitialized memory contents, generated by fair dice roll; } return(device.Read(address)); }
/// <summary> /// Dispatches reads to memory mapped hardware (RAM, I/O) /// </summary> /// <param name="address"></param> /// <returns></returns> private ushort ReadFromBus(ushort address, TaskType task, bool extendedMemoryReference) { if (address <= Memory.RamTop) { // Main memory access; shortcut hashtable lookup for performance reasons. return(_mainMemory.Read(address, task, extendedMemoryReference)); } else { // Memory-mapped device access: // Look up address in hash; if populated ask the device // to return a value otherwise return 0. IMemoryMappedDevice memoryMappedDevice = null; if (_bus.TryGetValue(address, out memoryMappedDevice)) { return(memoryMappedDevice.Read(address, task, extendedMemoryReference)); } else { return(0); } } }