Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions psprecomp/docs/installer.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ of the fork.
of what the current stage does in the information panel. The step weights live in `setup/install.cpp`.
- **Add to Steam** (desktop only; an Options toggle, and a row on the start page of an installed game): `plan_steam` runs `games/dissidia/tools/steam_shortcut.py` (Linux, Windows; the script also serves the Steam Deck setup) to add a non-Steam shortcut to every Steam account on the machine, pointing at `DissidiaRecomp --launch` (check for an update, then play), with the game's icon and the disc's PIC1.PNG as banner. Steam is closed for a moment (`-shutdown`) and started again, because it rewrites its shortcut list on exit. The step is optional: no Steam installed only adds a note to the last page.
- **Change extras** (start page of an installed game): the Extras page again, applied without a rebuild (`plan_extras`): downloads / swaps / removes the HD texture pack, adds the Japanese voices, builds the Android version once.
- **Disc checks at pick time** (`install.cpp` `read_disc_id`, `d1_disc_problem`, `undub_disc_problem`; ISO or CSO, also an Android `fd:N`):
the picked file's `PSP_GAME/PARAM.SFO` says which game it is. The Dissidia 1 pick must be `ULUS10437` (a Dissidia 012 image, another
D1 release or another game is refused with what it is). The undub pick must be Dissidia 012 and must not carry the English voices:
Bartz's battle bank (`voice/en/battle/voice_p_fiv100_00.scd`, package CRC `4300D781`) is 302368 bytes with CRC-32 `6EE2B876` on the
EU and US discs, and differs on an undub. A refused pick shows a WRONG DISC page whose OK goes back to choosing that file.
`tools/d1_moves.py install` refuses a disc whose DISC_ID is not `ULUS10437` too. `tests/test_install.cpp` builds small ISO / CSO
images; `SETUP_TEST_DISCS="<D1 iso>|<English 012 iso>|<undub iso>"` adds the real ones.
- **Options** (one page in the game's Settings-screen look, without the category sidebar: HD textures on / off, then Texture pack when on, Japanese voices, Android version, Import saves, update check, install folder, Start installing): check for updates; HD textures (on / off) and, when on, Texture pack (LiinkPK's hand-retouched pack or the AI upscaled pack; the help line credits the selected pack); Japanese voices (undub; asks for the undub disc image first); **Bartz: Dissidia 1 moves** (`d1_moves=1`; asks for a Dissidia Final Fantasy (2008) disc image, then `tools/d1_moves.py install --d1 <iso> --work <game>` rebuilds the mod's six files from the shipped patches in `game/d1_moves/` and the player's two discs, checks each against its SHA-256, adds the abilities to main.bin and writes `mods/retail_moves.txt`; also offered by Change extras); Android
version; **Import saves** (cycles Off / each PPSSPP or memory-stick SAVEDATA folder found with Dissidia 012 saves, found by
`psp_savemgr::detect_sources`; it adds the last install step, `DissidiaRecomp --import-saves FROM --dir WORK`, which copies the
Expand Down
4 changes: 2 additions & 2 deletions psprecomp/games/dissidia/tools/charmod_objx.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def hit_encode(d):
# ---------------------------------------------------------------- json helpers
def wj(path, obj, compact=True):
"""compact: every item of a top-level list on one line (events, hits, commands ...)."""
with open(path, 'w') as f:
with open(path, 'w', encoding='utf-8') as f:
if not compact or not isinstance(obj, dict):
json.dump(obj, f, indent=1, ensure_ascii=False)
else:
Expand All @@ -437,7 +437,7 @@ def wj(path, obj, compact=True):


def rj(path):
with open(path) as f:
with open(path, encoding='utf-8') as f:
return json.load(f)


Expand Down
62 changes: 47 additions & 15 deletions psprecomp/games/dissidia/tools/d1_moves.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def mark_d1(desc):
return desc


D1_DISC_ID = 'ULUS10437' # Dissidia Final Fantasy (2008), USA: the release the shipped patches are made from


class IsoPackage(pe.Package):
"""PACKAGE.BIN / PACKAGE_INFO.BIN read in place from an ISO 9660 image."""

Expand Down Expand Up @@ -145,6 +148,22 @@ def _find(self, path):
rec = found
return struct.unpack_from('<I', rec, 2)[0], struct.unpack_from('<I', rec, 10)[0]

def disc_id(self):
"""(DISC_ID, TITLE) from PSP_GAME/PARAM.SFO, e.g. ('ULUS10437', 'DISSIDIA FINAL FANTASY')."""
lba, size = self._find('PSP_GAME/PARAM.SFO')
self.iso.seek(lba * 2048)
s = self.iso.read(size)
if s[:4] != b'\0PSF':
return '', ''
keys, data, n = struct.unpack_from('<III', s, 8)
out = {}
for i in range(n):
ko, fmt, ln, _mx, do = struct.unpack_from('<HHIII', s, 20 + 16 * i)
if fmt != 0x404:
k = s[keys + ko:s.index(b'\0', keys + ko)].decode('latin1')
out[k] = s[data + do:data + do + ln].split(b'\0')[0].decode('utf8', 'replace')
return out.get('DISC_ID', ''), out.get('TITLE', '')

def read_crc(self, crc):
sector, size, _ = self.entries[crc]
self.iso.seek((self.pkg_lba + sector) * 2048)
Expand All @@ -154,7 +173,7 @@ def read_crc(self, crc):
def prepare(src, d1, d12):
"""<src>/d1bartz (D1, 012 layout) and <src>/bartz (retail Bartz) for the Studio."""
os.makedirs(src + '/_template')
with open(src + '/_template/mod.json', 'w') as f:
with open(src + '/_template/mod.json', 'w', encoding="utf-8") as f:
f.write('{}')
gmo = d1.read('obj/p_fiv100_1p.gmo')
os.makedirs(src + '/d1bartz/models')
Expand All @@ -163,7 +182,7 @@ def prepare(src, d1, d12):
co.unpack(d1_objx.convert(d1.read('obj/p_fiv100.objx')), src + '/d1bartz/moveset/p_d1b', bones=G.Model(gmo).bone_names())
names = {'%02X' % (0x60 + i): {'cmd': '0x%X' % c, 'name': n, 'type': t, 'phase': ph}
for i, (c, n, t, ph, *_r) in enumerate(MOVES)}
with open(src + '/d1bartz/mod.json', 'w') as f: # based_on = this character: voices and face textures come along
with open(src + '/d1bartz/mod.json', 'w', encoding="utf-8") as f: # based_on = this character: voices and face textures come along
json.dump({'character': {'name': 'Bartz (DFF)', 'code': 'd1b', 'based_on': 'fiv100'}, 'move_names': names, 'files': {}}, f, indent=1)
os.makedirs(src + '/bartz/models')
files = {}
Expand All @@ -174,13 +193,13 @@ def prepare(src, d1, d12):
co.unpack(d12.read('obj/%s.objx' % ms), '%s/bartz/moveset/%s' % (src, ms), bones=G.Model(g).bone_names())
files['obj/%s.objx' % ms] = 'moveset/' + ms
files['obj/%s.gmo' % rig] = 'models/%s.gmo' % rig
with open(src + '/bartz/mod.json', 'w') as f: # move_names: the retail abilities, filled in by the page from the ISO
with open(src + '/bartz/mod.json', 'w', encoding="utf-8") as f: # move_names: the retail abilities, filled in by the page from the ISO
json.dump({'kind': 'retail', 'character': {'name': 'Bartz', 'code': 'fiv100'}, 'move_names': {}, 'files': files}, f, indent=1)


def finish(mod, d1, d12):
"""Names, help, costs, learn levels; D1's voice lines in the slots 012's bank left empty."""
with open(mod + '/mod.json') as f:
with open(mod + '/mod.json', encoding="utf-8") as f:
m = json.load(f)
by_name = {mv[1]: mv for mv in MOVES}
helps = d1_help(d1)
Expand All @@ -195,7 +214,7 @@ def finish(mod, d1, d12):
e['_note'] = 'Dissidia (2008) Bartz move, command 0x%X there (tools/d1_moves.py)' % cmd
m['display'] = 'Bartz: Dissidia (2008) moves'
ms = mod + '/moveset/p_fiv100'
rj = lambda p: json.load(open(p)) # noqa: E731
rj = lambda p: json.load(open(p, encoding="utf-8")) # noqa: E731
acts = {a['action']: a['script'] for a in rj(ms + '/actions.json')['actions']}
rows = rj(ms + '/motion_map.json')['rows']
new_cmds = {int(e['cmd'], 16) for e in m['move_names'].values() if 'copy' in e}
Expand All @@ -221,7 +240,7 @@ def finish(mod, d1, d12):
with open(p, 'wb') as f:
f.write(b12.to_bytes())
m['files'][VOICE_012] = 'files/' + VOICE_012
with open(mod + '/mod.json', 'w') as f:
with open(mod + '/mod.json', 'w', encoding="utf-8") as f:
json.dump(m, f, indent=1, ensure_ascii=False)
f.write('\n')
print('voice lines from Dissidia (2008) in slots %s' % ', '.join(map(str, filled)))
Expand Down Expand Up @@ -268,8 +287,8 @@ def cmd_patches(a):
import netpack as npk
npk.BLOCK = 8
d1, d12 = IsoPackage(a.d1), pe.Package(a.disc)
m = json.load(open(os.path.join(REPO, 'mods', 'bartz-dff', 'mod.json')))
owner = json.load(open(os.path.join(a.mods, 'readme_charmod_retail.json')))
m = json.load(open(os.path.join(REPO, 'mods', 'bartz-dff', 'mod.json'), encoding="utf-8"))
owner = json.load(open(os.path.join(a.mods, 'readme_charmod_retail.json'), encoding="utf-8"))
os.makedirs(PATCH_DIR, exist_ok=True)
for f in os.listdir(PATCH_DIR):
if f.endswith('.npd'):
Expand All @@ -295,7 +314,7 @@ def cmd_patches(a):
e = {x: v for x, v in e.items() if x != 'help'}
e['help_d1_cmd'] = next(mv[0] for mv in MOVES if mv[1] == e['name']) # D1's own text, read at install
man['move_names'][k] = e
with open(os.path.join(PATCH_DIR, 'manifest.json'), 'w') as f:
with open(os.path.join(PATCH_DIR, 'manifest.json'), 'w', encoding="utf-8") as f:
json.dump(man, f, indent=1)
f.write('\n')
print('wrote', os.path.normpath(PATCH_DIR))
Expand All @@ -306,9 +325,15 @@ def cmd_install(a):
byte for byte (SHA-256); the new abilities into main.bin (roster_mainbin.py), the Settings switch (retail_moves.txt)
and the online deltas (netpack.py)."""
import netpack as npk
man = json.load(open(os.path.join(PATCH_DIR, 'manifest.json')))
man = json.load(open(os.path.join(PATCH_DIR, 'manifest.json'), encoding="utf-8"))
d12 = pe.Package(os.path.join(a.work, 'disc0'))
d1 = IsoPackage(a.d1)
disc, title = d1.disc_id() # Dissidia 012 has obj/p_fiv100.objx too: the disc's own id tells the games apart
if disc != D1_DISC_ID:
what = '%s (%s)' % (title or 'this disc', disc or 'no PARAM.SFO')
if 'duodecim' in title.lower():
raise SystemExit('%s is Dissidia 012, %s: the moves need the first Dissidia (USA, ULUS-10437)' % (a.d1, what))
raise SystemExit('%s is %s, not Dissidia Final Fantasy (USA, ULUS-10437)' % (a.d1, what))
if pe.package_crc('obj/p_fiv100.objx') not in d1.entries:
raise SystemExit('%s is not a Dissidia Final Fantasy (2008) disc image' % a.d1)
mods = os.path.join(a.work, 'mods')
Expand Down Expand Up @@ -338,22 +363,29 @@ def cmd_install(a):
rm.expand_help(e['help'], '')
names[k] = e
ab_p = os.path.join(mods, 'extra_abilities.json')
ab = json.load(open(ab_p)) if os.path.exists(ab_p) else {}
ab = {}
if os.path.exists(ab_p):
try:
ab = json.load(open(ab_p, encoding="utf-8"))
except ValueError: # cut short by a crash of an earlier install (v0.1.18 on Windows wrote it in cp1252 and stopped)
os.replace(ab_p, ab_p + '.bad')
print('%s could not be read (kept as %s.bad): written again' % (ab_p, os.path.basename(ab_p)), flush=True)
ab[man['code']] = names
with open(ab_p, 'w') as fh:
with open(ab_p + '.tmp', 'w', encoding="utf-8") as fh: # whole or not at all
json.dump(ab, fh, indent=2, ensure_ascii=False)
fh.write('\n')
os.replace(ab_p + '.tmp', ab_p)
ids = ','.join('%04X' % ((9 << 8) | int(k, 16)) for k in sorted(names))
line = '%s 9 %s nm=%s' % (man['folder'], ids, man['display'].replace(' ', '_'))
rt = os.path.join(mods, 'retail_moves.txt')
lines = open(rt).read().splitlines() if os.path.exists(rt) else []
lines = open(rt, encoding="utf-8").read().splitlines() if os.path.exists(rt) else []
off = any(l.startswith('#off# ' + man['folder'] + ' ') for l in lines)
lines = [l for l in lines if not (l.split() and l.replace('#off# ', '').split()[0] == man['folder'])]
lines.append(('#off# ' if off else '') + line)
with open(rt, 'w') as fh:
with open(rt, 'w', encoding="utf-8") as fh:
fh.write('\n'.join(lines) + '\n')
if not os.path.exists(os.path.join(mods, 'roster.txt')):
open(os.path.join(mods, 'roster.txt'), 'w').close() # (roster_mainbin would make up a character without one)
open(os.path.join(mods, 'roster.txt'), 'w', encoding="utf-8").close() # (roster_mainbin would make up a character without one)
print('PROGRESS 75', flush=True)
if subprocess.call([sys.executable, os.path.join(HERE, 'roster_mainbin.py'), os.path.join(a.work, 'disc0'), mods]):
raise SystemExit('roster_mainbin.py failed')
Expand Down
14 changes: 7 additions & 7 deletions psprecomp/games/dissidia/tools/netpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,25 @@ def decode(delta, src, max_out=64 << 20):

# ---------------------------------------------------------------- the list
def load():
return json.load(open(PACKS_JSON)) if os.path.exists(PACKS_JSON) else {'_info': __doc__.split('\n\n')[1], 'packs': []}
return json.load(open(PACKS_JSON, encoding="utf-8")) if os.path.exists(PACKS_JSON) else {'_info': __doc__.split('\n\n')[1], 'packs': []}


def save(j):
with open(PACKS_JSON, 'w') as f:
with open(PACKS_JSON, 'w', encoding="utf-8") as f:
json.dump(j, f, indent=1)
f.write('\n')


def cmd_record(a):
mods, disc = a.mods, pe.Package(a.disc)
owner = json.load(open(os.path.join(mods, RETAIL_STATE)))
owner = json.load(open(os.path.join(mods, RETAIL_STATE), encoding="utf-8"))
files = sorted(gp for gp, n in owner.items() if n == a.folder)
if not files:
raise SystemExit('%s installs no retail files in %s (build it first)' % (a.folder, mods))
abil = json.load(open(os.path.join(mods, ABILITIES)))
mod = json.load(open(os.path.join(HERE, '..', '..', '..', '..', 'mods', a.folder, 'mod.json')))
abil = json.load(open(os.path.join(mods, ABILITIES), encoding="utf-8"))
mod = json.load(open(os.path.join(HERE, '..', '..', '..', '..', 'mods', a.folder, 'mod.json'), encoding="utf-8"))
code = mod['character']['code']
lines = [l.split() for l in open(os.path.join(mods, 'retail_moves.txt')).read().splitlines()]
lines = [l.split() for l in open(os.path.join(mods, 'retail_moves.txt'), encoding="utf-8").read().splitlines()]
char = next(int(l[-3]) for l in lines if a.folder in l)
name = a.name or a.folder
if len(name) > MAX_NAME:
Expand Down Expand Up @@ -166,7 +166,7 @@ def cmd_inc(_a=None):
for x in p['abilities']:
out.append(' {%s, %s, %s, %d, %d},' % (x['id'], x['copy'], x['cmd'], x['type'], x['phase']))
out.append(' }},')
with open(PACKS_INC, 'w') as f:
with open(PACKS_INC, 'w', encoding="utf-8") as f:
f.write('\n'.join(out) + '\n')


Expand Down
2 changes: 1 addition & 1 deletion psprecomp/games/dissidia/tools/package_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main(argv):
cmd = argv[1]
if cmd == "list":
sub = argv[2].lower()
for line in open(PATHS):
for line in open(PATHS, encoding="utf-8"):
p = line.strip()
if sub in p.lower():
c = package_crc(p)
Expand Down
4 changes: 2 additions & 2 deletions psprecomp/games/dissidia/tools/roster_mainbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def parse_arc(d, base): # {tag: (offset, size)}
def read_roster(path, min_id=FIRST_NEW):
"""[(charId, code, like)] for charId >= min_id (default FIRST_NEW) from a roster.txt ('<id> <code> [like] [k=v...]')."""
out = []
for line in open(path):
for line in open(path, encoding="utf-8"):
line = line.split("#")[0].split()
if len(line) < 2 or not line[0].isdigit():
continue
Expand All @@ -245,7 +245,7 @@ def parse_objs(spec):
def read_roster_objs(path):
"""(objs, charId of the line that declares the first objs= token) from a roster.txt; objs = every `objs=new:src,...` pair."""
out, char = [], None
for line in open(path):
for line in open(path, encoding="utf-8"):
toks = line.split("#")[0].split()
for tok in toks:
if tok.startswith("objs="):
Expand Down
6 changes: 3 additions & 3 deletions psprecomp/games/dissidia/tools/voice_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def cmd_dump(a):
man["slots"].append(s)
if vold:
man["vold"] = vold
json.dump(man, open(os.path.join(a.outdir, "manifest.json"), "w"), indent=1)
json.dump(man, open(os.path.join(a.outdir, "manifest.json"), "w", encoding="utf-8"), indent=1)
nd = sum(1 for e in bank.entries if e["kind"] == "data")
print("%s: %d slots (%d clips, %d aliases, %d links, %d empty) -> %s"
% (src, len(bank.entries), nd, sum(e["kind"] == "alias" for e in bank.entries),
Expand Down Expand Up @@ -472,7 +472,7 @@ def pcm_for_slot(path, rate_opt, template_rate):
def cmd_build(a):
d = a.dir
mpath = os.path.join(d, "manifest.json")
man = json.load(open(mpath)) if os.path.exists(mpath) else None
man = json.load(open(mpath, encoding="utf-8")) if os.path.exists(mpath) else None
like = None
if a.like:
like, _ = load_bank_file(a.like)
Expand Down Expand Up @@ -683,7 +683,7 @@ def cmd_alias(a):
import package_extract as pe
pkg = pe.Package(a.disc)
like, code = a.like.lower(), a.code.lower()
paths = [l.strip().lower() for l in open(os.path.join(HERE, "..", "package_paths.txt"))]
paths = [l.strip().lower() for l in open(os.path.join(HERE, "..", "package_paths.txt"), encoding="utf-8")]
want = []
for n in range(10):
for suf in ("", "_a"):
Expand Down
2 changes: 1 addition & 1 deletion psprecomp/setup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ install(TARGETS psprecomp_setup RUNTIME DESTINATION . COMPONENT setup)
option(PSPRECOMP_SETUP_TESTS "Build the setup wizard's unit tests" OFF)
if(PSPRECOMP_SETUP_TESTS)
enable_testing()
add_executable(test_setup_install tests/test_install.cpp install.cpp proc.cpp)
add_executable(test_setup_install tests/test_install.cpp install.cpp proc.cpp third_party/miniz.c)
target_link_libraries(test_setup_install PRIVATE $<$<NOT:$<PLATFORM_ID:Windows>>:pthread>)
add_test(NAME setup_install COMMAND test_setup_install)
add_executable(test_payload tests/test_payload.cpp payload.cpp third_party/miniz.c)
Expand Down
Loading
Loading