From af16147de79598292c2f11b1ea7d73cd4cd773ea Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 31 Aug 2023 21:49:31 -0400 Subject: [PATCH] sound/vrender0.cpp, video/ims_cvc.cpp: Use util::sext function --- src/devices/sound/vrender0.cpp | 11 +++-------- src/devices/video/ims_cvc.cpp | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/devices/sound/vrender0.cpp b/src/devices/sound/vrender0.cpp index 4178d98859a..a364ed8ef67 100644 --- a/src/devices/sound/vrender0.cpp +++ b/src/devices/sound/vrender0.cpp @@ -14,11 +14,6 @@ - Sample Rate is unverified *************************************************************************************/ -static inline s32 sign_ext(s32 val, s32 bit) -{ - bit = 32 - bit; - return ((s32)(val << bit)) >> bit; -} //Correct table thanks to Evoga //they left a ulaw<->linear conversion tool inside the roms @@ -460,7 +455,7 @@ void vr0sound_device::channel_t::write(offs_t offset, u16 data, u16 mem_mask) case 0x06/2: LD = data & 0x1000; EnvStage = (data & 0x0f00) >> 8; - EnvVol = sign_ext((EnvVol & 0x00ffff) | ((data << 16) & 0xff0000), 24); + EnvVol = util::sext((EnvVol & 0x00ffff) | ((data << 16) & 0xff0000), 24); break; case 0x08/2: dSAddr = data & 0xffff; @@ -492,8 +487,8 @@ void vr0sound_device::channel_t::write(offs_t offset, u16 data, u16 mem_mask) case 0x1e/2: EnvTarget[((offset - (0x1c/2)) * 2) + 0] = (data & 0x007f); EnvTarget[((offset - (0x1c/2)) * 2) + 1] = ((data & 0x7f00) >> 8); - EnvRate[((offset - (0x1c/2)) * 2) + 0] = sign_ext((EnvRate[((offset - (0x1c/2)) * 2) + 0] & 0xffff) | ((data & 0x0080) << 9), 17); - EnvRate[((offset - (0x1c/2)) * 2) + 1] = sign_ext((EnvRate[((offset - (0x1c/2)) * 2) + 1] & 0xffff) | ((data & 0x8000) << 1), 17); + EnvRate[((offset - (0x1c/2)) * 2) + 0] = util::sext((EnvRate[((offset - (0x1c/2)) * 2) + 0] & 0xffff) | ((data & 0x0080) << 9), 17); + EnvRate[((offset - (0x1c/2)) * 2) + 1] = util::sext((EnvRate[((offset - (0x1c/2)) * 2) + 1] & 0xffff) | ((data & 0x8000) << 1), 17); break; } } diff --git a/src/devices/video/ims_cvc.cpp b/src/devices/video/ims_cvc.cpp index b3abdba027a..31097027314 100644 --- a/src/devices/video/ims_cvc.cpp +++ b/src/devices/video/ims_cvc.cpp @@ -257,8 +257,8 @@ u32 g332_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, rect if (!(m_control_a & CURSOR_DISABLE)) { // get cursor origin - int const cursor_x = screen.visible_area().min_x + (s32(m_cursor_start << 8) >> 20); - int const cursor_y = screen.visible_area().min_y + (s32(m_cursor_start << 20) >> 20); + int const cursor_x = screen.visible_area().min_x + util::sext(m_cursor_start >> 12, 12); + int const cursor_y = screen.visible_area().min_y + util::sext(m_cursor_start, 12); // intersect cursor with screen rectangle cursor(cursor_x, cursor_x + 63, cursor_y, cursor_y + 63);