TO LOAD THIS PICO-8 CART, in immediate mode, type:
If you are running this code in Pico-8, you will see that the Spritesheet does not contain this picture ! Instead there is only a single line of code, and a PRINT statement at that to create the display you see above. How is this possible ? Well, we need to go back a day to find this out.
I was taking a look at @GPI's marvelous example of multi-poke using P8SCII code:
And I thought to myself, it would be interesting to write code that could save off an entire 128x128 16-color picture as a single print command. Could it be done ? And yes, it could. The picture above for instance is just 8948-text characters directly in source-code as a single PRINT statement.
It looks a little like this:
To do so in your own work and code is quite simple, load up the code I wrote here by bringing up Pico-8 EXE and then loading my cart with:
Change to the directory you have a 128x128 picture you want to convert. From there in immediate mode type,
import pic.png which contains the 128x128 picture you want to convert to a single line of P8SCII code.
Call my function,
spr2p8sci() which is 230-characters long so it's fast and doesn't take much code space.
Once that is done the current picture in the spritesheet will then be saved to clipboard, ready to paste in your code. And be aware that you can post this single line all by itself with nothing else written in your code and it will still display properly.
So in a newly opened Pico-8 process you want to have this picture appear in, in your source-code, press CTRL+P first to enter puny font mode, then press CTRL+V to paste it. Then CTRL+P to leave puny font mode, and there you have it.
Run that code to see that you do not need any functions or code at all except for that one-line to house your picture.
And there you have it !
Now I also want to mention that this is getting compressed of a sort. That is I am NOT just taking every byte of the spritesheet and converting it over with 4-characters in the format,
\000 . Nope, because that would take 32768-characters not even counting the
Nor is it doing it via
\000 for 3-digits. That method takes exactly 30687-characters for the current picture.
No, instead I am converting every single byte to a readable character if it is permitted, going from 30687-characters down to even smaller. Now considering the actual graphic memory is 8192-bytes and even converting raw 8192-bytes to 6-bit yields 10923-characters, this method of P8SCII is quite the compression at only 8948-characters !
Which is only 9% bigger than raw memory. And doubtless that could be compressed further from there.
So, yes, that picture above is only 8948-typed characters with no other code needed.
Also if you want to change the memory your picture is stored instead of the screen, simply change the
?"\^! followed by the 4-digits of hexadecimal memory, currently
6000 you want to put the picture. If if it is
0000 that is the spritesheet, yet you can also store your pictures in high memory such as
Easy to use. Single function, and creates a single line of code close to actual memory size for your picture to display !
Hope This Helps !