From 9c236064ed255baff7ffcc5f2678bd40f836c210 Mon Sep 17 00:00:00 2001 From: AJR Date: Wed, 20 May 2020 16:37:00 -0400 Subject: [PATCH] exelv.cpp, newbrain.cpp: Simplify handler signatures; modernize logging (nw) --- src/mame/drivers/exelv.cpp | 12 +++---- src/mame/drivers/newbrain.cpp | 64 +++++++++++++++++------------------ src/mame/includes/newbrain.h | 16 ++++----- src/mame/video/newbrain.cpp | 9 ++--- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/mame/drivers/exelv.cpp b/src/mame/drivers/exelv.cpp index f391413b709..a2ed5a271ff 100644 --- a/src/mame/drivers/exelv.cpp +++ b/src/mame/drivers/exelv.cpp @@ -90,8 +90,8 @@ private: required_device m_tms5220c; optional_device m_cart; - DECLARE_READ8_MEMBER( mailbox_wx319_r ); - DECLARE_WRITE8_MEMBER( mailbox_wx318_w ); + uint8_t mailbox_wx319_r(); + void mailbox_wx318_w(uint8_t data); uint8_t tms7020_porta_r(); void tms7020_portb_w(uint8_t data); uint8_t tms7041_porta_r(); @@ -100,7 +100,7 @@ private: void tms7041_portc_w(uint8_t data); uint8_t tms7041_portd_r(); void tms7041_portd_w(uint8_t data); - DECLARE_READ8_MEMBER( rom_r ); + uint8_t rom_r(offs_t offset); DECLARE_MACHINE_START(exl100); DECLARE_MACHINE_START(exeltel); @@ -206,14 +206,14 @@ TIMER_DEVICE_CALLBACK_MEMBER(exelv_state::exelv_hblank_interrupt) */ -READ8_MEMBER(exelv_state::mailbox_wx319_r) +uint8_t exelv_state::mailbox_wx319_r() { logerror("[TMS7220] reading mailbox %d\n", m_wx319); return m_wx319; } -WRITE8_MEMBER(exelv_state::mailbox_wx318_w) +void exelv_state::mailbox_wx318_w(uint8_t data) { logerror("wx318 write 0x%02x\n", data); m_wx318 = data; @@ -377,7 +377,7 @@ void exelv_state::tms7041_portd_w(uint8_t data) /* CARTRIDGE ACCESS */ -READ8_MEMBER(exelv_state::rom_r) +uint8_t exelv_state::rom_r(offs_t offset) { if (m_cart && m_cart->exists()) return m_cart->read_rom(offset + 0x200); diff --git a/src/mame/drivers/newbrain.cpp b/src/mame/drivers/newbrain.cpp index 5413714d878..cb17c4652b4 100644 --- a/src/mame/drivers/newbrain.cpp +++ b/src/mame/drivers/newbrain.cpp @@ -62,9 +62,10 @@ // MACROS / CONSTANTS //************************************************************************** -#define LOG 0 -#define LOG_COP 0 -#define LOG_VFD 0 +#define LOG_COP (1 << 1U) +#define LOG_VFD (1 << 2U) +#define VERBOSE 0 +#include "logmacro.h" @@ -88,7 +89,7 @@ void newbrain_state::check_interrupt() // mreq_r - memory request read //------------------------------------------------- -READ8_MEMBER( newbrain_state::mreq_r ) +uint8_t newbrain_state::mreq_r(offs_t offset) { bool romov = 1, raminh = 0; int exrm = 0; @@ -134,7 +135,7 @@ READ8_MEMBER( newbrain_state::mreq_r ) // mreq_w - memory request write //------------------------------------------------- -WRITE8_MEMBER( newbrain_state::mreq_w ) +void newbrain_state::mreq_w(offs_t offset, uint8_t data) { bool romov = 1, raminh = 0; int exrm = 0; @@ -155,7 +156,7 @@ WRITE8_MEMBER( newbrain_state::mreq_w ) // iorq_r - I/O request read //------------------------------------------------- -READ8_MEMBER( newbrain_state::iorq_r ) +uint8_t newbrain_state::iorq_r(offs_t offset) { bool prtov = 0; uint8_t data = m_exp->iorq_r(offset, 0xff, prtov); @@ -180,11 +181,11 @@ READ8_MEMBER( newbrain_state::iorq_r ) case 5: // UST if (BIT(offset, 1)) { - data = ust_b_r(space, offset, data); + data = ust_b_r(); } else { - data = ust_a_r(space, offset, data); + data = ust_a_r(); } break; } @@ -198,7 +199,7 @@ READ8_MEMBER( newbrain_state::iorq_r ) // iorq_w - I/O request write //------------------------------------------------- -WRITE8_MEMBER( newbrain_state::iorq_w ) +void newbrain_state::iorq_w(offs_t offset, uint8_t data) { bool prtov = 0; m_exp->iorq_w(offset, 0xff, prtov); @@ -219,7 +220,7 @@ WRITE8_MEMBER( newbrain_state::iorq_w ) break; case 3: // ENRG1 - enrg_w(space, offset, data); + enrg_w(data); break; } break; @@ -229,7 +230,7 @@ WRITE8_MEMBER( newbrain_state::iorq_w ) break; case 3: // TVTL - tvtl_w(space, offset, data); + tvtl_w(data); break; } } @@ -242,7 +243,7 @@ WRITE8_MEMBER( newbrain_state::iorq_w ) void newbrain_state::clclk() { - if (LOG) logerror("%s %s CLCLK\n", machine().time().as_string(), machine().describe_context()); + LOG("%s %s CLCLK\n", machine().time().as_string(), machine().describe_context()); m_clkint = 1; check_interrupt(); @@ -253,7 +254,7 @@ void newbrain_state::clclk() // enrg_w - //------------------------------------------------- -WRITE8_MEMBER( newbrain_state::enrg_w ) +void newbrain_state::enrg_w(uint8_t data) { /* @@ -270,7 +271,7 @@ WRITE8_MEMBER( newbrain_state::enrg_w ) */ - if (LOG) logerror("%s %s ENRG %02x\n", machine().time().as_string(), machine().describe_context(), data); + LOG("%s %s ENRG %02x\n", machine().time().as_string(), machine().describe_context(), data); // clock enable int clk = BIT(data, 0); @@ -296,7 +297,7 @@ WRITE8_MEMBER( newbrain_state::enrg_w ) // ust_r - //------------------------------------------------- -READ8_MEMBER( newbrain_state::ust_a_r ) +uint8_t newbrain_state::ust_a_r() { /* @@ -330,7 +331,7 @@ READ8_MEMBER( newbrain_state::ust_a_r ) // user_r - //------------------------------------------------- -READ8_MEMBER( newbrain_state::ust_b_r ) +uint8_t newbrain_state::ust_b_r() { /* @@ -385,7 +386,7 @@ uint8_t newbrain_state::cop_in_r() // keyboard data |= BIT(m_403_q, 2); - if (LOG_COP) logerror("%s %s IN %01x\n", machine().time().as_string(), machine().describe_context(), data); + LOGMASKED(LOG_COP, "%s %s IN %01x\n", machine().time().as_string(), machine().describe_context(), data); return data; } @@ -415,7 +416,7 @@ uint8_t newbrain_state::cop_g_r() data |= BIT(m_403_q, 0) << 2; data |= BIT(m_403_q, 3) << 3; - if (LOG_COP) logerror("%s %s G %01x\n", machine().time().as_string(), machine().describe_context(), data); + LOGMASKED(LOG_COP, "%s %s G %01x\n", machine().time().as_string(), machine().describe_context(), data); return data; } @@ -453,7 +454,7 @@ void newbrain_state::cop_g_w(uint8_t data) int copint = !BIT(data, 0); - if (LOG_COP) logerror("%s %s COPINT %u\n", machine().time().as_string(), machine().describe_context(), copint); + LOGMASKED(LOG_COP, "%s %s COPINT %u\n", machine().time().as_string(), machine().describe_context(), copint); if (m_copint != copint) { @@ -486,7 +487,7 @@ void newbrain_state::cop_d_w(uint8_t data) int k4 = !BIT(data, 0); int k6 = !BIT(data, 2); - if (LOG_COP) logerror("%s %s K4 %u K6 %u\n", machine().time().as_string(), machine().describe_context(), k4, k6); + LOGMASKED(LOG_COP, "%s %s K4 %u K6 %u\n", machine().time().as_string(), machine().describe_context(), k4, k6); m_cop_tdo = BIT(data, 1); m_cassette1->output(m_cop_tdo ? -1.0 : +1.0); @@ -495,18 +496,18 @@ void newbrain_state::cop_d_w(uint8_t data) if (k4) { m_405_q = 0; - if (LOG_COP) logerror("%s %s keylatch reset\n", machine().time().as_string(), machine().describe_context()); + LOGMASKED(LOG_COP, "%s %s keylatch reset\n", machine().time().as_string(), machine().describe_context()); } else if (m_cop_k6 && !k6) { m_405_q++; m_405_q &= 0x7f; - if (LOG_COP) logerror("%s %s keylatch %u\n", machine().time().as_string(), machine().describe_context(), m_405_q); + LOGMASKED(LOG_COP, "%s %s keylatch %u\n", machine().time().as_string(), machine().describe_context(), m_405_q); } if (!m_cop_k6 && k6) { m_403_d = m_y[m_405_q & 0x0f]->read() & 0x0f; - if (LOG_COP) logerror("%s %s keydata %01x\n", machine().time().as_string(), machine().describe_context(), m_403_d); + LOGMASKED(LOG_COP, "%s %s keydata %01x\n", machine().time().as_string(), machine().describe_context(), m_403_d); } if (k6) { @@ -514,14 +515,14 @@ void newbrain_state::cop_d_w(uint8_t data) } else { m_403_q = 0xf; - if (LOG_COP) logerror("%s %s keydata disabled\n", machine().time().as_string(), machine().describe_context()); + LOGMASKED(LOG_COP, "%s %s keydata disabled\n", machine().time().as_string(), machine().describe_context()); // COP to VFD serial format, bits 15..0 // A B J I x H G2 C x F G1 E K L M D uint16_t value = bitswap<16>(m_402_q, 11, 7, 1, 13, 10, 3, 2, 12, 9, 5, 6, 4, 0, 8, 14, 15) & 0x3fff; m_digits[m_405_q & 0x0f] = value; - if (LOG_VFD) logerror("%s %s vfd segment %u 402.Q %04x data %04x\n", machine().time().as_string(), machine().describe_context(), m_405_q & 0x0f, m_402_q, value); + LOGMASKED(LOG_VFD, "%s %s vfd segment %u 402.Q %04x data %04x\n", machine().time().as_string(), machine().describe_context(), m_405_q & 0x0f, m_402_q, value); } m_cop_k6 = k6; @@ -535,7 +536,7 @@ void newbrain_state::cop_d_w(uint8_t data) WRITE_LINE_MEMBER( newbrain_state::k1_w ) { - if (LOG_VFD) logerror("%s %s SO %u\n", machine().time().as_string(), machine().describe_context(), state); + LOGMASKED(LOG_VFD, "%s %s SO %u\n", machine().time().as_string(), machine().describe_context(), state); m_cop_so = state; } @@ -547,7 +548,7 @@ WRITE_LINE_MEMBER( newbrain_state::k1_w ) WRITE_LINE_MEMBER( newbrain_state::k2_w ) { - if (LOG_VFD) logerror("%s %s SK %u\n", machine().time().as_string(), machine().describe_context(), state); + LOGMASKED(LOG_VFD, "%s %s SK %u\n", machine().time().as_string(), machine().describe_context(), state); if (state) { @@ -766,8 +767,7 @@ void newbrain_state::machine_reset() m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); m_cop->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); - address_space &space = m_maincpu->space(AS_PROGRAM); - enrg_w(space, 0, 0); + enrg_w(0); timer_set(attotime::from_usec(get_reset_t()), TIMER_ID_RESET); } @@ -782,20 +782,20 @@ void newbrain_state::device_timer(emu_timer &timer, device_timer_id id, int para switch (id) { case TIMER_ID_RESET: - if (LOG) logerror("%s %s RESET 1\n", machine().time().as_string(), machine().describe_context()); + LOG("%s %s RESET 1\n", machine().time().as_string(), machine().describe_context()); m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); m_cop->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); break; case TIMER_ID_PWRUP: - if (LOG) logerror("%s %s PWRUP 1\n", machine().time().as_string(), machine().describe_context()); + LOG("%s %s PWRUP 1\n", machine().time().as_string(), machine().describe_context()); m_pwrup = 1; break; case TIMER_ID_CLKINT: - if (LOG) logerror("%s CLKINT\n", machine().time().as_string()); + LOG("%s CLKINT\n", machine().time().as_string()); m_clkint = 0; check_interrupt(); diff --git a/src/mame/includes/newbrain.h b/src/mame/includes/newbrain.h index 90689676942..80eb1dec811 100644 --- a/src/mame/includes/newbrain.h +++ b/src/mame/includes/newbrain.h @@ -58,15 +58,15 @@ public: private: uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - DECLARE_READ8_MEMBER( mreq_r ); - DECLARE_WRITE8_MEMBER( mreq_w ); - DECLARE_READ8_MEMBER( iorq_r ); - DECLARE_WRITE8_MEMBER( iorq_w ); + uint8_t mreq_r(offs_t offset); + void mreq_w(offs_t offset, uint8_t data); + uint8_t iorq_r(offs_t offset); + void iorq_w(offs_t offset, uint8_t data); - DECLARE_WRITE8_MEMBER( enrg_w ); - DECLARE_WRITE8_MEMBER( tvtl_w ); - DECLARE_READ8_MEMBER( ust_a_r ); - DECLARE_READ8_MEMBER( ust_b_r ); + void enrg_w(uint8_t data); + void tvtl_w(uint8_t data); + uint8_t ust_a_r(); + uint8_t ust_b_r(); void cop_g_w(uint8_t data); uint8_t cop_g_r(); diff --git a/src/mame/video/newbrain.cpp b/src/mame/video/newbrain.cpp index 79458eb10f1..714326050b0 100644 --- a/src/mame/video/newbrain.cpp +++ b/src/mame/video/newbrain.cpp @@ -13,7 +13,8 @@ #include "rendlay.h" #include "screen.h" -#define LOG 0 +#define VERBOSE 0 +#include "logmacro.h" #define NEWBRAIN_VIDEO_RV 0x01 #define NEWBRAIN_VIDEO_FS 0x02 @@ -32,10 +33,10 @@ void newbrain_state::tvl(uint8_t data, int a6) /* latch data to video address counter bits A14-A7 */ m_tvl |= (data << 7); - if (LOG) logerror("%s %s TVL %04x\n", machine().time().as_string(), machine().describe_context(), m_tvl); + LOG("%s %s TVL %04x\n", machine().time().as_string(), machine().describe_context(), m_tvl); } -WRITE8_MEMBER( newbrain_state::tvtl_w ) +void newbrain_state::tvtl_w(uint8_t data) { /* @@ -52,7 +53,7 @@ WRITE8_MEMBER( newbrain_state::tvtl_w ) */ - if (LOG) logerror("%s %s TVTL %02x\n", machine().time().as_string(), machine().describe_context(), data); + LOG("%s %s TVTL %02x\n", machine().time().as_string(), machine().describe_context(), data); m_rv = BIT(data, 0); m_fs = BIT(data, 1);