1 LET I=VAL "0"
2 LET X=I
3 LET Y=I
4 LET X1=PI/PI
5 LET Y1=X1
6 FOR I=X TO X1
7 PRINT AT Y,X;" "
8 LET X=X+X1
9 LET Y=Y+Y1
10 IF X>=VAL "31" THEN LET X1=VAL "-1"
11 IF X<=PI-PI THEN LET X1=PI/PI
12 IF Y>=VAL "21" THEN LET Y1=VAL "-1"
13 IF Y<=PI-PI THEN LET Y1=PI/PI
14 PRINT AT Y,X;"O"
15 LET I=VAL "0"
16 NEXT I
Obviously does not use GOTO, which I don't think would be any quicker, just another way to solve the same problem.
There might be a way to minimise the if statements somehow but my brain isn't working at the moment - any suggestions and fixes are welcome
Well your avoidance of GOTO has simply made it use more bytes really, as well as subverting the usual meaning of FOR. But anyway - one thing I remember from my 1K days is that NOT PI gives you zero in two bytes, whereas PI-PI takes 3 bytes.
command LET x = CODE "symbol" much faster = VAL "NN".
Unfortunately not always suitable.
But the VAL"31" and VAL "21" should be replaced by CODE "3" and CODE"+".
"The Earth is just too small and fragile a basket for the human race to keep all its eggs in." ― Robert Anson Heinlein
Elektronika MK61, Psion series 5mx have now. Many years ago had Spectrum 48, 128k/TRDOS and Amiga A600 ...
In the emulator available here http://rullf2.xs4all.nl/sg/z81-2.2.tar.gz I've added a startup flag (-f) so that the six bytes after a number are not stored in the BASIC program when lines are entered. Programs still run, but of course more slowly. Just for fun, to see what changes are needed to the ROM (23 bytes, see function zx81hacks), and to evaluate the decrease in performance. When a p-file is loaded, the six bytes are shown as cursor characters; this could be improved, but gives a visual indication of the space needed to store the floating point numbers.
As I'm back on 8-bit stuff again, after at least a few years, I thought I'd post this bouncing ball thing but using PLOT/UNPLOT stuff (attached as an image).