Misc: Remove unused files
This commit is contained in:
@ -1,87 +0,0 @@
|
||||
import csv
|
||||
import sys
|
||||
from xml.sax.saxutils import escape
|
||||
|
||||
SKIP_COLS = 1
|
||||
SKIP_ROWS = 3
|
||||
|
||||
def compatibility_string_to_int(value):
|
||||
value_lower = value.lower()
|
||||
if (value_lower == "doesn't boot"):
|
||||
return 1
|
||||
elif (value_lower == "crashes in intro"):
|
||||
return 2
|
||||
elif (value_lower == "crashes in-game"):
|
||||
return 3
|
||||
elif (value_lower == "graphical/audio issues"):
|
||||
return 4
|
||||
elif (value_lower == "no issues"):
|
||||
return 5
|
||||
|
||||
print("*** Unknown compatibility level string: '%s'" % value)
|
||||
return 0
|
||||
|
||||
|
||||
def compatibility_csv_to_xml(input_file, output_file):
|
||||
fin = open(input_file, "r")
|
||||
if (not input_file):
|
||||
print("Failed to open %s" % input_file)
|
||||
return False
|
||||
|
||||
fout = open(output_file, "w")
|
||||
if (not output_file):
|
||||
print("Failed to open %s" % output_file)
|
||||
return False
|
||||
|
||||
fout.write("<?xml version=\"1.0\"?>\n")
|
||||
fout.write("<compatibility-list>\n")
|
||||
|
||||
row_number = 0
|
||||
for row in csv.reader(fin):
|
||||
row_number += 1
|
||||
if (row_number <= SKIP_ROWS):
|
||||
continue
|
||||
# Skip header rows
|
||||
# TODO: Proper map for these if the column order changes
|
||||
#if (row[SKIP_COLS + 0] == "Game Code" or row[SKIP_COLS + 1] == "Game Title" or row[SKIP_COLS + 2] == "Region" or
|
||||
# row[SKIP_COLS + 3] == "Compatibility" or row[SKIP_COLS + 4] == "Upscaling Issues" or
|
||||
# row[SKIP_COLS + 5] == "Version tested" or row[SKIP_COLS + 6] == "Comments"):
|
||||
# continue
|
||||
|
||||
code = str(row[SKIP_COLS + 0]).strip()
|
||||
title = str(row[SKIP_COLS + 1]).strip()
|
||||
region = str(row[SKIP_COLS + 2]).strip()
|
||||
compatibility = str(row[SKIP_COLS + 3]).strip()
|
||||
upscaling_issues = str(row[SKIP_COLS + 4]).strip()
|
||||
version_tested = str(row[SKIP_COLS + 5]).strip()
|
||||
comments = str(row[SKIP_COLS + 6]).strip()
|
||||
|
||||
if (len(code) == 0):
|
||||
print("** Code is missing for '%s' (%s), skipping" % (title, region))
|
||||
continue
|
||||
|
||||
# TODO: Quoting here
|
||||
fout.write(" <entry code=\"%s\" title=\"%s\" region=\"%s\" compatibility=\"%d\">\n" % (escape(code), escape(title), escape(region), compatibility_string_to_int(compatibility)))
|
||||
fout.write(" <compatibility>%s</compatibility>\n" % escape(compatibility))
|
||||
if (len(upscaling_issues) > 0):
|
||||
fout.write(" <upscaling-issues>%s</upscaling-issues>\n" % escape(upscaling_issues))
|
||||
if (len(version_tested) > 0):
|
||||
fout.write(" <version-tested>%s</version-tested>\n" % escape(version_tested))
|
||||
if (len(comments) > 0):
|
||||
fout.write(" <comments>%s</comments>\n" % escape(comments))
|
||||
fout.write(" </entry>\n")
|
||||
|
||||
fout.write("</compatibility-list>\n")
|
||||
fout.close()
|
||||
fin.close()
|
||||
return True
|
||||
|
||||
|
||||
if (__name__ == "__main__"):
|
||||
if (len(sys.argv) < 3):
|
||||
print("Usage: %s <path to csv> <path to xml>" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
result = compatibility_csv_to_xml(sys.argv[1], sys.argv[2])
|
||||
sys.exit(0 if result else 1)
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
import sys
|
||||
import argparse
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
def convert_list(filename, separator=','):
|
||||
fields = ["Game Code", "Game Title", "Region", "Compatibility", "Upscaling Issues", "Version tested", "Comments"]
|
||||
output = separator.join(fields) + "\n"
|
||||
|
||||
tree = ET.parse(filename)
|
||||
for child in tree.getroot():
|
||||
if (child.tag != "entry"):
|
||||
print("!!! Skipping invalid tag '%s'" % child.tag)
|
||||
continue
|
||||
|
||||
game_code = child.get("code")
|
||||
if game_code is None:
|
||||
game_code = ""
|
||||
game_title = child.get("title") or ""
|
||||
if game_title is None:
|
||||
game_title = ""
|
||||
region = child.get("region")
|
||||
if region is None:
|
||||
region = ""
|
||||
|
||||
node = child.find("compatibility")
|
||||
compatibility = node.text if node is not None else ""
|
||||
node = child.find("upscaling-issues")
|
||||
upscaling_issues = node.text if node is not None else ""
|
||||
node = child.find("version-tested")
|
||||
version_tested = node.text if node is not None else ""
|
||||
node = child.find("comments")
|
||||
comments = node.text if node is not None else ""
|
||||
|
||||
fix = None
|
||||
if separator == '\t':
|
||||
fix = lambda x: "" if x is None else x.replace('\t', ' ')
|
||||
elif separator == ',':
|
||||
fix = lambda x: "" if x is None else x if x.find(',') < 0 else ("\"%s\"" % x)
|
||||
else:
|
||||
fix = lambda x: "" if x is None else x
|
||||
|
||||
entry_fields = [fix(game_code), fix(game_title), fix(region), fix(compatibility), fix(upscaling_issues), fix(version_tested), fix(comments)]
|
||||
output += separator.join(entry_fields) + "\n"
|
||||
|
||||
return output
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--tabs", action="store_true")
|
||||
parser.add_argument("list_file", action="store")
|
||||
parser.add_argument("output_file", action="store")
|
||||
args = parser.parse_args()
|
||||
|
||||
output = convert_list(args.list_file, '\t' if args.tabs else ',')
|
||||
output_file = open(args.output_file, "w")
|
||||
output_file.write(output)
|
||||
output_file.close()
|
||||
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
bools = ["false", "true"]
|
||||
|
||||
|
||||
print("static constexpr DrawRectangleFunction funcs[2][2][2] = {")
|
||||
for texture in range(2):
|
||||
print(" {")
|
||||
for raw_texture in range(2):
|
||||
print(" {")
|
||||
for transparency in range(2):
|
||||
line = "&GPU_SW_Backend::DrawRectangle<%s, %s, %s>" % (bools[texture], bools[0 if texture == 0 else raw_texture], bools[transparency])
|
||||
print(" %s%s" % (line, "," if transparency == 0 else ""))
|
||||
print(" }%s" % ("," if raw_texture == 0 else ""))
|
||||
print(" }%s" % ("," if texture == 0 else ""))
|
||||
print("};")
|
||||
|
||||
|
||||
print("static constexpr DrawTriangleFunction funcs[2][2][2][2][2] = {")
|
||||
for shading in range(2):
|
||||
print(" {")
|
||||
for texture in range(2):
|
||||
print(" {")
|
||||
for raw_texture in range(2):
|
||||
print(" {")
|
||||
for transparency in range(2):
|
||||
print(" {")
|
||||
for dither in range(2):
|
||||
line = "&GPU_SW_Backend::DrawTriangle<%s, %s, %s, %s, %s>" % (bools[shading], bools[texture], bools[0 if texture == 0 else raw_texture], bools[transparency], bools[0 if raw_texture != 0 else dither])
|
||||
print(" %s%s" % (line, "," if dither == 0 else ""))
|
||||
print(" }%s" % ("," if transparency == 0 else ""))
|
||||
print(" }%s" % ("," if raw_texture == 0 else ""))
|
||||
print(" }%s" % ("," if texture == 0 else ""))
|
||||
print(" }%s" % ("," if shading == 0 else ""))
|
||||
print("};")
|
||||
|
||||
|
||||
print("static constexpr DrawLineFunction funcs[2][2][2] = {")
|
||||
for shading in range(2):
|
||||
print(" {")
|
||||
for transparency in range(2):
|
||||
print(" {")
|
||||
for dither in range(2):
|
||||
line = "&GPU_SW_Backend::DrawLine<%s, %s, %s>" % (bools[shading], bools[transparency], bools[dither])
|
||||
print(" %s%s" % (line, "," if dither == 0 else ""))
|
||||
print(" }%s" % ("," if transparency == 0 else ""))
|
||||
print(" }%s" % ("," if shading == 0 else ""))
|
||||
print("};")
|
||||
@ -1,108 +0,0 @@
|
||||
import sys
|
||||
import re
|
||||
import xml.etree.ElementTree as ET
|
||||
from xml.sax.saxutils import unescape
|
||||
|
||||
class GameEntry:
|
||||
def __init__(self, title, serials):
|
||||
self.title = title
|
||||
self.serials = serials
|
||||
|
||||
def __repr__(self):
|
||||
return self.title + " (" + ",".join(self.serials) + ")"
|
||||
|
||||
|
||||
def get_serials(s):
|
||||
out = []
|
||||
for it in s.split("/"):
|
||||
for it2 in it.split(","):
|
||||
for it3 in it2.split("~"):
|
||||
i = it3.find('(')
|
||||
if i > 0:
|
||||
it3 = it3[:i-1]
|
||||
it3 = re.sub("[^A-Za-z0-9-]", "", it3)
|
||||
out.append(it3.strip())
|
||||
print(out)
|
||||
return out
|
||||
|
||||
|
||||
def parse_xml(path):
|
||||
entries = {}
|
||||
tree = ET.parse(path)
|
||||
for child in tree.getroot():
|
||||
name = child.get("name")
|
||||
if name is None:
|
||||
continue
|
||||
|
||||
title = ""
|
||||
description = child.find("description")
|
||||
if description is not None:
|
||||
title = description.text
|
||||
|
||||
serials = []
|
||||
for grandchild in child.iterfind("info"):
|
||||
gname = grandchild.get("name")
|
||||
gvalue = grandchild.get("value")
|
||||
#print(gname, gvalue)
|
||||
if gname is not None and gname == "serial" and gvalue is not None:
|
||||
serials.extend(get_serials(gvalue))
|
||||
|
||||
if len(serials) > 0:
|
||||
entries[name] = GameEntry(title, serials)
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
def write_codes(entries, fout, name, codes):
|
||||
if name == "" or len(codes) == 0:
|
||||
return
|
||||
|
||||
if name not in entries:
|
||||
print("Unknown game '%s'" % name)
|
||||
return
|
||||
|
||||
entry = entries[name]
|
||||
fout.write(";%s\n" % entry.title)
|
||||
for serial in entry.serials:
|
||||
fout.write(":%s\n" % serial)
|
||||
fout.write("\n".join(codes))
|
||||
fout.write("\n\n")
|
||||
|
||||
|
||||
def rewrite_dat(entries, inpath, outpath):
|
||||
fin = open(inpath, "r", encoding="utf-8")
|
||||
fout = open(outpath, "w", encoding="utf-8")
|
||||
|
||||
current_name = ""
|
||||
code_lines = []
|
||||
|
||||
for line in fin.readlines():
|
||||
if line[0] == ' ' or line[0] == ';' or line[:2] == "##":
|
||||
continue
|
||||
|
||||
line = line.strip()
|
||||
if len(line) == 0:
|
||||
continue
|
||||
|
||||
line = unescape(line)
|
||||
|
||||
if line[0] == ':':
|
||||
write_codes(entries, fout, current_name, code_lines)
|
||||
current_name = line[1:].split(':')[0].strip()
|
||||
code_lines = []
|
||||
else:
|
||||
code_lines.append(line)
|
||||
|
||||
write_codes(entries, fout, current_name, code_lines)
|
||||
|
||||
fin.close()
|
||||
fout.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 4:
|
||||
print("usage: %s <psx.xml path> <cheatpsx.dat> <output file>" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
entries = parse_xml(sys.argv[1])
|
||||
rewrite_dat(entries, sys.argv[2], sys.argv[3])
|
||||
@ -1,59 +0,0 @@
|
||||
from copy import deepcopy
|
||||
import sys
|
||||
import argparse
|
||||
import xml.etree.ElementTree as ET
|
||||
from xml.dom import minidom
|
||||
|
||||
# https://pymotw.com/2/xml/etree/ElementTree/create.html
|
||||
def prettify(elem):
|
||||
"""Return a pretty-printed XML string for the Element.
|
||||
"""
|
||||
rough_string = ET.tostring(elem, 'utf-8')
|
||||
reparsed = minidom.parseString(rough_string)
|
||||
dom_string = reparsed.toprettyxml(encoding="utf-8",indent=" ")
|
||||
return b'\n'.join([s for s in dom_string.splitlines() if s.strip()])
|
||||
|
||||
|
||||
# https://stackoverflow.com/questions/25338817/sorting-xml-in-python-etree/25339725#25339725
|
||||
def sortchildrenby(parent, attr):
|
||||
parent[:] = sorted(parent, key=lambda child: child.get(attr))
|
||||
|
||||
|
||||
def add_entries_from_file(filename, new_tree, overwrite_existing = False):
|
||||
tree = ET.parse(filename)
|
||||
for child in tree.getroot():
|
||||
if (child.tag != "entry"):
|
||||
print("!!! Skipping invalid tag '%s'" % child.tag)
|
||||
continue
|
||||
|
||||
game_code = child.get("code")
|
||||
existing_node = new_tree.getroot().find(".//*[@code='%s']" % game_code)
|
||||
if existing_node is not None:
|
||||
if overwrite_existing:
|
||||
print("*** Replacing %s from new list" % game_code)
|
||||
new_tree.getroot().remove(existing_node)
|
||||
else:
|
||||
print("*** Skipping %s from new list" % game_code)
|
||||
continue
|
||||
|
||||
new_tree.getroot().append(deepcopy(child))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--overwrite", action="store_true")
|
||||
parser.add_argument("existing_list", action="store")
|
||||
parser.add_argument("list_to_merge", action="store")
|
||||
parser.add_argument("output_list", action="store")
|
||||
args = parser.parse_args()
|
||||
|
||||
new_tree = ET.ElementTree(ET.Element("compatibility-list"))
|
||||
add_entries_from_file(args.existing_list, new_tree, False)
|
||||
add_entries_from_file(args.list_to_merge, new_tree, args.overwrite)
|
||||
|
||||
sortchildrenby(new_tree.getroot(), "title")
|
||||
|
||||
output_file = open(args.output_list, "wb")
|
||||
output_file.write(prettify(new_tree.getroot()))
|
||||
output_file.close()
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
def pad_bios(in_name, out_name):
|
||||
print("Reading %s..." % in_name)
|
||||
with open(in_name, "rb") as f:
|
||||
indata = f.read()
|
||||
if len(indata) > (512 * 1024):
|
||||
print("Input file %s is too large (%u bytes)", in_name, len(indata))
|
||||
sys.exit(1)
|
||||
|
||||
padding_size = (512 * 1024) - len(indata)
|
||||
padding = b'\0' * padding_size
|
||||
print("Padding with %u bytes" % padding_size)
|
||||
|
||||
print("Writing %s..." % out_name)
|
||||
with open(out_name, "wb") as f:
|
||||
f.write(indata)
|
||||
f.write(padding)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: %s <input filename> <output filename>" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
pad_bios(sys.argv[1], sys.argv[2])
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user