get rid of the last set_indexed_value in drivers/devices - this ends up a bit ugly to maintain backwards compatibility with layouts/web UI (nw)

This commit is contained in:
Vas Crabb 2018-03-05 17:51:26 +11:00
parent 594673c02f
commit 7f78b5975a
4 changed files with 42 additions and 37 deletions

View File

@ -162,9 +162,6 @@ public:
// set the value for a given output
void set_value(const char *outname, s32 value);
// set an indexed value for an output (concatenates basename + index)
void set_indexed_value(const char *basename, int index, int value);
// return the current value for a given output
s32 get_value(const char *outname);
@ -189,6 +186,9 @@ public:
void resume();
private:
// set an indexed value for an output (concatenates basename + index)
void set_indexed_value(const char *basename, int index, int value);
output_item *find_item(const char *string);
output_item &create_new_item(const char *outname, s32 value);

View File

@ -304,7 +304,7 @@ void esq2x16_sq1_device::write_char(int data)
}
//--------------------------------------------------------------------------------------------------------------------------------------------
esq2x16_sq1_device::esq2x16_sq1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
esqvfd_device(mconfig, ESQ2X16_SQ1, tag, owner, clock, 2, 16),
esqvfd_device(mconfig, ESQ2X16_SQ1, tag, owner, clock, make_dimensions<2, 16>()),
m_lcdPix(*this, "pg_%u%03u", 1U, 0U),
m_leds(*this, "rLed_%u", 0U)
{

View File

@ -116,15 +116,17 @@ static const uint16_t font[]=
0x0000, // 0000 0000 0000 0000 (DEL)
};
esqvfd_device::esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rows, int cols) :
esqvfd_device::esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, dimensions_param &&dimensions) :
device_t(mconfig, type, tag, owner, clock),
m_rows(rows),
m_cols(cols)
m_vfds(std::move(std::get<0>(dimensions))),
m_rows(std::get<1>(dimensions)),
m_cols(std::get<2>(dimensions))
{
}
void esqvfd_device::device_start()
{
m_vfds->resolve();
}
void esqvfd_device::device_reset()
@ -142,30 +144,6 @@ void esqvfd_device::device_timer(emu_timer &timer, device_timer_id id, int param
{
}
// why isn't the font just stored in this order?
uint32_t esqvfd_device::conv_segments(uint16_t segin)
{
uint32_t segout = 0;
if ( segin & 0x0004 ) segout |= 0x0001;
if ( segin & 0x0002 ) segout |= 0x0002;
if ( segin & 0x0020 ) segout |= 0x0004;
if ( segin & 0x0200 ) segout |= 0x0008;
if ( segin & 0x2000 ) segout |= 0x0010;
if ( segin & 0x0001 ) segout |= 0x0020;
if ( segin & 0x8000 ) segout |= 0x0040;
if ( segin & 0x4000 ) segout |= 0x0080;
if ( segin & 0x0008 ) segout |= 0x0100;
if ( segin & 0x0400 ) segout |= 0x0200;
if ( segin & 0x0010 ) segout |= 0x0400;
if ( segin & 0x0040 ) segout |= 0x0800;
if ( segin & 0x0080 ) segout |= 0x1000;
if ( segin & 0x0800 ) segout |= 0x2000;
if ( segin & 0x1000 ) segout |= 0x4000;
return segout;
}
// generic display update; can override from child classes if not good enough
void esqvfd_device::update_display()
{
@ -181,7 +159,7 @@ void esqvfd_device::update_display()
if (m_attrs[row][col] & AT_UNDERLINE)
segdata |= 0x0008;
machine().output().set_indexed_value("vfd", (row*m_cols) + col, segdata);
m_vfds->set((row * m_cols) + col, segdata);
m_dirty[row][col] = 0;
}
@ -317,7 +295,8 @@ bool esq2x40_device::write_contents(std::ostream &o)
}
esq2x40_device::esq2x40_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ2X40, tag, owner, clock, 2, 40)
esq2x40_device::esq2x40_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
esqvfd_device(mconfig, ESQ2X40, tag, owner, clock, make_dimensions<2, 40>())
{
}
@ -364,7 +343,8 @@ void esq1x22_device::write_char(int data)
update_display();
}
esq1x22_device::esq1x22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ1X22, tag, owner, clock, 1, 22)
esq1x22_device::esq1x22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
esqvfd_device(mconfig, ESQ1X22, tag, owner, clock, make_dimensions<1, 22>())
{
}
@ -425,7 +405,8 @@ void esq2x40_sq1_device::write_char(int data)
}
}
esq2x40_sq1_device::esq2x40_sq1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ2X40_SQ1, tag, owner, clock, 2, 40)
esq2x40_sq1_device::esq2x40_sq1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
esqvfd_device(mconfig, ESQ2X40_SQ1, tag, owner, clock, make_dimensions<2, 40>())
{
m_wait87shift = false;
m_wait88shift = false;

View File

@ -3,6 +3,9 @@
#ifndef MAME_MACHINE_ESQVFD_H
#define MAME_MACHINE_ESQVFD_H
#include <memory>
#include <tuple>
#define MCFG_ESQ1X22_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, ESQ1X22, 60)
@ -30,10 +33,30 @@ public:
virtual void update_display();
virtual bool write_contents(std::ostream &o) { return false; }
uint32_t conv_segments(uint16_t segin);
// why isn't the font just stored in this order?
static uint32_t conv_segments(uint16_t segin) { return bitswap<15>(segin, 12, 11, 7, 6, 4, 10, 3, 14, 15, 0, 13, 9, 5, 1, 2); }
protected:
esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rows, int cols);
class output_helper {
public:
typedef std::unique_ptr<output_helper> ptr;
virtual ~output_helper() { }
virtual void resolve() = 0;
virtual int32_t set(unsigned n, int32_t value) = 0;
};
template <unsigned N> class output_helper_impl : public output_helper, protected output_finder<N> {
public:
output_helper_impl(device_t &device) : output_finder<N>(device, "vfd%u", 0U) { }
virtual void resolve() override { output_finder<N>::resolve(); }
virtual int32_t set(unsigned n, int32_t value) override { return this->operator[](n) = value; }
};
typedef std::tuple<output_helper::ptr, int, int> dimensions_param;
template <int R, int C> dimensions_param make_dimensions() { return dimensions_param(std::make_unique<output_helper_impl<R * C> >(*this), R, C); }
esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, dimensions_param &&dimensions);
static constexpr uint8_t AT_NORMAL = 0x00;
static constexpr uint8_t AT_BOLD = 0x01;
@ -45,6 +68,7 @@ protected:
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
output_helper::ptr m_vfds;
int m_cursx, m_cursy;
int m_savedx, m_savedy;
int const m_rows, m_cols;