mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
psx/ctlrport: use required_device (nw)
sort_hiscore: make it much faster (nw)
This commit is contained in:
parent
09ab222658
commit
1092f2009b
@ -81,20 +81,20 @@ end
|
|||||||
lstfile:close()
|
lstfile:close()
|
||||||
|
|
||||||
local sorted = {}
|
local sorted = {}
|
||||||
local comments = 0
|
local sindex = {}
|
||||||
|
local comments = ""
|
||||||
|
|
||||||
for num, entry in ipairs(entries) do
|
for num, entry in pairs(entries) do
|
||||||
if not entry.name then
|
if not entry.name then
|
||||||
if entry.comment then
|
if entry.comment then
|
||||||
if entry.comment[1]:sub(2,4) ~= "@s:" then
|
if entry.comment[1]:sub(2,4) ~= "@s:" then
|
||||||
comments = comments + 1
|
comments = comments .. table.concat(entry.comment, "\n") .. "\n"
|
||||||
table.insert(sorted, comments, entry)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
table.sort(entry.name)
|
table.sort(entry.name)
|
||||||
entry.src = "source not found"
|
entry.src = "source not found"
|
||||||
for num, name in ipairs(entry.name) do
|
for num, name in pairs(entry.name) do
|
||||||
name = name:match("[^,]*")
|
name = name:match("[^,]*")
|
||||||
if not list[name] then
|
if not list[name] then
|
||||||
entry.name[num] = entry.name[num] .. ": ; missing"
|
entry.name[num] = entry.name[num] .. ": ; missing"
|
||||||
@ -103,61 +103,60 @@ for num, entry in ipairs(entries) do
|
|||||||
entry.src = list[name]
|
entry.src = list[name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
entry.data = table.concat(entry.data, "\n")
|
||||||
|
if entry.comment then
|
||||||
|
entry.comment = table.concat(entry.comment, "\n")
|
||||||
|
end
|
||||||
sorted[#sorted + 1] = entry
|
sorted[#sorted + 1] = entry
|
||||||
|
if not sindex[entry.src] then
|
||||||
|
sindex[entry.src] = {}
|
||||||
|
end
|
||||||
|
sindex[entry.src][#sorted] = entry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for num1, entry in ipairs(sorted) do
|
for src, entries in pairs(sindex) do
|
||||||
if entry.data then
|
for num1, entry in pairs(entries) do
|
||||||
for num2, entry2 in ipairs(sorted) do
|
for num2, entry2 in pairs(entries) do
|
||||||
if entry2.data and entry.src == entry2.src and entry ~= entry2 and #entry.data == #entry2.data then
|
if entry ~= entry2 and entry.data == entry2.data then
|
||||||
for i = 1, #entry2.data do
|
for num3, name in pairs(entry2.name) do
|
||||||
if entry.data[i] ~= entry2.data[i] then
|
entry.name[#entry.name + 1] = name
|
||||||
break
|
end
|
||||||
end
|
if entry2.comment then
|
||||||
if i == #entry2.data then
|
if not entry.comment then
|
||||||
for num3, name in ipairs(entry2.name) do
|
entry.comment = entry2.comment
|
||||||
entry.name[#entry.name + 1] = name
|
elseif entry.comment ~= entry2.comment then
|
||||||
end
|
entry.comment = entry.comment .. "\n" .. entry2.comment
|
||||||
if entry2.comment then
|
|
||||||
for num3, comment in ipairs(entry2.comment) do
|
|
||||||
if not entry.comment then
|
|
||||||
entry.comment = {}
|
|
||||||
end
|
|
||||||
entry.comment[#entry.comment + 1] = comment
|
|
||||||
end
|
|
||||||
end
|
|
||||||
sorted[num2] = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
sorted[num2] = {}
|
||||||
|
entries[num2] = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for num1, entry in ipairs(sorted) do
|
local nindex = {}
|
||||||
|
|
||||||
|
for num1, entry in pairs(sorted) do
|
||||||
if entry.name then
|
if entry.name then
|
||||||
for num2, name in ipairs(entry.name) do
|
for num2, name in pairs(entry.name) do
|
||||||
local curname = name:match("[^:]*")
|
local curname = name:match("[^:]*")
|
||||||
for num3, entry2 in ipairs(sorted) do
|
if nindex[curname] then
|
||||||
if entry2.name and entry.src == entry2.src then
|
if nindex[curname] == entry then
|
||||||
for num4, name2 in ipairs(entry2.name) do
|
entry.name[num2] = ""
|
||||||
if curname == name2:match("[^:]*") then
|
else
|
||||||
if entry ~= entry2 then
|
print(curname, "duplicate name")
|
||||||
print(name, "duplicate name")
|
|
||||||
elseif num2 ~= num4 then
|
|
||||||
entry2.name[num4] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
nindex[curname] = entry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- copyright 2010 Uli Schlachter GPLv2
|
-- copyright 2010 Uli Schlachter GPLv2
|
||||||
function stable_sort(list, comp)
|
local function stable_sort(list, comp)
|
||||||
-- A table could contain non-integer keys which we have to ignore.
|
-- A table could contain non-integer keys which we have to ignore.
|
||||||
local num = 0
|
local num = 0
|
||||||
for k, v in ipairs(list) do
|
for k, v in ipairs(list) do
|
||||||
@ -198,24 +197,21 @@ stable_sort(sorted, function(a,b)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
src = "error";
|
local src = "error";
|
||||||
|
|
||||||
|
print(comments)
|
||||||
|
|
||||||
for num, entry in ipairs(sorted) do
|
for num, entry in ipairs(sorted) do
|
||||||
local function printall(table)
|
|
||||||
for num, str in ipairs(table) do
|
|
||||||
print(str)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if entry.src and entry.src ~= src then
|
|
||||||
print(";@s:" .. entry.src .. "\n")
|
|
||||||
src = entry.src
|
|
||||||
end
|
|
||||||
if entry.comment then
|
|
||||||
printall(entry.comment)
|
|
||||||
end
|
|
||||||
if entry.name then
|
if entry.name then
|
||||||
printall(entry.name)
|
if entry.src and entry.src ~= src then
|
||||||
printall(entry.data)
|
print(";@s:" .. entry.src .. "\n")
|
||||||
|
src = entry.src
|
||||||
|
end
|
||||||
|
if entry.comment then
|
||||||
|
print(entry.comment)
|
||||||
|
end
|
||||||
|
print(table.concat(entry.name, "\n"))
|
||||||
|
print(entry.data)
|
||||||
|
print("\n")
|
||||||
end
|
end
|
||||||
print("\n")
|
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,8 @@ void psx_controller_port_device::disable_card(bool state)
|
|||||||
|
|
||||||
psxcontrollerports_device::psxcontrollerports_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
psxcontrollerports_device::psxcontrollerports_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||||
device_t(mconfig, PSXCONTROLLERPORTS, tag, owner, clock),
|
device_t(mconfig, PSXCONTROLLERPORTS, tag, owner, clock),
|
||||||
m_port0(nullptr), m_port1(nullptr),
|
m_port0(*this, "port0"),
|
||||||
|
m_port1(*this, "port1"),
|
||||||
m_dsr_handler(*this),
|
m_dsr_handler(*this),
|
||||||
m_rxd_handler(*this)
|
m_rxd_handler(*this)
|
||||||
{
|
{
|
||||||
@ -50,8 +51,6 @@ void psxcontrollerports_device::device_start()
|
|||||||
m_dsr_handler.resolve_safe();
|
m_dsr_handler.resolve_safe();
|
||||||
m_rxd_handler.resolve_safe();
|
m_rxd_handler.resolve_safe();
|
||||||
|
|
||||||
m_port0 = machine().device<psx_controller_port_device>("port1");
|
|
||||||
m_port1 = machine().device<psx_controller_port_device>("port2");
|
|
||||||
m_port0->setup_ack_cb(psx_controller_port_device::void_cb(&psxcontrollerports_device::ack, this));
|
m_port0->setup_ack_cb(psx_controller_port_device::void_cb(&psxcontrollerports_device::ack, this));
|
||||||
m_port1->setup_ack_cb(psx_controller_port_device::void_cb(&psxcontrollerports_device::ack, this));
|
m_port1->setup_ack_cb(psx_controller_port_device::void_cb(&psxcontrollerports_device::ack, this));
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,8 @@ protected:
|
|||||||
virtual void device_start() override;
|
virtual void device_start() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
psx_controller_port_device *m_port0;
|
required_device<psx_controller_port_device> m_port0;
|
||||||
psx_controller_port_device *m_port1;
|
required_device<psx_controller_port_device> m_port1;
|
||||||
|
|
||||||
devcb_write_line m_dsr_handler;
|
devcb_write_line m_dsr_handler;
|
||||||
devcb_write_line m_rxd_handler;
|
devcb_write_line m_rxd_handler;
|
||||||
|
Loading…
Reference in New Issue
Block a user