From ec30abcbb94942bbea8a4e2c81f8d05f0a38dace Mon Sep 17 00:00:00 2001 From: Robbbert Date: Sun, 10 Apr 2022 08:51:19 +1000 Subject: acefruit: placate coverity (251457,251459,251461) --- src/mame/drivers/acefruit.cpp | 72 +++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/src/mame/drivers/acefruit.cpp b/src/mame/drivers/acefruit.cpp index d343155cf94..313f087f3bc 100644 --- a/src/mame/drivers/acefruit.cpp +++ b/src/mame/drivers/acefruit.cpp @@ -90,10 +90,9 @@ private: void acefruit_state::acefruit_update_irq(int vpos) { - int col; int row = vpos / 8; - for( col = 0; col < 32; col++ ) + for( int col = 0; col < 32; col++ ) { int tile_index = ( col * 32 ) + row; int color = m_colorram[ tile_index ]; @@ -225,52 +224,31 @@ uint32_t acefruit_state::screen_update_acefruit(screen_device &screen, bitmap_in template int acefruit_state::sidewndr_payout_r() { - switch (Mask) - { - case 0x01: - return ((m_port_payout->read() & Mask) >> 0); - case 0x02: - return ((m_port_payout->read() & Mask) >> 1); - default: - logerror("sidewndr_payout_r : invalid %02X bit_mask\n",Mask); - return 0; - } + if (Mask < 2) + return BIT(m_port_payout->read(), Mask); + + logerror("sidewndr_payout_r : invalid %02X bit_mask\n",Mask); + return 0; } template int acefruit_state::starspnr_coinage_r() { - switch (Mask) - { - case 0x01: - return ((m_port_coinage->read() & Mask) >> 0); - case 0x02: - return ((m_port_coinage->read() & Mask) >> 1); - case 0x04: - return ((m_port_coinage->read() & Mask) >> 2); - case 0x08: - return ((m_port_coinage->read() & Mask) >> 3); - default: - logerror("starspnr_coinage_r : invalid %02X bit_mask\n",Mask); - return 0; - } + if (Mask < 4) + return BIT(m_port_coinage->read(), Mask); + + logerror("starspnr_coinage_r : invalid %02X bit_mask\n",Mask); + return 0; } template int acefruit_state::starspnr_payout_r() { - switch (Mask) - { - case 0x01: - return ((m_port_payout->read() & Mask) >> 0); - case 0x02: - return ((m_port_payout->read() & Mask) >> 1); - case 0x04: - return ((m_port_payout->read() & Mask) >> 2); - default: - logerror("starspnr_payout_r : invalid %02X bit_mask\n",Mask); - return 0; - } + if (Mask < 3) + return BIT(m_port_payout->read(), Mask); + + logerror("starspnr_payout_r : invalid %02X bit_mask\n",Mask); + return 0; } void acefruit_state::acefruit_colorram_w(offs_t offset, uint8_t data) @@ -373,14 +351,14 @@ static INPUT_PORTS_START( sidewndr ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME( "Cancel/Clear" ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME( "Refill" ) PORT_TOGGLE PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 ) /* "Token in" - also "Refill" when "Refill" mode ON */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, sidewndr_payout_r<0x01>) + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, sidewndr_payout_r<0x00>) PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("IN3") // 3 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME( "Hold/Nudge 1" ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME( "Accountancy System" ) PORT_TOGGLE PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN4 ) /* "50P in" */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, sidewndr_payout_r<0x02>) + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, sidewndr_payout_r<0x01>) PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("IN4") // 4 @@ -487,7 +465,7 @@ static INPUT_PORTS_START( starspnr ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME( "Collect/Cancel" ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 ) /* tested at 0xeed7 with IN1 bit 3 - before coins are tested - table at 0xef55 (4 * 3 bytes) */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x08>) /* to be confirmed */ + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x03>) /* to be confirmed */ PORT_START("IN2") // 2 /* tested at 0xe83c */ @@ -497,7 +475,7 @@ static INPUT_PORTS_START( starspnr ) /* tested at 0xef82 after IN5 bit 1 and after IN1 bit 3 - after coins are tested - table at 0xefa8 (3 bytes) */ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested at 0xeeba with IN3 bit 3 - before coins are tested - table at 0xef55 (4 * 3 bytes) */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x02>) /* to be confirmed */ + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x01>) /* to be confirmed */ /* tested at 0x1b0f */ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -506,7 +484,7 @@ static INPUT_PORTS_START( starspnr ) /* tested at 0xe8ea and 0xecbe */ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested at 0xeeba with IN2 bit 3 - before coins are tested - table at 0xef55 (4 * 3 bytes) */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x01>) /* to be confirmed */ + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x00>) /* to be confirmed */ /* tested at 0x0178 */ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -517,7 +495,7 @@ static INPUT_PORTS_START( starspnr ) /* tested at 0xed86 */ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested at 0xeed7 with IN1 bit 3 - before coins are tested - table at 0xef55 (4 * 3 bytes) */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x04>) /* to be confirmed */ + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_coinage_r<0x02>) /* to be confirmed */ PORT_START("IN5") // 5 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME( "Hold 3" ) @@ -526,7 +504,7 @@ static INPUT_PORTS_START( starspnr ) /* tested at 0xec6f */ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested at 0x1d60 with IN6 bit 3 and IN7 bit 3 - table at 0x1d90 (8 * 3 bytes) */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_payout_r<0x01>) /* to be confirmed */ + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_payout_r<0x00>) /* to be confirmed */ /* tested at 0xe312 and 0xe377 */ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -535,7 +513,7 @@ static INPUT_PORTS_START( starspnr ) /* tested at 0xee42, 0xee5e and 0xeff5 before IN1 bit 0 - invalid code after 0xf000 */ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested at 0x1d60 with IN5 bit 3 and IN7 bit 3 - table at 0x1d90 (8 * 3 bytes) */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_payout_r<0x02>) /* to be confirmed */ + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_payout_r<0x01>) /* to be confirmed */ /* tested at 0xe8dd and 0xec1c */ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -547,7 +525,7 @@ static INPUT_PORTS_START( starspnr ) /* tested at 0xedcb */ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* tested at 0x1d60 with IN5 bit 3 and IN6 bit 3 - table at 0x1d90 (8 * 3 bytes) */ - PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_payout_r<0x04>) /* to be confirmed */ + PORT_BIT( 0x08, 0x00, IPT_CUSTOM) PORT_READ_LINE_MEMBER(acefruit_state, starspnr_payout_r<0x02>) /* to be confirmed */ /* tested at 0xec2a */ PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) -- cgit v1.2.3