git @ Cat's Eye Technologies Braktif / caceda5
Braktif as you've never... (I just copied what I did in Circute.) catseye 7 years ago
4 changed file(s) with 880 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 <!DOCTYPE html>
1 <head>
2 <meta charset="utf-8">
3 <title>Braktif Demo</title>
4 </head>
5 <body>
6
7 <h1>Braktif Demo</h1>
8
9 <textarea id="input" rows="10" cols="50">
10 *
11 &lt;&lt;*[--]*
12 000000000000000000 *[----- --]
13 -----------------d-i-- --------
14 </textarea>
15
16 <pre id="output" style="border: 1px solid blue">
17 </pre>
18
19 <button id="start">Start</button>
20 <button id="stop">Stop</button>
21 <button id="step">Step</button>
22 <button id="load">Load</button>
23 Speed: <input id="speed" type="range" min="0" max="200" value="0" />
24
25 </body>
26 <script src="yoob/controller.js"></script>
27 <script src="yoob/playfield.js"></script>
28 <script src="../script/braktif.js"></script>
29 <script>
30 var output = document.getElementById('output');
31 var c = new yoob.Controller();
32 var pf;
33
34 c.load = function(text) {
35 pf = new yoob.Playfield();
36 pf.setDefault('Space');
37 pf.load(0, 0, text, loadMapper);
38 output.innerHTML = pf.dump(dumpMapper);
39 };
40
41 c.step = function() {
42 var newPf = new yoob.Playfield();
43 newPf.setDefault('Space');
44 evolve_playfield(pf, newPf);
45 pf = newPf;
46 output.innerHTML = pf.dump(dumpMapper);
47 };
48
49 c.connect({
50 'start': 'start',
51 'stop': 'stop',
52 'step': 'step',
53 'load': 'load',
54 'source': 'input',
55 'speed': 'speed'
56 });
57 </script>
0 /*
1 * This file is part of yoob.js version 0.2-PRE
2 * This file is in the public domain. See http://unlicense.org/ for details.
3 */
4 if (window.yoob === undefined) yoob = {};
5
6 /*
7 * A controller for executing(/animating/evolving) states
8 * (such as esolang program states or cellular automaton
9 * configurations.)
10 *
11 * Can be connected to a UI in the DOM.
12 *
13 * Subclass this and override the following methods:
14 * - make it evolve the state by one tick in the step() method
15 * - make it load the state from a multiline string in the load() method
16 */
17 yoob.Controller = function() {
18 this.intervalId = undefined;
19 this.delay = 100;
20 this.source = undefined;
21 this.speed = undefined;
22
23 var makeOnClick = function(controller, key) {
24 if (controller['click_' + key] !== undefined)
25 key = 'click_' + key;
26 return function(e) { controller[key](); }
27 };
28
29 /*
30 * Single argument is a dictionary (object) where the keys
31 * are the actions a controller can undertake, and the values
32 * are either DOM elements or strings; if strings, DOM elements
33 * with those ids will be obtained from the document and used.
34 */
35 this.connect = function(dict) {
36 var self = this;
37 var keys = ["start", "stop", "step", "load"];
38 for (var i in keys) {
39 var key = keys[i];
40 var value = dict[key];
41 if (typeof value === 'string') {
42 value = document.getElementById(value);
43 }
44 if (value !== undefined) {
45 value.onclick = makeOnClick(this, key);
46 }
47 }
48
49 var source = dict.source;
50 if (typeof source === 'string') {
51 source = document.getElementById(source);
52 }
53 if (source !== undefined) {
54 this.source = source;
55 }
56
57 var speed = dict.speed;
58 if (typeof speed === 'string') {
59 speed = document.getElementById(speed);
60 }
61 if (speed !== undefined) {
62 this.speed = speed;
63 speed.value = self.delay;
64 speed.onchange = function(e) {
65 self.delay = speed.value;
66 if (self.intervalId !== undefined) {
67 self.stop();
68 self.start();
69 }
70 }
71 }
72 };
73
74 this.click_step = function(e) {
75 this.stop();
76 this.step();
77 };
78
79 this.step = function() {
80 alert("step() NotImplementedError");
81 };
82
83 this.click_load = function(e) {
84 this.stop();
85 this.load(this.source.value);
86 };
87
88 this.load = function(text) {
89 alert("load() NotImplementedError");
90 };
91
92 this.start = function() {
93 if (this.intervalId !== undefined)
94 return;
95 this.step();
96 var self = this;
97 this.intervalId = setInterval(function() { self.step(); }, this.delay);
98 };
99
100 this.stop = function() {
101 if (this.intervalId === undefined)
102 return;
103 clearInterval(this.intervalId);
104 this.intervalId = undefined;
105 };
106 };
0 /*
1 * This file is part of yoob.js version 0.2
2 * This file is in the public domain. See http://unlicense.org/ for details.
3 */
4 if (window.yoob === undefined) yoob = {};
5
6 /*
7 * A two-dimensional Cartesian grid of values.
8 */
9 yoob.Playfield = function() {
10 this._store = {};
11 this.minX = undefined;
12 this.minY = undefined;
13 this.maxX = undefined;
14 this.maxY = undefined;
15 this._default = undefined;
16
17 /*
18 * Set the default value for this Playfield. This
19 * value is returned by get() for any cell that was
20 * never written to, or had `undefined` put() into it.
21 */
22 this.setDefault = function(v) {
23 this._default = v;
24 };
25
26 /*
27 * Obtain the value at (x, y). The default value will
28 * be returned if the cell was never written to.
29 */
30 this.get = function(x, y) {
31 var v = this._store[x+','+y];
32 if (v === undefined) return this._default;
33 return v;
34 };
35
36 /*
37 * Write a new value into (x, y). Note that writing
38 * `undefined` into a cell has the semantics of deleting
39 * the value at that cell; a subsequent get() for that
40 * location will return this Playfield's default value.
41 */
42 this.put = function(x, y, value) {
43 var key = x+','+y;
44 if (value === undefined || value === this._default) {
45 delete this._store[key];
46 return;
47 }
48 if (this.minX === undefined || x < this.minX) this.minX = x;
49 if (this.maxX === undefined || x > this.maxX) this.maxX = x;
50 if (this.minY === undefined || y < this.minY) this.minY = y;
51 if (this.maxY === undefined || y > this.maxY) this.maxY = y;
52 this._store[key] = value;
53 };
54
55 /*
56 * Like put(), but does not update the playfield bounds. Do
57 * this if you must do a batch of put()s in a more efficient
58 * manner; after doing so, call recalculateBounds().
59 */
60 this.putDirty = function(x, y, value) {
61 var key = x+','+y;
62 if (value === undefined || value === this._default) {
63 delete this._store[key];
64 return;
65 }
66 this._store[key] = value;
67 };
68
69 /*
70 * Recalculate the bounds (min/max X/Y) which are tracked
71 * internally to support methods like foreach(). This is
72 * not needed *unless* you've used putDirty() at some point.
73 * (In which case, call this immediately after your batch
74 * of putDirty()s.)
75 */
76 this.recalculateBounds = function() {
77 this.minX = undefined;
78 this.minY = undefined;
79 this.maxX = undefined;
80 this.maxX = undefined;
81
82 for (var cell in this._store) {
83 var pos = cell.split(',');
84 var x = parseInt(pos[0], 10);
85 var y = parseInt(pos[1], 10);
86 if (this.minX === undefined || x < this.minX) this.minX = x;
87 if (this.maxX === undefined || x > this.maxX) this.maxX = x;
88 if (this.minY === undefined || y < this.minY) this.minY = y;
89 if (this.maxY === undefined || y > this.maxY) this.maxY = y;
90 }
91 };
92
93 /*
94 * Clear the contents of this Playfield.
95 */
96 this.clear = function() {
97 this._store = {};
98 this.minX = undefined;
99 this.minY = undefined;
100 this.maxX = undefined;
101 this.maxX = undefined;
102 };
103
104 /*
105 * Load a string into this Playfield.
106 * The string may be multiline, with newline (ASCII 10)
107 * characters delimiting lines. ASCII 13 is ignored.
108 *
109 * If transformer is given, it should be a one-argument
110 * function which accepts a character and returns the
111 * object you wish to write into the playfield upon reading
112 * that character.
113 */
114 this.load = function(x, y, string, transformer) {
115 var lx = x;
116 var ly = y;
117 if (transformer === undefined) {
118 transformer = function(c) {
119 if (c === ' ') {
120 return undefined;
121 } else {
122 return c;
123 }
124 }
125 }
126 for (var i = 0; i < string.length; i++) {
127 var c = string.charAt(i);
128 if (c === '\n') {
129 lx = x;
130 ly++;
131 } else if (c === '\r') {
132 } else {
133 this.putDirty(lx, ly, transformer(c));
134 lx++;
135 }
136 }
137 this.recalculateBounds();
138 };
139
140 /*
141 * Convert this Playfield to a multi-line string. Each row
142 * is a line, delimited with a newline (ASCII 10).
143 *
144 * If transformer is given, it should be a one-argument
145 * function which accepts a playfield element and returns a
146 * character (or string) you wish to place in the resulting
147 * string for that element.
148 */
149 this.dump = function(transformer) {
150 var text = "";
151 if (transformer === undefined) {
152 transformer = function(c) { return c; }
153 }
154 for (var y = this.minY; y <= this.maxY; y++) {
155 var row = "";
156 for (var x = this.minX; x <= this.maxX; x++) {
157 row += transformer(this.get(x, y));
158 }
159 text += row + "\n";
160 }
161 return text;
162 };
163
164 /*
165 * Iterate over every defined cell in the Playfield.
166 * fun is a callback which takes three parameters:
167 * x, y, and value. If this callback returns a value,
168 * it is written into the Playfield at that position.
169 * This function ensures a particular order.
170 */
171 this.foreach = function(fun) {
172 for (var y = this.minY; y <= this.maxY; y++) {
173 for (var x = this.minX; x <= this.maxX; x++) {
174 var key = x+','+y;
175 var value = this._store[key];
176 if (value === undefined)
177 continue;
178 var result = fun(x, y, value);
179 if (result !== undefined) {
180 if (result === ' ') {
181 result = undefined;
182 }
183 this.put(x, y, result);
184 }
185 }
186 }
187 };
188
189 /*
190 * Analogous to (monoid) map in functional languages,
191 * iterate over this Playfield, transform each value using
192 * a supplied function, and write the transformed value into
193 * a destination Playfield.
194 *
195 * Supplied function should take a Playfield (this Playfield),
196 * x, and y, and return a value.
197 *
198 * The map source may extend beyond the internal bounds of
199 * the Playfield, by giving the min/max Dx/Dy arguments
200 * (which work like margin offsets.)
201 *
202 * Useful for evolving a cellular automaton playfield. In this
203 * case, min/max Dx/Dy should be computed from the neighbourhood.
204 */
205 this.map = function(destPf, fun, minDx, minDy, maxDx, maxDy) {
206 if (minDx === undefined) minDx = 0;
207 if (minDy === undefined) minDy = 0;
208 if (maxDx === undefined) maxDx = 0;
209 if (maxDy === undefined) maxDy = 0;
210 for (var y = this.minY + minDy; y <= this.maxY + maxDy; y++) {
211 for (var x = this.minX + minDx; x <= this.maxX + maxDx; x++) {
212 destPf.putDirty(x, y, fun(pf, x, y));
213 }
214 }
215 destPf.recalculateBounds();
216 };
217
218 /*
219 * Draws elements of the Playfield in a drawing context.
220 * x and y are canvas coordinates, and width and height
221 * are canvas units of measure.
222 * The default implementation just renders them as text,
223 * in black.
224 * Override if you wish to draw them differently.
225 */
226 this.drawElement = function(ctx, x, y, cellWidth, cellHeight, elem) {
227 ctx.fillStyle = "black";
228 ctx.fillText(elem.toString(), x, y);
229 };
230
231 /*
232 * Draws the Playfield in a drawing context.
233 * cellWidth and cellHeight are canvas units of measure for each cell.
234 */
235 this.drawContext = function(ctx, offsetX, offsetY, cellWidth, cellHeight) {
236 var me = this;
237 this.foreach(function (x, y, elem) {
238 me.drawElement(ctx, offsetX + x * cellWidth, offsetY + y * cellHeight,
239 cellWidth, cellHeight, elem);
240 });
241 };
242
243 this.getExtentX = function() {
244 if (this.maxX === undefined || this.minX === undefined) {
245 return 0;
246 } else {
247 return this.maxX - this.minX + 1;
248 }
249 };
250
251 this.getExtentY = function() {
252 if (this.maxY === undefined || this.minY === undefined) {
253 return 0;
254 } else {
255 return this.maxY - this.minY + 1;
256 }
257 };
258
259 /*
260 * Draws the Playfield, and a set of Cursors, on a canvas element.
261 * Resizes the canvas to the needed dimensions.
262 * cellWidth and cellHeight are canvas units of measure for each cell.
263 */
264 this.drawCanvas = function(canvas, cellWidth, cellHeight, cursors) {
265 var ctx = canvas.getContext('2d');
266
267 var width = this.getExtentX();
268 var height = this.getExtentY();
269
270 if (cellWidth === undefined) {
271 ctx.textBaseline = "top";
272 ctx.font = cellHeight + "px monospace";
273 cellWidth = ctx.measureText("@").width;
274 }
275
276 canvas.width = width * cellWidth;
277 canvas.height = height * cellHeight;
278
279 ctx.clearRect(0, 0, canvas.width, canvas.height);
280
281 ctx.textBaseline = "top";
282 ctx.font = cellHeight + "px monospace";
283
284 var offsetX = this.minX * cellWidth * -1;
285 var offsetY = this.minY * cellHeight * -1;
286
287 for (var i = 0; i < cursors.length; i++) {
288 cursors[i].drawContext(
289 ctx,
290 cursors[i].x * cellWidth, cursors[i].y * cellHeight,
291 cellWidth, cellHeight
292 );
293 }
294
295 this.drawContext(ctx, offsetX, offsetY, cellWidth, cellHeight);
296 };
297
298 };
0 /*
1 * This file was AUTOMATICALLY generated from an ALPACA description.
2 * EDIT AT YOUR OWN RISK!
3 */
4
5
6 function in_nbhd_pred(pf, x, y, pred, nbhd) {
7 var count = 0;
8 for (var i = 0; i < nbhd.length; i++) {
9 if (pred(pf.get(x+nbhd[i][0], y+nbhd[i][1]))) {
10 count++;
11 }
12 }
13 return count;
14 }
15
16 function in_nbhd_eq(pf, x, y, stateId, nbhd) {
17 return in_nbhd_pred(pf, x, y, function(x) { return x === stateId; }, nbhd);
18 }
19
20 function evolve_playfield(pf, new_pf) {
21 pf.map(new_pf, evalState, -1, -1, 1, 1);
22 }
23 function loadMapper(c) {
24 if (c === '!') return 'SkipStart';
25 if (c === ' ') return 'Space';
26 if (c === '%') return 'SkipStop';
27 if (c === '*') return 'FlipCmd';
28 if (c === '-') return 'Bus';
29 if (c === '1') return 'OnBit';
30 if (c === '0') return 'OffBit';
31 if (c === '<') return 'LeftCmd';
32 if (c === '>') return 'RightCmd';
33 if (c === 'C') return 'ContReply';
34 if (c === 'F') return 'FlipSig';
35 if (c === 'I') return 'InstrMark';
36 if (c === 'L') return 'LeftSig';
37 if (c === 'Q') return 'QuerySig';
38 if (c === 'S') return 'SkipReply';
39 if (c === 'R') return 'RightSig';
40 if (c === 'W') return 'WakeMark';
41 if (c === '[') return 'WhileCmd';
42 if (c === ']') return 'WendCmd';
43 if (c === 'c') return 'ContTool';
44 if (c === 'd') return 'DataPtr';
45 if (c === 'f') return 'FlipTool';
46 if (c === 'i') return 'InstrPtr';
47 if (c === 'l') return 'LeftTool';
48 if (c === 's') return 'SkipTool';
49 if (c === 'r') return 'RightTool';
50 if (c === '{') return 'SkipBack';
51 if (c === '}') return 'SkipFore';
52 };
53 function dumpMapper(s) {
54 if (s === 'SkipStart') return '!';
55 if (s === 'Space') return ' ';
56 if (s === 'SkipStop') return '%';
57 if (s === 'FlipCmd') return '*';
58 if (s === 'Bus') return '-';
59 if (s === 'OnBit') return '1';
60 if (s === 'OffBit') return '0';
61 if (s === 'LeftCmd') return '<';
62 if (s === 'RightCmd') return '>';
63 if (s === 'ContReply') return 'C';
64 if (s === 'FlipSig') return 'F';
65 if (s === 'InstrMark') return 'I';
66 if (s === 'LeftSig') return 'L';
67 if (s === 'QuerySig') return 'Q';
68 if (s === 'SkipReply') return 'S';
69 if (s === 'RightSig') return 'R';
70 if (s === 'WakeMark') return 'W';
71 if (s === 'WhileCmd') return '[';
72 if (s === 'WendCmd') return ']';
73 if (s === 'ContTool') return 'c';
74 if (s === 'DataPtr') return 'd';
75 if (s === 'FlipTool') return 'f';
76 if (s === 'InstrPtr') return 'i';
77 if (s === 'LeftTool') return 'l';
78 if (s === 'SkipTool') return 's';
79 if (s === 'RightTool') return 'r';
80 if (s === 'SkipBack') return '{';
81 if (s === 'SkipFore') return '}';
82 };
83 function is_Reply(st) {
84 return (st === 'SkipReply') || (st === 'ContReply') || 0;
85 }
86
87 function is_Signal(st) {
88 return (st === 'RightSig') || (st === 'FlipSig') || (st === 'LeftSig') || (st === 'QuerySig') || 0;
89 }
90
91 function evalClass_Signal(pf, x, y) {
92 var id;
93 if (true) {
94 return 'Bus';
95 }
96 return undefined;
97 }
98
99 function evalClass_Reply(pf, x, y) {
100 var id;
101 if (true) {
102 return 'Bus';
103 }
104 return undefined;
105 }
106
107 function eval_Space(pf, x, y) {
108 var id;
109 if ((((pf.get(x+0,y+-1)==='WakeMark')&&(pf.get(x+1,y+-1)==='WendCmd'))||(pf.get(x+1,y+0)==='SkipBack'))) {
110 return 'SkipBack';
111 }
112 if (((pf.get(x+-1,y+-1)==='SkipReply')&&(pf.get(x+0,y+-1)==='InstrMark'))) {
113 return 'SkipStart';
114 }
115 if (((pf.get(x+-1,y+1)==='SkipStart')||(pf.get(x+-1,y+0)==='SkipFore'))) {
116 return 'SkipFore';
117 }
118 return 'Space';
119 }
120
121 function eval_Bus(pf, x, y) {
122 var id;
123 if (is_Signal(pf.get(x+1,y+0))) {
124 return pf.get(x+1,y+0);
125 }
126 if (is_Signal(pf.get(x+1,y+-1))) {
127 return pf.get(x+1,y+-1);
128 }
129 if (is_Signal(pf.get(x+1,y+1))) {
130 return pf.get(x+1,y+1);
131 }
132 if (is_Reply(pf.get(x+-1,y+0))) {
133 return pf.get(x+-1,y+0);
134 }
135 if (is_Reply(pf.get(x+-1,y+-1))) {
136 return pf.get(x+-1,y+-1);
137 }
138 if (is_Reply(pf.get(x+-1,y+1))) {
139 return pf.get(x+-1,y+1);
140 }
141 if (((pf.get(x+1,y+0)==='LeftTool')||(pf.get(x+-1,y+0)==='RightTool'))) {
142 return 'ContTool';
143 }
144 if ((pf.get(x+-1,y+0)==='ContTool')) {
145 return 'ContReply';
146 }
147 if ((pf.get(x+-1,y+0)==='SkipTool')) {
148 return 'SkipReply';
149 }
150 if (((pf.get(x+1,y+0)==='InstrPtr')&&(pf.get(x+1,y+-1)==='LeftCmd'))) {
151 return 'LeftSig';
152 }
153 if (((pf.get(x+1,y+0)==='InstrPtr')&&(pf.get(x+1,y+-1)==='RightCmd'))) {
154 return 'RightSig';
155 }
156 if (((pf.get(x+1,y+0)==='InstrPtr')&&(pf.get(x+1,y+-1)==='FlipCmd'))) {
157 return 'FlipSig';
158 }
159 if (((pf.get(x+1,y+0)==='InstrPtr')&&(pf.get(x+1,y+-1)==='WhileCmd'))) {
160 return 'QuerySig';
161 }
162 if ((((pf.get(x+-1,y+0)==='WakeMark')||(pf.get(x+-1,y+1)==='WakeMark'))||(pf.get(x+-1,y+-1)==='Wakemark'))) {
163 return 'InstrPtr';
164 }
165 if (((pf.get(x+-1,y+0)==='InstrPtr')&&(pf.get(x+-1,y+-1)==='Space'))) {
166 return 'InstrPtr';
167 }
168 if ((pf.get(x+1,y+0)==='SkipBack')) {
169 return 'InstrPtr';
170 }
171 if ((pf.get(x+-1,y+0)==='SkipFore')) {
172 return 'SkipStop';
173 }
174 if ((pf.get(x+-1,y+0)==='SkipStop')) {
175 return 'InstrPtr';
176 }
177 return 'Bus';
178 }
179
180 function eval_LeftSig(pf, x, y) {
181 var id;
182 id = evalClass_Signal(pf, x, y);
183 if (id !== undefined) return id;
184 return 'LeftSig';
185 }
186
187 function eval_RightSig(pf, x, y) {
188 var id;
189 id = evalClass_Signal(pf, x, y);
190 if (id !== undefined) return id;
191 return 'RightSig';
192 }
193
194 function eval_FlipSig(pf, x, y) {
195 var id;
196 id = evalClass_Signal(pf, x, y);
197 if (id !== undefined) return id;
198 return 'FlipSig';
199 }
200
201 function eval_QuerySig(pf, x, y) {
202 var id;
203 id = evalClass_Signal(pf, x, y);
204 if (id !== undefined) return id;
205 return 'QuerySig';
206 }
207
208 function eval_ContReply(pf, x, y) {
209 var id;
210 id = evalClass_Reply(pf, x, y);
211 if (id !== undefined) return id;
212 return 'ContReply';
213 }
214
215 function eval_SkipReply(pf, x, y) {
216 var id;
217 id = evalClass_Reply(pf, x, y);
218 if (id !== undefined) return id;
219 return 'SkipReply';
220 }
221
222 function eval_DataPtr(pf, x, y) {
223 var id;
224 if ((pf.get(x+1,y+0)==='FlipSig')) {
225 return 'FlipTool';
226 }
227 if ((pf.get(x+1,y+0)==='LeftSig')) {
228 return 'LeftTool';
229 }
230 if ((pf.get(x+1,y+0)==='RightSig')) {
231 return 'RightTool';
232 }
233 if (((pf.get(x+1,y+0)==='QuerySig')&&(pf.get(x+0,y+-1)==='OffBit'))) {
234 return 'SkipTool';
235 }
236 if (((pf.get(x+1,y+0)==='QuerySig')&&(pf.get(x+0,y+-1)==='OnBit'))) {
237 return 'ContTool';
238 }
239 return 'DataPtr';
240 }
241
242 function eval_FlipTool(pf, x, y) {
243 var id;
244 if (true) {
245 return 'ContTool';
246 }
247 return 'FlipTool';
248 }
249
250 function eval_LeftTool(pf, x, y) {
251 var id;
252 if (true) {
253 return 'Bus';
254 }
255 return 'LeftTool';
256 }
257
258 function eval_RightTool(pf, x, y) {
259 var id;
260 if (true) {
261 return 'Bus';
262 }
263 return 'RightTool';
264 }
265
266 function eval_ContTool(pf, x, y) {
267 var id;
268 if (true) {
269 return 'DataPtr';
270 }
271 return 'ContTool';
272 }
273
274 function eval_SkipTool(pf, x, y) {
275 var id;
276 if (true) {
277 return 'DataPtr';
278 }
279 return 'SkipTool';
280 }
281
282 function eval_OnBit(pf, x, y) {
283 var id;
284 if ((pf.get(x+0,y+1)==='FlipTool')) {
285 return 'OffBit';
286 }
287 return 'OnBit';
288 }
289
290 function eval_OffBit(pf, x, y) {
291 var id;
292 if ((pf.get(x+0,y+1)==='FlipTool')) {
293 return 'OnBit';
294 }
295 return 'OffBit';
296 }
297
298 function eval_InstrPtr(pf, x, y) {
299 var id;
300 if ((pf.get(x+0,y+-1)==='Space')) {
301 return 'Bus';
302 }
303 if (true) {
304 return 'InstrMark';
305 }
306 return 'InstrPtr';
307 }
308
309 function eval_InstrMark(pf, x, y) {
310 var id;
311 if ((pf.get(x+-1,y+0)==='ContReply')) {
312 return 'WakeMark';
313 }
314 if ((pf.get(x+-1,y+0)==='SkipReply')) {
315 return 'Bus';
316 }
317 return 'InstrMark';
318 }
319
320 function eval_WakeMark(pf, x, y) {
321 var id;
322 if (true) {
323 return 'Bus';
324 }
325 return 'WakeMark';
326 }
327
328 function eval_SkipStart(pf, x, y) {
329 var id;
330 if (true) {
331 return 'Space';
332 }
333 return 'SkipStart';
334 }
335
336 function eval_SkipStop(pf, x, y) {
337 var id;
338 if (true) {
339 return 'Bus';
340 }
341 return 'SkipStop';
342 }
343
344 function eval_SkipFore(pf, x, y) {
345 var id;
346 if (true) {
347 return 'Space';
348 }
349 return 'SkipFore';
350 }
351
352 function eval_SkipBack(pf, x, y) {
353 var id;
354 if (true) {
355 return 'Space';
356 }
357 return 'SkipBack';
358 }
359
360 function eval_FlipCmd(pf, x, y) {
361 var id;
362 return 'FlipCmd';
363 }
364
365 function eval_LeftCmd(pf, x, y) {
366 var id;
367 return 'LeftCmd';
368 }
369
370 function eval_RightCmd(pf, x, y) {
371 var id;
372 return 'RightCmd';
373 }
374
375 function eval_WhileCmd(pf, x, y) {
376 var id;
377 return 'WhileCmd';
378 }
379
380 function eval_WendCmd(pf, x, y) {
381 var id;
382 return 'WendCmd';
383 }
384
385 function evalState(pf, x, y) {
386 var stateId = pf.get(x, y);
387 if (stateId === 'Space') return eval_Space(pf, x, y);
388 if (stateId === 'Bus') return eval_Bus(pf, x, y);
389 if (stateId === 'LeftSig') return eval_LeftSig(pf, x, y);
390 if (stateId === 'RightSig') return eval_RightSig(pf, x, y);
391 if (stateId === 'FlipSig') return eval_FlipSig(pf, x, y);
392 if (stateId === 'QuerySig') return eval_QuerySig(pf, x, y);
393 if (stateId === 'ContReply') return eval_ContReply(pf, x, y);
394 if (stateId === 'SkipReply') return eval_SkipReply(pf, x, y);
395 if (stateId === 'DataPtr') return eval_DataPtr(pf, x, y);
396 if (stateId === 'FlipTool') return eval_FlipTool(pf, x, y);
397 if (stateId === 'LeftTool') return eval_LeftTool(pf, x, y);
398 if (stateId === 'RightTool') return eval_RightTool(pf, x, y);
399 if (stateId === 'ContTool') return eval_ContTool(pf, x, y);
400 if (stateId === 'SkipTool') return eval_SkipTool(pf, x, y);
401 if (stateId === 'OnBit') return eval_OnBit(pf, x, y);
402 if (stateId === 'OffBit') return eval_OffBit(pf, x, y);
403 if (stateId === 'InstrPtr') return eval_InstrPtr(pf, x, y);
404 if (stateId === 'InstrMark') return eval_InstrMark(pf, x, y);
405 if (stateId === 'WakeMark') return eval_WakeMark(pf, x, y);
406 if (stateId === 'SkipStart') return eval_SkipStart(pf, x, y);
407 if (stateId === 'SkipStop') return eval_SkipStop(pf, x, y);
408 if (stateId === 'SkipFore') return eval_SkipFore(pf, x, y);
409 if (stateId === 'SkipBack') return eval_SkipBack(pf, x, y);
410 if (stateId === 'FlipCmd') return eval_FlipCmd(pf, x, y);
411 if (stateId === 'LeftCmd') return eval_LeftCmd(pf, x, y);
412 if (stateId === 'RightCmd') return eval_RightCmd(pf, x, y);
413 if (stateId === 'WhileCmd') return eval_WhileCmd(pf, x, y);
414 if (stateId === 'WendCmd') return eval_WendCmd(pf, x, y);
415 }