"""M3 texel store: parse the game wire's action-0x1a texture uploads into a handle -> (u_size, v_size, mode, RGB array) dict. Format: header[32] = {handle, byte_size, u, v, mode, ...}, then v rows of 256 bytes, texels in 0x00BBGGRR little-endian words (bytes R,G,B,0). Verified: decodes to the real game textures (HUD 'PLAYER n' labels, squadron emblem, panel/terrain art).""" import struct import numpy as np def build_texstore(recs): store = {} i = 0 while i < len(recs): a, p = recs[i] if a == 0x1a and len(p) == 32: h = [struct.unpack_from('= n * 4: arr = np.frombuffer(rb[:n * 4], dtype=np.uint8).reshape(v, u, 4) # v-flip (rows arrive bottom-up: 'PLAYER' reads mirrored otherwise) store[handle] = (u, v, mode, arr[::-1, :, :3].copy()) i = j else: i += 1 return store