Trace post-skip tilt and gate gameplay changes on original lifecycle recovery
This commit is contained in:
1 parent
a2e89c625a
commit
68154dffce
15 files changed
+752
-6
No files matched your search
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only source ordering and actual lab camera graph; no gameplay mutation."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
|
||||
from pe_inspect import PE
|
||||
import gam
|
||||
|
||||
REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
|
||||
CALLS = (('physics before registry', 0x47e554, 0x479bc0),
|
||||
('registry callbacks', 0x47e582, 0x473740),
|
||||
('dynamic contact notification', 0x479c83, 0x47a430),
|
||||
('AI trigger base contact', 0x40c209, 0x470a90),
|
||||
('AI trigger synchronous action', 0x40c21f, 0x40c300),
|
||||
('Carl inherited AI before talk', 0x41b95d, 0x408000))
|
||||
SITES = (('first dynamic enter', 0x47a555, 'ff5040'),
|
||||
('second dynamic enter', 0x47a578, 'ff5240'),
|
||||
('registry per-object update', 0x473758, 'ff5010'),
|
||||
('Carl talk in ordinary actor update', 0x41b988, 'ff9240010000'),
|
||||
('MCA shot complete', 0x430ed8, 'ff92e4000000'),
|
||||
('MCA skip input-latch write', 0x430f37, 'c680001e000001'),
|
||||
('MCA shared skip flag', 0x430f3e, 'c605e4834f0001'),
|
||||
('MCA skip finish', 0x431012, 'ff90e4000000'),
|
||||
('CAM skip input-latch write', 0x41613b, 'c680001e000001'),
|
||||
('CAM shared skip flag', 0x416142, 'c605e4834f0001'),
|
||||
('DEFAULT clears shared skip', 0x447f89, 'c605e4834f0000'))
|
||||
SLOTS = (('AI trigger enter, game interface+C8', 0x48f8c0, 0x40, 0x40c200),
|
||||
('Carl enter, game interface+C0', 0x495364, 0x40, 0x40a3c0),
|
||||
('Carl update', 0x495364, 0x3c4, 0x41b950),
|
||||
('CAM update, game interface+C8', 0x497bfc, 0x3c4, 0x415f90),
|
||||
('MCA update, game interface+C8', 0x4a8f64, 0x3c4, 0x430da0),
|
||||
('MCA finish, complete table', 0x4a93c8, 0xe4, 0x4311f0))
|
||||
RANGES = ((0x47e554, 0x47e58c), (0x479c7e, 0x479c8c),
|
||||
(0x47a488, 0x47a57c), (0x40c200, 0x40c227),
|
||||
(0x41b950, 0x41b98e), (0x41b7b0, 0x41b810),
|
||||
(0x473740, 0x473768), (0x430da0, 0x430ef2),
|
||||
(0x430eed, 0x431027), (0x4160f1, 0x4161cd),
|
||||
(0x447f73, 0x447fc5))
|
||||
FIELDS = {'ObjectTag','NextTrigger','PlayerControlled','DeactivateInv','AITarget',
|
||||
'AIAnim','AIState','AINewPos','AINewRotY','AIHideObj','ActivateBy',
|
||||
'ActivateByAnim','TaskName','TimesToTrigger','TouchActivated',
|
||||
'TargetActAnim','TargetDeactAnim','FaceObject'}
|
||||
|
||||
|
||||
def collect(original, rea=None):
|
||||
original = Path(original)
|
||||
pe = PE(find_case(original, 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unexpected original executable')
|
||||
calls=[]
|
||||
for name, va, target in CALLS:
|
||||
if rel_call_target(pe,va) != target:
|
||||
raise ValueError(name)
|
||||
calls.append(dict(name=name,va=hex(va),file_offset=hex(pe.offset(va-pe.base)),target=hex(target)))
|
||||
sites=[]
|
||||
for name,va,expected in SITES:
|
||||
if read_va(pe,va,len(bytes.fromhex(expected))).hex()!=expected:
|
||||
raise ValueError(name)
|
||||
sites.append(dict(name=name,va=hex(va),file_offset=hex(pe.offset(va-pe.base)),bytes=expected))
|
||||
slots=[]
|
||||
for name,table,slot,target in SLOTS:
|
||||
if struct.unpack('<I',read_va(pe,table+slot,4))[0]!=target:
|
||||
raise ValueError(name)
|
||||
slots.append(dict(name=name,table=hex(table),slot=hex(slot),target=hex(target),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base))))
|
||||
gam_path=find_case(original,'gam/level1b.gam')
|
||||
level=gam.parse(gam_path.read_bytes())
|
||||
by={}
|
||||
for index,e in enumerate(level.entities):
|
||||
by.setdefault(str(e.values().get('ObjectTag','')).casefold(),(index,e))
|
||||
route=[]
|
||||
pending=['teleportexplanation','neutron1a'];seen=set()
|
||||
while pending:
|
||||
tag=pending.pop(0).casefold()
|
||||
if tag in seen or tag in ('none','default'):continue
|
||||
seen.add(tag)
|
||||
index,e=by[tag];v=e.values()
|
||||
route.append(dict(index=index,kind=e.kind,offset=hex(e.offset),fields={k:x for k,x in v.items()
|
||||
if k in FIELDS or k.startswith(('ActivateState','ActivateObject','CameraTarget','TargetAnim'))}))
|
||||
pending.extend(str(x) for k,x in v.items() if k=='NextTrigger' or k.startswith('ActivateObject'))
|
||||
result=dict(source_sha256=EXE_SHA256,rea_evidence_id=REA_ID,calls=calls,sites=sites,slots=slots,
|
||||
ranges=[dict(va=hex(a),file_offset=hex(pe.offset(a-pe.base)),length=b-a,
|
||||
sha256=hashlib.sha256(read_va(pe,a,b-a)).hexdigest()) for a,b in RANGES],
|
||||
gam_sha256=hashlib.sha256(gam_path.read_bytes()).hexdigest(),route=route,
|
||||
scope='Static source and data partial order; no runtime chain, full registry or causal fix proven.')
|
||||
if rea:
|
||||
record=next(r for r in json.loads(Path(rea).read_text())['records'] if r['evidence_id']==REA_ID)
|
||||
if record['subject']['digest']['sha256']!=EXE_SHA256:raise ValueError('REA identity mismatch')
|
||||
rows=[]
|
||||
for line in record['raw_result']['stdout'].splitlines():
|
||||
m=re.match(r'\s*([0-9a-f]+):',line)
|
||||
if m:rows.append((int(m[1],16),line))
|
||||
result['rea_extracts']={hex(a):'\n'.join(l for va,l in rows if a<=va<b)+'\n' for a,b in RANGES}
|
||||
return result
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path)
|
||||
cli.add_argument('--rea-disassembly',type=Path)
|
||||
args=cli.parse_args()
|
||||
print(json.dumps(collect(args.original,args.rea_disassembly),indent=2))
|
||||
Reference in new issue
Block a user