I was playing around with the Julia set program from over in the Shed and
it occured to me that FOR loops plotting sequentially is painfully slow to watch; mand.bas
even assumes you want to save a bitmap at the end of the ordeal.
So I replaced them with a never ending DO loop and that just picks random points. (ie:
FOR X=0 to 319 becomes X=319*RND) The picocalc is fast enough that the image is recognizable in about 30 secs and somewhat entertaining to watch as the calculation/plotting drags on.
Of course, there’s nothing to stop it from hitting the same points over and over unless I keep track of what has been already plotted. (A 320x320 array is too big.) So can I PEEK into screen memory somehow and get what value is stored at the address corresponding to pixel X,Y?
Instead of using random numbers, consider using a function that is guaranteed to hit every position only once. The simplest example I can think of is to have a simple counter going from 0 to 320*320, but you reverse the bits of the counter before converting it to a screen location. It’s a bit clunky to do the reversal, but I did find an implementation on TheBackShed (see the brv function):
To convert from the counter to a screen position, it’s simply y=count\320:x=count MOD 320. Note the backslash, that does an integer division.
I haven’t gotten back to mmbasic to try this out because I’ve been diverted by machikania (or is it phyllosoma? )basic: this compiled basic is so fast it really doesn’t matter whether you use for loops or some more creative way to make your iterating bug hop from pixel to pixel.
Im also interested in an answer to your original question of how to PEEK the values in video memory in MMBASIC on PicoCalc. I’m going to dive into the source code on GitHub to see if I can figure out what memory address range the video memory occupies and report back if I figure it out.
@Arron_Addison:Thanks so much for pointing that out so clearly! The MMBasic manual doesn’t mention that the Pixel command can also read color values — Pixel read. Or maybe I just missed it. But that’s quite an important detail when it comes to programming games or fantastic demos for the PicoCalc!
@Blixten You’re absolutely right! The 6.0 manual is slightly different in some parts from the 5.0 manual. On top of that, I still using the German translation of the 5.0 manual. Thanks for the important reminder to update my manual file in Acrobat !