diff --git a/src/devices/cpu/e0c6200/e0c6s46.cpp b/src/devices/cpu/e0c6200/e0c6s46.cpp index c53c1d29b56..16e1e3d3eb2 100644 --- a/src/devices/cpu/e0c6200/e0c6s46.cpp +++ b/src/devices/cpu/e0c6200/e0c6s46.cpp @@ -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; } diff --git a/src/devices/cpu/e0c6200/e0c6s46.h b/src/devices/cpu/e0c6200/e0c6s46.h index ca432e52481..82f734d3172 100644 --- a/src/devices/cpu/e0c6200/e0c6s46.h +++ b/src/devices/cpu/e0c6200/e0c6s46.h @@ -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 pixel_update_delegate; e0c6s46_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); @@ -85,7 +85,7 @@ public: template static devcb_base &set_write_p2_callback(device_t &device, Object &&cb) { return downcast(device).m_write_p2.set_callback(std::forward(cb)); } template static devcb_base &set_write_p3_callback(device_t &device, Object &&cb) { return downcast(device).m_write_p3.set_callback(std::forward(cb)); } - static void static_set_pixel_update_cb(device_t &device, pixel_update_func cb) { downcast(device).m_pixel_update_handler = cb; } + static void static_set_pixel_update_cb(device_t &device, pixel_update_delegate &&cb) { downcast(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; diff --git a/src/mame/drivers/tamag1.cpp b/src/mame/drivers/tamag1.cpp index 4b582cffe48..1dfec3b1038 100644 --- a/src/mame/drivers/tamag1.cpp +++ b/src/mame/drivers/tamag1.cpp @@ -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 m_maincpu; required_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 */ diff --git a/src/mame/layout/tama.lay b/src/mame/layout/tama.lay index e4a8c62aaab..db2eaf55159 100644 --- a/src/mame/layout/tama.lay +++ b/src/mame/layout/tama.lay @@ -58,15 +58,15 @@ - - - - + + + + - - - - + + + +