summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2018-07-10 04:26:57 +1000
committer Vas Crabb <vas@vastheman.com>2018-07-10 04:26:57 +1000
commit82c6d7dbc54694c544283bf5b77e209000c2d54d (patch)
treed2b96f06d70859ac49df3a2d349db586b66525b3
parentdfb09f2c175ac5f0195d79d4762b68c5725ff652 (diff)
Allow layouts to specify screen tags rather than indices - makes order of instantiation irrelevant in Model 1 etc.
-rw-r--r--scripts/build/complay.py16
-rw-r--r--src/emu/rendlay.cpp5
-rw-r--r--src/mame/layout/model1io2.lay8
-rw-r--r--src/mame/layout/nbmj8688.lay26
4 files changed, 37 insertions, 18 deletions
diff --git a/scripts/build/complay.py b/scripts/build/complay.py
index af5003581e6..ff60a19158f 100644
--- a/scripts/build/complay.py
+++ b/scripts/build/complay.py
@@ -92,6 +92,7 @@ class XmlError(Exception):
class LayoutChecker(Minifyer):
+ BADTAGPATTERN = re.compile('[^abcdefghijklmnopqrstuvwxyz0123456789_.:^$]')
VARPATTERN = re.compile('^~scr(0|[1-9][0-9]*)(native[xy]aspect|width|height)~$')
SHAPES = frozenset(('disk', 'led14seg', 'led14segsc', 'led16seg', 'led16segsc', 'led7seg', 'led8seg_gts1', 'rect'))
OBJECTS = frozenset(('backdrop', 'bezel', 'cpanel', 'marquee', 'overlay'))
@@ -181,6 +182,21 @@ class LayoutChecker(Minifyer):
self.handleError('Element screen attribute index "%s" is negative' % (attrs['index'], ))
except:
self.handleError('Element screen attribute index "%s" is not an integer' % (attrs['index'], ))
+ if 'tag' in attrs:
+ self.handleError('Element screen has both index and tag attributes');
+ if 'tag' in attrs:
+ tag = attrs['tag']
+ if '' == tag:
+ self.handleError('Element screen attribute tag is empty')
+ else:
+ if self.BADTAGPATTERN.search(tag):
+ self.handleError('Element screen attribute tag "%s" contains invalid characters' % (tag, ));
+ if tag.find('^') >= 0:
+ self.handleError('Element screen attribute tag "%s" contains parent device reference' % (tag, ));
+ if ':' == tag[-1]:
+ self.handleError('Element screen attribute tag "%s" ends with separator' % (tag, ));
+ if tag.find('::') >= 0:
+ self.handleError('Element screen attribute tag "%s" contains double separator' % (tag, ));
self.in_object = True
self.have_bounds.append(False)
elif 'group' == name:
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index f63e8ab8259..1dd93271b70 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -2676,7 +2676,10 @@ layout_view::item::item(
// sanity checks
if (strcmp(itemnode.get_name(), "screen") == 0)
{
- if (m_screen == nullptr)
+ char const *const tag(itemnode.get_attribute_string("tag", nullptr));
+ if (tag)
+ m_screen = dynamic_cast<screen_device *>(machine.root_device().subdevice(tag));
+ if (!m_screen)
throw layout_reference_error(util::string_format("invalid screen index %d", index));
}
else
diff --git a/src/mame/layout/model1io2.lay b/src/mame/layout/model1io2.lay
index 18ec50db629..1a552d3352c 100644
--- a/src/mame/layout/model1io2.lay
+++ b/src/mame/layout/model1io2.lay
@@ -18,10 +18,10 @@
</element>
<view name="Default">
- <screen index="0">
+ <screen tag="ioboard:screen">
<bounds left="0" top="0" right="1" bottom="1" />
</screen>
- <screen index="1">
+ <screen tag="screen">
<bounds left="0" top="0" right="4" bottom="3" />
</screen>
</view>
@@ -30,10 +30,10 @@
<backdrop element="background">
<bounds x="0" y="0" width="496" height="419" />
</backdrop>
- <screen index="1">
+ <screen tag="screen">
<bounds left="0" top="0" right="496" bottom="384" />
</screen>
- <screen index="0">
+ <screen tag="ioboard:screen">
<bounds left="8" top="392" right="129" bottom="411" />
</screen>
<cpanel name="led_comm_err" element="led_red">
diff --git a/src/mame/layout/nbmj8688.lay b/src/mame/layout/nbmj8688.lay
index 897d14b5f37..9dc702d198a 100644
--- a/src/mame/layout/nbmj8688.lay
+++ b/src/mame/layout/nbmj8688.lay
@@ -1,70 +1,70 @@
<?xml version="1.0"?>
<mamelayout version="2">
<view name="Main Screen Standard (4:3)">
- <screen index="0">
+ <screen tag="screen">
<bounds left="0" top="0" right="4" bottom="3" />
</screen>
</view>
<view name="LCD0 Standard (15:3)">
- <screen index="1">
+ <screen tag="lcd0">
<bounds left="0" top="0" right="15" bottom="3" />
</screen>
</view>
<view name="LCD1 Standard (15:3)">
- <screen index="2">
+ <screen tag="lcd1">
<bounds left="0" top="0" right="15" bottom="3" />
</screen>
</view>
<view name="Main Screen Pixel Aspect (~scr0nativexaspect~:~scr0nativeyaspect~)">
- <screen index="0">
+ <screen tag="screen">
<bounds left="0" top="0" right="~scr0width~" bottom="~scr0height~" />
</screen>
</view>
<view name="LCD0 Pixel Aspect (~scr1nativexaspect~:~scr1nativeyaspect~)">
- <screen index="1">
+ <screen tag="lcd0">
<bounds left="0" top="0" right="~scr1width~" bottom="~scr1height~" />
</screen>
</view>
<view name="LCD1 Pixel Aspect (~scr2nativexaspect~:~scr2nativeyaspect~)">
- <screen index="2">
+ <screen tag="lcd1">
<bounds left="0" top="0" right="~scr2width~" bottom="~scr2height~" />
</screen>
</view>
<view name="Triple">
- <screen index="0">
+ <screen tag="screen">
<bounds x="0" y="3" width="15" height="11.25" />
</screen>
- <screen index="1">
+ <screen tag="lcd0">
<bounds x="0" y="14.25" width="15" height="3" />
<orientation rotate="180" />
</screen>
- <screen index="2">
+ <screen tag="lcd1">
<bounds x="0" y="0" width="15" height="3" />
</screen>
</view>
<view name="Player 1">
- <screen index="0">
+ <screen tag="screen">
<bounds x="0" y="3" width="15" height="11.25" />
</screen>
- <screen index="1">
+ <screen tag="lcd0">
<bounds x="0" y="14.25" width="15" height="3" />
<orientation rotate="180" />
</screen>
</view>
<view name="Player 2">
- <screen index="0">
+ <screen tag="screen">
<bounds x="0" y="3" width="15" height="11.25" />
<orientation rotate="180" />
</screen>
- <screen index="2">
+ <screen tag="lcd1">
<bounds x="0" y="14.25" width="15" height="3" />
<orientation rotate="180" />
</screen>