For the Sega Beena, I want to render a backdrop behind a screen. This backdrop is always present in every game, so I wanted to specify it in a layout. The screen can display up to 2 opaque pages, each covering half of the screen, but the backdrop only needs to be shown on the left half. Requirements:

- Opaque backdrop when screen is filled with transparent pens;
- No visible backdrop when screen is filled with opaque pens;
- Lightgun crosshair should be visible at all times;
- Lightgun inputs should still be captured on the left half of the screen;

I've tried these alternatives but none appear to fulfill these requirements.

1) Both backdrop and screen using alpha blending:

Code
<mamelayout version="2">
        <element name="bg">
		<image file="settings.png" />
	</element>
	<view name="Dual Under-Over">
                <element ref="bg">
			<bounds x="0" y="-480" width="352" height="480" />
		</element>
		<screen index="1">
			<bounds x="0" y="-480" width="704" height="480" />
		</screen>
		<screen index="0">
			<bounds x="0" y="0" width="704" height="480" />
		</screen>
	</view>
</mamelayout>

With a transparent screen, I don't see the backdrop. According to the docs, "The element will be drawn with alpha blending, and will obscure any elements/screens instantiated earlier in the view", so I suppose this is the expected behaviour.

2) backdrop using alpha blending, screen using additive blending:

Code
<mamelayout version="2">
        <element name="bg">
		<image file="settings.png" />
	</element>
	<view name="Dual Under-Over">
                <element ref="bg">
			<bounds x="0" y="-480" width="352" height="480" />
		</element>
                <screen index="1" blend="add">
			<bounds x="0" y="-480" width="704" height="480" />
		</screen>
		<screen index="0">
			<bounds x="0" y="0" width="704" height="480" />
		</screen>
	</view>
</mamelayout>

This works when the screen is transparent, but anything else will just get mixed with backdrop colors. Similar results if using RGB multiply.

Is there any way to make this work with the existing layout logic, or would a new blend mode be required?

Or should I try a different approach and instead use a picture_image_device (not great since a player would have to always specify it in the command line), or manually parse the backdrop from the artwork folder to then fill it directly in the screen's bitmap?

EDIT: Got the conditional part working using the element state, I had missed this when reading the docs... so this is the layout:

Code
<mamelayout version="2">
        <element name="settings_image">
		<image state="1" file="settings.png" />
	</element>
	<view name="Dual Under-Over">
		<screen index="1">
			<bounds x="0" y="-480" width="704" height="480" />
		</screen>
        <element name="settings" ref="settings_image">
			<bounds x="0" y="-480" width="352" height="480" />
		</element>
		<screen index="0">
			<bounds x="0" y="0" width="704" height="480" />
		</screen>
	</view>
</mamelayout>

Then on my device I have an output_finder for "settings".

The only problem with this is that the lightgun's crosshair doesn't get rendered on top of the (now overlayed) image. Was hoping to workaround this by rendering the image before the screen then using the additive blending with a transparent screen, but that just causes the crosshair to not get rendered on the screen at all...

Last edited by QUFB; 05/25/23 09:26 PM.