Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10643 from Tilka/ax_cleanup
AX: fix missing ramp of main surround channel
  • Loading branch information
Tilka committed May 12, 2022
2 parents c41467a + e6e283a commit 333659c
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 52 deletions.
25 changes: 8 additions & 17 deletions Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp
Expand Up @@ -291,42 +291,33 @@ AXMixControl AXUCode::ConvertMixerControl(u32 mixer_control)
// TODO: find other UCode versions with different mixer_control values
if (m_crc == 0x4e8a8b21)
{
ret |= MIX_L | MIX_R;
ret |= MIX_MAIN_L | MIX_MAIN_R;
if (mixer_control & 0x0001)
ret |= MIX_AUXA_L | MIX_AUXA_R;
if (mixer_control & 0x0002)
ret |= MIX_AUXB_L | MIX_AUXB_R;
if (mixer_control & 0x0004)
{
ret |= MIX_S;
ret |= MIX_MAIN_S;
if (ret & MIX_AUXA_L)
ret |= MIX_AUXA_S;
if (ret & MIX_AUXB_L)
ret |= MIX_AUXB_S;
}
if (mixer_control & 0x0008)
{
ret |= MIX_L_RAMP | MIX_R_RAMP;
if (ret & MIX_AUXA_L)
ret |= MIX_AUXA_L_RAMP | MIX_AUXA_R_RAMP;
if (ret & MIX_AUXB_L)
ret |= MIX_AUXB_L_RAMP | MIX_AUXB_R_RAMP;
if (ret & MIX_AUXA_S)
ret |= MIX_AUXA_S_RAMP;
if (ret & MIX_AUXB_S)
ret |= MIX_AUXB_S_RAMP;
}
ret |= MIX_ALL_RAMPS;
}
else
{
// newer GameCube ucodes
if (mixer_control & 0x0001)
ret |= MIX_L;
ret |= MIX_MAIN_L;
if (mixer_control & 0x0002)
ret |= MIX_R;
ret |= MIX_MAIN_R;
if (mixer_control & 0x0004)
ret |= MIX_S;
ret |= MIX_MAIN_S;
if (mixer_control & 0x0008)
ret |= MIX_L_RAMP | MIX_R_RAMP | MIX_S_RAMP;
ret |= MIX_MAIN_L_RAMP | MIX_MAIN_R_RAMP | MIX_MAIN_S_RAMP;
if (mixer_control & 0x0010)
ret |= MIX_AUXA_L;
if (mixer_control & 0x0020)
Expand Down
38 changes: 21 additions & 17 deletions Source/Core/Core/HW/DSPHLE/UCodes/AX.h
Expand Up @@ -28,33 +28,37 @@ class DSPHLE;
// mixer_control value to an AXMixControl bitfield.
enum AXMixControl
{
MIX_L = 0x000001,
MIX_L_RAMP = 0x000002,
MIX_R = 0x000004,
MIX_R_RAMP = 0x000008,
MIX_S = 0x000010,
MIX_S_RAMP = 0x000020,

MIX_AUXA_L = 0x000040,
// clang-format off
MIX_MAIN_L = 0x000001,
MIX_MAIN_L_RAMP = 0x000002,
MIX_MAIN_R = 0x000004,
MIX_MAIN_R_RAMP = 0x000008,
MIX_MAIN_S = 0x000010,
MIX_MAIN_S_RAMP = 0x000020,

MIX_AUXA_L = 0x000040,
MIX_AUXA_L_RAMP = 0x000080,
MIX_AUXA_R = 0x000100,
MIX_AUXA_R = 0x000100,
MIX_AUXA_R_RAMP = 0x000200,
MIX_AUXA_S = 0x000400,
MIX_AUXA_S = 0x000400,
MIX_AUXA_S_RAMP = 0x000800,

MIX_AUXB_L = 0x001000,
MIX_AUXB_L = 0x001000,
MIX_AUXB_L_RAMP = 0x002000,
MIX_AUXB_R = 0x004000,
MIX_AUXB_R = 0x004000,
MIX_AUXB_R_RAMP = 0x008000,
MIX_AUXB_S = 0x010000,
MIX_AUXB_S = 0x010000,
MIX_AUXB_S_RAMP = 0x020000,

MIX_AUXC_L = 0x040000,
MIX_AUXC_L = 0x040000,
MIX_AUXC_L_RAMP = 0x080000,
MIX_AUXC_R = 0x100000,
MIX_AUXC_R = 0x100000,
MIX_AUXC_R_RAMP = 0x200000,
MIX_AUXC_S = 0x400000,
MIX_AUXC_S_RAMP = 0x800000
MIX_AUXC_S = 0x400000,
MIX_AUXC_S_RAMP = 0x800000,

MIX_ALL_RAMPS = 0xAAAAAA,
// clang-format on
};

class AXUCode : public UCodeInterface
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/Core/HW/DSPHLE/UCodes/AXStructs.h
Expand Up @@ -75,32 +75,32 @@ struct PBUpdates
// and ramped down on a per-sample basis to provide a gentle "roll off."
struct PBDpop
{
s16 left;
s16 main_left;
s16 auxA_left;
s16 auxB_left;

s16 right;
s16 main_right;
s16 auxA_right;
s16 auxB_right;

s16 surround;
s16 main_surround;
s16 auxA_surround;
s16 auxB_surround;
};

struct PBDpopWii
{
s16 left;
s16 main_left;
s16 auxA_left;
s16 auxB_left;
s16 auxC_left;

s16 right;
s16 main_right;
s16 auxA_right;
s16 auxB_right;
s16 auxC_right;

s16 surround;
s16 main_surround;
s16 auxA_surround;
s16 auxB_surround;
s16 auxC_surround;
Expand Down
40 changes: 33 additions & 7 deletions Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h
Expand Up @@ -428,44 +428,70 @@ void ProcessVoice(PB_TYPE& pb, const AXBuffers& buffers, u16 count, AXMixControl
#define MIX_ON(C) (0 != (mctrl & MIX_##C))
#define RAMP_ON(C) (0 != (mctrl & MIX_##C##_RAMP))

if (MIX_ON(L))
MixAdd(buffers.main_left, samples, count, &pb.mixer.main_left, &pb.dpop.left, RAMP_ON(L));
if (MIX_ON(R))
MixAdd(buffers.main_right, samples, count, &pb.mixer.main_right, &pb.dpop.right, RAMP_ON(R));
if (MIX_ON(S))
MixAdd(buffers.main_surround, samples, count, &pb.mixer.main_surround, &pb.dpop.surround,
RAMP_ON(S));
if (MIX_ON(MAIN_L))
{
MixAdd(buffers.main_left, samples, count, &pb.mixer.main_left, &pb.dpop.main_left,
RAMP_ON(MAIN_L));
}
if (MIX_ON(MAIN_R))
{
MixAdd(buffers.main_right, samples, count, &pb.mixer.main_right, &pb.dpop.main_right,
RAMP_ON(MAIN_R));
}
if (MIX_ON(MAIN_S))
{
MixAdd(buffers.main_surround, samples, count, &pb.mixer.main_surround, &pb.dpop.main_surround,
RAMP_ON(MAIN_S));
}

if (MIX_ON(AUXA_L))
{
MixAdd(buffers.auxA_left, samples, count, &pb.mixer.auxA_left, &pb.dpop.auxA_left,
RAMP_ON(AUXA_L));
}
if (MIX_ON(AUXA_R))
{
MixAdd(buffers.auxA_right, samples, count, &pb.mixer.auxA_right, &pb.dpop.auxA_right,
RAMP_ON(AUXA_R));
}
if (MIX_ON(AUXA_S))
{
MixAdd(buffers.auxA_surround, samples, count, &pb.mixer.auxA_surround, &pb.dpop.auxA_surround,
RAMP_ON(AUXA_S));
}

if (MIX_ON(AUXB_L))
{
MixAdd(buffers.auxB_left, samples, count, &pb.mixer.auxB_left, &pb.dpop.auxB_left,
RAMP_ON(AUXB_L));
}
if (MIX_ON(AUXB_R))
{
MixAdd(buffers.auxB_right, samples, count, &pb.mixer.auxB_right, &pb.dpop.auxB_right,
RAMP_ON(AUXB_R));
}
if (MIX_ON(AUXB_S))
{
MixAdd(buffers.auxB_surround, samples, count, &pb.mixer.auxB_surround, &pb.dpop.auxB_surround,
RAMP_ON(AUXB_S));
}

#ifdef AX_WII
if (MIX_ON(AUXC_L))
{
MixAdd(buffers.auxC_left, samples, count, &pb.mixer.auxC_left, &pb.dpop.auxC_left,
RAMP_ON(AUXC_L));
}
if (MIX_ON(AUXC_R))
{
MixAdd(buffers.auxC_right, samples, count, &pb.mixer.auxC_right, &pb.dpop.auxC_right,
RAMP_ON(AUXC_R));
}
if (MIX_ON(AUXC_S))
{
MixAdd(buffers.auxC_surround, samples, count, &pb.mixer.auxC_surround, &pb.dpop.auxC_surround,
RAMP_ON(AUXC_S));
}
#endif

#undef MIX_ON
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/HW/DSPHLE/UCodes/AXWii.cpp
Expand Up @@ -331,15 +331,15 @@ AXMixControl AXWiiUCode::ConvertMixerControl(u32 mixer_control)
u32 ret = 0;

if (mixer_control & 0x00000001)
ret |= MIX_L;
ret |= MIX_MAIN_L;
if (mixer_control & 0x00000002)
ret |= MIX_R;
ret |= MIX_MAIN_R;
if (mixer_control & 0x00000004)
ret |= MIX_L_RAMP | MIX_R_RAMP;
ret |= MIX_MAIN_L_RAMP | MIX_MAIN_R_RAMP;
if (mixer_control & 0x00000008)
ret |= MIX_S;
ret |= MIX_MAIN_S;
if (mixer_control & 0x00000010)
ret |= MIX_S_RAMP;
ret |= MIX_MAIN_S_RAMP;
if (mixer_control & 0x00010000)
ret |= MIX_AUXA_L;
if (mixer_control & 0x00020000)
Expand Down

0 comments on commit 333659c

Please sign in to comment.