mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2024-12-23 02:29:59 +00:00
More analysis suggested tidy ups.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
d6d8c4e13c
commit
0e8a530573
@ -41,7 +41,7 @@ namespace EightBit
|
||||
protected override ushort GetWordPaged(byte page, byte offset)
|
||||
{
|
||||
var high = this.BusRead(offset, page);
|
||||
var low = this.BusRead((byte)(offset + 1), page);
|
||||
var low = this.BusRead(++offset, page);
|
||||
return Chip.MakeWord(low, high);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ namespace EightBit
|
||||
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
||||
{
|
||||
this.BusWrite(offset, page, Chip.HighByte(value));
|
||||
this.BusWrite((byte)(offset + 1), page, Chip.LowByte(value));
|
||||
this.BusWrite(++offset, page, Chip.LowByte(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace EightBit
|
||||
public abstract class Bus : IMapper
|
||||
{
|
||||
private byte data;
|
||||
private ushort address;
|
||||
|
||||
public event EventHandler<EventArgs> WritingByte;
|
||||
|
||||
@ -21,7 +20,7 @@ namespace EightBit
|
||||
|
||||
public byte Data { get => this.data; set => this.data = value; }
|
||||
|
||||
public ushort Address { get => this.address; set => this.address = value; }
|
||||
public ushort Address { get; set; }
|
||||
|
||||
public abstract MemoryMapping Mapping(ushort absolute);
|
||||
|
||||
|
@ -8,15 +8,13 @@ namespace EightBit
|
||||
|
||||
public class ClockedChip : Chip
|
||||
{
|
||||
private int cycles;
|
||||
|
||||
protected ClockedChip()
|
||||
{
|
||||
}
|
||||
|
||||
public event EventHandler<EventArgs> Ticked;
|
||||
|
||||
public int Cycles { get => this.cycles; protected set => this.cycles = value; }
|
||||
public int Cycles { get; protected set; }
|
||||
|
||||
public void Tick(int extra)
|
||||
{
|
||||
|
@ -8,8 +8,8 @@ namespace EightBit
|
||||
|
||||
public sealed class InputOutput
|
||||
{
|
||||
private byte[] input = new byte[0x100];
|
||||
private byte[] output = new byte[0x100];
|
||||
private readonly byte[] input = new byte[0x100];
|
||||
private readonly byte[] output = new byte[0x100];
|
||||
|
||||
public InputOutput()
|
||||
{
|
||||
|
@ -9,16 +9,14 @@ namespace EightBit
|
||||
public abstract class IntelProcessor : LittleEndianProcessor
|
||||
{
|
||||
private readonly IntelOpCodeDecoded[] decodedOpCodes = new IntelOpCodeDecoded[0x100];
|
||||
private ushort sp;
|
||||
private ushort memptr;
|
||||
|
||||
private PinLevel haltLine;
|
||||
|
||||
protected IntelProcessor(Bus bus)
|
||||
: base(bus)
|
||||
{
|
||||
this.sp = (ushort)Mask.Mask16;
|
||||
this.memptr = (ushort)Mask.Mask16;
|
||||
this.SP = (ushort)Mask.Mask16;
|
||||
this.MEMPTR = (ushort)Mask.Mask16;
|
||||
|
||||
for (int i = 0; i < 0x100; ++i)
|
||||
{
|
||||
@ -34,9 +32,9 @@ namespace EightBit
|
||||
|
||||
public event EventHandler<EventArgs> LoweredHALT;
|
||||
|
||||
public ushort SP { get => this.sp; set => this.sp = value; }
|
||||
public ushort SP { get; set; }
|
||||
|
||||
public ushort MEMPTR { get => this.memptr; set => this.memptr = value; }
|
||||
public ushort MEMPTR { get; set; }
|
||||
|
||||
public abstract ushort AF { get; set; }
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace EightBit
|
||||
protected override ushort GetWordPaged(byte page, byte offset)
|
||||
{
|
||||
var low = this.BusRead(offset, page);
|
||||
var high = this.BusRead((byte)(offset + 1), page);
|
||||
var high = this.BusRead(++offset, page);
|
||||
return Chip.MakeWord(low, high);
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ namespace EightBit
|
||||
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
||||
{
|
||||
this.BusWrite(offset, page, Chip.LowByte(value));
|
||||
this.BusWrite((byte)(offset + 1), page, Chip.HighByte(value));
|
||||
this.BusWrite(++offset, page, Chip.HighByte(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,25 +6,20 @@ namespace EightBit
|
||||
{
|
||||
public class MemoryMapping
|
||||
{
|
||||
private Memory memory;
|
||||
private ushort begin;
|
||||
private ushort mask;
|
||||
private AccessLevel access;
|
||||
|
||||
public MemoryMapping(Memory memory, ushort begin, ushort mask, AccessLevel access)
|
||||
{
|
||||
this.memory = memory;
|
||||
this.begin = begin;
|
||||
this.mask = mask;
|
||||
this.access = access;
|
||||
this.Memory = memory;
|
||||
this.Begin = begin;
|
||||
this.Mask = mask;
|
||||
this.Access = access;
|
||||
}
|
||||
|
||||
public Memory Memory { get => this.memory; set => this.memory = value; }
|
||||
public Memory Memory { get; set; }
|
||||
|
||||
public ushort Begin { get => this.begin; set => this.begin = value; }
|
||||
public ushort Begin { get; set; }
|
||||
|
||||
public ushort Mask { get => this.mask; set => this.mask = value; }
|
||||
public ushort Mask { get; set; }
|
||||
|
||||
public AccessLevel Access { get => this.access; set => this.access = value; }
|
||||
public AccessLevel Access { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,8 @@ namespace EightBit
|
||||
|
||||
public sealed class PortEventArgs : EventArgs
|
||||
{
|
||||
private byte port;
|
||||
public PortEventArgs(byte value) => this.Port = value;
|
||||
|
||||
public PortEventArgs(byte value) => this.port = value;
|
||||
|
||||
public byte Port => this.port;
|
||||
public byte Port { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,16 +8,12 @@ namespace EightBit
|
||||
|
||||
public abstract class Processor : ClockedChip
|
||||
{
|
||||
private readonly Bus bus;
|
||||
private byte opcode;
|
||||
private ushort pc = 0;
|
||||
|
||||
private PinLevel resetLine;
|
||||
private PinLevel intLine;
|
||||
|
||||
protected Processor(Bus memory)
|
||||
{
|
||||
this.bus = memory;
|
||||
this.Bus = memory;
|
||||
}
|
||||
|
||||
public event EventHandler<EventArgs> RaisingRESET;
|
||||
@ -36,11 +32,11 @@ namespace EightBit
|
||||
|
||||
public event EventHandler<EventArgs> LoweredINT;
|
||||
|
||||
public ushort PC { get => this.pc; set => this.pc = value; }
|
||||
public ushort PC { get; set; }
|
||||
|
||||
public Bus Bus { get => this.bus; }
|
||||
public Bus Bus { get; }
|
||||
|
||||
protected byte OpCode { get => this.opcode; set => this.opcode = value; }
|
||||
protected byte OpCode { get; set; }
|
||||
|
||||
public ref PinLevel RESET() => ref this.resetLine;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user