Page 1 of 1

FOR SETEP is faster calculating parameters than using variables

Posted: Mon May 15, 2023 1:40 am
by bola_dor
:shock:
I was playng arroud drawing circles an elipses and found that using
FOR A=0 TO 2*PI STEP 2*PI/L
Is faster than using variables replacing both the counter end and the STEP paremeter with precalculated variables. it was almost a seccond from 77s but it means several bytes less too
thet wasn´t the same when I replaced L wit the elpse perimeter formula that includes SQR and **.
I guess PI is faster to retrieve than any variable but I thought division and multiplication would cost much more frames...

Re: FOR SETEP is faster calculating parameters than using variables

Posted: Mon May 15, 2023 2:55 am
by Flatulentia
I'm very rusty when it comes to programming my ZX81, but isn't this something to do with the use of PI requiring less bytes to be read?

I seem to remember using various incantations of PI (eg, PI-PI instead of 0) for space saving on a 1K ZX81 many years ago.

Re: FOR SETEP is faster calculating parameters than using variables

Posted: Mon May 15, 2023 8:06 am
by 1024MAK
PI is definitely useful for saving space. This, along with many other methods is covered in a useful tips topic.

Mark

Re: FOR SETEP is faster calculating parameters than using variables

Posted: Mon May 15, 2023 10:37 am
by Paul
Frequent used variables have to be the first variables defined. That makes finding them much quicker.