Log In  


Cart #mengerspongetest-2 | 2025-09-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

This is also serving as a test for memory manipulation.

And yes i need that first line of code, if you remove it and restart the screen go black.
fixed.



I'm mostly understanding your code :
sponge() draws the fractal to the screen recursively, with 3x3 squares whith a black pixel in the middle at the lowest level.
_draw draws the sponge and the level, copies the screen memory to the sprite sheet, then clear screen and redrawns the fractal scaled with sspr.
Not sure what the sspr(0,123,3,5,56,52,15,25) is about.
What is very weird it the size parameter in the memcpy(0x0000,0x6000,0x6000) call.
Screen size is 128 x 128 x 0.5 = 0x2000 , not 0x6000.
Your memcpy writes garbage to the entire system memory, including draw state and hardware state.
The fact that you fixed the problem by adding another crazy system memory write at the start of the program is baffling to me.
If someone has any insight how the two writes cancel each other, I'm curious.


The first copy will copy the hardware state into himem, so it gets copied back the same as before. You could remove the first one and correct the arguments to the memcpys and it should work fine.


@RealShadowCaster Yeah I uh was very sleep deprived when writing this code. Gonna fix rn. I think my logic with that one was that thats where the spritesheet ends and so thats the screen memory size.
The sspr is the sprite stretching function.
I take the fractal and stretch it to fill the screen.


@Soupster, makes sense, thanks for the explanation.
You'd think something would go very wrong with brute system memory backup/restore, but apparently not. Guess the real CPU memory is safe in the LUA space, so "only" visuals an sound are affected by memory manipulation, as long as cartdata or gpio is not set to anything.
Still, why a black screen... Maybe the palette memory gets zeroed and everything is displayed as black for example...


I gotta remember that i can get hex values in pico-8 through the tostr function instead of guessing.


@qwertyad1,
I see you've fixed the code, but your memcpy size is still too big : 0x4000 is 16K, twice the size of the screen/sprite sheet.
Each pixel is half a byte, so the 16K pixels take 8K or 0x2000 bytes of memory.
This time you are erasing the map and most of the sound from memory on top of the sprite sheet, but both are unsused so it doesn't show.
I'd recommend playing with memsplore.
https://www.lexaloffle.com/bbs/?pid=80908

it's a great way to familiarize yourself with the pico-8 memory layout and/or experiment with magic pokes.



[Please log in to post a comment]