1
0
mirror of https://github.com/livingcomputermuseum/ContrAlto.git synced 2026-04-18 00:47:23 +00:00

Fixed display microcode and display controller. Alto display now generated 100% by microcode tasks. A few small optimizations.

This commit is contained in:
Josh Dersch
2015-11-16 16:46:24 -08:00
parent 30ecfa6900
commit 03661fc90b
11 changed files with 138 additions and 126 deletions

View File

@@ -15,6 +15,14 @@ namespace Contralto.Memory
Reset();
}
/// <summary>
/// The top address of main memory (above which lies the I/O space)
/// </summary>
public static ushort MemTop
{
get { return _memTop; }
}
public void Reset()
{
// 4 64K banks
@@ -33,13 +41,6 @@ namespace Contralto.Memory
{
address += 0x10000 * GetBankNumber(task, extendedMemory);
ushort data = _mem[address];
/*
if (extendedMemory)
{
Log.Write(LogComponent.Memory, "extended memory read from {0} - {1}", Conversion.ToOctal(address), Conversion.ToOctal(data));
} */
return data;
}
}
@@ -58,18 +59,7 @@ namespace Contralto.Memory
else
{
address += 0x10000 * GetBankNumber(task, extendedMemory);
_mem[address] = data;
if (address == 0x110 && data != 0)
{
Console.WriteLine("DASTART WRITE!");
}
/*
if (extendedMemory)
{
Log.Write(LogComponent.Memory, "extended memory write to {0} of {1}", Conversion.ToOctal(address), Conversion.ToOctal(data));
} */
_mem[address] = data;
}
}
@@ -85,12 +75,12 @@ namespace Contralto.Memory
private readonly MemoryRange[] _addresses =
{
new MemoryRange(0, _memTop), // Main bank of RAM to 176777; IO page above this.
new MemoryRange(_xmBanksStart, _xmBanksStart + 16), // Memory bank registers
new MemoryRange(0, _memTop), // Main bank of RAM to 176777; IO page above this.
new MemoryRange(_xmBanksStart, (ushort)(_xmBanksStart + 16)), // Memory bank registers
};
private const int _memTop = 0xfdff; // 176777
private const int _xmBanksStart = 0xffe0; // 177740
private static readonly ushort _memTop = 0xfdff; // 176777
private static readonly ushort _xmBanksStart = 0xffe0; // 177740
private ushort[] _mem;

View File

@@ -42,6 +42,11 @@ namespace Contralto.Memory
else
{
_bus.Add(addr, dev);
if (dev is Memory)
{
_mainMemory = (Memory)dev;
}
}
}
}
@@ -269,17 +274,27 @@ namespace Contralto.Memory
/// <returns></returns>
private ushort ReadFromBus(ushort address, TaskType task, bool extendedMemoryReference)
{
// Look up address in hash; if populated ask the device
// to return a value otherwise throw.
if (_bus.ContainsKey(address))
if (address <= Memory.MemTop)
{
return _bus[address].Read(address, task, extendedMemoryReference);
// Main memory access; shortcut hashtable lookup for performance reasons.
return _mainMemory.Read(address, task, extendedMemoryReference);
}
else
{
//throw new NotImplementedException(String.Format("Read from unimplemented memory-mapped I/O device at {0}.", OctalHelpers.ToOctal(address)));
//Console.WriteLine("Read from unimplemented memory-mapped I/O device at {0}.", Conversion.ToOctal(address));
return 0;
// Memory-mapped device access:
// Look up address in hash; if populated ask the device
// to return a value otherwise throw.
IMemoryMappedDevice memoryMappedDevice = null;
if (_bus.TryGetValue(address, out memoryMappedDevice))
{
return memoryMappedDevice.Read(address, task, extendedMemoryReference);
}
else
{
//throw new NotImplementedException(String.Format("Read from unimplemented memory-mapped I/O device at {0}.", OctalHelpers.ToOctal(address)));
//Console.WriteLine("Read from unimplemented memory-mapped I/O device at {0}.", Conversion.ToOctal(address));
return 0;
}
}
}
@@ -291,16 +306,26 @@ namespace Contralto.Memory
/// <returns></returns>
private void WriteToBus(ushort address, ushort data, TaskType task, bool extendedMemoryReference)
{
// Look up address in hash; if populated ask the device
// to store a value otherwise throw.
if (_bus.ContainsKey(address))
{
_bus[address].Load(address, data, task, extendedMemoryReference);
if (address <= Memory.MemTop)
{
// Main memory access; shortcut hashtable lookup for performance reasons.
_mainMemory.Load(address, data, task, extendedMemoryReference);
}
else
{
// throw new NotImplementedException(String.Format("Write to unimplemented memory-mapped I/O device at {0}.", OctalHelpers.ToOctal(address)));
//Console.WriteLine("Write to unimplemented memory-mapped I/O device at {0}.", Conversion.ToOctal(address));
// Memory-mapped device access:
// Look up address in hash; if populated ask the device
// to store a value otherwise throw.
IMemoryMappedDevice memoryMappedDevice = null;
if (_bus.TryGetValue(address, out memoryMappedDevice))
{
memoryMappedDevice.Load(address, data, task, extendedMemoryReference);
}
else
{
// throw new NotImplementedException(String.Format("Write to unimplemented memory-mapped I/O device at {0}.", OctalHelpers.ToOctal(address)));
//Console.WriteLine("Write to unimplemented memory-mapped I/O device at {0}.", Conversion.ToOctal(address));
}
}
}
@@ -308,7 +333,13 @@ namespace Contralto.Memory
/// Hashtable used for address-based dispatch to devices on the memory bus.
/// </summary>
private Dictionary<ushort, IMemoryMappedDevice> _bus;
//
// Optimzation: keep reference to main memory; since 99.9999% of accesses go directly there,
// we can avoid the hashtable overhead using a simple address check.
//
private Memory _mainMemory;
private bool _memoryOperationActive;
private int _memoryCycle;
private ushort _memoryAddress;