mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2024-12-25 00:31:13 +00:00
d4a35c402c
1) Drop Get/SetPagedByte in favour of normal BusRead/Write 2) Tidy some "using" statements 3) More "expression body" usage, if possible 4) Use field initialisation, rather than construction, if possible 5) Correct IntelProcessor register set/get methods (there were remnants of "copy pasta" code) Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
namespace EightBit
|
|
{
|
|
using System;
|
|
|
|
public sealed class InputOutput
|
|
{
|
|
private byte[] input = new byte[0x100];
|
|
private byte[] output = new byte[0x100];
|
|
|
|
public InputOutput()
|
|
{
|
|
}
|
|
|
|
public event EventHandler<PortEventArgs> ReadingPort;
|
|
public event EventHandler<PortEventArgs> ReadPort;
|
|
|
|
public event EventHandler<PortEventArgs> WritingPort;
|
|
public event EventHandler<PortEventArgs> WrittenPort;
|
|
|
|
byte Read(byte port) => ReadInputPort(port);
|
|
void Write(byte port, byte value) => WriteOutputPort(port, value);
|
|
|
|
byte ReadInputPort(byte port)
|
|
{
|
|
OnReadingPort(port);
|
|
var value = input[port];
|
|
OnReadPort(port);
|
|
return value;
|
|
}
|
|
|
|
void WriteInputPort(byte port, byte value) => input[port] = value;
|
|
|
|
byte ReadOutputPort(byte port) => output[port];
|
|
|
|
void WriteOutputPort(byte port, byte value)
|
|
{
|
|
OnWritingPort(port);
|
|
output[port] = value;
|
|
OnWrittenPort(port);
|
|
}
|
|
|
|
private void OnReadingPort(byte port) => ReadingPort?.Invoke(this, new PortEventArgs(port));
|
|
private void OnReadPort(byte port) => ReadPort?.Invoke(this, new PortEventArgs(port));
|
|
|
|
private void OnWritingPort(byte port) => WritingPort?.Invoke(this, new PortEventArgs(port));
|
|
private void OnWrittenPort(byte port) => WrittenPort?.Invoke(this, new PortEventArgs(port));
|
|
}
|
|
}
|