Log In  


I want to automate calling the save @url command so that I can get the https://www.pico-8-edu.com/ url for my cart programmatically.

Ideally I would be able to use a terminal command like
pico8 -export @url
which would output the url to stdout but that is not supported.

I noticed that the url query string matches the binary contents of a tiny rom export.
This would allow me to construct the url myself, but unfortunately
pico8 -export -t mycart.p8.rom
similarly does not work (the -t flag is only supported when exporting from within the PICO-8 console)

Another possibility would be to parse the p8.png file for the compressed cart contents, but I'm not 100% sure that uses the same format as the tiny rom, and I would like to avoid it if possible.

Does anyone know if there is a way to do this?



So, what the -t flag does is tell pico-8 to export the contents of the cart rom from the address of 0x4300 onward trimming the 0's at the end. I'm not sure if it's all 0's or not, but I'm guessing a url wouldn't suffer from just assuming all 0's. As such, if you export a .p8.rom and then loop through backwards from the end until a non-zero byte, you can then copy the tiny rom contents.

This info is taken from the manual where it lists the 3 types of memory. The cart roms are 32k in the same form as the base ram, but with the addresses above 0x4300 being reserved for the actual code (and also no upper memory).


Nice tip, I didn't realize the tiny rom was a substring of the full rom! It does look like it's all 0's at the end to pad the file to the 32k ROM size.

For anyone trying to do the same thing, I was able to use this python script to make my URL.

import base64

rom_location = '/path/to/mycart.p8.rom'

full_rom = open(rom_location, 'rb').read()
code = full_rom[0x4300:].rstrip(b'\x00')
encoded = base64.b64encode(code, altchars=b'_-').decode('ascii')
url = f'https://pico-8-edu.com/?c={encoded}'
print(url)


[Please log in to post a comment]