diff options
author | Devine Lu Linvega <[email protected]> | 2018-10-18 21:27:24 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-10-18 21:27:24 +1200 |
commit | a70c6fbead65165d1ae09e407c461d98d5894478 (patch) | |
tree | d697e435e96dd7c88af224eae8ac890fea6289ed | |
parent | 0c98174b007dd2131e20d309b0b521c8379e7f15 (diff) | |
download | Orca-a70c6fbead65165d1ae09e407c461d98d5894478.tar.gz Orca-a70c6fbead65165d1ae09e407c461d98d5894478.zip |
Replacing bang with `*`
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | desktop/core/lib.js | 3 | ||||
-rw-r--r-- | desktop/core/lib/_bang.js | 17 | ||||
-rw-r--r-- | desktop/core/lib/_base.js | 11 | ||||
-rw-r--r-- | desktop/core/lib/_move.js | 6 | ||||
-rw-r--r-- | desktop/core/lib/_query.js | 2 | ||||
-rw-r--r-- | desktop/core/lib/a.js | 5 | ||||
-rw-r--r-- | desktop/core/lib/c.js | 4 | ||||
-rw-r--r-- | desktop/core/lib/d.js | 2 | ||||
-rw-r--r-- | desktop/core/lib/e.js | 4 | ||||
-rw-r--r-- | desktop/core/lib/h.js | 3 | ||||
-rw-r--r-- | desktop/core/lib/n.js | 4 | ||||
-rw-r--r-- | desktop/core/lib/r.js | 4 | ||||
-rw-r--r-- | desktop/core/lib/s.js | 6 | ||||
-rw-r--r-- | desktop/core/lib/t.js | 4 | ||||
-rw-r--r-- | desktop/core/lib/w.js | 4 | ||||
-rw-r--r-- | desktop/core/lib/x.js | 2 | ||||
-rw-r--r-- | desktop/core/pico.js | 8 | ||||
-rw-r--r-- | desktop/sources/scripts/keyboard.js | 3 |
19 files changed, 61 insertions, 32 deletions
@@ -81,6 +81,7 @@ function frequencyFromNoteNumber(note) { The idea is to build a synth/mini sequencer, here's some tasks I need to tackle before then. +- [ ] Replace bang with `*` - [ ] Add `:MID[CD]` - [ ] custom synth functions, like `:SYN[ADSR](C)` - [ ] sub programs scope diff --git a/desktop/core/lib.js b/desktop/core/lib.js index eaab5b8..7191f77 100644 --- a/desktop/core/lib.js +++ b/desktop/core/lib.js @@ -43,10 +43,11 @@ module.exports = { }, special: { '.': require('./lib/_null'), + '*': require('./lib/_bang'), ':': require('./lib/_query'), '-': require('./lib/_wireh'), '|': require('./lib/_wirev'), - '*': require('./lib/_wiren'), + '~': require('./lib/_wiren'), '+': require('./lib/_wiref') }, queries: { diff --git a/desktop/core/lib/_bang.js b/desktop/core/lib/_bang.js new file mode 100644 index 0000000..9e17ac8 --- /dev/null +++ b/desktop/core/lib/_bang.js @@ -0,0 +1,17 @@ +'use strict' + +const FnBase = require('./_base') + +function FnBang (pico, x, y, passive) { + FnBase.call(this, pico, x, y, true) + + this.name = 'bang' + this.glyph = '*' + this.info = 'Bangs!' + + this.operation = function () { + this.remove() + } +} + +module.exports = FnBang diff --git a/desktop/core/lib/_base.js b/desktop/core/lib/_base.js index 98efd7a..5b537c6 100644 --- a/desktop/core/lib/_base.js +++ b/desktop/core/lib/_base.js @@ -1,8 +1,9 @@ 'use strict' -function FnBase (pico, x, y, passive) { +function FnBase (pico, x, y, passive = false) { this.x = x this.y = y + this.passive = passive this.name = '<missing name>' this.glyph = '.' this.type = 'misc' @@ -10,6 +11,10 @@ function FnBase (pico, x, y, passive) { this.ports = [] this.docs = 'Hello!' + if (!passive) { + this.ports.push({ x: 0, y: 0, bang: true }) + } + this.id = function () { return this.x + (this.y * pico.h) } @@ -51,7 +56,7 @@ function FnBase (pico, x, y, passive) { if (this.y + y <= -1) { return false } const target = pico.glyphAt(this.x + x, this.y + y) - return target === '.' || target === 'b' ? true : target + return target === '.' || target === '*' ? true : target } this.neighbor_by = function (x, y) { @@ -72,7 +77,7 @@ function FnBase (pico, x, y, passive) { } this.bang = function () { - const ns = this.neighbors('b') + const ns = this.neighbors('*') for (const id in ns) { const n = ns[id] return { x: n.x, y: n.y } diff --git a/desktop/core/lib/_move.js b/desktop/core/lib/_move.js index 1c1e65c..740c073 100644 --- a/desktop/core/lib/_move.js +++ b/desktop/core/lib/_move.js @@ -9,7 +9,7 @@ function FnMove (pico, x, y, passive) { this.proceed = function (ahead, behind, paralG, perpeG, posAhead, moveLeft, moveAcross, moveRight) { const wireAhead = ahead && ahead.glyph === paralG - const wireBehind = behind && (behind.glyph === paralG || behind.glyph === '*' || behind.glyph === '+') + const wireBehind = behind && (behind.glyph === paralG || behind.glyph === '~' || behind.glyph === '+') // Is On Wire if (wireAhead && wireBehind) { @@ -18,13 +18,13 @@ function FnMove (pico, x, y, passive) { return true } // Entering Wire - else if (!wireBehind && ahead && (ahead.glyph === '*' || ahead.glyph === '+')) { + else if (!wireBehind && ahead && (ahead.glyph === '~' || ahead.glyph === '+')) { pico.add(moveAcross.x, moveAcross.y, moveAcross.glyph) this.remove() return true } // At Splitter - else if (ahead && ahead.glyph === '*') { + else if (ahead && ahead.glyph === '~') { let eject = true // Left Turn if (pico.glyphAt(moveLeft.x, moveLeft.y) === perpeG) { diff --git a/desktop/core/lib/_query.js b/desktop/core/lib/_query.js index 473ac99..fda25ff 100644 --- a/desktop/core/lib/_query.js +++ b/desktop/core/lib/_query.js @@ -33,7 +33,7 @@ function FnQuery (pico, x, y, passive) { } this.run = function () { - if (!this.north('b') && !this.west('b') && !this.south('b')) { return } + if (!this.north('*') && !this.west('*') && !this.south('*')) { return } if (!this.query) { pico.terminal.log(`Unknown query <${this.cmd}>`); return } if (this.cmd.indexOf('.') > -1) { return } this.query.run() diff --git a/desktop/core/lib/a.js b/desktop/core/lib/a.js index f8981f8..22f1616 100644 --- a/desktop/core/lib/a.js +++ b/desktop/core/lib/a.js @@ -9,7 +9,10 @@ function FnA (pico, x, y, passive) { this.name = 'add' this.glyph = 'a' this.info = 'Creates the result of the addition of east and west fns, southward.' - this.ports = [{ x: -1, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1, output: true }] + + this.ports.push({ x: -1, y: 0 }) + this.ports.push({ x: 1, y: 0 }) + this.ports.push({ x: 0, y: 1, output: true }) this.haste = function () { pico.lock(this.x, this.y + 1) diff --git a/desktop/core/lib/c.js b/desktop/core/lib/c.js index 2669449..30cc7de 100644 --- a/desktop/core/lib/c.js +++ b/desktop/core/lib/c.js @@ -7,7 +7,9 @@ function FnC (pico, x, y, passive) { this.name = 'clamp' this.glyph = 'c' this.info = '[FIX]Clamp the northern fn between the westward and eastward fn bang.' - this.ports = [{ x: 0, y: 0, bang: true }, { x: 1, y: 0, output: true }, { x: -1, y: 0 }] + this.ports.push({ x: 0, y: 0, bang: true }) + this.ports.push({ x: 1, y: 0, output: true }) + this.ports.push({ x: -1, y: 0 }) this.operation = function () { if (!this.bang() || !this.west()) { return } diff --git a/desktop/core/lib/d.js b/desktop/core/lib/d.js index 85f70a6..83d9d28 100644 --- a/desktop/core/lib/d.js +++ b/desktop/core/lib/d.js @@ -8,7 +8,7 @@ function FnD (pico, x, y, passive) { this.name = 'deflect' this.glyph = 'd' this.info = '[FIX]Converts neighboors into direction fns.' - this.ports = [{ x: 0, y: 1 }, { x: 0, y: -1 }, { x: 1, y: 0 }, { x: -1, y: 0 }] + // this.ports = [{ x: 0, y: 1 }, { x: 0, y: -1 }, { x: 1, y: 0 }, { x: -1, y: 0 }] this.operation = function () { if (this.north() && this.north().glyph !== 'n') { diff --git a/desktop/core/lib/e.js b/desktop/core/lib/e.js index e00f8f4..6099860 100644 --- a/desktop/core/lib/e.js +++ b/desktop/core/lib/e.js @@ -7,12 +7,12 @@ function FnE (pico, x, y, passive) { this.type = 'direction' this.name = 'east' - this.glyph = 'e' + this.glyph = passive ? 'E' : 'e' this.info = 'Moves eastward, or bangs.' this.haste = function () { if (this.signal()) { return } - if (this.is_free(1, 0) !== true) { this.replace('b'); this.lock(); return } + if (this.is_free(1, 0) !== true) { this.replace('*'); this.lock(); return } this.move(1, 0) } } diff --git a/desktop/core/lib/h.js b/desktop/core/lib/h.js index 0001484..000483d 100644 --- a/desktop/core/lib/h.js +++ b/desktop/core/lib/h.js @@ -9,8 +9,7 @@ function FnH (pico, x, y, passive) { this.name = 'halt' this.glyph = 'h' this.info = 'Stops southward fn from operating.' - - this.ports = [{ x: 0, y: 1, output: true }] + this.ports.push({ x: 0, y: 1, output: true }) this.haste = function () { pico.lock(this.x, this.y + 1) diff --git a/desktop/core/lib/n.js b/desktop/core/lib/n.js index d982600..a0c3bf6 100644 --- a/desktop/core/lib/n.js +++ b/desktop/core/lib/n.js @@ -7,12 +7,12 @@ function FnN (pico, x, y, passive) { this.type = 'direction' this.name = 'north' - this.glyph = 'n' + this.glyph = passive ? 'N' : 'n' this.info = 'Moves Northward, or bangs.' this.haste = function () { if (this.signal()) { return } - if (this.is_free(0, -1) !== true) { this.replace('b'); this.lock(); return } + if (this.is_free(0, -1) !== true) { this.replace('*'); this.lock(); return } this.move(0, -1) } } diff --git a/desktop/core/lib/r.js b/desktop/core/lib/r.js index 6c38daa..c6eed2e 100644 --- a/desktop/core/lib/r.js +++ b/desktop/core/lib/r.js @@ -20,10 +20,10 @@ function FnR (pico, x, y, passive) { let prev = beam while (pico.inBounds(beam.x, beam.y)) { beam = { x: beam.x + vector.x, y: beam.y + vector.y } - const busy = pico.glyphAt(beam.x, beam.y) !== '.' && pico.glyphAt(beam.x, beam.y) !== 'b' + const busy = pico.glyphAt(beam.x, beam.y) !== '.' && pico.glyphAt(beam.x, beam.y) !== '*' const outside = !pico.inBounds(beam.x, beam.y) if (busy || outside) { - pico.add(prev.x, prev.y, 'b') + pico.add(prev.x, prev.y, '*') break } prev = beam diff --git a/desktop/core/lib/s.js b/desktop/core/lib/s.js index 7ece44d..94a5327 100644 --- a/desktop/core/lib/s.js +++ b/desktop/core/lib/s.js @@ -7,12 +7,12 @@ function FnS (pico, x, y, passive) { this.type = 'direction' this.name = 'south' - this.glyph = 's' + this.glyph = passive ? 'S' : 's' this.info = 'Moves southward, or bangs.' this.haste = function () { - if (this.signal()) { return } - if (this.is_free(0, 1) !== true) { this.replace('b'); return } + // if (this.signal()) { return } + if (this.is_free(0, 1) !== true) { this.replace('*'); return } this.move(0, 1) } } diff --git a/desktop/core/lib/t.js b/desktop/core/lib/t.js index 716282f..b5276ae 100644 --- a/desktop/core/lib/t.js +++ b/desktop/core/lib/t.js @@ -15,13 +15,13 @@ function FnT (pico, x, y, passive) { if (!n) { return } - if (n.glyph === '1' || n.glyph === 'w' || n.glyph === 's' || n.glyph === 'n' || n.glyph === 'e' || n.glyph === 'b' || n.glyph === 'z') { + if (n.glyph === '1' || n.glyph === 'w' || n.glyph === 's' || n.glyph === 'n' || n.glyph === 'e' || n.glyph === '*' || n.glyph === 'z') { this.fire() } } this.fire = function () { - pico.add(this.x, this.y + 1, 'b') + pico.add(this.x, this.y + 1, '*') pico.lock(this.x, this.y + 1) } } diff --git a/desktop/core/lib/w.js b/desktop/core/lib/w.js index f3c2440..ac98603 100644 --- a/desktop/core/lib/w.js +++ b/desktop/core/lib/w.js @@ -7,12 +7,12 @@ function FnW (pico, x, y, passive) { this.type = 'direction' this.name = 'west' - this.glyph = 'w' + this.glyph = passive ? 'W' : 'w' this.info = 'Moves westward, or bangs.' this.haste = function () { if (this.signal()) { return } - if (this.is_free(-1, 0) !== true) { this.replace('b'); this.lock(); return } + if (this.is_free(-1, 0) !== true) { this.replace('*'); this.lock(); return } this.move(-1, 0) } } diff --git a/desktop/core/lib/x.js b/desktop/core/lib/x.js index 6407ca7..9b321c9 100644 --- a/desktop/core/lib/x.js +++ b/desktop/core/lib/x.js @@ -20,7 +20,7 @@ function FnX (pico, x, y, passive) { } this.fire = function (x, y) { - pico.add(this.x + x, this.y + y, 'b') + pico.add(this.x + x, this.y + y, '*') pico.lock(this.x + x, this.y + y) } } diff --git a/desktop/core/pico.js b/desktop/core/pico.js index dc2b7b4..533a81e 100644 --- a/desktop/core/pico.js +++ b/desktop/core/pico.js @@ -81,13 +81,17 @@ function Pico (w, h) { for (const id in fns) { const fn = fns[id] if (this.isLocked(fn.x, fn.y)) { continue } - fn.haste() + if (fn.passive || fn.bang()) { + fn.haste() + } } // Operate for (const id in fns) { const fn = fns[id] if (this.isLocked(fn.x, fn.y)) { continue } - fn.run() + if (fn.passive || fn.bang()) { + fn.run() + } } } diff --git a/desktop/sources/scripts/keyboard.js b/desktop/sources/scripts/keyboard.js index 826493d..f786e4b 100644 --- a/desktop/sources/scripts/keyboard.js +++ b/desktop/sources/scripts/keyboard.js @@ -36,9 +36,6 @@ function Keyboard () { if (event.key.length === 1) { terminal.cursor.insert(event.key) - if (event.shiftKey) { - terminal.cursor.move(1, 0) - } terminal.update() } } |