Smoked out some issues by rendering a single frame of Game of Life.
Incredibly slow.
This commit is contained in:
Kartik K. Agaram 2021-07-26 02:27:32 -07:00
parent 81c3678515
commit 46441d7204
3 changed files with 40 additions and 10 deletions

View File

@ -98,7 +98,7 @@ fn draw-code-point-at-cursor screen: (addr screen), c: code-point, color: int, b
# return the next 'x' coordinate
# if there isn't enough space, truncate
fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, xmax: int, y: int, color: int, background-color: int -> _/eax: int {
var stream-storage: (stream byte 0x200/print-buffer-size)
var stream-storage: (stream byte 0x400/print-buffer-size)
var stream/esi: (addr stream byte) <- address stream-storage
write stream, text
var xcurr/eax: int <- draw-stream-rightward screen, stream, x, xmax, y, color, background-color

View File

@ -66,10 +66,6 @@
(list (list (car xs)))
(cons (list (car xs) (cadr xs))
(pair (cddr xs)))])
(grid . [def (grid m n val)
ret g (populate n ())
for i 0 (< i n) ++i
iset g i (populate m val)])
(with . [mac (with bindings . body)
`((fn ,(map1 car (pair bindings))
,@body)
@ -124,6 +120,14 @@
(while ,test
,@body
,update))])
(grid . [def (grid m n val)
ret g (populate n ())
for i 0 (< i n) ++i
iset g i (populate m val)])
(indexgrid . [def (indexgrid g x y)
(index (index g y) x)])
(isetgrid . [def (isetgrid g x y val)
iset (index g y) x val])
(hborder . [def (hborder scr y color)
(hline scr y 0 (width scr) color)])
(vborder . [def (vborder scr x color)
@ -162,6 +166,27 @@
(pixel screen x y (palette Greys x*y))])
(main . [def (main screen keyboard)
(pat screen)])
(lifreres . [define liferes 8])
(life . [def (life screen)
let g (grid (/ (width screen) liferes)
(/ (height screen) liferes)
0)
isetgrid g 5 5 1
isetgrid g 6 5 1
isetgrid g 4 6 1
isetgrid g 5 6 1
isetgrid g 5 7 1
while 1
steplife g
renderlife screen g])
(steplife . [def (steplife g)
])
(renderlife . [def (renderlife screen g)
with (w (width screen)
h (height screen))
for y 0 (< y h) ++y
for x 0 (< x w) ++x
(pixel screen x y (indexgrid g x/liferes y/liferes))])
))
(sandbox . [pat screen])
(sandbox . [life screen])
)

View File

@ -3641,14 +3641,19 @@ fn apply-index _args-ah: (addr handle cell), out: (addr handle cell), trace: (ad
return
}
var second-value/eax: (addr float) <- get second, number-data
var index/edx: int <- convert *second-value
var index/edx: int <- truncate *second-value
var data-ah/eax: (addr handle array handle cell) <- get first, array-data
var data/eax: (addr array handle cell) <- lookup *data-ah
{
var len/eax: int <- length data
compare index, len
break-if-<
error trace, "too few elements in array"
error trace, "index: too few elements in array"
compare index, len
{
break-if-<=
error trace, "foo"
}
return
}
var offset/edx: (offset handle cell) <- compute-offset data, index
@ -3716,13 +3721,13 @@ fn apply-iset _args-ah: (addr handle cell), out: (addr handle cell), trace: (add
return
}
var second-value/eax: (addr float) <- get second, number-data
var idx/eax: int <- convert *second-value
var idx/eax: int <- truncate *second-value
# offset based on idx after bounds check
var max/edx: int <- length array
compare idx, max
{
break-if-<
error trace, "too few elements in array"
error trace, "iset: too few elements in array"
return
}
var offset/edx: (offset handle cell) <- compute-offset array, idx