From ac835f3e5a5642da5a2d6f01e97dcad2f5a357a0 Mon Sep 17 00:00:00 2001 From: 0x32 <95779166+0x32767@users.noreply.github.com> Date: Thu, 29 Feb 2024 22:14:41 +0000 Subject: [PATCH 1/3] Added status script Add a cli to display decomp progress and create a status svg file. --- README.md | 2 + resources/progress.svg | 15 +++++++ resources/progress_template.svg | 15 +++++++ scripts/update_decompile_stats.py | 67 +++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 resources/progress.svg create mode 100644 resources/progress_template.svg create mode 100644 scripts/update_decompile_stats.py diff --git a/README.md b/README.md index 57fa5779..cfb3c701 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # 東方紅魔郷 ~ the Embodiment of Scarlet Devil +[Decomp-progress]: https://github.com/happyhavoc/th06/blob/master/resources/progress.svg + [![Discord][discord-badge]][discord] [discord]: https://discord.gg/VyGwAjrh9a diff --git a/resources/progress.svg b/resources/progress.svg new file mode 100644 index 00000000..cfeac52e --- /dev/null +++ b/resources/progress.svg @@ -0,0 +1,15 @@ + + + + + Decomp Progress + Functions implimented: + + + 8.29% + + Bytes implimented: + + + 11.86% + diff --git a/resources/progress_template.svg b/resources/progress_template.svg new file mode 100644 index 00000000..a38b7a4e --- /dev/null +++ b/resources/progress_template.svg @@ -0,0 +1,15 @@ + + + + + Decomp Progress + Functions implimented: + + + {FUNC_PROG_PERCENT}% + + Bytes implimented: + + + {BYTES_PROG_PERCENT}% + diff --git a/scripts/update_decompile_stats.py b/scripts/update_decompile_stats.py new file mode 100644 index 00000000..99531767 --- /dev/null +++ b/scripts/update_decompile_stats.py @@ -0,0 +1,67 @@ +import os.path +from pathlib import Path +import sys + +script_path = Path(os.path.dirname(os.path.realpath(__file__))) / ".." + + +def get_file(fp): + try: + with open(fp, "r") as file: + return file.readlines() + + except FileNotFoundError: + print("couldn't open "+str(fp)+" file") + print("hint: try running the ci from the project root") + exit(1) + +def create_status_profile(): + impl = get_file(script_path / "config" / "implemented.csv") + maps = get_file(script_path / "config" / "mapping.csv") + + raw_func_percentage = len(impl) / len(maps) * 100 + + total_func_bytes = 246112 # number of function bytes + impl_bytes = 0 + + for (f_name, location, size) in (line.split(",") for line in maps): + if int(location.removeprefix("0x"), 16) > 4444512: # 0x0043d160 is where 3rd party lib functions start + break + + if f_name+"\n" in impl: + impl_bytes += int(size.removeprefix("0x"), 16) + + byte_impl_percentage = impl_bytes / total_func_bytes * 100 + + return raw_func_percentage, byte_impl_percentage + +def update_svg(): + with open(script_path / "resources" / "progress_template.svg", "r") as f: + svg_data = f.read() + + func_impl, bytes_impl = create_status_profile() + + new_svg = svg_data.format( + FUNC_PROG_PERCENT=round(func_impl, 2), + BYTES_PROG_PERCENT=round(bytes_impl, 2), + FUNC_PROG_WIDTH=round((322*func_impl/100), 2), + BYTES_PROG_WIDTH=round((322*func_impl/100), 2), + ) + + with open(script_path / "resources" / "progress.svg", "w") as f: + f.write(new_svg) + + +def main(): + if "gen_svg" in sys.argv: + update_svg() + print("SVG file updated!\n") + + raw_func_percentage, byte_impl_percentage = create_status_profile() + + print(round(raw_func_percentage, 2), "% func implemented") + print(round(byte_impl_percentage, 2), "% size implemented") + + +if __name__ == "__main__": + main() From 85b9957e3cc07a512807f9b0843f7fc67e3695ce Mon Sep 17 00:00:00 2001 From: "[[Reisen]]" Date: Thu, 29 Feb 2024 22:20:37 +0000 Subject: [PATCH 2/3] Update README Image The decomp progress now shows in the readme file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfb3c701..4cf212c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 東方紅魔郷 ~ the Embodiment of Scarlet Devil -[Decomp-progress]: https://github.com/happyhavoc/th06/blob/master/resources/progress.svg +![Decomp-progress](./resources/progress.svg) [![Discord][discord-badge]][discord] From d34a8c1a2fc1037301bd51e1bda47d75f0a2fba7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 22:25:47 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/update_decompile_stats.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/update_decompile_stats.py b/scripts/update_decompile_stats.py index 99531767..72b8fdc1 100644 --- a/scripts/update_decompile_stats.py +++ b/scripts/update_decompile_stats.py @@ -11,41 +11,45 @@ def get_file(fp): return file.readlines() except FileNotFoundError: - print("couldn't open "+str(fp)+" file") + print("couldn't open " + str(fp) + " file") print("hint: try running the ci from the project root") exit(1) + def create_status_profile(): impl = get_file(script_path / "config" / "implemented.csv") maps = get_file(script_path / "config" / "mapping.csv") raw_func_percentage = len(impl) / len(maps) * 100 - total_func_bytes = 246112 # number of function bytes + total_func_bytes = 246112 # number of function bytes impl_bytes = 0 - for (f_name, location, size) in (line.split(",") for line in maps): - if int(location.removeprefix("0x"), 16) > 4444512: # 0x0043d160 is where 3rd party lib functions start + for f_name, location, size in (line.split(",") for line in maps): + if ( + int(location.removeprefix("0x"), 16) > 4444512 + ): # 0x0043d160 is where 3rd party lib functions start break - if f_name+"\n" in impl: + if f_name + "\n" in impl: impl_bytes += int(size.removeprefix("0x"), 16) byte_impl_percentage = impl_bytes / total_func_bytes * 100 return raw_func_percentage, byte_impl_percentage + def update_svg(): with open(script_path / "resources" / "progress_template.svg", "r") as f: svg_data = f.read() - + func_impl, bytes_impl = create_status_profile() new_svg = svg_data.format( FUNC_PROG_PERCENT=round(func_impl, 2), BYTES_PROG_PERCENT=round(bytes_impl, 2), - FUNC_PROG_WIDTH=round((322*func_impl/100), 2), - BYTES_PROG_WIDTH=round((322*func_impl/100), 2), + FUNC_PROG_WIDTH=round((322 * func_impl / 100), 2), + BYTES_PROG_WIDTH=round((322 * func_impl / 100), 2), ) with open(script_path / "resources" / "progress.svg", "w") as f: @@ -61,7 +65,7 @@ def main(): print(round(raw_func_percentage, 2), "% func implemented") print(round(byte_impl_percentage, 2), "% size implemented") - + if __name__ == "__main__": main()