diff options
author | Лu Лinveгa <[email protected]> | 2019-05-31 12:07:03 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2019-05-31 12:07:03 +0900 |
commit | 17bd9edaee82bb179036032c8b388f0f67cda977 (patch) | |
tree | 1e98417d549cfc8d50ef1222af8db8e6a588778d | |
parent | 87ebec98983cc76520d27093aa0832f2a301b21a (diff) | |
parent | ef36e2fed52aadc5d6125ee6ec87897fe33e20c4 (diff) | |
download | Orca-17bd9edaee82bb179036032c8b388f0f67cda977.tar.gz Orca-17bd9edaee82bb179036032c8b388f0f67cda977.zip |
Merge pull request #122 from hundredrabbits/Hasteless
Hasteless
42 files changed, 216 insertions, 264 deletions
diff --git a/desktop/core/library/_bang.js b/desktop/core/library/_bang.js index dd0b9c8..90fb738 100644 --- a/desktop/core/library/_bang.js +++ b/desktop/core/library/_bang.js @@ -9,14 +9,7 @@ export default function OperatorBang (orca, x, y, passive) { this.info = 'Bangs neighboring operands' this.draw = false - // Overwrite run, to disable draw. - - this.run = function (force = false) { - - } - - this.haste = function () { - this.passive = true + this.operation = function () { this.erase() } } diff --git a/desktop/core/library/_cc.js b/desktop/core/library/_cc.js index c785b44..92fed96 100644 --- a/desktop/core/library/_cc.js +++ b/desktop/core/library/_cc.js @@ -8,24 +8,22 @@ export default function OperatorCC (orca, x, y) { this.name = 'cc' this.info = 'Sends MIDI control change' - this.ports.input.channel = { x: 1, y: 0, clamp: { min: 0, max: 15 } } - this.ports.input.knob = { x: 2, y: 0, clamp: { min: 0 } } - this.ports.input.value = { x: 3, y: 0, clamp: { min: 0 } } + this.ports.channel = { x: 1, y: 0, clamp: { min: 0, max: 15 } } + this.ports.knob = { x: 2, y: 0, clamp: { min: 0 } } + this.ports.value = { x: 3, y: 0, clamp: { min: 0 } } this.operation = function (force = false) { if (!this.hasNeighbor('*') && force === false) { return } + if (this.listen(this.ports.channel) === '.') { return } + if (this.listen(this.ports.knob) === '.') { return } - if (this.listen(this.ports.input.channel) === '.') { return } - if (this.listen(this.ports.input.knob) === '.') { return } - - const channel = this.listen(this.ports.input.channel, true) - const knob = this.listen(this.ports.input.knob, true) - const rawValue = this.listen(this.ports.input.value, true) - - const val = Math.ceil((127 * rawValue) / 35) + const channel = this.listen(this.ports.channel, true) + const knob = this.listen(this.ports.knob, true) + const rawValue = this.listen(this.ports.value, true) + const value = Math.ceil((127 * rawValue) / 35) this.draw = false - terminal.io.cc.send(channel, knob, val) + terminal.io.cc.send(channel, knob, value) if (force === true) { terminal.io.cc.run() diff --git a/desktop/core/library/_comment.js b/desktop/core/library/_comment.js index 16cf02d..8dcf0ae 100644 --- a/desktop/core/library/_comment.js +++ b/desktop/core/library/_comment.js @@ -9,12 +9,11 @@ export default function OperatorComment (orca, x, y, passive) { this.info = 'Halts line' this.draw = false - this.haste = function () { + this.operation = function () { for (let x = this.x + 1; x <= orca.w; x++) { orca.lock(x, this.y) if (orca.glyphAt(x, this.y) === this.glyph) { break } } - this.passive = false orca.lock(this.x, this.y) } } diff --git a/desktop/core/library/_midi.js b/desktop/core/library/_midi.js index 8b37c23..2f8ccc1 100644 --- a/desktop/core/library/_midi.js +++ b/desktop/core/library/_midi.js @@ -8,24 +8,24 @@ export default function OperatorMidi (orca, x, y, passive) { this.name = 'midi' this.info = 'Sends MIDI note' - this.ports.input.channel = { x: 1, y: 0, clamp: { min: 0, max: 16 } } - this.ports.input.octave = { x: 2, y: 0, clamp: { min: 0, max: 8 } } - this.ports.input.note = { x: 3, y: 0 } - this.ports.input.velocity = { x: 4, y: 0, default: 'f', clamp: { min: 0, max: 16 } } - this.ports.input.length = { x: 5, y: 0, default: '1', clamp: { min: 0, max: 16 } } + this.ports.channel = { x: 1, y: 0, clamp: { min: 0, max: 16 } } + this.ports.octave = { x: 2, y: 0, clamp: { min: 0, max: 8 } } + this.ports.note = { x: 3, y: 0 } + this.ports.velocity = { x: 4, y: 0, default: 'f', clamp: { min: 0, max: 16 } } + this.ports.length = { x: 5, y: 0, default: '1', clamp: { min: 0, max: 16 } } this.operation = function (force = false) { if (!this.hasNeighbor('*') && force === false) { return } - if (this.listen(this.ports.input.channel) === '.') { return } - if (this.listen(this.ports.input.octave) === '.') { return } - if (this.listen(this.ports.input.note) === '.') { return } + if (this.listen(this.ports.channel) === '.') { return } + if (this.listen(this.ports.octave) === '.') { return } + if (this.listen(this.ports.note) === '.') { return } - const channel = this.listen(this.ports.input.channel, true) - const rawOctave = this.listen(this.ports.input.octave, true) - const rawNote = this.listen(this.ports.input.note) - const rawVelocity = this.listen(this.ports.input.velocity, true) - const length = this.listen(this.ports.input.length, true) + const channel = this.listen(this.ports.channel, true) + const rawOctave = this.listen(this.ports.octave, true) + const rawNote = this.listen(this.ports.note) + const rawVelocity = this.listen(this.ports.velocity, true) + const length = this.listen(this.ports.length, true) if (!isNaN(rawNote)) { return } diff --git a/desktop/core/library/_mono.js b/desktop/core/library/_mono.js index 740e4a2..9c69537 100644 --- a/desktop/core/library/_mono.js +++ b/desktop/core/library/_mono.js @@ -8,25 +8,27 @@ export default function OperatorMono (orca, x, y, passive) { this.name = 'mono' this.info = 'Sends MIDI monophonic note' - this.ports.input.channel = { x: 1, y: 0, clamp: { min: 0, max: 16 } } - this.ports.input.octave = { x: 2, y: 0, clamp: { min: 0, max: 8 } } - this.ports.input.note = { x: 3, y: 0 } - this.ports.input.velocity = { x: 4, y: 0, default: 'f', clamp: { min: 0, max: 16 } } - this.ports.input.length = { x: 5, y: 0, default: '1', clamp: { min: 0, max: 16 } } + this.ports.channel = { x: 1, y: 0, clamp: { min: 0, max: 16 } } + this.ports.octave = { x: 2, y: 0, clamp: { min: 0, max: 8 } } + this.ports.note = { x: 3, y: 0 } + this.ports.velocity = { x: 4, y: 0, default: 'f', clamp: { min: 0, max: 16 } } + this.ports.length = { x: 5, y: 0, default: '1', clamp: { min: 0, max: 16 } } this.operation = function (force = false) { if (!this.hasNeighbor('*') && force === false) { return } - if (this.listen(this.ports.input.channel) === '.') { return } - if (this.listen(this.ports.input.octave) === '.') { return } - if (this.listen(this.ports.input.note) === '.') { return } + if (this.listen(this.ports.channel) === '.') { return } + if (this.listen(this.ports.octave) === '.') { return } + if (this.listen(this.ports.note) === '.') { return } - const channel = this.listen(this.ports.input.channel, true) - const rawOctave = this.listen(this.ports.input.octave, true) - const rawNote = this.listen(this.ports.input.note) - const rawVelocity = this.listen(this.ports.input.velocity, true) - const length = this.listen(this.ports.input.length, true) + const channel = this.listen(this.ports.channel, true) + const rawOctave = this.listen(this.ports.octave, true) + const rawNote = this.listen(this.ports.note) + const rawVelocity = this.listen(this.ports.velocity, true) + const length = this.listen(this.ports.length, true) + if (!isNaN(rawNote)) { return } + const transposed = this.transpose(rawNote, rawOctave) // 1 - 8 const octave = transposed.octave diff --git a/desktop/core/library/_osc.js b/desktop/core/library/_osc.js index 8f4fec2..51c9ed2 100644 --- a/desktop/core/library/_osc.js +++ b/desktop/core/library/_osc.js @@ -8,22 +8,24 @@ export default function OperatorOsc (orca, x, y, passive) { this.name = 'osc' this.info = 'Sends OSC message' - this.ports.haste.path = { x: 1, y: 0 } + this.ports.path = { x: 1, y: 0 } + + this.operation = function (force = false) { + if (!this.hasNeighbor('*') && force === false) { return } + + this.path = this.listen(this.ports.path) + + if (!this.path || this.path === '.') { return } - this.haste = function () { - this.path = this.listen(this.ports.haste.path) this.msg = '' + for (let x = 2; x <= 36; x++) { const g = orca.glyphAt(this.x + x, this.y) if (g === '.') { break } orca.lock(this.x + x, this.y) this.msg += g } - } - this.operation = function (force = false) { - if (!this.hasNeighbor('*') && force === false) { return } - if (!this.path || this.path === '.') { return } this.draw = false terminal.io.osc.send('/' + this.path, this.msg) diff --git a/desktop/core/library/_udp.js b/desktop/core/library/_udp.js index 5309e6b..f89c00c 100644 --- a/desktop/core/library/_udp.js +++ b/desktop/core/library/_udp.js @@ -8,16 +8,14 @@ export default function OperatorUdp (orca, x, y, passive) { this.name = 'udp' this.info = 'Sends UDP message' - this.haste = function () { + this.operation = function (force = false) { + if (!this.hasNeighbor('*') && force === false) { return } + for (let x = 1; x <= 36; x++) { const g = orca.glyphAt(this.x + x, this.y) if (g === '.') { break } orca.lock(this.x + x, this.y) } - } - - this.operation = function (force = false) { - if (!this.hasNeighbor('*') && force === false) { return } let msg = '' for (let x = 1; x <= 36; x++) { diff --git a/desktop/core/library/a.js b/desktop/core/library/a.js index cdc42e6..c2c66e5 100644 --- a/desktop/core/library/a.js +++ b/desktop/core/library/a.js @@ -8,13 +8,13 @@ export default function OperatorA (orca, x, y, passive) { this.name = 'add' this.info = 'Outputs sum of inputs' - this.ports.haste.a = { x: -1, y: 0 } - this.ports.input.b = { x: 1, y: 0 } + this.ports.a = { x: -1, y: 0 } + this.ports.b = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1, sensitive: true } this.operation = function (force = false) { - const a = this.listen(this.ports.haste.a, true) - const b = this.listen(this.ports.input.b, true) + const a = this.listen(this.ports.a, true) + const b = this.listen(this.ports.b, true) return orca.keyOf(a + b) } } diff --git a/desktop/core/library/b.js b/desktop/core/library/b.js index f461b90..a3bf23a 100644 --- a/desktop/core/library/b.js +++ b/desktop/core/library/b.js @@ -8,14 +8,14 @@ export default function OperatorB (orca, x, y, passive) { this.name = 'bounce' this.info = 'Outputs values between inputs' - this.ports.haste.rate = { x: -1, y: 0, clamp: { min: 1 } } - this.ports.input.mod = { x: 1, y: 0, default: '8' } + this.ports.rate = { x: -1, y: 0, clamp: { min: 1 } } + this.ports.mod = { x: 1, y: 0, default: '8' } this.ports.output = { x: 0, y: 1, sensitive: true } this.operation = function (force = false) { - const rate = this.listen(this.ports.haste.rate, true) - const mod = this.listen(this.ports.input.mod, true) - 1 - const key = (Math.floor(orca.f / rate) % (mod * 2)) + const rate = this.listen(this.ports.rate, true) + const mod = this.listen(this.ports.mod, true) - 1 + const key = Math.floor(orca.f / rate) % (mod * 2) return orca.keyOf(key <= mod ? key : mod - (key - mod)) } } diff --git a/desktop/core/library/c.js b/desktop/core/library/c.js index 610e31e..38dc20e 100644 --- a/desktop/core/library/c.js +++ b/desktop/core/library/c.js @@ -8,14 +8,14 @@ export default function OperatorC (orca, x, y, passive) { this.name = 'clock' this.info = 'Outputs modulo of frame' - this.ports.haste.rate = { x: -1, y: 0, clamp: { min: 1 } } - this.ports.input.mod = { x: 1, y: 0, default: '8' } + this.ports.rate = { x: -1, y: 0, clamp: { min: 1 } } + this.ports.mod = { x: 1, y: 0, default: '8' } this.ports.output = { x: 0, y: 1, sensitive: true } this.operation = function (force = false) { - const rate = this.listen(this.ports.haste.rate, true) - const mod = this.listen(this.ports.input.mod, true) - const val = (Math.floor(orca.f / rate) % mod) + const rate = this.listen(this.ports.rate, true) + const mod = this.listen(this.ports.mod, true) + const val = Math.floor(orca.f / rate) % mod return orca.keyOf(val) } } diff --git a/desktop/core/library/d.js b/desktop/core/library/d.js index 46cdb86..90cad15 100644 --- a/desktop/core/library/d.js +++ b/desktop/core/library/d.js @@ -8,13 +8,13 @@ export default function OperatorD (orca, x, y, passive) { this.name = 'delay' this.info = 'Bangs on modulo of frame' - this.ports.haste.rate = { x: -1, y: 0, clamp: { min: 1 } } - this.ports.input.mod = { x: 1, y: 0, default: '8' } + this.ports.rate = { x: -1, y: 0, clamp: { min: 1 } } + this.ports.mod = { x: 1, y: 0, default: '8' } this.ports.output = { x: 0, y: 1, bang: true } this.operation = function (force = false) { - const rate = this.listen(this.ports.haste.rate, true) - const mod = this.listen(this.ports.input.mod, true) + const rate = this.listen(this.ports.rate, true) + const mod = this.listen(this.ports.mod, true) const res = orca.f % (mod * rate) return res === 0 || mod === 1 } diff --git a/desktop/core/library/e.js b/desktop/core/library/e.js index ad6eb07..dab6b39 100644 --- a/desktop/core/library/e.js +++ b/desktop/core/library/e.js @@ -9,7 +9,7 @@ export default function OperatorE (orca, x, y, passive) { this.info = 'Moves eastward, or bangs' this.draw = false - this.haste = function () { + this.operation = function () { this.move(1, 0) this.passive = false } diff --git a/desktop/core/library/f.js b/desktop/core/library/f.js index 3960e8c..9566562 100644 --- a/desktop/core/library/f.js +++ b/desktop/core/library/f.js @@ -8,13 +8,13 @@ export default function OperatorF (orca, x, y, passive) { this.name = 'if' this.info = 'Bangs if inputs are equal' - this.ports.haste.a = { x: -1, y: 0 } - this.ports.input.b = { x: 1, y: 0 } + this.ports.a = { x: -1, y: 0 } + this.ports.b = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1, bang: true } this.operation = function (force = false) { - const a = this.listen(this.ports.haste.a) - const b = this.listen(this.ports.input.b) + const a = this.listen(this.ports.a) + const b = this.listen(this.ports.b) return a === b && a !== '.' } } diff --git a/desktop/core/library/g.js b/desktop/core/library/g.js index e5f107b..ba22d83 100644 --- a/desktop/core/library/g.js +++ b/desktop/core/library/g.js @@ -8,28 +8,22 @@ export default function OperatorG (orca, x, y, passive) { this.name = 'generator' this.info = 'Writes operands with offset' - this.ports.haste.x = { x: -3, y: 0 } - this.ports.haste.y = { x: -2, y: 0 } - this.ports.haste.len = { x: -1, y: 0, clamp: { min: 1 } } - this.ports.output = { x: 0, y: 1 } - - this.haste = function () { - const len = this.listen(this.ports.haste.len, true) - for (let x = 1; x <= len; x++) { - orca.lock(this.x + x, this.y) - } - } + this.ports.x = { x: -3, y: 0 } + this.ports.y = { x: -2, y: 0 } + this.ports.len = { x: -1, y: 0, clamp: { min: 1 } } this.operation = function (force = false) { - const len = this.listen(this.ports.haste.len, true) - const x = this.listen(this.ports.haste.x, true) - const y = this.listen(this.ports.haste.y, true) + 1 - this.ports.output = { x: x, y: y } - // Read - for (let i = 0; i < len; i++) { - const port = { x: i + 1, y: 0 } + const len = this.listen(this.ports.len, true) + const x = this.listen(this.ports.x, true) + const y = this.listen(this.ports.y, true) + 1 + for (let offset = 0; offset <= len; offset++) { + if (offset > 0) { + orca.lock(this.x + offset, this.y) + } + const port = { x: offset + 1, y: 0 } const value = this.listen(port) - orca.write(this.x + x + i, this.y + y, value) + orca.write(this.x + x + offset, this.y + y, value) } + this.ports.output = { x: x, y: y } } } diff --git a/desktop/core/library/h.js b/desktop/core/library/h.js index 8565b10..24b1184 100644 --- a/desktop/core/library/h.js +++ b/desktop/core/library/h.js @@ -10,11 +10,8 @@ export default function OperatorH (orca, x, y, passive) { this.ports.output = { x: 0, y: 1, reader: true } - this.haste = function () { - orca.lock(this.x + this.ports.output.x, this.y + this.ports.output.y) - } - this.operation = function (force = false) { + orca.lock(this.x + this.ports.output.x, this.y + this.ports.output.y) return this.listen(this.ports.output, true) } } diff --git a/desktop/core/library/i.js b/desktop/core/library/i.js index cb3a44b..f896f25 100644 --- a/desktop/core/library/i.js +++ b/desktop/core/library/i.js @@ -8,13 +8,13 @@ export default function OperatorI (orca, x, y, passive) { this.name = 'increment' this.info = 'Increments southward operand' - this.ports.haste.step = { x: -1, y: 0, default: '1' } - this.ports.input.mod = { x: 1, y: 0 } + this.ports.step = { x: -1, y: 0, default: '1' } + this.ports.mod = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1, sensitive: true, reader: true } this.operation = function (force = false) { - const step = this.listen(this.ports.haste.step, true) - const mod = this.listen(this.ports.input.mod, true) + const step = this.listen(this.ports.step, true) + const mod = this.listen(this.ports.mod, true) const val = this.listen(this.ports.output, true) return orca.keyOf((val + step) % (mod > 0 ? mod : 36)) } diff --git a/desktop/core/library/j.js b/desktop/core/library/j.js index d8aaf5f..0c7e68d 100644 --- a/desktop/core/library/j.js +++ b/desktop/core/library/j.js @@ -8,14 +8,11 @@ export default function OperatorJ (orca, x, y, passive) { this.name = 'jumper' this.info = 'Outputs northward operand' - this.ports.haste.val = { x: 0, y: -1 } + this.ports.val = { x: 0, y: -1 } this.ports.output = { x: 0, y: 1 } - this.haste = function () { - orca.lock(this.x, this.y + 1) - } - this.operation = function (force = false) { - return this.listen(this.ports.haste.val) + orca.lock(this.x, this.y + 1) + return this.listen(this.ports.val) } } diff --git a/desktop/core/library/k.js b/desktop/core/library/k.js index 07cad34..8fce517 100644 --- a/desktop/core/library/k.js +++ b/desktop/core/library/k.js @@ -8,22 +8,15 @@ export default function OperatorK (orca, x, y, passive) { this.name = 'konkat' this.info = 'Reads multiple variables' - this.ports.haste.len = { x: -1, y: 0, clamp: { min: 1 } } - - this.haste = function () { - this.len = this.listen(this.ports.haste.len, true) - for (let x = 1; x <= this.len; x++) { - orca.lock(this.x + x, this.y) - const g = orca.glyphAt(this.x + x, this.y) - if (g !== '.') { - orca.lock(this.x + x, this.y + 1) - } - } - } + this.ports.len = { x: -1, y: 0, clamp: { min: 1 } } this.operation = function (force = false) { + this.len = this.listen(this.ports.len, true) for (let x = 1; x <= this.len; x++) { + orca.lock(this.x + x, this.y) const key = orca.glyphAt(this.x + x, this.y) + if (key === '.') { continue } + orca.lock(this.x + x, this.y + 1) orca.write(this.x + x, this.y + 1, orca.valueIn(key)) } } diff --git a/desktop/core/library/l.js b/desktop/core/library/l.js index 71a076b..518c2ec 100644 --- a/desktop/core/library/l.js +++ b/desktop/core/library/l.js @@ -8,27 +8,23 @@ export default function OperatorL (orca, x, y, passive) { this.name = 'loop' this.info = 'Moves eastward operands' - this.ports.haste.step = { x: -2, y: 0, default: '1' } - this.ports.haste.len = { x: -1, y: 0 } - this.ports.input.val = { x: 1, y: 0 } + this.ports.step = { x: -2, y: 0, default: '1' } + this.ports.len = { x: -1, y: 0 } + this.ports.val = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1 } - this.haste = function () { - const len = this.listen(this.ports.haste.len, true) - for (let x = 1; x <= len; x++) { - orca.lock(this.x + x, this.y) - } - } - this.operation = function (force = false) { - const step = this.listen(this.ports.haste.step, true) - const len = this.listen(this.ports.haste.len, true) + const len = this.listen(this.ports.len, true) + const step = this.listen(this.ports.step, true) const index = orca.indexAt(this.x + 1, this.y) const seg = orca.s.substr(index, len) const res = seg.substr(len - step, step) + seg.substr(0, len - step) - for (let x = 0; x < len; x++) { - orca.write(this.x + x + 1, this.y, res.charAt(x)) + for (let offset = 0; offset <= len; offset++) { + if (offset > 0) { + orca.lock(this.x + offset, this.y) + } + orca.write(this.x + offset + 1, this.y, res.charAt(offset)) } - return this.listen(this.ports.input.val) + return this.listen(this.ports.val) } } diff --git a/desktop/core/library/m.js b/desktop/core/library/m.js index 5eb5514..5986708 100644 --- a/desktop/core/library/m.js +++ b/desktop/core/library/m.js @@ -8,13 +8,13 @@ export default function OperatorM (orca, x, y, passive) { this.name = 'multiply' this.info = 'Outputs product of inputs' - this.ports.haste.a = { x: -1, y: 0 } - this.ports.input.b = { x: 1, y: 0 } + this.ports.a = { x: -1, y: 0 } + this.ports.b = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1, sensitive: true } this.operation = function (force = false) { - const a = this.listen(this.ports.haste.a, true) - const b = this.listen(this.ports.input.b, true) + const a = this.listen(this.ports.a, true) + const b = this.listen(this.ports.b, true) return orca.keyOf(a * b) } } diff --git a/desktop/core/library/n.js b/desktop/core/library/n.js index c3cc89e..1f1f290 100644 --- a/desktop/core/library/n.js +++ b/desktop/core/library/n.js @@ -9,7 +9,7 @@ export default function OperatorN (orca, x, y, passive) { this.info = 'Moves Northward, or bangs' this.draw = false - this.haste = function () { + this.operation = function () { this.move(0, -1) this.passive = false } diff --git a/desktop/core/library/o.js b/desktop/core/library/o.js index 6d89dc7..5f39a88 100644 --- a/desktop/core/library/o.js +++ b/desktop/core/library/o.js @@ -8,15 +8,14 @@ export default function OperatorO (orca, x, y, passive) { this.name = 'read' this.info = 'Reads operand with offset' - this.ports.haste.x = { x: -2, y: 0 } - this.ports.haste.y = { x: -1, y: 0 } - this.ports.input.read = { x: 1, y: 0 } + this.ports.x = { x: -2, y: 0 } + this.ports.y = { x: -1, y: 0 } this.ports.output = { x: 0, y: 1 } this.operation = function (force = false) { - const x = this.listen(this.ports.haste.x, true) - const y = this.listen(this.ports.haste.y, true) - this.ports.input.read = { x: x + 1, y: y } - return this.listen(this.ports.input.read) + const x = this.listen(this.ports.x, true) + const y = this.listen(this.ports.y, true) + this.ports.read = { x: x + 1, y: y } + return this.listen(this.ports.read) } } diff --git a/desktop/core/library/p.js b/desktop/core/library/p.js index 82893df..4e48af9 100644 --- a/desktop/core/library/p.js +++ b/desktop/core/library/p.js @@ -8,22 +8,17 @@ export default function OperatorP (orca, x, y, passive) { this.name = 'push' this.info = 'Writes eastward operand' - this.ports.haste.len = { x: -1, y: 0, clamp: { min: 1 } } - this.ports.haste.key = { x: -2, y: 0 } - this.ports.input.val = { x: 1, y: 0 } - this.ports.output = { x: 0, y: 1 } + this.ports.len = { x: -1, y: 0, clamp: { min: 1 } } + this.ports.key = { x: -2, y: 0 } + this.ports.val = { x: 1, y: 0 } - this.haste = function () { - const len = this.listen(this.ports.haste.len, true) + this.operation = function (force = false) { + const len = this.listen(this.ports.len, true) + const key = this.listen(this.ports.key, true) for (let x = 0; x < len; x++) { orca.lock(this.x + x, this.y + 1) } - } - - this.operation = function (force = false) { - const len = this.listen(this.ports.haste.len, true) - const key = this.listen(this.ports.haste.key, true) this.ports.output = { x: (key % len), y: 1 } - return this.listen(this.ports.input.val) + return this.listen(this.ports.val) } } diff --git a/desktop/core/library/q.js b/desktop/core/library/q.js index 1890bf4..318758d 100644 --- a/desktop/core/library/q.js +++ b/desktop/core/library/q.js @@ -8,28 +8,19 @@ export default function OperatorQ (orca, x, y, passive) { this.name = 'query' this.info = 'Reads operands with offset' - this.ports.haste.x = { x: -3, y: 0 } - this.ports.haste.y = { x: -2, y: 0 } - this.ports.haste.len = { x: -1, y: 0, clamp: { min: 1 } } - - this.haste = function () { - const len = this.listen(this.ports.haste.len, true) - const x = this.listen(this.ports.haste.x, true) - const y = this.listen(this.ports.haste.y, true) - for (let i = 1; i <= len; i++) { - orca.lock(this.x + x + i, this.y + y) - } - } + this.ports.x = { x: -3, y: 0 } + this.ports.y = { x: -2, y: 0 } + this.ports.len = { x: -1, y: 0, clamp: { min: 1 } } this.operation = function (force = false) { - const len = this.listen(this.ports.haste.len, true) - const x = this.listen(this.ports.haste.x, true) - const y = this.listen(this.ports.haste.y, true) + const len = this.listen(this.ports.len, true) + const x = this.listen(this.ports.x, true) + const y = this.listen(this.ports.y, true) for (let i = 1; i <= len; i++) { - this.ports.haste[`val${i}`] = { x: x + i, y: y } orca.lock(this.x + x + i, this.y + y) + this.ports[`val${i}`] = { x: x + i, y: y } this.ports.output = { x: i - len, y: 1 } - const res = this.listen(this.ports.haste[`val${i}`]) + const res = this.listen(this.ports[`val${i}`]) this.output(`${res}`) } this.ports.output = { x: 0, y: 1 } diff --git a/desktop/core/library/r.js b/desktop/core/library/r.js index d27635d..591717a 100644 --- a/desktop/core/library/r.js +++ b/desktop/core/library/r.js @@ -8,13 +8,13 @@ export default function OperatorR (orca, x, y, passive) { this.name = 'random' this.info = 'Outputs random value' - this.ports.haste.min = { x: -1, y: 0 } - this.ports.input.max = { x: 1, y: 0 } + this.ports.min = { x: -1, y: 0 } + this.ports.max = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1, sensitive: true } this.operation = function (force = false) { - const min = this.listen(this.ports.haste.min, true) - const max = this.listen(this.ports.input.max, true) + const min = this.listen(this.ports.min, true) + const max = this.listen(this.ports.max, true) const val = parseInt((Math.random() * ((max > 0 ? max : 36) - min)) + min) return orca.keyOf(val) } diff --git a/desktop/core/library/s.js b/desktop/core/library/s.js index 1b9cccf..0c13a28 100644 --- a/desktop/core/library/s.js +++ b/desktop/core/library/s.js @@ -9,7 +9,7 @@ export default function OperatorS (orca, x, y, passive) { this.info = 'Moves southward, or bangs' this.draw = false - this.haste = function () { + this.operation = function () { this.move(0, 1) this.passive = false } diff --git a/desktop/core/library/t.js b/desktop/core/library/t.js index e140d24..287a664 100644 --- a/desktop/core/library/t.js +++ b/desktop/core/library/t.js @@ -8,22 +8,17 @@ export default function OperatorT (orca, x, y, passive) { this.name = 'track' this.info = 'Reads eastward operand' - this.ports.haste.key = { x: -2, y: 0 } - this.ports.haste.len = { x: -1, y: 0, clamp: { min: 1 } } - this.ports.input.val = { x: 1, y: 0 } + this.ports.key = { x: -2, y: 0 } + this.ports.len = { x: -1, y: 0, clamp: { min: 1 } } this.ports.output = { x: 0, y: 1 } - this.haste = function () { - const len = this.listen(this.ports.haste.len, true) + this.operation = function (force = false) { + const len = this.listen(this.ports.len, true) + const key = this.listen(this.ports.key, true) for (let x = 1; x <= len; x++) { orca.lock(this.x + x, this.y) } - } - - this.operation = function (force = false) { - const len = this.listen(this.ports.haste.len, true) - const key = this.listen(this.ports.haste.key, true) - this.ports.input.val = { x: (key % len) + 1, y: 0 } - return this.listen(this.ports.input.val) + this.ports.val = { x: (key % len) + 1, y: 0 } + return this.listen(this.ports.val) } } diff --git a/desktop/core/library/u.js b/desktop/core/library/u.js index ab82edb..4dc50e2 100644 --- a/desktop/core/library/u.js +++ b/desktop/core/library/u.js @@ -8,13 +8,13 @@ export default function OperatorU (orca, x, y, passive) { this.name = 'uclid' this.info = 'Bangs on Euclidean rhythm' - this.ports.haste.step = { x: -1, y: 0, clamp: { min: 0 }, default: '1' } - this.ports.input.max = { x: 1, y: 0, clamp: { min: 1 }, default: '8' } + this.ports.step = { x: -1, y: 0, clamp: { min: 0 }, default: '1' } + this.ports.max = { x: 1, y: 0, clamp: { min: 1 }, default: '8' } this.ports.output = { x: 0, y: 1, bang: true } this.operation = function (force = false) { - const step = this.listen(this.ports.haste.step, true) - const max = this.listen(this.ports.input.max, true) + const step = this.listen(this.ports.step, true) + const max = this.listen(this.ports.max, true) const bucket = (step * (orca.f + max - 1)) % max + step return bucket >= max } diff --git a/desktop/core/library/v.js b/desktop/core/library/v.js index ae20581..8b2fc96 100644 --- a/desktop/core/library/v.js +++ b/desktop/core/library/v.js @@ -8,20 +8,15 @@ export default function OperatorV (orca, x, y, passive) { this.name = 'variable' this.info = 'Reads and writes variable' - this.ports.haste.write = { x: -1, y: 0 } - this.ports.input.read = { x: 1, y: 0 } + this.ports.write = { x: -1, y: 0 } + this.ports.read = { x: 1, y: 0 } - this.haste = function () { - const write = this.listen(this.ports.haste.write) - const read = this.listen(this.ports.input.read) + this.operation = function (force = false) { + const write = this.listen(this.ports.write) + const read = this.listen(this.ports.read) if (write === '.' && read !== '.') { this.ports.output = { x: 0, y: 1 } } - } - - this.operation = function (force = false) { - const write = this.listen(this.ports.haste.write) - const read = this.listen(this.ports.input.read) if (write !== '.') { orca.variables[write] = read return diff --git a/desktop/core/library/w.js b/desktop/core/library/w.js index c9b0439..aae8615 100644 --- a/desktop/core/library/w.js +++ b/desktop/core/library/w.js @@ -9,7 +9,7 @@ export default function OperatorW (orca, x, y, passive) { this.info = 'Moves westward, or bangs' this.draw = false - this.haste = function () { + this.operation = function () { this.move(-1, 0) this.passive = false } diff --git a/desktop/core/library/x.js b/desktop/core/library/x.js index 016c3db..94a41dc 100644 --- a/desktop/core/library/x.js +++ b/desktop/core/library/x.js @@ -8,14 +8,14 @@ export default function OperatorX (orca, x, y, passive) { this.name = 'write' this.info = 'Writes operand with offset' - this.ports.haste.x = { x: -2, y: 0 } - this.ports.haste.y = { x: -1, y: 0 } - this.ports.input.val = { x: 1, y: 0 } + this.ports.x = { x: -2, y: 0 } + this.ports.y = { x: -1, y: 0 } + this.ports.val = { x: 1, y: 0 } this.operation = function (force = false) { - const x = this.listen(this.ports.haste.x, true) - const y = this.listen(this.ports.haste.y, true) + 1 + const x = this.listen(this.ports.x, true) + const y = this.listen(this.ports.y, true) + 1 this.ports.output = { x: x, y: y } - return this.listen(this.ports.input.val) + return this.listen(this.ports.val) } } diff --git a/desktop/core/library/y.js b/desktop/core/library/y.js index 05f5daf..a0ae7c9 100644 --- a/desktop/core/library/y.js +++ b/desktop/core/library/y.js @@ -8,14 +8,11 @@ export default function OperatorY (orca, x, y, passive) { this.name = 'jymper' this.info = 'Outputs westward operand' - this.ports.haste.val = { x: -1, y: 0 } + this.ports.val = { x: -1, y: 0 } this.ports.output = { x: 1, y: 0 } - this.haste = function () { - orca.lock(this.x + 1, this.y) - } - this.operation = function (force = false) { - return this.listen(this.ports.haste.val) + orca.lock(this.x + 1, this.y) + return this.listen(this.ports.val) } } diff --git a/desktop/core/library/z.js b/desktop/core/library/z.js index c8ea941..b91cde4 100644 --- a/desktop/core/library/z.js +++ b/desktop/core/library/z.js @@ -6,15 +6,15 @@ export default function OperatorZ (orca, x, y, passive) { Operator.call(this, orca, x, y, 'z', passive) this.name = 'lerp' - this.info = 'Transitions operand to input' + this.info = 'Transitions operand to target' - this.ports.haste.rate = { x: -1, y: 0, default: '1' } - this.ports.input.target = { x: 1, y: 0 } + this.ports.rate = { x: -1, y: 0, default: '1' } + this.ports.target = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1, sensitive: true, reader: true } this.operation = function (force = false) { - const rate = this.listen(this.ports.haste.rate, true) - const target = this.listen(this.ports.input.target, true) + const rate = this.listen(this.ports.rate, true) + const target = this.listen(this.ports.target, true) const val = this.listen(this.ports.output, true) const mod = val <= target - rate ? rate : val >= target + rate ? -rate : target - val return orca.keyOf(val + mod) diff --git a/desktop/core/operator.js b/desktop/core/operator.js index 1539cb3..776f824 100644 --- a/desktop/core/operator.js +++ b/desktop/core/operator.js @@ -10,7 +10,7 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) { this.draw = passive this.glyph = passive ? glyph.toUpperCase() : glyph this.info = '--' - this.ports = { input: {}, haste: {}, bang: !passive } + this.ports = { bang: !passive } // Actions @@ -39,25 +39,13 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) { // Phases - this.permissions = function () { - for (const id in this.ports.input) { - const port = this.ports.input[id] - orca.lock(this.x + port.x, this.y + port.y) - } - if (this.ports.output) { - orca.lock(this.x + this.ports.output.x, this.y + this.ports.output.y) - } - } - - this.haste = function () { - } - - this.operation = function () { - - } - this.run = function (force = false) { + // Permissions + for (const id in this.ports) { + orca.lock(this.x + this.ports[id].x, this.y + this.ports[id].y) + } this.draw = true + // Operate const payload = this.operation(force) if (this.ports.output) { if (this.ports.output.bang === true) { @@ -68,6 +56,10 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) { } } + this.operation = function () { + + } + // Helpers this.lock = function () { @@ -84,7 +76,7 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) { this.explode = function () { this.replace('*') - this.lock() + // this.lock() } this.move = function (x, y) { @@ -115,13 +107,9 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) { a.push([this.x, this.y, 0, `${this.name.charAt(0).toUpperCase() + this.name.substring(1).toLowerCase()}`]) } if (!this.passive) { return a } - for (const id in this.ports.haste) { - const port = this.ports.haste[id] - a.push([this.x + port.x, this.y + port.y, 1, `${this.glyph}-${id}`]) - } - for (const id in this.ports.input) { - const port = this.ports.input[id] - a.push([this.x + port.x, this.y + port.y, 2, `${this.glyph}-${id}`]) + for (const id in this.ports) { + const port = this.ports[id] + a.push([this.x + port.x, this.y + port.y, port.x < 0 || port.y < 0 ? 1 : 2, `${this.glyph}-${id}`]) } if (this.ports.output) { const port = this.ports.output @@ -130,7 +118,7 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) { return a } - this.requireUC = function (ports = this.ports.input) { + this.requireUC = function (ports = this.ports) { if (this.ports.output.sensitive !== true) { return false } for (const id in ports) { const value = this.listen(ports[id]) diff --git a/desktop/core/orca.js b/desktop/core/orca.js index c7c44c7..98dd675 100644 --- a/desktop/core/orca.js +++ b/desktop/core/orca.js @@ -85,8 +85,6 @@ export default function Orca (terminal) { const operator = operators[id] if (this.lockAt(operator.x, operator.y)) { continue } if (operator.passive || operator.hasNeighbor('*')) { - operator.haste() - operator.permissions() operator.run() } } diff --git a/desktop/main.js b/desktop/main.js index fc44717..2c3bc30 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -37,6 +37,7 @@ app.on('ready', () => { }) app.win.loadURL(`file://${__dirname}/sources/index.html`) + app.inspect() app.win.on('closed', () => { win = null diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 8b7fd57..405305f 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -17,21 +17,27 @@ export default function Commander (terminal) { } this.actives = { + // Ports 'osc': (val) => { terminal.io.osc.select(parseInt(val)) }, 'udp': (val) => { terminal.io.udp.select(parseInt(val)) }, + // Cursor 'copy': (val) => { terminal.cursor.copy() }, 'paste': (val) => { terminal.cursor.paste(true) }, 'erase': (val) => { terminal.cursor.erase() }, + // Controls 'play': (val) => { terminal.clock.play() }, 'stop': (val) => { terminal.clock.stop() }, 'run': (val) => { terminal.run() }, + // Speed 'apm': (val) => { terminal.clock.set(null, parseInt(val)) }, 'bpm': (val) => { terminal.clock.set(parseInt(val), parseInt(val), true) }, 'time': (val) => { terminal.clock.setFrame(parseInt(val)) }, 'rewind': (val) => { terminal.clock.setFrame(terminal.orca.f - parseInt(val)) }, 'skip': (val) => { terminal.clock.setFrame(terminal.orca.f + parseInt(val)) }, + // Themeing 'color': (val) => { const parts = val.split(';'); terminal.theme.set('b_med', parts[0]); terminal.theme.set('b_inv', parts[1]); terminal.theme.set('b_high', parts[2]) }, 'graphic': (val) => { terminal.theme.setImage(terminal.source.locate(val + '.jpg')) }, + // Edit 'inject': (val) => { terminal.source.inject(val, true) }, 'write': (val) => { const parts = val.split(';'); terminal.cursor.select(parts[1], parts[2], parts[0].length); terminal.cursor.writeBlock([parts[0].split('')]) } } diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index bf41f20..5dfd871 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -12,7 +12,7 @@ import Controller from './lib/controller.js' import library from '../../core/library.js' export default function Terminal () { - this.version = 131 + this.version = 132 this.library = library this.orca = new Orca(this) @@ -376,7 +376,7 @@ export default function Terminal () { const operators = Object.keys(library).filter((val) => { return isNaN(val) }) for (const id in operators) { const oper = new this.library[operators[id]]() - const ports = (oper.ports.haste ? Object.keys(oper.ports.haste).reduce((acc, key, val) => { return acc + ' *' + key + '*' }, '') : '') + (oper.ports.input ? Object.keys(oper.ports.input).reduce((acc, key, val) => { return acc + ' ' + key }, '') : '') + const ports = oper.ports.input ? Object.keys(oper.ports.input).reduce((acc, key, val) => { return acc + ' ' + key }, '') : '' html += `- \`${oper.glyph.toUpperCase()}\` **${oper.name}**${ports !== '' ? '(' + ports.trim() + ')' : ''}: ${oper.info}.\n` } return html diff --git a/examples/benchmarks/cardinals.orca b/examples/benchmarks/cardinals.orca new file mode 100644 index 0000000..47c553f --- /dev/null +++ b/examples/benchmarks/cardinals.orca @@ -0,0 +1,18 @@ +.......................................... +.#.CLOCKWISE.#...#.COUNTER.#.............. +.......................................... +...2D4.....D4......2D4....D4.............. +.32X.............32X...................... +.......H...............H.................. +.......E...H...........S.................. +.......j...S...........j.................. +...........j................0............. +.......................................... +..........................H............... +...........S..........H...Ny.............. +............H.........Ey..E.0............. +...........xW............................. +.......0.................................. +.......................................... +.......................................... +..........................................
\ No newline at end of file diff --git a/examples/misc/io.orca b/examples/benchmarks/io.orca index 9caea1e..9caea1e 100644 --- a/examples/misc/io.orca +++ b/examples/benchmarks/io.orca diff --git a/examples/misc/benchmark.orca b/examples/benchmarks/logic.orca index 1245574..1245574 100644 --- a/examples/misc/benchmark.orca +++ b/examples/benchmarks/logic.orca diff --git a/examples/misc/read+write.orca b/examples/benchmarks/rw.orca index d584ad6..d584ad6 100644 --- a/examples/misc/read+write.orca +++ b/examples/benchmarks/rw.orca |