Skip to content

Commit

Permalink
Remove private members
Browse files Browse the repository at this point in the history
  • Loading branch information
remko committed Oct 28, 2023
1 parent 0fdaa1c commit ec30950
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
3 changes: 1 addition & 2 deletions scripts/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,6 @@ def replace_set(m, is_rst, is_keep, flip):
(global $wstp (mut i32) (i32.const -1))
(global $rstp (mut i32) (i32.const -1))
(start $reset)
)
(start $reset))
"""
print(out)
39 changes: 16 additions & 23 deletions src/uxn.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,30 @@ import wasmModule from "./uxn.wat";
function Uxn() {
this.dev = 0x10200;

let core, wstd, rstd;

const reset = () => {
core.exports.reset();
};

this.init = async (system) => {
const instance = await WebAssembly.instantiate(wasmModule, { system });
this._core = instance.instance;
this.ram = new Uint8Array(this._core.exports.memory.buffer, 0, 0x10300);
this._wstd = new Uint8Array(
this._core.exports.memory.buffer,
0x10000,
0xff
);
this._rstd = new Uint8Array(
this._core.exports.memory.buffer,
0x10100,
0xff
);
core = (await WebAssembly.instantiate(wasmModule, { system })).instance;
this.ram = new Uint8Array(core.exports.memory.buffer, 0, 0x10300);
wstd = new Uint8Array(core.exports.memory.buffer, 0x10000, 0xff);
rstd = new Uint8Array(core.exports.memory.buffer, 0x10100, 0xff);
return this;
};

this.load = (rom) => {
this.reset();
reset();
for (let i = 0, len = rom.length; i < len; ++i) {
this.ram[0x100 + i] = rom[i];
}
return this;
};

this.eval = (addr) => {
this._core.exports.eval(addr);
core.exports.eval(addr);
};

this.poke8 = (addr, val) => {
Expand All @@ -49,25 +46,21 @@ function Uxn() {
return (this.ram[addr] << 8) + this.ram[addr + 1];
};

this.reset = () => {
this._core.exports.reset();
};

this.wst = {
get: (i) => {
return this._wstd[0xfe - i];
return wstd[0xfe - i];
},
ptr: () => {
return 0x100ff - this._core.exports.wstp();
return 0x100ff - core.exports.wstp();
},
};

this.rst = {
get: (i) => {
return this._rstd[0xfe - i];
return rstd[0xfe - i];
},
ptr: () => {
return 0x101ff - this._core.exports.rstp();
return 0x101ff - core.exports.rstp();
},
};

Expand Down
3 changes: 1 addition & 2 deletions src/uxn.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,5 @@
(global $wstp (mut i32) (i32.const -1))
(global $rstp (mut i32) (i32.const -1))

(start $reset)
)
(start $reset))

0 comments on commit ec30950

Please sign in to comment.