"""Expose native state in a test-only COFF copy; never patch instructions.""" from pathlib import Path import struct from check_card_exit_build import Coff ROOT = Path(__file__).resolve().parents[2] EXPOSE = {"casinoMap","hallLevel3D","outdoorRender3D","hallLights3D","hallLoungeDecor3D", "hallRopeFurniture3D","hallLampFurniture3D","cityObjects3D","hallStreetLife3D","cityDecorPack3D", "playerX","playerY","playerAngle","viewEye3D","viewCeiling3D","viewHorizon3D", "worldMap3D","floorTexture3D","cityMap3D","cityPhase3D","cityTime3D","cityClock3D","arrivalState3D", "screenBuffer","cityDepthBuffer3D","cityRayX3D","cityRayY3D","zBuffer","cityBackdrop3D", "playerPlaneX","playerPlaneY"} def main(): out = ROOT/"build/world" out.mkdir(parents=True,exist_ok=True) baseline = out/"prior-release.obj" if not baseline.exists(): baseline.write_bytes((ROOT/"build/actions/actions-test.obj").read_bytes()) coff = Coff(baseline) 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 changed.add(at+16) assert found==EXPOSE,EXPOSE-found assert {i for i,(a,b) in enumerate(zip(data,original)) if a!=b}==changed (out/"base.obj").write_bytes(data) source = (ROOT/"src_graphics/city_bins.inc").read_text(encoding="cp1251") bodies = [] for name in ("ResolveCitySurface3D","DrawCityVertical3D","DrawCityHorizontal3D"): body = source.split(name+" PROC",1)[1].split(name+" ENDP",1)[0] bodies.append(name+" PROC"+body+name+" ENDP\n") (out/"surfaces.inc").write_text("\n".join(bodies),encoding="ascii") print("Prepared native renderer probe: storage visibility only, no modified code or relocations") if __name__=="__main__": main()