aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-10-18 21:49:45 +1200
committerDevine Lu Linvega <[email protected]>2018-10-18 21:49:45 +1200
commit6c48c936fe38b4e302547d90757b78e2115686f8 (patch)
tree1aad0bb1d9c9c8626aa340c34e139db0e9ba38d1
parenta70c6fbead65165d1ae09e407c461d98d5894478 (diff)
downloadOrca-6c48c936fe38b4e302547d90757b78e2115686f8.tar.gz
Orca-6c48c936fe38b4e302547d90757b78e2115686f8.zip
Moved Bang to specials
-rw-r--r--README.md11
-rw-r--r--desktop/core/lib.js1
-rw-r--r--desktop/core/lib/_query.js43
-rw-r--r--desktop/core/lib/b.js9
-rw-r--r--desktop/core/lib/c.js14
-rw-r--r--desktop/core/lib/d.js24
-rw-r--r--desktop/core/lib/f.js4
-rw-r--r--desktop/core/lib/g.js13
-rw-r--r--desktop/core/lib/i.js7
-rw-r--r--desktop/core/lib/j.js5
-rw-r--r--desktop/core/lib/k.js4
-rw-r--r--desktop/core/lib/m.js4
-rw-r--r--desktop/core/lib/o.js12
-rw-r--r--desktop/core/lib/p.js3
-rw-r--r--desktop/core/lib/q.js34
-rw-r--r--desktop/core/lib/r.js2
-rw-r--r--desktop/core/lib/s.js2
-rw-r--r--desktop/core/lib/u.js7
-rw-r--r--desktop/core/lib/y.js4
-rw-r--r--examples/benchmark.pico14
20 files changed, 65 insertions, 152 deletions
diff --git a/README.md b/README.md
index e613d29..3094609 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,6 @@
### alpha functions
- `A`, **add**(math): Creates the result of the addition of east and west fns, southward.
-- `B`, **bang**(unique): The bang is used to trigger various fns, only lasts one cycle.
- `E`, **east**(direction): Moves eastward, or bangs.
- `F`, **if**(math): Bangs if east and west fns are equal, southward.
- `G`, **generator**(transport): Generates a direction fn from bang.
@@ -19,6 +18,7 @@
- `L`, **loop**(list): Loop a number of characters ahead.
- `M`, **modulo**(math): Creates the result of the modulo operation of east and west fns, southward.
- `N`, **north**(direction): Moves Northward, or bangs.
+- `P`, **push**(direction): Moves away, on bang.
- `R`, **raycast**(transport): Sends a bang to the nearest fn following the direction of the bang.
- `S`, **south**(direction): Moves southward, or bangs.
- `W`, **west**(direction): Moves westward, or bangs.
@@ -28,7 +28,7 @@
- `-`, **wire-h**(wire): Send data along the wire, horizontally.
- `|`, **wire-v**(wire): Send data along the wire, vertically.
-- `*`, **wire-n**(wire): Send data along the wire, entry or exit.
+- `~`, **wire-n**(wire): Send data along the wire, entry or exit.
- `+`, **wire-f**(wire): Send data along the wire, across an intersection.
### queries functions
@@ -40,8 +40,7 @@
### Functions(By Type)
- **maths**: `a` `f` `m` `y`.
-- **uniques**: `b`.
-- **directions**: `e` `n` `s` `w`.
+- **directions**: `e` `n` `p` `s` `w`.
- **transports**: `g` `r`.
- **stoppers**: `h`.
- **triggers**: `i` `k`.
@@ -81,7 +80,6 @@ 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
@@ -89,8 +87,7 @@ The idea is to build a synth/mini sequencer, here's some tasks I need to tackle
- [ ] Finish midi channel implementation
- [ ] Convert notes to midi values
- [ ] Implement a block comment syntax
-- [ ] Maybe caps should all be passive?
-- [ ] Maybe lowercase trigger only on bang?
+- [ ] Fix M
## Extras
diff --git a/desktop/core/lib.js b/desktop/core/lib.js
index 7191f77..fe9aba4 100644
--- a/desktop/core/lib.js
+++ b/desktop/core/lib.js
@@ -44,7 +44,6 @@ module.exports = {
special: {
'.': require('./lib/_null'),
'*': require('./lib/_bang'),
- ':': require('./lib/_query'),
'-': require('./lib/_wireh'),
'|': require('./lib/_wirev'),
'~': require('./lib/_wiren'),
diff --git a/desktop/core/lib/_query.js b/desktop/core/lib/_query.js
deleted file mode 100644
index fda25ff..0000000
--- a/desktop/core/lib/_query.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict'
-
-const FnBase = require('./_base')
-
-function FnQuery (pico, x, y, passive) {
- FnBase.call(this, pico, x, y, passive)
-
- this.name = 'query'
- this.glyph = ':'
- this.info = 'Call a function by name, freezes 3 characters eastward.'
-
- if (pico) {
- this.cmd = `${pico.glyphAt(this.x + 1, this.y)}${pico.glyphAt(this.x + 2, this.y)}${pico.glyphAt(this.x + 3, this.y)}`
- this.query = pico.lib.queries[this.cmd] ? new pico.lib.queries[this.cmd](pico, x + 3, y) : null
- }
-
- this.ports = [{ x: 0, y: 0, bang: true }, { x: 1, y: 0, input: true }, { x: 2, y: 0, input: true }, { x: 3, y: 0, input: true }]
-
- if (this.query) {
- for (const id in this.query.ports) {
- const port = this.query.ports[id]
- this.ports.push({ x: port.x + 3, y: port.y, bang: port.bang, output: port.output })
- }
- }
-
- this.haste = function () {
- pico.lock(this.x + 1, this.y)
- pico.lock(this.x + 2, this.y)
- pico.lock(this.x + 3, this.y)
- if (this.query) {
- this.query.haste()
- }
- }
-
- this.run = function () {
- 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()
- }
-}
-
-module.exports = FnQuery
diff --git a/desktop/core/lib/b.js b/desktop/core/lib/b.js
index 4002463..6812712 100644
--- a/desktop/core/lib/b.js
+++ b/desktop/core/lib/b.js
@@ -4,15 +4,6 @@ const FnBase = require('./_base')
function FnB (pico, x, y, passive) {
FnBase.call(this, pico, x, y, passive)
-
- this.type = 'unique'
- this.name = 'bang'
- this.glyph = 'b'
- this.info = 'The bang is used to trigger various fns, only lasts one cycle.'
-
- this.haste = function () {
- this.remove()
- }
}
module.exports = FnB
diff --git a/desktop/core/lib/c.js b/desktop/core/lib/c.js
index 30cc7de..d93fb3b 100644
--- a/desktop/core/lib/c.js
+++ b/desktop/core/lib/c.js
@@ -1,21 +1,9 @@
'use strict'
const FnBase = require('./_base')
+
function FnC (pico, x, y, passive) {
FnBase.call(this, 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.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 }
-
- pico.add(this.x + 1, this.y, this.west().glyph)
- }
}
module.exports = FnC
diff --git a/desktop/core/lib/d.js b/desktop/core/lib/d.js
index 83d9d28..6e175dd 100644
--- a/desktop/core/lib/d.js
+++ b/desktop/core/lib/d.js
@@ -4,30 +4,6 @@ const FnBase = require('./_base')
function FnD (pico, x, y, passive) {
FnBase.call(this, 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.operation = function () {
- if (this.north() && this.north().glyph !== 'n') {
- pico.add(this.x, this.y - 1, 'n')
- pico.lock(this.x, this.y - 1)
- }
- if (this.south() && this.south().glyph !== 'd') {
- pico.add(this.x, this.y + 1, 'd')
- pico.lock(this.x, this.y + 1)
- }
- if (this.west() && this.west().glyph !== 'w') {
- pico.add(this.x - 1, this.y, 'w')
- pico.lock(this.x - 1, this.y)
- }
- if (this.east() && this.east().glyph !== 'e') {
- pico.add(this.x + 1, this.y, 'e')
- pico.lock(this.x + 1, this.y)
- }
- }
}
module.exports = FnD
diff --git a/desktop/core/lib/f.js b/desktop/core/lib/f.js
index 358f5e1..70b079f 100644
--- a/desktop/core/lib/f.js
+++ b/desktop/core/lib/f.js
@@ -9,7 +9,9 @@ function FnF (pico, x, y, passive) {
this.name = 'if'
this.glyph = 'f'
this.info = 'Bangs if east and west fns are equal, 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/g.js b/desktop/core/lib/g.js
index 487da00..139b7e1 100644
--- a/desktop/core/lib/g.js
+++ b/desktop/core/lib/g.js
@@ -9,14 +9,17 @@ function FnG (pico, x, y, passive) {
this.name = 'generator'
this.glyph = 'g'
this.info = 'Generates a direction fn from bang.'
- this.ports = [{ x: 0, y: 0, bang: true }]
+ this.ports.push({ x: 0, y: 0, bang: true })
this.operation = function () {
- const origin = this.bang()
- if (!origin) { return }
+ const bang = this.bang()
+ const origin = bang || { x: this.x, y: this.y - 1 }
+
+ if (this.south()) { return }
+ if (!bang && pico.f % 2 !== 0) { return }
+
const vector = { x: this.x - origin.x, y: this.y - origin.y }
- const beam = { x: this.x + vector.x, y: this.y + vector.y }
- pico.add(beam.x, beam.y, vector.x === 1 ? 'e' : vector.x === -1 ? 'w' : vector.y === -1 ? 'n' : 's')
+ pico.add(this.x + vector.x, this.y + vector.y, vector.x === 1 ? 'E' : vector.x === -1 ? 'W' : vector.y === -1 ? 'N' : 'S')
}
}
diff --git a/desktop/core/lib/i.js b/desktop/core/lib/i.js
index 5207fa4..2c0db3d 100644
--- a/desktop/core/lib/i.js
+++ b/desktop/core/lib/i.js
@@ -9,7 +9,10 @@ function FnI (pico, x, y, passive) {
this.name = 'increment'
this.glyph = 'i'
this.info = 'Increments southward numeric fn on bang.'
- this.ports = [{ x: 0, y: 0, bang: true }, { x: 0, y: 1, output: true }, { x: 1, y: 0, input: true }, { x: -1, y: 0, input: true }]
+ this.ports.push({ x: 0, y: 0, bang: true })
+ this.ports.push({ x: 0, y: 1, output: true })
+ this.ports.push({ x: 1, y: 0, input: true })
+ this.ports.push({ x: -1, y: 0, input: true })
this.haste = function () {
pico.lock(this.x, this.y + 1)
@@ -18,8 +21,6 @@ function FnI (pico, x, y, passive) {
}
this.operation = function () {
- if (!this.bang()) { return }
-
const w = this.west()
const e = this.east()
const s = this.south()
diff --git a/desktop/core/lib/j.js b/desktop/core/lib/j.js
index 09054e6..3b4978f 100644
--- a/desktop/core/lib/j.js
+++ b/desktop/core/lib/j.js
@@ -5,12 +5,11 @@ const FnBase = require('./_base')
function FnJ (pico, x, y, passive) {
FnBase.call(this, pico, x, y, passive)
- // TODO
this.name = 'jump'
this.glyph = 'j'
this.info = 'Copies the northward fn, southwardly.'
-
- this.ports = [{ x: 0, y: -1, input: true }, { x: 0, y: 1, output: true }]
+ this.ports.push({ x: 0, y: -1, input: true })
+ this.ports.push({ x: 0, y: 1, output: true })
this.operation = function () {
const n = this.north()
diff --git a/desktop/core/lib/k.js b/desktop/core/lib/k.js
index 644a8c1..fea0917 100644
--- a/desktop/core/lib/k.js
+++ b/desktop/core/lib/k.js
@@ -9,10 +9,10 @@ function FnK (pico, x, y, passive) {
this.name = 'kill'
this.glyph = 'k'
this.info = 'Kills southward fns, on bang.'
- this.ports = [{ x: 0, y: 0, bang: true }, { x: 0, y: 1, output: true }]
+ this.ports.push({ x: 0, y: 0, bang: true })
+ this.ports.push({ x: 0, y: 1, output: true })
this.operation = function () {
- if (!this.bang()) { return }
pico.remove(this.x, this.y + 1)
}
}
diff --git a/desktop/core/lib/m.js b/desktop/core/lib/m.js
index ed1461a..9d3cf9f 100644
--- a/desktop/core/lib/m.js
+++ b/desktop/core/lib/m.js
@@ -9,7 +9,9 @@ function FnM (pico, x, y, passive) {
this.name = 'modulo'
this.glyph = 'm'
this.info = 'Creates the result of the modulo operation 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/o.js b/desktop/core/lib/o.js
index 52a7e64..b484649 100644
--- a/desktop/core/lib/o.js
+++ b/desktop/core/lib/o.js
@@ -4,18 +4,6 @@ const FnBase = require('./_base')
function FnO (pico, x, y, passive) {
FnBase.call(this, pico, x, y, passive)
-
- this.name = 'odd'
- this.glyph = 'o'
- this.info = '[FIX]Adds 0 southward, transforms into Q on bang.'
- this.ports = [{ x: 0, y: 0, bang: true }, { x: 0, y: -1 }]
-
- this.operation = function () {
- if (this.bang()) {
- this.replace('q')
- }
- pico.add(this.x, this.y + 1, '0')
- }
}
module.exports = FnO
diff --git a/desktop/core/lib/p.js b/desktop/core/lib/p.js
index d3a67c7..e018c6b 100644
--- a/desktop/core/lib/p.js
+++ b/desktop/core/lib/p.js
@@ -5,10 +5,11 @@ const FnBase = require('./_base')
function FnP (pico, x, y, passive) {
FnBase.call(this, pico, x, y, passive)
+ this.type = 'direction'
this.name = 'push'
this.glyph = 'p'
this.info = 'Moves away, on bang.'
- this.ports = [{ x: 0, y: 0, bang: true }]
+ this.ports.push({ x: 0, y: 0, bang: true })
this.operation = function () {
const origin = this.bang()
diff --git a/desktop/core/lib/q.js b/desktop/core/lib/q.js
index 4686440..5324dc3 100644
--- a/desktop/core/lib/q.js
+++ b/desktop/core/lib/q.js
@@ -5,16 +5,32 @@ const FnBase = require('./_base')
function FnQ (pico, x, y, passive) {
FnBase.call(this, pico, x, y, passive)
- this.name = 'even'
- this.glyph = 'q'
- this.info = '[FIX]Adds 1 southward, transforms into O on bang.'
- this.ports = [{ x: 0, y: 0, bang: true }, { x: 0, y: 1, output: true }]
-
- this.operation = function () {
- if (this.bang()) {
- this.replace('o')
+ this.name = 'query'
+ this.glyph = ':'
+ this.info = 'Call a function by name, freezes 3 characters eastward.'
+
+ if (pico) {
+ this.cmd = `${pico.glyphAt(this.x + 1, this.y)}${pico.glyphAt(this.x + 2, this.y)}${pico.glyphAt(this.x + 3, this.y)}`.toLowerCase()
+ this.query = pico.lib.queries[this.cmd] ? new pico.lib.queries[this.cmd](pico, x + 3, y) : null
+ }
+
+ this.ports.push({ x: 1, y: 0, input: true })
+ this.ports.push({ x: 2, y: 0, input: true })
+ this.ports.push({ x: 3, y: 0, input: true })
+
+ this.haste = function () {
+ pico.lock(this.x + 1, this.y)
+ pico.lock(this.x + 2, this.y)
+ pico.lock(this.x + 3, this.y)
+ if (this.query) {
+ this.query.haste()
}
- pico.add(this.x, this.y + 1, '1')
+ }
+
+ this.run = function () {
+ 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/r.js b/desktop/core/lib/r.js
index c6eed2e..8284c73 100644
--- a/desktop/core/lib/r.js
+++ b/desktop/core/lib/r.js
@@ -10,8 +10,6 @@ function FnR (pico, x, y, passive) {
this.glyph = 'r'
this.info = 'Sends a bang to the nearest fn following the direction of the bang.'
- this.ports = [{ x: 0, y: 0, bang: true }]
-
this.operation = function () {
const origin = this.bang()
if (!origin) { return }
diff --git a/desktop/core/lib/s.js b/desktop/core/lib/s.js
index 94a5327..4e05e11 100644
--- a/desktop/core/lib/s.js
+++ b/desktop/core/lib/s.js
@@ -11,7 +11,7 @@ function FnS (pico, x, y, passive) {
this.info = 'Moves southward, or bangs.'
this.haste = function () {
- // if (this.signal()) { 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/u.js b/desktop/core/lib/u.js
index c36d198..161ed2d 100644
--- a/desktop/core/lib/u.js
+++ b/desktop/core/lib/u.js
@@ -4,13 +4,6 @@ const FnBase = require('./_base')
function FnU (pico, x, y, passive) {
FnBase.call(this, pico, x, y, passive)
-
- this.name = 'idle'
- this.glyph = 'u'
- this.info = '[TODO]Nothing..'
-
- this.operation = function () {
- }
}
module.exports = FnU
diff --git a/desktop/core/lib/y.js b/desktop/core/lib/y.js
index 9da635e..31c768c 100644
--- a/desktop/core/lib/y.js
+++ b/desktop/core/lib/y.js
@@ -9,7 +9,9 @@ function FnY (pico, x, y, passive) {
this.name = 'type'
this.glyph = 'y'
this.info = 'Compares the type(num/alpha/special) of westward and eastward fns, and return 1 or 0 southward.'
- this.ports = [{ x: -1, y: 0, input: true }, { x: 1, y: 0, input: true }, { x: 0, y: 1, output: true }]
+ this.ports.push({ x: -1, y: 0, input: true })
+ this.ports.push({ x: 1, y: 0, input: true })
+ this.ports.push({ x: 0, y: 1, output: true })
this.haste = function () {
pico.lock(this.x, this.y + 1)
diff --git a/examples/benchmark.pico b/examples/benchmark.pico
index 0cc1a14..217633a 100644
--- a/examples/benchmark.pico
+++ b/examples/benchmark.pico
@@ -1,22 +1,22 @@
...................................................................
-.................a.......m.......f.......y.........................
+.................A.......M.......F.......Y.........................
...................................................................
...................................................................
-................2a......2m......2f......2y.........................
+................2A......2M......2F......2Y.........................
...................................................................
...................................................................
-.................a2......m2......f2......y2........................
+.................A2......M2......F2......Y2........................
...................................................................
...................................................................
-................2a2.....2m2.....2f2.....2y2........................
+................2A2.....2M2.....2F2.....2Y2........................
...................................................................
...................................................................
-................2a3.....2m3.....2f3.....2y3........................
+................2A3.....2M3.....2F3.....2Y3........................
...................................................................
...................................................................
-................2ak.....9mk.....2fk.....2yk........................
+................2AK.....9MK.....2FK.....2YK........................
...................................................................
...................................................................
-................ka2.....km6.....kfk.....kyk........................
+................KA2.....KM6.....KFK.....KYK........................
...................................................................
................................................................... \ No newline at end of file