mirror of
https://github.com/holub/mame
synced 2025-06-30 07:58:56 +03:00
tamag1: added output finder, modernize mcu pixel callback (nw)
This commit is contained in:
parent
f288f5df71
commit
41a4612b5b
@ -50,7 +50,6 @@ e0c6s46_device::e0c6s46_device(const machine_config &mconfig, const char *tag, d
|
||||
: e0c6200_cpu_device(mconfig, E0C6S46, tag, owner, clock, ADDRESS_MAP_NAME(e0c6s46_program), ADDRESS_MAP_NAME(e0c6s46_data))
|
||||
, m_vram1(*this, "vram1")
|
||||
, m_vram2(*this, "vram2"), m_osc(0), m_svd(0), m_lcd_control(0), m_lcd_contrast(0)
|
||||
, m_pixel_update_handler(nullptr)
|
||||
, m_write_r0(*this), m_write_r1(*this), m_write_r2(*this), m_write_r3(*this), m_write_r4(*this)
|
||||
, m_read_p0(*this), m_read_p1(*this), m_read_p2(*this), m_read_p3(*this)
|
||||
, m_write_p0(*this), m_write_p1(*this), m_write_p2(*this), m_write_p3(*this), m_r_dir(0), m_p_dir(0), m_p_pullup(0), m_dfk0(0), m_256_src_pulse(0), m_core_256_handle(nullptr),
|
||||
@ -84,6 +83,8 @@ void e0c6s46_device::device_start()
|
||||
m_write_p2.resolve_safe();
|
||||
m_write_p3.resolve_safe();
|
||||
|
||||
m_pixel_update_cb.bind_relative_to(*owner());
|
||||
|
||||
// create timers
|
||||
m_core_256_handle = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(e0c6s46_device::core_256_cb), this));
|
||||
m_core_256_handle->adjust(attotime::from_ticks(64, unscaled_clock()));
|
||||
@ -602,8 +603,8 @@ u32 e0c6s46_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c
|
||||
int seg = offset / 2;
|
||||
int com = bank * 8 + (offset & 1) * 4 + c;
|
||||
|
||||
if (m_pixel_update_handler != nullptr)
|
||||
m_pixel_update_handler(*this, bitmap, cliprect, m_lcd_contrast, seg, com, pixel);
|
||||
if (!m_pixel_update_cb.isnull())
|
||||
m_pixel_update_cb(bitmap, cliprect, m_lcd_contrast, seg, com, pixel);
|
||||
else if (cliprect.contains(seg, com))
|
||||
bitmap.pix16(com, seg) = pixel;
|
||||
}
|
||||
|
@ -56,16 +56,16 @@ enum
|
||||
|
||||
|
||||
// lcd driver
|
||||
#define MCFG_E0C6S46_PIXEL_UPDATE_CB(_cb) \
|
||||
e0c6s46_device::static_set_pixel_update_cb(*device, _cb);
|
||||
#define MCFG_E0C6S46_PIXEL_UPDATE_CB(_class, _method) \
|
||||
e0c6s46_device::static_set_pixel_update_cb(*device, e0c6s46_device::pixel_update_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
|
||||
|
||||
#define E0C6S46_PIXEL_UPDATE_CB(name) void name(device_t &device, bitmap_ind16 &bitmap, const rectangle &cliprect, int contrast, int seg, int com, int state)
|
||||
#define E0C6S46_PIXEL_UPDATE(name) void name(bitmap_ind16 &bitmap, const rectangle &cliprect, int contrast, int seg, int com, int state)
|
||||
|
||||
|
||||
class e0c6s46_device : public e0c6200_cpu_device
|
||||
{
|
||||
public:
|
||||
typedef void (*pixel_update_func)(device_t &device, bitmap_ind16 &bitmap, const rectangle &cliprect, int contrast, int seg, int com, int state);
|
||||
typedef device_delegate<void (bitmap_ind16 &bitmap, const rectangle &cliprect, int contrast, int seg, int com, int state)> pixel_update_delegate;
|
||||
|
||||
e0c6s46_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
@ -85,7 +85,7 @@ public:
|
||||
template <class Object> static devcb_base &set_write_p2_callback(device_t &device, Object &&cb) { return downcast<e0c6s46_device &>(device).m_write_p2.set_callback(std::forward<Object>(cb)); }
|
||||
template <class Object> static devcb_base &set_write_p3_callback(device_t &device, Object &&cb) { return downcast<e0c6s46_device &>(device).m_write_p3.set_callback(std::forward<Object>(cb)); }
|
||||
|
||||
static void static_set_pixel_update_cb(device_t &device, pixel_update_func cb) { downcast<e0c6s46_device &>(device).m_pixel_update_handler = cb; }
|
||||
static void static_set_pixel_update_cb(device_t &device, pixel_update_delegate &&cb) { downcast<e0c6s46_device &>(device).m_pixel_update_cb = std::move(cb); }
|
||||
|
||||
DECLARE_READ8_MEMBER(io_r);
|
||||
DECLARE_WRITE8_MEMBER(io_w);
|
||||
@ -114,7 +114,7 @@ private:
|
||||
|
||||
u8 m_lcd_control;
|
||||
u8 m_lcd_contrast;
|
||||
pixel_update_func m_pixel_update_handler;
|
||||
pixel_update_delegate m_pixel_update_cb;
|
||||
|
||||
// i/o ports
|
||||
devcb_write8 m_write_r0, m_write_r1, m_write_r2, m_write_r3, m_write_r4;
|
||||
|
@ -23,18 +23,28 @@ public:
|
||||
tamag1_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_speaker(*this, "speaker")
|
||||
m_speaker(*this, "speaker"),
|
||||
m_out_x(*this, "%u.%u", 0U, 0U)
|
||||
{ }
|
||||
|
||||
required_device<e0c6s46_device> m_maincpu;
|
||||
required_device<speaker_sound_device> m_speaker;
|
||||
output_finder<16, 40> m_out_x;
|
||||
|
||||
DECLARE_WRITE8_MEMBER(speaker_w);
|
||||
|
||||
DECLARE_PALETTE_INIT(tama);
|
||||
DECLARE_INPUT_CHANGED_MEMBER(input_changed);
|
||||
E0C6S46_PIXEL_UPDATE(pixel_update);
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
};
|
||||
|
||||
void tamag1_state::machine_start()
|
||||
{
|
||||
m_out_x.resolve();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
@ -42,7 +52,7 @@ public:
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static E0C6S46_PIXEL_UPDATE_CB(tama_pixel_update)
|
||||
E0C6S46_PIXEL_UPDATE(tamag1_state::pixel_update)
|
||||
{
|
||||
// 16 COM(common) pins, 40 SEG(segment) pins from MCU,
|
||||
// 32x16 LCD screen:
|
||||
@ -62,17 +72,10 @@ static E0C6S46_PIXEL_UPDATE_CB(tama_pixel_update)
|
||||
// 2 rows of indicators:
|
||||
// above screen: 0:meal, 1:lamp, 2:play, 3:medicine
|
||||
// under screen: 4:bath, 5:scales, 6:shout, 7:attention
|
||||
|
||||
// they are on pin SEG8(x=35) + COM0-3, pin SEG28(x=36) + COM12-15
|
||||
if (x == 35 && y < 4)
|
||||
device.machine().output().set_lamp_value(y, state);
|
||||
else if (x == 36 && y >= 12)
|
||||
device.machine().output().set_lamp_value(y-8, state);
|
||||
|
||||
// output for svg2lay
|
||||
char buf[0x10];
|
||||
sprintf(buf, "%d.%d", y, x);
|
||||
device.machine().output().set_value(buf, state);
|
||||
// output to y.x
|
||||
m_out_x[y][x] = state;
|
||||
}
|
||||
|
||||
PALETTE_INIT_MEMBER(tamag1_state, tama)
|
||||
@ -132,7 +135,7 @@ static MACHINE_CONFIG_START( tama )
|
||||
|
||||
/* basic machine hardware */
|
||||
MCFG_CPU_ADD("maincpu", E0C6S46, XTAL_32_768kHz)
|
||||
MCFG_E0C6S46_PIXEL_UPDATE_CB(tama_pixel_update)
|
||||
MCFG_E0C6S46_PIXEL_UPDATE_CB(tamag1_state, pixel_update)
|
||||
MCFG_E0C6S46_WRITE_R_CB(4, WRITE8(tamag1_state, speaker_w))
|
||||
|
||||
/* video hardware */
|
||||
|
@ -58,15 +58,15 @@
|
||||
<bezel element="static_yellow"><bounds x="0" y="0" width="32" height="4" /></bezel>
|
||||
<bezel element="static_yellow"><bounds x="0" y="22" width="32" height="4" /></bezel>
|
||||
|
||||
<bezel name="lamp0" element="ind0"><bounds x="0" y="1" width="8" height="2" /></bezel>
|
||||
<bezel name="lamp1" element="ind1"><bounds x="8" y="1" width="8" height="2" /></bezel>
|
||||
<bezel name="lamp2" element="ind2"><bounds x="16" y="1" width="8" height="2" /></bezel>
|
||||
<bezel name="lamp3" element="ind3"><bounds x="24" y="1" width="8" height="2" /></bezel>
|
||||
<bezel name="0.35" element="ind0"><bounds x="0" y="1" width="8" height="2" /></bezel>
|
||||
<bezel name="1.35" element="ind1"><bounds x="8" y="1" width="8" height="2" /></bezel>
|
||||
<bezel name="2.35" element="ind2"><bounds x="16" y="1" width="8" height="2" /></bezel>
|
||||
<bezel name="3.35" element="ind3"><bounds x="24" y="1" width="8" height="2" /></bezel>
|
||||
|
||||
<bezel name="lamp4" element="ind4"><bounds x="0" y="23" width="8" height="2" /></bezel>
|
||||
<bezel name="lamp5" element="ind5"><bounds x="8" y="23" width="8" height="2" /></bezel>
|
||||
<bezel name="lamp6" element="ind6"><bounds x="16" y="23" width="8" height="2" /></bezel>
|
||||
<bezel name="lamp7" element="ind7"><bounds x="24" y="23" width="8" height="2" /></bezel>
|
||||
<bezel name="12.36" element="ind4"><bounds x="0" y="23" width="8" height="2" /></bezel>
|
||||
<bezel name="13.36" element="ind5"><bounds x="8" y="23" width="8" height="2" /></bezel>
|
||||
<bezel name="14.36" element="ind6"><bounds x="16" y="23" width="8" height="2" /></bezel>
|
||||
<bezel name="15.36" element="ind7"><bounds x="24" y="23" width="8" height="2" /></bezel>
|
||||
|
||||
</view>
|
||||
</mamelayout>
|
||||
|
Loading…
Reference in New Issue
Block a user