#!/usr/bin/env python3 """Exercise the actual windowless ASM renderer through its public mailbox.""" import ctypes as C import mmap import os from pathlib import Path import struct import subprocess import time ROOT = Path(__file__).resolve().parents[1] SIZE, TEXTURES, PIXELS = 1357792, 2016, 1050592 def check_preview(engine, expected=None, output=None): name = f"Local\\EblanPreview-test-{os.getpid()}-{time.monotonic_ns()}" with mmap.mmap(-1, SIZE, tagname=name) as packet: base = C.addressof(C.c_char.from_buffer(packet)) state = C.cast(base+8, C.POINTER(C.c_long)) struct.pack_into("<4I3i6I", packet, 0, 0x56504245, 1, 0, os.getpid(), 160, 1024, 0, 0x383838, 0x222222, 0, 0, 0, 1) for y in range(32): packet[128+y*32+10] = 1 # Flat red wall, other slots black; proves texture upload rather than fallback. packet[TEXTURES+65536:TEXTURES+2*65536] = struct.pack("deadline: raise AssertionError("Preview renderer did not answer") time.sleep(.005) return packet[PIXELS:PIXELS+307200] try: frame=request() middle=struct.unpack_from(">16,y>>16) packet[1152:1152+len(sprites)]=sprites pack=(ROOT/"assets/textures/texturepack.bin").read_bytes() packet[TEXTURES:TEXTURES+len(pack)-8]=pack[8:] struct.pack_into("