divideo: Fetch screen to be potentially configured during device_config_complete (nw)

- Allow device finder to be used as an argument for set_screen (nw)

screen: Calculate physical aspect ratio whenever required, not in device_config_complete, since the renderer caches the result anyway (nw)

cdp1861, cdp1864: Eliminate the "magic reference" constructors, doing their work in device_config_complete instead (nw)
This commit is contained in:
AJR 2018-08-21 09:04:09 -04:00
parent afdcf4dcec
commit b3e306b985
15 changed files with 122 additions and 41 deletions

View File

@ -23,6 +23,7 @@
#include "emu.h"
#include "cdp1864.h"
#include "screen.h"
@ -78,12 +79,23 @@ cdp1864_device::cdp1864_device(const machine_config &mconfig, const char *tag, d
{
}
cdp1864_device::cdp1864_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, screen_device &screen)
: cdp1864_device(mconfig, tag, owner, clock)
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void cdp1864_device::device_config_complete()
{
set_screen(screen, DEVICE_SELF);
screen.set_screen_update(screen_update_rgb32_delegate(FUNC(cdp1864_device::screen_update), this));
screen.set_raw(clock, SCREEN_WIDTH, HBLANK_END, HBLANK_START, TOTAL_SCANLINES, SCANLINE_VBLANK_END, SCANLINE_VBLANK_START);
if (!has_screen())
return;
if (!screen().refresh_attoseconds())
screen().set_raw(clock(), SCREEN_WIDTH, HBLANK_END, HBLANK_START, TOTAL_SCANLINES, SCANLINE_VBLANK_END, SCANLINE_VBLANK_START);
if (!screen().have_screen_update())
screen().set_screen_update(screen_update_rgb32_delegate(FUNC(cdp1864_device::screen_update), this));
}

View File

@ -40,8 +40,6 @@
#include "machine/rescap.h"
#include "video/resnet.h"
#include "screen.h"
//**************************************************************************
@ -83,7 +81,6 @@ public:
// construction/destruction
cdp1864_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
cdp1864_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, screen_device &screen);
auto inlace_cb() { return m_read_inlace.bind(); }
auto int_cb() { return m_write_int.bind(); }
@ -112,6 +109,7 @@ public:
protected:
// device-level overrides
virtual void device_config_complete() override;
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;

View File

@ -9,6 +9,8 @@
#include "emu.h"
#include "cdp1861.h"
#include "screen.h"
//**************************************************************************
@ -51,12 +53,23 @@ cdp1861_device::cdp1861_device(const machine_config &mconfig, const char *tag, d
{
}
cdp1861_device::cdp1861_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, screen_device &screen)
: cdp1861_device(mconfig, tag, owner, clock)
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void cdp1861_device::device_config_complete()
{
set_screen(screen, DEVICE_SELF);
screen.set_screen_update(screen_update_rgb32_delegate(FUNC(cdp1861_device::screen_update), this));
screen.set_raw(clock, SCREEN_WIDTH, HBLANK_END, HBLANK_START, TOTAL_SCANLINES, SCANLINE_VBLANK_END, SCANLINE_VBLANK_START);
if (!has_screen())
return;
if (!screen().refresh_attoseconds())
screen().set_raw(clock(), SCREEN_WIDTH, HBLANK_END, HBLANK_START, TOTAL_SCANLINES, SCANLINE_VBLANK_END, SCANLINE_VBLANK_START);
if (!screen().have_screen_update())
screen().set_screen_update(screen_update_rgb32_delegate(FUNC(cdp1861_device::screen_update), this));
}

View File

@ -26,8 +26,6 @@
#pragma once
#include "screen.h"
//**************************************************************************
// TYPE DEFINITIONS
@ -65,7 +63,6 @@ public:
// construction/destruction
cdp1861_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
cdp1861_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, screen_device &screen);
auto int_cb() { return m_write_int.bind(); }
auto dma_out_cb() { return m_write_dma_out.bind(); }
@ -81,6 +78,7 @@ public:
protected:
// device-level overrides
virtual void device_config_complete() override;
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;

