diff --git a/src/ucode1.c b/src/ucode1.c index ef67d98..3411761 100644 --- a/src/ucode1.c +++ b/src/ucode1.c @@ -343,38 +343,23 @@ static void RESAMPLE(uint32_t w1, uint32_t w2) static void SETVOL(uint32_t w1, uint32_t w2) { - /* Might be better to unpack these depending on the flags... */ - uint8_t flags = (uint8_t)((w1 >> 16) & 0xff); - uint16_t vol = (int16_t)(w1 & 0xffff); - uint16_t volrate = (uint16_t)((w2 & 0xffff)); + uint8_t flags = (w1 >> 16); if (flags & A_AUX) { - l_alist.dry = (int16_t)vol; /* m_MainVol */ - l_alist.wet = (int16_t)volrate; /* m_AuxVol */ - return; + l_alist.dry = w1; + l_alist.wet = w2; } + else { + unsigned lr = (flags & A_LEFT) ? 0 : 1; - /* Set the Source(start) Volumes */ - if (flags & A_VOL) { - if (flags & A_LEFT) - l_alist.vol[0] = (int16_t)vol; - else - /* A_RIGHT */ - l_alist.vol[1] = (int16_t)vol; - return; - } - - /* 0x370 Loop Value (shared location) - * 0x370 Target Volume (Left) - */ - - /* Set the Ramping values Target, Ramp */ - if (flags & A_LEFT) { - l_alist.target[0] = (int16_t)w1; - l_alist.rate[0] = (int32_t)w2; - } else { /* A_RIGHT */ - l_alist.target[1] = (int16_t)w1; - l_alist.rate[1] = (int32_t)w2; + if (flags & A_VOL) { + l_alist.vol[lr] = w1; + l_alist.vol[lr] = w2; + } + else { + l_alist.target[lr] = w1; + l_alist.rate[lr] = w2; + } } } diff --git a/src/ucode3.c b/src/ucode3.c index e0f8685..43b0110 100644 --- a/src/ucode3.c +++ b/src/ucode3.c @@ -48,19 +48,22 @@ static struct { static void SETVOL3(uint32_t w1, uint32_t w2) { - uint8_t Flags = (uint8_t)(w1 >> 0x10); - if (Flags & 0x4) { /* 288 */ - if (Flags & 0x2) { /* 290 */ - l_alist.vol[0] = (int16_t)w1; /* 0x50 */ - l_alist.dry = (int16_t)(w2 >> 0x10); /* 0x4E */ - l_alist.wet = (int16_t)w2; /* 0x4C */ - } else { - l_alist.target[1] = (int16_t)w1; /* 0x46 */ - l_alist.rate[1] = (int32_t)w2; /* 0x48/0x4A */ + uint8_t flags = (w1 >> 16); + + if (flags & 0x4) { + if (flags & 0x2) { + l_alist.vol[0] = w1; + l_alist.dry = (w2 >> 16); + l_alist.wet = w2; } - } else { - l_alist.target[0] = (int16_t)w1; /* 0x40 */ - l_alist.rate[0] = (int32_t)w2; /* 0x42/0x44 */ + else { + l_alist.target[1] = w1; + l_alist.rate[1] = w2; + } + } + else { + l_alist.target[0] = w1; + l_alist.rate[0] = w2; } }