mirror of
https://github.com/pmret/papermario.git
synced 2024-11-18 08:52:40 +01:00
build images
This commit is contained in:
parent
c46c637c31
commit
f35cca8b0b
26
configure.py
26
configure.py
@ -31,6 +31,7 @@ def obj(path: str):
|
|||||||
def read_splat(splat_config: str):
|
def read_splat(splat_config: str):
|
||||||
import argparse
|
import argparse
|
||||||
import yaml
|
import yaml
|
||||||
|
from segtypes.n64.code import N64SegCode
|
||||||
|
|
||||||
# Load config
|
# Load config
|
||||||
with open(splat_config) as f:
|
with open(splat_config) as f:
|
||||||
@ -52,6 +53,17 @@ def read_splat(splat_config: str):
|
|||||||
objects.add(path)
|
objects.add(path)
|
||||||
segments[path] = segment
|
segments[path] = segment
|
||||||
|
|
||||||
|
if isinstance(segment, N64SegCode):
|
||||||
|
for split_file in segment.files:
|
||||||
|
if split_file["subtype"] in ["ci4", "palette"]:
|
||||||
|
path = os.path.join(
|
||||||
|
"src",
|
||||||
|
split_file["name"] + "." + segment.get_ext(split_file["subtype"])
|
||||||
|
)
|
||||||
|
|
||||||
|
if path in segments:
|
||||||
|
segments[path] = split_file
|
||||||
|
|
||||||
# note: `objects` lacks .o extensions
|
# note: `objects` lacks .o extensions
|
||||||
return objects, segments
|
return objects, segments
|
||||||
|
|
||||||
@ -102,13 +114,11 @@ def build_image(f: str, segment):
|
|||||||
out = "$builddir/" + path + "." + img_type + ".png"
|
out = "$builddir/" + path + "." + img_type + ".png"
|
||||||
|
|
||||||
flags = ""
|
flags = ""
|
||||||
"""
|
|
||||||
if img_type != "palette":
|
if img_type != "palette":
|
||||||
if segment.flip_horizontal:
|
if segment.flip_horizontal:
|
||||||
flags += "--flip-x"
|
flags += "--flip-x"
|
||||||
if segment.flip_vertical:
|
if segment.flip_vertical:
|
||||||
flags += "--flip-y"
|
flags += "--flip-y"
|
||||||
"""
|
|
||||||
|
|
||||||
n.build(out, "img", path + ".png", implicit="tools/convert_image.py", variables={
|
n.build(out, "img", path + ".png", implicit="tools/convert_image.py", variables={
|
||||||
"img_type": img_type,
|
"img_type": img_type,
|
||||||
@ -413,7 +423,17 @@ async def main():
|
|||||||
elif f.endswith(".s"):
|
elif f.endswith(".s"):
|
||||||
n.build(obj(f), "as", f)
|
n.build(obj(f), "as", f)
|
||||||
elif f.endswith(".png"):
|
elif f.endswith(".png"):
|
||||||
build_image(f, segment)
|
if isinstance(segment, dict):
|
||||||
|
# image within a code section
|
||||||
|
out = "$builddir/" + f + ".bin"
|
||||||
|
n.build(out, "img", f, implicit="tools/convert_image.py", variables={
|
||||||
|
"img_type": segment["subtype"],
|
||||||
|
"img_flags": "",
|
||||||
|
})
|
||||||
|
|
||||||
|
n.build("$builddir/" + f + ".o", "bin", out)
|
||||||
|
else:
|
||||||
|
build_image(f, segment)
|
||||||
elif f == "sprite/npc":
|
elif f == "sprite/npc":
|
||||||
# combine sprites
|
# combine sprites
|
||||||
n.build(f"$builddir/{f}.bin", "npc_sprites", npc_sprite_yay0s, implicit="tools/compile_npc_sprites.py")
|
n.build(f"$builddir/{f}.bin", "npc_sprites", npc_sprite_yay0s, implicit="tools/compile_npc_sprites.py")
|
||||||
|
@ -15,8 +15,8 @@ Gfx D_802A1A60_7303C0[] = {
|
|||||||
gsDPSetTextureFilter(G_TF_AVERAGE),
|
gsDPSetTextureFilter(G_TF_AVERAGE),
|
||||||
gsDPSetTextureConvert(G_TC_FILT),
|
gsDPSetTextureConvert(G_TC_FILT),
|
||||||
gsDPSetTextureLUT(G_TT_RGBA16),
|
gsDPSetTextureLUT(G_TT_RGBA16),
|
||||||
gsDPLoadTLUT_pal16(0, &D_802A1A00_730360),
|
gsDPLoadTLUT_pal16(0, &battle_item_coconut_coconut_png),
|
||||||
gsDPLoadTextureTile_4b(&D_802A1800_730160, G_IM_FMT_CI, 32, 0, 0, 0, 31, 31, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD),
|
gsDPLoadTextureTile_4b(&battle_item_coconut_coconut_png, G_IM_FMT_CI, 32, 0, 0, 0, 31, 31, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD),
|
||||||
gsSPClearGeometryMode(G_LIGHTING),
|
gsSPClearGeometryMode(G_LIGHTING),
|
||||||
gsSPClearGeometryMode(G_SHADING_SMOOTH),
|
gsSPClearGeometryMode(G_SHADING_SMOOTH),
|
||||||
gsSPVertex(&D_802A1A20_730380, 4, 0),
|
gsSPVertex(&D_802A1A20_730380, 4, 0),
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
#undef NAMESPACE
|
#undef NAMESPACE
|
||||||
#define NAMESPACE battle_item_coconut
|
#define NAMESPACE battle_item_coconut
|
||||||
|
|
||||||
|
Script D_802A1240_72F960;
|
||||||
|
Script D_802A1670_72FFD0;
|
||||||
|
|
||||||
ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall);
|
ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall);
|
||||||
ApiStatus func_802A11D4_72F8F4(ScriptInstance* script, s32 isInitialCall);
|
ApiStatus func_802A11D4_72F8F4(ScriptInstance* script, s32 isInitialCall);
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ class Converter():
|
|||||||
for row in reversed_if(img.read()[2], self.flip_y):
|
for row in reversed_if(img.read()[2], self.flip_y):
|
||||||
for a, b in iter_in_groups(row, 2):
|
for a, b in iter_in_groups(row, 2):
|
||||||
byte = (a << 4) | b
|
byte = (a << 4) | b
|
||||||
|
byte = byte & 0xFF
|
||||||
f.write(byte.to_bytes(1, byteorder="big"))
|
f.write(byte.to_bytes(1, byteorder="big"))
|
||||||
elif self.mode == "palette":
|
elif self.mode == "palette":
|
||||||
img.preamble(True)
|
img.preamble(True)
|
||||||
|
@ -18,7 +18,7 @@ class N64SegCi8(N64SegRgba16):
|
|||||||
if self.compressed:
|
if self.compressed:
|
||||||
data = Yay0decompress.decompress_yay0(data)
|
data = Yay0decompress.decompress_yay0(data)
|
||||||
|
|
||||||
self.image = N64SegCi8.parse_image(data)
|
self.image = type(self).parse_image(data, self.width, self.height)
|
||||||
|
|
||||||
def postsplit(self, segments):
|
def postsplit(self, segments):
|
||||||
palettes = [seg for seg in segments if seg.type ==
|
palettes = [seg for seg in segments if seg.type ==
|
||||||
@ -53,7 +53,7 @@ class N64SegCi8(N64SegRgba16):
|
|||||||
f"No unnamed palette for {self.name}; wrote image data to {self.path}")
|
f"No unnamed palette for {self.name}; wrote image data to {self.path}")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_image(data):
|
def parse_image(data, width, height):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def max_length(self):
|
def max_length(self):
|
||||||
|
@ -849,7 +849,7 @@ class N64SegCode(N64Segment):
|
|||||||
split_file["name"] + "." + self.get_ext(split_file["subtype"])
|
split_file["name"] + "." + self.get_ext(split_file["subtype"])
|
||||||
)
|
)
|
||||||
|
|
||||||
if file_type == "ci4":
|
if file_type == "ci4" and (file_type in self.options["modes"] or "all" in self.options["modes"] or "img" in self.options["modes"]):
|
||||||
from segtypes.n64.ci4 import N64SegCi4
|
from segtypes.n64.ci4 import N64SegCi4
|
||||||
|
|
||||||
width, height = split_file["args"]
|
width, height = split_file["args"]
|
||||||
@ -862,6 +862,8 @@ class N64SegCode(N64Segment):
|
|||||||
|
|
||||||
# TODO other image types
|
# TODO other image types
|
||||||
|
|
||||||
|
# TODO write orphaned palettes
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_subdir(subtype):
|
def get_subdir(subtype):
|
||||||
if subtype in ["c", ".data", ".rodata", ".bss", "i4", "i8", "ia4", "ia8", "ia16", "rgba16", "rgba32", "ci4", "ci8", "palette"]:
|
if subtype in ["c", ".data", ".rodata", ".bss", "i4", "i8", "ia4", "ia8", "ia16", "rgba16", "rgba32", "ci4", "ci8", "palette"]:
|
||||||
@ -879,7 +881,7 @@ class N64SegCode(N64Segment):
|
|||||||
elif subtype == "bin":
|
elif subtype == "bin":
|
||||||
return "bin"
|
return "bin"
|
||||||
elif subtype in ["i4", "i8", "ia4", "ia8", "ia16", "rgba16", "rgba32", "ci4", "ci8", "palette"]:
|
elif subtype in ["i4", "i8", "ia4", "ia8", "ia16", "rgba16", "rgba32", "ci4", "ci8", "palette"]:
|
||||||
return subtype + ".png"
|
return "png"
|
||||||
return subtype
|
return subtype
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
from util import log
|
from util import log
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
default_subalign = 16
|
default_subalign = 16
|
||||||
|
|
||||||
@ -138,6 +139,9 @@ class Segment:
|
|||||||
f"SPLAT_BEGIN_SEG({tmp_sect_name}, 0x{start:X}, 0x{tmp_vram:X}, {subalign_str})\n"
|
f"SPLAT_BEGIN_SEG({tmp_sect_name}, 0x{start:X}, 0x{tmp_vram:X}, {subalign_str})\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
path_cname = re.sub(r"[^0-9a-zA-Z_]", "_", path)
|
||||||
|
s += f" {path_cname} = .;\n"
|
||||||
|
|
||||||
path = PurePath(subdir) / PurePath(path)
|
path = PurePath(subdir) / PurePath(path)
|
||||||
path = path.with_suffix(".o" if replace_ext else path.suffix + ".o")
|
path = path.with_suffix(".o" if replace_ext else path.suffix + ".o")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user