Skip to content

Commit

Permalink
Merge pull request #134 from jacky400/master
Browse files Browse the repository at this point in the history
sceSas Full Wrap
  • Loading branch information
hrydgard committed Dec 6, 2012
2 parents e327eea + 223a3b0 commit e1aa287
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 58 deletions.
16 changes: 16 additions & 0 deletions Core/HLE/FunctionWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ template<u32 func(u32, u32)> void WrapU_UU() {
RETURN(retval);
}

template<void func(u32, int, u32, int, int)> void WrapV_UIUII() {
func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
}

template<void func(u32, int, int, int)> void WrapV_UIII() {
func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
}

template<void func(u32, int, int, int, int, int)> void WrapV_UIIIII() {
func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5));
}

template<void func(u32, int, int)> void WrapV_UII() {
func(PARAM(0), PARAM(1), PARAM(2));
}

template<u32 func(int, u32)> void WrapU_IU() {
int retval = func(PARAM(0), PARAM(1));
RETURN(retval);
Expand Down
83 changes: 25 additions & 58 deletions Core/HLE/sceSas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ struct Voice
int releaseType;
int pitch;
bool endFlag;
bool PauseFlag;
bool playing;

VagDecoder vag;
Expand Down Expand Up @@ -215,31 +216,24 @@ u32 sceSasGetEndFlag()
}

// Runs the mixer
void _sceSasCore()
void _sceSasCore(u32 outAddr)
{
u32 outAddr = PARAM(1);
DEBUG_LOG(HLE,"0=sceSasCore(, %08x) (grain: %i samples)", outAddr, sas.grainSize);
Memory::Memset(outAddr, 0, sas.grainSize * 2 * 2);
sas.mix(outAddr);
RETURN(0);
}

// Another way of running the mixer, what was the difference again?
void _sceSasCoreWithMix()
void _sceSasCoreWithMix(u32 outAddr)
{
u32 outAddr = PARAM(1);
DEBUG_LOG(HLE,"0=sceSasCoreWithMix(, %08x)", outAddr);
sas.mix(outAddr);
RETURN(0);
}

void sceSasSetVoice()
void sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop)
{
u32 core = PARAM(0);
int voiceNum = PARAM(1);
u32 vagAddr = PARAM(2);
int size = PARAM(3);
int loop = PARAM(4);
DEBUG_LOG(HLE,"0=sceSasSetVoice(core=%08x, voicenum=%i, vag=%08x, size=%i, loop=%i)",
core, voiceNum, vagAddr, size, loop);

Expand All @@ -252,36 +246,25 @@ void sceSasSetVoice()
RETURN(0);
}

void sceSasSetVolume()
void sceSasSetVolume(u32 core, int voiceNum, int l, int r, int el, int er)
{
u32 core = PARAM(0);
int voiceNum = PARAM(1);
int l = PARAM(2);
int r = PARAM(3);
int el = PARAM(4);
int er = PARAM(5);
DEBUG_LOG(HLE,"UNIMPL 0=sceSasSetVolume(core=%08x, voicenum=%i, l=%i, r=%i, el=%i, er=%i", core, voiceNum, l, r, el, er);
Voice &v = sas.voices[voiceNum];
v.volumeLeft = l;
v.volumeRight = r;
RETURN(0);
}

void sceSasSetPitch()
void sceSasSetPitch(u32 core, int voiceNum, int pitch)
{
u32 core = PARAM(0);
int voiceNum = PARAM(1);
int pitch = PARAM(2);
Voice &v = sas.voices[voiceNum];
v.pitch = pitch;
DEBUG_LOG(HLE,"UNIMPL 0=sceSasSetPitch(core=%08x, voicenum=%i, pitch=%i)", core, voiceNum, pitch);
RETURN(0);
}

