From 00f6156cbbadfc01dcd2a7e91d26d55fa210dfab Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 4 Aug 2017 11:39:32 +1000 Subject: [PATCH] minimaws: show compatible slots for devices [Vas Crabb] (nw) Identify Donkey Kong Junior (Japan set F-1) [Corrado Comaselli] --- scripts/minimaws/lib/dbaccess.py | 7 +++++++ scripts/minimaws/lib/htmltmpl.py | 14 ++++++++++++++ scripts/minimaws/lib/wsgiserve.py | 29 +++++++++++++++++++++++++++-- src/mame/drivers/dkong.cpp | 2 +- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/scripts/minimaws/lib/dbaccess.py b/scripts/minimaws/lib/dbaccess.py index b1cc48b87b8..147986e0039 100644 --- a/scripts/minimaws/lib/dbaccess.py +++ b/scripts/minimaws/lib/dbaccess.py @@ -198,6 +198,13 @@ class QueryCursor(object): 'WHERE machine.id IN (SELECT machine FROM devicereference WHERE device = ?)', (device, )) + def get_compatible_slots(self, device): + return self.dbcurs.execute( + 'SELECT machine.shortname AS shortname, machine.description AS description, slot.name AS slot, slotoption.name AS slotoption, sourcefile.filename AS sourcefile ' \ + 'FROM slotoption JOIN slot ON slotoption.slot = slot.id JOIN machine on slot.machine = machine.id JOIN sourcefile ON machine.sourcefile = sourcefile.id ' + 'WHERE slotoption.device = ?', + (device, )) + def get_sourcefile_id(self, filename): return (self.dbcurs.execute('SELECT id FROM sourcefile WHERE filename = ?', (filename, )).fetchone() or (None, ))[0] diff --git a/scripts/minimaws/lib/htmltmpl.py b/scripts/minimaws/lib/htmltmpl.py index d465f0d993d..815905a59bb 100644 --- a/scripts/minimaws/lib/htmltmpl.py +++ b/scripts/minimaws/lib/htmltmpl.py @@ -19,6 +19,11 @@ ERROR_PAGE = string.Template( '\n') +SORTABLE_TABLE_EPILOGUE = string.Template( + ' \n' + '\n' + '\n') + MACHINE_PROLOGUE = string.Template( '\n' \ '\n' \ @@ -64,6 +69,15 @@ EXCL_MACHINE_ROW = string.Template( ' \n' \ ' \n') +COMPATIBLE_SLOT_ROW = string.Template( + ' \n' \ + ' ${shortname}\n' \ + ' ${description}\n' \ + ' ${slot}\n' \ + ' ${slotoption}\n' \ + ' ${sourcefile}\n' \ + ' \n') + SOURCEFILE_PROLOGUE = string.Template( '\n' \ diff --git a/scripts/minimaws/lib/wsgiserve.py b/scripts/minimaws/lib/wsgiserve.py index fe96a60f4f4..1743178dbb7 100644 --- a/scripts/minimaws/lib/wsgiserve.py +++ b/scripts/minimaws/lib/wsgiserve.py @@ -211,6 +211,7 @@ class MachineHandler(QueryPageHandler): yield htmltmpl.MACHINE_SLOTS_PLACEHOLDER.substitute( machine=self.js_escape(self.shortname)).encode('utf=8') + # list devices referenced by this system/device first = True for name, desc, src in self.dbcurs.get_devices_referenced(id): if first: @@ -224,8 +225,32 @@ class MachineHandler(QueryPageHandler): first = False yield self.machine_row(name, desc, src) if not first: - yield ' \n\n\n'.encode('utf-8') + yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-dev-refs').encode('utf-8') + # list slots where this device is an option + first = True + for name, desc, slot, opt, src in self.dbcurs.get_compatible_slots(id): + if (first): + yield \ + '

Compatible Slots

\n' \ + '\n' \ + ' \n' \ + ' \n' \ + ' \n' \ + ' \n'.encode('utf-8') + first = False + yield htmltmpl.COMPATIBLE_SLOT_ROW.substitute( + machinehref=self.machine_href(name), + sourcehref=self.sourcefile_href(src), + shortname=cgi.escape(name), + description=cgi.escape(desc), + sourcefile=cgi.escape(src), + slot=cgi.escape(slot), + slotoption=cgi.escape(opt)).encode('utf-8') + if not first: + yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-comp-slots').encode('utf-8') + + # list systems/devices that reference this device first = True for name, desc, src in self.dbcurs.get_device_references(id): if first: @@ -239,7 +264,7 @@ class MachineHandler(QueryPageHandler): first = False yield self.machine_row(name, desc, src) if not first: - yield ' \n
Short nameDescriptionSlotChoiceSource file
\n\n'.encode('utf-8') + yield htmltmpl.SORTABLE_TABLE_EPILOGUE.substitute(id='tbl-ref-by').encode('utf-8') yield '\n'.encode('utf-8') diff --git a/src/mame/drivers/dkong.cpp b/src/mame/drivers/dkong.cpp index 83a4148b4e1..06348358273 100644 --- a/src/mame/drivers/dkong.cpp +++ b/src/mame/drivers/dkong.cpp @@ -3383,7 +3383,7 @@ GAME( 2013, dkongpe, dkong, dkong2b, dkong, dkong_state, 0, ROT GAME( 1982, dkongjr, 0, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo of America", "Donkey Kong Junior (US set F-2)", MACHINE_SUPPORTS_SAVE ) GAME( 1982, dkongjrj, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo", "Donkey Kong Jr. (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, dkongjnrj, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo", "Donkey Kong Junior (Japan?)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, dkongjnrj, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo", "Donkey Kong Junior (Japan set F-1)", MACHINE_SUPPORTS_SAVE ) GAME( 1982, dkongjrb, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "bootleg", "Donkey Kong Jr. (bootleg)", MACHINE_SUPPORTS_SAVE ) GAME( 1982, dkongjre, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "Nintendo of America", "Donkey Kong Junior (E kit)", MACHINE_SUPPORTS_SAVE ) GAME( 1982, dkongjrpb, dkongjr, dkongjr, dkongjr, dkong_state, 0, ROT90, "bootleg", "Donkey Kong Junior (P kit, bootleg)", MACHINE_SUPPORTS_SAVE ) // definitely not issued by Nintendo