.bin (the bytes the VM runs, before the load-time // fixes), and .specs (the 16 VM spec bytes of the main script). // bin/jumphp php games/alis tools/lang/dump.php ../../.alis-data/robinson use App\Alis\Machine; use App\Alis\UnpackVars; require __DIR__ . '/../../vendor/autoload.php'; $dir = rtrim($argv[1] ?? 'data/robinson', '/'); $out = __DIR__ . '/../../var/scripts'; @mkdir($out, 0777, true); $m = new Machine(); if (!$m->boot(__DIR__ . '/../../' . $dir)) { fwrite(STDERR, "boot failed: {$m->error}\n"); exit(1); } $n = 0; foreach (glob(__DIR__ . '/../../' . $dir . '/*.io') as $path) { $raw = file_get_contents($path); $magic = unpack('V', $raw)[1]; $isMain = unpack('v', substr($raw, 4, 2))[1] === 0; $name = basename($path, '.io'); if (($magic >> 24) & 0x80) { $size = ($magic & 0xffffff) - UnpackVars::$kPackedHeaderSize - ($isMain ? UnpackVars::$kVMSpecsSize : 0); \App\Alis\Alis::$typepack = \App\Alis\s8(($magic >> 24) & 0xfe); $buf = \App\Alis\script_scratch(1024 + $size); $got = \App\Alis\unpack_script($path, $buf); $bytes = \App\Alis\mem_read($buf, $got); } else { $bytes = substr($raw, 6 + ($isMain ? 16 : 0)); } file_put_contents("$out/$name.bin", $bytes); if ($isMain) { file_put_contents("$out/$name.specs", substr($raw, 6, 16)); } $n++; } echo "$n scripts -> var/scripts\n";