Merge branch 'master', remote-tracking branch 'origin'

This commit is contained in:
Henrik Rydgard 2012-11-28 10:38:22 +01:00
commit 52572d92e6
21 changed files with 332 additions and 178 deletions

View File

@ -1,3 +1,4 @@
# vim:noexpandtab:
cmake_minimum_required(VERSION 2.8.8)
project(PPSSPP)
@ -23,7 +24,7 @@ else() # Assume x86
set(X86 ON)
endif()
if(ARM OR APPLE)
if(ANDROID OR BLACKBERRY OR IOS)
set(HEADLESS OFF)
elseif(NOT DEFINED HEADLESS)
set(HEADLESS ON)
@ -69,6 +70,9 @@ else()
endif()
include(FindSDL)
include(FindThreads)
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
endif()
# Needed for Globals.h
include_directories("${CMAKE_SOURCE_DIR}")
@ -815,7 +819,8 @@ endif()
if(HEADLESS)
add_executable(PPSSPPHeadless headless/Headless.cpp)
target_link_libraries(PPSSPPHeadless ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(PPSSPPHeadless ${CoreLibName}
${COCOA_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
setup_target_project(PPSSPPHeadless headless)
endif()
@ -848,7 +853,6 @@ if(SDL_FOUND)
set(SDL_Main ${SDL_Main}
SDL/SDLMain.h
SDL/SDLMain.mm)
find_library(COCOA_LIBRARY Cocoa)
set(LinkCommon ${LinkCommon} ${COCOA_LIBRARY})
endif()

View File

@ -35,17 +35,16 @@ std::string DirectoryFileSystem::GetLocalPath(std::string localpath)
if (localpath.empty())
return basePath;
if (localpath[0] == '/')
localpath.erase(0,1);
if (localpath[0] == '/')
localpath.erase(0,1);
//Convert slashes
#ifdef _WIN32
for (size_t i = 0; i < localpath.size(); i++)
{
if (localpath[i] == '/')
localpath[i] = '\\';
}
}
#endif
return basePath + localpath;
}
@ -56,8 +55,8 @@ bool DirectoryFileSystem::MkDir(const std::string &dirname)
#ifdef _WIN32
return CreateDirectory(fullName.c_str(), NULL) == TRUE;
#else
mkdir(fullName.c_str(), 0777);
return true;
mkdir(fullName.c_str(), 0777);
return true;
#endif
}
@ -67,7 +66,26 @@ bool DirectoryFileSystem::RmDir(const std::string &dirname)
#ifdef _WIN32
return RemoveDirectory(fullName.c_str()) == TRUE;
#else
return 0 == rmdir(fullName.c_str());
return 0 == rmdir(fullName.c_str());
#endif
}
bool DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to)
{
std::string fullFrom = GetLocalPath(from);
std::string fullTo = to;
// TO filename may not include path. Intention is that it uses FROM's path
if (to.find("/") != std::string::npos) {
int offset = from.find_last_of("/");
if (offset >= 0) {
fullTo = from.substr(0, offset + 1) + to;
}
}
fullTo = GetLocalPath(fullTo);
#ifdef _WIN32
return MoveFile(fullFrom.c_str(), fullTo.c_str()) == TRUE;
#else
return 0 == rename(fullFrom.c_str(), fullTo.c_str());
#endif
}
@ -77,7 +95,7 @@ bool DirectoryFileSystem::DeleteFile(const std::string &filename)
#ifdef _WIN32
return DeleteFile(fullName.c_str()) == TRUE;
#else
return 0 == unlink(fullName.c_str());
return 0 == unlink(fullName.c_str());
#endif
}
@ -243,7 +261,7 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename)
x.name = filename;
std::string fullName = GetLocalPath(filename);
std::string fullName = GetLocalPath(filename);
if (!File::Exists(fullName)) {
return x;
}
@ -257,8 +275,8 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename)
x.size = data.nFileSizeLow | ((u64)data.nFileSizeHigh<<32);
#else
x.size = File::GetSize(fullName);
//TODO
x.size = File::GetSize(fullName);
//TODO
#endif
return x;

View File

@ -36,7 +36,7 @@ class DirectoryFileSystem : public IFileSystem
#ifdef _WIN32
HANDLE hFile;
#else
FILE *hFile;
FILE *hFile;
#endif
};
@ -61,6 +61,7 @@ public:
bool OwnsHandle(u32 handle);
bool MkDir(const std::string &dirname);
bool RmDir(const std::string &dirname);
bool RenameFile(const std::string &from, const std::string &to);
bool DeleteFile(const std::string &filename);
};

View File

@ -83,6 +83,7 @@ public:
virtual bool OwnsHandle(u32 handle) = 0;
virtual bool MkDir(const std::string &dirname) = 0;
virtual bool RmDir(const std::string &dirname) = 0;
virtual bool RenameFile(const std::string &from, const std::string &to) = 0;
virtual bool DeleteFile(const std::string &filename) = 0;
};
@ -100,6 +101,7 @@ public:
bool OwnsHandle(u32 handle) {return false;}
virtual bool MkDir(const std::string &dirname) {return false;}
virtual bool RmDir(const std::string &dirname) {return false;}
virtual bool RenameFile(const std::string &from, const std::string &to) {return false;}
virtual bool DeleteFile(const std::string &filename) {return false;}
};

View File

@ -82,5 +82,6 @@ public:
virtual bool MkDir(const std::string &dirname) {return false;}
virtual bool RmDir(const std::string &dirname) {return false;}
virtual bool RenameFile(const std::string &from, const std::string &to) {return false;}
virtual bool DeleteFile(const std::string &filename) {return false;}
};

View File

