mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-09-07 12:54:31 +00:00
Fix FOR index variable and update lores example
This commit is contained in:
parent
bbfa59ccc7
commit
e77ff928ca
Binary file not shown.
@ -1,12 +1,12 @@
|
||||
(DEFINE
|
||||
(PLOTFUNC (LAMBDA (FN)
|
||||
(PROG (X Y)
|
||||
(SETQ X 0)
|
||||
A (SETQ Y (* 0.99 (FN (/ (- X 20) 20.0))))
|
||||
(IF (AND (> Y -1.0) (< Y 1.0))
|
||||
(PLOT X, (* (+ Y 1.0) 19.0)))
|
||||
(SETQ X (+ X 1))
|
||||
(IF (< X 40) (GO A))
|
||||
(PROG (I X Y)
|
||||
(FOR I 0 1 (< I 40)
|
||||
(SETQ X (/ (- I 19.5) 20.0))
|
||||
(SETQ Y (FN X))
|
||||
(AND (AND (> Y -1.0) (< Y 1.0))
|
||||
(PLOT I (- 19.5 (* Y 20.0))))
|
||||
)
|
||||
(RETURN 0)
|
||||
)
|
||||
))
|
||||
|
@ -660,6 +660,9 @@ export def new_assoc(symptr, valptr)#0
|
||||
pairlist=>car = pair
|
||||
pairlist=>cdr = assoc_list
|
||||
assoc_list = pairlist
|
||||
if trace
|
||||
puts("\n New ASSOC:"); print_expr(pair); putln
|
||||
fin
|
||||
end
|
||||
|
||||
def assoc_pair(symptr)
|
||||
@ -1245,27 +1248,23 @@ def natv_trace(symptr, expr)
|
||||
end
|
||||
|
||||
def natv_for(symptr, expr)
|
||||
var index, ufunc, dlist
|
||||
var[2] incval, stepval
|
||||
var idxsym, idxint, ufunc, dlist
|
||||
word[2] stepval
|
||||
|
||||
if expr=>car->type & TYPE_MASK <> SYM_TYPE
|
||||
idxsym = expr=>car
|
||||
if idxsym->type & TYPE_MASK <> SYM_TYPE
|
||||
puts("For index not symbol\n")
|
||||
return NULL
|
||||
fin
|
||||
index = eval_expr(expr=>car)
|
||||
expr = expr=>cdr
|
||||
if index->type <> NUM_INT
|
||||
puts("FOR index not integer\n")
|
||||
return NULL
|
||||
fin
|
||||
expr = expr=>cdr
|
||||
symptr = eval_expr(expr=>car)
|
||||
expr = expr=>cdr
|
||||
if symptr->type <> NUM_INT
|
||||
puts("FOR initial not integer\n")
|
||||
return NULL
|
||||
fin
|
||||
incval[0] = symptr=>intval[0]
|
||||
incval[1] = symptr=>intval[1]
|
||||
set_assoc(idxsym, new_int(symptr=>intval[0], symptr=>intval[1]))
|
||||
idxint = eval_expr(idxsym)
|
||||
symptr = eval_expr(expr=>car)
|
||||
expr = expr=>cdr
|
||||
if symptr->type <> NUM_INT
|
||||
@ -1289,9 +1288,9 @@ def natv_for(symptr, expr)
|
||||
sweep_stack[sweep_stack_top - 1] = eval_expr(expr=>car)
|
||||
expr = expr=>cdr
|
||||
loop
|
||||
load32(index + intval) // Manipulate integer value directly!
|
||||
load32(idxint + intval) // Manipulate integer value directly!
|
||||
add32(@stepval)
|
||||
store32(index + intval)
|
||||
store32(idxint + intval)
|
||||
loop
|
||||
return pop_sweep_stack
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user