more space for definitions

This commit is contained in:
Kartik K. Agaram 2021-06-06 10:54:50 -07:00
parent b5d3095c92
commit c4cf38773f
3 changed files with 16 additions and 11 deletions

View File

@ -58,6 +58,10 @@
(write str c)
(set c (key keyboard))))
str))])
(wait . [(def (wait keyboard)
(while (= 0 (key keyboard))))])
(sq . [(def (sq n) (* n n))])
(cube . [(def (cube n) (* (* n n) n))])
(fill_rect . [(def (fill_rect screen x1 y1 x2 y2 color)
(for y y1 (< y y2) (++ y)
(hline1 screen y x1 x2 color)))])
@ -125,16 +129,17 @@
(for y r (< y ymax) (+= y side)
(for x r (< x xmax) (+= x side)
(circle_rainbow screen x y (- r 100) 10)))))))])
(task . [(def (task screen)
(task . [(def (task screen keyboard)
(let xmax (width screen)
(let ymax (height screen)
(for y 0 (< y ymax) (+= y 1)
(for x 4 (< x xmax) (+= x 1)
(for y 0 (< y ymax) (+= y 4)
#(wait keyboard)
(for x 0 (< x xmax) (+= x 1)
(pixel screen x y
# color
(+ (* x x) (* y y))))))))])
(+ 16 (+ (/ x 4) (cube (/ y 4))))))))))])
(main . [(def (main screen keyboard)
(task screen))])
(task screen keyboard))])
))
(sandbox . (task screen))
(sandbox . (task screen keyboard))
)

View File

@ -329,11 +329,11 @@ fn render-function-modal-menu screen: (addr screen), _self: (addr environment) {
fn load-state _self: (addr environment), data-disk: (addr disk) {
var self/esi: (addr environment) <- copy _self
# data-disk -> stream
var s-storage: (stream byte 0x1000) # space for 8/sectors
var s-storage: (stream byte 0x2000) # space for 16/sectors
var s/ebx: (addr stream byte) <- address s-storage
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "loading sectors from data disk", 3/fg, 0/bg
move-cursor-to-left-margin-of-next-line 0/screen
load-sectors data-disk, 0/lba, 8/sectors, s
load-sectors data-disk, 0/lba, 0x10/sectors, s
#? draw-stream-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, s, 7/fg, 0xc5/bg=blue-bg
# stream -> gap-buffer (HACK: we temporarily cannibalize the sandbox's gap-buffer)
draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "parsing", 3/fg, 0/bg
@ -413,11 +413,11 @@ fn store-state data-disk: (addr disk), sandbox: (addr sandbox), globals: (addr g
break-if-!=
return
}
var stream-storage: (stream byte 0x1000) # space enough for 8/sectors
var stream-storage: (stream byte 0x2000) # space enough for 16/sectors
var stream/edi: (addr stream byte) <- address stream-storage
write stream, "(\n"
write-globals stream, globals
write-sandbox stream, sandbox
write stream, ")\n"
store-sectors data-disk, 0/lba, 8/sectors, stream
store-sectors data-disk, 0/lba, 0x10/sectors, stream
}

View File

@ -14,7 +14,7 @@ fn initialize-sandbox _self: (addr sandbox), fake-screen-and-keyboard?: boolean
var data-ah/eax: (addr handle gap-buffer) <- get self, data
allocate data-ah
var data/eax: (addr gap-buffer) <- lookup *data-ah
initialize-gap-buffer data, 0x1000/4KB
initialize-gap-buffer data, 0x2000/8KB
#
var value-ah/eax: (addr handle stream byte) <- get self, value
populate-stream value-ah, 0x1000/4KB