80 lines
2.9 KiB
Lua
80 lines
2.9 KiB
Lua
-- m3-check.lua -- load the M3 COFF with dwt/loader/loader.lua, read the
|
|
-- compiled branch/Xlib marker words, and prove a window was mapped by reading
|
|
-- the white background pixel in VRAM.
|
|
--
|
|
-- M3_LOADER_LUA path to vendor/vt1200/dwt/loader/loader.lua
|
|
-- LOADER_END loader inspection/exit frame
|
|
--
|
|
-- The marker read runs one frame before loader.lua's inspection/exit frame.
|
|
-- XSync is diagnostic only; the pass requires the visible white pixel.
|
|
--
|
|
-- The DWT root window is a fine monochrome weave, so one set bit at (150,150)
|
|
-- cannot distinguish the mapped client window from the root. Require the
|
|
-- whole 32-bit VRAM word containing (150,150) to be 0xFFFFFFFF, and check a
|
|
-- second interior word at (250,200) so the client area is proven solid, not
|
|
-- just a lucky white stripe.
|
|
|
|
dofile(os.getenv("M3_LOADER_LUA"))
|
|
|
|
local ENDF = tonumber(os.getenv("LOADER_END") or "3400")
|
|
|
|
-- Window: XCreateSimpleWindow(display, root, 100, 100, 400, 200, 2, 0, 1).
|
|
-- The client area starts at (102,102); sample well inside it.
|
|
local VRAM_BASE = 0x04000000
|
|
local VRAM_PITCH = 2048 -- VR319: 2048 bits per row
|
|
local WHITE_WORD = 0xFFFFFFFF
|
|
local PX, PY = 150, 150
|
|
local PX2, PY2 = 250, 200
|
|
|
|
local frames = 0
|
|
local checked = false
|
|
|
|
local function vram_word(prog, x, y)
|
|
local bit = VRAM_BASE + y * VRAM_PITCH + x
|
|
local word = bit - (bit % 32)
|
|
return prog:read_u32(word), word, 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 display = prog:read_u32(0x018A8000)
|
|
local root = prog:read_u32(0x018A8020)
|
|
local window = prog:read_u32(0x018A8040)
|
|
local sync = prog:read_u32(0x018A8060)
|
|
local sum = prog:read_u32(0x018A8080)
|
|
local maxv = prog:read_u32(0x018A80A0)
|
|
local ltv = prog:read_u32(0x018A80C0)
|
|
local screens = prog:read_u32(0x018A80E0)
|
|
local rootoff = prog:read_u32(0x018A8100)
|
|
|
|
-- The full words containing each sample pixel.
|
|
local pix, word, bit = vram_word(prog, PX, PY)
|
|
local pix2, word2, bit2 = vram_word(prog, PX2, PY2)
|
|
local solid = pix == WHITE_WORD
|
|
local solid2 = pix2 == WHITE_WORD
|
|
|
|
print(string.format(
|
|
"M3: display=%u root=%u window=%u sync=%d sum=%d max=%d lt=%d screens=0x%x root_off=0x%x",
|
|
display, root, window, sync, sum, maxv, ltv, screens, rootoff))
|
|
print(string.format(
|
|
"M3: pixel(%d,%d) bit=0x%08X word=0x%08X value=0x%08X %s",
|
|
PX, PY, bit, word, pix, solid and "SOLID-WHITE" or "not-solid-white"))
|
|
print(string.format(
|
|
"M3: pixel(%d,%d) bit=0x%08X word=0x%08X value=0x%08X %s",
|
|
PX2, PY2, bit2, word2, pix2, solid2 and "SOLID-WHITE" or "not-solid-white"))
|
|
|
|
local ok = display ~= 0 and root ~= 0 and window ~= 0
|
|
and sum == 55 and maxv == 22 and ltv == 1
|
|
and screens == 0x480 and rootoff == 0x40
|
|
and solid and solid2
|
|
if ok then
|
|
print("M3 MAME: PASS")
|
|
else
|
|
print("M3 MAME: FAIL")
|
|
end
|
|
end
|
|
end, "m3-check")
|