-- Diagnostic for FINDINGS 46.6: separate the WRITE path from the DISPLAY path. M=manager.machine; SP=M.devices[":maincpu"].spaces["program"]; SUB=nil local function load_mode() for _,p in ipairs{"../tools/bench/crtc_mode.lua","tools/bench/crtc_mode.lua"} do local f=loadfile(p); if f then return f() end end error("no crtc_mode.lua") end local MODE = load_mode() local CRTC, GV = 0xE80000, 0xC00000 local function T() local t=M.time; return t.seconds+t.attoseconds/1e18 end local st="wait" SUB = emu.add_machine_frame_notifier(function() if st~="wait" then return end if T()<3.0 then return end MODE.apply(SP) local function trial(name, r20) SP:write_u16(CRTC+20*2, r20) -- clear both bytes of word 0 via the two aliases, masked mode SP:write_u16(CRTC+20*2, MODE.r20) SP:write_u16(GV, 0); SP:write_u16(GV+0x80000, 0) SP:write_u16(CRTC+20*2, r20) SP:write_u16(GV, 0xAB5C) -- the write under test local raw = SP:read_u16(GV) SP:write_u16(CRTC+20*2, MODE.r20) -- back to masked to read pages local p0 = SP:read_u16(GV) -- page 0 alias -> low byte local p1 = SP:read_u16(GV+0x80000) -- page 1 alias -> high byte SP:write_u16(CRTC+20*2, r20) print(string.format("[PROBE] %-22s R20=%04X wrote AB5C raw=%04X page0=%02X page1=%02X", name, r20, raw, p0 & 0xff, p1 & 0xff)) end trial("masked (bit11=0)", MODE.r20) trial("buffer (bit11=1)", MODE.r20 | 0x0800) -- what does the video controller look like after MODE.apply? print(string.format("[PROBE] VC R0=%04X R1=%04X R2=%04X", SP:read_u16(0xE82400), SP:read_u16(0xE82500), SP:read_u16(0xE82600))) st="done"; M:exit() end)