Implement evidence-backed VR02 Rocketship flight and ownership
This commit is contained in:
1 parent
312efccb77
commit
e77add5fdf
50 files changed
+4326
-66
No files matched your search
@@ -0,0 +1,167 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guarded Rocketship body callbacks and isolated probe evidence.
|
||||
|
||||
Pure projections omit actual rider/audio/scene execution. The optional C probe
|
||||
executes copied370/374 instructions with synthetic body/rider/audio dependencies.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
from rocketship import collect as rocket_collect
|
||||
|
||||
BODIES = (
|
||||
('ceiling', 0x43eb70, 0x43ebaf, '501a86c0a0263c4087932081a1516579f3a1fdb985d244682997e012a242ad3f'),
|
||||
('wall', 0x43e8d0, 0x43ea49, '5a3c59889ae6ee9c4d599c1116782c7a2e8213c1b2cad9c22f7b8b55c1ee32a2'),
|
||||
('physics', 0x479d20, 0x47a32a, '5f4b05518bef5e5f0ecc3909ff0de0b43d2c7350c6beae0c4f797d3238a77fa1'),
|
||||
('prevent_setter', 0x470f70, 0x470f83, 'b4963d8c48531af2870e39531aadfa8c1178542943ba51d8e3b57184256ee81a'),
|
||||
('pair_getter', 0x471930, 0x471937, '72ca47ad0ea64edf6110c3a080c805774593958fb2d34dce19f63261a8242327'),
|
||||
('pair_setter', 0x471940, 0x47194d, 'fa5b69a6074a26a0b8dd535d288645d2875039673639282571e029a60479cd37'),
|
||||
('pair_notify_gate', 0x470bf0, 0x470c44, '5211f48735716c7a7426486f0b44ae9e93388546d825437edc6ef3f787e2aa8d'),
|
||||
('dynamic_push_gate', 0x47b2eb, 0x47b3a5, '75e20325939a77354add4decb44bba860003d56914426dc1b98f6d52c08056cb'),
|
||||
)
|
||||
TABLES = ((0x370, 0x43eb70), (0x374, 0x43e8d0), (0x378, 0x472750),
|
||||
(0x37c, 0x472970), (0x1e0, 0x471930), (0x1e4, 0x471940),
|
||||
(0x208, 0x4719d0), (0x20c, 0x4719e0), (0x210, 0x4719f0))
|
||||
|
||||
|
||||
def collect(original: Path | str):
|
||||
report = rocket_collect(Path(original))
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
records = []
|
||||
for name, start, end, expected in BODIES:
|
||||
digest = hashlib.sha256(read_va(pe, start, end-start)).hexdigest()
|
||||
if digest != expected:
|
||||
raise ValueError(f'Changed Rocketship body span {name}')
|
||||
records.append(dict(name=name, va=hex(start), file_offset=hex(pe.offset(start-pe.base)),
|
||||
length=end-start, sha256=digest))
|
||||
for slot, target in TABLES:
|
||||
if struct.unpack('<I', read_va(pe, 0x4b25ac+slot, 4))[0] != target:
|
||||
raise ValueError(f'Changed Rocketship body virtual {slot:x}')
|
||||
# Rocket construction specifically enables prevent-lowering, unlike a
|
||||
# generic CGameObject; radius/factor alone do not establish this flag.
|
||||
if read_va(pe, 0x43d90d, 9) != bytes.fromhex('6a018bcee85a360300'):
|
||||
raise ValueError('Changed Rocketship prevent-lowering initialization')
|
||||
if read_va(pe, 0x472970, 1) != b'\xc3':
|
||||
raise ValueError('Changed no-op landing callback')
|
||||
report.update(body_callbacks=records,
|
||||
body_vtables=[dict(slot=hex(s), target=hex(t)) for s,t in TABLES],
|
||||
prevent_lowering=True, support_clearance_f32=struct.unpack('<f',struct.pack('<f',50*struct.unpack('<f',struct.pack('<f',.6))[0]))[0],
|
||||
ceiling_velocity_y=-120., ceiling_preserves_acceleration=True,
|
||||
wall_uses_reflection=False, flag137_is_integration_gate=False,
|
||||
scope='Guarded body state/callbacks; optional isolated-original probes are separate from whole-game fidelity')
|
||||
return report
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class WallEffect:
|
||||
energy_delta: float
|
||||
score_delta: int
|
||||
duration: float
|
||||
clear_rider_latch: bool
|
||||
secondary_rider_callback: bool = False
|
||||
sound: int = 197
|
||||
|
||||
|
||||
def wall_effect(material_id=0, *, rider=True, polygon=True, material=True,
|
||||
definition=True, active=False, rider_latch=False):
|
||||
"""43E8D0 decision only. Actual rider callback executes synchronously."""
|
||||
if not rider or not polygon or not material:
|
||||
return None
|
||||
if definition:
|
||||
if 130 <= material_id <= 139:
|
||||
return None if active else WallEffect(-10., -10, 5., True)
|
||||
if 185 <= material_id <= 189:
|
||||
return None if rider_latch else WallEffect(-5., -5, 5., False, True)
|
||||
if material_id in (-1,170):
|
||||
return None
|
||||
return None if active else WallEffect(-1., -1, 1., True)
|
||||
|
||||
|
||||
def ceiling_velocity(velocity):
|
||||
if len(velocity) != 3 or not all(math.isfinite(v) for v in velocity):
|
||||
raise ValueError('Finite three-component velocity required')
|
||||
return (velocity[0], -120., velocity[2])
|
||||
|
||||
|
||||
def callback_probe_results(log: Path, executable: Path):
|
||||
source = Path(__file__).with_name('rocketship_body_probe.c')
|
||||
content = log.read_text()
|
||||
if 'ROCKET_BODY_CALLBACK_COMPLETE:' not in content:
|
||||
raise ValueError('Incomplete Rocketship callback probe')
|
||||
names = ('id','rider','polygon','material','definition','active','rider_latch')
|
||||
inputs = {name:dict(zip(names,map(int,values.split(',')),strict=True))
|
||||
for name,values in re.findall(r'wall\("(\w+)",([^;]+)\);',source.read_text())}
|
||||
for name,value in re.findall(r'ceiling\("(\w+)",([^;]+)\);',source.read_text()):
|
||||
inputs[name] = dict(ceiling_velocity=float(value))
|
||||
cases = []
|
||||
for name,values in re.findall(r'^CASE (\w+) (.+)$',content,re.M):
|
||||
if name not in inputs or any(c['name']==name for c in cases):
|
||||
raise ValueError('Unexpected or duplicate Rocketship callback case')
|
||||
fields = {}
|
||||
for key,value in re.findall(r'(\w+)=([^\s]+)',values):
|
||||
fields[key] = [float(v) for v in value.split(',')] if ',' in value else float(value)
|
||||
if not {'velocity','acceleration','root','active','timer','duration','impulse','riderflag','calls','damage','points','seconds','secondary','sounds','soundid'} <= fields.keys():
|
||||
raise ValueError('Missing Rocketship callback output field')
|
||||
cases.append(dict(name=name,input=inputs[name],observed=fields))
|
||||
if len(cases) != len(inputs):
|
||||
raise ValueError('Missing Rocketship callback cases')
|
||||
return dict(source_sha256=EXE_SHA256, scope='Copied370/374; body accessors, rider and audio synthetic',
|
||||
generator_sha256=hashlib.sha256(source.read_bytes()).hexdigest(),
|
||||
executable_sha256=hashlib.sha256(executable.read_bytes()).hexdigest(),
|
||||
log_sha256=hashlib.sha256(log.read_bytes()).hexdigest(),cases=cases)
|
||||
|
||||
|
||||
def body_support_probe(output: Path):
|
||||
"""Generate six50/.6/prevent-lowering body cases from existing harness."""
|
||||
source = Path(__file__).with_name('body_step_probe.c').read_text()
|
||||
marker = ' puts("BODY_COMPONENT_COMPLETE:'
|
||||
if source.count(marker) != 1:
|
||||
raise ValueError('Unexpected original body harness')
|
||||
extra = ''' b=initial();b.radius=50;b.factor=.6f;b.position.y=30;b.previous=b.position;run("rocket_floor",b,1);
|
||||
b=initial();b.radius=50;b.factor=.6f;b.position.y=10;b.previous=b.position;run("rocket_spawn_low",b,1);
|
||||
b=initial();b.radius=50;b.factor=.6f;run("rocket_no_forced_lowering",b,1);
|
||||
b=initial();b.radius=50;b.factor=.6f;b.position.y=30;b.previous=b.position;b.velocity.y=300;run("rocket_rise",b,1);
|
||||
b=initial();b.radius=50;b.factor=.6f;b.position.y=30;b.previous=b.position;b.supported=1;b.velocity=(Vec){120,0,-60,0};b.acceleration.y=800;run("rocket_friction",b,1);
|
||||
b=initial();b.radius=50;b.factor=.6f;b.position.y=30;b.previous=b.position;b.supported=1;b.velocity=(Vec){120,0,-60,0};b.acceleration.y=800;b.speed=160;run("rocket_published_nonzero",b,1);
|
||||
'''
|
||||
output = output.resolve()
|
||||
originals = Path(__file__).resolve().parents[3]/'Original'
|
||||
if output.is_relative_to(originals) or originals.is_relative_to(output):
|
||||
raise ValueError('Generated output must be separate from originals')
|
||||
output.write_text(source.replace(marker,extra+marker))
|
||||
|
||||
|
||||
def main():
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path)
|
||||
cli.add_argument('--output',type=Path)
|
||||
cli.add_argument('--callback-log',type=Path)
|
||||
cli.add_argument('--callback-executable',type=Path)
|
||||
cli.add_argument('--body-probe-source',type=Path)
|
||||
args=cli.parse_args();report=collect(args.original)
|
||||
if bool(args.callback_log) != bool(args.callback_executable):
|
||||
cli.error('Use callback log/executable together')
|
||||
if args.callback_log:
|
||||
report['original_callback_probe']=callback_probe_results(args.callback_log,args.callback_executable)
|
||||
if args.body_probe_source:
|
||||
body_support_probe(args.body_probe_source)
|
||||
text=json.dumps(report,indent=2,allow_nan=False)+'\n'
|
||||
if args.output:
|
||||
target=args.output.resolve();original=args.original.resolve()
|
||||
if target.is_relative_to(original) or original.is_relative_to(target):
|
||||
cli.error('Output must be separate from originals')
|
||||
target.write_text(text)
|
||||
else: print(text,end='')
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,73 @@
|
||||
/* Isolated original Rocket370/374 callbacks. No game entrypoint or gameplay.
|
||||
* Body accessors, rider callbacks and sound are synthetic observations. */
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define TC __attribute__((thiscall))
|
||||
typedef struct {float x,y,z,w;} Vec;
|
||||
static unsigned char *mapped,object[0x1100],rider[0x2100],polygon[0x30],material[0x20],definition[0x20];
|
||||
static uintptr_t body_table[0x400/4],rider_table[0x200/4];
|
||||
static Vec velocity,acceleration,root;
|
||||
static unsigned rider_calls,secondary_calls,sound_calls;
|
||||
static float damage,duration;static int points,sound_id;
|
||||
#define AT(va) (mapped+(va)-0x400000)
|
||||
#define F(g,off) (*(float*)((g)+(off)))
|
||||
static void require(int ok,const char*m){if(!ok){fprintf(stderr,"FAIL %s\n",m);exit(2);}}
|
||||
static Vec* TC get_velocity(void*self,Vec*out){(void)self;*out=velocity;return out;}
|
||||
static void TC set_velocity(void*self,float x,float y,float z){(void)self;velocity.x=x;velocity.y=y;velocity.z=z;}
|
||||
static void TC rider_impact(void*self,float d,int p,float seconds){(void)self;rider_calls++;damage=d;points=p;duration=seconds;}
|
||||
static void TC rider_secondary(void*self){(void)self;secondary_calls++;}
|
||||
static int __cdecl sound(int unused,int id,int loop){(void)unused;(void)loop;sound_calls++;sound_id=id;return 77;}
|
||||
static void TC missing(void*self){(void)self;require(0,"unexpected virtual");}
|
||||
static void map_copy(void){
|
||||
mapped=VirtualAlloc(NULL,0x299000,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE);require(mapped!=NULL,"map");
|
||||
FILE*f=fopen("Neutron.exe","rb");require(f!=NULL,"copied EXE");fseek(f,0,SEEK_END);long size=ftell(f);rewind(f);
|
||||
require(size==1019904,"source size");unsigned char*data=malloc(size);require(data!=NULL,"buffer");
|
||||
require(fread(data,1,size,f)==(size_t)size,"read");fclose(f);require(*(uint16_t*)data==IMAGE_DOS_SIGNATURE,"DOS");
|
||||
uint32_t offset=*(uint32_t*)(data+0x3c);require(offset<(uint32_t)size-sizeof(IMAGE_NT_HEADERS32),"NT bounds");
|
||||
IMAGE_NT_HEADERS32*nt=(void*)(data+offset);require(nt->Signature==IMAGE_NT_SIGNATURE&&nt->FileHeader.Machine==IMAGE_FILE_MACHINE_I386&&nt->OptionalHeader.ImageBase==0x400000&&nt->OptionalHeader.SizeOfImage==0x299000,"PE");
|
||||
IMAGE_SECTION_HEADER*s=IMAGE_FIRST_SECTION(nt);require((unsigned char*)(s+nt->FileHeader.NumberOfSections)<=data+size,"sections");
|
||||
for(unsigned i=0;i<nt->FileHeader.NumberOfSections;i++){
|
||||
require((uint64_t)s[i].PointerToRawData+s[i].SizeOfRawData<=(uint64_t)size&&(uint64_t)s[i].VirtualAddress+s[i].SizeOfRawData<=0x299000,"section bounds");
|
||||
memcpy(mapped+s[i].VirtualAddress,data+s[i].PointerToRawData,s[i].SizeOfRawData);
|
||||
}
|
||||
free(data);
|
||||
/* Relative source CALL458980 is retained, but its external audio body is
|
||||
* replaced by a record-only thunk. Callback instruction ranges unchanged. */
|
||||
unsigned char*stub=AT(0x458980);stub[0]=0xb8;*(uint32_t*)(stub+1)=(uint32_t)sound;stub[5]=0xff;stub[6]=0xe0;
|
||||
for(unsigned i=0;i<sizeof(body_table)/sizeof(body_table[0]);i++)body_table[i]=(uintptr_t)missing;
|
||||
for(unsigned i=0;i<sizeof(rider_table)/sizeof(rider_table[0]);i++)rider_table[i]=(uintptr_t)missing;
|
||||
body_table[0x2bc/4]=(uintptr_t)get_velocity;body_table[0x2c4/4]=(uintptr_t)set_velocity;
|
||||
rider_table[0x1a0/4]=(uintptr_t)rider_impact;rider_table[0x198/4]=(uintptr_t)rider_secondary;
|
||||
}
|
||||
static unsigned char* reset(int has_rider,int active,int rider_flag){
|
||||
memset(object,0,sizeof(object));memset(rider,0,sizeof(rider));memset(polygon,0,sizeof(polygon));memset(material,0,sizeof(material));memset(definition,0,sizeof(definition));
|
||||
unsigned char*g=object+0xc0;*(uintptr_t**)g=body_table;*(uintptr_t**)rider=rider_table;
|
||||
*(void**)(g+0x680)=has_rider?rider:NULL;g[0xe84]=active;g[0xed0]=1;F(g,0xe88)=2.5f;F(g,0xec4)=13;
|
||||
rider[0x1e03]=rider_flag;velocity=(Vec){11,200,22,1};acceleration=(Vec){33,444,55,0};root=(Vec){66,77,88,1};
|
||||
rider_calls=secondary_calls=sound_calls=0;damage=duration=0;points=sound_id=0;return g;
|
||||
}
|
||||
static void show(const char*name,unsigned char*g){
|
||||
printf("CASE %s velocity=%.9g,%.9g,%.9g acceleration=%.9g,%.9g,%.9g root=%.9g,%.9g,%.9g active=%u timer=%.9g duration=%.9g impulse=%u riderflag=%u calls=%u damage=%.9g points=%d seconds=%.9g secondary=%u sounds=%u soundid=%d\n",
|
||||
name,velocity.x,velocity.y,velocity.z,acceleration.x,acceleration.y,acceleration.z,root.x,root.y,root.z,
|
||||
g[0xe84],F(g,0xe88),F(g,0xec4),g[0xed0],rider[0x1e03],rider_calls,damage,points,duration,secondary_calls,sound_calls,sound_id);
|
||||
}
|
||||
static void ceiling(const char*name,float vy){unsigned char*g=reset(1,0,1);velocity.y=vy;((void(TC*)(void*,Vec,void*))AT(0x43eb70))(g,(Vec){0,-1,0,0},polygon);show(name,g);}
|
||||
static void wall(const char*name,int id,int has_rider,int has_polygon,int has_material,int has_definition,int active,int rider_flag){
|
||||
unsigned char*g=reset(has_rider,active,rider_flag);*(void**)(polygon+4)=has_material?material:NULL;
|
||||
*(void**)(material+0xc)=has_definition?definition:NULL;*(int*)(definition+8)=id;
|
||||
((void(TC*)(void*,Vec,void*))AT(0x43e8d0))(g,(Vec){0,0,1,0},has_polygon?polygon:NULL);show(name,g);
|
||||
}
|
||||
int main(void){
|
||||
setbuf(stdout,NULL);map_copy();ceiling("ceiling_up",200);ceiling("ceiling_down",-900);ceiling("ceiling_zero",0);
|
||||
wall("ordinary",0,1,1,1,1,0,1);wall("ordinary5",5,1,1,1,1,0,1);
|
||||
wall("no_rider",0,0,1,1,1,0,1);wall("no_polygon",0,1,0,1,1,0,1);wall("no_material",0,1,1,0,1,0,1);
|
||||
wall("no_definition",170,1,1,1,0,0,1);wall("ignored170",170,1,1,1,1,0,1);wall("ignored_minus1",-1,1,1,1,1,0,1);
|
||||
wall("strong130",130,1,1,1,1,0,1);wall("strong139",139,1,1,1,1,0,1);wall("ordinary129",129,1,1,1,1,0,1);wall("ordinary140",140,1,1,1,1,0,1);
|
||||
wall("special185",185,1,1,1,1,0,0);wall("special189",189,1,1,1,1,0,0);wall("ordinary184",184,1,1,1,1,0,1);wall("ordinary190",190,1,1,1,1,0,1);
|
||||
wall("active_ordinary",0,1,1,1,1,1,0);wall("active_strong",130,1,1,1,1,1,0);
|
||||
wall("flag_special",185,1,1,1,1,0,1);wall("active_special",185,1,1,1,1,1,0);
|
||||
puts("ROCKET_BODY_CALLBACK_COMPLETE: copied instructions with synthetic dependencies");return 0;
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guarded Rocketship ownership/attachment evidence and bounded projections.
|
||||
|
||||
Reads originals without executing them. Projections describe loader selection,
|
||||
engine transitions and the normal impact tail; they are not live-game probes.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
ROCKET_ID = 0x33524f43
|
||||
BODIES = (
|
||||
('owned_setup',0x422420,0x4224ee,'97380f20076b8ff8851f74727fc17d3ba41b2c2b7e56c16bd410baf031fe3898'),
|
||||
('ship_ctor',0x43d840,0x43da40,'33d27053c2070f0c278bf3e14808d16c4479893d1ccb16c1ac8e199dfd9e53ba'),
|
||||
('postload',0x43db10,0x43dcf4,'af2007e942ed715ce8dd03bb725a7ab10bb536444a88f227c25f83527d18c15b'),
|
||||
('ship_update',0x43df70,0x43e7db,'707073786f6b19d6f77624ba4804376685652cfbd6dc3443143ca533e266de09'),
|
||||
('engine',0x43ea80,0x43eb31,'c154bb368050f16079288ee806be45879b219d2de7446672d7b1eb60d572ea09'),
|
||||
('class_id',0x462220,0x46222e,'8ae2a2a865683cb6583081b67d18ed787f53e6eeb3266a24bd6b9ed46df0ad80'),
|
||||
('reuse',0x46e6a0,0x46e70c,'bd2f9447ddcfbce9c1a58382d027a7450ea898ebd616d81a581a3ba5c9d5df8f'),
|
||||
('mount',0x42944d,0x429686,'2e8e15c52bf02a06afe2a56ccf8b31551368aefcde046c444ddb01a3ef978c70'),
|
||||
('cleanup',0x4284fb,0x42871d,'0474c58185373ce9e7a546ddaf47790bbb5193ecaa4fc9223bbecef9eead2c21'),
|
||||
('rider_damage',0x42a870,0x42a8c7,'59bfbe871fba2dea6bdbfca97db6fa8296db51b8b561582cda69f68ca7021efd'),
|
||||
('jimmy_drive_alias',0x422b04,0x422b18,'12f09afaef07ba842d5b0897ac8bba5223a4b59a9e58d7b4bc38f55c61955d89'),
|
||||
('dog_rock_alias',0x41ce2c,0x41ce40,'94fe59a673561374f0f3b3ec1b6dd1eb8dabbdc45e926c0463e670a616df56af'),
|
||||
('engine_input',0x41ab12,0x41ac0e,'ec4cf4afb58528ca0baf325869ad78d9d6753ab13efdd5a95b2b815bf5f5bbc8'),
|
||||
('control_store',0x475a40,0x475a4c,'d397cb6847c4ff58e32aac989afc348612b5285a4f03538ea6c016a4fdddda3c'),
|
||||
('dynamic_inhibit',0x471940,0x47194d,'fa5b69a6074a26a0b8dd535d288645d2875039673639282571e029a60479cd37'),
|
||||
)
|
||||
|
||||
|
||||
def f32(value):
|
||||
return struct.unpack('<f',struct.pack('<f',value))[0]
|
||||
|
||||
|
||||
def collect(original: Path | str):
|
||||
pe=PE(find_case(Path(original),'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256:
|
||||
raise ValueError('Unexpected original EXE identity')
|
||||
bodies=[]
|
||||
for name,start,end,expected in BODIES:
|
||||
digest=hashlib.sha256(read_va(pe,start,end-start)).hexdigest()
|
||||
if digest!=expected: raise ValueError(f'Changed lifecycle span {name}')
|
||||
bodies.append(dict(name=name,va=hex(start),end_va=hex(end),
|
||||
file_offset=hex(pe.offset(start-pe.base)),sha256=digest))
|
||||
tables=((0x4b25ac,0x40c,0x43db10),(0x4b25ac,0x3c4,0x43df70),
|
||||
(0x4b25ac,0x1e4,0x471940),(0x4b2a4c,0x128,0x43ea80),
|
||||
(0x4a3bdc,0x1a0,0x42a870),(0x4a3bdc,0x1e0,0x425120))
|
||||
for table,slot,target in tables:
|
||||
if struct.unpack('<I',read_va(pe,table+slot,4))[0]!=target:
|
||||
raise ValueError('Changed lifecycle virtual target')
|
||||
for va,text in [(0x4ef274,b'HIDRIVE'),(0x4ef27c,b'jimdrive.ase'),
|
||||
(0x4ee9a8,b'HIROCK'),(0x4ee9b0,b'godrocket.ASE'),(0x4f0990,b'ROCK')]:
|
||||
if read_va(pe,va,len(text)+1)!=text+b'\0':raise ValueError('Changed animation binding')
|
||||
for va,fmt,value in [(0x495324,'f',20.),(0x492a58,'d',1.),(0x48e5d0,'d',.5)]:
|
||||
if struct.unpack('<'+fmt,read_va(pe,va,struct.calcsize(fmt)))[0]!=value:
|
||||
raise ValueError('Changed impact scale constant')
|
||||
return dict(sha256=EXE_SHA256,bodies=bodies,virtuals=[dict(table=hex(t),slot=hex(s),target=hex(v)) for t,s,v in tables],
|
||||
owned_pointer='Jimmy complete+AB0',rider_pointer='rocket complete+740/interface+680',
|
||||
reuse_id=ROCKET_ID,reuse_flag='interface+9',retained_flag='interface+11/+139=0',
|
||||
rider_local=[0,0,0],companion_local=[0,10,-25],fire_local=[0,0,0],
|
||||
scope='Guarded static lifecycle and bounded projections; no whole-game or original lifecycle execution')
|
||||
|
||||
|
||||
def resolve_reused(entries):
|
||||
"""46E6A0 predicate, then separate46E6E0 first-ID lookup, in registry order.
|
||||
|
||||
Entries are (identity, ObjectID, reusable). The lookup does not repeat the
|
||||
reusable check. Normal Jimmy construction supplies the first/eligible ship.
|
||||
"""
|
||||
entries=list(entries)
|
||||
if not any(object_id==ROCKET_ID and reusable for _,object_id,reusable in entries):return None
|
||||
return next(identity for identity,object_id,_ in entries if object_id==ROCKET_ID)
|
||||
|
||||
|
||||
def engine_transition(previous,handle_present,requested):
|
||||
if previous not in (0,1,2) or requested not in (0,1,2):raise ValueError('Bounded engine states are0/1/2')
|
||||
if requested in (1,2) and previous==requested:
|
||||
return dict(stop=False,start=None,mode=requested)
|
||||
return dict(stop=bool(handle_present),start={0:None,1:195,2:196}[requested],mode=requested)
|
||||
|
||||
|
||||
def engine_input(up,down,speed):
|
||||
if not math.isfinite(speed):raise ValueError('Nonfinite scalar')
|
||||
return 2 if up else 0 if down or speed<=0 else 1
|
||||
|
||||
|
||||
def impact_tail(active,timer,duration,impulse_flag,seconds,drive_burst=False):
|
||||
if not all(math.isfinite(v) for v in (timer,duration,seconds)) or timer<0 or duration<0 or not 0<=seconds<1:
|
||||
raise ValueError('Unsupported impact input')
|
||||
impulses=[]
|
||||
scale=None
|
||||
drive=False
|
||||
if active:
|
||||
if impulse_flag:impulses.append(-700.)
|
||||
#Source fst stores E88 but retains the unrounded x87 sum for comparison
|
||||
#and the sine calculation. Double is a projection, not x87 emulation.
|
||||
source_time=float(f32(timer))+float(f32(seconds))
|
||||
timer=f32(source_time)
|
||||
if source_time>duration:
|
||||
active=impulse_flag=False
|
||||
scale=(1.,1.,1.,1.)
|
||||
drive=True
|
||||
else:
|
||||
pulse=f32((math.sin(source_time*20.)+1.)*.5)
|
||||
scale=(1.,pulse,pulse,1.)
|
||||
if drive_burst:impulses.append(-750.)
|
||||
return dict(active=active,timer=timer,impulse_flag=impulse_flag,scale=scale,
|
||||
select_drive=drive,queued_y=impulses)
|
||||
|
||||
|
||||
def impact_probe_source(original):
|
||||
collect(original)
|
||||
pe=PE(find_case(Path(original),'Neutron.exe'))
|
||||
code=read_va(pe,0x43e6e8,0x43e7db-0x43e6e8)
|
||||
pairs=[]
|
||||
for target in (0x495324,0x492a58,0x48e5d0):
|
||||
encoded=struct.pack('<I',target)
|
||||
for index in range(len(code)-3):
|
||||
if code[index:index+4]==encoded:pairs.append((0x43e6e8+index,target))
|
||||
return IMPACT_PROBE.replace('/* RELOCATIONS */',','.join('{0x%x,0x%x}'%p for p in pairs))
|
||||
|
||||
|
||||
IMPACT_PROBE=r'''/* Generated isolated copied43E6E8..43E7DB impact tail. */
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define TC __attribute__((thiscall))
|
||||
#define AT(a) (mapped+(a)-0x400000)
|
||||
#define F(g,o) (*(float*)((g)+(o)))
|
||||
static unsigned char*mapped,*thunk,object[0x1000],rider[0x200],render[0x100];
|
||||
static uintptr_t table[0x400/4],rider_table[0x200/4];
|
||||
static int selected,impulse_count;static float impulses[4];
|
||||
static void require(int ok,const char*what){if(!ok){fprintf(stderr,"FAIL %s\n",what);exit(2);}}
|
||||
static void TC missing(void*self){(void)self;require(0,"unexpected virtual");}
|
||||
static void TC select_drive(void*self,const char*name,int restart){(void)self;(void)name;(void)restart;selected++;}
|
||||
static void TC impulse(void*self,float x,float y,float z){(void)self;require(x==0&&z==0&&impulse_count<4,"impulse shape");impulses[impulse_count++]=y;}
|
||||
static void map_copy(void){
|
||||
mapped=VirtualAlloc(NULL,0x299000,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE);require(mapped!=NULL,"map source");
|
||||
FILE*f=fopen("Neutron.exe","rb");require(f!=NULL,"copied EXE");fseek(f,0,SEEK_END);long size=ftell(f);rewind(f);require(size==1019904,"source size");
|
||||
unsigned char*d=malloc(size);require(d!=NULL,"source buffer");require(fread(d,1,size,f)==(size_t)size,"read source");fclose(f);
|
||||
require(*(uint16_t*)d==IMAGE_DOS_SIGNATURE,"DOS");uint32_t off=*(uint32_t*)(d+0x3c);require(off<(uint32_t)size-sizeof(IMAGE_NT_HEADERS32),"NT bounds");
|
||||
IMAGE_NT_HEADERS32*nt=(void*)(d+off);require(nt->Signature==IMAGE_NT_SIGNATURE&&nt->FileHeader.Machine==IMAGE_FILE_MACHINE_I386&&nt->OptionalHeader.ImageBase==0x400000&&nt->OptionalHeader.SizeOfImage==0x299000,"PE identity");
|
||||
IMAGE_SECTION_HEADER*s=IMAGE_FIRST_SECTION(nt);require((unsigned char*)(s+nt->FileHeader.NumberOfSections)<=d+size,"section table");
|
||||
for(unsigned i=0;i<nt->FileHeader.NumberOfSections;i++){require((uint64_t)s[i].PointerToRawData+s[i].SizeOfRawData<=(uint64_t)size&&(uint64_t)s[i].VirtualAddress+s[i].SizeOfRawData<=0x299000,"section bounds");memcpy(mapped+s[i].VirtualAddress,d+s[i].PointerToRawData,s[i].SizeOfRawData);}free(d);
|
||||
static const struct{uint32_t va,target;} patches[]={/* RELOCATIONS */};
|
||||
for(unsigned i=0;i<sizeof(patches)/sizeof(patches[0]);i++){uint32_t*p=(void*)AT(patches[i].va);require(*p==patches[i].target,"operand guard");*p=(uint32_t)AT(patches[i].target);}
|
||||
for(unsigned i=0;i<sizeof(table)/sizeof(table[0]);i++)table[i]=(uintptr_t)missing;
|
||||
for(unsigned i=0;i<sizeof(rider_table)/sizeof(rider_table[0]);i++)rider_table[i]=(uintptr_t)missing;
|
||||
table[0x280/4]=(uintptr_t)impulse;rider_table[0xe0/4]=(uintptr_t)select_drive;
|
||||
const unsigned char code[]={0x83,0xec,0x38,0x53,0x55,0x56,0x57,0x8b,0xf1,0x33,0xdb,0xbf,1,0,0,0,0xe9,0,0,0,0};
|
||||
thunk=VirtualAlloc(NULL,sizeof(code),MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE);require(thunk!=NULL,"frame thunk");memcpy(thunk,code,sizeof(code));*(int32_t*)(thunk+17)=(int32_t)(AT(0x43e6e8)-(thunk+21));
|
||||
}
|
||||
static void run(const char*name,int active,float timer,float duration,int strong,float dt,int burst){
|
||||
memset(object,0,sizeof(object));memset(render,0,sizeof(render));memset(rider,0,sizeof(rider));unsigned char*g=object+0xc0;
|
||||
*(uintptr_t**)g=table;*(uintptr_t**)rider=rider_table;*(void**)(g+0x680)=rider;*(void**)(g+0x500)=render;
|
||||
F(g,0xe88)=timer;F(g,0xec4)=duration;g[0xe84]=active;g[0xed0]=strong;g[0xec0]=burst;
|
||||
for(int i=0;i<4;i++)F(render,0x4c+i*4)=1.25f;
|
||||
selected=impulse_count=0;memset(impulses,0,sizeof(impulses));((void(TC*)(void*,float))thunk)(g,dt);
|
||||
printf("CASE %s active=%u timer=%.9g strong=%u scale=%.9g,%.9g,%.9g,%.9g drive=%d count=%d impulses=%.9g,%.9g\n",name,g[0xe84],F(g,0xe88),g[0xed0],F(render,0x4c),F(render,0x50),F(render,0x54),F(render,0x58),selected,impulse_count,impulses[0],impulses[1]);
|
||||
}
|
||||
int main(void){map_copy();
|
||||
run("inactive",0,.75f,1,0,.1f,0);
|
||||
run("ordinary",1,0,1,0,1.f/60,0);
|
||||
run("equal",1,.5f,1,0,.5f,0);
|
||||
run("expired",1,.9f,1,0,.2f,0);
|
||||
run("strong",1,.1f,1,1,.1f,0);
|
||||
run("expired_both",1,1,1,1,.1f,1);
|
||||
run("inactive_burst",0,.75f,1,0,.1f,1);
|
||||
run("rounded_expired",1,.9999999403953552f,1,0,.0000001f,0);
|
||||
puts("ROCKET_IMPACT_COMPONENT_COMPLETE:");return 0;}
|
||||
'''
|
||||
|
||||
|
||||
def main():
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path)
|
||||
cli.add_argument('--output',type=Path)
|
||||
cli.add_argument('--probe-source',type=Path)
|
||||
args=cli.parse_args();report=collect(args.original)
|
||||
if args.probe_source:
|
||||
target=args.probe_source.resolve()
|
||||
if target.is_relative_to(args.original.resolve()):cli.error('Probe must be outside originals')
|
||||
target.parent.mkdir(parents=True,exist_ok=True);target.write_text(impact_probe_source(args.original))
|
||||
text=json.dumps(report,indent=2,allow_nan=False)+'\n'
|
||||
if args.output:
|
||||
target=args.output.resolve();original=args.original.resolve()
|
||||
if target.is_relative_to(original):cli.error('Output must be outside originals')
|
||||
target.parent.mkdir(parents=True,exist_ok=True);target.write_text(text)
|
||||
else:print(text,end='')
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,333 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guarded Rocketship motion/camera math and separate copied-source probe.
|
||||
|
||||
The projection omits original x87 bit identity and registry/body/actor execution.
|
||||
The generated probe uses copied EXE functions and the copied OMT2 trig/angles.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
from rocketship import PROBE as BASE_PROBE
|
||||
from shrink_heading import DLL_SHA256, half_acos_table, heading_units
|
||||
|
||||
|
||||
SPANS = (
|
||||
('flight_apply',0x41a140,0x41a6b1,'20fc706986e58791dc19334a01a772dd517cbd260079382dac2f009fc8707bb7'),
|
||||
('flight_input_camera',0x41a6c0,0x41ade6,'eae8075a264d9c51d12deba47c9f24eb1624c646f688c57949c8aad8268ac99d'),
|
||||
('facing',0x41adf0,0x41afa2,'ae33bec7932c0ac9d5287dcfd790d1699ebdef5ab05f74c843a43ae9bc2af4e1'),
|
||||
('add_euler',0x472480,0x472570,'406c3904538abe07d88ca440e39ca56c00765d0871943991ba7b792da4803c16'),
|
||||
('point_transform',0x472980,0x472b10,'18752360ad70d2db3aa95fdcc643d4099bca2e59843b1e57aca9f17b5b1ccb6c'),
|
||||
('vector_transform',0x472b10,0x472c10,'ee9516aef07738fcf7da370af74185f7522686759218ad1bf4d93be46f0c28b2'),
|
||||
('camera_ray',0x419de0,0x419ecf,'5ad2724e6dee64929a14ab8d7ab7ebcff1b219df547580bd044127310c6b6131'),
|
||||
('flying_ctor',0x419b70,0x419db0,'85c0e74764282ed55e2c7268a0dec5944097b16f1a9df71054e5458b446ee2c0'),
|
||||
('destination',0x472660,0x472685,'e18df19aec39509f78fd20861938b67f2688a6aa142f064a7f5721f4676ee344'),
|
||||
('registry_facing',0x473240,0x473298,'46dc448d383d31fcb9eb4ad2c033f5c08cc51b5d196f982a7c25dfa3242fb91d'),
|
||||
)
|
||||
TABLES = ((0x4b25ac,0x328,0x4723f0),(0x4b25ac,0x334,0x458f90),
|
||||
(0x4b25ac,0x36c,0x472660),(0x4b25ac,0x384,0x472980),
|
||||
(0x4b25ac,0x38c,0x472b10),(0x4b25ac,0x3d8,0x41adf0),
|
||||
(0x4b2a4c,0x12c,0x419de0))
|
||||
CONSTANTS = ((0x48e5a0,3.),(0x49d5e8,4.),(0x48e5b0,180.),
|
||||
(0x48e5c0,-180.),(0x48e5c4,360.),(0x49d5c0,1.2000000476837158),
|
||||
(0x49d5c4,.6000000238418579),(0x49d5ac,.75),(0x48d954,2.),
|
||||
(0x48e5e8,45.511112213134766),(0x49d5b8,.0181818176060915))
|
||||
|
||||
|
||||
def f32(x): return struct.unpack('<f',struct.pack('<f',x))[0]
|
||||
|
||||
|
||||
def collect(original):
|
||||
original=Path(original)
|
||||
pe=PE(find_case(original,'Neutron.exe'))
|
||||
dll=PE(find_case(original,'OMT2.dll'))
|
||||
if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256 or hashlib.sha256(dll.data).hexdigest()!=DLL_SHA256:
|
||||
raise ValueError('Unexpected source image identity')
|
||||
bodies=[]
|
||||
for name,start,end,expected in SPANS:
|
||||
actual=hashlib.sha256(read_va(pe,start,end-start)).hexdigest()
|
||||
if actual!=expected: raise ValueError(f'Changed source span {name}')
|
||||
bodies.append(dict(name=name,va=hex(start),end=hex(end),file_offset=hex(pe.offset(start-pe.base)),sha256=actual))
|
||||
for tab,slot,target in TABLES:
|
||||
if struct.unpack('<I',read_va(pe,tab+slot,4))[0]!=target: raise ValueError('Changed virtual target')
|
||||
for va,value in CONSTANTS:
|
||||
if struct.unpack('<f',read_va(pe,va,4))[0]!=value: raise ValueError('Changed motion/camera constant')
|
||||
imports={int(v['iat'],16):v['name'] for v in pe.imports()}
|
||||
if imports[0x48d108]!='?angles@OMedia3DVector@@QAEXAAF0@Z' or imports[0x48d10c]!='?global@OMediaCosSinTable@@2V1@A':
|
||||
raise ValueError('Changed OMT vector/table import')
|
||||
globals_=[0x4f8198,0x4f8182,0x50988c,0x509845,0x509acc,0x50988a,0x509aca,
|
||||
0x48d914,0x48e5b0,0x49d5bc,0x48d924,0x49d5b8,0x48e5e8,
|
||||
0x48d10c,0x48d108,0x4f81ac,0x49d5c0,0x49d5c4,
|
||||
0x509a50,0x50985d,0x50985f,0x509aa0,0x509aa4,0x48d948,0x48d94c,
|
||||
0x49b1fc,0x49d5e4,0x509882,0x509881,0x509885,0x509891,0x509848,
|
||||
0x50985e,0x509834,0x49d5e0,0x49d5dc,0x48e5bc,0x509860,0x50993a,
|
||||
0x49d5d8,0x49d5d4,0x48e5ec,0x495324,0x49d5d0,0x49d5cc,0x49d5c8,
|
||||
0x48e5c0,0x48e5c4,0x48e5a0,0x49d5e8,0x5cfc60,0x5cfc64,
|
||||
0x5cfc68,0x5cfc6c,0x49d5ac,0x48d954]
|
||||
reloc=[]
|
||||
for _,start,end,_ in SPANS:
|
||||
code=read_va(pe,start,end-start)
|
||||
for target in globals_:
|
||||
pattern=struct.pack('<I',target)
|
||||
for i in range(len(code)-3):
|
||||
if code[i:i+4]==pattern:reloc.append((start+i,target))
|
||||
return dict(source_sha256=EXE_SHA256,dll_sha256=DLL_SHA256,bodies=bodies,
|
||||
vtables=[dict(table=hex(a),slot=hex(b),target=hex(c)) for a,b,c in TABLES],
|
||||
constants=[dict(va=hex(a),value=b) for a,b in CONSTANTS],relocations=sorted(set(reloc)))
|
||||
|
||||
|
||||
def trig(angle):
|
||||
index=math.trunc(angle*f32(45.511112213134766))&16383
|
||||
return f32(math.sin(index*math.tau/16384)),f32(math.cos(index*math.tau/16384))
|
||||
|
||||
|
||||
def rotate(vector,euler):
|
||||
"""472B10: negative Z, then negative X, then negative Y; lookup-quantized."""
|
||||
x,y,z=vector;sx,cx=trig(euler[0]);sy,cy=trig(euler[1]);sz,cz=trig(euler[2])
|
||||
a=f32(cz*y-sz*x)
|
||||
b=cz*x+sz*y
|
||||
c=cx*z-a*sx
|
||||
return (f32(b*cy-c*sy),f32(a*cx+sx*z),f32(c*cy+b*sy))
|
||||
|
||||
|
||||
def add_axis(value,delta):
|
||||
total=value+delta
|
||||
if total<0:total=360-abs(math.trunc(total))
|
||||
elif total>360:total-=360
|
||||
return f32(total)
|
||||
|
||||
|
||||
def facing(rotation,destination,dt,enabled=True,barrel_timer=0):
|
||||
if not enabled or barrel_timer>0:return tuple(rotation),enabled
|
||||
differences=[]
|
||||
active=False
|
||||
for axis,(target,current) in enumerate(zip(destination,rotation)):
|
||||
d=target-current
|
||||
if d!=0:
|
||||
active=True
|
||||
if d>180:d-=360
|
||||
elif axis!=1 and d<-180:d+=360
|
||||
differences.append(d)
|
||||
increments=[f32(d*dt*k) for d,k in zip(differences,(2,4,3))]
|
||||
return tuple(add_axis(v,d) for v,d in zip(rotation,increments)),active
|
||||
|
||||
|
||||
def horizontal(velocity,rotation,speed,bank,previous_bank,dt,friction=.8,
|
||||
turn_timer=0,roll_timer=0,turn_latch=False,roll_latch=False,
|
||||
turn_pressed=False,roll_pressed=False,suppressed=False):
|
||||
"""Ordinary no-boost/no-roll apply, after inherited facing, before vertical."""
|
||||
moving=any(v!=0 for v in velocity)
|
||||
if not suppressed:
|
||||
if not turn_pressed:turn_latch=False
|
||||
elif moving and not turn_latch:
|
||||
turn_latch=True
|
||||
if turn_timer<=0:turn_timer=1
|
||||
if not roll_pressed:roll_latch=False
|
||||
elif moving and not roll_latch:
|
||||
roll_latch=True
|
||||
if roll_timer<=0:roll_timer=1
|
||||
if turn_timer>0:
|
||||
rotation=(rotation[0],add_axis(rotation[1],f32(180*dt)),rotation[2])
|
||||
turn_timer=f32(max(0,turn_timer-dt))
|
||||
elif moving:
|
||||
previous_bank=bank
|
||||
rotation=(rotation[0],add_axis(rotation[1],f32(bank*dt)),rotation[2])
|
||||
if roll_timer>0:
|
||||
roll_timer=f32(max(0,roll_timer-dt))
|
||||
rotation=(rotation[0],rotation[1],add_axis(rotation[2],f32(270*dt)))
|
||||
if moving:
|
||||
side=f32(previous_bank*f32(.0181818176060915)*(1-f32(friction))*speed)
|
||||
sy,cy=trig(rotation[1])
|
||||
side_x=f32(cy*side);side_z=f32(sy*side)
|
||||
else:side_x=side_z=0
|
||||
forward=rotate((0,0,speed),rotation)
|
||||
outgoing=velocity if turn_timer>0 else (f32(forward[0]+side_x),velocity[1],f32(forward[2]+side_z))
|
||||
return dict(rotation=tuple(rotation),velocity=tuple(outgoing),previous_bank=previous_bank,
|
||||
turn_timer=turn_timer,roll_timer=roll_timer,turn_latch=turn_latch,roll_latch=roll_latch)
|
||||
|
||||
|
||||
def camera(root,rotation,old_eye,dt,detail=0,hit=None):
|
||||
eye_local=rotate((0,200,-500),rotation);look_local=rotate((0,50,200),rotation)
|
||||
eye=tuple(f32(a+b) for a,b in zip(root,eye_local))
|
||||
look=tuple(f32(a+b) for a,b in zip(root,look_local))
|
||||
gain=1
|
||||
if hit is not None:
|
||||
eye=tuple(f32(a-(a-b)*.75) for a,b in zip(look,hit));gain=2
|
||||
multiplier=f32(.6 if detail<=1 else 1.2)
|
||||
updated=tuple(f32(old+(want-old)*gain*dt*multiplier) for old,want in zip(old_eye,eye))
|
||||
direction=tuple(f32(a-b) for a,b in zip(look,old_eye))
|
||||
pitch,yaw=angles(direction)
|
||||
return dict(eye=updated,desired_eye=eye,look=look,direction=direction,gain=gain,pitch=pitch,yaw=yaw)
|
||||
|
||||
|
||||
def angles(vector):
|
||||
x,y,z=vector;heading=heading_units(x,z)
|
||||
a=(-heading)&16383
|
||||
sine=f32(math.sin(a*math.tau/16384));cosine=f32(math.cos(a*math.tau/16384))
|
||||
h=x*sine+z*cosine
|
||||
if h==0 and y==0:value=0
|
||||
else:
|
||||
value=half_acos_table()[math.trunc(16384*y*y/(h*h+y*y))]
|
||||
if y<0:value=8192+value if h<0 else 8192-value
|
||||
elif h<0:value=16384-value
|
||||
pitch=(4096-value)&16383
|
||||
if pitch>8192:pitch-=16384
|
||||
return pitch,heading-16384 if heading>8192 else heading
|
||||
|
||||
|
||||
def ingest(report,log,executable,source):
|
||||
content=Path(log).read_text()
|
||||
if 'ROCKET_MOTION_CAMERA_COMPLETE:' not in content:raise ValueError('Incomplete original probe')
|
||||
cases=[];seen=set()
|
||||
for line in content.splitlines():
|
||||
fields=line.split()
|
||||
if not fields or fields[0] not in ('TRANSFORM','MOTION','AUX','FACING','CAMERA'):continue
|
||||
kind,name,*pairs=fields
|
||||
if (kind,name) in seen:raise ValueError('Repeated original case')
|
||||
seen.add((kind,name));sample={}
|
||||
for pair in pairs:
|
||||
key,value=pair.split('=',1)
|
||||
numbers=[float(v) for v in value.split(',')]
|
||||
if not all(math.isfinite(v) for v in numbers):raise ValueError('Nonfinite original result')
|
||||
sample[key]=numbers if ',' in value else numbers[0]
|
||||
cases.append(dict(kind=kind,name=name,values=sample))
|
||||
if len(cases)!=31:raise ValueError('Unexpected original case count')
|
||||
return dict(scope='Copied EXE motion/facing/camera and copied OMT trig/angles; synthetic actor/body/ray/input dependencies; no game entrypoint',
|
||||
source_sha256=report['source_sha256'],dll_sha256=report['dll_sha256'],
|
||||
generator_sha256=hashlib.sha256(Path(source).read_bytes()).hexdigest(),
|
||||
executable_sha256=hashlib.sha256(Path(executable).read_bytes()).hexdigest(),
|
||||
log_sha256=hashlib.sha256(Path(log).read_bytes()).hexdigest(),cases=cases)
|
||||
|
||||
|
||||
def probe_source(report):
|
||||
prefix=BASE_PROBE[:BASE_PROBE.index('static void run(')]
|
||||
prefix=prefix.replace('#include <string.h>','#include <string.h>\n#include <math.h>')
|
||||
prefix=prefix.replace('memcpy(AT(0x41ac0e),finish,sizeof(finish));','(void)finish;')
|
||||
reloc=',\n'.join(f'{{0x{a:x},0x{b:x}}}' for a,b in report['relocations'])
|
||||
return prefix.replace('/* RELOCATIONS */',reloc)+PROBE_TAIL
|
||||
|
||||
|
||||
PROBE_TAIL=r'''
|
||||
typedef struct{float x,y,z,w;}Vec;
|
||||
typedef void(TC*Angles)(const float*,short*,short*);
|
||||
static Vec root,velocity;
|
||||
static Vec trace_start,trace_end,hit_point;
|
||||
static int ray_hit;
|
||||
static HMODULE omt;
|
||||
static Vec*TC get_root(void*self,Vec*out){(void)self;*out=root;return out;}
|
||||
static Vec*TC get_velocity(void*self,Vec*out){(void)self;*out=velocity;return out;}
|
||||
static void TC set_velocity(void*self,float x,float y,float z){(void)self;velocity.x=x;velocity.y=y;velocity.z=z;}
|
||||
static int __cdecl trace(Vec start,Vec end,int sides){(void)sides;trace_start=start;trace_end=end;memcpy(AT(0x5cfc60),&hit_point,sizeof(hit_point));return ray_hit;}
|
||||
static void __cdecl base_skip(float dt){(void)dt;}
|
||||
static void patch_jump(unsigned va,void*fn){unsigned char*p=AT(va);p[0]=0xb8;*(uintptr_t*)(p+1)=(uintptr_t)fn;p[5]=0xff;p[6]=0xe0;}
|
||||
static void setup(void){
|
||||
map_copy();omt=LoadLibraryA("Z:\\work\\game\\OMT2.dll");require(omt!=NULL,"copied OMT2");
|
||||
*(void**)AT(0x48d108)=GetProcAddress(omt,"?angles@OMedia3DVector@@QAEXAAF0@Z");
|
||||
*(void**)AT(0x48d10c)=GetProcAddress(omt,"?global@OMediaCosSinTable@@2V1@A");
|
||||
require(*(void**)AT(0x48d108)&&*(void**)AT(0x48d10c),"original angles/trig exports");
|
||||
patch_jump(0x47c210,trace);
|
||||
const unsigned char ready[]={0xb0,1,0xc3};memcpy(AT(0x475ca0),ready,sizeof(ready));
|
||||
const unsigned char base[]={0xc2,4,0};memcpy(AT(0x40e050),base,sizeof(base));
|
||||
const unsigned char finish[]={0x5f,0x5e,0x5b,0x83,0xc4,0x38,0xc2,4,0};memcpy(AT(0x41a470),finish,sizeof(finish));
|
||||
table[0x310/4]=(uintptr_t)get_root;table[0x2bc/4]=(uintptr_t)get_velocity;table[0x2c4/4]=(uintptr_t)set_velocity;
|
||||
table[0x328/4]=(uintptr_t)AT(0x4723f0);table[0x334/4]=(uintptr_t)AT(0x472480);table[0x36c/4]=(uintptr_t)AT(0x472660);
|
||||
table[0x248/4]=(uintptr_t)AT(0x471ad0);table[0x384/4]=(uintptr_t)AT(0x472980);table[0x38c/4]=(uintptr_t)AT(0x472b10);
|
||||
outer[0x12c/4]=(uintptr_t)AT(0x419de0);
|
||||
}
|
||||
static unsigned char*reset(float pitch,float yaw,float roll){
|
||||
memset(object,0,sizeof(object));unsigned char*g=object+0xc0;*(uintptr_t**)object=outer;*(uintptr_t**)g=table;
|
||||
memset(AT(0x509830),0,0x1d0);*(void**)AT(0x509a50)=camera;
|
||||
memset(camera,0,sizeof(camera));F(g,0x224)=pitch;F(g,0x228)=yaw;F(g,0x22c)=roll;
|
||||
F(g,0x150)=.8f;root=(Vec){100,200,300,1};ray_hit=0;mouse_x=mouse_y=grounded=0;
|
||||
*(int*)AT(0x4f81ac)=0;return g;
|
||||
}
|
||||
static void transform_case(const char*name,float p,float y,float r,float x,float v,float z){
|
||||
unsigned char*g=reset(p,y,r);Vec out;((Vec*(TC*)(void*,Vec*,float,float,float))AT(0x472b10))(g,&out,x,v,z);
|
||||
printf("TRANSFORM %s euler=%.9g,%.9g,%.9g vector=%.9g,%.9g,%.9g observed=%.9g,%.9g,%.9g\n",name,p,y,r,x,v,z,out.x,out.y,out.z);
|
||||
}
|
||||
static void motion_case(const char*name,float vx,float vy,float vz,float p,float y,float r,float speed,float bank,float previous,float dt){
|
||||
unsigned char*g=reset(p,y,r);velocity=(Vec){vx,vy,vz,0};F(g,0x608)=speed;F(g,0x614)=bank;F(g,0x618)=previous;
|
||||
((void(TC*)(void*,float))AT(0x41a140))(g,dt);
|
||||
printf("MOTION %s incoming=%.9g,%.9g,%.9g euler=%.9g,%.9g,%.9g speed=%.9g bank=%.9g previous=%.9g dt=%.9g observed_rotation=%.9g,%.9g,%.9g observed_velocity=%.9g,%.9g,%.9g observed_previous=%.9g\n",name,vx,vy,vz,p,y,r,speed,bank,previous,dt,F(g,0x224),F(g,0x228),F(g,0x22c),velocity.x,velocity.y,velocity.z,F(g,0x618));
|
||||
}
|
||||
static void aux_case(const char*name,float turn,float roll,int turn_press,int roll_press,int tlatch,int rlatch,float vy,float dt,int suppressed){
|
||||
unsigned char*g=reset(0,0,0);velocity=(Vec){10,vy,100,0};F(g,0x608)=400;F(g,0x614)=16;F(g,0x618)=7;
|
||||
F(g,0x674)=turn;F(g,0x670)=roll;g[0x679]=tlatch;g[0x678]=rlatch;
|
||||
*(char*)AT(0x509845)=turn_press;*(char*)AT(0x50988a)=roll_press;*(char*)AT(0x4f8198)=suppressed;
|
||||
((void(TC*)(void*,float))AT(0x41a140))(g,dt);*(char*)AT(0x4f8198)=0;
|
||||
printf("AUX %s timer=%.9g,%.9g pressed=%d,%d latch=%d,%d vy=%.9g dt=%.9g suppressed=%d observed_rotation=%.9g,%.9g,%.9g observed_velocity=%.9g,%.9g,%.9g observed_timer=%.9g,%.9g observed_latch=%d,%d observed_previous=%.9g\n",name,turn,roll,turn_press,roll_press,tlatch,rlatch,vy,dt,suppressed,F(g,0x224),F(g,0x228),F(g,0x22c),velocity.x,velocity.y,velocity.z,F(g,0x674),F(g,0x670),g[0x679],g[0x678],F(g,0x618));
|
||||
}
|
||||
static void facing_case(const char*name,float p,float y,float r,float dp,float dy,float dr,float dt){
|
||||
unsigned char*g=reset(p,y,r);F(g,0x274)=dp;F(g,0x278)=dy;F(g,0x27c)=dr;g[0xa]=1;
|
||||
((void(TC*)(void*,float))AT(0x41adf0))(g,dt);
|
||||
printf("FACING %s euler=%.9g,%.9g,%.9g dest=%.9g,%.9g,%.9g dt=%.9g observed_rotation=%.9g,%.9g,%.9g active=%d\n",name,p,y,r,dp,dy,dr,dt,F(g,0x224),F(g,0x228),F(g,0x22c),g[0xa]);
|
||||
}
|
||||
static void camera_case(const char*name,float p,float y,float r,float ex,float ey,float ez,float dt,int detail,int hit){
|
||||
unsigned char*g=reset(p,y,r);F(g,0x5fc)=400;F(g,0x600)=1;F(g,0x604)=1400;F(g,0x660)=20;F(g,0x664)=-20;
|
||||
F(g,0x63c)=0;F(g,0x640)=200;F(g,0x644)=-500;F(g,0x64c)=0;F(g,0x650)=50;F(g,0x654)=200;
|
||||
F(camera,0x44)=ex;F(camera,0x48)=ey;F(camera,0x4c)=ez;*(int*)AT(0x4f81ac)=detail;ray_hit=hit;hit_point=(Vec){80,250,100,1};
|
||||
((void(TC*)(void*,float))AT(0x41a6c0))(g,dt);
|
||||
printf("CAMERA %s euler=%.9g,%.9g,%.9g old=%.9g,%.9g,%.9g dt=%.9g detail=%d hit=%d observed_eye=%.9g,%.9g,%.9g pitch=%d yaw=%d trace_start=%.9g,%.9g,%.9g trace_end=%.9g,%.9g,%.9g\n",name,p,y,r,ex,ey,ez,dt,detail,hit,F(camera,0x44),F(camera,0x48),F(camera,0x4c),*(short*)(camera+0x50),*(short*)(camera+0x52),trace_start.x,trace_start.y,trace_start.z,trace_end.x,trace_end.y,trace_end.z);
|
||||
}
|
||||
int main(void){setbuf(stdout,NULL);setup();
|
||||
transform_case("forward",0,0,0,0,0,100);
|
||||
transform_case("yaw90",0,90,0,0,0,100);
|
||||
transform_case("pitch20",20,0,0,0,0,100);
|
||||
transform_case("roll45",0,0,45,10,20,30);
|
||||
transform_case("combined",20,70,35,10,20,30);
|
||||
transform_case("negative",-20,-70,-35,10,20,30);
|
||||
motion_case("stationary",0,0,0,0,0,0,400,16,7,.1f);
|
||||
motion_case("vertical_only",0,10,0,0,0,0,400,16,7,.1f);
|
||||
motion_case("left",0,0,100,0,0,0,400,16,7,.1f);
|
||||
motion_case("right_seam",0,0,100,0,0,0,400,-16,7,.1f);
|
||||
motion_case("pitch",0,0,100,20,70,0,1000,0,7,.1f);
|
||||
motion_case("all_euler",0,10,100,20,70,35,1000,25,7,1.f/60);
|
||||
motion_case("retained_bank_no_motion",0,0,0,20,70,35,1000,25,7,.1f);
|
||||
aux_case("turn_start",0,0,1,0,0,0,10,.1f,0);
|
||||
aux_case("roll_start",0,0,0,1,0,0,10,.1f,0);
|
||||
aux_case("turn_finish",.05f,0,1,0,1,0,10,.1f,0);
|
||||
aux_case("roll_finish",0,.05f,0,1,0,1,10,.1f,0);
|
||||
aux_case("held_no_restart",0,0,1,0,1,0,10,.1f,0);
|
||||
aux_case("released",0,0,0,0,1,1,10,.1f,0);
|
||||
aux_case("suppressed",0,0,1,1,0,0,10,.1f,1);
|
||||
facing_case("normal",0,20,0,20,20,-16,.1f);
|
||||
facing_case("wrap",350,359,350,10,1,10,.1f);
|
||||
facing_case("negative_yaw_delta",0,359,0,0,1,0,.1f);
|
||||
facing_case("same",0,0,0,0,0,0,.1f);
|
||||
facing_case("negative_fraction",0,0,0,-.5f,0,-.5f,.1f);
|
||||
camera_case("straight",0,0,0,-40,50,-100,.1f,0,0);
|
||||
camera_case("detail1",0,0,0,-40,50,-100,.1f,1,0);
|
||||
camera_case("detail2",0,0,0,-40,50,-100,.1f,2,0);
|
||||
camera_case("blocked",0,0,0,-40,50,-100,.1f,0,1);
|
||||
camera_case("combined",20,70,35,-40,50,-100,1.f/60,0,0);
|
||||
camera_case("combined_blocked",20,70,35,-40,50,-100,1.f/60,2,1);
|
||||
puts("ROCKET_MOTION_CAMERA_COMPLETE: isolated copied EXE and OMT math, synthetic dependencies, no game entrypoint");FreeLibrary(omt);return 0;}
|
||||
'''
|
||||
|
||||
|
||||
def main():
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path);cli.add_argument('--output',type=Path)
|
||||
cli.add_argument('--probe-source',type=Path)
|
||||
cli.add_argument('--probe-log',type=Path);cli.add_argument('--probe-executable',type=Path)
|
||||
cli.add_argument('--compiled-source',type=Path)
|
||||
args=cli.parse_args();report=collect(args.original)
|
||||
for output in (args.output,args.probe_source):
|
||||
if output is not None and output.resolve().is_relative_to(args.original.resolve()):cli.error('Use generated outputs outside originals')
|
||||
if args.probe_source:
|
||||
args.probe_source.parent.mkdir(parents=True,exist_ok=True);args.probe_source.write_text(probe_source(report))
|
||||
if any((args.probe_log,args.probe_executable,args.compiled_source)):
|
||||
if not all((args.probe_log,args.probe_executable,args.compiled_source)):cli.error('Supply log, executable and compiled source together')
|
||||
report['original_probe']=ingest(report,args.probe_log,args.probe_executable,args.compiled_source)
|
||||
if args.output:args.output.write_text(json.dumps(report,indent=2)+'\n')
|
||||
else:print(json.dumps(report,indent=2))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -14,6 +14,7 @@ from gadget_resources import export_gadget_resources
|
||||
from gadget_followup_assets import export_meter
|
||||
from bubble_resources import export_bubble
|
||||
from baseball_resources import export_baseball
|
||||
from rocketship_resources import export_rocketship
|
||||
from sound_bank import export_sound_bank
|
||||
|
||||
|
||||
@@ -86,6 +87,7 @@ def main():
|
||||
export_meter(args.original, args.output / 'invisible-meter')
|
||||
export_bubble(args.original,args.output/'bubble')
|
||||
export_baseball(args.original,args.output/'baseball')
|
||||
export_rocketship(args.original,args.output/'rocketship')
|
||||
effects = export_sound_bank(args.original, args.output / 'effects')
|
||||
print(f"SoundEffects.omt: {len(effects['resources'])} original sound identities")
|
||||
for name in args.audio:
|
||||
|
||||
Reference in new issue
Block a user