diff --git a/Contralto/CPU/Tasks/EmulatorTask.cs b/Contralto/CPU/Tasks/EmulatorTask.cs index e61cfcd..f4d6564 100644 --- a/Contralto/CPU/Tasks/EmulatorTask.cs +++ b/Contralto/CPU/Tasks/EmulatorTask.cs @@ -143,18 +143,14 @@ namespace Contralto.CPU _wrtRam = true; break; - case EmulatorF1.LoadESRB: - // For now, this is always 0; we do not yet support the 3K RAM system with 8 banks of S registers. + case EmulatorF1.LoadESRB: _rb = (ushort)((_busData & 0xe) >> 1); - if (_rb != 0) + if (_rb != 0 && Configuration.SystemType != SystemType.ThreeKRam) { - _rb = 0; - Logging.Log.Write(Logging.LogType.Warning, Logging.LogComponent.EmulatorTask, "ESRB<- ({0}) not fully implemented.", - Conversion.ToOctal((_busData & 0xe) >> 1)); - - throw new NotImplementedException("ESRB<-"); - } + // Force bank 0 for machines with only 1K RAM. + _rb = 0; + } break; default: diff --git a/Contralto/CPU/Tasks/Task.cs b/Contralto/CPU/Tasks/Task.cs index 649c663..c84371e 100644 --- a/Contralto/CPU/Tasks/Task.cs +++ b/Contralto/CPU/Tasks/Task.cs @@ -446,12 +446,13 @@ namespace Contralto.CPU // // Switch banks if the last instruction had an SWMODE F1; - // this depends on the value of the NEXT field in this instruction + // this depends on the value of the NEXT field in this instruction. + // (And apparently the modifier applied to NEXT in this instruction -- MADTEST expects this.) // if (swMode) { - UCodeMemory.SwitchMode(instruction.NEXT, _taskType); - Logging.Log.Write(Logging.LogComponent.Microcode, "SWMODE: uPC {0}, next uPC {1}", Conversion.ToOctal(_mpc), Conversion.ToOctal(instruction.NEXT)); + UCodeMemory.SwitchMode((ushort)(instruction.NEXT | nextModifier), _taskType); + Logging.Log.Write(Logging.LogComponent.Microcode, "SWMODE: uPC {0}, next uPC {1}", Conversion.ToOctal(_mpc), Conversion.ToOctal(instruction.NEXT | nextModifier)); } // diff --git a/Contralto/CPU/UCodeMemory.cs b/Contralto/CPU/UCodeMemory.cs index 84f4c23..4db1658 100644 --- a/Contralto/CPU/UCodeMemory.cs +++ b/Contralto/CPU/UCodeMemory.cs @@ -109,11 +109,10 @@ namespace Contralto.CPU case SystemType.TwoKRom: _ramBank = 0; break; - case SystemType.ThreeKRam: - if (_ramBank > 3) + case SystemType.ThreeKRam: + if (_ramBank > 2) { - // TODO: clip or not. - throw new InvalidOperationException(String.Format("Unexpected RAM bank value of {0}.", _ramBank)); + _ramBank = 2; } break; } @@ -152,8 +151,49 @@ namespace Contralto.CPU } break; - case SystemType.ThreeKRam: - throw new NotImplementedException("3K uCode RAM not yet implemented."); + case SystemType.ThreeKRam: + if ((nextAddress & 0x100) == 0) + { + switch(_microcodeBank[(int)task]) + { + case MicrocodeBank.ROM0: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.RAM0 : MicrocodeBank.RAM2; + break; + + case MicrocodeBank.RAM0: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.ROM0 : MicrocodeBank.RAM2; + break; + + case MicrocodeBank.RAM1: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.ROM0 : MicrocodeBank.RAM2; + break; + + case MicrocodeBank.RAM2: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.ROM0 : MicrocodeBank.RAM1; + break; + } + } + else + { + switch (_microcodeBank[(int)task]) + { + case MicrocodeBank.ROM0: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.RAM1 : MicrocodeBank.RAM0; + break; + + case MicrocodeBank.RAM0: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.RAM1 : MicrocodeBank.RAM1; + break; + + case MicrocodeBank.RAM1: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.RAM0 : MicrocodeBank.RAM0; + break; + + case MicrocodeBank.RAM2: + _microcodeBank[(int)task] = (nextAddress & 0x80) == 0 ? MicrocodeBank.RAM0 : MicrocodeBank.RAM0; + break; + } + } break; } diff --git a/Contralto/Disk/Josh.dsk b/Contralto/Disk/Josh.dsk index 6d808bc..867d8f8 100644 Binary files a/Contralto/Disk/Josh.dsk and b/Contralto/Disk/Josh.dsk differ diff --git a/Contralto/Disk/allgames.dsk b/Contralto/Disk/allgames.dsk index aa6e380..1954a55 100644 Binary files a/Contralto/Disk/allgames.dsk and b/Contralto/Disk/allgames.dsk differ diff --git a/Contralto/Disk/bravox.dsk b/Contralto/Disk/bravox.dsk index b5d669b..b723972 100644 Binary files a/Contralto/Disk/bravox.dsk and b/Contralto/Disk/bravox.dsk differ diff --git a/Contralto/Disk/diag.dsk b/Contralto/Disk/diag.dsk index 8280966..1736cd9 100644 Binary files a/Contralto/Disk/diag.dsk and b/Contralto/Disk/diag.dsk differ diff --git a/Contralto/Disk/st76boot.dsk b/Contralto/Disk/st76boot.dsk index 390aa00..a87c2f5 100644 Binary files a/Contralto/Disk/st76boot.dsk and b/Contralto/Disk/st76boot.dsk differ diff --git a/Contralto/Disk/tdisk8.dsk b/Contralto/Disk/tdisk8.dsk index f2b5132..8f3404d 100644 Binary files a/Contralto/Disk/tdisk8.dsk and b/Contralto/Disk/tdisk8.dsk differ diff --git a/Contralto/Disk/xmsmall.dsk b/Contralto/Disk/xmsmall.dsk index 2805a9a..6333a39 100644 Binary files a/Contralto/Disk/xmsmall.dsk and b/Contralto/Disk/xmsmall.dsk differ diff --git a/Contralto/IO/DiskController.cs b/Contralto/IO/DiskController.cs index b5a5bcd..dbdf1d4 100644 --- a/Contralto/IO/DiskController.cs +++ b/Contralto/IO/DiskController.cs @@ -416,7 +416,7 @@ namespace Contralto.IO _seeking = true; // And figure out how long this will take. - _seekDuration = (ulong)(CalculateSeekTime() / (ulong)(Math.Abs(_destCylinder - SelectedDrive.Cylinder) + 1)); + _seekDuration = 0; // (ulong)(CalculateSeekTime() / (ulong)(Math.Abs(_destCylinder - SelectedDrive.Cylinder) + 1)); _seekEvent.TimestampNsec = _seekDuration; _system.Scheduler.Schedule(_seekEvent); diff --git a/Contralto/IO/UDPEncapsulation.cs b/Contralto/IO/UDPEncapsulation.cs index 3ced3ee..4d1c226 100644 --- a/Contralto/IO/UDPEncapsulation.cs +++ b/Contralto/IO/UDPEncapsulation.cs @@ -133,21 +133,12 @@ namespace Contralto.IO packetBytes[i * 2 + 3] = (byte)(packet[i] >> 8); } - // - // Grab the source and destination host addresses from the packet we're sending - // and build 10mbit versions. - // - byte destinationHost = packetBytes[3]; - byte sourceHost = packetBytes[2]; - - Log.Write(LogComponent.HostNetworkInterface, "Sending packet; source {0} destination {1}, length {2} words.", - Conversion.ToOctal(sourceHost), - Conversion.ToOctal(destinationHost), + Log.Write(LogType.Verbose, LogComponent.HostNetworkInterface, "Sending packet via UDP; source {0} destination {1}, length {2} words.", + Conversion.ToOctal(packetBytes[2]), + Conversion.ToOctal(packetBytes[3]), length); _udpClient.Send(packetBytes, packetBytes.Length, _broadcastEndpoint); - - Log.Write(LogComponent.HostNetworkInterface, "Encapsulated 3mbit packet sent via UDP."); } /// @@ -167,8 +158,7 @@ namespace Contralto.IO // properly.) Log.Write(LogComponent.HostNetworkInterface, "UDP Receiver thread started."); - IPEndPoint groupEndPoint = new IPEndPoint(IPAddress.Any, _udpPort); - //return; + IPEndPoint groupEndPoint = new IPEndPoint(IPAddress.Any, _udpPort); while (true) {