Hi! It's me. Long time no see.
It's rather nice to see FBA is still going -- I had no idea. I started to do some work on my old source lately, and you seem to have based yours on an old release with just my neo-geo CD emulation added. So it seems I might have some code you'd like include.
What's your choice of version control system? I use Mercurial myself.
One of the things I wanted to tackle was some cleanup and modernisation. To that effect, Perl is out and Python is in (I'll convert the perl scripts). Here's a python script that removes the annoying and outdated tchar.h rubbish and replaces it with the regular wchar_t equivalents. It leaves untouched a few macros and I think a single function call, so edit the macros in title.h and a few other bits that the compiler will complain about. Name this something.py and run it from your FBA directory. N.B. Make sure to commit any changes or make a backup of your source before running this -- it overwrites all files it modifies.
import sys
import os.path
import re
class converter(object):
def __init__(self):
self.re_str = re.compile(r'_T\(\s*\"(?P<string>.*?)\"\)')
self.re_chr = re.compile(r'_T\(\'(?P<string>.*?)\'\)')
self.re_macro = re.compile(r'_T\((?P<string>[a-zA-Z0-9_()#]*?)\)')
self.re_tc = re.compile(r'TCHAR')
self.re_tcs = re.compile(r'_tcs(?P<string>[^(]*)')
self.re_fnc = re.compile(r'_[a-zA-Z]*?t[a-zA-Z]*?(printf|scanf|fopen|remove|access|asctime)')
self.re_get = re.compile(r'_f(putt|gett)[a-zA-Z]*?')
self.re_txt = re.compile(r'_ist(space|digit)')
def convertfile(self, file):
def _str(m):
return 'L"' + m.group('string') + '"'
def _chr(m):
return 'L\'' + m.group('string') + '\''
def _macro(m):
return m.group('string')
def _tc(m):
return 'wchar_t'
def _tcs(m):
return 'wcs' + m.group('string')
def _fnc(m):
return m.group().replace('t', 'w', 1).replace('_fw', 'fw', 1).replace('_sw', 'sw', 1)
def _get(m):
return m.group().replace('_fgett', 'fgetw', 1).replace('_fputt', 'fputw', 1)
def _txt(m):
return m.group().replace('_ist', 'isw', 1)
with open(file + ".tmp", "wt") as nf:
changes = 0
with open(file, "rt") as f:
for line in f:
line = line.rstrip()
n = 0;
m = self.re_str.subn(_str, line)
if m[1] > 0:
line = m[0]
n += 1
m = self.re_chr.subn(_chr, line)
if m[1] > 0:
line = m[0]
n += 1
m = self.re_macro.subn(_macro, line)
if m[1] > 0:
line = m[0]
n += 1
m = self.re_tc.subn(_tc, line)
if m[1] > 0:
line = m[0]
n += 1
m = self.re_tcs.subn(_tcs, line)
if m[1] > 0:
line = m[0]
n += 1
m = self.re_fnc.subn(_fnc, line)
if m[1] > 0:
line = m[0]
n += 1
m = self.re_get.subn(_get, line)
if m[1] > 0:
line = m[0]
n += 1
m = self.re_txt.subn(_txt, line)
if m[1] > 0:
line = m[0]
n += 1
#if n > 0:
# print(line)
changes += n
print(line, file=nf)
if changes > 0:
os.replace(file + ".tmp", file)
else:
os.remove(file + ".tmp")
def convert(self, srcdir):
for root, dir, files in os.walk(srcdir):
print("processing: {root}...".format(root=root))
for file in files:
if not (file.endswith(".c") or file.endswith(".cpp") or file.endswith(".h")):
continue
self.convertfile("{root}\\{file}".format(root=root, file=file))
if __name__ == '__main__':
src = sys.argv[1] if len(sys.argv) == 2 else "src"
c = converter()
c.convert(src)