Thanks, good to know.
I would have suggested the same, but I wasn't sure if was updated while using Pascal
Pascal for ZX81
Re: Pascal for ZX81
In theory, there is no difference between theory and practice. But, in practice, there is.
Re: Pascal for ZX81
Here's an RND routine which will give you a pseudo-random number sequence. Feed it N, the maximum number in the sequence you want up to 4096 and it will return an integer in N between 0 and N-1. For example, N:=RND(10) will return a random number between 0 and 9 stored in N. Make sure you do not overwrite the contents of the R and C variables in the main program.
Code: Select all
PROGRAM TEST(INPUT,OUTPUT);
VAR
R,C,N:INTEGER
FUNCTION RND(V:INTEGER):INTEGER;
VAR
I,T: INTEGER;
BEGIN
IF C=4096 THEN
BEGIN
R:=MEM(.16436.);
C:=0
END
ELSE
C:=C+1;
REPEAT
R:=(5*R+33) MOD 4096;
T:=R DIV (4096 DIV V);
UNTIL T<V;
RND:=T
END;
BEGIN (* MAIN PROGRAM *)
R:=MEM(.16436.);
C:=0;
...
END.