Files
arti a6379b206b M7.3: make the xmore flags honest (review round 2)
The ROM builders do not set A8, so markers 4 and 10 are no longer
presented as return values:

- property_called=1 and attrs_called=1 are plain post-call flags.  The
  gate requires the flag, states that the property has no server read-back
  (zero X errors is the only runtime check), and keeps the black margin
  as the real CWBackPixel proof.  Marker 14 pins the 160x120 fill
  geometry (0xA00078) so the margin sample cannot become vacuous.
- InternAtom wording: the display marker only proves the connection was
  live before the call; stage 14 cannot distinguish the intended _XSend
  block from a crash/wrong import.  The isolated probe is narrative entry
  evidence, not a gate check.
- XSetWindowAttributes attrs = {0}; replaces the unsigned int * zeroing
  loop.
- Fix the stale image_roundtrip stage-11 comment (text pixels now set
  stage 12).
- GC wording is 'source call sites; runtime entry not proven', not
  'proves call presence'.
2026-11-15 02:21:08 +00:00

150 lines
6.8 KiB
Lua

-- xmore-check.lua -- load the M7.3 wider-Xlib COFF with dwt/loader/loader.lua,
-- then prove the markers and the window pixels.
--
-- M4_LOADER_LUA path to vendor/vt1200/dwt/loader/loader.lua
-- LOADER_END loader inspection/exit frame (default 3400)
--
-- Markers (0x20 bits apart, read at LOADER_END-1):
-- 018A8000 parent Window id, nonzero
-- 018A8020 child Window id, nonzero
-- 018A8040 gc GC pointer, nonzero
-- 018A8060 atom XInternAtom("WM_NAME"): nonzero atom, or
-- 0xFFFFFFFF documented skip (the ROM _XSend path
-- that carries the name does not complete here)
-- 018A8080 property 1 after the XChangeProperty call site ran (no
-- server read-back; zero X errors is the only
-- runtime check)
-- 018A80A0 configure client-computed (child width << 16) | height
-- (0x00C80096); the move is pixel-proven, the size
-- is not read back
-- 018A80C0 font XLoadFont("fixed"), nonzero
-- 018A80E0 image (pixel << 8) | flags (0x13F when the full
-- XCreateImage/XGetImage/XPutImage/XDestroyImage
-- round trip worked: pixel=1 and flags=0x3F)
-- 018A8100 errors X protocol error count (0)
-- 018A8120 stage 14 = InternAtom attempted (skip), 15 = returned
-- 018A8140 attrs 1 after the XChangeWindowAttributes call site ran;
-- the real proof is the black CWBackPixel margin
-- (the ROM builder does not set A8)
-- 018A8160 gcchange XChangeGC source call count (2); runtime entry is
-- not proven, and the ROM entry is a cache flush
-- 018A8180 text set pixels in the XDrawString band (0,126) 64x16
-- 018A81A0 display Display pointer stored just before XInternAtom
-- 018A81C0 fill (FILL_W << 16) | FILL_H (0xA00078), pins the
-- margin sample's fill geometry
--
-- Geometry: parent at screen (100,100) 400x300 (the WM leaves a top-level
-- client window at its requested origin, as the M4 xshow gate proves), child
-- configured to (20,20) 200x150. The child is created with background 1
-- (white), then CWBackPixel=0 (black). The 160x120 black fill leaves a
-- right/bottom margin; screen (300,240) is in that margin, so it is black only
-- because of the window attribute (without it the child background is white).
-- The white rectangle is at child (0,0) 32x32 (screen 120,120), the heap image
-- at child (40,32) (screen 160,152; 32-bit aligned) and the XGetImage result
-- put back at child (104,32) (screen 224,152). The text is drawn at baseline
-- child (4,140) on the black margin, and the XGetImage band (child 0,126 64x16)
-- counts its white glyph pixels.
--
-- The printed "parent(...)" coordinate is screen minus the parent origin
-- (100,100), i.e. parent-relative, not child-relative (the child is at 20,20
-- inside the parent).
--
-- Pixel sampling reads the exact VRAM bit address (VR319: 2048-bit rows,
-- LSB-first), not a whole unaligned word. If XConfigureWindow did not move the
-- child from its created (40,40), the p_rect sample (screen 128,128) is outside
-- the child and p_back (screen 240,160) maps outside the put-back image; p_img
-- alone would still be white (it would land inside the 32x32 rectangle).
dofile(os.getenv("M4_LOADER_LUA"))
local ENDF = tonumber(os.getenv("LOADER_END") or "3400")
local VRAM_BASE = 0x04000000
local VRAM_PITCH = 2048
local WIN_X, WIN_Y = 100, 100
local frames = 0
local checked = false
local function read_bit(prog, sx, sy)
local bit = VRAM_BASE + sy * VRAM_PITCH + sx
return prog:read_u16(bit) % 2, bit
end
emu.register_frame_done(function()
frames = frames + 1
if frames == ENDF - 1 and not checked then
checked = true
local prog = manager.machine.devices[':maincpu'].spaces['program']
local m = {}
for i = 0, 14 do
m[i] = prog:read_u32(0x018A8000 + i * 0x20)
end
print(string.format(
"M7: window=0x%X child=0x%X gc=0x%X atom=0x%X property_called=%d configure=0x%X font=0x%X image=0x%X errors=%d stage=%d attrs_called=%d gcchange=%d text=%d display=0x%X fill=0x%X",
m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9],
m[10], m[11], m[12], m[13], m[14]))
local function sample(sx, sy, want)
local b, bit = read_bit(prog, sx, sy)
print(string.format(
"M7: pixel screen(%d,%d) parent(%d,%d) bit=0x%08X value=%d %s",
sx, sy, sx - WIN_X, sy - WIN_Y, bit, b,
b == 1 and "white" or "black"))
return b == want
end
-- (screen x, screen y, expected); parent-relative coordinates.
local p_rect = sample(128, 128, 1) -- parent (28,28): XFillRectangle
local p_img = sample(170, 162, 1) -- parent (70,62): heap XPutImage
local p_back = sample(240, 160, 1) -- parent (140,60): put back
local p_bg = sample(300, 240, 0) -- parent (200,140): CWBackPixel margin
local configure_want = 200 * 65536 + 150
local image_want = 0x13F
local atom_skip = (m[3] == 0xFFFFFFFF)
local atom_ok = (m[3] ~= 0 and m[3] ~= 0xFFFFFFFF
and m[3] ~= 0xFFFFFFFE)
local stage_ok = (atom_skip and m[9] == 14)
or (atom_ok and m[9] == 15)
local text_want_max = 64 * 16
local ok = m[0] ~= 0 and m[1] ~= 0 and m[2] ~= 0
and (atom_skip or atom_ok)
and m[4] == 1 and m[5] == configure_want and m[6] ~= 0
and m[7] == image_want and m[8] == 0 and stage_ok
and m[10] == 1 and m[11] == 2
and m[12] > 0 and m[12] < text_want_max
and m[13] ~= 0 and m[14] == 0xA00078
and p_rect and p_img and p_back and p_bg
print(string.format(
"M7: text band child(0,126) 64x16 set_pixels=%d (%s); "
.. "gcchange=%d (source call sites; runtime entry not proven); "
.. "attrs_called=%d; property_called=%d (call site ran, no "
.. "server read-back)",
m[12], (m[12] > 0 and m[12] < text_want_max) and "ok" or "BAD",
m[11], m[10], m[4]))
if atom_skip then
print("M7: internatom=SKIP (ROM _XSend scatter path blocks; "
.. "WM_NAME written with predefined atom 39; the display "
.. "marker only proves the connection was live before the "
.. "call; the isolated probe is narrative entry evidence)")
elseif atom_ok then
print(string.format("M7: internatom=0x%X", m[3]))
end
if ok then
print("M7 MAME: PASS")
else
print(string.format(
"M7 MAME: FAIL (window=0x%X child=0x%X gc=0x%X atom=0x%X property_called=%d configure=0x%X font=0x%X image=0x%X errors=%d stage=%d attrs_called=%d gcchange=%d text=%d display=0x%X fill=0x%X; pixels rect=%s image=%s putback=%s margin=%s)",
m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9],
m[10], m[11], m[12], m[13], m[14],
tostring(p_rect), tostring(p_img), tostring(p_back),
tostring(p_bg)))
end
end
end, "xmore-check")