Skip to content

Instantly share code, notes, and snippets.

@marijnvdwerf
Created January 22, 2017 17:39
Show Gist options
  • Save marijnvdwerf/64da109af7e2b9c9b3d2c0469babaf85 to your computer and use it in GitHub Desktop.
Save marijnvdwerf/64da109af7e2b9c9b3d2c0469babaf85 to your computer and use it in GitHub Desktop.
Pokemon ruby decompilation progress
#!/usr/bin/env php
<?php
$basedir = getcwd();
if (!file_exists($basedir . '/pokeruby.map')) {
die(sprintf("pokeruby.map couldn't be found in %s", $basedir));
}
$lines = file_get_contents($basedir . '/pokeruby.map');
$lines = explode("\n", $lines);
$working = false;
$counts = [
'src' => 0,
'asm' => 0,
];
foreach ($lines as $line) {
if (strpos($line, '.text') === 0) {
$working = true;
}
if (!$working) {
continue;
}
if (strpos($line, 'script_data') === 0) {
break;
}
if (!preg_match('~^ (.{14}) (0x[0-9a-f]{8}) ( *0x[0-9a-f]*) (asm|src)/(.*)$~', $line, $m)) {
continue;
}
$counts[$m[4]] += intval($m[3], 16);
}
printf("%s%%\n", number_format($counts['src'] / array_sum($counts) * 100, 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment