about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-25 01:41:40 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-25 01:41:40 -0800
commitbee53b4b169feab631658b5450328a317779831a (patch)
treeedcbafff1d75e1467586540f5b216ba093e67e6c
parenta5fb9d1554bc04fcd0480cf0634855942e045d7b (diff)
downloadmu-bee53b4b169feab631658b5450328a317779831a.tar.gz
619 - chessboard now working right
2 bugs found:
  a) Have to slurp the newlines.
  b) Have to clear the line-buffer at the start of each line.
-rw-r--r--chessboard.mu20
-rw-r--r--mu.arc13
2 files changed, 28 insertions, 5 deletions
diff --git a/chessboard.mu b/chessboard.mu
index e976e3ab..9479ab24 100644
--- a/chessboard.mu
+++ b/chessboard.mu
@@ -107,6 +107,7 @@
   (expect-stdin stdin:channel-address ((#\- literal)))
   (to-file:integer <- read-file stdin:channel-address)
   (to-rank:integer <- read-rank stdin:channel-address)
+  (expect-stdin stdin:channel-address ((#\newline literal)))
   ; construct the move object
   (result:move-address <- new move:literal)
   (f:integer-integer-pair-address <- get-address result:move-address/deref from:offset)
@@ -127,9 +128,14 @@
   (default-space:space-address <- new space:literal 30:literal)
   (stdin:channel-address <- next-input)
   (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
+;?   (print-primitive-to-host x:tagged-value) ;? 1
+;?   (print-primitive-to-host (("\n" literal))) ;? 1
   (a:character <- copy ((#\a literal)))
   (file-base:integer <- character-to-integer a:character)
   (c:character <- maybe-coerce x:tagged-value character:literal)
+;?   (print-primitive-to-host (("AAA " literal))) ;? 1
+;?   (print-primitive-to-host c:character) ;? 1
+;?   (print-primitive-to-host (("\n" literal))) ;? 1
   { begin
     (quit:boolean <- equal c:character ((#\q literal)))
     (break-unless quit:boolean)
@@ -150,6 +156,9 @@
   (stdin:channel-address <- next-input)
   (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
   (c:character <- maybe-coerce x:tagged-value character:literal)
+;?   (print-primitive-to-host (("BBB " literal))) ;? 1
+;?   (print-primitive-to-host c:character) ;? 1
+;?   (print-primitive-to-host (("\n" literal))) ;? 1
   { begin
     (quit:boolean <- equal c:character ((#\q literal)))
     (break-unless quit:boolean)
@@ -167,10 +176,10 @@
   (reply rank:integer)
 ])
 
+; slurp a character and check that it matches
 (function expect-stdin [
   (default-space:space-address <- new space:literal 30:literal)
   (stdin:channel-address <- next-input)
-  ; slurp hyphen
   (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
   (c:character <- maybe-coerce x:tagged-value character:literal)
   (expected:character <- next-input)
@@ -223,12 +232,19 @@
     (cursor-to-next-line nil:literal/terminal)
     (print-board nil:literal/terminal b:board-address)
     (cursor-to-next-line nil:literal/terminal)
-    (print-primitive-to-host (("Type in your move as <from square>-<to square>. For example: 'a2-a4'. Currently very unforgiving of typos; exactly five letters, no <Enter>, no uppercase." literal)))
+    (print-primitive-to-host (("Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>." literal)))
     (cursor-to-next-line nil:literal/terminal)
     (print-primitive-to-host (("Hit 'q' to exit." literal)))
     (cursor-to-next-line nil:literal/terminal)
     (print-primitive-to-host (("move: " literal)))
     (m:move-address <- read-move buffered-stdin:channel-address)
+;?     (retro-mode) ;? 1
+;?     (print-primitive-to-host stdin:channel-address) ;? 1
+;?     (print-primitive-to-host (("\n" literal))) ;? 1
+;?     (print-primitive-to-host buffered-stdin:channel-address) ;? 1
+;?     (print-primitive-to-host (("\n" literal))) ;? 1
+;?     (dump-memory) ;? 1
+;?     (cursor-mode) ;? 1
     (break-unless m:move-address)
     (b:board-address <- make-move b:board-address m:move-address)
     (loop)
diff --git a/mu.arc b/mu.arc
index ca98f72b..46c28494 100644
--- a/mu.arc
+++ b/mu.arc
@@ -739,6 +739,11 @@
                     (prn ($.rgb-red pixel) " " ($.rgb-blue pixel) " " ($.rgb-green pixel))
                     ($:rgb-red pixel))
 
+                ; debugging aide
+                dump-memory
+                  (do1 nil
+                    (prn:repr int-canon.memory*))
+
                 ; user-defined functions
                 next-input
                   (let idx caller-arg-idx.routine*
@@ -2022,14 +2027,18 @@
   (default-space:space-address <- new space:literal 30:literal)
   (stdin:channel-address <- next-input)
   (buffered-stdin:channel-address <- next-input)
-  (line:buffer-address <- init-buffer 30:literal)
   ; repeat forever
   { begin
+    (line:buffer-address <- init-buffer 30:literal)
     ; read characters from stdin until newline, copy into line
     { begin
       (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
       (c:character <- maybe-coerce x:tagged-value character:literal)
       (assert c:character)
+;?       (print-primitive-to-host line:buffer-address) ;? 1
+;?       (print-primitive-to-host (("\n" literal))) ;? 1
+;?       (print-primitive-to-host c:character) ;? 1
+;?       (print-primitive-to-host (("\n" literal))) ;? 1
       { begin
         (backspace?:boolean <- equal c:character ((#\backspace literal)))
         (break-unless backspace?:boolean)
@@ -2039,8 +2048,6 @@
       }
       (line:buffer-address <- append line:buffer-address c:character)
       (line-contents:string-address <- get line:buffer-address/deref data:offset)
-;?       (print-primitive-to-host c:character) ;? 0
-;?       (print-primitive-to-host (("\n" literal))) ;? 2
       (line-done?:boolean <- equal c:character ((#\newline literal)))
       (break-if line-done?:boolean)
       (eof?:boolean <- equal c:character ((#\null literal)))
f='/djm/dotfiles/commit/.emacs.d/lisp/init-minibuffer.el?h=sops&id=d113ddd1f319386ee7381fb062c2d664b75a9de6'>d113ddd ^
4bb6cfd ^
45e480c ^
d113ddd ^
45e480c ^


57b36ca ^



679c36f ^
57b36ca ^




679c36f ^
57b36ca ^

45e480c ^


1c9f64d ^
45e480c ^
d113ddd ^
85a4765 ^

d113ddd ^










57b36ca ^
45e480c ^


82a42c2 ^
5812e11 ^















45e480c ^

45e480c ^



















d6d9ab2 ^



0f24120 ^
3f873cc ^
45e480c ^










be55778 ^
45e480c ^
1906a44 ^

e1835df ^






45e480c ^
fc3ad64 ^
45e480c ^










45e480c ^



45e480c ^















d6d9ab2 ^



45e480c ^





e80520b ^
3f873cc ^

85ed757 ^








9823984 ^
85ed757 ^












45e480c ^

85ed757 ^


45e480c ^



85ed757 ^
45e480c ^








45e480c ^


e1835df ^
45e480c ^


71c27e4 ^
e1835df ^
45e480c ^
543ed1f ^
e1835df ^







45e480c ^
e1835df ^
45e480c ^
f38d340 ^
1c9f64d ^
33b0b94 ^











45e480c ^

1c9f64d ^
a6a07a4 ^
619f012 ^

45e480c ^





1c9f64d ^

















ec0a75e ^
1c9f64d ^
1906a44 ^
2b7769b ^

1c9f64d ^


1447feb ^


1c9f64d ^


2b7769b ^
1447feb ^
1906a44 ^
1447feb ^


1906a44 ^
1447feb ^
a7055e0 ^
1447feb ^









1c9f64d ^



1447feb ^

de70fb0 ^
45e480c ^







45e480c ^
c8f0dad ^
45e480c ^


fe29ee3 ^
8ac94b8 ^
fe29ee3 ^
45e480c ^
fc3ad64 ^

7052176 ^
7052176 ^
45e480c ^



45e480c ^
5ed427c ^
45e480c ^

a58ad88 ^

515f4b6 ^



fc3ad64 ^

45e480c ^
a58ad88 ^




72734a9 ^
a58ad88 ^
45e480c ^







fc3ad64 ^


515f4b6 ^



45e480c ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469