plugins/hiscore: start delay (nw)

This commit is contained in:
cracyc 2019-02-17 13:16:33 -06:00
parent 63979771d8
commit f1e51d745a

View File

@ -33,6 +33,7 @@ function hiscore.startplugin()
local mem_check_passed = false;
local found_hiscore_entry = false;
local timed_save = true;
local delaytime = 0;
local positions = {};
-- Configuration file will be searched in the first path defined
@ -59,29 +60,34 @@ function hiscore.startplugin()
local function parse_table ( dsting )
local _table = {};
for line in string.gmatch(dsting, '([^\n]+)') do
local cpu, mem;
local cputag, space, offs, len, chk_st, chk_ed, fill = string.match(line, '^@([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),?(%x?%x?)');
cpu = manager:machine().devices[cputag];
if not cpu then
error(cputag .. " device not found")
end
local rgnname, rgntype = space:match("([^/]*)/?([^/]*)")
if rgntype == "share" then
mem = manager:machine():memory().shares[rgnname]
local delay = line:match('^@delay=([%d])')
if delay and #delay > 0 then
delaytime = os.time() + tonumber(delay)
else
mem = cpu.spaces[space]
local cpu, mem;
local cputag, space, offs, len, chk_st, chk_ed, fill = string.match(line, '^@([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),?(%x?%x?)');
cpu = manager:machine().devices[cputag];
if not cpu then
error(cputag .. " device not found")
end
local rgnname, rgntype = space:match("([^/]*)/?([^/]*)")
if rgntype == "share" then
mem = manager:machine():memory().shares[rgnname]
else
mem = cpu.spaces[space]
end
if not mem then
error(space .. " space not found")
end
_table[ #_table + 1 ] = {
mem = mem,
addr = tonumber(offs, 16),
size = tonumber(len, 16),
c_start = tonumber(chk_st, 16),
c_end = tonumber(chk_ed, 16),
fill = tonumber(fill, 16)
};
end
if not mem then
error(space .. " space not found")
end
_table[ #_table + 1 ] = {
mem = mem,
addr = tonumber(offs, 16),
size = tonumber(len, 16),
c_start = tonumber(chk_st, 16),
c_end = tonumber(chk_ed, 16),
fill = tonumber(fill, 16)
};
end
return _table;
end
@ -211,7 +217,7 @@ function hiscore.startplugin()
local function init ()
if not scores_have_been_read then
if check_mem( positions ) then
if (delaytime <= os.time()) and check_mem( positions ) then
default_checksum = check_scores( positions );
if read_scores( positions ) then
emu.print_verbose( "hiscore: scores read OK" );