@ -177,6 +177,21 @@ bool MetaFileSystem::RmDir(const std::string &dirname)
}
}
bool MetaFileSystem::RenameFile(const std::string &from, const std::string &to)
{
std::string of;
std::string rf;
IFileSystem *system;
if (MapFilePath(from, of, &system) && MapFilePath(to, rf, &system))
{
return system->RenameFile(of, rf);
}
else
{
return false;
}
}
bool MetaFileSystem::DeleteFile(const std::string &filename)
{
std::string of;

View File

@ -56,6 +56,7 @@ public:
virtual bool MkDir(const std::string &dirname);
virtual bool RmDir(const std::string &dirname);
virtual bool RenameFile(const std::string &from, const std::string &to);
virtual bool DeleteFile(const std::string &filename);
// TODO: void IoCtl(...)

View File

@ -256,3 +256,13 @@ template<u32 func(u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUU() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5));
RETURN(retval);
}
template<int func(int, u32, u32, u32)> void WrapI_IUUU() {
int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
RETURN(retval);
}
template<int func(int, u32, u32)> void WrapI_IUU() {
int retval = func(PARAM(0), PARAM(1), PARAM(2));
RETURN(retval);
}

View File

@ -28,19 +28,14 @@
#define ATRAC_ERROR_API_FAIL 0x80630002
#define ATRAC_ERROR_ALL_DATA_DECODED 0x80630024
void sceAtracAddStreamData()
int sceAtracAddStreamData(int atracID, u32 bytesToAdd)
{
ERROR_LOG(HLE, "UNIMPL sceAtracAddStreamData(%i, %i)", PARAM(0), PARAM(1));
RETURN(0);
ERROR_LOG(HLE, "UNIMPL sceAtracAddStreamData(%i, %i)", atracID, bytesToAdd);
return 0;
}
void sceAtracDecodeData()
int sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 finishFlagAddr, u32 remainAddr)
{
u32 atracID = PARAM(0);
u32 outAddr = PARAM(1);
u32 numSamplesAddr = PARAM(2);
u32 finishFlagAddr = PARAM(3);
u32 remainAddr = PARAM(4);
ERROR_LOG(HLE, "FAKE sceAtracDecodeData(%i, %08x, %08x, %08x, %08x)", atracID, outAddr, numSamplesAddr, finishFlagAddr, remainAddr);
Memory::Write_U16(0, outAddr); // Write a single 16-bit stereo
@ -50,7 +45,7 @@ void sceAtracDecodeData()
Memory::Write_U32(1, finishFlagAddr); // Lie that decoding is finished
Memory::Write_U32(0, remainAddr); // Lie that decoding is finished
RETURN(0);
return 0;
}
void sceAtracEndEntry()
@ -71,10 +66,10 @@ void sceAtracGetBufferInfoForReseting()
RETURN(0);
}
void sceAtracGetBitrate()
int sceAtracGetBitrate(int atracID, u32 outBitrateAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetBitrate");
RETURN(0);
return 0;
}
void sceAtracGetChannel()
@ -101,64 +96,51 @@ void sceAtracGetMaxSample()
RETURN(0);
}
void sceAtracGetNextDecodePosition()
int sceAtracGetNextDecodePosition(int atracID, u32 outposAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetNextDecodePosition(%i, %08x)", PARAM(0), PARAM(1));
u32 *outPos = (u32*)Memory::GetPointer(PARAM(1));
*outPos = 1;
RETURN(0);
ERROR_LOG(HLE, "UNIMPL sceAtracGetNextDecodePosition(%i, %08x)", atracID, outposAddr);
Memory::Write_U32(1, outposAddr); // outpos
return 0;
}
void sceAtracGetNextSample()
int sceAtracGetNextSample(int atracID, u32 outNAddr)
{
u32 atracID = PARAM(0);
u32 outN = PARAM(1);
ERROR_LOG(HLE, "FAKE sceAtracGetNextSample(%i, %08x)", atracID, outN);
Memory::Write_U32(0, outN);
RETURN(0);
ERROR_LOG(HLE, "FAKE sceAtracGetNextSample(%i, %08x)", atracID, outNAddr);
Memory::Write_U32(0, outNAddr);
return 0;
}
void sceAtracGetRemainFrame()
int sceAtracGetRemainFrame(int atracID, u32 outposAddr)
{
ERROR_LOG(HLE, "sceAtracGetRemainFrame(%i, %08x)",PARAM(0),PARAM(1));
u32 *outPos = (u32*)Memory::GetPointer(PARAM(1));
*outPos = 12;
RETURN(0);
ERROR_LOG(HLE, "sceAtracGetRemainFrame(%i, %08x)", atracID, outposAddr);
Memory::Write_U32(12, outposAddr); // outpos
return 0;
}
void sceAtracGetSecondBufferInfo()
int sceAtracGetSecondBufferInfo(int atracID, u32 outposAddr, u32 outBytesAddr)
{
ERROR_LOG(HLE, "sceAtracGetSecondBufferInfo(%i, %08x, %08x)",PARAM(0),PARAM(1),PARAM(2));
u32 *outPos = (u32*)Memory::GetPointer(PARAM(1));
u32 *outBytes = (u32*)Memory::GetPointer(PARAM(2));
*outPos = 0;
*outBytes = 0x10000;
RETURN(0);
ERROR_LOG(HLE, "sceAtracGetSecondBufferInfo(%i, %08x, %08x)", atracID, outposAddr, outBytesAddr);
Memory::Write_U32(0, outposAddr); // outpos
Memory::Write_U32(0x10000, outBytesAddr); // outBytes
return 0;
}
void sceAtracGetSoundSample()
int sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSampleAddr, u32 outLoopEndSampleAddr)
{
ERROR_LOG(HLE, "UNIMPL sceAtracGetSoundSample(%i, %08x, %08x, %08x)",PARAM(0),PARAM(1),PARAM(2),PARAM(3));
u32 *outEndSample = (u32*)Memory::GetPointer(PARAM(1));
u32 *outLoopStartSample = (u32*)Memory::GetPointer(PARAM(2));
u32 *outLoopEndSample = (u32*)Memory::GetPointer(PARAM(2));
*outEndSample = 0x10000;
*outLoopStartSample = -1;
*outLoopEndSample = -1;
RETURN(0);
ERROR_LOG(HLE, "UNIMPL sceAtracGetSoundSample(%i, %08x, %08x, %08x)", atracID, outEndSampleAddr, outLoopStartSampleAddr, outLoopEndSampleAddr);
Memory::Write_U32(0x10000, outEndSampleAddr); // outEndSample
Memory::Write_U32(-1, outLoopStartSampleAddr); // outLoopStartSample
Memory::Write_U32(-1, outLoopEndSampleAddr); // outLoopEndSample
return 0;
}
void sceAtracGetStreamDataInfo()
int sceAtracGetStreamDataInfo(int atracID, u32 writePointerAddr, u32 availableBytesAddr, u32 readOffsetAddr)
{
u32 atracID = PARAM(0);
u32 writePointerAddr = PARAM(1);
u32 availableBytesAddr = PARAM(2);
u32 readOffsetAddr = PARAM(3);
ERROR_LOG(HLE, "FAKE sceAtracGetStreamDataInfo(%i, %08x, %08x, %08x)", atracID, writePointerAddr, availableBytesAddr, readOffsetAddr);
Memory::Write_U32(0, readOffsetAddr);
Memory::Write_U32(0, availableBytesAddr);
Memory::Write_U32(0, writePointerAddr);
RETURN(0);
return 0;
}
void sceAtracReleaseAtracID()
@ -218,22 +200,22 @@ void sceAtracSetLoopNum()
const HLEFunction sceAtrac3plus[] =
{
{0x7db31251,sceAtracAddStreamData,"sceAtracAddStreamData"},
{0x6a8c3cd5,sceAtracDecodeData,"sceAtracDecodeData"},
{0x7db31251,WrapI_IU<sceAtracAddStreamData>,"sceAtracAddStreamData"},
{0x6a8c3cd5,WrapI_IUUUU<sceAtracDecodeData>,"sceAtracDecodeData"},
{0xd5c28cc0,sceAtracEndEntry,"sceAtracEndEntry"},
{0x780f88d1,sceAtracGetAtracID,"sceAtracGetAtracID"},
{0xca3ca3d2,sceAtracGetBufferInfoForReseting,"sceAtracGetBufferInfoForReseting"},
{0xa554a158,sceAtracGetBitrate,"sceAtracGetBitrate"},
{0xa554a158,WrapI_IU<sceAtracGetBitrate>,"sceAtracGetBitrate"},
{0x31668baa,sceAtracGetChannel,"sceAtracGetChannel"},
{0xfaa4f89b,sceAtracGetLoopStatus,"sceAtracGetLoopStatus"},
{0xe88f759b,sceAtracGetInternalErrorInfo,"sceAtracGetInternalErrorInfo"},
{0xd6a5f2f7,sceAtracGetMaxSample,"sceAtracGetMaxSample"},
{0xe23e3a35,sceAtracGetNextDecodePosition,"sceAtracGetNextDecodePosition"},
{0x36faabfb,sceAtracGetNextSample,"sceAtracGetNextSample"},
{0x9ae849a7,sceAtracGetRemainFrame,"sceAtracGetRemainFrame"},
{0x83e85ea0,sceAtracGetSecondBufferInfo,"sceAtracGetSecondBufferInfo"},
{0xa2bba8be,sceAtracGetSoundSample,"sceAtracGetSoundSample"},
{0x5d268707,sceAtracGetStreamDataInfo,"sceAtracGetStreamDataInfo"},
{0xe23e3a35,WrapI_IU<sceAtracGetNextDecodePosition>,"sceAtracGetNextDecodePosition"},
{0x36faabfb,WrapI_IU<sceAtracGetNextSample>,"sceAtracGetNextSample"},
{0x9ae849a7,WrapI_IU<sceAtracGetRemainFrame>,"sceAtracGetRemainFrame"},
{0x83e85ea0,WrapI_IUU<sceAtracGetSecondBufferInfo>,"sceAtracGetSecondBufferInfo"},
{0xa2bba8be,WrapI_IUUU<sceAtracGetSoundSample>,"sceAtracGetSoundSample"},
{0x5d268707,WrapI_IUUU<sceAtracGetStreamDataInfo>,"sceAtracGetStreamDataInfo"},
{0x61eb33f5,sceAtracReleaseAtracID,"sceAtracReleaseAtracID"},
{0x644e5607,sceAtracResetPlayPosition,"sceAtracResetPlayPosition"},
{0x3f6e26b5,sceAtracSetHalfwayBuffer,"sceAtracSetHalfwayBuffer"},

View File

@ -212,7 +212,7 @@ u32 sceAudioChReserve(u32 channel, u32 sampleCount, u32 format) //.Allocate soun
{
WARN_LOG(HLE, "WARNING: Reserving already reserved channel. Error?");
}
DEBUG_LOG(HLE, "%i = sceAudioChReserve(%i, %i, %i)", channel, PARAM(0), sampleCount, format);
DEBUG_LOG(HLE, "%i = sceAudioChReserve(%i, %i, %i)", channel, sampleCount, format);
chans[channel].sampleCount = sampleCount;
chans[channel].reserved = true;
@ -300,46 +300,42 @@ u32 sceAudioChangeChannelVolume(u32 chan, u32 lvolume, u32 rvolume)
}
}
void sceAudioInit()
u32 sceAudioInit()
{
DEBUG_LOG(HLE,"sceAudioInit()");
DEBUG_LOG(HLE,"sceAudioInit()");
// Don't need to do anything
RETURN(0);
return 0;
}
void sceAudioEnd()
u32 sceAudioEnd()
{
DEBUG_LOG(HLE,"sceAudioEnd()");
// Don't need to do anything
RETURN(0);
return 0;
}
void sceAudioOutput2Reserve()
u32 sceAudioOutput2Reserve(u32 sampleCount)
{
int sampleCount = PARAM(0);
ERROR_LOG(HLE,"sceAudioOutput2Reserve(%i)", sampleCount);
ERROR_LOG(HLE,"sceAudioOutput2Reserve(%i)", sampleCount);
chans[0].sampleCount = sampleCount;
chans[0].reserved = true;
RETURN(0);
return 0;
}
void sceAudioOutput2OutputBlocking()
u32 sceAudioOutput2OutputBlocking(u32 vol, u32 dataPtr)
{
int vol = PARAM(0);
u32 dataPtr = PARAM(1);
WARN_LOG(HLE,"FAKE sceAudioOutput2OutputBlocking(%i, %08x)", vol, dataPtr);
WARN_LOG(HLE,"FAKE sceAudioOutput2OutputBlocking(%i, %08x)", vol, dataPtr);
chans[0].leftVolume = vol;
chans[0].rightVolume = vol;
chans[0].sampleAddress = dataPtr;
RETURN(0);
u32 retval = __AudioEnqueue(chans[0], 0, true);
return 0;
u32 retval = __AudioEnqueue(chans[0], 0, true);
if (retval < 0)
RETURN(retval);
return retval;
}
u32 sceAudioOutput2ChangeLength(u32 sampleCount)
{
WARN_LOG(HLE,"sceAudioOutput2ChangeLength(%i)", sampleCount);
WARN_LOG(HLE,"sceAudioOutput2ChangeLength(%i)", sampleCount);
chans[0].sampleCount = sampleCount;
return 0;
}
@ -350,11 +346,11 @@ u32 sceAudioOutput2GetRestSample()
return chans[0].sampleQueue.size() * 2;
}
void sceAudioOutput2Release()
u32 sceAudioOutput2Release()
{
WARN_LOG(HLE,"sceAudioOutput2Release()");
WARN_LOG(HLE,"sceAudioOutput2Release()");
chans[0].reserved = false;
RETURN(0);
return 0;
}
u32 sceAudioSetFrequency(u32 freq) {
@ -372,14 +368,14 @@ const HLEFunction sceAudio[] =
{
// Newer simplified single channel audio output. Presumably for games that use Atrac3
// directly from Sas instead of playing it on a separate audio channel.
{0x01562ba3, sceAudioOutput2Reserve, "sceAudioOutput2Reserve"},
{0x2d53f36e, sceAudioOutput2OutputBlocking, "sceAudioOutput2OutputBlocking"},
{0x01562ba3, WrapU_U<sceAudioOutput2Reserve>, "sceAudioOutput2Reserve"},
{0x2d53f36e, WrapU_UU<sceAudioOutput2OutputBlocking>, "sceAudioOutput2OutputBlocking"},
{0x63f2889c, WrapU_U<sceAudioOutput2ChangeLength>, "sceAudioOutput2ChangeLength"},
{0x647cef33, WrapU_V<sceAudioOutput2GetRestSample>, "sceAudioOutput2GetRestSample"},
{0x43196845, sceAudioOutput2Release, "sceAudioOutput2Release"},
{0x43196845, WrapU_V<sceAudioOutput2Release>, "sceAudioOutput2Release"},
{0x80F1F7E0, sceAudioInit, "sceAudioInit"},
{0x210567F7, sceAudioEnd, "sceAudioEnd"},
{0x80F1F7E0, WrapU_V<sceAudioInit>, "sceAudioInit"},
{0x210567F7, WrapU_V<sceAudioEnd>, "sceAudioEnd"},
{0xA2BEAA6C, WrapU_U<sceAudioSetFrequency>, "sceAudioSetFrequency"},
{0x927AC32B, 0, "sceAudioSetVolumeOffset"},

View File

@ -157,7 +157,7 @@ u32 sceCtrlReadBufferPositive(u32 ctrlDataPtr, u32 nBufs)
//if (ctrlInited)
//{
SampleControls();
memcpy(Memory::GetPointer(ctrlDataPtr), &ctrl, sizeof(_ctrl_data));
Memory::WriteStruct(ctrlDataPtr, &ctrl);
//}
return 1;
}

View File

@ -22,7 +22,7 @@ u32 sceDmacMemcpy(u32 dst, u32 src, u32 size)
{
DEBUG_LOG(HLE, "sceDmacMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
// TODO: check the addresses.
memcpy(Memory::GetPointer(dst), Memory::GetPointer(src), size);
Memory::Memcpy(dst, Memory::GetPointer(src), size);
return 0;
}

View File

@ -250,9 +250,11 @@ void sceIoGetstat()
const char *filename = Memory::GetCharPointer(PARAM(0));
u32 addr = PARAM(1);
SceIoStat *stat = (SceIoStat*)Memory::GetPointer(addr);
SceIoStat stat;
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
__IoGetStat(stat, info);
__IoGetStat(&stat, info);
Memory::WriteStruct(addr, &stat);
DEBUG_LOG(HLE,"sceIoGetstat(%s, %08x) : sector = %08x",filename,addr,info.startSector);
RETURN(0);
@ -698,8 +700,11 @@ void sceIoRename() //(const char *oldname, const char *newname);
{
const char *from = Memory::GetCharPointer(PARAM(0));
const char *to = Memory::GetCharPointer(PARAM(1));
ERROR_LOG(HLE,"UNIMPL sceIoRename(%s, %s)", from, to);
RETURN(0);
if (pspFileSystem.RenameFile(from, to))
RETURN(0);
else
RETURN(-1);
DEBUG_LOG(HLE,"sceIoRename(%s, %s)", from, to);
}
void sceIoChdir()
@ -793,9 +798,8 @@ void sceIoGetAsyncStat()
FileNode *f = kernelObjects.Get<FileNode>(id, error);
if (f)
{
u64 *resPtr = (u64*)Memory::GetPointer(PARAM(2));
*resPtr = f->asyncResult;
DEBUG_LOG(HLE,"%i = sceIoGetAsyncStat(%i, %i, %08x) (HACK)", (u32)*resPtr, id, PARAM(1), PARAM(2));
Memory::Write_U64(f->asyncResult, PARAM(2));
DEBUG_LOG(HLE,"%i = sceIoGetAsyncStat(%i, %i, %08x) (HACK)", (u32)f->asyncResult, id, PARAM(1), PARAM(2));
RETURN(0); //completed
}
else
@ -813,14 +817,14 @@ void sceIoWaitAsync()
FileNode *f = kernelObjects.Get<FileNode>(id, error);
if (f)
{
u64 *resPtr = (u64*)Memory::GetPointer(PARAM(1));
*resPtr = f->asyncResult;
u64 res = f->asyncResult;
if (defAction)
{
*resPtr = defAction(id, defParam);
res = defAction(id, defParam);
defAction = 0;
}
DEBUG_LOG(HLE,"%i = sceIoWaitAsync(%i, %08x) (HACK)", (u32)*resPtr, id, PARAM(1));
Memory::Write_U64(res, PARAM(1));
DEBUG_LOG(HLE,"%i = sceIoWaitAsync(%i, %08x) (HACK)", (u32)res, id, PARAM(1));
RETURN(0); //completed
}
else
@ -839,14 +843,14 @@ void sceIoWaitAsyncCB()
FileNode *f = kernelObjects.Get<FileNode>(id, error);
if (f)
{
u64 *resPtr = (u64*)Memory::GetPointer(PARAM(1));
*resPtr = f->asyncResult;
u64 res = f->asyncResult;
if (defAction)
{
*resPtr = defAction(id, defParam);
res = defAction(id, defParam);
defAction = 0;
}
DEBUG_LOG(HLE,"%i = sceIoWaitAsyncCB(%i, %08x) (HACK)", (u32)*resPtr, id, PARAM(1));
Memory::Write_U64(res, PARAM(1));
DEBUG_LOG(HLE,"%i = sceIoWaitAsyncCB(%i, %08x) (HACK)", (u32)res, id, PARAM(1));
RETURN(0); //completed
}
else
@ -862,14 +866,14 @@ void sceIoPollAsync()
FileNode *f = kernelObjects.Get<FileNode>(id, error);
if (f)
{
u64 *resPtr = (u64*)Memory::GetPointer(PARAM(1));
*resPtr = f->asyncResult;
u64 res = f->asyncResult;
if (defAction)
{
*resPtr = defAction(id, defParam);
res = defAction(id, defParam);
defAction = 0;
}
DEBUG_LOG(HLE,"%i = sceIoPollAsync(%i, %08x) (HACK)", (u32)*resPtr, id, PARAM(1));
Memory::Write_U64(res, PARAM(1));
DEBUG_LOG(HLE,"%i = sceIoPollAsync(%i, %08x) (HACK)", (u32)res, id, PARAM(1));
RETURN(0); //completed
}
else

View File

@ -426,7 +426,7 @@ u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
DEBUG_LOG(HLE, "sceKernelMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
if (Memory::IsValidAddress(dst) && Memory::IsValidAddress(src+size)) // a bit of bound checking. Wrong??
{
memcpy(Memory::GetPointer(dst), Memory::GetPointer(src), size);
Memory::Memcpy(dst, Memory::GetPointer(src), size);
}
return 0;
}

View File

@ -246,7 +246,6 @@ int sceKernelCancelReceiveMbx(SceUID id, u32 numWaitingThreadsAddr)
{
u32 error;
Mbx *m = kernelObjects.Get<Mbx>(id, error);
int *numWaitingThreads = (int*)Memory::GetPointer(numWaitingThreadsAddr);
if (!m)
{
@ -262,8 +261,9 @@ int sceKernelCancelReceiveMbx(SceUID id, u32 numWaitingThreadsAddr)
__KernelResumeThreadFromWait(m->waitingThreads[i].first);
}
m->waitingThreads.clear();
if (numWaitingThreads)
*numWaitingThreads = count;
if (numWaitingThreadsAddr)
Memory::Write_U32(count, numWaitingThreadsAddr);
return 0;
}

View File

@ -515,13 +515,12 @@ void sceKernelAllocateVpl()
if (vpl)
{
u32 size = PARAM(1);
u32 *blockPtrPtr = (u32 *)Memory::GetPointer(PARAM(2));
int timeOut = PARAM(2);
int timeOut = PARAM(3);
DEBUG_LOG(HLE,"sceKernelAllocateVpl(vpl=%i, size=%i, ptrout= %08x , timeout=%i)", id, size, PARAM(2), timeOut);
u32 addr = vpl->alloc.Alloc(size);
if (addr != (u32)-1)
{
*blockPtrPtr = addr;
Memory::Write_U32(addr, PARAM(2));
RETURN(0);
}
else
@ -545,13 +544,12 @@ void sceKernelAllocateVplCB()
if (vpl)
{
u32 size = PARAM(1);
u32 *blockPtrPtr = (u32 *)Memory::GetPointer(PARAM(2));
int timeOut = PARAM(2);
int timeOut = PARAM(3);
DEBUG_LOG(HLE,"sceKernelAllocateVplCB(vpl=%i, size=%i, ptrout= %08x , timeout=%i)", id, size, PARAM(2), timeOut);
u32 addr = vpl->alloc.Alloc(size);
if (addr != (u32)-1)
{
*blockPtrPtr = addr;
Memory::Write_U32(addr, PARAM(2));
RETURN(0);
}
else
@ -576,13 +574,12 @@ void sceKernelTryAllocateVpl()
if (vpl)
{
u32 size = PARAM(1);
u32 *blockPtrPtr = (u32 *)Memory::GetPointer(PARAM(2));
int timeOut = PARAM(2);
int timeOut = PARAM(3);
DEBUG_LOG(HLE,"sceKernelAllocateVplCB(vpl=%i, size=%i, ptrout= %08x , timeout=%i)", id, size, PARAM(2), timeOut);
u32 addr = vpl->alloc.Alloc(size);
if (addr != (u32)-1)
{
*blockPtrPtr = addr;
Memory::Write_U32(addr, PARAM(2));
RETURN(0);
}
else
@ -634,9 +631,8 @@ void sceKernelReferVplStatus()
if (v)
{
DEBUG_LOG(HLE,"sceKernelReferVplStatus(%i, %08x)", id, PARAM(1));
SceKernelVplInfo *info = (SceKernelVplInfo*)Memory::GetPointer(PARAM(1));
v->nv.freeSize = v->alloc.GetTotalFreeBytes();
*info = v->nv;
Memory::WriteStruct(PARAM(1), &v->nv);
}
else
{

View File

@ -117,8 +117,7 @@ void sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr)
if (numWaitThreadsPtr)
{
u32* numWaitThreads = (u32*)Memory::GetPointer(numWaitThreadsPtr);
*numWaitThreads = s->ns.numWaitThreads;
Memory::Write_U32(s->ns.numWaitThreads, numWaitThreadsPtr);
}
if (newCount < 0)

View File

@ -452,13 +452,12 @@ void sceKernelReferThreadStatus()
if (t)
{
DEBUG_LOG(HLE,"sceKernelReferThreadStatus(%i, %08x)", threadID, PARAM(1));
void *outptr = (void*)Memory::GetPointer(PARAM(1));
u32 wantedSize = *(u32 *)outptr;
u32 wantedSize = Memory::Read_U32(PARAM(1));
u32 sz = sizeof(NativeThread);
if (wantedSize) {
t->nt.nativeSize = sz = std::min(sz, wantedSize);
}
memcpy(outptr, &(t->nt), sz);
Memory::Memcpy(PARAM(1), &(t->nt), sz);
RETURN(0);
}
else

View File

@ -154,13 +154,13 @@ void __RtcTicksToPspTime(ScePspDateTime &t, u64 ticks)
t.microsecond = ticks % 1000000;
}
u64 JumpYMD(u64 Y, u64 M, u64 D) {
return 367*Y - 7*(Y+(M+9)/12)/4 + 275*M/9 + D;
u64 JumpYMD(u64 year, u64 month, u64 day) {
return 367*year - 7*(year+(month+9)/12)/4 + 275*month/9 + day;
}
u64 JumpSeconds(u64 Y, u64 M, u64 D, u64 H, u64 m, u64 S) {
u64 JumpSeconds(u64 year, u64 month, u64 day, u64 hour, u64 minute, u64 second) {
static const u64 secs_per_day = 24 * 60 * 60;
return JumpYMD(Y, M, D) * secs_per_day + H * 3600 + m * 60 + S;
return JumpYMD(year, month, day) * secs_per_day + hour * 3600 + minute * 60 + second;
}
u64 __RtcPspTimeToTicks(ScePspDateTime &t)
@ -332,52 +332,160 @@ u32 sceRtcGetDaysInMonth(u32 year, u32 month)
return numberOfDays;
}
// these need tests and code writing:
u32 sceRtcIsLeapYear(u32 year)
{
ERROR_LOG(HLE, "UNIMPL sceRtcIsLeapYear(%d)", year);
return 0;
ERROR_LOG(HLE, "sceRtcIsLeapYear(%d)", year);
return (year % 4 == 0) && !(year % 100 == 0)|| (year % 400 == 0);
}
int sceRtcConvertLocalTimeToUTC(u32 tickLocalPtr,u32 tickUTCPtr)
{
ERROR_LOG(HLE, "UNIMPL sceRtcConvertLocalTimeToUTC(%d, %d)", tickLocalPtr, tickUTCPtr);
DEBUG_LOG(HLE, "sceRtcConvertLocalTimeToUTC(%d, %d)", tickLocalPtr, tickUTCPtr);
if (Memory::IsValidAddress(tickLocalPtr) && Memory::IsValidAddress(tickUTCPtr))
{
u64 srcTick = Memory::Read_U64(tickLocalPtr);
// TODO:convert UTC as ticks to localtime as ticks.. fake it by preteding timezone is UTC for now
Memory::Write_U64(srcTick, tickUTCPtr);
}
else
{
return 1;
}
return 0;
}
int sceRtcConvertUtcToLocalTime(u32 tickUTCPtr,u32 tickLocalPtr)
{
ERROR_LOG(HLE, "UNIMPL sceRtcConvertLocalTimeToUTC(%d, %d)", tickLocalPtr, tickUTCPtr);
ERROR_LOG(HLE, "sceRtcConvertLocalTimeToUTC(%d, %d)", tickLocalPtr, tickUTCPtr);
if (Memory::IsValidAddress(tickLocalPtr) && Memory::IsValidAddress(tickUTCPtr))
{
u64 srcTick = Memory::Read_U64(tickUTCPtr);
// TODO:convert localtime as ticks to UTC as ticks.. fake it by preteding timezone is UTC for now
Memory::Write_U64(srcTick, tickLocalPtr);
}
else
{
return 1;
}
return 0;
}
int sceRtcCheckValid(u32 datePtr)
{
ERROR_LOG(HLE, "UNIMPL sceRtcCheckValid(%d)", datePtr);
return 0;
DEBUG_LOG(HLE, "sceRtcCheckValid(%d)", datePtr);
int ret = 0;
if (Memory::IsValidAddress(datePtr))
{
ScePspDateTime pt;
Memory::ReadStruct(datePtr, &pt);
if (pt.year >= 0) // is there a maximum?
{
ret = PSP_TIME_INVALID_YEAR;
}
else if (pt.month < 1 || pt.month > 12)
{
ret = PSP_TIME_INVALID_MONTH;
}
else if (pt.day < 1 || pt.day > 31)
{
ret = PSP_TIME_INVALID_DAY;
}
else if (pt.day < 0 || pt.day > 31) // TODO: Needs to check actual days in month, including leaps
{
ret = PSP_TIME_INVALID_DAY;
}
else if (pt.hour < 0 || pt.hour > 23)
{
ret = PSP_TIME_INVALID_HOUR;
}
else if (pt.minute < 0 || pt.minute > 59)
{
ret = PSP_TIME_INVALID_MINUTES;
}
else if (pt.second < 0 || pt.second > 59)
{
ret = PSP_TIME_INVALID_SECONDS;
}
else if (pt.microsecond < 0 || pt.microsecond >= 1000000)
{
ret = PSP_TIME_INVALID_MICROSECONDS;
}
}
else
{
ret=-1;
}
return ret;
}
int sceRtcSetTime_t(u32 datePtr, u64 time)
{
ERROR_LOG(HLE, "UNIMPL sceRtcSetTime_t(%d,%d)", datePtr, time);
ERROR_LOG(HLE, "HACK sceRtcSetTime_t(%d,%d)", datePtr, time);
if (Memory::IsValidAddress(datePtr))
{
ScePspDateTime pt;
__RtcTicksToPspTime(pt, time);
Memory::WriteStruct(datePtr, &pt);
}
else
{
return 1;
}
return 0;
}
int sceRtcGetTime_t(u32 datePtr, u64 time)
int sceRtcGetTime_t(u32 datePtr, u32 timePtr)
{
ERROR_LOG(HLE, "UNIMPL sceRtcGetTime_t(%d,%d)", datePtr, time);
ERROR_LOG(HLE, "HACK sceRtcGetTime_t(%d,%d)", datePtr, time);
if (Memory::IsValidAddress(datePtr)&&Memory::IsValidAddress(timePtr))
{
ScePspDateTime pt;
Memory::ReadStruct(datePtr, &pt);
u64 result = __RtcPspTimeToTicks(pt);
Memory::Write_U64(result, timePtr);
}
else
{
return 1;
}
return 0;
}
int sceRtcSetDosTime(u32 datePtr, u32 dosTime)
{
ERROR_LOG(HLE, "UNIMPL sceRtcSetDosTime(%d,%d)", datePtr, dosTime);
ERROR_LOG(HLE, "HACK sceRtcSetDosTime(%d,%d)", datePtr, dosTime);
if (Memory::IsValidAddress(datePtr))
{
ScePspDateTime pt;
__RtcTicksToPspTime(pt, dosTime);
Memory::WriteStruct(datePtr, &pt);
}
else
{
return 1;
}
return 0;
}
int sceRtcGetDosTime(u32 datePtr, u32 dosTime)
{
ERROR_LOG(HLE, "UNIMPL sceRtcGetDosTime(%d,%d)", datePtr, dosTime);
ERROR_LOG(HLE, "HACK sceRtcGetDosTime(%d,%d)", datePtr, dosTime);
if (Memory::IsValidAddress(datePtr)&&Memory::IsValidAddress(dosTime))
{
ScePspDateTime pt;
Memory::ReadStruct(datePtr, &pt);
u64 result = __RtcPspTimeToTicks(pt);
Memory::Write_U64(result, dosTime);
}
else
{
return 1;
}
return 0;
}
int sceRtcSetWin32FileTime(u32 datePtr, u32 win32TimePtr)
@ -394,7 +502,22 @@ int sceRtcGetWin32FileTime(u32 datePtr, u32 win32TimePtr)
int sceRtcCompareTick(u32 tick1Ptr, u32 tick2Ptr)
{
ERROR_LOG(HLE, "UNIMPL sceRtcCompareTick(%d,%d)", tick1Ptr, tick2Ptr);
ERROR_LOG(HLE, "HACK sceRtcCompareTick(%d,%d)", tick1Ptr, tick2Ptr);
if (Memory::IsValidAddress(tick1Ptr)&&Memory::IsValidAddress(tick1Ptr))
{
u64 tick1 = Memory::Read_U64(tick1Ptr);
u64 tick2 = Memory::Read_U64(tick2Ptr);
if (tick1 > tick2)
{
return 1;
}
if (tick1 < tick2)
{
return -1;
}
}
return 0;
}
@ -408,7 +531,7 @@ int sceRtcTickAddTicks(u32 destTickPtr, u32 srcTickPtr, u64 numTicks)
Memory::Write_U64(srcTick, destTickPtr);
}
ERROR_LOG(HLE, "sceRtcTickAddTicks(%d,%d,%d)", destTickPtr, srcTickPtr, numTicks);
DEBUG_LOG(HLE, "sceRtcTickAddTicks(%d,%d,%d)", destTickPtr, srcTickPtr, numTicks);
return 0;
}
@ -448,7 +571,7 @@ int sceRtcTickAddMinutes(u32 destTickPtr, u32 srcTickPtr, u64 numMins)
srcTick += numMins*60000000UL;
Memory::Write_U64(srcTick, destTickPtr);
}
ERROR_LOG(HLE, "UNIMPL sceRtcTickAddMinutes(%d,%d,%d)", destTickPtr, srcTickPtr, numMins);
ERROR_LOG(HLE, "HACK sceRtcTickAddMinutes(%d,%d,%d)", destTickPtr, srcTickPtr, numMins);
return 0;
}
@ -461,7 +584,7 @@ int sceRtcTickAddHours(u32 destTickPtr, u32 srcTickPtr, int numHours)
srcTick += numHours*3600000000UL;
Memory::Write_U64(srcTick, destTickPtr);
}
ERROR_LOG(HLE, "UNIMPL sceRtcTickAddMinutes(%d,%d,%d)", destTickPtr, srcTickPtr, numHours);
ERROR_LOG(HLE, "HACK sceRtcTickAddMinutes(%d,%d,%d)", destTickPtr, srcTickPtr, numHours);
return 0;
}
@ -474,7 +597,7 @@ int sceRtcTickAddDays(u32 destTickPtr, u32 srcTickPtr, int numDays)
srcTick += numDays*86400000000UL;
Memory::Write_U64(srcTick, destTickPtr);
}
ERROR_LOG(HLE, "UNIMPL sceRtcTickAddDays(%d,%d,%d)", destTickPtr, srcTickPtr, numDays);
ERROR_LOG(HLE, "HACK sceRtcTickAddDays(%d,%d,%d)", destTickPtr, srcTickPtr, numDays);
return 0;
}
@ -487,7 +610,7 @@ int sceRtcTickAddWeeks(u32 destTickPtr, u32 srcTickPtr, int numWeeks)
srcTick += numWeeks*604800000000UL;
Memory::Write_U64(srcTick, destTickPtr);
}
ERROR_LOG(HLE, "UNIMPL sceRtcTickAddWeeks(%d,%d,%d)", destTickPtr, srcTickPtr, numWeeks);
ERROR_LOG(HLE, "HACK sceRtcTickAddWeeks(%d,%d,%d)", destTickPtr, srcTickPtr, numWeeks);
return 0;
}
@ -510,10 +633,11 @@ int sceRtcTickAddMonths(u32 destTickPtr, u32 srcTickPtr, int numMonths)
Memory::Write_U64(srcTick, destTickPtr);
}
ERROR_LOG(HLE, "UNIMPL sceRtcTickAddMonths(%d,%d,%d)", destTickPtr, srcTickPtr, numMonths);
ERROR_LOG(HLE, "HACK sceRtcTickAddMonths(%d,%d,%d)", destTickPtr, srcTickPtr, numMonths);
return 0;
}
//TODO: off by 6 days every 2000 years.
int sceRtcTickAddYears(u32 destTickPtr, u32 srcTickPtr, int numYears)
{
if (Memory::IsValidAddress(destTickPtr) && Memory::IsValidAddress(srcTickPtr))
@ -546,7 +670,7 @@ int sceRtcTickAddYears(u32 destTickPtr, u32 srcTickPtr, int numYears)
Memory::Write_U64(srcTick, destTickPtr);
}
DEBUG_LOG(HLE, "sceRtcTickAddYears(%d,%d,%d)", destTickPtr, srcTickPtr, numYears);
DEBUG_LOG(HLE, "HACK sceRtcTickAddYears(%d,%d,%d)", destTickPtr, srcTickPtr, numYears);
return 0;
}
@ -571,7 +695,7 @@ const HLEFunction sceRtc[] =
{0x57726bc1, WrapU_UUU<sceRtcGetDayOfWeek>, "sceRtcGetDayOfWeek"},
{0x4B1B5E82, WrapI_U<sceRtcCheckValid>, "sceRtcCheckValid"},
{0x3a807cc8, WrapI_UU64<sceRtcSetTime_t>, "sceRtcSetTime_t"},
{0x27c4594c, WrapI_UU64<sceRtcGetTime_t>, "sceRtcGetTime_t"},
{0x27c4594c, WrapI_UU<sceRtcGetTime_t>, "sceRtcGetTime_t"},
{0xF006F264, WrapI_UU<sceRtcSetDosTime>, "sceRtcSetDosTime"},
{0x36075567, WrapI_UU<sceRtcGetDosTime>, "sceRtcGetDosTime"},
{0x7ACE4C04, WrapI_UU<sceRtcSetWin32FileTime>, "sceRtcSetWin32FileTime"},

