Various palette and screen improvements (nw)

- Use device_resolve_objects to remove the need for resolve_palette
- Palette format no longer depends on configuration of first screen
This commit is contained in:
AJR 2017-10-31 16:57:59 -04:00
parent 55010e6fad
commit bf8eac0fbb
5 changed files with 37 additions and 37 deletions

View File

@ -26,7 +26,7 @@ device_palette_interface::device_palette_interface(const machine_config &mconfig
: device_interface(device, "palette"),
m_palette(nullptr),
m_pens(nullptr),
m_format(),
m_format(BITMAP_FORMAT_RGB32),
m_shadow_table(nullptr),
m_shadow_group(0),
m_hilight_group(0),
@ -57,10 +57,6 @@ void device_palette_interface::interface_validity_check(validity_checker &valid)
void device_palette_interface::interface_pre_start()
{
// reset all our data
screen_device *screen = device().machine().first_screen();
m_format = (screen != nullptr) ? screen->format() : BITMAP_FORMAT_INVALID;
// allocate the palette
u32 numentries = palette_entries();
allocate_palette(numentries);

View File

@ -37,6 +37,8 @@ typedef u16 indirect_pen_t;
class device_palette_interface : public device_interface
{
friend class screen_device;
static constexpr int MAX_SHADOW_PRESETS = 4;
public:

View File

@ -134,9 +134,6 @@ void device_video_interface::interface_pre_start()
throw device_missing_dependencies();
else
{
// resolve the palette for the sake of register_screen_bitmap
m_screen->resolve_palette();
// no other palette may be specified
if (m_screen->has_palette() && palintf != &m_screen->palette())
throw emu_fatalerror("Device '%s' cannot control screen '%s' with palette '%s'", device().tag(), m_screen_tag, m_screen->palette().device().tag());

View File

@ -803,6 +803,39 @@ void screen_device::device_validity_check(validity_checker &valid) const
}
//-------------------------------------------------
// device_resolve_objects - resolve objects that
// may be needed for other devices to set
// initial conditions at start time
//-------------------------------------------------
void screen_device::device_resolve_objects()
{
// bind our handlers
m_screen_update_ind16.bind_relative_to(*owner());
m_screen_update_rgb32.bind_relative_to(*owner());
m_screen_vblank.resolve_safe();
// find the specified palette
if (m_palette_tag != nullptr && m_palette == nullptr)
{
// find our palette as a sibling device
device_t *palette = owner()->subdevice(m_palette_tag);
if (palette == nullptr)
fatalerror("Screen '%s' specifies nonexistent device '%s' as palette\n",
tag(),
m_palette_tag);
if (!palette->interface(m_palette))
fatalerror("Screen '%s' specifies device '%s' as palette, but it has no palette interface\n",
tag(),
m_palette_tag);
// assign our format to the palette before it starts
m_palette->m_format = format();
}
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -826,13 +859,7 @@ void screen_device::device_start()
}
}
// bind our handlers
m_screen_update_ind16.bind_relative_to(*owner());
m_screen_update_rgb32.bind_relative_to(*owner());
m_screen_vblank.resolve_safe();
// if we have a palette and it's not started, wait for it
resolve_palette();
if (m_palette != nullptr && !m_palette->device().started())
throw device_missing_dependencies();
@ -1481,28 +1508,6 @@ void screen_device::register_screen_bitmap(bitmap_t &bitmap)
}
//-------------------------------------------------
// resolve_palette - find the specified palette
//-------------------------------------------------
void screen_device::resolve_palette()
{
if (m_palette_tag != nullptr && m_palette == nullptr)
{
// find our palette as a sibling device
device_t *palette = owner()->subdevice(m_palette_tag);
if (palette == nullptr)
fatalerror("Screen '%s' specifies nonexistent device '%s' as palette\n",
tag(),
m_palette_tag);
if (!palette->interface(m_palette))
fatalerror("Screen '%s' specifies device '%s' as palette, but it has no palette interface\n",
tag(),
m_palette_tag);
}
}
//-------------------------------------------------
// vblank_begin - call any external callbacks to
// signal the VBLANK period has begun

View File

@ -239,7 +239,6 @@ public:
// additional helpers
void register_vblank_callback(vblank_state_delegate vblank_callback);
void register_screen_bitmap(bitmap_t &bitmap);
void resolve_palette();
// internal to the video system
bool update_quads();
@ -263,6 +262,7 @@ private:
// device-level overrides
virtual void device_validity_check(validity_checker &valid) const override;
virtual void device_resolve_objects() override;
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_stop() override;