52 lines
2.0 KiB
Lua
52 lines
2.0 KiB
Lua
-- m2-check.lua -- load the M2 COFF with dwt/loader/loader.lua and read the
|
|
-- marker words the compiled TI-ABI code wrote.
|
|
--
|
|
-- M2_LOADER_LUA path to vendor/vt1200/dwt/loader/loader.lua
|
|
-- M2_EXPECT_CHECK 4 (strlen("0::0"))
|
|
-- M2_EXPECT_FIRST 20 (first(20,22))
|
|
-- M2_EXPECT_SECOND 22 (second(20,22))
|
|
-- M2_EXPECT_CALLER 42 (add2(20,22))
|
|
-- M2_EXPECT_LOCALS 7
|
|
-- M2_EXPECT_KEEP 16 (g == 5, + keep(10))
|
|
--
|
|
-- The marker read runs one frame before loader.lua's inspection/exit frame.
|
|
|
|
dofile(os.getenv("M2_LOADER_LUA"))
|
|
|
|
local ENDF = tonumber(os.getenv("LOADER_END") or "2700")
|
|
local EXPECT_CHECK = tonumber(os.getenv("M2_EXPECT_CHECK") or "4")
|
|
local EXPECT_FIRST = tonumber(os.getenv("M2_EXPECT_FIRST") or "20")
|
|
local EXPECT_SECOND = tonumber(os.getenv("M2_EXPECT_SECOND") or "22")
|
|
local EXPECT_CALLER = tonumber(os.getenv("M2_EXPECT_CALLER") or "42")
|
|
local EXPECT_LOCALS = tonumber(os.getenv("M2_EXPECT_LOCALS") or "7")
|
|
local EXPECT_KEEP = tonumber(os.getenv("M2_EXPECT_KEEP") or "16")
|
|
local frames = 0
|
|
local checked = false
|
|
|
|
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 check = prog:read_u32(0x018A8000)
|
|
local first = prog:read_u32(0x018A8020)
|
|
local second = prog:read_u32(0x018A8040)
|
|
local caller = prog:read_u32(0x018A8060)
|
|
local locals = prog:read_u32(0x018A8080)
|
|
local keep = prog:read_u32(0x018A80A0)
|
|
print(string.format(
|
|
"M2: check=%d first=%d second=%d caller=%d locals=%d keep=%d",
|
|
check, first, second, caller, locals, keep))
|
|
if check == EXPECT_CHECK and first == EXPECT_FIRST
|
|
and second == EXPECT_SECOND and caller == EXPECT_CALLER
|
|
and locals == EXPECT_LOCALS and keep == EXPECT_KEEP then
|
|
print("M2 MAME: PASS")
|
|
else
|
|
print(string.format(
|
|
"M2 MAME: FAIL (want check=%d first=%d second=%d caller=%d locals=%d keep=%d)",
|
|
EXPECT_CHECK, EXPECT_FIRST, EXPECT_SECOND, EXPECT_CALLER,
|
|
EXPECT_LOCALS, EXPECT_KEEP))
|
|
end
|
|
end
|
|
end, "m2-check")
|