Skip to content

Commit

Permalink
small updates to picotron tiny rom support
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismypassport committed Aug 26, 2024
1 parent 4e0ffe7 commit 8196bdd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
18 changes: 16 additions & 2 deletions picotron_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pico_cart import load_image_of_size, get_res_path, k_base64_alt_chars, k_png_header
from pico_export import lz4_uncompress, lz4_compress
from pico_defs import decode_luastr, encode_luastr
from pico_compress import print_size, compress_code, encode_p8str, decode_p8str
from pico_compress import print_size, compress_code, uncompress_code, encode_p8str, decode_p8str
from picotron_defs import get_default_picotron_version, Cart64Glob
from picotron_fs import PicotronFile, PicotronDir
import base64
Expand Down Expand Up @@ -146,8 +146,20 @@ def write_cart64_to_rom(cart, size_handler=None, debug_handler=None, padding=0,

return io.getvalue()

def read_cart64_from_tiny_rom(buffer, **opts):
with BinaryReader(BytesIO(buffer), big_end = True) as r:
if r.bytes(3) == k_rom_header_sig:
return read_cart64_from_rom(buffer, **opts)
else:
r.rewind()
tiny_cart = Cart64()
tiny_cart.files[k_p64_main_path] = PicotronFile(encode_p8str(uncompress_code(r, **opts)))
return tiny_cart

def write_cart64_to_tiny_rom(cart, size_handler=None, debug_handler=None, **opts):
data = cart.files[k_p64_main_path].raw_payload
main = cart.files.get(k_p64_main_path)
check(main, "{k_p64_main_path} not found in cart")
data = main.raw_payload

tiny_cart = Cart64()
tiny_cart.files[k_p64_main_path] = PicotronFile(data)
Expand Down Expand Up @@ -482,6 +494,8 @@ def read_cart64(path, format=None, **opts):
return read_cart64_from_image(file_read(path), path=path, **opts)
elif format == Cart64Format.rom:
return read_cart64_from_rom(file_read(path), path=path, **opts)
elif format == Cart64Format.tiny_rom:
return read_cart64_from_tiny_rom(file_read(path), path=path, **opts)
elif format == Cart64Format.lua:
return read_cart64_from_source(file_read(path), raw=True, path=path, **opts)
elif format in (Cart64Format.dir, Cart64Format.fs):
Expand Down
2 changes: 1 addition & 1 deletion shrinko.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from picotron_cart import write_cart64_compressed_size, write_cart64_version
import argparse

k_version = 'v1.2.2e'
k_version = 'v1.2.2f'

def SplitBySeps(val):
return k_hint_split_re.split(val)
Expand Down
8 changes: 6 additions & 2 deletions site/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,12 @@ async function doMinify() {
}

// (adjust p8 preview)
if (isPico8 && format === "tiny-rom") {
args.push("--output-sections", "lua");
if (format === "tiny-rom") {
if (isPico8) {
args.push("--output-sections", "lua");
} else {
args.push("--filter", "main.lua");
}
} else if (format === "url") {
args.push("--output-sections", "lua,gfx");
}
Expand Down

0 comments on commit 8196bdd

Please sign in to comment.