Correct a number of style issues across the EightBitNet solution.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2019-05-06 09:46:23 +01:00
parent a8849ccf43
commit 0340142282
4 changed files with 70 additions and 72 deletions

View File

@ -822,8 +822,7 @@
registers.Add("PC");
}
output += string.Join(",", registers);
return output;
return string.Join(",", registers);
}
private string PshX(string mnemomic, string upon)
@ -872,8 +871,7 @@
registers.Add("CC");
}
output += string.Join(",", registers);
return output;
return string.Join(",", registers);
}
private byte GetByte(ushort absolute) => this.BUS.Peek(absolute);

View File

@ -1,4 +1,8 @@
namespace EightBit
// <copyright file="Board.cs" company="Adrian Conlon">
// Copyright (c) Adrian Conlon. All rights reserved.
// </copyright>
namespace EightBit
{
using System;
@ -27,8 +31,29 @@
}
public MC6809 CPU { get; }
public MC6850 ACIA { get; } = new MC6850();
public override MemoryMapping Mapping(ushort absolute)
{
if (absolute < 0x8000)
{
return new MemoryMapping(this.ram, 0x0000, Mask.Mask16, AccessLevel.ReadWrite);
}
if (absolute < 0xa000)
{
return new MemoryMapping(this.unused2000, 0x8000, Mask.Mask16, AccessLevel.ReadOnly);
}
if (absolute < 0xc000)
{
return new MemoryMapping(this.io, 0xa000, Mask.Mask16, AccessLevel.ReadWrite);
}
return new MemoryMapping(this.rom, 0xc000, Mask.Mask16, AccessLevel.ReadOnly);
}
public override void RaisePOWER()
{
base.RaisePOWER();
@ -44,8 +69,9 @@
// Get the ACIA ready for action
this.Address.Word = 0b1010000000000000;
this.Data = (byte)(MC6850.ControlRegister.CR0 | MC6850.ControlRegister.CR1); // Master reset
this.UpdateAciaPinsWrite();
this.ACIA.CTS.Lower();
this.ACIA.RW.Lower();
this.UpdateAciaPins();
this.ACIA.RaisePOWER();
this.AccessAcia();
}
@ -59,6 +85,8 @@
public override void Initialize()
{
System.Console.TreatControlCAsInput = true;
// Load our BASIC interpreter
var directory = this.configuration.RomDirectory + "\\";
this.LoadHexFile(directory + "ExBasROM.hex");
@ -66,12 +94,6 @@
// Catch a byte being transmitted
this.ACIA.Transmitting += this.ACIA_Transmitting;
// Marshal data from memory -> ACIA
this.WrittenByte += this.Board_WrittenByte;
// Marshal data from ACIA -> memory
this.ReadingByte += this.Board_ReadingByte;
// Keyboard wiring, check for input once per frame
this.CPU.ExecutedInstruction += this.CPU_ExecutedInstruction;
@ -89,6 +111,32 @@
}
}
// Marshal data from ACIA -> memory
protected override void OnReadingByte()
{
this.UpdateAciaPins();
this.ACIA.RW.Raise();
if (this.AccessAcia())
{
this.Poke(this.ACIA.DATA);
}
base.OnReadingByte();
}
// Marshal data from memory -> ACIA
protected override void OnWrittenByte()
{
base.OnWrittenByte();
this.UpdateAciaPins();
if (this.ACIA.Selected)
{
this.ACIA.RW.Lower();
this.ACIA.DATA = this.Data;
this.AccessAcia();
}
}
private void CPU_ExecutedInstruction_Termination(object sender, EventArgs e)
{
this.totalCycleCount += (ulong)this.CPU.Cycles;
@ -129,64 +177,12 @@
}
}
private void Board_ReadingByte(object sender, EventArgs e)
{
this.UpdateAciaPinsRead();
if (this.AccessAcia())
{
this.Poke(this.ACIA.DATA);
}
}
private void Board_WrittenByte(object sender, EventArgs e)
{
this.UpdateAciaPinsWrite();
if (this.ACIA.Selected)
{
this.ACIA.DATA = this.Data;
this.AccessAcia();
}
}
private void ACIA_Transmitting(object sender, EventArgs e)
{
System.Console.Out.Write(Convert.ToChar(this.ACIA.TDR));
this.ACIA.MarkTransmitComplete();
}
public override MemoryMapping Mapping(ushort absolute)
{
if (absolute < 0x8000)
{
return new MemoryMapping(this.ram, 0x0000, Mask.Mask16, AccessLevel.ReadWrite);
}
if (absolute < 0xa000)
{
return new MemoryMapping(this.unused2000, 0x8000, Mask.Mask16, AccessLevel.ReadOnly);
}
if (absolute < 0xc000)
{
return new MemoryMapping(this.io, 0xa000, Mask.Mask16, AccessLevel.ReadWrite);
}
return new MemoryMapping(this.rom, 0xc000, Mask.Mask16, AccessLevel.ReadOnly);
}
// Use the bus data to update the ACIA access/address pins
private void UpdateAciaPinsRead()
{
this.ACIA.RW.Raise();
this.UpdateAciaPins();
}
private void UpdateAciaPinsWrite()
{
this.ACIA.RW.Lower();
this.UpdateAciaPins();
}
private void UpdateAciaPins()
{
this.ACIA.DATA = this.Data;

View File

@ -1,10 +1,14 @@
namespace EightBit
// <copyright file="Configuration.cs" company="Adrian Conlon">
// Copyright (c) Adrian Conlon. All rights reserved.
// </copyright>
namespace EightBit
{
public class Configuration
{
public static readonly ulong CyclesPerSecond = 2 * 1024 * 1024;
public static readonly ulong FrameCycleInterval = CyclesPerSecond / 60;
public static readonly ulong TerminationCycles = CyclesPerSecond* 10 * 10;
public static readonly ulong TerminationCycles = CyclesPerSecond * 10 * 10;
public bool DebugMode { get; set; } = false;

View File

@ -456,6 +456,12 @@ namespace EightBit
return returned;
}
protected override void OnTicked()
{
base.OnTicked();
this.Step();
}
////private static byte SetFlag(byte f, StatusRegisters flag) => SetFlag(f, (byte)flag);
////private static byte SetFlag(byte f, StatusRegisters flag, int condition) => SetFlag(f, (byte)flag, condition);
@ -466,12 +472,6 @@ namespace EightBit
////private static byte ClearFlag(byte f, StatusRegisters flag, int condition) => ClearFlag(f, (byte)flag, condition);
protected override void OnTicked()
{
base.OnTicked();
this.Step();
}
private void OnAccessing() => this.Accessing?.Invoke(this, EventArgs.Empty);
private void OnAccessed() => this.Accessed?.Invoke(this, EventArgs.Empty);