Files
bigmak94andClaude Opus 5.5 bd9bded792 GalaxyQuest: Super Mario Galaxy in VR on Meta Quest 3
A native port built on the Petari decompilation (previous commit): an
HLE platform layer (OS, DVD, GX, audio, input, NAND) under the game's
own code, an OpenXR presentation (a diorama around the player, a giant
screen, the HUD and settings as compositor layers, SpaceWarp, dynamic
resolution), Touch Plus controls, the tools that convert your own game
files (tools/cook, which also takes the few pieces of data the game's
executable holds from your sys/main.dol), and the port's changes to the
decompilation (`git diff petari-base -- decomp`).  README.md explains
installing and building, docs/TECHNICAL.md how it works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 01:59:38 +02:00

46 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Tiny helper for applying exact, verified text substitutions to decomp files.
Usage from other scripts:
from patch import sub
sub('path', 'old', 'new') # exactly one occurrence required
sub('path', 'old', 'new', count=0) # replace all, at least one required
"""
import os
import sys
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'decomp')
_failures = []
def read(path):
with open(os.path.join(ROOT, path), 'rb') as fh:
return fh.read().decode('utf-8', errors='surrogateescape')
def write(path, text):
with open(os.path.join(ROOT, path), 'wb') as fh:
fh.write(text.encode('utf-8', errors='surrogateescape'))
def sub(path, old, new, count=1):
text = read(path)
n = text.count(old)
if n == 0:
if new in text:
return # already applied
_failures.append('%s: pattern not found: %r' % (path, old[:80]))
return
if count == 1 and n != 1:
_failures.append('%s: pattern found %d times (expected 1): %r' % (path, n, old[:80]))
return
text = text.replace(old, new) if count == 0 else text.replace(old, new, count)
write(path, text)
def done():
if _failures:
print('\n'.join(_failures))
sys.exit(1)
print('ok')