-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMemoryAccessEventArgs.cs
88 lines (84 loc) · 4.61 KB
/
MemoryAccessEventArgs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
namespace Konamiman.Z80dotNet
{
/// <summary>
/// Event triggered by the <see cref="IZ80Processor"/> class before and after a memory or port access.
/// </summary>
public class MemoryAccessEventArgs : ProcessorEventArgs
{
/// <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;
}
/// <summary>
/// Gets the type of event being processed.
/// </summary>
public MemoryAccessEventType EventType { get; private set; }
/// <summary>
/// Gets the memory or port address being accessed.
/// </summary>
public ushort Address { get; private set; }
/// <summary>
/// Gets or sets the value that has been read, will be written, or has been written.
/// </summary>
/// <remarks>
/// <para>
/// The underlying memory manager (the <see cref="IZ80Processor.Memory"/>
/// property or the <see cref="IZ80Processor.PortsSpace"/> property of the <see cref="IZ80Processor"/>
/// that triggered the event) will not be accessed, and the value of this property when the <c>After*</c>
/// event starts will be the same as when the matching <c>Before*</c> method finished
/// (see <see cref="EventType"/>), in the following cases:
/// </para>
/// <list type="bullet">
/// <item><description>The access is a memory or port read, and the memory mode for the address
/// (see <see cref="IZ80Processor.SetMemoryAccessMode"/>, <see cref="IZ80Processor.GetMemoryAccessMode"/>,
/// <see cref="IZ80Processor.SetPortsSpaceAccessMode"/>, <see cref="IZ80Processor.GetPortAccessMode"/>)
/// is <see cref="MemoryAccessMode.NotConnected"/> or <see cref="MemoryAccessMode.WriteOnly"/>.
/// </description></item>
/// <item><description>The access is a memory or port write, and the memory mode for the address
/// is <see cref="MemoryAccessMode.NotConnected"/> or <see cref="MemoryAccessMode.ReadOnly"/>.
/// </description></item>
/// <item><description>The <see cref="CancelMemoryAccess"/> property is set to <b>true</b> during
/// the <c>Before*</c> event.
/// </description></item>
/// </list>
/// <para>The value of this property at the beginning of a <c>Before*</c> event for read is always 0xFF.</para>
/// </remarks>
public byte Value { get; set; }
/// <summary>
/// Gets or sets a value that indicates whether access to the underlying memory manager should be cancelled.
/// </summary>
/// <remarks>
/// <para>
/// If this property is set to <b>true</b> during a <c>Before*</c> event (see <see cref="EventType"/>),
/// then the underlying memory manager (the <see cref="IZ80Processor.Memory"/>
/// property or the <see cref="IZ80Processor.PortsSpace"/> property of the <see cref="IZ80Processor"/> that triggered the event)
/// will not be accessed. Instead, the matching <c>After*</c> event will be triggered directly, having a
/// <see cref="Value"/> equal to the one set in the <c>Before*</c> event.
/// </para>
/// <para>
/// The value of this property when the <c>After*</c> event is triggered is the same that the matching
/// <c>Before*</c> event had when it ended,
/// so it is possible to check whether the memory access was cancelled or not. Changing the value
/// of this property during the <c>After*</c> event has no effect.
/// </para>
/// </remarks>
public bool CancelMemoryAccess { get; set; }
}
}