2 data: (handle array global)
4 render-list: (handle array int) # sequence of globals to render on the left side
5 # no pagination or scrolling
9 name: (handle array byte)
10 input: (handle gap-buffer)
15 fn initialize-globals _self: (addr global-table) {
16 var self/esi: (addr global-table) <- copy _self
20 abort "initialize globals"
23 var data-ah/eax: (addr handle array global) <- get self, data
24 populate data-ah, 0x80
25 initialize-primitives self
26 var render-ah/eax: (addr handle array int) <- get self, render-list
27 populate render-ah, 0x20/render-size
30 fn load-globals in: (addr handle cell), self: (addr global-table) {
31 draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "loading globals:", 3/fg, 0/bg
32 var remaining-ah/esi: (addr handle cell) <- copy in
34 var _remaining/eax: (addr cell) <- lookup *remaining-ah
35 var remaining/ebx: (addr cell) <- copy _remaining
36 var done?/eax: boolean <- nil? remaining
37 compare done?, 0/false
39 var curr-ah/eax: (addr handle cell) <- get remaining, left
40 var _curr/eax: (addr cell) <- lookup *curr-ah
41 var curr/ecx: (addr cell) <- copy _curr
42 remaining-ah <- get remaining, right
43 var name-ah/eax: (addr handle cell) <- get curr, left
44 var name/eax: (addr cell) <- lookup *name-ah
45 var name-data-ah/eax: (addr handle stream byte) <- get name, text-data
46 var _name-data/eax: (addr stream byte) <- lookup *name-data-ah
47 var name-data/edx: (addr stream byte) <- copy _name-data
48 rewind-stream name-data
49 draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " ", 3/fg 0/bg
50 draw-stream-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, name-data, 3/fg, 0/bg
51 var value-ah/eax: (addr handle cell) <- get curr, right
52 var value/eax: (addr cell) <- lookup *value-ah
53 var value-data-ah/eax: (addr handle stream byte) <- get value, text-data
54 var _value-data/eax: (addr stream byte) <- lookup *value-data-ah
55 var value-data/ecx: (addr stream byte) <- copy _value-data
56 var value-gap-buffer-storage: (handle gap-buffer)
57 var value-gap-buffer-ah/edi: (addr handle gap-buffer) <- address value-gap-buffer-storage
58 allocate value-gap-buffer-ah
59 var value-gap-buffer/eax: (addr gap-buffer) <- lookup *value-gap-buffer-ah
60 initialize-gap-buffer value-gap-buffer, 0x40000/256KB
61 load-gap-buffer-from-stream value-gap-buffer, value-data
62 load-lexical-scope value-gap-buffer-ah, self
65 move-cursor-to-left-margin-of-next-line 0/screen
68 fn write-globals out: (addr stream byte), _self: (addr global-table) {
69 var self/esi: (addr global-table) <- copy _self
76 write out, " (globals . (\n"
77 var data-ah/eax: (addr handle array global) <- get self, data
78 var data/eax: (addr array global) <- lookup *data-ah
79 var final-index/edx: (addr int) <- get self, final-index
80 var curr-index/ecx: int <- copy 1/skip-0
82 compare curr-index, *final-index
84 var curr-offset/ebx: (offset global) <- compute-offset data, curr-index
85 var curr/ebx: (addr global) <- index data, curr-offset
86 var curr-value-ah/edx: (addr handle cell) <- get curr, value
87 var curr-value/eax: (addr cell) <- lookup *curr-value-ah
88 var curr-type/eax: (addr int) <- get curr-value, type
90 compare *curr-type, 4/primitive-function
92 compare *curr-type, 5/screen
94 compare *curr-type, 6/keyboard
97 var curr-name-ah/eax: (addr handle array byte) <- get curr, name
98 var curr-name/eax: (addr array byte) <- lookup *curr-name-ah
101 var curr-input-ah/eax: (addr handle gap-buffer) <- get curr, input
102 var curr-input/eax: (addr gap-buffer) <- lookup *curr-input-ah
104 compare curr-input, 0
106 abort "null gap buffer"
108 append-gap-buffer curr-input, out
111 curr-index <- increment
117 # globals layout: 1 char padding, 41 code, 1 padding, 41 code, 1 padding = 85 chars
118 fn render-globals screen: (addr screen), _self: (addr global-table), show-cursor?: boolean {
119 clear-rect screen, 0/xmin, 0/ymin, 0x55/xmax, 0x2f/ymax=screen-height-without-menu, 0xdc/bg=green-bg
120 var self/esi: (addr global-table) <- copy _self
124 abort "render globals"
127 var data-ah/eax: (addr handle array global) <- get self, data
128 var _data/eax: (addr array global) <- lookup *data-ah
129 var data/ebx: (addr array global) <- copy _data
130 var curr-index/edx: int <- copy 0
132 copy-to y1, 1/padding-top
134 copy-to y2, 1/padding-top
135 $render-globals:loop: {
136 compare curr-index, 0x20/render-size
139 compare y1, 0x2f/ymax
141 compare y2, 0x2f/ymax
143 break $render-globals:loop
145 $render-globals:iter: {
146 var cursor-in-current-line?: boolean
148 compare show-cursor?, 0/false
150 compare curr-index, 0
152 copy-to cursor-in-current-line?, 1/true
154 var render-list-ah/eax: (addr handle array int) <- get self, render-list
155 var render-list/eax: (addr array int) <- lookup *render-list-ah
156 var global-id-a/eax: (addr int) <- index render-list, curr-index
157 var global-id/eax: int <- copy *global-id-a
160 var global-offset/edx: (offset global) <- compute-offset data, global-id
161 var curr/edx: (addr global) <- index data, global-offset
163 var render-image?/eax: boolean <- render-image? curr, cursor-in-current-line?
164 compare render-image?, 0/false
166 var y/ecx: int <- render-image-definition screen, curr, 0/x y1
167 y <- increment # padding
169 break $render-globals:iter
171 var curr-input-ah/eax: (addr handle gap-buffer) <- get curr, input
172 var _curr-input/eax: (addr gap-buffer) <- lookup *curr-input-ah
173 var curr-input/ebx: (addr gap-buffer) <- copy _curr-input
174 compare curr-input, 0
176 var curr-trace-ah/eax: (addr handle trace) <- get curr, trace
177 var _curr-trace/eax: (addr trace) <- lookup *curr-trace-ah
178 var curr-trace/edx: (addr trace) <- copy _curr-trace
179 $render-globals:render-global: {
180 var x/eax: int <- copy 0
181 var y/ecx: int <- copy y1
185 x, y <- render-gap-buffer-wrapping-right-then-down screen, curr-input, 1/padding-left, y1, 0x2a/xmax, 0x2f/ymax, cursor-in-current-line?, 7/fg=definition, 0xc5/bg=blue-bg
187 y <- render-trace screen, curr-trace, 1/padding-left, y, 0x2a/xmax, 0x2f/ymax, 0/no-cursor
190 break $render-globals:render-global
192 x, y <- render-gap-buffer-wrapping-right-then-down screen, curr-input, 0x2b/xmin, y2, 0x54/xmax, 0x2f/ymax, cursor-in-current-line?, 7/fg=definition, 0xc5/bg=blue-bg
194 y <- render-trace screen, curr-trace, 0x2b/xmin, y, 0x54/xmax, 0x2f/ymax, 0/no-cursor
199 curr-index <- increment
202 # render primitives on top
203 render-primitives screen, 1/xmin=padding-left, 0x55/xmax, 0x2f/ymax
206 fn render-globals-menu screen: (addr screen), _self: (addr global-table) {
207 var _width/eax: int <- copy 0
208 var height/ecx: int <- copy 0
209 _width, height <- screen-size screen
210 var width/edx: int <- copy _width
211 var y/ecx: int <- copy height
213 var height/ebx: int <- copy y
215 clear-rect screen, 0/x, y, width, height, 0xc5/bg=blue-bg
216 set-cursor-position screen, 0/x, y
217 draw-text-rightward-from-cursor screen, " ^r ", width, 0/fg, 0x5c/bg=menu-highlight
218 draw-text-rightward-from-cursor screen, " run main ", width, 7/fg, 0xc5/bg=blue-bg
219 draw-text-rightward-from-cursor screen, " ^s ", width, 0/fg, 0x5c/bg=menu-highlight
220 draw-text-rightward-from-cursor screen, " run sandbox ", width, 7/fg, 0xc5/bg=blue-bg
221 draw-text-rightward-from-cursor screen, " ^g ", width, 0/fg, 0x5c/bg=menu-highlight
222 draw-text-rightward-from-cursor screen, " go to ", width, 7/fg, 0xc5/bg=blue-bg
223 draw-text-rightward-from-cursor screen, " ^a ", width, 0/fg, 0x5c/bg=menu-highlight
224 draw-text-rightward-from-cursor screen, " << ", width, 7/fg, 0xc5/bg=blue-bg
225 draw-text-rightward-from-cursor screen, " ^b ", width, 0/fg, 0x5c/bg=menu-highlight
226 draw-text-rightward-from-cursor screen, " <word ", width, 7/fg, 0xc5/bg=blue-bg
227 draw-text-rightward-from-cursor screen, " ^f ", width, 0/fg, 0x5c/bg=menu-highlight
228 draw-text-rightward-from-cursor screen, " word> ", width, 7/fg, 0xc5/bg=blue-bg
229 draw-text-rightward-from-cursor screen, " ^e ", width, 0/fg, 0x5c/bg=menu-highlight
230 draw-text-rightward-from-cursor screen, " >> ", width, 7/fg, 0xc5/bg=blue-bg
233 fn edit-globals _self: (addr global-table), key: code-point-utf8 {
234 var self/esi: (addr global-table) <- copy _self
237 compare key, 0x13/ctrl-s
240 refresh-cursor-definition self
243 var cursor-index/ecx: int <- cursor-global self
244 compare cursor-index, 0
249 var data-ah/eax: (addr handle array global) <- get self, data
250 var data/eax: (addr array global) <- lookup *data-ah
251 var cursor-offset/ecx: (offset global) <- compute-offset data, cursor-index
252 var curr-global/eax: (addr global) <- index data, cursor-offset
253 var curr-editor-ah/eax: (addr handle gap-buffer) <- get curr-global, input
254 var curr-editor/eax: (addr gap-buffer) <- lookup *curr-editor-ah
255 edit-gap-buffer curr-editor, key
258 fn create-empty-global _self: (addr global-table), name-stream: (addr stream byte), capacity: int {
259 var self/esi: (addr global-table) <- copy _self
260 var final-index-addr/ecx: (addr int) <- get self, final-index
261 increment *final-index-addr
262 var render-list-ah/eax: (addr handle array int) <- get self, render-list
263 var render-list/eax: (addr array int) <- lookup *render-list-ah
264 slide-down render-list, 0/start 0x1f/penultimate, 1/target
265 var curr-index/ecx: int <- copy *final-index-addr
266 var dest/eax: (addr int) <- index render-list, 0
267 copy-to *dest, curr-index
268 var data-ah/eax: (addr handle array global) <- get self, data
269 var data/eax: (addr array global) <- lookup *data-ah
270 var curr-offset/ecx: (offset global) <- compute-offset data, curr-index
271 var curr/esi: (addr global) <- index data, curr-offset
272 var curr-name-ah/eax: (addr handle array byte) <- get curr, name
273 stream-to-array name-stream, curr-name-ah
274 var curr-input-ah/eax: (addr handle gap-buffer) <- get curr, input
275 allocate curr-input-ah
276 var curr-input/eax: (addr gap-buffer) <- lookup *curr-input-ah
277 initialize-gap-buffer curr-input, capacity
278 var trace-ah/eax: (addr handle trace) <- get curr, trace
280 var trace/eax: (addr trace) <- lookup *trace-ah
281 initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
284 fn refresh-cursor-definition _self: (addr global-table) {
285 var self/esi: (addr global-table) <- copy _self
286 var render-list-ah/eax: (addr handle array int) <- get self, render-list
287 var render-list/eax: (addr array int) <- lookup *render-list-ah
288 var cursor-index/edx: (addr int) <- index render-list, 0
289 refresh-definition self, *cursor-index
292 fn refresh-definition _self: (addr global-table), _index: int {
293 var self/esi: (addr global-table) <- copy _self
294 var data-ah/eax: (addr handle array global) <- get self, data
295 var data/eax: (addr array global) <- lookup *data-ah
296 var index/ebx: int <- copy _index
297 var offset/ebx: (offset global) <- compute-offset data, index
298 var curr-global/ebx: (addr global) <- index data, offset
299 var curr-input-ah/edx: (addr handle gap-buffer) <- get curr-global, input
300 var curr-trace-ah/eax: (addr handle trace) <- get curr-global, trace
301 var curr-trace/eax: (addr trace) <- lookup *curr-trace-ah
302 clear-trace curr-trace
303 var curr-value-ah/edi: (addr handle cell) <- get curr-global, value
304 var definitions-created-storage: (stream int 0x10)
305 var definitions-created/ecx: (addr stream int) <- address definitions-created-storage
306 read-and-evaluate-and-save-gap-buffer-to-globals curr-input-ah, curr-value-ah, self, definitions-created, curr-trace, 0/no-screen, 0/no-keyboard
309 fn assign-or-create-global _self: (addr global-table), name: (addr array byte), value: (handle cell), index-updated: (addr int), trace: (addr trace) {
310 var self/esi: (addr global-table) <- copy _self
314 abort "assign global"
316 var curr-index/ecx: int <- find-symbol-name-in-globals self, name
318 compare curr-index, -1/not-found
320 var final-index-addr/eax: (addr int) <- get self, final-index
321 increment *final-index-addr
322 curr-index <- copy *final-index-addr
323 var arr-ah/eax: (addr handle array int) <- get self, render-list
324 var arr/eax: (addr array int) <- lookup *arr-ah
325 slide-down arr, 0/start 0x1e/penultimate, 1/target
326 var dest/eax: (addr int) <- index arr, 0
327 copy-to *dest, curr-index
329 var data-ah/eax: (addr handle array global) <- get self, data
330 var data/eax: (addr array global) <- lookup *data-ah
331 var curr-offset/esi: (offset global) <- compute-offset data, curr-index
332 var curr/esi: (addr global) <- index data, curr-offset
333 var curr-name-ah/eax: (addr handle array byte) <- get curr, name
334 copy-array-object name, curr-name-ah
335 var curr-value-ah/eax: (addr handle cell) <- get curr, value
336 copy-handle value, curr-value-ah
337 var index-updated/edi: (addr int) <- copy index-updated
338 copy-to *index-updated, curr-index
339 var trace-ah/eax: (addr handle trace) <- get curr, trace
341 var trace/eax: (addr trace) <- lookup *trace-ah
342 initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
345 fn bump-global _globals: (addr global-table), global-id: int {
346 var globals/esi: (addr global-table) <- copy _globals
347 var render-list-ah/eax: (addr handle array int) <- get globals, render-list
348 var render-list/eax: (addr array int) <- lookup *render-list-ah
349 var idx/ecx: int <- find-slide-down-slot-in-array render-list, global-id
355 slide-down render-list, 0/start idx, 1/target
356 var dest/eax: (addr int) <- index render-list, 0
357 var val/ecx: int <- copy global-id
361 fn cursor-global _globals: (addr global-table) -> _/ecx: int {
362 var globals/esi: (addr global-table) <- copy _globals
363 var render-list-ah/eax: (addr handle array int) <- get globals, render-list
364 var render-list/eax: (addr array int) <- lookup *render-list-ah
365 var dest/eax: (addr int) <- index render-list, 0
369 fn lookup-symbol-in-globals _sym: (addr cell), out: (addr handle cell), _globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell) {
370 var sym/eax: (addr cell) <- copy _sym
371 var sym-name-ah/eax: (addr handle stream byte) <- get sym, text-data
372 var _sym-name/eax: (addr stream byte) <- lookup *sym-name-ah
373 var sym-name/edx: (addr stream byte) <- copy _sym-name
374 var globals/esi: (addr global-table) <- copy _globals
378 var curr-index/ecx: int <- find-symbol-in-globals globals, sym-name
379 compare curr-index, -1/not-found
381 var global-data-ah/eax: (addr handle array global) <- get globals, data
382 var global-data/eax: (addr array global) <- lookup *global-data-ah
383 var curr-offset/ebx: (offset global) <- compute-offset global-data, curr-index
384 var curr/ebx: (addr global) <- index global-data, curr-offset
385 var curr-value/eax: (addr handle cell) <- get curr, value
386 copy-object curr-value, out
389 # if sym is "screen" and inner-screen-var exists, return it
391 var sym-is-screen?/eax: boolean <- stream-data-equal? sym-name, "screen"
392 compare sym-is-screen?, 0/false
394 compare inner-screen-var, 0
396 copy-object inner-screen-var, out
399 # if sym is "keyboard" and inner-keyboard-var exists, return it
401 var sym-is-keyboard?/eax: boolean <- stream-data-equal? sym-name, "keyboard"
402 compare sym-is-keyboard?, 0/false
404 compare inner-keyboard-var, 0
406 copy-object inner-keyboard-var, out
409 # otherwise error "unbound symbol: ", sym
410 var stream-storage: (stream byte 0x40)
411 var stream/ecx: (addr stream byte) <- address stream-storage
412 write stream, "unbound symbol: "
413 rewind-stream sym-name
414 write-stream stream, sym-name
415 error-stream trace, stream
418 fn maybe-lookup-symbol-in-globals _sym: (addr cell), out: (addr handle cell), _globals: (addr global-table), trace: (addr trace) {
419 var sym/eax: (addr cell) <- copy _sym
420 var sym-name-ah/eax: (addr handle stream byte) <- get sym, text-data
421 var _sym-name/eax: (addr stream byte) <- lookup *sym-name-ah
422 var sym-name/edx: (addr stream byte) <- copy _sym-name
423 var globals/esi: (addr global-table) <- copy _globals
427 var curr-index/ecx: int <- find-symbol-in-globals globals, sym-name
428 compare curr-index, -1/not-found
430 var global-data-ah/eax: (addr handle array global) <- get globals, data
431 var global-data/eax: (addr array global) <- lookup *global-data-ah
432 var curr-offset/ebx: (offset global) <- compute-offset global-data, curr-index
433 var curr/ebx: (addr global) <- index global-data, curr-offset
434 var curr-value/eax: (addr handle cell) <- get curr, value
435 copy-object curr-value, out
440 # return the index in globals containing 'sym'
442 fn find-symbol-in-globals _globals: (addr global-table), sym-name: (addr stream byte) -> _/ecx: int {
443 var globals/esi: (addr global-table) <- copy _globals
449 var global-data-ah/eax: (addr handle array global) <- get globals, data
450 var global-data/eax: (addr array global) <- lookup *global-data-ah
451 var final-index/ecx: (addr int) <- get globals, final-index
452 var curr-index/ecx: int <- copy *final-index
454 compare curr-index, 0
456 var curr-offset/ebx: (offset global) <- compute-offset global-data, curr-index
457 var curr/ebx: (addr global) <- index global-data, curr-offset
458 var curr-name-ah/eax: (addr handle array byte) <- get curr, name
459 var curr-name/eax: (addr array byte) <- lookup *curr-name-ah
460 var found?/eax: boolean <- stream-data-equal? sym-name, curr-name
461 compare found?, 0/false
466 curr-index <- decrement
472 # return the index in globals containing 'sym'
474 fn find-symbol-name-in-globals _globals: (addr global-table), sym-name: (addr array byte) -> _/ecx: int {
475 var globals/esi: (addr global-table) <- copy _globals
481 var global-data-ah/eax: (addr handle array global) <- get globals, data
482 var global-data/eax: (addr array global) <- lookup *global-data-ah
483 var final-index/ecx: (addr int) <- get globals, final-index
484 var curr-index/ecx: int <- copy *final-index
486 compare curr-index, 0
488 var curr-offset/ebx: (offset global) <- compute-offset global-data, curr-index
489 var curr/ebx: (addr global) <- index global-data, curr-offset
490 var curr-name-ah/eax: (addr handle array byte) <- get curr, name
491 var curr-name/eax: (addr array byte) <- lookup *curr-name-ah
492 var found?/eax: boolean <- string-equal? sym-name, curr-name
493 compare found?, 0/false
498 curr-index <- decrement
504 fn mutate-binding-in-globals name: (addr stream byte), val: (addr handle cell), _globals: (addr global-table), trace: (addr trace) {
505 var globals/esi: (addr global-table) <- copy _globals
509 var curr-index/ecx: int <- find-symbol-in-globals globals, name
510 compare curr-index, -1/not-found
512 var global-data-ah/eax: (addr handle array global) <- get globals, data
513 var global-data/eax: (addr array global) <- lookup *global-data-ah
514 var curr-offset/ebx: (offset global) <- compute-offset global-data, curr-index
515 var curr/ebx: (addr global) <- index global-data, curr-offset
516 var dest/eax: (addr handle cell) <- get curr, value
517 copy-object val, dest
520 # otherwise error "unbound symbol: ", sym
521 var stream-storage: (stream byte 0x40)
522 var stream/ecx: (addr stream byte) <- address stream-storage
523 write stream, "unbound symbol: "
525 write-stream stream, name
526 error-stream trace, stream
529 fn stash-gap-buffer-to-globals _globals: (addr global-table), definitions: (addr stream int), gap: (addr handle gap-buffer) {
530 var globals/eax: (addr global-table) <- copy _globals
536 var global-data-ah/eax: (addr handle array global) <- get globals, data
537 var global-data/eax: (addr array global) <- lookup *global-data-ah
538 rewind-stream definitions
541 var done?/eax: boolean <- stream-empty? definitions
542 compare done?, 0/false
546 var index-addr/ecx: (addr int) <- address index
547 read-from-stream definitions, index-addr
548 var index/ecx: int <- copy *index-addr
549 var offset/ebx: (offset global) <- compute-offset global-data, index
550 var dest-global/eax: (addr global) <- index global-data, offset
551 var dest-ah/eax: (addr handle gap-buffer) <- get dest-global, input
552 copy-object gap, dest-ah
557 # load all bindings in a single lexical scope, aka gap buffer of the environment, aka file of the file system
558 fn load-lexical-scope in-ah: (addr handle gap-buffer), _globals: (addr global-table) {
559 var globals/esi: (addr global-table) <- copy _globals
560 var definitions-created-storage: (stream int 0x10)
561 var definitions-created/ebx: (addr stream int) <- address definitions-created-storage
562 var trace-h: (handle trace)
563 var trace-ah/edx: (addr handle trace) <- address trace-h
565 var trace/eax: (addr trace) <- lookup *trace-ah
566 initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
567 var dummy-result-h: (handle cell)
568 var dummy-result-ah/ecx: (addr handle cell) <- address dummy-result-h
569 read-and-evaluate-and-save-gap-buffer-to-globals in-ah, dummy-result-ah, globals, definitions-created, trace, 0/no-inner-screen-var, 0/no-inner-keyboard-var
571 # save trace to all needed globals as well
572 rewind-stream definitions-created
573 var globals-data-ah/eax: (addr handle array global) <- get globals, data
574 var _globals-data/eax: (addr array global) <- lookup *globals-data-ah
575 var globals-data/edi: (addr array global) <- copy _globals-data
577 var no-definitions?/eax: boolean <- stream-empty? definitions-created
578 compare no-definitions?, 0/false
581 var curr-index-a/eax: (addr int) <- address curr-index
582 read-from-stream definitions-created, curr-index-a
583 var curr-offset/eax: (offset global) <- compute-offset globals-data, curr-index
584 var curr-global/ecx: (addr global) <- index globals-data, curr-offset
585 var curr-trace-ah/eax: (addr handle trace) <- get curr-global, trace
586 copy-object trace-ah, curr-trace-ah
591 fn render-image? _self: (addr global), cursor-in-definition?: boolean -> _/eax: boolean {
593 compare cursor-in-definition?, 0/false
595 # if the cursor is in this definition we need to be able to edit raw data
598 var self/esi: (addr global) <- copy _self
599 var value-ah/eax: (addr handle cell) <- get self, value
600 var value/eax: (addr cell) <- lookup *value-ah
604 # unparsed buffers can't be rendered; either they're uninitialized or they have errors
608 var pair?/eax: boolean <- pair? value
609 compare pair?, 0/false
611 # not a pair? not an image
614 var first-ah/eax: (addr handle cell) <- get value, left
615 var first/eax: (addr cell) <- lookup *first-ah
616 var litimg?/eax: boolean <- litimg? first
620 fn render-image-definition screen: (addr screen), _self: (addr global), x: int, _y: int -> _/ecx: int {
621 var self/esi: (addr global) <- copy _self
622 var y/ecx: int <- copy _y
623 set-cursor-position 0/screen, 0x20 0x20
624 draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 4/fg 0/bg
626 var name-ah/eax: (addr handle array byte) <- get self, name
627 var _name/eax: (addr array byte) <- lookup *name-ah
628 var name/edx: (addr array byte) <- copy _name
629 var x/eax: int <- draw-text-rightward-over-full-screen screen, "define ", x y, 7/fg=definition, 0xc5/bg=blue-bg
630 x <- draw-text-rightward-over-full-screen screen, name, x y, 7/fg=definition, 0xc5/bg=blue-bg
632 y <- increment # skip definition line
634 y <- shift-left 4/log2fontheight
636 shift-left x, 3/log2fontwidth
637 var value-ah/eax: (addr handle cell) <- get self, value
638 var value/eax: (addr cell) <- lookup *value-ah
639 var rest-ah/eax: (addr handle cell) <- get value, right
640 var rest/eax: (addr cell) <- lookup *rest-ah
641 var second-ah/eax: (addr handle cell) <- get rest, left
642 var second/eax: (addr cell) <- lookup *second-ah
643 var img-data-ah/eax: (addr handle stream byte) <- get second, text-data
644 var img-data/eax: (addr stream byte) <- lookup *img-data-ah
645 var img-h: (handle cell)
646 var img-cell-ah/edx: (addr handle cell) <- address img-h
647 new-image img-cell-ah, img-data
648 var img-cell/eax: (addr cell) <- lookup *img-cell-ah
649 var img-ah/eax: (addr handle image) <- get img-cell, image-data
650 var img/eax: (addr image) <- lookup *img-ah
651 var height/ebx: int <- scale-image-height img, 0x80/width
652 render-image screen, img, x y, 0x80/width height
654 # switch y back to characters
655 y <- scale-down-and-round-up y, 0x10/font-height