Run the original macOS ARM64 game code on iOS: - tools/retarget.py: header-only Mach-O retargeting to an iOS dylib - platform/native: UIKit host and macOS API shims (AppKit for SDL's Cocoa backend, CoreGraphics displays, CoreAudio device, Metal device properties, Wuffs PNG decoding, Steam and peripheral stubs) - touch, overlay, iOS keyboard and hardware keyboard input - tools/build_native.py: build, sign, install, data copy, launch - docs: build guide, controls, architecture Also includes the earlier static-translation research (ARM64 -> WASM -> native) under docs/research, runtime/, tests/ and tools/. No game files are included; the build reads them from a local install.
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""Check refusal of changed game code/constants without writing modified binaries."""
|
|
import importlib.util
|
|
import json
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
spec = importlib.util.spec_from_file_location("lift_rng", Path(__file__).parents[1] / "tools/lift_rng.py")
|
|
lift = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(lift)
|
|
source = Path(sys.argv[1])
|
|
original = source.read_bytes()
|
|
image, slice_offset = lift.arm64_image(original)
|
|
ranges = [("function", lift.FUNCTION_VA, lift.BODY_SIZE),
|
|
("seed constructor", lift.SEED_VA, lift.SEED_SIZE),
|
|
("constants", lift.CONSTANT_VA, 32)]
|
|
for label, address, length in ranges:
|
|
changed = bytearray(original)
|
|
changed[slice_offset + lift.file_range(image, address, length)] ^= 1
|
|
with tempfile.TemporaryDirectory() as folder:
|
|
out = Path(folder) / "generated"
|
|
with patch.object(Path, "read_bytes", return_value=bytes(changed)):
|
|
try:
|
|
lift.generate(source, out)
|
|
except ValueError:
|
|
assert not out.exists(), "Rejected input produced output artifacts"
|
|
print(f"PASS: changed {label} rejected before output")
|
|
else:
|
|
raise AssertionError(f"Changed {label} accepted")
|