View File

@ -50,6 +50,22 @@ void device_video_interface::set_screen(const char *tag)
}
//-------------------------------------------------
// interface_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void device_video_interface::interface_config_complete()
{
// find the screen if explicitly configured
if (m_screen_tag && strcmp(m_screen_tag, s_unconfigured_screen_tag) != 0)
m_screen = m_screen_base->subdevice<screen_device>(m_screen_tag);
// device_config_complete may now do whatever it needs to with the screen
}
//-------------------------------------------------
// interface_validity_check - validation for a
// device after the configuration has been

View File

@ -49,6 +49,12 @@ public:
m_screen_base = &base;
m_screen_tag = tag;
}
template <class ObjectClass, bool Required>
void set_screen(device_finder<ObjectClass, Required> &finder)
{
m_screen_base = &finder.finder_target().first;
m_screen_tag = finder.finder_target().second;
}
// getters
screen_device &screen() const { return *m_screen; }
@ -56,6 +62,7 @@ public:
protected:
// optional operation overrides
virtual void interface_config_complete() override;
virtual void interface_validity_check(validity_checker &valid) const override;
virtual void interface_pre_start() override;

View File

@ -656,19 +656,32 @@ void screen_device::device_config_complete()
{
// combine orientation with machine orientation
m_orientation = orientation_add(m_orientation, mconfig().gamedrv().flags & machine_flags::MASK_ORIENTATION);
}
//-------------------------------------------------
// physical_aspect - determine the physical
// aspect ratio to be used for rendering
//-------------------------------------------------
std::pair<unsigned, unsigned> screen_device::physical_aspect() const
{
assert(configured());
std::pair<unsigned, unsigned> phys_aspect = m_phys_aspect;
// physical aspect ratio unconfigured
if (!m_phys_aspect.first || !m_phys_aspect.second)
if (!phys_aspect.first || !phys_aspect.second)
{
switch (m_type)
{
case SCREEN_TYPE_RASTER:
case SCREEN_TYPE_VECTOR:
m_phys_aspect = std::make_pair(4, 3); // assume standard CRT
phys_aspect = std::make_pair(4, 3); // assume standard CRT
break;
case SCREEN_TYPE_LCD:
case SCREEN_TYPE_SVG:
m_phys_aspect = std::make_pair(~0U, ~0U); // assume square pixels
phys_aspect = std::make_pair(~0U, ~0U); // assume square pixels
break;
case SCREEN_TYPE_INVALID:
default:
@ -677,16 +690,17 @@ void screen_device::device_config_complete()
}
// square pixels?
if ((~0U == m_phys_aspect.first) && (~0U == m_phys_aspect.second))
if ((~0U == phys_aspect.first) && (~0U == phys_aspect.second))
{
m_phys_aspect.first = visible_area().width();
m_phys_aspect.second = visible_area().height();
phys_aspect.first = visible_area().width();
phys_aspect.second = visible_area().height();
}
// always keep this in reduced form
util::reduce_fraction(m_phys_aspect.first, m_phys_aspect.second);
}
util::reduce_fraction(phys_aspect.first, phys_aspect.second);
return phys_aspect;
}
//-------------------------------------------------

View File

@ -182,7 +182,7 @@ public:
// configuration readers
screen_type_enum screen_type() const { return m_type; }
int orientation() const { assert(configured()); return m_orientation; }
std::pair<unsigned, unsigned> physical_aspect() const { assert(configured()); return m_phys_aspect; }
std::pair<unsigned, unsigned> physical_aspect() const;
int width() const { return m_width; }
int height() const { return m_height; }
const rectangle &visible_area() const { return m_visarea; }

View File

