adamlwgriffiths / qbasic-fractal

Mandelbrot in QBasic
2 stars 2 forks source link

~~Tiny~~ *Significant* speedup by not doing an exponent calculation #2

Closed lilithebowman closed 3 years ago

lilithebowman commented 3 years ago

Simply changed 2^2 to 4

adamlwgriffiths commented 3 years ago

Is there any performance improvement for changing the x^2 to x*x? I'm unsure if there's a difference in how those are handled.

lilithebowman commented 3 years ago

Is there any performance improvement for changing the x^2 to x*x? I'm unsure if there's a difference in how those are handled.

You might be right there. I've also written a SUBroutine that saves out the screen in raw format to a file (as CHR$ of POINT(x,y))

SUB SaveScreen (filename AS STRING, w AS INTEGER, h AS INTEGER)
    OPEN filename FOR OUTPUT AS #1
        FOR y = 0 TO h - 1
            FOR x = 0 TO w - 1
                PRINT #1, CHR$(POINT(x, y));
            NEXT x
        NEXT y
    CLOSE #1
SUB END

Not as useful on a PC where you can screenshot things but this is the only way for me to screenshot it on real hardware :D

It can be re-loaded by basically making the reverse logic in a function.

lilithebowman commented 3 years ago

Yeah I made these edits on an 8088 CPU (NEC V20) and even for sections in the middle of the set where the value keeps going up and up until the cutoff it's significantly faster. For the other sections it obviously whips across the screen where before it used to crawl.

So I think these are good edits.

adamlwgriffiths commented 3 years ago

Fantastic, thanks for trying those changes out.