Add stubs and add getCodecType in sceAtrac

This commit is contained in:
raven02 2013-01-06 11:42:28 +08:00
parent 596dee2871
commit 8e950efff4
2 changed files with 115 additions and 5 deletions

View File

@ -116,6 +116,11 @@ template<int func(u32, int)> void WrapI_UI() {
RETURN(retval);
}
template<int func(u32, int, int, u32)> void WrapI_UIIU() {
int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
RETURN(retval);
}
template<u32 func(int, u32, int)> void WrapU_IUI() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
RETURN(retval);
@ -449,6 +454,10 @@ template<int func(int, u32, u32, u32, u32)> void WrapI_IUUUU() {
RETURN(retval);
}
template<int func(int, u32, int, int)> void WrapI_IUII() {
int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
RETURN(retval);
}
template<u32 func(u32, u32, u32, u32, u32)> void WrapU_UUUUU() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
RETURN(retval);

View File

@ -25,9 +25,13 @@
#include "sceKernel.h"
#include "sceUtility.h"
#define ATRAC_ERROR_API_FAIL 0x80630002
#define ATRAC_ERROR_ALL_DATA_DECODED 0x80630024
#define ATRAC_ERROR_API_FAIL 0x80630002
#define ATRAC_ERROR_ALL_DATA_DECODED 0x80630024
#define AT3_MAGIC 0x0270
#define AT3_PLUS_MAGIC 0xFFFE
#define PSP_MODE_AT_3_PLUS 0x00001000
#define PSP_MODE_AT_3 0x00001001
struct Atrac {
@ -44,6 +48,15 @@ Atrac *getAtrac(int atracID) {
}
}
int getCodecType(int addr) {
int at3magic = Memory::Read_U16(addr+20);
if (at3magic == AT3_MAGIC) {
return PSP_MODE_AT_3;
} else if (at3magic == AT3_PLUS_MAGIC) {
return PSP_MODE_AT_3_PLUS;
}
return 0;
}
u32 sceAtracGetAtracID(int codecType)
{
@ -65,7 +78,10 @@ u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd)
u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 finishFlagAddr, u32 remainAddr)
{
ERROR_LOG(HLE, "FAKE sceAtracDecodeData(%i, %08x, %08x, %08x, %08x)", atracID, outAddr, numSamplesAddr, finishFlagAddr, remainAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
Memory::Write_U16(0, outAddr); // Write a single 16-bit stereo
Memory::Write_U16(0, outAddr + 2);
@ -85,6 +101,10 @@ u32 sceAtracEndEntry()
u32 sceAtracGetBufferInfoForReseting(int atracID, int sample, u32 bufferInfoAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetBufferInfoForReseting(%i, %i, %08x)",atracID, sample, bufferInfoAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
// TODO: Write the right stuff instead.
Memory::Memset(bufferInfoAddr, 0, 32);
return 0;
@ -93,6 +113,10 @@ u32 sceAtracGetBufferInfoForReseting(int atracID, int sample, u32 bufferInfoAddr
u32 sceAtracGetBitrate(int atracID, u32 outBitrateAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetBitrate(%i, %08x)", atracID, outBitrateAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
if (Memory::IsValidAddress(outBitrateAddr))
Memory::Write_U32(64, outBitrateAddr);
return 0;
@ -101,6 +125,10 @@ u32 sceAtracGetBitrate(int atracID, u32 outBitrateAddr)
u32 sceAtracGetChannel(int atracID, u32 channelAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetChannel(%i, %08x)", atracID, channelAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
if (Memory::IsValidAddress(channelAddr))
Memory::Write_U32(2, channelAddr);
return 0;
@ -109,18 +137,32 @@ u32 sceAtracGetChannel(int atracID, u32 channelAddr)
u32 sceAtracGetLoopStatus(int atracID, u32 loopNbr, u32 statusAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetLoopStatus(%i, %08x, %08x)", atracID, loopNbr, statusAddr );
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
return 0;
}
u32 sceAtracGetInternalErrorInfo(int atracID, u32 errorAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetInternalErrorInfo(%i, %08x)", atracID, errorAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
if (Memory::IsValidAddress(errorAddr))
Memory::Write_U32(0, errorAddr);
return 0;
}
u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetMaxSample(%i, %08x)", atracID, maxSamplesAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
if (Memory::IsValidAddress(maxSamplesAddr))
Memory::Write_U32(1024, maxSamplesAddr);
return 0;
@ -129,6 +171,10 @@ u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr)
u32 sceAtracGetNextDecodePosition(int atracID, u32 outposAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetNextDecodePosition(%i, %08x)", atracID, outposAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
Memory::Write_U32(1, outposAddr); // outpos
return 0;
}
@ -136,6 +182,10 @@ u32 sceAtracGetNextDecodePosition(int atracID, u32 outposAddr)
u32 sceAtracGetNextSample(int atracID, u32 outNAddr)
{
ERROR_LOG(HLE, "FAKE sceAtracGetNextSample(%i, %08x)", atracID, outNAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
Memory::Write_U32(0, outNAddr);
return 0;
}
@ -143,6 +193,10 @@ u32 sceAtracGetNextSample(int atracID, u32 outNAddr)
u32 sceAtracGetRemainFrame(int atracID, u32 outposAddr)
{
ERROR_LOG(HLE, "sceAtracGetRemainFrame(%i, %08x)", atracID, outposAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
Memory::Write_U32(12, outposAddr); // outpos
return 0;
}
@ -150,6 +204,10 @@ u32 sceAtracGetRemainFrame(int atracID, u32 outposAddr)
u32 sceAtracGetSecondBufferInfo(int atracID, u32 outposAddr, u32 outBytesAddr)
{
ERROR_LOG(HLE, "sceAtracGetSecondBufferInfo(%i, %08x, %08x)", atracID, outposAddr, outBytesAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
Memory::Write_U32(0, outposAddr); // outpos
Memory::Write_U32(0x10000, outBytesAddr); // outBytes
return 0;
@ -158,6 +216,10 @@ u32 sceAtracGetSecondBufferInfo(int atracID, u32 outposAddr, u32 outBytesAddr)
u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSampleAddr, u32 outLoopEndSampleAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetSoundSample(%i, %08x, %08x, %08x)", atracID, outEndSampleAddr, outLoopStartSampleAddr, outLoopEndSampleAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
Memory::Write_U32(0x10000, outEndSampleAddr); // outEndSample
Memory::Write_U32(-1, outLoopStartSampleAddr); // outLoopStartSample
Memory::Write_U32(-1, outLoopEndSampleAddr); // outLoopEndSample
@ -167,6 +229,10 @@ u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSa
u32 sceAtracGetStreamDataInfo(int atracID, u32 writePointerAddr, u32 availableBytesAddr, u32 readOffsetAddr)
{
ERROR_LOG(HLE, "FAKE sceAtracGetStreamDataInfo(%i, %08x, %08x, %08x)", atracID, writePointerAddr, availableBytesAddr, readOffsetAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
Memory::Write_U32(0, readOffsetAddr);
Memory::Write_U32(0, availableBytesAddr);
Memory::Write_U32(0, writePointerAddr);
@ -182,6 +248,10 @@ u32 sceAtracReleaseAtracID(int atracID)
u32 sceAtracResetPlayPosition(int atracID, int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf)
{
ERROR_LOG(HLE, "UNIMPL sceAtracResetPlayPosition(%i, %i, %i, %i)", atracID, sample, bytesWrittenFirstBuf, bytesWrittenSecondBuf);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
return 0;
}
@ -194,6 +264,10 @@ u32 sceAtracSetHalfwayBuffer(int atracID, u32 halfBuffer, u32 readSize, u32 half
u32 sceAtracSetSecondBuffer(int atracID, u32 secondBuffer, u32 secondBufferSize)
{
ERROR_LOG(HLE, "UNIMPL sceAtracSetSecondBuffer(%i, %08x, %8x)", atracID, secondBuffer, secondBufferSize);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
return 0;
}
@ -206,12 +280,14 @@ u32 sceAtracSetData(int atracID, u32 buffer, u32 bufferSize)
int sceAtracSetDataAndGetID(u32 buffer, u32 bufferSize)
{
ERROR_LOG(HLE, "UNIMPL sceAtracSetDataAndGetID(%08x, %08x)", buffer, bufferSize);
int codecType = getCodecType(buffer);
return 0;
}
int sceAtracSetHalfwayBufferAndGetID(int atracID, u32 halfBuffer, u32 readSize, u32 halfBufferSize)
{
ERROR_LOG(HLE, "UNIMPL sceAtracSetHalfwayBufferAndGetID(%i, %08x, %08x, %08x)", atracID, halfBuffer, readSize, halfBufferSize);
int codecType = getCodecType(halfBuffer);
return 0;
}
@ -224,6 +300,10 @@ u32 sceAtracStartEntry()
u32 sceAtracSetLoopNum(int atracID, int loopNum)
{
ERROR_LOG(HLE, "UNIMPL sceAtracSetLoopNum(%i, %i)", atracID, loopNum);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
return 0;
}
@ -244,6 +324,27 @@ int sceAtracGetOutputChannel(int atracID, u32 outputChanPtr)
int sceAtracIsSecondBufferNeeded(int atracID)
{
ERROR_LOG(HLE, "UNIMPL sceAtracIsSecondBufferNeeded(%i)", atracID);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
return 0;
}
int sceAtracSetMOutHalfwayBuffer(int atracID, u32 MOutHalfBuffer, int readSize, int MOutHalfBufferSize)
{
ERROR_LOG(HLE, "UNIMPL sceAtracSetMOutHalfwayBuffer(%i, %08x, %i, %i)", atracID, MOutHalfBuffer, readSize, MOutHalfBufferSize);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {
return -1;
}
return 0;
}
int sceAtracSetAA3DataAndGetID(u32 buffer, int bufferSize, int fileSize, u32 metadataSizeAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracSetAA3DataAndGetID(%08x, %i, %i, %08x)", buffer, bufferSize, fileSize, metadataSizeAddr);
int codecType = getCodecType(buffer);
return 0;
}
@ -277,12 +378,12 @@ const HLEFunction sceAtrac3plus[] =
{0xeca32a99,WrapI_I<sceAtracIsSecondBufferNeeded>,"sceAtracIsSecondBufferNeeded"},
{0x0fae370e,WrapI_IUUU<sceAtracSetHalfwayBufferAndGetID>,"sceAtracSetHalfwayBufferAndGetID"},
{0x2DD3E298,WrapU_IIU<sceAtracGetBufferInfoForReseting>,"sceAtracGetBufferInfoForResetting"},
{0x5CF9D852,0,"sceAtracSetMOutHalfwayBuffer"},
{0x5CF9D852,WrapI_IUII<sceAtracSetMOutHalfwayBuffer>,"sceAtracSetMOutHalfwayBuffer"},
{0xB3B5D042,WrapI_IU<sceAtracGetOutputChannel>,"sceAtracGetOutputChannel"},
{0xF6837A1A,0,"sceAtracSetMOutData"},
{0x472E3825,0,"sceAtracSetMOutDataAndGetID"},
{0x9CD7DE03,0,"sceAtracSetMOutHalfwayBufferAndGetID"},
{0x5622B7C1,0,"sceAtracSetAA3DataAndGetID"},
{0x5622B7C1,WrapI_UIIU<sceAtracSetAA3DataAndGetID>,"sceAtracSetAA3DataAndGetID"},
{0x5DD66588,0,"sceAtracSetAA3HalfwayBufferAndGetID"},
};