@ -36,6 +36,7 @@
#include "emu.h"
#include "includes/cosmicos.h"
#include "screen.h"
#include "speaker.h"
#include "cosmicos.lh"
@ -527,13 +528,15 @@ MACHINE_CONFIG_START(cosmicos_state::cosmicos)
MCFG_TIMER_DRIVER_ADD_PERIODIC("digit", cosmicos_state, digit_tick, attotime::from_hz(100))
MCFG_TIMER_DRIVER_ADD_PERIODIC("interrupt", cosmicos_state, int_tick, attotime::from_hz(1000))
SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);
/* sound hardware */
SPEAKER(config, "mono").front_center();
MCFG_DEVICE_ADD("speaker", SPEAKER_SOUND)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
CDP1864(config, m_cti, 1.75_MHz_XTAL, SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1864(config, m_cti, 1.75_MHz_XTAL).set_screen(SCREEN_TAG);
m_cti->inlace_cb().set_constant(0);
m_cti->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_cti->dma_out_cb().set(FUNC(cosmicos_state::dmaout_w));

View File

@ -17,6 +17,7 @@
#include "emu.h"
#include "includes/elf.h"
#include "elf2.lh"
#include "screen.h"
#define RUN \
BIT(m_special->read(), 0)
@ -251,11 +252,11 @@ MACHINE_CONFIG_START(elf2_state::elf2)
/* video hardware */
config.set_default_layout(layout_elf2);
CDP1861(config, m_vdc, XTAL(3'579'545)/2, SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1861(config, m_vdc, XTAL(3'579'545)/2).set_screen(SCREEN_TAG);
m_vdc->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_vdc->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);
m_vdc->efx_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_EF1);
SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);
/* devices */
MCFG_DEVICE_ADD(MM74C923_TAG, MM74C923, 0)

View File

@ -38,6 +38,7 @@
#include "emu.h"
#include "includes/eti660.h"
#include "screen.h"
#include "speaker.h"
@ -318,9 +319,12 @@ MACHINE_CONFIG_START(eti660_state::eti660)
m_maincpu->q_cb().set(FUNC(eti660_state::q_w));
m_maincpu->dma_wr_cb().set(FUNC(eti660_state::dma_w));
/* video/sound hardware */
/* video hardware */
SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);
/* sound hardware */
SPEAKER(config, "mono").front_center();
CDP1864(config, m_cti, XTAL(8'867'238)/5, SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1864(config, m_cti, XTAL(8'867'238)/5).set_screen(SCREEN_TAG);
m_cti->inlace_cb().set_constant(0);
m_cti->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_cti->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);

View File

@ -194,6 +194,7 @@ Notes:
#include "bus/generic/slot.h"
#include "bus/generic/carts.h"
#include "screen.h"
#include "softlist.h"
#include "speaker.h"
@ -660,7 +661,8 @@ MACHINE_CONFIG_START(studio2_state::studio2)
m_maincpu->dma_wr_cb().set(m_vdc, FUNC(cdp1861_device::dma_w));
/* video hardware */
CDP1861(config, m_vdc, 1760000, SCREEN(config, m_screen, SCREEN_TYPE_RASTER));
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
CDP1861(config, m_vdc, 1760000).set_screen(m_screen);
m_vdc->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_vdc->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);
m_vdc->efx_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_EF1);
@ -685,11 +687,13 @@ MACHINE_CONFIG_START(visicom_state::visicom)
m_maincpu->dma_wr_cb().set(FUNC(visicom_state::dma_w));
/* video hardware */
CDP1861(config, m_vdc, XTAL(3'579'545)/2, SCREEN(config, m_screen, SCREEN_TYPE_RASTER));
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_screen_update(FUNC(visicom_state::screen_update));
CDP1861(config, m_vdc, XTAL(3'579'545)/2).set_screen(m_screen);
m_vdc->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_vdc->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);
m_vdc->efx_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_EF1);
m_screen->set_screen_update(FUNC(visicom_state::screen_update));
/* sound hardware */
SPEAKER(config, "mono").front_center();
@ -718,7 +722,8 @@ MACHINE_CONFIG_START(mpt02_state::mpt02)
SPEAKER(config, "mono").front_center();
BEEP(config, m_beeper, 300).add_route(ALL_OUTPUTS, "mono", 1.00);
CDP1864(config, m_cti, 1.75_MHz_XTAL, SCREEN(config, m_screen, SCREEN_TYPE_RASTER));
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
CDP1864(config, m_cti, 1.75_MHz_XTAL).set_screen(m_screen);
m_cti->inlace_cb().set_constant(0);
m_cti->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_cti->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);

