private void WritetoMemoryOrPort( ushort address, byte value, IMemory memory, MemoryAccessMode accessMode, MemoryAccessEventType beforeEventType, MemoryAccessEventType afterEventType, byte waitStates) { var beforeEventArgs = FireMemoryAccessEvent(beforeEventType, address, value); if (!beforeEventArgs.CancelMemoryAccess && (accessMode == MemoryAccessMode.ReadAndWrite || accessMode == MemoryAccessMode.WriteOnly)) { memory[address] = beforeEventArgs.Value; } if (executionContext != null) { executionContext.AccummulatedMemoryWaitStates += waitStates; } FireMemoryAccessEvent( afterEventType, address, beforeEventArgs.Value, beforeEventArgs.LocalUserState, beforeEventArgs.CancelMemoryAccess); }
MemoryAccessEventArgs FireMemoryAccessEvent( MemoryAccessEventType eventType, ushort address, byte value, object localUserState = null, bool cancelMemoryAccess = false) { var eventArgs = new MemoryAccessEventArgs(eventType, address, value, localUserState, cancelMemoryAccess); MemoryAccess?.Invoke(this, eventArgs); return(eventArgs); }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="eventType">Type of event being processed</param> /// <param name="address">Memory or port address being accessed</param> /// <param name="value">Initial value for the <see cref="Value"/> property</param> /// <param name="localUserState">Initial value for the <see cref="ProcessorEventArgs.LocalUserState"/> property</param> /// <param name="cancelMemoryAccess">Initial value for the <see cref="CancelMemoryAccess"/> property</param> public MemoryAccessEventArgs( MemoryAccessEventType eventType, ushort address, byte value, object localUserState = null, bool cancelMemoryAccess = false) { this.EventType = eventType; this.Address = address; this.Value = value; this.LocalUserState = localUserState; this.CancelMemoryAccess = cancelMemoryAccess; }
private byte ReadFromMemoryOrPort( ushort address, IMemory memory, MemoryAccessMode accessMode, MemoryAccessEventType beforeEventType, MemoryAccessEventType afterEventType, byte waitStates) { var beforeEventArgs = FireMemoryAccessEvent(beforeEventType, address, 0xFF); byte value; if (!beforeEventArgs.CancelMemoryAccess && (accessMode == MemoryAccessMode.ReadAndWrite || accessMode == MemoryAccessMode.ReadOnly)) { value = memory[address]; } else { value = beforeEventArgs.Value; } if (executionContext != null) { executionContext.AccummulatedMemoryWaitStates += waitStates; } var afterEventArgs = FireMemoryAccessEvent( afterEventType, address, value, beforeEventArgs.LocalUserState, beforeEventArgs.CancelMemoryAccess); return(afterEventArgs.Value); }