From eb1d4f8ad755caa3db522bdb98ee16bea88dc24d Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 9 Nov 2023 10:13:47 -0500 Subject: namco/ygv608.cpp, sega/saturn_v.cpp, seibu/seibuspi_v.cpp: Use util::sext for sign extension --- src/mame/namco/ygv608.cpp | 6 ++---- src/mame/sega/saturn_v.cpp | 10 +++------- src/mame/seibu/seibuspi_v.cpp | 8 ++------ 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/mame/namco/ygv608.cpp b/src/mame/namco/ygv608.cpp index ad6cc77242a..b05db8a42a8 100644 --- a/src/mame/namco/ygv608.cpp +++ b/src/mame/namco/ygv608.cpp @@ -2295,8 +2295,7 @@ inline uint32_t ygv608_device::roz_convert_raw24(uint32_t *raw_reg, uint8_t offs // convert raw to the given register res = *raw_reg & roz_data_mask24; - res <<= 7; - if( res & 0x08000000 ) res |= 0xf8000000; // 2s complement + res = util::sext(res << 7, 28); return res; } @@ -2313,8 +2312,7 @@ inline uint32_t ygv608_device::roz_convert_raw16(uint16_t *raw_reg, uint8_t offs // convert raw to the given register res = *raw_reg & roz_data_mask16; - res <<= 7; - if( res & 0x00080000 ) res |= 0xfff80000; // 2s complement + res = util::sext(res << 7, 20); return res; } diff --git a/src/mame/sega/saturn_v.cpp b/src/mame/sega/saturn_v.cpp index 5ddf63124a1..b5c6135934f 100644 --- a/src/mame/sega/saturn_v.cpp +++ b/src/mame/sega/saturn_v.cpp @@ -6373,9 +6373,7 @@ void saturn_state::stv_vdp2_draw_basic_tilemap(bitmap_rgb32 &bitmap, const recta #define STV_VDP2_READ_VERTICAL_LINESCROLL( _val, _address ) \ { \ - _val = m_vdp2_vram[ _address ]; \ - _val &= 0x07ffff00; \ - if ( _val & 0x04000000 ) _val |= 0xf8000000; \ + _val = util::sext(m_vdp2_vram[ _address ] & 0x07ffff00, 27); \ } @@ -6478,8 +6476,7 @@ void saturn_state::stv_vdp2_check_tilemap_with_linescroll(bitmap_rgb32 &bitmap, // linescroll if ( linescroll_enable ) { - prev_scroll_values[i] &= 0x07ffff00; - if ( prev_scroll_values[i] & 0x04000000 ) prev_scroll_values[i] |= 0xf8000000; + prev_scroll_values[i] = util::sext(prev_scroll_values[i] & 0x07ffff00, 27); stv2_current_tilemap.scrollx = main_scrollx + (prev_scroll_values[i] >> 16); i++; } @@ -6493,8 +6490,7 @@ void saturn_state::stv_vdp2_check_tilemap_with_linescroll(bitmap_rgb32 &bitmap, // linezooom if ( linezoom_enable ) { - prev_scroll_values[i] &= 0x0007ff00; - if ( prev_scroll_values[i] & 0x00040000 ) prev_scroll_values[i] |= 0xfff80000; + prev_scroll_values[i] = util::sext(prev_scroll_values[i] & 0x0007ff00, 19); stv2_current_tilemap.incx = prev_scroll_values[i]; i++; } diff --git a/src/mame/seibu/seibuspi_v.cpp b/src/mame/seibu/seibuspi_v.cpp index eaa814ead5c..bce277f4164 100644 --- a/src/mame/seibu/seibuspi_v.cpp +++ b/src/mame/seibu/seibuspi_v.cpp @@ -512,12 +512,8 @@ void seibuspi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprec continue; const u8 primask = 1 << priority; - s16 xpos = m_sprite_ram[a + 1] & 0x3ff; - if (xpos & 0x200) - xpos |= 0xfc00; - s16 ypos = m_sprite_ram[a + 1] >> 16 & 0x1ff; - if (ypos & 0x100) - ypos |= 0xfe00; + s16 xpos = util::sext(m_sprite_ram[a + 1], 10); + s16 ypos = util::sext(m_sprite_ram[a + 1] >> 16, 9); const int color = m_sprite_ram[a + 0] & 0x3f; int width = (m_sprite_ram[a + 0] >> 8 & 0x7) + 1; -- cgit v1.2.3