Files
psxrecomp/tools/ds_screenshot.py
T
Matthew Stanley 101fd2e1a9 feat: 46 GTE library seeds + DuckStation oracle SW readback + debug tooling
Add 46 seeds for the libgte helper functions at BFC34E00-BFC36D00.
These wrap individual GTE operations (RTPS, RTPT, NCLIP, MVMVA, etc.)
and were never discovered because they're called via JALR function
pointers, not direct JAL. Coverage: 52→114 gte_execute, 166→429
LWC2/SWC2. Emitted functions: 1178→1214. Seeds: 960→1006.

Fix DuckStation oracle VRAM readback by setting
UseSoftwareRendererForReadbacks=true in settings.ini.

Add debug/analysis tools: GTE audit, VRAM stitching, rapid polling,
GPU info, divergence comparison, jump table dumps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-24 00:29:06 -07:00

43 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Capture DuckStation oracle VRAM as screenshot via debug server."""
import socket, json, sys
from PIL import Image
port = int(sys.argv[1]) if len(sys.argv) > 1 else 4371
out = sys.argv[2] if len(sys.argv) > 2 else "ds_screenshot.png"
s = socket.create_connection(('localhost', port))
cmd = '{"cmd":"read_vram","x":0,"y":0,"w":640,"h":480}\n'
s.sendall(cmd.encode())
data = b''
while True:
chunk = s.recv(65536)
if not chunk:
break
data += chunk
if b'\n' in data:
break
s.close()
resp = json.loads(data.split(b'\n')[0])
if not resp.get('ok'):
print('Error:', resp)
sys.exit(1)
pixels = bytes.fromhex(resp['pixels'])
w, h = resp['w'], resp['h']
img = Image.new('RGB', (w, h))
for y in range(h):
for x in range(w):
off = (y * w + x) * 2
if off + 1 >= len(pixels):
break
val = pixels[off] | (pixels[off + 1] << 8)
r = (val & 0x1F) << 3
g = ((val >> 5) & 0x1F) << 3
b = ((val >> 10) & 0x1F) << 3
img.putpixel((x, y), (r, g, b))
img.save(out)
print(f'Saved {out} ({w}x{h})')