"""Expose native helpers in a test-only COFF copy, without patching instructions.""" from pathlib import Path import re import struct from check_card_exit_build import Coff ROOT = Path(__file__).resolve().parents[2] EXPOSE = {"engineMode", "deltaTime3D", "mouseClick3D", "mouseX3D", "mouseY3D", "keys3D", "pressedKeys3D", "tableCos", "tableSin", "screenBuffer", "cardExitButton3D", "unavailableText3D", "bankroll", "rngSeed3D"} def main(): folder = ROOT / "build/billiards" folder.mkdir(exist_ok=True) functions = set() for name in ("billiards", "pyramid_rules", "eightball", "pyramid_play", "billiards_prediction", "pyramid_render"): source = (ROOT / "src_graphics" / (name + ".inc")).read_text(encoding="cp1251") functions.update(re.findall(r"^(\w+) PROC", source, re.M)) for name in ("pyramid_test", "billiards_choice_test", "eightball_regression"): source = (ROOT / "tools/tests" / (name + ".inc")).read_text(encoding="cp1251") functions.update(re.findall(r"^(\w+) PROC", source, re.M)) coff = Coff(ROOT / "build/actions/actions-test.obj") original = coff.data data = bytearray(original) start = struct.unpack_from(" 0: target = 3 if target is not None and target != storage: data[at+16] = target changes.add(at+16) assert found == EXPOSE, EXPOSE-found assert {i for i, (a, b) in enumerate(zip(original, data)) if a != b} == changes (folder / "helpers.obj").write_bytes(data) print("Prepared test-only native helpers; only COFF visibility bytes changed") if __name__ == "__main__": main()