-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathIZ80InstructionExecutor.cs
48 lines (45 loc) · 2.42 KB
/
IZ80InstructionExecutor.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
using System;
namespace Konamiman.Z80dotNet
{
/// <summary>
/// Represents a class that can execute Z80 instructions.
/// </summary>
public interface IZ80InstructionExecutor
{
/// <summary>
/// The <see cref="IZ80ProcessorAgent"/> that the <see cref="Execute"/> method will use in order
/// to interact with the processor.
/// </summary>
IZ80ProcessorAgent ProcessorAgent { get; set; }
/// <summary>
/// Executes the next instruction.
/// </summary>
/// <param name="firstOpcodeByte">First byte of the opcode for the instruction to execute</param>
/// <returns>Total number of T states elapsed when executing the instruction,
/// not including extra memory wait states.</returns>
/// <remarks>
/// <para>
/// The execution flow for this method should be as follows:
/// </para>
/// <list type="number">
/// <item><description>If needed, extra opcode bytes are fetched by using the
/// <see cref="IZ80ProcessorAgent.FetchNextOpcode"/> method on <see cref="ProcessorAgent"/>.</description></item>
/// <item><description>The <see cref="InstructionFetchFinished"/> event is triggered.</description></item>
/// <item><description>The instruction is processed by accessing the <see cref="ProcessorAgent"/> members as appropriate.</description></item>
/// <item><description>The method terminates, returning the total count of T states required for the instruction
/// execution, not including any extra memory or port wait states (but including the automatically
/// inserted wait state used for port access).</description></item>
/// </list>
/// <para>
/// The PC register will point to the address after the supplied opcode byte when this method is invoked,
/// and each subsequent call to <see cref="IZ80ProcessorAgent.FetchNextOpcode"/> will further increment
/// PC by one. This has to be taken in account when implementing the relative jump instructions (DJNZ and JR).
/// </para>
/// </remarks>
int Execute(byte firstOpcodeByte);
/// <summary>
/// Event triggered when the instruction opcode has been fully fetched.
/// </summary>
event EventHandler<InstructionFetchFinishedEventArgs> InstructionFetchFinished;
}
}