diff options
author | Devine Lu Linvega <[email protected]> | 2018-11-17 14:35:11 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-11-17 14:35:11 +1200 |
commit | 1c8d49e63ad3b15488c146363ce7fa9dbe5b3f2a (patch) | |
tree | 3ba7c9c68741168b58675dea17adeaed1e78faab | |
parent | f2a8c8ab41d4cdb5d2ed9ad8ac7e51eeab6ed8a1 (diff) | |
download | Orca-1c8d49e63ad3b15488c146363ce7fa9dbe5b3f2a.tar.gz Orca-1c8d49e63ad3b15488c146363ce7fa9dbe5b3f2a.zip |
Optimized track
-rw-r--r-- | desktop/core/lib/t.js | 5 | ||||
-rw-r--r-- | desktop/core/pico.js | 4 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 24 | ||||
-rw-r--r-- | examples/benchmark.pico | 3 |
4 files changed, 24 insertions, 12 deletions
diff --git a/desktop/core/lib/t.js b/desktop/core/lib/t.js index 05d2c29..2795790 100644 --- a/desktop/core/lib/t.js +++ b/desktop/core/lib/t.js @@ -22,8 +22,9 @@ function FnT (pico, x, y, isPassive) { } this.operation = function () { - const pos = (this.key % this.len) + this.ports.input.val.x - const res = pico.glyphAt(this.x + pos, this.y) + const pos = (this.key % this.len) + this.ports.input.val.x = pos + 1 + const res = this.listen(this.ports.input.val) this.output(`${res}`) } diff --git a/desktop/core/pico.js b/desktop/core/pico.js index e335965..7f9ca86 100644 --- a/desktop/core/pico.js +++ b/desktop/core/pico.js @@ -11,6 +11,7 @@ function Pico (w, h) { this.docs = {} this.allowed = [] this.locks = [] + this.runtime = [] this.terminal = null // Set in terminal.start @@ -114,7 +115,8 @@ function Pico (w, h) { } this.run = function () { - this.runFns(this.findFns()) + this.runtime = this.findFns() + this.runFns(this.runtime) this.record() this.s = this.s.substr(0, this.w * this.h) this.f += 1 diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index 32fb14c..69311a7 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -108,16 +108,20 @@ function Terminal (pico) { this.findPorts = function () { const h = {} - const fns = pico.findFns() + const fns = pico.runtime for (const id in fns) { const g = fns[id] if (pico.isLocked(g.x, g.y)) { continue } if (g.isPassive) { h[`${g.x}:${g.y}`] = 4 } if (g.ports.output) { h[`${g.x}:${g.y + 1}`] = 2 } - // for (const id in g.ports) { - // const port = g.ports[id] - // // h[`${g.x + port.x}:${g.y + port.y}`] = port.output ? 2 : port.bang ? 1 : 3 - // } + for (const id in g.ports.haste) { + const port = g.ports.haste[id] + h[`${g.x + port.x}:${g.y + port.y}`] = 5 + } + for (const id in g.ports.input) { + const port = g.ports.input[id] + h[`${g.x + port.x}:${g.y + port.y}`] = 3 + } } return h } @@ -199,14 +203,18 @@ function Terminal (pico) { ctx.fillStyle = this.theme.active.b_high ctx.fillRect(x * this.tile.w, (y) * this.tile.h, this.tile.w, this.tile.h) ctx.fillStyle = this.theme.active.f_low - } else if (styles.isPort === 3) { - ctx.fillStyle = this.theme.active.b_low + } else if (styles.isPort === 3) { // Input + ctx.fillStyle = this.theme.active.background ctx.fillRect(x * this.tile.w, (y) * this.tile.h, this.tile.w, this.tile.h) - ctx.fillStyle = this.theme.active.f_high + ctx.fillStyle = this.theme.active.b_high } else if (styles.isPort === 4) { // Passive ctx.fillStyle = this.theme.active.b_med ctx.fillRect(x * this.tile.w, (y) * this.tile.h, this.tile.w, this.tile.h) ctx.fillStyle = this.theme.active.f_low + } else if (styles.isPort === 5) { // Haste + ctx.fillStyle = this.theme.active.background + ctx.fillRect(x * this.tile.w, (y) * this.tile.h, this.tile.w, this.tile.h) + ctx.fillStyle = this.theme.active.b_med } } else if (styles.isLocked) { ctx.fillStyle = this.theme.active.background diff --git a/examples/benchmark.pico b/examples/benchmark.pico index 76eb589..7c09b06 100644 --- a/examples/benchmark.pico +++ b/examples/benchmark.pico @@ -1,6 +1,8 @@ ............................................................................... ............................................................................... ...;.....;.....;.....;.....;.....;.....;.....;.....;.....;.....;.....;.....;... +............................................................................... +............................................................................... ...A.....B.....C.....F.....I.....Lc....M.....Tc....X.....Y..................... ............................................................................... ............................................................................... @@ -22,5 +24,4 @@ ...AK2...Bw....CK2...FKK...IK2.........MK6.50T...........YKK................... ............................................................................... ............................................................................... -............................................................................... ...............................................................................
\ No newline at end of file |