Skip to content

Commit

Permalink
undocument cart editing options, and add export explanation in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismypassport committed Oct 15, 2023
1 parent a6cd122 commit 6df9176
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ The following example imports the spritesheet from a 128x128 image at `spriteshe

## Reading and writing exported formats

Shrinko8 supports reading and writing exported formats. Creating exports through Shrinko8 can be useful in cases when Pico8's compression algorithm isn't able to fit your cart into the export, while Shrinko8's can.

Creating an export requires you to have a copy of Pico8 and provide the pico8.dat file that comes with it as an argument to Shrinko8, as seen [below](#creating-exports).

### Reading exports

Shrinko8 can read the following exports:
Expand Down Expand Up @@ -538,20 +542,6 @@ If you need to explicitly specify the type of each additional input cart, you ca

Also, if both the input and output are exports, all carts from the input get placed in the output, unless `--cart` is explicitly specified.

### Modifying exports

For advanced usecases, you can also modify an existing export. (bin)

To do this, you can pass one of the below options:
* `--insert-cart` to insert a new cart to the export. (The name is taken from the input cart)
* `--insert-cart <name>` to insert a new cart to the export and give it a specific name.
* `--replace-cart <name>` to replace the cart with the specified name
* `--replace-cart` to replace the main cart
* `--delete-cart <name>` to delete the cart with the specified name (no need to pass input cart)
* `--rename-cart <name> <newname>` to rename the cart to the specified name (no need to pass input cart)

Note that modifying existing exports doesn't require `--pico8-dat` - only creating exports does.

# Unminification

You can undo some of the effects of minification, or just reformat the cart's code in a consistent manner:
Expand Down
18 changes: 11 additions & 7 deletions shrinko8.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ def ParsableCountHandler(prefix, name, size, limit):
pgroup.add_argument("--output-cart", help="override name to use for the main cart in the export")
pgroup.add_argument("--extra-input", nargs='+', action="append", metavar=("INPUT [FORMAT [NAME]]", ""),
help="additional input file to place in export (and optionally, the format of the file & the name to use for it in the export)")

pgroup = parser.add_argument_group("other interesting options (semi-undocumented)")
pgroup.add_argument("--template-image", help="template image to use for png carts, instead of the default pico8 template")
pgroup.add_argument("--template-only", action="store_true", help="when creating the png cart, ignore the label & title, using just the template")
pgroup.add_argument("--dump-misc-too", action="store_true", help="causes --dump to also dump misc. files inside the export")
pgroup.add_argument("--version", action="store_true", help="print version of cart. (if no cart is provided - print shrinko8 version and exit)")
pgroup.add_argument("--bbs", action="store_true", help="interpret input as a bbs cart id, e.g. '#...' and download it from the bbs")
pgroup.add_argument("--url", action="store_true", help="interpret input as a URL, and download it from the internet")

pgroup = parser.add_argument_group("export editing options (semi-undocumented)")
pgroup.add_argument("--insert-cart", nargs="*", metavar=("NAME", "BEFORE"), help="add the cart to an existing export. (The default name is the input cart's name)")
pgroup.add_argument("--replace-cart", nargs="*", metavar=("NAME"), help="replace the cart with the given name (Default: main cart) in the export")
pgroup.add_argument("--delete-cart", nargs=1, help="delete the cart with the given name from the export")
Expand All @@ -110,21 +120,15 @@ def ParsableCountHandler(prefix, name, size, limit):
pgroup.add_argument("--trace-compression", help="trace the compressed symbols and their cost into this file")
pgroup.add_argument("--trace-input-compression", help="trace the input's compressed symbols and their cost into this file")

pgroup = parser.add_argument_group("other semi-undocumented options")
pgroup = parser.add_argument_group("other uninteresting options (semi-undocumented)")
pgroup.add_argument("--builtin", type=SplitBySeps, action=extend_arg, help="treat identifier(s) as a pico-8 builtin (for minify, lint, etc.)")
pgroup.add_argument("--not-builtin", type=SplitBySeps, action=extend_arg, help="do not treat identifier(s) as a pico-8 builtin (for minify, lint, etc.)")
pgroup.add_argument("--global-builtins-only", action="store_true", help="assume all builtins are global, corresponds to pico8's -global_api option")
pgroup.add_argument("--local-builtin", type=SplitBySeps, action=extend_arg, help="treat identifier(s) as a local builtin (probably no use outside of testing)")
pgroup.add_argument("--version", action="store_true", help="print version of cart. (if no cart is provided - print shrinko8 version and exit)")
pgroup.add_argument("--bbs", action="store_true", help="interpret input as a bbs cart id, e.g. '#...' and download it from the bbs")
pgroup.add_argument("--url", action="store_true", help="interpret input as a URL, and download it from the internet")
pgroup.add_argument("--ignore-hints", action="store_true", help="ignore shrinko8 hint comments")
pgroup.add_argument("--custom-preprocessor", action="store_true", help="enable a custom preprocessor (#define X 123, #ifdef X, #[X], #[X[[print('X enabled')]]])")
pgroup.add_argument("--dump-misc-too", action="store_true", help="causes --dump to also dump misc. files inside the export")
pgroup.add_argument("--output-sections", type=SplitBySeps, action=extend_arg, help="only output the specified p8 sections {%s,...}" % ",".join(k_def_sections))
pgroup.add_argument("--export-name", help="name to use for the export (by default, taken from output name)")
pgroup.add_argument("--template-image", help="template image to use for png carts, instead of the default pico8 template")
pgroup.add_argument("--template-only", action="store_true", help="when creating the png cart, ignore the label & title, using just the template")

def default_format(input, for_output=False):
ext = path_extension(input)[1:].lower()
Expand Down

0 comments on commit 6df9176

Please sign in to comment.