View File

@ -34,6 +34,7 @@
#include "emu.h"
#include "includes/tmc2000e.h"
#include "screen.h"
#include "speaker.h"
@ -293,9 +294,12 @@ void tmc2000e_state::tmc2000e(machine_config &config)
m_maincpu->q_cb().set(FUNC(tmc2000e_state::q_w));
m_maincpu->dma_wr_cb().set(FUNC(tmc2000e_state::dma_w));
// video/sound hardware
// video hardware
SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);
// sound hardware
SPEAKER(config, "mono").front_center();
CDP1864(config, m_cti, 1.75_MHz_XTAL, SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1864(config, m_cti, 1.75_MHz_XTAL).set_screen(SCREEN_TAG);
m_cti->inlace_cb().set_constant(0);
m_cti->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_cti->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);

View File

@ -222,6 +222,7 @@ Notes:
#include "emu.h"
#include "includes/vip.h"
#include "screen.h"
#include "softlist.h"
#include "speaker.h"
@ -716,11 +717,12 @@ MACHINE_CONFIG_START(vip_state::vip)
m_maincpu->tpb_cb().set(m_exp, FUNC(vip_expansion_slot_device::tpb_w));
// video hardware
screen_device &screen(SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1861(config, m_vdc, 3.52128_MHz_XTAL / 2, screen);
CDP1861(config, m_vdc, 3.52128_MHz_XTAL / 2).set_screen(SCREEN_TAG);
m_vdc->int_cb().set(FUNC(vip_state::vdc_int_w));
m_vdc->dma_out_cb().set(FUNC(vip_state::vdc_dma_out_w));
m_vdc->efx_cb().set(FUNC(vip_state::vdc_ef1_w));
screen_device &screen(SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
screen.set_screen_update(FUNC(vip_state::screen_update));
// sound hardware

View File

@ -7,6 +7,7 @@
#include "machine/rescap.h"
#include "sound/cdp1864.h"
#include "video/cdp1861.h"
#include "screen.h"
#include "speaker.h"
@ -38,10 +39,11 @@ uint32_t osc1000b_state::screen_update(screen_device &screen, bitmap_rgb32 &bitm
void tmc1800_state::tmc1800_video(machine_config &config)
{
CDP1861(config, m_vdc, XTAL(1'750'000), SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1861(config, m_vdc, XTAL(1'750'000)).set_screen(SCREEN_TAG);
m_vdc->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_vdc->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);
m_vdc->efx_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_EF1);
SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);
}
MACHINE_CONFIG_START(osc1000b_state::osc1000b_video)
@ -54,8 +56,9 @@ MACHINE_CONFIG_END
void tmc2000_state::tmc2000_video(machine_config &config)
{
SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);
SPEAKER(config, "mono").front_center();
CDP1864(config, m_cti, XTAL(1'750'000), SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1864(config, m_cti, XTAL(1'750'000)).set_screen(SCREEN_TAG);
m_cti->inlace_cb().set_constant(0);
m_cti->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_cti->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);
@ -69,8 +72,9 @@ void tmc2000_state::tmc2000_video(machine_config &config)
void nano_state::nano_video(machine_config &config)
{
SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);
SPEAKER(config, "mono").front_center();
CDP1864(config, m_cti, XTAL(1'750'000), SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
CDP1864(config, m_cti, XTAL(1'750'000)).set_screen(SCREEN_TAG);
m_cti->inlace_cb().set_constant(0);
m_cti->int_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_INT);
m_cti->dma_out_cb().set_inputline(m_maincpu, COSMAC_INPUT_LINE_DMAOUT);