View File

@ -211,7 +211,7 @@ void _sceSasCore()
{
u32 outAddr = PARAM(1);
DEBUG_LOG(HLE,"0=sceSasCore(, %08x) (grain: %i samples)", outAddr, sas.grainSize);
memset(Memory::GetPointer(outAddr), 0, sas.grainSize * 2 * 2);
Memory::Memset(outAddr, 0, sas.grainSize * 2 * 2);
sas.mix(outAddr);
RETURN(0);
}

View File

@ -559,36 +559,38 @@ u32 sceUtilityGetSystemParamString(u32 id, u32 destaddr, u32 unknownparam)
u32 sceUtilityGetSystemParamInt(u32 id, u32 destaddr)
{
DEBUG_LOG(HLE,"sceUtilityGetSystemParamInt(%i, %08x)", id,destaddr);
u32 *outPtr = (u32*)Memory::GetPointer(destaddr);
u32 param = 0;
switch (id) {
case PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL:
*outPtr = PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC;
param = PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC;
break;
case PSP_SYSTEMPARAM_ID_INT_WLAN_POWERSAVE:
*outPtr = PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF;
param = PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF;
break;
case PSP_SYSTEMPARAM_ID_INT_DATE_FORMAT:
*outPtr = PSP_SYSTEMPARAM_DATE_FORMAT_DDMMYYYY;
param = PSP_SYSTEMPARAM_DATE_FORMAT_DDMMYYYY;
break;
case PSP_SYSTEMPARAM_ID_INT_TIME_FORMAT:
*outPtr = PSP_SYSTEMPARAM_TIME_FORMAT_24HR;
param = PSP_SYSTEMPARAM_TIME_FORMAT_24HR;
break;
case PSP_SYSTEMPARAM_ID_INT_TIMEZONE:
*outPtr = 60;
param = 60;
break;
case PSP_SYSTEMPARAM_ID_INT_DAYLIGHTSAVINGS:
*outPtr = PSP_SYSTEMPARAM_TIME_FORMAT_24HR;
param = PSP_SYSTEMPARAM_TIME_FORMAT_24HR;
break;
case PSP_SYSTEMPARAM_ID_INT_LANGUAGE:
*outPtr = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
param = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
break;
case PSP_SYSTEMPARAM_ID_INT_UNKNOWN:
*outPtr = 1;
param = 1;
break;
default:
return PSP_SYSTEMPARAM_RETVAL_FAIL;
}
Memory::Write_U32(param, destaddr);
return 0;
}