You ever have that moment when somebody tells you something and you SORT OF get it but not really, and then later, maybe a day or two you cry out, "Ah ha !" because then you understand it ?
Well I'm not going to claim full knowledge of the YIELD() command, but I will tell you what it CAN do - at least for me.
I can take any program I've written to date and make it OOPS very simply.
Replace all FLIP() with YIELD(), then make a coroutine to run my MAIN() function. Done.
But it goes beyond this. Since I can now join the ranks of _DRAW() and _UPDATE() this means I can write a custom background engine that operates exactly as I like it.
In this case for this example you can hit "Q" and bring up Quick Debugger which shows memory usage and how much of the CPU is being tasked. You can also hit [ESC] and type RESUME to leave off where you where.
Before YIELD() I couldn't do either of these things nor read the CPU. Now I can. This does herald the END of FLIP() for me and the very welcome arrival of YIELD().
What does this mean for you ? YIELD() does not just exit a function it retains the exact position when you return even if you were nested in a whirl of FOR/DO, IF/END, and REPEAT/UNTIL statements. It also retains all local variables and values at the point you exit and return. That is immensely powerful.
Giving credit where credit is due. I found out about YIELD() from freds72 HERE:
and MBoffin HERE:
. . .
More and more I begin to appreciate this Pico-8 system and daresay it is the most powerful programming language I have ever come across.
Glad you like it. I've since added to it, displays what joystick keys are being touched with this new icon.
Changed the rabbit too (CPU usage).
Later though. I was wondering if there was a way to read the source-code size in code so I could also monitor it. The number of symbols <=8192.
I know the editor already has it build in the corner, just was curious to see if it could also be read and acted on by the programmer.
Yeah, that's what I really want. TOTO access to memory. :D Maybe a sweet POKE() somewhere to swap memory and then when you PEEK you can read not only the cart in, every memory value that couldn't be read including the 3x5 character set, the Pico-8 boot logo, the works.
You could read the existing 7x5 icons for instance or write new ones through POKE. No way to record it to your program's binary data of course, but a few POKEs in your source would change 'em when you run. I think the PET computer could do this - had a modifiable B&W 8x8 character set.
[Please log in to post a comment]