Various fixes for conditional calcs

This commit is contained in:
VirtualColossus 2019-11-30 10:25:24 +00:00
parent 4c0d944992
commit c32fec6b53
3 changed files with 21 additions and 9 deletions

View file

@ -332,26 +332,26 @@ export class ColossusComputer {
const Qswitch = this.readBusSwitches(row.Qswitches);
// Match switches to bit pattern
for (let s=0;s<5;s++) {
if (Qswitch[s] >= 0 && Qswitch[s] !== this.Qbits[s]) result = false;
if (Qswitch[s] >= 0 && Qswitch[s] !== parseInt(this.Qbits[s],10)) result = false;
}
// Check for NOT switch
if (row.Negate) result = !result;
// AND each row to get final result
if (cnt[cPnt] === -1) {
cnt[cPnt] = (result?1:0);
} else if (result === 0) {
cnt[cPnt] = 0;
cnt[cPnt] = result;
} else if (!result) {
cnt[cPnt] = false;
}
}
}
// 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] = !cnt[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]===1) this.allCounters[c]++;
if (cnt[c] === true) this.allCounters[c]++;
}
}

View file

@ -12,6 +12,8 @@ export const SWITCHES = [
{name: "Down (x)", value: "x"}
];
export const VALID_ITA2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ34589+-./";
export const ITA2_TABLE = {
"A": "11000",
"B": "10011",