diff --git a/.gitignore b/.gitignore index 2df8f60..7b29f11 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,6 @@ data/* notes/* -pre_edited_cs/Doukutsu\.exe\.blbkp - -pre_edited_cs/Profile* - -pre_edited_cs/window\.rect - *Copy/ venv/ @@ -17,9 +11,12 @@ dist/ cave_story_randomizer.egg-info/ -*/__pycache__ -caver/version.py +**/__pycache__ -pre_edited_cs/data/Stage/_version.txt +pre_edited_cs/**/Doukutsu\.exe\.blbkp +pre_edited_cs/**/Profile* +pre_edited_cs/**/window\.rect -pre_edited_cs/freeware/window.rect +pre_edited_cs/data/version.txt + +pre_edited_cs/freeware/Doukutsu_backup.exe diff --git a/caver/patcher.py b/caver/patcher.py index a50fab5..ac2055a 100644 --- a/caver/patcher.py +++ b/caver/patcher.py @@ -98,10 +98,10 @@ def patch_files( def ensure_base_files_exist(platform: CSPlatform, output_dir: Path) -> None: internal_copy = pre_edited_cs.get_path() - with internal_copy.joinpath("data", "Stage", "_version.txt").open() as version_file: + with internal_copy.joinpath("data", "version.txt").open() as version_file: latest_version = version_file.readline() - version = output_dir.joinpath("data", "Stage", "_version.txt") + version = output_dir.joinpath("data", "version.txt") current_version = "v0.0.0.0" if version.exists(): with version.open() as version_file: diff --git a/cs-hacks/VersionFromFile/version_from_file.txt b/cs-hacks/VersionFromFile/version_from_file.txt new file mode 100644 index 0000000..41e5ec0 --- /dev/null +++ b/cs-hacks/VersionFromFile/version_from_file.txt @@ -0,0 +1,103 @@ +; Reads version number from data\version.txt +; The file must start with the version string in the format shown at the bottom of this file +; Made by periwinkle + +#define +gDataPath=49E220 +gVersionString=48C2BC +sprintf=481010 +fopen=480FFD +rb=48C28C +fread=480F55 +fclose=480E1B +sscanf=4817E8 +call VirtualProtect=data ff 15 84 c0 48 00 +filePath=[ebp-114] +bufchk=[ebp-10] +tmp=[ebp-c] +oldProtect=[ebp-8] +fp=[ebp-4] +v1=[ebp+8] +v2=[ebp+c] +v3=[ebp+10] +v4=[ebp+14] +#enddefine + +offset 410990 ; GetCompileVersion +push ebp +mov ebp, esp +sub esp, 114 +mov eax, [498B20] +mov bufchk, eax + +; Get path to data\version.txt file +push gDataPath +push :VersionPath ; "%s\version.txt" +lea edx, filePath +push edx +call sprintf +add esp, c + +; Open file +push rb ; "rb" +lea ecx, filePath +push ecx +call fopen +add esp, 8 +test eax, eax +jz :ReadVersion +mov fp, eax + +; Mark gVersionString as read/write (it's normally in a read-only segment) +lea eax, oldProtect +push eax +push 4 ; PAGE_READWRITE +push 40 ; Max size of gVersionString (including null character) +push gVersionString +call VirtualProtect +test eax, eax +jz :CloseFile + +; Read contents of file into gVersionString +push fp + +push 3F ; count (excluding null character) +push 1 ; size +push gVersionString +call fread +add esp, 10 +mov byte [eax+gVersionString], 0 ; Write null terminator + +; Restore previous protection status +lea eax, tmp +push eax +push oldProtect +push 40 +push gVersionString +call VirtualProtect + +:CloseFile +push fp +call fclose +pop ecx + +:ReadVersion +; Parse the version string +push v4 +push v3 +push v2 +push v1 +push :VersionString +push gVersionString +call sscanf +add esp, 18 + +mov ecx, bufchk +call 480DC1 +leave +retn + +:VersionPath +data 25 73 5C 76 65 72 73 69 6F 6E 2E 74 78 74 00 00 ; "%s\version.txt" +:VersionString +data 76 25 64 2E 25 64 2E 25 64 2E 25 64 00 ; "v%d.%d.%d.%d" \ No newline at end of file diff --git a/pre_edited_cs/freeware/Doukutsu.exe b/pre_edited_cs/freeware/Doukutsu.exe index c3314fe..1405395 100644 Binary files a/pre_edited_cs/freeware/Doukutsu.exe and b/pre_edited_cs/freeware/Doukutsu.exe differ diff --git a/pre_edited_cs/freeware/data/version.txt b/pre_edited_cs/freeware/data/version.txt new file mode 100644 index 0000000..341a182 --- /dev/null +++ b/pre_edited_cs/freeware/data/version.txt @@ -0,0 +1,3 @@ +v0.0.0.0 +2019/03/07 - ????/??/?? +duncathan_salt \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 11a1c5a..aae0700 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,9 +3,10 @@ requires = ["setuptools>=44.0.0", "setuptools_scm[toml]>=3.4.3"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] -version_file_template = "v{version_tuple[0]}.{version_tuple[1]}.{version_tuple[2]}.{scm_version.distance}\n2019/03/07 - {scm_version.node_date.year:04}/{scm_version.node_date.month:02}/{scm_version.node_date.day:02}\nduncathan_salt" +version_file_template = "v{scm_version.tag}.{scm_version.distance}\n2019/03/07 - {scm_version.node_date.year:04}/{scm_version.node_date.month:02}/{scm_version.node_date.day:02}\nduncathan_salt" local_scheme = "no-local-version" -version_file = "pre_edited_cs/data/Stage/_version.txt" +version_scheme = "no-guess-dev" +version_file = "pre_edited_cs/data/version.txt" [tool.ruff] line-length = 120