void sceSasSetKeyOn()
void sceSasSetKeyOn(u32 core, int voiceNum)
{
u32 core = PARAM(0);
int voiceNum = PARAM(1);
DEBUG_LOG(HLE,"0=sceSasSetKeyOff(core=%08x, voicenum=%i)", core, voiceNum);
Voice &v = sas.voices[voiceNum];
v.vag.Start(Memory::GetPointer(v.vagAddr));
Expand All @@ -291,10 +274,8 @@ void sceSasSetKeyOn()

// TODO: We really need ADSR work:
// sceSasSetKeyOff can be used to start sounds, that just sound during the Release phase!
void sceSasSetKeyOff()
void sceSasSetKeyOff(u32 core, int voiceNum)
{
u32 core = PARAM(0);
int voiceNum = PARAM(1);
DEBUG_LOG(HLE,"0=sceSasSetKeyOff(core=%08x, voicenum=%i)", core, voiceNum);
Voice &v = sas.voices[voiceNum];
v.playing = false; // not right! Should directly enter Release envelope stage instead!
Expand Down Expand Up @@ -346,19 +327,14 @@ u32 sceSasGetEnvelopeHeight(u32 core, u32 voiceNum)
return v.playing ? 0x3fffffff : 0;
}

void sceSasRevType()
void sceSasRevType(u32 core, int type)
{
u32 core = PARAM(0);
int type = PARAM(1);
DEBUG_LOG(HLE,"UNIMPL 0=sceSasRevType(core=%08x, type=%i)", core, type);
RETURN(0);
}

void sceSasRevParam()
void sceSasRevParam(u32 core, int param1, int param2)
{
u32 core = PARAM(0);
int param1 = PARAM(1);
int param2 = PARAM(2);
DEBUG_LOG(HLE,"UNIMPL 0=sceSasRevParam(core=%08x, param1=%i, param2=%i)", core, param1, param2);
RETURN(0);
}
Expand All @@ -376,29 +352,20 @@ u32 sceSasGetPauseFlag()



void sceSasRevEVOL()
void sceSasRevEVOL(u32 core, int param1, int param2)
{
u32 core = PARAM(0);
int param1 = PARAM(1);
int param2 = PARAM(2);
DEBUG_LOG(HLE,"UNIMPL 0=sceSasRevEVOL(core=%08x, param1=%i, param2=%i)", core, param1, param2);
RETURN(0);
}

void sceSasRevVON()
void sceSasRevVON(u32 core, int param1, int param2)
{
u32 core = PARAM(0);
int param1 = PARAM(1);
int param2 = PARAM(2);
DEBUG_LOG(HLE,"UNIMPL 0=sceSasRevEVOL(core=%08x, param1=%i, param2=%i)", core, param1, param2);
RETURN(0);
}

void sceSasGetOutputMode()
void sceSasGetOutputMode(u32 core, int param1, int param2)
{
u32 core = PARAM(0);
int param1 = PARAM(1);
int param2 = PARAM(2);
DEBUG_LOG(HLE,"UNIMPL 0=sceSasGetOutputMode(core=%08x, param1=%i, param2=%i)", core, param1, param2);
RETURN(0);
}
Expand All @@ -407,31 +374,31 @@ void sceSasGetOutputMode()
const HLEFunction sceSasCore[] =
{
{0x42778a9f, WrapU_UUUUU<sceSasInit>, "__sceSasInit"}, // (SceUID * sasCore, int grain, int maxVoices, int outputMode, int sampleRate)
{0xa3589d81, _sceSasCore, "__sceSasCore"},
{0x50a14dfc, _sceSasCoreWithMix, "__sceSasCoreWithMix"}, // Process and mix into buffer (int sasCore, int sasInOut, int leftVolume, int rightVolume)
{0xa3589d81, WrapV_U<_sceSasCore>, "__sceSasCore"},
{0x50a14dfc, WrapV_U<_sceSasCoreWithMix>, "__sceSasCoreWithMix"}, // Process and mix into buffer (int sasCore, int sasInOut, int leftVolume, int rightVolume)
{0x68a46b95, WrapU_V<sceSasGetEndFlag>, "__sceSasGetEndFlag"}, // int sasCore
{0x440ca7d8, sceSasSetVolume, "__sceSasSetVolume"},
{0xad84d37f, sceSasSetPitch, "__sceSasSetPitch"},
{0x99944089, sceSasSetVoice, "__sceSasSetVoice"}, // (int sasCore, int voice, int vagAddr, int size, int loopmode)
{0x440ca7d8, WrapV_UIIIII<sceSasSetVolume>, "__sceSasSetVolume"},
{0xad84d37f, WrapV_UII<sceSasSetPitch>, "__sceSasSetPitch"},
{0x99944089, WrapV_UIUII<sceSasSetVoice>, "__sceSasSetVoice"}, // (int sasCore, int voice, int vagAddr, int size, int loopmode)
{0xb7660a23, 0, "__sceSasSetNoise"},
{0x019b25eb, WrapU_UIIIIII<sceSasSetADSR>, "__sceSasSetADSR"},
{0x9ec3676a, WrapU_UIIIIII<sceSasSetADSRMode>, "__sceSasSetADSRmode"},
{0x5f9529f6, 0, "__sceSasSetSL"},
{0x74ae582a, WrapU_UU<sceSasGetEnvelopeHeight>, "__sceSasGetEnvelopeHeight"},
{0xcbcd4f79, WrapU_UUUU<sceSasSetSimpleADSR>, "__sceSasSetSimpleADSR"},
{0xa0cf2fa4, sceSasSetKeyOff, "__sceSasSetKeyOff"},
{0x76f01aca, sceSasSetKeyOn, "__sceSasSetKeyOn"}, // (int sasCore, int voice)
{0xf983b186, sceSasRevVON, "__sceSasRevVON"}, // int sasCore, int dry, int wet
{0xd5a229c9, sceSasRevEVOL, "__sceSasRevEVOL"}, // (int sasCore, int leftVol, int rightVol) // effect volume
{0x33d4ab37, sceSasRevType, "__sceSasRevType"}, // (int sasCore, int type)
{0x267a6dd2, sceSasRevParam, "__sceSasRevParam"}, // (int sasCore, int delay, int feedback)
{0xa0cf2fa4, WrapV_UI<sceSasSetKeyOff>, "__sceSasSetKeyOff"},
{0x76f01aca, WrapV_UI<sceSasSetKeyOn>, "__sceSasSetKeyOn"}, // (int sasCore, int voice)
{0xf983b186, WrapV_UII<sceSasRevVON>, "__sceSasRevVON"}, // int sasCore, int dry, int wet
{0xd5a229c9, WrapV_UII<sceSasRevEVOL>, "__sceSasRevEVOL"}, // (int sasCore, int leftVol, int rightVol) // effect volume
{0x33d4ab37, WrapV_UI<sceSasRevType>, "__sceSasRevType"}, // (int sasCore, int type)
{0x267a6dd2, WrapV_UII<sceSasRevParam>, "__sceSasRevParam"}, // (int sasCore, int delay, int feedback)
{0x2c8e6ab3, WrapU_V<sceSasGetPauseFlag>, "__sceSasGetPauseFlag"}, // int sasCore
{0x787d04d5, 0, "__sceSasSetPause"},
{0xa232cbe6, 0, "__sceSasSetTriangularWave"}, // (int sasCore, int voice, int unknown)
{0xd5ebbbcd, 0, "__sceSasSetSteepWave"}, // (int sasCore, int voice, int unknown) // square wave?
{0xBD11B7C2, 0, "__sceSasGetGrain"},
{0xd1e0a01e, 0, "__sceSasSetGrain"},
{0xe175ef66, sceSasGetOutputMode, "__sceSasGetOutputmode"},
{0xe175ef66, WrapV_UII<sceSasGetOutputMode>, "__sceSasGetOutputmode"},
{0xe855bf76, 0, "__sceSasSetOutputmode"},
{0x07f58c24, 0, "__sceSasGetAllEnvelopeHeights"}, // (int sasCore, int heightAddr) 32-bit heights, 0-0x40000000
{0xE1CD9561, 0, "__sceSasSetVoicePCM"},
Expand Down

0 comments on commit e1aa287

Please sign in to comment.