Correct preview ground placement and expose original animation clips
This commit is contained in:
1 parent
670adb4795
commit
37fa18094f
22 files changed
+398
-33
No files matched your search
@@ -0,0 +1,44 @@
|
||||
/* Run only inside the isolated reference namespace. No original file is written. */
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <float.h>
|
||||
#define OMT_THISCALL __attribute__((thiscall))
|
||||
typedef void *(OMT_THISCALL *ctor0)(void *);
|
||||
typedef void (OMT_THISCALL *writefn)(void *, void *, unsigned);
|
||||
typedef void (OMT_THISCALL *seekfn)(void *, unsigned, short);
|
||||
typedef void *(OMT_THISCALL *converterctor)(void *, void *, void *);
|
||||
typedef void (OMT_THISCALL *convertfn)(void *);
|
||||
static FARPROC required(HMODULE h, const char *name) {
|
||||
FARPROC p=GetProcAddress(h,name);
|
||||
if(!p){fprintf(stderr,"Missing export: %s\n",name);exit(2);} return p;
|
||||
}
|
||||
int main(int argc,char **argv) {
|
||||
setbuf(stdout,NULL);
|
||||
const char *input=argc>1?argv[1]:"ASE\\jimstop.ase";
|
||||
FILE *f=fopen(input,"rb");if(!f){perror(input);return 2;}
|
||||
fseek(f,0,SEEK_END);long length=ftell(f);rewind(f);
|
||||
char *data=malloc(length);if(fread(data,1,length,f)!=(size_t)length)return 2;fclose(f);
|
||||
HMODULE h=LoadLibraryA("Z:\\work\\game\\OMT2.dll");
|
||||
if(!h){fprintf(stderr,"LoadLibrary OMT error %lu\n",GetLastError());return 2;}
|
||||
unsigned char *stream=calloc(1,8192),*shape=calloc(1,8192),*converter=calloc(1,8192);
|
||||
((ctor0)required(h,"??0OMediaMemStream@@QAE@XZ"))(stream);
|
||||
((writefn)required(h,"?write@OMediaStream@@UAEXPAXK@Z"))(stream,data,length);
|
||||
((seekfn)required(h,"?setposition@OMediaStream@@UAEXKF@Z"))(stream,0,0);
|
||||
((ctor0)required(h,"??0OMedia3DShape@@QAE@XZ"))(shape);
|
||||
*(int*)required(h,"?obj_conv_mode@OMedia3DShapeConverter@@1W4omt_3DObjectConvertMode@@A")=0;
|
||||
*(int*)required(h,"?anim_conv_mode@OMedia3DShapeConverter@@1W4omt_3DAnimConvertMode@@A")=0;
|
||||
((converterctor)required(h,"??0OMediaASEConverter@@QAE@PAVOMediaStreamOperators@@PAVOMedia3DShape@@@Z"))(converter,stream,shape);
|
||||
puts("CONVERT_BEGIN");
|
||||
((convertfn)required(h,"?convert@OMediaASEConverter@@UAEXXZ"))(converter);
|
||||
float *begin=*(float**)(shape+0x68),*end=*(float**)(shape+0x6c);
|
||||
intptr_t bytes=(intptr_t)end-(intptr_t)begin;
|
||||
if(!begin || bytes<=0 || bytes%16 || bytes>16000000){fputs("Unexpected shape layout\n",stderr);return 3;}
|
||||
printf("VERTICES %ld\n",(long)bytes/16);
|
||||
float lo[3]={FLT_MAX,FLT_MAX,FLT_MAX},hi[3]={-FLT_MAX,-FLT_MAX,-FLT_MAX};
|
||||
for(float *p=begin;p<end;p+=4){for(int i=0;i<3;i++){if(p[i]<lo[i])lo[i]=p[i];if(p[i]>hi[i])hi[i]=p[i];}}
|
||||
printf("MIN %.9g %.9g %.9g\nMAX %.9g %.9g %.9g\n",lo[0],lo[1],lo[2],hi[0],hi[1],hi[2]);
|
||||
for(int i=0;i<3 && begin+i*4<end;i++)printf("V%d %.9g %.9g %.9g\n",i,begin[i*4],begin[i*4+1],begin[i*4+2]);
|
||||
return 0;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ def main():
|
||||
parser.add_argument('--output', type=Path, default=Path('artifacts/extracted'))
|
||||
parser.add_argument('--scenes', nargs='+', default=['level1b', 'VR01'])
|
||||
parser.add_argument('--audio', nargs='*', default=['sounds', 'musicjimmyshouse', 'musicneighborhood'])
|
||||
parser.add_argument('--animations', nargs='*', default=['jimstop', 'jimrun', 'jimjump'])
|
||||
parser.add_argument('--animations', nargs='*', default=['jimstop', 'jimrun', 'jimjump', 'jimscratch'])
|
||||
args = parser.parse_args()
|
||||
if args.output.resolve().is_relative_to(args.original.resolve()):
|
||||
parser.error('Output must be outside the original installation')
|
||||
|
||||
@@ -38,6 +38,7 @@ def enter_key():
|
||||
|
||||
def inside(args):
|
||||
work = Path('/work')
|
||||
if args.port_smoke: (work/'port-frame.ppm').unlink(missing_ok=True)
|
||||
with (work/'xvfb.log').open('w') as xlog, (work/'wine.log').open('w') as wlog:
|
||||
display = subprocess.Popen(['/native/usr/bin/Xvfb', ':89', '-screen', '0', '1024x768x24', '-nolisten', 'tcp'], stdout=xlog, stderr=xlog)
|
||||
wine = None
|
||||
@@ -52,8 +53,11 @@ def inside(args):
|
||||
application = ['/opt/wine-stable/bin/wine', r'Z:\port\GamePort.exe',
|
||||
'--assets', r'Z:\port\assets', '--scene', r'Z:\port\scenes\level1b\scene.json',
|
||||
'--level', 'gam/level1b.gam', '--original-camera', '--with-player',
|
||||
'--headless', '--frames', '2', '--time', '0.05', '--no-validation',
|
||||
'--frames', '6' if args.port_window else '2', '--time', '0.05', '--no-validation',
|
||||
'--screenshot', r'Z:\work\port-frame.ppm']
|
||||
application += ['--smoke-window'] if args.port_window else ['--headless']
|
||||
if args.asset_probe:
|
||||
application = ['/opt/wine-stable/bin/wine', r'Z:\probe.exe', args.probe_model]
|
||||
wine = subprocess.Popen(application, cwd='/work' if args.port_smoke else '/work/game', stdout=wlog, stderr=wlog, env=wine_env)
|
||||
captures = []
|
||||
for index in range(3):
|
||||
@@ -63,7 +67,7 @@ def inside(args):
|
||||
captures.append({'file': target, 'captureExit': image.returncode, 'wineExit': wine.poll()})
|
||||
if args.enter:
|
||||
captures[-1]['sentReturn'] = enter_key()
|
||||
if args.port_smoke and wine.poll() is not None: break
|
||||
if (args.port_smoke or args.asset_probe) and wine.poll() is not None: break
|
||||
tree = subprocess.run(['xwininfo', '-root', '-tree'], capture_output=True, text=True)
|
||||
(work/'windows.txt').write_text(tree.stdout + tree.stderr)
|
||||
processes = []
|
||||
@@ -71,7 +75,8 @@ def inside(args):
|
||||
try: processes.append(path.parent.name + ': ' + path.read_bytes().replace(b'\x00', b' ').decode('utf8', 'replace'))
|
||||
except OSError: pass
|
||||
(work/'processes.txt').write_text('\n'.join(processes)+'\n')
|
||||
(work/'capture.json').write_text(json.dumps({'game': 'GamePort.exe' if args.port_smoke else args.game, 'captures': captures}, indent=2)+'\n')
|
||||
application_name = 'GamePort.exe' if args.port_smoke else 'omt_shape_probe.exe' if args.asset_probe else args.game
|
||||
(work/'capture.json').write_text(json.dumps({'game': application_name, 'captures': captures}, indent=2)+'\n')
|
||||
finally:
|
||||
subprocess.run(['/opt/wine-stable/bin/wineserver', '-k'], timeout=10, check=False)
|
||||
if wine and wine.poll() is None: wine.terminate()
|
||||
@@ -88,13 +93,19 @@ def main():
|
||||
p.add_argument('--debug', action='store_true', help='Record Wine process and exception diagnostics')
|
||||
p.add_argument('--wine-renderer', choices=['gl','vulkan'], default='gl')
|
||||
p.add_argument('--port-smoke', action='store_true', help='Preliminary Windows port check under Wine64; not native Windows validation')
|
||||
p.add_argument('--port-window', action='store_true', help='Windows port SDL window/input/resize/animation smoke under Wine64')
|
||||
p.add_argument('--asset-probe', action='store_true', help='Run compiled read-only OMT shape probe inside isolated copy')
|
||||
p.add_argument('--probe-model', default=r'ASE\jimstop.ase')
|
||||
p.add_argument('--output', type=Path)
|
||||
args = p.parse_args()
|
||||
args.port_smoke = args.port_smoke or args.port_window
|
||||
if args.port_smoke and args.asset_probe: p.error('Select either port smoke or asset probe')
|
||||
if not 3 <= args.seconds <= 120: p.error('--seconds must be 3..120')
|
||||
if args.inside: return inside(args)
|
||||
project = Path(__file__).resolve().parents[2]
|
||||
source = project.parent/'Original'
|
||||
work = (args.output or project/('artifacts/windows-smoke' if args.port_smoke else 'artifacts/reference')).resolve()
|
||||
default_output = 'artifacts/windows-smoke' if args.port_smoke else 'artifacts/asset-probe' if args.asset_probe else 'artifacts/reference'
|
||||
work = (args.output or project/default_output).resolve()
|
||||
if work.is_relative_to(source.resolve()) or source.resolve().is_relative_to(work):
|
||||
p.error('Output must be separate from originals')
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
@@ -113,6 +124,8 @@ def main():
|
||||
'--ro-bind', str(Path(__file__).resolve()), '/capture.py']
|
||||
if args.port_smoke:
|
||||
cmd += ['--ro-bind', str(project/'dist/win-x64'), '/port']
|
||||
if args.asset_probe:
|
||||
cmd += ['--ro-bind', str(project/'artifacts/binary/omt_shape_probe.exe'), '/probe.exe']
|
||||
for key,value in {'HOME':'/work/home', 'WINEPREFIX':'/work/prefix', 'WINEARCH':'win64' if args.port_smoke else 'win32',
|
||||
'DISPLAY':':89', 'PATH':'/opt/wine-stable/bin:/usr/bin:/bin', 'LANG':'C.UTF-8',
|
||||
'WINEDEBUG':'-all,err+all,warn+ddraw,warn+d3d,+seh' if args.debug else '-all',
|
||||
@@ -130,6 +143,8 @@ def main():
|
||||
cmd += ['/usr/bin/python3', '/capture.py', '--inside', '--game', args.game, '--seconds', str(args.seconds)]
|
||||
if args.enter: cmd += ['--enter']
|
||||
if args.port_smoke: cmd += ['--port-smoke']
|
||||
if args.port_window: cmd += ['--port-window']
|
||||
if args.asset_probe: cmd += ['--asset-probe', '--probe-model', args.probe_model]
|
||||
print('Running isolated Windows port' if args.port_smoke else 'Running copied original', 'with no network and no original-directory mount:', work, flush=True)
|
||||
subprocess.run(cmd, check=True, timeout=args.seconds + 40)
|
||||
print('Capture metadata:', work/'capture.json')
|
||||
@@ -138,6 +153,10 @@ def main():
|
||||
if result['captures'][-1]['wineExit'] != 0 or not (work/'port-frame.ppm').is_file():
|
||||
raise SystemExit('Windows port smoke did not pass; inspect wine.log (native Windows remains unverified)')
|
||||
print('Windows port rendered under Wine; native Windows validation is still required')
|
||||
if args.asset_probe:
|
||||
result = json.loads((work/'capture.json').read_text())
|
||||
if result['captures'][-1]['wineExit'] != 0 or 'VERTICES ' not in (work/'wine.log').read_text():
|
||||
raise SystemExit('OMT asset probe did not complete; inspect wine.log')
|
||||
|
||||
|
||||
if __name__ == '__main__': main()
|
||||
Reference in new issue
Block a user