mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Decompiled 11 functions in unknown_080500
This commit is contained in:
+41
-4
@@ -1,9 +1,11 @@
|
||||
import re
|
||||
import sys
|
||||
from file_util import FileUtil
|
||||
|
||||
SRC_DIRECTORY = './src'
|
||||
FUNCTION_REGEX = r'([/][*]([^*]|([*][^/]))*[*][/][\n]\s*)?(void|s64|s32|s16|s8|u64|u32|u16|u8|f32|f64)(\s|[*])*([0-9A-Za-z_]+)\s*[(][^)]*[)]\s*{'
|
||||
WIP_REGEX = r'#if(.|\n)*?(GLOBAL_ASM[(][^)]*[)])(.|\n)*?#else(.|\n)*?#endif'
|
||||
GLOBAL_ASM_REGEX = r'GLOBAL_ASM[(]\"[^/]*/[^/]*/[^/]*/([a-zA-Z0-9_]*).s\"[)]'
|
||||
WIP_REGEX = r'#if(.|\n)*?(GLOBAL_ASM[(]([^)]*)[)])(.|\n)*?#else(.|\n)*?#endif'
|
||||
|
||||
CODE_START = 0x80000400
|
||||
CODE_END = 0x800D75F4
|
||||
@@ -41,6 +43,7 @@ class ScoreFileMatch:
|
||||
class ScoreFile:
|
||||
def __init__(self, filepath):
|
||||
self.functions = []
|
||||
self.unfinishedSize = 0
|
||||
self.numGlobalAsms = 0
|
||||
self.path = filepath
|
||||
self.read_file()
|
||||
@@ -50,14 +53,22 @@ class ScoreFile:
|
||||
def read_file(self):
|
||||
with open(self.path, "r") as inFile:
|
||||
self.text = inFile.read()
|
||||
self.text = re.sub(WIP_REGEX, 'GLOBAL_ASM()', self.text)
|
||||
self.text = re.sub(WIP_REGEX, r"GLOBAL_ASM(\3)", self.text)
|
||||
|
||||
def get_matches(self):
|
||||
matches = re.finditer(FUNCTION_REGEX, self.text, re.MULTILINE)
|
||||
for matchNum, match in enumerate(matches, start=1):
|
||||
groups = match.groups()
|
||||
self.functions.append(ScoreFileMatch(groups[0], groups[5]))
|
||||
self.numGlobalAsms = self.text.count("GLOBAL_ASM")
|
||||
|
||||
matches = re.finditer(GLOBAL_ASM_REGEX, self.text, re.MULTILINE)
|
||||
for matchNum, match in enumerate(matches, start=1):
|
||||
groups = match.groups()
|
||||
self.numGlobalAsms += 1
|
||||
try:
|
||||
self.unfinishedSize += MAP_FILE.functionSizes[groups[0]]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def get_number_of_documented_functions(self):
|
||||
count = 0
|
||||
@@ -80,6 +91,19 @@ class ScoreFile:
|
||||
return size
|
||||
|
||||
def main():
|
||||
showTopFiles = 0
|
||||
|
||||
numArgs = len(sys.argv)
|
||||
for i in range(1, numArgs):
|
||||
arg = sys.argv[i].lower()
|
||||
print('Argument:', sys.argv[i])
|
||||
if arg.startswith("--top"):
|
||||
num = arg[5:]
|
||||
if num == "":
|
||||
showTopFiles = 10 # 10 is the default
|
||||
else:
|
||||
showTopFiles = int(num)
|
||||
|
||||
scoreFiles = []
|
||||
srcFilenames = FileUtil.get_filenames_from_directory_recursive(SRC_DIRECTORY, extensions=('.c'))
|
||||
totalNumberOfDecompiledFunctions = 0
|
||||
@@ -111,7 +135,20 @@ def main():
|
||||
print(' # Documented functions: ' + str(totalNumberOfDocumentedFunctions))
|
||||
print(' # Undocumented remaining: ' + str(totalNumberOfFunctions - totalNumberOfDocumentedFunctions))
|
||||
print('=========================================')
|
||||
#print(totalNumberOfDecompiledFunctions, totalNumberOfGlobalAsms, totalNumberOfDocumentedFunctions)
|
||||
|
||||
if showTopFiles > 0:
|
||||
if showTopFiles > len(scoreFiles):
|
||||
showTopFiles = len(scoreFiles)
|
||||
print('======= TOP FILES ======== | TODO | DONE |')
|
||||
files = []
|
||||
for file in scoreFiles:
|
||||
files.append([file.path, file.unfinishedSize, file.get_size_of_functions()])
|
||||
files.sort(key=lambda x:x[1], reverse=True) # Sort by Size, Largest to Smallest
|
||||
for i in range(0, showTopFiles):
|
||||
percentageRemaining = (files[i][1] / CODE_SIZE) * 100
|
||||
percentageDone = (files[i][2] / CODE_SIZE) * 100
|
||||
funcName = files[i][0][12:]
|
||||
print("", funcName, (" " * (24 - len(funcName))), "| {:5.2f}% | {:5.2f}% |".format(percentageRemaining, percentageDone))
|
||||
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user