mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-01-11 07:30:10 +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)
|
protected override ushort GetWordPaged(byte page, byte offset)
|
||||||
{
|
{
|
||||||
var high = this.BusRead(offset, page);
|
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);
|
return Chip.MakeWord(low, high);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ namespace EightBit
|
|||||||
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
||||||
{
|
{
|
||||||
this.BusWrite(offset, page, Chip.HighByte(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
|
public abstract class Bus : IMapper
|
||||||
{
|
{
|
||||||
private byte data;
|
private byte data;
|
||||||
private ushort address;
|
|
||||||
|
|
||||||
public event EventHandler<EventArgs> WritingByte;
|
public event EventHandler<EventArgs> WritingByte;
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ namespace EightBit
|
|||||||
|
|
||||||
public byte Data { get => this.data; set => this.data = value; }
|
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);
|
public abstract MemoryMapping Mapping(ushort absolute);
|
||||||
|
|
||||||
|
@ -8,15 +8,13 @@ namespace EightBit
|
|||||||
|
|
||||||
public class ClockedChip : Chip
|
public class ClockedChip : Chip
|
||||||
{
|
{
|
||||||
private int cycles;
|
|
||||||
|
|
||||||
protected ClockedChip()
|
protected ClockedChip()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler<EventArgs> Ticked;
|
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)
|
public void Tick(int extra)
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,8 @@ namespace EightBit
|
|||||||
|
|
||||||
public sealed class InputOutput
|
public sealed class InputOutput
|
||||||
{
|
{
|
||||||
private byte[] input = new byte[0x100];
|
private readonly byte[] input = new byte[0x100];
|
||||||
private byte[] output = new byte[0x100];
|
private readonly byte[] output = new byte[0x100];
|
||||||
|
|
||||||
public InputOutput()
|
public InputOutput()
|
||||||
{
|
{
|
||||||
|
@ -9,16 +9,14 @@ namespace EightBit
|
|||||||
public abstract class IntelProcessor : LittleEndianProcessor
|
public abstract class IntelProcessor : LittleEndianProcessor
|
||||||
{
|
{
|
||||||
private readonly IntelOpCodeDecoded[] decodedOpCodes = new IntelOpCodeDecoded[0x100];
|
private readonly IntelOpCodeDecoded[] decodedOpCodes = new IntelOpCodeDecoded[0x100];
|
||||||
private ushort sp;
|
|
||||||
private ushort memptr;
|
|
||||||
|
|
||||||
private PinLevel haltLine;
|
private PinLevel haltLine;
|
||||||
|
|
||||||
protected IntelProcessor(Bus bus)
|
protected IntelProcessor(Bus bus)
|
||||||
: base(bus)
|
: base(bus)
|
||||||
{
|
{
|
||||||
this.sp = (ushort)Mask.Mask16;
|
this.SP = (ushort)Mask.Mask16;
|
||||||
this.memptr = (ushort)Mask.Mask16;
|
this.MEMPTR = (ushort)Mask.Mask16;
|
||||||
|
|
||||||
for (int i = 0; i < 0x100; ++i)
|
for (int i = 0; i < 0x100; ++i)
|
||||||
{
|
{
|
||||||
@ -34,9 +32,9 @@ namespace EightBit
|
|||||||
|
|
||||||
public event EventHandler<EventArgs> LoweredHALT;
|
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; }
|
public abstract ushort AF { get; set; }
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace EightBit
|
|||||||
protected override ushort GetWordPaged(byte page, byte offset)
|
protected override ushort GetWordPaged(byte page, byte offset)
|
||||||
{
|
{
|
||||||
var low = this.BusRead(offset, page);
|
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);
|
return Chip.MakeWord(low, high);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ namespace EightBit
|
|||||||
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
protected override void SetWordPaged(byte page, byte offset, ushort value)
|
||||||
{
|
{
|
||||||
this.BusWrite(offset, page, Chip.LowByte(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
|
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)
|
public MemoryMapping(Memory memory, ushort begin, ushort mask, AccessLevel access)
|
||||||
{
|
{
|
||||||
this.memory = memory;
|
this.Memory = memory;
|
||||||
this.begin = begin;
|
this.Begin = begin;
|
||||||
this.mask = mask;
|
this.Mask = mask;
|
||||||
this.access = access;
|
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
|
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 { get; }
|
||||||
|
|
||||||
public byte Port => this.port;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,12 @@ namespace EightBit
|
|||||||
|
|
||||||
public abstract class Processor : ClockedChip
|
public abstract class Processor : ClockedChip
|
||||||
{
|
{
|
||||||
private readonly Bus bus;
|
|
||||||
private byte opcode;
|
|
||||||
private ushort pc = 0;
|
|
||||||
|
|
||||||
private PinLevel resetLine;
|
private PinLevel resetLine;
|
||||||
private PinLevel intLine;
|
private PinLevel intLine;
|
||||||
|
|
||||||
protected Processor(Bus memory)
|
protected Processor(Bus memory)
|
||||||
{
|
{
|
||||||
this.bus = memory;
|
this.Bus = memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler<EventArgs> RaisingRESET;
|
public event EventHandler<EventArgs> RaisingRESET;
|
||||||
@ -36,11 +32,11 @@ namespace EightBit
|
|||||||
|
|
||||||
public event EventHandler<EventArgs> LoweredINT;
|
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;
|
public ref PinLevel RESET() => ref this.resetLine;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user