Initial commit

This commit is contained in:
snesrev
2023-03-05 07:03:54 +01:00
committed by Snesrev
commit 09c1bdd874
100 changed files with 142957 additions and 0 deletions

59
other/annotate_funcs.py Normal file
View File

@@ -0,0 +1,59 @@
import re
class FuncParser:
def __init__(self):
self.functions = []
self.lines_prefix = []
def read(self, filename):
current_func_name = None
state = 0
collect = []
c = re.compile('^(?:static )?(?:inline )?[a-zA-Z0-9_]+ \\*? *([a-zA-Z0-9_]+)\\(.*\\) {( *//.*)?$')
for line in open(filename).read().splitlines():
# print(line)
line = line.rstrip()
if m := c.match(line):
assert state != 1
if state == 0:
self.lines_prefix = collect
collect = []
current_func_name = m.group(1)
state = 1
collect.append(line)
if line == '}':
assert state == 1
self.functions.append((current_func_name, collect))
collect = []
state = 2
funcs = {}
for line in open('../funcs.h'):
if m := re.match('^#define fn([^ ]+) (0x[0-9A-Fa-f]+)', line):
name, addr = m.group(1), m.group(2)
funcs[name] = addr
import glob
for fname in glob.glob('../sm_??.cpp'):
fp = FuncParser()
fp.read(fname)
fout = open(fname, 'w')
for c in fp.lines_prefix:
print(c, file = fout)
for a, b in fp.functions:
if a.endswith('_Async'):
a = a[:-6]
cmt = funcs.get(a)
if cmt == None:
print('noname ', a)
for line in b:
if cmt != None and line.endswith('{'):
print(line + ' // ' + cmt, file = fout)
cmt = None
else:
print(line, file = fout)
fout.close()

17
other/strip_some.py Normal file
View File

@@ -0,0 +1,17 @@
import re
import glob
all_data = ''
for fname in glob.glob('../sm_??.cpp'):
all_data += open(fname).read()
assert 'Eproj_NorfairLavaquakeRocks_Func1' in all_data
for line in open('../funcs.h').read().splitlines():
if m := re.match('^#define fn([^ ]+) (0x[0-9A-Fa-f]+)', line):
name, addr = m.group(1), m.group(2)
test1 = ('fn' + name)
test2 = f'FUNC16({name})'
if (test1 in all_data) or (test2) in all_data:
print(line)