FOR SETEP is faster calculating parameters than using variables
FOR SETEP is faster calculating parameters than using variables
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...
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
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
- Flatulentia
- Posts: 93
- Joined: Sun May 14, 2023 3:58 pm
- Location: Cambridgeshire, UK
Re: FOR SETEP is faster calculating parameters than using variables
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.
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.
ZX81 with ZiLOG Z84 CMOS Z80, 32KB battery-backed Toshiba 55257 SRAM with charge status LED, Wilf's "Why Wait?" mod and switch-mode 5V regulator. 50/60Hz mode switch, composite video output with Zigg's back porch mod and 1080p60 HDMI output.
- 1024MAK
- Posts: 5189
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: FOR SETEP is faster calculating parameters than using variables
PI is definitely useful for saving space. This, along with many other methods is covered in a useful tips topic.
Mark
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
Re: FOR SETEP is faster calculating parameters than using variables
Frequent used variables have to be the first variables defined. That makes finding them much quicker.
In theory, there is no difference between theory and practice. But, in practice, there is.