"""Link fresh scratch MASM against existing native graphics helpers for fast QA. Only COFF symbol visibility changes in a test-only COPY. Instructions and relocations remain untouched; neither shipping binaries nor source are patched. The full engine is rebuilt/tested separately before publication. """ from pathlib import Path import struct from check_card_exit_build import Coff ROOT = Path(__file__).resolve().parents[2] EXPOSE = {"engineMode","paused3D","bankroll","deltaTime3D","animationClock3D", "viewWidth3D","viewHeight3D","viewLeft3D","viewTop3D","clpSymbolsPath3D", "coinExitText3D","coinBankText3D","hudNumBuffer","screenBuffer","rngSeed3D","h3DWnd","lastSoundPath3D"} def main(): coff = Coff(ROOT/"build/actions/actions-test.obj") original = coff.data data = bytearray(original) symbols = struct.unpack_from("0 exposed.add(name) target = 2 elif ("Scratch" in name or name=="_LoadAnimPack3D@8") and kind==0x20 and storage==2 and section>0: target = 3 if target is not None and storage!=target: data[at+16] = target touched.add(at+16) assert exposed==EXPOSE,EXPOSE-exposed assert {i for i,(a,b) in enumerate(zip(original,data)) if a!=b}==touched (ROOT/"build/scratch/module-base.obj").write_bytes(data) loader = (ROOT/"src_graphics/scene_animation.inc").read_text(encoding="cp1251") loader = loader.split("LoadAnimPack3D ENDP",1)[0]+"LoadAnimPack3D ENDP\n" (ROOT/"build/scratch/module-loader.inc").write_text(loader,encoding="ascii") print("Prepared test-only native helper object; all code and relocations unchanged") if __name__=="__main__": main()