Added Total Motor, fixed bug in printout

This commit is contained in:
VirtualColossus 2019-11-27 13:38:28 +00:00
parent 32625dc0b0
commit 820bd2f867
2 changed files with 46 additions and 15 deletions

View File

@ -61,6 +61,8 @@ export class ColossusComputer {
this.rotorPtrs = {};
this.totalmotor = 0;
}
/**
@ -98,13 +100,17 @@ export class ColossusComputer {
var slowRef = "00";
if (fast !== "") fastRef = this.leftPad(this.rotorPtrs[fast],2);
if (slow !== "") slowRef = this.leftPad(this.rotorPtrs[slow],2);
result.printout += fastRef + " " + slowRef + " : ";
var printline = '';
for (let c=0;c<5;c++) {
if (this.allCounters[c] > this.settotal) {
result.printout += String.fromCharCode(c+97) + this.allCounters[c]+" ";
printline += String.fromCharCode(c+97) + this.allCounters[c]+" ";
}
}
result.printout += "\n";
if (printline !== "") {
result.printout += fastRef + " " + slowRef + " : ";
result.printout += printline;
result.printout += "\n";
}
// Step fast rotor if required
if (fast != '') {
@ -193,17 +199,17 @@ export class ColossusComputer {
//console.log(this.Mptr);
//console.log(this.rings.M[2]);
const basicmotor = this.rings.M[2][this.Mptr[0]-1];
let totalmotor = basicmotor;
this.totalmotor = basicmotor;
if (x2sw || s1sw) {
if (basicmotor===0 && lim===1) {
totalmotor = 0;
this.totalmotor = 0;
} else {
totalmotor = 1;
this.totalmotor = 1;
}
}
//console.log('BM='+basicmotor+', TM='+totalmotor);
//console.log('BM='+basicmotor+', TM='+this.totalmotor);
// Step Chi rotors
for (let r=0; r<5; r++) {
@ -211,7 +217,7 @@ export class ColossusComputer {
if (this.Xptr[r] > ROTOR_SIZES["X"+(r+1)]) this.Xptr[r] = 1;
}
if (totalmotor) {
if (this.totalmotor) {
//console.log('step Psi');
// Step Psi rotors
for (let r=0; r<5; r++) {
@ -346,7 +352,10 @@ export class ColossusComputer {
for (let c=0;c<5;c++) {
if (this.qbusswitches.condNegateAll) cnt[c] = !cnt[c];
if (cnt[c]==1) this.allCounters[c]++;
if (this.qbusswitches.totalMotor === "" || (this.qbusswitches.totalMotor === "x" && this.totalmotor == 0) || (this.qbusswitches.totalMotor === "." && this.totalmotor == 1)) {
if (cnt[c]==1) this.allCounters[c]++;
}
}
}

View File

@ -87,7 +87,7 @@ class Colossus extends Operation {
{
name: "Program to run",
type: "option",
value: ["", "1+2=. (1+2 Break In, Find X1,X2)", "4=3=/1=2 (Given X1,X2 find X4,X5)", "/,5,U (Count chars to find X3)"]
value: ["", "Letter Count", "1+2=. (1+2 Break In, Find X1,X2)", "4=3=/1=2 (Given X1,X2 find X4,X5)", "/,5,U (Count chars to find X3)"]
},
{
name: "K Rack: Conditional",
@ -241,7 +241,8 @@ class Colossus extends Operation {
{
name: "Add-Equals",
type: "editableOptionShort",
value: SWITCHES
value: SWITCHES,
defaultIndex: 1
},
{
name: "Add-Counter1",
@ -253,7 +254,9 @@ class Colossus extends Operation {
},
{
name: "Total Motor",
type: "boolean"
type: "editableOptionShort",
value: SWITCHES,
defaultIndex: 1
},
{
name: "Master Control Panel",
@ -411,8 +414,27 @@ class Colossus extends Operation {
*/
selectProgram(progname, args) {
// Basic Letter Count
if (progname == "Letter Count") {
// Set Conditional R1 : count every character into counter 1
args[9] = "";
args[10] = "";
args[11] = "";
args[12] = "";
args[13] = "";
args[14] = false;
args[15] = "1";
// clear Conditional R2 & R3
args[22] = "";
args[29] = "";
// Clear Negate result
args[30] = false;
// Clear Addition row counter
args[38] = false;
}
// Bill Tutte's 1+2 Break In
if(progname == "1+2=. (1+2 Break In, Find X1,X2)") {
if (progname == "1+2=. (1+2 Break In, Find X1,X2)") {
// Clear any other counters
args[15] = ""; // Conditional R1
args[22] = ""; // Conditional R2
@ -428,7 +450,7 @@ class Colossus extends Operation {
}
// 4=3=/1=2 : Find X4 & X5 where X1 & X2 are known
if(progname == "4=3=/1=2 (Given X1,X2 find X4,X5)") {
if (progname == "4=3=/1=2 (Given X1,X2 find X4,X5)") {
// Set Conditional R1 : Match NOT ..?.. into counter 1
args[9] = ".";
args[10] = ".";
@ -454,7 +476,7 @@ class Colossus extends Operation {
}
// /,5,U : Count number of matches of /, 5 & U to find X3
if(progname == "/,5,U (Count chars to find X3)") {
if (progname == "/,5,U (Count chars to find X3)") {
// Set Conditional R1 : Match / char, ITA2 = ..... into counter 1
args[9] = ".";
args[10] = ".";