diff --git a/src/core/config/Categories.json b/src/core/config/Categories.json index f663e16d..d731815b 100755 --- a/src/core/config/Categories.json +++ b/src/core/config/Categories.json @@ -110,7 +110,8 @@ "Bombe", "Multiple Bombe", "Typex", - "Lorenz" + "Lorenz", + "Colossus" ] }, { diff --git a/src/core/lib/Colossus.mjs b/src/core/lib/Colossus.mjs index 7fd67e2e..9301eb90 100644 --- a/src/core/lib/Colossus.mjs +++ b/src/core/lib/Colossus.mjs @@ -143,14 +143,11 @@ export class ColossusComputer { this.Xptr = [this.rotorPtrs.X1, this.rotorPtrs.X2, this.rotorPtrs.X3, this.rotorPtrs.X4, this.rotorPtrs.X5]; this.Mptr = [this.rotorPtrs.M37, this.rotorPtrs.M61]; this.Sptr = [this.rotorPtrs.S1, this.rotorPtrs.S2, this.rotorPtrs.S3, this.rotorPtrs.S4, this.rotorPtrs.S5]; - // console.log(this.Xptr); // Run full loop of all character on the input tape (Z) for (let i=0; i= 0 && Qswitch[s] !== parseInt(this.Qbits[s],10)) result = false; + if (Qswitch[s] >= 0 && Qswitch[s] !== parseInt(this.Qbits[s], 10)) result = false; } // Check for NOT switch if (row.Negate) result = !result; @@ -372,21 +339,21 @@ export class ColossusComputer { // Negate the whole column, this allows A OR B by doing NOT(NOT A AND NOT B) for (let c=0;c<5;c++) { if (this.qbusswitches.condNegateAll && cnt[c] !== -1) cnt[c] = !cnt[c]; - - if (this.qbusswitches.totalMotor === "" || (this.qbusswitches.totalMotor === "x" && this.totalmotor === 0) || (this.qbusswitches.totalMotor === "." && this.totalmotor === 1)) { - if (cnt[c] === true) this.allCounters[c]++; - } - } + return cnt; + } /** * Addition of impulses Q bus section */ - runQbusProcessingAddition() { + runQbusProcessingAddition(cnt) { const row = this.qbusswitches.addition[0]; const Qswitch = row.Qswitches.slice(); + + // To save making the arguments of this operation any larger, limiting addition counter to first one only + // Colossus could actually add into any of the five counters. if (row.C1) { let addition = 0; for (let s=0;s<5;s++) { @@ -397,10 +364,24 @@ export class ColossusComputer { } const equals = (row.Equals===""?-1:(row.Equals==="."?0:1)); if (addition === equals) { - this.allCounters[0]++; + // AND with conditional rows to get final result + if (cnt[0] === -1) cnt[0] = true; + } else { + cnt[0] = false; } } - // console.log("counter1="+this.allCounters[0]); + + // Final check, check for addition section negate + // then, if any column set, from top to bottom of rack, add to counter. + for (let c=0;c<5;c++) { + if (this.qbusswitches.addNegateAll && cnt[c] !== -1) cnt[c] = !cnt[c]; + + if (this.qbusswitches.totalMotor === "" || (this.qbusswitches.totalMotor === "x" && this.totalmotor === 0) || (this.qbusswitches.totalMotor === "." && this.totalmotor === 1)) { + if (cnt[c] === true) this.allCounters[c]++; + } + + } + } /** diff --git a/src/core/operations/Colossus.mjs b/src/core/operations/Colossus.mjs index 896252dd..260616b2 100644 --- a/src/core/operations/Colossus.mjs +++ b/src/core/operations/Colossus.mjs @@ -17,13 +17,13 @@ import { SWITCHES, VALID_ITA2 } from "../lib/Lorenz.mjs"; class Colossus extends Operation { /** - * Lorenz constructor + * Colossus constructor */ constructor() { super(); this.name = "Colossus"; this.module = "Bletchley"; - this.description = "Colossus ... "; + this.description = "Colossus is the name of the world's first electronic computer. Ten computers were designed by Tommy Flowers and built at the Post Office Research Labs at Dollis Hill in 1943 during World War 2. They assisted with the breaking of the German Lorenz cipher attachment, a machine created to encipher communications between Hitler and his generals on the front lines.

To learn more, Virtual Colossus, an online, browser based simulation of a Colossus computer is available at https://virtualcolossus.co.uk.

A more detailed description of this operation can be found here."; this.infoURL = "https://wikipedia.org/wiki/Colossus_computer"; this.inputType = "string"; this.outputType = "JSON"; @@ -438,8 +438,6 @@ class Colossus extends Operation { const colossus = new ColossusComputer(input, pattern, qbusin, qbusswitches, control, starts, settotal, limit); const result = colossus.run(); - console.log(result); - return result; } @@ -553,9 +551,6 @@ class Colossus extends Operation { * @returns {html} */ present(output) { - console.log("output="+ typeof(output)); - console.log("counters="+ typeof(output.counters)); - let html = "Colossus Printer\n\n"; html += output.printout + "\n\n"; html += "Colossus Counters\n\n"; diff --git a/tests/operations/index.mjs b/tests/operations/index.mjs index c54fa7ef..8c80ff99 100644 --- a/tests/operations/index.mjs +++ b/tests/operations/index.mjs @@ -93,6 +93,7 @@ import "./tests/DefangIP.mjs"; import "./tests/ParseUDP.mjs"; import "./tests/AvroToJSON.mjs"; import "./tests/Lorenz.mjs"; +import "./tests/Colossus.mjs"; // Cannot test operations that use the File type yet