Log In  

Cart #yield_fireball-0 | 2019-09-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

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:
https://www.lexaloffle.com/bbs/?tid=31359

and MBoffin HERE:

https://www.lexaloffle.com/bbs/?tid=35381

. . .

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.

P#68002 2019-09-22 16:47 ( Edited 2019-09-22 21:36)

:: sol

a very pretty cartridge, and that debugger trick is something I wish I had thought of :o

P#68076 2019-09-24 01:45
:: dw817
1

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).

[8x8]

[8x8]

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.

P#68082 2019-09-24 02:37
:: sol

@dw817 you can't do any reflection whatsoever on the lua stack, unfortunately. the only situation I can fathom where you might need to do token math anyway is when using #include, and the INFO command helpfully computes the token count for you in that scenario

P#68086 2019-09-24 03:33
:: dw817

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.

P#68088 2019-09-24 03:41 ( Edited 2019-09-24 03:47)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-01-24 02:45 | 0.022s | 2097k | Q:36