Fix AFP extract always decompiling and writing code, fix colors off on some textures for some games.
This commit is contained in:
parent
6ce7ad8f60
commit
8efe913ad5
@ -527,14 +527,17 @@ class TXP2File(TrackedCoverage, VerboseOutput):
|
||||
|
||||
# Since the AFP file format can be found in both big and little endian, its
|
||||
# possible that some of these loaders might need byteswapping on some platforms.
|
||||
# This has been tested on files intended for X86 (little endian).
|
||||
# This has been tested on files intended for X86 (little endian). I've found that
|
||||
# the "correct" thing to do is always treat data as little-endian instead of the
|
||||
# determined endianness of the file. But, this could also be broken per-game, so
|
||||
# I'm not entirely sure this is fully possible to do generically.
|
||||
|
||||
if fmt == 0x0B:
|
||||
# 16-bit 565 color RGB format. Game references D3D9 texture format 23 (R5G6B5).
|
||||
newdata = []
|
||||
for i in range(width * height):
|
||||
pixel = struct.unpack(
|
||||
f"{self.endian}H",
|
||||
"<H",
|
||||
raw_data[(64 + (i * 2)) : (66 + (i * 2))],
|
||||
)[0]
|
||||
|
||||
@ -581,7 +584,7 @@ class TXP2File(TrackedCoverage, VerboseOutput):
|
||||
newdata = []
|
||||
for i in range(width * height):
|
||||
pixel = struct.unpack(
|
||||
f"{self.endian}H",
|
||||
"<H",
|
||||
raw_data[(64 + (i * 2)) : (66 + (i * 2))],
|
||||
)[0]
|
||||
|
||||
@ -661,7 +664,7 @@ class TXP2File(TrackedCoverage, VerboseOutput):
|
||||
newdata = []
|
||||
for i in range(width * height):
|
||||
pixel = struct.unpack(
|
||||
f"{self.endian}H",
|
||||
"<H",
|
||||
raw_data[(64 + (i * 2)) : (66 + (i * 2))],
|
||||
)[0]
|
||||
|
||||
|
@ -26,7 +26,7 @@ from bemani.format.afp import (
|
||||
from bemani.format import IFS
|
||||
|
||||
|
||||
def write_bytecode(swf: SWF, directory: str, *, verbose: bool) -> None:
|
||||
def decompile_and_write_bytecode(swf: SWF, directory: str, *, verbose: bool) -> None:
|
||||
# Actually place the files down.
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
|
||||
@ -103,6 +103,7 @@ def extract_txp2(
|
||||
write_mappings: bool = False,
|
||||
write_raw: bool = False,
|
||||
write_binaries: bool = False,
|
||||
write_bytecode: bool = False,
|
||||
pretend: bool = False,
|
||||
verbose: bool = False,
|
||||
) -> int:
|
||||
@ -312,7 +313,7 @@ def extract_txp2(
|
||||
announced[texturename] = True
|
||||
if write_bytecode:
|
||||
for swf in afpfile.swfdata:
|
||||
write_bytecode(swf, output_dir, verbose=verbose)
|
||||
decompile_and_write_bytecode(swf, output_dir, verbose=verbose)
|
||||
|
||||
return 0
|
||||
|
||||
@ -414,7 +415,7 @@ def decompile_afp(afp: str, bsi: str, output_dir: str, *, verbose: bool = False)
|
||||
|
||||
# Now, decompile it
|
||||
swf.parse(verbose=verbose)
|
||||
write_bytecode(swf, output_dir, verbose=verbose)
|
||||
decompile_and_write_bytecode(swf, output_dir, verbose=verbose)
|
||||
|
||||
return 0
|
||||
|
||||
@ -1375,6 +1376,7 @@ def main() -> int:
|
||||
write_mappings=args.write_mappings,
|
||||
write_raw=args.write_raw,
|
||||
write_binaries=args.write_binaries,
|
||||
write_bytecode=args.write_bytecode,
|
||||
pretend=args.pretend,
|
||||
verbose=args.verbose,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user