On 8/25/2021 at 1:34 AM, voltage said:
That's a huge speed boost. Are you using fixed point math in place of the default rom routines? That's what I would have attempted.
I've actually thought of something along those lines but with sine/cosine table in ML with a little USR() routine that coughs up a lookup. But that's not quite on the menu (yet!).
On 8/25/2021 at 8:47 AM, Scott Robison said:
Replaced TI$ with "000347"? ?
LOL!
On 8/25/2021 at 8:48 AM, ZeroByte said:
I'd guess that maybe you switched from using simple variables to using an array, with that array being the first variable initialized....
I've tried this, and in game type programs especially it actually helps. Even the first array is slower than about the first 10 or 12 initialized scalar variables because of the interpreter character fetch (parsing) overhead. If you have a variable array "V(n)" and you refer to it in the program with V(1) its got a bunch of extra fetches and a numeric to FAC conversion to do, plus some added overhead because even though BASIC finds your first array at ARYTAB it also runs some extra tests to compare the index you supplied and the dimension of the variable as dimensioned. Also, once there are more than 10 values 'V(0) to V(9)' there's a linear increase in time as you have additional digits of the array index value to parse, i.e., 'V(5)' is faster to parse than 'V(27)'. Alternatively, if you use a regular simple/scaler variable to tell BASIC which element you want e.g., N=A(V), you incur not an extra cost for the 'fetch' of the variable that contains the element number. And its maddening to program with! But it does help create a rather more consistent variable fetch time than just using 24 or 30 scalar variables.
But that's not what I did here.
1. I did not use any assembly/machine code routines. There are no SYS calls, no USR() calls, no pokes and peeks.
2. I did not add data statements.
3. The program does not load anything from the file system. No external data is loaded from any source.
4. The previously fastest program version (the one that clocked in at 6 minutes, 52 seconds above) was 709 bytes long. This version is 878 bytes long. 42 of the new bytes are a print statement and string; and 23 more bytes are fluff to display a 'progress bar'...
5. Its not using turbo mode or any modification of the emulator, ROMs, host operating system or anything like that.
I'll write it up tonight when I get back from some medical stuff today, but it comes down to looking hard at the precursor calculation that gets fed into that COSINES stack and which is based on 'Pythagorean Addition' of our outer and inner loop indexing variable values.
Bottom line the program spends about 1 minute and 39 seconds preparing a lookup table as a 2 dimension array, and the rest of the time plotting to the screen.
More this evening. Cheers!