XavSnap wrote: ↑Sat Apr 18, 2020 1:14 am
Hi,
In this point, don't store your values in integer format (DIM TABLE(x,y)), but in chars values to preserve memory !
1 DIM T$(10,2)
; 10 values, and 2 chars by value
10 LET X=CODE T$(1,1)
20 LET Y=CODE T$(1,2)
Use CHR$(x) or CHR$(y) to set the value !
In integer format, each value take 6 bytes…
In character format, only 1 byte per value.
yes,,sadly ZX81 can´t define variables as integers,, I miss something like LET A%...
sadly 2 MCODER is not able to mange strings like basic.. I could use REM statements but 126 and 118 values are troublesome... do you know if is there something written about?
I think I can use 32 bytes at PRBUFF to store parameters,, do you think is safe enough? i am not planing to use a printer,, and parameters may be cleared when routines are not called,,, but as you may notice I have just discovered it...
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
1 DIM T$(50,2)
2 LET CNT=1
5 PRINT "BUILD ARRAY"
10 FOR A=-3.14 TO 3.14 STEP ((3.14)/25)
20 LET X=INT(SIN (A)*10)+20
30 LET Y=INT(COS (A)*10)+20
40 LET T$(CNT)=CHR$ X+ CHR$ Y
50 LET CNT=CNT+1
60 REM PLOT X,Y
70 IF CNT<51 THEN NEXT A
80 CLS
90 REM DISPLAY
100 FOR A=1 TO 50
110 LET X=CODE T$(A,1)
120 LET Y=CODE T$(A,2)
130 PLOT X-7,Y+5
132 PLOT X+13,Y+5
134 PLOT X+33,Y+5
136 PLOT X+23,Y-10
138 PLOT X+4,Y-10
140 NEXT A
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
I am working on this but I whant to keep an aray with SIN and COS in degrees ( not in radians) to avoid recalculations, as SIN and /or COS are values from -1.00 to +1.00, I plan to store values in one char$ from 1 to 90 *100 and +100 to fit values in a range from 000 to 200,, then 640 values can be calculated as needed upon wich cuadrant do you need.. i haven´t tested speeds yet,, I´m not avoiding the division and .. i havent determined the resolution/precision I will need... to have 640 values in floating point arrays is fast but eats lots of memmory...
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come
You probably worked this out already, but you only need to store one set of values for both SIN and COS because SIN X is COS(90-X) and vice versa. That might save a few bytes.
solar penguin wrote: ↑Thu Apr 30, 2020 9:38 am
You probably worked this out already, but you only need to store one set of values for both SIN and COS because SIN X is COS(90-X) and vice versa. That might save a few bytes.
Thanks.. yes .. my idea was to store just 90dgrees of values and then shift and chance sign to get both 360.. but now I am lackin of any time
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come