mirror of
https://github.com/pmret/papermario.git
synced 2024-11-18 08:52:40 +01:00
73af4eb5a0
* git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "ec7bd4868e" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "ec7bd4868e" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * wips * more * wipperz * it workz * mdl_make_local_vertex_copy * sleep_bubble finished + gfx * fire_breath gfx * func_800F0490 * func_800EFE2C * 8a860 funcs * cleanup + dead cod * dead clean * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "a1730f38ad" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "a1730f38ad" git-subrepo: version: "0.4.5" origin: "https://github.com/ingydotnet/git-subrepo" commit: "aa416e4" * cleanup + splat prep * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "4e5fca24a5" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "4e5fca24a5" git-subrepo: version: "0.4.5" origin: "https://github.com/ingydotnet/git-subrepo" commit: "aa416e4" * bits * clean * bss c -> asm * btl_update_starpoints_display * is_debug + cleanup * load_script / 190B20 data * all the symz * clean * cleanup + stuff
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
from segtypes.n64.segment import N64Segment
|
|
from segtypes.n64.palette import iter_in_groups
|
|
from util.color import unpack_color
|
|
from util import options
|
|
import png
|
|
|
|
def parse_palette(data):
|
|
palette = []
|
|
|
|
for a, b in iter_in_groups(data, 2):
|
|
palette.append(unpack_color([a, b]))
|
|
|
|
return palette
|
|
|
|
class N64SegPm_charset_palettes(N64Segment):
|
|
require_unique_name = False
|
|
|
|
def scan(self, rom_bytes):
|
|
data = rom_bytes[self.rom_start:self.rom_end]
|
|
|
|
# pm_charset sibling
|
|
self.sibling = next(filter(lambda s: s.type == "pm_charset" and s.name == self.name, self.parent.subsegments))
|
|
|
|
self.palettes = []
|
|
|
|
for i in range(0, self.size, 0x10):
|
|
palette = parse_palette(data[i : i + 0x10])
|
|
self.palettes.append(palette)
|
|
|
|
def split(self, rom_bytes):
|
|
fs_dir = options.opts.asset_path / self.dir / self.name / "palette"
|
|
fs_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
for i, palette in enumerate(self.palettes):
|
|
raster = self.sibling.rasters[0]
|
|
|
|
w = png.Writer(self.sibling.width, self.sibling.height, palette=palette)
|
|
with open(fs_dir / f"{i:02X}.png", "wb") as f:
|
|
w.write_array(f, raster)
|
|
|
|
def get_linker_entries(self):
|
|
from segtypes.linker_entry import LinkerEntry
|
|
|
|
fs_dir = options.opts.asset_path / self.dir / self.name / "palette"
|
|
|
|
return [LinkerEntry(
|
|
self,
|
|
[fs_dir / f"{i:02X}.png" for i in range(self.yaml[3])],
|
|
fs_dir.with_suffix(".dat"), ".data"),
|
|
]
|