Skip to content

Commit

Permalink
Fix flip impl error
Browse files Browse the repository at this point in the history
  • Loading branch information
A4-Tacks committed Sep 28, 2024
1 parent 1991f72 commit 5a04e77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"displayName": "Logic-Atomics",
"author": "A4-Tacks",
"description": "Processor atomic operation extension.",
"version": "0.2.2",
"version": "0.2.3",
"minGameVersion": 136
}
32 changes: 23 additions & 9 deletions src/scripts/inst/memory-atomics.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const OPTIONS = {
args: {},
run(_exec, mem, index, _args) {
let old = mem[index];
mem[index] = boundLong(Long(old).flipBit());
mem[index] = boundLong(Long(old).not());
return old;
},
},
Expand Down Expand Up @@ -327,7 +327,7 @@ const MemoryAtomicsStatement = {
},

read(words) {
this.op = words[1] || "add";
this.op = words[1] || OPTIONS_KEYS[0];
this.result = words[2] || "result";
this.mem = words[3] || "cell1";
this.index = words[4] || "0";
Expand Down Expand Up @@ -396,15 +396,19 @@ const MemoryAtomicsStatement = {

sep("fetch");

if (!OPTIONS[this.op]) this.op = OPTIONS_KEYS[0];

var optb = table.button(this.op, Styles.logict, () => {
this.showSelect(optb, OPTIONS_KEYS, this.op, op => {
this.op = op;
this.buildt(table);
}, 4, c => {c.width(90)});
this.showSelectTable(optb, (t, hide) => {
let i = 0;
for (var op in OPTIONS) {
let sub = this.setter(table, t, op, hide)
.size(90, 40);
if (++i % 3 == 0) sub.row();
}
});
}).width(80).color(table.color).get();

if (!OPTIONS[this.op]) return;

const arg_kvs = OPTIONS[this.op].args || {};
const argnames = Object.keys(arg_kvs);
for (let i in argnames) {
Expand All @@ -420,13 +424,23 @@ const MemoryAtomicsStatement = {
}
},

setter(root, table, op, hide) {
return table.button(op, Styles.logicTogglet, () => {
if (this.op != op) {
this.op = op;
this.buildt(root);
}
hide.run();
});
},

name: () => "Memory Atomics",
color: () => Pal.logicIo,
category: () => LCategory.io,
};

global.anuke.register(NAME, MemoryAtomicsStatement, [
NAME, Object.keys(OPTIONS)[0], /* init default codes */
NAME, OPTIONS_KEYS[0], /* init default codes */
]);

module.exports = MemoryAtomicsStatement;

0 comments on commit 5a04e77

Please sign in to comment.