dansanderson / picotool

Tools and Python libraries for manipulating Pico-8 game files. http://www.lexaloffle.com/pico-8.php
MIT License
367 stars 46 forks source link

Build is producing gibberish for my cart, not sure why. #45

Open relsqui opened 6 years ago

relsqui commented 6 years ago

Hiya,

I have an otherwise-perfectly-fine .p8 file which is over the compressed size limit, so I'm trying to minify it. I tried this:

./picotool/p8tool build dragondell.p8.png --lua dragondell.p8 --gfx dragondell.p8 --lua-minify

and it produced no error, but when I run stats on the resulting .p8.png, I get:

dragondell.p8.png: Syntax error (remaining:b'\x15\x1a\x1c! \x1f\x01\x18\x1b\x0f \x18\x02\x17\x11%;\x18\x11\x12 9<:\x1e\x15\x13\x14<[!\x1c=C\x10\x1b#\x1a=M\x1b>D$\x023\x02\x039\x02\x049\x02\x059\x02\x069\x02\x079\x02\x08A\xaf\x0f\x1b\x18\x1b\x1e<\x16\x10\x11Bd=2;\x0e\x18 \x0f\x179<]\x10\x17\x0e\x18!\x11<\x8e\x1e\x11\x10=\x8b\x13\x1e\x11\x11C\x14?W\x1eD1@D\x1b\x18\x15"?v\x13\x1e %A`#\x14\x15 @\x7f@\x9d\x1b\x1e \x1a\x13Bx%\x11\x18\x18\x1b#@\x80B\xa7D\xbfA\xab\x1c\x15\x1aGw\x1c\x11 \x0f\x14L\xf0\x02\x089\x02\t9\x02\n9\x02\x0b9\x02\x0cM\x1bM/N\x10\x04N\x11\x04N\x12\x04N\x13\x04\x08SQ\x1e\x1b% \x18;N5\x1fP\x1a,G\xf4E\xf8\x11\x02-W?\x19 \x1c\x02 \x15\x18Qw<,;\x1e\x1bQ%<;\x0e!\x1f\x14<[ P\x12<\x9b \x1bX\x1d>?# \x18\x18<\x9b;=\x1aX\x1f\x04G\x1e\x05Y\x11\x07H\x10\x06Y\x16\x08Y*\tB\xa7#  \x11\x1e@t<\x1c;\x1fBa<_Q\x17=\x9e\x1a=\xce\x1a#_\x15\x07M\x1b\x06^\x1e\x06N\x1f\x08`\x12\x08\x04H\xa9\x0f\x1b\x15b\x18<{\x1f<l\x14\x11\x1fe\x1dJ<f\x1c>b]EL2\x1c\x18!P)\x08S\x1cS)\x05T\x1a\x07e\x1a\x07f!\x03N\xab_\x10\x1fAg\x10 \x15\x1f@m !\x18\x15N`\x19P\x14\x1e\x1b\x1b\x19j\x14\x06j\x15\x06M%Y\x18\x07L\xbd\x0f \x1f S\x1b\x1aKc=`Sc>PMs=`\x11A&^\x16\x06^\x17\x08o\x1a\x08\x07X\xaa\x1c\x1b\x1e ]\x1aV\x8c=Q\x0e\x1b  EAa\x1b\x08`g[=\x14\x11 \x1eMm\x11$\x0f\x18 \x19  \x15\x1bPg\x1f\x19\x1b\x17C#cOf\x13\x05\x01\x01\x01\x12!\x1a\x0f>$\x02!\x1a\x1cu\x10*{\x19\x12\x1e\x1b\x19`\x13\x1b+\x01\x02\x02\x02<>z\x12<7x\x18\x04=5 \x1b{\x15<\x15y\x19( >7\x15\x12>J1=, \x14\x11\x1a\x02\x1e\x11 !\x1e\x1a\x02\x11\x1a\x10@8<_ .A//9C\xd02\x7f\x1fC">.E\x84\x0f \x1e"\x11;E *$9\x02y\x1d\x19 &\x11EG\x86N\x10\x15oU\x87\xf7\x87\xf7\x87\x17o\x18I"\x8d\x17\x1f\x14!\x12\x12\x18\x11F)I\x15\x10\x11\x1eJK\x86\x18\x15\x88\x1e(A\'\x892\n') at line 1 char 1
dragondell.p8.png: could not load cart

I can load it into Pico-8, and the graphics look fine, but the code section is garbage.

Things I tried:

I see in the readme that picotool sometimes "rejects a cart with a syntax error but Pico-8 accepts it," which I suppose could be the case, but I'm not sure how I'd determine that, nor what the numbers in parentheses afterwards refer to (since they don't seem to be either issue numbers or cart numbers).

Any ideas what might be up, or anything else I can try? Apparently Github won't let me attach a .p8 file, but I'd be happy to send it to you another way if that's helpful. (It's a slightly newer and apparently slightly larger version of this one: https://www.lexaloffle.com/bbs/?tid=30999)

Thanks!

relsqui commented 6 years ago

Possibly relevant: building the cart with picotool appears to change the cart version, or claims it does.

relsqui@albatross:~/pico8$ ./picotool/p8tool stats dragondell.p8
dRAGONDELL (dragondell.p8)
BY rELSQUI
- version: 16
- lines: 1652
- chars: 52134
- tokens: 8497
- compressed chars: 15566

relsqui@albatross:~/pico8$ ./picotool/p8tool build dragondell.p8.png --lua dragondell.p8 --lua-minify
relsqui@albatross:~/pico8$ ./picotool/p8tool stats dragondell.p8.png
dragondell.p8.png
- version: 8
- lines: 1378
- chars: 23743
- tokens: 8497
- compressed chars: 8720

(Version 16 is accurate to how the cart was created.) I also just noticed that the token count reported by picotool is much higher than that reported by pico8 -- 8497 vs. 7696.

hsandt commented 6 years ago

Same issue with code becoming garbage. Sprites are fine, but map, sound and music (basically all the rest) are also garbage. Maybe this is due to an update in PICO-8 as @relsqui suggested, which changed how bytes are handled for png generation. This currently makes build .p8.png unusable, so I can't automate it with my CI. Instead, when I really want a cartridge release I will have to open PICO-8 locally, add the game title / author comment lines myself at the top of the source (my label lines are preserved when building on top of an existing p8), then enter "save mygame.p8.png" and upload the resulting file manually to GitHub.

p8tool map issue on png build

hsandt commented 6 years ago

Note that a .p8 build works fine, only .p8.png fails. In other words, to_p8_file works fine, but not to_p8png_file.