Log In  

I was curious to know if there is a known memory layout of any of the PNG games.

I would be more than happy to write a comprehensive external graphic editor if I knew how to access the image files and where they are located in the PNG cartridge.

P#27476 2016-08-27 12:35 ( Edited 2016-09-01 07:40)

Take a look at picolove, there's a PNG decoder in there.

https://github.com/picolove/picolove

P#27484 2016-08-27 15:34 ( Edited 2016-08-27 19:34)

Matt, is it a PNG decoder for the image or a PNG decoder that shows where the hidden data of the PNG is ?

That's what I'm interested in - not the visual PNG data.

P#27496 2016-08-27 20:33 ( Edited 2016-08-28 00:33)

Picolove probably has what you're looking for. See also picotool, which can read .p8.png files, provide programmatic access to all of the cart code and data, and save .p8 files, in Python: http://github.com/dansanderson/picotool/

P#27514 2016-08-28 00:53 ( Edited 2016-08-28 04:54)

Dan (or anyone who can answer this), is there a program that takes the .PNG (not .p8) and breaks out the 5-files internal ? Code, Tiles, Maps, Sound, and Music ?

P#27662 2016-08-29 15:18 ( Edited 2016-08-29 19:19)

picotool offers Python APIs to read and write all of the sections of a cart (code, tiles, maps, sound, music). It can read .p8.png files as well as .p8. (It only writes .p8 for now.)

P#27665 2016-08-29 15:40 ( Edited 2016-08-29 19:40)

OK, I'm very new to this. There are no EXEs in the PICO TOOLS. The directory name is, "picotool-master."

Inside are several files. There is one in the root called, "run_tests.py"

In executing that, it does a quick DOS SHELL and returns back to the filer.

Is there a way to convert a .PY to .EXE ... or is there some other way of running this file ?

P#27666 2016-08-29 15:58 ( Edited 2016-08-29 19:58)

Run it on the command line using python

P#27739 2016-08-30 19:43 ( Edited 2016-08-30 23:43)

I've got Python 3.5.2 shell running.

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>

In the command line, how do I load to work with one of the .PNG files ? And I gotta ask, why on Earth did they use Python instead of just a comfortable Windows EXE ??

To save me trouble, =IS= there a memory layout of the PICO game cartridge ? If it's exact and specific I can certainly write a utility on my own - compiled as an EXE to work with the data files and post it for everyone to make use of.

P#27752 2016-08-30 23:47 ( Edited 2016-08-31 03:47)

I think everyone can make use of the picotool code, a lot more than a EXE (I use Linux and I would have no use — or trust — for such a program).

The layout from 0x0000 to 0x42ff is exactly the same in the PNG cartridge (once decoded) as in the console’s memory. In that sense the format is a lot simpler to parse than the .p8 format. The code that decodes the byte array within the PNG is in picotool’s game.py, around line 200. That’s all you need, 10 lines of code.

Then there is the Lua code, which is not exactly in memory. It’s stored at 0x4300 in the game cartridge, and you may need to decompress it. Picotool does it in game.py, too, around line 225.

P#27762 2016-08-31 05:00 ( Edited 2016-08-31 09:00)

Hi SAM. Thanks for the info. Ok, I've messed with PYTHON a bit more and am still not having much luck. I've downloaded presumably both parts needed.

picotool-master (DIR) 402k
python-3.5.2.exe 27.91mb

Now what steps do I take may I ask to get it working proper where I can both extract and import data ?

P#27773 2016-08-31 09:50 ( Edited 2016-08-31 13:51)

picotool is a Python library you can use to build tools in the Python language. Notice that you need to do this to do what you're trying to accomplish: you need to write the code that converts the raw Pico-8 data into whatever format you're trying to use.

If you want the result to be a file containing a raw dump of the Pico-8 cart ROM in memory order, you can do that easily with a small amount of Python code. picotool does the heavy lifting of processing the .p8.png file into a Python variable containing the bytes, and you just need to write the code that dumps this into a file. You could probably even type this code at the Python ">>>" prompt without having to create a tool for it. I can try this out and give more explicit instructions, if this is actually what you need.

Can you explain what you're trying to do with the data?

P#27813 2016-09-01 02:15 ( Edited 2016-09-01 06:15)

-- Ah, you mentioned working on a graphics editor at the top of the thread. I should point out that Pico-8 already knows how to save and load its sprite sheet as a PNG file. Typing "export foo.png" and "import foo.png" at the command prompt will save and load/overwrite the sprite sheet of the current cart from a PNG image file. So without much difficulty, you can construct your image editor to just read and write these PNG files, and instruct users to import/export the result.

Of course it's fun and more useful to implement cart saving/loading directly. Unless you plan to implement the editor app in Python, you're better off just learning the file format than trying to execute picotool's code. You can use picotool as an example and port the algorithm. The actual PNG reading occurs in a third-party library, but once you're able to read the color values of the PNG image, you can see pico8/game/game.py for how to extract the cart data from the image. Once you have the cart data, see http://pico-8.wikia.com/wiki/Memory for a description of the layout and format of the graphics.

picotool doesn't yet have an example of saving a .p8.png cart, but if you're only changing the graphics region, you can overwrite the lower bits of the corresponding byte range in the .png file without worrying about the other sections.

P#27821 2016-09-01 03:40 ( Edited 2016-09-01 07:41)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 08:31:44 | 0.008s | Q:24